mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-28 23:48:39 +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:
@@ -228,6 +228,46 @@ describe('session workspace helpers', () => {
|
||||
expect(updated?.sessions[0].runs).toEqual([run]);
|
||||
});
|
||||
|
||||
test('auto-completes previous pending assistant messages when a new message starts', () => {
|
||||
const first = applySessionEventWorkspace(createWorkspace(), {
|
||||
sessionId: 'session-1',
|
||||
kind: 'message-delta',
|
||||
occurredAt: '2026-03-23T00:00:01.000Z',
|
||||
messageId: 'assistant-1',
|
||||
authorName: 'Primary Agent',
|
||||
contentDelta: 'Exploring the codebase...',
|
||||
content: 'Exploring the codebase...',
|
||||
} satisfies SessionEventRecord);
|
||||
|
||||
expect(first?.sessions[0].messages).toHaveLength(1);
|
||||
expect(first?.sessions[0].messages[0]).toMatchObject({
|
||||
id: 'assistant-1',
|
||||
pending: true,
|
||||
});
|
||||
|
||||
const second = applySessionEventWorkspace(first, {
|
||||
sessionId: 'session-1',
|
||||
kind: 'message-delta',
|
||||
occurredAt: '2026-03-23T00:00:02.000Z',
|
||||
messageId: 'assistant-2',
|
||||
authorName: 'Primary Agent',
|
||||
contentDelta: 'Still exploring...',
|
||||
content: 'Still exploring...',
|
||||
} satisfies SessionEventRecord);
|
||||
|
||||
expect(second?.sessions[0].messages).toHaveLength(2);
|
||||
expect(second?.sessions[0].messages[0]).toMatchObject({
|
||||
id: 'assistant-1',
|
||||
content: 'Exploring the codebase...',
|
||||
pending: false,
|
||||
});
|
||||
expect(second?.sessions[0].messages[1]).toMatchObject({
|
||||
id: 'assistant-2',
|
||||
content: 'Still exploring...',
|
||||
pending: true,
|
||||
});
|
||||
});
|
||||
|
||||
test('ignores events for unknown sessions', () => {
|
||||
const workspace = createWorkspace();
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user