Moved theme to slashCommand
This commit is contained in:
parent
5f5edb4c9b
commit
2616e965a7
|
@ -35,16 +35,6 @@ interface AppProps {
|
||||||
export const App = ({ config, cliVersion }: AppProps) => {
|
export const App = ({ config, cliVersion }: AppProps) => {
|
||||||
const [history, setHistory] = useState<HistoryItem[]>([]);
|
const [history, setHistory] = useState<HistoryItem[]>([]);
|
||||||
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
|
const [startupWarnings, setStartupWarnings] = useState<string[]>([]);
|
||||||
const {
|
|
||||||
streamingState,
|
|
||||||
submitQuery,
|
|
||||||
initError,
|
|
||||||
debugMessage,
|
|
||||||
slashCommands,
|
|
||||||
} = useGeminiStream(setHistory, config);
|
|
||||||
const { elapsedTime, currentLoadingPhrase } =
|
|
||||||
useLoadingIndicator(streamingState);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isThemeDialogOpen,
|
isThemeDialogOpen,
|
||||||
openThemeDialog,
|
openThemeDialog,
|
||||||
|
@ -52,18 +42,26 @@ export const App = ({ config, cliVersion }: AppProps) => {
|
||||||
handleThemeHighlight,
|
handleThemeHighlight,
|
||||||
} = useThemeCommand();
|
} = useThemeCommand();
|
||||||
|
|
||||||
|
const {
|
||||||
|
streamingState,
|
||||||
|
submitQuery,
|
||||||
|
initError,
|
||||||
|
debugMessage,
|
||||||
|
slashCommands,
|
||||||
|
} = useGeminiStream(setHistory, config, openThemeDialog);
|
||||||
|
const { elapsedTime, currentLoadingPhrase } =
|
||||||
|
useLoadingIndicator(streamingState);
|
||||||
|
|
||||||
useStartupWarnings(setStartupWarnings);
|
useStartupWarnings(setStartupWarnings);
|
||||||
|
|
||||||
const handleFinalSubmit = useCallback(
|
const handleFinalSubmit = useCallback(
|
||||||
(submittedValue: string) => {
|
(submittedValue: string) => {
|
||||||
const trimmedValue = submittedValue.trim();
|
const trimmedValue = submittedValue.trim();
|
||||||
if (trimmedValue === '/theme') {
|
if (trimmedValue.length > 0) {
|
||||||
openThemeDialog();
|
|
||||||
} else if (trimmedValue.length > 0) {
|
|
||||||
submitQuery(submittedValue);
|
submitQuery(submittedValue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[openThemeDialog, submitQuery],
|
[submitQuery],
|
||||||
);
|
);
|
||||||
|
|
||||||
const userMessages = useMemo(
|
const userMessages = useMemo(
|
||||||
|
|
|
@ -30,17 +30,9 @@ export const useSlashCommandProcessor = (
|
||||||
setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>,
|
setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>,
|
||||||
setDebugMessage: React.Dispatch<React.SetStateAction<string>>,
|
setDebugMessage: React.Dispatch<React.SetStateAction<string>>,
|
||||||
getNextMessageId: (baseTimestamp: number) => number,
|
getNextMessageId: (baseTimestamp: number) => number,
|
||||||
|
openThemeDialog: () => void,
|
||||||
) => {
|
) => {
|
||||||
const slashCommands: SlashCommand[] = [
|
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',
|
name: 'help',
|
||||||
description: 'for help on gemini-code',
|
description: 'for help on gemini-code',
|
||||||
|
@ -56,6 +48,22 @@ export const useSlashCommandProcessor = (
|
||||||
addHistoryItem(setHistory, { type: 'info', text: helpText }, timestamp);
|
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',
|
name: 'exit',
|
||||||
description: '',
|
description: '',
|
||||||
|
@ -85,7 +93,6 @@ export const useSlashCommandProcessor = (
|
||||||
process.exit(0);
|
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.
|
// Checks if the query is a slash command and executes the command if it is.
|
||||||
|
|
|
@ -49,6 +49,7 @@ const addHistoryItem = (
|
||||||
export const useGeminiStream = (
|
export const useGeminiStream = (
|
||||||
setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>,
|
setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>,
|
||||||
config: Config,
|
config: Config,
|
||||||
|
openThemeDialog: () => void,
|
||||||
) => {
|
) => {
|
||||||
const toolRegistry = config.getToolRegistry();
|
const toolRegistry = config.getToolRegistry();
|
||||||
const [streamingState, setStreamingState] = useState<StreamingState>(
|
const [streamingState, setStreamingState] = useState<StreamingState>(
|
||||||
|
@ -74,6 +75,7 @@ export const useGeminiStream = (
|
||||||
setHistory,
|
setHistory,
|
||||||
setDebugMessage,
|
setDebugMessage,
|
||||||
getNextMessageId,
|
getNextMessageId,
|
||||||
|
openThemeDialog,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { handleShellCommand } = useShellCommandProcessor(
|
const { handleShellCommand } = useShellCommandProcessor(
|
||||||
|
|
Loading…
Reference in New Issue