From 2616e965a7caa39d731bda881db5a2feb851aa34 Mon Sep 17 00:00:00 2001 From: Seth Troisi Date: Wed, 30 Apr 2025 22:26:28 +0000 Subject: [PATCH] Moved theme to slashCommand --- packages/cli/src/ui/App.tsx | 26 +++++++++--------- .../cli/src/ui/hooks/slashCommandProcessor.ts | 27 ++++++++++++------- packages/cli/src/ui/hooks/useGeminiStream.ts | 2 ++ 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index 8b219778..8aaa1018 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -35,16 +35,6 @@ interface AppProps { export const App = ({ config, cliVersion }: AppProps) => { const [history, setHistory] = useState([]); const [startupWarnings, setStartupWarnings] = useState([]); - const { - streamingState, - submitQuery, - initError, - debugMessage, - slashCommands, - } = useGeminiStream(setHistory, config); - const { elapsedTime, currentLoadingPhrase } = - useLoadingIndicator(streamingState); - const { isThemeDialogOpen, openThemeDialog, @@ -52,18 +42,26 @@ export const App = ({ config, cliVersion }: AppProps) => { handleThemeHighlight, } = useThemeCommand(); + const { + streamingState, + submitQuery, + initError, + debugMessage, + slashCommands, + } = useGeminiStream(setHistory, config, openThemeDialog); + const { elapsedTime, currentLoadingPhrase } = + useLoadingIndicator(streamingState); + useStartupWarnings(setStartupWarnings); const handleFinalSubmit = useCallback( (submittedValue: string) => { const trimmedValue = submittedValue.trim(); - if (trimmedValue === '/theme') { - openThemeDialog(); - } else if (trimmedValue.length > 0) { + if (trimmedValue.length > 0) { submitQuery(submittedValue); } }, - [openThemeDialog, submitQuery], + [submitQuery], ); const userMessages = useMemo( diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index f7f93b9d..89649810 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -30,17 +30,9 @@ export const useSlashCommandProcessor = ( setHistory: React.Dispatch>, setDebugMessage: React.Dispatch>, getNextMessageId: (baseTimestamp: number) => number, + openThemeDialog: () => void, ) => { const slashCommands: SlashCommand[] = [ - { - name: 'clear', - description: 'clear the screen', - action: (_value: PartListUnion) => { - // This just clears the *UI* history, not the model history. - setDebugMessage('Clearing terminal.'); - setHistory((_) => []); - }, - }, { name: 'help', description: 'for help on gemini-code', @@ -56,6 +48,22 @@ export const useSlashCommandProcessor = ( addHistoryItem(setHistory, { type: 'info', text: helpText }, timestamp); }, }, + { + name: 'clear', + description: 'clear the screen', + action: (_value: PartListUnion) => { + // This just clears the *UI* history, not the model history. + setDebugMessage('Clearing terminal.'); + setHistory((_) => []); + }, + }, + { + name: 'theme', + description: 'change the theme', + action: (_value: PartListUnion) => { + openThemeDialog(); + }, + }, { name: 'exit', description: '', @@ -85,7 +93,6 @@ export const useSlashCommandProcessor = ( process.exit(0); }, }, - // Removed /theme command, handled in App.tsx ]; // Checks if the query is a slash command and executes the command if it is. diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 89cd5223..9e2901ec 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -49,6 +49,7 @@ const addHistoryItem = ( export const useGeminiStream = ( setHistory: React.Dispatch>, config: Config, + openThemeDialog: () => void, ) => { const toolRegistry = config.getToolRegistry(); const [streamingState, setStreamingState] = useState( @@ -74,6 +75,7 @@ export const useGeminiStream = ( setHistory, setDebugMessage, getNextMessageId, + openThemeDialog, ); const { handleShellCommand } = useShellCommandProcessor(