diff options
| author | Seth Troisi <[email protected]> | 2025-04-25 01:12:47 +0000 |
|---|---|---|
| committer | Seth Troisi <[email protected]> | 2025-04-25 14:29:00 -0700 |
| commit | a5ba681f8df6efc0669370249b860546b690c09e (patch) | |
| tree | 0ea575a1f4c3b8b5e50613f7652719f6dda9eaea /packages/cli/src/ui/hooks/useGeminiStream.ts | |
| parent | ed12a2e133cffa02b607589d4cce9dd2afee2f05 (diff) | |
Add /exit and /quit commands
Diffstat (limited to 'packages/cli/src/ui/hooks/useGeminiStream.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useGeminiStream.ts | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index b76a5698..d8254cd3 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -105,14 +105,30 @@ export const useGeminiStream = ( } const query = rawQuery.trim(); - const maybeCommand = query.split(/\s+/)[0]; - if (query === 'clear') { + if (query === 'clear' || query === '/clear') { // This just clears the *UI* history, not the model history. // TODO: add a slash command for that. setDebugMessage('Clearing terminal.'); setHistory((_) => []); return true; } + if ( + query === 'exit' || + query === '/exit' || + query === 'quit' || + query === '/quit' + ) { + setDebugMessage('Quitting. Good-bye.'); + const timestamp = getNextMessageId(Date.now()); + addHistoryItem( + setHistory, + { type: 'info', text: 'good-bye!' }, + timestamp, + ); + process.exit(0); + return true; + } + const maybeCommand = query.split(/\s+/)[0]; if (config.getPassthroughCommands().includes(maybeCommand)) { // Execute and capture output const targetDir = config.getTargetDir(); @@ -147,11 +163,11 @@ export const useGeminiStream = ( }); // Set state to Responding while the command runs setStreamingState(StreamingState.Responding); - return true; // Prevent Gemini call + return true; } - return true; - } + return false; // Not handled by a manual command. + }; // Improved submit query function const submitQuery = useCallback( |
