Skip to content

Expose bb's public API client to plugin frontends as useSdk() - #4027

Merged
SawyerHood merged 2 commits into
thread-list/1e-title-and-env-providersfrom
thread-list/1g-use-sdk
Sep 22, 2026
Merged

SawyerHood merged 2 commits into
thread-list/1e-title-and-env-providersfrom
thread-list/1g-use-sdk

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Plugin frontends run on the app origin and can already reach the public API with same-origin fetch (plugin-api-docs and inline-vis do), but there was no typed client. @bb/sdk is workspace-only and not shimmed, so a third party would hand-roll requests, and the guide steered authors toward a server-side RPC proxy for every write. The sidebar-as-plugin work needs section CRUD, thread moves, pins, and unarchive from the frontend.

What changed

  • useSdk(): PluginBrowserBbSdk on @get-bb/plugin-sdk/app. The host binds its browser SDK instance per plugin in apps/app/src/lib/plugin-bound-sdk.ts, mirroring the backend bb.sdk narrowing: spawn and fork stamp origin: "plugin" and originPluginId, and the metadata calls default pluginId. One stable client per plugin, so it is safe in dependency lists.
  • PluginBoundThreadsArea and PluginBrowserBbSdk types, inlined into the bundled app declarations the same way the backend contract inlines BbSdk. No npm publish of @bb/sdk is needed.
  • The bundled-types guard that kept SDK areas out of the app entry is updated to assert the bound client instead; the app declarations still contain no @bb/ imports.
  • Testing harness: sdk option with per-area partial fakes, inspection.sdkCalls, and a loud error for an unfaked method.
  • Guide (frontend-hooks-and-ui.md, registration example), API indexes, and surfaces updated.

Prerequisite: #4026.

How you verified

Binding tests for attribution rules, explicit origins, metadata defaulting, passthrough, and identity caching. A harness test that serves a faked threadSections.create, records calls, and throws for threads.pin. pnpm exec turbo run test build:types --filter=@get-bb/plugin-sdk, app typecheck and hook suites, guide parity suite.

🤖 Generated with Claude Code

AGENT GENERATED

SawyerHood and others added 2 commits September 21, 2026 17:08
Plugin frontends could already reach the public API over same-origin fetch,
but had no typed client. Bind the app's browser SDK per plugin, mirroring
the backend bb.sdk narrowing (spawn and fork stamp the plugin origin, the
metadata calls default pluginId), and hand it out through useSdk(). The
bundled app declarations now carry the SDK areas on purpose; the guard that
kept them out is updated to assert the bound client instead.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@SawyerHood
SawyerHood force-pushed the thread-list/1g-use-sdk branch from 9d02dbc to 267cdcf 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 1b7d60e into main Sep 22, 2026
16 checks passed
@SawyerHood
SawyerHood deleted the thread-list/1g-use-sdk branch September 22, 2026 00:18
SawyerHood added a commit that referenced this pull request Sep 22, 2026
…ole split layout (#4029)

## Human comments

## What was wrong

Four more things bb's own list reads that a plugin could not: the pin
timestamp that breaks ties in pinned order, the archive timestamp, an
app-relative URL per thread and per project so rows can be real anchors
(the host already routes plugin-root anchor clicks in place), and two
whole-list reads for collapsed-group rollups, every row status by thread
id and the whole split layout with the thread each pane shows.

## What changed

- `PluginSidebarThread` gains `pinnedAt`, `archivedAt`, `href`;
`PluginSidebarProject` gains `href` and `settingsHref`.
- `useSidebarThreadRowStatuses()` over a new cached snapshot in
`plugin-thread-row-status.ts`, invalidated on every notify and
identity-stable while unchanged.
- `useSidebarSplitLayout()` over `splitLayoutAtom`, null on compact
viewports and single-pane layouts, via a pure
`toPluginSidebarSplitLayout`.
- Harness fakes (`sidebarSplitLayout` option), guide, API index, and
surfaces updated.

Prerequisite: #4027.

## How you verified

Mapper test for the timestamps and href; hook tests for project hrefs
(personal project resolves to `/`), row-status snapshot identity, and a
pure split-layout test. Same typecheck/test filters as the lower PRs
plus `build:types`.

🤖 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