Terminal: physical Alt+letter chords are sent as legacy ESC+byte and ignored by programs using modifyOtherKeys (gentle-shell alt+k)
What happened
- Open a pane running Pi with gentle-shell in Ovis's Terminal view (web or Electron) and press
Alt+K, gentle-shell's documented shortcut for/gentle:commands. - Nothing happens. Typing
/gentle:commandsopens the curated command menu. All physical Alt chords tried (Alt+G,Alt+A,Alt+S,Alt+K) do nothing. - Expected: the chord reaches the program in the encoding that program asked for, so
Alt+Kopens gentle-shell's menu.
How often
Every time
Ovis version
0.5.11 locally; keyboard input code is unchanged in v0.5.12.
How it runs
herdr plugin, server at 127.0.0.1:7317
Server PC
Fedora Linux 44 x86_64, herdr 0.9.5
Device and browser
Fedora 44, Chrome/Chromium and the desktop Electron app. Measured in headless Chromium at 1280 px against the live gentle-shell pane.
Evidence
- The browser does deliver the key:
keydown(code=KeyK, altKey=true, defaultPrevented=false), and the app sends{"type":"input","pane_id":"wG:pJ","text":"\u001bk"}— legacyESC k. - Against that same gentle-shell pane, measured independently:
- raw
ESC k→ no menu; {"type":"keys","pane_id":"wG:pJ","keys":["alt+k"]}→ the command menu opens;- raw
CSI 27;3;107~(modifyOtherKeys for Alt+K) → the command menu opens.
- raw
- Pi negotiates the Kitty keyboard protocol on startup. Ovis deliberately does not answer that request (
src/lib/ghostty/terminal.ts:189: "the input layer encodes keys as xterm does, which knows no Kitty keyboard protocol"), so Pi falls back to modifyOtherKeys withCSI >4;2m. Ovis tracks that mode insrc/lib/useTerminalMount.tsbut only uses it to rewrite Ctrl+Enter; physical Alt chords still travel as xterm'sESC + letter. src/lib/useTerminalMount.ts:339-357:attachCustomKeyEventHandleronly builds a named chord when the sticky modifiers from the key bar are held (hasModifiers(modifiersRef.current)); a realevent.altKeyis left to xterm.src/lib/useTerminalMount.ts:1735-1737and:1655-1667: the named-chord path (socket.sendKeys→{"type":"keys",...}) exists and is what the key bar's sticky Alt uses; that path works.
Proposal
When a physical chord carries altKey (and the pane has requested a keyboard protocol such as modifyOtherKeys/Kitty), derive it with terminalChord and send it through socket.sendKeys instead of xterm's raw ESC + byte. Keep the legacy encoding for panes that never asked for a keyboard protocol. That makes the hardware key behave like the key bar's sticky Alt, which already works.
Workarounds today
/gentle:commands, or add a K key with the Alt modifier to the key bar and use sticky Alt+K (verified to open the menu).
Relation
#4653 (unbindable Alt chords, fixed by #4793 in v0.5.12) and #4893 (Electron's Alt reveals the native menu bar) are other layers. Here the chord reaches Ovis but is encoded in a mode the program no longer uses.
Thanks for the precise report. Reproduced on main: the pane's program asks for modifyOtherKeys level 2, herdr passes that request on to the browser, and Ovis already tracked it, but only used it for Ctrl+Enter, so a physical Alt+K still went out as ESC k. Native Ghostty and xterm send CSI 27;3;107~ in that mode. #4937 (merged as 9da0576ab0) sends Alt+character that way while the program has level 2 on, and leaves every other program's bytes unchanged. Option+Left/Right on macOS keep sending ESC b / ESC f. Panes drawn without a PTY host (mirrored panes, e.g. Windows) still send ESC+letter for now.