Repository navigation
fix(web): terminal paste no longer opens Firefox's Paste prompt - #27451
tastelessjolt wants to merge 2 commits into
Conversation
Ctrl+Shift+V read the clipboard on keydown even when the browser's own paste event delivered the text. Firefox and Safari answer that read with a native Paste prompt that steals focus from the terminal. Defer the fallback read one task so a native paste claims the shortcut first. Fixes pingdotgg#27439 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The terminal now lets native paste run before attempting a fallback clipboard read, avoiding Firefox's focus-stealing prompt. Existing paste encoding and duplicate protection remain unchanged, keeping the change narrowly scoped. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Deferred clipboard fallback apps/web/src/terminal/ghostty/surface.ts, apps/web/src/terminal/ghostty/surface.test.ts |
The shortcut checks clipboard-read permission before reading and retains its disposal, token, and gesture checks. Tests cover permission-query failure, native and clipboard paste ordering, and a later menu paste. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers: t3dotgg, maria-rcks
Merge Risk: 
Minimal · up to ab164
-
The change stops Firefox's Paste prompt from taking focus on the terminal paste shortcut while native paste keeps working. No concrete merge-blocking risk remains.
Pre-merge checks: 
3 · 
1
-
Failed checks: 1 warning Passed checks: 3 passed-
Full details: Title check
-
Explanation
The title names the main change: terminal paste in Firefox no longer opens the native Paste prompt. It matches the changeset, which delays the fallback clipboard read and skips it when a native paste has already claimed the shortcut token. It follows the conventional commit form the template asks for.
Full details: Out of Scope Changes check
-
Explanation
The changes are limited to the integrated terminal paste handler and its focused tests. The permission check, timing change, and test updates address the Firefox paste prompt and paste deduplication in [
#27439]. No unrelated surface or behavior changes are shown.
Full details: Description check
-
Explanation
The description is complete and follows the required template. It explains the Firefox paste prompt problem, the delayed permission-aware fallback change, the focused scope, detailed automated and manual verification, known unverified cases, screenshots, and agent attribution. It also identifies issue
#27439and explains why this focused bug fix does not require separate approval.
-
Full details: Linked Issues check
-
Explanation
Issue [
#27439] requires the delayed clipboard-read fallback to remain available when no nativepasteevent arrives. The handler returns from the timeout whennavigator.permissions.query({ name: "clipboard-read" })rejects or is unavailable. Therefore, browsers without this permission query cannot use the fallback. The test covers the rejected-query case only when a native paste arrives first, so it does not verify the required fallback path.Resolution
Keep the one-task delay and token check, but preserve the fallback for browsers that do not provide or reject the permission query. Add a test for the rejected or unsupported permission query with no native paste event, and verify one clipboard read and one paste.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Note Written by Verified in a real dev environmentreproduced on pushed ran one background dev server at a time after after the fix, firefox ctrl+shift+v pasted once without a prompt and subsequent typing executed. five consecutive pastes and shift+insert also retained typing without duplicates. chrome native paste delivered once with zero fallback reads. uploaded video playback and seeking were checked. the new unsupported-permission row failed before the fix and passed afterward. two independent read-only reviews found no blockers in the final head. review note: the unsupported-permission test dispatches native paste after the timer, not before it. the clipboard-first row covers a missing native event and preserves the chromium fallback. restoring a read after an unsupported permission query would reopen the firefox prompt reproduced above, so browsers without that permission intentionally use native paste. the issue's one-task timing assumption did not hold in firefox 159. all 29 ci checks passed on Not verifiednative electron, ios/android, safari, macos/windows, and remote/relay/tunnel connections were not exercised on this linux VM. macos chromium's late-native-paste timing was not exercised; its existing duplicate tests pass. other providers were outside this clipboard-only change. |



Problem
In Firefox, pressing Ctrl+Shift+V in the integrated terminal pastes the text, but Firefox also opens a one-item native Paste menu at the mouse pointer. The menu takes focus from the terminal (#27439).
The terminal's keydown handler called
navigator.clipboard.readText()right away, as a fallback for browsers that fire no native paste. It also left the browser's own paste in place. When the nativepasteevent arrives,onPasteadvancespasteShortcutToken, so the read's result is thrown away anyway. But Firefox (and Safari) answer a page's clipboard read with that confirmation menu. Chromium asks for a site permission instead, which is why the earlier double-paste fix (#19366) didn't hit this.Change
Delay the fallback
readText()by one task, and skip it if native paste has claimed the token. Native paste can also arrive after that timer, so the fallback requires support for theclipboard-readpermission. Firefox and Safari use native paste without opening a clipboard-read prompt. Chromium keeps the fallback when permission allows it. If native paste arrives late, the existing duplicate check from #19366 still handles it.Scope and approval
This fixes #27439 (filed alongside this PR). It's a small, focused bug fix in one handler: no new behavior, settings, or surfaces. Desktop (Electron/Chromium) and mobile don't show this prompt and keep the same paste paths.
Verification
pastes once when %s arrives firstcase to assert thatreadTextis never called when the native paste arrives first. That assertion fails onmain(expected "vi.fn()" to be called +0 times, but got 1 times) and passes with the fix. The clipboard-first case still reads exactly once and pastes once. All 33 cases insurface.test.tspass.vp run check:changed: format, lint, knip, typecheck, tests and React compiler all pass.xclip). On a bare X server Firefox closes the Paste prompt the moment it opens, which rejects the read before it can be seen. So this test profile setsui.popup.disable_autohide, which only stops popups from auto-closing. The page code is unchanged; the two clips differ only in this commit.main): the text pastes, then Firefox's Paste prompt opens at the pointer and takes keyboard focus. The terminal cursor goes hollow, and; echo still here, typed afterwards, never reaches the shell.; echo still herelands in the terminal.Before:
After:
Not verified: Safari, and the timing of macOS Chromium's late native paste. That path runs into the existing duplicate check, which this change doesn't touch.
Reviewed with sol-loop: 1 round with gpt-6.1-sol on high. Sol verdict: approved
Implemented, tested and recorded with Claude Opus 5.5 in Claude Code, through T3 Code.
🤖 Generated with Claude Code
takeover verification at
ab16435f50real firefox 159 still reproduced the prompt on the original timer-only head. the takeover adds a clipboard-read permission capability check, preserving chromium fallback while firefox/safari use native paste. the real app now retains typing after paste; five repeats and shift+insert passed. real codex
gpt-6.1-solturns and chrome native paste passed. blacksmith passed all 34 terminal tests andcheck:changedagainst the pr base. native clients, safari, macos/windows and remote connection modes remain unverified.