Skip to content

fix(terminal): compose Option keys on the macOS US-International-PC layout - #20164

Closed
ablause wants to merge 1 commit into
stablyai:mainfrom
ablause:fix/us-international-pc-option-compose
Closed

ablause wants to merge 1 commit into
stablyai:mainfrom
ablause:fix/us-international-pc-option-compose

Conversation

@ablause

@ablause ablause commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

ELI5

On the U.S. International - PC keyboard layout, pressing Option+C in an Orca terminal produced nothing at all. No ç, no error, no feedback. Same for Ç, å, and the dead-key accents.

Orca had that layout on the list of keyboards where Option means Alt, so it turned every Option+letter into a readline chord instead of letting macOS compose the character. On a layout whose whole point is typing accented characters, that is the wrong end of the trade.

Problem

classifyInputSourceId allowlists two input sources as Option-as-Meta:

const META_INPUT_SOURCE_IDS: readonly string[] = [
  'com.apple.keylayout.us',
  'com.apple.keylayout.usinternational-pc'
]

With the default terminalMacOptionAsAlt: 'auto', the second entry sends US-International users down this path: classifier returns 'meta' → effectiveMacOptionAsAlt resolves to 'true' → macOptionIsMeta turns on → resolveTerminalOptionShortcutAction emits \x1b + the base character. In a shell, in Claude Code, in Codex CLI, Esc c is a no-op with no output, so the keystroke looks like it was dropped.

This is #1205 again — Polish Pro, ABC, US Extended, all silently swallowed by the same mechanism — on a layout that fix did not cover.

The entry came from Ghostty's allowlist rather than from the layout itself. The shipped keylayout says the opposite; UCKeyTranslate against the active input source:

Key Plain Option Option+Shift
C c ç Ç
A a å Å
E e ´ (dead) ´
N n ˜ (dead) ˜
U u ¨ (dead) ¨

That is a composition layer, structurally identical to the layouts already classified compose. And unlike plain U.S., where the Option glyphs are incidental and nobody selected the layout for them, picking the International variant is itself the statement that accented input matters.

Fix

Drop com.apple.keylayout.usinternational-pc from the allowlist. Plain com.apple.keylayout.US stays the only entry, so nothing changes for US users, who keep Option as Alt.

The fingerprint probe in detect-option-as-alt.ts is untouched: getLayoutMap() only exposes the base layer, which is identical across US, US-International and ABC, so it cannot separate them and still maps every US-shaped layout to true. input-source-id.ts is what narrows that to plain US whenever macOS hands us a real input source ID, and it stays authoritative. Comments in both files now say which one decides what.

Users who prefer the old behaviour set Settings > Terminal > Option as Alt to Both. Users on the fix keep Option+B / Option+F / Option+D word navigation regardless, since terminal-option-shortcut-policy.ts sends those explicitly when Option is not Meta.

Linked Issue

Fixes #20163

Visual Proof

N/A. The observable difference is one character appearing in a terminal where nothing appeared before, so a screenshot shows a ç without showing which keystroke produced it. The mechanical evidence is the UCKeyTranslate table above and input-source-id.test.ts, which pins the exact input source ID.

Testing

macOS 26 (Darwin 25.6.0), Apple silicon, local execution host, input source com.apple.keylayout.USInternational-PC, terminalMacOptionAsAlt left at auto.

Manual, in a terminal pane on a dev build: Option+C → ç, Option+Shift+C → Ç, Option+A → å, Option+E then e → é. Option+B / Option+F / Option+D still move by word, so the readline compensation survives the flip.

  • pnpm test src/renderer/src/lib/keyboard-layout src/renderer/src/components/terminal-pane/terminal-shortcut-option-compose.test.ts src/renderer/src/components/terminal-pane/terminal-option-kitty-release.test.ts src/renderer/src/components/settings — 181 files, 1250 tests, all pass
  • pnpm tc — clean
  • pnpm run check:code-quality:changed — 0 new findings across 3 changed files

input-source-id.test.ts had a case asserting the old behaviour; it now asserts compose for that ID and carries the layout evidence as a comment, so the next person reading the allowlist does not re-add the entry from Ghostty's list.

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

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

macOS-only code path, behind the existing isMac guard. No wire format, no IPC shape, no persisted setting changed, so remote hosts and older clients are unaffected and the setting keeps its four explicit modes plus auto. Windows and Linux never reach this classifier. Anyone who had already set an explicit Option as Alt value keeps it: only auto resolves differently, and only on this one input source.

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)

The macOS input-source allowlist treated com.apple.keylayout.
USInternational-PC as Option-as-Meta, so xterm's macOptionIsMeta turned
on and every Option+letter keystroke became an invisible Esc+letter
readline chord: Option+C never produced ç, Option+Shift+C never
produced Ç.

That layout is a composition layout like the ones issue stablyai#1205 already
fixed. UCKeyTranslate against the shipped keylayout returns ç, Ç, å and
a dead acute for Option+C, Option+Shift+C, Option+A and Option+E. It
stayed in the allowlist only because Ghostty's list was copied verbatim,
and choosing the International variant over plain US is itself a
statement that accented input matters.

Plain com.apple.keylayout.US remains the only allowlisted layout.

@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

  • Drops USInternational-PC from the Option-as-Meta allowlist — META_INPUT_SOURCE_IDS in input-source-id.ts now holds only com.apple.keylayout.us, so the classifier returns 'compose' for the International variant. The probe resolves that to 'non-us', effectiveMacOptionAsAlt('auto', 'non-us') becomes 'false', macOptionIsMeta stays off, and macOS composes ç/å/dead keys again. Verified the full path through option-as-alt-probe.ts:169 → detect-option-as-alt.ts:106 → terminal-appearance.ts:211.
  • Test pins the new behavior — the old allowlists US International PC as meta case now asserts 'compose', with the UCKeyTranslate evidence in the comment. This test would fail against the pre-PR allowlist, so it actually guards the change.
  • Comment updates in both files — detect-option-as-alt.ts now documents that the base-layer fingerprint cannot separate US / US-International / ABC and that input-source-id.ts is the narrowing authority; input-source-id.ts explains why the International variant is deliberately excluded despite Ghostty allowlisting it.

Verified the readline compensation the PR claims: resolveTerminalOptionShortcutAction (terminal-option-shortcut-policy.ts:169-179) still emits \x1b + b/f/d for Option+B/F/D when Option is not Meta, so word-nav survives the flip. Repo-wide grep found no other reference to USInternational, and no test or config asserts the removed behavior.

Pullfrog  | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 11, 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: d321015c-eb78-46fc-b719-fd9255cb445d

📥 Commits

Reviewing files that changed from the base of the PR and between 7294915 and 4e866c4.

📒 Files selected for processing (3)
  • src/renderer/src/lib/keyboard-layout/detect-option-as-alt.ts
  • src/renderer/src/lib/keyboard-layout/input-source-id.test.ts
  • src/renderer/src/lib/keyboard-layout/input-source-id.ts

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


📝 Walkthrough

Walkthrough

The change removes com.apple.keylayout.usinternational-pc from the Option-as-Meta allowlist. classifyInputSourceId now classifies US-International-PC as compose, preserving Option-based character composition. Tests now expect compose for this layout. Related comments describe the plain-US allowlist and the limits of base-layer detection.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 4e866

The narrow macOS keyboard-layout change restores Option-based character composition without affecting explicit settings or plain US behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the terminal behavior fix and the affected macOS US-International-PC layout.
Description check ✅ Passed The description is detailed and covers the change, rationale, linked issue, visual-proof rationale, testing, platform impact, and checklist. It uses Problem and Fix sections instead of the template's …
Linked Issues check ✅ Passed The change satisfies the coding requirements in issue #20163. META_INPUT_SOURCE_IDS now contains only com.apple.keylayout.us, so com.apple.keylayout.USInternational-PC returns compose instead …
Out of Scope Changes check ✅ Passed The pull request changes only the input-source classifier, its documentation, and its focused unit tests. These changes directly support issue #20163. The diff does not change wire formats, IPC, persi…
  • 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.

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]>
@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded by merged PR #21082, which changes the same Option-as-Alt classification and explicitly enables US-International-PC composition; linked issue #20163 is completed.

@nwparker nwparker closed this Sep 27, 2026
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]: Option+C types nothing on the macOS US-International-PC layout

2 participants