Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(agents): the run page is a dossier — numbered registers, the agent's own report, a file ledger from the diff

rubenluetke10-beep090a95fcc936
diff --git a/jarvis/missions/diff_summary.py b/jarvis/missions/diff_summary.py
new file mode 100644
index 0000000000..ae1688788f
--- /dev/null
+++ b/jarvis/missions/diff_summary.py
@@ -0,0 +1,188 @@
+"""Turn a mission's archived worker diff into a per-file ledger.
+
+Every mission archives what its worker changed as a unified diff under
+``tasks/<task_id>/artifacts/diff.patch`` (``diff.iter<N>.patch`` per critic
+round). That file is the most concrete record of what an agent actually did —
+more concrete than its own report, which is prose — but a 60 KB patch is not
+something a person reads. This module reduces it to what a person asks:
+which files, new or changed, how much.
+
+Pure text parsing, bounded reads, no IO beyond the mission directory. The
+``WorkerDraftReady`` event carries the same diff capped at 8 000 characters
+(orchestrator), which is why the ledger reads the file on disk instead.
+"""
+
+from __future__ import annotations
+
+import re
+from pathlib import Path
+from typing import Any, Final
+
+_MISSION_ID_RE = re.compile(r"^[0-9a-f-]{6,64}$", re.IGNORECASE)
+_MAX_READ_BYTES: Final[int] = 4 * 1_048_576
+_MAX_FILES: Final[int] = 400
+
+_GIT_HEADER = re.compile(r"^diff --git a/(?P<a>.+?) b/(?P<b>.+)$")
+_RENAME_FROM = re.compile(r"^rename from (?P<path>.+)$")
+_RENAME_TO = re.compile(r"^rename to (?P<path>.+)$")
+
+
+def summarize_unified_diff(text: str) -> dict[str, Any]:
+ """Reduce one unified diff to ``{files, additions, deletions, truncated_files}``.
+
+ Each file: ``path`` (the new path), ``previous_path`` for a rename,
+ ``status`` in ``added | modified | deleted | renamed``, ``additions``,
+ ``deletions`` and ``binary``. Sections that are not ``diff --git`` blocks
+ (a worker-authored evidence pseudo-diff, for example) are skipped rather
+ than miscounted.
+ """
+ files: list[dict[str, Any]] = []
+ current: dict[str, Any] | None = None
+ in_hunk = False
+ truncated_files = False
+
+ for raw in text.splitlines():
+ header = _GIT_HEADER.match(raw)
+ if header:
+ if len(files) >= _MAX_FILES:
+ truncated_files = True
+ current = None
+ in_hunk = False
+ continue
+ current = {
+ "path": header.group("b"),
+ "previous_path": None,
+ "status": "modified",
+ "additions": 0,
+ "deletions": 0,
+ "binary": False,
+ }
+ files.append(current)
+ in_hunk = False
+ continue
+ if raw.startswith("diff "):
+ # Some other diff flavour (``diff --desktop-action-evidence``):
+ # not a file, and its lines must not be counted against one.
+ current = None
+ in_hunk = False
+ continue
+ if current is None:
+ continue
+ if not in_hunk:
+ if raw.startswith("new file mode"):
+ current["status"] = "added"
+ elif raw.startswith("deleted file mode"):
+ current["status"] = "deleted"
+ elif raw.startswith("Binary files"):
+ current["binary"] = True
+ elif m := _RENAME_FROM.match(raw):
+ current["previous_path"] = m.group("path")
+ current["status"] = "renamed"
+ elif m := _RENAME_TO.match(raw):
+ current["path"] = m.group("path")
+ current["status"] = "renamed"
+ elif raw.startswith("@@"):
+ in_hunk = True
+ continue
+ if raw.startswith("@@"):
+ continue
+ if raw.startswith("+") and not raw.startswith("+++"):
+ current["additions"] += 1
+ elif raw.startswith("-") and not raw.startswith("---"):
+ current["deletions"] += 1
+
+ return {
+ "files": files,
+ "additions": sum(f["additions"] for f in files),
+ "deletions": sum(f["deletions"] for f in files),
+ "truncated_files": truncated_files,
+ }
+
+
+def _final_patch(artifacts_dir: Path) -> Path | None:
+ """``diff.patch`` when present, else the highest ``diff.iter<N>.patch``."""
+ final = artifacts_dir / "diff.patch"
+ if final.is_file():
+ return final
+ best: tuple[int, Path] | None = None
+ try:
+ for candidate in artifacts_dir.glob("diff.iter*.patch"):
+ m = re.search(r"iter(\d+)", candidate.name)
+ if not m:
+ continue
+ n = int(m.group(1))
+ if best is None or n > best[0]:
+ best = (n, candidate)
+ except OSError:
+ return None
+ return best[1] if best else None
+
+
+def read_mission_changes(outputs_root: Path, mission_id: str) -> dict[str, Any]:
+ """The file ledger for one mission across all of its tasks.
+
+ Mirrors :func:`jarvis.missions.result_reader.read_mission_artifacts`: the
+ directory is derived from the already-authorized mission id, never from a
+ caller-supplied path, and must stay under the outputs root.
+ """
+ empty: dict[str, Any] = {
+ "tasks": [],
+ "files": [],
+ "additions": 0,
+ "deletions": 0,
+ "truncated": False,
+ }
+ clean_id = str(mission_id or "").strip()
+ if not _MISSION_ID_RE.fullmatch(clean_id):
+ return empty
+ root = Path(outputs_root).resolve()
+ mission_dir = (root / f"mission_{clean_id[:13]}").resolve()
+ try:
+ mission_dir.relative_to(root)
+ except ValueError:
+ return empty
+ if not mission_dir.is_dir():
+ return empty
+
+ tasks: list[dict[str, Any]] = []
+ merged: list[dict[str, Any]] = []
+ truncated = False
+ try:
+ task_dirs = sorted(p for p in (mission_dir / "tasks").iterdir() if p.is_dir())
+ except OSError:
+ return empty
+
+ for task_dir in task_dirs:
+ patch = _final_patch(task_dir / "artifacts")
+ if patch is None:
+ continue
+ try:
+ with patch.open("rb") as handle:
+ raw = handle.read(_MAX_READ_BYTES + 1)
+ except OSError:
+ continue
+ was_cut = len(raw) > _MAX_READ_BYTES
+ summary = summarize_unified_diff(raw[:_MAX_READ_BYTES].decode("utf-8", errors="replace"))
+ truncated = truncated or was_cut or bool(summary["truncated_files"])
+ tasks.append(
+ {
+ "task_id": task_dir.name,
+ "patch": patch.name,
+ "files": summary["files"],
+ "additions": summary["additions"],
+ "deletions": summary["deletions"],
+ "truncated": was_cut or bool(summary["truncated_files"]),
+ }
+ )
+ merged.extend(summary["files"])
+
+ return {
+ "tasks": tasks,
+ "files": merged,
+ "additions": sum(f["additions"] for f in merged),
+ "deletions": sum(f["deletions"] for f in merged),
+ "truncated": truncated,
+ }
+
+
+__all__ = ["read_mission_changes", "summarize_unified_diff"]
diff --git a/jarvis/ui/web/frontend/src/components/missions/api.ts b/jarvis/ui/web/frontend/src/components/missions/api.ts
index 3640bec03b..c0cf19b470 100644
--- a/jarvis/ui/web/frontend/src/components/missions/api.ts
+++ b/jarvis/ui/web/frontend/src/components/missions/api.ts
@@ -6,6 +6,7 @@
import type {
CriticVerdictReady,
EventEnvelope,
+ MissionChanges,
MissionDetail,
MissionResult,
MissionSummary,
@@ -52,6 +53,11 @@ export async function fetchMissionResult(id: string): Promise<MissionResult> {
return requestJson(`${API_BASE}/${encodeURIComponent(id)}/result`);
}
+/** The per-file ledger of what the workers changed (from the archived diff). */
+export async function fetchMissionChanges(id: string): Promise<MissionChanges> {
+ return requestJson(`${API_BASE}/${encodeURIComponent(id)}/changes`);
+}
+
export function missionToolApprovalsQueryKey(missionId: string | null) {
return ["missions", "tool-approvals", missionId] as const;
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index ef7bbce45f..862a5dc061 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -759,7 +759,6 @@
},
"insight_loading": "Der Verlauf des Laufs wird gelesen…",
"insight_load_error": "Der Verlauf des Laufs konnte nicht geladen werden: {detail}",
- "action_open_output": "Ergebnis öffnen",
"action_map": "Missionskarte",
"no_output_dir": "Ausgabeordner liegt nicht mehr auf der Platte",
"stat_cost_label": "Kosten",
@@ -818,7 +817,6 @@
"transcript_no_dir": "Das vollständige Worker-Transkript ist mit dem Ausgabeordner verschwunden — die Schritte oben decken weiterhin jedes Ereignis des Laufs ab.",
"transcript_truncated": "Das Transkript war länger als hier gezeigt.",
"transcript_dropped": "{n} weitere Schritte werden nicht gezeigt.",
- "final_answer": "Abschließende Antwort",
"step_status": {
"pending": "Ausstehend",
"running": "Läuft",
@@ -844,9 +842,6 @@
"details_title": "Details",
"live_title": "Gerade jetzt",
"live_subtitle": "Tool-Aufrufe, die der Agent in diesem Moment ausführt.",
- "timeline_title": "Schritt für Schritt",
- "timeline_subtitle": "Was {agent} gesagt und getan hat, der Reihe nach.",
- "output_title": "Was herausgekommen ist",
"actions_one": "1 Aktion ausgeführt",
"actions_many": "{n} Aktionen in {span} ausgeführt",
"transcript_fold": "Vollständiges Worker-Transkript · {n} Schritte",
@@ -889,6 +884,39 @@
"failed_worker_error": "Der Worker-Prozess ist abgestürzt. Es wurde nichts geliefert.",
"failed_after_review": "Der Worker hat einen Entwurf abgeliefert, aber der Prüfer hat ihn nicht abgenommen — dort endete der Lauf.",
"failed_generic": "Die Aufgabe des Workers ist nach {runtime} fehlgeschlagen. Es wurde nichts geliefert."
+ },
+ "action_open_artifacts": "In Artefakten öffnen",
+ "register_verdict": "Was passiert ist",
+ "register_report": "Bericht von {agent}",
+ "register_timeline": "Zeitverlauf",
+ "register_files": "Dateien",
+ "timeline_meta": "{n} aufgezeichnete Ereignisse",
+ "files_meta": "{n} Dateien · +{add} −{del} Zeilen",
+ "fact_files": "Dateien",
+ "confidence": "{pct} % Sicherheit",
+ "report_expand": "Ganzen Bericht lesen",
+ "report_collapse": "Bericht einklappen",
+ "kind": {
+ "start": "Start",
+ "plan": "Plan",
+ "worker": "Worker",
+ "said": "Sagte",
+ "ran": "Lief",
+ "draft": "Entwurf",
+ "review": "Prüfung",
+ "fix": "Korrektur",
+ "stop": "Stopp",
+ "end": "Ende",
+ "budget": "Budget",
+ "thought": "Gedanke"
+ },
+ "change": {
+ "added": "Neue Datei",
+ "modified": "Geändert",
+ "deleted": "Gelöscht",
+ "renamed": "Umbenannt",
+ "delivered": "Geliefert",
+ "binary": "binär"
}
},
"tasks_view": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 862a25fad9..d5e7aae9ea 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -759,7 +759,6 @@
},
"insight_loading": "Reading the run's record…",
"insight_load_error": "The run's record could not be loaded: {detail}",
- "action_open_output": "Open output",
"action_map": "Mission map",
"no_output_dir": "output directory no longer on disk",
"stat_cost_label": "Cost",
@@ -818,7 +817,6 @@
"transcript_no_dir": "The worker's full transcript went with the output folder — the steps above still cover every event of the run.",
"transcript_truncated": "The transcript was longer than what is shown.",
"transcript_dropped": "{n} more steps are not shown.",
- "final_answer": "Final answer",
"step_status": {
"pending": "Pending",
"running": "Running",
@@ -844,9 +842,6 @@
"details_title": "Details",
"live_title": "Right now",
"live_subtitle": "Tool calls the agent is running at this moment.",
- "timeline_title": "Step by step",
- "timeline_subtitle": "What {agent} said and did, in order.",
- "output_title": "What came out",
"actions_one": "Ran 1 action",
"actions_many": "Ran {n} actions in {span}",
"transcript_fold": "Full worker transcript · {n} steps",
@@ -889,6 +884,39 @@
"failed_worker_error": "The worker process crashed. Nothing was delivered.",
"failed_after_review": "The worker produced a draft, but the reviewer did not approve it and the run ended there.",
"failed_generic": "The worker's task failed after {runtime}. Nothing was delivered."
+ },
+ "action_open_artifacts": "Open in Artifacts",
+ "register_verdict": "What happened",
+ "register_report": "{agent}'s report",
+ "register_timeline": "Timeline",
+ "register_files": "Files",
+ "timeline_meta": "{n} recorded events",
+ "files_meta": "{n} files · +{add} −{del} lines",
+ "fact_files": "Files",
+ "confidence": "{pct}% confidence",
+ "report_expand": "Read the full report",
+ "report_collapse": "Collapse the report",
+ "kind": {
+ "start": "Start",
+ "plan": "Plan",
+ "worker": "Worker",
+ "said": "Said",
+ "ran": "Ran",
+ "draft": "Draft",
+ "review": "Review",
+ "fix": "Fix",
+ "stop": "Stop",
+ "end": "End",
+ "budget": "Budget",
+ "thought": "Thought"
+ },
+ "change": {
+ "added": "New file",
+ "modified": "Changed",
+ "deleted": "Deleted",
+ "renamed": "Renamed",
+ "delivered": "Delivered",
+ "binary": "binary"
}
},
"tasks_view": {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index b237b1f93a..89a7f81390 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -759,7 +759,6 @@
},
"insight_loading": "Leyendo el registro de la ejecución…",
"insight_load_error": "No se pudo cargar el registro de la ejecución: {detail}",
- "action_open_output": "Abrir resultado",
"action_map": "Mapa de la misión",
"no_output_dir": "la carpeta de salida ya no está en el disco",
"stat_cost_label": "Coste",
@@ -818,7 +817,6 @@
"transcript_no_dir": "La transcripción completa del worker se fue con la carpeta de salida — los pasos de arriba siguen cubriendo cada evento de la ejecución.",
"transcript_truncated": "La transcripción era más larga de lo que se muestra.",
"transcript_dropped": "{n} pasos más no se muestran.",
- "final_answer": "Respuesta final",
"step_status": {
"pending": "Pendiente",
"running": "En marcha",
@@ -844,9 +842,6 @@
"details_title": "Detalles",
"live_title": "Ahora mismo",
"live_subtitle": "Llamadas a herramientas que el agente ejecuta en este momento.",
- "timeline_title": "Paso a paso",
- "timeline_subtitle": "Lo que {agent} dijo e hizo, en orden.",
- "output_title": "Lo que salió",
"actions_one": "Ejecutó 1 acción",
"actions_many": "Ejecutó {n} acciones en {span}",
"transcript_fold": "Transcripción completa del worker · {n} pasos",
@@ -889,6 +884,39 @@
"failed_worker_error": "El proceso del worker falló. No se entregó nada.",
"failed_after_review": "El worker produjo un borrador, pero el revisor no lo aprobó y la ejecución terminó ahí.",
"failed_generic": "La tarea del worker falló tras {runtime}. No se entregó nada."
+ },
+ "action_open_artifacts": "Abrir en Artefactos",
+ "register_verdict": "Qué pasó",
+ "register_report": "Informe de {agent}",
+ "register_timeline": "Cronología",
+ "register_files": "Archivos",
+ "timeline_meta": "{n} eventos registrados",
+ "files_meta": "{n} archivos · +{add} −{del} líneas",
+ "fact_files": "Archivos",
+ "confidence": "{pct} % de confianza",
+ "report_expand": "Leer el informe completo",
+ "report_collapse": "Plegar el informe",
+ "kind": {
+ "start": "Inicio",
+ "plan": "Plan",
+ "worker": "Worker",
+ "said": "Dijo",
+ "ran": "Ejecutó",
+ "draft": "Borrador",
+ "review": "Revisión",
+ "fix": "Corrección",
+ "stop": "Parada",
+ "end": "Fin",
+ "budget": "Presupuesto",
+ "thought": "Pensó"
+ },
+ "change": {
+ "added": "Archivo nuevo",
+ "modified": "Modificado",
+ "deleted": "Eliminado",
+ "renamed": "Renombrado",
+ "delivered": "Entregado",
+ "binary": "binario"
}
},
"tasks_view": {
diff --git a/jarvis/ui/web/frontend/src/types/missions.ts b/jarvis/ui/web/frontend/src/types/missions.ts
index 877cd11d4f..f0b81b7290 100644
--- a/jarvis/ui/web/frontend/src/types/missions.ts
+++ b/jarvis/ui/web/frontend/src/types/missions.ts
@@ -277,6 +277,33 @@ export interface MissionArtifact {
truncated: boolean;
}
+/** One file of the worker's archived diff — mirror of jarvis/missions/diff_summary.py. */
+export interface MissionChangedFile {
+ path: string;
+ previous_path: string | null;
+ status: "added" | "modified" | "deleted" | "renamed";
+ additions: number;
+ deletions: number;
+ binary: boolean;
+}
+
+/** Mirror of `get_mission_changes` in jarvis/ui/web/missions_routes.py. */
+export interface MissionChanges {
+ mission_id: string;
+ tasks: Array<{
+ task_id: string;
+ patch: string;
+ files: MissionChangedFile[];
+ additions: number;
+ deletions: number;
+ truncated: boolean;
+ }>;
+ files: MissionChangedFile[];
+ additions: number;
+ deletions: number;
+ truncated: boolean;
+}
+
/** Mirror of `get_mission_result` in jarvis/ui/web/missions_routes.py. */
export interface MissionResult {
mission_id: string;
diff --git a/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.test.tsx b/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.test.tsx
index 2515f27d52..8aed92817c 100644
--- a/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.test.tsx
@@ -85,8 +85,22 @@ const RESULT = {
summary: null,
result_uri: null,
reason: "task_error",
- artifacts: [],
- artifact_count: 0,
+ artifacts: [
+ { path: "tasks/t/artifacts/files/index.html", deliverable_path: "index.html", size: 2048, is_text: true, content: "<html>", truncated: false },
+ ],
+ artifact_count: 1,
+ truncated: false,
+};
+
+const CHANGES = {
+ mission_id: MISSION_ID,
+ tasks: [],
+ files: [
+ { path: "index.html", previous_path: null, status: "added", additions: 120, deletions: 0, binary: false },
+ { path: "README.md", previous_path: null, status: "modified", additions: 4, deletions: 2, binary: false },
+ ],
+ additions: 124,
+ deletions: 2,
truncated: false,
};
@@ -100,13 +114,13 @@ const PLAN = {
{ step_id: "t:0", name: "I will look at the workspace first.", kind: "reasoning", status: "done", output: "I will look at the workspace first.", task_key: "t" },
{ step_id: "t:1", name: "jarvis/ui", tool_name: "Grep", kind: "tool", status: "failed", error: "quota", task_key: "t" },
],
- final_answer: null,
+ final_answer: "## Done\n\nI built the **page** and wrote it to `index.html`.",
truncated: false,
dropped_steps: 0,
};
-function jsonResponse(body: unknown): Response {
- return new Response(JSON.stringify(body), { status: 200, headers: { "Content-Type": "application/json" } });
+function jsonResponse(body: unknown, status = 200): Response {
+ return new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });
}
function agentNode(over: Partial<SubAgentNode> = {}): SubAgentNode {
@@ -142,21 +156,25 @@ function renderWithQuery(ui: ReactElement) {
return render(<QueryClientProvider client={client}>{ui}</QueryClientProvider>);
}
-describe("AgentInsight", () => {
- beforeEach(() => {
- vi.stubGlobal(
- "fetch",
- vi.fn(async (input: RequestInfo | URL) => {
- const url = String(input);
- if (url.endsWith(`/api/missions/${MISSION_ID}/result`)) return jsonResponse(RESULT);
- if (url.endsWith(`/api/missions/${MISSION_ID}`)) return jsonResponse(DETAIL);
- if (url.endsWith("/api/outputs")) return jsonResponse(OUTPUTS);
- if (url.endsWith("/api/outputs/mission_019fecaa-5a92/plan")) return jsonResponse(PLAN);
- return new Response("not found", { status: 404 });
- }),
- );
- });
+function stubFetch(opts: { changes: "ok" | "missing" } = { changes: "ok" }) {
+ vi.stubGlobal(
+ "fetch",
+ vi.fn(async (input: RequestInfo | URL) => {
+ const url = String(input);
+ if (url.endsWith(`/api/missions/${MISSION_ID}/result`)) return jsonResponse(RESULT);
+ if (url.endsWith(`/api/missions/${MISSION_ID}/changes`)) {
+ return opts.changes === "ok" ? jsonResponse(CHANGES) : jsonResponse({ detail: "Not Found" }, 404);
+ }
+ if (url.endsWith(`/api/missions/${MISSION_ID}`)) return jsonResponse(DETAIL);
+ if (url.endsWith("/api/outputs")) return jsonResponse(OUTPUTS);
+ if (url.endsWith("/api/outputs/mission_019fecaa-5a92/plan")) return jsonResponse(PLAN);
+ return new Response("not found", { status: 404 });
+ }),
+ );
+}
+describe("AgentInsight", () => {
+ beforeEach(() => stubFetch());
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
@@ -166,49 +184,85 @@ describe("AgentInsight", () => {
renderWithQuery(<AgentInsight agent={agentNode()} onBack={() => {}} onOpenOutput={() => {}} />);
expect(await screen.findByText("Did not deliver")).toBeTruthy();
- expect(
- await screen.findByText(/stopped because the provider \(claude\) ran out of quota/i),
- ).toBeTruthy();
- // Quoted in the verdict card; the timeline's kill and failure rows do
- // NOT repeat it (the note before them already said it).
+ expect(await screen.findByText(/stopped because the provider \(claude\) ran out of quota/i)).toBeTruthy();
+ // Quoted in register 01; the timeline's kill and failure rows do NOT
+ // repeat it (the note before them already said it).
expect(screen.getByText("Provider said")).toBeTruthy();
expect(screen.getAllByText("You've reached your limit.")).toHaveLength(2);
- // No jargon table: the raw tokens live behind "Details".
- expect(screen.queryByText("Broke during")).toBeNull();
+ // Raw tokens live behind "Details", not in the verdict.
expect(screen.getByText(/task_error · provider_quota · CRITIQUING/)).toBeTruthy();
});
- it("folds consecutive tool calls into one timeline block", async () => {
+ it("numbers the registers in order and folds the report past a screenful", async () => {
+ renderWithQuery(<AgentInsight agent={agentNode()} onBack={() => {}} onOpenOutput={() => {}} />);
+ await screen.findByText(/ran out of quota/i);
+
+ expect(screen.getByRole("heading", { name: "What happened" })).toBeTruthy();
+ expect(await screen.findByRole("heading", { name: /'s report$/ })).toBeTruthy();
+ expect(screen.getByRole("heading", { name: "Timeline" })).toBeTruthy();
+ // "Files" is also a fact label in register 01 — the heading is the register.
+ expect(await screen.findByRole("heading", { name: "Files" })).toBeTruthy();
+ // The report is rendered Markdown, not raw text.
+ expect(screen.getByRole("heading", { name: "Done" })).toBeTruthy();
+ expect(screen.getByText("page", { selector: "strong" })).toBeTruthy();
+ });
+
+ it("folds consecutive tool calls into one ledger line", async () => {
renderWithQuery(<AgentInsight agent={agentNode()} onBack={() => {}} onOpenOutput={() => {}} />);
- await screen.findByText("Did not deliver");
+ await screen.findByText(/ran out of quota/i);
const fold = await screen.findByRole("button", { name: /Ran 3 actions/ });
expect(screen.getByText("×2")).toBeTruthy(); // Grep ran twice
expect(screen.queryByText("jarvis/core")).toBeNull();
fireEvent.click(fold);
expect(screen.getByText("jarvis/core")).toBeTruthy();
- // The worker's own words stand alone as a quote.
+ // The worker's own words stand alone, labelled by who said them.
expect(screen.getByText("I will look at the workspace first.")).toBeTruthy();
+ expect(screen.getAllByText("Said").length).toBeGreaterThan(0);
+ });
+
+ it("lists the changed files with their line counts and opens Artifacts from a row", async () => {
+ const opened: string[] = [];
+ renderWithQuery(<AgentInsight agent={agentNode()} onBack={() => {}} onOpenOutput={(s) => opened.push(s)} />);
+
+ expect(await screen.findByText("README.md")).toBeTruthy();
+ expect(screen.getByText("+120")).toBeTruthy();
+ expect(screen.getByText("−2")).toBeTruthy();
+ expect(screen.getByText("2 files · +124 −2 lines")).toBeTruthy();
+ fireEvent.click(screen.getByText("README.md"));
+ expect(opened).toEqual(["mission_019fecaa-5a92"]);
+ });
+
+ it("falls back to the deliverable list when the backend has no /changes route", async () => {
+ vi.unstubAllGlobals();
+ stubFetch({ changes: "missing" });
+ renderWithQuery(<AgentInsight agent={agentNode()} onBack={() => {}} onOpenOutput={() => {}} />);
+
+ expect(await screen.findByText("index.html")).toBeTruthy();
+ expect(screen.getByText("2.0 KB")).toBeTruthy();
+ expect(screen.queryByText("README.md")).toBeNull();
+ expect(screen.getByText("1 deliverable file(s)")).toBeTruthy();
});
- it("hands the archived output slug to the Artifacts section", async () => {
+ it("hands the archived output slug to the Artifacts section from the masthead", async () => {
const opened: string[] = [];
renderWithQuery(<AgentInsight agent={agentNode()} onBack={() => {}} onOpenOutput={(s) => opened.push(s)} />);
- const button = await screen.findByRole("button", { name: /open output/i });
- await waitFor(() => expect((button as HTMLButtonElement).disabled).toBe(false));
- fireEvent.click(button);
+ const buttons = await screen.findAllByRole("button", { name: /open in artifacts/i });
+ await waitFor(() => expect((buttons[0] as HTMLButtonElement).disabled).toBe(false));
+ fireEvent.click(buttons[0]);
expect(opened).toEqual(["mission_019fecaa-5a92"]);
});
it("keeps the worker transcript folded away under the timeline", async () => {
renderWithQuery(<AgentInsight agent={agentNode()} onBack={() => {}} onOpenOutput={() => {}} />);
- await screen.findByText("Did not deliver");
+ await screen.findByText(/ran out of quota/i);
const fold = await screen.findByRole("button", { name: /transcript · 2 steps/i });
expect(screen.queryByText("quota")).toBeNull();
fireEvent.click(fold);
expect(screen.getByText("quota")).toBeTruthy();
+ expect(screen.getByText("Thought")).toBeTruthy();
});
it("goes back to the board", async () => {
diff --git a/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.tsx b/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.tsx
index 5feb5c74e5..a7be1e7a74 100644
--- a/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.tsx
+++ b/jarvis/ui/web/frontend/src/views/sub-agents/AgentInsight.tsx
@@ -1,23 +1,30 @@
/**
- * AgentInsight — one agent run, explained.
+ * AgentInsight — the dossier of one agent run.
*
- * The board row answers "did it land?" in one word. This page answers what a
- * person asks next, in the order they ask it:
+ * Set like the Marketplace catalogue rather than like a dashboard: numbered
+ * registers with hairlines between rows, one display-face title, a status
+ * stamp, monospace only where a value is a value (timestamps, paths, counts).
+ * No icon-in-a-circle timelines, no tabs, no stat tiles — a run is a report,
+ * and a report is read top to bottom:
*
- * 1. What happened? — one paragraph in plain words, with the provider's
- * or the reviewer's own sentence when they left one.
- * 2. How did it go? — a timeline: what the agent said, what it ran
- * (folded: "ran 14 actions"), what the reviewer
- * said, where it stopped.
- * 3. What came out? — the answer and the files, with the way to them.
+ * 01 What happened — one paragraph in plain words, the provider's or
+ * reviewer's own sentence quoted once, then a ledger
+ * of the facts (when, how long, which worker, …).
+ * 02 The agent's report — what the worker itself wrote at the end, as
+ * rendered Markdown. For most runs this is the most
+ * detailed account of the work that exists.
+ * 03 Timeline — every recorded moment: what the agent said, what
+ * it ran (folded per burst), the reviewer's verdict
+ * with its evidence, where it stopped.
+ * 04 Files — what the workers actually changed, per file with
+ * added/removed lines (from the archived diff), or
+ * what they delivered. Every row leads to Artifacts.
+ * 05 Details — ids, raw reason tokens, the full request; folded.
*
- * Everything else (ids, raw reason tokens, the full request) sits behind a
- * "Details" fold at the bottom. No tabs: a run's story is read top to bottom.
- *
- * Four sources, all of which already exist — nothing here is a second store:
- * `GET /api/missions/{id}` (events), `GET /api/missions/{id}/result` (summary
- * + files), `GET /api/outputs` + `/{slug}/plan` (the archived transcript, only
- * while the directory exists) and the live registry node the board holds.
+ * Sources, all pre-existing: `GET /api/missions/{id}` (events), `/result`
+ * (summary + deliverables), `/changes` (the diff ledger; an older backend
+ * answers 404 and the page falls back to the deliverable list), `/api/outputs`
+ * + `/{slug}/plan` (the archived transcript) and the live registry node.
*
* Every visible string goes through i18n; the brand is the wake-word-derived
* assistant name (lib/agentBrand.ts), never a product name.
@@ -25,34 +32,29 @@
import { useMemo, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import {
- AlertTriangle,
ArrowUpRight,
- Bot,
- Brain,
CheckCircle2,
ChevronDown,
ChevronRight,
CircleAlert,
- FileText,
- Gavel,
- ListChecks,
Map as MapIcon,
- Rocket,
- StopCircle,
- TerminalSquare,
- Timer,
- Wrench,
XCircle,
} from "lucide-react";
import type { SubAgentNode, ToolCallEntry } from "@/store/jarvisAgents";
-import type { CriticAxisResult, CriticVerdictReady, MissionArtifact } from "@/types/missions";
-import { fetchMissionDetail, fetchMissionResult } from "@/components/missions/api";
+import type {
+ CriticAxisResult,
+ CriticVerdictReady,
+ MissionArtifact,
+ MissionChangedFile,
+} from "@/types/missions";
+import { fetchMissionChanges, fetchMissionDetail, fetchMissionResult } from "@/components/missions/api";
import { useOutputsList, usePlanForOutput, type PlanStep } from "@/hooks/useOutputs";
import { missionMapUrl } from "@/hooks/useVisualArtifacts";
+import { MarkdownProse } from "@/components/outputs/MarkdownProse";
import { openExternalUrl } from "@/lib/openExternal";
import { ScrollArea } from "@/components/ui/scroll-area";
-import { BackLink, Panel, SoftButton, StatusDot } from "@/components/extensions/primitives";
+import { BackLink, SoftButton, StatusDot } from "@/components/extensions/primitives";
import { agentBrand, agentsBrand } from "@/lib/agentBrand";
import { cn } from "@/lib/utils";
import { useEventStore } from "@/store/events";
@@ -73,12 +75,9 @@ import { formatBytes, formatClock, formatDuration, formatOffset, formatUsd } fro
type T = (key: string) => string;
-const STATUS_TONE: Record<SubAgentNode["status"], "busy" | "ok" | "error" | "warn"> = {
- running: "busy",
- completed: "ok",
- failed: "error",
- cancelled: "warn",
-};
+// ---------------------------------------------------------------------------
+// Tone vocabulary — one place, so light and dark read the same everywhere
+// ---------------------------------------------------------------------------
const TONE_TEXT: Record<StoryTone, string> = {
neutral: "text-muted-foreground",
@@ -88,12 +87,12 @@ const TONE_TEXT: Record<StoryTone, string> = {
error: "text-destructive",
};
-const TONE_RING: Record<StoryTone, string> = {
- neutral: "border-border bg-card",
- busy: "border-primary/50 bg-primary/10",
- ok: "border-emerald-500/50 bg-emerald-500/10",
- warn: "border-amber-500/50 bg-amber-500/10",
- error: "border-destructive/50 bg-destructive/10",
+const STAMP: Record<StoryTone, string> = {
+ neutral: "border-border text-muted-foreground",
+ busy: "border-primary/60 text-primary",
+ ok: "border-emerald-500/60 text-emerald-600 dark:text-emerald-400",
+ warn: "border-amber-500/60 text-amber-600 dark:text-amber-400",
+ error: "border-destructive/60 text-destructive",
};
const STATE_TONE: Record<Narrative["state"], StoryTone> = {
@@ -104,12 +103,35 @@ const STATE_TONE: Record<Narrative["state"], StoryTone> = {
timed_out: "error",
};
-const STATE_ICON: Record<Narrative["state"], typeof Bot> = {
- running: Rocket,
- approved: CheckCircle2,
- failed: XCircle,
- cancelled: StopCircle,
- timed_out: Timer,
+const KIND_KEY: Record<StoryEntry["kind"], string> = {
+ dispatched: "start",
+ plan: "plan",
+ spawn: "worker",
+ narration: "said",
+ tool: "ran",
+ draft: "draft",
+ verdict: "review",
+ correction: "fix",
+ killed: "stop",
+ budget: "budget",
+ approved: "end",
+ failed: "end",
+ cancelled: "end",
+ timed_out: "end",
+};
+
+const AXIS_KEYS: Record<string, string> = {
+ correctness: "subagents_view.axis.correctness",
+ completeness: "subagents_view.axis.completeness",
+ side_effects: "subagents_view.axis.side_effects",
+ security: "subagents_view.axis.security",
+};
+
+const CHANGE_GLYPH: Record<MissionChangedFile["status"], { glyph: string; tone: StoryTone }> = {
+ added: { glyph: "A", tone: "ok" },
+ modified: { glyph: "M", tone: "warn" },
+ deleted: { glyph: "D", tone: "error" },
+ renamed: { glyph: "R", tone: "neutral" },
};
/** The first paragraph of the request — the part the user actually said. */
@@ -131,6 +153,10 @@ function killLabel(reason: string, t: T): string {
return key ? t(key) : reason;
}
+function pad2(n: number): string {
+ return String(n).padStart(2, "0");
+}
+
interface Props {
agent: SubAgentNode;
onBack: () => void;
@@ -155,6 +181,15 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
queryFn: () => fetchMissionResult(missionId),
refetchInterval: running ? 10_000 : false,
});
+ // An older backend has no /changes route: the query errors once and the
+ // file register falls back to the deliverable list. Never retried — a 404
+ // is an answer, not a hiccup.
+ const changes = useQuery({
+ queryKey: ["missions", "changes", missionId],
+ queryFn: () => fetchMissionChanges(missionId),
+ retry: false,
+ refetchInterval: running ? 10_000 : false,
+ });
const outputs = useOutputsList();
const slug = useMemo(() => {
const match = outputs.data?.find((o) => o.mission_id === missionId);
@@ -168,6 +203,7 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
const blocks = useMemo(() => groupStory(buildStory(events)), [events]);
const steps: PlanStep[] = plan.data?.steps ?? [];
const artifacts: MissionArtifact[] = result.data?.artifacts ?? [];
+ const changedFiles: MissionChangedFile[] = changes.data?.files ?? [];
const finalAnswer = plan.data?.final_answer ?? null;
const title = requestTitle(result.data?.prompt ?? agent.utterance, t("subagents_view.task_none"));
@@ -183,6 +219,7 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
steps.filter((s) => s.kind !== "reasoning").length,
outcome.workers.reduce((sum, w) => sum + w.tool_notes, 0),
);
+ const fileCount = changedFiles.length || artifacts.length;
const narrative = useMemo(
() =>
@@ -194,6 +231,7 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
),
[agent, outcome, agentName, runtime, result.data?.artifact_count, artifacts.length, notes, t],
);
+ const tone = STATE_TONE[narrative.state];
const worker = outcome.workers.at(0) ?? null;
const rounds = Math.max(outcome.revisions, outcome.verdicts.at(-1)?.iteration ?? 0) + 1;
@@ -208,53 +246,64 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
? [{ label: t("subagents_view.fact_rounds"), value: String(rounds) }]
: []),
...(actions > 0 ? [{ label: t("subagents_view.fact_actions"), value: String(actions) }] : []),
+ ...(fileCount > 0
+ ? [
+ {
+ label: t("subagents_view.fact_files"),
+ value: String(fileCount),
+ hint:
+ changes.data && (changes.data.additions || changes.data.deletions)
+ ? `+${changes.data.additions} −${changes.data.deletions}`
+ : undefined,
+ },
+ ]
+ : []),
...(cost > 0 ? [{ label: t("subagents_view.stat_cost_label"), value: formatUsd(cost) }] : []),
];
- const hasOutput = !!finalAnswer || artifacts.length > 0;
+ let register = 0;
+ const next = () => pad2(++register);
return (
<div className="flex h-full min-h-0 flex-col">
<ScrollArea className="flex-1">
- <div className="mx-auto flex w-full max-w-[980px] flex-col gap-5 px-6 py-6">
+ <div className="mx-auto flex w-full max-w-[1040px] flex-col gap-5 px-6 py-6">
<BackLink label={agentsBrand(assistantName)} onClick={onBack} />
- {/* Header ---------------------------------------------------- */}
- <div className="flex flex-wrap items-start justify-between gap-x-6 gap-y-3">
+ {/* Masthead ------------------------------------------------- */}
+ <header className="flex flex-wrap items-end justify-between gap-x-8 gap-y-4 pb-1">
<div className="min-w-0 flex-1">
- <div className="text-xs font-medium uppercase tracking-wider text-muted-foreground">
+ <p className="text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground">
{agentName}
- </div>
- <h1 className="mt-1 line-clamp-2 font-display text-[22px] font-semibold leading-snug tracking-tight text-foreground">
+ <span className="mx-2 text-muted-foreground/50">·</span>
+ <span className="font-mono normal-case tracking-normal">{missionId.slice(0, 13)}</span>
+ <span className="mx-2 text-muted-foreground/50">·</span>
+ {formatClock(startedMs, locale)}
+ </p>
+ <h1 className="mt-2 line-clamp-3 font-display text-[26px] font-semibold leading-[1.15] tracking-tight text-foreground">
{title}
</h1>
- <div className="mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted-foreground">
- <StatusDot
- tone={STATUS_TONE[agent.status]}
- pulse={running}
- label={t(`subagents_view.status.${agent.status}`)}
- />
- <span aria-hidden>·</span>
- <span>{formatClock(startedMs, locale)}</span>
- <span aria-hidden>·</span>
- <span>{runtime}</span>
- </div>
</div>
- {slug && (
- <div className="flex shrink-0 items-center gap-2">
- <SoftButton
- onClick={() => void openExternalUrl(`${window.location.origin}${missionMapUrl(slug)}`)}
- >
- <MapIcon className="h-3.5 w-3.5" />
- {t("subagents_view.action_map")}
- </SoftButton>
- <SoftButton primary onClick={() => onOpenOutput(slug)}>
- <ArrowUpRight className="h-3.5 w-3.5" />
- {t("subagents_view.action_open_output")}
- </SoftButton>
- </div>
- )}
- </div>
+ <div className="flex shrink-0 flex-col items-end gap-3">
+ <Stamp tone={tone} pulse={narrative.state === "running"}>
+ {narrative.headline}
+ </Stamp>
+ {slug && (
+ <div className="flex items-center gap-2">
+ <SoftButton
+ onClick={() => void openExternalUrl(`${window.location.origin}${missionMapUrl(slug)}`)}
+ >
+ <MapIcon className="h-3.5 w-3.5" />
+ {t("subagents_view.action_map")}
+ </SoftButton>
+ <SoftButton primary onClick={() => onOpenOutput(slug)}>
+ {t("subagents_view.action_open_artifacts")}
+ <ArrowUpRight className="h-3.5 w-3.5" />
+ </SoftButton>
+ </div>
+ )}
+ </div>
+ </header>
{detail.isError && (
<Notice>
@@ -264,25 +313,81 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
</Notice>
)}
- {/* 1. What happened ----------------------------------------- */}
- <VerdictCard narrative={narrative} loading={detail.isPending} facts={facts} t={t} />
+ {/* 01 What happened ------------------------------------------ */}
+ <Register number={next()} title={t("subagents_view.register_verdict")}>
+ <div className="px-5 pb-5 pt-4">
+ <p className={cn("max-w-[68ch] text-[16px] leading-relaxed text-foreground", detail.isPending && "text-muted-foreground")}>
+ {detail.isPending ? t("subagents_view.insight_loading") : narrative.paragraph}
+ </p>
+ {narrative.quote && (
+ <blockquote className="mt-4 max-w-[68ch] border-l-2 border-primary/60 pl-4">
+ <p className="text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground">
+ {narrative.quote.label}
+ </p>
+ <p
+ className={cn(
+ "mt-1 whitespace-pre-wrap break-words text-foreground/90",
+ narrative.quote.mono ? "font-mono text-[12.5px] leading-relaxed" : "text-[14.5px] leading-relaxed",
+ )}
+ >
+ {narrative.quote.text}
+ </p>
+ </blockquote>
+ )}
+ {narrative.note && (
+ <p className="mt-4 flex items-center gap-2 text-sm text-muted-foreground">
+ <CircleAlert className="h-3.5 w-3.5 shrink-0" />
+ {narrative.note}
+ </p>
+ )}
+ </div>
+ <dl className="grid grid-cols-2 border-t border-border/70 sm:grid-cols-3 lg:grid-cols-7">
+ {facts.map((f, i) => (
+ <div
+ key={f.label}
+ className={cn(
+ "px-5 py-3 border-border/70",
+ i > 0 && "sm:border-l",
+ i > 0 && i % 2 === 1 && "border-l sm:border-l",
+ i >= 2 && "border-t sm:border-t-0",
+ i >= 3 && "sm:border-t lg:border-t-0",
+ )}
+ >
+ <dt className="text-[10.5px] font-semibold uppercase tracking-[0.16em] text-muted-foreground">
+ {f.label}
+ </dt>
+ <dd className="mt-1 truncate font-display text-[15px] font-semibold tabular-nums text-foreground" title={f.hint ?? f.value}>
+ {f.value}
+ {f.hint && <span className="ml-1.5 font-mono text-[11px] font-normal text-muted-foreground">{f.hint}</span>}
+ </dd>
+ </div>
+ ))}
+ </dl>
+ </Register>
+
+ {/* 02 The agent's report -------------------------------------- */}
+ {finalAnswer && (
+ <Register number={next()} title={fill(t("subagents_view.register_report"), { agent: agentName })}>
+ <Report text={finalAnswer} slug={slug ?? ""} t={t} />
+ </Register>
+ )}
- {/* Live tool calls, while the registry still holds them ------ */}
+ {/* Live tool calls, while the registry still holds them --------- */}
{agent.tool_calls.length > 0 && (
- <Section icon={TerminalSquare} title={t("subagents_view.live_title")} subtitle={t("subagents_view.live_subtitle")}>
- <div className="divide-y divide-border/60">
+ <Register number={next()} title={t("subagents_view.live_title")} meta={t("subagents_view.live_subtitle")}>
+ <div className="divide-y divide-border/70">
{agent.tool_calls.map((call, idx) => (
<LiveToolCall key={`${agent.trace_id}-${idx}`} call={call} t={t} />
))}
</div>
- </Section>
+ </Register>
)}
- {/* 2. How it went ------------------------------------------- */}
- <Section
- icon={ListChecks}
- title={t("subagents_view.timeline_title")}
- subtitle={fill(t("subagents_view.timeline_subtitle"), { agent: agentName })}
+ {/* 03 Timeline ------------------------------------------------ */}
+ <Register
+ number={next()}
+ title={t("subagents_view.register_timeline")}
+ meta={blocks.length > 0 ? fill(t("subagents_view.timeline_meta"), { n: events.length }) : undefined}
>
<Timeline
blocks={blocks}
@@ -301,60 +406,51 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
dropped={plan.data?.dropped_steps ?? 0}
t={t}
/>
- </Section>
-
- {/* 3. What came out ----------------------------------------- */}
- {hasOutput && (
- <Section
- icon={FileText}
- title={t("subagents_view.output_title")}
- subtitle={
- artifacts.length > 0
- ? fill(t("subagents_view.deliverables"), { n: artifacts.length })
- : t("subagents_view.final_answer")
+ </Register>
+
+ {/* 04 Files --------------------------------------------------- */}
+ {(changedFiles.length > 0 || artifacts.length > 0) && (
+ <Register
+ number={next()}
+ title={t("subagents_view.register_files")}
+ meta={
+ changes.data && (changes.data.additions || changes.data.deletions)
+ ? fill(t("subagents_view.files_meta"), {
+ n: changedFiles.length,
+ add: changes.data.additions,
+ del: changes.data.deletions,
+ })
+ : fill(t("subagents_view.deliverables"), { n: artifacts.length })
}
actions={
slug ? (
<SoftButton primary onClick={() => onOpenOutput(slug)}>
+ {t("subagents_view.action_open_artifacts")}
<ArrowUpRight className="h-3.5 w-3.5" />
- {t("subagents_view.action_open_output")}
</SoftButton>
) : null
}
>
- {finalAnswer && (
- <div className="px-5 py-4">
- <ClampedBlock text={finalAnswer} t={t} lines={8} className="whitespace-pre-wrap text-[15px] leading-relaxed text-foreground/90" />
- </div>
- )}
- {artifacts.length > 0 && (
- <ul className={cn("divide-y divide-border/60", finalAnswer && "border-t border-border/60")}>
- {artifacts.map((a) => (
- <li key={a.path} className="px-5 py-3">
- <div className="flex items-center gap-2.5 text-sm">
- <FileText className="h-4 w-4 shrink-0 text-muted-foreground" />
- <span className="min-w-0 flex-1 truncate font-medium" title={a.deliverable_path}>
- {a.deliverable_path}
- </span>
- <span className="shrink-0 text-xs tabular-nums text-muted-foreground">{formatBytes(a.size)}</span>
- </div>
- </li>
- ))}
- {result.data?.truncated && (
- <li className="px-5 py-2 text-xs text-muted-foreground">{t("subagents_view.deliverables_truncated")}</li>
- )}
- </ul>
- )}
- </Section>
+ <FilesLedger
+ changed={changedFiles}
+ artifacts={artifacts}
+ truncated={!!changes.data?.truncated || !!result.data?.truncated}
+ onOpen={slug ? () => onOpenOutput(slug) : undefined}
+ t={t}
+ />
+ </Register>
)}
- {/* Details, for the curious ---------------------------------- */}
- <details className="group rounded-xl border border-border/70 bg-card/30 px-5 py-3 text-sm">
- <summary className="flex cursor-pointer select-none items-center gap-2 text-muted-foreground hover:text-foreground">
- <ChevronRight className="h-4 w-4 transition-transform group-open:rotate-90" />
- {t("subagents_view.details_title")}
+ {/* 05 Details ------------------------------------------------- */}
+ <details className="group overflow-hidden rounded-xl border border-border bg-card/60 backdrop-blur-sm">
+ <summary className="flex cursor-pointer select-none items-baseline gap-3 px-5 py-3 hover:bg-secondary/40">
+ <span className="font-mono text-[11px] text-primary">{next()}</span>
+ <span className="text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground">
+ {t("subagents_view.details_title")}
+ </span>
+ <ChevronRight className="ml-auto h-4 w-4 text-muted-foreground transition-transform group-open:rotate-90" />
</summary>
- <dl className="mt-3 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-2 text-sm">
+ <dl className="grid grid-cols-[max-content_minmax(0,1fr)] gap-x-8 gap-y-2.5 border-t border-border/70 px-5 py-4 text-sm">
<dt className="text-muted-foreground">{t("subagents_view.fact_request")}</dt>
<dd className="whitespace-pre-wrap break-words text-foreground/85">{result.data?.prompt ?? agent.utterance ?? "—"}</dd>
<dt className="text-muted-foreground">{t("subagents_view.fact_mission_id")}</dt>
@@ -372,7 +468,7 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
{worker && (
<>
<dt className="text-muted-foreground">{t("subagents_view.fact_worker")}</dt>
- <dd className="font-mono text-xs">
+ <dd className="whitespace-pre-wrap font-mono text-xs">
{outcome.workers.map((w) => `${w.cli}${w.model ? ` (${w.model})` : ""} · ${w.worker_id}`).join("\n")}
</dd>
</>
@@ -383,17 +479,10 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
<dd className="break-all font-mono text-xs">{outcome.result_uri}</dd>
</>
)}
- {slug ? (
- <>
- <dt className="text-muted-foreground">{t("subagents_view.fact_output_dir")}</dt>
- <dd className="font-mono text-xs">{slug}</dd>
- </>
- ) : (
- <>
- <dt className="text-muted-foreground">{t("subagents_view.fact_output_dir")}</dt>
- <dd className="text-muted-foreground">{t("subagents_view.no_output_dir")}</dd>
- </>
- )}
+ <dt className="text-muted-foreground">{t("subagents_view.fact_output_dir")}</dt>
+ <dd className={cn("text-xs", slug ? "font-mono" : "text-muted-foreground")}>
+ {slug ?? t("subagents_view.no_output_dir")}
+ </dd>
</dl>
</details>
</div>
@@ -403,96 +492,93 @@ export function AgentInsight({ agent, onBack, onOpenOutput }: Props) {
}
// ---------------------------------------------------------------------------
-// 1. The verdict card
+// The register — a numbered section with a hairline header
// ---------------------------------------------------------------------------
-function VerdictCard({
- narrative,
- loading,
- facts,
- t,
+function Register({
+ number,
+ title,
+ meta,
+ actions,
+ children,
}: {
- narrative: Narrative;
- loading: boolean;
- facts: Array<{ label: string; value: string; hint?: string }>;
- t: T;
+ number: string;
+ title: string;
+ meta?: string;
+ actions?: React.ReactNode;
+ children: React.ReactNode;
}) {
- const tone = STATE_TONE[narrative.state];
- const Icon = STATE_ICON[narrative.state];
return (
- <Panel>
- <div className="flex items-start gap-4 px-5 pb-4 pt-5">
- <span className={cn("grid h-11 w-11 shrink-0 place-items-center rounded-full border", TONE_RING[tone], TONE_TEXT[tone])}>
- <Icon className="h-5 w-5" />
- </span>
- <div className="min-w-0 flex-1">
- <h2 className="font-display text-lg font-semibold leading-tight text-foreground">{narrative.headline}</h2>
- <p className="mt-1.5 text-[15px] leading-relaxed text-foreground/90">
- {loading ? t("subagents_view.insight_loading") : narrative.paragraph}
- </p>
- {narrative.quote && (
- <blockquote className="mt-3 border-l-2 border-border pl-3">
- <div className="text-xs font-medium text-muted-foreground">{narrative.quote.label}</div>
- <div
- className={cn(
- "mt-0.5 whitespace-pre-wrap break-words text-foreground/85",
- narrative.quote.mono ? "font-mono text-[12.5px] leading-relaxed" : "text-[14px] leading-relaxed",
- )}
- >
- {narrative.quote.text}
- </div>
- </blockquote>
- )}
- {narrative.note && (
- <p className="mt-3 flex items-center gap-1.5 text-sm text-muted-foreground">
- <CircleAlert className="h-3.5 w-3.5 shrink-0" />
- {narrative.note}
- </p>
- )}
- </div>
- </div>
- <dl className="grid grid-cols-2 gap-px border-t border-border bg-border/60 sm:grid-cols-3 lg:grid-cols-6">
- {facts.map((f) => (
- <div key={f.label} className="bg-card/80 px-4 py-2.5">
- <dt className="text-[11px] uppercase tracking-wider text-muted-foreground">{f.label}</dt>
- <dd className="mt-0.5 truncate text-sm font-medium text-foreground" title={f.hint ?? f.value}>
- {f.value}
- {f.hint && <span className="ml-1.5 font-normal text-muted-foreground">{f.hint}</span>}
- </dd>
- </div>
- ))}
- </dl>
- </Panel>
+ <section className="overflow-hidden rounded-xl border border-border bg-card/60 backdrop-blur-sm">
+ <header className="flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border/70 px-5 py-3">
+ <span className="font-mono text-[11px] text-primary">{number}</span>
+ <h2 className="text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground">{title}</h2>
+ {meta && <span className="text-[11px] text-muted-foreground/70">{meta}</span>}
+ {actions && <div className="ml-auto">{actions}</div>}
+ </header>
+ {children}
+ </section>
+ );
+}
+
+function Stamp({ tone, pulse, children }: { tone: StoryTone; pulse?: boolean; children: React.ReactNode }) {
+ return (
+ <span
+ className={cn(
+ "inline-flex items-center gap-2 rounded-md border-2 px-3.5 py-1.5 font-display text-[13px] font-bold uppercase tracking-[0.16em]",
+ STAMP[tone],
+ )}
+ >
+ <span className={cn("h-1.5 w-1.5 rounded-full bg-current", pulse && "animate-pulse")} />
+ {children}
+ </span>
);
}
// ---------------------------------------------------------------------------
-// 2. The timeline
+// 02 The agent's report — Markdown, folded past a screenful
// ---------------------------------------------------------------------------
-const ENTRY_ICON: Record<StoryEntry["kind"], typeof Bot> = {
- dispatched: Rocket,
- plan: ListChecks,
- spawn: Bot,
- narration: Brain,
- tool: Wrench,
- draft: FileText,
- verdict: Gavel,
- correction: AlertTriangle,
- killed: StopCircle,
- budget: AlertTriangle,
- approved: CheckCircle2,
- failed: XCircle,
- cancelled: StopCircle,
- timed_out: Timer,
-};
+function Report({ text, slug, t }: { text: string; slug: string; t: T }) {
+ const [open, setOpen] = useState(false);
+ const long = text.length > 1_400 || text.split("\n").length > 18;
+ return (
+ <div className="relative">
+ <div className={cn("px-6 py-5", !open && long && "max-h-[380px] overflow-hidden")}>
+ <MarkdownProse
+ slug={slug}
+ path="report.md"
+ files={[]}
+ text={text}
+ className="prose-sm max-w-[72ch] prose-headings:font-display prose-h3:text-[15px]"
+ testId="agent-report"
+ />
+ </div>
+ {long && (
+ <>
+ {!open && (
+ <div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-11 h-24 bg-gradient-to-t from-card to-transparent" />
+ )}
+ <div className="border-t border-border/70 px-5 py-2.5">
+ <button
+ type="button"
+ onClick={() => setOpen((v) => !v)}
+ aria-expanded={open}
+ className="inline-flex items-center gap-1.5 text-sm font-medium text-primary hover:underline"
+ >
+ {open ? t("subagents_view.report_collapse") : t("subagents_view.report_expand")}
+ <ChevronDown className={cn("h-3.5 w-3.5 transition-transform", open && "rotate-180")} />
+ </button>
+ </div>
+ </>
+ )}
+ </div>
+ );
+}
-const AXIS_KEYS: Record<string, string> = {
- correctness: "subagents_view.axis.correctness",
- completeness: "subagents_view.axis.completeness",
- side_effects: "subagents_view.axis.side_effects",
- security: "subagents_view.axis.security",
-};
+// ---------------------------------------------------------------------------
+// 03 Timeline — a ledger of moments, not a chain of badges
+// ---------------------------------------------------------------------------
function entryTitle(entry: StoryEntry, agentName: string, t: T): string {
const m = entry.meta;
@@ -545,7 +631,7 @@ function Timeline({
startedMs: number;
loading: boolean;
agentName: string;
- /** The sentence the verdict card already quotes — not repeated down here. */
+ /** The sentence register 01 already quotes — not repeated down here. */
quoteText: string | null;
t: T;
}) {
@@ -553,9 +639,7 @@ function Timeline({
return <EmptyNote>{loading ? t("subagents_view.insight_loading") : t("subagents_view.story_empty")}</EmptyNote>;
}
return (
- <ol className="relative py-2">
- {/* The rail the nodes sit on. */}
- <span aria-hidden className="absolute bottom-6 left-[83px] top-6 w-px bg-border" />
+ <ol className="divide-y divide-border/70">
{blocks.map((block) =>
block.kind === "actions" ? (
<ActionsRow key={block.id} block={block} startedMs={startedMs} t={t} />
@@ -574,24 +658,23 @@ function Timeline({
);
}
-function RowFrame({
+/** One ledger line: offset · KIND · content. */
+function Line({
offset,
- icon: Icon,
+ kind,
tone,
children,
}: {
offset: string;
- icon: typeof Bot;
+ kind: string;
tone: StoryTone;
children: React.ReactNode;
}) {
return (
- <li className="relative grid grid-cols-[56px_28px_minmax(0,1fr)] items-start gap-x-3 px-5 py-2.5">
- <span className="pt-1 text-right font-mono text-[11px] tabular-nums text-muted-foreground/70">{offset}</span>
- <span className={cn("relative z-[1] grid h-7 w-7 place-items-center rounded-full border", TONE_RING[tone], TONE_TEXT[tone])}>
- <Icon className="h-3.5 w-3.5" />
- </span>
- <div className="min-w-0 pt-0.5">{children}</div>
+ <li className="grid grid-cols-[60px_76px_minmax(0,1fr)] items-baseline gap-x-4 px-5 py-3">
+ <span className="font-mono text-[11px] tabular-nums text-muted-foreground/70">{offset}</span>
+ <span className={cn("text-[10.5px] font-semibold uppercase tracking-[0.16em]", TONE_TEXT[tone])}>{kind}</span>
+ <div className="min-w-0">{children}</div>
</li>
);
}
@@ -609,64 +692,74 @@ function EntryRow({
hideText: boolean;
t: T;
}) {
- const title = entryTitle(entry, agentName, t);
- const strong = ["approved", "failed", "cancelled", "timed_out", "killed", "verdict", "spawn"].includes(entry.kind);
+ const kind = t(`subagents_view.kind.${KIND_KEY[entry.kind]}`);
+ const offset = formatOffset(entry.ts_ms - startedMs);
const text = hideText ? "" : entry.text;
- return (
- <RowFrame offset={formatOffset(entry.ts_ms - startedMs)} icon={ENTRY_ICON[entry.kind]} tone={entry.tone}>
- {entry.kind === "narration" ? (
- <div className="border-l-2 border-primary/40 pl-3">
- <div className="text-xs font-medium text-muted-foreground">{title}</div>
- <ClampedBlock text={text} t={t} lines={3} className="mt-0.5 text-[14.5px] leading-relaxed text-foreground/90" />
+ if (entry.kind === "narration") {
+ return (
+ <Line offset={offset} kind={kind} tone="neutral">
+ <div className="border-l-2 border-primary/50 pl-3">
+ <span className="text-[11px] font-medium text-muted-foreground">{agentName}</span>
+ <ClampedBlock text={text} t={t} lines={3} className="mt-0.5 max-w-[72ch] text-[14.5px] leading-relaxed text-foreground/90" />
</div>
- ) : entry.kind === "verdict" && entry.verdict ? (
- <VerdictRow verdict={entry.verdict} t={t} />
- ) : (
- <>
- <div className={cn("text-sm", strong ? "font-semibold text-foreground" : "font-medium text-foreground/85")}>{title}</div>
- {text && (
- <ClampedBlock
- text={text}
- t={t}
- lines={3}
- className={cn("mt-0.5 text-sm leading-relaxed", entry.tone === "error" ? "text-destructive/90" : "text-muted-foreground")}
- />
- )}
- </>
+ </Line>
+ );
+ }
+ if (entry.kind === "verdict" && entry.verdict) {
+ return (
+ <Line offset={offset} kind={kind} tone={entry.tone}>
+ <VerdictBody verdict={entry.verdict} t={t} />
+ </Line>
+ );
+ }
+ const terminal = ["approved", "failed", "cancelled", "timed_out", "killed"].includes(entry.kind);
+ return (
+ <Line offset={offset} kind={kind} tone={entry.tone}>
+ <div className={cn("text-[14px]", terminal ? "font-semibold text-foreground" : "font-medium text-foreground/90")}>
+ {entryTitle(entry, agentName, t)}
+ </div>
+ {text && (
+ <ClampedBlock
+ text={text}
+ t={t}
+ lines={3}
+ className={cn("mt-1 max-w-[72ch] text-sm leading-relaxed", entry.tone === "error" ? "text-destructive/90" : "text-muted-foreground")}
+ />
)}
- </RowFrame>
+ </Line>
);
}
-function VerdictRow({ verdict, t }: { verdict: CriticVerdictReady; t: T }) {
+function VerdictBody({ verdict, t }: { verdict: CriticVerdictReady; t: T }) {
const tone: StoryTone = verdict.verdict === "approve" ? "ok" : verdict.verdict === "revise" ? "warn" : "error";
const axes = Object.entries(verdict.axes ?? {});
return (
<div>
- <div className="flex flex-wrap items-center gap-2">
- <span className="text-sm font-semibold text-foreground">{t("subagents_view.story.verdict")}</span>
- <span className={cn("rounded-md border px-1.5 py-0.5 text-[11px] font-medium", TONE_RING[tone], TONE_TEXT[tone])}>
+ <div className="flex flex-wrap items-center gap-2.5">
+ <span className={cn("rounded border px-1.5 py-0.5 font-display text-[11px] font-bold uppercase tracking-[0.14em]", STAMP[tone])}>
{t(`subagents_view.verdict.${verdict.verdict}`)}
</span>
- <span className="text-xs text-muted-foreground">{Math.round(verdict.confidence * 100)}%</span>
+ <span className="font-mono text-[11px] tabular-nums text-muted-foreground">
+ {fill(t("subagents_view.confidence"), { pct: Math.round(verdict.confidence * 100) })}
+ </span>
</div>
- <p className="mt-1 text-sm leading-relaxed text-foreground/85">{verdict.summary}</p>
+ <p className="mt-1.5 max-w-[72ch] text-[14px] leading-relaxed text-foreground/90">{verdict.summary}</p>
{axes.length > 0 && (
- <ul className="mt-1.5 flex flex-wrap gap-x-4 gap-y-1">
+ <ul className="mt-2.5 divide-y divide-border/50 rounded-lg border border-border/70">
{axes.map(([name, axis]) => {
const passed = axisPassed(axis);
const label = AXIS_KEYS[name] ? t(AXIS_KEYS[name]) : name;
+ const evidence = (axis.evidence ?? []).filter((e): e is string => typeof e === "string");
return (
- <li
- key={name}
- className={cn(
- "inline-flex items-center gap-1 text-xs",
- passed === true ? TONE_TEXT.ok : passed === false ? TONE_TEXT.error : "text-muted-foreground",
- )}
- >
- {passed === true ? <CheckCircle2 className="h-3.5 w-3.5" /> : passed === false ? <XCircle className="h-3.5 w-3.5" /> : <CircleAlert className="h-3.5 w-3.5" />}
- {label}
+ <li key={name} className="grid grid-cols-[20px_140px_minmax(0,1fr)] items-start gap-x-3 px-3 py-2">
+ <span className={cn("pt-0.5", passed === true ? TONE_TEXT.ok : passed === false ? TONE_TEXT.error : "text-muted-foreground")}>
+ {passed === true ? <CheckCircle2 className="h-3.5 w-3.5" /> : passed === false ? <XCircle className="h-3.5 w-3.5" /> : <CircleAlert className="h-3.5 w-3.5" />}
+ </span>
+ <span className="text-[13px] font-medium text-foreground">{label}</span>
+ <span className="min-w-0 break-words font-mono text-[11.5px] leading-relaxed text-muted-foreground">
+ {evidence.length > 0 ? evidence.join(" · ") : axis.notes ? String(axis.notes) : "—"}
+ </span>
</li>
);
})}
@@ -680,43 +773,41 @@ function ActionsRow({ block, startedMs, t }: { block: ActionsBlock; startedMs: n
const [open, setOpen] = useState(false);
const span = block.end_ms - block.ts_ms;
return (
- <RowFrame offset={formatOffset(block.ts_ms - startedMs)} icon={Wrench} tone="neutral">
+ <Line offset={formatOffset(block.ts_ms - startedMs)} kind={t("subagents_view.kind.ran")} tone="neutral">
<button
type="button"
onClick={() => setOpen((v) => !v)}
aria-expanded={open}
- className="flex w-full items-center gap-2 text-left"
+ className="group/actions flex w-full flex-wrap items-center gap-x-3 gap-y-1.5 text-left"
>
- <span className="text-sm font-medium text-foreground/85">
+ <span className="text-[14px] font-medium text-foreground/90">
{fill(t(block.entries.length === 1 ? "subagents_view.actions_one" : "subagents_view.actions_many"), {
n: block.entries.length,
span: formatDuration(span),
})}
</span>
+ <span className="flex flex-wrap gap-1.5">
+ {block.counts.map((c) => (
+ <span key={c.tool} className="inline-flex h-5 items-center gap-1 rounded border border-border/70 px-1.5 font-mono text-[11px] text-foreground/80">
+ {c.tool}
+ {c.n > 1 && <span className="text-muted-foreground">×{c.n}</span>}
+ </span>
+ ))}
+ </span>
<ChevronDown className={cn("h-3.5 w-3.5 text-muted-foreground transition-transform", open && "rotate-180")} />
</button>
- <div className="mt-1.5 flex flex-wrap gap-1.5">
- {block.counts.map((c) => (
- <span key={c.tool} className="inline-flex h-6 items-center gap-1 rounded-md border border-border bg-sheen/[0.04] px-2 font-mono text-[11.5px] text-foreground/80">
- {c.tool}
- {c.n > 1 && <span className="text-muted-foreground">×{c.n}</span>}
- </span>
- ))}
- </div>
{open && (
- <ol className="mt-2 divide-y divide-border/50 rounded-lg border border-border/70 bg-sheen/[0.03]">
+ <ol className="mt-2.5 divide-y divide-border/50 rounded-lg border border-border/70">
{block.entries.map((e) => (
- <li key={e.id} className="grid grid-cols-[52px_minmax(0,1fr)] gap-x-3 px-3 py-1.5 font-mono text-[12px]">
- <span className="text-muted-foreground/60">{formatOffset(e.ts_ms - startedMs)}</span>
- <span className="min-w-0 break-all text-foreground/85">
- <span className="mr-2 text-muted-foreground">{e.tool}</span>
- {e.text}
- </span>
+ <li key={e.id} className="grid grid-cols-[52px_72px_minmax(0,1fr)] gap-x-3 px-3 py-1.5 font-mono text-[11.5px]">
+ <span className="tabular-nums text-muted-foreground/60">{formatOffset(e.ts_ms - startedMs)}</span>
+ <span className="truncate text-muted-foreground">{e.tool}</span>
+ <span className="min-w-0 break-all text-foreground/85">{e.text}</span>
</li>
))}
</ol>
)}
- </RowFrame>
+ </Line>
);
}
@@ -752,13 +843,13 @@ function TranscriptFold({
const [open, setOpen] = useState(false);
if (!hasSlug) {
return hadWorkers ? (
- <div className="border-t border-border/60 px-5 py-2.5 text-xs text-muted-foreground">{t("subagents_view.transcript_no_dir")}</div>
+ <div className="border-t border-border/70 px-5 py-2.5 text-xs text-muted-foreground">{t("subagents_view.transcript_no_dir")}</div>
) : null;
}
if (loading || steps.length === 0) return null;
return (
- <div className="border-t border-border/60">
+ <div className="border-t border-border/70">
<button
type="button"
onClick={() => setOpen((v) => !v)}
@@ -769,7 +860,7 @@ function TranscriptFold({
{fill(t("subagents_view.transcript_fold"), { n: steps.length })}
</button>
{open && (
- <div className="border-t border-border/60">
+ <div className="border-t border-border/70">
{(truncated || dropped > 0) && (
<div className="px-5 py-2 text-xs text-amber-600 dark:text-amber-400">
{dropped > 0 ? fill(t("subagents_view.transcript_dropped"), { n: dropped }) : t("subagents_view.transcript_truncated")}
@@ -778,17 +869,16 @@ function TranscriptFold({
<ol className="divide-y divide-border/50">
{steps.map((step, idx) => {
const kind = step.kind ?? "tool";
- const Icon = kind === "reasoning" ? Brain : kind === "spawn" ? Bot : Wrench;
const body = step.error ?? step.output ?? null;
return (
- <li key={step.step_id} className="grid grid-cols-[36px_28px_minmax(0,1fr)_100px] items-start gap-x-3 px-5 py-2.5">
- <span className="pt-0.5 text-right font-mono text-[11px] tabular-nums text-muted-foreground/60">{idx + 1}</span>
- <span className={cn("grid h-6 w-6 place-items-center rounded-full border border-border bg-card", kind === "reasoning" ? "text-primary" : "text-muted-foreground")}>
- <Icon className="h-3.5 w-3.5" />
+ <li key={step.step_id} className="grid grid-cols-[60px_76px_minmax(0,1fr)_100px] items-baseline gap-x-4 px-5 py-2.5">
+ <span className="font-mono text-[11px] tabular-nums text-muted-foreground/60">{pad2(idx + 1)}</span>
+ <span className={cn("text-[10.5px] font-semibold uppercase tracking-[0.16em]", kind === "reasoning" ? "text-primary" : "text-muted-foreground")}>
+ {t(`subagents_view.kind.${kind === "reasoning" ? "thought" : kind === "spawn" ? "worker" : "ran"}`)}
</span>
<div className="min-w-0">
{kind === "reasoning" ? (
- <ClampedBlock text={step.output ?? step.name} t={t} lines={3} className="text-sm leading-relaxed text-foreground/85" />
+ <ClampedBlock text={step.output ?? step.name} t={t} lines={3} className="max-w-[72ch] text-sm leading-relaxed text-foreground/85" />
) : (
<>
<div className="font-mono text-[12.5px] text-foreground">
@@ -822,50 +912,118 @@ function TranscriptFold({
}
// ---------------------------------------------------------------------------
-// Small shared pieces
+// 04 Files — the diff ledger, every row a door into Artifacts
// ---------------------------------------------------------------------------
-function Section({
- icon: Icon,
- title,
- subtitle,
- actions,
- children,
+function FilesLedger({
+ changed,
+ artifacts,
+ truncated,
+ onOpen,
+ t,
}: {
- icon: typeof Bot;
- title: string;
- subtitle?: string;
- actions?: React.ReactNode;
- children: React.ReactNode;
+ changed: MissionChangedFile[];
+ artifacts: MissionArtifact[];
+ truncated: boolean;
+ onOpen?: () => void;
+ t: T;
}) {
+ const sizes = useMemo(() => new Map(artifacts.map((a) => [a.deliverable_path, a.size])), [artifacts]);
+ const rows: Array<{ key: string; glyph: string; tone: StoryTone; path: string; from: string | null; add: number | null; del: number | null; size: number | null; binary: boolean; title: string }> =
+ changed.length > 0
+ ? changed.map((f) => ({
+ key: `${f.status}:${f.path}`,
+ glyph: CHANGE_GLYPH[f.status].glyph,
+ tone: CHANGE_GLYPH[f.status].tone,
+ path: f.path,
+ from: f.previous_path,
+ add: f.additions,
+ del: f.deletions,
+ size: sizes.get(f.path) ?? null,
+ binary: f.binary,
+ title: t(`subagents_view.change.${f.status}`),
+ }))
+ : artifacts.map((a) => ({
+ key: a.path,
+ glyph: "·",
+ tone: "neutral" as StoryTone,
+ path: a.deliverable_path,
+ from: null,
+ add: null,
+ del: null,
+ size: a.size,
+ binary: !a.is_text,
+ title: t("subagents_view.change.delivered"),
+ }));
+
+ const Row = onOpen ? "button" : "div";
return (
- <Panel>
- <div className="flex items-start justify-between gap-4 border-b border-border px-5 py-3.5">
- <div className="flex min-w-0 items-start gap-2.5">
- <Icon className="mt-0.5 h-4 w-4 shrink-0 text-primary" />
- <div className="min-w-0">
- <h2 className="font-display text-[15px] font-semibold text-foreground">{title}</h2>
- {subtitle && <p className="mt-0.5 text-xs text-muted-foreground">{subtitle}</p>}
- </div>
- </div>
- {actions ? <div className="shrink-0">{actions}</div> : null}
- </div>
- {children}
- </Panel>
+ <div>
+ <ol className="divide-y divide-border/70">
+ {rows.map((r) => (
+ <li key={r.key}>
+ <Row
+ {...(onOpen ? { type: "button", onClick: onOpen } : {})}
+ className={cn(
+ "grid w-full grid-cols-[28px_minmax(0,1fr)_auto_auto_16px] items-center gap-x-3 px-5 py-2.5 text-left",
+ onOpen && "transition-colors hover:bg-secondary/50 focus-visible:bg-secondary/50 focus-visible:outline-none",
+ )}
+ >
+ <span
+ title={r.title}
+ className={cn("grid h-5 w-5 place-items-center rounded border font-mono text-[10.5px] font-bold", STAMP[r.tone])}
+ >
+ {r.glyph}
+ </span>
+ <span className="min-w-0">
+ <span className="block truncate font-mono text-[12.5px] text-foreground" title={r.path}>
+ {r.path}
+ </span>
+ {r.from && (
+ <span className="block truncate font-mono text-[11px] text-muted-foreground">← {r.from}</span>
+ )}
+ </span>
+ <span className="font-mono text-[11.5px] tabular-nums">
+ {r.binary ? (
+ <span className="text-muted-foreground">{t("subagents_view.change.binary")}</span>
+ ) : r.add != null && r.del != null ? (
+ <>
+ <span className={TONE_TEXT.ok}>+{r.add}</span>
+ <span className="mx-1 text-muted-foreground/50">/</span>
+ <span className={TONE_TEXT.error}>−{r.del}</span>
+ </>
+ ) : null}
+ </span>
+ <span className="w-14 text-right font-mono text-[11.5px] tabular-nums text-muted-foreground">
+ {r.size != null ? formatBytes(r.size) : ""}
+ </span>
+ {onOpen ? <ArrowUpRight className="h-3.5 w-3.5 text-muted-foreground/50" /> : <span />}
+ </Row>
+ </li>
+ ))}
+ </ol>
+ {truncated && (
+ <div className="border-t border-border/70 px-5 py-2 text-xs text-muted-foreground">{t("subagents_view.deliverables_truncated")}</div>
+ )}
+ </div>
);
}
+// ---------------------------------------------------------------------------
+// Small shared pieces
+// ---------------------------------------------------------------------------
+
function LiveToolCall({ call, t }: { call: ToolCallEntry; t: T }) {
const tone: Record<ToolCallEntry["status"], "busy" | "ok" | "error"> = { running: "busy", completed: "ok", failed: "error" };
return (
<div className="grid grid-cols-[minmax(0,1fr)_64px_96px] items-center gap-3 px-5 py-2.5 text-sm">
<div className="min-w-0">
- <div className="truncate font-medium text-foreground">{call.tool_name || t("subagents_view.tool_unnamed")}</div>
+ <div className="truncate font-mono text-[12.5px] text-foreground">{call.tool_name || t("subagents_view.tool_unnamed")}</div>
<div className="truncate text-xs text-muted-foreground" title={call.args_preview}>
{call.error || call.args_preview || call.output_preview || "—"}
</div>
</div>
- <div className="text-right text-xs tabular-nums text-muted-foreground">
+ <div className="text-right font-mono text-[11px] tabular-nums text-muted-foreground">
{call.duration_ms != null ? formatDuration(call.duration_ms) : "—"}
</div>
<div className="flex justify-end">
@@ -878,11 +1036,10 @@ function LiveToolCall({ call, t }: { call: ToolCallEntry; t: T }) {
const CLAMP_CLASS: Record<number, string> = {
2: "line-clamp-2",
3: "line-clamp-3",
- 8: "line-clamp-[8]",
};
/** Text that clamps to `lines` and expands on a click — the page's own "more". */
-function ClampedBlock({ text, t, lines, className }: { text: string; t: T; lines: 2 | 3 | 8; className?: string }) {
+function ClampedBlock({ text, t, lines, className }: { text: string; t: T; lines: 2 | 3; className?: string }) {
const [open, setOpen] = useState(false);
// Judged by length and line breaks rather than layout, so the list never
// re-flows on mount.
@@ -891,7 +1048,7 @@ function ClampedBlock({ text, t, lines, className }: { text: string; t: T; lines
<div className={cn("min-w-0", className)}>
<div className={cn("break-words", !open && long && CLAMP_CLASS[lines])}>{text}</div>
{long && (
- <button type="button" onClick={() => setOpen((v) => !v)} className="mt-0.5 text-xs text-primary hover:underline">
+ <button type="button" onClick={() => setOpen((v) => !v)} className="mt-0.5 text-xs font-medium text-primary hover:underline">
{open ? t("subagents_view.see_less") : t("subagents_view.see_more")}
</button>
)}
diff --git a/jarvis/ui/web/missions_routes.py b/jarvis/ui/web/missions_routes.py
index 3563edf584..c100295bd2 100644
--- a/jarvis/ui/web/missions_routes.py
+++ b/jarvis/ui/web/missions_routes.py
@@ -17,6 +17,7 @@ Pattern like ``tasks_routes.py``:
"""
from __future__ import annotations
+import asyncio
import logging
from pathlib import Path
from typing import Any, Literal
@@ -25,6 +26,7 @@ from uuid import UUID
from fastapi import APIRouter, BackgroundTasks, HTTPException, Request
from pydantic import BaseModel
+from jarvis.missions.diff_summary import read_mission_changes
from jarvis.missions.events import (
EventEnvelope,
MissionApproved,
@@ -309,6 +311,28 @@ async def get_mission_result(
}
[email protected]("/{mission_id}/changes")
+async def get_mission_changes(
+ mission_id: str,
+ request: Request,
+) -> dict[str, Any]:
+ """Return the per-file ledger of what the mission's workers changed.
+
+ Read from the archived ``tasks/*/artifacts/diff.patch`` (see
+ :mod:`jarvis.missions.diff_summary`) — the ``WorkerDraftReady`` event only
+ carries the first 8 000 characters of that diff. A mission whose output
+ directory is gone answers with an empty ledger, not a 404: the run
+ existed, it just left no readable diff behind.
+ """
+ mgr = _require_manager(request)
+ view = await mgr.store.get_mission_view(mission_id)
+ if view is None:
+ raise HTTPException(status_code=404, detail="Mission not found")
+ root = _mission_outputs_root(request)
+ changes = await asyncio.to_thread(read_mission_changes, root, mission_id)
+ return {"mission_id": mission_id, **changes}
+
+
@router.get("/{mission_id}/tool-approvals")
async def list_mission_tool_approvals(
mission_id: str,
diff --git a/tests/missions/api/test_missions_changes.py b/tests/missions/api/test_missions_changes.py
new file mode 100644
index 0000000000..3352c1b5a8
--- /dev/null
+++ b/tests/missions/api/test_missions_changes.py
@@ -0,0 +1,150 @@
+"""The per-file change ledger behind ``GET /api/missions/{id}/changes``."""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest_asyncio
+from fastapi import FastAPI
+from fastapi.testclient import TestClient
+
+from jarvis.missions.diff_summary import read_mission_changes, summarize_unified_diff
+from jarvis.missions.manager import MissionManager
+from jarvis.ui.web.missions_routes import router as missions_router
+
+PATCH = """\
+diff --git a/jarvis/plugins/tool/gmail_deep_clean.py b/jarvis/plugins/tool/gmail_deep_clean.py
+new file mode 100644
+index 0000000..1111111
+--- /dev/null
++++ b/jarvis/plugins/tool/gmail_deep_clean.py
+@@ -0,0 +1,3 @@
++import os
++
++print("hi")
+diff --git a/README.md b/README.md
+index 2222222..3333333 100644
+--- a/README.md
++++ b/README.md
+@@ -1,2 +1,2 @@
+-old line
++new line
+ kept
+diff --git a/old.txt b/new.txt
+similarity index 90%
+rename from old.txt
+rename to new.txt
+diff --git a/logo.png b/logo.png
+new file mode 100644
+Binary files /dev/null and b/logo.png differ
+diff --desktop-action-evidence b/<desktop-launch-operations>
+# verified-desktop-launch
++not a real line
+diff --git a/gone.py b/gone.py
+deleted file mode 100644
+--- a/gone.py
++++ /dev/null
+@@ -1,2 +0,0 @@
+-a
+-b
+"""
+
+
+def test_summary_counts_every_kind_of_change_and_skips_pseudo_diffs() -> None:
+ summary = summarize_unified_diff(PATCH)
+ by_path = {f["path"]: f for f in summary["files"]}
+
+ assert list(by_path) == [
+ "jarvis/plugins/tool/gmail_deep_clean.py",
+ "README.md",
+ "new.txt",
+ "logo.png",
+ "gone.py",
+ ]
+ assert by_path["jarvis/plugins/tool/gmail_deep_clean.py"]["status"] == "added"
+ assert by_path["jarvis/plugins/tool/gmail_deep_clean.py"]["additions"] == 3
+ assert by_path["README.md"] == {
+ "path": "README.md",
+ "previous_path": None,
+ "status": "modified",
+ "additions": 1,
+ "deletions": 1,
+ "binary": False,
+ }
+ assert by_path["new.txt"]["status"] == "renamed"
+ assert by_path["new.txt"]["previous_path"] == "old.txt"
+ assert by_path["logo.png"]["binary"] is True
+ assert by_path["gone.py"]["status"] == "deleted"
+ assert by_path["gone.py"]["deletions"] == 2
+ # The worker-authored evidence block contributes nothing.
+ assert summary["additions"] == 4
+ assert summary["deletions"] == 3
+ assert summary["truncated_files"] is False
+
+
+def test_read_mission_changes_prefers_the_final_patch_and_aggregates_tasks(
+ tmp_path: Path,
+) -> None:
+ mid = "019fecaa-5a92-7360-a784-829281639cf6"
+ mission_dir = tmp_path / f"mission_{mid[:13]}"
+ task_a = mission_dir / "tasks" / "task-a" / "artifacts"
+ task_b = mission_dir / "tasks" / "task-b" / "artifacts"
+ task_a.mkdir(parents=True)
+ task_b.mkdir(parents=True)
+ (task_a / "diff.iter0.patch").write_text(
+ "diff --git a/x b/x\n@@ -0,0 +1 @@\n+stale\n", encoding="utf-8"
+ )
+ (task_a / "diff.patch").write_text(PATCH, encoding="utf-8")
+ (task_b / "diff.iter1.patch").write_text(
+ "diff --git a/b.py b/b.py\nnew file mode 100644\n@@ -0,0 +1 @@\n+b\n", encoding="utf-8"
+ )
+
+ changes = read_mission_changes(tmp_path, mid)
+
+ assert [t["task_id"] for t in changes["tasks"]] == ["task-a", "task-b"]
+ assert changes["tasks"][0]["patch"] == "diff.patch"
+ assert changes["tasks"][1]["patch"] == "diff.iter1.patch"
+ assert len(changes["files"]) == 6
+ assert changes["additions"] == 5
+ assert changes["deletions"] == 3
+ assert changes["truncated"] is False
+
+
+def test_read_mission_changes_is_empty_for_a_missing_dir_or_bad_id(tmp_path: Path) -> None:
+ assert read_mission_changes(tmp_path, "019fecaa-5a92-7360-a784-829281639cf6")["files"] == []
+ assert read_mission_changes(tmp_path, "../escape")["files"] == []
+
+
+@pytest_asyncio.fixture
+async def manager(tmp_path: Path):
+ mgr = MissionManager(tmp_path / "missions.db")
+ await mgr.start()
+ try:
+ yield mgr
+ finally:
+ await mgr.stop()
+
+
+async def test_changes_route_returns_the_ledger_for_a_known_mission(
+ manager: MissionManager,
+ tmp_path: Path,
+) -> None:
+ mid = await manager.dispatch(prompt="Build the thing.", language="en")
+ artifacts = tmp_path / "outputs" / f"mission_{mid[:13]}" / "tasks" / "t1" / "artifacts"
+ artifacts.mkdir(parents=True)
+ (artifacts / "diff.patch").write_text(PATCH, encoding="utf-8")
+
+ app = FastAPI()
+ app.include_router(missions_router)
+ app.state.mission_manager = manager
+ app.state.outputs_root = tmp_path / "outputs"
+ with TestClient(app) as client:
+ ok = client.get(f"/api/missions/{mid}/changes")
+ missing = client.get("/api/missions/00000000-0000-0000-0000-000000000000/changes")
+
+ assert ok.status_code == 200
+ body = ok.json()
+ assert body["mission_id"] == mid
+ assert len(body["files"]) == 5
+ assert body["additions"] == 4
+ assert missing.status_code == 404