From 0a2a8dc9833286aa4ca8ddda20404d62ecc54587 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sun, 8 Nov 2026 23:34:45 -0800 Subject: [PATCH] Show usage reset dates in account switcher --- .../AccountSwitchRowItem.fixture.tsx | 9 ++- .../status-bar/AccountSwitchRowItem.tsx | 2 +- .../status-bar/InlineProviderUsage.tsx | 78 +++++++++++++------ src/renderer/src/i18n/locales/de.json | 3 + src/renderer/src/i18n/locales/en.json | 3 + src/renderer/src/i18n/locales/es.json | 3 + src/renderer/src/i18n/locales/fr.json | 3 + src/renderer/src/i18n/locales/ja.json | 3 + src/renderer/src/i18n/locales/ko.json | 3 + src/renderer/src/i18n/locales/pt.json | 3 + src/renderer/src/i18n/locales/ru.json | 3 + src/renderer/src/i18n/locales/tr.json | 3 + src/renderer/src/i18n/locales/zh-Hant.json | 3 + src/renderer/src/i18n/locales/zh.json | 3 + 14 files changed, 96 insertions(+), 26 deletions(-) diff --git a/src/renderer/src/components/status-bar/AccountSwitchRowItem.fixture.tsx b/src/renderer/src/components/status-bar/AccountSwitchRowItem.fixture.tsx index 0b65c0efe62..fbef8bb0d9d 100644 --- a/src/renderer/src/components/status-bar/AccountSwitchRowItem.fixture.tsx +++ b/src/renderer/src/components/status-bar/AccountSwitchRowItem.fixture.tsx @@ -21,12 +21,17 @@ function accountRows(provider: 'codex' | 'claude', width = 520) { weekly: { usedPercent: 38, windowMinutes: 10_080, - resetsAt: null, + resetsAt: Date.now() + (6 * 24 + 4) * 3_600_000 + 5_000, resetDescription: null }, fableWeekly: provider === 'claude' - ? { usedPercent: 42, windowMinutes: 10_080, resetsAt: null, resetDescription: null } + ? { + usedPercent: 42, + windowMinutes: 10_080, + resetsAt: Date.now() + 43 * 3_600_000 + 5_000, + resetDescription: null + } : null, updatedAt: 0, error: null, diff --git a/src/renderer/src/components/status-bar/AccountSwitchRowItem.tsx b/src/renderer/src/components/status-bar/AccountSwitchRowItem.tsx index c3acbc0259e..589f62ff5db 100644 --- a/src/renderer/src/components/status-bar/AccountSwitchRowItem.tsx +++ b/src/renderer/src/components/status-bar/AccountSwitchRowItem.tsx @@ -48,7 +48,7 @@ export function AccountSwitchRowItem({ {detail} ) : null} - {children ?
{children}
: null} + {children ?
{children}
: null} {action ?
{action}
: null} diff --git a/src/renderer/src/components/status-bar/InlineProviderUsage.tsx b/src/renderer/src/components/status-bar/InlineProviderUsage.tsx index 8a5adae43d2..758dbff20e0 100644 --- a/src/renderer/src/components/status-bar/InlineProviderUsage.tsx +++ b/src/renderer/src/components/status-bar/InlineProviderUsage.tsx @@ -10,10 +10,14 @@ import { } from '../../../../shared/usage-percentage-display' import { useResetCountdownClock } from '@/hooks/useResetCountdownClock' import { barColor, clampUsedPercent } from './tooltip' -import { formatRateLimitWindowChipLabel } from '../../../../shared/rate-limit-window-label' +import { formatWindowLabel } from '../../../../shared/rate-limit-window-label' +import { formatResetDuration } from '../../../../shared/rate-limit-reset-format' +import { formatUsageLimitResetClock } from '../../../../shared/agent-session/failures/agent-session-usage-limit' import { formatUsagePercentageLabel } from './usage-percentage-label' import { getUsageRosterRowState } from './usage-roster-row-state' -import { useTranslate } from '@/i18n/use-translate' +import { useIntlLocale, useTranslate } from '@/i18n/use-translate' + +type InlineUsageWindow = { key: string; used: number; label: string; resetsAt: number | null } export function InlineUsageBars({ limits, @@ -23,32 +27,40 @@ export function InlineUsageBars({ isFetching: boolean }): React.JSX.Element { const t = useTranslate() + const intlLocale = useIntlLocale() const display = normalizeUsagePercentageDisplay( useAppStore((state) => state.usagePercentageDisplay) ) - // Why: tick the session countdown live via one boundary-scheduled clock, not just the usage poll (#5399). - const now = useResetCountdownClock([limits.session?.resetsAt, limits.monthly?.resetsAt]) + // Why: tick every reset countdown live via one boundary-scheduled clock, not just the usage poll (#5399). + const now = useResetCountdownClock([ + limits.session?.resetsAt, + limits.weekly?.resetsAt, + limits.fableWeekly?.resetsAt, + limits.monthly?.resetsAt + ]) const usageWindows = [ limits.session ? { key: 'session', used: clampUsedPercent(limits.session.usedPercent), - // Why: live reset countdown (matches popover); '5h' window length only when resetsAt is unknown (#5399). - label: formatRateLimitWindowChipLabel(limits.session, now) + label: formatWindowLabel(limits.session.windowMinutes), + resetsAt: limits.session.resetsAt } : null, limits.weekly ? { key: 'weekly', used: clampUsedPercent(limits.weekly.usedPercent), - label: t('auto.components.status.bar.StatusBar.5c938d39ac', 'wk') + label: t('auto.components.status.bar.StatusBar.5c938d39ac', 'wk'), + resetsAt: limits.weekly.resetsAt } : null, limits.fableWeekly ? { key: 'fableWeekly', used: clampUsedPercent(limits.fableWeekly.usedPercent), - label: t('auto.components.status.bar.StatusBar.54e8d6bb2d', 'Fable') + label: t('auto.components.status.bar.StatusBar.54e8d6bb2d', 'Fable'), + resetsAt: limits.fableWeekly.resetsAt } : null, // Why: matches the status bar chip; monthly is the only limit when there is no 5h/7d window. @@ -56,10 +68,11 @@ export function InlineUsageBars({ ? { key: 'monthly', used: clampUsedPercent(limits.monthly.usedPercent), - label: formatRateLimitWindowChipLabel(limits.monthly, now) + label: formatWindowLabel(limits.monthly.windowMinutes), + resetsAt: limits.monthly.resetsAt } : null - ].filter((window): window is { key: string; used: number; label: string } => window !== null) + ].filter((window): window is InlineUsageWindow => window !== null) // Why: a lapsed token or failed refresh is not a sign-out; ask for a sign-in only when one is confirmed. const emptyState = usageWindows.length === 0 && limits.status === 'error' @@ -70,20 +83,39 @@ export function InlineUsageBars({
- {usageWindows.map((window) => ( -
-
- {/* Why: fill follows the selected percentage; color still signals consumption urgency. */} -
+ {usageWindows.map((window) => { + const resetsAt = + window.resetsAt != null && Number.isFinite(new Date(window.resetsAt).getTime()) + ? window.resetsAt + : null + return ( +
+
+
+ {/* Why: fill follows the selected percentage; color still signals consumption urgency. */} +
+
+ + {formatUsagePercentageLabel(window.used, display, t)} {window.label} + + {/* Why: fixed width keeps the reset countdowns in one column across account rows. */} + + {resetsAt != null ? formatResetDuration(resetsAt - now) : null} + +
+ {resetsAt != null ? ( + + {t('auto.components.status.bar.InlineUsageBars.resetsAt', 'Resets {{when}}', { + when: formatUsageLimitResetClock(resetsAt, now, intlLocale) + })} + + ) : null}
- - {formatUsagePercentageLabel(window.used, display, t)} {window.label} - -
- ))} + ) + })} {emptyState ? ( {emptyState.kind === 'sign-in' diff --git a/src/renderer/src/i18n/locales/de.json b/src/renderer/src/i18n/locales/de.json index 683bed935ae..2a3d0b79f33 100644 --- a/src/renderer/src/i18n/locales/de.json +++ b/src/renderer/src/i18n/locales/de.json @@ -5044,6 +5044,9 @@ "accounts": "Gespeicherte Antigravity-Konten", "readAgo": "Ausgelesen {{time}}", "notRead": "Nutzung unbekannt: noch nicht ausgelesen" + }, + "InlineUsageBars": { + "resetsAt": "Zurücksetzung um {{when}}" } } }, diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index e452d630054..d8d369e1a90 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -5308,6 +5308,9 @@ "accounts": "Saved Antigravity Accounts", "readAgo": "Read {{time}}", "notRead": "Usage unknown: not read yet" + }, + "InlineUsageBars": { + "resetsAt": "Resets {{when}}" } } }, diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index e046109f418..c0950ceaa51 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -4610,6 +4610,9 @@ "accounts": "Cuentas de Antigravity guardadas", "readAgo": "Consultado {{time}}", "notRead": "Uso desconocido: aún no consultado" + }, + "InlineUsageBars": { + "resetsAt": "Se restablece a las {{when}}" } } }, diff --git a/src/renderer/src/i18n/locales/fr.json b/src/renderer/src/i18n/locales/fr.json index 9a9db3f0f91..fa5195a5087 100644 --- a/src/renderer/src/i18n/locales/fr.json +++ b/src/renderer/src/i18n/locales/fr.json @@ -4835,6 +4835,9 @@ "accounts": "Comptes Antigravity enregistrés", "readAgo": "Relevé {{time}}", "notRead": "Utilisation inconnue : pas encore relevée" + }, + "InlineUsageBars": { + "resetsAt": "Réinitialisation à {{when}}" } } }, diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index abe1e728793..3af05458e5d 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -4474,6 +4474,9 @@ "accounts": "保存済み Antigravity アカウント", "readAgo": "{{time}} に取得", "notRead": "使用量は不明:未取得" + }, + "InlineUsageBars": { + "resetsAt": "{{when}} にリセット" } } }, diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index bcc999cac07..2dcfbfc1a5a 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -4474,6 +4474,9 @@ "accounts": "저장된 Antigravity 계정", "readAgo": "{{time}}에 조회", "notRead": "사용량을 알 수 없음: 아직 조회하지 않음" + }, + "InlineUsageBars": { + "resetsAt": "{{when}}에 초기화" } } }, diff --git a/src/renderer/src/i18n/locales/pt.json b/src/renderer/src/i18n/locales/pt.json index aa7059bee2d..97cefac24e7 100644 --- a/src/renderer/src/i18n/locales/pt.json +++ b/src/renderer/src/i18n/locales/pt.json @@ -3629,6 +3629,9 @@ "accounts": "Contas Antigravity salvas", "readAgo": "Lido {{time}}", "notRead": "Uso desconhecido: ainda não consultado" + }, + "InlineUsageBars": { + "resetsAt": "Redefinição em {{when}}" } } }, diff --git a/src/renderer/src/i18n/locales/ru.json b/src/renderer/src/i18n/locales/ru.json index 7fd908fc590..54b1d4756cb 100644 --- a/src/renderer/src/i18n/locales/ru.json +++ b/src/renderer/src/i18n/locales/ru.json @@ -5232,6 +5232,9 @@ "accounts": "Сохранённые аккаунты Antigravity", "readAgo": "Считано {{time}}", "notRead": "Использование неизвестно: данные ещё не считаны" + }, + "InlineUsageBars": { + "resetsAt": "Сброс: {{when}}" } } }, diff --git a/src/renderer/src/i18n/locales/tr.json b/src/renderer/src/i18n/locales/tr.json index 5982adda0d0..1df4a2246cc 100644 --- a/src/renderer/src/i18n/locales/tr.json +++ b/src/renderer/src/i18n/locales/tr.json @@ -5028,6 +5028,9 @@ "accounts": "Kayıtlı Antigravity Hesapları", "readAgo": "Okunma zamanı: {{time}}", "notRead": "Kullanım bilinmiyor: henüz okunmadı" + }, + "InlineUsageBars": { + "resetsAt": "Sıfırlanma zamanı: {{when}}" } } }, diff --git a/src/renderer/src/i18n/locales/zh-Hant.json b/src/renderer/src/i18n/locales/zh-Hant.json index af6bdc53c6c..ae427c3f4a6 100644 --- a/src/renderer/src/i18n/locales/zh-Hant.json +++ b/src/renderer/src/i18n/locales/zh-Hant.json @@ -4929,6 +4929,9 @@ "accounts": "已儲存的 Antigravity 帳戶", "readAgo": "讀取於 {{time}}", "notRead": "用量未知:尚未讀取" + }, + "InlineUsageBars": { + "resetsAt": "將於 {{when}} 重設" } } }, diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index fb4dd77cd12..44857d9cc28 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -4474,6 +4474,9 @@ "accounts": "已保存的 Antigravity 账户", "readAgo": "读取于 {{time}}", "notRead": "用量未知:尚未读取" + }, + "InlineUsageBars": { + "resetsAt": "将在 {{when}} 重置" } } },