Keep worktree archive from detaching external children - #2463
Open
jshph wants to merge 1 commit into
Open
Conversation
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.
User story
As a user coordinating a parent thread with children in separate worktrees, I expect Archive worktree to affect only that worktree. If a child is working somewhere else, archiving the parent's worktree must not silently detach that child and flatten the thread tree.
This came from a real session: one worktree held an orchestrator thread, while nine active child threads used isolated worktrees. Archiving the shared worktree also cleared the parent link on all nine isolated children. The links then had to be restored manually before orchestration could continue.
What was wrong
The environment archive path correctly selected only threads attached to the chosen worktree. However, it archived each selected thread through the ordinary single-thread helper. That helper deliberately releases active children when their parent is archived, without checking which environment those children use.
The result was a scope leak: an action on one worktree changed thread ownership in nine other worktrees. Unarchiving the original worktree also could not restore those links because the ownership changes had already been persisted.
What changed
The archive lifecycle now makes child-release behavior explicit:
There are no wire, daemon protocol, CLI, configuration, or documentation changes.
How you verified
pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-parenting.test.ts— 12 tests passed.pnpm exec turbo run typecheck --filter=@bb/server— passed.get-bb/bb:main(31d66d9d4).