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.

fix: diffs cause hang (#6440)

Eric Hayesf03d01474271
diff --git a/apps/web/src/features/block-agent/component/parts/EditToolCall.tsx b/apps/web/src/features/block-agent/component/parts/EditToolCall.tsx
index 13c6b2fd30..a543f0d2f7 100644
--- a/apps/web/src/features/block-agent/component/parts/EditToolCall.tsx
+++ b/apps/web/src/features/block-agent/component/parts/EditToolCall.tsx
@@ -19,6 +19,7 @@ export function EditToolCall(props: {
trailing={props.common.trailing ?? <DiffChanges {...changes()} />}
status={props.common.status}
muted={props.common.muted}
+ hasContent={props.detail.diffs.length > 0}
>
<Show when={props.detail.diffs.length > 0}>
<PierreDiff diffs={props.detail.diffs} />
diff --git a/apps/web/src/features/block-agent/component/parts/ElicitationPart.tsx b/apps/web/src/features/block-agent/component/parts/ElicitationPart.tsx
index 3ac8c51ddc..1ba9dc21ab 100644
--- a/apps/web/src/features/block-agent/component/parts/ElicitationPart.tsx
+++ b/apps/web/src/features/block-agent/component/parts/ElicitationPart.tsx
@@ -223,6 +223,7 @@ function ResolvedQuestion(props: { part: ElicitationPartData }) {
status={props.part.outcome.kind === 'errored' ? 'failed' : 'completed'}
muted={props.part.outcome.kind === 'errored'}
trailing={<span class="text-ink">{outcomeLabel(props.part)}</span>}
+ hasContent={shown().length > 0 || Boolean(refusal())}
>
<Show when={shown().length > 0 || refusal()}>
<div class="flex flex-col gap-2 py-1">
diff --git a/apps/web/src/features/block-agent/component/parts/MacroToolCall.tsx b/apps/web/src/features/block-agent/component/parts/MacroToolCall.tsx
index 21c5cedda1..0f03a44983 100644
--- a/apps/web/src/features/block-agent/component/parts/MacroToolCall.tsx
+++ b/apps/web/src/features/block-agent/component/parts/MacroToolCall.tsx
@@ -101,6 +101,11 @@ function GenericMacroToolCall(props: {
status={props.common.status}
muted={props.common.muted}
trailing={props.common.trailing}
+ hasContent={
+ props.detail.input != null ||
+ props.detail.output != null ||
+ Boolean(props.detail.error)
+ }
>
<Show when={body()}>{(text) => <FoldedOutput text={text()} />}</Show>
</ToolCard>
diff --git a/apps/web/src/features/block-agent/component/parts/OutputToolCall.tsx b/apps/web/src/features/block-agent/component/parts/OutputToolCall.tsx
index 1213f4184a..116b6a2e87 100644
--- a/apps/web/src/features/block-agent/component/parts/OutputToolCall.tsx
+++ b/apps/web/src/features/block-agent/component/parts/OutputToolCall.tsx
@@ -19,6 +19,7 @@ export function OutputToolCall(props: {
status={props.common.status}
muted={props.common.muted}
trailing={props.common.trailing}
+ hasContent={Boolean(props.detail.output)}
>
<Show when={props.detail.output}>
{(output) => <FoldedOutput text={output()} />}
diff --git a/apps/web/src/features/block-agent/component/parts/PathsToolCall.tsx b/apps/web/src/features/block-agent/component/parts/PathsToolCall.tsx
index 3f7fd39562..5d06380e30 100644
--- a/apps/web/src/features/block-agent/component/parts/PathsToolCall.tsx
+++ b/apps/web/src/features/block-agent/component/parts/PathsToolCall.tsx
@@ -16,6 +16,7 @@ export function PathsToolCall(props: {
status={props.common.status}
muted={props.common.muted}
trailing={props.common.trailing}
+ hasContent={props.detail.paths.length > 1}
>
<Show when={props.detail.paths.length > 1}>
<FoldedPathList paths={props.detail.paths} />
diff --git a/apps/web/src/features/block-agent/component/parts/SearchToolCall.tsx b/apps/web/src/features/block-agent/component/parts/SearchToolCall.tsx
index 7578c6dc5d..47d74a9502 100644
--- a/apps/web/src/features/block-agent/component/parts/SearchToolCall.tsx
+++ b/apps/web/src/features/block-agent/component/parts/SearchToolCall.tsx
@@ -16,6 +16,7 @@ export function SearchToolCall(props: {
status={props.common.status}
muted={props.common.muted}
trailing={props.common.trailing}
+ hasContent={Boolean(props.detail.output)}
>
<Show when={props.detail.output}>
{(output) => <FoldedOutput text={output()} />}
diff --git a/apps/web/src/features/block-agent/component/parts/SubagentToolCall.tsx b/apps/web/src/features/block-agent/component/parts/SubagentToolCall.tsx
index 8274c544d7..2b33c0e5f9 100644
--- a/apps/web/src/features/block-agent/component/parts/SubagentToolCall.tsx
+++ b/apps/web/src/features/block-agent/component/parts/SubagentToolCall.tsx
@@ -111,6 +111,7 @@ export function SubagentToolCall(props: {
muted={props.common.muted || props.detail.result?.error != null}
trailing={trailing()}
defaultOpen={props.detail.children.length > 0}
+ hasContent={hasBody()}
>
<Show when={hasBody()}>
<div class="flex flex-col gap-2">
diff --git a/apps/web/src/features/block-agent/component/parts/TerminalToolCall.tsx b/apps/web/src/features/block-agent/component/parts/TerminalToolCall.tsx
index 96ad8d215c..0ff2869ed9 100644
--- a/apps/web/src/features/block-agent/component/parts/TerminalToolCall.tsx
+++ b/apps/web/src/features/block-agent/component/parts/TerminalToolCall.tsx
@@ -16,6 +16,7 @@ export function TerminalToolCall(props: {
status={props.common.status}
muted={props.common.muted}
trailing={props.common.trailing}
+ hasContent={Boolean(props.detail.output)}
>
<Show when={props.detail.output}>
{(output) => (
diff --git a/apps/web/src/features/block-agent/ui/PierreDiff.test.tsx b/apps/web/src/features/block-agent/ui/PierreDiff.test.tsx
new file mode 100644
index 0000000000..5e5d732252
--- /dev/null
+++ b/apps/web/src/features/block-agent/ui/PierreDiff.test.tsx
@@ -0,0 +1,80 @@
+/** @vitest-environment jsdom */
+
+import { cleanup, render as renderComponent } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { PierreDiff } from './PierreDiff';
+
+const mocks = vi.hoisted(() => ({
+ render: vi.fn(),
+ cleanUp: vi.fn(),
+ construct: vi.fn(),
+ pool: {},
+}));
+vi.mock('@pierre/diffs', () => ({
+ FileDiff: class {
+ constructor(...args: unknown[]) {
+ mocks.construct(...args);
+ }
+ render = mocks.render;
+ cleanUp = mocks.cleanUp;
+ setThemeType = vi.fn();
+ },
+}));
+vi.mock('./diff-workers', () => ({
+ useDiffWorkers: () => () => ({ kind: 'ready', pool: mocks.pool }),
+}));
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe('PierreDiff', () => {
+ it('uses the worker pool and isolates same-path edits and streaming revisions', () => {
+ const [newText, setNewText] = createSignal('const value = 2;');
+ const view = renderComponent(() => (
+ <PierreDiff
+ diffs={[
+ { path: 'file.ts', oldText: 'const value = 1;', newText: newText() },
+ {
+ path: 'file.ts',
+ oldText: 'const value = 2;',
+ newText: 'const value = 3;',
+ },
+ { path: 'file.ts', oldText: null, newText: 'const value = 4;' },
+ ]}
+ />
+ ));
+ expect(mocks.construct).toHaveBeenCalledTimes(3);
+ for (const args of mocks.construct.mock.calls) {
+ expect(args[1]).toBe(mocks.pool);
+ }
+ const initialKeys = mocks.render.mock.calls.map(
+ ([args]) => args.newFile.cacheKey
+ );
+ expect(new Set(initialKeys).size).toBe(3);
+ expect(mocks.render.mock.calls[2][0].oldFile).toBeNull();
+ setNewText('const value = 5;');
+ const changed = mocks.render.mock.calls.findLast(
+ ([args]) => args.newFile.contents === 'const value = 5;'
+ );
+ expect(changed).toBeDefined();
+ expect(initialKeys).not.toContain(changed![0].newFile.cacheKey);
+ expect(changed![0].oldFile.cacheKey).not.toBe(changed![0].newFile.cacheKey);
+ view.unmount();
+ expect(mocks.cleanUp.mock.calls.length).toBe(
+ mocks.construct.mock.calls.length
+ );
+ });
+
+ it('retains the size limit for main-thread diff and DOM work', () => {
+ const view = renderComponent(() => (
+ <PierreDiff
+ diffs={[{ path: 'large.ts', oldText: '', newText: '\n'.repeat(2000) }]}
+ />
+ ));
+ expect(view.getByText('large diff (2,001 lines)')).toBeTruthy();
+ expect(mocks.construct).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/web/src/features/block-agent/ui/PierreDiff.tsx b/apps/web/src/features/block-agent/ui/PierreDiff.tsx
index f79fb2a316..d6488fc7b8 100644
--- a/apps/web/src/features/block-agent/ui/PierreDiff.tsx
+++ b/apps/web/src/features/block-agent/ui/PierreDiff.tsx
@@ -10,11 +10,8 @@
* - Entry point: `FileDiff.render({ oldFile, newFile })` — takes raw
* before/after contents directly (`oldFile: null` marks a new file),
* matching our wire shape. No patch parsing on our side.
- * - No worker pool: pierre renders fine on the main thread via its shared
- * shiki highlighter (JS regex engine, no wasm fetch). Tradeoff: shiki
- * tokenization of big files runs on the main thread; the
- * MAX_RENDER_LINES fallback bounds that cost. Wire a WorkerPoolManager
- * (see opencode's pierre/worker.ts) only if profiling demands it.
+ * - Highlighting runs in a shared, lazy worker pool. The line limit also
+ * bounds diff calculation and DOM work, which still run on the main thread.
* - Theme: pierre's built-in `pierre-light`/`pierre-dark` pair (its
* default). Macro flags dark mode via `html[data-theme-light="false"]`
* (see features/theme/signals/themeReactive.ts), so we watch that
@@ -27,6 +24,7 @@ import {
FileDiff as PierreFileDiffInstance,
type ThemeTypes,
} from '@pierre/diffs';
+import type { WorkerPoolManager } from '@pierre/diffs/worker';
import {
createEffect,
createMemo,
@@ -37,12 +35,12 @@ import {
Show,
untrack,
} from 'solid-js';
+import { useDiffWorkers } from './diff-workers';
import type { FileDiff } from './types';
/**
* Files whose before or after side exceeds this many lines get a plain
- * placeholder instead of a rendered diff, keeping main-thread highlighting
- * cost bounded.
+ * placeholder instead of a rendered diff, bounding diff calculation and DOM size.
*/
const MAX_RENDER_LINES = 2000;
@@ -110,6 +108,7 @@ function DiffNote(props: { children: JSX.Element }) {
function PierreFileView(props: {
diff: FileDiff;
themeType: () => 'light' | 'dark';
+ workers: WorkerPoolManager;
}) {
let container!: HTMLDivElement;
let instance: PierreFileDiffInstance | undefined;
@@ -127,15 +126,24 @@ function PierreFileView(props: {
const oldText = props.diff.oldText;
const newText = props.diff.newText;
try {
- instance ??= new PierreFileDiffInstance({
- ...DIFF_OPTIONS,
- themeType: untrack(props.themeType) satisfies ThemeTypes,
- });
+ instance ??= new PierreFileDiffInstance(
+ {
+ ...DIFF_OPTIONS,
+ themeType: untrack(props.themeType) satisfies ThemeTypes,
+ },
+ props.workers
+ );
+ // Paths repeat across edits and sessions. Each content revision needs its
+ // own worker-cache identity, including when an open call streams an update.
+ const revision = crypto.randomUUID();
instance.render({
// `== null` deliberately: the wire declares `oldText: string | null`,
// but crossing the WASM boundary serde turns `None` into `undefined`.
- oldFile: oldText == null ? null : { name, contents: oldText },
- newFile: { name, contents: newText },
+ oldFile:
+ oldText == null
+ ? null
+ : { name, contents: oldText, cacheKey: `${revision}:old` },
+ newFile: { name, contents: newText, cacheKey: `${revision}:new` },
containerWrapper: container,
});
} catch (error) {
@@ -176,6 +184,7 @@ function PierreFileView(props: {
function FileDiffBlock(props: {
diff: FileDiff;
themeType: () => 'light' | 'dark';
+ workers: WorkerPoolManager;
}) {
const longestSide = createMemo(() =>
Math.max(lineCount(props.diff.oldText ?? ''), lineCount(props.diff.newText))
@@ -194,7 +203,11 @@ function FileDiffBlock(props: {
</DiffNote>
}
>
- <PierreFileView diff={props.diff} themeType={props.themeType} />
+ <PierreFileView
+ diff={props.diff}
+ themeType={props.themeType}
+ workers={props.workers}
+ />
</Show>
</div>
);
@@ -206,12 +219,36 @@ function FileDiffBlock(props: {
*/
export function PierreDiff(props: { diffs: FileDiff[] }): JSX.Element {
const themeType = createThemeType();
+ const workers = useDiffWorkers();
+ const readyPool = () => {
+ const state = workers();
+ return state.kind === 'ready' ? state.pool : undefined;
+ };
return (
<div class="flex flex-col gap-2">
- <For each={props.diffs}>
- {(diff) => <FileDiffBlock diff={diff} themeType={themeType} />}
- </For>
+ <Show
+ when={readyPool()}
+ fallback={
+ <DiffNote>
+ {workers().kind === 'failed'
+ ? 'diff could not be rendered'
+ : 'Loading diff…'}
+ </DiffNote>
+ }
+ >
+ {(pool) => (
+ <For each={props.diffs}>
+ {(diff) => (
+ <FileDiffBlock
+ diff={diff}
+ themeType={themeType}
+ workers={pool()}
+ />
+ )}
+ </For>
+ )}
+ </Show>
</div>
);
}
diff --git a/apps/web/src/features/block-agent/ui/ToolCard.test.tsx b/apps/web/src/features/block-agent/ui/ToolCard.test.tsx
new file mode 100644
index 0000000000..4b4ffed1f3
--- /dev/null
+++ b/apps/web/src/features/block-agent/ui/ToolCard.test.tsx
@@ -0,0 +1,89 @@
+/** @vitest-environment jsdom */
+
+import { cleanup, render, waitFor } from '@solidjs/testing-library';
+import { createSignal, onCleanup } from 'solid-js';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { ToolCard } from './ToolCard';
+
+vi.mock('@phosphor/caret-right.svg', () => ({ default: () => <svg /> }));
+
+afterEach(cleanup);
+
+describe('ToolCard', () => {
+ it('constructs expensive content only on expansion and disposes it on close', async () => {
+ const mounted = vi.fn();
+ const disposed = vi.fn();
+ function Body() {
+ mounted();
+ onCleanup(disposed);
+ return <div>Diff contents</div>;
+ }
+ const view = render(() => (
+ <ToolCard title="Edit" status="completed">
+ <Body />
+ </ToolCard>
+ ));
+ expect(mounted).not.toHaveBeenCalled();
+ const trigger = view.getByRole('button');
+ expect(trigger.getAttribute('aria-expanded')).toBe('false');
+ trigger.click();
+ expect(mounted).toHaveBeenCalledTimes(1);
+ expect(view.getByText('Diff contents')).toBeTruthy();
+ trigger.click();
+ await waitFor(() => expect(disposed).toHaveBeenCalledTimes(1));
+ trigger.click();
+ expect(mounted).toHaveBeenCalledTimes(2);
+ });
+
+ it('updates conditional content availability without constructing the body', () => {
+ const [available, setAvailable] = createSignal(false);
+ const mounted = vi.fn();
+ const view = render(() => (
+ <ToolCard title="Bash" status="running" hasContent={available()}>
+ {mounted()}
+ <div>Output</div>
+ </ToolCard>
+ ));
+ expect(view.queryByRole('button')).toBeNull();
+ setAvailable(true);
+ expect(view.getByRole('button')).toBeTruthy();
+ expect(mounted).not.toHaveBeenCalled();
+ view.getByRole('button').click();
+ expect(mounted).toHaveBeenCalledTimes(1);
+ });
+
+ it('supports controlled expansion without mounting until the owner opens it', () => {
+ const [open, setOpen] = createSignal(false);
+ const onOpenChange = vi.fn();
+ const mounted = vi.fn();
+ const view = render(() => (
+ <ToolCard
+ title="Edit"
+ status="completed"
+ open={open()}
+ onOpenChange={onOpenChange}
+ >
+ {mounted()}
+ <div>Diff</div>
+ </ToolCard>
+ ));
+ view.getByRole('button').click();
+ expect(onOpenChange).toHaveBeenCalledWith(true);
+ expect(mounted).not.toHaveBeenCalled();
+ setOpen(true);
+ expect(mounted).toHaveBeenCalledTimes(1);
+ });
+
+ it('renders default-open content and leaves bodyless cards noninteractive', () => {
+ const view = render(() => (
+ <>
+ <ToolCard title="Question" status="running" defaultOpen>
+ <input aria-label="Answer" />
+ </ToolCard>
+ <ToolCard title="Read" status="completed" />
+ </>
+ ));
+ expect(view.getByRole('textbox', { name: 'Answer' })).toBeTruthy();
+ expect(view.getAllByRole('button')).toHaveLength(1);
+ });
+});
diff --git a/apps/web/src/features/block-agent/ui/ToolCard.tsx b/apps/web/src/features/block-agent/ui/ToolCard.tsx
index 9133fadc73..621984225c 100644
--- a/apps/web/src/features/block-agent/ui/ToolCard.tsx
+++ b/apps/web/src/features/block-agent/ui/ToolCard.tsx
@@ -10,13 +10,7 @@
import { Collapsible } from '@kobalte/core/collapsible';
import CaretRight from '@phosphor/caret-right.svg';
-import {
- createMemo,
- For,
- type JSX,
- children as resolveChildren,
- Show,
-} from 'solid-js';
+import { createSignal, For, type JSX, Show } from 'solid-js';
import { TextShimmer } from './TextShimmer';
import { isToolActive, type ToolStatus } from './types';
@@ -35,6 +29,8 @@ export interface ToolCardProps {
open?: boolean;
defaultOpen?: boolean;
onOpenChange?: (open: boolean) => void;
+ /** Whether conditional children have content, without constructing them. */
+ hasContent?: boolean;
/** Expandable body. Without children the row has no collapse affordance. */
children?: JSX.Element;
}
@@ -44,11 +40,17 @@ const ROW_CLASS =
export function ToolCard(props: ToolCardProps) {
const active = () => isToolActive(props.status);
- const resolved = resolveChildren(() => props.children);
- const hasChildren = createMemo(() => {
- const body = resolved();
- return Array.isArray(body) ? body.length > 0 : body != null;
- });
+ const [uncontrolledOpen, setUncontrolledOpen] = createSignal(
+ props.defaultOpen ?? false
+ );
+ const open = () => props.open ?? uncontrolledOpen();
+ const setOpen = (value: boolean) => {
+ setUncontrolledOpen(value);
+ props.onOpenChange?.(value);
+ };
+ // Reading children to inspect them mounts expensive bodies even while closed.
+ // Conditional callers supply presence separately; Kobalte mounts the body.
+ const hasChildren = () => props.hasContent ?? 'children' in props;
const row = (expandable: boolean) => (
<>
@@ -101,16 +103,14 @@ export function ToolCard(props: ToolCardProps) {
when={hasChildren()}
fallback={<div class={ROW_CLASS}>{row(false)}</div>}
>
- <Collapsible
- open={props.open}
- defaultOpen={props.defaultOpen}
- onOpenChange={props.onOpenChange}
- >
+ <Collapsible open={open()} onOpenChange={setOpen}>
<Collapsible.Trigger class={`group hover:bg-hover ${ROW_CLASS}`}>
{row(true)}
</Collapsible.Trigger>
<Collapsible.Content class="data-closed:hidden">
- <div class="min-w-0 px-3 pb-2">{resolved()}</div>
+ <Show when={open()}>
+ <div class="min-w-0 px-3 pb-2">{props.children}</div>
+ </Show>
</Collapsible.Content>
</Collapsible>
</Show>
diff --git a/apps/web/src/features/block-agent/ui/diff-workers.test.ts b/apps/web/src/features/block-agent/ui/diff-workers.test.ts
new file mode 100644
index 0000000000..fae1d45361
--- /dev/null
+++ b/apps/web/src/features/block-agent/ui/diff-workers.test.ts
@@ -0,0 +1,68 @@
+/** @vitest-environment jsdom */
+
+import { waitFor } from '@solidjs/testing-library';
+import { createRoot } from 'solid-js';
+import { describe, expect, it, vi } from 'vitest';
+import { useDiffWorkers } from './diff-workers';
+
+const mocks = vi.hoisted(() => ({
+ construct: vi.fn(),
+ initialize: vi.fn<() => Promise<void>>(),
+ terminate: vi.fn(),
+ worker: vi.fn(),
+}));
+vi.mock('@pierre/diffs/worker', () => ({
+ WorkerPoolManager: class {
+ constructor(...args: unknown[]) {
+ mocks.construct(...args);
+ }
+ initialize = mocks.initialize;
+ terminate = mocks.terminate;
+ },
+}));
+vi.mock('@pierre/diffs/worker/worker.js?worker', () => ({
+ default: mocks.worker,
+}));
+
+describe('diff workers', () => {
+ it('starts lazily, shares the pool, and terminates after the last body unmounts', async () => {
+ expect(mocks.construct).not.toHaveBeenCalled();
+ let resolve!: () => void;
+ mocks.initialize.mockReturnValue(
+ new Promise<void>((done) => {
+ resolve = done;
+ })
+ );
+ const first = createRoot((dispose) => ({
+ dispose,
+ state: useDiffWorkers(),
+ }));
+ const second = createRoot((dispose) => ({
+ dispose,
+ state: useDiffWorkers(),
+ }));
+ expect(mocks.construct).toHaveBeenCalledTimes(1);
+ expect(first.state).toBe(second.state);
+ expect(first.state().kind).toBe('loading');
+ resolve();
+ await waitFor(() => expect(first.state().kind).toBe('ready'));
+ first.dispose();
+ await Promise.resolve();
+ expect(mocks.terminate).not.toHaveBeenCalled();
+ second.dispose();
+ await waitFor(() => expect(mocks.terminate).toHaveBeenCalledTimes(1));
+ });
+
+ it('reports initialization failure without exposing a pool that falls back to the main thread', async () => {
+ const error = vi.spyOn(console, 'error').mockImplementation(() => {});
+ mocks.initialize.mockRejectedValue(new Error('worker unavailable'));
+ const root = createRoot((dispose) => ({
+ dispose,
+ state: useDiffWorkers(),
+ }));
+ await waitFor(() => expect(root.state().kind).toBe('failed'));
+ root.dispose();
+ await Promise.resolve();
+ error.mockRestore();
+ });
+});
diff --git a/apps/web/src/features/block-agent/ui/diff-workers.ts b/apps/web/src/features/block-agent/ui/diff-workers.ts
new file mode 100644
index 0000000000..acf5e9c2ee
--- /dev/null
+++ b/apps/web/src/features/block-agent/ui/diff-workers.ts
@@ -0,0 +1,36 @@
+import { WorkerPoolManager } from '@pierre/diffs/worker';
+import DiffWorker from '@pierre/diffs/worker/worker.js?worker';
+import { createSingletonRoot } from '@solid-primitives/rootless';
+import { createSignal, onCleanup } from 'solid-js';
+
+type DiffWorkers =
+ | { kind: 'loading' }
+ | { kind: 'ready'; pool: WorkerPoolManager }
+ | { kind: 'failed' };
+
+/** Share a bounded pool only while diff bodies are mounted. Never start on import. */
+export const useDiffWorkers = createSingletonRoot(() => {
+ const [state, setState] = createSignal<DiffWorkers>({ kind: 'loading' });
+ const pool = new WorkerPoolManager(
+ {
+ workerFactory: () => new DiffWorker(),
+ poolSize: 2,
+ totalASTLRUCacheSize: 20,
+ },
+ { lineDiffType: 'none' }
+ );
+ onCleanup(() => pool.terminate());
+
+ async function initialize() {
+ try {
+ await pool.initialize();
+ setState({ kind: 'ready', pool });
+ } catch (error) {
+ // Do not let Pierre fall back to main-thread syntax highlighting.
+ console.error('[pierre-diff] worker initialization failed', error);
+ setState({ kind: 'failed' });
+ }
+ }
+ void initialize();
+ return state;
+});
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index 72638f58a0..e5e4d5a38a 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -239,6 +239,12 @@ to open the title menu (caret), then **Rename** — that opens the generic entit
rename dialog. Do not expect a tap on the name itself to start
an inline edit.
+Tool groups and individual tool cards start collapsed. Expand a group to see
+its calls, then expand an edit card to view its file diffs. Diff bodies load
+only when their card opens; syntax highlighting may appear after the diff text.
+Opening a session or expanding a group should leave the app responsive, even
+when the session contains many file edits.
+
### Sharing a session
Saved sessions have **Share** and **Copy Share Link** in the desktop header;