Repository navigation
Storage retention: reliable cleanup status, bulk cleanup by staleness, plain explanations - #7521
Merged
ymichael merged 5 commits intoNov 13, 2026
Conversation
…tuck trash - Keep polling a row cleanup through brief network drops instead of reporting "Failed to fetch" for work that completes. - Toast scan completion and failure only for scans started from the page; hourly and reconnect scans stay silent. - Omit freed space from a combined toast when any completion has no size, instead of showing "0 B freed". - Disable single worktree removal while a bulk worktree removal runs. - Make owner-read-only directories writable before deleting trash, so removed storage no longer reappears as orphaned on the next scan. - Retry every leftover worktree even when one needs manual recovery, and report the ones that could not be retried. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y, plain explanations - Date worktrees created outside BB by when they were last used (latest git activity, uncommitted edits, or linked thread activity) and remove everything unused for a chosen period in one confirmation, optionally keeping ones with uncommitted changes. Row-by-row removal stays. - Remove a whole group of development instances at once, with instances whose threads are all archived in their own group. - Recover leftover checkouts whose cleanup was interrupted, hourly and from Clean up, when they have no uncommitted changes; one confirmation removes the rest. Each row says in plain words why it is kept. - Turning on "Delete thread storage on archive" also clears threads that were already archived, and scans keep that up to date. - Explain when an archived thread can't be cleared because another thread still uses a checkout inside its storage, label worktrees left over from removed BB environments, and count every leftover checkout per project. - Report freed space for orphan, development and worktree cleanups, and treat worktrees that are already gone as removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oasts Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and stop reporting kept checkouts as failures Single-row cleanups (clearing a thread's files, removing a development instance) were followed by polling a per-cleanup status RPC every 500 ms. A dropped bb Connect tunnel made a poll fail, which the page reported as "Failed to fetch" even though the cleanup kept running, and a reload lost track of the cleanup entirely. The server now lists in-flight and recently finished row cleanups in the storage list response and publishes a change notice on every transition. The page waits for a cleanup by watching that list, refreshes after the realtime connection comes back, and marks rows busy from the list, so a cleanup started before a reload or on another device still shows as busy. The polling RPC and its transient-failure retry are removed. Clean up on leftover worktrees reported checkouts it deliberately kept (uncommitted changes, programs still running) as an error toast reading "1 checkout kept: Kept because ...". Kept checkouts are now reported separately from real failures and the cleanup finishes normally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…f on Windows On Windows, chmod only toggles the read-only bit, so a directory chmodded to 0o555 reads back as 0o444 and the fixed expectation failed. The test now records the outside directory's mode before removing the tree and checks it is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/fix-storage-retention-plugin-errors-thr_qjiray8j3c
branch
November 13, 2026 18:53
ymichael
added a commit
that referenced
this pull request
Nov 13, 2026
## Human comments ## What was wrong `bb environment cleanup <id> --recover`, and the storage plugin's automatic recovery, refused on every non-Linux machine. The daemon's check for programs still running in a workspace (`inspectWorkspaceProcesses`) only read `/proc`. On macOS it returned `supported: false`, so the server refused with "process inspection requires Linux". Worktrees whose teardown was interrupted stayed in "Needs recovery" on Macs, and nothing in the UI or CLI could remove them. ## What changed - `apps/host-daemon/src/workspace-processes.ts`: on darwin, finds same-user processes with `/bin/ps`, then reads their cwd, txt and mapped files with `/usr/sbin/lsof`. - The workspace path is canonicalized with `realpath` and matched against lsof's escaped names. - Same-user processes that lsof can't read are reported as unreadable, which refuses recovery, unless they exited or run under another effective UID. - A missing, failing or timed-out `ps`/`lsof` returns `supported: false`, as before. - The result shape and the wire contract are unchanged, so `HOST_DAEMON_PROTOCOL_VERSION` isn't bumped. An older daemon on macOS still reports `supported: false` and the server still refuses. - The server refusal now reads "process inspection is unavailable on this host (supported on Linux and macOS)", and the `--recover` help text matches. - Docs: `bb-guide-environments.md` and `tests/qa/scripts/environment-recovery.md`. **Decision for review: the effective-UID exception.** Every Terminal tab keeps a root-owned `login` process whose cwd lsof can't read. Without the exception, recovery would always be refused while Terminal is open. The cost is that a `sudo` process running inside the workspace isn't detected, though the shell that started it still is. This is independent of #7521, which makes the storage plugin's leftover-worktree cleanup use this recovery path. Without this change, that cleanup keeps Mac checkouts and tells the user to update BB. ## How you verified - `workspace-processes-darwin.test.ts` (new) runs real `ps`/`lsof` against spawned processes. It covers: - processes whose cwd or mapped executable is inside the canonicalized workspace - an unused workspace - lsof-escaped names, without matching sibling paths - refusing rather than reporting a clean workspace when lsof is unavailable - live unreadable same-user processes, while ignoring exited, zombie and other-user setuid processes These tests are skipped on non-darwin runners, so Linux CI won't run them. They pass locally on macOS. - `pnpm exec turbo run typecheck test --filter=@bb/host-daemon --filter=@bb/cli`: 874 daemon tests and 937 CLI tests pass. - Manual check in an isolated dev instance on macOS, with an environment forced into "Needs recovery": - With a Codex session still running in the workspace, `--recover` was refused with "workspace processes remain". - After `bb thread stop`, recovery removed the checkout and the environment was destroyed. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Cleaning up storage on the Storage page produced confusing toasts and errors, and the page often showed stale data:
What changed
All changes are in
plugins/storage-retention. No core or Plugin SDK changes.hostsresponse, and publisheschangedon every transition.entryCleanupRPC and its retry are removed.bb storage cleanup --kind worktrees --include-uncommittedand--kind externalWorktrees --unused-for <days>.On macOS, interrupted checkouts are kept with "BB can't check for running programs yet; update BB on this machine" until #7520 ships. That PR adds the macOS process check that recovery needs.
How you verified
pnpm exec turbo run typecheck test lint --filter=bb-plugin-bb--storage-retention: 103 tests pass and lint is clean. New tests cover:src/leftover-cleanup.test.ts: a kept checkout finishes normally, and only all-failed retries fail.app.test.tsx:src/storage.test.ts:hostsresponsesrc/git-worktrees.test.ts: the last-used date and checkout inspection.src/remove-tree.test.ts: read-only trash, and symbolic links left untouched.pnpm start:worktree) with sample worktrees aged from 2 to 200 days, on desktop, tablet (820 px) and phone (390 px) widths:🤖 Generated with Claude Code