Skip to content

Commit 9df7dd2

Browse files
committed
fix: persist aborted stream output
1 parent a968e06 commit 9df7dd2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/store.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,18 @@ export const AgentStore = createContextStore<StoreModel>({
143143
abortRequest: action((state) => {
144144
state.abortController?.abort()
145145
state.abortController = undefined
146-
state.currentAssistantMessage = ""
146+
147+
if (state.currentAssistantMessage.trim()) {
148+
// Persist what has been generated so far
149+
state.chatHistory.push({
150+
type: "message",
151+
role: "assistant",
152+
content: state.currentAssistantMessage,
153+
})
154+
155+
state.currentAssistantMessage = ""
156+
}
157+
147158
state.stats = "User aborted the request."
148159
state.isProcessing = false
149160
}),

0 commit comments

Comments
 (0)