Skip to content
Source
Sign inSign up
pingdotgg/t3code

Add safe worktree inventory, pruning, and revival #4742

Closedjuliusmarmingewants to merge 1 commit intomain fromt3code/plan-worktree-managementopened View on GitHub

Showing 22 changed files with 187 additions and 0 deletions (loading 18).

x
0 of 22 viewed, 22 left
175 additions and 0 deletions.plans/worktree-management-v1.mdAdded
View file
@@ -0,0 +1,175 @@
+# Worktree Management v1
+​
+## Problem
+​
+t3code creates a worktree per thread (`~/.t3/worktrees/<project>/t3code-<hash>`, branch
+`t3code/<8hex>`) but has almost no lifecycle management. With the settled system, threads
+are rarely deleted anymore, so worktrees accumulate unboundedly (real case: 186 worktrees).
+​
+Current state:
+​
+- No worktree registry. A worktree exists only as the denormalized `worktree_path` column on
+ `projection_threads` (`apps/server/src/persistence/Layers/ProjectionThreads.ts:41`). Nothing
+ records creation time, last use, or dirty state.
+- The only cleanup path is the interactive "delete worktree too?" dialog when deleting the
+ last thread that uses one (`apps/web/src/hooks/useThreadActions.ts:253-397`). It is
+ desktop-only (requires `localApi`), so web users always leak worktrees. `thread.delete`
+ on the server never touches the worktree (`apps/server/src/orchestration/decider.ts:381-401`).
+- `git worktree prune` is never invoked anywhere.
+- Settling (`settled_override`/`settled_at`) is a projection-level soft-hide; it has no effect
+ on the worktree, so settled threads pin their worktrees forever.
+- Checkpoint refs (`refs/t3/checkpoints/...`) live in the shared ref store, not in the
+ worktree's private git dir, so removing a worktree does not lose checkpoints. Branches are
+ likewise repo-level. This is what makes lossless revival possible.
+​
+## Decisions (locked)
+​
+1. **Worktrees only in v1.** No branch deletion, no checkpoint-ref GC. Branches are cheap and
+ keeping them makes revival trivial. Merged-branch cleanup can be a later tier.
+2. **No safety-snapshot-before-delete.** Auto-prune only ever touches *safe* worktrees. Users
+ may force-delete a dirty worktree, but the UI must make clear that this is destructive and