fix: wait for interactive shell before sending pane commands - #193
Open
mvanhorn wants to merge 1 commit into
Open
fix: wait for interactive shell before sending pane commands#193mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
Owner
|
Not sure I want to change the handshake process to poll for all users because one specific prompt implementation has issues (this doesn't appear to be a widespread issue). Maybe it could be an opt-in configuration option. |
Author
|
Fair point — I agree it shouldn't change the handshake for everyone when it's specific to one prompt implementation. Happy to rework this as an opt-in config option (default off) so only users who hit it enable the wait. Want me to go that route? |
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.
Summary
When
workmux addopens a new workbox, pane commands (e.g.nvimor a long-running CLI) flash briefly and never execute for users running an async prompt theme like Pure. The handshake wrapper (TmuxHandshakeinsrc/multiplexer/handshake.rs) signals readiness viatmux wait-for -U <channel>beforeexec <shell> -l, sosetup_paneswrites the command into the PTY while the shell is still initializing. Plain zsh eventually reads the buffered characters, but Pure's zpty-based async workers reset ZLE state during init and flush the terminal input buffer, silently discarding the keystrokes.This moves readiness detection to after the shell is interactive. After the existing
wait()unblocks, a bounded post-exec wait (~5s, matchingHANDSHAKE_TIMEOUT_SECS) pollstmux capture-pane -puntil the pane content is non-empty and stable across two consecutive polls (prompt rendered and init settled), then falls back to the current behavior on timeout so minimal-rc shells are neither slowed nor broken. It is wired into the sharedsetup_panesbetweenhandshake.wait()andsend_keys(...), so all pane commands benefit.Why this matters
The issue includes a self-contained repro that loses the keystrokes with Pure and succeeds without it. The root cause is a race between shell init flushing the input buffer and workmux writing the command; the pre-exec
wait-foronly proves the wrapper reached the exec, not that the shell is ready to read. The fix keeps the change tmux-focused per the issue - the wrapper script is unchanged (echo suppression is still needed) and other multiplexer backends keep their existing handshake semantics through the trait default.Testing
Added
tests/test_workmux_add/test_shell_init.py, which uses a ZDOTDIR with a Pure-style async init that flushes PTY input during startup and asserts the configured pane command still executes. The timeout fallback path preserves current behavior for minimal shells.Fixes #155