Fix paste into browser routing to terminal text box (text box beta)
Fixes #6380
Problem
With a terminal and a browser pane side by side and text box beta enabled, pasting (Cmd+V) into the focused browser pasted into the terminal's text box instead of the browser.
Only paste was affected — not copy/cut/select-all, and not typing — and only with the text box beta enabled. That asymmetry is the tell.
Root cause
Two complementary issues:
-
Paste was missing from the browser document-editing commands.
BrowserDocumentEditingCommandEquivalentlistedcopy,cut, andselectAllbut notpaste. Those three preflight into the focused web view (shouldRouteBrowserDocumentEditingCommandEquivalentThroughWebContentFirst) before cmux's menu fallback, so the focused browser claims them first. Cmd+V was never routed there, so it fell through to the originalNSWindow.performKeyEquivalent. -
performKeyEquivalentis broadcast to every view in the window, not just the first responder.TextBoxInputTextViewoverrides it and claimed Cmd+C/X/V (and undo/redo) unconditionally. So in the fall-through broadcast, the unfocused terminal text box grabbed Cmd+V before the menu could route it to the browser — pasting into the text box. Copy/cut weren't affected because they were already routed to web content first (issue 1); typing wasn't affected becausekeyDownonly reaches the first responder.
Fix
ShortcutRoutingSupport.swift— addpaste(Cmd+V) toBrowserDocumentEditingCommandEquivalentso the focused web view claims it first, exactly like copy/cut/select-all. Cmd+V only; Cmd+Shift+V (paste-and-match-style) keeps its dedicated path becausematchesrequires an exact modifier match.TextBoxInput.swift— gate the text box's standard edit/undo shortcuts inperformKeyEquivalenton the text view actually owning first responder, so an unfocused text box no longer steals copy/cut/paste/undo from the focused browser (web content or omnibar) or terminal. The focus shortcut path is intentionally left ungated so it can still focus the text box.
Tests
Two-commit red/green:
- Commit 1 (failing):
testBrowserPasteCommandRoutesThroughWebContentFirstandtestTextBoxDeclinesPasteShortcutWhenNotFirstResponder. - Commit 2 (fix + guards): plus
testTextBoxHandlesPasteShortcutWhenFirstResponder(normal paste still works when focused) andtestBrowserPlainTextPasteCommandIsNotADocumentEditingPaste(Cmd+Shift+V keeps its own path).
Localization
No user-facing strings, menus, settings rows, shortcut metadata, alerts, tooltips, or docs changed — Cmd+V is a standard system command (not a cmux-owned KeyboardShortcutSettings shortcut), matching the existing copy/cut/select-all pattern. No localization updates required.
🤖 Generated with Claude Code
Summary by cubic
Fixes Cmd+V being intercepted by the terminal text box when Text Box Beta is enabled. Paste now goes to the focused browser; the text box only handles edit shortcuts when it’s first responder (fixes #6380).
- Bug Fixes
- Added paste (Cmd+V) to
BrowserDocumentEditingCommandEquivalentso the focused web view claims it first; Cmd+Shift+V keeps its dedicated path. - Gated
TextBoxInputTextView.performKeyEquivalentso copy/cut/paste/undo/redo run only when the text box owns first responder; the focus shortcut stays ungated. - Moved regression tests to Swift Testing covering browser preflight, first-responder gating, Cmd+Shift+V behavior, and paste while the text box is focused.
- Added paste (Cmd+V) to
Summary by CodeRabbit
- Bug Fixes
- Improved keyboard shortcut routing so paste now goes to the currently focused web content instead of an unrelated text field.
- Text boxes no longer intercept editing shortcuts unless they are the active input, preventing unfocused fields from handling copy, cut, paste, undo, and redo.
- Added coverage for paste and paste-as-plain-text shortcut behavior to help ensure consistent handling.