Repository navigation
Pick every exclusive plugin slot with one rule and one synced store - #7962
Merged
ymichael merged 3 commits intoNov 23, 2026
Merged
Conversation
ymichael
force-pushed
the
bb/implement-plugin-winner-rule-api-thr_iiq29hrnps
branch
3 times, most recently
from
November 23, 2026 18:43
89b544f to
1e66bdf
Compare
One resolver (resolveExclusive) now decides the composer, thread list, sidebar navigation, diff and source renderers, thread header title, file openers, code fences and message directives. bb's bundled plugins are ordinary claimants. A present pick wins, an absent one waits for plugins to load and then behaves as Automatic (first plugin the user installed by id, then bb's own, bundled or from bb's official marketplace, then core's). A message directive several plugins claim has no Automatic winner and renders its source with a Choose link. Picks are synced UI preferences only: new keys diff.provider, sourceCode.provider, threadHeader.titleProvider, fileOpener.byExtension, codeFence.byLanguage and messageDirective.byName; no key is renamed or retired. Every pick key has a device last-known cache so first paint uses the user's pick. Device-only diff, source and file-opener picks move to the server once while it is still at its default. A crashed installed composer or thread list renders the bundled one with a persistent Reload toast. Settings → Installed plugins → Plugin choices replaces the Appearance and Files rows. Docs, Plugin Guide, SDK JSDoc and the plugin-authoring skill describe the rule. Plugin SDK 0.6.177. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The composer, thread list and navigation remembered their last Automatic winner when they mounted and waited for it whenever plugin frontends were not settled. Settled goes false on every later plugin install, enable or update, so after the Automatic winner changed in a session each later plugin reload blanked the surface to its loading placeholder. The wait now applies only until plugins first settle, and the exclusive resolver no longer takes the settled flag. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hoice where it applies A message directive that several plugins claim now shows as text in a card like a code block, with a "Choose plugin" menu in its top right: one item per plugin, then a divider and Settings. A pick there writes messageDirective.byName like the Settings row does. The Plugin choices section is gone. Each row sits with what it changes, as on main: Navigation, Sidebar thread list, Source code, Diffs and Composer in Settings → Appearance → Interface (now with Thread header title), and file openers in Settings → Files → File openers. Code block and directive rows go in a new Appearance → Markdown section, with a row for every language or directive a plugin draws, so the user can switch one back to bb's own even when only one plugin claims it. Search, docs, the Guide and the skill point at those places. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/implement-plugin-winner-rule-api-thr_iiq29hrnps
branch
from
November 23, 2026 20:11
1e66bdf to
66d72c4
Compare
ymichael
deleted the
bb/implement-plugin-winner-rule-api-thr_iiq29hrnps
branch
November 23, 2026 20:21
ymichael
added a commit
that referenced
this pull request
Dec 1, 2026
…8507) ## Human comments ## What was wrong Boot JavaScript grew from 393.2 KB to 418.9 KB brotli between #7744 (Nov 18) and main, leaving 0.2 KB under the 419.1 KB limit. Two of the largest steps were static edges from the boot path into page-only code: - #8089: `plugin-navigation-hooks` imports `useTimelinePaneThreadId` from `timeline-viewport.tsx`, which also defined `TimelineViewportScrollSource`. That put `bottom-anchored-scroll-body` and `scroll-position-keeper` on boot. - #7960: `active-composer.ts` built the active composer's plugin handle itself, so the action-context binder (on boot) pulled in `plugin-composer-handle`, the SDK's `composer-handle` and `composer-draft-actions`, `plugin-composer-host` and `composer-editor-registry`. #8050 added a second path to the same modules: plugin navigation converts `initialPrompt` parts through `plugin-composer-handle.ts`. #7962's boot growth (~1 KB brotli) is the exclusive-pick logic the sidebar thread list and navigation need before they paint, so it stays. ## What changed - `TimelineViewportScrollSource` moved to `apps/app/src/lib/timeline-viewport-scroll-source.tsx`; `timeline-viewport.tsx` exports `useTimelineViewportStore` for it. - `ActiveComposerCandidate` gained `handle(pluginId)`. `composer-root` registers a factory built by the new `active-composer-handle.ts`, and `getActiveComposerHandle` calls it, so `active-composer.ts` no longer imports the handle code. `experimental_useActiveComposer` uses the same builder. - `initialPromptSeedFromComposer` and `mentionText` moved to `apps/app/src/lib/initial-prompt-seed.ts`. It imports `composerDraftFromInsertParts` from a new SDK internal subpath, `@get-bb/plugin-sdk/internal/composer-draft-transforms`, where that function now lives. A re-export through `internal/composer-handle` still kept the whole module on boot. - Plugin SDK 0.6.216 for the new subpath. - `bundle-budget.json`: `splitBoundaries` boot guards for `bottom-anchored-scroll-body.tsx`, `active-composer-handle.ts` and `plugin-composer-handle.ts`, plus a dated `$comment` entry. Limits unchanged. ## How you verified Real builds of main (e0c49e2) and this branch, brotli bytes from the `.br` files `check-bundle-budget.mjs` counts: | Closure | main | branch | Δ | |---|---|---|---| | boot | 428,920 | 419,163 | −9,757 | | ThreadPage | 498,511 | 507,873 | +9,362 | | NewThreadPage | 268,226 | 277,858 | +9,632 | | PluginFrontend | 219,813 | 229,475 | +9,662 | | boot + each page | | | −95 to −395 | Raw boot: 1,708,056 → 1,668,548. Every page shell uses the scroll body (`page-shell.tsx`) and every page loads the plugin runtime that needs the composer handle, so the code moved into the shared page chunks. The shell's critical path shrinks, the total before page content is unchanged, and boot is back to 2.3% headroom. I didn't measure paint timings. - Negative control: re-adding the `timeline-viewport` → scroll-body import and a `plugin-navigation-hooks` → `plugin-composer-handle` import fails the check with both new guards, and boot returns to 418.6 KB. - `pnpm exec turbo run test --filter=@bb/app --filter=@get-bb/plugin-sdk`: 709 + 47 test files pass. - `pnpm exec turbo run typecheck lint --filter=@bb/app --filter=@get-bb/plugin-sdk`, `node apps/app/scripts/check-bundle-budget.mjs`, `oxfmt --check`. - Live `pnpm start:worktree` with a real Claude Code thread, driven in headless Chrome: no console errors, scroll-to-latest works, the outline rail's active tick follows scrolling, and typing in the composer works. > 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 one-plugin surfaces each had their own winner rule and store. The composer, thread list and navigation used a pinned synced preference with "installed before bundled", but file openers sorted by plugin id (so bb's bundled Docs beat an installed
.mdopener) and fell back to bb's preview when a pinned opener was gone; the thread header title took whichever plugin sorted first with no way to choose; a code-fence language or message directive claimed by two plugins rendered nobody's view, only a console warning. The diff/source renderer and file-opener picks lived in device localStorage, so they did not follow the user or show up inbb settings ui. The composer and thread list had no last-known cache, so a cold load painted the Automatic winner for ~1.7 s before the user's pin arrived (kill-test 4 of the design, failed on main). A crashed composer or thread list left an empty "crashed" placeholder.Design:
design-winner-rule.md(section 2 as amended by section 6) from the plugin API audit.What changed
resolveExclusive(apps/app/src/lib/plugin-replacement-preference.ts) decides every exclusive slot and keyed surface: a present pick wins;__builtin__means core's own where core has one (diff, source, header title, file preview, code block, directive-as-text); an absent pick waits while plugins first load, then behaves as Automatic; Automatic is the first claimant the user chose over bb's defaults, by (plugin id, registration order), then bb's own (bundled or from bb's official marketplace), then core's own. "From bb's official marketplace" reuses the UI's official check, now one function (isOfficialPlugin/isOfficialMarketplaceinapps/app/src/lib/official-plugins.ts, also used by the plugin cards, detail page, author page and listing), so Docs, Tasks and Browser Automation rank as bb's defaults however they were installed. Keybinding conflict resolution still uses only bundled (builtin) plugins. bb's bundled Composer, Thread list, Navigation, Docs, Tasks and inline-vis are ordinary claimants through it. Message directives use the same resolver with no Automatic winner: a name several plugins claim renders as its source text in a card like a code block, with a "Choose plugin" menu in its top right (one item per plugin with its icon, a divider, then Settings…). A pick there writesmessageDirective.byName, the same value as the Settings row.composer-provider.ts,ComposerBox), thread list (threadListProvider.ts,PluginThreadList), sidebar navigation (sidebarNavigationProvider.ts, placement and remembered-winner kept as extras), diff and source renderers (codeRendererProvider.ts), thread header title (PluginThreadHeaderTitle.tsx,ThreadDetailHeader), file openers (resolveFileOpenerReplacement), code fences (resolveCodeFenceRendererRegistry) and message directives (resolveMessageDirectiveRegistry,markdown-message-directives.tsx).@bb/domain:diff.provider,sourceCode.provider,threadHeader.titleProvider, and the mapsfileOpener.byExtension,codeFence.byLanguage,messageDirective.byName(a missing map key means Automatic). No key is renamed or retired. Every pick key, including the existingcomposer.providerandsidebar.threadListProvider, now has a device last-known cache so first paint uses the user's pick; composer and thread list also remember their last Automatic winner and wait for it during boot instead of painting another claimant. The wait applies only until plugin frontends first settle (navigation used the same wait on main, re-armed on every later plugin reload), so a plugin install or update later in the session never blanks these surfaces after the Automatic winner changed.bb.appearance.diffRenderer,bb.appearance.sourceCodeRenderer,bb.fileOpenerByExtensionwithpluginId:id→pluginId/id) seed first paint and move to the server once, only while the server value is still the default (a conflict re-reads and keeps another device's pick); the legacy key is then removed.bb settings ui sethelp mentions maps take JSON;bb settings ui listdescriptions state the rule. Updateddocs/configuration.md, the customization guide template, the Plugin Guide (one "Exclusive slots" card in Plugin backend; per-slot cards link to it), SDK JSDoc (per-slot exclusivity notes now point to that card and name the pick key), the bb-plugin-authoring skill (an "Exclusive slots" section,onInstallexample that only writes over__automatic__),docs/api_to_audit.mdentries for the affected experimental slots, plugin READMEs/overviews that pointed at Appearance/Files, and the verify-bb settings feature map. The thread-list section the skill now keeps infrontend-thread-list.mdstates the exclusivity rule and the bundled-list crash fallback; the replacement-lab example points at Appearance → Sidebar thread list. Plugin SDK 0.6.184 (JSDoc only, no new member).HOST_DAEMON_PROTOCOL_VERSIONunchanged).sourceCode.provideris included (the source code renderer slot still exists, and leaving its pick in localStorage would keep a second store);__builtin__for a directive means "show as text" and dismisses the in-message picker; the crash toast stays until dismissed (an auto-closing one left no way back to the crashed plugin); a file opened before plugins first finish loading, whose picked opener hasn't arrived yet, opens in bb's preview, because a one-shot open has no loading state.Follow-ups
bb plugin listshowscommand: bb tasksfor both with no warning, andbb tasksalways routes to Tasks, so tasks-plus's CLI can't be reached by name.Community plugins that can migrate (not edited here): nav-rail and compact-nav write the retired
sidebar.headerProviderinonInstalland throw onpreferences[key].revision; stewards already writes only over__automatic__; bang-shell/inline-terminal users can now pick per language; tasks-plus and scott-tasks users get an in-message plugin picker for::task.How you verified
Tests that fail on main for the class of bug:
apps/app/src/lib/pinned-replacement-surfaces.test.tsx: one contract table run against all eight surfaces (composer, thread list, navigation, source, diff, header title,.mdopener,bashfence): pinned wins and Settings names it; absent pin behaves as Automatic once settled; installed ranks ahead of bundled and official-marketplace plugins by id; loading waits for the pin. On main the opener, header-title and fence rows fail (id-sorted bundled first, no pick, collision renders nobody).exclusive-pick-first-paint.test.ts: every pick key, includingcomposer.providerandsidebar.threadListProvider, starts from the device's last pick after a reload; a pre-upgradepluginId:idopener map seeds first paint aspluginId/id.ui-preferences-sync.test.ts: a legacy pick is written to the server only while it is at its default, dropped otherwise, and a concurrent device's write wins.PluginChoiceSettings.test.tsx: two shell renderers share one row and one pick writes all six languages; a contested::taskrow is "Not chosen" until picked; a code block or directive only one plugin draws still gets a row whose "bb (built-in)" / "Show as text" writes__builtin__.markdown-message-directives.test.tsx/.test.ts: a contested directive renders its source with a "Choose plugin" menu listing both plugins then Settings…, and picking one renders that plugin; picks,__builtin__and loading states.PluginThreadList.test.tsx: a crashed installed list shows the bundled list and the toast's Reload remounts the installed one.Commands:
pnpm exec turbo run typecheck lint --filter=@bb/app --filter=@bb/domain --filter=@get-bb/plugin-sdk --filter=@bb/cli --filter=@bb/server --filter=bb-plugin-plugin-api-docs --filter=bb-plugin-bb-guide --filter=@bb/templates(pass),lint:type-awarefor app/domain/cli (pass),turbo run testfor the same packages (pass after fixes; app 7368, server 4425, cli 1413, sdk 445, domain 361 tests).Live (
pnpm start:worktree, community plugins installed from the 503-repo corpus, headless Chrome):bb settings ui get codeFence.byLanguagematches, thread re-renders with inline-terminal). Main: both claimants → bb's block plus six console warnings.pluginId:idopeners, device B pinned image-diff. After upgrading A then B: the CLI shows A's picks in/form (revision 1), B's local pick was dropped, both devices' legacy keys are gone, and both render what the CLI reports.bb--composer/composerandthread-list/thread-listwith t3-composer and stewards installed,GET /api/v1/preferences/uidelayed 2 s by CDP Fetch, screencast: 3 runs, zero frames of t3-composer or stewards (main: ~1.7 s of both). With both on Automatic, t3-composer and stewards paint first with no bb flash..mdpick on a disabled markdown-reader opens with Automatic's opener, not bb's preview (main: bb's preview).::zz-card): the reply shows::zz-card{label="…"}as text in a card with "Choose plugin" top right; the menu lists both plugins, a divider and Settings…; picking one replaces the card with that plugin's view andbb settings ui get messageDirective.byNamereturns{"zz-card":"zz-shell-b/zz-card"}; Settings… opens Appearance with the Markdown section in view. Checked at 1280 px and 390 px (menu opens as a bottom sheet).🤖 Generated with Claude Code