diff --git a/.changelog/next/fixed-issue-4284.md b/.changelog/next/fixed-issue-4284.md new file mode 100644 index 0000000000..c2233203d3 --- /dev/null +++ b/.changelog/next/fixed-issue-4284.md @@ -0,0 +1 @@ +- [issue-4284] Worktree cleanup now reports canonical ownership reasons consistently. diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.js index 91c5990792..75f450e140 100644 --- a/server/services/worktreeManager.js +++ b/server/services/worktreeManager.js @@ -1114,13 +1114,7 @@ export async function reapMergedWorktrees(sourceWorkspace, { requireKnownLiveness: true, }); if (ownershipReason) { - const reason = { - 'worktree-human-claim': 'human-claim', - 'worktree-active-agent': 'active-agent', - 'worktree-locked': 'locked', - 'worktree-unmanaged-location': 'unmanaged-location', - }[ownershipReason] || ownershipReason; - skipped.push({ path: wt.path, reason }); + skipped.push({ path: wt.path, reason: ownershipReason }); continue; } if (isClaudeTree && !includeClaudeTrees) { skipped.push({ path: wt.path, reason: 'claude-tree-excluded' }); continue; } diff --git a/server/services/worktreeReap.test.js b/server/services/worktreeReap.test.js index bd3d3aec9e..ac28d2a2fc 100644 --- a/server/services/worktreeReap.test.js +++ b/server/services/worktreeReap.test.js @@ -199,7 +199,7 @@ describe('reapMergedWorktrees', () => { const result = await reapMergedWorktrees(dir, { includeClaudeTrees: true }); expect(result.reaped.map(r => r.branch)).not.toContain('locked-br'); - expect(skipReason(result, path)).toBe('locked'); + expect(skipReason(result, path)).toBe('worktree-locked'); expect(existsSync(path)).toBe(true); }); @@ -213,7 +213,7 @@ describe('reapMergedWorktrees', () => { }); expect(result.reaped.map(r => r.branch)).not.toContain('active-br'); - expect(skipReason(result, path)).toBe('active-agent'); + expect(skipReason(result, path)).toBe('worktree-active-agent'); expect(existsSync(path)).toBe(true); // The main repo checkout is never reported as reaped or skipped-with-branch. expect(result.reaped.find(r => r.branch === 'main')).toBeUndefined();