Skip to content

Make the built-in plugins with settings sections forkable - #4190

Merged
SawyerHood merged 1 commit into
bb/forkable-08-chat-surfacesfrom
bb/forkable-09-settings
Sep 23, 2026
Merged

SawyerHood merged 1 commit into
bb/forkable-08-chat-surfacesfrom
bb/forkable-09-settings

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Eighth PR in the forkable built-ins stack; it builds on #4189. Five built-ins that contribute Settings sections couldn't be copied out of the repository: keep-awake, concurrency-limit, memory, provider-usage, and account-pool.

Beyond the shared-ui imports and vitest.shared.ts:

  • SDK paths in tsconfig. keep-awake, concurrency-limit, and account-pool mapped @get-bb/plugin-sdk onto its bundled .d.ts files, which vitest loads as the SDK once it follows tsconfig paths.
  • App imports. provider-usage imported @bb/shared-ui/lib/usage-format, which only it used. Its story imported the app's Ladle story card and read logo files from other plugins.
  • Tests outside the repository: account-pool's tests read BB_ACCOUNT_POOL_PARENT_URL/_TOKEN from the shell, which turbo strips but a copy's npm test doesn't. They also ran tsx without declaring it.

What changed

  • Registry and config:
    • UI imports go through the registry alias, with thread-list's tsconfig paths, and the SDK path entries are gone.
    • Tests use defineConfig with tsconfig paths, and each plugin declares its test peers.
    • Each plugin gets a lint script and turbo entries.
  • provider-usage:
    • usage-format.ts moves into the plugin, and its shared-ui export is deleted.
    • Its story is self-contained: it lays out its own rows and inlines the two provider logos.
    • apps/app/.ladle applies the forkable-plugin path mapping, so Ladle resolves the plugin's @/ imports the way the app's vitest config does.
  • account-pool tests: they unset the parent-pool variables and declare tsx.

How you verified

  • pnpm exec turbo run typecheck test lint for the five plugins.
  • pnpm check:plugin-forks: all five pass in a copy. This run had the pool env vars set, which is what surfaced the test-environment leak.
  • @bb/app and @bb/server typecheck; @bb/scripts, @bb/plugin-api-map, and @bb/shared-ui; prepare:bundled for the five.
  • The Ladle stories render (headless Chromium, no console errors).
  • Bundle identity: keep-awake, concurrency-limit, and memory ship byte-identical app.js, app.css, and host.js. provider-usage's and account-pool's app.js differ from the base only in module paths and the registry icon (the same host component).

🤖 Generated with Claude Code

AGENT GENERATED

@SawyerHood
SawyerHood added this pull request to stack #4182 September 23, 2026 17:22
@SawyerHood
SawyerHood force-pushed the bb/forkable-09-settings branch 2 times, most recently from b564e3f to bda3522 Compare September 23, 2026 17:53
@SawyerHood
SawyerHood force-pushed the bb/forkable-09-settings branch from bda3522 to aee575c Compare September 23, 2026 20:40
@SawyerHood
SawyerHood marked this pull request as ready for review September 23, 2026 21:07
@SawyerHood
SawyerHood removed this pull request from stack #4182 September 23, 2026 21:40
@SawyerHood
SawyerHood added this pull request to stack #4220 September 23, 2026 21:41
keep-awake, concurrency-limit, memory, provider-usage, and account-pool
imported shared-ui components by workspace package, so a copy could not
install them:

- They import components through the registry alias
  (`@/components/ui/*`, `@/lib/utils`), and their tsconfigs map it the
  way thread-list does. keep-awake, concurrency-limit, and account-pool
  also mapped `@get-bb/plugin-sdk` onto its bundled .d.ts files. Vitest
  applies tsconfig paths at runtime and loaded those stubs, so the
  mappings are gone; the SDK's package exports name the same files for
  tsc.
- usage-format was shared-ui code that only provider-usage used. It
  moves into the plugin and leaves shared-ui's exports.
- provider-usage's story imported the app's Ladle StoryCard and read two
  provider logos from sibling plugins. It lays out its own rows and
  inlines the logos now. Ladle stays the only thing that knows about the
  app: its Vite config resolves forkable plugins' `@/` imports the way
  the app's vitest config does.

Each plugin declares what its tests load, including the SDK harness
peers. account-pool declares tsx, which its HTTP/1.1 negotiation test
uses to run the transport in a child process with NODE_EXTRA_CA_CERTS.
account-pool's server tests read BB_ACCOUNT_POOL_PARENT_URL and
BB_ACCOUNT_POOL_PARENT_TOKEN from the environment. Turbo strips them,
but `npm test` in a copy inside a pool-routed bb thread saw a parent
pool and failed 130 tests; the suite now unsets both.

Each plugin gets a lint script and turbo typecheck and test entries
with the registry flavors as inputs, and joins the forkable list.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/forkable-09-settings branch from aee575c to 4393503 Compare September 23, 2026 22:10
@SawyerHood
SawyerHood merged commit 5d83da6 into main Sep 23, 2026
23 of 34 checks passed
@SawyerHood
SawyerHood deleted the bb/forkable-09-settings branch September 23, 2026 22:13
SawyerHood added a commit that referenced this pull request Sep 23, 2026
## Human comments

## What was wrong

Ninth PR in the forkable built-ins stack; it builds on #4190. Four
nav-panel built-ins couldn't be copied out of the repository: workflows,
github, docs (plugin id `simple-notes`), and theme-preview.

Beyond the shared-ui imports and `vitest.shared.ts`:

- **Undeclared test dependencies:** github didn't declare `jsdom`, so in
a copy every jsdom test worker died with "Failed to start forks worker".
- **Tests that reach outside the plugin:**
  - workflows had a test that scanned the whole repository.
- theme-preview's `fixture-anatomy` tests read `apps/app/src` files,
which are assertions about host source.
- **SDK paths in tsconfig:** workflows and theme-preview mapped the SDK
onto bundled `.d.ts` files.
- **Lint:** theme-preview had 187 code comments and had never been
formatted.

## What changed

- **Theme Preview cleanup (first commit):** the comment autofix and
oxfmt only, so the second commit stays readable. `server.js` is
byte-identical after it.
- **Forkable conversion (second commit):**
- UI imports go through the registry alias with thread-list's tsconfig
paths, and github's local `@/components` alias becomes relative imports.
- Each plugin uses `defineConfig`, declares its test dependencies, and
gets lint and turbo entries. The lint script surfaced two effect
dependency lists in docs' editor that deliberately leave out values, now
marked for the linter.
- **Tests:**
- workflows' removed-command test scans only the plugin. The
repository-wide half moves to
`packages/scripts/test/workflows-removed-command.test.ts`.
- theme-preview's anatomy tests move to
`apps/app/src/components/plugin/theme-preview-fixture-anatomy.test.ts`,
next to the files they read. They still check that every mock view has a
source contract, and `@bb/app#test` takes
`plugins/theme-preview/taxonomy.ts` as an input so a change to the view
list reruns them.
- **Tooling:**
- `apps/cli`'s official-bundle tests anchor the copied plugin's tsconfig
paths.
  - `apps/app/.ladle` resolves the plugins' `@/` imports.

## How you verified

- `pnpm exec turbo run typecheck test lint` for the four plugins
(theme-preview's anatomy tests now run in `@bb/app`).
- `pnpm check:plugin-forks`: all four pass in a copy.
- `@bb/app` and `@bb/cli` typecheck, the moved anatomy test, and the CLI
official-bundle tests; `@bb/scripts` and `@bb/plugin-api-map`.
- **Removed-command scan:** appending `bb workflows catalog` to
`packages/templates/src/templates/bb-guide-plugins.md` fails the new
`@bb/scripts` test, while the plugin's own scan still passes.
- **Turbo input:** without the new input, `turbo --dry=json` reported
the same `@bb/app#test` hash after a change to `taxonomy.ts`; with it,
the hash changes.
- **Bundle identity:**
- `app.js` differs only in module order, the registry icon (the same
host component), and theme-preview JSX text that oxfmt split around `{"
"}`, which renders the same text.
- theme-preview's `app.css` loses four utilities that Tailwind picked up
from deleted comments and anchor strings; no element uses them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED
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