summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useShellHistory.ts
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-07-23 15:49:09 -0700
committerGitHub <[email protected]>2025-07-23 22:49:09 +0000
commite9e2f5514465d596032eed41572f13db3268a81b (patch)
treeadf9360e002be13ffea652ff58103f284c65146d /packages/cli/src/ui/hooks/useShellHistory.ts
parent2e28bb90a00ad415d453a2ec868faa78679602f0 (diff)
Fix InputPrompt.test.tsx to be windows compatible (#4736)
Diffstat (limited to 'packages/cli/src/ui/hooks/useShellHistory.ts')
-rw-r--r--packages/cli/src/ui/hooks/useShellHistory.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/packages/cli/src/ui/hooks/useShellHistory.ts b/packages/cli/src/ui/hooks/useShellHistory.ts
index 90248cc0..61c7207c 100644
--- a/packages/cli/src/ui/hooks/useShellHistory.ts
+++ b/packages/cli/src/ui/hooks/useShellHistory.ts
@@ -12,6 +12,13 @@ import { isNodeError, getProjectTempDir } from '@google/gemini-cli-core';
const HISTORY_FILE = 'shell_history';
const MAX_HISTORY_LENGTH = 100;
+export interface UseShellHistoryReturn {
+ addCommandToHistory: (command: string) => void;
+ getPreviousCommand: () => string | null;
+ getNextCommand: () => string | null;
+ resetHistoryPosition: () => void;
+}
+
async function getHistoryFilePath(projectRoot: string): Promise<string> {
const historyDir = getProjectTempDir(projectRoot);
return path.join(historyDir, HISTORY_FILE);
@@ -42,7 +49,7 @@ async function writeHistoryFile(
}
}
-export function useShellHistory(projectRoot: string) {
+export function useShellHistory(projectRoot: string): UseShellHistoryReturn {
const [history, setHistory] = useState<string[]>([]);
const [historyIndex, setHistoryIndex] = useState(-1);
const [historyFilePath, setHistoryFilePath] = useState<string | null>(null);