mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix streaming message disappearing after it finishes
This commit is contained in:
2 files changed
+12
-3
No files matched your search
@@ -372,7 +372,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{streamingMessage && (
|
||||
{streamingMessage && isLoading && (
|
||||
streamingMessage.content ? (
|
||||
<AIMessageItem
|
||||
key="streaming-message"
|
||||
|
||||
@@ -345,9 +345,18 @@ export class SessionManager {
|
||||
...(accumulatedToolCalls.length > 0 && { tool_calls: accumulatedToolCalls })
|
||||
};
|
||||
|
||||
// Clear streaming message and add final message
|
||||
// Add final message and clear streaming message atomically
|
||||
session.messages.push(assistantMessage);
|
||||
session.streamingMessage = undefined;
|
||||
await this.addMessage(sessionId, assistantMessage);
|
||||
session.lastActivity = new Date();
|
||||
|
||||
// Save and emit all updates together
|
||||
await this.saveSessionHistory(sessionId);
|
||||
this.debouncedPersist();
|
||||
this.cleanupOldSessions();
|
||||
|
||||
this.emit('messageAdded', sessionId, assistantMessage);
|
||||
this.emit('sessionUpdated', sessionId, session);
|
||||
conversationMessages.push(assistantMessage);
|
||||
|
||||
// Update cost if usage data is available
|
||||
|
||||
Reference in new issue
Block a user