graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Quiet the transcript file-chip wall.
justrach004ab81aaa43
diff --git a/apps/native/components/primitives/DiffChipStrip.tsx b/apps/native/components/primitives/DiffChipStrip.tsxnew file mode 100644index 00000000..16a595e1--- /dev/null+++ b/apps/native/components/primitives/DiffChipStrip.tsx@@ -0,0 +1,138 @@+"use client";++import { useState, type SyntheticEvent } from "react";+import { createPortal } from "react-dom";+import { DIFF_CHIP_CAP, diffChipLabels, meaningfulDiffStat } from "@/lib/diff-chip-label";++type DiffLine = { text: string; tone: "add" | "del" | "ctx" };++export type DiffChipModel = {+ file: string;+ add: number;+ del: number;+ lines?: DiffLine[];+};++/**+ * What a turn changed, without a wall of pills. A few files stay as short+ * chips. A long list folds behind `+N` — the reader opens it, the transcript+ * does not.+ */+export default function DiffChipStrip({+ diffs,+ onOpenPath,+}: {+ diffs: DiffChipModel[];+ onOpenPath?: (path: string) => void;+}) {+ const [expanded, setExpanded] = useState(false);+ const [preview, setPreview] = useState<{ file: string; x: number; top?: number; bottom?: number } | null>(null);+ if (diffs.length === 0) return null;+ const labels = diffChipLabels(diffs.map((diff) => diff.file));+ const folded = !expanded && diffs.length > DIFF_CHIP_CAP;+ const shown = folded ? diffs.slice(0, DIFF_CHIP_CAP) : diffs;+ const linesOf = (file: string) => diffs.find((diff) => diff.file === file)?.lines ?? [];++ const openPreview = (file: string) => (event: SyntheticEvent) => {+ const rect = (event.currentTarget as Element).closest("[data-diffchip]")!.getBoundingClientRect();+ const previewHeight = 38 + linesOf(file).length * 19;+ const fitsBelow = rect.bottom + 6 + previewHeight <= window.innerHeight - 12;+ setPreview({+ file,+ x: Math.max(12, Math.min(rect.left, window.innerWidth - 300)),+ ...(fitsBelow ? { top: rect.bottom + 6 } : { bottom: window.innerHeight - rect.top + 6 }),+ });+ };+ const closePreview = (file: string) => () =>+ setPreview((current) => (current?.file === file ? null : current));++ return (+ <div data-diff-strip className="mt-2 flex max-w-full flex-wrap items-center gap-1.5">+ <div className={expanded && diffs.length > DIFF_CHIP_CAP ? "flex max-h-[min(28vh,200px)] min-w-0 flex-1 flex-wrap gap-1.5 overflow-auto overscroll-contain" : "contents"}>+ {shown.map((diff) => {+ const index = diffs.indexOf(diff);+ const label = labels[index] ?? diff.file;+ const showStat = meaningfulDiffStat(diff.add, diff.del);+ return (+ <span+ key={diff.file}+ data-diffchip+ className="relative max-w-full"+ onMouseEnter={openPreview(diff.file)}+ onMouseLeave={closePreview(diff.file)}+ >+ <button+ type="button"+ aria-expanded={preview?.file === diff.file}+ aria-label={`Show diff for ${diff.file}`}+ title={diff.file}+ onFocus={openPreview(diff.file)}+ onBlur={closePreview(diff.file)}+ onClick={onOpenPath ? () => onOpenPath(diff.file) : undefined}+ className="inline-flex h-7 max-w-full items-center gap-1.5 rounded-chip bg-surface px-2 font-mono text-[11.5px] text-ink shadow-btn transition-colors duration-100 hover:bg-hover"+ >+ <span data-diff-label className="min-w-0 truncate">{label}</span>+ {showStat && (+ <span data-diff-stat className="shrink-0 tabular-nums">+ <span className="text-green">+{diff.add}</span>+ {diff.del > 0 && <span className="text-red"> −{diff.del}</span>}+ </span>+ )}+ </button>+ </span>+ );+ })}+ </div>+ {diffs.length > DIFF_CHIP_CAP && (+ <button+ type="button"+ data-diff-more+ aria-expanded={expanded}+ onClick={() => setExpanded((current) => !current)}+ className="inline-flex h-7 items-center rounded-full px-2 text-[12px] text-ink-3 transition-colors duration-100 hover:bg-hover hover:text-ink-2"+ >+ {expanded ? "Show less" : `+${diffs.length - DIFF_CHIP_CAP}`}+ </button>+ )}+ {preview && typeof document !== "undefined" && createPortal(+ <div+ className="fixed z-50 w-72 overflow-hidden rounded-card bg-surface shadow-overlay"+ style={{+ left: preview.x,+ top: preview.top,+ bottom: preview.bottom,+ transformOrigin: preview.top === undefined ? "bottom left" : "top left",+ }}+ >+ <div className="flex items-center justify-between border-b border-line px-2.5 py-1.5 font-mono text-[11px]">+ <span className="min-w-0 truncate text-ink-2">{preview.file}</span>+ {(() => {+ const diff = diffs.find((item) => item.file === preview.file);+ if (!diff || !meaningfulDiffStat(diff.add, diff.del)) return null;+ return (+ <span className="shrink-0 tabular-nums">+ <span className="text-green">+{diff.add}</span>+ {diff.del > 0 && <span className="text-red"> −{diff.del}</span>}+ </span>+ );+ })()}+ </div>+ <div className="py-1 font-mono text-[11px] leading-[1.8]">+ {linesOf(preview.file).map((line, index) => (+ <div+ key={index}+ className={`flex gap-2 px-2.5 whitespace-pre ${+ line.tone === "add" ? "bg-green-tint text-green" : line.tone === "del" ? "bg-red-tint text-red" : "text-ink-2"+ }`}+ >+ <span className="w-3 shrink-0 select-none">{line.tone === "add" ? "+" : line.tone === "del" ? "−" : " "}</span>+ <span className="min-w-0 truncate">{line.text}</span>+ </div>+ ))}+ </div>+ </div>,+ document.body,+ )}+ </div>+ );+}diff --git a/apps/native/components/primitives/ToolChips.tsx b/apps/native/components/primitives/ToolChips.tsxindex 147dfdab..975327d7 100644--- a/apps/native/components/primitives/ToolChips.tsx+++ b/apps/native/components/primitives/ToolChips.tsx@@ -1,7 +1,8 @@"use client";import { useEffect, useState } from "react";-import { createPortal } from "react-dom";+import { shortPath } from "@/lib/diff-chip-label";+import DiffChipStrip from "./DiffChipStrip";import ToolOutput from "./ToolOutput";/* ─────────────────────────────────────────────────────────@@ -55,34 +56,35 @@ const ROWS: { icon: string; label: string; chip: string; mono: boolean; detailMo];const DIFFS = [- { file: "flavors.css", add: 13, del: 0 },- { file: "ChurnSchedule.tsx", add: 74, del: 41 },- { file: "menu.ts", add: 8, del: 2 },+ {+ file: "flavors.css", add: 13, del: 0,+ lines: [+ { text: ".scoop-card {", tone: "ctx" as const },+ { text: " gap: 14px;", tone: "del" as const },+ { text: " gap: 12px;", tone: "add" as const },+ { text: " container-type: inline-size;", tone: "add" as const },+ { text: "}", tone: "ctx" as const },+ ],+ },+ {+ file: "ChurnSchedule.tsx", add: 74, del: 41,+ lines: [+ { text: "const slots = coldSlots(week);", tone: "ctx" as const },+ { text: "const windows = slots;", tone: "del" as const },+ { text: "const windows = slots.filter(", tone: "add" as const },+ { text: " (s) => s.temp <= -12,", tone: "add" as const },+ { text: ");", tone: "add" as const },+ ],+ },+ {+ file: "menu.ts", add: 8, del: 2,+ lines: [+ { text: "export const hero = \"mint-chip\";", tone: "del" as const },+ { text: "export const hero = \"pistachio\";", tone: "add" as const },+ ],+ },];-/* hovering a file chip opens its diff — green added, red removed */-type DiffLine = { text: string; tone: "add" | "del" | "ctx" };-const DIFF_LINES: Record<string, DiffLine[]> = {- "flavors.css": [- { text: ".scoop-card {", tone: "ctx" },- { text: " gap: 14px;", tone: "del" },- { text: " gap: 12px;", tone: "add" },- { text: " container-type: inline-size;", tone: "add" },- { text: "}", tone: "ctx" },- ],- "ChurnSchedule.tsx": [- { text: "const slots = coldSlots(week);", tone: "ctx" },- { text: "const windows = slots;", tone: "del" },- { text: "const windows = slots.filter(", tone: "add" },- { text: " (s) => s.temp <= -12,", tone: "add" },- { text: ");", tone: "add" },- ],- "menu.ts": [- { text: "export const hero = \"mint-chip\";", tone: "del" },- { text: "export const hero = \"pistachio\";", tone: "add" },- ],-};-export type LiveToolRow = {id?: string;icon: string;@@ -126,9 +128,9 @@ export default function ToolChips({const live = liveRows !== undefined;const rows = live ? liveRows : ROWS;const diffs = live ? (liveDiffs ?? []) : DIFFS;- const diffLines: Record<string, { text: string; tone: "add" | "del" | "ctx" }[]> = live- ? Object.fromEntries((liveDiffs ?? []).map((d) => [d.file, d.lines ?? []]))- : DIFF_LINES;+ const pathPeers = rows.flatMap((row) =>+ "path" in row && row.path && row.chip === row.path ? [row.path] : [],+ );const [step, setStep] = useState(0);const [page, setPage] = useState(0);const pageSize = 50;@@ -145,28 +147,6 @@ export default function ToolChips({// Disclosure belongs to the reader. New calls and completion never change it.const showHeader = true;const [openRows, setOpenRows] = useState<Set<string>>(new Set());- /* Rendered in a body portal so animated/translated reply wrappers cannot- * redefine the fixed-position coordinate system. */- const [preview, setPreview] = useState<{- file: string;- x: number;- top?: number;- bottom?: number;- } | null>(null);- const openPreview = (file: string) => (event: React.SyntheticEvent) => {- const rect = (event.currentTarget as Element).closest("[data-diffchip]")!.getBoundingClientRect();- const previewHeight = 38 + (diffLines[file]?.length ?? 0) * 19;- const fitsBelow = rect.bottom + 6 + previewHeight <= window.innerHeight - 12;- setPreview({- file,- x: Math.max(12, Math.min(rect.left, window.innerWidth - 300)),- ...(fitsBelow- ? { top: rect.bottom + 6 }- : { bottom: window.innerHeight - rect.top + 6 }),- });- };- const closePreview = (file: string) => () =>- setPreview((current) => (current?.file === file ? null : current));const total = live ? rows.length : ROWS.length + 1; // rows, then diff chipsuseEffect(() => {@@ -284,7 +264,7 @@ export default function ToolChips({text-[12px] text-ink shadow-hairline transition-colors duration-100 hover:bg-hover-2${row.mono ? "font-mono" : ""} ${onOpenPath && "path" in row && row.path ? "cursor-pointer" : ""}`}>- {row.chip}+ {"path" in row && row.path && row.chip === row.path ? shortPath(row.path, pathPeers) : row.chip}</span></>) : (@@ -312,76 +292,9 @@ export default function ToolChips({</div></div>}- {/* file-diff chips — sit outside the disclosure so a collapsed run still shows what changed */}+ {/* A few short names. A long edit list folds; the full paths stay on hover. */}{(live ? diffs.length > 0 : step >= total) && (- <div className="mt-2.5 flex max-w-full flex-wrap gap-1.5 border-t border-line pt-2.5">- {diffs.map((d, i) => (- <span- key={d.file}- data-diffchip- className="relative"- onMouseEnter={openPreview(d.file)}- onMouseLeave={closePreview(d.file)}- >- <button- type="button"- aria-expanded={preview?.file === d.file}- aria-label={`Show diff for ${d.file}`}- onFocus={openPreview(d.file)}- onBlur={closePreview(d.file)}- onClick={onOpenPath ? () => onOpenPath(d.file) : undefined}- className="inline-flex h-7 max-w-full items-center gap-1.5 rounded-chip- bg-surface px-2 font-mono text-[11.5px] text-ink shadow-btn- transition-colors duration-100 hover:bg-hover"- style={{ animation: `pop-in 250ms cubic-bezier(0.23,1,0.32,1) ${i * 80}ms both` }}- >- <span className="min-w-0 truncate">{d.file}</span>- <span className="shrink-0 text-green tabular-nums">+{d.add}</span>- {d.del > 0 && <span className="shrink-0 text-red tabular-nums">−{d.del}</span>}- </button>- </span>- ))}- </div>- )}- {preview && typeof document !== "undefined" && createPortal(- <div- className="fixed z-50 w-72 overflow-hidden rounded-[10px] bg-surface shadow-overlay"- style={{- left: preview.x,- top: preview.top,- bottom: preview.bottom,- animation: "pop-in 160ms cubic-bezier(0.23,1,0.32,1) both",- transformOrigin: preview.top === undefined ? "bottom left" : "top left",- }}- >- <div className="flex items-center justify-between border-b border-line px-2.5 py-1.5 font-mono text-[11px]">- <span className="min-w-0 truncate text-ink-2">{preview.file}</span>- <span className="shrink-0 tabular-nums">- <span className="text-green">+{diffs.find((diff) => diff.file === preview.file)?.add}</span>- {(diffs.find((diff) => diff.file === preview.file)?.del ?? 0) > 0 && (- <span className="text-red"> −{diffs.find((diff) => diff.file === preview.file)?.del}</span>- )}- </span>- </div>- <div className="py-1 font-mono text-[11px] leading-[1.8]">- {(diffLines[preview.file] ?? []).map((line, index) => (- <div- key={index}- className={`flex gap-2 px-2.5 whitespace-pre ${- line.tone === "add"- ? "bg-green-tint text-green"- : line.tone === "del"- ? "bg-red-tint text-red"- : "text-ink-2"- }`}- >- <span className="w-3 shrink-0 select-none">{line.tone === "add" ? "+" : line.tone === "del" ? "−" : " "}</span>- <span className="min-w-0 truncate">{line.text}</span>- </div>- ))}- </div>- </div>,- document.body,+ <DiffChipStrip diffs={diffs} onOpenPath={onOpenPath} />)}</div>);diff --git a/apps/native/lib/diff-chip-label.test.ts b/apps/native/lib/diff-chip-label.test.tsnew file mode 100644index 00000000..76c9f828--- /dev/null+++ b/apps/native/lib/diff-chip-label.test.ts@@ -0,0 +1,26 @@+import { describe, it } from "node:test";+import assert from "node:assert/strict";+import { DIFF_CHIP_CAP, diffChipLabels, fileBase, meaningfulDiffStat, shortPath } from "./diff-chip-label.ts";++const prefix = "codegraff/.worktrees/desktop-task-workspaces/gui/src/";++describe("diff chip labels", () => {+ it("uses the basename, not the worktree prefix", () => {+ assert.equal(fileBase(prefix + "styles/core.css"), "core.css");+ assert.deepEqual(diffChipLabels([prefix + "styles/core.css", prefix + "lib.rs"]), ["core.css", "lib.rs"]);+ });++ it("keeps the parent when basenames collide", () => {+ const files = [prefix + "dto/mod.rs", prefix + "runtime/mod.rs", prefix + "app/mod.rs"];+ assert.deepEqual(diffChipLabels(files), ["dto/mod.rs", "runtime/mod.rs", "app/mod.rs"]);+ assert.equal(shortPath(files[1], files), "runtime/mod.rs");+ });++ it("treats the placeholder +1 −1 as not a measured stat", () => {+ assert.equal(meaningfulDiffStat(1, 1), false);+ assert.equal(meaningfulDiffStat(1, 0), false);+ assert.equal(meaningfulDiffStat(13, 0), true);+ assert.equal(meaningfulDiffStat(2, 4), true);+ assert.equal(DIFF_CHIP_CAP, 3);+ });+});diff --git a/apps/native/lib/diff-chip-label.ts b/apps/native/lib/diff-chip-label.tsnew file mode 100644index 00000000..377ab3b9--- /dev/null+++ b/apps/native/lib/diff-chip-label.ts@@ -0,0 +1,39 @@+/** Short labels for transcript file chips. A wall of worktree prefixes is noise. */++export const DIFF_CHIP_CAP = 3;++export function pathParts(file: string): string[] {+ return file.split(/[/\\]/).filter(Boolean);+}++export function fileBase(file: string): string {+ const parts = pathParts(file);+ return parts[parts.length - 1] || file;+}++/** Basename, or `parent/basename` when two chips would otherwise collide. */+export function diffChipLabels(files: string[]): string[] {+ const bases = files.map(fileBase);+ return files.map((file, index) => {+ const base = bases[index];+ if (!base || bases.filter((item) => item === base).length < 2) return base || file;+ const parts = pathParts(file);+ const peers = files.filter((_, peer) => bases[peer] === base);+ for (let depth = 2; depth <= parts.length; depth++) {+ const label = parts.slice(-depth).join("/");+ const same = peers.filter((peer) => pathParts(peer).slice(-depth).join("/") === label);+ if (same.length === 1) return label;+ }+ return file;+ });+}++export function shortPath(file: string, peers: string[]): string {+ const index = peers.indexOf(file);+ return index >= 0 ? diffChipLabels(peers)[index] : fileBase(file);+}++/** ACP stamps every edit +1 −1. That pair is not a measured diff. */+export function meaningfulDiffStat(add: number, del: number): boolean {+ return add > 1 || del > 1;+}diff --git a/apps/native/lib/diff-chip-strip.test.tsx b/apps/native/lib/diff-chip-strip.test.tsxnew file mode 100644index 00000000..2d1fd57f--- /dev/null+++ b/apps/native/lib/diff-chip-strip.test.tsx@@ -0,0 +1,32 @@+import { expect, test } from "bun:test";+import { renderToStaticMarkup } from "react-dom/server";+import ToolChips from "../components/primitives/ToolChips";++const prefix = "codegraff/.worktrees/desktop-task-workspaces/gui/src/";+const files = ["a.ts", "b.ts", "c.ts", "d.ts", "e.ts", "f.ts", "g.ts", "h.ts"];++test("a long edit list stays a few short chips, not a path wall", () => {+ const html = renderToStaticMarkup(+ <ToolChips+ rows={[]}+ diffs={files.map((file) => ({ file: prefix + file, add: 1, del: 1 }))}+ />,+ );+ expect(html.match(/data-diffchip/g)?.length).toBe(3);+ expect(html).toContain("data-diff-more");+ expect(html).toContain("+5");+ expect(html).toContain(">a.ts</span>");+ expect(html).not.toContain(`>${prefix}`);+ expect(html).not.toContain("data-diff-stat");+});++test("a handful of files still shows a measured count", () => {+ const html = renderToStaticMarkup(+ <ToolChips rows={[]} diffs={[{ file: "flavors.css", add: 13, del: 0 }]} />,+ );+ expect(html.match(/data-diffchip/g)?.length).toBe(1);+ expect(html).not.toContain("data-diff-more");+ expect(html).toContain("data-diff-stat");+ expect(html).toContain("+13");+});+diff --git a/apps/native/package.json b/apps/native/package.jsonindex 3aaa7162..c68db358 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/motion-throttle.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/queued-attachments.test.ts lib/idle-http.test.ts lib/composer-model-pick.test.ts lib/composer-keyboard.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 lib/close-confirm.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/diff-chip-label.test.ts lib/motion-throttle.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/queued-attachments.test.ts lib/idle-http.test.ts lib/composer-model-pick.test.ts lib/composer-keyboard.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 lib/close-confirm.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",diff --git a/docs/uxlog.md b/docs/uxlog.mdindex a95f8016..ac1f9d7b 100644--- a/docs/uxlog.md+++ b/docs/uxlog.md@@ -6,6 +6,17 @@ UX = how it behaves. Add an entry whenever a change alters what the usersees or how an interaction flows — small entries are fine; the point isthat "why does it work this way?" always has an answer here.+## 2026-09-22++### File chips stop shouting the worktree (UI)+A collapsed run was still a wall of full-width pills — the same+`.worktrees/…` prefix on every row, plus a green/red +1 −1 that ACP stamps+on every edit whether or not it measured a diff. The transcript now shows+three short names (`core.css`, `dto/mod.rs` when basenames collide) and a+`+N` for the rest. The full path stays on the chip title and the hover+preview. Opening the tool list uses the same short name, so expanding+"Edited 54" is a list of files, not a list of worktree prefixes.+## 2026-08-21### Transcript is the task, not the event bus (UI)