t3code icon indicating copy to clipboard operation
t3code copied to clipboard

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

Open mbeckenbach opened this issue 2 months ago • 11 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Ensure to use a German Mac Keyboard layout
  2. Open a Terminal inside t3code desktop app on MacOS
  3. Try to type the @ character

Expected behavior

I should be able to type the @ character in terminal by [option]+[l]

Actual behavior

Nothing happens. Terminal does not seam to receive the typed char.

Impact

Blocks work completely

Version or commit

0.0.43-nightly.20260921.2058

Environment

MacOS 27.0 (26A428)

Logs or stack traces


Screenshots, recordings, or supporting files

No response

Workaround

Not a workaround but additional info: The same issue is also typical for german keyboards in MacOS Terminal App. There you can fix it by unchecking "Use Option as Meta key" in the MacOS Terminal App settings. Possibly similar issue.

mbeckenbach avatar Sep 22 '26 09:09 mbeckenbach

This is a real macOS terminal input bug, and it is not the Shift-@ issue from #5276 / #7485.

On a German Mac layout, @ is Option+L. The desktop terminal (and the web app, which uses the same Ghostty surface) always forwards Option as Alt into libghostty-vt. The WASM encoder is not built as macOS, so Ghostty’s macos-option-as-alt = false path — the one that types the composed character — never runs. alt_esc_prefix (DEC 1036) is on by default, and ghosttyConsumedMods only consumes a lone Shift.

Option+L is therefore sent as ESC @. At a bash/zsh prompt that is set-mark, so no character appears. The same encoding drops the other Option-layer ASCII keys used on this layout ([ ] { } | ~ \). Electron does not set AltGraph for Option, so the existing AltGr bypass in isTerminalAltGraphText does not apply. Option+arrow word motion is handled separately and is not what is eating this key.

Fixing this means treating a lone Option that produced a printable character as composing input (mark Alt consumed, or write event.key directly), which is Terminal.app with “Use Option as Meta key” off. Note that Option+letter Meta chords such as Option+B currently become ESC b through the unshifted-codepoint fallback, so that behavior will change. Setting GHOSTTY_KEY_ENCODER_OPT_MACOS_OPTION_AS_ALT will not help: every key press resets it via setopt_from_terminal, and the WASM build ignores it anyway.

juliusmarminge avatar Sep 22 '26 09:09 juliusmarminge

@juliusmarminge Thanks for checking. I tested some more on my german keyboard here. the issue does not only affect the @ char. It affects also:

  • option+e for €
  • option+n for ~
  • option+number row for chars like []|{}'
  • option+shift+7 for \

mbeckenbach avatar Sep 22 '26 14:09 mbeckenbach

Same problem on a Swedish Mac layout, in the stable build 0.0.42 (T3 Code (Alpha), macOS). Every Option+number combination types nothing in the terminal, so I can't type | (⌥7), @ (⌥2), $ (⌥4), [ ] (⌥8/⌥9) or { } (⇧⌥8/⇧⌥9). Pasting with Cmd+V works.

This looks like the terminal's keydown handler. From the bundled ThreadTerminalDrawer chunk:

function Ft(e){return e.getModifierState(`AltGraph`)&&[...e.key].length===1}
// ...
onKeyDown=e=>{if(Ft(e)||!this.options.beforeKey(e)){this.suppressedKeyCodes.add(e.code);return} ...

Only AltGr is allowed to fall through to text input. On macOS, Chromium reports Option as altKey, never AltGraph, so a composed character like e.key === "|" from ⌥7 doesn't go through the text-input path. It goes through encodeKey with the alt modifier set instead.

A possible fix: on macOS, treat altKey && !ctrlKey && !metaKey && [...e.key].length === 1 the same as AltGraph and send e.key as text. Ghostty's macos-option-as-alt setting could make this opt-out for people who want Option to act as Alt.

jockee avatar Sep 24 '26 13:09 jockee

Finnish layout here on my M5.

My claude came to the following conclusion:

Your keyboard is fine. This is a bug in T3 Code's terminal.

Cause. T3's terminal (a libghostty-vt build compiled to WebAssembly) treats Option as Alt whenever you press it. It ignores the character macOS already produced. I loaded the app's own ghostty-vt-DdA0Zryv.wasm in Node and fed it an Option+7 keypress with the character |:

Terminal state Bytes sent to the shell
Default `ESC
After fish turns on the kitty keyboard protocol ESC[55;3u (Alt+7)

In both cases fish gets an Alt shortcut that has nothing bound to it, so nothing appears. T3 has a check for this, but it only covers the AltGraph key on Windows and Linux. On a Mac, Option never counts as AltGraph, so the check never kicks in. There's no T3 setting to change this. The real fix is upstream: T3 should treat Option as used up when it produced a character. That's worth filing with T3 (pingdotgg/t3code).

wouter-leistra avatar Sep 25 '26 06:09 wouter-leistra

I've opened #19833 to fix this.

Option now types the character your layout puts on that key, which is what Terminal.app and iTerm2 do by default. If anyone would rather have Option act as Alt (for shortcuts like Option+B), there's a new "Option as Alt in terminal" setting with the same options that Ghostty has. The main difference is that Ghostty.app picks its default from the keyboard layout, but we can't reliably do that here.

jcxplorer avatar Oct 15 '26 09:10 jcxplorer

Since fixing this properly requires a new setting, I've started a discussion at https://github.com/pingdotgg/t3code/discussions/21525.

jcxplorer avatar Oct 19 '26 05:10 jcxplorer

Checked current main at b5a226e49c and searched open issues and PRs. No duplicate or open replacement fix found. The earlier fix #19833 was closed pending maintainer agreement on Option/Alt behavior; the existing discussion covers that choice.

This triage environment is Linux x86_64, so I could not run the reported macOS desktop + German keyboard steps. No runtime reproduction or fix is claimed. Verification needed: on current main in macOS desktop, focus the terminal and type Option+L using the German layout; check whether @ appears. The report already provides the layout and affected combinations; no additional reporter details are needed at this point.

juliusmarminge avatar Oct 22 '26 01:10 juliusmarminge

@juliusmarminge Still reproduces on current main (3b95e7831b, which includes b5a226e49c) in the macOS desktop app. With the Finnish layout, Option+7 (|), Option+8/9 ([ ]) and Option+2 (@) don't type anything in the terminal. German Option+L goes through the same code path.

Two PRs fix it:

  • #19833 (mine) fixes it, adds an "Option as Alt" setting for people who want the old behaviour, and also works in Vim. It was closed pending maintainer agreement on the setting, which is what #21525 is for.
  • #21596 is a smaller fix without the setting. It works at the shell prompt but not yet in Vim's insert mode.

I tested both on a Finnish layout.

jcxplorer avatar Oct 22 '26 06:10 jcxplorer

Hey, everything below has been collected by Codex in a T3 Code Nightly thread.

This also affects the Polish Pro macOS keyboard layout when using Helix in T3 Code's integrated terminal.

Environment:

  • T3 Code Nightly 0.1.3-nightly.20261023.3579
  • macOS 26.2
  • Helix 25.07.1 (a05c151b)

Reproduction:

  1. Select the macOS Polish Pro keyboard layout.
  2. Open T3 Code's integrated terminal and run hx /tmp/polish-input.txt.
  3. Press i to enter insert mode.
  4. Press Option+L, Option+Z, Option+X, Option+E, and Option+A.

Expected: łżźęą. Actual: lzxea. The terminal sends Alt shortcuts instead of the composed characters.

artpods56 avatar Oct 27 '26 22:10 artpods56

Same problem on a Slovenian Mac layout. In the T3 Code terminal I can't type | or the other characters that need Option. They work fine in the chat input.

  • T3 Code (Nightly) 0.1.7-nightly.20261101.4035
  • macOS 15.7.7, Apple Silicon

It's still there on the latest nightly. Looking forward to #21596.

hisenb3rg avatar Nov 01 '26 20:11 hisenb3rg

Found a shell-prompt workaround for this:

printf '\033[?1036l'

Confirmed on T3 Code desktop 0.1.7, macOS, connected to a remote Linux machine running zsh. With a custom Slovak-Ubuntu keyboard layout, the usual modifier combinations for special characters did nothing in the integrated terminal, while working in other text inputs. Running the command restored character input.

It disables DEC mode 1036, which adds an Escape prefix to Alt-modified input. Codex also tested the WASM bundled with this exact release: before disabling the mode, the encoder emitted Escape followed by ~, $, or |; afterwards it emitted the plain characters. That was a separate encoder test; the working shell behavior was confirmed with the physical Mac keyboard.

This is a workaround, not a complete fix. It changes Alt shortcut behavior, applies to the current terminal, and can be undone by a reset or an application changing terminal modes. The user also tested Vim: the affected keys still do not work there after running this command. Other applications using advanced keyboard protocols were not tested.

To restore the previous behavior:

printf '\033[?1036h'

Prepared with Codex (gpt-6.1-sol); workaround confirmed by the user.

samochreno avatar Nov 06 '26 23:11 samochreno