* feat: add i18n foundation * feat: localize sessions sidebar * Localize multirun/scheduled tasks and fix dialog dropdown interactions * localize git sidebar surface and add zh-CN keys * feat(ui): localize context panel, diff/plan views, and context sidebar content * fix(config): resolve user config home via fs/home before embedded home * localize header/chat UI and complete model/worktree panel strings * localize worktree + github issue/pr dialog flows * localize settings sections and split settings i18n dictionaries * localize additional settings sections and sidebars * localize more settings pages and dialogs * fix settings select trigger localization * localize tunnel settings ui surface * localize additional settings sections * localize keyboard shortcuts labels in settings * localize terminal and utility dialogs surfaces * feat(i18n): localize remaining UI strings * Add Ukrainian locale * Add Spanish locale * Add Brazilian Portuguese locale * Polish locale translations
100 lines
3.3 KiB
TypeScript
100 lines
3.3 KiB
TypeScript
import React from 'react';
|
|
import { cn } from '@/lib/utils';
|
|
import type { PaceInfo } from '@/lib/quota';
|
|
import { getPaceStatusColor, formatRemainingTime } from '@/lib/quota';
|
|
import { useI18n } from '@/lib/i18n';
|
|
|
|
interface PaceIndicatorProps {
|
|
paceInfo: PaceInfo;
|
|
className?: string;
|
|
/** Compact mode shows just the status dot and prediction */
|
|
compact?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Visual indicator showing whether usage is on track, slightly fast, or too fast.
|
|
* Inspired by opencode-bar's pace visualization.
|
|
*/
|
|
export const PaceIndicator: React.FC<PaceIndicatorProps> = ({
|
|
paceInfo,
|
|
className,
|
|
compact = false,
|
|
}) => {
|
|
const { t } = useI18n();
|
|
const statusColor = getPaceStatusColor(paceInfo.status);
|
|
|
|
const statusLabel = React.useMemo(() => {
|
|
switch (paceInfo.status) {
|
|
case 'on-track':
|
|
return t('settings.usage.pace.status.onTrack');
|
|
case 'slightly-fast':
|
|
return t('settings.usage.pace.status.slightlyFast');
|
|
case 'too-fast':
|
|
return t('settings.usage.pace.status.tooFast');
|
|
case 'exhausted':
|
|
return t('settings.usage.pace.status.usedUp');
|
|
}
|
|
}, [paceInfo.status, t]);
|
|
|
|
const predictionTooltip = t('settings.usage.pace.predictionTooltip', { prediction: paceInfo.predictText });
|
|
|
|
if (compact) {
|
|
return (
|
|
<div className={cn('flex items-center gap-1.5', className)}>
|
|
<div
|
|
className="h-2 w-2 rounded-full flex-shrink-0"
|
|
style={{ backgroundColor: statusColor }}
|
|
title={statusLabel}
|
|
/>
|
|
<span
|
|
className="typography-micro tabular-nums"
|
|
style={{ color: statusColor }}
|
|
title={paceInfo.isExhausted ? undefined : predictionTooltip}
|
|
>
|
|
{paceInfo.isExhausted ? (
|
|
<>{t('settings.usage.pace.wait', { duration: formatRemainingTime(paceInfo.remainingSeconds) })}</>
|
|
) : (
|
|
<>{t('settings.usage.pace.prediction', { prediction: paceInfo.predictText })}</>
|
|
)}
|
|
</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className={cn('flex items-center justify-between gap-2', className)}>
|
|
<div className="flex items-center gap-1.5">
|
|
{!paceInfo.isExhausted && (
|
|
<span className="typography-micro text-muted-foreground">
|
|
{t('settings.usage.pace.rate', { rate: paceInfo.paceRateText })}
|
|
</span>
|
|
)}
|
|
</div>
|
|
<div className="flex items-center gap-1.5">
|
|
<span
|
|
className="typography-micro tabular-nums"
|
|
style={{ color: statusColor }}
|
|
>
|
|
{paceInfo.isExhausted ? (
|
|
<>
|
|
<span className="font-medium">{statusLabel}</span>
|
|
<span className="text-muted-foreground">{t('settings.usage.pace.waitSeparator')}</span>
|
|
<span className="font-medium">{formatRemainingTime(paceInfo.remainingSeconds)}</span>
|
|
</>
|
|
) : (
|
|
<span title={predictionTooltip}>
|
|
<span className="text-muted-foreground">{t('settings.usage.pace.predictionLabel')}</span>
|
|
<span className="font-medium">{paceInfo.predictText}</span>
|
|
</span>
|
|
)}
|
|
</span>
|
|
<div
|
|
className="h-2 w-2 rounded-full flex-shrink-0"
|
|
style={{ backgroundColor: statusColor }}
|
|
title={statusLabel}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|