fix(ssh): let typing leave tmux copy-mode after scrolling up - #355
Merged
Merged
Conversation
Scrolling the wheel up in a persistent session puts our tmux wrapper into copy-mode, whose default key table has no Enter binding, so every keystroke was swallowed until q/Escape (#344). A one-shot exec per persistent connection now binds keys in both copy mode tables to cancel and forward themselves. It runs on its own channel so the size-capped create payload is untouched, waits for the session so a cold server is covered, and re-applies to servers started before this change. tmux 3.4+ gets every printable key; 2.6-3.3 get Enter only, because those versions run a paste's first key through bindings and would drop the bracketed-paste start. q, Escape and C-c keep exiting without forwarding. Also folds the three exec-and-read copies in connect() into exec_collect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #344.
Cause
Persistent SSH sessions run inside our tmux wrapper with
mouse on. Wheel-up puts tmux into copy-mode, and tmux's default (emacs) copy-mode table has noEnterbinding, so keystrokes were silently dropped untilq/Escape. The[25/47880]in the report's screenshot is tmux's copy-mode position indicator.Change
persistent_copy_mode_keys_command(shell_integration.rs): waits for the session, then binds keys incopy-modeandcopy-mode-vitosend -X cancel \; send-keys <key>.q,Escape,C-cand navigation keys are untouched.connect()now shareexec_collect.Verification
Container matrix driving the real payload through an outer tmux pane (raw client input, incl. SGR mouse and bracketed paste), old vs new, on tmux 2.6, 2.7, 3.0a, 3.1c, 3.2a, 3.3a, 3.4, 3.7c:
q/Escape/C-c, arrows/PageUp, wheel back to bottom, click, drag-copy, motion, right-click, non-ASCII input, and bracketed paste into bash (never executes).cargo fmt,clippy -D warningsand the shell_integration tests pass.Live-tested in the headless app (debug build of this branch) against real sshd hosts, driven with X mouse/keyboard events:
[20/364]indicator, and typingecho live-344-ok+ Enter exited copy-mode and ran it.q/Escape/C-cexit with nothing typed;Upand a click stay in copy-mode; wheel-down exits; a multi-line paste via the app's paste path is swallowed and never runs.