Problem#
publishEnrichedSnapshot in packages/provider-core/src/server/managedProvider.ts unconditionally copies state.snapshot.usageLimits and state.usageAuthLabel onto every enriched snapshot. When enrichment reports a sign-out (auth.status === "unauthenticated", such as AntigravityProvider.onSignedOut or onAuthRequired) or an account/workspace switch, the signed-out or previous account's usage limits and plan override stay published on streamChanges and getSnapshot until a later health check clears them. Similarly, applySnapshotBase did not treat auth.status === "unauthenticated" as clearing retained usage limits if a probe returned probeFailed or raced with a live usage update.
Change#
packages/provider-core/src/server/managedProvider.ts:
- Extract
dropsPublishedUsage(previous, next) to check next.status === "unauthenticated", a case-insensitive email change, or a new/different workspaceId.
- Use it in both
publishEnrichedSnapshot and applySnapshotBase so sign-out or an account/workspace switch drops state.snapshot.usageLimits (using the incoming snapshot's usageLimits) and clears state.usageAuthLabel without resurrecting stale plan overrides on subsequent enrichments.
- Keep
state.snapshot reference intact when Equal.equals(state.snapshot, merged) matches while still clearing usageAuthLabel in state.
packages/provider-core/src/server/managedProvider.test.ts:
- Add failing-first tests covering
publishEnrichedSnapshot on sign-out, email switch, and workspace switch (including confirming a follow-up enrichment does not resurrect the cleared plan override), and applySnapshotBase on a sign-out probe with probeFailed.
Scope#
Small, focused bug fix in packages/provider-core (2 files) under the obvious-bug exception in CONTRIBUTING.md—no separate issue needed, and no maintainer request required. Keeps stale usage limits and plan overrides from leaking across sign-out or account/workspace switches without changing contracts, settings, or UI.
Verification#
- Confirmed all 4 new test cases fail on
main before the fix and pass after (25/25 in packages/provider-core/src/server/managedProvider.test.ts).
- Rebased cleanly onto
main (ad2bdc76a5) at 4154e37187 and verified vp run check:changed passes (format, lint, knip, typecheck, and tests).
Written with Gemini 4 Neon (Antigravity) and verified with Claude Opus 5.5 (Claude Code) in T3 Code.
This PR conflicts with
main. Rebase it or mergemaininto it. If it still conflicts after 7 days with no activity, it will be closed automatically.See the conflict window.