mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix: clarify account usage reset display
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
DropdownMenuSeparator
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { useAppStore } from '../../store'
|
||||
import { normalizeUsagePercentageDisplay } from '../../../../shared/usage-percentage-display'
|
||||
|
||||
export function AccountSwitchList({
|
||||
heading,
|
||||
@@ -14,9 +16,28 @@ export function AccountSwitchList({
|
||||
heading: string
|
||||
children: React.ReactNode
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const display = normalizeUsagePercentageDisplay(
|
||||
useAppStore((state) => state.usagePercentageDisplay)
|
||||
)
|
||||
return (
|
||||
<div className="pb-1">
|
||||
<DropdownMenuLabel>{heading}</DropdownMenuLabel>
|
||||
<DropdownMenuLabel>
|
||||
<span className="flex items-center gap-2">
|
||||
<span className="min-w-0 flex-1 truncate">{heading}</span>
|
||||
<span className="flex w-1/2 max-w-48 shrink-0 items-center gap-1 text-right">
|
||||
<span className="min-w-0 flex-1" />
|
||||
<span className="w-8 shrink-0">
|
||||
{display === 'used'
|
||||
? t('auto.components.status.bar.AccountSwitchList.used', 'Used')
|
||||
: t('auto.components.status.bar.AccountSwitchList.left', 'Left')}
|
||||
</span>
|
||||
<span className="w-11 shrink-0">
|
||||
{t('auto.components.status.bar.AccountSwitchList.reset', 'Reset')}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</DropdownMenuLabel>
|
||||
<div className="max-h-[min(300px,40vh)] overflow-y-auto scrollbar-sleek">{children}</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -12,10 +12,9 @@ import { useResetCountdownClock } from '@/hooks/useResetCountdownClock'
|
||||
import { barColor, clampUsedPercent } from './tooltip'
|
||||
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 { formatBareUsagePercentage, formatUsagePercentageLabel } from './usage-percentage-label'
|
||||
import { getUsageRosterRowState } from './usage-roster-row-state'
|
||||
import { useIntlLocale, useTranslate } from '@/i18n/use-translate'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
|
||||
type InlineUsageWindow = { key: string; used: number; label: string; resetsAt: number | null }
|
||||
|
||||
@@ -27,7 +26,6 @@ export function InlineUsageBars({
|
||||
isFetching: boolean
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const intlLocale = useIntlLocale()
|
||||
const display = normalizeUsagePercentageDisplay(
|
||||
useAppStore((state) => state.usagePercentageDisplay)
|
||||
)
|
||||
@@ -89,30 +87,28 @@ export function InlineUsageBars({
|
||||
? window.resetsAt
|
||||
: null
|
||||
return (
|
||||
<div key={window.key} className="grid min-w-0 gap-0.5">
|
||||
<div className="flex min-w-0 items-center gap-1">
|
||||
<div className="h-1 min-w-0 flex-1 overflow-hidden rounded-full bg-muted">
|
||||
{/* Why: fill follows the selected percentage; color still signals consumption urgency. */}
|
||||
<div
|
||||
className={`h-full rounded-full ${barColor(window.used)}`}
|
||||
style={{ width: `${getDisplayedUsagePercentage(window.used, display)}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="min-w-[4.5rem] shrink-0 text-right text-3xs tabular-nums text-muted-foreground">
|
||||
{formatUsagePercentageLabel(window.used, display, t)} {window.label}
|
||||
</span>
|
||||
{/* Why: fixed width keeps the reset countdowns in one column across account rows. */}
|
||||
<span className="w-11 shrink-0 text-right text-3xs tabular-nums text-muted-foreground">
|
||||
{resetsAt != null ? formatResetDuration(resetsAt - now) : null}
|
||||
</span>
|
||||
<div
|
||||
key={window.key}
|
||||
className="flex min-w-0 items-center gap-1 text-3xs text-muted-foreground"
|
||||
aria-label={`${window.label}: ${formatUsagePercentageLabel(window.used, display, t)}${
|
||||
resetsAt != null
|
||||
? `, ${t('auto.components.status.bar.InlineUsageBars.resetsIn', 'resets in {{duration}}', { duration: formatResetDuration(resetsAt - now) })}`
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
<span className="w-8 shrink-0 truncate">{window.label}</span>
|
||||
<div className="h-1 min-w-0 flex-1 overflow-hidden rounded-full bg-muted">
|
||||
<div
|
||||
className={`h-full rounded-full ${barColor(window.used)}`}
|
||||
style={{ width: `${getDisplayedUsagePercentage(window.used, display)}%` }}
|
||||
/>
|
||||
</div>
|
||||
{resetsAt != null ? (
|
||||
<span className="text-right text-3xs tabular-nums text-muted-foreground">
|
||||
{t('auto.components.status.bar.InlineUsageBars.resetsAt', 'Resets {{when}}', {
|
||||
when: formatUsageLimitResetClock(resetsAt, now, intlLocale)
|
||||
})}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="w-8 shrink-0 text-right tabular-nums">
|
||||
{formatBareUsagePercentage(window.used, display, t)}
|
||||
</span>
|
||||
<span className="w-11 shrink-0 text-right tabular-nums">
|
||||
{resetsAt != null ? formatResetDuration(resetsAt - now) : null}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -5047,8 +5047,13 @@
|
||||
"readAgo": "Ausgelesen {{time}}",
|
||||
"notRead": "Nutzung unbekannt: noch nicht ausgelesen"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "Verbraucht",
|
||||
"left": "Übrig",
|
||||
"reset": "Zurücksetzung"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "Zurücksetzung um {{when}}"
|
||||
"resetsIn": "Zurücksetzung in {{duration}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -5433,8 +5433,13 @@
|
||||
"readAgo": "Read {{time}}",
|
||||
"notRead": "Usage unknown: not read yet"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "Used",
|
||||
"left": "Left",
|
||||
"reset": "Reset"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "Resets {{when}}"
|
||||
"resetsIn": "resets in {{duration}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4595,8 +4595,13 @@
|
||||
"readAgo": "Consultado {{time}}",
|
||||
"notRead": "Uso desconocido: aún no consultado"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "Usado",
|
||||
"left": "Restante",
|
||||
"reset": "Restablecimiento"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "Se restablece a las {{when}}"
|
||||
"resetsIn": "se restablece en {{duration}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4838,8 +4838,13 @@
|
||||
"readAgo": "Relevé {{time}}",
|
||||
"notRead": "Utilisation inconnue : pas encore relevée"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "Utilisé",
|
||||
"left": "Restant",
|
||||
"reset": "Réinitialisation"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "Réinitialisation à {{when}}"
|
||||
"resetsIn": "réinitialisation dans {{duration}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4459,8 +4459,13 @@
|
||||
"readAgo": "{{time}} に取得",
|
||||
"notRead": "使用量は不明:未取得"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "使用済み",
|
||||
"left": "残り",
|
||||
"reset": "リセット"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "{{when}} にリセット"
|
||||
"resetsIn": "{{duration}}後にリセット"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4459,8 +4459,13 @@
|
||||
"readAgo": "{{time}}에 조회",
|
||||
"notRead": "사용량을 알 수 없음: 아직 조회하지 않음"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "사용량",
|
||||
"left": "남음",
|
||||
"reset": "초기화"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "{{when}}에 초기화"
|
||||
"resetsIn": "{{duration}} 후 초기화"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3614,8 +3614,13 @@
|
||||
"readAgo": "Lido {{time}}",
|
||||
"notRead": "Uso desconhecido: ainda não consultado"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "Usado",
|
||||
"left": "Restante",
|
||||
"reset": "Redefinição"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "Redefinição em {{when}}"
|
||||
"resetsIn": "redefinição em {{duration}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -5235,8 +5235,13 @@
|
||||
"readAgo": "Считано {{time}}",
|
||||
"notRead": "Использование неизвестно: данные ещё не считаны"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "Использовано",
|
||||
"left": "Осталось",
|
||||
"reset": "Сброс"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "Сброс: {{when}}"
|
||||
"resetsIn": "сброс через {{duration}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -5031,8 +5031,13 @@
|
||||
"readAgo": "Okunma zamanı: {{time}}",
|
||||
"notRead": "Kullanım bilinmiyor: henüz okunmadı"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "Kullanılan",
|
||||
"left": "Kalan",
|
||||
"reset": "Sıfırlanma"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "Sıfırlanma zamanı: {{when}}"
|
||||
"resetsIn": "{{duration}} içinde sıfırlanır"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4932,8 +4932,13 @@
|
||||
"readAgo": "讀取於 {{time}}",
|
||||
"notRead": "用量未知:尚未讀取"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "已用",
|
||||
"left": "剩餘",
|
||||
"reset": "重設"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "將於 {{when}} 重設"
|
||||
"resetsIn": "{{duration}}後重設"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4459,8 +4459,13 @@
|
||||
"readAgo": "读取于 {{time}}",
|
||||
"notRead": "用量未知:尚未读取"
|
||||
},
|
||||
"AccountSwitchList": {
|
||||
"used": "已用",
|
||||
"left": "剩余",
|
||||
"reset": "重置"
|
||||
},
|
||||
"InlineUsageBars": {
|
||||
"resetsAt": "将在 {{when}} 重置"
|
||||
"resetsIn": "{{duration}}后重置"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user