Skip to content

Move bb's thread outline onto a public rail slot plugins can replace - #8089

Merged
ymichael merged 2 commits into
mainfrom
bb/thread-outline-public-api
Nov 24, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/thread-outline-public-api

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

bb's thread outline (ThreadTableOfContents) was core-only. It read the pane's private timeline rows and the bottom-anchored scroll element, scanned [data-timeline-row-id] in the DOM to find the prompt in view, and revealed messages through a private, pane-local messageRevealRequest instead of the public navigate.toThread(threadId, { messageSeq }). Plugins had none of these. In the community corpus, sticky-prompt, threadline, minimap, pinned-turns, bookmarks, chat-search, quick-reply and others rebuild the outline from the DOM: they scroll-probe to reach rows windowing has not drawn, send synthetic wheel events so bb does not snap back to the bottom, forge searchMessageSeq router state, or hide [data-thread-toc] with CSS to replace bb's outline. Design and kill-tests: thr_kr2zhuzxnn (DESIGN.md).

What changed

  • app.slots.experimental_threadRailOutline (exclusive) and app.slots.experimental_threadRail (additive). These mirror threadHeaderTitle and threadHeaderRow. PluginThreadRail renders a column at the conversation's right edge in thread pages and split panes. The outline goes at the top, chosen by the shared exclusive-slot rule from the new synced pick threadRail.outlineProvider (__builtin__ = bb's outline). It is set in Settings > Appearance > Interface > Thread outline, or with bb settings ui set threadRail.outlineProvider <pick>. Rail items stack below it by order. A crashing plugin outline falls back to bb's for that thread. While the pane is narrower than 56rem, the rail stays mounted, hidden and inert, and components get visible: false. visible is a prop because the sibling slot props pass host layout state that way (isCompactViewport).
  • experimental_useConversationOutline(threadId, role, { enabled? }) returns a thread's user prompts or assistant replies across the whole thread. It is the public conversation-outline route with the pane's loaded rows laid over it. Previews have the sender envelope stripped, and senderThreadId is set from it. Items keep their identity until an item changes.
  • experimental_useTimelineViewport() returns { visibleMessageIds, atLatest } for the pane the component renders in. It uses one shared, lazily attached observer per pane (TimelineViewportProvider in ThreadScreen) and updates once scrolling settles.
  • toThread(threadId, { messageSeq }) now reveals in place and replaces the history entry when the route, or the thread pane the caller renders in, already shows that thread. The pane case covers clicking the outline of an unfocused split pane: pane focus replaces the route, but toThread reads the route from the last render, so it used to push an entry there. Before, it pushed one entry per call, so Back stepped through reveals that did not move the view. This is documented in the JSDoc and in the audit entry.
  • bb's outline moved to apps/app/src/core-contributions/thread-outline.tsx.
    • It registers through experimental_threadRailOutline and imports only public SDK members and registry items; bb/core-contribution-imports passes.
    • The host collects it once as the builtin (BUILT_IN_THREAD_RAIL_OUTLINE), not as a claimant.
    • Its sender titles now come from experimental_useThread, so a sender thread the sidebar does not hold (an archived one, for example) shows its title instead of "Agent".
    • The experimental_use* imports are aliased to use* names, so the React Compiler treats them as hooks. The rail tests caught this.
  • Deleted: components/thread/toc/ and the private messageRevealRequest path (ThreadScreen state, the ThreadTimelineSurface/ThreadTimelineRows props, and the request ordering in SearchMessageLocationProvider).
  • useScrollOverflowState moved to @bb/shared-ui/use-scroll-overflow-state as a registry item (use-scroll-overflow-state), so core's outline and plugins import the same hook. Seven app callers switched imports. The registry r/ output was regenerated.
  • Core SDK binding (lib/core-plugin-sdk-app.ts) now re-exports useBbNavigate, experimental_useThread, experimental_useConversationOutline, experimental_useTimelineViewport, experimental_PromptMentionIcon and experimental_describePromptMention, from the same implementations plugins get.
  • Plugin SDK 0.6.196. The testing harness gains conversationOutlines and timelineViewport options and captures threadRails / threadRailOutlines.
  • Docs:
    • docs/api_to_audit.md: three entries naming the core callers, plus the toThread change.
    • Plugin Guide card thread-rail, with its anatomy entry and wireframe mark.
    • bb-plugin-authoring references/frontend-thread-rail.md, exclusive-slots.md and SKILL.md.
    • docs/configuration.md gets the new pick key; the demo server gets the new preference entry.
  • No server/daemon wire change.

How you verified

Tests (each fails on main):

  • PluginThreadRail.test.tsx: bb's outline reveals a clicked prompt in place with REPLACE, hides below three prompts, and stays hidden and inert without reading while the pane is narrow (items get visible: false). It reads Agent replies only once that tab is chosen, names an archived sender thread, marks the first prompt in view or the last one at the latest message, and caps the rail at twenty ticks. A plugin outline replaces bb's under Automatic with rail items below it, __builtin__ keeps bb's, and a crashing outline falls back to bb's.
  • conversation-outline.test.tsx: merge and append, nested rows, the context boundary, waiting for the first timeline page and enabled: false, and identity while a reply streams.
  • timeline-viewport.test.tsx: visible ids, atLatest, logarithmic measurement, settle timing and render count, and null outside a pane.
  • plugin-navigation-hooks.test.tsx: REPLACE while the route or the calling pane shows the thread, PUSH otherwise.
  • ThreadTimelineRows.windowing.test.tsx: a windowed-out message link is drawn and revealed, and revealed again on a replace.
  • The exclusive-slot tables (pinned-replacement-surfaces, exclusive-pick-first-paint), settings search, and registration tests.

Live, on a pnpm start:worktree build with a dev copy of a real 143-turn thread (121 prompts, 5318 events), in headless Chrome at 1600×1000. The machine's load average was 100–300 throughout, so the timings are noisy. Scripts and JSON are in the design thread's storage (thr_kr2zhuzxnn/evidence).

  • Reveal from bb's outline:
    • A windowed-out prompt (seq 3807) lands at +16 px in 110–119 ms over 5 runs; the old outline took 111 ms.
    • An unloaded prompt (seq 1) lands in 108–142 ms warm; the old outline took 140 ms.
    • history.length stays flat across every click, and the URL gains #msg=<seq>.
  • Renders while a reply streams. Measured with a throwaway render counter, since reverted:
    • bb's outline rendered 4 times over a 582-word reply: twice from the prompt list (the new prompt, then the whole-thread refresh at completion) and twice from viewport changes. It rendered 0 times while tokens streamed.
    • The old outline re-rendered 41–58 times per reply.
    • Two causes were found and fixed on the way:
      • An always-mounted assistant read. Replies are now read only in the open popover.
      • The viewport hook reading the bottom-anchor context, which changes every delta. The scroll element now reaches the store through TimelineViewportScrollSource.
    • Both have regression tests that fail on the earlier code (12 renders against 4).
  • Requests on opening the thread: one timeline request, then conversation-outline?role=user after it, and no assistant request.
  • Replacement through the pick, using a throwaway outline plugin built only on experimental_useConversationOutline, experimental_useTimelineViewport and toThread:
    • bb settings ui set threadRail.outlineProvider <plugin>/fixture-outline: the plugin outline (121 items, ready) replaces bb's, and its rail item stacks below.
    • Clicking a plugin tick reveals in place with no new history entry.
    • A crash shows bb's outline for the thread, with the item kept.
    • __automatic__ picks the installed plugin, and __builtin__ restores bb's.
  • Settings: the "Thread outline" row shows under Settings > Appearance > Interface.
  • Plugin Guide: card 12, "Thread outline and rail", opens from its annotation between the context card (11) and timeline renderers (13).

Commands:

  • turbo run typecheck lint lint:type-aware --filter='...[origin/main]' (270 tasks). It found three issues, all fixed: a fixture type, the demo server's preference table, and two floating act promises.
  • turbo run typecheck lint lint:type-aware test for @bb/app, @get-bb/plugin-sdk, @bb/shared-ui, @bb/domain, @bb/plugin-registry, bb-plugin-plugin-api-docs, bb-plugin-theme-preview and @bb/demo-server: typecheck and both lints are green.
  • Tests: everything passes except four @bb/app cases, which time out under the machine's load (average 70–300):
    • exclusive-pick-first-paint (first dynamic import over 15 s).
    • LazyQueuedMessagesList (a 40 s lazy import).
    • Both fail identically on a detached origin/main checkout run at the same time.
  • The wide ...[origin/main] test run also timed out in install-machine-script, process-utils, environment-provider-host and the integration suite. These are load-sensitive suites this change does not touch; CI is the clean signal for them.
  • node .github/workflows/check-plugin-sdk-version.mjs passes, at SDK 0.6.196.
  • The old ThreadTableOfContents.stories.tsx is deleted with no replacement story. The rail has no Ladle story yet.

Found, not fixed

  • I read this from the code and the sequence numbers I measured; I did not reproduce it live. While a reply streams, its row's messageSeq is the seq of its latest update. It becomes the item/completed seq once the reply finishes (in the design kill-tests: 208 → 307). A message link copied mid-stream therefore carries an intermediate seq, and after completion findMessageSeqRowPath (useScrollToSearchedMessage.ts) matches only the completion seq, so the link should toast "Message not found". This is out of scope here.

AGENT GENERATED

🤖 Generated with Claude Code

@ymichael
ymichael force-pushed the bb/thread-outline-public-api branch from 89aa32f to fdf968a Compare November 24, 2026 06:00
ymichael and others added 2 commits November 24, 2026 11:59
bb's thread outline read private timeline rows, the scroll element and the
DOM, and revealed messages through a pane-local request plugins could not
use. Community outlines rebuilt it from the DOM and hid bb's with CSS.

- app.slots.experimental_threadRailOutline (exclusive, pick
  threadRail.outlineProvider) and app.slots.experimental_threadRail
  (additive), rendered by PluginThreadRail beside the conversation, mirroring
  threadHeaderTitle and threadHeaderRow.
- experimental_useConversationOutline: a thread's prompts or replies across
  the whole thread, with the pane's loaded rows laid over the public outline
  route.
- experimental_useTimelineViewport: the messages a pane shows, from one
  shared observer per pane.
- toThread(threadId, { messageSeq }) reveals in place and replaces the
  history entry when the route already shows the thread.
- bb's outline moves to core-contributions/thread-outline.tsx on public SDK
  members and registry items only; the private messageRevealRequest path and
  components/thread/toc are deleted; useScrollOverflowState becomes the
  use-scroll-overflow-state registry item.
- Plugin SDK 0.6.191, api_to_audit entries, Plugin Guide card, authoring
  reference, configuration docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n thread

toThread(threadId, { messageSeq }) replaced the history entry only when the
route already showed the thread. Clicking the outline in an unfocused split
pane focuses that pane by replacing the route, but toThread read the route
from the last render, so it pushed an entry and Back appeared to do nothing.
It now also replaces when the thread pane the caller renders in shows the
thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/thread-outline-public-api branch from fdf968a to 85ffe31 Compare November 24, 2026 20:01
@ymichael
ymichael merged commit dd3d63e into main Nov 24, 2026
53 checks passed
@ymichael
ymichael deleted the bb/thread-outline-public-api branch November 24, 2026 20:42
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]>
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