Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agents): group consecutive tool calls into a collapsed row (#6380)

Eric Hayesac2b47de2dec
diff --git a/apps/web/src/features/block-agent/component/AgentMessage.test.tsx b/apps/web/src/features/block-agent/component/AgentMessage.test.tsx
new file mode 100644
index 0000000000..6676ca55cf
--- /dev/null
+++ b/apps/web/src/features/block-agent/component/AgentMessage.test.tsx
@@ -0,0 +1,213 @@
+/**
+ * @vitest-environment jsdom
+ */
+
+import type {
+ FoldedMessage,
+ MessagePart,
+} from '@service-agent-fold/generated/types';
+import { cleanup, render } from '@solidjs/testing-library';
+import type { JSX } from 'solid-js';
+import { createStore, reconcile } from 'solid-js/store';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { Message } from './AgentMessage';
+
+// The layer under test is how a message lays its parts out — which calls fold
+// into a group and at what index — so every part renderer and ui primitive
+// is a marker. The per-part components have their own tests.
+vi.mock('@core/util/message-send-motion', () => ({
+ messageSendMotion: () => {},
+}));
+vi.mock('@ui', () => ({
+ UserMessageBubble: (props: { children: JSX.Element }) => (
+ <div data-testid="bubble">{props.children}</div>
+ ),
+}));
+vi.mock('./parts/TextPart', () => ({
+ TextPart: (props: { text: string }) => <p data-testid="text">{props.text}</p>,
+}));
+vi.mock('./parts/ToolCallPart', () => ({
+ ToolCallPart: (props: {
+ part: { id: string };
+ context: { partIndex: number };
+ }) => (
+ <div data-index={props.context.partIndex} data-testid="tool">
+ {props.part.id}
+ </div>
+ ),
+}));
+vi.mock('./parts/PermissionPart', () => ({
+ PermissionPart: () => <div data-testid="permission" />,
+}));
+vi.mock('./parts/PlanPart', () => ({ PlanPart: () => null }));
+vi.mock('./parts/ControlPart', () => ({ ControlPart: () => null }));
+vi.mock('./parts/ElicitationPart', () => ({ ElicitationPart: () => null }));
+vi.mock('../ui', () => ({
+ isToolActive: (status: string) =>
+ status === 'pending' || status === 'running',
+ Thought: (props: { text: string }) => (
+ <div data-testid="thought">{props.text}</div>
+ ),
+ WorkingLine: () => <div data-testid="working" />,
+ ActionLine: (props: { label: string }) => <div>{props.label}</div>,
+ ToolGroup: (props: {
+ count: number;
+ active: boolean;
+ latest: { label: string; detail?: string };
+ children: JSX.Element;
+ }) => (
+ <div
+ data-active={String(props.active)}
+ data-count={props.count}
+ data-latest={`${props.latest.label}${props.latest.detail ? ` · ${props.latest.detail}` : ''}`}
+ data-testid="group"
+ >
+ {props.children}
+ </div>
+ ),
+}));
+
+afterEach(cleanup);
+
+const text = (value: string): MessagePart => ({ kind: 'text', text: value });
+const tool = (
+ id: string,
+ overrides?: Partial<Extract<MessagePart, { kind: 'tool_use' }>>
+): MessagePart => ({
+ kind: 'tool_use',
+ id,
+ name: { kind: 'native', name: 'Read' },
+ status: 'completed',
+ detail: { kind: 'read', paths: [`${id}.rs`] },
+ ...overrides,
+});
+const permission = (toolCall: string): MessagePart => ({
+ kind: 'permission',
+ toolCall,
+ options: [],
+ outcome: { kind: 'pending' },
+});
+const message = (
+ parts: MessagePart[],
+ stop: FoldedMessage['stop'] = { kind: 'end_turn' }
+): FoldedMessage => ({
+ agentSessionId: 'session',
+ requestId: null,
+ turn: 0,
+ author: { kind: 'agent' },
+ parts,
+ stop,
+});
+
+describe('Message tool grouping', () => {
+ it('folds consecutive tool calls into one group, keeping their indices', () => {
+ const view = render(() => (
+ <Message
+ message={message([
+ text('Looking.'),
+ tool('read'),
+ tool('edit'),
+ tool('bash', {
+ name: { kind: 'native', name: 'Bash' },
+ detail: {
+ kind: 'terminal',
+ command: 'cargo test',
+ output: null,
+ exitCode: 0,
+ },
+ }),
+ text('Done.'),
+ ])}
+ />
+ ));
+ const group = view.getByTestId('group');
+ expect(group.dataset.count).toBe('3');
+ expect(group.dataset.active).toBe('false');
+ expect(group.dataset.latest).toBe('Bash · cargo test');
+ expect(view.getAllByTestId('tool').map((el) => el.dataset.index)).toEqual([
+ '1',
+ '2',
+ '3',
+ ]);
+ expect(view.getAllByTestId('text').map((el) => el.textContent)).toEqual([
+ 'Looking.',
+ 'Done.',
+ ]);
+ });
+
+ it('leaves a lone tool call as its own card', () => {
+ const view = render(() => (
+ <Message message={message([text('Looking.'), tool('read')])} />
+ ));
+ expect(view.queryByTestId('group')).toBeNull();
+ expect(view.getByTestId('tool').dataset.index).toBe('1');
+ });
+
+ it('breaks a run at a permission prompt', () => {
+ const view = render(() => (
+ <Message
+ message={message([
+ tool('a'),
+ tool('b'),
+ permission('b'),
+ tool('c'),
+ tool('d'),
+ ])}
+ />
+ ));
+ expect(view.getAllByTestId('group').map((el) => el.dataset.count)).toEqual([
+ '2',
+ '2',
+ ]);
+ expect(view.getByTestId('permission')).toBeTruthy();
+ });
+
+ it('reads as active while a call in the run is still running', () => {
+ const view = render(() => (
+ <Message
+ message={message([tool('a'), tool('b', { status: 'running' })], null)}
+ />
+ ));
+ expect(view.getByTestId('group').dataset.active).toBe('true');
+ });
+
+ it('keeps the group mounted as streamed calls extend the run', () => {
+ const [store, setStore] = createStore({
+ message: message([text('Looking.'), tool('a'), tool('b')], null),
+ });
+ const view = render(() => <Message message={store.message} />);
+ const group = view.getByTestId('group');
+ expect(group.dataset.count).toBe('2');
+
+ setStore(
+ 'message',
+ reconcile(
+ message([text('Looking.'), tool('a'), tool('b'), tool('c')], null)
+ )
+ );
+ expect(view.getByTestId('group')).toBe(group);
+ expect(group.dataset.count).toBe('3');
+ expect(group.dataset.latest).toBe('Read · c.rs');
+ expect(view.getAllByTestId('tool').map((el) => el.dataset.index)).toEqual([
+ '1',
+ '2',
+ '3',
+ ]);
+ });
+
+ it('promotes a lone call to a group when a second follows it', () => {
+ const [store, setStore] = createStore({
+ message: message([text('Looking.'), tool('a')], null),
+ });
+ const view = render(() => <Message message={store.message} />);
+ expect(view.queryByTestId('group')).toBeNull();
+ const prose = view.getByTestId('text');
+
+ setStore(
+ 'message',
+ reconcile(message([text('Looking.'), tool('a'), tool('b')], null))
+ );
+ expect(view.getByTestId('group').dataset.count).toBe('2');
+ expect(view.getByTestId('text')).toBe(prose);
+ });
+});
diff --git a/apps/web/src/features/block-agent/component/AgentMessage.tsx b/apps/web/src/features/block-agent/component/AgentMessage.tsx
index 8b73c7ad4b..83e433c1f9 100644
--- a/apps/web/src/features/block-agent/component/AgentMessage.tsx
+++ b/apps/web/src/features/block-agent/component/AgentMessage.tsx
@@ -11,14 +11,22 @@ import type {
MessagePart,
} from '@service-agent-fold/generated/types';
import { UserMessageBubble } from '@ui';
-import { For, type JSX, Show } from 'solid-js';
+import { For, Index, type JSX, Show } from 'solid-js';
import { match } from 'ts-pattern';
import { isControlMessage } from '../state/control-message';
-import { ActionLine, Thought, WorkingLine } from '../ui';
+import { segmentParts } from '../state/tool-groups';
+import {
+ ActionLine,
+ isToolActive,
+ Thought,
+ ToolGroup,
+ WorkingLine,
+} from '../ui';
import { ControlPart } from './parts/ControlPart';
import { ElicitationPart } from './parts/ElicitationPart';
import { PermissionPart } from './parts/PermissionPart';
import { PlanPart } from './parts/PlanPart';
+import { type ToolUsePart, toolCallDetail, toolLabel } from './parts/shared';
import { TextPart } from './parts/TextPart';
import { ToolCallPart } from './parts/ToolCallPart';
@@ -57,6 +65,50 @@ function AgentMessagePart(props: {
.exhaustive();
}
+/**
+ * A run of consecutive tool calls (see `segmentParts`), folded to one row
+ * that opens to the calls themselves, each at its original part index.
+ */
+function ToolGroupPart(props: {
+ message: FoldedMessage;
+ start: number;
+ /** Exclusive. */
+ end: number;
+ inFlight: boolean;
+}): JSX.Element {
+ const calls = () =>
+ props.message.parts
+ .slice(props.start, props.end)
+ .filter((part): part is ToolUsePart => part.kind === 'tool_use');
+ const active = () => calls().some((call) => isToolActive(call.status));
+
+ return (
+ <Show when={calls().at(-1)}>
+ {(latest) => (
+ <ToolGroup
+ count={calls().length}
+ active={active()}
+ latest={{
+ label: toolLabel(latest().name),
+ detail: toolCallDetail(latest()),
+ }}
+ >
+ <For each={calls()}>
+ {(part, offset) => (
+ <AgentMessagePart
+ part={part}
+ message={props.message}
+ index={props.start + offset()}
+ inFlight={props.inFlight}
+ />
+ )}
+ </For>
+ </ToolGroup>
+ )}
+ </Show>
+ );
+}
+
/**
* Whether an open turn should show the working row at its tail.
*
@@ -126,16 +178,35 @@ export function Message(props: { message: FoldedMessage }) {
}
fallback={
<div class="flex flex-col gap-1 min-w-0">
- <For each={props.message.parts}>
- {(part, index) => (
- <AgentMessagePart
- part={part}
- message={props.message}
- index={index()}
- inFlight={inFlight()}
- />
+ {/* Segments are positional, and a run at the tail grows as calls
+ stream in — so rows are keyed by index, not by segment value,
+ and a group keeps its open state while it fills. */}
+ <Index each={segmentParts(props.message.parts)}>
+ {(segment) => (
+ <Show
+ when={segment().kind === 'tools'}
+ fallback={
+ <Show when={props.message.parts[segment().start]}>
+ {(part) => (
+ <AgentMessagePart
+ part={part()}
+ message={props.message}
+ index={segment().start}
+ inFlight={inFlight()}
+ />
+ )}
+ </Show>
+ }
+ >
+ <ToolGroupPart
+ message={props.message}
+ start={segment().start}
+ end={segment().end}
+ inFlight={inFlight()}
+ />
+ </Show>
)}
- </For>
+ </Index>
{/* The turn is open with nothing to read yet — a dot and a rotating
verb, so the wait reads as work rather than as a stall. */}
<Show when={inFlight() && showsWorkingLine(props.message)}>
diff --git a/apps/web/src/features/block-agent/component/parts/ToolCallPart.tsx b/apps/web/src/features/block-agent/component/parts/ToolCallPart.tsx
index d82664af00..ad07735fec 100644
--- a/apps/web/src/features/block-agent/component/parts/ToolCallPart.tsx
+++ b/apps/web/src/features/block-agent/component/parts/ToolCallPart.tsx
@@ -9,7 +9,6 @@
* tool from its title.
*/
-import type { MessagePart } from '@service-agent-fold/generated/types';
import type { JSX } from 'solid-js';
import { match } from 'ts-pattern';
import { EditToolCall } from './EditToolCall';
@@ -18,12 +17,15 @@ import { OutputToolCall } from './OutputToolCall';
import { PathsToolCall } from './PathsToolCall';
import { SearchToolCall } from './SearchToolCall';
import { SubagentToolCall } from './SubagentToolCall';
-import { type ToolCallCommon, type ToolCallContext, toolLabel } from './shared';
+import {
+ type ToolCallCommon,
+ type ToolCallContext,
+ type ToolUsePart,
+ toolLabel,
+} from './shared';
import { TerminalToolCall } from './TerminalToolCall';
import { UserToolCall } from './UserToolCall';
-type ToolUsePart = Extract<MessagePart, { kind: 'tool_use' }>;
-
export function ToolCallPart(props: {
part: ToolUsePart;
/** Where the part sits, for the chat components Macro tools render with. */
diff --git a/apps/web/src/features/block-agent/component/parts/shared.ts b/apps/web/src/features/block-agent/component/parts/shared.ts
index 7dd2452ff4..53ff547d60 100644
--- a/apps/web/src/features/block-agent/component/parts/shared.ts
+++ b/apps/web/src/features/block-agent/component/parts/shared.ts
@@ -5,10 +5,16 @@
* row-level facts every card shares.
*/
-import type { ToolName } from '@service-agent-fold/generated/types';
+import type {
+ MessagePart,
+ ToolName,
+} from '@service-agent-fold/generated/types';
import type { JSX } from 'solid-js';
+import { match } from 'ts-pattern';
import type { ToolStatus } from '../../ui';
+export type ToolUsePart = Extract<MessagePart, { kind: 'tool_use' }>;
+
/**
* Where a part sits in its transcript, for the chat components a Macro tool
* renders with: they key per-call state by chat, message, and part, and the
@@ -51,3 +57,24 @@ export function pathsSubtitle(paths: string[]): string | undefined {
if (paths.length === 1) return paths[0];
return `${paths.length} files`;
}
+
+/**
+ * What a call touched, in a word — the subtitle its card would show, for the
+ * one-line summary a collapsed group gives its latest call.
+ */
+export function toolCallDetail(part: ToolUsePart): string | undefined {
+ return match(part.detail)
+ .with({ kind: 'terminal' }, (detail) => detail.command ?? undefined)
+ .with({ kind: 'edit' }, (detail) =>
+ pathsSubtitle(detail.diffs.map((diff) => diff.path))
+ )
+ .with(
+ { kind: 'read' },
+ { kind: 'delete' },
+ { kind: 'move' },
+ { kind: 'search' },
+ (detail) => pathsSubtitle(detail.paths)
+ )
+ .with({ kind: 'subagent' }, (detail) => detail.title)
+ .otherwise(() => undefined);
+}
diff --git a/apps/web/src/features/block-agent/debug/Gallery.tsx b/apps/web/src/features/block-agent/debug/Gallery.tsx
index a00c50bf4c..fb864f6a8a 100644
--- a/apps/web/src/features/block-agent/debug/Gallery.tsx
+++ b/apps/web/src/features/block-agent/debug/Gallery.tsx
@@ -36,6 +36,7 @@ import {
TodoList,
ToolCard,
ToolErrorCard,
+ ToolGroup,
ToolStatusTitle,
} from '../ui';
@@ -634,6 +635,39 @@ export default function AgentUiGallery() {
</ToolCard>
</Item>
+ <Item label="ToolGroup (active / settled)">
+ <ToolGroup
+ count={3}
+ active={pulse()}
+ latest={{ label: 'Bash', detail: 'cargo test -p agent_fold' }}
+ >
+ <ToolCard
+ title="Read"
+ subtitle="crates/agent_fold/src/domain/fold.rs"
+ status="completed"
+ />
+ <ToolCard
+ title="Edit"
+ subtitle={FIXTURE_DIFF.path}
+ status="completed"
+ />
+ <ToolCard
+ title="Bash"
+ subtitle="cargo test -p agent_fold"
+ status={pulse() ? 'running' : 'completed'}
+ />
+ </ToolGroup>
+ <ToolGroup
+ count={2}
+ active={false}
+ latest={{ label: 'ReadContent' }}
+ defaultOpen
+ >
+ <ToolCard title="NameSearch" subtitle="fold" status="completed" />
+ <ToolCard title="ReadContent" status="completed" />
+ </ToolGroup>
+ </Item>
+
<Item label="Thought (active / settled)">
<Thought
text="The batch fold re-derives every message per frame; the incremental machine already handles this."
diff --git a/apps/web/src/features/block-agent/state/tool-groups.test.ts b/apps/web/src/features/block-agent/state/tool-groups.test.ts
new file mode 100644
index 0000000000..438ed5eacc
--- /dev/null
+++ b/apps/web/src/features/block-agent/state/tool-groups.test.ts
@@ -0,0 +1,65 @@
+import type { MessagePart } from '@service-agent-fold/generated/types';
+import { describe, expect, it } from 'vitest';
+import { segmentParts } from './tool-groups';
+
+const text = (): MessagePart => ({ kind: 'text', text: 'hi' });
+const tool = (): MessagePart => ({
+ kind: 'tool_use',
+ id: 'call',
+ name: { kind: 'native', name: 'Read' },
+ status: 'completed',
+ detail: { kind: 'read', paths: ['a.rs'] },
+});
+const permission = (): MessagePart => ({
+ kind: 'permission',
+ toolCall: 'call',
+ options: [],
+ outcome: { kind: 'pending' },
+});
+
+describe('segmentParts', () => {
+ it('leaves a message without tool calls as one segment per part', () => {
+ expect(segmentParts([text(), text()])).toEqual([
+ { kind: 'part', start: 0, end: 1 },
+ { kind: 'part', start: 1, end: 2 },
+ ]);
+ });
+
+ it('keeps a lone tool call as its own part', () => {
+ expect(segmentParts([text(), tool(), text()])).toEqual([
+ { kind: 'part', start: 0, end: 1 },
+ { kind: 'part', start: 1, end: 2 },
+ { kind: 'part', start: 2, end: 3 },
+ ]);
+ });
+
+ it('folds a run of consecutive tool calls into one group', () => {
+ expect(segmentParts([text(), tool(), tool(), tool(), text()])).toEqual([
+ { kind: 'part', start: 0, end: 1 },
+ { kind: 'tools', start: 1, end: 4 },
+ { kind: 'part', start: 4, end: 5 },
+ ]);
+ });
+
+ it('breaks a run at anything that is not a tool call', () => {
+ // The permission prompt is waiting on the reader; it must stay visible.
+ expect(
+ segmentParts([tool(), tool(), permission(), tool(), tool()])
+ ).toEqual([
+ { kind: 'tools', start: 0, end: 2 },
+ { kind: 'part', start: 2, end: 3 },
+ { kind: 'tools', start: 3, end: 5 },
+ ]);
+ });
+
+ it('groups a run that closes the message', () => {
+ expect(segmentParts([text(), tool(), tool()])).toEqual([
+ { kind: 'part', start: 0, end: 1 },
+ { kind: 'tools', start: 1, end: 3 },
+ ]);
+ });
+
+ it('is empty for no parts', () => {
+ expect(segmentParts([])).toEqual([]);
+ });
+});
diff --git a/apps/web/src/features/block-agent/state/tool-groups.ts b/apps/web/src/features/block-agent/state/tool-groups.ts
new file mode 100644
index 0000000000..048fb45971
--- /dev/null
+++ b/apps/web/src/features/block-agent/state/tool-groups.ts
@@ -0,0 +1,36 @@
+/**
+ * Where a message's parts fold for display: a run of two or more consecutive
+ * tool calls reads as one collapsed row (`ui/ToolGroup`), everything else as
+ * itself. A lone call stays a card of its own — a group of one would hide the
+ * call behind a count that says nothing the card did not.
+ *
+ * Segments are half-open index ranges into the parts array, so a grouped call
+ * keeps its position for the tool render context.
+ */
+
+import type { MessagePart } from '@service-agent-fold/generated/types';
+
+export type PartSegment = {
+ kind: 'part' | 'tools';
+ start: number;
+ /** Exclusive. A `part` segment spans exactly one index. */
+ end: number;
+};
+
+export function segmentParts(parts: readonly MessagePart[]): PartSegment[] {
+ const segments: PartSegment[] = [];
+ let start = 0;
+ while (start < parts.length) {
+ let end = start + 1;
+ if (parts[start]?.kind === 'tool_use') {
+ while (parts[end]?.kind === 'tool_use') end += 1;
+ }
+ segments.push({
+ kind: end - start >= 2 ? 'tools' : 'part',
+ start,
+ end,
+ });
+ start = end;
+ }
+ return segments;
+}
diff --git a/apps/web/src/features/block-agent/ui/ToolGroup.test.tsx b/apps/web/src/features/block-agent/ui/ToolGroup.test.tsx
new file mode 100644
index 0000000000..c132648fd1
--- /dev/null
+++ b/apps/web/src/features/block-agent/ui/ToolGroup.test.tsx
@@ -0,0 +1,61 @@
+/** @vitest-environment jsdom */
+
+import { cleanup, render } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { ToolGroup } from './ToolGroup';
+
+vi.mock('@phosphor/caret-right.svg', () => ({
+ default: () => <svg data-testid="caret" />,
+}));
+
+afterEach(cleanup);
+
+function mount(overrides?: { active?: boolean; defaultOpen?: boolean }) {
+ return render(() => (
+ <ToolGroup
+ count={3}
+ active={overrides?.active ?? false}
+ defaultOpen={overrides?.defaultOpen}
+ latest={{ label: 'Bash', detail: 'cargo test -p agent_fold' }}
+ >
+ <div data-testid="call">Read</div>
+ <div data-testid="call">Edit</div>
+ <div data-testid="call">Bash</div>
+ </ToolGroup>
+ ));
+}
+
+describe('ToolGroup', () => {
+ it('starts closed, counting the calls and naming the latest one', () => {
+ const view = mount();
+ expect(view.getByRole('button').textContent).toContain('Called 3 tools');
+ expect(view.getByRole('button').getAttribute('aria-expanded')).toBe(
+ 'false'
+ );
+ expect(view.container.textContent).toContain('Bash');
+ expect(view.container.textContent).toContain('cargo test -p agent_fold');
+ expect(view.queryAllByTestId('call')).toHaveLength(0);
+ });
+
+ it('opens on click, swapping the latest line for the calls', () => {
+ const view = mount();
+ view.getByRole('button').click();
+ expect(view.getByRole('button').getAttribute('aria-expanded')).toBe('true');
+ expect(view.getAllByTestId('call')).toHaveLength(3);
+ expect(view.container.textContent).not.toContain(
+ 'cargo test -p agent_fold'
+ );
+ view.getByRole('button').click();
+ expect(view.queryAllByTestId('call')).toHaveLength(0);
+ });
+
+ it('reads as in progress while a call is still running', () => {
+ const view = mount({ active: true });
+ expect(view.getByRole('button').textContent).toContain('Calling 3 tools');
+ });
+
+ it('can start open', () => {
+ const view = mount({ defaultOpen: true });
+ expect(view.getAllByTestId('call')).toHaveLength(3);
+ });
+});
diff --git a/apps/web/src/features/block-agent/ui/ToolGroup.tsx b/apps/web/src/features/block-agent/ui/ToolGroup.tsx
new file mode 100644
index 0000000000..caba18aeac
--- /dev/null
+++ b/apps/web/src/features/block-agent/ui/ToolGroup.tsx
@@ -0,0 +1,66 @@
+/**
+ * A run of consecutive tool calls folded to one row: how many, and — while
+ * closed — the latest one in a quiet line beneath, so a reader following a
+ * long stretch of tool use sees what the agent is on without a card per call.
+ *
+ * Shaped like `Thought` rather than `ToolCard`: a bare caret row, no surface,
+ * because the cards themselves appear once it opens.
+ */
+
+import CaretRight from '@phosphor/caret-right.svg';
+import { createSignal, type JSX, Show } from 'solid-js';
+import { TextShimmer } from './TextShimmer';
+
+export interface ToolGroupProps {
+ count: number;
+ /** A call in the run is still in flight: reads "Calling" and shimmers. */
+ active: boolean;
+ /** The most recent call: its label and, when it has one, what it touched. */
+ latest: { label: string; detail?: string };
+ defaultOpen?: boolean;
+ /** The calls themselves, shown in place of the latest line once open. */
+ children: JSX.Element;
+}
+
+export function ToolGroup(props: ToolGroupProps) {
+ const [expanded, setExpanded] = createSignal(props.defaultOpen ?? false);
+ const title = () =>
+ `${props.active ? 'Calling' : 'Called'} ${props.count} tools`;
+
+ return (
+ <div class="min-w-0 text-xs leading-5 text-ink-extra-muted">
+ <button
+ type="button"
+ aria-expanded={expanded()}
+ class="flex min-h-7 items-center gap-1 py-1 text-left text-ink-extra-muted hover:text-ink-muted"
+ onClick={() => setExpanded((prev) => !prev)}
+ >
+ <CaretRight
+ class="size-4 shrink-0 transition-transform motion-reduce:transition-none"
+ classList={{ 'rotate-90': expanded() }}
+ />
+ <TextShimmer text={title()} active={props.active} />
+ </button>
+ <Show
+ when={expanded()}
+ fallback={
+ <div class="flex min-w-0 items-center gap-1.5 pl-5 text-ink-placeholder">
+ <span class="shrink-0">{props.latest.label}</span>
+ <Show when={props.latest.detail}>
+ {(detail) => (
+ <>
+ <span aria-hidden="true" class="shrink-0">
+ ·
+ </span>
+ <span class="min-w-0 truncate font-mono">{detail()}</span>
+ </>
+ )}
+ </Show>
+ </div>
+ }
+ >
+ <div class="flex min-w-0 flex-col gap-1 pl-5">{props.children}</div>
+ </Show>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/block-agent/ui/index.ts b/apps/web/src/features/block-agent/ui/index.ts
index d1d4eef7cf..30bbcaeff2 100644
--- a/apps/web/src/features/block-agent/ui/index.ts
+++ b/apps/web/src/features/block-agent/ui/index.ts
@@ -45,6 +45,7 @@ export { Thought, type ThoughtProps } from './Thought';
export { TodoList } from './TodoList';
export { ToolCard, type ToolCardProps } from './ToolCard';
export { ToolErrorCard, type ToolErrorCardProps } from './ToolErrorCard';
+export { ToolGroup, type ToolGroupProps } from './ToolGroup';
export {
ToolStatusTitle,
type ToolStatusTitleProps,