From 7a72d255d8effec1396170306cc6be57f598a6d8 Mon Sep 17 00:00:00 2001
From: Abhi <43648792+abhipatel12@users.noreply.github.com>
Date: Wed, 11 Jun 2025 16:40:31 -0400
Subject: feat: Add exit UI w/ stats (#924)
---
packages/cli/src/ui/components/StatsDisplay.tsx | 91 ++-----------------------
1 file changed, 7 insertions(+), 84 deletions(-)
(limited to 'packages/cli/src/ui/components/StatsDisplay.tsx')
diff --git a/packages/cli/src/ui/components/StatsDisplay.tsx b/packages/cli/src/ui/components/StatsDisplay.tsx
index be447595..76d48821 100644
--- a/packages/cli/src/ui/components/StatsDisplay.tsx
+++ b/packages/cli/src/ui/components/StatsDisplay.tsx
@@ -9,6 +9,7 @@ import { Box, Text } from 'ink';
import { Colors } from '../colors.js';
import { formatDuration } from '../utils/formatters.js';
import { CumulativeStats } from '../contexts/SessionContext.js';
+import { FormattedStats, StatRow, StatsColumn } from './Stats.js';
// --- Constants ---
@@ -22,89 +23,6 @@ interface StatsDisplayProps {
duration: string;
}
-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.
- */
-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.
- */
-const StatsColumn: React.FC<{
- title: string;
- stats: FormattedStats;
- isCumulative?: boolean;
-}> = ({ title, stats, isCumulative = false }) => {
- 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}
-
-
-
-
-
-
- {/* Divider Line */}
-
-
-
-
- );
-};
-
// --- Main Component ---
export const StatsDisplay: React.FC = ({
@@ -143,11 +61,16 @@ export const StatsDisplay: React.FC = ({
-
+
--
cgit v1.2.3