Skip to content

Commit 2ffef3c

Browse files
authored
feat(cli): polish cached token stats and simplify stats display when quota is present. (#14961)
1 parent 08be314 commit 2ffef3c

7 files changed

Lines changed: 201 additions & 131 deletions

File tree

packages/cli/src/ui/components/ModelStatsDisplay.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('<ModelStatsDisplay />', () => {
116116
});
117117

118118
const output = lastFrame();
119-
expect(output).not.toContain('Cached');
119+
expect(output).not.toContain('Cache Reads');
120120
expect(output).not.toContain('Thoughts');
121121
expect(output).not.toContain('Tool');
122122
expect(output).toMatchSnapshot();
@@ -168,7 +168,7 @@ describe('<ModelStatsDisplay />', () => {
168168
});
169169

170170
const output = lastFrame();
171-
expect(output).toContain('Cached');
171+
expect(output).toContain('Cache Reads');
172172
expect(output).toContain('Thoughts');
173173
expect(output).toContain('Tool');
174174
expect(output).toMatchSnapshot();

packages/cli/src/ui/components/ModelStatsDisplay.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,24 +160,28 @@ export const ModelStatsDisplay: React.FC = () => {
160160
<StatRow
161161
title="Total"
162162
values={getModelValues((m) => (
163-
<Text color={theme.status.warning}>
163+
<Text color={theme.text.secondary}>
164164
{m.tokens.total.toLocaleString()}
165165
</Text>
166166
))}
167167
/>
168168
<StatRow
169-
title="Prompt"
169+
title="Input"
170170
isSubtle
171-
values={getModelValues((m) => m.tokens.prompt.toLocaleString())}
171+
values={getModelValues((m) => (
172+
<Text color={theme.text.primary}>
173+
{Math.max(0, m.tokens.prompt - m.tokens.cached).toLocaleString()}
174+
</Text>
175+
))}
172176
/>
173177
{hasCached && (
174178
<StatRow
175-
title="Cached"
179+
title="Cache Reads"
176180
isSubtle
177181
values={getModelValues((m) => {
178182
const cacheHitRate = calculateCacheHitRate(m);
179183
return (
180-
<Text color={theme.status.success}>
184+
<Text color={theme.text.secondary}>
181185
{m.tokens.cached.toLocaleString()} ({cacheHitRate.toFixed(1)}%)
182186
</Text>
183187
);
@@ -188,20 +192,32 @@ export const ModelStatsDisplay: React.FC = () => {
188192
<StatRow
189193
title="Thoughts"
190194
isSubtle
191-
values={getModelValues((m) => m.tokens.thoughts.toLocaleString())}
195+
values={getModelValues((m) => (
196+
<Text color={theme.text.primary}>
197+
{m.tokens.thoughts.toLocaleString()}
198+
</Text>
199+
))}
192200
/>
193201
)}
194202
{hasTool && (
195203
<StatRow
196204
title="Tool"
197205
isSubtle
198-
values={getModelValues((m) => m.tokens.tool.toLocaleString())}
206+
values={getModelValues((m) => (
207+
<Text color={theme.text.primary}>
208+
{m.tokens.tool.toLocaleString()}
209+
</Text>
210+
))}
199211
/>
200212
)}
201213
<StatRow
202214
title="Output"
203215
isSubtle
204-
values={getModelValues((m) => m.tokens.candidates.toLocaleString())}
216+
values={getModelValues((m) => (
217+
<Text color={theme.text.primary}>
218+
{m.tokens.candidates.toLocaleString()}
219+
</Text>
220+
))}
205221
/>
206222
</Box>
207223
);

packages/cli/src/ui/components/StatsDisplay.test.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ describe('<StatsDisplay />', () => {
7676

7777
expect(output).toContain('Performance');
7878
expect(output).toContain('Interaction Summary');
79-
expect(output).not.toContain('Efficiency & Optimizations');
8079
expect(output).toMatchSnapshot();
8180
});
8281

@@ -113,8 +112,8 @@ describe('<StatsDisplay />', () => {
113112

114113
expect(output).toContain('gemini-2.5-pro');
115114
expect(output).toContain('gemini-2.5-flash');
116-
expect(output).toContain('1,000');
117-
expect(output).toContain('25,000');
115+
expect(output).toContain('15,000');
116+
expect(output).toContain('10,000');
118117
expect(output).toMatchSnapshot();
119118
});
120119

@@ -167,7 +166,6 @@ describe('<StatsDisplay />', () => {
167166
expect(output).toContain('Performance');
168167
expect(output).toContain('Interaction Summary');
169168
expect(output).toContain('User Agreement');
170-
expect(output).toContain('Savings Highlight');
171169
expect(output).toContain('gemini-2.5-pro');
172170
expect(output).toMatchSnapshot();
173171
});
@@ -232,7 +230,6 @@ describe('<StatsDisplay />', () => {
232230
const { lastFrame } = renderWithMockedStats(metrics);
233231
const output = lastFrame();
234232

235-
expect(output).not.toContain('Efficiency & Optimizations');
236233
expect(output).toMatchSnapshot();
237234
});
238235
});
@@ -442,7 +439,7 @@ describe('<StatsDisplay />', () => {
442439
);
443440
const output = lastFrame();
444441

445-
expect(output).toContain('Usage limit remaining');
442+
expect(output).toContain('Usage left');
446443
expect(output).toContain('75.0%');
447444
expect(output).toContain('(Resets in 1h 30m)');
448445
expect(output).toMatchSnapshot();

0 commit comments

Comments
 (0)