Worktree lifecycle isn't reflected in the agents/sessions menu

Status Open
Maintainer reply None cached
Activity 0 comments · opened Aug 20, 2026

When a session enters a git worktree (EnterWorktree), exits it, and the worktree is torn down, the agents menu shows no trace of any of it.

Repro: a session creates a worktree, works there, exits with keep, then git worktree remove plus a branch delete.

  • The session's own entry never appears in its ListAgents output, so there's no way to see its current working directory.
  • Peer sessions tied to worktrees stay listed for days under their original names after that work shipped and the worktrees were removed — nothing marks them as pointing at a directory that no longer exists.

The information needed is already there. EnterWorktree and ExitWorktree rewrite the session's working directory, and the exit path explicitly invalidates cwd-dependent state (system prompt sections, memory files, plans directory). Both transitions are known to the harness the moment they occur — they just aren't propagated to the session/agents listing.

Expected: entering, moving, or tearing down a worktree updates the session's entry — current directory, and some indication when the worktree it was attached to has been removed.

View original on GitHub ↗