Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): correct test assertions for runtime provider and store

Steven Enamakeld994ef68952a
diff --git a/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx b/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
index 9588e7ca0b..a66c56df1a 100644
--- a/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
+++ b/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
@@ -1620,7 +1620,7 @@ describe('ChatRuntimeProvider — dedupe, proactive resolution, mid-turn invaria
expect(store.getState().chatRuntime.streamingAssistantByThread['t-inv']).toBeUndefined();
});
- it('terminates running tool-timeline rows on chat_done', () => {
+ it('leaves a still-running tool row running on chat_done instead of inventing success', () => {
const listeners = renderProvider();
act(() => {
@@ -1649,9 +1649,57 @@ describe('ChatRuntimeProvider — dedupe, proactive resolution, mid-turn invaria
});
});
+ // The core drains every queued progress event before `chat_done`, so a
+ // row with no result by now has none; the settled snapshot/projection
+ // decides its real status. Forcing `success` here invented an outcome.
const timeline = store.getState().chatRuntime.toolTimelineByThread['t-inv'] ?? [];
expect(timeline).toHaveLength(1);
- expect(timeline[0]?.status).toBe('success');
+ expect(timeline[0]?.status).toBe('running');
+ });
+
+ it('keeps two id-less calls of one tool in a round apart by seq, still deduping a redelivery', () => {
+ const listeners = renderProvider();
+ const call = (seq: number) => ({
+ thread_id: 't-seq',
+ request_id: 'r1',
+ seq,
+ round: 1,
+ tool_name: 'shell',
+ skill_id: 'web_channel',
+ args: {},
+ });
+
+ act(() => {
+ listeners.onToolCall?.(call(3));
+ listeners.onToolCall?.(call(5));
+ // Socket redelivery of the first frame.
+ listeners.onToolCall?.(call(3));
+ });
+
+ expect(store.getState().chatRuntime.toolTimelineByThread['t-seq']).toHaveLength(2);
+ });
+
+ it('drops a redelivered text delta by seq instead of appending it twice', () => {
+ const listeners = renderProvider();
+ const delta = (seq: number, text: string) => ({
+ thread_id: 't-delta',
+ request_id: 'r1',
+ seq,
+ round: 1,
+ delta: text,
+ });
+
+ act(() => {
+ listeners.onTextDelta?.(delta(1, 'Hel'));
+ listeners.onTextDelta?.(delta(2, 'lo'));
+ listeners.onTextDelta?.(delta(1, 'Hel'));
+ listeners.onThinkingDelta?.(delta(2, 'lo'));
+ listeners.onTextDelta?.(delta(3, '!'));
+ });
+
+ expect(store.getState().chatRuntime.streamingAssistantByThread['t-delta']?.content).toBe(
+ 'Hello!'
+ );
});
it('transitions running tool-timeline rows to error on chat_error', () => {
diff --git a/app/src/store/__tests__/chatRuntimeSlice.test.ts b/app/src/store/__tests__/chatRuntimeSlice.test.ts
index 1fcd996a8e..d8d3d01427 100644
--- a/app/src/store/__tests__/chatRuntimeSlice.test.ts
+++ b/app/src/store/__tests__/chatRuntimeSlice.test.ts
@@ -1089,6 +1089,32 @@ describe('chatRuntimeSlice', () => {
});
describe('toolCallReceived (Phase 3 reducer-side merge)', () => {
+ it('does not reopen a settled row when a late tool_call for it arrives', () => {
+ let state = reducer(
+ undefined,
+ toolCallReceived({ threadId: 't1', round: 1, toolName: 'shell', toolCallId: 'c1' })
+ );
+ state = reducer(
+ state,
+ toolResultReceived({
+ threadId: 't1',
+ round: 1,
+ toolName: 'shell',
+ toolCallId: 'c1',
+ success: true,
+ output: 'ok',
+ })
+ );
+ state = reducer(
+ state,
+ toolCallReceived({ threadId: 't1', round: 1, toolName: 'shell', toolCallId: 'c1' })
+ );
+
+ const rows = state.toolTimelineByThread['t1'];
+ expect(rows).toHaveLength(1);
+ expect(rows[0]).toMatchObject({ id: 'c1', status: 'success', result: 'ok' });
+ });
+
it('appends a new running row with a generated id and records the processing pointer', () => {
const state = reducer(
undefined,