Repository navigation
Conversation
ymichael
force-pushed
the
bb/plugin-loading-gates-per-plugin-not-all-bundles-thr_6jhj97abwz
branch
3 times, most recently
from
November 20, 2026 19:03
92f4144 to
474fadd
Compare
Plugin frontends published only one "settled" signal, true once every
enabled bundle had loaded. Surfaces that need a single plugin waited on it:
- Thread and plugin-page right panels kept splits and tab reconciliation off
until the slowest bundle landed, then switched to the split container,
remounting a remembered Git diff tab that was already on screen.
- Plugin pages, action tabs, pending-interaction forms, git status and
remembered sidebar items could only tell "still loading" from "gone" after
every bundle settled.
- Unclaimed ::name{...} directives rendered as literal source text until the
claiming plugin loaded.
- Activating a remembered nav item whose bundle was still loading did nothing.
The slot store now tracks which plugins are still loading (candidates not yet
applied plus plugins still starting on the server) and publishes that set in
the same flush as registrations, so a plugin never reads as settled before its
slots are visible. usePluginFrontendSettled(pluginId) and
useIsPluginFrontendSettled() read it, and each surface waits only for its own
plugin; thread fixed tabs wait for the plugins that own the thread's persisted
tabs. While any plugin may still claim a directive, unclaimed block directives
are held empty instead of shown as source. Activating a loading nav item opens
its page, which shows the panel once the bundle registers.
Composer, thread list and sidebar navigation replacement fallbacks still use
the global gate; their resolution belongs to the replacement-preference work.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/plugin-loading-gates-per-plugin-not-all-bundles-thr_6jhj97abwz
branch
from
November 20, 2026 19:19
f208222 to
99e6797
Compare
ymichael
deleted the
bb/plugin-loading-gates-per-plugin-not-all-bundles-thr_6jhj97abwz
branch
November 20, 2026 19:25
ymichael
added a commit
to lanjak/bb
that referenced
this pull request
Nov 20, 2026
After get-bb#7878 a thread's tab readiness also waits for its saved thread tabs to load, so holding the split surface behind a skeleton showed a blank panel for a network round trip on a first visit. Mount the split container immediately instead. When it mounts before the tab list is ready with a saved layout, it renders a best-effort layout, skips persistence, and restores the saved layout once the list is ready. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 20, 2026
## Human comments ## What was wrong `ThreadSecondaryPanel` only mounted `SidebarSplitContainer` once the thread's fixed tabs were ready (`areFixedTabsReady`). Until then it rendered the flat panel surface. On a thread switch, readiness is false on the first render: plugin tabs report visibility from layout effects, and since #7878 a thread also waits for its saved thread tabs (`useThreadTabs`) to load. When readiness arrived, the panel replaced the flat surface with the split container, and React mounted all panel content a second time. The same swap ran whenever readiness dropped mid-session, for example while a plugin that owns a saved tab reloads. The gate came from #6013. It keeps a saved split layout from being parsed, and overwritten, against an incomplete tab list. ## What changed - `ThreadSecondaryPanel` mounts `SidebarSplitContainer` right away and passes readiness down as `isTabListReady`. There is no flat-to-split swap, so content mounts once on a switch and stays mounted through plugin reloads. - `SidebarSplitContainer` (new required `isTabListReady` prop): if it mounts before the tab list is ready and a saved layout exists, it renders a best-effort layout from the available tabs, skips persistence so the saved value stays intact, and restores the saved layout once the list is ready. With no saved layout it uses the deterministic default layout, so nothing remounts when tabs arrive. - No skeleton is shown on a switch. The first version of this PR held the panel behind `SecondaryPanelContentSkeleton`. After #7878 that skeleton painted for one thread-tabs fetch on every first visit to a thread: 33 ms locally and 333 ms with 150 ms of added latency, with no tab bar or close button. - The drawer path is unchanged. ## How you verified - `ThreadSecondaryPanel.threadSwitch.test.tsx` uses the real `useThreadFixedTabs`, a real plugin tab registration and a stubbed `sdk.threads.tabs.get`. Content mounts once per switch for Info and an open file. Content stays mounted with no skeleton while a saved tab's owning plugin reloads, for Info, an open file and a plugin tab. These five tests fail with main's `ThreadSecondaryPanel.tsx` and `SidebarSplitContainer.tsx` (`expected [ 'info:thr_b', 'info:thr_b' ] to deeply equal [ 'info:thr_b' ]`). Further tests check that panel content shows while saved tabs load and that a reloaded plugin tab stays selected. - The existing saved-split test in `ThreadSecondaryPanel.collapseControl.test.tsx` passes: the stored split survives while visibility resolves and is restored afterwards. It now seeds the thread's `lastUsedAt`, because the container mounts earlier and `pruneSidebarSplitStorage` drops splits for threads without one. - `pnpm exec turbo run typecheck lint --filter=@bb/app` passes. The `secondary-panel/`, `plugin/` and `thread-detail/` suites pass, apart from two failures unrelated to this change: a lazy-loading test that times out under load and passes alone, and a `branding.icon` test that reads leftover untracked plugin directories in this checkout. - Live, headless Chromium at 1600x1000 on `pnpm start:worktree`: - Repeated switches, Info or Diff active, 30 each: 1 panel chrome insertion per switch (main: 2). Click-to-paint median 16 ms both ways. - First visit to a thread after a reload, 4 runs each at 0 ms and 150 ms added latency: 1 insertion, 0 skeleton frames. - Saved Info | Diff split, first visit after a reload, at 0 ms and 150 ms: the panel shows Info, then restores both panes. The stored layout is unchanged and no skeleton frames paint. - Disabling and re-enabling the Git plugin and another plugin with the panel open: 0 panel remounts, 0 skeleton frames. - Main-thread CPU per switch, measured on the pre-#7878 base (main: 1 run, branch: 2 runs): Info 50 ms on main vs 45–47 ms on the branch, Diff 92 ms vs 80–84 ms. Related: #7801. With that change, the duplicate mount opened one extra short-lived terminal socket per thread switch. Fixes #7802 > AGENT GENERATED --------- Co-authored-by: Michael Yong <[email protected]> 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
Plugin frontends published a single readiness signal,
usePluginFrontendsSettled(). It turned true only after every enabled bundle had loaded, and every surface that needs one plugin used it. The API audit's claim that "a remembered Git diff tab waits for Tasks and Docs" did not reproduce: the tab first renders as soon as the git plugin registers. The real bug was that the thread right panel held its split container and fixed-tab reconciliation on that global signal. When the slowest bundle landed, the panel switched surfaces and remounted the diff tab that was already on screen. The same signal also caused three other problems:SidebarNavigationModelreturned onisLoading, and the SDK docs promised that.::name{…}directives in assistant messages showed as source text until the claiming plugin loaded.What changed
apps/app/src/lib/plugin-slots.ts,plugin-frontend.ts). The reconcile records which plugins are still loading: candidates not yet applied, plus plugins stillstartingon the server.fetchFrontendCandidatesnow returns{ candidates, startingPluginIds }, so the hand-off from "starting" to "loading" happens in one step. The slot store publishes the set in the same flush as registrations, so a plugin never reads as settled before its slots are visible. New internal hooks:usePluginFrontendSettled(pluginId)anduseIsPluginFrontendSettled().usePluginTabstakes the plugin ids it waits for. A plugin page's right panel waits for its own plugin. A thread waits for the owners of its persistedplugin-fixedtabs (local and server).PluginPanelView, unavailable action tabs,PluginPendingInteractionComposer, the git status query and remembered nav chrome each check their own plugin.MessageDirectiveRegistrybecomes{ directives, unclaimed: "hold" | "literal" }. While any plugin may still claim a name, unclaimed block directives are held as an empty node. They render as literal text once all plugins have settled. This stays on the global signal on purpose, because any plugin could claim the name.activate()no longer drops loading items, and the bundled navigation plugin's overflow menu no longer disables them. The page shows the panel once its bundle registers. TheExperimentalSidebarNavigationItem.isLoadingJSDoc is updated to match, and the plugin SDK is bumped to 0.6.171.item.isLoading, and most disable the button themselves: SawyerHood compact-nav/nav-rail, tarasenko-by spaces, VanDalkvist collapsible-navigation, wy3z cursor-suite, smsunarto gtd-sidebar, gpambrozio, Johannes-Berggren jb-flow, davideiffert herdr-theme and devalextelematika BBDesk. They keep the old no-op until they drop|| item.isLoading. Plugins that callactivate()on a loading item now navigate.How you verified
New tests, which fail on origin/main and pass here:
components/plugin/plugin-frontend-gates.test.tsxdrives the real reconcile and slot store, with one plugin loaded and one bundle that never resolves.SidebarNavigationRail.test.tsx: "opens a remembered plugin panel clicked before its bundle registers".markdown-message-directives.test.tsx: a directive is held, then mounts or falls back to literal text, both on its own line and inside a paragraph. 4 tests.pnpm exec turbo run test typecheck --filter=@bb/app --filter=bb-plugin-navigation --filter=@get-bb/plugin-sdk --filter=@bb/domainpasses: app 7255 tests, SDK 444, navigation 14, domain 340.turbo run lintis clean.Live A/B: production
pnpm start:worktreebuilds of origin/main and this branch, the default plugin set (26 bundles), headless Chrome at 1440×900, medians. A delayed bundle was held back 4 s with request interception.::inline-vis{…}shown as text in an assistant messageFirst paint and the first show of the remembered tab are unchanged; that tab never waited on other bundles for its first render. The gain is no remount, nav clicks that work while a bundle loads, and no directive source-text flash.