Repository navigation
Pane(fix[run]): Wait for a new pane's shell - #156
Merged
Merged
Conversation
why: The release rehearsal on master failed with "running a command to
its end needs a POSIX shell in the pane, and it is running 'tmux'". The
staged consumer creates a session and calls Pane.run on its pane at
once. Between fork and exec the process in a pane's terminal is the
server's own copy, so #{pane_current_command} reads "tmux" for a moment,
and Pane.run read it once and refused. The same call passed on the
previous master run, so it is a race, not a change: 3 of 150 reads
straight after new-session -d returned "tmux" on tmux 3.8a.
Alternatives considered:
- Wait in the consumer. Every caller that follows the README, which
runs a command in a pane it just made, has the same race.
- Accept "tmux" as a shell. A pane that really runs tmux would then be
typed into as if it read POSIX syntax.
- Poll for the prompt. The library does not know the shell's prompt.
The wait is bounded, so a pane that stays "tmux" is refused as before,
after the wait.
what:
- Make Pane.run await a name other than "tmux" for up to two seconds
when its first read says "tmux", then read the command and the socket
again before the shell check
- Test it with a pane whose process is a symlink named tmux that sleeps
before it execs a shell: refused with the CI message before the
change, runs the command after it
- Record the measurement in docs/internals/tmux-behaviour.md
why: A caller can observe the change: Pane.run on a pane created a moment ago no longer throws while its shell starts. what: - Add a Fixed entry under Unreleased in libtmux/CHANGELOG.md
tony
force-pushed
the
fix/release-rehearsal-shell
branch
from
November 12, 2026 23:55
ecbdf09 to
75bb1ed
Compare
why: run_shell_command read the pane's command once, as Pane.run did before the previous commit, so a pane created a moment before the call was refused with "run_shell_command requires a POSIX-compatible shell in the target pane; it is running 'tmux'". tmux names a pane "tmux" between fork and exec. The wait added to Pane.run belongs in one place that both callers use, and the MCP server is the outside caller PaneCommand is public for. The cohort read that follows also compares the pane's command before and at dispatch, so a pane that changed from "tmux" to a shell in between would have been refused as changed under the run. Waiting before the first read keeps both reads on the shell. what: - Move the wait out of Pane.run into PaneCommand.awaitShellStart, which waits only when the command it is given is "tmux" and says whether it did, so the caller reads the pane again - Call it from Pane.run and from RunningCommands.run, which resolves the input cohort again after a wait - Add RunningCommandsTest aPaneThatHasNotStartedItsShellYetIsWaitedFor: a pane whose process is a symlink named tmux that sleeps before it execs a shell. It failed before the change with the refusal above, and passes after it - Name the MCP caller in docs/internals/tmux-behaviour.md
why: A caller can observe two changes: run_shell_command on a pane created a moment ago no longer refuses it while its shell starts, and PaneCommand has a new public method both run paths use. what: - Add a Fixed entry under Unreleased in libtmux-mcp/CHANGELOG.md - Add an Added entry for PaneCommand.awaitShellStart under Unreleased in libtmux/CHANGELOG.md
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
Pane.runno longer refuses a pane that was created a moment ago. It waits, for up to two seconds, until tmux names the pane something other thantmux, then runs the usual POSIX-shell check.Root cause
The
release rehearsaljob on master failed in run 43230109896 with:The staged consumer creates a session and calls
Pane.runon its pane at once. Between fork and exec the process in a pane's terminal is the server's own copy, so#{pane_current_command}readstmux.Pane.runread that once andrequirePosixShellrefused it.It is a race, not a regression: the previous master run passed, and 3 of 150 reads straight after
new-session -dreturnedtmuxon tmux 3.8a. libtmux-rs recorded the same window as a just-forked pane namedtmux.The README's
Pane.runexample has the same exposure, so the wait is in the library rather than in the consumer.libtmux-mcp'srun_shell_commandreads the pane command in its own code path and is not changed here.Test plan
PaneRunIntegrationTest.aPaneThatHasNotStartedItsShellYetIsWaitedForfailed before the change with the message above, and passes after itPaneRunIntegrationTestcases pass, includingaPaneNotRunningAShellIsRefused./gradlew :integration-tests:test --tests '*PaneRunIntegrationTest' :libtmux:spotlessCheck :integration-tests:spotlessCheckandpython3 -m tools.ci.checkrelease rehearsalon this branch several times