Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/account-card-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### English

- Tidy the account card: the state shows once in the header chip, the runtime strip dims while the account is healthy, quota reads as remaining with used / total and percent, check-in fits on one line, and the action bar stays on one row with models, cooldowns, check-in, records, export, and delete under More.

### 中文

- 整理账号卡片:状态只在头部 Chip 显示一次,账号正常时运行状态条降低对比度,额度改为显示剩余量并附已用 / 总量和百分比,签到合并为一行,操作栏固定一行,模型、冷却、立即签到、签到记录、导出、删除收进「更多」。
95 changes: 53 additions & 42 deletions frontend/src/components/account/AccountCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export function AccountCard({
const chipRef = useRef<HTMLSpanElement>(null)
const authRef = useRef<HTMLElement>(null)
const [authCopied, setAuthCopied] = useState(false)
const [idCopied, setIdCopied] = useState(false)
const [cooldownsOpen, setCooldownsOpen] = useState(false)
const lastStateRef = useRef<string | null>(null)
const [, refreshCooldowns] = useState(0)
Expand Down Expand Up @@ -166,6 +167,12 @@ export function AccountCard({
const lastError = account.last_error || account.lastError
const errorKind = account.last_error_kind || account.kind
const provider = accountProviderLabel(account.provider, account.region, t)
// The provider mark already names the family, so the header tag only carries
// the region. The full provider label stays in the mark and tag tooltips.
const region = String(account.region || '').toLowerCase()
const regionLabel = region === 'cn' ? t('regionCN') : region === 'global' ? t('regionGlobal') : ''
const identity = account.remote_uid || account.id
const shortIdentity = identity.length > 12 ? identity.slice(0, 8) : identity
const checkinStatus = account.last_checkin_status
const checkinLabel = checkinStatus === 'success' ? 'checkinRecordSuccess' : checkinStatus === 'already' ? 'checkinRecordAlready' : checkinStatus === 'skipped' ? 'checkinRecordSkipped' : checkinStatus === 'error' ? 'checkinRecordFailed' : 'lastCheckinNone'
const checkedInCurrentDay = checkedInToday(account, checkinTimezone)
Expand Down Expand Up @@ -227,17 +234,35 @@ export function AccountCard({
>
<Card.Header className="flex-row items-start justify-between gap-2.5 px-4 pt-3.5 pb-2">
<div className="flex min-w-0 items-center gap-2.5">
<div className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary">
<div className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary" title={provider}>
<ProviderMark provider={account.provider} size={20} />
</div>
<div className="min-w-0">
<div className="flex min-w-0 items-center gap-2">
<Card.Title className="truncate text-body leading-5">{account.name || account.id}</Card.Title>
<span className="shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted">{provider}</span>
{regionLabel ? <span className="shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted" title={provider}>{regionLabel}</span> : null}
</div>
<div className="flex min-w-0 items-center gap-1">
<Card.Description className="mono truncate text-caption leading-4 text-foreground/60" title={`${account.id}${account.remote_uid ? ` · UID ${account.remote_uid}` : ''}`}>
{shortIdentity}
</Card.Description>
<Button
isIconOnly
size="sm"
variant="ghost"
className="size-5 min-w-0 shrink-0 text-muted"
aria-label={idCopied ? t('copied') : t('copy')}
onPress={() => {
void copyText(identity).then((ok) => {
if (!ok) return
setIdCopied(true)
window.setTimeout(() => setIdCopied(false), 1100)
})
}}
>
<CopyIcon copied={idCopied} size={12} />
</Button>
</div>
<Card.Description className="mono truncate text-caption leading-4 text-foreground/60" title={`${account.id}${account.remote_uid ? ` · UID ${account.remote_uid}` : ''}`}>
{account.remote_uid ? `UID ${account.remote_uid}` : account.id}
</Card.Description>
</div>
</div>
<div className="flex max-w-[48%] shrink-0 flex-wrap justify-end gap-1.5">
Expand Down Expand Up @@ -467,11 +492,11 @@ export function AccountCard({
) : null}

{onCheckin ? (
<div className="flex items-start justify-between gap-2 border-t border-separator px-4 py-2 text-caption text-muted">
<div className="mt-auto flex items-center justify-between gap-2 px-4 pb-2.5 text-caption text-muted">
<Tooltip>
<Tooltip.Trigger>
<span className="flex cursor-help flex-wrap items-center gap-2">
<span className="font-medium">{t('lastCheckin')}</span>
<span className="flex min-w-0 cursor-help flex-wrap items-center gap-1.5">
<span className="font-medium text-foreground/75">{t('checkinStatus')}</span>
<span className={checkinStatus === 'error' ? 'text-danger' : ''}>{t(checkinLabel)}</span>
{!checkedInCurrentDay ? (
<span className="whitespace-nowrap rounded-full bg-warning/15 px-1.5 py-px font-medium text-warning">
Expand All @@ -485,7 +510,7 @@ export function AccountCard({
<Tooltip>
<Tooltip.Trigger>
<span className="flex shrink-0 cursor-help items-center gap-1.5 whitespace-nowrap">
<span className="font-medium">{t('autoCheckin')}</span>
<span>{t('checkinDaily')}</span>
<span className="mono text-caption text-foreground/55">{account.checkin_time || checkinDefaultTime}</span>
<CompactSwitch isSelected={Boolean(account.auto_checkin)} isDisabled={Boolean(busyKind)} ariaLabel={t('autoCheckin')} onChange={(selected) => onToggleAutoCheckin?.(selected)} />
</span>
Expand All @@ -495,11 +520,11 @@ export function AccountCard({
</div>
) : null}

<Card.Footer className="flex flex-wrap items-center gap-1 bg-surface-secondary px-2 py-2">
<Card.Footer className={`flex flex-nowrap items-center gap-1 bg-surface-secondary px-2 py-2${onCheckin ? '' : ' mt-auto'}`}>
{onRefresh ? (
<Tooltip>
<Tooltip.Trigger>
<Button isIconOnly size="sm" variant="secondary" isPending={busyKind === 'refresh'} onPress={onRefresh} aria-label={t('refreshAccount')}>
<Button isIconOnly size="sm" variant="ghost" isPending={busyKind === 'refresh'} onPress={onRefresh} aria-label={t('refreshAccount')}>
<ArrowClockwise size={15} />
</Button>
</Tooltip.Trigger>
Expand All @@ -514,14 +539,6 @@ export function AccountCard({
</Tooltip.Trigger>
<Tooltip.Content>{t('authentication')}</Tooltip.Content>
</Tooltip>
<Tooltip>
<Tooltip.Trigger>
<Button isIconOnly size="sm" variant="ghost" onPress={onViewModels} aria-label={t('accountModels')}>
<Cube size={15} />
</Button>
</Tooltip.Trigger>
<Tooltip.Content>{t('accountModels')}</Tooltip.Content>
</Tooltip>
<Tooltip>
<Tooltip.Trigger>
<Button isIconOnly size="sm" variant="ghost" onPress={onEdit} aria-label={t('editAccount')}>
Expand All @@ -530,46 +547,40 @@ export function AccountCard({
</Tooltip.Trigger>
<Tooltip.Content>{t('editAccount')}</Tooltip.Content>
</Tooltip>
{onCheckin ? (
<Tooltip>
<Tooltip.Trigger>
<Button isIconOnly size="sm" variant="ghost" isDisabled={!account.enabled || Boolean(busyKind)} isPending={busyKind === 'checkin'} onPress={onCheckin} aria-label={t('checkinNow')}>
<CalendarCheck size={15} />
</Button>
</Tooltip.Trigger>
<Tooltip.Content>{t('checkinNow')}</Tooltip.Content>
</Tooltip>
) : null}
<Tooltip>
<Tooltip.Trigger>
<Button isIconOnly size="sm" variant={cooldownsOpen ? 'secondary' : 'ghost'} onPress={() => setCooldownsOpen((open) => !open)} aria-label={t('modelCooldowns')}>
<Timer size={15} className={modelCooldowns.length ? 'text-warning' : undefined} />
</Button>
</Tooltip.Trigger>
<Tooltip.Content>{t('modelCooldowns')}{modelCooldowns.length ? ` · ${modelCooldowns.length}` : ''}</Tooltip.Content>
</Tooltip>
<Dropdown>
<Dropdown.Trigger>
<Button isIconOnly size="sm" variant="secondary" aria-label={t('more')}>
<Button isIconOnly size="sm" variant={cooldownsOpen ? 'secondary' : 'ghost'} isPending={busyKind === 'checkin'} aria-label={t('more')} className="relative">
<DotsThreeVertical size={16} />
{modelCooldowns.length ? <span className="absolute top-1 right-1 size-1.5 rounded-full bg-warning" aria-hidden /> : null}
</Button>
</Dropdown.Trigger>
<Dropdown.Popover placement="bottom end">
<Dropdown.Popover placement="bottom start">
<Dropdown.Menu
aria-label={t('more')}
disabledKeys={!account.enabled || Boolean(busyKind) ? ['checkin'] : []}
onAction={(key) => {
if (key === 'export') onExport()
if (key === 'models') onViewModels()
if (key === 'cooldowns') setCooldownsOpen((open) => !open)
if (key === 'checkin') onCheckin?.()
if (key === 'checkin-records') onViewCheckins?.()
if (key === 'export') onExport()
if (key === 'delete') onDelete()
}}
>
{account.auth_type !== 'none' ? <Dropdown.Item id="export" textValue={t('export')}><Copy size={15} />{t('export')}</Dropdown.Item> : null}
<Dropdown.Item id="models" textValue={t('accountModels')}><Cube size={15} />{t('accountModels')}</Dropdown.Item>
<Dropdown.Item id="cooldowns" textValue={t('modelCooldowns')}>
<Timer size={15} className={modelCooldowns.length ? 'text-warning' : undefined} />
{t('modelCooldowns')}
{modelCooldowns.length ? <span className="mono ml-auto text-caption text-warning">{modelCooldowns.length}</span> : null}
</Dropdown.Item>
{onCheckin ? <Dropdown.Item id="checkin" textValue={t('checkinNow')}><CalendarCheck size={15} />{t('checkinNow')}</Dropdown.Item> : null}
{onViewCheckins ? <Dropdown.Item id="checkin-records" textValue={t('checkinRecords')}><ListBullets size={15} />{t('checkinRecords')}</Dropdown.Item> : null}
{account.auth_type !== 'none' ? <Dropdown.Item id="export" textValue={t('export')}><Copy size={15} />{t('export')}</Dropdown.Item> : null}
<Dropdown.Item id="delete" textValue={t('delete')} className="text-danger"><TrashSimple size={15} />{t('delete')}</Dropdown.Item>
</Dropdown.Menu>
</Dropdown.Popover>
</Dropdown>
<div className="ml-auto flex shrink-0 flex-nowrap items-center gap-3 whitespace-nowrap">
<div className="ml-auto flex shrink-0 flex-nowrap items-center whitespace-nowrap">
<CompactSwitch
isSelected={Boolean(account.enabled)}
isDisabled={busyKind === 'toggle'}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/account/QuotaMeter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ export function QuotaMeter({ quota, t, label, usedLabel, remainingLabel, addOnLa
>
<Meter.Output className="flex w-full items-baseline justify-between text-caption">
<span className="text-body font-semibold leading-5 text-foreground tabular-nums">
{quota.exceeded ? <span className="mr-1.5 text-danger">{exceededLabel}</span> : null}
{quota.exceeded ? <span className="mr-1.5 text-danger">{exceededLabel}</span> : <span className="mr-1.5 text-caption font-normal text-muted">{remainingLabel}</span>}
{remaining}
<span className="ml-1 text-caption font-normal text-foreground/60">{unit}</span>
</span>
<span className="mono text-foreground/55">{usedLabel} {used}</span>
<span className="mono text-foreground/55">{used} · {Math.round(ratio * 100)}%</span>
</Meter.Output>
<Meter.Track>
<Meter.Fill />
Expand Down
11 changes: 5 additions & 6 deletions frontend/src/components/account/RuntimeMeter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export function RuntimeMeter({ state, stateCopy, t }: Props) {
return () => context.revert()
}, [count, state])

// The state Chip in the card header already names the state, so the strip
// carries no label of its own. A healthy account renders it at low contrast;
// warning and danger tones stay at full colour so problems stand out.
return (
<div ref={rootRef} className="flex items-center gap-2">
<div className="flex items-center gap-1.5 text-caption font-medium text-foreground/75">
<span className="status-dot" data-state={tone === 'muted' ? undefined : tone === 'warn' ? 'warn' : tone} />
<span>{t('runtimeState')}</span>
</div>
<div ref={rootRef} className="flex items-center">
<div
className="runtime-meter min-w-[80px] flex-1"
data-quiet={tone === 'ok' ? 'true' : undefined}
role="meter"
aria-label={t('runtimeState')}
aria-valuemin={0}
Expand All @@ -73,7 +73,6 @@ export function RuntimeMeter({ state, stateCopy, t }: Props) {
/>
))}
</div>
<span className="mono shrink-0 text-caption text-foreground/65">{stateCopy}</span>
</div>
)
}
6 changes: 6 additions & 0 deletions frontend/src/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ export const messages: Record<Lang, Dict> = {
lastCheckin: 'Last check-in',
lastCheckinNone: 'No check-in yet',
checkinStatus: 'Check-in',
checkinDaily: 'Daily',
regionCN: 'CN',
regionGlobal: 'Global',
checkinToday: 'Checked in today',
checkinPending: 'Not checked in today',
checkinFailed: 'Check-in failed',
Expand Down Expand Up @@ -1733,6 +1736,9 @@ export const messages: Record<Lang, Dict> = {
lastCheckin: '最近签到',
lastCheckinNone: '还没有签到记录',
checkinStatus: '签到',
checkinDaily: '每日',
regionCN: '国内版',
regionGlobal: '国际版',
checkinToday: '今日已签到',
checkinPending: '今日未签到',
checkinFailed: '签到异常',
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ body {
background: var(--muted);
}

/* Healthy accounts: the strip steps back so the quota bar leads. */
.runtime-meter[data-quiet="true"] .runtime-meter__seg[data-tone="ok"] {
background: color-mix(in oklch, var(--success) 38%, var(--separator));
}

.release-notes-panel {
border-radius: var(--radius-xl);
background: var(--surface-secondary);
Expand Down
Loading
Loading