fix(app): prevent large paste stalls - #41579
Open
vanthunder wants to merge 1 commit into
Open
Conversation
The V2 composer routed every paste carrying text/plain straight into
execCommand("insertText"), so its large-paste guard was unreachable and the
browser built one DOM node per line. Every following keystroke then had to
walk that document back into prompt parts. Large pastes now apply to the
prompt model directly, honouring the selection and the caret. Legacy got
this in 7e681b0; V2 never did.
Also bounds the cursor and suggestion scans, coalesces draft writes before
the IPC hop, and stops the desktop main process from reading every stored
draft back at startup.
100 KiB paste: 13.9 s -> 42 ms. 256 KiB and 1 MiB did not complete before.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Found a related PR: #38934: fix(app): convert large paste to file attachment This is closely related as the current PR mentions it explicitly: "This is an alternative approach to #38934, which converts large pastes into temporary file attachments." Both PRs address the same issue (#38932) but use different strategies to handle large multiline pastes in the V2 composer to prevent renderer stalls. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #38932
Type of change
What does this PR do?
Large multiline pastes in the V2 composer were routed through
execCommand("insertText"), causing Chromium to create a DOM node per line and block the renderer.This applies those pastes directly to the prompt model instead, preserving the text as normal editable prompt content. It also bounds related editor scans and reduces unnecessary draft persistence work.
This is an alternative approach to #38934, which converts large pastes into temporary file attachments.
How did you verify your code works?
session-ui: 96 tests passedapp: 722 unit tests and 58 browser tests passedScreenshots / recordings
N/A — this is a performance/behavior fix without a visual UI change.
Checklist