From b4c0622f3fceea3469845fed042b3e6263899017 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Fri, 11 Sep 2026 16:57:21 +0200 Subject: [PATCH] fix: carry the event type narrowing through the stream parser Co-Authored-By: Claude Opus 5 (1M context) --- frontend/src/lib/components/aiAgentResult.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/aiAgentResult.ts b/frontend/src/lib/components/aiAgentResult.ts index b7ec8d695e..c954ac3964 100644 --- a/frontend/src/lib/components/aiAgentResult.ts +++ b/frontend/src/lib/components/aiAgentResult.ts @@ -173,7 +173,7 @@ const STREAM_EVENT_TYPES = [ 'tool_result' ] -function parseStreamEvent(line: string): Record | undefined { +function parseStreamEvent(line: string): (Record & { type: string }) | undefined { let event: unknown try { event = JSON.parse(line) @@ -183,7 +183,9 @@ function parseStreamEvent(line: string): Record | undefined { if (!isRecord(event) || typeof event.type !== 'string') { return undefined } - return STREAM_EVENT_TYPES.includes(event.type) ? event : undefined + return STREAM_EVENT_TYPES.includes(event.type) + ? (event as Record & { type: string }) + : undefined } /**