[Bug] Background session delete always reports "worktree is locked" despite successful cleanup
Bug Description
▎ Deleting a completed background session always reports "not deleted · worktree is locked — in use by another live session, or locked by hand." The lock in .git/worktrees/<name>/locked is held by the deleted session's own host process (a claude bg-spare process whose start time matches the lock timestamp), which is still resident when the job shows Completed. The delete-time cleanup checks the lock before that process exits, so it loses the race every time; seconds later the process exits and its exit path unlocks and removes the worktree successfully. The message is therefore always-firing noise — the "another live session" wording is wrong (it's the session being deleted), and the successful cleanup a moment later is never reported. Suggested fix: on delete, wait for / signal the session process to exit before the lock check, or retry the removal after process exit instead of reporting a terminal "not deleted."
Environment Info
- Platform: darwin
- Terminal: xterm-256color
- Version: 2.1.224
- Feedback ID: 39b82bd9-9930-4644-87e6-d89560b80045
Errors
[]