Repository navigation
Description
#316 shipped the whole GC engine — scan, batch clean, retention, disk rollup — and then made retention opt-in. Nobody opted in, so two days later the maintainer's own machine looks like this.
Read-only scan of this machine (2026-08-19)
~/Library/Application Support/Solenta/worktrees 96.0 GB 166 directories
median worktree 709 MB
thread status of those 166 done 162, working 4
archived 161
pinned 0
per project
solenta 119 dirs 57.3 GB
huskyscout 25 dirs 16.0 GB
AppVideo 9 dirs 12.3 GB
Shipnest-v2 12 dirs 9.6 GB
digitalnomads 1 dir 0.6 GB
worktreeRetention setting
solenta undefined
huskyscout undefined
AppVideo undefined
Shipnest-v2 undefined
digitalnomads undefined
enforceRetention runs on every boot sweep and does nothing, by design:
// electron/worktrees.js:3789
const n = Math.floor(Number(project && project.worktreeRetention));
if (!(n > 0)) continue;161 of 166 directories belong to archived threads. Four are live. The app has never reclaimed a byte on the machine it was written on.
A default retention of 10 per project reclaims 64.0 GB of the 96.0 GB, computed against the real store (newest 10 settled per project kept, working/pinned excluded — the same rule gcScan already applies).
Why the default is the whole fix
The engine is already conservative in exactly the ways that make a default safe (gcScan, worktrees.js:3829-3860):
working/quota-waitand pinned threads are never candidatesblockedonuncommitted changesor an unreadable tree, andenforceRetentionfilters!c.blocked- branches are never deleted (
removeGcWorktree, worktrees.js:3870-3879) — GC reclaims directories, every commit stays reachable
So the worst case of a default is "a settled thread's directory is gone and git worktree add recreates it from the branch." That is recoverable. The status quo — 96 GB, growing ~700 MB per finished thread — is not what anyone chose; it is what happens when the knob starts at undefined.
Proposed
- Default
worktreeRetentionto 10 for new and existing projects. One constant plus one store migration inmigrateProject(electron/store.js:827). Keep0as the explicit "keep everything" escape hatch thatupdateProjectalready accepts (services.js:313-321). - Surface the number where it is seen without opening a dialog.
gcScanalready returnsusageandtotalBytesper project. A single line in the project header or settings —worktrees 57.3 GB · 119with a button into the existing GC dialog — is enough. No modal, no nag. - Reclaim on the transition, not only on the boot sweep. The natural moment is thread archive / branch merge, which is when the user has already decided the work is done.
Not proposed: deleting branches, touching dirty trees, or auto-removing anything a human has not been able to see first.
This is the category's open wound, and the engine is already built
block/buzz#5781: one repo's worktree directory hit 164 GB, enough to make the desktop and relay fail; manualgit worktree removeis the only mitigation.anthropics/claude-code#55435: worktree and branch survive session end, success or failure; one manual sweep of 46 stale agent worktrees recovered 10.93 GB.- The GitHub Copilot desktop app (Build 2026) markets "automates the entire worktree lifecycle — creating, separating, and removing" as a headline.
Solenta is the only one of these with the scan, the classifier, the batch clean and the disk rollup already written and tested. It is one default away from being the only one where the problem does not occur.
Tests
migrateProjecton a project without the field yieldsworktreeRetention: 10; an explicit0survives the migration.enforceRetentionwith the default set removes settled worktrees past the newest 10 and skipsblocked/working/ pinned ones (extend the existing Worktree garbage collection with UI: retention limits, batch cleanup, visible disk usage #316 coverage).- Project usage rollup renders in the header without opening the GC dialog.
Related
#316 (the engine this turns on), #213 (worker threads archived but never deleted), #396 (environment contract — provisioning cost is what makes each directory 709 MB), #390 (shared build cache across worktrees — the other half of the same bill), #185 (worktree location/prefix settings).
Activity
currentbits commentedon Aug 20, 2026
Implemented on
coder/fork-worktree-gc-shipped-opt-in-and-is-i-a279bf(this worktree).worktreeRetentionis now 10, persisted bymigrateProject(missing/junk → 10) and stamped onaddProject. Explicit 0 is the keep-everything hatch and survives migration;updateProject(0)stores 0 instead of deleting the key.enforceRetentiontherefore runs on the boot sweep. Same guards as Worktree garbage collection with UI: retention limits, batch cleanup, visible disk usage #316/Reclaim the ~100 GB of stranded worker worktrees (#600 follow-up) #601: skip working / pinned / dirty / unmerged, never delete branches,skipSizesso no Boot sweep spawns 166 parallel du walks over 96 GB on every launch, then discards the result #563dustorm.scheduleRetentionfrom IPC + orchthread_archive/thread_merge).worktrees · N(count from threads that still hold aworktreePath, no disk walk). Click opens Settings → existing GC section. Settings usage rows useworktrees 5.0 MB · 3.Child plan issues: #603 #604 #605.
currentbits commentedon Aug 20, 2026
Landed on main as 7ef4c56.
DEFAULT_WORKTREE_RETENTION = 10moved to electron/store.js and persisted bymigrateProjecton every project (junk/missing → 10). An explicit 0 is now the keep-everything hatch and survives migration.enforceRetentionno longer skips projects riding the default, so boot GC actually reclaims. Guards unchanged: settled only, never working/pinned, never dirty, never unmerged, directories only — branches always survive.git:mergeWorktree/git:removeWorktreeand after orchestratorthread_merge/thread_archive, viascheduleRetention(swallows errors so GC can never fail the user action).Verified: electron worktree-gc-retention / worktree-gc / store / projects-update = 80 pass 0 fail; renderer format / worktreeGc / editProject / sidebar = 94 pass 0 fail.