Skip to content

fix(web): terminal paste no longer doubles when the clipboard read wins - #29

Merged
r4iju merged 1 commit into
mainfrom
fix/terminal-double-paste
Sep 24, 2026
Merged

r4iju merged 1 commit into
mainfrom
fix/terminal-double-paste

Conversation

@r4iju

@r4iju r4iju commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Pasting into the terminal from a browser (for example over the network) sometimes sends the text twice.

The paste shortcut starts navigator.clipboard.readText() and also keeps the browser's native paste event. The shared token only handled the native event landing first. When the read resolved first, the native paste that followed was sent too. Upstream noted this remaining ordering when closing pingdotgg#8457, and there is no upstream issue for it yet.

The read now records the text it delivered. The next native paste with the same text is dropped, and any keydown clears the record so a later paste gesture is never swallowed.

Verification

  • New case in surface.test.ts resolves the read before dispatching the native paste. It fails on the old code (2 writes) and passes with the fix, and it covers the next gesture still pasting.
  • vp test run src/terminal/ghostty/surface.test.ts: 55 passing. Lint and tsc --noEmit for apps/web are clean.

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 native paste that
followed was sent again. Record the text the read delivered and drop the
matching native paste of the same gesture.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S labels Sep 24, 2026
@r4iju
r4iju merged commit 9929fb7 into main Sep 24, 2026
7 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant