Skip to content

Settings > Storage: disk use per machine, worktrees with their threads, delete a worktree - #59

Merged
ziyadakl merged 5 commits into
custom-v2from
storage-panel
Nov 6, 2026
Merged

ziyadakl merged 5 commits into
custom-v2from
storage-panel

Conversation

@ziyadakl

@ziyadakl ziyadakl commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

New Settings > Storage page, one block per machine in scope:

Disk                                   245 MB  ⟳
[██████████████████████████▒▒▒░]
● Worktrees 220 MB  ● Database 22.1 MB  ● Logs 3.05 MB  ● Other 320 KB

Worktrees                 (largest first)
tokenmaxxing              2.1 GB   🗑
  <thread title>  → opens the thread
  <archived thread title> (muted)
career-ops                840 MB   🗑
  t3/ab12cd34     (branch, when no thread uses it)

Delete asks first. When files would be lost, it says how many ("2 uncommitted files will be lost."). Threads and branches are kept: like storage cleanup, a thread rebuilds its folder when you message it.

storage.getOverview({ refresh? })              cached 60 s, one measurement at a time
  discoverWorktrees(<root>/<project>/<name>)   the same helper removal uses
  walk each worktree (lstat, skip hardlinks)   4 at a time, 30 s cap each
  thread links from the projection snapshot

storage.removeWorktree({ path, allowUncommittedFiles })
  refuse unless: listed by discoverWorktrees, linked worktree, not a symlink,
                 holds no project checkout, no live agent session, no open terminal
  inside the workspace lease (same key as turn start / terminals / cleanup):
    recount uncommitted files → refuse if more than the dialog showed
    removeLinkedWorktree(force only when files > 0)
  bump the cache generation so an in-flight measurement can't resurrect the row

Fork seams (all listed in CUSTOM.md): 6 own files. 15 upstream files get only added registration lines, except one rewritten line: the nav list in settingsSearch.ts. sync-upstream.sh footprint goes from 161 files, +8085 −2322 to 166 files, +8167 −2323.

Evidence

  • Before: you could see worktree sizes only after cleanup removed them (the cleanup's last-run report), and there was no way to delete one by hand.
    After: I ran it live on a dev server with a throwaway T3 home holding two demo worktrees (180 MB, and 40 MB with uncommitted files):
    • The page listed both worktrees, largest first, with a 245 MB total.
    • Delete on the 40 MB one showed "2 uncommitted files will be lost." Cancel had focus by default.
    • Confirming removed the row, and the total dropped to 205 MB.
    • git worktree list no longer showed it, and branch t3/5e6f7a8b was kept.
    • At iPhone width (390 px), nothing wraps or overflows.
  • StorageOverview.test.ts, 6 tests, plus a permission test in RpcAuthorization.test.ts (25/25 across both files):
    • lists a worktree with its size and thread
    • refuses a path outside the roots
    • refuses a path that is too deep
    • refuses when the files changed since the list loaded
    • refuses when a terminal is open
    • removes with the allowed count
    • counts every file inside a new folder (fails on the old status.showUntrackedFiles=normal with "expected 1 to be 3", passes now)
    • storage.removeWorktree is refused before the handler without settings-write permission
  • tsc is clean (contracts, client-runtime, server, web). Lint, fmt and knip are clean. Settings search tests pass 22/22.
  • An Opus review found 6 gaps. All are fixed in 0b701470a: the terminal check, the lease key, the depth limit, the stale count, the cache race, and the dialog copy for orphans.
  • Thermo review (4 axes + Opus merge): 1 blocker, the uncommitted-file count missed files inside new folders (on the VPS, 1 of 59 worktrees showed 1 file where 2 would be lost). Fixed in 1ea289e6f; the narrow re-check found 0 new blockers. Also fixed: dialog copy for worktrees with no branch, and a fresh measurement after a refused delete.

How I proved it: a live dev server on a throwaway T3 home (list, warn, delete, branch kept, phone width), real-git server tests including one that fails on the old code, and tsc and lint clean.

Merge Danger

Door: two-way for the code; one-way for each delete a user confirms.

Reverting the PR removes the page. A worktree deleted through it loses only uncommitted and ignored files (like .env), and the dialog counts the uncommitted ones. Commits stay on the branch.

Blast Radius: contained

The page reads only; nothing runs until someone opens it. Measuring a machine with many large worktrees can take minutes of disk reads (capped at 30 s per worktree). Older servers without the storageOverview capability show an empty page. The menu item always shows.

🤖 Generated with Claude Code

…eletion

Adds storage.getOverview and storage.removeWorktree RPCs (own module in
server/storageOverview), the storageOverview capability, and a Settings >
Storage page at /settings/disk. Upstream files are touched at registration
seams only; CUSTOM.md lists them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… wrong depth and cache races

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s shows in the menu

Every machine runs the fork, so hiding the item for old servers is not
worth three rewritten lines in an upstream file that changes weekly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Nov 6, 2026
…sion test; dialog copy and refresh after a refusal

A new folder of untracked files counted as one line, so the delete dialog
undercounted what a forced delete loses and the stale-count refusal missed
files added inside it. Both counts now use one --untracked-files=all list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng the cached list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ziyadakl
ziyadakl merged commit 3b120d7 into custom-v2 Nov 6, 2026
30 of 31 checks passed
@ziyadakl
ziyadakl deleted the storage-panel branch November 6, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants