From 8676bd29452f7539622901cb5ae703a3fdaebd07 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Thu, 15 Oct 2026 08:27:26 +0900 Subject: feat(tool-call-cards): pair calls and results in summarized collapsible bubbles --- src/features/chat/ui/ChatView.svelte | 81 ++++-------------------------------- 1 file changed, 8 insertions(+), 73 deletions(-) (limited to 'src/features/chat/ui/ChatView.svelte') diff --git a/src/features/chat/ui/ChatView.svelte b/src/features/chat/ui/ChatView.svelte index 5e4513c..18fea7c 100644 --- a/src/features/chat/ui/ChatView.svelte +++ b/src/features/chat/ui/ChatView.svelte @@ -11,6 +11,7 @@ } from "../../../core/metrics"; import { Markdown } from "../../markdown"; import LazyCollapse from "./LazyCollapse.svelte"; + import ToolCard from "./ToolCard.svelte"; const badgeClass = { success: "badge-success", @@ -73,6 +74,7 @@ const rows = $derived(interleaveTurnMetrics(groups, turnMetrics)); + // Tool cards use toolCallId keys across pending/result/seal and orphan page-in. // Stable per-row keys. Thinking blocks get an ordinal key (`think`) that // survives the provisional→committed (seq null → seq N) transition, so the // collapse's open/close state is NOT lost when a turn seals. The ordinal @@ -89,8 +91,8 @@ } const group = row.group; let key: string; - if (group.kind === "tool-batch") { - key = `b${group.stepId}`; + if (group.kind === "tool") { + key = `t${group.entry.toolCallId}`; } else if (group.chunk.chunk.type === "thinking") { key = `think${thinking++}`; } else if (group.chunk.seq != null) { @@ -103,22 +105,6 @@ }); -{#snippet wrench()} - -{/snippet} - {#snippet chunkRow(rendered: RenderedChunk)} {#if rendered.role === "user"} -
-
- {#if rendered.chunk.type === "tool-call"} - {@const call = rendered.chunk} - - {#snippet title()} - {@render wrench()} - {call.toolName} - {/snippet} -
{JSON.stringify(call.input, null, 2)}
-
- {:else} - {@const res = rendered.chunk} - - {#snippet title()} - {@render wrench()} - {res.toolName} - {#if res.isError} - error - {/if} - {/snippet} -
{res.content}
-
- {/if} -
-
{:else} @@ -287,31 +243,10 @@ {:else if row.group.kind === "single"} {@render chunkRow(row.group.chunk)} {:else} - -
-
-
- {#each row.group.entries as entry, entryIndex (entryIndex)} - - {#snippet title()} - {@render wrench()} - {entry.call.toolName} - {#if entry.result?.isError} - error - {:else if entry.result === null} - - {/if} - {/snippet} -
{JSON.stringify(entry.call.input, null, 2)}
- {#if entry.result} -
{entry.result.content}
- {/if} -
- {/each} -
+ +
+
+
{/if} -- cgit v1.2.3