Skip to content

fix(web): German Option characters reach the terminal - #74

Draft
macodev00 wants to merge 5 commits into
mainfrom
cursor/german-terminal-option-chars-redo1-008d
Draft

macodev00 wants to merge 5 commits into
mainfrom
cursor/german-terminal-option-chars-redo1-008d

Conversation

@macodev00

Copy link
Copy Markdown
Owner

Problem

On a German Mac layout, @ is Option+L. The desktop terminal (and the web app, which shares this Ghostty surface) forwarded Option as Alt into libghostty-vt. That WASM build is not Darwin, so Ghostty's macos-option-as-alt = false path never runs, and DEC 1036 turns Option+L into ESC @ (readline set-mark). The same encoding drops the rest of that Option layer (€, ~, []{}|, \).

Fixes pingdotgg#13046. Supersedes pingdotgg#13222, which Macroscope re-verdicted Not approved on 2026-10-01: marking Alt consumed still left the raw Alt bit set, and tests never checked the WASM sequence.

Change

A lone macOS Option that produces one character is consumed, and those consumed bits are cleared from the raw modifier mask before encoding. Shift is cleared only when it participated in that Option composition. Ctrl, Meta, Option+arrow, and a lone Shift stay intact, including Shift+letter under modifyOtherKeys mode 2.

There is no Option-as-Meta setting. This matches Terminal.app with "Use Option as Meta key" off, and Ghostty's default. Option+letter chords that previously became ESC plus the unshifted letter now type the composed character.

Clearing the raw Alt bit is required on this build. modifyOtherKeys mode 2 and Kitty report-all still encode a raw Alt bit as Alt even when Alt is also marked consumed. The tests encode all three masks (raw Alt, raw Alt plus consumed Alt, and the mask encodeKey sends) through the vendored WASM encoder.

Scope and approval

Triaged bug pingdotgg#13046 (accepted). The change is the terminal key encoder in the web surface the desktop app embeds. Mobile's native terminal is a different path and is unchanged.

Verification

From apps/web at 5b73e922d, Node 24.13.1:

vp test run --project unit src/terminal/ghostty/keyCodes.test.ts src/terminal/ghostty/runtimeAbi.test.ts src/terminal/ghostty/core.test.ts

Result: 3 files passed, 33 tests passed.

vp run --filter @t3tools/web typecheck

Result: tsc --noEmit passed (exit 0).

vp fmt apps/web/src/terminal/ghostty/keyCodes.ts apps/web/src/terminal/ghostty/keyCodes.test.ts apps/web/src/terminal/ghostty/core.ts apps/web/src/terminal/ghostty/core.test.ts apps/web/src/terminal/ghostty/runtimeAbi.test.ts

Result: finished, no further edits.

The WASM tests assert the encoded bytes, not only the consumed-mod bitmask:

  • Default and Kitty disambiguate: raw Alt encodes ESC @ / CSI 64;3 u; consumed Alt without clearing the raw bit is still an Alt sequence under modifyOtherKeys mode 2 (CSI 27;3;64~). The mask encodeKey sends encodes @.
  • Option+Shift+7 (\): leaving the composing Shift in the raw mask encodes CSI 27;2;92~. Clearing it encodes \.
  • Lone Shift+A under modifyOtherKeys mode 2 stays CSI 27;2;65~.
  • GhosttyTerminalCore.encodeKey on a MacIntel platform writes @, €, |, and \ in the default, modifyOtherKeys, and Kitty disambiguate modes, and the Kitty report-all sequence \x1b[64::108;;64u. Linux and Windows Alt still prefix ESC. Ctrl+C and Option+Left are unchanged.

Not checked: a physical German keyboard or Electron on macOS. The assertions pass a platform string into the same encoder the desktop app uses.

Grok 4.7 via Cursor cloud agent.

Open in Web Open in Cursor 

t3dotgg and others added 4 commits September 30, 2026 23:40
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nup (pingdotgg#14553)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
On macOS, Option+L is @. The terminal forwarded Option as Alt into a
non-Darwin libghostty-vt build, so DEC 1036 sent ESC @. Marking Alt
consumed still left the raw Alt bit set, and modifyOtherKeys mode 2
encoded that as an Alt sequence.

Consume a lone macOS Option that produced a character, and clear those
consumed bits from the raw modifier mask before encoding. Ctrl, Meta,
Option+arrow, and a lone Shift stay intact. There is no Option-as-Meta
setting; this matches Terminal.app with that option off.

Grok 4.7 via Cursor cloud agent.

Co-authored-by: maco <macodev00@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Oct 1, 2026
CodeRabbit docstring coverage on the functions this diff touches was
33.33%. Add JSDoc to the key-encoding helpers and the test functions
beside them. Behavior is unchanged.

From apps/web at Node 24.13.1:

vp test run --project unit src/terminal/ghostty/keyCodes.test.ts src/terminal/ghostty/runtimeAbi.test.ts src/terminal/ghostty/core.test.ts

Result: 3 files passed, 33 tests passed.

vp run --filter @t3tools/web typecheck

Result: tsc --noEmit passed (exit 0).

vp fmt apps/web/src/terminal/ghostty/keyCodes.ts apps/web/src/terminal/ghostty/core.ts apps/web/src/terminal/ghostty/core.test.ts

Result: finished, no further edits.

vp lint apps/web/src/terminal/ghostty/keyCodes.ts apps/web/src/terminal/ghostty/core.ts apps/web/src/terminal/ghostty/core.test.ts

Result: exit 0. One pre-existing warning in ghosttyCellText (unicorn no-new-array).

Grok 4.7 via Cursor cloud agent.

Co-authored-by: maco <macodev00@users.noreply.github.com>

This branch has not been deployed

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

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cannot type @ char in Terminal on MacOS with German Keyboard Layout

3 participants