Skip to content

fix(watch): show only the worktrees that are still on disk - #41

Merged
pfriedrix merged 2 commits into
masterfrom
fix/hide-deleted-worktrees
Aug 8, 2026
Merged

fix(watch): show only the worktrees that are still on disk#41
pfriedrix merged 2 commits into
masterfrom
fix/hide-deleted-worktrees

Conversation

@pfriedrix

Copy link
Copy Markdown
Owner
  • The registry a background process leaves behind names every worktree it ever ran in: it never drops a session from its own list, and flushes that list once more on the way out. Four of the six sessions in mine pointed at directories deleted weeks ago, and each one had a row on the dashboard that enter could only open into a directory that is not there. sessions.visible is the single rule now, and both read paths go through it — plus git's own worktree list, which goes on reporting one whose directory was removed until someone prunes it.
  • A session still running in a deleted worktree is dropped with the rest, so lcc open --stop-all is what reaches it. That leaves nothing producing Status.orphan, so the status goes too.
  • A registry row reading unknown no longer counts as a session either. It was hiding the status recovered from the hooks for every worktree its daemon had touched — which is precisely when that file is the only thing left able to report one.

Checked against the same fixtures on master and on this branch: 6 sessions → 2 in lcc open --json; a rm -rf'd worktree that git still lists loses its row; a dead daemon plus a hook file reads ● waiting (1h) instead of ? unknown (56y).

The dashboard listed every worktree a daemon had ever run in. A daemon never
drops a session from its own list and flushes that list once more as it exits,
so its registry file outlives it naming worktrees removed weeks ago — here six
sessions, four of them pointing at directories that were gone. Those rows were
dead ends: enter on one starts an agent in a directory that is not there.

sessions.visible is the rule now, and both read paths go through it — the live
snapshot and the fallback the registry provides. The dashboard puts the same
test on git's worktree list, which goes on reporting a worktree whose directory
was deleted until someone prunes it. A session still running in a deleted
worktree is dropped with the rest, and `lcc open --stop-all` is what ends it;
nothing produces Status.orphan after that, so it goes too.

A registry row reading `unknown` is no longer a match either. It was hiding the
status recovered from the hooks for every worktree its daemon had touched,
which is precisely when that file is the only thing left able to report one.
@pfriedrix
pfriedrix merged commit 0652212 into master Aug 8, 2026
1 check passed
@pfriedrix
pfriedrix deleted the fix/hide-deleted-worktrees branch August 8, 2026 12:31
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