summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/slashCommandProcessor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.ts')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index daec0379..6159fe89 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -11,7 +11,7 @@ import process from 'node:process';
import { UseHistoryManagerReturn } from './useHistoryManager.js';
import { Config, MCPServerStatus, getMCPServerStatus } from '@gemini-cli/core';
import { Message, MessageType, HistoryItemWithoutId } from '../types.js';
-import { useSession } from '../contexts/SessionContext.js';
+import { useSessionStats } from '../contexts/SessionContext.js';
import { createShowMemoryAction } from './useShowMemoryCommand.js';
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
import { formatMemoryUsage } from '../utils/formatters.js';
@@ -50,8 +50,7 @@ export const useSlashCommandProcessor = (
toggleCorgiMode: () => void,
showToolDescriptions: boolean = false,
) => {
- const session = useSession();
-
+ const session = useSessionStats();
const addMessage = useCallback(
(message: Message) => {
// Convert Message to HistoryItemWithoutId
@@ -147,7 +146,9 @@ export const useSlashCommandProcessor = (
description: 'check session stats',
action: (_mainCommand, _subCommand, _args) => {
const now = new Date();
- const duration = now.getTime() - session.startTime.getTime();
+ const { sessionStartTime, cumulative } = session.stats;
+
+ const duration = now.getTime() - sessionStartTime.getTime();
const durationInSeconds = Math.floor(duration / 1000);
const hours = Math.floor(durationInSeconds / 3600);
const minutes = Math.floor((durationInSeconds % 3600) / 60);
@@ -161,9 +162,25 @@ export const useSlashCommandProcessor = (
.filter(Boolean)
.join(' ');
+ const overheadTotal =
+ cumulative.thoughtsTokenCount + cumulative.toolUsePromptTokenCount;
+
+ const statsContent = [
+ ` ⎿ Total duration (wall): ${durationString}`,
+ ` Total Token usage:`,
+ ` Turns: ${cumulative.turnCount.toLocaleString()}`,
+ ` Total: ${cumulative.totalTokenCount.toLocaleString()}`,
+ ` ├─ Input: ${cumulative.promptTokenCount.toLocaleString()}`,
+ ` ├─ Output: ${cumulative.candidatesTokenCount.toLocaleString()}`,
+ ` ├─ Cached: ${cumulative.cachedContentTokenCount.toLocaleString()}`,
+ ` └─ Overhead: ${overheadTotal.toLocaleString()}`,
+ ` ├─ Model thoughts: ${cumulative.thoughtsTokenCount.toLocaleString()}`,
+ ` └─ Tool-use prompts: ${cumulative.toolUsePromptTokenCount.toLocaleString()}`,
+ ].join('\n');
+
addMessage({
type: MessageType.INFO,
- content: `Session duration: ${durationString}`,
+ content: statsContent,
timestamp: new Date(),
});
},
@@ -477,7 +494,7 @@ Add any other context about the problem here.
toggleCorgiMode,
config,
showToolDescriptions,
- session.startTime,
+ session,
],
);