@google/gemini-cli 0.1.7 → 0.1.8-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/google-gemini-cli-0.1.8-rc.0.tgz +0 -0
- package/dist/package.json +14 -10
- package/dist/src/config/config.js +1 -1
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/settings.d.ts +1 -0
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/nonInteractiveCli.js +4 -1
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/ui/App.js +2 -23
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/App.test.js +19 -0
- package/dist/src/ui/App.test.js.map +1 -1
- package/dist/src/ui/components/Footer.d.ts +0 -2
- package/dist/src/ui/components/Footer.js +2 -2
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Help.js +3 -1
- package/dist/src/ui/components/Help.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.js +3 -1
- package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
- package/dist/src/ui/components/HistoryItemDisplay.test.js +19 -25
- package/dist/src/ui/components/HistoryItemDisplay.test.js.map +1 -1
- package/dist/src/ui/components/ModelStatsDisplay.d.ts +7 -0
- package/dist/src/ui/components/ModelStatsDisplay.js +33 -0
- package/dist/src/ui/components/ModelStatsDisplay.js.map +1 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js +217 -0
- package/dist/src/ui/components/ModelStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/SessionSummaryDisplay.d.ts +0 -2
- package/dist/src/ui/components/SessionSummaryDisplay.js +14 -8
- package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/SessionSummaryDisplay.test.js +71 -25
- package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +1 -1
- package/dist/src/ui/components/StatsDisplay.d.ts +0 -3
- package/dist/src/ui/components/StatsDisplay.js +27 -20
- package/dist/src/ui/components/StatsDisplay.js.map +1 -1
- package/dist/src/ui/components/StatsDisplay.test.js +227 -37
- package/dist/src/ui/components/StatsDisplay.test.js.map +1 -1
- package/dist/src/ui/components/ToolStatsDisplay.d.ts +7 -0
- package/dist/src/ui/components/ToolStatsDisplay.js +41 -0
- package/dist/src/ui/components/ToolStatsDisplay.js.map +1 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.d.ts +6 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js +160 -0
- package/dist/src/ui/components/ToolStatsDisplay.test.js.map +1 -0
- package/dist/src/ui/components/messages/UserMessage.js +1 -1
- package/dist/src/ui/components/messages/UserMessage.js.map +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.js +3 -3
- package/dist/src/ui/components/shared/MaxSizedBox.js.map +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.test.js +1 -1
- package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +1 -1
- package/dist/src/ui/contexts/SessionContext.d.ts +17 -19
- package/dist/src/ui/contexts/SessionContext.js +20 -103
- package/dist/src/ui/contexts/SessionContext.js.map +1 -1
- package/dist/src/ui/contexts/SessionContext.test.js +66 -121
- package/dist/src/ui/contexts/SessionContext.test.js.map +1 -1
- package/dist/src/ui/editors/editorSettingsManager.js +4 -0
- package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.js +36 -18
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useConsoleMessages.js +3 -2
- package/dist/src/ui/hooks/useConsoleMessages.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +64 -92
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.test.js +85 -133
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.js +2 -2
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useStateAndRef.d.ts +1 -1
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js +7 -2
- package/dist/src/ui/privacy/CloudFreePrivacyNotice.js.map +1 -1
- package/dist/src/ui/themes/shades-of-purple.d.ts +11 -0
- package/dist/src/ui/themes/shades-of-purple.js +302 -0
- package/dist/src/ui/themes/shades-of-purple.js.map +1 -0
- package/dist/src/ui/themes/theme-manager.js +2 -0
- package/dist/src/ui/themes/theme-manager.js.map +1 -1
- package/dist/src/ui/types.d.ts +17 -8
- package/dist/src/ui/types.js +2 -0
- package/dist/src/ui/types.js.map +1 -1
- package/dist/src/ui/utils/computeStats.d.ts +10 -0
- package/dist/src/ui/utils/computeStats.js +55 -0
- package/dist/src/ui/utils/computeStats.js.map +1 -0
- package/dist/src/ui/utils/displayUtils.d.ts +17 -0
- package/dist/src/ui/utils/displayUtils.js +24 -0
- package/dist/src/ui/utils/displayUtils.js.map +1 -0
- package/dist/src/ui/utils/formatters.js +1 -1
- package/dist/src/ui/utils/formatters.js.map +1 -1
- package/dist/src/ui/utils/textUtils.js +2 -2
- package/dist/src/ui/utils/textUtils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -10
- package/dist/google-gemini-cli-0.1.7.tgz +0 -0
|
@@ -8,6 +8,7 @@ import { render } from 'ink-testing-library';
|
|
|
8
8
|
import { describe, it, expect, vi } from 'vitest';
|
|
9
9
|
import { HistoryItemDisplay } from './HistoryItemDisplay.js';
|
|
10
10
|
import { MessageType } from '../types.js';
|
|
11
|
+
import { SessionStatsProvider } from '../contexts/SessionContext.js';
|
|
11
12
|
// Mock child components
|
|
12
13
|
vi.mock('./messages/ToolGroupMessage.js', () => ({
|
|
13
14
|
ToolGroupMessage: () => _jsx("div", {}),
|
|
@@ -29,24 +30,12 @@ describe('<HistoryItemDisplay />', () => {
|
|
|
29
30
|
expect(lastFrame()).toContain('Hello');
|
|
30
31
|
});
|
|
31
32
|
it('renders StatsDisplay for "stats" type', () => {
|
|
32
|
-
const stats = {
|
|
33
|
-
turnCount: 1,
|
|
34
|
-
promptTokenCount: 10,
|
|
35
|
-
candidatesTokenCount: 20,
|
|
36
|
-
totalTokenCount: 30,
|
|
37
|
-
cachedContentTokenCount: 5,
|
|
38
|
-
toolUsePromptTokenCount: 2,
|
|
39
|
-
thoughtsTokenCount: 3,
|
|
40
|
-
apiTimeMs: 123,
|
|
41
|
-
};
|
|
42
33
|
const item = {
|
|
43
34
|
...baseItem,
|
|
44
35
|
type: MessageType.STATS,
|
|
45
|
-
stats,
|
|
46
|
-
lastTurnStats: stats,
|
|
47
36
|
duration: '1s',
|
|
48
37
|
};
|
|
49
|
-
const { lastFrame } = render(_jsx(HistoryItemDisplay, { ...baseItem, item: item }));
|
|
38
|
+
const { lastFrame } = render(_jsx(SessionStatsProvider, { children: _jsx(HistoryItemDisplay, { ...baseItem, item: item }) }));
|
|
50
39
|
expect(lastFrame()).toContain('Stats');
|
|
51
40
|
});
|
|
52
41
|
it('renders AboutBox for "about" type', () => {
|
|
@@ -63,24 +52,29 @@ describe('<HistoryItemDisplay />', () => {
|
|
|
63
52
|
const { lastFrame } = render(_jsx(HistoryItemDisplay, { ...baseItem, item: item }));
|
|
64
53
|
expect(lastFrame()).toContain('About Gemini CLI');
|
|
65
54
|
});
|
|
66
|
-
it('renders
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
it('renders ModelStatsDisplay for "model_stats" type', () => {
|
|
56
|
+
const item = {
|
|
57
|
+
...baseItem,
|
|
58
|
+
type: 'model_stats',
|
|
59
|
+
};
|
|
60
|
+
const { lastFrame } = render(_jsx(SessionStatsProvider, { children: _jsx(HistoryItemDisplay, { ...baseItem, item: item }) }));
|
|
61
|
+
expect(lastFrame()).toContain('No API calls have been made in this session.');
|
|
62
|
+
});
|
|
63
|
+
it('renders ToolStatsDisplay for "tool_stats" type', () => {
|
|
64
|
+
const item = {
|
|
65
|
+
...baseItem,
|
|
66
|
+
type: 'tool_stats',
|
|
76
67
|
};
|
|
68
|
+
const { lastFrame } = render(_jsx(SessionStatsProvider, { children: _jsx(HistoryItemDisplay, { ...baseItem, item: item }) }));
|
|
69
|
+
expect(lastFrame()).toContain('No tool calls have been made in this session.');
|
|
70
|
+
});
|
|
71
|
+
it('renders SessionSummaryDisplay for "quit" type', () => {
|
|
77
72
|
const item = {
|
|
78
73
|
...baseItem,
|
|
79
74
|
type: 'quit',
|
|
80
|
-
stats,
|
|
81
75
|
duration: '1s',
|
|
82
76
|
};
|
|
83
|
-
const { lastFrame } = render(_jsx(HistoryItemDisplay, { ...baseItem, item: item }));
|
|
77
|
+
const { lastFrame } = render(_jsx(SessionStatsProvider, { children: _jsx(HistoryItemDisplay, { ...baseItem, item: item }) }));
|
|
84
78
|
expect(lastFrame()).toContain('Agent powering down. Goodbye!');
|
|
85
79
|
});
|
|
86
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryItemDisplay.test.js","sourceRoot":"","sources":["../../../../src/ui/components/HistoryItemDisplay.test.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAe,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"HistoryItemDisplay.test.js","sourceRoot":"","sources":["../../../../src/ui/components/HistoryItemDisplay.test.tsx"],"names":[],"m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,KAAC,oBAAoB,cACnB,KAAC,kBAAkB,OAAK,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAI,GAC3B,CACxB,CAAC;QACF,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAC3B,+CAA+C,CAChD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,IAAI,GAAgB;YACxB,GAAG,QAAQ;YACX,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,oBAAoB,cACnB,KAAC,kBAAkB,OAAK,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAI,GAC3B,CACxB,CAAC;QACF,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,+BAA+B,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { Colors } from '../colors.js';
|
|
4
|
+
import { formatDuration } from '../utils/formatters.js';
|
|
5
|
+
import { calculateAverageLatency, calculateCacheHitRate, calculateErrorRate, } from '../utils/computeStats.js';
|
|
6
|
+
import { useSessionStats } from '../contexts/SessionContext.js';
|
|
7
|
+
const METRIC_COL_WIDTH = 28;
|
|
8
|
+
const MODEL_COL_WIDTH = 22;
|
|
9
|
+
const StatRow = ({ title, values, isSubtle = false, isSection = false, }) => (_jsxs(Box, { children: [_jsx(Box, { width: METRIC_COL_WIDTH, children: _jsx(Text, { bold: isSection, color: isSection ? undefined : Colors.LightBlue, children: isSubtle ? ` ↳ ${title}` : title }) }), values.map((value, index) => (_jsx(Box, { width: MODEL_COL_WIDTH, children: _jsx(Text, { children: value }) }, index)))] }));
|
|
10
|
+
export const ModelStatsDisplay = () => {
|
|
11
|
+
const { stats } = useSessionStats();
|
|
12
|
+
const { models } = stats.metrics;
|
|
13
|
+
const activeModels = Object.entries(models).filter(([, metrics]) => metrics.api.totalRequests > 0);
|
|
14
|
+
if (activeModels.length === 0) {
|
|
15
|
+
return (_jsx(Box, { borderStyle: "round", borderColor: Colors.Gray, paddingY: 1, paddingX: 2, children: _jsx(Text, { children: "No API calls have been made in this session." }) }));
|
|
16
|
+
}
|
|
17
|
+
const modelNames = activeModels.map(([name]) => name);
|
|
18
|
+
const getModelValues = (getter) => activeModels.map(([, metrics]) => getter(metrics));
|
|
19
|
+
const hasThoughts = activeModels.some(([, metrics]) => metrics.tokens.thoughts > 0);
|
|
20
|
+
const hasTool = activeModels.some(([, metrics]) => metrics.tokens.tool > 0);
|
|
21
|
+
const hasCached = activeModels.some(([, metrics]) => metrics.tokens.cached > 0);
|
|
22
|
+
return (_jsxs(Box, { borderStyle: "round", borderColor: Colors.Gray, flexDirection: "column", paddingY: 1, paddingX: 2, children: [_jsx(Text, { bold: true, color: Colors.AccentPurple, children: "Model Stats For Nerds" }), _jsx(Box, { height: 1 }), _jsxs(Box, { children: [_jsx(Box, { width: METRIC_COL_WIDTH, children: _jsx(Text, { bold: true, children: "Metric" }) }), modelNames.map((name) => (_jsx(Box, { width: MODEL_COL_WIDTH, children: _jsx(Text, { bold: true, children: name }) }, name)))] }), _jsx(Box, { borderStyle: "single", borderBottom: true, borderTop: false, borderLeft: false, borderRight: false }), _jsx(StatRow, { title: "API", values: [], isSection: true }), _jsx(StatRow, { title: "Requests", values: getModelValues((m) => m.api.totalRequests.toLocaleString()) }), _jsx(StatRow, { title: "Errors", values: getModelValues((m) => {
|
|
23
|
+
const errorRate = calculateErrorRate(m);
|
|
24
|
+
return (_jsxs(Text, { color: m.api.totalErrors > 0 ? Colors.AccentRed : Colors.Foreground, children: [m.api.totalErrors.toLocaleString(), " (", errorRate.toFixed(1), "%)"] }));
|
|
25
|
+
}) }), _jsx(StatRow, { title: "Avg Latency", values: getModelValues((m) => {
|
|
26
|
+
const avgLatency = calculateAverageLatency(m);
|
|
27
|
+
return formatDuration(avgLatency);
|
|
28
|
+
}) }), _jsx(Box, { height: 1 }), _jsx(StatRow, { title: "Tokens", values: [], isSection: true }), _jsx(StatRow, { title: "Total", values: getModelValues((m) => (_jsx(Text, { color: Colors.AccentYellow, children: m.tokens.total.toLocaleString() }))) }), _jsx(StatRow, { title: "Prompt", isSubtle: true, values: getModelValues((m) => m.tokens.prompt.toLocaleString()) }), hasCached && (_jsx(StatRow, { title: "Cached", isSubtle: true, values: getModelValues((m) => {
|
|
29
|
+
const cacheHitRate = calculateCacheHitRate(m);
|
|
30
|
+
return (_jsxs(Text, { color: Colors.AccentGreen, children: [m.tokens.cached.toLocaleString(), " (", cacheHitRate.toFixed(1), "%)"] }));
|
|
31
|
+
}) })), hasThoughts && (_jsx(StatRow, { title: "Thoughts", isSubtle: true, values: getModelValues((m) => m.tokens.thoughts.toLocaleString()) })), hasTool && (_jsx(StatRow, { title: "Tool", isSubtle: true, values: getModelValues((m) => m.tokens.tool.toLocaleString()) })), _jsx(StatRow, { title: "Output", isSubtle: true, values: getModelValues((m) => m.tokens.candidates.toLocaleString()) })] }));
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=ModelStatsDisplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelStatsDisplay.js","sourceRoot":"","sources":["../../../../src/ui/components/ModelStatsDisplay.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,eAAe,EAAgB,MAAM,+BAA+B,C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AAI,CAAC,cAAc,EAAE,CAAC,GAC7D,CACH,EACD,KAAC,OAAO,IACN,KAAK,EAAC,QAAQ,EACd,QAAQ,QACR,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,GACnE,IACE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2025 Google LLC
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
import { render } from 'ink-testing-library';
|
|
8
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
9
|
+
import { ModelStatsDisplay } from './ModelStatsDisplay.js';
|
|
10
|
+
import * as SessionContext from '../contexts/SessionContext.js';
|
|
11
|
+
// Mock the context to provide controlled data for testing
|
|
12
|
+
vi.mock('../contexts/SessionContext.js', async (importOriginal) => {
|
|
13
|
+
const actual = await importOriginal();
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
useSessionStats: vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats);
|
|
20
|
+
const renderWithMockedStats = (metrics) => {
|
|
21
|
+
useSessionStatsMock.mockReturnValue({
|
|
22
|
+
stats: {
|
|
23
|
+
sessionStartTime: new Date(),
|
|
24
|
+
metrics,
|
|
25
|
+
lastPromptTokenCount: 0,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
return render(_jsx(ModelStatsDisplay, {}));
|
|
29
|
+
};
|
|
30
|
+
describe('<ModelStatsDisplay />', () => {
|
|
31
|
+
it('should render "no API calls" message when there are no active models', () => {
|
|
32
|
+
const { lastFrame } = renderWithMockedStats({
|
|
33
|
+
models: {},
|
|
34
|
+
tools: {
|
|
35
|
+
totalCalls: 0,
|
|
36
|
+
totalSuccess: 0,
|
|
37
|
+
totalFail: 0,
|
|
38
|
+
totalDurationMs: 0,
|
|
39
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
40
|
+
byName: {},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
expect(lastFrame()).toContain('No API calls have been made in this session.');
|
|
44
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
45
|
+
});
|
|
46
|
+
it('should not display conditional rows if no model has data for them', () => {
|
|
47
|
+
const { lastFrame } = renderWithMockedStats({
|
|
48
|
+
models: {
|
|
49
|
+
'gemini-2.5-pro': {
|
|
50
|
+
api: { totalRequests: 1, totalErrors: 0, totalLatencyMs: 100 },
|
|
51
|
+
tokens: {
|
|
52
|
+
prompt: 10,
|
|
53
|
+
candidates: 20,
|
|
54
|
+
total: 30,
|
|
55
|
+
cached: 0,
|
|
56
|
+
thoughts: 0,
|
|
57
|
+
tool: 0,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
tools: {
|
|
62
|
+
totalCalls: 0,
|
|
63
|
+
totalSuccess: 0,
|
|
64
|
+
totalFail: 0,
|
|
65
|
+
totalDurationMs: 0,
|
|
66
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
67
|
+
byName: {},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
const output = lastFrame();
|
|
71
|
+
expect(output).not.toContain('Cached');
|
|
72
|
+
expect(output).not.toContain('Thoughts');
|
|
73
|
+
expect(output).not.toContain('Tool');
|
|
74
|
+
expect(output).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
it('should display conditional rows if at least one model has data', () => {
|
|
77
|
+
const { lastFrame } = renderWithMockedStats({
|
|
78
|
+
models: {
|
|
79
|
+
'gemini-2.5-pro': {
|
|
80
|
+
api: { totalRequests: 1, totalErrors: 0, totalLatencyMs: 100 },
|
|
81
|
+
tokens: {
|
|
82
|
+
prompt: 10,
|
|
83
|
+
candidates: 20,
|
|
84
|
+
total: 30,
|
|
85
|
+
cached: 5,
|
|
86
|
+
thoughts: 2,
|
|
87
|
+
tool: 0,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
'gemini-2.5-flash': {
|
|
91
|
+
api: { totalRequests: 1, totalErrors: 0, totalLatencyMs: 50 },
|
|
92
|
+
tokens: {
|
|
93
|
+
prompt: 5,
|
|
94
|
+
candidates: 10,
|
|
95
|
+
total: 15,
|
|
96
|
+
cached: 0,
|
|
97
|
+
thoughts: 0,
|
|
98
|
+
tool: 3,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
tools: {
|
|
103
|
+
totalCalls: 0,
|
|
104
|
+
totalSuccess: 0,
|
|
105
|
+
totalFail: 0,
|
|
106
|
+
totalDurationMs: 0,
|
|
107
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
108
|
+
byName: {},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
const output = lastFrame();
|
|
112
|
+
expect(output).toContain('Cached');
|
|
113
|
+
expect(output).toContain('Thoughts');
|
|
114
|
+
expect(output).toContain('Tool');
|
|
115
|
+
expect(output).toMatchSnapshot();
|
|
116
|
+
});
|
|
117
|
+
it('should display stats for multiple models correctly', () => {
|
|
118
|
+
const { lastFrame } = renderWithMockedStats({
|
|
119
|
+
models: {
|
|
120
|
+
'gemini-2.5-pro': {
|
|
121
|
+
api: { totalRequests: 10, totalErrors: 1, totalLatencyMs: 1000 },
|
|
122
|
+
tokens: {
|
|
123
|
+
prompt: 100,
|
|
124
|
+
candidates: 200,
|
|
125
|
+
total: 300,
|
|
126
|
+
cached: 50,
|
|
127
|
+
thoughts: 10,
|
|
128
|
+
tool: 5,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
'gemini-2.5-flash': {
|
|
132
|
+
api: { totalRequests: 20, totalErrors: 2, totalLatencyMs: 500 },
|
|
133
|
+
tokens: {
|
|
134
|
+
prompt: 200,
|
|
135
|
+
candidates: 400,
|
|
136
|
+
total: 600,
|
|
137
|
+
cached: 100,
|
|
138
|
+
thoughts: 20,
|
|
139
|
+
tool: 10,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
tools: {
|
|
144
|
+
totalCalls: 0,
|
|
145
|
+
totalSuccess: 0,
|
|
146
|
+
totalFail: 0,
|
|
147
|
+
totalDurationMs: 0,
|
|
148
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
149
|
+
byName: {},
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
const output = lastFrame();
|
|
153
|
+
expect(output).toContain('gemini-2.5-pro');
|
|
154
|
+
expect(output).toContain('gemini-2.5-flash');
|
|
155
|
+
expect(output).toMatchSnapshot();
|
|
156
|
+
});
|
|
157
|
+
it('should handle large values without wrapping or overlapping', () => {
|
|
158
|
+
const { lastFrame } = renderWithMockedStats({
|
|
159
|
+
models: {
|
|
160
|
+
'gemini-2.5-pro': {
|
|
161
|
+
api: {
|
|
162
|
+
totalRequests: 999999999,
|
|
163
|
+
totalErrors: 123456789,
|
|
164
|
+
totalLatencyMs: 9876,
|
|
165
|
+
},
|
|
166
|
+
tokens: {
|
|
167
|
+
prompt: 987654321,
|
|
168
|
+
candidates: 123456789,
|
|
169
|
+
total: 999999999,
|
|
170
|
+
cached: 123456789,
|
|
171
|
+
thoughts: 111111111,
|
|
172
|
+
tool: 222222222,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
tools: {
|
|
177
|
+
totalCalls: 0,
|
|
178
|
+
totalSuccess: 0,
|
|
179
|
+
totalFail: 0,
|
|
180
|
+
totalDurationMs: 0,
|
|
181
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
182
|
+
byName: {},
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
expect(lastFrame()).toMatchSnapshot();
|
|
186
|
+
});
|
|
187
|
+
it('should display a single model correctly', () => {
|
|
188
|
+
const { lastFrame } = renderWithMockedStats({
|
|
189
|
+
models: {
|
|
190
|
+
'gemini-2.5-pro': {
|
|
191
|
+
api: { totalRequests: 1, totalErrors: 0, totalLatencyMs: 100 },
|
|
192
|
+
tokens: {
|
|
193
|
+
prompt: 10,
|
|
194
|
+
candidates: 20,
|
|
195
|
+
total: 30,
|
|
196
|
+
cached: 5,
|
|
197
|
+
thoughts: 2,
|
|
198
|
+
tool: 1,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
tools: {
|
|
203
|
+
totalCalls: 0,
|
|
204
|
+
totalSuccess: 0,
|
|
205
|
+
totalFail: 0,
|
|
206
|
+
totalDurationMs: 0,
|
|
207
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
208
|
+
byName: {},
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
const output = lastFrame();
|
|
212
|
+
expect(output).toContain('gemini-2.5-pro');
|
|
213
|
+
expect(output).not.toContain('gemini-2.5-flash');
|
|
214
|
+
expect(output).toMatchSnapshot();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
//# sourceMappingURL=ModelStatsDisplay.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelStatsDisplay.test.js","sourceRoot":"","sources":["../../../../src/ui/components/ModelStatsDisplay.test.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;AAGhE,0DAA0D;AAC1D,EAAE,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAK,EAAE,cAAc,EA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,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QACjD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import { CumulativeStats } from '../contexts/SessionContext.js';
|
|
8
7
|
interface SessionSummaryDisplayProps {
|
|
9
|
-
stats: CumulativeStats;
|
|
10
8
|
duration: string;
|
|
11
9
|
}
|
|
12
10
|
export declare const SessionSummaryDisplay: React.FC<SessionSummaryDisplayProps>;
|
|
@@ -3,18 +3,24 @@ import { Box, Text } from 'ink';
|
|
|
3
3
|
import Gradient from 'ink-gradient';
|
|
4
4
|
import { Colors } from '../colors.js';
|
|
5
5
|
import { formatDuration } from '../utils/formatters.js';
|
|
6
|
+
import { useSessionStats } from '../contexts/SessionContext.js';
|
|
7
|
+
import { computeSessionStats } from '../utils/computeStats.js';
|
|
6
8
|
import { StatRow, StatsColumn } from './Stats.js';
|
|
7
9
|
// --- Main Component ---
|
|
8
|
-
export const SessionSummaryDisplay = ({
|
|
10
|
+
export const SessionSummaryDisplay = ({ duration, }) => {
|
|
11
|
+
const { stats } = useSessionStats();
|
|
12
|
+
const { metrics } = stats;
|
|
13
|
+
const computed = computeSessionStats(metrics);
|
|
9
14
|
const cumulativeFormatted = {
|
|
10
|
-
inputTokens:
|
|
11
|
-
outputTokens:
|
|
12
|
-
toolUseTokens:
|
|
13
|
-
thoughtsTokens:
|
|
14
|
-
cachedTokens:
|
|
15
|
-
totalTokens:
|
|
15
|
+
inputTokens: Object.values(metrics.models).reduce((acc, model) => acc + model.tokens.prompt, 0),
|
|
16
|
+
outputTokens: Object.values(metrics.models).reduce((acc, model) => acc + model.tokens.candidates, 0),
|
|
17
|
+
toolUseTokens: Object.values(metrics.models).reduce((acc, model) => acc + model.tokens.tool, 0),
|
|
18
|
+
thoughtsTokens: Object.values(metrics.models).reduce((acc, model) => acc + model.tokens.thoughts, 0),
|
|
19
|
+
cachedTokens: Object.values(metrics.models).reduce((acc, model) => acc + model.tokens.cached, 0),
|
|
20
|
+
totalTokens: Object.values(metrics.models).reduce((acc, model) => acc + model.tokens.total, 0),
|
|
16
21
|
};
|
|
22
|
+
const totalRequests = Object.values(metrics.models).reduce((acc, model) => acc + model.api.totalRequests, 0);
|
|
17
23
|
const title = 'Agent powering down. Goodbye!';
|
|
18
|
-
return (_jsxs(Box, { borderStyle: "round", borderColor: "gray", flexDirection: "column", paddingY: 1, paddingX: 2, alignSelf: "flex-start", children: [_jsx(Box, { marginBottom: 1, flexDirection: "column", children: Colors.GradientColors ? (_jsx(Gradient, { colors: Colors.GradientColors, children: _jsx(Text, { bold: true, children: title }) })) : (_jsx(Text, { bold: true, children: title })) }), _jsx(Box, { marginTop: 1, children: _jsx(StatsColumn, { title: `Cumulative Stats (${
|
|
24
|
+
return (_jsxs(Box, { borderStyle: "round", borderColor: "gray", flexDirection: "column", paddingY: 1, paddingX: 2, alignSelf: "flex-start", children: [_jsx(Box, { marginBottom: 1, flexDirection: "column", children: Colors.GradientColors ? (_jsx(Gradient, { colors: Colors.GradientColors, children: _jsx(Text, { bold: true, children: title }) })) : (_jsx(Text, { bold: true, children: title })) }), _jsx(Box, { marginTop: 1, children: _jsx(StatsColumn, { title: `Cumulative Stats (${totalRequests} API calls)`, stats: cumulativeFormatted, isCumulative: true, children: _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(StatRow, { label: "Total duration (API)", value: formatDuration(computed.totalApiTime) }), _jsx(StatRow, { label: "Total duration (Tools)", value: formatDuration(computed.totalToolTime) }), _jsx(StatRow, { label: "Total duration (wall)", value: duration })] }) }) })] }));
|
|
19
25
|
};
|
|
20
26
|
//# sourceMappingURL=SessionSummaryDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionSummaryDisplay.js","sourceRoot":"","sources":["../../../../src/ui/components/SessionSummaryDisplay.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"SessionSummaryDisplay.js","sourceRoot":"","sources":["../../../../src/ui/components/SessionSummaryDisplay.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAkB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQlE,yBAAyB;AAEzB,MAAM,CAAC,MAAM,qBAAqB,GAAyC,CAAC,EAC1E,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,eAAe,EAAE,CAAC;IACpC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1B,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE9C,MAAM,mBAAmB,GAAmB;QAC1C,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAC/C,CAAC,GAAG,EAAE,KAAK,EAA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+BAA+B,CAAC;IAE9C,OAAO,CACL,MAAC,GAAG,IACF,WAAW,EAAC,OAAO,EACnB,WAAW,EAAC,MAAM,EAClB,aAAa,EAAC,QAAQ,EACtB,QAAQ,EAAE,CAAC,EACX,QAAQ,EAAE,CAAC,EACX,SAAS,EAAC,YAAY,aAEtB,KAAC,GAAG,IAAC,YAAY,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,YACzC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CACvB,KAAC,QAAQ,IAAC,MAAM,EAAE,MAAM,CAAC,cAAc,YACrC,KAAC,IAAI,IAAC,IAAI,kBAAE,KAAK,GAAQ,GAChB,CACZ,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,IAAI,kBAAE,KAAK,GAAQ,CAC1B,GACG,EAEN,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,WAAW,IACV,KAAK,EAAE,qBAAqB,aAAa,aAAa,EACtD,KAAK,EAAE,mBAAmB,EAC1B,YAAY,EAAE,IAAI,YAElB,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,KAAC,OAAO,IACN,KAAK,EAAC,sBAAsB,EAC5B,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,GAC5C,EACF,KAAC,OAAO,IACN,KAAK,EAAC,wBAAwB,EAC9B,KAAK,EAAE,cAAc,CAAC,QAAQ,CAAC,aAAa,CAAC,GAC7C,EACF,KAAC,OAAO,IAAC,KAAK,EAAC,uBAAuB,EAAC,KAAK,EAAE,QAAQ,GAAI,IACtD,GACM,GACV,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -5,36 +5,82 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
7
|
import { render } from 'ink-testing-library';
|
|
8
|
-
import { describe, it, expect } from 'vitest';
|
|
8
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
9
9
|
import { SessionSummaryDisplay } from './SessionSummaryDisplay.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
cachedContentTokenCount: 500,
|
|
17
|
-
toolUsePromptTokenCount: 200,
|
|
18
|
-
thoughtsTokenCount: 300,
|
|
19
|
-
apiTimeMs: 50234,
|
|
10
|
+
import * as SessionContext from '../contexts/SessionContext.js';
|
|
11
|
+
vi.mock('../contexts/SessionContext.js', async (importOriginal) => {
|
|
12
|
+
const actual = await importOriginal();
|
|
13
|
+
return {
|
|
14
|
+
...actual,
|
|
15
|
+
useSessionStats: vi.fn(),
|
|
20
16
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
});
|
|
18
|
+
const useSessionStatsMock = vi.mocked(SessionContext.useSessionStats);
|
|
19
|
+
const renderWithMockedStats = (metrics) => {
|
|
20
|
+
useSessionStatsMock.mockReturnValue({
|
|
21
|
+
stats: {
|
|
22
|
+
sessionStartTime: new Date(),
|
|
23
|
+
metrics,
|
|
24
|
+
lastPromptTokenCount: 0,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return render(_jsx(SessionSummaryDisplay, { duration: "1h 23m 45s" }));
|
|
28
|
+
};
|
|
29
|
+
describe('<SessionSummaryDisplay />', () => {
|
|
30
|
+
it('correctly sums and displays stats from multiple models', () => {
|
|
31
|
+
const metrics = {
|
|
32
|
+
models: {
|
|
33
|
+
'gemini-2.5-pro': {
|
|
34
|
+
api: { totalRequests: 10, totalErrors: 1, totalLatencyMs: 50234 },
|
|
35
|
+
tokens: {
|
|
36
|
+
prompt: 1000,
|
|
37
|
+
candidates: 2000,
|
|
38
|
+
total: 3500,
|
|
39
|
+
cached: 500,
|
|
40
|
+
thoughts: 300,
|
|
41
|
+
tool: 200,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
'gemini-2.5-flash': {
|
|
45
|
+
api: { totalRequests: 5, totalErrors: 0, totalLatencyMs: 12345 },
|
|
46
|
+
tokens: {
|
|
47
|
+
prompt: 500,
|
|
48
|
+
candidates: 1000,
|
|
49
|
+
total: 1500,
|
|
50
|
+
cached: 100,
|
|
51
|
+
thoughts: 50,
|
|
52
|
+
tool: 20,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
tools: {
|
|
57
|
+
totalCalls: 0,
|
|
58
|
+
totalSuccess: 0,
|
|
59
|
+
totalFail: 0,
|
|
60
|
+
totalDurationMs: 0,
|
|
61
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
62
|
+
byName: {},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const { lastFrame } = renderWithMockedStats(metrics);
|
|
66
|
+
const output = lastFrame();
|
|
67
|
+
// Verify totals are summed correctly
|
|
68
|
+
expect(output).toContain('Cumulative Stats (15 API calls)');
|
|
69
|
+
expect(output).toMatchSnapshot();
|
|
25
70
|
});
|
|
26
71
|
it('renders zero state correctly', () => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
72
|
+
const zeroMetrics = {
|
|
73
|
+
models: {},
|
|
74
|
+
tools: {
|
|
75
|
+
totalCalls: 0,
|
|
76
|
+
totalSuccess: 0,
|
|
77
|
+
totalFail: 0,
|
|
78
|
+
totalDurationMs: 0,
|
|
79
|
+
totalDecisions: { accept: 0, reject: 0, modify: 0 },
|
|
80
|
+
byName: {},
|
|
81
|
+
},
|
|
36
82
|
};
|
|
37
|
-
const { lastFrame } =
|
|
83
|
+
const { lastFrame } = renderWithMockedStats(zeroMetrics);
|
|
38
84
|
expect(lastFrame()).toMatchSnapshot();
|
|
39
85
|
});
|
|
40
86
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionSummaryDisplay.test.js","sourceRoot":"","sources":["../../../../src/ui/components/SessionSummaryDisplay.test.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"SessionSummaryDisplay.test.js","sourceRoot":"","sources":["../../../../src/ui/components/SessionSummaryDisplay.test.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;AAGhE,EAAE,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,cAAc,EAAyB,CAAC;IAC7D,OAAO;QACL,GAAG,MAAM;QACT,eAAe,EAAE,EAAE,CAAC,EAAE,EAAE;KACzB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;AAEtE,MAAM,qBAAqB,GAAG,CAAC,OAAuB,EAAE,EAAE;IACxD,mBAAmB,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE;YACL,gBAAgB,EAAE,IAAI,IAAI,EAAE;YAC5B,OAAO;YACP,oBAAoB,EAAE,CAAC;SACxB;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,KAAC,qBAAqB,IAAC,QAAQ,EAAC,YAAY,GAAG,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,QAAQ,CAAC,2BAA2B,EAA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EH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,WAAW,GAAmB;YAClC,MAAM,EAAE,EAAE;YACV,KAAK,EAAE;gBACL,UAAU,EAAE,CAAC;gBACb,YAAY,EAAE,CAAC;gBACf,SAAS,EAAE,CAAC;gBACZ,eAAe,EAAE,CAAC;gBAClB,cAAc,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;gBACnD,MAAM,EAAE,EAAE;aACX;SACF,CAAC;QAEF,MAAM,EAAE,SAAS,EAAE,GAAG,qBAAqB,CAAC,WAAW,CAAC,CAAC;QACzD,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import { CumulativeStats } from '../contexts/SessionContext.js';
|
|
8
7
|
interface StatsDisplayProps {
|
|
9
|
-
stats: CumulativeStats;
|
|
10
|
-
lastTurnStats: CumulativeStats;
|
|
11
8
|
duration: string;
|
|
12
9
|
}
|
|
13
10
|
export declare const StatsDisplay: React.FC<StatsDisplayProps>;
|