graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Add an opt-in GUI inspector for local run traces.
Cursor Agent06cb1b7ff969
diff --git a/apps/native/app/api/traces/route.ts b/apps/native/app/api/traces/route.tsnew file mode 100644index 00000000..d4ad4a24--- /dev/null+++ b/apps/native/app/api/traces/route.ts@@ -0,0 +1,63 @@+import { lstatSync, readdirSync } from "node:fs";+import path from "node:path";+import { filePreview } from "@/lib/file-preview";+import { isTraceId, summarizeTrace } from "@/lib/run-traces";+import { resolveRoot } from "@/lib/server-root";+import { NextRequest } from "next/server";++export const runtime = "nodejs";+export const dynamic = "force-dynamic";++const MAX_LIST = 40;++function tracesDir(root: string): string {+ return path.join(root, ".graff", "traces");+}++function resolveTrace(root: string, id: string): string | null {+ if (!isTraceId(id)) return null;+ const target = path.resolve(tracesDir(root), `${id}.jsonl`);+ const dir = tracesDir(root);+ if (target !== dir && !target.startsWith(dir + path.sep)) return null;+ return target;+}++export async function GET(req: NextRequest) {+ const resolved = resolveRoot(req.nextUrl.searchParams.get("root"));+ if ("error" in resolved) return Response.json({ error: resolved.error }, { status: resolved.status });+ const id = req.nextUrl.searchParams.get("id");+ if (id) {+ const file = resolveTrace(resolved.root, id);+ if (!file) return Response.json({ error: "unknown trace" }, { status: 400 });+ try {+ if (lstatSync(file).isSymbolicLink()) return Response.json({ error: "unknown trace" }, { status: 404 });+ const preview = await filePreview(file);+ if (preview.binary) return Response.json({ error: "trace is not text" }, { status: 415 });+ const parsed = summarizeTrace(id, preview.text);+ return Response.json({ ...parsed, truncated: preview.truncated }, { headers: { "cache-control": "no-store" } });+ } catch {+ return Response.json({ error: "trace not found" }, { status: 404 });+ }+ }+ let names: string[] = [];+ try { names = readdirSync(tracesDir(resolved.root)); } catch {+ return Response.json({ traces: [] }, { headers: { "cache-control": "no-store" } });+ }+ const rows = [];+ for (const name of names) {+ if (!name.endsWith(".jsonl")) continue;+ const stem = name.slice(0, -".jsonl".length);+ const file = resolveTrace(resolved.root, stem);+ if (!file) continue;+ try {+ const st = lstatSync(file);+ if (!st.isFile() || st.isSymbolicLink()) continue;+ const preview = await filePreview(file);+ if (preview.binary) continue;+ const { summary } = summarizeTrace(stem, preview.text);+ rows.push({ ...summary, mtime: st.mtimeMs, bytes: st.size, truncated: preview.truncated });+ } catch { /* skip unreadable */ }+ }+ rows.sort((a, b) => b.mtime - a.mtime);+ return Response.json({ traces: rows.slice(0, MAX_LIST) }, { headers: { "cache-control": "no-store" } });+}diff --git a/apps/native/components/site/AppSettings.tsx b/apps/native/components/site/AppSettings.tsxindex 3bebc640..33585109 100644--- a/apps/native/components/site/AppSettings.tsx+++ b/apps/native/components/site/AppSettings.tsx@@ -4,12 +4,16 @@ import { IconSettingsGear1 } from "@/lib/icons";import { ThemeToggle } from "./ThemeToggle";import DesktopSettings from "./DesktopSettings";import McpServers from "./McpServers";+import TracesPane from "./TracesPane";export default function AppSettings({ sidebar = false }: { sidebar?: boolean }) {- return <ActionMenu label="Settings" text={<IconSettingsGear1 size={16} />}- className={sidebar ? "mx-2 flex shrink-0 justify-end border-t border-line pt-2 [&>button]:size-8 [&>button]:p-0" : "shrink-0"}>- <ThemeToggle labeled />- <DesktopSettings labeled />- <McpServers labeled />- </ActionMenu>;+ return <>+ <ActionMenu label="Settings" text={<IconSettingsGear1 size={16} />}+ className={sidebar ? "mx-2 flex shrink-0 justify-end border-t border-line pt-2 [&>button]:size-8 [&>button]:p-0" : "shrink-0"}>+ <ThemeToggle labeled />+ <DesktopSettings labeled />+ <McpServers labeled />+ </ActionMenu>+ <TracesPane />+ </>;}diff --git a/apps/native/components/site/HarnessChrome.tsx b/apps/native/components/site/HarnessChrome.tsxindex 6571339c..b304084c 100644--- a/apps/native/components/site/HarnessChrome.tsx+++ b/apps/native/components/site/HarnessChrome.tsx@@ -1,3 +1,4 @@+"use client";import SessionTabs from "./SessionTabs";import type {SplitTree} from "@/lib/split-tree";import ActionMenu from "@/components/primitives/ActionMenu";@@ -5,6 +6,8 @@ import AppSettings from "./AppSettings";import type { PointerEvent, MouseEvent, ReactNode } from "react";import type { Chat } from "./harness-types";import reviewStyles from "./ChangesPane.module.css";+import { useEffect, useState } from "react";+import { openTraces, tracesPrefEvent, tracesWanted } from "@/lib/trace-pref";type Props = {navigationToggle?: ReactNode; sidebarVisible?: boolean;@@ -27,8 +30,16 @@ export default function HarnessChrome({navigationToggle, sidebarVisible = false,conversationsOpen, openConversations, split, toggleSplit, filesOpen, onFiles, chatCwd,workspaceName, onFolder, openChanges, changesOpen = false, reviewsOpen = false, onReviews, browserOpen, onBrowser, pinCount, terminalVisible,toggleTerminal, agentsOpen, onAgents, workingAgents = 0, tasksOpen = false, taskCount = 0, onTasks, splitNotice, onTabPointerDown, onTabClickCapture}: Props) {+ const [showTraces, setShowTraces] = useState(false);+ useEffect(() => {+ const sync = () => setShowTraces(tracesWanted());+ sync();+ window.addEventListener(tracesPrefEvent, sync);+ window.addEventListener("storage", sync);+ return () => { window.removeEventListener(tracesPrefEvent, sync); window.removeEventListener("storage", sync); };+ }, []);return (- <div data-workspace-toolbar className={`${reviewStyles.chatbar} flex shrink-0 flex-col ${sidebarVisible ? "overflow-visible bg-transparent" : "overflow-hidden rounded-[14px] border border-line bg-page"}`}>+ <div data-workspace-toolbar data-workspace-root={chatCwd} className={`${reviewStyles.chatbar} flex shrink-0 flex-col ${sidebarVisible ? "overflow-visible bg-transparent" : "overflow-hidden rounded-[14px] border border-line bg-page"}`}>{!sidebarVisible && <div data-session-tab-strip className="flex h-10 min-w-0 shrink-0 items-center gap-1 px-2"><div className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"><button type="button" aria-label="Show agents" aria-pressed={agentsOpen} onClick={onAgents}@@ -56,6 +67,7 @@ export default function HarnessChrome({navigationToggle, sidebarVisible = false,<button type="button" aria-label="Toggle terminal" aria-pressed={terminalVisible} onClick={toggleTerminal}>Terminal <span className="ml-auto text-ink-3">⌘J</span></button><button type="button" aria-label="Browser" aria-pressed={browserOpen} onClick={onBrowser}>Browser{pinCount > 0 ? ` (${pinCount})` : ""}</button><button type="button" aria-label="Files" aria-pressed={filesOpen && !changesOpen} onClick={onFiles}>Files</button>+ {showTraces && <button type="button" aria-label="Run traces" onClick={() => openTraces()}>Traces</button>}</ActionMenu>{(taskCount > 0 || tasksOpen) && onTasks && <button type="button" aria-label="Show tasks" aria-pressed={tasksOpen} onClick={onTasks} className={paneBtn(tasksOpen)}>Tasks{taskCount ? ` (${taskCount})` : ""}</button>}<ActionMenu label="Chat actions" text="More" className="shrink-0">diff --git a/apps/native/components/site/ThemeToggle.tsx b/apps/native/components/site/ThemeToggle.tsxindex 92876ed3..ef8a6b27 100644--- a/apps/native/components/site/ThemeToggle.tsx+++ b/apps/native/components/site/ThemeToggle.tsx@@ -4,6 +4,7 @@ import { createPortal } from "react-dom";import { restoreActionFocus } from "../primitives/ActionMenu";import CustomThemes from "./CustomThemes";import DesktopSettings from "./DesktopSettings";+import TraceSettings from "./TraceSettings";import { appearanceEvent, appearanceKey, applyAppearance, readAppearance, type Appearance } from "@/lib/appearance";const themes = [@@ -67,6 +68,7 @@ export function ThemeToggle({ labeled = false }: { labeled?: boolean }) {</button>)}</div><CustomThemes selected={theme} /><DesktopSettings embedded />+ <TraceSettings /></div></div></div>, document.body)}diff --git a/apps/native/components/site/TraceSettings.tsx b/apps/native/components/site/TraceSettings.tsxnew file mode 100644index 00000000..5fd20ffc--- /dev/null+++ b/apps/native/components/site/TraceSettings.tsx@@ -0,0 +1,25 @@+"use client";+import { useEffect, useState } from "react";+import { openTraces, setTracesWanted, tracesPrefEvent, tracesWanted } from "@/lib/trace-pref";++export default function TraceSettings() {+ const [on, setOn] = useState(false);+ useEffect(() => {+ const sync = () => setOn(tracesWanted());+ sync();+ window.addEventListener(tracesPrefEvent, sync);+ window.addEventListener("storage", sync);+ return () => { window.removeEventListener(tracesPrefEvent, sync); window.removeEventListener("storage", sync); };+ }, []);+ return <fieldset className="mt-3 border-t border-line pt-3">+ <legend className="mb-1 text-xs font-medium">Run traces</legend>+ <p className="mb-3 text-xs text-ink-3">Inspect this workspace’s local <span className="font-mono">.graff/traces</span> timeline. Off until you turn it on. Stays on this machine.</p>+ <div className="flex flex-col gap-2">+ <button type="button" aria-pressed={on} onClick={() => { setTracesWanted(true); setOn(true); }}+ className={`rounded-lg border px-3 py-2 text-left text-xs focus-visible:outline-2 focus-visible:outline-accent ${on ? "border-accent bg-accent-tint" : "border-line hover:bg-hover"}`}>Show Traces in Tools</button>+ <button type="button" aria-pressed={!on} onClick={() => { setTracesWanted(false); setOn(false); }}+ className={`rounded-lg border px-3 py-2 text-left text-xs focus-visible:outline-2 focus-visible:outline-accent ${!on ? "border-accent bg-accent-tint" : "border-line hover:bg-hover"}`}>Hide</button>+ </div>+ {on && <button type="button" onClick={() => openTraces()} className="mt-2 text-xs text-accent hover:underline">Open traces…</button>}+ </fieldset>;+}diff --git a/apps/native/components/site/TracesPane.tsx b/apps/native/components/site/TracesPane.tsxnew file mode 100644index 00000000..d3af9b4d--- /dev/null+++ b/apps/native/components/site/TracesPane.tsx@@ -0,0 +1,101 @@+"use client";+import { useEffect, useState } from "react";+import { createPortal } from "react-dom";+import { eventLabel, formatDuration, type TraceEvent, type TraceSummary } from "@/lib/run-traces";+import { tracesOpenEvent, tracesWanted } from "@/lib/trace-pref";+import { listTraces, readTrace, type TraceListItem } from "@/lib/traces";++function workspaceRoot(): string | undefined {+ return document.querySelector<HTMLElement>("[data-workspace-root]")?.dataset.workspaceRoot || undefined;+}++function EventRow({ event }: { event: TraceEvent }) {+ return <li className={`flex items-baseline gap-2 py-1 text-[12.5px] ${event.is_error ? "text-red" : "text-ink-2"}`}>+ <span className="w-16 shrink-0 tabular-nums text-ink-3">{formatDuration(event.t)}</span>+ <span className="min-w-0 flex-1 truncate">{eventLabel(event)}{event.from_sub ? " · worker" : ""}</span>+ {event.ms !== undefined && <span className="shrink-0 tabular-nums text-ink-3">{formatDuration(event.ms)}</span>}+ </li>;+}++export default function TracesPane() {+ const [open, setOpen] = useState(false);+ const [root, setRoot] = useState<string | undefined>();+ const [rows, setRows] = useState<TraceListItem[] | null>(null);+ const [error, setError] = useState("");+ const [selected, setSelected] = useState<string | null>(null);+ const [detail, setDetail] = useState<{ summary: TraceSummary; events: TraceEvent[]; truncated: boolean } | null>(null);+ const [loading, setLoading] = useState("");++ useEffect(() => {+ const openPane = () => { if (tracesWanted()) { setRoot(workspaceRoot()); setOpen(true); } };+ window.addEventListener(tracesOpenEvent, openPane);+ return () => window.removeEventListener(tracesOpenEvent, openPane);+ }, []);++ useEffect(() => {+ if (!open) return;+ const keys = (event: KeyboardEvent) => { if (event.key === "Escape") { event.stopPropagation(); setOpen(false); } };+ document.addEventListener("keydown", keys);+ return () => document.removeEventListener("keydown", keys);+ }, [open]);++ useEffect(() => {+ if (!open) return;+ let alive = true;+ setRows(null); setError(""); setSelected(null); setDetail(null); setLoading("Reading traces…");+ void listTraces(root).then(list => { if (alive) { setRows(list); setError(""); } })+ .catch(e => { if (alive) setError(e instanceof Error ? e.message : "Traces unavailable"); })+ .finally(() => { if (alive) setLoading(""); });+ return () => { alive = false; };+ }, [open, root]);++ useEffect(() => {+ if (!open || !selected) return;+ let alive = true;+ setDetail(null); setLoading("Reading run…");+ void readTrace(selected, root).then(next => { if (alive) { setDetail(next); setError(""); } })+ .catch(e => { if (alive) setError(e instanceof Error ? e.message : "Trace unavailable"); })+ .finally(() => { if (alive) setLoading(""); });+ return () => { alive = false; };+ }, [open, selected, root]);++ if (!open) return null;+ return createPortal(+ <div className="fixed inset-0 z-[180] flex justify-end bg-black/20 p-3" onPointerDown={event => { if (event.target === event.currentTarget) setOpen(false); }}>+ <aside role="dialog" aria-label="Run traces" aria-modal="true" className="flex h-full w-[min(440px,100%)] flex-col overflow-hidden rounded-window border border-line bg-page text-ink shadow-overlay">+ <header className="flex items-center gap-3 border-b border-line p-4">+ <div className="min-w-0 flex-1">+ <strong>Traces</strong>+ <p className="mt-1 text-xs text-ink-3">Local operational timeline for this workspace. Prompt text is not shown.</p>+ </div>+ <button type="button" onClick={() => setOpen(false)} aria-label="Close traces" className="rounded px-2 py-1 hover:bg-hover">×</button>+ </header>+ <div className="min-h-0 flex-1 overflow-y-auto p-4">+ {loading && <p role="status" className="text-sm text-ink-3">{loading}</p>}+ {error && <p role="alert" className="text-sm text-red">{error}</p>}+ {!selected && rows && !rows.length && !loading && <p className="text-sm text-ink-2">No traces in this workspace yet. Run a turn, then reopen.</p>}+ {!selected && rows && !!rows.length && <ul className="space-y-2">{rows.map(row =>+ <li key={row.id}>+ <button type="button" onClick={() => setSelected(row.id)} className="w-full rounded-xl border border-line bg-surface px-3 py-2 text-left hover:bg-hover">+ <div className="flex items-center gap-2 text-[12.5px]">+ <span className="min-w-0 flex-1 truncate font-mono text-ink">{row.id}</span>+ <span className="shrink-0 tabular-nums text-ink-3">{formatDuration(row.durationMs)}</span>+ </div>+ <p className="mt-1 text-[11px] text-ink-3">{row.events} events{row.errors ? ` · ${row.errors} errors` : ""}{row.models[0] ? ` · ${row.models[0]}` : ""}</p>+ </button>+ </li>+ )}</ul>}+ {selected && <div className="space-y-3">+ <button type="button" className="text-xs hover:underline" onClick={() => { setSelected(null); setDetail(null); }}>← All traces</button>+ {detail && <>+ <p className="text-xs text-ink-3 font-mono break-all">{detail.summary.id}</p>+ <p className="text-xs text-ink-3">{detail.summary.events} events · {formatDuration(detail.summary.durationMs)}{detail.summary.tools.length ? ` · ${detail.summary.tools.slice(0, 4).join(", ")}` : ""}{detail.truncated ? " · truncated" : ""}</p>+ <ol className="divide-y divide-line">{detail.events.map((event, i) => <EventRow key={`${event.t}:${event.ev}:${i}`} event={event} />)}</ol>+ </>}+ </div>}+ </div>+ </aside>+ </div>,+ document.body,+ );+}diff --git a/apps/native/lib/run-traces.test.ts b/apps/native/lib/run-traces.test.tsnew file mode 100644index 00000000..da54eed9--- /dev/null+++ b/apps/native/lib/run-traces.test.ts@@ -0,0 +1,41 @@+import { describe, it } from "node:test";+import assert from "node:assert/strict";+import { eventLabel, formatDuration, isTraceId, parseTraceLine, summarizeTrace } from "./run-traces.ts";++const sample = [+ JSON.stringify({ run_id: "abc", t: 12, ev: "api", model: "terra", ms: 400, is_error: false }),+ JSON.stringify({ t: 80, ev: "tool", name: "bash", ms: 20, is_error: false }),+ JSON.stringify({ t: 90, ev: "tool", name: "edit", ms: 8, is_error: true }),+ JSON.stringify({ t: 5, ev: "prompt", text: "secret user prompt" }),+ "{not json}",+ JSON.stringify({ t: 100, ev: "first_token", model: "terra", ms: 30 }),+].join("\n");++describe("run traces", () => {+ it("keeps allowlisted operational fields and drops prompt text", () => {+ const { summary, events } = summarizeTrace("abc", sample);+ assert.equal(summary.id, "abc");+ assert.equal(summary.events, 4);+ assert.equal(summary.errors, 1);+ assert.equal(summary.durationMs, 100);+ assert.deepEqual(summary.models, ["terra"]);+ assert.deepEqual(summary.tools, ["bash", "edit"]);+ assert.ok(!JSON.stringify(events).includes("secret"));+ assert.equal(parseTraceLine(JSON.stringify({ ev: "prompt", t: 1, text: "nope" })), null);+ });++ it("rejects path-shaped trace ids", () => {+ assert.equal(isTraceId("abc123"), true);+ assert.equal(isTraceId("../etc/passwd"), false);+ assert.equal(isTraceId("a/b"), false);+ assert.equal(isTraceId(""), false);+ });++ it("labels and formats the timeline", () => {+ assert.equal(eventLabel({ t: 1, ev: "tool", name: "bash" }), "bash");+ assert.equal(eventLabel({ t: 1, ev: "api", model: "terra" }), "api · terra");+ assert.equal(formatDuration(420), "420ms");+ assert.equal(formatDuration(12_400), "12s");+ assert.equal(formatDuration(90_000), "1m 30s");+ });+});diff --git a/apps/native/lib/run-traces.ts b/apps/native/lib/run-traces.tsnew file mode 100644index 00000000..2b199ba7--- /dev/null+++ b/apps/native/lib/run-traces.ts@@ -0,0 +1,100 @@+/** Operational `.graff/traces/<run>.jsonl` → a readable timeline.+ * Only allowlisted fields: no prompt text, no paths, no raw detail. */++export type TraceEvent = {+ t: number;+ ev: string;+ name?: string;+ model?: string;+ ms?: number;+ is_error?: boolean;+ agent?: string;+ from_sub?: boolean;+ turn?: number;+};++export type TraceSummary = {+ id: string;+ events: number;+ errors: number;+ durationMs: number;+ models: string[];+ tools: string[];+};++const MAX_EVENTS = 2000;+const SKIP = new Set(["prompt"]);+export const TRACE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$/;++export function isTraceId(id: string): boolean {+ return TRACE_ID.test(id);+}++function num(value: unknown): number | undefined {+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;+}++function text(value: unknown, max = 64): string | undefined {+ if (typeof value !== "string") return undefined;+ const trimmed = value.trim();+ if (!trimmed) return undefined;+ return trimmed.length > max ? trimmed.slice(0, max) : trimmed;+}++export function parseTraceLine(line: string): TraceEvent | null {+ let raw: unknown;+ try { raw = JSON.parse(line); } catch { return null; }+ if (!raw || typeof raw !== "object") return null;+ const rec = raw as Record<string, unknown>;+ const ev = text(rec.ev) ?? text(rec.kind);+ const t = num(rec.t);+ if (!ev || t === undefined || SKIP.has(ev)) return null;+ return {+ t,+ ev,+ name: text(rec.name),+ model: text(rec.model, 80),+ ms: num(rec.ms),+ is_error: rec.is_error === true,+ agent: text(rec.agent, 32),+ from_sub: rec.from_sub === true ? true : undefined,+ turn: num(rec.turn),+ };+}++export function summarizeTrace(id: string, text: string): { summary: TraceSummary; events: TraceEvent[] } {+ const events: TraceEvent[] = [];+ const models = new Set<string>();+ const tools = new Set<string>();+ let errors = 0;+ let durationMs = 0;+ for (const line of text.split("\n")) {+ if (!line.trim()) continue;+ const event = parseTraceLine(line);+ if (!event) continue;+ if (events.length < MAX_EVENTS) events.push(event);+ durationMs = Math.max(durationMs, event.t);+ if (event.model) models.add(event.model);+ if (event.name && event.ev === "tool") tools.add(event.name);+ if (event.is_error) errors += 1;+ }+ return {+ summary: { id, events: events.length, errors, durationMs, models: [...models], tools: [...tools] },+ events,+ };+}++export function formatDuration(ms: number): string {+ if (ms < 1000) return `${Math.round(ms)}ms`;+ if (ms < 60_000) return `${(ms / 1000).toFixed(ms < 10_000 ? 1 : 0)}s`;+ const minutes = Math.floor(ms / 60_000);+ const seconds = Math.round((ms % 60_000) / 1000);+ return seconds ? `${minutes}m ${seconds}s` : `${minutes}m`;+}++export function eventLabel(event: TraceEvent): string {+ if (event.ev === "tool") return event.name ?? "tool";+ if (event.ev === "api") return event.model ? `api · ${event.model}` : "api";+ if (event.ev === "first_token") return event.model ? `first token · ${event.model}` : "first token";+ return event.ev.replaceAll("_", " ");+}diff --git a/apps/native/lib/trace-pref.ts b/apps/native/lib/trace-pref.tsnew file mode 100644index 00000000..91e6b21d--- /dev/null+++ b/apps/native/lib/trace-pref.ts@@ -0,0 +1,16 @@+export const tracesPrefKey = "graff-show-traces";+export const tracesPrefEvent = "graff-traces-pref";+export const tracesOpenEvent = "graff-open-traces";++export function tracesWanted(): boolean {+ try { return localStorage.getItem(tracesPrefKey) === "1"; } catch { return false; }+}++export function setTracesWanted(on: boolean): void {+ try { localStorage.setItem(tracesPrefKey, on ? "1" : "0"); } catch { /* optional */ }+ window.dispatchEvent(new Event(tracesPrefEvent));+}++export function openTraces(): void {+ window.dispatchEvent(new Event(tracesOpenEvent));+}diff --git a/apps/native/lib/traces.ts b/apps/native/lib/traces.tsnew file mode 100644index 00000000..145a9b19--- /dev/null+++ b/apps/native/lib/traces.ts@@ -0,0 +1,24 @@+import type { TraceEvent, TraceSummary } from "./run-traces";++function query(params: Record<string, string | undefined>): string {+ const q = new URLSearchParams();+ for (const [k, v] of Object.entries(params)) if (v !== undefined) q.set(k, v);+ const s = q.toString();+ return s ? `?${s}` : "";+}++export type TraceListItem = TraceSummary & { mtime: number; bytes: number; truncated: boolean };++export async function listTraces(root?: string): Promise<TraceListItem[]> {+ const res = await fetch(`/api/traces${query({ root })}`, { cache: "no-store" });+ const body = await res.json() as { traces?: TraceListItem[]; error?: string };+ if (!res.ok) throw new Error(body.error ?? `traces ${res.status}`);+ return body.traces ?? [];+}++export async function readTrace(id: string, root?: string): Promise<{ summary: TraceSummary; events: TraceEvent[]; truncated: boolean }> {+ const res = await fetch(`/api/traces${query({ root, id })}`, { cache: "no-store" });+ const body = await res.json() as { summary?: TraceSummary; events?: TraceEvent[]; truncated?: boolean; error?: string };+ if (!res.ok) throw new Error(body.error ?? `traces ${res.status}`);+ return { summary: body.summary ?? { id, events: 0, errors: 0, durationMs: 0, models: [], tools: [] }, events: body.events ?? [], truncated: !!body.truncated };+}diff --git a/apps/native/package.json b/apps/native/package.jsonindex 7a0a7e37..bb840b07 100644--- a/apps/native/package.json+++ b/apps/native/package.json@@ -10,7 +10,7 @@"start": "NEXT_TELEMETRY_DISABLED=1 next start --port 3000","mock-serve": "node scripts/mock-serve.mjs","lint": "next lint",- "test": "node --experimental-strip-types --test lib/cite-markup.test.ts lib/graff-events.test.ts lib/acp.test.ts lib/sessions.test.ts lib/session-store.test.ts lib/follow-scroll.test.ts lib/prompt-queue.test.ts lib/prompt-queue-steer.test.ts lib/prompt-queue-resume.test.ts lib/streaming-code.test.ts lib/agents.test.ts lib/mermaid-plugin.test.ts lib/prompt-history.test.ts lib/attachments.test.ts lib/workspaces.test.ts lib/fuzzy.test.ts lib/folder-picker.test.ts lib/browser/annotations.test.ts lib/browser/url.test.ts lib/extension-bridge.test.ts components/site/harness-split.test.ts components/site/appearance-panel.test.ts",+ "test": "node --experimental-strip-types --test lib/cite-markup.test.ts lib/graff-events.test.ts lib/acp.test.ts lib/sessions.test.ts lib/session-store.test.ts lib/follow-scroll.test.ts lib/prompt-queue.test.ts lib/prompt-queue-steer.test.ts lib/prompt-queue-resume.test.ts lib/streaming-code.test.ts lib/run-traces.test.ts lib/agents.test.ts lib/mermaid-plugin.test.ts lib/prompt-history.test.ts lib/attachments.test.ts lib/workspaces.test.ts lib/fuzzy.test.ts lib/folder-picker.test.ts lib/browser/annotations.test.ts lib/browser/url.test.ts lib/extension-bridge.test.ts components/site/harness-split.test.ts components/site/appearance-panel.test.ts","electron:build": "bash electron/build.sh","test:electron": "bun test electron/policy.test.cjs","test:webauthn": "node scripts/test-webauthn.mjs",