You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Worktree garbage collection with UI: retention limits, batch cleanup, visible disk usage #316
T3 Code's cautionary tale: a user's state dir hit 8 GB across 20+ invisible worktrees and crash-looped the app; the feature request for per-project retention limits followed. Conductor: archiving could silently fail to delete branches; branch names collided and showed unrelated merged PRs.
Solenta has scripts/prune-worktrees.sh but no in-app GC. Add: per-project retention limits for settled threads, batch cleanup of orphaned worktrees (one dialog, not per-item), collision-safe boring branch names, and visible disk usage per project.
per-project worktree disk usage + total in Settings
one batch-cleanup dialog, one confirm, blocked rows disabled with reason
per-project retention input in Edit Project
Design decision worth recording: GC reclaims directories only, never branches. Conductor's failure mode was archiving that silently failed to delete branches and branch names colliding onto unrelated merged PRs; keeping every branch ref makes GC unable to lose work, and the collision-safe naming fixes the second half.
Four commits: shared contract → UI half → backend half → two integration fixes found by dogfooding.
Backend (electron/worktrees.js)
gcScan: du -sk per directory, orphan vs retention classification, blocked reasons (uncommitted changes / unreadable), per-project usage rollup + total
gcClean: re-scans and only removes what the fresh scan still reports unblocked, so a stale UI selection can never delete live work; clears thread pointers, one broadcast for the batch
enforceRetention runs on the boot sweep after the orphan pass — opt-in, so no limit means no-op. Orphans stay the dialog's job (they deserve a human look)
collision-safe branch names: uniqueCoderBranch checks local and all remote refs, suffixes -2, -3; a rename that finds no free name leaves the placeholder alone
branches are never deleted — GC reclaims directories only, so no commit can be lost to it
per-project usage rows + total in Settings, one batch dialog with pre-selected unblocked candidates, blocked rows disabled with their reason, one confirm reading Delete N worktrees (X MB)
retention input per project; empty/0 = unlimited stays the default
Two gaps found by running the scan against the real state dir
Nothing enforced retention — the scan only surfaced candidates, so a limit applied only when the user opened the dialog. Now enforced on the boot sweep.
isSettledForGc ignored archived. The renderer filters archived threads before the settle split, so they never carry a settled override — and on this machine that was 108 of 127 worktree-holding threads: precisely the invisible worktrees this issue is about. Archived now counts as settled for GC.
Measured on the real state dir (read-only simulation, nothing deleted): 108 worktrees, 58 GB — 7x T3's cautionary 8 GB. Reclaimable at retention=10: 26 GB; at retention=3: 44 GB. Before the archived fix: 0.
Tests: electron/test/worktree-gc.test.js (13 cases), test/worktreeGc.test.tsx, plus store/services coverage. Full suite green — 914/915 electron, the single failure being the pre-existing web-integration reconnect baseline on main; renderer 796/796, core and memory green; tsc --noEmit clean.
Research note (fleet ops, Microsoft's attestation model): extend GC to sprawl attestation — stale automations, abandoned worktrees, dormant threads flagged for periodic keep-or-archive review, not just silent deletion.
Follow-up filed as #559. The engine landed here works; the default did not. Read-only scan of the maintainer's machine two days after this closed: 96.0 GB across 166 worktree directories, 161 of them belonging to archived threads, worktreeRetentionundefined on all five projects, so enforceRetention has been a no-op on every boot sweep (worktrees.js:3789). A default of 10 per project would reclaim 64.0 GB of that, computed against the real store with this issue's own exclusion rules.
Activity
currentbits commentedon Aug 17, 2026
Plan (orchestrated, 2 parallel grok workers)
Landed on main first — shared contract (
Merge worktree GC contract (#316)):src/shared/ipc.ts:GcCandidate,ProjectDiskUsage,GcScanResult,GcCleanInput/Result,ProjectInfo.worktreeRetentiongit:gcScan/git:gcCleanacrosspreload.js,wireClient.ts,ipc.js,devCoder.tsworktrees.gcScan/gcCleanland as empty-result placeholders so main stays green while both halves are builtWorker A — backend engine (
electron/worktrees.js,services.js,store.js,electron/test/*)gcScan: per-directory size (du -sk), orphan vs retention classification,blockedreasons, per-project usage rollupgcClean: re-validates against a fresh scan, batch removal, never deletes a branch (disk only — every commit stays reachable)migrateProject/updateProject-2,-3Worker B — UI (
src/components/*,test/*.tsx)Design decision worth recording: GC reclaims directories only, never branches. Conductor's failure mode was archiving that silently failed to delete branches and branch names colliding onto unrelated merged PRs; keeping every branch ref makes GC unable to lose work, and the collision-safe naming fixes the second half.
currentbits commentedon Aug 17, 2026
Landed on
mainFour commits: shared contract → UI half → backend half → two integration fixes found by dogfooding.
Backend (
electron/worktrees.js)gcScan:du -skper directory, orphan vs retention classification,blockedreasons (uncommitted changes / unreadable), per-project usage rollup + totalgcClean: re-scans and only removes what the fresh scan still reports unblocked, so a stale UI selection can never delete live work; clears thread pointers, one broadcast for the batchenforceRetentionruns on the boot sweep after the orphan pass — opt-in, so no limit means no-op. Orphans stay the dialog's job (they deserve a human look)uniqueCoderBranchchecks local and all remote refs, suffixes-2,-3; a rename that finds no free name leaves the placeholder aloneUI (
src/components/WorktreeGcSection.tsx,EditProjectModal)Delete N worktrees (X MB)Two gaps found by running the scan against the real state dir
isSettledForGcignoredarchived. The renderer filters archived threads before the settle split, so they never carry a settled override — and on this machine that was 108 of 127 worktree-holding threads: precisely the invisible worktrees this issue is about. Archived now counts as settled for GC.Measured on the real state dir (read-only simulation, nothing deleted): 108 worktrees, 58 GB — 7x T3's cautionary 8 GB. Reclaimable at retention=10: 26 GB; at retention=3: 44 GB. Before the archived fix: 0.
Tests:
electron/test/worktree-gc.test.js(13 cases),test/worktreeGc.test.tsx, plus store/services coverage. Full suite green — 914/915 electron, the single failure being the pre-existingweb-integrationreconnect baseline onmain; renderer 796/796, core and memory green;tsc --noEmitclean.Merge pull request #330 from currentbits/coder/worktree-garbage-colle…
Merge origin/main into the observability branch (#280)
currentbits commentedon Aug 17, 2026
Research note (fleet ops, Microsoft's attestation model): extend GC to sprawl attestation — stale automations, abandoned worktrees, dormant threads flagged for periodic keep-or-archive review, not just silent deletion.
currentbits commentedon Aug 19, 2026
Follow-up filed as #559. The engine landed here works; the default did not. Read-only scan of the maintainer's machine two days after this closed: 96.0 GB across 166 worktree directories, 161 of them belonging to archived threads,
worktreeRetentionundefinedon all five projects, soenforceRetentionhas been a no-op on every boot sweep (worktrees.js:3789). A default of 10 per project would reclaim 64.0 GB of that, computed against the real store with this issue's own exclusion rules.