Skip to content

Load plugin surfaces and core contributions from chunks with one lazy helper - #8152

Merged
ymichael merged 1 commit into
mainfrom
bb/prototype-lazy-plugin-bundles-thr_2s4y24ssi4
Nov 25, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/prototype-lazy-plugin-bundles-thr_2s4y24ssi4

Conversation

@ymichael

@ymichael ymichael commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Every enabled plugin's app bundle was one ESM file, so all of it downloaded and evaluated at startup whether or not its surfaces rendered. On a cold thread load all 26 bundled plugin bundles arrived before the thread was interactive, and git's entry pulled the @pierre/diffs runtime in with it.

Core contributions had the mirror problem. They register from modules that load with the app, so everything their registration file imports statically lands in that payload. They cannot use the app's defineSplit preload tier, because bb/core-contribution-imports limits them to the public SDK. #8095 worked around this with a hand-written import() and no preload, and bb's Info rows then popped in above the Git plugin's rows. Every feature that moves behind the plugin boundary would hit the same choice: grow startup, or hand-split and pop in.

What changed

  • One lazy primitive, experimental_lazy(load) on @get-bb/plugin-sdk/app, with the same loader shape as React.lazy. It returns an ExperimentalLazyComponent<Props> to pass straight to a slot.
    • It has one implementation (apps/app/src/lib/lazy-component.tsx): a preload-tier defineSplit, warmed at idle once startup and plugin frontends settle, with the same download retries and a direct render once loaded.
    • The plugin runtime and the core binding (core-plugin-sdk-app.ts) serve the same function.
    • A final load failure crashes the slot into onCrash.
    • React.lazy keeps React's meaning.
    • SDK 0.6.203.
  • One host loading rule (useOrderedReveal in apps/app/src/lib/lazy-parts.ts), applied to Info rows and sections, context card rows and sections, context segments, the rail, settings, setup-guide and homepage sections, and thread header rows:
    • An entry shows once every entry above it is ready.
    • Entries below a loading entry wait at most 3 seconds; after that the host shows what is ready.
    • The late entry is inserted in its place when it arrives, moving the entries below it once.
    • Eager entries that register later behave as before.
    • bb's entries and plugins' follow the same rule.
    • Hosts find lazy components through PLUGIN_APP_COMPONENT_FIELDS, a typed list next to the SDK's registration collector in which every slot kind names its component fields, including nested ones such as composer banners.
  • Page owners: the plugin that owns the page (a plugin panel route or its settings page) loads first, prefetches its lazy chunks with its entry, and publishes its registrations once they load, bounded the same way.
  • Core contributions:
    • The rail outline's component moved behind experimental_lazy (core-contributions/components/ThreadOutline.tsx).
    • Core registrations load at startup, and the thread route starts their lazy parts alongside the thread view, so the outline arrives with the page.
    • docs/ui-code-splitting.md describes how core contributions split.
  • Guard:
    • bundle-budget.json adds src/core-contributions/components/* as a split boundary for boot, ThreadPage and NewThreadPage. The checker expands dir/* patterns.
    • ThreadPage limits drop by the measured win (7.1 KB raw, 1.0 KB brotli). Boot limits are unchanged; boot grew 3.9 KB raw / 1.2 KB brotli within them.
  • Build and serve:
    • Each dynamic import() in a plugin becomes a chunk under dist/chunks/, listed in app.meta.json.
    • A bundle with chunks has artifactFormatVersion: 2, which older bb versions refuse.
    • The server serves chunks only under the bundle's content hash, checks each chunk's sha256 on read, and keeps or deletes chunks with the artifact directory on rollback and uninstall.
    • Chunk CSS stays in the single scoped app.css.
  • Slot Suspense: every plugin slot now renders inside its own <Suspense fallback={null}> (PluginSlotMount.tsx), so a lazy component that is still loading leaves only its slot empty. This also applies to any plugin component that suspends for another reason: it now renders nothing inside its slot instead of suspending to the page's loading state.
  • Plugins: Git (Diff tab, commit dialog), Automations (panel, thread Info section), Account Pooler and bb connect (settings and setup-guide sections) load those surfaces lazily. Composer's existing paste-time import() now splits.
  • Test timing: exclusive-pick-first-paint.test.ts imports composer-provider at collection time. Its first case paid about 3.9 s of cold module transform inside the test (other cases took about 0.1 s) and timed out under a loaded parallel run; it now takes 131 ms.
  • Docs: docs/api_to_audit.md entry with its core callers, Plugin Guide card lazy-components, and the bb-plugin-authoring skill (frontend-registration.md, quickstart.md). bb plugin build lists chunk files. demo-server copies chunks.

No daemon wire change.

How you verified

Cold loads of a real thread page from pnpm start:worktree in headless Chromium, with an empty cache per run. Main (ce81bd5) and this PR alternated in four blocks with the same plugin state, 18 runs per side (14 for module eval); medians:

main this PR
All JS before thread interactive (HTTP/1.1, 4x CPU) 1,696 KB br 1,454 KB br
Plugin module eval before interactive, 4x CPU (CPU profile) 148 ms 132 ms
Thread interactive, HTTP/1.1, 4x CPU 1,427 ms 1,391 ms
Thread interactive, HTTP/2, 1x CPU 317 ms 321 ms

HTTP/2 shows no change with 50 ms added latency either (638 vs 645 ms), or with a 2.5 MB/s cap (902 vs 901 ms). The win is the bytes and module evaluation that leave the startup path; time to interactive moves only slightly.

Slow 4G (562.5 ms RTT, 1.44 Mbps), desktop and phone widths, compared frame by frame with main:

  • Info rows and sections, the rail outline, the commit dialog, the Automations panel and the setup guide's bb connect section render in the same order and layout as main.
  • Settings sections arrive sooner: bb connect's at 12.8 s (main 20.3 s) and Account Pooler's at 12.9 s (main over 20 s). On bb connect's page the section now arrives before the plugin's Configuration form fills in, so on phone the form pushes it down once (layout shift 0.06).
  • The Diff tab, clicked as soon as it appears, shows an empty panel for about 0.9 s while its chunk loads; once warmed (any later click), it renders in 5 ms, as on main.
  • Git's Commit button and context card arrive 0.6–1.0 s later (22.9–23.4 s vs 22.3–22.8 s), because the idle chunk downloads share the link with Git's status requests.
  • An aborted chunk crashes only its slot: the Diff tab and Automations panel show their crash state while Info and the composer keep working.

bb plugin dev on a split plugin rebuilt an edited lazy panel, updated the open page without a reload, served it under a new hash, and returned 404 for the old chunk. A git-installed split plugin whose update crashed rolled back to its previous hash, kept serving that version's chunk and rendered it; uninstalling it returned 404 for the chunk and deleted its files.

Tests added, each failing on main:

  • split build and stale-chunk cleanup (build-plugin-app.test.ts);
  • hashed chunk serving, stale-chunk refusal and format version (plugin-app-bundle.test.ts);
  • rollback keeps chunks (plugin-update.test.ts);
  • the reveal rule, including a late entry inserted in place after the bound, first-commit render and crash containment (lazy-parts.test.tsx, PluginSlotMount.test.tsx);
  • every registered component, nested composer parts included, and no non-component functions (plugin-app-component-fields.test.ts);
  • page-owner publishing and chunk prefetch (plugin-frontend-load-order.test.ts, plugin-frontend.test.ts).

pnpm exec turbo run typecheck lint test passes for every touched package, and node apps/app/scripts/check-bundle-budget.mjs passes. Making the outline eager fails the budget check with "ThreadOutline.tsx is eager in ThreadPage".

🤖 Generated with Claude Code

AGENT GENERATED

… helper

Every enabled plugin's app bundle was one ESM file, so all of it downloaded
and evaluated at startup, and git's entry pulled the @pierre/diffs runtime in
with it. Core contributions had the mirror problem: they register from modules
that load with the app, cannot use defineSplit, and a hand-written import()
made bb's own Info rows pop in above plugin rows.

experimental_lazy(load) on @get-bb/plugin-sdk/app is the one lazy primitive
for both. It is a preload-tier defineSplit served to plugin bundles and bound
for core contributions, so parts warm at idle, retry downloads, render in
their first frame once loaded, and crash only their slot when a chunk fails.

Stacking hosts (Info, context card, context segments, the rail, settings,
setup-guide and homepage sections, thread header rows) reveal an entry only
once every entry above it is ready and hold entries below a loading one for
at most 3 seconds; a late entry is then inserted in its place when it arrives.
Hosts find lazy components through a typed list of each slot kind's component
fields next to the SDK's registration collector. The plugin that owns the page
loads and prefetches its lazy parts before it publishes, and the thread route
starts core contributions' lazy parts with the thread view.

The plugin build splits each dynamic import into dist/chunks/ and stamps
artifactFormatVersion 2, which older bb versions refuse. The server serves
chunks only under the bundle's content hash and checks each chunk's digest;
rollback and uninstall keep and delete them with the artifact.

The rail outline, Git's Diff tab and commit dialog, the Automations panel and
Info section, and the Account Pooler and bb connect settings load lazily. A
split boundary keeps every core-contribution component module out of boot
and both page journeys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/prototype-lazy-plugin-bundles-thr_2s4y24ssi4 branch from 9e3fc4f to aab393c Compare November 25, 2026 01:05
@ymichael
ymichael merged commit 6547791 into main Nov 25, 2026
53 checks passed
@ymichael
ymichael deleted the bb/prototype-lazy-plugin-bundles-thr_2s4y24ssi4 branch November 25, 2026 23:55
ymichael added a commit that referenced this pull request Nov 26, 2026
…n needs them (#8203)

## Human comments

## What was wrong

#8152 was squash-merged from its first commit only. The three follow-up
commits on the branch were never pushed, so two load-order fixes for
lazy plugin parts did not land:

- A lazy chunk's shim waits for its host-loaded runtime slots, such as
the 556 KB diff viewer, before the chunk evaluates. That wait only
starts once the chunk has downloaded. So reloading a thread with Git's
Diff tab open fetched the chunk and then the diff viewer, one after the
other.
- A lazy part only started loading when its host rendered it or at idle
warming. The restored Diff tab requested its chunk about a second after
Git's code had run. A plugin's own page also waited for every lazy part
of that plugin, including parts the page does not show.

## What changed

- **Chunk downloads start their slots too.** `bb plugin build`
(`packages/plugin-build/src/build-plugin-app.ts`) rewrites each dynamic
import of a chunk to call `loadRuntimeSlot` for the host-loaded slots in
that chunk's static import closure that the entry does not already load.
The chunk and its slots download together, and the shim's own call joins
the pending load. `HOST_LOADED_RUNTIME_SLOTS` in `runtime-shims.mjs`
lists those slots.
- **The restored screen's lazy parts start early.**
`apps/app/src/lib/restored-lazy-parts.ts` lists, before plugin frontends
load, the parts the restored screen shows:
  - a plugin's settings sections on its settings page
  - its nav panel on its own page
- on a thread route, the open right-panel tab from the thread's saved
panel state: a plugin tab, a plugin panel action, or every plugin's Info
rows and sections

A plugin that a listed part names prefetches its lazy chunks with its
entry. Its listed parts start loading as soon as its registrations are
collected. Only a plugin's own page or settings page holds its publish,
and only for the parts that page shows, with the same 3-second limit.
This replaces the old page-owner rule.
- **Boot stays small.** Boot works out the settings-page and plugin-page
parts synchronously with `restoredPageLazyParts`, which only matches the
route. `readStoredPanelTabs` moves into `fixed-panel-tabs-state.ts`, so
client-core's panel-state parser stays out of boot. Thread-panel parts
start when the plugin loader runs. Boot is 417.1 KB brotli, against
416.5 KB on main.
- **Doc comment fix.** `PluginSdkApp`'s doc comment moves back onto
`PluginSdkApp`. It had attached itself to `ExperimentalLazyComponent`.
- **SDK version bump to 0.6.204.** `app-contract.ts` changes here, and
#8152 and #8158 both shipped 0.6.203.
- **Docs.** `docs/ui-code-splitting.md` and the `experimental_lazy`
entry in `docs/api_to_audit.md` describe the new behaviour.

No wire, daemon-protocol or CLI changes.

## How you verified

**Performance**, measured on `pnpm start:worktree` with the same data
dir for both builds. Base is `65477919199` (#8152); after is this PR.
Each run used headless Chromium at 1440×900 with an empty cache and a
localStorage snapshot from a returning user (Git remembered as the
panel-tab provider). Slow 4G is CDP at 562.5 ms RTT and 1.44 Mbps.
Values are medians of 5 runs, and run-to-run spread was under 0.15 s on
Slow 4G.

| Scenario | Base | After |
| --- | --- | --- |
| Reload a thread with the Diff tab open, Slow 4G: diff visible | 27.41
s | 27.14 s |
| Same: Diff tab chunk starts / diff viewer starts | 14.05 s / 19.00 s |
10.13 s / 10.81 s |
| Same, unthrottled: diff visible | 539 ms | 503 ms |
| Cold thread load, composer visible: Slow 4G / unthrottled | 11.15 s /
283 ms | 11.16 s / 253 ms |
| Reload onto bb connect settings, Slow 4G | 13.14 s | 13.11 s |
| Reload onto the automations page, Slow 4G | 11.74 s | 11.74 s |

The Diff tab's code now arrives about 8 s earlier on Slow 4G, but the
diff shows only 0.27 s sooner. What holds it back is Git's RPC chain:
`status` runs twice in a row, each 432-byte response takes 4.5–7 s on
the shared link, and then `files` and `fileSide` follow.

An earlier version of this PR loaded the restored-part check with a
dynamic import. That put it inside the 157 KB plugin-frontend chunk,
which delayed bb connect's settings by 0.9 s on Slow 4G (14.03 s). The
current version measures at 13.11 s.


- `pnpm exec turbo run typecheck --filter=@bb/app
--filter=@bb/plugin-build --filter=@get-bb/plugin-sdk
--filter=@bb/server` passes.
- `pnpm exec turbo run test --filter=@bb/plugin-build
--filter=@get-bb/plugin-sdk` passes. That includes the new
`build-plugin-app.test.ts` cases for the slot preloads that dynamic
imports start.
- `pnpm exec turbo run test --filter=@bb/app` passes: 711 files, 7,526
tests. That includes the new `restored-lazy-parts.test.ts` and the
updated `plugin-frontend-load-order.test.ts`.
- `node .github/workflows/check-plugin-sdk-version.mjs` passes.
- `node apps/app/scripts/check-bundle-budget.mjs` passes after a local
`turbo run build --filter=@bb/app`.

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

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 26, 2026
#8152 replaced hand-written import() splits in core contributions with
experimental_lazy, and #8203 starts the restored screen's lazy parts,
including every plugin's Info rows and sections when Info is the restored
panel tab. Register bb's Info rows and sections as experimental_lazy parts
(components in core-contributions/components/ThreadInfoEntries.tsx) so the
host's ordered reveal holds them like plugin entries, and start them from
bootPluginFrontends with the same restoredLazyParts list.

ThreadInfoSlots shows the pending marker while the reveal holds an entry,
since a lazy part no longer suspends into the host. core-contribution-parts
imports plugin-slots first: the core binding's ThreadInfo reaches
plugin-slots, which collects the core contributions at module load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Nov 26, 2026
## Human comments

## What was wrong

bb's Info tab was registered through the public tab slot, but its body
was not public. `ThreadSecondaryPanel` filled a private React context
(`ThreadInfoContentContext`) with `<ThreadMetadataContent>`. That
component took 18 props built in `ThreadDetailView` and merged a
core-only array of seven rows and three sections with plugin
registrations. No plugin could build or replace that body. Core rows
read private host state that plugin rows can't reach (audit V8,
core-contributions rank 8).

Emptiness was also decided from core fields alone.
`hasAnyThreadMetadata` (`ThreadDetailSecondaryContent.tsx`) showed "No
thread details available." whenever core saw no environment, parent,
provisioning failure, archive or forks. That hid every plugin row and
section, and core's own Parent and Project rows (a-thread F12). Repro on
main: a pending thread with no environment and an automation targeting
it shows only "No thread details available."; the Automations section is
hidden.

Main's provisioning-failure row was also wrong. It scanned the cached
timeline for a `systemKind: "error"` row titled "Provisioning thread
failed". `normalize-provisioning-failures` replaces that row with an
`operation` row, so a real failure (a worktree whose repository is gone)
showed "No thread details available." instead of "Environment: Not
created · provisioning failed". Nothing durable recorded the failure:
the thread only moved to `error`, which a lost start, a refused start
command or `provider.failed` before start also do.

## What changed

**The Info tab is the public host**
- `experimental_ThreadInfo` (component, `ExperimentalThreadTabProps`) is
the Info body. Implementation:
`apps/app/src/components/secondary-panel/info/ThreadInfo.tsx`.
- It renders every `threadInfoRow` and `threadInfoSection`, bb's own
included, through the same mount path.
  - It shows a skeleton while the thread loads.
- It shows "No thread details available." only when no `dt` and no
`[data-info-section]` rendered.
- `apps/app/src/core-contributions/thread-info.tsx` (plus
`thread-info/*.tsx`) registers:
  - the `info` fixed tab;
- the seven rows: Parent, Notify parent, Project, Environment and
Machine, provisioning failure, Directory, Archived;
  - the three sections: Child threads, Forks, Thread storage.
- They import only `@get-bb/plugin-sdk` and registry components;
`bb/core-contribution-imports` is green.
- The registration module stays light. The components live in
`core-contributions/components/ThreadInfoEntries.tsx` (inside #8152's
`src/core-contributions/components/*` split boundary), and each row and
section is an `experimental_lazy` part, the helper #8152 added for core
contributions. The host's ordered reveal (`useOrderedReveal`) holds them
like plugin entries. `ThreadInfoSlots` renders a pending marker while
the reveal holds an entry, and the host shows its skeleton rather than
the empty text.
- When Info is the restored panel tab, bb's rows and sections start
through #8203's restored-parts path: `bootPluginFrontends` passes the
same `restoredLazyParts` list to `startRestoredCoreContributionParts`
(`apps/app/src/lib/core-contribution-parts.ts`). Calling
`readStoredPanelTabs` from boot instead would add 12.5 KB raw / 2.3 KB
brotli, which #8203 kept out.
- `vite-core-plugin-sdk-app.ts` resolves the one core binding with
`moduleSideEffects: false` (the same option as #8088), so each importer
pulls in only the members it uses.
- Boot payload: 1661.3 KB raw / 417.3 KB brotli against main's 1657.4 KB
raw / 417.1 KB brotli, inside the 1682.1 KB / 419.1 KB budget, with no
split-boundary violations.
  - `plugin-slots.ts` puts them first in the slot lists plugins join.
- Removed:
  - `ThreadInfoContentContext` and `thread-info-registration.tsx`;
  - `ThreadMetadataContent` and its 18-prop `metadata` plumbing;
  - `metadataContent` on the secondary panel;
  - `hasAnyThreadMetadata`;
  - the private parent-thread subset query;
- `useThreadTimelineProvisioningFailure` and
`thread-provisioning-failure.ts`.
- Section collapse state is stored under `<pluginId>/<id>` for every
section; bb's own are `bb--core/<id>`. The `infoPanel.collapsedSections`
schema maps the legacy bare ids `childThreads`, `forks` and
`threadStorage`, so existing collapsed state carries over.

**New and changed public API (plugin SDK 0.6.205)**
- `experimental_useEnvironment(environmentId):
ExperimentalEnvironmentState`
- States: `loading`, `ready` with `environment`, `notFound`, `error`,
the same as `experimental_useThread`.
- `ExperimentalEnvironment` = `environments.get`'s `Environment` plus
`label` and `host: { id, name, connected, local, named, machineProvider
} | null`.
- It reads the same realtime-kept environment, hosts and provider
queries the thread view uses.
- `label` comes from core's
`formatEnvironmentDisplay`/`getEnvironmentWorkspaceInfoDisplay`.
  - `named` and `machineProvider` carry core's Machine-row rules.
- `GET /api/v1/hosts/:id?includeRemoved=true` / `useSdk().hosts.get({
hostId, includeRemoved })` returns a removed machine, disconnected, so
the Machine row keeps naming it.
- `experimental_useThreadStorageFiles(threadId, { enabled? }):
ExperimentalThreadStorageFilesState`
- States: `loading`, `ready` with `files`, or `error` with
`errorMessage` (core's error text).
- `enabled: false` pauses the read and keeps the last list, the same
option shape as the RPC query hooks. Core's Thread storage section
pauses it while the Info tab is hidden or the machine is offline.
- `experimental_searchPickerOptions({ options, query, getLabel,
getAliases? })` exposes bb's picker ranking.
- It is named after `searchPickerOptions`, which moved from
`@bb/shared-ui/picker-search` into `@bb/fuzzy-match`.
  - Core and the SDK runtime now share that one function.
- `ExperimentalThread.runtime.failure: "provisioning" | null`.
- Stored in the new nullable `threads.failure_kind` (migration
`0172_thread_failure_kind`, generated by drizzle-kit).
- Written only in `writeThreadLifecycleStateInTransaction`: set when
`provisioning.failed` moves the thread to `error`, cleared on every
other status move.
- Filled by the runtime builders for `threads.get`, sidebar entries and
status-change realtime.
  - Server to client only; no daemon protocol change.
- Type-only widening, already supported at runtime:
`ExperimentalThreadTitleTextProps.tooltip`.

**Registry components (no SDK member)**
- Moved from `apps/app` into `@bb/shared-ui` and published by
`plugin-registry`:
  - `option-picker` (13 app callers repointed);
  - `thread-unarchive-button`;
  - `truncate-path-middle`;
  - `thread-storage-tree`;
  - `use-thread-storage-browser`;
  - `right-panel-file-visuals`.
- Newly published: `info-list-row`, `copy-button`,
`list-loading-placeholder`, `picker-layout`, `use-reset-picker-scroll`,
and a new `info-list-more-row`.

**Docs**
- `docs/api_to_audit.md`:
- new entries for `experimental_useEnvironment`,
`experimental_useThreadStorageFiles` and
`experimental_searchPickerOptions`;
- updated entries for Info rows/`experimental_ThreadInfo`,
`experimental_useThread` (`runtime.failure`), panel tabs, unified tabs
and thread-title text.
- Plugin Guide `surfaces.ts` and the anatomy manifest.
- bb-plugin-authoring `frontend-registration.md` and
`frontend-components.md`.
- `docs/configuration.md` row for `infoPanel.collapsedSections`.

**Core callers on the shared path**
- Every core Info row and section and the Info tab itself
(`thread-info.tsx`) run on the public slots and hooks.
- `ThreadInfoRows`/`ThreadInfoSections` mount core and plugin entries
identically.
- The lazy panel placeholder renders the same `ThreadInfo`.
- `BranchPicker`, `ProjectSelector`, `ModelReasoningPicker` and machine
search call the same `searchPickerOptions`.

**Visible changes, all intended**
- A thread with no environment, parent, failure, archive or forks now
shows its Parent and Project rows and any plugin rows or sections,
instead of "No thread details available." (F12).
- A real provisioning failure now shows "Environment: Not created ·
provisioning failed".
- Thread storage no longer marks the file open in a split panel pane, or
opens folders and expands "N more" to reveal it. That highlight only
showed with Info and the file side by side, and reading it publicly
needed a required `target` on every file tab. Removed with `InfoList`'s
`revealIndex`, which existed only for it.
- Everything else matched main on live data (see below).

## How you verified

**Live, one dev server, main's app bundle via a proxy against the
branch's bundle on identical data:**
- Info card element screenshots are pixel-identical for:
- a child thread (Parent link, Notify parent "When stuck", Project,
Environment, Directory, Git rows);
  - an archived thread (Archived row with Unarchive);
  - a fork.
- On the root worktree thread (Child threads, Forks, Thread storage) the
only difference is the relative time "3m" against "4m", from capture
timing.
- Parent picker options are identical ("None", "Fork of QA"; the child
and the archived thread excluded).
- Opening a storage file opens the same tab on both builds.
- F12: the pending thread with an automation shows "No thread details
available." on main. On the branch it shows Parent, Project and the
Automations section.
- Provisioning failure: a worktree thread whose repository was deleted
before dispatch. Main shows "No thread details available."; the branch
shows "Environment: Not created · provisioning failed". The DB row has
`failure_kind = 'provisioning'`.
- Two machines (a second daemon enrolled on the dev server): the Machine
row is pixel-identical on main and branch for a thread on each machine.
- Removed machine (host set to `destroyed` in the dev DB, then
restored): both builds show "Unavailable — machine removed" with Machine
"Studio (second)". The branch gets the name from `hosts.get({
includeRemoved: true })`.
- Removing machine (host `phase = 'removing'`): both builds show
"Machine removal in progress" with the machine named. Pixel-identical.
- Split panes (Root and Child threads side by side): the Info panel
follows the focused pane on both builds. Pixel-identical for the child;
the root differs only in the Forks collapse state.

**Tests (each fails on main for the behaviour it covers):**
- `ThreadInfo.test.tsx`, 7 tests:
  - plugin section plus core rows on a thread without metadata;
- Environment label, Machine row and new-thread action with two
machines;
  - removed machine named through the removed-host read;
  - provisioning failure shown only for `runtime.failure`;
  - archived thread read by id;
  - child threads and forks;
- parent options (children first; self, descendants, side chats and
other projects excluded).
- `lifecycle-failure-kind.test.ts`: `provisioning.failed` sets the
failure. A lost start, a refused start command, `provider.failed` before
start and a deleted environment row leave it null. A retry clears it.
The check covers the column, `threads.get` and the list entry.
- `public-host-get-removed.test.ts`: `includeRemoved` returns a removed
host; a plain GET still 404s.
- `public-ui-preferences.test.ts`: legacy section ids map to
`bb--core/*`.
- `ThreadInfoSlots.test.tsx`: updated so the "core" entries are a plugin
registered first, and it settles bb's lazy Info entries before
asserting.
- `core-contribution-parts.test.ts`: bb's Info rows and sections start
loading when Info is the restored tab and not for another restored tab.

**Commands:**
- `pnpm exec turbo run typecheck lint --filter='...[origin/main]'`:
168/168.
- `pnpm exec turbo run test` for @bb/app, @bb/server, @bb/db,
@bb/domain, @get-bb/plugin-sdk, @bb/shared-ui, @bb/fuzzy-match,
@bb/plugin-registry, @bb/sdk, @bb/server-contract, @bb/test-helpers,
demo-server, bb-guide, the Git plugin and plugin-api-docs: all green.
- `node apps/app/scripts/check-bundle-budget.mjs` after `turbo run build
--filter=@bb/app`: OK (numbers above). `drizzle-kit generate`: no schema
changes after 0172.
- After rebasing onto #8152/#8203, live on `pnpm start:worktree`: the
Info tab on the root thread shows the same rows, Git rows and sections.
A reload with Info restored requests the Info chunk 122 ms in, right
after the plugin loader chunk. The provisioning-failure and
pending-automation threads show what they did before.

## Plugin author impact

One type-only break. Runtime values are unaffected: the host always
sends the field. Plugin code typed against these shapes needs it when it
builds them, which in practice means test fixtures.
- **`runtime.failure` is required** on `ExperimentalThread`
(`ThreadWithRuntime`) and thread list entries. Add `failure: null` to
literal `runtime` objects. In the community corpus (504 folders), 31
folders build `runtime: { displayStatus }` literals, all in tests or
test helpers. Only the ones typed as these thread shapes break.
Examples: tobi/bb-bots-sidebar `tests/workflow-runs.test.ts`,
openwizdev/WizPlugins wizbar tests, VKirill/bb-plugin-project-folders
`auto-archive.test.ts`.

I did not edit these plugins.

**Community callers that can migrate (not edited):**
- environment reads in the app: 14 folders call
`useSdk().environments.*` and about 10 call `hosts.*` as one-shot
fetches, e.g. SergeyGavrilov/bb-diff-tree, wy3z/bb-cursor-suite
agent-pills;
  - storage files: 9 folders call `threads.storageFiles`.
- The KosachMax/bb-plugin-notion-theme CSS on `dl [data-info-section]`
still matches.

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

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Dec 1, 2026
## Human comments

## What was wrong

One piece of thread context, such as the parent thread or a pull
request, needed separate registrations for each surface: a context
segment above the composer and a context card row or section. They were
linked only by a rule each plugin hand-wrote: hide the segment in panes
that show the card. Core, Git and GitHub PR Status each carried that
rule, and so do at least six community plugins (audit a-thread F7).
Core's own parent segment, parent row and Child threads section also
read private modules and mounted outside the slot crash boundary.

The segments' `environment` was also gated on git eligibility
(`contextEnvironmentId`, the other half of F7), while card rows, Info
rows and tabs got the thread's environment. So the same prop meant
different things on different surfaces.

## What changed

- **One registration per piece of thread context.**
`app.slots.experimental_threadContextItem({ id, title, group, order?,
banner?, card? })`.
- `banner` is a context row segment: `{ summary, action?, details?,
useVisible? }`.
  - `card` is `{ row }` or `{ section }`.
  - A plugin registers only the parts it draws.
- bb places them. The banner part shows in `banner` panes, and in `card`
panes too when the item has no card part, so no pane shows the same
thing twice. In a `card` pane the banner part's `useVisible` does not
run.
  - The collector rejects:
    - an item with no parts;
    - a card with both or neither of `row` and `section`;
- an item id the plugin already uses for an item, segment, card row or
card section.
- **Callers moved.** These now register items, each with one shared
group and order:
- core's parent thread (banner and card row) and Child threads (card
section), importing only the public SDK;
  - the Git plugin's changed files (banner and card row);
  - GitHub PR Status's pull request (banner and card row).
- **The old slots keep working.**
- `threadContextItemsOf` (`apps/app/src/lib/plugin-slots.ts`) adapts
every legacy segment, card row and card section onto a one-part item.
The banner and the card read one slot kind, and plugins built against
older SDKs run unchanged.
  - Legacy segments still show in both kinds, as before.
- `CapturedPluginApp` adds `threadContextItems` and keeps the legacy
arrays.
- **`contextKinds` is gone.** It never shipped on main.
- **F7b: segments get the thread's environment**, as card rows, Info
rows and tabs do; `null` remains only for embedded `ThreadChat`.
- The git gate only ever affected non-git environments. For a removed
machine or a destroyed environment, the composer already shows read-only
history, which never renders plugin segments.
  - The Git segment still needs a git status with a workspace.
  - PR Status still needs a pull request.
- **Order.** `experimental_THREAD_INFO_ROW_GROUPS.pullRequest` is now
`2_pullRequest`. The pull request now sorts before Git in the card and
the Info tab, matching the banner.
- **Lazy loading (#8152).**
- `PLUGIN_APP_COMPONENT_FIELDS` learns nested part paths
(`banner.summary`, `card.component`).
  - The banner and card hosts keep `useOrderedReveal` over items.
- **Core rows on the public SDK.**
- `experimental_useThread`, `navigate.experimental_threadHref`,
`navigate.toThread` and `experimental_useSidebarThreads()`.
- The new pure `experimental_threadDisplayTitle`, which core's
`getThreadDisplayTitle` also returns.
  - `inline` on `ExperimentalThreadTitleTextProps`.
- `experimental_ThreadContextCardRow` in the core binding, resolved
side-effect-free (`moduleSideEffects: false`) to keep the boot payload
in budget.
- `ThreadContextCardCore.tsx` and `useParentThreadSection.ts` are
deleted.
- **Docs.**
- `docs/api_to_audit.md`: a new thread context items entry, and the
card, segment, `experimental_useThread` and
`experimental_threadDisplayTitle` entries updated.
  - Plugin Guide `surfaces.ts` and the anatomy manifest anchors.
- The bb-plugin-authoring references `frontend-thread-context-card.md`,
`frontend-registration.md`, `frontend-core-slots.md` and
`frontend-components.md`.
- JSDoc for `experimental_useThreadContextKind` and the card row and
section docs (the card experiment is retired).
- SDK 0.6.213.

Visible differences from main:

- **Pull request before Git.** The card and the Info tab now list the
pull request before Git: "Parent, PR, Changes" in the card, and
"…Directory, Pull request, Branch, Git status" in the Info tab. The
banner already showed "PR, changed files".
- **Parent group label.** The parent segment's summary gains the slot's
`role="group"` "Parent thread" wrapper.
- **Cmd/Ctrl-click on the parent link** opens a split, like bb's other
thread links.
- **Archived child in a wide pane.** The read-only banner hides the
parent, which the card shows, and shows Unarchive in its place (approved
Nov 24).

## How you verified

- **Tests.**
- `ThreadPromptContextBanner.segments.test.tsx` runs one placement table
against core's parent thread, the Git item and a third-party item in
`card` and `banner` panes. A banner-only item and a legacy segment show
in both.
  - The existing focus-handoff table passes unchanged.
- `plugin-app-thread-context-item.test.ts` covers collection, every
rejection, and id collisions in both registration orders. Legacy
segments and card rows may still share an id.
- `plugin-app-component-fields.test.ts` finds an item's nested lazy
components.
- `PluginThreadContextCard.test.tsx` runs on core items plus legacy
plugin rows and sections.
- **Checks.**
- `pnpm exec turbo run typecheck lint test` passes for `@bb/app`,
`@get-bb/plugin-sdk`, `@bb/plugin-registry`, `@bb/domain`,
`@bb/scripts`, `bb-plugin-bb--git`, `bb-plugin-bb--github-pr-status`,
`bb-plugin-plugin-api-docs` and `bb-plugin-bb-guide` (32/32).
  - The boot bundle budget and the plugin SDK version guard pass.
- Rebased onto `946ba1822a7`: the same 9 packages pass typecheck, lint
and test, except one `@bb/app` test that timed out under a load average
of ~70. It and two other load-sensitive app test files pass when run
alone (408/408, twice).
- **Live A/B, main (`2a21dd56f69`) against this branch.** I ran `pnpm
start:worktree` from each build in turn on one data directory, so
server, plugins and app all came from the same build.
  - Fixtures:
    - a parent with three children and one archived child, and a fork;
- a child and parent on a git clone of this branch with an uncommitted
change and PR #8088 open;
    - a thread on a plain folder.
- At 1000px (banner) and 1700px (card), element screenshots are
pixel-identical for:
    - the parent, fork and archived-child banners;
    - the git child's and git parent's banners (PR, changed files);
    - the parent, fork and archived child card rows;
    - the Child threads section;
    - the plain-folder card;
    - a two-pane split.
  - The fork card differs by 10 pixels along its edges (anti-aliasing).
  - The plain-folder thread shows no Git or PR rows on either build.
  - The only other differences are the visible changes listed above.
  - Navigation is identical on both builds, with no page reload:
    - the banner parent link;
    - the card parent row and a Child threads row;
    - the parent link inside a two-pane split.

> AGENT GENERATED

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
scowalt pushed a commit to scowalt/bb that referenced this pull request Dec 1, 2026
## Human comments

## What was wrong

One piece of thread context, such as the parent thread or a pull
request, needed separate registrations for each surface: a context
segment above the composer and a context card row or section. They were
linked only by a rule each plugin hand-wrote: hide the segment in panes
that show the card. Core, Git and GitHub PR Status each carried that
rule, and so do at least six community plugins (audit a-thread F7).
Core's own parent segment, parent row and Child threads section also
read private modules and mounted outside the slot crash boundary.

The segments' `environment` was also gated on git eligibility
(`contextEnvironmentId`, the other half of F7), while card rows, Info
rows and tabs got the thread's environment. So the same prop meant
different things on different surfaces.

## What changed

- **One registration per piece of thread context.**
`app.slots.experimental_threadContextItem({ id, title, group, order?,
banner?, card? })`.
- `banner` is a context row segment: `{ summary, action?, details?,
useVisible? }`.
  - `card` is `{ row }` or `{ section }`.
  - A plugin registers only the parts it draws.
- bb places them. The banner part shows in `banner` panes, and in `card`
panes too when the item has no card part, so no pane shows the same
thing twice. In a `card` pane the banner part's `useVisible` does not
run.
  - The collector rejects:
    - an item with no parts;
    - a card with both or neither of `row` and `section`;
- an item id the plugin already uses for an item, segment, card row or
card section.
- **Callers moved.** These now register items, each with one shared
group and order:
- core's parent thread (banner and card row) and Child threads (card
section), importing only the public SDK;
  - the Git plugin's changed files (banner and card row);
  - GitHub PR Status's pull request (banner and card row).
- **The old slots keep working.**
- `threadContextItemsOf` (`apps/app/src/lib/plugin-slots.ts`) adapts
every legacy segment, card row and card section onto a one-part item.
The banner and the card read one slot kind, and plugins built against
older SDKs run unchanged.
  - Legacy segments still show in both kinds, as before.
- `CapturedPluginApp` adds `threadContextItems` and keeps the legacy
arrays.
- **`contextKinds` is gone.** It never shipped on main.
- **F7b: segments get the thread's environment**, as card rows, Info
rows and tabs do; `null` remains only for embedded `ThreadChat`.
- The git gate only ever affected non-git environments. For a removed
machine or a destroyed environment, the composer already shows read-only
history, which never renders plugin segments.
  - The Git segment still needs a git status with a workspace.
  - PR Status still needs a pull request.
- **Order.** `experimental_THREAD_INFO_ROW_GROUPS.pullRequest` is now
`2_pullRequest`. The pull request now sorts before Git in the card and
the Info tab, matching the banner.
- **Lazy loading (get-bb#8152).**
- `PLUGIN_APP_COMPONENT_FIELDS` learns nested part paths
(`banner.summary`, `card.component`).
  - The banner and card hosts keep `useOrderedReveal` over items.
- **Core rows on the public SDK.**
- `experimental_useThread`, `navigate.experimental_threadHref`,
`navigate.toThread` and `experimental_useSidebarThreads()`.
- The new pure `experimental_threadDisplayTitle`, which core's
`getThreadDisplayTitle` also returns.
  - `inline` on `ExperimentalThreadTitleTextProps`.
- `experimental_ThreadContextCardRow` in the core binding, resolved
side-effect-free (`moduleSideEffects: false`) to keep the boot payload
in budget.
- `ThreadContextCardCore.tsx` and `useParentThreadSection.ts` are
deleted.
- **Docs.**
- `docs/api_to_audit.md`: a new thread context items entry, and the
card, segment, `experimental_useThread` and
`experimental_threadDisplayTitle` entries updated.
  - Plugin Guide `surfaces.ts` and the anatomy manifest anchors.
- The bb-plugin-authoring references `frontend-thread-context-card.md`,
`frontend-registration.md`, `frontend-core-slots.md` and
`frontend-components.md`.
- JSDoc for `experimental_useThreadContextKind` and the card row and
section docs (the card experiment is retired).
- SDK 0.6.213.

Visible differences from main:

- **Pull request before Git.** The card and the Info tab now list the
pull request before Git: "Parent, PR, Changes" in the card, and
"…Directory, Pull request, Branch, Git status" in the Info tab. The
banner already showed "PR, changed files".
- **Parent group label.** The parent segment's summary gains the slot's
`role="group"` "Parent thread" wrapper.
- **Cmd/Ctrl-click on the parent link** opens a split, like bb's other
thread links.
- **Archived child in a wide pane.** The read-only banner hides the
parent, which the card shows, and shows Unarchive in its place (approved
Nov 24).

## How you verified

- **Tests.**
- `ThreadPromptContextBanner.segments.test.tsx` runs one placement table
against core's parent thread, the Git item and a third-party item in
`card` and `banner` panes. A banner-only item and a legacy segment show
in both.
  - The existing focus-handoff table passes unchanged.
- `plugin-app-thread-context-item.test.ts` covers collection, every
rejection, and id collisions in both registration orders. Legacy
segments and card rows may still share an id.
- `plugin-app-component-fields.test.ts` finds an item's nested lazy
components.
- `PluginThreadContextCard.test.tsx` runs on core items plus legacy
plugin rows and sections.
- **Checks.**
- `pnpm exec turbo run typecheck lint test` passes for `@bb/app`,
`@get-bb/plugin-sdk`, `@bb/plugin-registry`, `@bb/domain`,
`@bb/scripts`, `bb-plugin-bb--git`, `bb-plugin-bb--github-pr-status`,
`bb-plugin-plugin-api-docs` and `bb-plugin-bb-guide` (32/32).
  - The boot bundle budget and the plugin SDK version guard pass.
- Rebased onto `f253bb24cb7`: the same 9 packages pass typecheck, lint
and test, except one `@bb/app` test that timed out under a load average
of ~70. It and two other load-sensitive app test files pass when run
alone (408/408, twice).
- **Live A/B, main (`e9e0493838b`) against this branch.** I ran `pnpm
start:worktree` from each build in turn on one data directory, so
server, plugins and app all came from the same build.
  - Fixtures:
    - a parent with three children and one archived child, and a fork;
- a child and parent on a git clone of this branch with an uncommitted
change and PR get-bb#8088 open;
    - a thread on a plain folder.
- At 1000px (banner) and 1700px (card), element screenshots are
pixel-identical for:
    - the parent, fork and archived-child banners;
    - the git child's and git parent's banners (PR, changed files);
    - the parent, fork and archived child card rows;
    - the Child threads section;
    - the plain-folder card;
    - a two-pane split.
  - The fork card differs by 10 pixels along its edges (anti-aliasing).
  - The plain-folder thread shows no Git or PR rows on either build.
  - The only other differences are the visible changes listed above.
  - Navigation is identical on both builds, with no page reload:
    - the banner parent link;
    - the card parent row and a Child threads row;
    - the parent link inside a two-pane split.

> AGENT GENERATED

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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