Skip to content

Discover plugin RPC contracts and move usage displays into Provider Usage - #3449

Merged
ymichael merged 53 commits into
mainfrom
bb/improve-plugin-surface-compatibility-thr_2iguhd9c6n
Sep 14, 2026
Merged

ymichael merged 53 commits into
mainfrom
bb/improve-plugin-surface-compatibility-thr_2iguhd9c6n

Conversation

@ymichael

@ymichael ymichael commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Plugins could call schema-validated RPC methods but could not discover implementations or inspect their contracts. Usage displays had no common resource model for pooled and machine-local accounts, targeted fetching, or deduplicating known accounts. Usage settings lived in core instead of the display plugin.

What changed

  • Add opt-in RPC publication with experimental_discoverable, registration/method descriptions, JSON Schemas, and SDK discovery. CLI supports rpc list [plugin-id], rpc inspect <plugin-id> [method], and rpc call. Discovery advertises live registrations; it does not change authorization or negotiate versions. SDK minimum is 0.4.87.
  • Provider Usage owns provider-usage.v1.listResources (cheap inventory) and provider-usage.v1.getResource (actual usage for one resource, with optional cache reuse through refresh: false). Account Pooler, Codex, Claude Code, and ACP explicitly implement copied contracts. No shared schema package or core adapter is introduced.
  • Separate source-local resource IDs from provider-issued account identities. Deduplicate known identities within the selected location, never by email. Normalize plan/window labels; pooled Codex accounts preserve plan metadata from usage responses.
  • Move usage settings into Provider Usage, enable it by default on new installations, and retain the temporary /settings/usage redirect. Existing enable/disable choices remain intact. Settings and footer share aggregation/cache; settings fetches the selected location and the footer fetches its selected provider tab. Each settings account uses the same provider icon/header, email and plan-tag layout.
  • Preserve stale measurements after refresh failures and handle empty pools, authentication, missing limits, offline hosts, loading and removed resources. Sources remain independent of the display. Footer customization uses the implementation already merged in PR Let users customize sidebar footer order and visibility #3550.
  • Update Plugin Guide, API audit, CLI/configuration guidance and verification recipes. Isolate server test loggers and restore spies to prevent cross-test warning leakage.

How you verified

  • Relevant app/server/SDK/provider/CLI typechecks and RPC discovery tests passed during implementation. Recent focused checks: 285 Account Pooler tests, 20 Provider Usage tests, 607 CLI tests and 74 Plugin Guide tests passed. The full server suite passed with 2,601 tests after logger isolation.
  • Source tests cover cheap inventories, targeted fetches, cache/force concurrency, ownership, removed resources, offline hosts and account identity normalization. Display tests cover source/provider selection, empty/error/loading states and cached measurements.
  • Dev Browser verified real pool and machine usage, consistent per-account headers and plan tags, and the settings redirect. Browser fixtures exercised empty/loading/error responses without changing saved accounts. The preview runs with pnpm start:worktree.
  • JSON Schema refinement/transform fidelity remains an experimental stabilization audit. Safari interaction verification was blocked by Computer Use cgWindowNotFound; no Safari pass is claimed.

Preview: https://ymichael-latest--25451.getbb.app/settings/plugins/provider-usage

AGENT GENERATED

ymichael added a commit that referenced this pull request Sep 11, 2026
## Human comments

## What was wrong

The Provider Usage footer coverage put plugin import/registration, the
content-script preload and focus listener lifecycle, disclosure
rendering, two Radix machine-menu sessions, provider mouse and keyboard
navigation, disconnected state, dismiss, manual refresh, and disposal
inside one asynchronous test with the default 5-second budget.
Package-shard concurrency and Vitest worker oversubscription made that
serial UI sequence slow enough to expose the test architecture: the
unchanged test reproduced at 6.610 seconds under bounded Intel
contention and timed out at 5 seconds. The CI failure was therefore not
a deterministic regression in PR #3449, and scheduler contention was the
trigger rather than the root cause.

## What changed

`plugins/provider-usage/app.test.tsx` now loads and captures the plugin
registration once outside test clocks, reuses one response fixture, and
divides coverage into registration, content-script focus refresh,
disconnected/manual refresh, and connected machine/provider interaction
scenarios. Content-script disposal is protected by `finally`. The
disconnected case starts from the active Intel machine, removing a
second Radix menu lifecycle while the connected case still proves all
machines are aggregated and exercises machine selection plus provider
mouse and keyboard navigation. No assertions were disabled, no timeout
was increased, and there are no wire, CLI, or documentation changes.

## How you verified

- Before: on enrolled Intel host `host_nwqfteeqz4`, a warmed run with 12
bounded CPU competitors reproduced the exact failure: 6.610 seconds and
`Test timed out in 5000ms`.
- After: the same 12-worker warmed stress passed all four scenarios; the
slowest scenario was 833 ms.
- After: five fresh focused iterations under 12 CPU competitors passed
20/20 scenario executions; the slowest scenario was 1.202 seconds.
- `pnpm exec turbo run test --filter=bb-plugin-provider-usage` — 3 files
and 7 tests passed.
- `pnpm exec turbo run typecheck --filter=bb-plugin-provider-usage` —
passed.
- `pnpm exec turbo run build --filter=bb-plugin-provider-usage` — passed
the package's available upstream generator tasks; this package has no
build script.
- `bb plugin build` from `plugins/provider-usage` — emitted validated
server and app bundles.
- Every test/build/load command ran in a bounded process group; teardown
and the final process scan found no surviving Vitest, Turbo,
plugin-build, or load workers.

> AGENT GENERATED
@ymichael
ymichael force-pushed the bb/improve-plugin-surface-compatibility-thr_2iguhd9c6n branch from 14869a0 to 7874efb Compare September 11, 2026 20:50
@ymichael
ymichael marked this pull request as ready for review September 11, 2026 20:55
@ymichael
ymichael force-pushed the bb/improve-plugin-surface-compatibility-thr_2iguhd9c6n branch 2 times, most recently from 2114294 to 13f98a1 Compare September 12, 2026 04:03
@ymichael ymichael changed the title Prototype discoverable RPC for provider usage sources Discover plugin RPC contracts and move usage displays into Provider Usage Sep 12, 2026
@ymichael
ymichael force-pushed the bb/improve-plugin-surface-compatibility-thr_2iguhd9c6n branch 2 times, most recently from bf5e432 to a027665 Compare September 14, 2026 16:58
@ymichael
ymichael force-pushed the bb/improve-plugin-surface-compatibility-thr_2iguhd9c6n branch from 981086a to 7b6ca66 Compare September 14, 2026 17:22
@ymichael
ymichael merged commit c7d2c7f into main Sep 14, 2026
16 checks passed
@ymichael
ymichael deleted the bb/improve-plugin-surface-compatibility-thr_2iguhd9c6n branch September 14, 2026 20:22
OXI-717 added a commit to OXI-717/bb that referenced this pull request Sep 17, 2026
Twenty commits from the 0.43.1 line: three opencode subscriptions and Cursor pooled
behind the hub, real quota for all of them, and an exhausted pool that refuses instead of
handing back a multi-day retry-after a coding agent obeys in silence.

Every conflict was inside plugins/account-pool, so the merge takes that plugin whole from
the branch that is actually running rather than reconciling two designs. Upstream's own
post-0.43.1 work on this plugin — the parent-pool layer from get-bb#3654 and the usage-source
split from get-bb#3449 — is therefore not carried over; adopting it belongs with the re-port
onto whatever app version supersedes 0.43.1, where the result can be exercised.

Verified: turbo typecheck and the plugin suite (14 files) on the merge result, whose
plugin tree is identical to the one serving six pooled subscriptions today.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
OXI-717 added a commit to OXI-717/bb that referenced this pull request Sep 17, 2026
Quota for the pooled subscriptions lived only on the plugin's own card, so the standard
Provider Usage view showed nothing for them — the same blind spot that made a missing
Cursor meter look like a broken provider.

Restores upstream's usage-source layer (get-bb#3449), which the 0.43.1 port had dropped, and
widens it from two providers to the six we pool: each subscription reports its windows
under the BB provider that actually spends it. The mapping is pinned by a test — the
type only guarantees an entry exists, not that it names the right card.

Co-Authored-By: Claude Opus 5 (1M context) <[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]>
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