Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(agents): restore peek window for code-mode SDK activity (#8531)
Wolf Mermelstein8e0aeddc44cc
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 07ef17b2fd..e0e574a81d 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -164,6 +164,8 @@ ownership. Cancel, logout, and the ten-minute timeout retire pending callbacks.- Diagnose native full reloads with `native_webview_started`, `native_diagnostic_recovered`, and the shared `frontend_instance_id`; use `reloadApp(reason)` for frontend reloads and keep breadcrumbs content-free. Treat `previous_document_*` checkpoints as last-observed lifecycle evidence, never a crash verdict; clear them on logout. `previous_document_last_*` comes from the native navigation breadcrumb (route and entity type, never ids). See [frontend checkpoints](docs/native-reload-diagnostics.md) and `tauri/src-tauri/README.md`.- Inline agent steps reuse the session code-execution query for live SDK operationnames; completed step snapshots come from the shared fold of the tool receipt.+ Session `ExecuteCode` activity uses the same Calling N tools peek window as+ ordinary consecutive tool calls.- All API/network calls live in service-clients.- Open projects through `openProject` (`features/projects/open-project.ts`): itretargets an already-open project split to the section or comment in place.diff --git a/apps/web/src/features/block-agent/component/parts/CodeExecutionToolCall.tsx b/apps/web/src/features/block-agent/component/parts/CodeExecutionToolCall.tsxindex 552d2c0c47..4e6ec2658c 100644--- a/apps/web/src/features/block-agent/component/parts/CodeExecutionToolCall.tsx+++ b/apps/web/src/features/block-agent/component/parts/CodeExecutionToolCall.tsx@@ -1,10 +1,12 @@import CodeIcon from '@phosphor/code.svg';import type {+ ExecutionActivity,ExecutionRecord,RecordedToolCall,} from '@service-agent-harness/generated/schemas';-import { createMemo, For, Show } from 'solid-js';+import { For, Show } from 'solid-js';import { isToolActive, ToolCard, type ToolStatus } from '../../ui';+import { LiveToolGroup } from '../../views/LiveToolGroup';import { DisplayResultsToolCall } from './DisplayResultsToolCall';import { MacroToolCall } from './MacroToolCall';import type { ToolCallCommon, ToolCallContext } from './shared';@@ -19,40 +21,19 @@ export function CodeExecutionToolCall(props: {unavailable: boolean;}) {const calls = () => props.record?.calls ?? [];+ const activity = () => props.record?.activity ?? [];const errorVisible = () =>Boolean(props.error &&(props.record?.status !== 'running' ||!isToolActive(props.common.status)));- const activity = createMemo(() => {- const groups = new Map<- string,- {- label: string;- completed: number;- running: number;- failed: number;- unknown: number;- }- >();- for (const item of props.record?.activity ?? []) {- const group = groups.get(item.label) ?? {- label: item.label,- completed: 0,- running: 0,- failed: 0,- unknown: 0,- };- const status =- item.status === 'running' && !isToolActive(props.common.status)- ? 'unknown'- : item.status;- group[status] += 1;- groups.set(item.label, group);- }- return [...groups.values()];- });+ const activeIndex = () =>+ isToolActive(props.common.status)+ ? activity().findIndex((item) => item.status === 'running')+ : -1;+ const active = () => activeIndex() !== -1;+return (<div class="min-w-0" data-code-execution={props.record?.executionId}><Show when={activity().length === 0 || errorVisible()}>@@ -76,28 +57,24 @@ export function CodeExecutionToolCall(props: {</Show></ToolCard></Show>- <For each={activity()}>- {(group) => (- <ToolCard- title={group.label}- status={- group.running > 0- ? 'running'- : group.failed > 0- ? 'failed'- : 'completed'- }- trailing={[- group.completed && `${group.completed} completed`,- group.running && `${group.running} running`,- group.failed && `${group.failed} failed`,- group.unknown && `${group.unknown} outcome unknown`,- ]- .filter(Boolean)- .join(' · ')}- />- )}- </For>+ <Show when={activity().length > 0}>+ <LiveToolGroup+ count={activity().length}+ active={active()}+ activeIndex={active() ? activeIndex() : undefined}+ >+ <For each={activity()}>+ {(item) => (+ <div class="min-h-8 shrink-0">+ <ActivityRow+ item={item}+ turnActive={isToolActive(props.common.status)}+ />+ </div>+ )}+ </For>+ </LiveToolGroup>+ </Show><Show when={props.record?.activityTruncated}><p class="text-xs text-ink-extra-muted">Activity list limited to the first 128 requests.@@ -139,6 +116,27 @@ export function CodeExecutionToolCall(props: {);}+function ActivityRow(props: { item: ExecutionActivity; turnActive: boolean }) {+ const status = (): ToolStatus => {+ if (props.item.status === 'failed') return 'failed';+ if (props.item.status === 'running' && props.turnActive) return 'running';+ if (props.item.status === 'completed') return 'completed';+ // Unfinished ops after the turn ends, or an unknown outcome.+ return 'completed';+ };+ const uncertain = () =>+ props.item.status === 'unknown' ||+ (props.item.status === 'running' && !props.turnActive);+ return (+ <ToolCard+ title={props.item.label}+ status={status()}+ muted={uncertain()}+ trailing={uncertain() ? 'Outcome unknown' : undefined}+ />+ );+}+function RecordedCall(props: {call: RecordedToolCall;context: ToolCallContext;diff --git a/apps/web/src/features/block-agent/component/parts/ToolCallPart.test.tsx b/apps/web/src/features/block-agent/component/parts/ToolCallPart.test.tsxindex 729ee80986..027d6aeb3c 100644--- a/apps/web/src/features/block-agent/component/parts/ToolCallPart.test.tsx+++ b/apps/web/src/features/block-agent/component/parts/ToolCallPart.test.tsx@@ -1408,6 +1408,17 @@ describe('coding agent dispatch', () => {});describe('code execution results', () => {+ beforeEach(() => {+ vi.stubGlobal(+ 'ResizeObserver',+ class {+ observe() {}+ unobserve() {}+ disconnect() {}+ }+ );+ });+const executionId = '019a0000-0000-7000-8000-000000000001';const codePart = (server: string): ToolUsePart => ({kind: 'tool_use',@@ -1471,7 +1482,7 @@ describe('code execution results', () => {};});- it('hides source and shows observed parallel operation counts', () => {+ it('hides source and folds observed SDK ops into the peek window', () => {codeQuery.record = {...codeQuery.record!,activity: [@@ -1490,42 +1501,61 @@ describe('code execution results', () => {expect(rendered.container.textContent).not.toContain('return { count: 1 };');- const rows = rendered.getAllByTestId('tool-card');- const classification = rows.find((row) =>- row.textContent?.includes('Classify content')- );- expect(classification?.textContent).toContain(- '1 completed · 1 outcome unknown'- );- expect(classification?.dataset.status).toBe('completed');- const read = rows.find((row) =>- row.textContent?.includes('Read documents')- );- expect(read?.textContent).toContain('1 failed');- expect(read?.dataset.status).toBe('failed');+ const group = rendered.getByRole('button', { name: /Called 3 tools/ });+ expect(group.getAttribute('aria-expanded')).toBe('false');+ expect(+ rendered+ .queryAllByTestId('tool-card')+ .filter((row) =>+ /Classify content|Read documents/.test(row.textContent ?? '')+ )+ ).toHaveLength(0);++ group.click();+ expect(group.getAttribute('aria-expanded')).toBe('true');+ const activity = rendered+ .getAllByTestId('tool-card')+ .filter((row) =>+ /Classify content|Read documents/.test(row.textContent ?? '')+ );+ expect(activity).toHaveLength(3);+ expect(activity[0].textContent).toContain('Classify content');+ expect(activity[0].dataset.status).toBe('completed');+ expect(activity[1].textContent).toContain('Outcome unknown');+ expect(activity[2].dataset.status).toBe('failed');expect(rendered.container.textContent).not.toContain('API calls');expect(rendered.container.textContent).toContain('first 128 requests');});- it('shows active SDK operations as tool rows without an extra wrapper', () => {+ it('opens the peek window for live SDK operations', () => {+ vi.useFakeTimers();codeQuery.record = {...codeQuery.record!,status: 'running',error: null,calls: [],- activity: [{ id: 1, label: 'Browse workspace', status: 'running' }],+ activity: [+ { id: 1, label: 'Browse workspace', status: 'completed' },+ { id: 2, label: 'Search email', status: 'running' },+ ],};const part = codePart('macro_internal');part.status = 'running';const rendered = render(() => (<ToolCallPart part={part} context={context(true)} />));+ const group = rendered.getByRole('button');+ expect(group.textContent).toContain('Calling 2 tools');+ expect(rendered.container.textContent).not.toContain('Workspace activity');+ vi.advanceTimersByTime(150);+ expect(group.getAttribute('aria-expanded')).toBe('true');const rows = rendered.getAllByTestId('tool-card');- expect(rows).toHaveLength(1);+ expect(rows).toHaveLength(2);expect(rows[0].textContent).toContain('Browse workspace');- expect(rows[0].textContent).toContain('1 running');- expect(rows[0].dataset.status).toBe('running');- expect(rendered.container.textContent).not.toContain('Workspace activity');+ expect(rows[0].dataset.status).toBe('completed');+ expect(rows[1].textContent).toContain('Search email');+ expect(rows[1].dataset.status).toBe('running');+ vi.useRealTimers();});it('loads trusted records and keeps custom components after a script failure', () => {diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.mdindex d141dc77c4..7fb709ad33 100644--- a/docs/agent-guide/ai-chat.md+++ b/docs/agent-guide/ai-chat.md@@ -908,13 +908,14 @@ promises are supported. Preserve the user's source filters, source IDs, errors,and coverage limits; stopping a paginated iterator does not prove exhaustiveness.Code execution hides program source and raw returned JSON. Observed SDK operations-use the same compact tool rows as ordinary tools, with an icon, operation name,-and right-aligned completed, running, failed, or unknown counts. Repeated operations-share a row; there is no separate API-call count wrapper once activity is available.-Activity refreshes about once per second while a run is active, survives reload,-and is capped at the first 128 requests. These are advisory observations, not-confirmation that a user approved an action. Results appear in the agent's answer-or dedicated review components. Desktop email drafts keep Cc/Bcc controls beside To;+use the same **Calling N tools** peek window as ordinary consecutive tool calls:+each request is its own compact row (label plus status), live runs open the+five-row scrolling window, and settled runs collapse to the count. There is no+separate API-call count wrapper or per-label aggregation once activity is+available. Activity refreshes about once per second while a run is active,+survives reload, and is capped at the first 128 requests. These are advisory+observations, not confirmation that a user approved an action. Results appear in+the agent's answer or dedicated review components. Desktop email drafts keep Cc/Bcc controls beside To;the sender row appears only when it has a sender address, inbox picker, or notice.Inline email drafts on phones use normal card padding without reserving a page-header gap.Source remains in saved execution records and@@ -1390,7 +1391,8 @@ before collapsing smoothly. These delays are shared by the group, never queuedper call, and do not delay answer text or tool execution. Manually opening,closing, or interacting with a group overrides automatic collapse. Subagentsand tools requiring user input remain outside these groups so they stay visible-during other tool bursts. Nested agent activity has its own scrollable window.+during other tool bursts. Nested agent activity and code-mode SDK operations each+use the same peek window.The group caret sits immediately after its label and appears on hover or keyboardfocus. Expand an edit row to view its diffs. Result bodies load only when their