[PR #15906] [CLOSED] debounce on chat input. #127637

Closed
opened 2026-05-21 09:38:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/15906
Author: @jvz-devx
Created: 7/21/2025
Status: Closed

Base: devHead: main


📝 Commits (3)

  • 5fbfe2b Merge pull request #15879 from open-webui/dev
  • 8da07f6 Debounce and defer draft autosave in Chat.svelte
  • 93bfc6a Refactor draft autosave logic in Chat.svelte to use a constant for maximum input length

📊 Changes

1 file changed (+15 additions, -4 deletions)

View changed files

📝 src/lib/components/chat/Chat.svelte (+15 -4)

📄 Description

Pull Request Checklis# Pull Request Checklist

Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
  • [] Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?

got instant ERESOLVE could not resolve errors when trying to install the packages of this project, but i only added 1 package:
import { debounce } from 'lodash-es'

  • Testing: Have you written and run sufficient tests to validate the changes?

  • [] Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?

  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:

    • perf: Performance improvement

Changelog Entry

Description

  • Improved paste and typing performance in the main chat view by debouncing and deferring the draft autosave to sessionStorage.
  • Prevents main-thread blocking when saving large draft text on every keystroke.

Added

  • New dependency: lodash-es for the debounce helper.
  • saveDraft helper in Chat.svelte that debounces input changes and uses requestIdleCallback for non-blocking writes.

Changed

  • Chat.svelte

    • Replaced direct, synchronous sessionStorage.setItem(JSON.stringify(input)) on every MessageInput change with saveDraft(input).
    • Debounce delay set to 300 ms.
    • Skip saving drafts longer than 5 000 characters.
  • Reduced synchronous workload on input events to keep the UI responsive.

Deprecated

  • None.

Removed

  • Direct calls to sessionStorage.setItem(...) in the onChange handler of <MessageInput>.

Fixed

  • Eliminates massive lag when pasting or typing very large text into the chat input.

Security

  • None.

Breaking Changes

  • None.

Additional Information

  • This change does not alter any user-facing functionality; it only optimizes internal autosave behavior.
  • Related issue: N/A

Screenshots or Videos

  • N/A

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/15906 **Author:** [@jvz-devx](https://github.com/jvz-devx) **Created:** 7/21/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `main` --- ### 📝 Commits (3) - [`5fbfe2b`](https://github.com/open-webui/open-webui/commit/5fbfe2bdcadf5f157926f6551891e4dc0802b9f3) Merge pull request #15879 from open-webui/dev - [`8da07f6`](https://github.com/open-webui/open-webui/commit/8da07f673e3b47ea50503f8790de30568be8b6cb) Debounce and defer draft autosave in Chat.svelte - [`93bfc6a`](https://github.com/open-webui/open-webui/commit/93bfc6ab11b29bbbd0c64a86237592df2701ec76) Refactor draft autosave logic in Chat.svelte to use a constant for maximum input length ### 📊 Changes **1 file changed** (+15 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/Chat.svelte` (+15 -4) </details> ### 📄 Description # Pull Request Checklis# Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [[Discussions](https://github.com/open-webui/open-webui/discussions)](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** * [x] **Target branch:** Please verify that the pull request targets the `dev` branch. * [x] **Description:** Provide a concise description of the changes made in this pull request. * [x] **Changelog:** Ensure a changelog entry following the format of [[Keep a Changelog](https://keepachangelog.com/)](https://keepachangelog.com/) is added at the bottom of the PR description. * [ ] **Documentation:** Have you updated relevant documentation [[Open WebUI Docs](https://github.com/open-webui/docs)](https://github.com/open-webui/docs), or other documentation sources? * [] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? got instant ERESOLVE could not resolve errors when trying to install the packages of this project, but i only added 1 package: import { debounce } from 'lodash-es' * [ ] **Testing:** Have you written and run sufficient tests to validate the changes? * [] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? * [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: * **perf**: Performance improvement # Changelog Entry ### Description * Improved paste and typing performance in the main chat view by debouncing and deferring the draft autosave to `sessionStorage`. * Prevents main-thread blocking when saving large draft text on every keystroke. ### Added * New dependency: `lodash-es` for the `debounce` helper. * `saveDraft` helper in **Chat.svelte** that debounces input changes and uses `requestIdleCallback` for non-blocking writes. ### Changed * **Chat.svelte** * Replaced direct, synchronous `sessionStorage.setItem(JSON.stringify(input))` on every `MessageInput` change with `saveDraft(input)`. * Debounce delay set to 300 ms. * Skip saving drafts longer than 5 000 characters. * Reduced synchronous workload on input events to keep the UI responsive. ### Deprecated * None. ### Removed * Direct calls to `sessionStorage.setItem(...)` in the `onChange` handler of `<MessageInput>`. ### Fixed * Eliminates massive lag when pasting or typing very large text into the chat input. ### Security * None. ### Breaking Changes * None. --- ### Additional Information * This change does not alter any user-facing functionality; it only optimizes internal autosave behavior. * Related issue: N/A ### Screenshots or Videos * N/A ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-21 09:38:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#127637