diff --git a/client/src/components/Chat/Input/TokenUsageIndicator.tsx b/client/src/components/Chat/Input/TokenUsageIndicator.tsx index f4a847ef06..1e8658bfdd 100644 --- a/client/src/components/Chat/Input/TokenUsageIndicator.tsx +++ b/client/src/components/Chat/Input/TokenUsageIndicator.tsx @@ -17,15 +17,23 @@ interface ProgressBarProps { value: number; max: number; colorClass: string; + label: string; showPercentage?: boolean; } -function ProgressBar({ value, max, colorClass, showPercentage = false }: ProgressBarProps) { +function ProgressBar({ value, max, colorClass, label, showPercentage = false }: ProgressBarProps) { const percentage = max > 0 ? Math.min((value / max) * 100, 100) : 0; return (
-
+
{showPercentage && ( - + )} @@ -48,9 +56,10 @@ interface TokenRowProps { value: number; total: number; colorClass: string; + ariaLabel: string; } -function TokenRow({ label, value, total, colorClass }: TokenRowProps) { +function TokenRow({ label, value, total, colorClass, ariaLabel }: TokenRowProps) { const percentage = total > 0 ? Math.round((value / total) * 100) : 0; return ( @@ -59,10 +68,12 @@ function TokenRow({ label, value, total, colorClass }: TokenRowProps) { {label} {formatTokens(value)} - ({percentage}%) +
- +
); } @@ -88,11 +99,18 @@ function TokenUsageContent() { return 'bg-green-500'; }; + const inputPercentage = totalUsed > 0 ? Math.round((inputTokens / totalUsed) * 100) : 0; + const outputPercentage = totalUsed > 0 ? Math.round((outputTokens / totalUsed) * 100) : 0; + return ( -
+
{/* Header */}
- + {localize('com_ui_token_usage_context')} {hasMaxContext && ( @@ -111,8 +129,13 @@ function TokenUsageContent() { {/* Main Progress Bar */} {hasMaxContext && (
- -
+ + @@ -120,7 +143,7 @@ function TokenUsageContent() { )} {/* Divider */} -
+
{/* Input/Output Breakdown */}
@@ -129,30 +152,16 @@ function TokenUsageContent() { value={inputTokens} total={totalUsed} colorClass="bg-blue-500" + ariaLabel={`${localize('com_ui_token_usage_input')}: ${formatTokens(inputTokens)}, ${inputPercentage}% of total`} />
- - {/* Total Section */} -
-
- {localize('com_ui_token_usage_total')} - {formatTokens(totalUsed)} -
-
- - {/* Max Context (when available) */} - {hasMaxContext && ( -
- {localize('com_ui_token_usage_max_context')} - {formatTokens(maxContext)} -
- )}
); } @@ -203,8 +212,9 @@ const TokenUsageIndicator = memo(function TokenUsageIndicator() {