Skip to content

Scaffold the thread-list plugin with synced layout preferences - #4031

Merged
SawyerHood merged 2 commits into
thread-list/1h-parity-fieldsfrom
thread-list/2-plugin-scaffold
Sep 22, 2026
Merged

SawyerHood merged 2 commits into
thread-list/1h-parity-fieldsfrom
thread-list/2-plugin-scaffold

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The sidebar's layout state (organization mode, sort, section orders, hidden groups, six collapsed-id lists) lives in a closed enum of sidebar.* UI preferences that only the host can read or write. A thread list that is a plugin needs to own that state. This layer stands the plugin up with its state before any rendering moves.

What changed

  • New bundled plugin plugins/thread-list (bb.branding.icon: ListView, registered in the builtin registry, bundled-plugins package, official catalog, and the marketplace snapshot). Its experimental_threadList registration renders Original for now, so enabling it changes nothing visible.
  • server.ts: preference store on bb.storage.kv validated by the plugin's own zod schemas (shared/preferences.ts), listPreferences/setPreference/resetPreference RPC, preferences realtime channel, bb thread-list prefs list|get|set|reset, and a one-time migration copying non-default sidebar.* values from bb.sdk.system.uiPreferences.
  • Frontend app/preferences/: jotai atoms with the same createSyncedPreferenceAtom(key) shape the host uses (so later slices port by changing an import), hydrated from a localStorage mirror then RPC, patched by realtime unless a local write is pending, written back debounced and coalesced.
  • Skill plugins/thread-list/skills/thread-list/SKILL.md and the bb-guide customization template mention the command.

Prerequisite: #4029.

How you verified

Server tests: defaults, valid write with realtime fan-out, schema rejection leaves storage alone, hidden-group dedupe and reset, invalid stored value falls back, migration copies once and never overwrites, migration skipped without marking done when bb is unreachable, CLI list/get/set/reset with bad key and bad value. Frontend tests: hydrate and mirror, mirror-first paint with junk ignored, coalesced debounced writes, remote signal precedence, no write for an unchanged value. Bundled-plugin, catalog generator, and guide parity suites pass; prepare:bundled builds.

🤖 Generated with Claude Code

AGENT GENERATED

SawyerHood and others added 2 commits September 21, 2026 17:08
A bundled plugin that registers the thread-list slot and, for now, renders
bb's list through Original while it stands up its own state: the sidebar's
organization, sort, section-order, hidden-group, and collapsed-group
preferences move into the plugin's KV storage, reached over RPC, pushed to
every window over realtime, mirrored to localStorage for first paint, and
written back debounced. A one-time migration copies non-default sidebar.*
values from bb settings. bb thread-list prefs keeps them scriptable.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@SawyerHood
SawyerHood force-pushed the thread-list/2-plugin-scaffold branch from e3dd0f9 to 671936c Compare September 22, 2026 00:08
@SawyerHood
SawyerHood marked this pull request as ready for review September 22, 2026 00:15
@SawyerHood
SawyerHood merged commit 38657df into main Sep 22, 2026
16 checks passed
@SawyerHood
SawyerHood deleted the thread-list/2-plugin-scaffold branch September 22, 2026 00:18
SawyerHood added a commit that referenced this pull request Sep 22, 2026
## Human comments

## What was wrong

`useSdk()` should not ship with a single consumer. Two first-party
frontends reached the public API by other means: plugin-api-docs
hand-rolled `fetch("/api/v1/plugins")` and the catalog search with
ad-hoc JSON parsing, and side-chat's `sendToMain` RPC was a pure
pass-through to `bb.sdk.threads.queuedMessages.create`.

## What changed

- plugin-api-docs: `loadPluginReferences(sdk, signal)` over
`sdk.plugins.list()` and `sdk.plugins.catalog.search({ query: "" })`,
with a Vitest setup and first tests for the plugin.
- side-chat: the message action calls
`sdk.threads.queuedMessages.create` directly; the `sendToMain` RPC, its
contract entry, and its server test are deleted.
- Testing harness: `sdk` fakes are now nested (`{ threads: {
queuedMessages: { create } } }`) through a recursive proxy; unfaked
methods still throw with the dot-path.
- Guide: the new-thread composer example spawns from the frontend.

theme-preview's RPCs were reviewed and left alone: they enrich the
catalog and re-apply on disk changes, which is real server work.

Prerequisite: #4031.

## How you verified

side-chat app and server suites, plugin-api-docs suite, plugin SDK
harness suite (nested fake case added), bundled types build, guide
parity suite.

🤖 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
## 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](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