From f877b1b01f19432f731a5cc7c4bca71a39824172 Mon Sep 17 00:00:00 2001 From: rune-oai <157205701+rune-gh@users.noreply.github.com> Date: Thu, 3 Dec 2026 12:36:39 -0800 Subject: [PATCH] fix(quota): reset column per Antigravity model group; name trial plans Antigravity reports a weekly window per model group (Claude and GPT, Gemini), each resetting on its own clock, but the accounts table showed only the primary window's reset. Grouped windows now get one reset column per group, on that group's longest window. A Google AI Pro trial gets no Claude or GPT models from Antigravity (fetchAvailableModels lists them as *-disabled and the quota summary omits the group), so its row had empty Claude and GPT columns with no explanation. The recorder and the panel's live read now report the plan as "pro-trial", shown as "Pro Trial". Antigravity has no plan weights, so routing is unchanged. Co-Authored-By: Claude Opus 5.5 --- internal/quotahistory/providers.go | 7 +- internal/quotahistory/providers_test.go | 11 +-- web/src/features/quota/QuotaPage.tsx | 6 +- .../quota/components/PoolAccountsTable.tsx | 70 +++++++++++++------ web/src/features/quota/liveWindows.ts | 4 ++ web/src/features/quota/poolWindowLabels.ts | 21 ++++++ .../antigravity/AntigravityQuotaBody.tsx | 2 + web/tests/quotaAccountDetail.test.ts | 52 ++++++++++++++ web/tests/quotaLivePools.test.ts | 33 ++++++++- 9 files changed, 174 insertions(+), 32 deletions(-) diff --git a/internal/quotahistory/providers.go b/internal/quotahistory/providers.go index 2f0d8cf620b..e31b8d6678d 100644 --- a/internal/quotahistory/providers.go +++ b/internal/quotahistory/providers.go @@ -213,7 +213,9 @@ var antigravityTierPlans = map[string]string{ } // antigravityPlan names the Google subscription tier. The paid tier wins over -// the current tier, as in the panel's account view. +// the current tier, as in the panel's account view. A trial ("Google AI Pro · +// Trial") gets a "-trial" suffix: Google gives it fewer models than the paid +// plan (no Claude or GPT), so its account shows no Claude and GPT windows. func (r *Recorder) antigravityPlan(ctx context.Context, auth *coreauth.Auth) string { headers := bearerHeaders() headers["User-Agent"] = misc.AntigravityUserAgent() @@ -235,6 +237,9 @@ func parseAntigravityPlan(body []byte) string { continue } if plan := antigravityTierPlans[id]; plan != "" { + if strings.Contains(strings.ToLower(firstString(tier.Get("name"))), "trial") { + return plan + "-trial" + } return plan } if name := firstString(tier.Get("name")); name != "" { diff --git a/internal/quotahistory/providers_test.go b/internal/quotahistory/providers_test.go index 6b887b6de43..c7b28e1f644 100644 --- a/internal/quotahistory/providers_test.go +++ b/internal/quotahistory/providers_test.go @@ -264,11 +264,12 @@ func TestRecorderRetriesAnUnknownPlanOnTheNextPoll(t *testing.T) { func TestParseAntigravityPlan(t *testing.T) { for body, want := range map[string]string{ - `{"currentTier":{"id":"free-tier"}}`: "free", - `{"paid_tier":{"id":"g1-ultra-tier"},"current_tier":{"id":"free-tier"}}`: "ultra", - `{"currentTier":{"id":"new-tier","name":"Google AI Next"}}`: "Google AI Next", - `{"currentTier":{"id":"new-tier"}}`: "new-tier", - `{}`: "", + `{"currentTier":{"id":"free-tier"}}`: "free", + `{"paid_tier":{"id":"g1-ultra-tier"},"current_tier":{"id":"free-tier"}}`: "ultra", + `{"currentTier":{"id":"new-tier","name":"Google AI Next"}}`: "Google AI Next", + `{"currentTier":{"id":"new-tier"}}`: "new-tier", + `{"paidTier":{"id":"g1-pro-tier","name":"Google AI Pro · Trial"},"currentTier":{"id":"standard-tier"}}`: "pro-trial", + `{}`: "", } { if got := parseAntigravityPlan([]byte(body)); got != want { t.Fatalf("parseAntigravityPlan(%s) = %q, want %q", body, got, want) diff --git a/web/src/features/quota/QuotaPage.tsx b/web/src/features/quota/QuotaPage.tsx index 6c69c736b45..ebef15d84ac 100644 --- a/web/src/features/quota/QuotaPage.tsx +++ b/web/src/features/quota/QuotaPage.tsx @@ -68,7 +68,7 @@ import { } from './poolModel'; import { formatPlanName, formatWeight } from './poolPrefs'; import { liveReadFor, type LiveRead } from './liveWindows'; -import { windowColumns, windowLabel } from './poolWindowLabels'; +import { resetColumns, windowColumns } from './poolWindowLabels'; import { formatMoney } from './poolFormat'; import { useQuotaHistory } from './hooks/useQuotaHistory'; import { usePlanWeights } from './hooks/usePlanWeights'; @@ -1056,8 +1056,8 @@ export function QuotaPage() { providerLabel={providerLabel} rows={rows} windowColumns={columns} - primaryLabel={ - windows[0] ? windowLabel(t, windows[0].key, windowLabels) : undefined + resetColumns={ + columns ? resetColumns(t, windows, windowLabels) : undefined } now={now} locale={locale} diff --git a/web/src/features/quota/components/PoolAccountsTable.tsx b/web/src/features/quota/components/PoolAccountsTable.tsx index 3dae2125000..0c2664bff19 100644 --- a/web/src/features/quota/components/PoolAccountsTable.tsx +++ b/web/src/features/quota/components/PoolAccountsTable.tsx @@ -53,8 +53,11 @@ export interface PoolAccountsTableProps { rows: readonly PoolAccountRow[]; /** Window columns for providers other than Claude and Codex, shortest first. */ windowColumns?: readonly PoolWindowColumn[]; - /** Label of the window the reset column follows (other providers). */ - primaryLabel?: string; + /** + * Windows that get a reset column (other providers): the primary window, or + * each group's longest window when the windows split into groups. + */ + resetColumns?: readonly { key: string; label: string }[]; now: number; locale: string; /** Codex only: banked reset credits per auth index. */ @@ -130,7 +133,7 @@ export function PoolAccountsTable({ providerLabel, rows, windowColumns, - primaryLabel, + resetColumns, now, locale, credits, @@ -159,16 +162,27 @@ export function PoolAccountsTable({ const capacityOf = (row: PoolAccountRow) => (heaviest > 0 ? (100 * row.weight) / heaviest : 100); // "Next" only means something when there is another account to pick instead. const showNext = rows.filter((row) => !row.disabled).length > 1; - const resetLabel = - generic && primaryLabel - ? t('quota_accounts.col_window_reset', { window: primaryLabel }) - : t('quota_accounts.col_next_reset'); + // Claude and Codex (and a provider with no reset windows): one "Next reset" column on `weekly`. + const resets = + generic && resetColumns?.length + ? resetColumns.map((column) => ({ + key: column.key, + label: t('quota_accounts.col_window_reset', { window: column.label }), + of: (row: PoolAccountRow) => row.windows[column.key]?.resetsAt ?? null, + })) + : [ + { + key: 'next', + label: t('quota_accounts.col_next_reset'), + of: (row: PoolAccountRow) => row.weekly?.resetsAt ?? null, + }, + ]; const columnCount = 3 + (generic ? windowColumns.length : 2) + (!generic && showScoped ? 1 : 0) + - 1 + + resets.length + (showCredits ? 1 : 0); const renderCredits = (row: PoolAccountRow) => { @@ -247,7 +261,11 @@ export function PoolAccountsTable({ {!generic && showScoped && ( {labels.scoped} )} - {resetLabel} + {resets.map((column) => ( + + {column.label} + + ))} {showCredits && ( {t('quota_accounts.col_banked')} )} @@ -255,7 +273,6 @@ export function PoolAccountsTable({ {rows.map((row) => { - const reset = row.weekly?.resetsAt ?? null; const expanded = open.has(row.authIndex); const detailId = `pool-account-${provider}-${row.authIndex}`; return ( @@ -344,18 +361,27 @@ export function PoolAccountsTable({ )} - - {reset === null ? ( - — - ) : ( - <> - - {t('quota_pool.in_duration', { duration: formatDuration(reset - now) })} - - {formatResetInstant(reset, now, locale)} - - )} - + {resets.map((column) => { + const reset = column.of(row); + return ( + + {reset === null ? ( + — + ) : ( + <> + + {t('quota_pool.in_duration', { + duration: formatDuration(reset - now), + })} + + + {formatResetInstant(reset, now, locale)} + + + )} + + ); + })} {showCredits && {renderCredits(row)}} {expanded && renderDetail && ( diff --git a/web/src/features/quota/liveWindows.ts b/web/src/features/quota/liveWindows.ts index b9ca061f09a..dbb217742b3 100644 --- a/web/src/features/quota/liveWindows.ts +++ b/web/src/features/quota/liveWindows.ts @@ -224,6 +224,10 @@ export function liveReadFor(provider: string, quota: unknown): LiveRead | null { const groups = quota as AntigravityQuotaState; windows = groupWindows(groups); plan = groups.subscription?.plan ? stableKey(groups.subscription.plan) : null; + // A trial ("Google AI Pro · Trial") has fewer models than the paid plan; the recorder says "pro-trial". + if (plan && plan !== 'unknown' && /trial/i.test(groups.subscription?.tierName ?? '')) { + plan += '_trial'; + } break; } case 'xai': { diff --git a/web/src/features/quota/poolWindowLabels.ts b/web/src/features/quota/poolWindowLabels.ts index 58d0fa11e46..07f1492458e 100644 --- a/web/src/features/quota/poolWindowLabels.ts +++ b/web/src/features/quota/poolWindowLabels.ts @@ -164,3 +164,24 @@ export function windowColumns( })) ); } + +/** + * Reset columns for a provider's windows (given longest first): the primary + * window alone, or, when the windows split into groups, each group's longest + * window ("Claude and GPT models weekly", "Gemini Models weekly"), since each + * group resets on its own clock. + */ +export function resetColumns( + t: Translate, + windows: readonly { key: string; periodHours?: number | null }[], + reported?: Record +): { key: string; label: string }[] { + const columns = windowColumns(t, windows, reported); + if (!columns.some((column) => column.group)) { + return windows[0] ? [{ key: windows[0].key, label: windowLabel(t, windows[0].key, reported) }] : []; + } + // Columns run shortest first within a group, so the last one seen is the group's longest. + const longest = new Map(); + columns.forEach((column) => longest.set(column.group ?? '', column)); + return [...longest.values()].map(({ key, label }) => ({ key, label })); +} diff --git a/web/src/features/quota/providers/antigravity/AntigravityQuotaBody.tsx b/web/src/features/quota/providers/antigravity/AntigravityQuotaBody.tsx index 0a5dc250e12..fb90b7ff30e 100644 --- a/web/src/features/quota/providers/antigravity/AntigravityQuotaBody.tsx +++ b/web/src/features/quota/providers/antigravity/AntigravityQuotaBody.tsx @@ -81,6 +81,8 @@ const getAntigravityPlanLabel = ( t: TFunction ): string | null => { if (!subscription) return null; + // "Google AI Pro · Trial": the trial has fewer models than the paid plan, so keep Google's name. + if (subscription.tierName && /trial/i.test(subscription.tierName)) return subscription.tierName; if (subscription.plan === 'free') return t('antigravity_subscription.plan_free'); if (subscription.plan === 'pro') return t('antigravity_subscription.plan_pro'); if (subscription.plan === 'ultra') return t('antigravity_subscription.plan_ultra'); diff --git a/web/tests/quotaAccountDetail.test.ts b/web/tests/quotaAccountDetail.test.ts index b9602a079c7..a238d48b55d 100644 --- a/web/tests/quotaAccountDetail.test.ts +++ b/web/tests/quotaAccountDetail.test.ts @@ -118,6 +118,58 @@ describe('accounts table rows', () => { expect(markup).not.toContain('>detail<'); }); + test('grouped windows get a reset column per group', () => { + const geminiReset = NOW + 3 * 86_400_000; + const claudeReset = NOW + 17 * 60_000; + const history = normalizeQuotaHistory({ + accounts: [{ auth_index: 'a1', provider: 'antigravity', label: 'ag', plan: 'pro' }], + samples: [ + { + t: NOW - 60_000, + auth_index: 'a1', + windows: { + group_claude_and_gpt_models_3p_weekly: { + used_percent: 100, + resets_at: claudeReset, + period_hours: 168, + }, + group_gemini_models_gemini_weekly: { + used_percent: 62, + resets_at: geminiReset, + period_hours: 168, + }, + }, + }, + ], + }); + const keys = ['group_claude_and_gpt_models_3p_weekly', 'group_gemini_models_gemini_weekly']; + const agRows = buildPoolAccountRows( + history, + 'antigravity', + [{ authIndex: 'a1', label: 'ag', plan: 'pro', disabled: false }], + NOW, + { windowKeys: keys, primary: keys[0] } + ); + const markup = renderToStaticMarkup( + createElement(PoolAccountsTable, { + provider: 'antigravity', + providerLabel: 'Antigravity', + rows: agRows, + windowColumns: keys.map((key) => ({ key, label: key })), + resetColumns: [ + { key: keys[0], label: 'Claude and GPT models weekly' }, + { key: keys[1], label: 'Gemini Models weekly' }, + ], + now: NOW, + locale: 'en', + }) + ); + expect(markup).toContain('Claude and GPT models weekly reset'); + expect(markup).toContain('Gemini Models weekly reset'); + expect(markup).toContain('in 17m'); + expect(markup).toContain('in 3d'); + }); + test('a history-only account lists its recorded windows', () => { const markup = renderToStaticMarkup( createElement(HistoryAccountDetail, { diff --git a/web/tests/quotaLivePools.test.ts b/web/tests/quotaLivePools.test.ts index 26e9e18fc9a..139ec5698fa 100644 --- a/web/tests/quotaLivePools.test.ts +++ b/web/tests/quotaLivePools.test.ts @@ -13,8 +13,13 @@ import { providerWindowLabels, providerWindows, } from '../src/features/quota/poolModel'; -import { groupWindowChoices, windowColumns } from '../src/features/quota/poolWindowLabels'; +import { + groupWindowChoices, + resetColumns, + windowColumns, +} from '../src/features/quota/poolWindowLabels'; import { POOL_UNITS } from '../src/features/quota/poolFormat'; +import { formatPlanName } from '../src/features/quota/poolPrefs'; const NOW = Date.UTC(2026, 10, 15, 12, 0, 0); const H = 3_600_000; @@ -129,6 +134,17 @@ describe('live reads as history windows', () => { expect(read?.windows[1].usedPercent).toBeCloseTo(27); }); + test('an Antigravity trial reads as its own plan, matching the recorder', () => { + const read = liveReadFor('antigravity', { + status: 'success', + subscription: { plan: 'pro', tierName: 'Google AI Pro · Trial', tierId: 'g1-pro-tier' }, + groups: [], + }); + expect(read?.plan).toBe('pro_trial'); + expect(formatPlanName(read?.plan ?? null)).toBe('Pro Trial'); + expect(formatPlanName('pro-trial')).toBe('Pro Trial'); + }); + test('xAI weekly credit usage maps to `weekly`; a monthly limit adds `monthly`', () => { const read = liveReadFor('xai', { status: 'success', @@ -295,6 +311,21 @@ describe('owner pool fixture', () => { ['Claude and GPT models', '5-hour'], ['Claude and GPT models', 'Weekly'], ]); + // Each group resets on its own clock, so each gets a reset column. + expect(resetColumns(t, providerWindows(history, 'antigravity'), labels)).toEqual([ + { key: 'group_gemini_models_gemini_weekly', label: 'Gemini Models weekly' }, + { key: 'group_claude_and_gpt_models_3p_weekly', label: 'Claude and GPT models weekly' }, + ]); + }); + + test('ungrouped windows keep one reset column on the primary window', () => { + expect( + resetColumns(t, [ + { key: 'monthly', periodHours: 720 }, + { key: 'five_hour', periodHours: 5 }, + ]) + ).toEqual([{ key: 'monthly', label: 'Monthly' }]); + expect(resetColumns(t, [])).toEqual([]); }); test('xAI with one unlabelled weekly window offers no switcher', () => {