fix: Clear previous thoughts when starting new prompts (#4966)

This commit is contained in:
Neha Prasad
2025-07-28 23:27:33 +05:30
committed by GitHub
parent 379765da23
commit a5ea113a8e
2 changed files with 200 additions and 2 deletions

View File

@@ -414,8 +414,9 @@ export const useGeminiStream = (
userMessageTimestamp,
);
setIsResponding(false);
setThought(null); // Reset thought when user cancels
},
[addItem, pendingHistoryItemRef, setPendingHistoryItem],
[addItem, pendingHistoryItemRef, setPendingHistoryItem, setThought],
);
const handleErrorEvent = useCallback(
@@ -437,8 +438,9 @@ export const useGeminiStream = (
},
userMessageTimestamp,
);
setThought(null); // Reset thought when there's an error
},
[addItem, pendingHistoryItemRef, setPendingHistoryItem, config],
[addItem, pendingHistoryItemRef, setPendingHistoryItem, config, setThought],
);
const handleFinishedEvent = useCallback(
@@ -637,6 +639,7 @@ export const useGeminiStream = (
if (!options?.isContinuation) {
startNewPrompt();
setThought(null); // Reset thought when starting a new prompt
}
setIsResponding(true);