diff options
| author | Brandon Keiji <[email protected]> | 2025-05-13 23:55:49 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-13 16:55:49 -0700 |
| commit | d3303fd3a004ee816c2c498c2f7ffa51753afc07 (patch) | |
| tree | c8764197104ed1d33c5c0efa5cb1dfc69b6df38f /packages/cli/src/ui/App.tsx | |
| parent | c4c11f1d65233f31751cee65e29aa6ae3f7f2410 (diff) | |
refactor: move nested debugmessage and slashcommand hooks outside of useGeminiStream (#341)
Diffstat (limited to 'packages/cli/src/ui/App.tsx')
| -rw-r--r-- | packages/cli/src/ui/App.tsx | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index a2ed7cdc..39cbaf47 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -10,6 +10,7 @@ import { StreamingState, type HistoryItem } from './types.js'; import { useGeminiStream } from './hooks/useGeminiStream.js'; import { useLoadingIndicator } from './hooks/useLoadingIndicator.js'; import { useThemeCommand } from './hooks/useThemeCommand.js'; +import { useSlashCommandProcessor } from './hooks/slashCommandProcessor.js'; import { Header } from './components/Header.js'; import { LoadingIndicator } from './components/LoadingIndicator.js'; import { EditorState, InputPrompt } from './components/InputPrompt.js'; @@ -36,36 +37,40 @@ interface AppProps { export const App = ({ config, settings, cliVersion }: AppProps) => { const { history, addItem, clearItems } = useHistory(); + const [staticKey, setStaticKey] = useState(0); + const refreshStatic = useCallback(() => { + setStaticKey((prev) => prev + 1); + }, [setStaticKey]); + const [startupWarnings, setStartupWarnings] = useState<string[]>([]); + const [debugMessage, setDebugMessage] = useState<string>(''); const [showHelp, setShowHelp] = useState<boolean>(false); const [themeError, setThemeError] = useState<string | null>(null); + const { isThemeDialogOpen, openThemeDialog, handleThemeSelect, handleThemeHighlight, } = useThemeCommand(settings, setThemeError); - - const [staticKey, setStaticKey] = useState(0); - const refreshStatic = useCallback(() => { - setStaticKey((prev) => prev + 1); - }, [setStaticKey]); - - const { - streamingState, - submitQuery, - initError, - debugMessage, - slashCommands, - pendingHistoryItem, - } = useGeminiStream( + const { handleSlashCommand, slashCommands } = useSlashCommandProcessor( addItem, clearItems, refreshStatic, setShowHelp, - config, + setDebugMessage, openThemeDialog, ); + + const { streamingState, submitQuery, initError, pendingHistoryItem } = + useGeminiStream( + addItem, + refreshStatic, + setShowHelp, + config, + setDebugMessage, + handleSlashCommand, + ); const { elapsedTime, currentLoadingPhrase } = useLoadingIndicator(streamingState); |
