Repository navigation
Conversation
ymichael
added a commit
that referenced
this pull request
Oct 21, 2026
## 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](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Provider Usage rejected successful RPC responses after #5658 added
tags,keyTags, andinvalidatedmetadata. Its strict response-envelope schema accepted onlyokandresult, so the sidebar showed “Couldn’t load usage” even when the server returned valid measurements.What changed
Allow additional response-envelope fields while retaining strict validation of the usage payload. Update the existing sidebar integration test to include the metadata returned by the server.
How you verified
pnpm exec turbo run test lint typecheck --filter=bb-plugin-bb--provider-usage: all 23 tests, lint, and typecheck passed.git diff --checkpassed.