Repository navigation
fix(terminal): type Option-composed ASCII instead of reporting it as a chord - #14743
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change adds a native macOS keyboard-layout helper and exposes validated snapshots through IPC and preload APIs. Renderer layout resolution now supports native Shift and Option mappings, change notifications, stale-refresh fencing, and Option-key location tracking. Terminal paths use shared Kitty CSI-u encoding, layout-aware Option shortcuts, deferred releases, and richer IME modifier data. macOS build and packaging pipelines now compile, sign, bundle, and validate the helper. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts (1)
75-87: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the helper comment.
These lines add a long historical explanation. Keep one concise comment that states the ASCII composition rule.
As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0ed0b5c0-a280-4138-a0b1-ca173a534470
📒 Files selected for processing (2)
src/renderer/src/components/terminal-pane/terminal-shortcut-option-compose.test.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b01a2fc1-8116-4ebf-80e1-4bd2f6e659fd
📒 Files selected for processing (35)
config/electron-builder.config.cjsconfig/scripts/build-keyboard-layout-macos.mjsconfig/scripts/build-native-for-platform.mjsconfig/scripts/electron-builder-config.test.mjsconfig/scripts/package-electron-runtime-contract.test.mjsconfig/scripts/run-electron-vite-dev.mjsnative/keyboard-layout-macos/main.swiftpackage.jsonsrc/main/ipc/app.tssrc/main/ipc/macos-keyboard-layout-snapshot.test.tssrc/main/ipc/macos-keyboard-layout-snapshot.tssrc/preload/api/app-api.tssrc/preload/index.tssrc/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsxsrc/renderer/src/components/dashboard-popout/preview-terminal-key-handler.tssrc/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.test.tssrc/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.tssrc/renderer/src/components/terminal-pane/keyboard-handlers.test.tssrc/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/terminal-ime-kitty-commit-encoding.tssrc/renderer/src/components/terminal-pane/terminal-kitty-keyboard-flags.tssrc/renderer/src/components/terminal-pane/terminal-option-kitty-release.test.tssrc/renderer/src/components/terminal-pane/terminal-option-kitty-release.tssrc/renderer/src/components/terminal-pane/terminal-option-shortcut-policy.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-option-compose.test.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.tssrc/renderer/src/lib/keyboard-layout/layout-base-character.test.tssrc/renderer/src/lib/keyboard-layout/layout-base-character.tssrc/renderer/src/lib/keyboard-layout/option-as-alt-probe.test.tssrc/renderer/src/lib/keyboard-layout/option-as-alt-probe.tssrc/renderer/src/lib/keyboard-layout/option-key-location-state.test.tssrc/renderer/src/lib/keyboard-layout/option-key-location-state.tssrc/renderer/src/web/web-preload-api.tssrc/shared/keyboard-layout-snapshot.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 1 remains after this review.
| function readArg(name) { | ||
| const index = args.indexOf(name) | ||
| return index === -1 ? undefined : args[index + 1] |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Validate the --output value.
If --output is last, readArg returns undefined. If --output precedes --single-arch, it treats that option as the output path. The script can then fail in path.dirname or write a helper named --single-arch in the working directory. Reject a missing or option-like value.
Proposed fix
function readArg(name) {
const index = args.indexOf(name)
- return index === -1 ? undefined : args[index + 1]
+ if (index === -1) {
+ return undefined
+ }
+ const value = args[index + 1]
+ if (!value || value.startsWith('--')) {
+ throw new Error(`Missing value for ${name}`)
+ }
+ return value
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function readArg(name) { | |
| const index = args.indexOf(name) | |
| return index === -1 ? undefined : args[index + 1] | |
| function readArg(name) { | |
| const index = args.indexOf(name) | |
| if (index === -1) { | |
| return undefined | |
| } | |
| const value = args[index + 1] | |
| if (!value || value.startsWith('--')) { | |
| throw new Error(`Missing value for ${name}`) | |
| } | |
| return value | |
| } |
b75ac26 to
745a562
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.ts (1)
71-71: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd lock-state coverage to the synthetic forwarder tests. Production callers pass xterm’s live
KeyboardEventunchanged. Test helpers omitgetModifierState; addCapsLockandNumLockcases to detect regressions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d255e776-4970-46cd-b94c-da5c79f7fa54
📒 Files selected for processing (47)
config/electron-builder.config.cjsconfig/reliability-gates.jsoncconfig/scripts/build-keyboard-layout-macos.mjsconfig/scripts/build-native-for-platform.mjsconfig/scripts/electron-builder-config.test.mjsconfig/scripts/package-electron-runtime-contract.test.mjsconfig/scripts/run-electron-vite-dev.mjsnative/keyboard-layout-macos/main.swiftpackage.jsonsrc/main/ipc/app.test.tssrc/main/ipc/app.tssrc/main/ipc/macos-keyboard-layout-change-notifications.test.tssrc/main/ipc/macos-keyboard-layout-change-notifications.tssrc/main/ipc/macos-keyboard-layout-snapshot.test.tssrc/main/ipc/macos-keyboard-layout-snapshot.tssrc/preload/api/app-api.tssrc/preload/app-restart-checkpoint-routing.test.tssrc/preload/index.tssrc/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsxsrc/renderer/src/components/dashboard-popout/preview-terminal-key-handler.tssrc/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.test.tssrc/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.tssrc/renderer/src/components/terminal-pane/keyboard-handlers.test.tssrc/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/terminal-ime-kitty-commit-encoding.tssrc/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.test.tssrc/renderer/src/components/terminal-pane/terminal-ime-native-text-forwarder.tssrc/renderer/src/components/terminal-pane/terminal-ime-substituted-text-commit.test.tssrc/renderer/src/components/terminal-pane/terminal-kitty-csi-u-encoding.test.tssrc/renderer/src/components/terminal-pane/terminal-kitty-csi-u-encoding.tssrc/renderer/src/components/terminal-pane/terminal-option-kitty-release.test.tssrc/renderer/src/components/terminal-pane/terminal-option-kitty-release.tssrc/renderer/src/components/terminal-pane/terminal-option-shortcut-policy.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-option-compose.test.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.tssrc/renderer/src/lib/keyboard-layout/layout-base-character.test.tssrc/renderer/src/lib/keyboard-layout/layout-base-character.tssrc/renderer/src/lib/keyboard-layout/option-as-alt-probe.test.tssrc/renderer/src/lib/keyboard-layout/option-as-alt-probe.tssrc/renderer/src/lib/keyboard-layout/option-key-location-state.test.tssrc/renderer/src/lib/keyboard-layout/option-key-location-state.tssrc/renderer/src/web/web-preload-api-ui.test.tssrc/renderer/src/web/web-preload-api.tssrc/shared/keyboard-layout-events.tssrc/shared/keyboard-layout-snapshot.tssrc/shared/terminal-kitty-keyboard-flags.ts
🚧 Files skipped from review as they are similar to previous changes (24)
- config/scripts/electron-builder-config.test.mjs
- src/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.ts
- src/renderer/src/components/terminal-pane/keyboard-handlers.test.ts
- src/renderer/src/lib/keyboard-layout/option-key-location-state.test.ts
- package.json
- src/renderer/src/web/web-preload-api.ts
- config/scripts/build-keyboard-layout-macos.mjs
- src/renderer/src/components/dashboard-popout/AgentTerminalPreview.tsx
- src/main/ipc/macos-keyboard-layout-snapshot.test.ts
- config/scripts/run-electron-vite-dev.mjs
- config/scripts/package-electron-runtime-contract.test.mjs
- src/renderer/src/components/terminal-pane/terminal-option-kitty-release.test.ts
- src/renderer/src/components/dashboard-popout/preview-terminal-shortcuts.test.ts
- config/electron-builder.config.cjs
- src/shared/keyboard-layout-snapshot.ts
- src/preload/index.ts
- src/renderer/src/components/terminal-pane/terminal-option-kitty-release.ts
- src/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.ts
- src/renderer/src/components/dashboard-popout/preview-terminal-key-handler.ts
- src/renderer/src/lib/keyboard-layout/option-key-location-state.ts
- src/renderer/src/lib/keyboard-layout/layout-base-character.ts
- config/scripts/build-native-for-platform.mjs
- src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
- src/renderer/src/components/terminal-pane/keyboard-handlers.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review.
The Option-compose fix had unit coverage only. This drives a live Electron pane whose kitty flags are armed by the application's own CSI > 1 u and asserts the bytes at the pty boundary: composed `@` and Shift-layer `\` arrive as text, configured Option-as-Alt still reports the layout-resolved chord, and a non-ASCII glyph still reaches the app as its alt hotkey. Restoring the pre-fix policy fails exactly the two composed-text scenarios. Also records the ASCII rule's rationale where the rule lives, not only in a test comment.
…pshot The native helper computed an Option and Option+Shift character for every key, shipped both over IPC, validated them in the parser and cached them in the renderer — but no production caller ever asked for them. Only the base and Shift layers are read, and Shift is the one the web layout map cannot supply, which is why the helper exists at all. Removing them halves the helper's UCKeyTranslate work per key and drops the option parameter that six signatures were threading through for nobody.
…a chord (#14743) * fix(terminal): preserve Option-composed ASCII input * fix(terminal): preserve Option keyboard protocol semantics * fix(terminal): complete Option keyboard event encoding * fix(terminal): harden Option input encoding * fix(terminal): close keyboard protocol fallback gaps * test(terminal): prove Option-composed ASCII reaches the pty end to end The Option-compose fix had unit coverage only. This drives a live Electron pane whose kitty flags are armed by the application's own CSI > 1 u and asserts the bytes at the pty boundary: composed `@` and Shift-layer `\` arrive as text, configured Option-as-Alt still reports the layout-resolved chord, and a non-ASCII glyph still reaches the app as its alt hotkey. Restoring the pre-fix policy fails exactly the two composed-text scenarios. Also records the ASCII rule's rationale where the rule lives, not only in a test comment. * refactor(terminal): drop the unread Option layers from the layout snapshot The native helper computed an Option and Option+Shift character for every key, shipped both over IPC, validated them in the parser and cached them in the renderer — but no production caller ever asked for them. Only the base and Shift layers are read, and Shift is the one the web layout map cannot supply, which is why the helper exists at all. Removing them halves the helper's UCKeyTranslate work per key and drops the option parameter that six signatures were threading through for nobody.
stablyai#15017 gave the composing-chord deferral an owner and a ceiling, and stablyai#14743 moved MacOptionAsAlt into terminal-option-shortcut-policy.ts. Both landed on the lines this branch had rewritten. The deferral now goes through main's `deferredChordSender`, which blur and teardown can drop, and which abandons a chord after 10 s rather than waiting forever. The release-recovered path keeps its own `composing` argument, since a chord answered for at keyup has no live event to read it from. `runShortcutAction` gained main's Option-release arming. Its narrowed event type now carries the modifier flags the tracker reads; a snapshotted chord already held them. The arming is keydown-only in effect — the Option policy returns null for a composing event, which every recovered chord is.
…a chord (stablyai#14743) * fix(terminal): preserve Option-composed ASCII input * fix(terminal): preserve Option keyboard protocol semantics * fix(terminal): complete Option keyboard event encoding * fix(terminal): harden Option input encoding * fix(terminal): close keyboard protocol fallback gaps * test(terminal): prove Option-composed ASCII reaches the pty end to end The Option-compose fix had unit coverage only. This drives a live Electron pane whose kitty flags are armed by the application's own CSI > 1 u and asserts the bytes at the pty boundary: composed `@` and Shift-layer `\` arrive as text, configured Option-as-Alt still reports the layout-resolved chord, and a non-ASCII glyph still reaches the app as its alt hotkey. Restoring the pre-fix policy fails exactly the two composed-text scenarios. Also records the ASCII rule's rationale where the rule lives, not only in a test comment. * refactor(terminal): drop the unread Option layers from the layout snapshot The native helper computed an Option and Option+Shift character for every key, shipped both over IPC, validated them in the parser and cached them in the renderer — but no production caller ever asked for them. Only the base and Shift layers are read, and Shift is the one the web layout map cannot supply, which is why the helper exists at all. Removing them halves the helper's UCKeyTranslate work per key and drops the option parameter that six signatures were threading through for nobody.
Fixes #14024.
Problem
On macOS layouts that produce printable ASCII with Option, terminal panes could report the physical Alt chord instead of typing the composed character. Neighboring paths could also lose authoritative IME text, mis-pair press/release events, retain stale layout state after an in-focus input-source switch, or encode incomplete protocol fields.
Fix
Dead,Process,Unidentified, composing, and keyCode-229 events from normal shortcut encoding. Native dead-key keydowns keep composition ownership, matching rewritten keyups cannot leak orphan releases, and an explicitly configured Alt side retains its legacy dead-key chord.Representative byte oracles:
\x1bq\x1be\x1b[112;3u\x1b[97;;97:769u\x1b[113;67;64u\x1b[60;3;124u\x1b[32;3;160uCompatibility
Verification
1b 62for global legacy Option+B and1b5b3131323b3375for negotiated Option+P.The reliability manifest now records the input invariant, exact deterministic command, notification fanout/cleanup assertions, and the event-driven performance budget.
Remaining gaps
£on Option+3,¢on Option+4,∞,π,∫,œ) still reaches a kitty-negotiated pane as its Alt chord, so it cannot be typed there under any Option-as-Alt setting. This is fix(terminal): forward Option hotkeys to kitty-keyboard TUIs on compose layouts #8031's tradeoff unchanged — those chords are what TUI Option hotkeys bind — and every other terminal instead makes Option-as-Alt a plain binary switch. Panes that never negotiated the protocol still compose normally, as do dead keys on every pane.Follow-up two-host validation