Repository navigation
Make the sidebar thread list plugin forkable - #4140
Merged
SawyerHood merged 9 commits intoSep 23, 2026
Merged
Conversation
`@get-bb/plugin-sdk/app` read `globalThis.__bbPluginRuntime.pluginSdkApp` once, when the module loaded, and copied every member into its exports. A test that imported a component before calling installTestPluginRuntime() got undefined hooks and components, so plugins had to load app.tsx through a thunk or install the runtime from a vitest setup file. Each export is now a stable forwarder that looks the runtime up when it is called or rendered. Components render through the runtime's React, which the host already installs and installTestPluginRuntime() now installs too, so the facade still imports nothing. definePluginApp builds the branded definition itself when no runtime is installed. renderSlot installs the test runtime. Production is unchanged: `bb plugin build` still swaps the specifier for the host shim, and the export names it reads are the same. Bumps the plugin SDK to 0.5.16. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A plugin's server already gets `bb.pluginId`, but its app code had no way to learn the id it runs under. Plugins that keep state in the browser, such as a localStorage mirror, had to hardcode their name, so a copy published under another package name shared that state with the original. `experimental_usePluginId()` returns the id of the plugin that owns the calling component. The host backs it with the plugin context its other hooks already read. `renderSlot` takes a `pluginId` option and defaults it to `test-plugin`. Documented in docs/api_to_audit.md, the Plugin Guide's thread-list surface, and the plugin authoring references. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The registry's icon item was the app's own icon module: the full hugeicons map plus a private copy of the icon registries. Every plugin that vendored a registry component with an icon (checkbox and dialog in the `bb plugin new` starter, among others) bundled that map, and its copy of the registries never saw icons other plugins register. Built-in plugins avoided both only because the build redirects shared-ui's own icon import to the host. registry.json gains pluginFlavors, which swaps a shared-ui file for a plugin-side version. The icon flavor re-exports the SDK's experimental_Icon, the same host registry built-ins get. The icon-registry and icon-extended items drop out of the registry, and hugeicons with them. Also adds chrome-style-tokens and empty-state (uiItems may now be .ts files), which the sidebar needs to leave @bb/shared-ui. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
When the thread list moved into the thread-list plugin, the app kept its own copies of the row, section header, and section drag-and-drop code in components/sidebar. Nothing in the app renders them any more: the sidebar mounts the plugin's list, and these files were reachable only from their own tests, their stories, and each other. Removes ThreadRow, TopLevelSidebarSection, useSectionThreadDnd with its context and drop-target hook, useNeighborReorderSortable, sidebarThreadRowDroppable, SidebarRowControls, SidebarChildToggleChevron, and SplitPaneMiniMap, with their tests and stories. The plugin keeps its own versions of all of them. The composer actions stories lose their thread-row status story, which rendered the removed row rather than the one users see. Files in components/sidebar that the app still uses stay: useSidebarThreadReveal (AppLayoutSidebar), useSidebarModeSectionOrder (ThreadSectionMoveProvider), SidebarInlineRename and SidebarRenameEditor (the thread header's rename), SidebarVisibilityControls and SidebarVisibilityCustomize (navigation customize), sidebarRowClasses, sortableMotion, and useSidebarReorderDnd. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
thread-list converted every PluginSidebarThread from the SDK into bb's internal ThreadListEntry (toSidebarThread) so it could reuse client-core's sidebar helpers, which are typed on that entry. That one conversion pulled the @bb/domain type graph and a dozen client-core modules into anything that copies the plugin. The plugin now works on the SDK type directly (SidebarThread is an alias of PluginSidebarThread) and owns the sidebar model it renders: project, section, and environment grouping, pinned roots, machine groups, section order, neighbor reorder, and the row indicator and collapsed-child rollups, ported into app/model with their tests. Read state comes from the host-computed isUnread instead of a local copy of the lastReadAt rule. The personal project is the one the SDK flags isPersonal rather than a hardcoded id. The one visible difference: if bb fails to load the sidebar, the Threads header's new-thread button opens compose without selecting the personal project, since no project list exists to find it. client-core keeps what the app itself still uses. buildSectionThreadList with its section items, buildMachineThreadGroups, reorderSidebarSectionOrder, insertSidebarSectionAfter, buildNeighborReorderRequest, getSidebarDndItemId, the row-count and navigation-entry helpers, and NO_COLLAPSED_CHILD_ACTIVITY had no consumer left besides their own tests, and are removed. Test fixtures build SDK threads, deriving isUnread, isPinned, isArchived, and displayTitle the way the host does, and keep the defaults each test used before, so every existing case checks the same data. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
thread-list imported its UI primitives from @bb/shared-ui and a few helpers from @bb/core-ui, so a copy of the plugin could not build outside the monorepo. The plugin now imports those components the way a scaffolded plugin does, through `@/` (`@/components/ui/button`, `@/lib/utils`). Its tsconfig maps `@/*` onto packages/shared-ui/src, the source the component registry is generated from, and `@/components/ui/icon` onto the registry's host-backed icon. tsc, esbuild, and vitest (resolve.tsconfigPaths) all follow that mapping, so the repository keeps one copy of the components. A fork instead writes the registry items it imports into its copy and points `@/*` at `./*`. scripts/forkable-plugins.json lists plugins set up this way. apps/app/vite-forkable-plugin-paths.ts applies the plugin's mapping when app tests import it, since the app's own `@` alias would otherwise capture those imports. The sidebar bench loads the plugin through a non-literal import, so the app's typecheck no longer compiles the plugin's source under the app's paths; the plugin typechecks itself. Error-message extraction and the environment display name are small plugin-local helpers, so @bb/core-ui goes too. The tsconfig resolves the SDK's published types and typechecks app.test.tsx, which it had skipped. The vitest config no longer imports the monorepo's shared config, and turbo builds the SDK before the plugin's tests. The package declares the optional peers the SDK's server test harness loads. Two test files install the test runtime, since their icons now come from the SDK. The ThreadRow test for an unregistered icon name's fallback glyph is removed: it tested the host icon, not the sidebar. The built bundle is unchanged for users: app.css is byte-identical to the previous build, and app.js is 47 KB smaller, because it no longer includes @bb/domain code. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A copy of thread-list published under another package name still registered `bb thread-list`, mirrored its layout into `bb.thread-list.preferences.v1`, and logged as `thread-list:`, so it shared the built-in's CLI and localStorage state until someone patched each literal. The server now names its CLI `bb.pluginId`, and the app reads its id from experimental_usePluginId() to key the preferences mirror and prefix its warnings. Under the built-in's id the values are unchanged, so existing layouts and `bb thread-list prefs` keep working. The thread-list slot keeps its literal id: the host keys thread-list providers as `<pluginId>/<slotId>`, so a copy's slot never collided. engines.bbPluginSdk moves to >=0.5.16, the first SDK with experimental_usePluginId. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
thread-list no longer needs anything from the monorepo, but nothing kept it that way. - The bb/forkable-plugin-imports lint rule covers plugins listed in scripts/forkable-plugins.json. It rejects `@bb/*` specifiers (imports, re-exports, dynamic and type imports, `vi.mock`, `require`), `@/` paths that no component registry item provides, and relative paths that leave the plugin. thread-list gains a lint script so turbo lint runs it; the script's ignore flags keep it usable in a copy that has no repository config. - `pnpm check:plugin-forks` (scripts/check-plugin-forks.mjs) makes the copy a fork would make, in a temporary directory outside the repository. It writes the registry items the plugin's `@/` imports name and points `@/*` at `./*`. It rewrites package.json: the SDK comes from a packed @get-bb/plugin-sdk, @bb/shared-ui becomes those items' npm packages, and workspace-only build tooling and its scripts are dropped. Any other workspace dependency is refused. It then runs npm install, the plugin's typecheck and tests, and `bb plugin build`, and checks the artifacts. A new CI job runs it. The rewrite lives in scripts/lib/plugin-fork.mjs so a future `bb plugin fork` can share it. Only thread-list is listed. Adding a built-in means listing it and giving it a lint script, which a test enforces. docs/plugin-sidebar-thread-list.md describes starting from bb's list. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
npm 10.9.8, the npm that ships with Node 22, crashes with "Cannot read properties of null (reading 'edgesOut')" while resolving vitest 4.1's peer set; a package.json that lists only vitest reproduces it. The fork check now installs with --legacy-peer-deps, as the external scaffold test already does, so it runs on both npm 10 and npm 11. Without automatic peers the copy must declare every peer it uses, so thread-list now lists @testing-library/dom, which @testing-library/react 16 expects the consumer to install. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
SawyerHood
deleted the
bb/make-the-sidebar-plugin-forkable-thr_tp8gpadn7t
branch
September 23, 2026 04:30
3 tasks done
This was referenced Sep 23, 2026
SawyerHood
added a commit
that referenced
this pull request
Sep 23, 2026
## Human comments ## What was wrong First PR in a stack that makes bb's other built-in plugins forkable, the way #4140 did for the sidebar. Auditing the other 36 built-ins against `pnpm check:plugin-forks` showed gaps in the machinery itself that every one of them hits after thread-list: - **SDK host entries fail under plain Node.** The published `@get-bb/plugin-sdk/host` and `/provider-bridge` entries inlined cross-spawn. cross-spawn is CommonJS that requires Node builtins, so importing either entry outside a bundler threw `Dynamic require of "child_process" is not supported`. A plugin's own `host.test.ts` does exactly that once it installs the SDK from npm. - **Registry versions come from the app manifest only.** The fork check read registry package versions from `apps/app/package.json` alone, so items the app doesn't depend on directly (collapsible, tabs, label, radio-group, cmdk) aborted the check. - **The lint rule only rejects `@bb/*`.** `bb/forkable-plugin-imports` let through workspace packages without the scope, such as `bb-environment-provider-host`, and the SDK's `internal/*` modules, which bb can change in any release. - **The check can't scale.** It ran plugins one at a time and stopped at the first failure, which won't fit the CI job's 20-minute budget once dozens of plugins are listed. ## What changed - **SDK 0.5.21: cross-spawn stays external.** It becomes a dependency of the package, so `dist/host.js` and `dist/provider-bridge.js` import it the way Node loads CommonJS. The entry list and esbuild options move from `build-runtime.mjs` to `scripts/runtime-entries.mjs` so a test can build the entries and import them. plugin-build's `zod-resolution` test simulates an npm install of the SDK, and it now copies the SDK's dependencies too. - **Fork check versions:** registry package versions come from `packages/plugin-registry/package.json`, and the app's pinned versions win where the app declares one. - **Fork check concurrency:** `--concurrency=<n>`, default up to 4. It prints `Checking <plugin> …` when each plugin starts, so a hung step still shows which plugin it was in, and the plugin's steps when it finishes. All failures are reported at the end. - **Lint rule:** rejects imports of every workspace package (apps, packages, plugins, tests, examples) except `@get-bb/plugin-sdk`. It also rejects the SDK's `internal/*` modules. - **Turbo:** `prepare:bundled` lists `packages/plugin-registry/flavors/**` as an input, so a change to the host-backed icon rebuilds forkable plugins' bundles. - **Docs:** `docs/forkable-plugins.md` describes the list, the checks, and what a listed plugin looks like: registry alias, its own vitest config, declared test peers, portable tests, turbo entries, names unchanged from the built-in, and `engines.bbPluginSdk` as the SDK floor. The thread-list doc links to it. No wire changes. ## How you verified - **New `runtime-entries.test.mjs`:** builds every published entry. It asserts that none inlines a CommonJS require shim, that every external is a dependency or peer, and that `./host` and `./provider-bridge` import under plain Node. Against the old externals list, 3 of its 4 tests fail with the `Dynamic require` error. - **Lint rule:** new `plugin-forks.test.mjs` cases reject `bb-environment-provider-host/git`, `bb-plugin-tasks`, and `@get-bb/plugin-sdk/internal/plugin-app-collector`, and still allow the SDK's public entries (`/host`, `/testing/app`) and npm packages. The `internal/` case fails without the new check. - **Turbo:** `pnpm exec turbo run build build:types typecheck test lint --filter=@get-bb/plugin-sdk --filter=@bb/scripts --filter=bb-plugin-thread-list`, plus the tests for `@bb/plugin-build`, `@bb/templates`, and `@bb/cli`. - **Fork check:** `pnpm check:plugin-forks` passes for thread-list. - **SDK version guards:** `node .github/workflows/check-plugin-sdk-version.mjs` and `node packages/plugin-sdk/scripts/check-npm-version-guard.mjs`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
SawyerHood
added a commit
that referenced
this pull request
Sep 23, 2026
## Human comments ## What was wrong Fifth PR in the forkable built-ins stack; it builds on #4181. `plugins/navigation` replaces bb's whole sidebar navigation region, which makes it the cleanest fork after the sidebar thread list (#4140). A copy of its directory still couldn't build on its own: - It imported ten `@bb/shared-ui` components and helpers. All ten have registry items. - Its vitest config imported the repository's `vitest.shared.ts`. - A copy installed without npm's peer resolution lacked `@testing-library/dom` and `@types/react-dom`. ## What changed - **Registry imports:** the plugin follows thread-list's conventions and imports UI through the registry alias (`@/components/ui/button`, `@/lib/utils`, …). - **tsconfig:** maps `@/*` onto `packages/shared-ui/src` and `@/components/ui/icon` onto the registry's host-backed icon. `customConditions: ["source"]` is gone. `app.test.tsx` is now typechecked. - **vitest config:** `defineConfig` with tsconfig paths. - **Tooling:** the package gets a lint script, and turbo gives its typecheck and test tasks the registry flavors as inputs and the SDK build as a test dependency. - **App test fixture:** `apps/app/src/test/fixtures/navigation-plugin.ts` imported the plugin's `app.tsx` by a literal path. That pulled the plugin into `@bb/app`'s typecheck, where `@/` means the app's own source. The fixture now loads the module by a resolved path and checks the export, as the sidebar bench already does for thread-list. ## How you verified - `pnpm exec turbo run typecheck test lint --filter=bb-plugin-navigation`, `@bb/app` typecheck, and the three app test files that load the plugin: `NavigationPlugin`, `SidebarNavigationRegion`, `plugin-slot-mounts`. `@bb/plugin-api-map` tests pass; it anchors `Navigation.tsx`. - `pnpm check:plugin-forks plugins/navigation`: install, typecheck, test, and `bb plugin build` pass in a copy. - **Bundle identity:** `app.css` and `server.js` are byte-identical before and after. An unminified `app.js` differs only in module order and names. The plugin's own icons now render through the SDK's `experimental_Icon`, which the host binds to the same `Icon` component that the old `@bb/shared-ui/icon` shim provided. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED
SawyerHood
added a commit
that referenced
this pull request
Sep 25, 2026
## Human comments ## What was wrong When the sidebar moved into the thread-list and navigation plugins (#4036, #4041, #4117, #4140), the old app and client-core copies stayed behind. Nothing in the shipped app renders or calls them, but their tests kept them compiling and passing. The shipped plugin copies have their own tests. A few other app tests could not fail: they restated constants or asserted a flag inside a block that only runs when the flag has that value. Others were near-duplicates of a stronger test. ## What changed Found by a read-only test audit using the repo `test-audit` skill (#4361). - Deletes dead code that nothing in the shipped app calls, and the tests that only exercised it: - `ThreadArchiveQuickAction` and `ThreadActionsContextMenu` (the plugin copies ship) - `SidebarRenameProvider`, the app's sidebar row state classes, the drop-animation constant and the sidebar lifecycle atom - `useSystemProviderUsageLimits` and its query key (unused since #3449), and `getAppCommandMetadata` - client-core's environment grouping, sort policy and pinned-root ordering. The only live callers read `effectivePinnedThreadIds` or pass their own comparator. - the unused `hasRunningPluginStatus` parameter, and the plugin copy of `arrangeByStoredOrder` - The theme-preview anatomy anchor now points at `plugins/thread-list/app/rows/sidebarRowClasses.ts`, the file that actually renders the rows. - Folds duplicate suites into table tests at their owners: bundle budget, command ordering, `isRowExpandable`, steer rendering and child activity. - Deletes tests that restate constants or cannot fail. - Adds two tests after coverage verification: - an unpinned parent stays out of `effectivePinnedThreadIds`; - the terminal enables xterm's proposed API, which the Unicode 11 addon requires. This builds a real `Terminal`. Production +59/−706, tests +476/−1618. ## How you verified - `pnpm exec turbo run test lint typecheck` passes for `@bb/app`, `@bb/client-core`, `@bb/thread-view`, `bb-plugin-thread-list` and `bb-plugin-theme-preview`, plus typecheck of every client-core and thread-view dependent. - An independent verifier used before and after worktrees on 175d5ac and 55 mutations. For each of the 75 removed or merged tests, it wrote the bug that test catches as a production change and checked that the old test fails and a remaining test also fails. - Result: 64 OK, 10 with no unique failure mode, 1 lost. The lost assertion is restored above. - The live callers `RootComposeMobileRecents` and `useSidebarThreadReveal` still fail on sort or pin mutations. - Known gap, not caused by this change: the rename-cancel effect in `useSidebarRename` was untested before and after. > 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.
Human comments
What was wrong
bb's sidebar (
plugins/thread-list) could not be copied out of the monorepo and built as a plugin of its own. It imported@bb/shared-ui,@bb/domain,@bb/client-core,@bb/core-ui, and@bb/test-helpers. It also converted every SDKPluginSidebarThreadinto bb's internalThreadListEntryjust to reuse client-core helpers typed on that entry. Vendoring it into a standalone plugin took 58 bb source files. A copy also collided with the built-in, because it hardcoded its CLI name and localStorage key. On the SDK side,@get-bb/plugin-sdk/appbound the runtime when the module loaded, so a test that imported a component before installing the test runtime gotundefinedhooks and components.What changed
Nine commits, each building on the last:
packages/plugin-sdk/src/app.ts). Each export is a stable forwarder that looks the runtime up when called or rendered; components render through the runtime's React. Import order no longer matters, andrenderSlotinstalls the test runtime. Production is unchanged:bb plugin buildstill shims the specifier, and the export names are the same.experimental_usePluginId()returns the id of the plugin that owns the calling component, backed by the host's existing plugin context.renderSlottakes apluginIdoption. It is documented indocs/api_to_audit.md, the Plugin Guide, and the authoring skill. SDK 0.5.16.pluginFlavors. Theiconitem is now a re-export ofexperimental_Iconinstead of the app's icon module (the full hugeicons map plus private copies of the icon registries). Every plugin that runsshadcn add @bb/icon, and thebb plugin newstarter, stops bundling the map and sees icons other plugins register. Theicon-registryandicon-extendeditems drop out. The commit also addschrome-style-tokensandempty-state.ThreadRow,TopLevelSidebarSection, the section drag-and-drop hooks,SplitPaneMiniMap, …). They were reachable only from their own tests and stories. Thecomponents/sidebarfiles the app still uses stay.SidebarThreadis an alias ofPluginSidebarThread, andtoSidebarThreadis gone. The sidebar model the plugin renders (grouping, sections, pins, machine groups, section order, indicator rollups) moves intoapp/model, with its tests. Read state comes from the host'sisUnread, and the personal project fromisPersonal. client-core exports that no longer had a consumer are deleted.@/components/ui/button,@/lib/utils. Its tsconfig maps@/*ontopackages/shared-ui/srcand@/components/ui/icononto the registry's host-backed icon. tsc, esbuild, and vitest follow that mapping, so the repository keeps one copy of the components.apps/app/vite-forkable-plugin-paths.tsapplies the same mapping when app tests import the plugin. The@bb/core-uihelpers become plugin-local. The package drops its remaining workspace dependencies except@bb/shared-ui, which a fork replaces.bb.pluginId, and the preferences mirror key and log prefixes come fromexperimental_usePluginId(). The built-in's values are unchanged (bb thread-list,bb.thread-list.preferences.v1). The slot id stays literal: providers are keyed<pluginId>/<slotId>, so it never collided.scripts/forkable-plugins.json, which only has thread-list today:bb/forkable-plugin-importsrejects@bb/*imports and@/paths no registry item provides in the listed plugins.pnpm check:plugin-forks(with a new CI job) makes the copy a fork would make in a temp directory. It writes the registry items the plugin imports, points@/*at./*, and installs the packed SDK plus npm packages. It then runs the copy's typecheck, tests, andbb plugin build. The rewrite lives inscripts/lib/plugin-fork.mjs, for a futurebb plugin fork.docs/plugin-sidebar-thread-list.mddescribes starting from bb's list.--legacy-peer-deps, like the external scaffold test, so the copy must declare its own peers; thread-list now lists@testing-library/dom.No wire changes.
Known difference: if bb never loads the sidebar, the new-thread actions on the Threads section open compose without selecting the personal project, because there is no project list to find it in.
How you verified
pnpm exec turbo run build typecheck lintacross the repo; full@bb/apptest suite; tests for thread-list, the plugin SDK, plugin-registry, templates, plugin-build, client-core, plugin-api-map, and@bb/scripts;smoke:tarball; both plugin SDK version guards.pnpm check:plugin-forkspasses on Node 22 / npm 10.9.8 and Node 24 / npm 11.16: the copy installs only published packages and the packed SDK, and its typecheck, all thread-list tests, andbb plugin buildpass. It fails when the plugin imports a workspace package; checked by adding an@bb/domainimport.app-facade-runtime.test.tsxfails 4 of 5 against the old facade. The preferences, server, and app tests check that a copy under another id gets its own mirror key and CLI name.app.cssis byte-identical to the previous build, andapp.jsis 47 KB smaller because it no longer includes@bb/domaincode. Icons still come from the host runtime.BB_SIDEBAR_BENCH=1sidebar bench, which renders the plugin under the real host runtime: same rendered rows and windowed items asmain. Mount and status-patch timings are flat; membership-refetch and pin timings are bimodal on both sides across 8 interleaved runs.🤖 Generated with Claude Code