Conversation
The paste shortcut races navigator.clipboard.readText() against the browser's native paste event. The token only covered the native event landing first; when the read resolved first, the following native paste was sent again. Record the text the read delivered and drop the matching native paste from that gesture. The gesture ends on that paste, the shortcut key's own keyup, a new paste shortcut, or blur. Unrelated keys do not end it, so a late native paste is still dropped, and a later menu paste of the same text still lands.
Owner
Author
|
Opened upstream. |
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.
Fixes pingdotgg#13346
What Changed
The terminal paste shortcut races
navigator.clipboard.readText()against the browser's nativepasteevent.pasteShortcutTokenonly covered the native event landing first. When the clipboard read resolved first, the native paste that followed was also written to the PTY, so Chromium (Brave) inserted the text twice.A read that wins records the text it delivered on the current paste gesture, and
onPastedrops the one matching native paste. The gesture ends on that paste, the shortcut key's own keyup, a new paste shortcut, or blur. Other keys do not end it.Why
This is the inverse ordering left open when pingdotgg#8457 was closed. The read exists for browsers whose paste shortcut never fires a paste event, so the native event cannot be cancelled. Recording the delivered text closes the read-first hole without giving up that fallback.
The record cannot live until the next keydown. Edit → Paste of the same string is an
onPastewith no keydown, so it would be swallowed. It also cannot be cleared by unrelated keys: Chromium can deliver the native paste after other keys move, and clearing early lets the duplicate through. The shortcut's own keyup is after the keyboard paste (clipboard spec), so the duplicate is still dropped, and a later paste of the same text still lands. Blur ends the gesture when focus leaves before release.Checklist
Verification
The new cases all passed:
pastes once when the shortcut's clipboard read lands before the native pastestill drops the late native paste when other keys move mid-gesturekeeps a later menu paste once the shortcut that only the read served endstsc --noEmitinapps/webcompleted with no errors.vp fmtreported the two touched files already formatted.Grok 4.7, Cursor cloud agent.