Skip to content

Reclaim the ~100 GB of stranded worker worktrees (#600 follow-up) #601

Closed

Description

@currentbits

Measured (live store, 2026-08-20)

  • 505 threads, 216 hold a worktreePath, 195 are orchWorker.
  • 191 orch workers are stranded: status done/idle, non-null worktreePath, all 191 archived, 0 pinned.
  • ~/Library/Application Support/Solenta/worktrees = 100 GB / 186 dirs.
  • worktreeRetention is undefined on all five projects.
  • Probe of 40 stranded workers: 15 already gone from disk, 0 dirty, 6 with commits not on main, 19 clean-and-merged.

#600 stopped the bleeding (thread_merge lands + removes a worker going forward). This issue reclaims the existing 100 GB.

Root cause: the GC already exists, it just never classifies anything

gcScan (#316) already walks worktreeBase, sizes each dir with du, and classifies candidates as orphan or retention; WorktreeGcSection already renders a per-project usage table, a per-row checkbox list and a "Delete N worktrees (X GB)" confirm. Nothing new is needed there.

The 191 stranded workers are not orphans — their threads still reference the path — so the only bucket that could catch them is retention, and that bucket is gated on worktreeRetention > 0 (electron/worktrees.js:3916), unset everywhere. They are invisible in the dialog and always have been. isSettledForGc already returns true for all 191 (archived is a settle signal), so the classification works the moment the gate opens.

Plan

  1. DEFAULT_WORKTREE_RETENTION = 10 as the fallback in gcScan's retention classification only. The 191 become visible retention candidates in the existing dialog; per-project setting still overrides.

  2. enforceRetention stays strictly opt-in — no new silent deletion. It is the one path that deletes without a human in the loop (boot, main.js:396). It must keep reclaiming only for projects with an explicit worktreeRetention, so it filters candidates to that set rather than inheriting the new default. It also skips anything with unmerged commits.

  3. Report unmerged commits per candidate. git rev-list --count HEAD ^<default branch> in inspectWorktreeDir (default branch memoized per repo). This is not a blocked reason — GC removes directories and never branches, so the commits stay reachable via the branch ref — but it is the difference between dead weight and work worth keeping, so it must be visible and must not be reclaimed by accident.

  4. UI: unmerged rows are never pre-selected. "Select all" and the initial selection cover clean candidates only; an unmerged row renders N unmerged commits · branch kept and stays untickable-by-default, so reclaiming one is an explicit per-row click. Section shows the reclaimable byte total.

Not doing

Tests

electron/test/worktree-gc-retention.test.js: default retention produces candidates with no project setting; explicit setting overrides; enforceRetention ignores default-retention projects; unmerged count reported and skipped by enforceRetention. Renderer: unmerged row not pre-selected.

Activity

  1. added
    plan:todo
    plan:doing
    and removed
    plan:todo
    on Aug 20, 2026
  2. currentbits commented on Aug 20, 2026

    @currentbits
    OwnerAuthor

    Shipped in 4c9605a.

    Verified against the live store (read-only, skipSizes:false):

    before after
    GC candidates 0 142
    pre-selected (clean + merged) — 114 · 67.0 GB
    held back (unmerged commits) — 27 · 9.0 GB
    blocked (git could not read) — 1
    enforceRetention removes at boot 0 0

    The last row is the one that matters: boot GC is still opt-in, so nothing is deleted without the user opening Settings → Worktrees and confirming.

    The unmerged probe is not a blocked reason — GC removes directories and never branches, so those 27 branches keep every commit either way — but they are never pre-selected and enforceRetention skips them outright.

    Tests: 8 new electron cases + 2 renderer. Confirmed load-bearing: stashing the diff makes the new suite fail, and the 5 remaining electron failures are byte-identical before and after (the #536 baseline).

  3. added
    plan:done
    and removed
    plan:doing
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions