Repository navigation
Add opt-in Storage & retention with durable cleanup - #4476
Conversation
16986b0 to
83b14e1
Compare
|
Since this adds automatic thread deletion, I want to raise a need it touches. What I'm trying to achieve: delete old threads to keep Why it matters for me:
Why I can't cover it with a plugin today: Related: #3598 (undelete).
|
@patleeman tracking your feedback here: #4714 - I'm curious what you'd find useful in the snapshot / feel free to comment on the issue to clarify anything I missed |
2922da2 to
b9e4b93
Compare
9806ea0 to
859ddc9
Compare
86e8023 to
6b2bdf3
Compare
Drop the duplicated page header, show machine online status and a usage summary per machine, replace day inputs with preset selects, and surface pinned-thread protection as a banner. Scans now record the free and total bytes of the thread-storage volume. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Largest threads render as single-line rows with archived and running pills. Machine rows follow Settings → Machines: server pill, status, and per-machine thread counts that need no scan. Drop the retention footer when there is nothing to report. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Thread counts come from the scan, the only source that can attribute storage to a machine: most archived threads no longer reference an environment, so environment-based counts undercount them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The panel owns the data and machine pages read their report from the host list, so moving between the list and a machine renders instantly. The first load shows nothing for 200 ms, then a page-shaped skeleton. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add Scan all and per-machine scan buttons to the machine list, a banner that clears storage of archived threads across scanned online machines, and an archived row in each machine's cleanup list. Pinned and running threads are skipped. Host discard now takes batches of entries. The CLI gains clear-archived and usage --rescan without --machine. Use the new DatabaseRestore icon for the plugin. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clear-archived now targets archived threads holding 100 MB or more, which on real machines covers about 99% of archived bytes while touching a few dozen threads instead of thousands. Reports carry the exact clearable count and size, and the banner moves to the top of the page with copy that says only thread-storage files go and conversations stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Scans now find files of 10 MB or more in thread storage. When archived, unpinned threads hold 1 GB or more of them, the Storage page suggests deleting just those files, keeping smaller files like reports and every conversation. Replaces whole-folder clearing of archived threads; the CLI command becomes clear-large-files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both passes stat every file in thread storage and are kernel-bound, so running them side by side cuts a 5.5M-file scan from about 3.5 to about 2 minutes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The scan now runs du -a once and streams its output, recording files at or above the threshold while summing directory sizes, instead of a separate find walk over the same files. The walker fallback records them too, and deleting large files reuses the same measurement. A scan of 5.5M files costs one du pass again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bundled plugins added after #4576 must use a bb-- id. Rename the package to bb-plugin-bb--storage-retention so the plugin id is bb--storage-retention; the directory and builtin:storage-retention source stay. The plugin has not shipped, so no migration is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pills sat in a flex column beside the title, so a wrapped title left them floating at the right edge. Thread titles in the largest-threads list and the development card now share one ThreadTitle that renders pills inline after the title text, and the development card uses the same archived pill instead of plain text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Clean up rows share one CleanupRow and a SectionHeading, and the bulk development-instance removal moves there from a banner inside the dev card. - Largest-thread rows match development rows: title with inline pills, size and a three-dot menu (Open thread, Clear files) on the right at every width. Clearing still starts immediately; progress and errors show under the title. - Linked threads of one development entry stack one per line, group counts drop the double gap, and pills or size badges that wrap no longer indent. - Scan times read "Scanned 3d ago" everywhere with the exact time on hover, and machine rows say "26.4 GB in 222 dev instances" like the thread total. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Some ~/.bb-dev entries are symlinks into thread storage or temp folders. Removal rejected any non-directory entry, so one symlink aborted the whole batch with "Development instance must be a directory, not a symbolic link". A symlinked entry is now unlinked, keeping the folder it points to, and other non-directory entries are skipped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each killProcessesWithCwdUnder call lists every process working directory (about 120 ms with lsof on macOS), and storage cleanup called it once per entry: roughly 16 s for 133 development instances and minutes for thousands of archived thread folders, so the remove buttons appeared to hang. The helper now takes directories and matches processes under any of them from one listing. Storage & retention passes each whole batch; the daemon, worktree and personal-workspace callers pass their single directory. 133 directories now take one ~120 ms sweep. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ances Thread rows and missing-checkout development rows now have an inline trash button that acts immediately, with a spinner on the button and progress or error text under the title. The ⋯ menu on development rows keeps navigation and path copying; thread rows drop their menu since the title opens the thread. Single-instance removal takes a per-row lock like thread clearing, so different rows can run at once while the bulk Clean up actions stay exclusive, and each removal re-reads the cached scan before updating it so concurrent removals don't overwrite each other. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The right-hand cluster's alignment placeholder was taller than the title line, pushing sizes below their titles and spacing rows apart; both row clusters now sit on the title's line height. An instance linked to several threads shows its first thread with an "Also linked to N other threads" line instead of stacking titles that read like separate rows. Group headings carry their own short description, replacing the footer that only explained "Other instances". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Only instances whose checkout was gone could be removed, so once those were cleared no row had an action. Each row now has the trash button. The host reports an instance as running when its daemon lock (daemon.lock.lock, refreshed every few seconds by proper-lockfile) changed in the last 15 seconds. Removing a single instance (removeDevInstances with names, or --instance) stops servers and removes it when its checkout is gone, removes it when it is not running, and otherwise refuses with "Stop the development server first"; BB never stops servers whose checkout still exists. The bulk Clean up action still removes only missing-checkout instances. The RPC is renamed from removeMissingDevInstances since it is no longer limited to them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Removing one development instance never refuses. When its dev server is
running (fresh daemon lock) and its checkout still exists, a plain removal
leaves it in place and reports it in `running`; the row then asks "Stop and
remove?" and confirming sends SIGTERM to the launcher PID recorded in that
instance's bb-app-runtime.json (SIGKILL after 15 s) before removing it. The CLI
treats --yes as that confirmation. Only the instance's own launcher is stopped,
never other processes in the checkout.
removeDevInstances takes {hostId, names: null} for the bulk missing-checkout
cleanup or {hostId, names, stopRunning} for chosen instances, and the host
contract carries the matching mode instead of a refusal condition.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Re-select each retention group right before archiving or deleting it, so a thread pinned or unarchived during a sweep is kept. - Confirm a development instance's recorded launcher (entry path and start time) before signalling its PID; expose experimental_readProcessIdentity from the Plugin SDK host entry for it. - Drop pending archive cleanups whose thread or machine no longer exists. - Clean development data on environment removal by re-measuring only that machine's ~/.bb-dev, queued behind running maintenance instead of dropped. - Replace a toast-placement UI test with the stop-and-remove request flow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…export
Git-installed plugins are rebuilt on install against the newest matching
SDK without a type check, so a plugin still passing { directory } would
crash at runtime once 0.6.27 is published. The SDK export maps the old
shape to { directories } at runtime while typing only the new one.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The description sat on a re-export line, which bundled declarations drop. A thin wrapper and a local interface carry it into the shipped types. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The machine list built each machine's report from its own full thread and project listing, so three machines and 3,265 threads took about a second per request. The page also requested it twice on open because the realtime connection callback fires immediately on subscribe. Reports now share one listing per request, and the page refreshes only on real reconnects. Measured on a 3-machine instance: hosts RPC 1.0-1.9 s to 0.15-0.25 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pinned archived threads are left out of the archived files total but showed only an archived pill, so their sizes looked unaccounted for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
c3323af to
6acdca3
Compare
Starting a large-file cleanup on all online machines updated its loading toast with toast.message, which keeps sonner's loading type, so it never timed out and no per-machine job ever replaced it. Turn it into an info toast once the jobs start, and show each machine's job as a loading toast while it runs so its completion or failure replaces it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Human comments
What was wrong
BB had no unified way to see storage use across machines, reclaim thread files or abandoned development instances, or opt into automatic retention. Cleanup tied only to live notifications could also lose work while a plugin was disabled, reloading, or its machine was offline.
What changed
bb storagecommands. Reports include hidden threads and link development data to its source checkout where possible.~/.bb-dev, queued behind any scan or cleanup already running there; later scans retry offline/busy machines or failed cleanup. Disabling the plugin stops its schedules and cancels active workers while retaining saved state.Public Plugin SDK changes
bb.events.on("experimental_environment.removed", handler)receives{ removal }after successful provider removal commits. The payload containsenvironmentId,removedAt,hostId,path, andproviderOwnedPath; delivery is ephemeral.PluginThreadEventPayloadsand the fake-host harness support it.experimental_killProcessesWithCwdUnder({ directories, graceMs? })replaces the singulardirectoryinput with a directory list in its types. The SDK export still accepts{ directory }at runtime, because git-installed plugins are rebuilt on install against the newest matching SDK without a type check. Each sweep enumerates processes for the whole batch, including deleted paths resolved through their nearest existing ancestor. It uses SIGTERM then SIGKILL; Windows cwd enumeration remains a no-op.experimental_readProcessIdentity(pid)from@get-bb/plugin-sdk/hostreturns{ command, startedAt }or null, the same probe bb's launcher uses before stopping a recorded PID. Storage & retention uses it to confirm a development instance's recorded launcher (entry path and start time) before signalling it.Plugin-owned RPC and data contracts
state,hosts,host,scanHost,scanAll, andpreview.configureaccepts archive/delete thresholds plusdeleteStorageOnArchiveanddeleteDevDataOnCheckoutRemoval.clearThread,clearArchivedFiles,clearLargeFiles,removeOrphans,retryWorktreeCleanup, andremoveDevInstances. The latter accepts all missing-checkout entries or selected names with explicitstopRunning.startClearLargeFiles,startClearArchivedFiles, andstartCleanup(orphans, development, or worktrees). Machine responses expose cleanup progress/completion/failure.How you verified
turbo run lint typecheck test --filter='...[origin/main]'passes exceptbuiltin-plugins.test.ts > surfaces builtin app build failures…, a file-watch rebuild test unrelated to this plugin that times out only under full parallel load and passes 3/3 in isolation.git diff --checkpasses.Known limits: automation targets have no special retention exemption; pin threads that must be kept. Reports are cached snapshots, and filesystem eligibility is rechecked before cleanup. Windows does not enumerate working directories for process sweeps.