summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/ui/hooks/slashCommandProcessor.ts82
-rw-r--r--packages/cli/src/ui/hooks/useCompletion.ts2
-rw-r--r--packages/cli/src/ui/hooks/useGeminiStream.ts5
-rw-r--r--packages/cli/src/ui/hooks/useThemeCommand.ts6
4 files changed, 54 insertions, 41 deletions
diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
index a51de459..0d5b7603 100644
--- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { useCallback } from 'react';
+import { useCallback, useMemo } from 'react';
import { type PartListUnion } from '@google/genai';
import { HistoryItem } from '../types.js';
import { getCommandFromQuery } from '../utils/commandUtils.js';
@@ -35,44 +35,54 @@ export const useSlashCommandProcessor = (
getNextMessageId: (baseTimestamp: number) => number,
openThemeDialog: () => void,
) => {
- const slashCommands: SlashCommand[] = [
- {
- name: 'help',
- altName: '?',
- description: 'for help on gemini-code',
- action: (_value: PartListUnion) => {
- setDebugMessage('Opening help.');
- setShowHelp(true);
+ const slashCommands: SlashCommand[] = useMemo(
+ () => [
+ {
+ name: 'help',
+ altName: '?',
+ description: 'for help on gemini-code',
+ action: (_value: PartListUnion) => {
+ setDebugMessage('Opening help.');
+ setShowHelp(true);
+ },
},
- },
- {
- name: 'clear',
- description: 'clear the screen',
- action: (_value: PartListUnion) => {
- // This just clears the *UI* history, not the model history.
- setDebugMessage('Clearing terminal.');
- setHistory((_) => []);
- refreshStatic();
+ {
+ name: 'clear',
+ description: 'clear the screen',
+ action: (_value: PartListUnion) => {
+ // This just clears the *UI* history, not the model history.
+ setDebugMessage('Clearing terminal.');
+ setHistory((_) => []);
+ refreshStatic();
+ },
},
- },
- {
- name: 'theme',
- description: 'change the theme',
- action: (_value: PartListUnion) => {
- openThemeDialog();
+ {
+ name: 'theme',
+ description: 'change the theme',
+ action: (_value: PartListUnion) => {
+ openThemeDialog();
+ },
},
- },
- {
- name: 'quit',
- altName: 'exit',
- description: '',
- action: (_value: PartListUnion) => {
- setDebugMessage('Quitting. Good-bye.');
- getNextMessageId(Date.now());
- process.exit(0);
+ {
+ name: 'quit',
+ altName: 'exit',
+ description: '',
+ action: (_value: PartListUnion) => {
+ setDebugMessage('Quitting. Good-bye.');
+ getNextMessageId(Date.now());
+ process.exit(0);
+ },
},
- },
- ];
+ ],
+ [
+ setDebugMessage,
+ setShowHelp,
+ setHistory,
+ refreshStatic,
+ openThemeDialog,
+ getNextMessageId,
+ ],
+ );
// Checks if the query is a slash command and executes the command if it is.
const handleSlashCommand = useCallback(
@@ -109,7 +119,7 @@ export const useSlashCommandProcessor = (
return false; // Not a recognized slash command
},
- [setDebugMessage, setHistory, getNextMessageId, slashCommands],
+ [setHistory, slashCommands],
);
return { handleSlashCommand, slashCommands };
diff --git a/packages/cli/src/ui/hooks/useCompletion.ts b/packages/cli/src/ui/hooks/useCompletion.ts
index 97ad48ed..10ee4e23 100644
--- a/packages/cli/src/ui/hooks/useCompletion.ts
+++ b/packages/cli/src/ui/hooks/useCompletion.ts
@@ -220,7 +220,7 @@ export function useCompletion(
isMounted = false;
clearTimeout(debounceTimeout);
};
- }, [query, cwd, isActive, resetCompletionState]);
+ }, [query, cwd, isActive, resetCompletionState, slashCommands]);
return {
suggestions,
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts
index 1761563b..75114f77 100644
--- a/packages/cli/src/ui/hooks/useGeminiStream.ts
+++ b/packages/cli/src/ui/hooks/useGeminiStream.ts
@@ -101,7 +101,7 @@ export const useGeminiStream = (
);
}
}
- }, [config.getApiKey(), config.getModel()]);
+ }, [config]);
// Input Handling Effect (remains the same)
useInput((input, key) => {
@@ -532,10 +532,13 @@ export const useGeminiStream = (
getNextMessageId,
updateGeminiMessage,
handleSlashCommand,
+ handleShellCommand,
// handleAtCommand is implicitly included via its direct call
setDebugMessage, // Added dependency for handleAtCommand & passthrough
setStreamingState, // Added dependency for handlePassthroughCommand
updateAndAddGeminiMessageContent,
+ setShowHelp,
+ toolRegistry,
],
);
diff --git a/packages/cli/src/ui/hooks/useThemeCommand.ts b/packages/cli/src/ui/hooks/useThemeCommand.ts
index 542ee062..0f4ab93b 100644
--- a/packages/cli/src/ui/hooks/useThemeCommand.ts
+++ b/packages/cli/src/ui/hooks/useThemeCommand.ts
@@ -35,14 +35,14 @@ export const useThemeCommand = (
setIsThemeDialogOpen(true);
}, []);
- function applyTheme(themeName: string | undefined) {
+ const applyTheme = useCallback((themeName: string | undefined) => {
try {
themeManager.setActiveTheme(themeName);
setForceRender((v) => v + 1); // Trigger potential re-render
} catch (error) {
console.error(`Error setting theme: ${error}`);
}
- }
+ }, []);
const handleThemeHighlight = useCallback(
(themeName: string | undefined) => {
@@ -61,7 +61,7 @@ export const useThemeCommand = (
setIsThemeDialogOpen(false); // Close the dialog
}
},
- [applyTheme], // Added applyTheme to dependencies
+ [applyTheme, loadedSettings],
);
return {