1ad75a3602f790858af1db46ca5980337fdc4a76
Two bugs caused the same AI response to appear twice: 1. handleSelectConversation would fetch conversation history even while a stream was in progress (isLoading). If the fetch resolved mid-stream, fetchConversation overwrote the conversation messages unconditionally, writing the server-persisted AI message (with a real UUID) alongside the still-streaming client-side message (with a temp ID), producing a duplicate. Fix: guard the fetch with !isLoading, and add a second check inside the .then callback so setConversations only writes history if the messages array is still empty (protects against slow-resolving network requests). 2. onDone in streamChat could theoretically be called a second time if the ReadableStream completed without a "done" SSE event. Fix: call reader.cancel() immediately after onDone so the while loop exits cleanly. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Description
No description provided
14 MiB
Languages
TypeScript
89.2%
CSS
4.3%
Makefile
2.9%
JavaScript
2.5%
Dockerfile
0.5%
Other
0.6%