Repository navigation
Fix Ctrl+Alt terminal input on Windows by repairing xterm's AltGr misclassification - #8810
Merged
AmethystLiang merged 4 commits intoJul 16, 2026
Conversation
Contributor
📝 WalkthroughWalkthroughAdds Windows-specific Ctrl+Alt terminal input resolution for genuine chords, including Alt-prefixed letter encoding and forwarding of digits and punctuation. Integrates the resolver into the terminal pane keyboard handler, which writes resolved bytes directly and bypasses subsequent xterm handling. Adds unit tests for modifier, composition, and event-state cases, and adds Windows end-to-end assertions for PTY writes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
…own key encoders Replace the hand-rolled Alt-prefix encoder in the custom key handler with a narrow repair of xterm's third-level-shift classification. xterm's keyboard service already computes the correct bytes for every input protocol (legacy ESC-prefixed, kitty CSI-u, win32-input-mode) before _isThirdLevelShift discards them on Windows Ctrl+Alt; rescuing only provably-genuine chords (Chromium's layout-wide AltGraph simulation, crbug 762557) lets those encoders deliver protocol-correct, layout-aware bytes with no duplicated encoding knowledge in Orca. Fixes vs the previous approach: kitty-mode TUIs now receive CSI-u instead of legacy bytes, digits/punctuation no longer alias to plain Alt chords, letters follow the logical layout (Dvorak/Colemak), Ctrl+Alt+Shift and Ctrl+Alt+F-keys gain Linux parity, and handled keys get xterm's stock preventDefault/stopPropagation. Firefox web clients keep stock behavior; a real-Terminal contract test fails loudly if an xterm upgrade removes the seam, degrading at runtime to the historical dropped-chord behavior. Co-authored-by: Orca <[email protected]>
AmethystLiang
force-pushed
the
fix/8734-windows-ctrl-alt-terminal-input
branch
from
July 16, 2026 07:41
2763988 to
0b6dc2c
Compare
- Extract a shared getCore() helper in the test file to dedupe repeated `_core` casts across third-level-shift and keyboard-service lookups. - Correct the AltGraph comment: Chromium simulates AltGraph per composing keypress, not for the whole Ctrl+Alt press duration. - Warn via console when xterm no longer exposes `_core._isThirdLevelShift`, so a silent classification-repair failure is diagnosable in the wild.
The comment previously implied Chromium always sets AltGraph=true for composable chords; the revised wording states the actual mechanism (Alt+Ctrl modifiers get replaced by AltGraph) so the inverse case is unambiguous.
AmethystLiang
requested review from
AmethystLiang
and removed request for
Jinwoo-H
July 16, 2026 20:18
Contributor
|
reviewing it |
9 tasks done
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…classification (stablyai#8810) * fix(terminal): forward Windows Ctrl Alt chords * fix(terminal): route rescued Windows Ctrl+Alt chords through xterm's own key encoders Replace the hand-rolled Alt-prefix encoder in the custom key handler with a narrow repair of xterm's third-level-shift classification. xterm's keyboard service already computes the correct bytes for every input protocol (legacy ESC-prefixed, kitty CSI-u, win32-input-mode) before _isThirdLevelShift discards them on Windows Ctrl+Alt; rescuing only provably-genuine chords (Chromium's layout-wide AltGraph simulation, crbug 762557) lets those encoders deliver protocol-correct, layout-aware bytes with no duplicated encoding knowledge in Orca. Fixes vs the previous approach: kitty-mode TUIs now receive CSI-u instead of legacy bytes, digits/punctuation no longer alias to plain Alt chords, letters follow the logical layout (Dvorak/Colemak), Ctrl+Alt+Shift and Ctrl+Alt+F-keys gain Linux parity, and handled keys get xterm's stock preventDefault/stopPropagation. Firefox web clients keep stock behavior; a real-Terminal contract test fails loudly if an xterm upgrade removes the seam, degrading at runtime to the historical dropped-chord behavior. Co-authored-by: Orca <[email protected]> * Refactor Windows Ctrl+Alt chord test helpers and clarify AltGraph commen - Extract a shared getCore() helper in the test file to dedupe repeated `_core` casts across third-level-shift and keyboard-service lookups. - Correct the AltGraph comment: Chromium simulates AltGraph per composing keypress, not for the whole Ctrl+Alt press duration. - Warn via console when xterm no longer exposes `_core._isThirdLevelShift`, so a silent classification-repair failure is diagnosable in the wild. * Clarify comment explaining why Windows Ctrl+Alt chords bypass AltGraph c The comment previously implied Chromium always sets AltGraph=true for composable chords; the revised wording states the actual mechanism (Alt+Ctrl modifiers get replaced by AltGraph) so the inverse case is unambiguous. --------- Co-authored-by: Jinjing <[email protected]> Co-authored-by: Orca <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ctrl+Altchords reach xterm's own protocol-aware key encoders instead of being silently dropped_isThirdLevelShiftdiscards them; the fix is a narrow runtime wrapper on that predicate — Orca adds no encoder of its ownCtrl+Altheld, no Meta, andgetModifierState('AltGraph') === false. Chromium simulates the AltGraph modifier layout-wide whenever the active layout maps AltGr characters (crbug 762557), so a false AltGraph state proves the chord cannot compose textFixes #8734.
Why not encode in Orca's key handler
An earlier revision intercepted the chord in
attachCustomKeyEventHandlerand injected hand-rolledESC-prefixed bytes. Review found four defects inherent to duplicating the encoder: kitty-protocol TUIs (neovim, helix, fish 4) received legacy bytes behind their negotiated protocol;Ctrl+Alt+2aliased to plainAlt+2andCtrl+Alt+[emitted a bare CSI introducer; letters keyed off physicalcode(wrong for Dvorak/Colemak); and the injected path skipped xterm's stockstopPropagation. Routing rescued chords through xterm's own encoders resolves all four and additionally fixesCtrl+Alt+Shiftchords andCtrl+Alt+F-keys, giving full parity with Linux client behavior.Screenshots
No visual change.
Testing
pnpm typecheckFocused checks:
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/pane-manager src/renderer/src/components/terminal-pane— 216 files, 2688 passedTerminaland pin, against the actual xterm build: (1) the internal seam exists — an xterm upgrade that removes_isThirdLevelShiftfails CI loudly instead of silently regressing; (2) rescued chords produce xterm-encoder output: legacyESC+0x15/ESC 2/ESC ;forCtrl+Alt+U/2/;, andCSI 117;7ufor the same chord once kitty progressive flags are negotiatedWindows forwards genuine Ctrl+Alt text chordsverifies the exact bytes at the main-process PTY write boundary (byte expectations unchanged from the previous revision — they match xterm's legacy encoder output exactly)ESC + Ctrl-Uthrough node-pty made Windows PowerShellReadKeyreportU,char=0x0015,modifiers=Alt, ControlNotes
installWindowsCtrlAltChordRepairreturns false and behavior degrades to today's dropped-chord behavior — never to wrong bytes. The contract test additionally turns that into a CI failure.Ctrl+Altchord, so genuine chords there remain indistinguishable from AltGr composition and are still dropped — same as before this PR. Unavoidable without misreading AltGr typing.onDatatransport paths.Security Audit
No new external data source, dependency, IPC method, filesystem access, or privilege. The change narrows one keyboard-classification predicate; all emitted bytes are produced by xterm's existing encoders on the existing trusted terminal input path.