Skip to content

Invalidate model pickers only for provider changes - #1817

Merged
ymichael merged 1 commit into
mainfrom
bb/narrow-provider-picker-invalidation
Aug 18, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/narrow-provider-picker-invalidation

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Summary

  • add a provider-registration-specific realtime change kind
  • coalesce registry mutations at plugin lifecycle boundaries using a monotonic registration revision
  • keep provider and execution-option caches intact for unrelated plugin changes
  • invalidate picker caches when a provider is installed, removed, enabled, disabled, or reloaded

Addresses the performance finding from #1810 (comment).

Testing

  • pnpm exec turbo run test --filter=@bb/server -- --run test/services/plugins/plugin-service.test.ts test/services/plugins/plugin-provider-registration.test.ts -t "broadcasts plugins-changed|adds the provider"
  • pnpm exec turbo run test --filter=@bb/app -- --run src/hooks/realtime-cache-effects.test.ts
  • pnpm exec turbo run typecheck --filter=@bb/domain --filter=@bb/server --filter=@bb/app
  • pnpm exec turbo run typecheck --filter=@get-bb/plugin-sdk
  • pnpm exec turbo run lint --filter=@bb/app --filter=@bb/server --filter=@bb/domain (0 errors; existing warnings remain)

This changes only the server-to-app realtime event contract; the host-daemon protocol is unchanged.

AGENT GENERATED: by GPT-5

@bb-slop-cop

bb-slop-cop Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am the SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior.

export const SYSTEM_CHANGE_KINDS = [
"config-changed",
"plugins-changed",
"provider-registrations-changed",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Regenerate the embedded plugin SDK template after this contract change. The committed packages/templates/src/generated/plugin-sdk-dts.generated.ts still lacks this enum member. node packages/templates/scripts/generate-templates.mjs --check fails, and generated template consumers receive the stale realtime contract until the file is regenerated.

deps.hub.notifySystem(["plugins-changed"]);
const changes: SystemChangeKind[] = ["plugins-changed"];
const providerRegistrationRevision =
deps.providerRegistry?.getRegistrationRevision();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — Non-blocking architecture note: the registry mutation does not own this notification. experimental_registerProvider supports registration after activation, and its returned handle can dispose that registration later. Those changes increment the revision, but no event reaches open pickers until another plugin lifecycle or settings event calls this function. This delay existed before this pull request, so it is not a new regression. A registry callback or subscription would remove the cross-service polling and cover live register/dispose changes; a focused test would document the intended behavior.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain-English summary

This change stops BB from reloading provider and model lists after every plugin update. It adds a specific signal for provider registration changes.

BB now reloads those lists when a provider plugin adds or removes a provider.

Review result

I found one issue that must be fixed before merge.

  1. The generated SDK template is stale.

The source type includes provider-registrations-changed, but the plugin scaffold template still contains the old type.

node packages/templates/scripts/generate-templates.mjs --check exits with code 1. Run the generator and commit its output.

See the inline finding.

Architecture note

The registry owns the provider state. The plugin service checks a revision only when it sends another plugin notice.

Live register or dispose actions can wait for a later plugin event before the browser receives an update. This limitation existed before this change.

A registry event callback could simplify this design and cover live changes. See the inline note.

I found no duplicate revision logic elsewhere.

Other checks

  • Security review found no issue.

  • Performance review found no issue. The change reduces unnecessary provider and execution-option requests.

  • GitHub CI passes all current required jobs.

  • The application realtime test passed all 44 tests.

  • The focused provider tests passed. A wider local run had one unrelated timeout during heavy shared-worktree use.

  • Browser tests showed live add and remove actions for Echo Agent in an open picker.

  • An unrelated plugin enable action caused no provider or execution-option request.

  • git diff --check passed, and the review worktree is clean.

The independent GPT-5.6-Sol review gate found the stale file and returned REQUEST CHANGES. I posted this GitHub review as a comment only.

@ymichael
ymichael merged commit 6889883 into main Aug 18, 2026
10 checks passed
@ymichael
ymichael deleted the bb/narrow-provider-picker-invalidation branch August 18, 2026 21:10
SawyerHood added a commit that referenced this pull request Aug 18, 2026
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