Skip to content

Port the sidebar row layer into the thread-list plugin - #4036

Merged
SawyerHood merged 3 commits into
thread-list/0-compiled-in-loaderfrom
thread-list/3a-row-layer
Sep 22, 2026
Merged

SawyerHood merged 3 commits into
thread-list/0-compiled-in-loaderfrom
thread-list/3a-row-layer

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The thread-list plugin (#4031) had state but no rendering. The built-in sidebar's row layer reaches into about twenty host modules (@/components/ui/sidebar, ThreadActionsProvider, ThreadTitleMentions, split-layout atoms, react-router, prompt-draft storage, the shortcut context) that a plugin cannot import.

What changed

Everything under plugins/thread-list/app/, all importing only @get-bb/plugin-sdk/app, @bb/shared-ui, @bb/client-core, @bb/core-ui, @bb/domain types, and npm packages (verified by grep for @/, react-router-dom, @tanstack/react-query, @bb/sdk):

  • model/: an adapter from PluginSidebarThread to the internal ThreadListEntry shape, cached per DTO identity, so every @bb/client-core builder and comparator runs unchanged; useSidebarData() regroups threads by project the way the bootstrap payload does.
  • ui/: ports of the sticky-stack primitives, hover-action classes, drag-click suppression, reorder DnD, action-menu items, the compact long-press menu, the shortcut pill, clipboard with sonner toasts, dialog state, the confirm-delete dialog, the empty state, and the environment display helpers.
  • rows/: row classes, item keys, sortable motion, droppable types, row controls, the child chevron, the split mini-map (from useSidebarSplitLayout()), inline rename with duck-typed error mapping, the status glyph, the section-move provider, the thread actions menu, and ThreadRow. The row's link is a plain anchor on thread.href (the host routes it); cmd-click calls open(id, { split: true }); drafts, row status, and shortcuts come from the per-row hooks; the title renders ThreadTitle; moves and unarchive go through useSdk().
  • New plugin dependencies: @dnd-kit/*, @radix-ui/react-slot, @radix-ui/react-compose-refs, @bb/core-ui, @bb/domain.

Nothing is wired into a list yet; app.tsx still renders Original. The next layer assembles sections, projects, and machines.

Prerequisite: #4035.

How you verified

124 plugin tests (112 new): 93 ThreadRow cases covering open, split, rename via double-click and menu, every menu item's action or SDK call including move-to-section and pinned-move sequencing, copy link, unarchive pending state, drag-click suppression, chevron toggles, glyph precedence, plugin status, the shortcut pill, and the cross-project glyph; 11 inline-rename cases including error duck-typing; 2 mini-map cases; 6 adapter and grouping cases. pnpm exec turbo run typecheck test --filter=bb-plugin-thread-list, prepare:bundled builds (1.8 MB dev bundle).

🤖 Generated with Claude Code

AGENT GENERATED

@SawyerHood
SawyerHood added this pull request to stack #4028 September 22, 2026 00:04
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch from 5f673d9 to d809173 Compare September 22, 2026 00:08
@SawyerHood
SawyerHood marked this pull request as ready for review September 22, 2026 00:15
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch 3 times, most recently from 2ff948a to f22fe06 Compare September 22, 2026 00:18
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch from f22fe06 to a72a0e2 Compare September 22, 2026 00:27
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch from a72a0e2 to 5ff464e Compare September 22, 2026 01:38
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch from 5ff464e to d122cae Compare September 22, 2026 02:02
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch from d122cae to c2a1ebb Compare September 22, 2026 02:06
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch from c2a1ebb to 6c5f16a Compare September 22, 2026 02:36
SawyerHood and others added 3 commits September 21, 2026 19:42
The platform the port stands on and the thread row itself, ported from the
built-in sidebar with host imports replaced by the plugin SDK: a DTO
adapter so the client-core builders keep working, the sticky and hover
primitives, drag-click suppression, reorder DnD, action menus, the compact
long-press menu, clipboard, dialogs, row classes, status glyph, split
mini-map, inline rename, the thread actions menu, and ThreadRow. Nothing is
wired into the list yet; app.tsx still renders Original.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@SawyerHood
SawyerHood force-pushed the thread-list/3a-row-layer branch from 6c5f16a to 4da875e Compare September 22, 2026 02:44
@SawyerHood
SawyerHood merged commit 11fe4d2 into main Sep 22, 2026
21 of 30 checks passed
@SawyerHood
SawyerHood deleted the thread-list/3a-row-layer 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
…parity (#4039)

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](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 25, 2026
## Human comments

## What was wrong

When the sidebar moved into the thread-list and navigation plugins
(#4036, #4041, #4117, #4140), the old app and client-core copies stayed
behind. Nothing in the shipped app renders or calls them, but their
tests kept them compiling and passing. The shipped plugin copies have
their own tests. A few other app tests could not fail: they restated
constants or asserted a flag inside a block that only runs when the flag
has that value. Others were near-duplicates of a stronger test.

## What changed

Found by a read-only test audit using the repo `test-audit` skill
(#4361).

- Deletes dead code that nothing in the shipped app calls, and the tests
that only exercised it:
- `ThreadArchiveQuickAction` and `ThreadActionsContextMenu` (the plugin
copies ship)
- `SidebarRenameProvider`, the app's sidebar row state classes, the
drop-animation constant and the sidebar lifecycle atom
- `useSystemProviderUsageLimits` and its query key (unused since #3449),
and `getAppCommandMetadata`
- client-core's environment grouping, sort policy and pinned-root
ordering. The only live callers read `effectivePinnedThreadIds` or pass
their own comparator.
- the unused `hasRunningPluginStatus` parameter, and the plugin copy of
`arrangeByStoredOrder`
- The theme-preview anatomy anchor now points at
`plugins/thread-list/app/rows/sidebarRowClasses.ts`, the file that
actually renders the rows.
- Folds duplicate suites into table tests at their owners: bundle
budget, command ordering, `isRowExpandable`, steer rendering and child
activity.
- Deletes tests that restate constants or cannot fail.
- Adds two tests after coverage verification:
  - an unpinned parent stays out of `effectivePinnedThreadIds`;
- the terminal enables xterm's proposed API, which the Unicode 11 addon
requires. This builds a real `Terminal`.

Production +59/−706, tests +476/−1618.

## How you verified

- `pnpm exec turbo run test lint typecheck` passes for `@bb/app`,
`@bb/client-core`, `@bb/thread-view`, `bb-plugin-thread-list` and
`bb-plugin-theme-preview`, plus typecheck of every client-core and
thread-view dependent.
- An independent verifier used before and after worktrees on 175d5ac
and 55 mutations. For each of the 75 removed or merged tests, it wrote
the bug that test catches as a production change and checked that the
old test fails and a remaining test also fails.
- Result: 64 OK, 10 with no unique failure mode, 1 lost. The lost
assertion is restored above.
- The live callers `RootComposeMobileRecents` and
`useSidebarThreadReveal` still fail on sort or pin mutations.
- Known gap, not caused by this change: the rename-cancel effect in
`useSidebarRename` was untested before and after.

> AGENT GENERATED

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael pushed a commit that referenced this pull request Oct 9, 2026
…stry

The thread-list plugin port (#4036) copied sidebar primitives instead of
moving them, and the app and plugin copies drifted. Presentation
primitives with no domain knowledge now have one home in
packages/shared-ui, published to plugins through the registry:
use-dialog-state, use-drag-click-suppression, use-reorder-dnd,
use-sidebar-reorder-dnd, sortable-motion, compact-long-press-menu,
action-menu-items, confirm-delete-dialog, rename-dialog, inline-rename,
inline-rename-editor, sidebar-visibility-customize,
sidebar-customize-panel, sidebar-row-classes, sidebar-hover-actions,
context-selection and thread-list-empty-state.

Where the app and plugin need different behaviour, the shared code takes
it as a prop: each side passes its own touch sensor (the app's
drawer-aware sensor, the plugin's deliberate long-press sensor, which now
owns its 500 ms hold); the app renders the inline rename editor through
its lazy split with field-sizing-content; the plugin keeps its shared
rename session and compact rename dialog. MachineRenameDialog uses the
shared RenameDialog shell, and the tasks plugin's confirm dialog is
replaced by ConfirmDeleteDialog with className, size and
confirmDisabled props.

docs/forkable-plugins.md gains a "What belongs in shared-ui" section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael added a commit that referenced this pull request Oct 9, 2026
…5275)

## Human comments

## What was wrong

When the sidebar row layer moved into the thread-list plugin (#4036),
about seventeen components were copied instead of moved. The app and the
plugin each kept a copy, and the copies drifted: different touch delays,
a release-click fix only in the app, extra rename features only in the
plugin, and a fourth confirm dialog in the tasks plugin. Separately,
bb's core `sidebar.collapsed*` UI preferences were left behind when the
plugin migrated its own preferences. The app kept writing all six, only
`sidebar.collapsedThreads` still had a reader (mobile recents), and that
made recents' collapse state sync across devices by accident.

## What changed

Three commits. Each component now has one home, placed by the rule now
written down in `docs/forkable-plugins.md` ("What belongs in
shared-ui"):

1. **Shared presentation primitives go to `packages/shared-ui` and the
plugin registry.** These are `use-dialog-state`,
`use-drag-click-suppression`, `use-reorder-dnd`,
`use-sidebar-reorder-dnd`, `sortable-motion`, `compact-long-press-menu`,
`action-menu-items`, `confirm-delete-dialog`, `rename-dialog`,
`inline-rename`, `inline-rename-editor`, `sidebar-visibility-customize`,
`sidebar-customize-panel`, `sidebar-row-classes`,
`sidebar-hover-actions`, `context-selection` and
`thread-list-empty-state`. Where the app and the plugin need different
behaviour, the difference is a prop:
- Each side passes its own touch sensor: the app's drawer-aware one, and
the plugin's 500 ms long-press one from #4329.
   - The app renders the inline rename editor through its lazy split.
   - `MachineRenameDialog` uses the shared `RenameDialog` shell.
- The tasks plugin's `ConfirmDialog` is replaced by
`ConfirmDeleteDialog`, which gains `className`, `size` and
`confirmDisabled` props.
2. **The thread status glyph is host-rendered through the SDK.** The app
still draws the glyph in the palette, related threads and mobile
recents, so the host now exposes it as `experimental_ThreadStatusGlyph`
(`indicator`, `archived`, `rowStatus`, `hideIdleDraftLabel`, `size`),
and the plugin deletes its copy. The plugin still resolves the indicator
itself, which lets it fold in collapsed children and drafts.
- The SDK test fake exposes the requested indicator as data attributes.
- Glyph rendering tests moved to the app's `ThreadStatusGlyph.test.tsx`.
   - SDK bumped to 0.6.36; the thread-list SDK floor is now 0.6.36.
- Added an `api_to_audit.md` entry and the Plugin Guide surface symbols.
3. **Mobile recents keeps its collapse state on the device.** It is
stored in local storage under `bb.mobileRecents.collapsedThreads`.
`useMobileRecentsThreadReveal` replaces the app's sidebar reveal hook
and keeps the one behaviour recents used: navigating to a thread, or a
thread becoming unread, opens its collapsed ancestors. The six
`sidebar.collapsed*` keys leave the UI preference registry, the demo
server and `docs/configuration.md`. The server already ignores stored
rows for unknown keys. The thread-list migration no longer reads them.

No server/daemon wire changes. Net −1,769 non-test lines (+399 generated
registry JSON).

**User-visible differences:**
- The plugin's long-press menus now swallow the click that follows a
long press (#4813), as the app's already did.
- `MachineRenameDialog` now returns focus to the opener after closing.
- Tasks confirm dialogs clear their content while closing.
- Mobile recents collapse no longer syncs across devices, and starts
expanded once per device.
- An install that has not started bb since 2026-09-21 loses its old
sidebar collapse state.

## How you verified

Ran with `pnpm exec turbo run typecheck lint test` on the touched
packages:

| Package | Tests |
|---|---|
| app | 5,640 |
| thread-list | 451 |
| tasks | 412 |
| db | 615 |
| client-core | 279 |
| domain | 220 |
| plugin-sdk | 368 |
| plugin-build | 165 |
| plugin-api-docs | 73 |
| demo-server | 15 |
| plugin-registry | 1 |

All pass. The server UI preferences test file also passes (18 tests).

- **Lint:** 0 errors.
- **Typecheck:** clean, except one error that already fails on main from
#5098 (`lazySecondaryPanelComponents.tsx:287`), in a file this PR does
not touch.
- **Fork check:** `pnpm check:plugin-forks plugins/thread-list
plugins/tasks` passes.
- **SDK version guard:** `check-plugin-sdk-version.mjs` passes.

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

> AGENT GENERATED

---------

Co-authored-by: qa <qa@x>
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