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 3b58704b0bf..f84e625d7fb 100644 --- a/internal/quotahistory/providers_test.go +++ b/internal/quotahistory/providers_test.go @@ -265,11 +265,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 989ec9972c8..955be8d3b2c 100644 --- a/web/src/features/quota/QuotaPage.tsx +++ b/web/src/features/quota/QuotaPage.tsx @@ -69,7 +69,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'; @@ -1058,8 +1058,8 @@ export function QuotaPage() { providerLabel={providerLabel} rows={rows} windowColumns={columns} - primaryLabel={ - orderingKey ? windowLabel(t, orderingKey, windowLabels) : undefined + resetColumns={ + columns ? resetColumns(t, windows, windowLabels, orderingKey) : undefined } now={now} locale={locale} diff --git a/web/src/features/quota/components/PoolAccountsTable.tsx b/web/src/features/quota/components/PoolAccountsTable.tsx index 92731400eff..c09e02402bd 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. */ @@ -133,7 +136,7 @@ export function PoolAccountsTable({ providerLabel, rows, windowColumns, - primaryLabel, + resetColumns, now, locale, credits, @@ -162,16 +165,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) => { @@ -250,7 +264,11 @@ export function PoolAccountsTable({ {!generic && showScoped && ( {labels.scoped} )} - {resetLabel} + {resets.map((column) => ( + + {column.label} + + ))} {showCredits && ( {t('quota_accounts.col_banked')} )} @@ -258,7 +276,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 ( @@ -352,18 +369,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..b0c1810a4b9 100644 --- a/web/src/features/quota/poolWindowLabels.ts +++ b/web/src/features/quota/poolWindowLabels.ts @@ -164,3 +164,27 @@ export function windowColumns( })) ); } + +/** + * Reset columns for a provider's windows (given longest first): the primary + * window alone (the window accounts are ordered by, else the longest), 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, + primary?: string | null +): { key: string; label: string }[] { + const columns = windowColumns(t, windows, reported); + if (!columns.some((column) => column.group)) { + const key = windows.find((window) => window.key === primary)?.key ?? windows[0]?.key; + return key ? [{ key, label: windowLabel(t, 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..94d38d381c8 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,33 @@ 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' }]); + // The window accounts are ordered by wins over the longest one. + expect( + resetColumns( + t, + [ + { key: 'monthly', periodHours: 720 }, + { key: 'five_hour', periodHours: 5 }, + ], + undefined, + 'five_hour' + ) + ).toEqual([{ key: 'five_hour', label: '5-hour' }]); + expect(resetColumns(t, [])).toEqual([]); }); test('xAI with one unlabelled weekly window offers no switcher', () => {