Repository navigation
Conversation
The plugin delete route refused every row with builtin provenance, so a builtin dropped from the registry (bb-ai after #4232) could never be removed. Only protect builtins that are still bundled, re-enable the Uninstall action for orphaned builtins in Settings, and have the CLI print the server's 409 message instead of a bare status code. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ymichael
force-pushed
the
bb/investigate-bb-ai-plugin-uninstall-failure-thr_xd5escd86j
branch
3 times, most recently
from
September 24, 2026 18:40
096760b to
bc93555
Compare
ymichael
added a commit
that referenced
this pull request
Sep 24, 2026
## Human comments ## What was wrong When bb stops bundling a built-in plugin, its installed row stays. Startup (`reconcileBundled`) only walks plugins that are currently bundled: it installs new ones and never looks at rows whose built-in is gone. After #4232 reverted #4229/#4230, data dirs that had run those builds kept `bb-ai` and `bb-account` forever, showing as "Missing: Plugin files are missing. Update or reinstall bb." The delete route refuses built-ins, so users couldn't remove them either. #4240 made the manual uninstall possible; this makes cleaning them up by hand unnecessary. ## What changed `apps/server/src/services/plugins/plugin-service.ts`: - After bundled reconciliation and before `loadAll()`, startup deletes every installed built-in whose name is no longer in this build's registry. It uses the existing orphan check behind `isOrphanedBuiltin`, now a shared `isOrphanedBuiltinRow` helper. - It also deletes the plugin's settings, secrets and schedules through the same helper manual removal uses (`deleteRemovedPluginData`, extracted from `remove()`). That includes `onPluginUnregistered`, which re-dispatches queued messages the plugin was holding. - The row is deleted outright rather than tombstoned, so a plugin that is bundled again later installs fresh. - Startup deletes the row only after settings, schedules, and secret cleanup succeeds. If secret removal fails, the row remains so the next startup retries cleanup. - Rows a user already uninstalled (tombstoned) are left alone, because `listInstalledPlugins` skips them. - Each removal is logged: `plugin <id> removed because bb no longer bundles builtin:<name>; its settings, secrets, and schedules were deleted`. - The check compares against the static registry, not what loaded, so a broken or partial build can't delete bundled plugins. No wire or daemon protocol changes. No CLI or UI changes. ## How you verified - `builtin-plugins.test.ts`: the old "marks a persisted builtin as orphaned" test is replaced by "removes a builtin and its data once bb no longer bundles it". It seeds a setting, a schedule and a secret file, restarts without the built-in, and asserts the row, settings, schedule and secrets directory are gone and the list is empty. It then re-bundles and asserts a fresh, enabled install. It fails with the startup call removed and passes with it. - `builtin-plugins.test.ts` also simulates one secret removal failure, confirms the registration remains, then confirms a second startup removes the secret and row. - `pnpm exec turbo run test --filter=@bb/server -- --run test/services/plugins/builtin-plugins.test.ts`: 35/35. - `pnpm exec turbo run typecheck --filter=@bb/server`: clean. - `pnpm exec turbo run typecheck lint --filter=@bb/server`: clean. - `turbo run test --filter=@bb/server -- test/services/plugins`: 521/521. - Live, in a disposable `pnpm start:worktree` instance whose data dir really went through #4230 then the revert, so it had `bb-ai` and `bb-account` rows with their folders missing, plus one seeded `bb-ai` setting. After restarting on this branch, both rows and the setting were gone, the API listed no orphans, `bb-guide` was unchanged, and the server log had both removal lines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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
DELETE /api/v1/plugins/:idreturned 409 for every installed row withbuiltinprovenance, whether or not that plugin was still bundled. Startup reconciliation only walks plugins that are still bundled and never prunes the rest, so a built-in that leaves the registry keeps its row forever.bb-aiis an example: #4230 bundled it and #4232 reverted it. The row can be disabled, butbb plugin uninstall bb-aiand the Settings UI both refuse to remove it. The server already reports these rows asisOrphanedBuiltin: true(added in #673 so they could be removed). The later 409 guard didn't respect that flag, and the UI stopped using it.What changed
apps/server:PluginService.isBuiltinis replaced byisBundledBuiltin, which returns false for orphaned rows.isOrphanedBuiltinand the delete guard now share a single orphan check. Orphaned built-ins go through the existingremovepath, which tombstones built-in rows, so a plugin that is bundled again later stays uninstalled.apps/app: the Uninstall action inPluginDetailand inusePluginRemovalis enabled for orphaned built-ins. Built-ins that are still bundled keep the "Included with BB; disable this plugin instead." message.apps/cli:bb pluginrequests pass 409 bodies through, sobb plugin uninstallprints the server's error instead offailed: HTTP 409.No wire or daemon protocol changes.
How you verified
builtin-plugins.test.ts: a bundled built-in is protected; once dropped from the registry it can be removed; it stays removed after bundling it again. It fails before the fix becauseisBuiltinreturned true for the orphaned row.ToolsView.plugin-detail.test.tsx: Uninstall is enabled for an orphaned built-in and callsonDelete.pnpm exec turbo run typecheck lint --filter=@bb/server --filter=@bb/app --filter=@bb/clipasses.turbo run test --filter=@bb/server -- test/services/plugins/builtin-plugins.test.ts: 35/35.turbo run test --filter=@bb/app -- src/views/ToolsView.plugin-detail.test.tsx src/components/plugin: 548/548.pnpm start:worktreeinstance, fresh data dir, one checkout replaying the real history:2bbdf66124):bb-aiauto-installs as a running built-in.4277998ed7):bb-aiandbb-accountreportisOrphanedBuiltin: true. Source-CLIbb plugin uninstall bb-aiprintsError: /api/v1/plugins/bb-ai failed: HTTP 409, and in Settings the Uninstall action is blocked with "Included with BB; disable this plugin instead."bc93555e80): Uninstall in Settings → confirm removesbb-aiwith a "Plugin uninstalled" toast. Source-CLIbb plugin uninstall bb-accountprintsRemoved bb-account., andbb plugin uninstall bb-guide(still bundled) printsBuilt-in plugins can be disabled, but not deleted.with exit 1. After a server restart and browser reload, both removed plugins stay gone (rows tombstoned withremoved_at) andbb-guideis unchanged.🤖 Generated with Claude Code