fix(tmux-manager): use '|' separator in reconcileSessions#71
Open
TeigenZhang wants to merge 1 commit intoArk0N:masterfrom
Open
fix(tmux-manager): use '|' separator in reconcileSessions#71TeigenZhang wants to merge 1 commit intoArk0N:masterfrom
TeigenZhang wants to merge 1 commit intoArk0N:masterfrom
Conversation
Under non-tty execution contexts (launchd on macOS, systemd without TTY),
tmux emits '\t' in FORMAT strings as the literal two characters `\` + `t`
rather than as a tab. The parser's `line.indexOf('\t')` (a real tab char)
therefore never matches, `activeSessions` stays empty, `reconcileSessions`
returns `alive: []` / `discovered: []`, and `cleanupStaleSessions()` wipes
every entry in `state.json` — even though the underlying tmux sessions are
still alive. On the next startup the user sees an empty session list.
The bug reproduces reliably when codeman is launched via a user LaunchAgent
or a systemd unit without `TTYPath`. Interactive `npm run dev` hides it
because tmux's format parser does interpret `\t` when stdout is a TTY.
Fix: use `|` as the separator. tmux passes it through verbatim in every
environment, and `|` is not a valid tmux session-name character so it
cannot collide with the codeman-<uuid> / claudeman-<uuid> naming scheme.
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
reconcileSessions()invokestmux list-panes -a -F '#{session_name}\t#{pane_pid}'and parses the result withline.indexOf('\t').TTYPath, Dockerexecwithout TTY) tmux emits the\tin FORMAT strings as the literal two characters\+t, not as a tab (0x09). The parser therefore never matches,activeSessionsstays empty,reconcilereturns{alive: [], dead: [], discovered: []}, andcleanupStaleSessions()wipes every entry instate.jsoneven though the underlying tmux sessions are still alive.npm run devhides this because tmux's FORMAT parser resolves\twhen stdout is a TTY.Root cause
Introduced in
88c415f(perf: batch tmux reconciliation) — the regression only manifests in production deployments under launchd/systemd.Fix
Switch the separator to
|. tmux passes it through verbatim in every environment, and|is rejected by tmux's own session-name validation so it cannot collide with thecodeman-<uuid>/claudeman-<uuid>naming scheme.Test plan
[StateStore] Cleaned up N stale session(s) from statewhiletmux lsshows the sessions alive.[Server] Found N alive mux session(s) from previous run→ sessions restored with tokens and attached PTYs.npm run devstill works: create session → kill-restart server → session restored.npm run typecheck/npm run lint/npm run buildall pass.