Skip to content

fix(stdin): decode generic modifyOtherKeys / Kitty CSI envelopes#692

Merged
esengine merged 1 commit into
mainfrom
fix/modify-other-keys-printables
May 12, 2026
Merged

fix(stdin): decode generic modifyOtherKeys / Kitty CSI envelopes#692
esengine merged 1 commit into
mainfrom
fix/modify-other-keys-printables

Conversation

@esengine

Copy link
Copy Markdown
Owner

Summary

Under Ubuntu's ghostty, typing @ and _ produces nothing in Reasonix while working everywhere else, including other CLIs on the same terminal. Root cause:

useTerminalSetup writes \x1b[>4;2m (xterm modifyOtherKeys=2) at startup. In that mode, xterm-compatible terminals re-encode any printable key whose Ctrl variant would clash with a control byte — @ (^@=NUL), [ (^[=ESC), \, ], ^, _ — as \x1b[27;<mod>;<cp>~. dispatchCsi only consulted CSI_TAIL_MAP, which has hardcoded entries for Tab/Enter modifier variants but not arbitrary printables. lookupCsi("27;2;64~") returned null, and the parser dropped the sequence on purpose ("Unknown CSI → drop. Do NOT insert raw bytes as text.").

Adds a generic decoder that handles both wire shapes:

  • xterm modifyOtherKeys (formatOtherKeys=0): \x1b[27;<mod>;<cp>~
  • Kitty keyboard protocol: \x1b[<cp>;<mod>u or \x1b[<cp>u

decodeModifiedKey reconstructs printable input, Alt-prefixed input, and Ctrl-letter, mirroring the existing single-byte paths. The new path runs after lookupCsi, so the hardcoded Tab / Enter / Shift+Tab / Ctrl+Enter entries still win — no behavior change for already-handled keys.

Closes #683

Test plan

  • new test cases under tests/stdin-reader.test.ts:
    • @ / _ / [ / \ / ] / ^ via \x1b[27;<mod>;<cp>~
    • @ / _ via Kitty \x1b[<cp>;<mod>u and bare \x1b[<cp>u
    • Alt+letter and Ctrl+letter via modifyOtherKeys
  • npx vitest run — 2657 passed / 2 skipped
  • npm run lint — clean
  • npm run typecheck — clean

Reasonix enables xterm modifyOtherKeys=2 at startup. Under that mode,
terminals re-encode any printable key whose Ctrl variant would produce
a control byte — `@` (^@=NUL), `[` (^[=ESC), `\`, `]`, `^`, `_` — as
`\x1b[27;<mod>;<cp>~`. The parser only had hardcoded entries for the
Tab / Enter modifier sequences, so those printables hit lookupCsi,
returned null, and were dropped silently. Reported under ghostty on
Ubuntu 25.10; the same shape also affects any xterm-compatible host
that honors the mode.

Adds a generic decoder for both the xterm `27;mod;cp~` and Kitty
`cp;mod u` / `cp u` envelopes, mapping back to the keystroke that
would have arrived as a bare byte without the mode.

Closes #683
@esengine esengine merged commit 2a9959c into main May 12, 2026
3 checks passed
@esengine esengine deleted the fix/modify-other-keys-printables branch May 12, 2026 07:52
esengine added a commit that referenced this pull request May 12, 2026
…il, CardStream fix (#705)

npm-only release. The Tauri desktop source is in the repo and the CLI
subcommand works, but installer bundles for macOS / Windows / Linux
don't ship this round (separate release once signing's settled).

Highlights:
- Tauri desktop client with multi-tab concurrent runtimes (#689)
  plus a near-full polish pass: wallet balance, version chip, active-
  plan rail, abortable pause-gates, edit-gate pill, en + zh-CN i18n,
  shared pause-policy module dedup'd with the CLI TUI (#701)
- checkpoint API + git-changes panel in the embedded dashboard (#682)
- outside-sandbox file access approval modal (#696)
- MCP loading pill + readiness gate on tool dispatch (#687)
- escalate-after flag for flash → pro threshold (#699)

Fixes:
- CardStream Maximum-update-depth crash, quantize window so boundary
  cards stop oscillating (#700, #702)
- `reasonix code` bridges config key to env + lazy subagent client so
  fresh installs can reach the setup wizard (#703)
- pinned-mode scroll shrinks coalesced (#666), generic CSI key decode
  (#692), shell-confirm preview clamp (#691), frontmatter BOM/folded
  lines (#690), MCP error classification (#688), and more
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…ngine#692)

Reasonix enables xterm modifyOtherKeys=2 at startup. Under that mode,
terminals re-encode any printable key whose Ctrl variant would produce
a control byte — `@` (^@=NUL), `[` (^[=ESC), `\`, `]`, `^`, `_` — as
`\x1b[27;<mod>;<cp>~`. The parser only had hardcoded entries for the
Tab / Enter modifier sequences, so those printables hit lookupCsi,
returned null, and were dropped silently. Reported under ghostty on
Ubuntu 25.10; the same shape also affects any xterm-compatible host
that honors the mode.

Adds a generic decoder for both the xterm `27;mod;cp~` and Kitty
`cp;mod u` / `cp u` envelopes, mapping back to the keystroke that
would have arrived as a bare byte without the mode.

Closes esengine#683
ChasLui pushed a commit to ChasLui/DeepSeek-Reasonix that referenced this pull request May 23, 2026
…il, CardStream fix (esengine#705)

npm-only release. The Tauri desktop source is in the repo and the CLI
subcommand works, but installer bundles for macOS / Windows / Linux
don't ship this round (separate release once signing's settled).

Highlights:
- Tauri desktop client with multi-tab concurrent runtimes (esengine#689)
  plus a near-full polish pass: wallet balance, version chip, active-
  plan rail, abortable pause-gates, edit-gate pill, en + zh-CN i18n,
  shared pause-policy module dedup'd with the CLI TUI (esengine#701)
- checkpoint API + git-changes panel in the embedded dashboard (esengine#682)
- outside-sandbox file access approval modal (esengine#696)
- MCP loading pill + readiness gate on tool dispatch (esengine#687)
- escalate-after flag for flash → pro threshold (esengine#699)

Fixes:
- CardStream Maximum-update-depth crash, quantize window so boundary
  cards stop oscillating (esengine#700, esengine#702)
- `reasonix code` bridges config key to env + lazy subagent client so
  fresh installs can reach the setup wizard (esengine#703)
- pinned-mode scroll shrinks coalesced (esengine#666), generic CSI key decode
  (esengine#692), shell-confirm preview clamp (esengine#691), frontmatter BOM/folded
  lines (esengine#690), MCP error classification (esengine#688), and more
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.

ubuntu ghostty 下无法输入一些字符(比如 @ _ )

1 participant