fix: scope close-session grouping to one repo when worktree names collide#1014
Open
SmolSmolStar wants to merge 1 commit into
Open
fix: scope close-session grouping to one repo when worktree names collide#1014SmolSmolStar wants to merge 1 commit into
SmolSmolStar wants to merge 1 commit into
Conversation
…lide Closing a terminal expands to its worktree group so the agent and server terminals live and die together. getSessionGroupIds looked sessions up by BOTH the repo-scoped key (repo-work1) and the bare worktree id (work1). In a mixed-repo workspace where several repos each have a work1 worktree, the bare-key lookup matched every repo's work1 sessions — so clicking the new x close button on one terminal killed every worktree in the workspace (only differently-named worktrees like work4 survived). - getSessionGroupIds: derive repo/worktree via parseWorktreeKey from the session id when the session record lacks them, and query only the repo-scoped key; the bare worktree id is used only when the repository is genuinely unknown (legacy single-repo ids like work1-claude). - tests: regression cases for repos sharing a worktree name, with and without repositoryName on the session records. Reproduced live: closing sandbox-work1-claude destroyed the sessions of agent-workspace/work1, USDUC/work1 and Cat-Code-Academy/work1 as well. Co-Authored-By: Claude Fable 5 <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.
Problem
Closing a terminal with the x close button (or
destroy-session) expands to the worktree group so the agent + server terminals die together.getSessionGroupIdsqueried sessions by both the repo-scoped key (repo-work1) and the bare worktree id (work1).In a mixed-repo workspace where several repos each have a
work1worktree (the default naming), the bare-key lookup matches every repo'swork1sessions. Clicking x on one terminal destroys every worktree's sessions in the workspace (only differently-named worktrees survive).Reproduced live on 0.1.22: closing
sandbox-work1-claudealso destroyed the sessions ofagent-workspace/work1,USDUC/work1andCat-Code-Academy/work1.Fix
getSessionGroupIds: derive repo/worktree viaparseWorktreeKeyfrom the session id when the session record lacks them, and query only the repo-scoped key. The bare worktree id is used only when the repository is genuinely unknown (legacy single-repo ids likework1-claude).getSessionIdsForWorktreeis unchanged, so bare-token lookups from other call sites behave as before.Tests
tests/unit/sessionManager.closeSession.test.js: repos sharing a worktree name stay scoped, with and withoutrepositoryNameon the session records; legacy pair grouping still works.🤖 Generated with Claude Code