diff --git a/packages/cli/src/ui/components/QuotaDisplay.tsx b/packages/cli/src/ui/components/QuotaDisplay.tsx index d20291580a..a88111f37b 100644 --- a/packages/cli/src/ui/components/QuotaDisplay.tsx +++ b/packages/cli/src/ui/components/QuotaDisplay.tsx @@ -42,7 +42,16 @@ export const QuotaDisplay: React.FC = ({ }); const resetInfo = - !terse && resetTime ? `, ${formatResetTime(resetTime)}` : ''; + !terse && resetTime + ? (function (t) { + const formatted = formatResetTime(t); + const info = + formatted === 'Resetting...' || formatted === '< 1m' + ? formatted + : `resets in ${formatted}`; + return `, ${info}`; + })(resetTime) + : ''; if (remaining === 0) { return ( diff --git a/packages/cli/src/ui/components/QuotaStatsInfo.tsx b/packages/cli/src/ui/components/QuotaStatsInfo.tsx index b9611d309b..9d9a890a65 100644 --- a/packages/cli/src/ui/components/QuotaStatsInfo.tsx +++ b/packages/cli/src/ui/components/QuotaStatsInfo.tsx @@ -69,7 +69,13 @@ export const QuotaStatsInfo: React.FC = ({ : ''} )} - {resetTime && `, ${formatResetTime(resetTime)}`} + {resetTime && + `, ${(function (t) { + const formatted = formatResetTime(t); + return formatted === 'Resetting...' || formatted === '< 1m' + ? formatted + : `resets in ${formatted}`; + })(resetTime)}`} )} {showDetails && ( diff --git a/packages/cli/src/ui/components/StatsDisplay.tsx b/packages/cli/src/ui/components/StatsDisplay.tsx index c90cff6cc6..3a50f5b3ad 100644 --- a/packages/cli/src/ui/components/StatsDisplay.tsx +++ b/packages/cli/src/ui/components/StatsDisplay.tsx @@ -365,10 +365,13 @@ const ModelUsageTable: React.FC<{ {' '} ( - {formatResetTime(row.bucket.resetTime).replace( - 'resets in', - 'Resets in', - )} + {(function (t) { + const formatted = formatResetTime(t); + return formatted === 'Resetting...' || + formatted === '< 1m' + ? formatted + : `Resets in ${formatted}`; + })(row.bucket.resetTime)} ) )} diff --git a/packages/cli/src/ui/utils/formatters.ts b/packages/cli/src/ui/utils/formatters.ts index d85549e68f..1cdd30a37f 100644 --- a/packages/cli/src/ui/utils/formatters.ts +++ b/packages/cli/src/ui/utils/formatters.ts @@ -115,7 +115,7 @@ export const formatResetTime = (resetTime: string): string => { } const diff = date.getTime() - Date.now(); - if (diff <= 0) return '(Resetting...)'; + if (diff <= 0) return 'Resetting...'; const totalMinutes = Math.ceil(diff / (1000 * 60)); const hours = Math.floor(totalMinutes / 60); @@ -128,16 +128,13 @@ export const formatResetTime = (resetTime: string): string => { unitDisplay: 'narrow', }).format(val); - let timeStr = ''; if (hours > 0 && minutes > 0) { - timeStr = `${fmt(hours, 'hour')} ${fmt(minutes, 'minute')}`; + return `${fmt(hours, 'hour')} ${fmt(minutes, 'minute')}`; } else if (hours > 0) { - timeStr = fmt(hours, 'hour'); + return fmt(hours, 'hour'); } else if (minutes > 0) { - timeStr = fmt(minutes, 'minute'); + return fmt(minutes, 'minute'); } else { - timeStr = '< 1m'; + return '< 1m'; } - - return `resets in ${timeStr}`; };