From d0fbfc5bef181b0903609914b4d13072b5cd9090 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 16 Jun 2026 15:31:17 +0200 Subject: [PATCH] refac --- .../components/chat/AssistantMessage.svelte | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte b/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte index 46b8767..736add6 100644 --- a/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte +++ b/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte @@ -214,7 +214,12 @@ item: any; } - type DisplayItem = ToolGroup | MessageItem | ArtifactItem; + interface ReasoningItem { + type: 'reasoning_item'; + item: any; + } + + type DisplayItem = ToolGroup | MessageItem | ArtifactItem | ReasoningItem; const outputText = $derived.by((): string => { return (output || []) @@ -263,6 +268,9 @@ } else if (item.type === 'artifact') { flushGroup(); items.push({ type: 'artifact_item', item }); + } else if (item.type === 'reasoning') { + // Don't flush group — reasoning precedes tool calls + items.push({ type: 'reasoning_item', item }); } // function_call_output items are handled via outputMap, skip standalone render } @@ -376,6 +384,44 @@ c.text).join('') || ''} /> + {:else if displayItem.type === 'reasoning_item'} + {@const reasoningText = (displayItem.item.summary ?? displayItem.item.content ?? []) + .filter((p) => 'text' in p) + .map((p) => p.text ?? '') + .join('')} + {#if reasoningText} +
+ + {#if expandedGroups.has(groupIdx)} +
+
+
{reasoningText}
+
+
+ {/if} +
+ {/if} {:else if displayItem.type === 'artifact_item'} {@const artifact = displayItem.item} {@const preview = (artifact.content || '')