Repository navigation
fix(tui): request extended keys from tmux so Shift+Enter arrives - #1251
Conversation
# Conflicts: # crates/jcode-harness-api-server/src/translate_tests.rs # crates/jcode-harness-api/src/lib.rs # sdk/typescript/src/protocol.ts
…20260913 Welcome pull requests from all contributors
jcode only pushed Kitty keyboard flags, which tmux does not treat as a request for extended keys. With the documented `extended-keys on`, tmux collapsed Shift+Enter to a bare CR, so the chord submitted instead of inserting a newline. Only `extended-keys always` worked, which forces reporting for every other application in the server. An outer terminal mapping that sends CSI-u to tmux does not help either: tmux decodes keys and re-encodes them per pane, so the opt-in has to come from the application. Request xterm modifyOtherKeys mode 2 when TMUX is set, reassert it when reapplying terminal modes, and reset it on cleanup. Behavior outside tmux is unchanged. Verified against an isolated tmux 3.7c server with `extended-keys on` and `extended-keys-format csi-u`, sending S-Enter to a raw-mode pane: Kitty push only -> \r modifyOtherKeys + push/set -> \e[13;2u after reset -> \r Closes #1250
|
Two further checks since opening: Cleanup with the real binary. Previously only the enable path was proven end to end. Running the built binary in a tmux pane with Against a real user config rather than a minimal
|
|
|
Re-ran the full check set against the exact pushed commit ( Correction. My first end-to-end runs classified submission by whether
The conclusion is unchanged, and the underlying claim is now backed by a discriminator I checked against real screens rather than an assumed one. Mutation check. Deleting just the two Also on this commit: |
|
Merged into master. Validated the built Jcode TUI inside an attached tmux 3.7c client PTY: physical CSI-u Shift+Enter produces a two-line composer, does not submit a message, and normal Integrated with original PR ancestry and contributor attribution preserved, applying only the actual contribution rather than the divergent old upstream tree. Validation is local targeted testing and isolated public-interface acceptance, not a claim that hosted CI is green. |
Closes #1250
Problem
Inside tmux with the settings
/terminal-setupwrites, Shift+Enter submits instead of inserting a newline:Only
extended-keys alwaysworked, which forces extended-key reporting on every other application in the server.enable_keyboard_enhancement()pushed Kitty keyboard flags but never requested xtermmodifyOtherKeysmode. tmux does not treat a Kitty push as a request for extended keys, so withextended-keys onit collapsed Shift+Enter to a bare CR.Configuring the outer terminal does not help. Mapping Shift+Enter to
ESC[13;2uin Kitty controls only what Kitty sends to tmux. tmux decodes keys and re-encodes them per pane, so the opt-in has to come from the application.Change
Send
ESC[>4;2mwhenTMUXis set, reassert it inreapply_terminal_modes_toalongside the existing Kitty set form, and reset it withESC[>4;0mon cleanup. Behavior outside tmux is byte-for-byte unchanged.The sequences are extracted into small writer-taking functions so the whole lifecycle is testable without a terminal.
Validation
Protocol level. An isolated tmux 3.7c server with
extended-keys onandextended-keys-format csi-u, sendingS-Enterto a raw-mode pane:ESC[>7u)\rESC[>4;2m+ Kitty pushESC[13;2uESC[>4;2m+ Kitty setESC[13;2uESC[>4;0m+ Kitty pop\rEnd to end, running the built binary in a tmux pane with
extended-keys on, typingalpha, pressing Shift+Enter, then typingbeta:TMUXunset): the prompt submitted and the model answeredalpha.alphaandbetasit on two lines of one input box, nothing submitted.Tests. Four unit tests in
tui::terminal_mode_testscover the tmux lifecycle, the unchanged non-tmux lifecycle, reapplication without a second Kitty stack push, and no keyboard sequences when enhancement is disabled. The tmux test fails without the fix.cargo test -p jcode-tui --lib -- terminal_mode_tests terminal_setup shift_enter bare_carriage_return keyboard: 41 passed.Not from this change:
import_continue_reaches_ready_quality_first_openai_modelandrecent_project_review_falls_back_cleanly_when_no_repo_is_knownalso fail on the unmodified base commit, and severalssh_remote_*tests hang in my environment.Notes
TMUXenvironment variable, matching howterminal_setup::diagnosealready detects tmux.ESC[>4;2mis sent unconditionally under tmux rather than after a capability probe, since tmux consumes it and a terminal that does not understand it ignores it.extended-keys on;alwaysis no longer needed.docs/SHIFT_ENTER.mdrecords why terminal-side mappings alone cannot fix this.