Repository navigation
fix(terminal): type Option-composed non-ASCII text in kitty panes (#20171) - #20579
eatmoreduck wants to merge 3 commits into
Conversation
|
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 (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe terminal shortcut policy now recognizes composed Unicode characters, including non-ASCII and supplementary-plane code points, while excluding DEL. Compose-side Option input sends the composed character as text. Option configured as Alt continues to send kitty CSI-u physical-key chords. Tests cover Unicode letters, diacritics, shifted characters, punctuation, Option-side modes, and uncomposed layout-map input. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The terminal now sends composed Unicode characters directly while retaining configured Alt chords, with no established merge-blocking risk in the current change. 🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/terminal-option-shortcut-policy.ts (1)
59-59: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winSupport supplementary composed characters.
key.length !== 1measures UTF-16 code units, not Unicode code points. For example, a layout that producesU+1D11Ehaskey.length === 2. The predicate returnsfalse, and a kitty pane sends a CSI-u chord instead of the composed text.Count Unicode code points before rejecting the key.
Proposed fix
- if (key.length !== 1) { + if (Array.from(key).length !== 1) { return false }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 518fcf46-7662-4868-9bbc-23ef622753bb
📥 Commits
Reviewing files that changed from the base of the PR and between 0c81284 and 354a111965ba99c2073460e2e00612518c4da1c8.
📒 Files selected for processing (6)
src/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/shared/automation-cron-occurrence.tssrc/shared/automation-schedule-occurrences.test.tssrc/shared/automation-schedule-occurrences.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const date = new Date(timestamp) | ||
| date.setSeconds(0, 0) | ||
| return date.getTime() | ||
| return timestamp - (timestamp % 60_000) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Floor negative timestamps toward negative infinity.
JavaScript % preserves the sign of timestamp. For timestamp = -15_000, this returns 0 instead of -60_000. latestAutomationOccurrenceAtOrBefore can then return an occurrence after now for pre-epoch schedules.
Proposed fix
- return timestamp - (timestamp % 60_000)
+ return Math.floor(timestamp / 60_000) * 60_000📝 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.
| return timestamp - (timestamp % 60_000) | |
| return Math.floor(timestamp / 60_000) * 60_000 |
…ablyai#20171) resolveTerminalOptionShortcutAction encoded every non-ASCII composed Option chord as kitty CSI-u from the physical key (alt+c for a press that produced ç), so with a compose layout and a kitty-protocol TUI (Claude Code negotiating CSI > 5 u) non-Latin prose was untypable: ç ą å ø never reached the PTY even with Option-as-Alt explicitly off, while the same pane typed them fine at the shell prompt. The ASCII-only composed-text branch existed so stablyai#8031 Option hotkeys kept reaching kitty TUIs. That trade sacrificed whole alphabets: on Polish Pro, all nine diacritics are Option chords with no fallback route. The effective setting is the user's contract — when it says Option composes, a genuine composition now types its text (any single printable character); chords remain for keys the layout did not compose (key echoes its base character), for Alt-configured sides (shouldActAsMeta), for numpad keys, and under report-all flags (associated text), so stablyai#8031 hotkeys stay reachable by configuring Option as Alt explicitly. Flips the regression expectations that locked stablyai#8031 chord behavior for composed non-ASCII glyphs; adds Polish Pro (layout map, flags 5), ç-style composition, and explicit-Alt escape-hatch coverage.
354a111 to
784a19e
Compare
|
Scope fix pushed (force-push, head is now
|
There was a problem hiding this comment.
ℹ️ No critical issues — one scope note.
Reviewed changes
- Option-compose text passthrough widened (
terminal-option-shortcut-policy.ts):isLayoutComposedAsciiCharacterbecomesisLayoutComposedCharacterand drops the<= 0x7eceiling (now only excluding0x7f), so a composed non-ASCII key on a compose side sends its text instead of a CSI-u chord in kitty panes. - Tests flipped and extended: non-ASCII composed glyphs (
π µ ∏ ¡ ≥ ¬ ƒ ∫ å ą) now assert typed text; Alt-side ('true','left'meta side) and base-echo chord expectations are retained; new Polish-Pro-under-flags-5 and explicit-macOptionAsAlt: 'true'cases cover the boundary. - DST fall-back cron fixes (
automation-cron-occurrence.ts,automation-schedule-occurrences.ts):floorToMinuteswitches to absolute modulo, and the HOURLY branches ofnextAutomationOccurrenceAfter/latestAutomationOccurrenceAtOrBeforewalk absolute minutes rather than recomposing local wall-clock fields. - New DST suite (
automation-schedule-occurrences.test.ts): TZ-pinned, Windows-skipped coverage for repeated fall-back minutes and the spring-forward skip.
ℹ️ Terminal fix bundles three unrelated automation commits
The branch carries three automation commits fixing DST fall-back cron occurrences (#20154) alongside the terminal change, and the PR body never mentions them. Merging as-is lands two independent fixes under one title, so a later revert of the Option-compose change would also roll back the cron repair. These look like a stacked branch carried onto main; consider splitting them into their own PR (or rebasing this one onto main).
Technical details
# Unrelated automation commits in a terminal PR
## Affected sites
- `src/shared/automation-cron-occurrence.ts:17` — `floorToMinute` absolute-modulo change
- `src/shared/automation-schedule-occurrences.ts:109` — HOURLY `nextAutomationOccurrenceAfter`
- `src/shared/automation-schedule-occurrences.ts:151` — HOURLY `latestAutomationOccurrenceAtOrBefore`
- `src/shared/automation-schedule-occurrences.test.ts` — new DST suite
## Required outcome
- The terminal fix and the cron DST fix land in separate PRs, or the PR body states the automation
changes are intentionally included.
## Open questions for the human
- Is this branch intentionally stacked on an open automation PR whose base should be that branch
rather than `main`? If so, retarget the base instead of editing the commits.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — one minor coverage nit inline.
Reviewed changes
- Rebased on
mainand slimmed down: the three unrelated automation DST commits that were present at the previously reviewed354a111are gone; the PR now changes only the terminal Option policy and its two test files. - Supplementary-plane compositions (
terminal-option-shortcut-policy.ts): the single-character guard moves fromkey.length !== 1toArray.from(key).length !== 1, so a𝕒-style astral composition is no longer rejected as a chording key. This matches the existing code-point idiom inxterm-bypass-policy.tsandterminal-non-latin-control-chord.ts. - The rest of the policy/test change set is unchanged from the initial review and remains sound: composed non-ASCII glyphs on a compose side type their text, while Alt-configured sides and base-echo keys still emit CSI-u chords.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Supplementary-plane coverage added (
terminal-shortcut-option-compose.test.ts): a new case asserts that the astral-plane composition𝕒(a length-2 UTF-16 string) resolves to{ type: 'sendInput', data: '𝕒' }rather than a CSI-u chord. Under the oldkey.length !== 1guard this expectation fails, so the assertion genuinely pins theArray.from(key)code-point counting from784a19e. - The policy change and the remaining flipped/retained test expectations are unchanged from the prior review and remain sound; this commit closes the only open coverage nit from that review.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
@sembsa the branch is ready for your matrix — apologies for the crossing messages, your offer landed a minute before my comment linking it: Your planned coverage maps perfectly onto what's testable from it:
@matematyk60's independent confirmation (queued |
|
@eatmoreduck Confirmed working on real Polish Pro hardware — thanks for the quick turnaround. Setup: dev build from Result: Polish diacritics now type correctly into a Claude Code pane. Unit tests pass locally too: Compose-side behaviour of Option hotkeys — matches the intended changeChecked the other half of the trade-off on the compose side, since that's the part the thread was weighing:
So the flip behaves exactly as described: on a compose layout every key the layout can compose yields the character, and only non-composing keys (Enter) keep their chord. Worth stating plainly for the record, because on Polish Pro this means Option-based hotkeys are gone on the default Still not verified
Note for anyone else testing from sourceWorth correcting the "local native-rebuild constraints" expectation in the PR description — building this natively on macOS was completely uneventful: Also confirming @matematyk60's symptom from the other direction: the pre-fix behaviour really is a swallowed keydown rather than a dropped character, which is why the queued letters resurfaced at the shell prompt after quitting Claude Code. |
|
Yes please — run the matrix. That's exactly the record we want before merge: the nine-letter × Also, thank you for the precision on verified vs not — exactly the right split, and for the testing notes: the "local native-rebuild constraints" line in the PR description was my machine's environment, not the branch; I'm correcting the description now to reflect your clean 27s build and to record this confirmation. |
|
@eatmoreduck @nwparker Matrix done — real Polish Pro keyboard, dev build of
Letters —
|
| kitty flags | delivered | form |
|---|---|---|
protocol off |
9/9 ✅ | UTF-8 |
CSI > 1 u |
9/9 ✅ | UTF-8 |
CSI > 5 u |
9/9 ✅ | UTF-8 |
CSI > 29 u |
9/9 ✅ | associated text |
Per-letter under CSI > 5 u, the set Claude Code negotiates:
| letter | key | bytes | letter | key | bytes |
|---|---|---|---|---|---|
| ą | Option+a |
c4 85 |
ś | Option+s |
c5 9b |
| ć | Option+c |
c4 87 |
ź | Option+x |
c5 ba |
| ę | Option+e |
c4 99 |
ż | Option+z |
c5 bc |
| ł | Option+l |
c5 82 |
ó | Option+o |
c3 b3 |
| ń | Option+n |
c5 84 |
Under >29u the same letters arrive as associated text, e.g. ą → CSI 97;3;261u (261 = U+0105).
Letters — terminalMacOptionAsAlt: "true" (escape hatch)
| kitty flags | delivered | what arrives instead |
|---|---|---|
protocol off |
0/9 | ESC+base, e.g. ą → 1b 61 (ESC a) |
CSI > 1 u |
0/9 | CSI 97;3u |
CSI > 5 u |
0/9 | CSI 97;3u |
CSI > 29 u |
0/9 | CSI 97;3u |
All nine keys emit alt-modified chords from the physical key under every flag set — ą→CSI 97;3u, ę→CSI 101;3u, ł→CSI 108;3u, ż→CSI 122;3u. Byte-identical to pre-fix behaviour.
Option hotkeys under CSI > 5 u + modifyOtherKeys=2
Measured with the flags held on during capture, i.e. exactly what Claude Code negotiates:
| key | auto (compose) |
true (alt) |
|---|---|---|
Option+P |
text Ļ c4 bb — hotkey unreachable |
CSI 112;3u ✅ reaches TUI as alt |
Option+Enter |
CSI 13;3u ✅ reaches TUI as alt |
CSI 13;3u ✅ reaches TUI as alt |
Option+a (control) |
text ą c4 85 ✅ |
CSI 97;3u |
Two things worth pulling out of that table:
1. @nwparker's no-regressions criterion is met with hard evidence. Under an explicit 'true', Option+P arrives as CSI 112;3u under Claude Code's own flags — the #8031 hotkey population has a working configuration, confirmed on real hardware rather than only in unit tests.
2. Option+Enter survives on both sides. Enter composes no character, so it never enters the composed-text branch and keeps its chord even on the compose side. That materially softens the trade-off discussed in the thread: a compose-layout user on the default auto loses letter-key hotkeys like Option+P, but keeps the newline binding, which is by far the most-used Option shortcut in a TUI. The practical cost of direction A is smaller than "Option hotkeys stop working" suggests — it's "Option hotkeys bound to text-producing keys stop working".
Observation: associated text disappears under 'true' + >29u
One asymmetry, since you asked for real-keyboard confirmation of the report-all path:
| setting | >29u, Option+a |
associated text |
|---|---|---|
auto |
CSI 97;3;261u |
present (261) |
true |
CSI 97;3u |
absent |
Flag 16 in the set of 29 is "report associated text", so per the kitty spec the text a key produces should be reported regardless of how the terminal maps Option. The cause looks like the canSendComposedText conjunct:
kittyReportsAllKeysAsEscapeCodes(flags) && canSendComposedText ? event.key : undefinedWith macOptionAsAlt: "true" the third parameter is dropped, so a TUI that explicitly asked for associated text cannot recover the character. This predates the PR rather than being introduced by it, and it's not a merge blocker — an app on flags 29 still gets an unambiguous alt chord. But it does mean the report-all path isn't strictly "unchanged": what it carries depends on the Option setting. Probably its own issue rather than scope creep here.
Summary
- Compose side: 36/36 letter measurements delivered across all four flag sets — [Bug]: macOS — Option-composed non-ASCII letters (ç, ñ, å, ø) are swallowed in kitty-protocol TUIs even with "Option as Alt" disabled #20171 is fixed.
- Alt side: chord behaviour preserved on all nine letter keys plus
Option+P, across all four flag sets — no regression for fix(terminal): forward Option hotkeys to kitty-keyboard TUIs on compose layouts #8031. Option+Enterkeeps working on both sides.- Only finding is the pre-existing
>29uassociated-text asymmetry above.
No blockers found from this hardware. Happy to re-run anything; the dev build stays up.
|
This is exemplary — 78 per-keystroke byte captures across four flag sets, on the exact hardware the trade-off was theorized about. Thank you. Agreed on both of your calls:
Matrix + summary now referenced from the issue thread. Nothing left blocking on this side. |
|
Verified on a third layout type: a custom Ukelele layout (input source ID
Thanks for the PR! |
#21082) * fix(terminal): preserve Option-composed text in kitty panes Adapt the composition fix from #20579 and the input-source correction from #20164. Extend coverage to every Polish letter, live setting changes, associated text, and Chromium-to-PTY word entry. Co-authored-by: yu.xia <[email protected]> Co-authored-by: Alexandre Blause <[email protected]> * test: guard native Korean IME against background launch --------- Co-authored-by: yu.xia <[email protected]> Co-authored-by: Alexandre Blause <[email protected]>
|
Closing — the fix has landed via #21082, which adapts this PR's composed-text policy and Unicode handling. Thanks @nwparker for the credit and the Co-authored-by attribution, and @sembsa / @coreequip for the real-keyboard verification that shaped it. |

ELI5
On macOS layouts where Option composes characters (ABC, Polish Pro, US-International, …), typing
çorąinto a kitty-protocol terminal (Claude Code) sentalt+c/alt+achords instead of the letter — so writing non-Latin prose in those panes was impossible, even with "Option as Alt" turned off. Now the composed letter is typed.What Changed
In
resolveTerminalOptionShortcutAction(terminal-option-shortcut-policy.ts): the composed-text branch under kitty flags no longer restricts itself to ASCII. When the effective Option resolution says this press composes (canSendComposedText) and the layout produced a single printable character, the character's text is sent instead of a CSI-u chord — forç ą å ø ƒ ∫ π …, not just@ $ [ ].Chords are unchanged (and still correct) for:
alt+qon US),macOptionAsAlt: 'true', or the designated side in'left'/'right'), which keep physical-key CSI-u for fix(terminal): forward Option hotkeys to kitty-keyboard TUIs on compose layouts #8031-style TUI hotkeys,Plus test updates: the expectations that locked #8031's non-ASCII chord behavior are flipped to the new text behavior, and new coverage was added (details below).
Why
#8031 deliberately encoded non-ASCII composed chords from the physical key so OMP-style
Option+Photkeys could reach kitty TUIs, with the ASCII/non-ASCII split chosen because "the glyphs on TUI-bound keys (π, ƒ, ∫) never are [ASCII]". That split sacrifices entire alphabets: on Polish Pro all nine diacritics (ą ć ę ł ń ó ś ź ż) are Option chords with no dead-key fallback, so ordinary Polish words were untypable in kitty panes (#20171); same forçon US-International and ABC (å).The thread converged on "the setting wins":
autoon a compose layout already renders "Option composes characters like @, €, [, ]" in Settings, and the same Claude Code binary typesąfine in Ghostty and in the same Orca pane at the shell prompt — only the kitty path drops it. Anyone who wants Option as a modifier configures it explicitly ('true'/'left'/'right'), and those paths keep chords here.Linked Issue
Fixes #20171
Visual Proof
N/A — no UI change; observable in a terminal pane: with Option-as-Alt off and Claude Code running,
Option+Cnow insertsçinstead of nothing.Testing
macOS (arm64, Node 22):
terminal-shortcut-option-compose.test.ts+terminal-shortcut-policy.test.ts: 73 passing, includingπ ∏ ¡ ≥ ¬ µ ƒ ∫ ånow send text on compose sides (was CSI-u chords),alt+m, Colemakalt+p, US fallback), Alt-side chords in'true'/'left'/'right', shifted-ASCII chord (alt+shift+2→\x1b[50;4u), numpad, report-all associated text, IME/dead-key exemptions, non-kitty B/F/D readline patches,ąthrough the layout map under flags 5 (what Claude Code negotiates,CSI > 5 u), and the explicit-'true'escape hatch (å→\x1b[97;3u).Full
src/renderer/src/components/terminal-pane/+dashboard-popout/suites: 490 files / 4644 tests passing.typecheckexits 0;oxlintclean on changed files.Full
pnpm lint/pnpm builddelegated to CI. Local note: the earlier "native-rebuild constraints" wording was this machine's stale-SDK environment, not the branch — an independent clean macOS arm64 checkout ranpnpm installin 27s withnode-ptycompiling without issue.Real-hardware verification (Polish Pro): @sembsa built this branch natively (
2feff9fd) and confirmed the fix on real hardware — Polish diacriticsłóążćśnow type straight into a Claude Code pane under the defaultautosetting (the previously broken path), with the same keystrokes producing nothing before the branch. Local suite re-run there: 74/74 passing. The byte-level matrix acrossoff/>1u/>5u/>29uand the explicit-'true'real-keyboard hotkey check are in flight (offered in #20171).AI Disclosure
Investigation and fix drafted with AI assistance (GLM, via ZCode); the author reviewed the diff, the policy rationale, and the test flips. Direction A was chosen in the issue thread with the reporter and @sembsa; @nwparker flagged the two acceptance criteria (Polish-keyboard testing, no regressions) this PR is structured around.
Review
AI-assisted review summary per the contributing guide:
context.isMacgate); Windows/Linux Option handling untouched; no keyboard-shortcut labels or paths changed.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
Deliberately reverses one aspect of #8031 (non-ASCII composed chords on compose sides); the chord paths for Alt sides and non-composed keys are preserved and tested. Related sibling defects are tracked separately: #20495 (stale per-pane Option setting at mount) and #20163 (US-International-PC misclassified as Meta-safe).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — all four verified locally on this branch: fullpnpm test= 81,443 tests passing with 13 file-level failures that are pre-existing environment constraints of this machine (shallow clone lacks the tags the cross-version harness needs, real-CLI-binary tests, PTY load timing) and none intersect this PR's files; fullpnpm lint(all ratchets + localization gates) exits 0; fullpnpm buildexits 0;pnpm typecheckexits 0Author: X — @eatmoremoreduck · GitHub — @eatmoreduck