mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Pulled manual commands to seperate function
This commit is contained in:
@@ -98,22 +98,22 @@ export const useGeminiStream = (
|
||||
[setHistory],
|
||||
);
|
||||
|
||||
// Improved submit query function
|
||||
const submitQuery = useCallback(
|
||||
async (query: PartListUnion) => {
|
||||
if (streamingState === StreamingState.Responding) return;
|
||||
if (typeof query === 'string' && query.trim().length === 0) return;
|
||||
// Possibly handle a query manually, return true if handled.
|
||||
const handleQueryManually = (rawQuery: PartListUnion): boolean => {
|
||||
if (typeof rawQuery !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof query === 'string') {
|
||||
setDebugMessage(`User query: ${query}`);
|
||||
const query = rawQuery.trim();
|
||||
const maybeCommand = query.split(/\s+/)[0];
|
||||
if (query.trim() === 'clear') {
|
||||
if (query === 'clear') {
|
||||
// This just clears the *UI* history, not the model history.
|
||||
// TODO: add a slash command for that.
|
||||
setDebugMessage('Clearing terminal.');
|
||||
setHistory((_) => []);
|
||||
return;
|
||||
} else if (config.getPassthroughCommands().includes(maybeCommand)) {
|
||||
return true;
|
||||
}
|
||||
if (config.getPassthroughCommands().includes(maybeCommand)) {
|
||||
// Execute and capture output
|
||||
const targetDir = config.getTargetDir();
|
||||
setDebugMessage(`Executing shell command in ${targetDir}: ${query}`);
|
||||
@@ -147,8 +147,24 @@ export const useGeminiStream = (
|
||||
});
|
||||
// Set state to Responding while the command runs
|
||||
setStreamingState(StreamingState.Responding);
|
||||
return; // Prevent Gemini call
|
||||
return true; // Prevent Gemini call
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Improved submit query function
|
||||
const submitQuery = useCallback(
|
||||
async (query: PartListUnion) => {
|
||||
if (streamingState === StreamingState.Responding) return;
|
||||
if (typeof query === 'string' && query.trim().length === 0) return;
|
||||
|
||||
if (typeof query === 'string') {
|
||||
setDebugMessage(`User query: '${query}'`);
|
||||
}
|
||||
|
||||
if (handleQueryManually(query)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const userMessageTimestamp = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user