Log bugs 2 and 3: agent panel expand and stale worktree issues

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave
2026-02-20 12:47:01 +00:00
parent 1064b50f86
commit 1cd1d318d3
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
---
name: Stale worktree references block agent start
---
# Bug 3: Stale Worktree References Block Agent Start
## Symptom
Starting an agent fails with `git worktree add failed: ... is already used by worktree` even though the worktree directory no longer exists.
## Root Cause
When a worktree directory is deleted externally (e.g., `rm -rf` by another agent or manual cleanup) without running `git worktree remove` or `git worktree prune`, git retains a stale reference. The `create_worktree` function in `worktree.rs` checks if the directory exists (line 43) but doesn't handle the case where git still thinks the branch is checked out in a now-deleted worktree.
## Reproduction Steps
1. Start an agent (creates worktree and branch)
2. Delete the worktree directory externally (`rm -rf`)
3. Try to start an agent for the same story again
4. Observe: `git worktree add` fails because git still references the old worktree
## Proposed Fix
Run `git worktree prune` before attempting `git worktree add` in `create_worktree_sync()`, or handle the "already used" error by pruning and retrying.