Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(chat): consecutive tool calls render as one morphing band

purple5855fe50f6b0
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsx
index d985cc0d..b5a2c900 100644
--- a/src/components/chat/CodexView.tsx
+++ b/src/components/chat/CodexView.tsx
@@ -4,6 +4,8 @@ import { useChatStore } from '../../stores/chatStore'
import { useGenerationStore } from '../../stores/generationStore'
import { ChatInput } from './ChatInput'
import { ToolCallBlock } from './ToolCallBlock'
+import { ToolCallBand } from './ToolCallBand'
+import { groupAgentBlocks } from '../../lib/tool-call-groups'
import { ThinkingBlock } from './ThinkingBlock'
import { MarkdownRenderer } from './MarkdownRenderer'
import { TokenCounter } from './TokenCounter'
@@ -278,24 +280,33 @@ export function CodexView() {
(b.phase === 'answer' && stripChannelTags(b.content)),
)
.sort((a, b) => a.timestamp - b.timestamp)
+ // Render EVERY answer normally + visible
+ // (David 2026-06-04: "kein Collapse, ganz
+ // normal wie eine Antwort"). Skip only a
+ // verbatim repeat of the previous answer.
+ const skippedAnswers = new Set<string>()
+ let lastAnswer = ''
+ for (const b of ordered) {
+ if (b.phase !== 'answer') continue
+ const a = stripChannelTags(b.content)
+ if (!a) continue
+ if (a === lastAnswer) skippedAnswers.add(b.id)
+ else lastAnswer = a
+ }
return (
<div className="space-y-1">
- {ordered.map((block, idx) => {
- if (block.phase === 'tool_call' && block.toolCall) {
- return <ToolCallBlock key={block.id} toolCall={block.toolCall} />
+ {groupAgentBlocks(ordered).map((group) => {
+ // Consecutive tool calls render as ONE
+ // band that morphs from tool to tool and
+ // collapses to "N steps" when done
+ // (David 2026-07-31).
+ if (group.kind === 'tools') {
+ return <ToolCallBand key={group.blocks[0].id} calls={group.calls} />
}
+ const block = group.block
if (block.phase === 'answer') {
const answer = stripChannelTags(block.content)
- if (!answer) return null
- // Render EVERY answer normally + visible
- // (David 2026-06-04: "kein Collapse, ganz
- // normal wie eine Antwort"). Skip only a
- // verbatim repeat of the previous answer.
- const prev = ordered
- .slice(0, idx)
- .reverse()
- .find((b) => b.phase === 'answer' && stripChannelTags(b.content))
- if (prev && stripChannelTags(prev.content) === answer) return null
+ if (!answer || skippedAnswers.has(block.id)) return null
return (
<div key={block.id} className="px-1 py-0.5">
<div className="text-[0.75rem] leading-relaxed">
@@ -311,11 +322,12 @@ export function CodexView() {
})()
: (
<div className="space-y-0">
- {msg.agentBlocks!
- .filter((b) => b.phase === 'tool_call' && b.toolCall)
- .map((block) => (
- <ToolCallBlock key={block.id} toolCall={block.toolCall!} />
- ))}
+ {(() => {
+ const calls = msg.agentBlocks!
+ .filter((b) => b.phase === 'tool_call' && b.toolCall)
+ .map((b) => b.toolCall!)
+ return calls.length > 0 ? <ToolCallBand calls={calls} /> : null
+ })()}
</div>
)
diff --git a/src/components/chat/MessageBubble.tsx b/src/components/chat/MessageBubble.tsx
index 0637e778..78692052 100644
--- a/src/components/chat/MessageBubble.tsx
+++ b/src/components/chat/MessageBubble.tsx
@@ -3,8 +3,9 @@ import { User, Copy, Check, Pencil, RefreshCw, X, Wrench, Trash2 } from 'lucide-
import { useState, useRef, useEffect, useMemo } from 'react'
import { MarkdownRenderer } from './MarkdownRenderer'
import { ThinkingBlock } from './ThinkingBlock'
-import { ToolCallBlock } from './ToolCallBlock'
+import { ToolCallBand } from './ToolCallBand'
import { ReflectionBlock } from './ReflectionBlock'
+import { groupAgentBlocks } from '../../lib/tool-call-groups'
import { VramSwitchCard } from './VramSwitchCard'
import { SpeakerButton } from './SpeakerButton'
import { ChatArtifactCard } from './ChatArtifactCard'
@@ -198,26 +199,32 @@ export function MessageBubble({ message, onRegenerate, onEdit, pendingApprovalId
bottom — every provider, every model. */}
{!isUser && message.agentBlocks && message.agentBlocks.length > 0 && (
<>
- {[...message.agentBlocks]
- .filter(
- (b) =>
- b.phase === 'tool_call' ||
- b.phase === 'reflection' ||
- (b.phase === 'answer' && b.content.trim()),
- )
- .sort((a, b) => a.timestamp - b.timestamp)
- .map((block) => {
- if (block.phase === 'tool_call' && block.toolCall) {
- const isPending = !!pendingApprovalId && block.toolCall.id === pendingApprovalId
+ {groupAgentBlocks(
+ [...message.agentBlocks]
+ .filter(
+ (b) =>
+ b.phase === 'tool_call' ||
+ b.phase === 'reflection' ||
+ (b.phase === 'answer' && b.content.trim()),
+ )
+ .sort((a, b) => a.timestamp - b.timestamp),
+ )
+ .map((group) => {
+ // Consecutive tool calls render as ONE band that morphs from
+ // tool to tool and collapses to "N steps" when done (David
+ // 2026-07-31) instead of a chip per call.
+ if (group.kind === 'tools') {
return (
- <ToolCallBlock
- key={block.id}
- toolCall={block.toolCall}
- onApprove={isPending ? onApprove : undefined}
- onReject={isPending ? onReject : undefined}
+ <ToolCallBand
+ key={group.blocks[0].id}
+ calls={group.calls}
+ pendingApprovalId={pendingApprovalId}
+ onApprove={onApprove}
+ onReject={onReject}
/>
)
}
+ const block = group.block
if (block.phase === 'reflection') {
return <ReflectionBlock key={block.id} content={block.content} />
}
diff --git a/src/components/chat/ToolCallBand.tsx b/src/components/chat/ToolCallBand.tsx
new file mode 100644
index 00000000..b8c15926
--- /dev/null
+++ b/src/components/chat/ToolCallBand.tsx
@@ -0,0 +1,155 @@
+import { useState } from 'react'
+import { AnimatePresence, motion } from 'framer-motion'
+import { AlertCircle, Check, ChevronDown, Wrench } from 'lucide-react'
+import type { AgentToolCall } from '../../types/agent-mode'
+import {
+ ToolCallBlock,
+ comfyViewUrlFromResult,
+ localMediaUrlFromResult,
+} from './ToolCallBlock'
+import {
+ activeToolCall,
+ groupDurationLabel,
+ groupIsLive,
+} from '../../lib/tool-call-groups'
+
+interface Props {
+ calls: AgentToolCall[]
+ pendingApprovalId?: string | null
+ onApprove?: () => void
+ onReject?: () => void
+}
+
+/**
+ * One row for a whole run of consecutive tool calls (David 2026-07-31).
+ *
+ * While the run is live the band renders only the ACTIVE call and morphs in
+ * place when the agent moves to the next tool — file_read transitions into
+ * file_write at the same position instead of stacking a new chip. When the
+ * run is done it collapses to an expandable "N steps" summary.
+ *
+ * Two things must never disappear into the collapse: an approval request
+ * (activeToolCall puts it in front, and ToolCallBlock opens itself for
+ * pending_approval), and completed media results (konata 2026-06-07 "and no
+ * image") — those calls keep rendering below the band whatever its state.
+ */
+export function ToolCallBand({ calls, pendingApprovalId, onApprove, onReject }: Props) {
+ const [userToggled, setUserToggled] = useState<boolean | null>(null)
+ const expanded = userToggled ?? false
+ const live = groupIsLive(calls)
+ const active = activeToolCall(calls)
+ const anyFailed = calls.some((c) => c.status === 'failed' || c.status === 'rejected')
+ const durationLabel = groupDurationLabel(calls)
+
+ const blockFor = (tc: AgentToolCall) => {
+ const isPending = !!pendingApprovalId && tc.id === pendingApprovalId
+ return (
+ <ToolCallBlock
+ key={tc.id}
+ toolCall={tc}
+ onApprove={isPending ? onApprove : undefined}
+ onReject={isPending ? onReject : undefined}
+ />
+ )
+ }
+
+ // Completed media calls stay visible outside the collapse/morph.
+ const mediaCalls = calls.filter(
+ (c) =>
+ c.status === 'completed' &&
+ (comfyViewUrlFromResult(c.result) || localMediaUrlFromResult(c.result)),
+ )
+
+ // A lone call is not spam — render it plain, exactly like before.
+ if (calls.length === 1) return blockFor(calls[0])
+
+ if (expanded) {
+ return (
+ <div className="mb-0.5">
+ <BandHeader
+ calls={calls}
+ live={live}
+ anyFailed={anyFailed}
+ durationLabel={durationLabel}
+ expanded
+ onToggle={() => setUserToggled(false)}
+ />
+ <div className="space-y-0.5 pl-1">{calls.map(blockFor)}</div>
+ </div>
+ )
+ }
+
+ if (live) {
+ return (
+ <div className="mb-0.5">
+ <AnimatePresence mode="popLayout" initial={false}>
+ <motion.div
+ key={active.id}
+ initial={{ opacity: 0, y: 6 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: -6 }}
+ transition={{ duration: 0.16 }}
+ >
+ {blockFor(active)}
+ </motion.div>
+ </AnimatePresence>
+ {mediaCalls.filter((c) => c.id !== active.id).map(blockFor)}
+ </div>
+ )
+ }
+
+ return (
+ <div className="mb-0.5">
+ <BandHeader
+ calls={calls}
+ live={false}
+ anyFailed={anyFailed}
+ durationLabel={durationLabel}
+ expanded={false}
+ onToggle={() => setUserToggled(true)}
+ />
+ {mediaCalls.map(blockFor)}
+ </div>
+ )
+}
+
+function BandHeader({
+ calls,
+ live,
+ anyFailed,
+ durationLabel,
+ expanded,
+ onToggle,
+}: {
+ calls: AgentToolCall[]
+ live: boolean
+ anyFailed: boolean
+ durationLabel: string | null
+ expanded: boolean
+ onToggle: () => void
+}) {
+ return (
+ <button
+ onClick={onToggle}
+ className="flex items-center gap-1.5 py-0.5 text-left hover:opacity-80 transition-opacity min-w-0"
+ >
+ <Wrench size={10} className="text-gray-500 dark:text-gray-500 shrink-0" />
+ <span className="text-[0.65rem] text-gray-600 dark:text-gray-400">
+ {calls.length} steps
+ </span>
+ {!live &&
+ (anyFailed ? (
+ <AlertCircle size={9} className="text-red-400/60 shrink-0" />
+ ) : (
+ <Check size={9} className="text-gray-400 dark:text-gray-500 shrink-0" />
+ ))}
+ {durationLabel && (
+ <span className="text-[0.5rem] text-gray-500 dark:text-gray-600">{durationLabel}</span>
+ )}
+ <ChevronDown
+ size={11}
+ className={`text-gray-400 dark:text-gray-500 shrink-0 transition-transform ${expanded ? 'rotate-180' : ''}`}
+ />
+ </button>
+ )
+}
diff --git a/src/components/chat/ToolCallBlock.tsx b/src/components/chat/ToolCallBlock.tsx
index e808ccee..8fa77998 100644
--- a/src/components/chat/ToolCallBlock.tsx
+++ b/src/components/chat/ToolCallBlock.tsx
@@ -197,7 +197,18 @@ export function ToolCallBlock({ toolCall, onApprove, onReject }: Props) {
className="flex items-center gap-1.5 py-0.5 text-left hover:opacity-80 transition-opacity flex-1 min-w-0"
>
<ToolIcon size={10} className="text-gray-500 dark:text-gray-500 shrink-0" />
- <span className="text-[0.65rem] text-gray-600 dark:text-gray-400">{toolCall.toolName}</span>
+ <span className={`text-[0.65rem] ${isRunning ? 'lu-tool-shimmer' : 'text-gray-600 dark:text-gray-400'}`}>{toolCall.toolName}</span>
+ {isRunning && (
+ <span className="flex items-center gap-[3px] shrink-0" aria-hidden>
+ {[0, 1, 2].map((i) => (
+ <span
+ key={i}
+ className="lu-band-dot w-[3px] h-[3px] rounded-full bg-gray-400 dark:bg-gray-500"
+ style={{ animationDelay: `${i * 0.2}s` }}
+ />
+ ))}
+ </span>
+ )}
<StatusIcon size={9} className={`shrink-0 ${
toolCall.status === 'completed' ? 'text-gray-400 dark:text-gray-500' :
isFailed ? 'text-red-400/60' :
diff --git a/src/index.css b/src/index.css
index 754d5fb2..7d7868f3 100644
--- a/src/index.css
+++ b/src/index.css
@@ -442,3 +442,28 @@ input[type="range"]::-webkit-slider-thumb {
background-size: 16px 16px;
background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
+
+/* Tool-call band (2.6.0, David 2026-07-31): the running tool's name gets a
+ soft violet sweep and trailing dots, so a live call reads as "working"
+ without a chip per step. Text shimmer needs background-clip, so light and
+ dark pick their own base grey. */
+@keyframes lu-tool-shimmer {
+ 0% { background-position: 200% 0; }
+ 100% { background-position: -200% 0; }
+}
+.lu-tool-shimmer {
+ background: linear-gradient(90deg, #4b5563 30%, #a78bfa 50%, #4b5563 70%);
+ background-size: 200% 100%;
+ -webkit-background-clip: text;
+ background-clip: text;
+ color: transparent;
+ animation: lu-tool-shimmer 1.6s linear infinite;
+}
+.dark .lu-tool-shimmer {
+ background-image: linear-gradient(90deg, #9ca3af 30%, #c4b5fd 50%, #9ca3af 70%);
+}
+@keyframes lu-band-dot {
+ 0%, 80%, 100% { opacity: 0.25; }
+ 40% { opacity: 1; }
+}
+.lu-band-dot { animation: lu-band-dot 1.2s ease-in-out infinite; }
diff --git a/src/lib/__tests__/tool-call-groups.test.ts b/src/lib/__tests__/tool-call-groups.test.ts
new file mode 100644
index 00000000..7955ce69
--- /dev/null
+++ b/src/lib/__tests__/tool-call-groups.test.ts
@@ -0,0 +1,76 @@
+import { describe, it, expect } from 'vitest'
+import {
+ groupAgentBlocks,
+ groupIsLive,
+ activeToolCall,
+ groupDurationLabel,
+} from '../tool-call-groups'
+import type { AgentBlock, AgentToolCall } from '../../types/agent-mode'
+
+let ts = 0
+function call(name: string, status: AgentToolCall['status'], duration?: number): AgentToolCall {
+ return { id: `c-${++ts}`, toolName: name, args: {}, status, duration, timestamp: ts }
+}
+function toolBlock(tc: AgentToolCall): AgentBlock {
+ return { id: `b-${tc.id}`, phase: 'tool_call', content: '', toolCall: tc, toolCalls: [tc], timestamp: ++ts }
+}
+function answerBlock(content: string): AgentBlock {
+ return { id: `a-${++ts}`, phase: 'answer', content, timestamp: ts }
+}
+
+describe('groupAgentBlocks', () => {
+ it('collects consecutive tool calls into one group', () => {
+ const a = toolBlock(call('file_read', 'completed'))
+ const b = toolBlock(call('file_write', 'completed'))
+ const groups = groupAgentBlocks([a, b])
+ expect(groups).toHaveLength(1)
+ expect(groups[0].kind).toBe('tools')
+ expect((groups[0] as any).calls.map((c: AgentToolCall) => c.toolName)).toEqual(['file_read', 'file_write'])
+ })
+
+ it('splits groups at interleaved answers, keeping order', () => {
+ const t1 = toolBlock(call('file_read', 'completed'))
+ const ans = answerBlock('found it')
+ const t2 = toolBlock(call('file_write', 'completed'))
+ const t3 = toolBlock(call('shell_execute', 'completed'))
+ const groups = groupAgentBlocks([t1, ans, t2, t3])
+ expect(groups.map(g => g.kind)).toEqual(['tools', 'single', 'tools'])
+ expect((groups[2] as any).calls).toHaveLength(2)
+ })
+
+ it('keeps a lone tool call as a group of one', () => {
+ const groups = groupAgentBlocks([toolBlock(call('web_search', 'running'))])
+ expect(groups).toHaveLength(1)
+ expect((groups[0] as any).calls).toHaveLength(1)
+ })
+
+ it('passes a tool_call block without a call payload through as single', () => {
+ const broken: AgentBlock = { id: 'x', phase: 'tool_call', content: '', timestamp: 1 }
+ const groups = groupAgentBlocks([broken])
+ expect(groups[0].kind).toBe('single')
+ })
+})
+
+describe('band state helpers', () => {
+ it('is live while any call runs or awaits approval, done otherwise', () => {
+ expect(groupIsLive([call('a', 'completed'), call('b', 'running')])).toBe(true)
+ expect(groupIsLive([call('a', 'completed'), call('b', 'pending_approval')])).toBe(true)
+ expect(groupIsLive([call('a', 'completed'), call('b', 'failed')])).toBe(false)
+ })
+
+ it('active call prefers approval, then earliest running, then the last call', () => {
+ const done = call('a', 'completed')
+ const run1 = call('b', 'running')
+ const run2 = call('c', 'running')
+ const pending = call('d', 'pending_approval')
+ expect(activeToolCall([done, run1, run2, pending]).toolName).toBe('d')
+ expect(activeToolCall([done, run1, run2]).toolName).toBe('b')
+ expect(activeToolCall([done, call('e', 'failed')]).toolName).toBe('e')
+ })
+
+ it('sums durations into the chip duration format', () => {
+ expect(groupDurationLabel([call('a', 'completed', 300), call('b', 'completed', 400)])).toBe('700ms')
+ expect(groupDurationLabel([call('a', 'completed', 800), call('b', 'completed', 700)])).toBe('1.5s')
+ expect(groupDurationLabel([call('a', 'running')])).toBeNull()
+ })
+})
diff --git a/src/lib/tool-call-groups.ts b/src/lib/tool-call-groups.ts
new file mode 100644
index 00000000..d139e993
--- /dev/null
+++ b/src/lib/tool-call-groups.ts
@@ -0,0 +1,67 @@
+/**
+ * Grouping for the tool-call band (David 2026-07-31): consecutive tool_call
+ * blocks in a message render as ONE band that morphs from tool to tool while
+ * running and collapses to an expandable "N steps" row when done, instead of
+ * stacking a chip per call and flooding the chat. Any non-tool block
+ * (reflection, answer) ends the current run, so interleaved commentary keeps
+ * its position in the transcript.
+ *
+ * Pure helpers, shared by MessageBubble (Agent) and CodexView (Code tab).
+ */
+
+import type { AgentBlock, AgentToolCall } from '../types/agent-mode'
+
+export type AgentBlockGroup =
+ | { kind: 'tools'; blocks: AgentBlock[]; calls: AgentToolCall[] }
+ | { kind: 'single'; block: AgentBlock }
+
+/** Blocks must already be filtered + timestamp-sorted by the caller. */
+export function groupAgentBlocks(blocks: AgentBlock[]): AgentBlockGroup[] {
+ const groups: AgentBlockGroup[] = []
+ for (const block of blocks) {
+ if (block.phase === 'tool_call' && block.toolCall) {
+ const last = groups[groups.length - 1]
+ if (last && last.kind === 'tools') {
+ last.blocks.push(block)
+ last.calls.push(block.toolCall)
+ } else {
+ groups.push({ kind: 'tools', blocks: [block], calls: [block.toolCall] })
+ }
+ } else {
+ groups.push({ kind: 'single', block })
+ }
+ }
+ return groups
+}
+
+/** A band is live while any of its calls still needs attention or runtime. */
+export function groupIsLive(calls: AgentToolCall[]): boolean {
+ return calls.some((c) => c.status === 'running' || c.status === 'pending_approval')
+}
+
+/**
+ * The call the collapsed band shows: an approval request beats everything
+ * (its buttons must be visible), then the earliest still-running call (so
+ * parallel batches display in order), else the last call of the group.
+ */
+export function activeToolCall(calls: AgentToolCall[]): AgentToolCall {
+ return (
+ calls.find((c) => c.status === 'pending_approval') ??
+ calls.find((c) => c.status === 'running') ??
+ calls[calls.length - 1]
+ )
+}
+
+/** Summed duration over the group, formatted like the per-chip label. */
+export function groupDurationLabel(calls: AgentToolCall[]): string | null {
+ let total = 0
+ let seen = false
+ for (const c of calls) {
+ if (c.duration != null) {
+ total += c.duration
+ seen = true
+ }
+ }
+ if (!seen) return null
+ return total < 1000 ? `${total}ms` : `${(total / 1000).toFixed(1)}s`
+}