Repository navigation
fix(terminal): let unselected Cmd+C reach apps that own their selection - #23597
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- App-owned Cmd+C predicate — new
isAppOwnedCopyChordinxterm-bypass-policy.ts: macOS only, no terminal selection, Kitty flags non-zero, and aMod+Cmatch.shouldBypassXtermKeyboardEventnow returnsfalsefor it (letting xterm's Kitty encoder deliver the chord to the app), placed after thedefaultPreventedearly-return so an already-claimed chord still bubbles. - Popout parity —
preview-terminal-key-handler.tsapplies the same rule to the dashboard popout, so an unselected Cmd+C falls through to xterm instead of being consumed; selection and plain-shell paths are unchanged. - Held-copy claim —
resolveTerminalShortcutActionnow resolvescopySelectionon repeat, anddispatchTerminalShortcutActionclaims copy keydowns before theevent.repeatguard, arming the native-only tracker and copying only on the first keydown — so a held copy no longer leaks repeat/release CSI-u into a Kitty app. - Tests — new unit tests for the predicate, the popout copy dispatch, and repeat/custom-binding resolution; the mac-only e2e covers plain shell, Kitty app, selection, after-Ctrl+C, and flags-cleared. E2E keyboard helpers were split into
tests/e2e/helpers/terminal-kitty-keyboard.ts.
Verification: the 6 changed/relevant unit suites pass (114 tests) and oxlint is clean on the 7 changed files. The one thing automation cannot exercise — whether a real macOS key press reaches the renderer before the Edit→Copy menu accelerator — is already called out in the PR body as a manual pre-merge check; merging depends on #23584 first, as the PR notes.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…keyboard On macOS Orca swallowed an unselected Cmd+C as a no-op copy, so a full-screen TUI like Codex, which captures the mouse and keeps its highlight out of xterm's selection, never received its own copy chord. - isAppOwnedCopyChord (xterm-bypass-policy) is the one rule: macOS, no xterm selection, and non-zero kitty flags from the pane's mirror. The pane's xterm bypass and the dashboard popout's key handler both use it. - A selection copy stays claimed through its repeats and release, including custom copy bindings, so kitty event reporting cannot leak them to the PTY. - Plain shells keep sending nothing; Linux and Windows are unchanged. - The e2e kitty helpers move to helpers/terminal-kitty-keyboard.ts so the shortcut spec stays under the line limit.
… pane A highlight of blank cells trims to empty text but is still a selection, so the popout must not hand that Cmd+C to a kitty app while the pane withholds it.
…tch tests The shortcut-policy suite is at its line limit.
…ut selection after the early return
28d38f2 to
35fceda
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (11)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe terminal copy routing now accounts for macOS Cmd+C, terminal selection state, and active Kitty keyboard flags. Repeated copy keydowns continue through shortcut dispatch without repeating clipboard writes. Unit and end-to-end tests cover copy routing, repeated shortcuts, and Kitty keyboard reporting. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The change is mergeable after normal checks. Complete the requested native macOS Cmd+C check to confirm that Edit→Copy does not interfere with app-owned input. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new routing is limited to an explicit macOS copy shortcut when there is no terminal selection and the application has enabled the keyboard protocol. A narrow transition remains: if the selection disappears while the key is held, later key events may be split between the terminal and the application. No broader security exposure was established. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |

ELI5
In Codex's full-screen view, Codex draws its own text highlight, so Orca's terminal has nothing selected. Orca treated Cmd+C as "copy nothing", so Codex never received it and you couldn't copy. Now, when nothing is selected in the terminal and the app has asked for the richer keyboard protocol, Cmd+C goes to the app, and Codex copies its own highlight.
What Changed
Before: on macOS, Cmd+C always skipped xterm's keyboard encoder, even with no terminal selection. So apps that manage their own selection never received it.
After: Cmd+C is handed to the app when all three hold:
Otherwise nothing changes:
Mechanism:
isAppOwnedCopyChordinxterm-bypass-policy.ts, is shared by the terminal pane and the dashboard popout. When it holds, the chord falls through to xterm's existing Kitty encoder and input transport.Why
cinto TUIs on an unselected Cmd+C, and another swallows it. Neither lets the app copy.Linked Issue
Related to #9727. This supersedes #22950, re-derived on top of #23584.
Visual Proof
N/A: this is a keyboard delivery change. The e2e test reads the exact bytes the app receives.
Testing
e2e (
terminal-shortcuts.spec.ts, macOS): a new test, "unselected Cmd+C reaches a Kitty app, including after Ctrl+C", covers four cases:\x1b[99;9;99u/\x1b[99;9:3u;It fails with the fix reverted.
Unit:
Results:
Not covered by automation: CDP-injected keys have no native macOS key event, so the automated tests can't check how a real key press interacts with Edit→Copy. From Electron's key handling, the renderer sees Cmd+C before the menu does. Please press Cmd+C once in Codex before merging.
Review
Edge cases:
Stacked PR: this is based on #23584. Review and merge that first.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)