[Bug]: Ctrl+Shift+V in the terminal opens Firefox's Paste prompt and steals focus#27439
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Open T3 Code in Firefox on Linux.
- Copy some text from another application.
- Focus the integrated terminal and press Ctrl+Shift+V.
Expected behavior
The text is pasted once and the terminal keeps focus.
Actual behavior
The text is pasted, and Firefox also opens a one-item native Paste menu at the mouse pointer. The menu takes focus away from the terminal, so you have to dismiss it and click back into the terminal before you can keep typing.
Terminal before pressing Ctrl+Shift+V
Text pasted, with Firefox's Paste prompt open at the pointer
Cause
On the paste shortcut, GhosttyTerminalSurface.onKeyDown (apps/web/src/terminal/ghostty/surface.ts) calls navigator.clipboard.readText() right away. It also leaves the browser's own paste in place. Firefox's native paste event delivers the text first, and onPaste advances pasteShortcutToken, so the read's result would be thrown away anyway. But in Firefox (and Safari), reading clipboard content that another site or app put there opens that Paste confirmation menu. Chromium asks for a site permission instead, which is why this didn't show up during #13346 / #19366.
The read only needs to run when no native paste event arrives. Delaying it by one task, and skipping it once onPaste has claimed the token, keeps that fallback without triggering the prompt.
Impact
Minor bug or occasional failure
Version or commit
main @ 08a463e299
Environment
Firefox 158.0.1, Arch Linux (niri, Wayland), web client
Logs or stack traces
No response