Skip to content

fix(plugins): warn when installing a path plugin from a managed workspace - #1566

Open
PennybagsCX wants to merge 1 commit into
get-bb:mainfrom
PennybagsCX:fix/warn-on-managed-workspace-plugin-install
Open

fix(plugins): warn when installing a path plugin from a managed workspace#1566
PennybagsCX wants to merge 1 commit into
get-bb:mainfrom
PennybagsCX:fix/warn-on-managed-workspace-plugin-install

Conversation

@PennybagsCX

Copy link
Copy Markdown

Summary

Cheapest of the three fixes proposed in #1565. When a user runs bb plugin install <path> (or installPath) and the resolved source_path lives inside a bb-managed workspace (<dataDir>/personal-workspaces/env_*/ or <dataDir>/worktrees/), emit a logger.warn so 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 isBbManagedWorkspacePath predicate (already used for thread path-claims in worktree-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 via bb plugin new, then bb plugin install . — collides with the normal archive→env-destroy lifecycle. The plugin source is silently rm -rf'd by provisionPersonalWorkspace's destroyFn (packages/host-workspace/src/provision.ts:762), leaving a dangling missing (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: in installPathSource, after resolving rootDir, check isBbManagedWorkspacePath({ dataDir: deps.dataDir, path: rootDir }) and logger.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 run in apps/server — 19/19 plugin-service tests pass (including the new one)
  • tsc --noEmit clean
  • eslint clean on both changed files

Closes #1565 (install-time-warning portion).

…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
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.

Env destroy deletes registered path-sourced plugins (no plugin-source guard before rm -rf)

1 participant