From dd53e5c96aa01708a3bdb675c8a8e0d71be35651 Mon Sep 17 00:00:00 2001 From: Abhi <43648792+abhipatel12@users.noreply.github.com> Date: Wed, 11 Jun 2025 20:08:32 -0400 Subject: Show session summary on exit for ctrl+c x 2. Fix exit UI (#963) --- packages/cli/src/ui/hooks/slashCommandProcessor.ts | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'packages/cli/src/ui/hooks/slashCommandProcessor.ts') diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index 478a62a3..d343c6ff 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -69,6 +69,7 @@ export const useSlashCommandProcessor = ( performMemoryRefresh: () => Promise, toggleCorgiMode: () => void, showToolDescriptions: boolean = false, + setQuittingMessages: (message: HistoryItem[]) => void, ) => { const session = useSessionStats(); const gitService = useMemo(() => { @@ -608,17 +609,24 @@ Add any other context about the problem here. name: 'quit', altName: 'exit', description: 'exit the cli', - action: async (_mainCommand, _subCommand, _args) => { + action: async (mainCommand, _subCommand, _args) => { const now = new Date(); const { sessionStartTime, cumulative } = session.stats; const wallDuration = now.getTime() - sessionStartTime.getTime(); - addMessage({ - type: MessageType.QUIT, - stats: cumulative, - duration: formatDuration(wallDuration), - timestamp: new Date(), - }); + setQuittingMessages([ + { + type: 'user', + text: `/${mainCommand}`, + id: now.getTime() - 1, + }, + { + type: 'quit', + stats: cumulative, + duration: formatDuration(wallDuration), + id: now.getTime(), + }, + ]); setTimeout(() => { process.exit(0); @@ -749,6 +757,7 @@ Add any other context about the problem here. gitService, loadHistory, addItem, + setQuittingMessages, ]); const handleSlashCommand = useCallback( @@ -763,7 +772,12 @@ Add any other context about the problem here. return false; } const userMessageTimestamp = Date.now(); - addItem({ type: MessageType.USER, text: trimmed }, userMessageTimestamp); + if (trimmed !== '/quit' && trimmed !== '/exit') { + addItem( + { type: MessageType.USER, text: trimmed }, + userMessageTimestamp, + ); + } let subCommand: string | undefined; let args: string | undefined; -- cgit v1.2.3