Skip to content

fix(terminal): type Option-composed non-ASCII text in kitty panes (#20171) - #20579

Closed
eatmoreduck wants to merge 3 commits into
stablyai:mainfrom
eatmoreduck:fix/option-compose-kitty-text-20171
Closed

eatmoreduck wants to merge 3 commits into
stablyai:mainfrom
eatmoreduck:fix/option-compose-kitty-text-20171

Conversation

@eatmoreduck

@eatmoreduck eatmoreduck commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

On macOS layouts where Option composes characters (ABC, Polish Pro, US-International, …), typing ç or ą into a kitty-protocol terminal (Claude Code) sent alt+c / alt+a chords 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:

  • keys the layout did not compose (key echoes its base character — e.g. plain alt+q on US),
  • sides configured as Alt (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,
  • numpad keys, report-all flags (associated text), dead keys / IME events (untouched, existing guards run first).

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+P hotkeys 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": auto on 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+C now inserts ç instead of nothing.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

macOS (arm64, Node 22):

  • terminal-shortcut-option-compose.test.ts + terminal-shortcut-policy.test.ts: 73 passing, including

    • flipped: composed π ∏ ¡ ≥ ¬ µ ƒ ∫ å now send text on compose sides (was CSI-u chords),
    • kept: base-echo keys still chord with the layout-correct base (AZERTY alt+m, Colemak alt+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,
    • new: Polish Pro ą 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.

  • typecheck exits 0; oxlint clean on changed files.

  • Full pnpm lint/pnpm build delegated 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 ran pnpm install in 27s with node-pty compiling 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 default auto setting (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 across off/>1u/>5u/>29u and 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:

  • Cross-platform: macOS-only code path (context.isMac gate); Windows/Linux Option handling untouched; no keyboard-shortcut labels or paths changed.
  • SSH / remote / local: policy runs in the renderer before bytes reach any PTY host; identical behavior local and SSH.
  • Agent / integration compatibility: intentional behavioral flip for compose-layout kitty panes (that is the fix). Non-kitty panes are byte-identical (verified by untouched readline tests). TUI Option hotkeys on compose layouts move to the explicit Alt configurations — this is the fix(terminal): forward Option hotkeys to kitty-keyboard TUIs on compose layouts #8031 trade-off reversal discussed in the issue.
  • Performance: same code path, one widened predicate; no hot-loop impact.
  • UI quality: N/A. Security: no new inputs or processes.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and 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

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — all four verified locally on this branch: full pnpm 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; full pnpm lint (all ratchets + localization gates) exits 0; full pnpm build exits 0; pnpm typecheck exits 0

Author: X — @eatmoremoreduck · GitHub — @eatmoreduck

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a9266d8a-0606-4335-83a7-34bd8579f2ca

📥 Commits

Reviewing files that changed from the base of the PR and between 784a19e and 2feff9f.

📒 Files selected for processing (1)
  • src/renderer/src/components/terminal-pane/terminal-shortcut-option-compose.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The 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 2feff

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The description links the relevant issue with Fixes #20171``, and the implementation directly addresses that issue's reported Option-composed character loss.
Out of Scope Changes check ✅ Passed The pull request is limited to three terminal policy and test files. The changes match the stated objective and do not include unrelated automation or product changes.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing non-ASCII Option-composed text in kitty terminal panes.
Description check ✅ Passed The description is complete and follows the repository template. It explains the problem, scope, rationale, linked issue, testing, compatibility impact, AI disclosure, and checklist status.
  • Fix all pre-merge checks with AI

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Support supplementary composed characters.

key.length !== 1 measures UTF-16 code units, not Unicode code points. For example, a layout that produces U+1D11E has key.length === 2. The predicate returns false, 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.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-option-compose.test.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.ts
  • src/shared/automation-cron-occurrence.ts
  • src/shared/automation-schedule-occurrences.test.ts
  • src/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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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.
@eatmoreduck
eatmoreduck force-pushed the fix/option-compose-kitty-text-20171 branch from 354a111 to 784a19e Compare September 14, 2026 07:08
@eatmoreduck

Copy link
Copy Markdown
Contributor Author

Scope fix pushed (force-push, head is now 784a19e9):

  • Out-of-scope automation changes removed — the branch was mistakenly cut from the #20179 branch instead of main, so three automation DST commits rode along. Rebased onto current main; this PR now touches only the three terminal files. The automation work stays solely in fix(automations): advance cron and hourly schedules past a DST fall-back hour #20179. (That also clears the pre-epoch note in the review — it belonged to those automation changes.)
  • Supplementary-plane fix from the review risk note — isLayoutComposedCharacter now counts code points via Array.from (like the existing isSingleNonAsciiPrintableText predicate), so a length-2 supplementary-plane composition (e.g. 𝕒) is one composed character, not a chord. Added inline comment; the diff is now +57/−32 across 3 files, tests re-run green (73/73).

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one scope note.

Reviewed changes

  • Option-compose text passthrough widened (terminal-option-shortcut-policy.ts): isLayoutComposedAsciiCharacter becomes isLayoutComposedCharacter and drops the <= 0x7e ceiling (now only excluding 0x7f), 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): floorToMinute switches to absolute modulo, and the HOURLY branches of nextAutomationOccurrenceAfter / latestAutomationOccurrenceAtOrBefore walk 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor coverage nit inline.

Reviewed changes

  • Rebased on main and slimmed down: the three unrelated automation DST commits that were present at the previously reviewed 354a111 are 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 from key.length !== 1 to Array.from(key).length !== 1, so a 𝕒-style astral composition is no longer rejected as a chording key. This matches the existing code-point idiom in xterm-bypass-policy.ts and terminal-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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 old key.length !== 1 guard this expectation fails, so the assertion genuinely pins the Array.from(key) code-point counting from 784a19e.
  • 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@eatmoreduck

Copy link
Copy Markdown
Contributor Author

@sembsa the branch is ready for your matrix — apologies for the crossing messages, your offer landed a minute before my comment linking it: eatmoreduck:fix/option-compose-kitty-text-20171 (head 2feff9fd), PR diff is this very PR.

Your planned coverage maps perfectly onto what's testable from it:

  • All nine composed letters under CSI > 5 u with terminalMacOptionAsAlt: "false" — that's flags 5, exactly what the new ą regression test pins
  • macOptionAsAlt: "true" still emitting chords — covered by the new escape-hatch expectation (å → \x1b[97;3u)
  • π / ƒ / ∫ on the chord path — those were the flipped expectations, now typed as text on compose sides (that's the intended change); they remain chords only on Alt-configured sides, so if your muscle-memory OMP-style hotkeys matter, 'true' is the config to check them under
  • report-all / CSI > 29 u associated text — unchanged path, existing tests assert it, but a real-keyboard confirmation would be great anyway

cat -v raw bytes would be ideal. If building from source is a hassle, say so and we can request a CI build artifact or wait for the next RC that carries the branch.

@matematyk60's independent confirmation (queued żżżż flushed at the shell prompt after exiting Claude Code — the encoder swallows the keydown but the text pipeline remembers) is exactly the symptom this fixes, for the record.

@sembsa

sembsa commented Sep 14, 2026 •

Copy link
Copy Markdown

@eatmoreduck Confirmed working on real Polish Pro hardware — thanks for the quick turnaround.

Setup: dev build from eatmoreduck:fix/option-compose-kitty-text-20171 @ 2feff9fd, built natively on macOS arm64 (Node 24.15.0, pnpm 12.0.0), running pnpm dev. Dev profile at its default terminalMacOptionAsAlt: "auto", which on Polish Pro resolves to the compose side.

Result: Polish diacritics now type correctly into a Claude Code pane. łóążćś typed straight into the prompt — before this branch the same keystrokes produced nothing at all.

Unit tests pass locally too: terminal-shortcut-option-compose.test.ts + terminal-shortcut-policy.test.ts → 74 passed (74), 2 files.

Compose-side behaviour of Option hotkeys — matches the intended change

Checked the other half of the trade-off on the compose side, since that's the part the thread was weighing:

input result on auto (compose side) expected per this PR
Option+P inserts Ļ (U+013B) as text — no model-picker hotkey yes — text on compose sides is the intended flip
Option+Enter still inserts a newline yes — Enter composes nothing, so the chord path is untouched

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 auto setting — Option+P is no longer reachable there. In Claude Code that's survivable (Ctrl+J for newline, /model instead of Option+P), but it is a real behavioural change for compose-layout users on the default, not only for people who opt into 'true'.

Still not verified

  • ❌ The macOptionAsAlt: "true" chord path on real hardware. I have not re-tested Option+P under an explicit Alt configuration, so I can't confirm the escape hatch empirically — only that your new test pins å → \x1b[97;3u. Happy to run it if you want that before merge.
  • ❌ Raw cat -v bytes per flag set (>1u / >5u / >29u). Verification here was visual — character appears in the prompt — not byte-level. I have a script ready that walks all nine letters across every flag set and emits the raw bytes as a markdown table; say the word and I'll post the output.

Note for anyone else testing from source

Worth correcting the "local native-rebuild constraints" expectation in the PR description — building this natively on macOS was completely uneventful: pnpm install finished in 27 s with zero errors and node-pty compiled fine (build/Release/pty.node present). pnpm dev needs pnpm on PATH rather than being invoked through corepack pnpm, since the dev script shells out to pnpm run ensure:electron-runtime internally — that was the only snag, and it's a one-line fix (corepack enable pnpm). The dev instance also correctly isolates its profile into Application Support/orca-dev, so it doesn't touch a production Orca install.

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.

@eatmoreduck

Copy link
Copy Markdown
Contributor Author

Yes please — run the matrix. That's exactly the record we want before merge: the nine-letter × off/>1u/>5u/>29u raw-byte table plus the explicit-'true' hotkey check would close nwparker's "no regressions" criterion with real-keyboard evidence, and the byte level pins what visual confirmation can't.

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.

@sembsa

sembsa commented Sep 14, 2026

Copy link
Copy Markdown

@eatmoreduck @nwparker Matrix done — real Polish Pro keyboard, dev build of 2feff9fd, macOS arm64. Every key pressed individually with bytes captured per keystroke (78 measurements), so nothing below is inferred from a visual check.

CSI ? u probe: kitty protocol SUPPORTED — Orca answers it, which is why 2.1.269 turns on >5u here.

Letters — terminalMacOptionAsAlt: "auto" (compose side)

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 : undefined

With 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

No blockers found from this hardware. Happy to re-run anything; the dev build stays up.

@eatmoreduck

Copy link
Copy Markdown
Contributor Author

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:

  • Option+Enter surviving on both sides is worth its weight in the merge discussion — "Option hotkeys bound to text-producing keys stop working" is a much more honest (and smaller) statement of the cost than "Option hotkeys stop working".
  • The >29u associated-text asymmetry is pre-existing and not a merge blocker, so it stays out of this PR's scope. It's your find — your call whether and when to file it; if you do, link it here and I'll weigh in with reproduction details from the policy side (the associatedText conjunct in resolveTerminalOptionShortcutAction is exactly where it lives).

Matrix + summary now referenced from the issue thread. Nothing left blocking on this side.

@coreequip

Copy link
Copy Markdown

Verified on a third layout type: a custom Ukelele layout (input source ID org.sil.ukelele.keyboardlayout.us-german…, US base layer, Option layer composes ä ö ü ß … æ œ ç), terminalMacOptionAsAlt: "auto", macOS Darwin 25.6.0.

  • Dev build of 2feff9fd: Option-composed characters type correctly into Claude Code 2.1.272, launched directly without any output filtering. Claude Code still negotiates CSI < u, CSI > 5 u, CSI > 4;2 m after the CSI ? u reply.
  • Added a local test with the 20 non-dead-key glyphs of this layout's Option layer under flags 1 and 5: 40/40 fail against main's terminal-option-shortcut-policy.ts, 40/40 pass on this branch. The existing suites also pass.
  • Nit: the new test comment says flags 5 = disambiguate + report-event-types. It's disambiguate (1) + report alternate keys (4). Constants are correct, so this is only the comment.

Thanks for the PR!

nwparker added a commit that referenced this pull request Sep 20, 2026
#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]>
@eatmoreduck

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS — Option-composed non-ASCII letters (ç, ñ, å, ø) are swallowed in kitty-protocol TUIs even with "Option as Alt" disabled

3 participants