Skip to content

Queue storage cleanup and run worktree removal in the background - #6293

Merged
ymichael merged 3 commits into
mainfrom
bb/debug-error-thr_jkz7i2qfni
Oct 26, 2026
Merged

ymichael merged 3 commits into
mainfrom
bb/debug-error-thr_jkz7i2qfni

Conversation

@ymichael

@ymichael ymichael commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Removing an external worktree from Storage held an HTTP request open until Git finished. Large checkouts could exceed BB Connect's 30-second response deadline, and a separate 60-second Git timeout could interrupt deletion. Moving removal into the background exposed another problem: enabled cleanup controls submitted overlapping requests that the server rejected with maintenance-lock errors. Bulk cleanup blocked individual deletions and vice versa, with no queue.

What changed

  • Run external worktree removal in the background without Git's separate 60-second timeout. The host call retains its 30-minute deadline.
  • Queue cleanup requests FIFO per machine instead of rejecting overlapping work. Other machines run independently; duplicate pending background requests reuse their job. Failures release the queue for the next request.
  • Recheck safety when each job executes. Treat targets already removed by an earlier BB job as handled; queueing never grants force-removal or stop-process permission.
  • Show queued/running/result feedback in toasts and keep other controls available. Preserve separate maintenance statuses for different cleanup kinds.
  • Submit thread and development-entry cleanup through startEntryCleanup and poll entryCleanup, so queued UI requests do not hit remote HTTP deadlines. Existing synchronous CLI/RPC commands participate in the queue and return their final results.
  • Update the plugin README and skill documentation. The queue and status history are in memory and are canceled on server shutdown or plugin reload. Queue changes are within the plugin server/UI contracts; they introduce no new daemon wire fields.

How you verified

  • pnpm exec turbo run typecheck test lint --filter=bb-plugin-bb--storage-retention passed; all 79 tests across 4 files passed in an uncached test run.
  • Regression coverage exercises individual → bulk, bulk → individual, duplicate pending requests, independent machines, failure recovery, already-removed targets, and a worktree acquiring uncommitted changes while queued. UI coverage checks the same toast moving through queued/running/completed states and preserves stop-and-remove confirmation.
  • Ran the updated worktree regression against the pre-queue production code: it failed with This worktree is already being removed; it passes after the fix.
  • Live browser verification against pnpm start:worktree: removed disposable worktrees with 100,000 files each, queued an individual removal behind bulk removal, observed queued → success without conflict errors, and confirmed the dirty worktree remained. Checked the resulting server statuses and inspected a screenshot.
  • Server and daemon health checks and git diff --check passed. The verification server remains available for manual testing.

AGENT GENERATED

ymichael and others added 3 commits October 23, 2026 20:20
The Storage page's per-row worktree removal held one HTTP request open
for the whole `git worktree remove`. Through bb connect that request hit
the 30s response deadline and failed with HTTP 504, and the host worker
killed git after its 60s command timeout, leaving multi-GB checkouts
half-deleted with their tracked files shown as uncommitted deletions.

The page now calls startRemoveExternalWorktree, which rechecks the
worktree, returns skipped reasons or "started", and removes it in the
background. Host reports carry externalWorktreeRemovals so the row stays
busy and the page toasts on completion. git worktree remove no longer
has its own timeout; the host call deadline still bounds it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Storage page showed inline "Removing…" lines, row spinners and
progress banners, and disabled the page's cleanup buttons while any
background job or row action ran. Progress, results and failures now
appear only in toasts, and no control locks while work runs; the
server's per-machine lock still rejects a conflicting cleanup, which
surfaces as an error toast. Row actions reuse a caller's toast id and
leave background work's loading toast for the server's result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael ymichael changed the title Run external worktree removal in the background and report cleanup in toasts Queue storage cleanup and run worktree removal in the background Oct 26, 2026
@ymichael
ymichael merged commit 4edabd0 into main Oct 26, 2026
30 checks passed
@ymichael
ymichael deleted the bb/debug-error-thr_jkz7i2qfni branch October 26, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant