fix: update chat history state after streaming and save complete conversation

This commit is contained in:
Nate 2025-07-15 19:23:01 -07:00
parent 6426777d65
commit 936786aee0
2 changed files with 11 additions and 5 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "@continuedev/cli", "name": "@continuedev/cli",
"version": "1.3.0", "version": "1.3.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@continuedev/cli", "name": "@continuedev/cli",
"version": "1.3.0", "version": "1.3.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@continuedev/config-yaml": "^1.0.96", "@continuedev/config-yaml": "^1.0.96",

View file

@ -266,8 +266,10 @@ export function useChat({
}, },
}; };
// Call streamChatResponse with the new history that includes the user message
const finalHistory = [...newHistory];
await streamChatResponse( await streamChatResponse(
newHistory, finalHistory,
model, model,
llmApi, llmApi,
controller, controller,
@ -286,7 +288,11 @@ export function useChat({
]); ]);
} }
saveSession(newHistory); // Update the chat history with the complete conversation after streaming
setChatHistory(finalHistory);
// Save the updated history to session
saveSession(finalHistory);
} catch (error: any) { } catch (error: any) {
const errorMessage = `Error: ${error.message}`; const errorMessage = `Error: ${error.message}`;
setMessages((prev) => [ setMessages((prev) => [
@ -345,4 +351,4 @@ export function useChat({
handleFileAttached, handleFileAttached,
resetChatHistory, resetChatHistory,
}; };
} }