/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import React from 'react'; import { Box, Text } from 'ink'; import { Colors } from '../colors.js'; // --- Prop and Data Structures --- export interface FormattedStats { inputTokens: number; outputTokens: number; toolUseTokens: number; thoughtsTokens: number; cachedTokens: number; totalTokens: number; } // --- Helper Components --- /** * Renders a single row with a colored label on the left and a value on the right. */ export const StatRow: React.FC<{ label: string; value: string | number; valueColor?: string; }> = ({ label, value, valueColor }) => ( {label} {value} ); /** * Renders a full column for either "Last Turn" or "Cumulative" stats. */ export const StatsColumn: React.FC<{ title: string; stats: FormattedStats; isCumulative?: boolean; width?: string | number; children?: React.ReactNode; }> = ({ title, stats, isCumulative = false, width, children }) => { const cachedDisplay = isCumulative && stats.totalTokens > 0 ? `${stats.cachedTokens.toLocaleString()} (${((stats.cachedTokens / stats.totalTokens) * 100).toFixed(1)}%)` : stats.cachedTokens.toLocaleString(); const cachedColor = isCumulative && stats.cachedTokens > 0 ? Colors.AccentGreen : undefined; return ( {title} {/* All StatRows below will now inherit the gap */} {stats.toolUseTokens > 0 && ( )} {/* Divider Line */} {children} ); }; /** * Renders a column for displaying duration information. */ export const DurationColumn: React.FC<{ apiTime: string; wallTime: string; }> = ({ apiTime, wallTime }) => ( Duration );