fix(wrapper): add timeouts to tmux send-keys and stop ignoring its exit status - #83
Open
Lafnaps wants to merge 1 commit into
Open
fix(wrapper): add timeouts to tmux send-keys and stop ignoring its exit status#83Lafnaps wants to merge 1 commit into
Lafnaps wants to merge 1 commit into
Conversation
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.
inject()in wrapper_unix.py runstmux send-keystwice (the text, then Enter) withcapture_output=Trueand notimeout=. If the tmux server wedges, the call blocks forever — and it blocks the queue-watcher thread with it, so delivery stops permanently: the watcher monitor only replaces dead threads, and this one is still alive. The wrapper looks healthy while the agent never receives another mention until a manual restart. (capture-paneinget_activity_checkeralready runs withtimeout=2;send-keyswas left unbounded.)The exit status is ignored on both calls, too. When the target session has died,
send-keysfails with rc=1, nothing reaches the composer, and the mention is gone — the watcher had already consumed the queue — with zero diagnostics.This bounds both calls with a 5s timeout and makes the outcome explicit:
"deferred"when tmux positively rejected the text command (nothing reached the composer, a retry is safe),"injected-uncertain"on a timeout or a failed Enter after the text already went in (retyping at that point could duplicate or even submit a half-typed prompt),"injected"when both succeeded. The watcher doesn't act on the result yet — the immediate fix is that a wedged tmux can no longer hang delivery — but the contract is there for a caller that wants to retry the safe case.Test plan: new
tests/test_wrapper_unix_inject.pywith a mockedsubprocess.run— success is reported only when both sends succeed; rc!=0 on the text send is deferred/retryable; a timeout is uncertain. No tmux needed to run them → 2 passed. Full suite: 83 passed (81 on current main).