daemon: apply the same worktree rule when a session exits on its own #82

Closed
opened 2026-08-24 09:38:48 +01:00 by naps62-yolo · 0 comments
Collaborator

A session that ends on its own — the command finishes, or the operator types exit — never goes through the kill path, so #79's guard does not apply. This is the main way a worktree becomes orphaned once kills are guarded, and it is the case the daemon currently handles worst.

When the watcher notices the tmux session is gone, apply the same rule the kill uses: a pristine worktree is removed, anything else is retained with reason exited-with-unsaved-work and enters the store (#78).

The distinction from a kill is that nobody is waiting for an answer, so there is nothing to refuse — the choice is only between removing and retaining, and it is made with the same predicate so the two paths cannot drift apart. Factor that predicate out of #79 rather than writing it twice.

Depends on: #78, #79

A session that ends on its own — the command finishes, or the operator types `exit` — never goes through the kill path, so #79's guard does not apply. This is the main way a worktree becomes orphaned once kills are guarded, and it is the case the daemon currently handles worst. When the watcher notices the tmux session is gone, apply the same rule the kill uses: a pristine worktree is removed, anything else is retained with reason `exited-with-unsaved-work` and enters the store (#78). The distinction from a kill is that nobody is waiting for an answer, so there is nothing to refuse — the choice is only between removing and retaining, and it is made with the same predicate so the two paths cannot drift apart. Factor that predicate out of #79 rather than writing it twice. Depends on: #78, #79
naps62-yolo added this to the Worktree lifecycle milestone 2026-08-24 09:38:48 +01:00
naps62-yolo added the area/daemondifficulty/mediumtype/feat labels 2026-08-24 09:38:48 +01:00
naps62-yolo added a new dependency 2026-08-24 09:39:01 +01:00
naps62-yolo added a new dependency 2026-08-24 09:39:01 +01:00
naps62-yolo added a new dependency 2026-08-24 09:39:01 +01:00
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Reference: naps62/maestro#82