From 811e2f72f14534d6f78a0a8ae879d83707d0f486 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 05:05:29 +0000 Subject: [PATCH 1/2] fix(usage): drop dead Go keys and say when Antigravity has no window OpenCode Go keys whose vendor says they have no subscription were listed as not-applicable rows. Those rows are omitted. A payment-required subscription still shows. Antigravity API key and Agent Platform reads say T3 has no quota window, and a missing Google sign-in is a notice instead of a blank row. Model: grok-4.7 Task: fix Agent: usage-panel lane (CLO-951) Lane: magpie Harness: t3/codex Model-family: Grok Model-generation: 4.7 Skills-SHA: 0540352af0d6f43bdeea39a8c4aad4660ab0ec55 Co-Authored-By: Grok 4.7 --- .../provider/antigravityUsageLimits.test.ts | 20 ++++++++--- .../src/provider/antigravityUsageLimits.ts | 7 +++- apps/server/src/usage/magpieQuotas.test.ts | 23 ++++++------- apps/server/src/usage/magpieQuotas.ts | 8 +++++ packages/shared/src/usageLimits.test.ts | 33 +++++++++++++++++++ packages/shared/src/usageLimits.ts | 15 +++++++-- 6 files changed, 87 insertions(+), 19 deletions(-) diff --git a/apps/server/src/provider/antigravityUsageLimits.test.ts b/apps/server/src/provider/antigravityUsageLimits.test.ts index 9defd9df90dce..f7a59745e8044 100644 --- a/apps/server/src/provider/antigravityUsageLimits.test.ts +++ b/apps/server/src/provider/antigravityUsageLimits.test.ts @@ -656,11 +656,21 @@ describe("Antigravity subscription limits", () => { it.effect("does not make network requests for API keys or missing sign-ins", () => Effect.gen(function* () { - for (const options of [{ authMethod: "gemini-api-key" as const }, { missingToken: true }]) { - const { probe, requests } = yield* fixture(options); - expect((yield* probe).unavailable?.reason).toBe("unsupported"); - expect(requests).toEqual([]); - } + const apiKey = yield* fixture({ authMethod: "gemini-api-key" }); + const apiLimits = yield* apiKey.probe; + expect(apiLimits.unavailable).toEqual({ + reason: "unsupported", + message: + "Not applicable: Antigravity API keys and Agent Platform are billed by Google. T3 has no quota window for them.", + }); + expect(apiKey.requests).toEqual([]); + const signedOut = yield* fixture({ missingToken: true }); + const signedOutLimits = yield* signedOut.probe; + expect(signedOutLimits.unavailable).toEqual({ + reason: "unsupported", + message: "Sign in with Google to see Antigravity limits.", + }); + expect(signedOut.requests).toEqual([]); }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))), ); }); diff --git a/apps/server/src/provider/antigravityUsageLimits.ts b/apps/server/src/provider/antigravityUsageLimits.ts index ede0e5c47d20e..2ff3e1ad1ac07 100644 --- a/apps/server/src/provider/antigravityUsageLimits.ts +++ b/apps/server/src/provider/antigravityUsageLimits.ts @@ -234,7 +234,12 @@ export const makeAntigravityUsageProbe = Effect.fn("makeAntigravityUsageProbe")( const startedGeneration = generation; const checkedAt = DateTime.formatIso(yield* DateTime.now); if (input.authMethod !== "oauth-personal" && input.authMethod !== "oauth-business") { - return makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" }); + return makeUnavailableUsageLimits({ + checkedAt, + reason: "unsupported", + message: + "Not applicable: Antigravity API keys and Agent Platform are billed by Google. T3 has no quota window for them.", + }); } if (!(yield* fs.exists(tokenPath))) { cached = undefined; diff --git a/apps/server/src/usage/magpieQuotas.test.ts b/apps/server/src/usage/magpieQuotas.test.ts index 1776dc2ce9b6f..ada555488b5f2 100644 --- a/apps/server/src/usage/magpieQuotas.test.ts +++ b/apps/server/src/usage/magpieQuotas.test.ts @@ -101,20 +101,21 @@ describe("magpieQuotasToAccounts", () => { ]); }); - it("marks standing refusals not applicable and passing failures as failed reads", () => { - const [, , team, go, timedOut] = accounts; - expect(team!.email).toBe("first@example.com · Team"); - expect(team!.usageLimits.unavailable).toEqual({ + it("drops a Go key with no subscription and keeps payment and failed reads", () => { + expect(accounts.map((account) => account.id)).toEqual([ + "claude:first@example.com", + "codex:first@example.com", + "codex:first@example.com · Team", + "claude:second@example.com", + ]); + const team = accounts[2]!; + const timedOut = accounts[3]!; + expect(team.email).toBe("first@example.com · Team"); + expect(team.usageLimits.unavailable).toEqual({ reason: "unsupported", message: "Payment Required.", }); - expect(go!.driver).toBe("opencode"); - expect(go!.email).toBeUndefined(); - expect(go!.usageLimits.unavailable).toEqual({ - reason: "unsupported", - message: "This key has no OpenCode Go subscription.", - }); - expect(timedOut!.usageLimits.unavailable?.reason).toBe("probeFailed"); + expect(timedOut.usageLimits.unavailable?.reason).toBe("probeFailed"); }); }); diff --git a/apps/server/src/usage/magpieQuotas.ts b/apps/server/src/usage/magpieQuotas.ts index 0098b6ee46c14..4f918072d6131 100644 --- a/apps/server/src/usage/magpieQuotas.ts +++ b/apps/server/src/usage/magpieQuotas.ts @@ -167,6 +167,14 @@ export function magpieQuotasToAccounts( for (const entry of entries) { const driver = driverFor(entry.provider); if (!driver) continue; + if ( + driver === "opencode" && + entry.error && + isStandingRefusal(entry.error) && + !/payment required/i.test(entry.error) + ) { + continue; + } const user = entry.user?.trim() || entry.name?.trim() || entry.provider; const id = `${entry.provider}:${user}`; if (seen.has(id)) continue; diff --git a/packages/shared/src/usageLimits.test.ts b/packages/shared/src/usageLimits.test.ts index 6e21b53ff83eb..7dd8084e302c7 100644 --- a/packages/shared/src/usageLimits.test.ts +++ b/packages/shared/src/usageLimits.test.ts @@ -1948,12 +1948,45 @@ describe("owners and not-applicable usage", () => { expect(groups.map((group) => group.owner)).toEqual(["Unassigned"]); }); + it("says when Antigravity has no quota window", () => { + const billed = provider({ + instanceId: ProviderInstanceId.make("antigravity-api"), + driver: ProviderDriverKind.make("antigravity"), + displayName: "Antigravity", + usageLimits: { + checkedAt, + windows: [], + unavailable: { + reason: "unsupported", + message: + "Not applicable: Antigravity API keys and Agent Platform are billed by Google. T3 has no quota window for them.", + }, + }, + }); + const view = new Map([ + [ + EnvironmentId.make("env-a"), + { entry: { target: { label: "Crown" } }, serverConfig: { providers: [billed] } }, + ], + ]); + expect(collectNotApplicable(view)).toEqual([ + { + environment: "Crown", + subject: "Antigravity", + reason: + "Antigravity API keys and Agent Platform are billed by Google. T3 has no quota window for them.", + }, + ]); + expect(collectLimitNotices(view)).toEqual([]); + }); + it("lists not-applicable usage apart from failures, and a billing refusal as a notice", () => { const view = presentations(); expect(collectNotApplicable(view)).toEqual([ { environment: "Crown", subject: "Magpie Codex", reason: "gateway reports it." }, ]); expect(collectLimitNotices(view)).toEqual([ + "Antigravity: Sign in with Google to see limits.", "Magpie · owner.a@example.com · Team: the vendor says payment is required, so this subscription's billing needs attention.", "Magpie · k: Upstream timed out.", ]); diff --git a/packages/shared/src/usageLimits.ts b/packages/shared/src/usageLimits.ts index 07121759317df..7c1d84e498db2 100644 --- a/packages/shared/src/usageLimits.ts +++ b/packages/shared/src/usageLimits.ts @@ -490,9 +490,20 @@ export function collectLimitNotices(presentations: LimitPresentations): readonly for (const presentation of presentations.values()) { const environmentLabel = presentation.entry.target.label; for (const provider of providersWithLimits(presentation.serverConfig?.providers ?? [])) { - if (provider.usageLimits?.unavailable?.reason === "unsupported") continue; - const notice = provider.usageLimits ? limitsNotice(provider.usageLimits) : null; const name = provider.displayName?.trim() || String(provider.driver); + const unavailable = provider.usageLimits?.unavailable; + if (unavailable?.reason === "unsupported") { + const message = unavailable.message?.trim(); + if ( + provider.driver === "antigravity" && + message && + !message.startsWith(NOT_APPLICABLE_PREFIX) + ) { + notices.add(`${label(environmentLabel, name)}: ${message}`); + } + continue; + } + const notice = provider.usageLimits ? limitsNotice(provider.usageLimits) : null; if (notice) notices.add(`${label(environmentLabel, name)}: ${notice}`); } for (const source of presentation.serverConfig?.usageLimitSources ?? []) { From 5e940860b1a18639d9ff9620a188aa0fba201de3 Mon Sep 17 00:00:00 2001 From: nullStack65 <112618179+nullStack65@users.noreply.github.com> Date: Fri, 20 Nov 2026 05:50:23 +0000 Subject: [PATCH 2/2] fix(usage): keep a billed Go key and name the Antigravity sign-in once A Go key whose vendor says payment is required stays on the panel. Only OpenCode's own "no OpenCode Go subscription" sentence is dropped, so a different refusal still shows. The sign-in notice no longer repeats Antigravity after the provider name. Model: grok-4.7 Task: fix Agent: usage-panel lane (CLO-951) Lane: magpie Harness: t3/codex Model-family: Grok Model-generation: 4.7 Skills-SHA: 0540352af0d6f43bdeea39a8c4aad4660ab0ec55 Co-Authored-By: Grok 4.7 --- .../provider/antigravityUsageLimits.test.ts | 2 +- .../src/provider/antigravityUsageLimits.ts | 2 +- apps/server/src/usage/magpieQuotas.test.ts | 29 ++++++++++++++++++- apps/server/src/usage/magpieQuotas.ts | 12 ++++---- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/apps/server/src/provider/antigravityUsageLimits.test.ts b/apps/server/src/provider/antigravityUsageLimits.test.ts index f7a59745e8044..360b913412ca8 100644 --- a/apps/server/src/provider/antigravityUsageLimits.test.ts +++ b/apps/server/src/provider/antigravityUsageLimits.test.ts @@ -668,7 +668,7 @@ describe("Antigravity subscription limits", () => { const signedOutLimits = yield* signedOut.probe; expect(signedOutLimits.unavailable).toEqual({ reason: "unsupported", - message: "Sign in with Google to see Antigravity limits.", + message: "Sign in with Google to see limits.", }); expect(signedOut.requests).toEqual([]); }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))), diff --git a/apps/server/src/provider/antigravityUsageLimits.ts b/apps/server/src/provider/antigravityUsageLimits.ts index 2ff3e1ad1ac07..852225d3c9205 100644 --- a/apps/server/src/provider/antigravityUsageLimits.ts +++ b/apps/server/src/provider/antigravityUsageLimits.ts @@ -246,7 +246,7 @@ export const makeAntigravityUsageProbe = Effect.fn("makeAntigravityUsageProbe")( return makeUnavailableUsageLimits({ checkedAt, reason: "unsupported", - message: "Sign in with Google to see Antigravity limits.", + message: "Sign in with Google to see limits.", }); } const token = yield* fs.readFileString(tokenPath).pipe(Effect.flatMap(decodeTokenFile)); diff --git a/apps/server/src/usage/magpieQuotas.test.ts b/apps/server/src/usage/magpieQuotas.test.ts index ada555488b5f2..4689da5c75ba3 100644 --- a/apps/server/src/usage/magpieQuotas.test.ts +++ b/apps/server/src/usage/magpieQuotas.test.ts @@ -62,6 +62,20 @@ const entries = [ error: "this key has no OpenCode Go subscription: Go belongs to the member who subscribed, in that workspace", }, + { + provider: "magpie-go", + name: "Magpie Go", + kind: "plan", + user: "oc-billed", + error: "Payment Required", + }, + { + provider: "magpie-go", + name: "Magpie Go", + kind: "plan", + user: "oc-other", + error: "no workspace subscription on this account", + }, { provider: "claude", user: "second@example.com", error: "upstream timed out" }, ]; @@ -106,15 +120,28 @@ describe("magpieQuotasToAccounts", () => { "claude:first@example.com", "codex:first@example.com", "codex:first@example.com · Team", + "magpie-go:oc-billed", + "magpie-go:oc-other", "claude:second@example.com", ]); const team = accounts[2]!; - const timedOut = accounts[3]!; + const billed = accounts[3]!; + const other = accounts[4]!; + const timedOut = accounts[5]!; expect(team.email).toBe("first@example.com · Team"); expect(team.usageLimits.unavailable).toEqual({ reason: "unsupported", message: "Payment Required.", }); + expect(billed.driver).toBe("opencode"); + expect(billed.usageLimits.unavailable).toEqual({ + reason: "unsupported", + message: "Payment Required.", + }); + expect(other.usageLimits.unavailable).toEqual({ + reason: "unsupported", + message: "No workspace subscription on this account.", + }); expect(timedOut.usageLimits.unavailable?.reason).toBe("probeFailed"); }); }); diff --git a/apps/server/src/usage/magpieQuotas.ts b/apps/server/src/usage/magpieQuotas.ts index 4f918072d6131..a118b69a04463 100644 --- a/apps/server/src/usage/magpieQuotas.ts +++ b/apps/server/src/usage/magpieQuotas.ts @@ -151,6 +151,11 @@ function isStandingRefusal(error: string): boolean { ); } +/** OpenCode's own sentence for a key that was never subscribed. */ +function isDeadGoSubscription(error: string): boolean { + return /this key has no opencode go subscription/i.test(error); +} + /** Magpie's sentences run long; the first clause names the reason. */ function shortReason(error: string): string { const first = error.split(/[:;]\s/)[0]!.trim(); @@ -167,12 +172,7 @@ export function magpieQuotasToAccounts( for (const entry of entries) { const driver = driverFor(entry.provider); if (!driver) continue; - if ( - driver === "opencode" && - entry.error && - isStandingRefusal(entry.error) && - !/payment required/i.test(entry.error) - ) { + if (driver === "opencode" && entry.error && isDeadGoSubscription(entry.error)) { continue; } const user = entry.user?.trim() || entry.name?.trim() || entry.provider;