Repository navigation
fix(plugins): warn when installing a path plugin from a managed workspace - #1566
Merged
SawyerHood merged 1 commit intoAug 14, 2026
Conversation
Collaborator
|
Ohhh man this is horrible! Let me make sure we do this! TY For the PR |
…pace (get-bb#1565) A path-sourced plugin installed from inside a bb-managed workspace (<dataDir>/personal-workspaces/env_*/ or <dataDir>/worktrees/) is silently deleted when that environment is destroyed (e.g. when the owning thread is archived). The env teardown path in packages/host-workspace/src/provision.ts recursively removes the workspace directory with no awareness of registered plugins whose source_path lives beneath it, leaving the plugin permanently "missing (reinstall)" with its source gone. This is the cheapest of the three fixes proposed in get-bb#1565: emit a logger.warn at install time so users know the source is ephemeral and can reinstall from a stable path. It reuses the existing isBbManagedWorkspacePath predicate already used for thread path-claims, and does not change install behavior. Tested: new case in plugin-service.test.ts asserts the warning fires for an install under <dataDir>/personal-workspaces/env_*. Refs get-bb#1565
SawyerHood
force-pushed
the
fix/warn-on-managed-workspace-plugin-install
branch
from
August 14, 2026 20:47
dce1d63 to
d3459d5
Compare
This was referenced Nov 3, 2026
ymichael
added a commit
that referenced
this pull request
Nov 4, 2026
…and say so at install (#6973) ## Human comments ## What was wrong `bb plugin install <path>` registers a plugin by its folder and loads it from there. When an agent built and installed a plugin inside a folder bb later deletes, the plugin broke. One such folder is `$BB_THREAD_STORAGE` (`<dataDir>/thread-storage/<threadId>`), deleted with the thread. The other is a thread's provider-owned workspace (personal workspace or git worktree), deleted when the environment is removed, for example after the thread is archived. The source disappeared and the plugin became "plugin directory not found", then `missing` after a restart. Users weren't warned either. The install-time warning from #1566 was a server log line only, and it didn't cover `thread-storage/`. See #6971 (thread storage, live repro on main) and #6670 (personal workspace, lost on archive). ## What changed **Keep the plugin when bb deletes its folder** - Before the server deletes a thread's storage folder, it calls the plugin service's new `preservePathPluginsInside(directory)`. This covers `requestThreadStorageDeletion` (thread delete, project delete, the lifecycle sweep, Storage Retention) and orphan cleanup. - The environment engine's `runRemove` calls it too, right before the provider's `remove` deletes a workspace it owns. This covers git worktrees and personal workspaces, whether the environment is removed by archive, delete, retirement or `bb environment delete`. - For each path plugin whose folder is inside that directory, it copies the folder to `<dataDir>/plugins/<id>/preserved-source` (staged, then renamed into place). It then moves the install through `installPathSource`, the same flow as `bb plugin install path:<new dir>`, so settings, secrets and schedules are kept. - If the copy fails, bb keeps the folder. Thread-storage deletion logs a warning and is retried on the next sweep. Environment teardown is marked failed and retried with its existing backoff, so the provider's `remove` isn't called. - If the plugin won't start from the copy, the path-move flow keeps the old registration, the copy stays on disk, and the warning names the `bb plugin install` command to run. **Tell the user at install** - `InstalledPlugin` gains `sourceNotice: string | null`, computed by the server for path plugins: - inside thread storage: "Installed from a thread's storage folder. When bb deletes that thread, it copies this plugin to … and runs it from there." - inside a live provider-owned workspace: "Installed from a bb-managed workspace. When bb removes that workspace, it copies this plugin to … and runs it from there." - inside other bb-managed folders (legacy `worktrees/` and `personal-workspaces/`, plugin data dirs), where nothing copies it out: "…where bb can delete it. Reinstall it from a folder outside <dataDir> to keep it." This replaces the old log-only warning. - After the move the notice is `null`, because `preserved-source` is stable. - Surfaces: - CLI: `bb plugin install` and `bb plugin list` print it as `note:`. - App: the install toast becomes a warning toast with the notice, and Plugin details shows it under **Source**. - The server still logs it at install. - The contract field defaults to `null`, so the SDK and CLI still parse responses from older servers. **Other** - Docs: the `bb guide plugins` chapter and the bb-plugin-authoring quickstart. - No daemon or protocol changes. I chose copying at deletion over copying at install. Install-time copying would break the documented in-place `bb plugin install .` + `bb plugin dev` loop. ## How you verified Live, `pnpm start:worktree` + source CLI (`env -u BB_CLI -u BB_SERVER_URL`): - **main:** install from `thread-storage/thr_45jajad99g/…`, then `bb thread delete`. `bb plugin reload storagedemo` fails with `plugin directory not found: …/thread-storage/thr_45jajad99g/bb-plugin-storagedemo (reinstall)`. There's no warning at install. - **Thread storage** (`thr_he4xywtg9e`): - Install prints `note: Installed from a thread's storage folder…`. - After `bb thread delete`, the folder is gone, `storagedemo` is `running` from `…/plugins/storagedemo/preserved-source` with no note, and `greeting = "hello-from-storage"` is kept. - **Personal workspace** (`thr_7c8tcxvmbt`, `env_j2g4g2buh4`): - Install from inside the workspace prints `note: Installed from a bb-managed workspace…`. - After `bb thread delete`, the environment retired, then went `destroyed`/`removed` and the workspace folder was deleted. `wsdemo` is `running` from `…/plugins/wsdemo/preserved-source`, and `bb plugin reload wsdemo` succeeds. - **App:** installed through **Install from source** from a thread's storage. A warning toast "Toast demo installed" shows the notice, and Plugin details shows it under **Source**. Checked at 1280×800 and 390×844. Tests: - `provider-orchestration.test.ts`: - A real path plugin inside a provider-owned workspace has the workspace notice; removing the environment moves it to `preserved-source`, `running`, with no notice. - When the copy fails, the provider's `remove` isn't called and the environment stays `failed` with the error. - `plugin-service.test.ts`: - Thread-storage notice at install, cleared after the move; copy-out keeps a secret setting; a plugin outside the directory is untouched. - When the plugin can't start from the copy, it stays at its old path. - A legacy `personal-workspaces` path gets the "reinstall" notice; a folder a provider only attached to gets none. - `thread-stop-retry.test.ts`: preservation runs before `thread.storage.delete` is queued, and nothing is deleted when it fails. - `PluginInstallJobsHost.test.ts`: a plugin with a notice gets the warning toast with that notice, not the success toast. - `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`: 174/174. Fixes #6971 Fixes #6670 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[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.
Summary
Cheapest of the three fixes proposed in #1565. When a user runs
bb plugin install <path>(orinstallPath) and the resolvedsource_pathlives inside a bb-managed workspace (<dataDir>/personal-workspaces/env_*/or<dataDir>/worktrees/), emit alogger.warnso they know the source is ephemeral — it will be deleted when that environment is destroyed (e.g. when the owning thread is archived).This does not change install behavior; it only surfaces the hazard. It reuses the existing
isBbManagedWorkspacePathpredicate (already used for thread path-claims inworktree-paths.ts), so there's no new concept to maintain.Why
I lost six plugins this way on a single machine (
browser-preview,automaker,file-explorer,prime-agent-ui,terminal-dock,thread-ops), one of them twice. The natural workflow — scaffold a plugin inside the thread's env viabb plugin new, thenbb plugin install .— collides with the normal archive→env-destroy lifecycle. The plugin source is silentlyrm -rf'd byprovisionPersonalWorkspace'sdestroyFn(packages/host-workspace/src/provision.ts:762), leaving a danglingmissing (reinstall)registration.A warning at install time is high-leverage and zero-risk: it teaches the user the model the first time, before any data is lost. The destroy-time guard (option 2 in the issue) is the stronger fix and is worth doing separately, but this PR stands on its own.
Changes
apps/server/src/services/plugins/plugin-registration.ts: ininstallPathSource, after resolvingrootDir, checkisBbManagedWorkspacePath({ dataDir: deps.dataDir, path: rootDir })andlogger.warn(...)if true.apps/server/test/services/plugins/plugin-service.test.ts: new test asserts the warning fires for an install under<dataDir>/personal-workspaces/env_test/....Test plan
pnpm vitest runinapps/server— 19/19 plugin-service tests pass (including the new one)tsc --noEmitcleaneslintclean on both changed filesCloses #1565 (install-time-warning portion).