Repository navigation
Description
Summary
Removing a managed worktree can discard private Git recovery refs or an unfinished Git operation even when HEAD is retained by a local branch and porcelain status is empty.
This differs from #5952's archive-dialog request: a check based on uncommitted or unpushed HEAD state also misses these clean-status cases.
Version and environment
Reproduced through the real Worktree host-entry harness against commit 916d684ac23d0b0de82c09cfc7553a50287d2188. Linux, Node 26.13.0, Git 2.56.0. This is a source-level reproduction, not a claim about every released client.
Reproduction
The disposable Git fixtures are in #6823. They create a linked worktree and either:
- Create a unique commit with
git commit-tree, then retain it only inrefs/worktree/recovery,refs/bisect/recovery, orrefs/rewritten/recovery. - Create a same-tree side commit, then run
git merge --no-ff --no-commit. Porcelain status remains empty, but MERGE_HEAD records the unfinished merge.
To run those fixtures against the original remover in a disposable checkout:
git clone --branch fix/preserve-worktree-on-retirement https://github.com/joeyfrasier/bb.git bb-preservation-repro
cd bb-preservation-repro
pnpm install --frozen-lockfile
git restore --source=916d684ac23d0b0de82c09cfc7553a50287d2188 -- plugins/environment-git-worktree/host.ts plugins/environment-git-worktree/host/worktree.ts
pnpm exec turbo run test --filter=bb-plugin-environment-git-worktree -- -t 'private refs|unfinished merge'Expected and actual
Expected: removal returns failed and preserves the worktree, private refs, and operation metadata until the owner preserves or resolves the work.
Actual: the original handler returns removed and deletes the worktree metadata. The preservation assertions fail with:
AssertionError: expected { status: 'removed' } to match object { status: 'failed' }
Evidence and scope
The original removeWorktree implementation uses forced Git removal plus a recursive filesystem fallback. The regression fixtures exercise the real handler.
The three private-ref cases and clean pending-merge case were reproduced before their guards were added. With the proposed fix, the full Worktree plugin suite passes 136 tests and typechecking. Private refs and merge metadata remain intact.
This report covers provider removal safety. Archive-dialog choices and an atomic barrier against unrelated external writers remain separate work.
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 2, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotworkspaces,confirmed-repro.Preserve worktree-local Git state before retirement (get-bb#6828)