forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 4
fix: coalesce fragmented paste events over SSH #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
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
…anomalyco#5628) Co-authored-by: noamzbr <noamzbr@users.noreply.github.com> Co-authored-by: noam-v <noam@bespo.ai>
…o#7809) Co-authored-by: noam-v <noam@bespo.ai>
…omalyco#6342) Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Some terminals (e.g., MobaXterm) fragment large pastes into multiple bracketed paste sequences, causing premature submit when newlines trigger the submit handler before the full paste is received. This adds paste coalescing with a 150ms debounce to buffer consecutive paste events and process them as a single paste operation. Submit is blocked while paste coalescing is active to prevent partial submissions.
Author
|
Closing as discovered new issue need to verify. |
Author
|
Closing - the paste coalescing fix is already in shuvcode-dev branch. |
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.
Summary
Some terminals (e.g., MobaXterm) fragment large pastes into multiple bracketed paste sequences, causing premature submit when newlines trigger the submit handler before the full paste is received.
This adds paste coalescing with a 150ms debounce to buffer consecutive paste events and process them as a single paste operation.
Changes
pasteBufferto collect paste fragmentsisPastingsignal to block submit during coalescingprocessCoalescedPaste()function for the actual paste processingonCleanupto clear timer on unmountTechnical Details
When a paste event arrives:
pasteBuffer.chunksisPastingsignal is set totrue(blocks submit)isPastingis cleared only if no new paste arrived during processingTesting
Tested over SSH with MobaXterm - multi-line pastes now correctly show
[Pasted ~X lines]instead of fragmenting and submitting prematurely.Greptile Summary
Adds paste coalescing to fix fragmented paste events over SSH connections. Some terminals like MobaXterm split large pastes into multiple bracketed paste sequences, causing newlines to trigger premature submit before the full content arrives.
Key Changes:
pasteBufferto accumulate paste fragments with a 150ms debounce timerisPastingsignal that blocks the submit handler during coalescingprocessCoalescedPaste()function for cleaner separationConfidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Terminal as Terminal (MobaXterm) participant onPaste as onPaste Handler participant Buffer as pasteBuffer participant Timer as Debounce Timer participant Process as processCoalescedPaste participant Input as Textarea Input Terminal->>onPaste: Paste Event 1 (fragment) onPaste->>Buffer: chunks.push(normalizedText) onPaste->>onPaste: setIsPasting(true) onPaste->>Timer: setTimeout(150ms) Terminal->>onPaste: Paste Event 2 (fragment) onPaste->>Timer: clearTimeout (cancel previous) onPaste->>Buffer: chunks.push(normalizedText) onPaste->>Timer: setTimeout(150ms) (reset) Note over Timer: 150ms passes without new paste Timer->>Process: Timer expires Process->>Buffer: coalesced = chunks.join("").trim() Process->>Buffer: Clear chunks and timer alt Empty content Process->>Process: Trigger prompt.paste command else File path detected Process->>Process: Handle as file/image else Large paste (≥3 lines or >150 chars) Process->>Input: pasteText(content, "[Pasted ~N lines]") else Small paste Process->>Input: insertText(pastedContent) end Process->>onPaste: setIsPasting(false) Note over Input: User can now submit