diff --git a/calliope-web/src/lib/components/agent/AgentChat.svelte b/calliope-web/src/lib/components/agent/AgentChat.svelte index 57c6fcb3..120e2c7f 100644 --- a/calliope-web/src/lib/components/agent/AgentChat.svelte +++ b/calliope-web/src/lib/components/agent/AgentChat.svelte @@ -48,6 +48,21 @@ let listEl = $state(null); let pinned = $state(true); + // A user message starts a turn; keep different named assistants distinct. + const studioGroups = $derived.by(() => { + const groups: AgentMessage[][] = []; + for (const message of messages) { + if (!['user', 'assistant', 'tool'].includes(message.role)) continue; + const previous = groups.at(-1); + const author = previous?.find(m => m.role === 'assistant')?.agent_name; + if (!previous || message.role === 'user' || previous[0].role === 'user' || + (message.role === 'assistant' && author !== undefined && message.agent_name !== author)) { + groups.push([message]); + } else previous.push(message); + } + return groups; + }); + // Derived tool rows carry no status — infer failure from the result shape, // same as the live SSE path does. function toolPhase(m: AgentMessage): 'done' | 'error' { @@ -193,29 +208,29 @@
{#if studio} {#if loading}

{t('agentChat.loading')}

{/if} - {#each messages as m (m.id)} - {#if m.role==='user' || m.role==='assistant'} -
-
{#if m.role==='user'}我{:else}{/if}
+ {#each studioGroups as group (group[0].id)} +
+
{#if group[0].role==='user'}我{:else}{/if}
- {#if m.reasoning}{/if} -
- {#if m.status==='steering'}{t('agentChat.steering')}{/if} - {#each m.attachments??[] as a (a.path)}{a.name}{/each} - {#each bubbleParts(m.content,(m.mentions??[]) as WorkflowMention[]) as part,i (`${i}-${part.type}`)}{#if part.type==='chip'}{part.text}{:else}{part.text}{/if}{/each} -
+ {#each group as m (m.id)} + {#if m.role==='tool'} + + {#each artifactJobs(m) as job(job.id)}{/each} + {:else} + {#if m.reasoning}{/if} +
{#if m.status==='steering'}{t('agentChat.steering')}{/if}{#each m.attachments??[] as a (a.path)}{a.name}{/each}{#each bubbleParts(m.content,(m.mentions??[]) as WorkflowMention[]) as part,i (`${i}-${part.type}`)}{#if part.type==='chip'}{part.text}{:else}{part.text}{/if}{/each}
+ {/if} + {/each}
- {:else if m.role==='tool'} - - {#each artifactJobs(m) as job(job.id)}{/each} - {/if} {/each} {#if lastQuestion && !running}

{lastQuestion.question}

{#each lastQuestion.options as opt(opt)}{/each}
{/if} - {#if running} - {#each liveTools as tool,i(i)}{/each} - {#if streamingReasoning}{/if} - {#if streaming}
{streaming}
{/if} + {#if running && (liveTools.length || streamingReasoning || streaming)} +
+ {#each liveTools as tool,i(i)}{/each} + {#if streamingReasoning}{/if} + {#if streaming}
{streaming}
{/if} +
{/if} {#if !loading&&!messages.length&&!running}

{t('agentChat.emptyHint')}

{/if} {:else} @@ -368,7 +383,7 @@ .studio-msg.me {align-self:flex-end;flex-direction:row-reverse;} .studio-avatar {width:28px;height:28px;border-radius:var(--agent-radius-8);flex:none;display:grid;place-items:center;background:color-mix(in srgb,var(--sc-agent) 18%,transparent);color:var(--sc-agent);} .studio-msg.me .studio-avatar {background:var(--bg-3);color:var(--tx-2);} - .studio-message-body {display:flex;flex-direction:column;gap:10px;min-width:0;} + .studio-message-body {flex:var(--agent-message-flex);display:flex;flex-direction:column;gap:10px;min-width:0;} .studio-bubble {padding:10px 13px;border-radius:var(--agent-bubble-radius);background:var(--bg-2);border:1px solid var(--line);font-size:13px;line-height:1.65;white-space:pre-wrap;word-break:break-word;} .studio-msg.me .studio-bubble {background:color-mix(in srgb,var(--gold) 10%,transparent);border-color:color-mix(in srgb,var(--gold) 25%,transparent);} .studio-bubble.failed {color:var(--err);border-color:var(--err);} diff --git a/calliope-web/src/lib/components/agent/AgentToolCard.svelte b/calliope-web/src/lib/components/agent/AgentToolCard.svelte index 9fa46ff1..6e605ea3 100644 --- a/calliope-web/src/lib/components/agent/AgentToolCard.svelte +++ b/calliope-web/src/lib/components/agent/AgentToolCard.svelte @@ -3,13 +3,14 @@ import { t } from '$lib/i18n.svelte'; interface Props { + studio?: boolean; name: string; args?: Record | null; result?: unknown; phase: 'running' | 'done' | 'error'; } - let { name, args = null, result = null, phase }: Props = $props(); + let { studio = false, name, args = null, result = null, phase }: Props = $props(); let open = $state(false); function fmt(value: unknown): string { @@ -21,18 +22,19 @@ } -
+
{#if open}
@@ -54,7 +56,8 @@