Skip to content

fix: opencode (and kitty-probing TUIs) lose Backspace inside rmux#103

Open
wiwiwa wants to merge 1 commit into
Helvesec:mainfrom
wiwiwa:fix/kitty-keyboard-query
Open

fix: opencode (and kitty-probing TUIs) lose Backspace inside rmux#103
wiwiwa wants to merge 1 commit into
Helvesec:mainfrom
wiwiwa:fix/kitty-keyboard-query

Conversation

@wiwiwa

@wiwiwa wiwiwa commented Jul 14, 2026

Copy link
Copy Markdown

Problem

Backspace does not work for opencode when run inside an rmux pane (Ctrl+Backspace works; plain Backspace is dead). ESC and other keys are fine. Backspace works for opencode in plain xterm and in real tmux.

Root cause

rmux's terminal emulator answered the kitty-keyboard capability query CSI ? u with CSI ? {flags} u, advertising support for the kitty-keyboard protocol. Real tmux 3.x does not answer it.

Probing applications (opencode / Bubble Tea) see the reply, conclude the terminal supports kitty keyboard, and switch into kitty/CSI-u input mode. rmux's kitty key encoding is only partial — trivial keys such as Backspace are always emitted as legacy bytes (0x7f) regardless of mode (input_keys.rs:58). The app therefore expects CSI 127 u and never recognises the bare 0x7f, so Backspace is dropped. Ctrl+Backspace (0x08 → Ctrl-H) survives because most parsers map it to delete independently.

Captured side-by-side from detached panes:

query rmux real tmux 3.6b
CSI ? u (kitty kb query) CSI ? 0 u (answers) no response

A live-attach byte capture confirmed rmux delivers the correct 0x7f for plain Backspace and 0x08 for Ctrl+Backspace, with no stray bytes — so this is not an input-forwarding bug.

Fix

Stop replying to the kitty-keyboard query (CsiCommand::KittyKeyboardQuery → no-op), matching tmux. Probing applications stay in legacy input mode and Backspace works.

Intentionally minimal: the kitty push/set/pop handlers and MODE_KEYS_KITTY tracking are left in place as scaffolding for a future complete kitty-keyboard implementation. A full implementation would also need: per-flag tracking (report-all etc.), a push/pop stack, event-type fields, and CSI-u encoding for trivial keys.

Verification

  • cargo test -p rmux-core --lib907 passed, 0 failed (incl. the updated kitty query test).
  • cargo fmt --all --check → clean.
  • cargo clippy -p rmux-core --all-targets --locked -- -D warnings → clean.
  • Confirmed opencode Backspace works after the fix.

rmux answered the kitty-keyboard capability query (CSI ? u) with the
current mode, signalling support to applications. The kitty key
encoding is partial (trivial keys such as Backspace are always sent as
legacy bytes), so applications that probed and then enabled kitty mode
(notably opencode) mis-parsed Backspace (0x7f). Real tmux does not
answer this query.

Stop replying to the query so probing applications stay in legacy input
mode. The push/set/pop handling is left intact for a future complete
implementation.
@wiwiwa

wiwiwa commented Jul 14, 2026

Copy link
Copy Markdown
Author

This is fix for #102

@wiwiwa

wiwiwa commented Jul 14, 2026

Copy link
Copy Markdown
Author

Closing — the fix did not resolve Backspace in testing. The kitty-query advertisement was not the (whole) cause; needs deeper investigation. Thanks.

@wiwiwa wiwiwa closed this Jul 14, 2026
@wiwiwa
wiwiwa deleted the fix/kitty-keyboard-query branch July 14, 2026 01:27
@wiwiwa
wiwiwa restored the fix/kitty-keyboard-query branch July 14, 2026 01:38
@wiwiwa wiwiwa reopened this Jul 14, 2026
@wiwiwa

wiwiwa commented Jul 14, 2026

Copy link
Copy Markdown
Author

Follow-up: the earlier "didn't work" was operator error — the running rmux daemon (old binary) hadn't been restarted. Verified the fix by running an isolated daemon on a separate socket (-L) from the rebuilt binary: the kitty-keyboard query CSI ? u now returns no response, and Backspace works in opencode under the fixed daemon. Reopening.

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.

1 participant