Skip to content

Return only ok and result from plugin RPC responses - #6073

Merged
ymichael merged 2 commits into
mainfrom
bb/plugin-rpc-public-envelope
Oct 21, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/plugin-rpc-public-envelope

Conversation

@ymichael

@ymichael ymichael commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

#5658 made plugin RPC responses carry the tag engine's bookkeeping. invokeRpcHandler returned tags, keyTags and invalidated, and the route sent that outcome as-is (context.json(outcome)). Every successful response became { ok, result, tags, keyTags, invalidated }.

Callers that fetch the endpoint directly with strict parsers rejected every success:

  • the provider usage card (plugins/provider-usage/usage-schema.ts), which shows an error even when usage loaded;
  • desktop machine enrollment (apps/desktop/src/connect-machine-enrollment.ts). It has no fallback, so a desktop app that hasn't enrolled yet fails silently, logging could not enroll this app with bb Connect (invalid_response). It only becomes visible when the local server is down and the app has no credential;
  • the local call in the desktop account server list (apps/desktop/src/connect-server-sync.ts). It falls back to the stored machine credential or the account session, so the server menu still fills.

The data was also redundant. Those fields are computed only from the RPC contract's tags, keyTags and invalidates declarations, using the parsed input and output. Core's RPC hooks already receive that same contract.

It affects main and the nightly build of Oct 21 (0.46.2-nightly). Stable 0.46.1 predates #5658. These callers aren't affected: the SDK's callRpc (used by the CLI and plugin server code), Side Chat, desktop session creation, and the community marketplace plugins checked, which call the endpoint directly and all parse loosely.

What changed

  • Server: invokeRpcHandler returns { ok: true, result }, and the route builds { ok: true, result: outcome.result } explicitly, so internal fields can't reach the response. The server still computes invalidated and broadcasts it through notifyPluginChanged.
  • Client:
    • rpc-query-host.ts computes tags, keyTags and invalidated with the shared rpcResponseTags, from the hook's contract, the input parsed by the contract's input schema, and the result. That's the same function the server uses, and the same way core routes derive their tags in route-tags.ts.
    • The app transport drops its envelope flag.
    • The SDK test host returns only the result.
  • Tests:
    • the six server tests that assert the exact response body now expect exactly { ok, result };
    • a new wire test: a method declaring tags, keyTags and invalidates returns exactly { ok, result } and still calls notifyPluginChanged with its invalidation. It fails on main, where the body also carries tags, keyTags and invalidated.

The provider usage card and both desktop paths work again without changes. This replaces #6069, which loosened the usage card's parser.

How you verified

  • Live pnpm start:worktree servers, same getUsage call: main returns keys invalidated, keyTags, ok, result, tags; this branch returns ok, result.
  • Typecheck: plugin SDK and app pass. The server typecheck failed only on the six old response expectations, which this PR updates.
  • @get-bb/plugin-sdk: 390 tests pass, including rpc-query-host.test.tsx, where reads refresh from contract-declared tags and keyTags with no server-sent tags.
  • push-notifications (44) and provider-usage (23) pass.
  • plugin-wire.test.ts: 31 tests pass; the new test fails on main.

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits October 21, 2026 12:35
#5658 added the tag engine's tags, keyTags and invalidated to every plugin
RPC response by serialising the handler outcome as-is. Strict callers that
fetch the endpoint directly rejected every successful response: the provider
usage card, desktop machine enrollment and the desktop account server list.

The response is now exactly { ok, result }. Core's RPC hooks compute the
same tags from the contract they already hold, with the shared
rpcResponseTags, and the server keeps using invalidated for its broadcast.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 67f2e8b into main Oct 21, 2026
48 checks passed
@ymichael
ymichael deleted the bb/plugin-rpc-public-envelope branch October 21, 2026 19:51
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