refactor: move nested debugmessage and slashcommand hooks outside of useGeminiStream (#341)

This commit is contained in:
Brandon Keiji
2025-05-13 23:55:49 +00:00
committed by GitHub
parent c4c11f1d65
commit d3303fd3a0
5 changed files with 42 additions and 49 deletions

View File

@@ -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);