mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-27 21:33:58 +02:00
fix: auto-complete previous pending messages when a new assistant message starts
When the agent produces multiple intermediate responses during a turn, each gets a unique messageId but all stay pending until finalizeTurn(). This caused multiple stacked 'Thinking' bubbles in the chat transcript. Now, when a new messageId arrives in applyTurnDelta, any previously pending assistant messages are marked complete and message-complete events are emitted before the new message-delta. The renderer reducer mirrors this logic for defensive consistency. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -112,10 +112,18 @@ function applyMessageDeltaEvent(session: SessionRecord, event: SessionEventRecor
|
||||
};
|
||||
}
|
||||
|
||||
// Auto-complete any previously pending assistant messages so only
|
||||
// the new message shows the "Thinking" indicator.
|
||||
const completedMessages = session.messages.map((message) =>
|
||||
message.pending && message.role === 'assistant'
|
||||
? { ...message, pending: false }
|
||||
: message,
|
||||
);
|
||||
|
||||
return {
|
||||
...session,
|
||||
messages: [
|
||||
...session.messages,
|
||||
...completedMessages,
|
||||
{
|
||||
id: event.messageId,
|
||||
role: 'assistant',
|
||||
|
||||
Reference in New Issue
Block a user