Skip to content

Assemble the thread list inside the plugin and bring it to benchmark parity - #4039

Merged
SawyerHood merged 4 commits into
thread-list/3a-row-layerfrom
thread-list/3b-list-assembly
Sep 22, 2026
Merged

SawyerHood merged 4 commits into
thread-list/3a-row-layerfrom
thread-list/3b-list-assembly

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Layer 11 of the thread-list plugin stack. Stacked on #4036 (row layer); merges after it.

Human comments

What was wrong

After #4036 the plugin owned rows, preferences, and the DTO adapter but still rendered nothing of its own: plugins/thread-list/app.tsx mounted the built-in list through Original. The list assembly (sections, windowing, drag and drop, header controls, visibility, reveal-on-navigate) still lived only in apps/app, so the plugin could not stand on the public API alone. A first port also ran 40 to 60 percent slower than the built-in list on updates because every per-row host hook rebuilt a 3,000-entry thread map on each payload change, and the plugin regrouped every project on every update.

What changed

  • plugins/thread-list/app/list/*, app/dnd/*: ports of the built-in list assembly onto the plugin API. Sections come from experimental_useSidebarThreads().sections, mutations go through useSdk().threads and threadSections, layout preferences through the plugin's own KV atoms. Imports stay inside the plugin boundary: @get-bb/plugin-sdk/app, @bb/shared-ui, @bb/client-core, @bb/core-ui, jotai, @dnd-kit.
  • plugins/thread-list/app.tsx now renders the plugin's ThreadList (PreferencesSync + ProjectList) instead of Original.
  • plugins/thread-list/app/model/use-sidebar-data.ts: grouped data keeps untouched projects and thread arrays by identity across updates so per-project memos skip.
  • plugins/thread-list/app/preferences/preferences-sync.ts: sync attaches to the jotai store the plugin renders in (attachPreferencesStore) instead of assuming the default store. Pending writes carry their value so a store swap cannot drop one.
  • apps/app/src/lib/plugin-sidebar-hooks.ts: one thread-entry map per bootstrap payload behind a WeakMap, shared by every per-row hook.
  • apps/app/src/components/sidebar/sidebar.bench.test.tsx: runs both lists through the same harness (plugin mounted via PluginThreadList with its real registration, preference RPC stubbed).
  • plans/thread-list-plugin.md: parity numbers.

The header includes the Active/Archived Filter menu. experimental_useSidebarThreads now accepts experimental_lifecycles and returns experimental_archived pagination/loading state, sharing the host archive query and cached row lookups. The plugin persists the selection as threadLifecycles, exposed by its existing preference RPC and bb thread-list prefs commands. Plugin Guide, API audit, and configuration guidance cover the additions. No server/daemon wire changes.

How you verified

Archive regression coverage: desktop and compact filter toggles keep at least one lifecycle selected; host-hook tests cover active-only, archived-only, combined views, duplicate/stale entries, loading/errors, pagination, and archived row lookup. CLI/RPC tests reject empty, duplicate, and invalid selections. Turbo: all 300 thread-list tests and 20 focused host-hook tests pass; app, plugin, SDK, and API-map typechecks pass. Focused lint passes.

Benchmark, 3,000 threads, jsdom, median of 5 (BB_SIDEBAR_BENCH=1 pnpm exec vitest run src/components/sidebar/sidebar.bench.test.tsx in apps/app):

ms built-in plugin
mount 719 725
status patch 184 222
membership refetch (50 rows) 255 221
pin 189 236

Tests added: structural-sharing and per-payload cache tests in sidebar-thread.test.ts, store-attachment test in preferences-sync.test.ts, and the ported list/dnd suites (drag chip, nest preview placement, section dnd projection, windowed items, section order, reveal, header controls, visibility, project row interactions, sort comparator). Before the fixes the benchmark's plugin scenario rendered zero rows and the update numbers were 40 to 60 percent above the built-in.

pnpm exec turbo run typecheck --filter=bb-plugin-thread-list --filter=@bb/app
pnpm exec vitest run   (plugins/thread-list: 25 files, 297 tests)
pnpm exec vitest run src/lib/plugin-sidebar src/components/sidebar/ThreadListPlaceholder src/components/plugin   (apps/app: 57 files, 550 tests)
pnpm exec oxlint plugins/thread-list apps/app/src/lib/plugin-sidebar-hooks.ts apps/app/src/components/sidebar/sidebar.bench.test.tsx

Manual: dev instance with 160 seeded threads, Settings → Appearance → Thread list set to the plugin, list renders with sections, pins, nesting, and drag and drop.

🤖 Generated with Claude Code

AGENT GENERATED

@SawyerHood
SawyerHood added this pull request to stack #4028 September 22, 2026 01:16
@SawyerHood SawyerHood changed the title thread list/3b list assembly Assemble the thread list inside the plugin and bring it to benchmark parity Sep 22, 2026
@SawyerHood
SawyerHood marked this pull request as ready for review September 22, 2026 01:17
@SawyerHood
SawyerHood force-pushed the thread-list/3b-list-assembly branch from f90b273 to 83a6a32 Compare September 22, 2026 01:38
@SawyerHood
SawyerHood force-pushed the thread-list/3b-list-assembly branch from 83a6a32 to 8406acc Compare September 22, 2026 02:02
@SawyerHood
SawyerHood force-pushed the thread-list/3b-list-assembly branch 2 times, most recently from 4f624e1 to 8a5ec5e Compare September 22, 2026 02:36
SawyerHood and others added 4 commits September 21, 2026 19:42
Ports the rest of the built-in sidebar onto the plugin's row layer: pinned,
custom-section, project, machine, and environment grouping; the header
menu with organize, sort, new section, and visibility; hide-from-list and
customize; windowing; inline section and project rename; auto-reveal on
route change; and the drag-and-drop layer (reorder, nest, pin, move
between sections) with the host's drop-target highlighting. app.tsx now
renders the plugin's own list instead of Original.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The plugin list rendered 40 to 60 percent slower than the built-in list
on status patches, membership refetches, and pins. Two causes: every
per-row host hook rebuilt a 3,000-entry thread map on each payload
change, and the plugin regrouped every project on every update so all
per-project memos ran.

The host now caches one entry map per payload behind a WeakMap, and the
plugin's grouped data keeps untouched projects and thread arrays by
identity across updates. Preference sync attaches to the jotai store the
plugin renders in instead of assuming the default store, which is what
made the benchmark's plugin scenario stick on the skeleton. The
benchmark runs both lists through the same harness and the plan records
the numbers.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@SawyerHood
SawyerHood force-pushed the thread-list/3b-list-assembly branch from 8a5ec5e to 5151817 Compare September 22, 2026 02:44
@SawyerHood
SawyerHood merged commit 9516da5 into main Sep 22, 2026
21 of 30 checks passed
@SawyerHood
SawyerHood deleted the thread-list/3b-list-assembly branch September 22, 2026 03:11
SawyerHood added a commit that referenced this pull request Sep 22, 2026
Layer 9 of the thread-list plugin stack. Base: main. #4036 (row layer)
and #4039 (list assembly) stack on it.

## Human comments

## What was wrong

The plugin list loads as a bundle after boot, so a cold start has
nothing to show in the sidebar until the bundle mounts, and the host had
no way to tell "still loading" from "no thread list plugin is enabled".
There was also no benchmark to hold the plugin list to the built-in
list's performance.

## What changed

- `apps/app/src/components/sidebar/ThreadListPlaceholder.tsx`: the three
sidebar states the flip in the next layers will render: loading skeleton
rows, "No thread list plugin is enabled" with a link to Plugins, and
"<plugin> stopped working" with a reload button. The flip reads the
existing `usePluginFrontendsSettled` hook from
`plugin-frontend-boot-state.ts` to pick loading versus missing; nothing
in the sidebar imports the loader module statically, because it carries
the plugin runtime shims and would pull the on-demand vendors into the
boot payload (an earlier revision did exactly that and failed the bundle
budget).
- `apps/app/src/components/sidebar/sidebar.bench.test.tsx`: gated
(`BB_SIDEBAR_BENCH=1`) jsdom benchmark, 3,000 threads, simulated
viewport so windowing engages, measuring mount, status patch, membership
refetch, and pin. The baseline for the built-in list is in
`plans/thread-list-plugin.md`.
- `apps/app/src/components/ui/theme.css`: Tailwind source entry for the
plugin directory.
- `turbo.json`: `@bb/plugin-build#test` waits for the SDK's bundled
types so the zod resolution race stops.
- `packages/plugin-api-map/test/mobile-guide.test.ts`: 30 s budget for
the layout case on loaded runners.

An earlier revision of this PR also compiled the thread-list plugin
frontend into the app build and seeded it at boot. That path was dropped
(last commit): it duplicated the loader for one plugin and needed a
localStorage memo to avoid a list-then-blank flash. The placeholder
covers the cold start instead.

No wire changes, no SDK surface changes.

## How you verified

- `ThreadListPlaceholder.test.tsx` covers the three states.
- `plugin-frontend*.test.ts` (65 tests) pass with the loader back to
main's version.
- `pnpm exec turbo run typecheck --filter=@bb/app`
- Benchmark run recorded in the plan: built-in mount 694 ms, status
patch 183 ms, membership refetch 247 ms, pin 181 ms (bee, jsdom, median
of 5).

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

> AGENT GENERATED

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
SawyerHood added a commit that referenced this pull request Sep 22, 2026
…ugin loads (#4041)

Layer 12 of the thread-list plugin stack, stacked on #4039 (list
assembly). This is the flip.

## Human comments

## What was wrong

The sidebar rendered bb's built-in list first and swapped in the plugin
list once its bundle arrived, which showed as a flicker on every load.
Keeping two lists had no purpose once the bundled `thread-list` plugin
reached parity (#4039): the plugin is bb's list now.

## What changed

- `apps/app/src/components/sidebar/PluginThreadList.tsx` mounts the
resolved plugin directly through `PluginSlotMount`. With no plugin it
renders `ThreadListPlaceholder`: skeleton rows until the existing
`usePluginFrontendsSettled` hook (light `plugin-frontend-boot-state.ts`,
no loader import, so the boot payload does not grow) reports the
deferred boot done, then "No thread list plugin is enabled" with a link
to Plugins. A crash shows "<plugin> stopped working" with a Reload
button that calls `resetCrashedPluginSlots` and remounts, plus one
toast.
- `AppSidebar.tsx` no longer builds a built-in list and drops the unused
quick-create controller.
- `ProjectList` and everything only it reached are deleted from
`apps/app` (about 12,900 lines including tests and stories).
`SidebarPrimaryActions.tsx` keeps the New thread and Search actions the
navigation region still renders; `SectionSidebar` takes its button class
from `sidebarRowClasses`. Row and drag modules that other surfaces
import (mobile recents, section move provider, settings) stay.
- Settings → Appearance → Sidebar offers Automatic and the registered
providers; `ReplacementProviderSetting` only adds the built-in option
when a description is passed. A stored `__builtin__` value for
`sidebar.threadListProvider` is read as Automatic
(`threadListProvider.ts`); the preference description in `@bb/domain`
and `docs/configuration.md` say so.
- `PluginThreadListProps` loses `Original` and `experimental_Original`
(nothing to delegate to). Plugin SDK 0.5.7. The guide
(`frontend-registration.md`), `docs/api_to_audit.md`,
`docs/plugin-sidebar-thread-list.md`, the API map summary, the
docs-parity prop list, the plugin's own test fixture, and the
`replacement-lab-beta` example are updated.
- The benchmark keeps only the plugin scenario; the built-in numbers
stay recorded in `plans/thread-list-plugin.md`.

No wire changes.

## How you verified

- New `PluginThreadList.test.tsx`: loading placeholder until boot
settles then missing state; plugin receives the host props and no
`Original`; crash shows the crashed placeholder and toast, and Reload
remounts a recovered list.
- `SidebarThreadListSetting.test.tsx`: no built-in menu item; pinning a
plugin stores its key.
- `pnpm exec turbo run typecheck --filter=@bb/app
--filter=bb-plugin-thread-list --filter=@get-bb/plugin-sdk
--filter=@bb/domain --filter=bb-plugin-replacement-lab-beta`
- `apps/app`: sidebar, settings, layout, plugin, views, and plugin-* lib
suites: 154 files, 1501 tests pass.
- `@get-bb/plugin-sdk` (346), `@bb/plugin-api-map` (82),
`bb-plugin-thread-list` (297), server plugin docs-parity and
builtin-plugin tests (57) pass.
- Provider-literal ratchet OK. Local `pnpm build` plus
`check-bundle-budget.mjs`: boot payload within budget (numbers below).
- Dev instance with 160 seeded threads, headless Chromium on bee
sampling the sidebar every 30 ms after a warm reload: host loading
placeholder from 94 ms, plugin root mounted at 320 ms rendering the same
two skeleton rows, thread rows at 700 ms. No built-in list at any point.
Cold Vite compile: placeholder until the bundle lands at about 7 s, then
rows.

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

> AGENT GENERATED

---------

Co-authored-by: Claude Fable 5.1 <[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