Skip to content

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

fix(chat): preserve streamed assistant text across runtime updates

Steven Enamakel56e64ae275e6
diff --git a/app/src/features/human/useHumanMascot.test.ts b/app/src/features/human/useHumanMascot.test.ts
index 55c2e3328f..e0218d5e71 100644
--- a/app/src/features/human/useHumanMascot.test.ts
+++ b/app/src/features/human/useHumanMascot.test.ts
@@ -367,11 +367,7 @@ describe('useHumanMascot state machine', () => {
const { result } = renderHook(() => useHumanMascot({ speakReplies: false }));
act(() => {
capturedListeners?.onDone?.(
- fakeEvent({
- full_response: 'sure thing',
- total_input_tokens: 1,
- total_output_tokens: 1,
- })
+ fakeEvent({ full_response: 'sure thing', total_input_tokens: 1, total_output_tokens: 1 })
);
});
expect(result.current.face).toBe('happy');
@@ -423,11 +419,7 @@ describe('useHumanMascot state machine', () => {
const { result } = renderHook(() => useHumanMascot({ speakReplies: false }));
act(() => {
capturedListeners?.onDone?.(
- fakeEvent({
- full_response: 'hi',
- total_input_tokens: 1,
- total_output_tokens: 1,
- })
+ fakeEvent({ full_response: 'hi', total_input_tokens: 1, total_output_tokens: 1 })
);
});
expect(result.current.face).toBe('happy');
@@ -566,11 +558,7 @@ describe('useHumanMascot state machine', () => {
fakeEvent({ tool_name: 'run', skill_id: 's', output: 'ok', success: true, round: 1 })
);
capturedListeners?.onDone?.(
- fakeEvent({
- full_response: 'Done.',
- total_input_tokens: 1,
- total_output_tokens: 1,
- })
+ fakeEvent({ full_response: 'Done.', total_input_tokens: 1, total_output_tokens: 1 })
);
});
expect(result.current.face).toBe('celebrating');
@@ -581,11 +569,7 @@ describe('useHumanMascot state machine', () => {
act(() => {
capturedListeners?.onInferenceStart?.(fakeEvent({}));
capturedListeners?.onDone?.(
- fakeEvent({
- full_response: 'Here you go.',
- total_input_tokens: 1,
- total_output_tokens: 1,
- })
+ fakeEvent({ full_response: 'Here you go.', total_input_tokens: 1, total_output_tokens: 1 })
);
});
expect(result.current.face).toBe('happy');
@@ -612,11 +596,7 @@ describe('useHumanMascot state machine', () => {
// Trigger a happy ack that starts the hold timer.
act(() => {
capturedListeners?.onDone?.(
- fakeEvent({
- full_response: 'Here you go.',
- total_input_tokens: 1,
- total_output_tokens: 1,
- })
+ fakeEvent({ full_response: 'Here you go.', total_input_tokens: 1, total_output_tokens: 1 })
);
});
expect(result.current.face).toBe('happy');
diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsx
index 26c67b9826..8e909834e1 100644
--- a/app/src/providers/ChatRuntimeProvider.tsx
+++ b/app/src/providers/ChatRuntimeProvider.tsx
@@ -649,11 +649,7 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
for (const item of queued) {
try {
await dispatch(
- addMessageLocal({
- threadId,
- message: item.message,
- attachments: item.attachments,
- })
+ addMessageLocal({ threadId, message: item.message, attachments: item.attachments })
).unwrap();
} catch (error) {
rtLog('flush_followup_append_failed', {
diff --git a/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx b/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
index 7108172758..8f681d5bb1 100644
--- a/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
+++ b/app/src/providers/__tests__/ChatRuntimeProvider.test.tsx
@@ -726,11 +726,7 @@ describe('ChatRuntimeProvider — dedupe, proactive resolution, mid-turn invaria
const listeners = renderProvider();
act(() => {
- listeners.onDone?.({
- thread_id: 't-user',
- request_id: 'r-user',
- full_response: 'hi',
- });
+ listeners.onDone?.({ thread_id: 't-user', request_id: 'r-user', full_response: 'hi' });
});
// The core stores an unsegmented reply before announcing it, so this
diff --git a/app/src/services/api/threadApi.ts b/app/src/services/api/threadApi.ts
index ce06fe89d4..d2a991e734 100644
--- a/app/src/services/api/threadApi.ts
+++ b/app/src/services/api/threadApi.ts
@@ -1,6 +1,5 @@
import debug from 'debug';
-import type { ContentPart } from '../chatWire';
import type {
DerivedTranscriptGetOptions,
DerivedTranscriptPage,
@@ -26,6 +25,7 @@ import type {
RunEventListResponse,
} from '../../types/turnState';
import type { ChatThreadTodoItem, ThreadGoal } from '../chatService';
+import type { ContentPart } from '../chatWire';
import { callCoreRpc } from '../coreRpcClient';
import { attachArtifactRows } from './artifactRows';
diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.ts
index 46cdbc7ce1..427c44b2b7 100644
--- a/app/src/services/chatService.ts
+++ b/app/src/services/chatService.ts
@@ -8,8 +8,8 @@
*/
import debug from 'debug';
-import type {
- ArtifactFailedEvent,
+import {
+ type ArtifactFailedEvent,
ArtifactKind,
ArtifactPendingEvent,
ArtifactReadyEvent,
@@ -43,13 +43,15 @@ import type {
ChatToolCallEvent,
ChatToolResultEvent,
ContentPart,
+ decodeApprovalDecided,
+ decodeRunModeChanged,
ExternalTransferPendingEvent,
+ externalTransferProvider,
ProactiveMessageEvent,
QueueItemEvent,
QueueItemPayload,
WireEvent,
} from './chatWire';
-import { decodeApprovalDecided, decodeRunModeChanged, externalTransferProvider } from './chatWire';
import { callCoreRpc } from './coreRpcClient';
import { socketService } from './socketService';
diff --git a/app/src/services/chatWire.test.ts b/app/src/services/chatWire.test.ts
index b94e8e9462..829411994c 100644
--- a/app/src/services/chatWire.test.ts
+++ b/app/src/services/chatWire.test.ts
@@ -12,7 +12,11 @@ import type { WebChannelEvent } from './chatWire.generated';
describe('chatWire', () => {
it('decodeRunModeChanged lifts the wire message into a mode', () => {
- const wire: WireEvent<'run_mode_changed'> = { thread_id: 't', request_id: '', message: 'build' };
+ const wire: WireEvent<'run_mode_changed'> = {
+ thread_id: 't',
+ request_id: '',
+ message: 'build',
+ };
expect(decodeRunModeChanged(wire)).toEqual({ thread_id: 't', request_id: '', mode: 'build' });
});