Files
orca/src/renderer
NeilandOrca 6834a980d8 fix(terminal): restore Polish / US-Extended Option+letter composition (#1205) (#1209)
* fix(terminal): restore Polish / US-Extended Option+letter composition (#1205)

The macOptionAsAlt layout probe only inspects `navigator.keyboard.getLayoutMap()`,
which surfaces the base (unshifted) layer. Polish Pro, US Extended, ABC
Extended, and the CJK Roman IMEs all ship a US-QWERTY base layer and put
their dead-key composition on the Option layer — invisible to the
fingerprint. The probe therefore classified them as `'us'`, flipped
`macOptionIsMeta=true`, and xterm.js translated every Option+letter into
an Esc+letter readline chord, silently swallowing ą, ć, ę, ł, etc.

Adds a main-process IPC that reads macOS's
`AppleCurrentKeyboardLayoutInputSourceID` (the same signal Ghostty uses
via TISCopyCurrentKeyboardInputSource) and an explicit denylist of input
source IDs whose Option layer composes. When the active ID is on the
denylist, the probe forces `'non-us'` so `effectiveMacOptionAsAlt`
resolves to `'false'` and Option+letter compositions reach the shell.

Co-authored-by: Orca <help@stably.ai>

* fix(terminal): widen Option+letter composition fix to ABC + all non-US layouts

My earlier attempt at #1205 missed the broader bug: Option+A wasn't working
on the plain "ABC" layout either (Option+A → å got swallowed). Two
corrections:

1. systemPreferences.getUserDefault only reads NSGlobalDomain / the app's
   own domain. AppleCurrentKeyboardLayoutInputSourceID lives in
   com.apple.HIToolbox, so the previous IPC returned null on every
   machine. Switched to execFileSync('/usr/bin/defaults') with a 500ms
   timeout — the same mechanism Apple documents — so the real ID reaches
   the renderer. Verified live: the IPC now returns
   `com.apple.keylayout.ABC` instead of `null`.

2. The denylist approach was too narrow. macOS ships many layouts that
   share a US-identical base layer but compose via Option (ABC, Polish
   Pro, US Extended, ABC Extended, every CJK Roman IME). Flipped to an
   allowlist matching Ghostty: only com.apple.keylayout.US and
   com.apple.keylayout.USInternational-PC get Option-as-Meta; everything
   else defaults to compose. When the IPC returns a concrete ID, the
   classifier is authoritative and the layout fingerprint is skipped;
   the fingerprint only runs as a fallback on non-Darwin / IPC failure.

Verified live in dev: on ABC, Option+A now produces å in the terminal.

Co-authored-by: Orca <help@stably.ai>

* fix(ipc): read keyboard input source ID asynchronously

Avoids blocking the main-process event loop on every focus-in probe
(up to 500ms). Same behavior, same timeout — just non-blocking.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-04-28 00:32:28 -07:00
..
2026-03-17 01:40:24 -07:00