Skip to content

fix(workspace): prune stale registered worktrees on reuse#3028

Open
AllBeingsFuture wants to merge 1 commit into
AgentWrapper:mainfrom
AllBeingsFuture:ao/agent-orchestrator-24/fix-workspace-stale-prune
Open

fix(workspace): prune stale registered worktrees on reuse#3028
AllBeingsFuture wants to merge 1 commit into
AgentWrapper:mainfrom
AllBeingsFuture:ao/agent-orchestrator-24/fix-workspace-stale-prune

Conversation

@AllBeingsFuture

Copy link
Copy Markdown

Problem

Git can still list a worktree after its directory was deleted (stale registration). existingWorktree treated that path as reusable, so Create returned a missing path. Downstream tmux new-session -c then fell back to the tmux server cwd and stranded agents in the wrong directory.

Solution

In existingWorktree, if a registered path is missing or empty:

  1. prune worktrees for the repo
  2. treat the registration as absent (ok=false) so Create re-adds a real worktree

Tests

  • go test ./internal/adapters/workspace/gitworktree/ -count=1
  • TestCreateReusesRegisteredWorktreeAtExpectedPath now seeds the directory on disk (registered-but-missing paths are no longer reused).

Notes

Independence

Can merge independently of the tmux stable-cwd and httpd forced-shutdown fixes.

When git still lists a worktree whose directory is missing or empty,
prune the registration and treat it as absent so Create re-adds a real
worktree instead of reusing a path that strands tmux in the server cwd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant