fix: clean up stale tmux watchers and prevent duplicate sessions#599
Open
nvandessel wants to merge 1 commit intoasheshgoplani:mainfrom
Open
Conversation
…eshgoplani#595, asheshgoplani#596) asheshgoplani#595: Kill orphaned `tmux -C attach-session` control-mode clients before spawning new ones in PipeManager.Connect(). Previously, each TUI reconnect accumulated watchers because old processes survived in their own process group. asheshgoplani#596: Kill any existing agentdeck tmux session with the same CLAUDE_SESSION_ID before starting a new one, in both Instance.Start() and Restart() paths. This prevents two tmux sessions from running `claude --resume` with the same conversation ID. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
tmux -C attach-sessioncontrol-mode clients before spawning new ones inPipeManager.Connect(). Previously, each TUI reconnect accumulated watchers because old processes survived in their own process group. NewkillStaleControlClients()usestmux list-clientsto find and kill stale control-mode processes.CLAUDE_SESSION_IDbefore starting a new one, in bothInstance.Start()andRestart()paths. NewKillSessionsWithEnvValue()scans agentdeck tmux sessions for matching env vars and kills duplicates.Fixes #595
Fixes #596
Test plan
TestKillStaleControlClients— spawns a real control-mode client, kills it, verifies removal from tmux client listTestPipeManager_ConnectCleansStaleClients— verifiesConnect()cleans stale clients before creating new onesTestKillStaleControlClients_PreservesOwnProcess— safety check that we don't kill ourselvesTestKillSessionsWithEnvValue— creates two sessions with same CLAUDE_SESSION_ID, kills duplicate, verifies correct one survivesTestKillSessionsWithEnvValue_EmptyID— no-op on empty IDTestKillSessionsWithEnvValue_NoMatch— doesn't kill sessions with different IDsgo build ./...passes🤖 Generated with Claude Code