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.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index 38fdddba..85ae825e 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -11,6 +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 { createShowMemoryAction } from './useShowMemoryCommand.js';
import { GIT_COMMIT_INFO } from '../../generated/git-commit.js';
import { formatMemoryUsage } from '../utils/formatters.js';
@@ -49,6 +50,8 @@ export const useSlashCommandProcessor = (
toggleCorgiMode: () => void,
showToolDescriptions: boolean = false,
) => {
+ const session = useSession();
+
const addMessage = useCallback(
(message: Message) => {
// Convert Message to HistoryItemWithoutId
@@ -139,6 +142,33 @@ export const useSlashCommandProcessor = (
},
},
{
+ name: 'stats',
+ altName: 'usage',
+ description: 'check session stats',
+ action: (_mainCommand, _subCommand, _args) => {
+ const now = new Date();
+ const duration = now.getTime() - session.startTime.getTime();
+ const durationInSeconds = Math.floor(duration / 1000);
+ const hours = Math.floor(durationInSeconds / 3600);
+ const minutes = Math.floor((durationInSeconds % 3600) / 60);
+ const seconds = durationInSeconds % 60;
+
+ const durationString = [
+ hours > 0 ? `${hours}h` : '',
+ minutes > 0 ? `${minutes}m` : '',
+ `${seconds}s`,
+ ]
+ .filter(Boolean)
+ .join(' ');
+
+ addMessage({
+ type: MessageType.INFO,
+ content: `Session duration: ${durationString}`,
+ timestamp: new Date(),
+ });
+ },
+ },
+ {
name: 'mcp',
description: 'list configured MCP servers and tools',
action: async (_mainCommand, _subCommand, _args) => {
@@ -447,6 +477,7 @@ Add any other context about the problem here.
toggleCorgiMode,
config,
showToolDescriptions,
+ session.startTime,
],
);