From 9ab44ea9d675cd9d560e22fba50d057f1764f25c Mon Sep 17 00:00:00 2001 From: Harold Mciver Date: Wed, 16 Jul 2025 22:40:56 -0400 Subject: updated `/quit` to use new slash command arch (#4259) Co-authored-by: Abhi --- packages/cli/src/ui/hooks/slashCommandProcessor.ts | 45 ++++------------------ 1 file changed, 8 insertions(+), 37 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 35371265..125d051e 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -20,7 +20,6 @@ import { } from '../types.js'; import { promises as fs } from 'fs'; import path from 'path'; -import { formatDuration } from '../utils/formatters.js'; import { LoadedSettings } from '../../config/settings.js'; import { type CommandContext, @@ -202,33 +201,6 @@ export const useSlashCommandProcessor = ( toggleCorgiMode(); }, }, - { - name: 'quit', - altName: 'exit', - description: 'exit the cli', - action: async (mainCommand, _subCommand, _args) => { - const now = new Date(); - const { sessionStartTime } = session.stats; - const wallDuration = now.getTime() - sessionStartTime.getTime(); - - setQuittingMessages([ - { - type: 'user', - text: `/${mainCommand}`, - id: now.getTime() - 1, - }, - { - type: 'quit', - duration: formatDuration(wallDuration), - id: now.getTime(), - }, - ]); - - setTimeout(() => { - process.exit(0); - }, 100); - }, - }, ]; if (config?.getCheckpointingEnabled()) { @@ -352,15 +324,7 @@ export const useSlashCommandProcessor = ( }); } return commands; - }, [ - addMessage, - toggleCorgiMode, - config, - session, - gitService, - loadHistory, - setQuittingMessages, - ]); + }, [addMessage, toggleCorgiMode, config, gitService, loadHistory]); const handleSlashCommand = useCallback( async ( @@ -470,6 +434,12 @@ export const useSlashCommandProcessor = ( }); return { type: 'handled' }; } + case 'quit': + setQuittingMessages(result.messages); + setTimeout(() => { + process.exit(0); + }, 100); + return { type: 'handled' }; default: { const unhandled: never = result; throw new Error(`Unhandled slash command result: ${unhandled}`); @@ -549,6 +519,7 @@ export const useSlashCommandProcessor = ( openThemeDialog, openPrivacyNotice, openEditorDialog, + setQuittingMessages, ], ); -- cgit v1.2.3