Add /exit and /quit commands
This commit is contained in:
parent
ed12a2e133
commit
a5ba681f8d
|
@ -105,14 +105,30 @@ export const useGeminiStream = (
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = rawQuery.trim();
|
const query = rawQuery.trim();
|
||||||
const maybeCommand = query.split(/\s+/)[0];
|
if (query === 'clear' || query === '/clear') {
|
||||||
if (query === 'clear') {
|
|
||||||
// This just clears the *UI* history, not the model history.
|
// This just clears the *UI* history, not the model history.
|
||||||
// TODO: add a slash command for that.
|
// TODO: add a slash command for that.
|
||||||
setDebugMessage('Clearing terminal.');
|
setDebugMessage('Clearing terminal.');
|
||||||
setHistory((_) => []);
|
setHistory((_) => []);
|
||||||
return true;
|
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)) {
|
if (config.getPassthroughCommands().includes(maybeCommand)) {
|
||||||
// Execute and capture output
|
// Execute and capture output
|
||||||
const targetDir = config.getTargetDir();
|
const targetDir = config.getTargetDir();
|
||||||
|
@ -147,12 +163,12 @@ export const useGeminiStream = (
|
||||||
});
|
});
|
||||||
// Set state to Responding while the command runs
|
// Set state to Responding while the command runs
|
||||||
setStreamingState(StreamingState.Responding);
|
setStreamingState(StreamingState.Responding);
|
||||||
return true; // Prevent Gemini call
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false; // Not handled by a manual command.
|
||||||
|
};
|
||||||
|
|
||||||
// Improved submit query function
|
// Improved submit query function
|
||||||
const submitQuery = useCallback(
|
const submitQuery = useCallback(
|
||||||
async (query: PartListUnion) => {
|
async (query: PartListUnion) => {
|
||||||
|
|
Loading…
Reference in New Issue