Skip to content

Reclaim plugin caches and run plugin updates in the background - #4681

Merged
ymichael merged 10 commits into
mainfrom
bb/plugin-cache-grows-to-many-gb-duplicated-node-mo-thr_9uskkfyrd8
Oct 7, 2026
Merged

ymichael merged 10 commits into
mainfrom
bb/plugin-cache-grows-to-many-gb-duplicated-node-mo-thr_9uskkfyrd8

Conversation

@ymichael

@ymichael ymichael commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Git-installed plugins retained clone history and obsolete copies of their dependencies. Uninstall left artifact-backed installs on disk, successful updates retained the replaced version for seven days, and users had no explicit cleanup command.

Manual QA also exposed two failures in the install/update journey. Toast swipe handling captured mouse pointers on links, preventing navigation. Plugin updates held their HTTP request open through preparation and a 30-second startup-error observation window, exceeding Connect's 30-second response-header deadline even when activation succeeded.

What changed

  • Remove .git from newly materialized Git plugin artifacts. Reclaim replaced artifacts after a successful update and unused artifacts after uninstall; preserve active, overlapping, shared, and rollback-protected paths.
  • Add bb plugin prune [--dry-run], sdk.plugins.experimental_pruneCache, and the app cleanup command with reclaimed-byte reporting. Keep installed dependencies required for rebuilds.
  • Preserve toast link clicks and touch taps while retaining swipe dismissal.
  • Run updates as server-owned jobs. The app closes confirmation when the job is accepted and shows preparation, activation, startup-check, and rollback progress. Watched jobs resume after refresh, and terminal notifications distinguish success, failure, and rollback.
  • plugins.applyUpdate polls short requests while retaining its existing result contract. Add experimental_startUpdate, experimental_updateJobs.list/get, bb plugin update --no-wait, and bb plugin update-jobs [job-id] [--json]. Raw HTTP callers opt in with Prefer: respond-async; legacy callers retain synchronous responses.
  • Deduplicate active updates for the same plugin and queue different updates. Completed jobs remain for ten minutes. Jobs survive client disconnects, but are in memory and do not survive server restarts. Running activation/rollback cannot be cancelled.
  • Update CLI guidance, Plugin Guide symbols, API audit notes, and Plugin SDK version to 0.6.26. No host-daemon wire change. No Connect timeout-policy change or hosted gateway deployment is needed.

How you verified

Check Result
Rebased cache prune/install/install-job/update suites 102 passed; SDK install/public-contract tests: 12 passed
Background update route regression Fails with the old synchronous route because no response arrives while activation is blocked; passes with 202 and a subsequently readable terminal result
Server update/job/settings suites 46 passed, including existing rollback and data-restoration tests
SDK background updates 5 passed: polling, rollback, failure, immediate job return, older-server compatibility
App dialog and update-job notifications 9 passed, including closing on acceptance and recovering a watched job after remount
CLI update commands 13 passed, including --no-wait and job inspection
Typechecks App, server, CLI, SDK and their required upstream checks passed through Turbo
Production build pnpm start:worktree --dryrun passed; isolated QA server rebuilt and running
Live Chromium install/update Install returned 202 in 26 ms. Update returned 202 in 38 ms, dialog closed in 286 ms, progress recovered after refresh, and success arrived after 30.8 seconds
Live rollback Deliberately broken candidate returned 202 in 31 ms, reported rollback, and restored version 1.1.0 with saved count 3
Live CLI and continued use --no-wait returned a job ID; a later healthy update completed. Counter increment and refresh worked afterward
Toast regression Real browser click failed before the fix and passed afterward; touch tap/swipe checks and 10 existing toast tests passed

Live browser automation used local Chromium against the isolated source app. The user reproduced the original 504 through authenticated remote Chrome; that authenticated session was not automated. Native desktop/iOS/Safari and server-restart job durability are not claimed as verified.

Plugin job notifications now use generic titles, plain display names, and explicit actions. Successful installs/updates open the registered plugin page (or show View details when there is no page); failures expose Details. Retry uses the same asynchronous job flow. The server resolves update display names from the plugin manifest. The 30-second activation safeguard is unchanged.

Toast follow-up verification: 23 focused UI tests and 29 server update tests passed, plus app/server typechecks. The retry regression fails on the prior implementation because Retry stays busy after job acceptance and passes with the shared flow. Live Chromium verified progress after refresh, rollback, retry, the success action, and saved counter state.

The shared Sonner patch now remeasures custom content when it changes. Live repro measured a 68px container around a 92px success card; after the fix both measure 92px and the first mouse click opens the plugin. Install success navigation was also verified after a source-CLI install.

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/plugin-cache-grows-to-many-gb-duplicated-node-mo-thr_9uskkfyrd8 branch 4 times, most recently from 3405e7c to 9f12956 Compare October 6, 2026 21:42
ymichael and others added 5 commits October 6, 2026 16:04
…, add prune

Git-installed plugins kept every version's full clone, including .git and a
complete node_modules. Removal deleted nothing and updates kept the replaced
version for 7 days, both collected only by a later startup GC, and there was
no way to clean up. Plugins scaffolded before SDK 0.5.16 also carry
@hugeicons/* (over 100 MB per copy) in dependencies.

- Verify the checked-out commit inside cloneGitCommit, then delete the clone's
  .git before validation and hashing. New installs always record their ref
  kind, so only pre-existing Phase 1 checkouts are read for ref evidence.
- `bb plugin remove` deletes the plugin's cached versions immediately,
  matching what its help and the guides already promised.
- A successful update deletes the plugin's replaced versions once activation
  has stabilized. The update's state snapshot keeps its 7-day retention.
- Add `bb plugin prune [--dry-run]`, `POST /plugins/cache/prune`,
  `sdk.plugins.experimental_pruneCache`, and a "Clean up plugin cache"
  command-palette entry. Prune deletes every version no installed plugin
  uses and unrecorded cache directories, under the registration lock. It
  keeps active versions, pending rollbacks, installed roots, and staging
  directories.
- node_modules stays: pre-1.0, every SDK version change makes bb rebuild a git
  plugin's server from source, and that build resolves dependencies from it.
- Point plugin authors at the host icon wrapper and how to drop hugeicons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/plugin-cache-grows-to-many-gb-duplicated-node-mo-thr_9uskkfyrd8 branch from 9ffe8c5 to b9aad18 Compare October 6, 2026 23:06
@ymichael ymichael changed the title Reclaim plugin cache disk: drop clone history, delete unused versions, add prune Reclaim plugin caches and run plugin updates in the background Oct 6, 2026
@ymichael
ymichael merged commit faff9cd into main Oct 7, 2026
48 checks passed
@ymichael
ymichael deleted the bb/plugin-cache-grows-to-many-gb-duplicated-node-mo-thr_9uskkfyrd8 branch October 7, 2026 02:34
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