fix(tmux): fix argument ordering that breaks spawned sessions#899
Closed
ljk53 wants to merge 1 commit intoslopus:mainfrom
Closed
fix(tmux): fix argument ordering that breaks spawned sessions#899ljk53 wants to merge 1 commit intoslopus:mainfrom
ljk53 wants to merge 1 commit intoslopus:mainfrom
Conversation
Three bugs in tmux argument construction cause daemon-spawned sessions
to fail silently:
1. spawnInTmux() appends `-P -F "#{pane_pid}"` AFTER the shell-command
argument. tmux treats everything after the first positional arg as
part of the shell command, so -P is never seen by tmux. The daemon
fails with "Failed to extract PID from tmux output".
Fix: push -P and -F before the shell-command (which must be last).
2. executeTmuxCommand() appends `-t <session>` after all args including
the shell-command. Same POSIX parsing issue — the spawned process
receives `-t <session>` as extra argv and exits immediately.
Fix: build fullCmd with cmd[0] first, insert -t, then append
remaining args with cmd.slice(1).
3. For `new-window`, `-t 0` is ambiguous when the session name is
numeric — tmux interprets it as "target window index 0" rather than
"session named 0", failing with "index in use".
Fix: append `:` to session name for new-window (i.e. `-t 0:`) so
tmux treats it as a session target with auto-assigned window index.
All three bugs are masked because tmux returns exit code 0 and the
daemon silently falls back to regular (non-tmux) process spawning.
Tested on tmux 3.2a, Linux.
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
18b1bbe to
34411c4
Compare
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.
Two bugs in tmux argument construction cause daemon-spawned sessions to fail silently:
executeTmuxCommand() appends
-t <session>AFTER all args including the shell-command positional argument. tmux follows POSIX-style parsing where flags after a positional arg are treated as part of that positional arg. This means the spawned process receives-t <session>as extra argv, causing it to exit immediately. The tmux window is created but dies instantly with no log output.Fix: insert
-tright after the subcommand name, before other args.spawnInTmux() appends
-P -F "#{pane_pid}"AFTER the shell-command argument. Same POSIX parsing issue — tmux never sees -P as its own flag, so it never prints the pane PID. The daemon then fails with "Failed to extract PID from tmux output".Fix: push -P and -F before the shell-command (which must be last).
Both bugs are masked because tmux still creates the window (returning exit code 0), but the spawned process dies immediately. The daemon falls back to regular process spawning, making it appear as if tmux integration silently does nothing.
Tested on tmux 3.2a, Linux.
Generated with Claude Code via Happy