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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(visualization): a live run's step timeline follows the mission
rubenluetke10-beepc0d68ada11ac
diff --git a/jarvis/ui/web/frontend/src/hooks/useOutputs.livePlan.test.tsx b/jarvis/ui/web/frontend/src/hooks/useOutputs.livePlan.test.tsxnew file mode 100644index 0000000000..ddf7a3cba8--- /dev/null+++ b/jarvis/ui/web/frontend/src/hooks/useOutputs.livePlan.test.tsx@@ -0,0 +1,101 @@+/**+ * The plan of a RUNNING run is a live step timeline — it must keep itself+ * fresh without anyone pressing Refresh (the Visualization canvas is "the+ * thing on the second monitor while the mission is still going"). The plan+ * of a finished run is history and must never poll: three hundred archived+ * runs re-reading their transcripts every few seconds would keep a disk busy+ * for data that can no longer change.+ */+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { renderHook } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";++import {+ usePlanForOutput,+ type OutputSummary,+ type PlanResponse,+} from "@/hooks/useOutputs";++const EMPTY_PLAN: PlanResponse = { plan: null, steps: [] };++function planFetchMock() {+ return vi.fn(async (input: RequestInfo | URL) => {+ if (!String(input).includes("/plan")) throw new Error(`unexpected ${input}`);+ return { ok: true, status: 200, json: async () => EMPTY_PLAN };+ });+}++function renderPlanHook(runs: OutputSummary[], slug: string) {+ // gcTime stays realistic: in the app the outputs-list observer keeps the+ // cache entry alive; gcTime 0 here would garbage-collect the seeded list+ // before the interval callback could ever read it.+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false, gcTime: 60_000 } },+ });+ // The outputs list is what every view already fetches and caches; the plan+ // hook only READS it to decide whether its run is still alive.+ client.setQueryData(["outputs"], runs);+ const wrapper = ({ children }: { children: React.ReactNode }) => (+ <QueryClientProvider client={client}>{children}</QueryClientProvider>+ );+ return renderHook(() => usePlanForOutput(slug), { wrapper });+}++beforeEach(() => {+ vi.useFakeTimers();+});++afterEach(() => {+ vi.useRealTimers();+ vi.restoreAllMocks();+});++describe("usePlanForOutput live-follow", () => {+ it("keeps refetching the plan while its run is running", async () => {+ const fetchMock = planFetchMock();+ vi.stubGlobal("fetch", fetchMock);++ const { unmount } = renderPlanHook(+ [{ slug: "run-live", status: "running" }],+ "run-live",+ );++ await vi.advanceTimersByTimeAsync(50);+ expect(fetchMock).toHaveBeenCalledTimes(1);++ // Two poll intervals later the timeline has been re-read twice more.+ await vi.advanceTimersByTimeAsync(6_200);+ expect(fetchMock.mock.calls.length).toBeGreaterThanOrEqual(3);+ unmount();+ });++ it("never polls the plan of a finished run", async () => {+ const fetchMock = planFetchMock();+ vi.stubGlobal("fetch", fetchMock);++ const { unmount } = renderPlanHook(+ [{ slug: "run-done", status: "success" }],+ "run-done",+ );++ await vi.advanceTimersByTimeAsync(50);+ expect(fetchMock).toHaveBeenCalledTimes(1);++ // Long after any poll interval would have fired: still only the one read.+ await vi.advanceTimersByTimeAsync(20_000);+ expect(fetchMock).toHaveBeenCalledTimes(1);+ unmount();+ });++ it("treats a run missing from the list as finished (no poll)", async () => {+ const fetchMock = planFetchMock();+ vi.stubGlobal("fetch", fetchMock);++ const { unmount } = renderPlanHook([], "run-gone");++ await vi.advanceTimersByTimeAsync(50);+ await vi.advanceTimersByTimeAsync(20_000);+ expect(fetchMock).toHaveBeenCalledTimes(1);+ unmount();+ });+});diff --git a/jarvis/ui/web/frontend/src/hooks/useOutputs.ts b/jarvis/ui/web/frontend/src/hooks/useOutputs.tsindex 2ecb106aa0..551e2de3cc 100644--- a/jarvis/ui/web/frontend/src/hooks/useOutputs.ts+++ b/jarvis/ui/web/frontend/src/hooks/useOutputs.ts@@ -189,6 +189,7 @@ export function useRerunMission() {}export function usePlanForOutput(slug: string | null) {+ const qc = useQueryClient();return useQuery<PlanResponse>({queryKey: ["output-plan", slug],queryFn: async () => {@@ -198,6 +199,15 @@ export function usePlanForOutput(slug: string | null) {},enabled: !!slug,staleTime: 3_000,+ // A finished run's plan is history and never refetches on its own. A+ // RUNNING run's plan is a live step timeline, so it follows the mission+ // the same way the artifact listing already does — the run's status is+ // read from the outputs list every consumer already keeps in this cache.+ refetchInterval: () => {+ const runs = qc.getQueryData<OutputSummary[]>(["outputs"]);+ const status = runs?.find((r) => r.slug === slug)?.status;+ return status === "running" ? 3_000 : false;+ },});}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex de3b2010a1..e2e4b144e0 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1227,6 +1227,19 @@"shared_delete_prefix": "Dieser Schlüssel wird auch verwendet von:","shared_delete_suffix": "Beim Löschen werden auch diese Provider deaktiviert.","delete_anyway": "Trotzdem löschen",+ "key_saved_label": "Schlüssel gespeichert",+ "key_saved_toast": "Schlüssel gespeichert ({0})",+ "key_removed_toast": "Schlüssel entfernt ({0})",+ "replace": "Ersetzen",+ "replace_tooltip": "Neuen Schlüssel eingeben — der gespeicherte wird beim Speichern ersetzt.",+ "delete_key_tooltip": "Diesen Schlüssel entfernen",+ "get_key_at": "Schlüssel holen auf {0}",+ "get_key_here": "Schlüssel hier holen",+ "paste_key_placeholder": "Schlüssel hier einfügen…",+ "format_match_hint": "Sieht richtig aus — passt zum Schlüsselformat, das dieses Feld erwartet.",+ "format_mismatch": "Das sieht nach {0} aus — dieses Feld erwartet einen anderen Schlüssel. Speichern ist trotzdem möglich, wenn du sicher bist.",+ "reveal_key": "Schlüssel anzeigen",+ "hide_key": "Schlüssel verbergen","save": "Speichern","saved": "Gespeichert","missing": "Fehlt",@@ -3791,7 +3804,7 @@"setup_label": "Arbeitsbereich einrichten","reading_mode": "Darstellung","reading_mode_label": "Darstellung des Arbeitsbereichs",- "view_hint": "Nur die Darstellung ändert sich — Agents, Fenster und Unterhaltungen bleiben gleich, und die Toolbar kann jederzeit wechseln. Das Command Deck meldet abgeschlossene Agents außerdem laut.",+ "view_hint": "Nur die Darstellung ändert sich — Agents, Fenster und Unterhaltungen bleiben gleich, und die Toolbar kann jederzeit wechseln.","selected": "Ausgewählt","workspace": "Arbeitsbereich","opens_as": "Wird geöffnet als",@@ -3807,10 +3820,14 @@},"views": {"grid": { "title": "Terminal-Raster", "description": "Alle Fenster gleichzeitig nebeneinander — die vollständige Terminal-Wand." },- "chat": { "title": "Chat-Ansicht", "description": "Ein Agent im Mittelpunkt, die anderen in einer Leiste — lesbar wie eine Unterhaltung." },- "deck": { "title": "Command Deck", "description": "Du gibst den Auftrag per Sprache, {name} koordiniert und meldet fertige Agents." }+ "chat": { "title": "Chat-Ansicht", "description": "Ein Agent im Mittelpunkt, die anderen in einer Leiste — lesbar wie eine Unterhaltung." }}},+ "crowded": {+ "warning": "{0} Terminals nebeneinander sind auf den meisten Bildschirmen zu klein zum Lesen, und der Arbeitsbereich kann träge werden. Öffne ihn trotzdem, wenn dein Bildschirm den Platz hat.",+ "accept": "Trotzdem öffnen",+ "accepted": "{0} Terminals werden trotzdem geöffnet."+ },"resume": {"eyebrow": "Vorheriger Arbeitsstand","title": "Den Arbeitsraum wiederherstellen, nicht nur die Fenster",@@ -4158,6 +4175,8 @@"field_output": "Ausgabe","field_error": "Fehler","field_status": "Status",+ "field_duration": "Dauer",+ "field_attempts": "Versuche","field_request": "Anfrage","field_answer": "Antwort","field_file": "Datei",@@ -4169,7 +4188,8 @@"sandbox_note": "Nur Vorschau: Skripte und externe Inhalte sind blockiert. Für die vollständige Seite im Browser öffnen.","zoom_in": "Vergrößern","zoom_out": "Verkleinern",- "zoom_reset": "Zoom zurücksetzen",+ "zoom_reset": "Zoom auf 100% zurücksetzen",+ "zoom_fit": "Ganzen Durchlauf einpassen","open_external": "Öffnen","download": "Kopie speichern","reveal": "Im Ordner zeigen",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex a260b8220c..cfe3d9f479 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1227,6 +1227,19 @@"shared_delete_prefix": "This key is also used by:","shared_delete_suffix": "Deleting it disables those providers too.","delete_anyway": "Delete anyway",+ "key_saved_label": "Key saved",+ "key_saved_toast": "Key saved ({0})",+ "key_removed_toast": "Key removed ({0})",+ "replace": "Replace",+ "replace_tooltip": "Enter a new key — the saved one is replaced when you press Save.",+ "delete_key_tooltip": "Remove this key",+ "get_key_at": "Get your key at {0}",+ "get_key_here": "Get your key here",+ "paste_key_placeholder": "Paste your key here…",+ "format_match_hint": "Looks right — this matches the key format this field expects.",+ "format_mismatch": "This looks like a {0} — this field expects a different key. You can still save it if you are sure.",+ "reveal_key": "Show key",+ "hide_key": "Hide key","save": "Save","saved": "Saved","missing": "Missing",@@ -3791,7 +3804,7 @@"setup_label": "Workspace setup","reading_mode": "Reading mode","reading_mode_label": "How the workspace opens",- "view_hint": "Only how the workspace is read changes — the agents, panes and conversations stay the same, and the toolbar can switch at any time. Command Deck also reports completed agents aloud.",+ "view_hint": "Only how the workspace is read changes — the agents, panes and conversations stay the same, and the toolbar can switch at any time.","selected": "Selected","workspace": "Workspace","opens_as": "Opens as",@@ -3807,10 +3820,14 @@},"views": {"grid": { "title": "Terminal grid", "description": "Every pane on screen at once, side by side — the full wall of terminals." },- "chat": { "title": "Chat view", "description": "One agent at a time on a calm stage, the rest on a rail — read like a conversation." },- "deck": { "title": "Command Deck", "description": "You brief by voice, {name} runs the floor — and tells you when an agent is done." }+ "chat": { "title": "Chat view", "description": "One agent at a time on a calm stage, the rest on a rail — read like a conversation." }}},+ "crowded": {+ "warning": "{0} terminals side by side will be too small to read on most displays, and the workspace may feel sluggish. Open it anyway if your screen has the room.",+ "accept": "Open it anyway",+ "accepted": "Opening {0} terminals anyway."+ },"resume": {"eyebrow": "Previous working set","title": "Restore the room, not just the windows",@@ -4158,6 +4175,8 @@"field_output": "Output","field_error": "Error","field_status": "Status",+ "field_duration": "Duration",+ "field_attempts": "Attempts","field_request": "Request","field_answer": "Answer","field_file": "File",@@ -4169,7 +4188,8 @@"sandbox_note": "Preview only: scripts and external content are blocked. Open it in your browser for the full page.","zoom_in": "Zoom in","zoom_out": "Zoom out",- "zoom_reset": "Reset zoom",+ "zoom_reset": "Reset zoom to 100%",+ "zoom_fit": "Fit the whole run into view","open_external": "Open","download": "Save a copy","reveal": "Show in folder",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 63c63af77c..71dc773d04 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1227,6 +1227,19 @@"shared_delete_prefix": "Esta clave también la usan:","shared_delete_suffix": "Al eliminarla, esos proveedores también se desactivan.","delete_anyway": "Eliminar de todos modos",+ "key_saved_label": "Clave guardada",+ "key_saved_toast": "Clave guardada ({0})",+ "key_removed_toast": "Clave eliminada ({0})",+ "replace": "Reemplazar",+ "replace_tooltip": "Introduce una clave nueva — la guardada se reemplaza al pulsar Guardar.",+ "delete_key_tooltip": "Eliminar esta clave",+ "get_key_at": "Consigue tu clave en {0}",+ "get_key_here": "Consigue tu clave aquí",+ "paste_key_placeholder": "Pega tu clave aquí…",+ "format_match_hint": "Parece correcta — coincide con el formato de clave que espera este campo.",+ "format_mismatch": "Esto parece {0} — este campo espera otra clave. Aun así puedes guardarla si estás seguro.",+ "reveal_key": "Mostrar clave",+ "hide_key": "Ocultar clave","save": "Guardar","saved": "Guardado","missing": "Falta",@@ -3791,7 +3804,7 @@"setup_label": "Configurar espacio de trabajo","reading_mode": "Modo de lectura","reading_mode_label": "Cómo se abre el espacio de trabajo",- "view_hint": "Solo cambia la presentación: los agentes, paneles y conversaciones siguen iguales, y la barra permite cambiar en cualquier momento. Command Deck también anuncia los agentes que terminan.",+ "view_hint": "Solo cambia la presentación: los agentes, paneles y conversaciones siguen iguales, y la barra permite cambiar en cualquier momento.","selected": "Seleccionado","workspace": "Espacio de trabajo","opens_as": "Se abre como",@@ -3807,10 +3820,14 @@},"views": {"grid": { "title": "Cuadrícula de terminales", "description": "Todos los paneles a la vez, uno junto a otro: la pared completa de terminales." },- "chat": { "title": "Vista de chat", "description": "Un agente en el centro y los demás en una barra, como una conversación." },- "deck": { "title": "Command Deck", "description": "Tú das las instrucciones por voz, {name} coordina y avisa cuando termina un agente." }+ "chat": { "title": "Vista de chat", "description": "Un agente en el centro y los demás en una barra, como una conversación." }}},+ "crowded": {+ "warning": "{0} terminales en paralelo serán demasiado pequeños para leerlos en la mayoría de las pantallas, y el espacio de trabajo puede volverse lento. Ábrelo de todos modos si tu pantalla tiene sitio.",+ "accept": "Abrir de todos modos",+ "accepted": "Se abrirán {0} terminales de todos modos."+ },"resume": {"eyebrow": "Espacio de trabajo anterior","title": "Recupera el espacio de trabajo, no solo las ventanas",@@ -4158,6 +4175,8 @@"field_output": "Salida","field_error": "Error","field_status": "Estado",+ "field_duration": "Duración",+ "field_attempts": "Intentos","field_request": "Petición","field_answer": "Respuesta","field_file": "Archivo",@@ -4169,7 +4188,8 @@"sandbox_note": "Solo vista previa: los scripts y el contenido externo están bloqueados. Ábrelo en el navegador para ver la página completa.","zoom_in": "Acercar","zoom_out": "Alejar",- "zoom_reset": "Restablecer zoom",+ "zoom_reset": "Restablecer el zoom al 100%",+ "zoom_fit": "Ajustar toda la ejecución a la vista","open_external": "Abrir","download": "Guardar una copia","reveal": "Mostrar en la carpeta",diff --git a/jarvis/ui/web/frontend/src/lib/runGraph.test.ts b/jarvis/ui/web/frontend/src/lib/runGraph.test.tsindex 49f8deb65d..22c491f627 100644--- a/jarvis/ui/web/frontend/src/lib/runGraph.test.ts+++ b/jarvis/ui/web/frontend/src/lib/runGraph.test.ts@@ -4,16 +4,25 @@* Contracts worth pinning:* - the main track is start → steps in order → result, each linked to its* predecessor, so the flow reads left to right like a workflow editor,- * - an artifact hangs off the step that wrote it (matched by filename),- * and off the result/start node when no step claims it — an archived run- * with no surviving stream still gets a complete, honest graph,+ * - a long main track wraps after MAIN_TRACK_COLUMNS and reads like text —+ * left to right, then down — instead of stretching into one endless row,+ * - an artifact hangs off the step that wrote it (matched by filename) and+ * sits UNDER that step where the row allows; it falls to the result/start+ * node when no step claims it — an archived run with no surviving stream+ * still gets a complete, honest graph,* - a live run's newest unconfirmed call renders as "running", while the* same shape in a finished run stays "skipped" (anti-hearsay).*/import { describe, expect, it } from "vitest";import type { ArtifactSummary, PlanStep } from "@/hooks/useOutputs";-import { buildRunGraph, edgePath, NODE_H, NODE_W } from "@/lib/runGraph";+import {+ buildRunGraph,+ edgePath,+ MAIN_TRACK_COLUMNS,+ NODE_H,+ NODE_W,+} from "@/lib/runGraph";function step(over: Partial<PlanStep> & { step_id: string }): PlanStep {return {@@ -60,6 +69,34 @@ describe("buildRunGraph", () => {expect(r.x).toBeGreaterThan(b.x);});+ it("wraps a long main track after MAIN_TRACK_COLUMNS, reading like text", () => {+ const steps = Array.from({ length: 12 }, (_, i) =>+ step({ step_id: `s${i}` }),+ );+ const graph = buildRunGraph({+ slug: "long",+ runStatus: "success",+ plan: {+ plan: { plan_id: "long", vision: "", status: "complete" },+ steps,+ final_answer: "done",+ },+ files: [],+ });++ // 14 main nodes in columns of MAIN_TRACK_COLUMNS → three rows.+ const rows = new Set(graph.nodes.map((n) => n.y));+ expect(rows.size).toBe(Math.ceil(14 / MAIN_TRACK_COLUMNS));+ // The first node after a wrap returns to the left edge, one row down.+ const first = graph.nodes[0];+ const lastOfRow = graph.nodes[MAIN_TRACK_COLUMNS - 1];+ const firstOfNextRow = graph.nodes[MAIN_TRACK_COLUMNS];+ expect(firstOfNextRow.x).toBe(first.x);+ expect(firstOfNextRow.y).toBeGreaterThan(lastOfRow.y);+ // The canvas stays bounded to the column count, not the step count.+ expect(graph.width).toBeLessThan(MAIN_TRACK_COLUMNS * (NODE_W + 100) + 100);+ });+it("hangs an artifact off the step that wrote it, matched by filename", () => {const graph = buildRunGraph({slug: "run-1",@@ -79,9 +116,39 @@ describe("buildRunGraph", () => {e.to.startsWith("artifact:"),);expect(edge?.from).toBe("step:a");- // Second track: the artifact sits below the main track.+ // Second track: the artifact sits below the main track, and directly+ // UNDER its source step — provenance readable from position alone.const artifact = graph.nodes.find((n) => n.kind === "artifact");+ const source = graph.nodes.find((n) => n.id === "step:a");expect(artifact!.y).toBeGreaterThan(graph.nodes[0].y);+ expect(artifact!.x).toBe(source!.x);+ });++ it("shifts colliding artifacts apart instead of stacking them", () => {+ const graph = buildRunGraph({+ slug: "run-1",+ runStatus: "success",+ plan: {+ plan: { plan_id: "run-1", vision: "", status: "complete" },+ steps: [+ step({+ step_id: "a",+ tool_name: "Write",+ writes: ["out/a.png", "out/b.png"],+ }),+ ],+ final_answer: "done",+ },+ files: [+ file("tasks/t1/artifacts/files/out/a.png"),+ file("tasks/t1/artifacts/files/out/b.png"),+ ],+ });++ const artifacts = graph.nodes.filter((n) => n.kind === "artifact");+ expect(artifacts).toHaveLength(2);+ const [left, right] = [...artifacts].sort((a, b) => a.x - b.x);+ expect(right.x - left.x).toBeGreaterThanOrEqual(NODE_W);});it("gives an unclaimed artifact to the result node, or start without one", () => {@@ -126,6 +193,32 @@ describe("buildRunGraph", () => {expect(done.nodes.find((n) => n.id === "step:b")?.status).toBe("skipped");});+ it("denies a cancelled run without an answer the success dot", () => {+ const plan = {+ plan: { plan_id: "r", vision: "", status: "cancelled" },+ steps: [step({ step_id: "a" })],+ };+ const cancelled = buildRunGraph({+ slug: "r",+ runStatus: "cancelled",+ plan,+ files: [],+ });+ expect(cancelled.nodes.find((n) => n.id === "result")?.status).toBe(+ "skipped",+ );++ // With a recorded final answer the worker DID finish its say — that+ // stays "done" even though the mission ended as cancelled.+ const answered = buildRunGraph({+ slug: "r",+ runStatus: "cancelled",+ plan: { ...plan, final_answer: "partial result" },+ files: [],+ });+ expect(answered.nodes.find((n) => n.id === "result")?.status).toBe("done");+ });+it("marks the edge into a failed step so the track can alarm", () => {const graph = buildRunGraph({slug: "r",diff --git a/jarvis/ui/web/frontend/src/lib/runGraph.ts b/jarvis/ui/web/frontend/src/lib/runGraph.tsindex d5b4026de5..036c7a0a50 100644--- a/jarvis/ui/web/frontend/src/lib/runGraph.ts+++ b/jarvis/ui/web/frontend/src/lib/runGraph.ts@@ -3,9 +3,10 @@** A run is drawn the way a workflow editor would draw it: what was asked* (start node), what the worker actually did (one node per tool call, in- * order, on the main track), what it said at the end (result node), and what- * it left behind (one node per deliverable, on a second track, connected to- * the step that wrote it). The data comes from two reads the app already+ * order, on the main track, wrapping like text after MAIN_TRACK_COLUMNS),+ * what it said at the end (result node), and what it left behind (one node+ * per deliverable, on a second track below, placed under the step that wrote+ * it and connected to it). The data comes from two reads the app already* makes — `/api/outputs/{slug}/plan` and `/api/outputs/{slug}/artifacts` —* so a run archived long before this feature existed still gets its graph.*@@ -67,8 +68,31 @@ export const NODE_W = 216;export const NODE_H = 76;const GAP_X = 56;const ROW_GAP = 72;+/* The deliverables track sits a little further off than wrapped main rows,+ * so "second track" stays visually distinct from "next line of the story". */+const TRACK_GAP = 104;const PADDING = 24;+/**+ * Main-track nodes per row before the track wraps to the next line.+ *+ * A run is read like text: left to right, then down. Without the wrap a+ * thirty-step run is an eight-thousand-pixel horizontal strip that no zoom+ * level makes readable; with it, the same run is a handful of rows that fit+ * one screen. Five columns keeps a row inside a typical canvas at 100%.+ */+export const MAIN_TRACK_COLUMNS = 5;++/** Top-left corner of the main-track slot `index` (start = slot 0). */+function slotPosition(index: number): { x: number; y: number } {+ const column = index % MAIN_TRACK_COLUMNS;+ const row = Math.floor(index / MAIN_TRACK_COLUMNS);+ return {+ x: PADDING + column * (NODE_W + GAP_X),+ y: PADDING + row * (NODE_H + ROW_GAP),+ };+}+/** Last path segment, tolerant of both separators. */function basename(path: string): string {const parts = path.split(/[\\/]/);@@ -123,9 +147,10 @@ export function buildRunGraph(input: RunGraphInput): RunGraph {const lastUnconfirmed = [...steps].reverse().find((s) => s.status === "skipped");- /* Main track: start → steps → result. */- let x = PADDING;- const mainY = PADDING;+ /* Main track: start → steps → result, wrapping after MAIN_TRACK_COLUMNS+ * so a long run reads like text — left to right, then down — instead of+ * becoming a horizontal strip no screen can hold. */+ let slot = 0;nodes.push({id: "start",@@ -138,11 +163,10 @@ export function buildRunGraph(input: RunGraphInput): RunGraph {: input.runStatus === "error"? "failed": "none",- x,- y: mainY,+ ...slotPosition(slot),});let previousId = "start";- x += NODE_W + GAP_X;+ slot += 1;for (const step of steps) {const id = `step:${step.step_id}`;@@ -154,8 +178,7 @@ export function buildRunGraph(input: RunGraphInput): RunGraph {subtitle: step.tool_name && step.name !== step.tool_name ? step.name : "",status,step,- x,- y: mainY,+ ...slotPosition(slot),});edges.push({id: `${previousId}->${id}`,@@ -164,7 +187,7 @@ export function buildRunGraph(input: RunGraphInput): RunGraph {failed: status === "failed",});previousId = id;- x += NODE_W + GAP_X;+ slot += 1;}/* The result node closes the track whenever there is anything to close it@@ -179,9 +202,15 @@ export function buildRunGraph(input: RunGraphInput): RunGraph {kind: "result",title: "result",subtitle: finalAnswer ?? "",- status: input.runStatus === "error" ? "failed" : "done",- x,- y: mainY,+ // A cancelled run that never answered must not wear the success dot —+ // "no confirmed result" is the honest reading of that ending.+ status:+ input.runStatus === "error"+ ? "failed"+ : input.runStatus === "cancelled" && !finalAnswer+ ? "skipped"+ : "done",+ ...slotPosition(slot),});edges.push({id: `${previousId}->result`,@@ -189,17 +218,28 @@ export function buildRunGraph(input: RunGraphInput): RunGraph {to: "result",failed: input.runStatus === "error",});+ slot += 1;}const hasResult = nodes[nodes.length - 1].id === "result";/* Deliverables track: one node per archived file, connected to the step- * that wrote it (result/start node when no step claims it). */- const artifactY = mainY + NODE_H + ROW_GAP;- let artifactX = PADDING;- for (const file of input.files) {- const id = `artifact:${file.path}`;+ * that wrote it (result/start node when no step claims it). Each artifact+ * sits UNDER its source node where the row allows — provenance readable+ * from position alone, not only by tracing an edge across the canvas. */+ const mainRows = Math.max(1, Math.ceil(slot / MAIN_TRACK_COLUMNS));+ const artifactY =+ PADDING + (mainRows - 1) * (NODE_H + ROW_GAP) + NODE_H + TRACK_GAP;+ const byId = new Map(nodes.map((n) => [n.id, n]));+ const placed = input.files.map((file) => {const source = findSourceStep(steps, file.path);const from = source ? `step:${source.step_id}` : hasResult ? "result" : "start";+ return { file, from, desiredX: byId.get(from)?.x ?? PADDING };+ });+ placed.sort((a, b) => a.desiredX - b.desiredX);+ let artifactX = PADDING;+ for (const { file, from, desiredX } of placed) {+ const id = `artifact:${file.path}`;+ const x = Math.max(desiredX, artifactX);nodes.push({id,kind: "artifact",@@ -207,11 +247,11 @@ export function buildRunGraph(input: RunGraphInput): RunGraph {subtitle: file.path,status: "none",artifact: file,- x: artifactX,+ x,y: artifactY,});edges.push({ id: `${from}->${id}`, from, to: id, failed: false });- artifactX += NODE_W + GAP_X;+ artifactX = x + NODE_W + GAP_X;}const width =diff --git a/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsx b/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsxindex 552c9008a2..d6207eec34 100644--- a/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/VisualizationView.test.tsx@@ -10,7 +10,9 @@* - clicking a node opens the inspector; an image deliverable previews via* `<img>`, a page via an inert sandboxed frame,* - the server-rendered mission map stays one click away ("open as page"),- * - only files the WebView can draw are offered a preview (`classifyVisual`).+ * - only files the WebView can draw are offered a preview (`classifyVisual`),+ * - a failed step alarms from its card frame, not from a 6px dot alone,+ * - the inspector surfaces the archived timing (`duration_s`) of a step.*/import { afterEach, describe, expect, it, vi } from "vitest";import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";@@ -109,6 +111,7 @@ const CHART_PLAN: PlanResponse = {tool_name: "Bash",status: "done",output: "wrote diagram.svg",+ duration_s: 3.2,},{step_id: "t1:1",@@ -229,6 +232,49 @@ describe("VisualizationView", () => {const inspector = await screen.findByTestId("visualization-inspector");expect(inspector.textContent).toContain("python plot.py");expect(inspector.textContent).toContain("wrote diagram.svg");+ // The archived timing is shown, not discarded.+ expect(inspector.textContent).toContain("3.2 s");+ });++ it("frames a failed step in the alarm colour, not just a dot", async () => {+ installFetchMock(+ [{ slug: "run-bad", utterance: "Deploy the site", status: "error" }],+ { "run-bad": [] },+ {+ "run-bad": {+ plan: { plan_id: "run-bad", vision: "Deploy", status: "failed" },+ steps: [+ {+ step_id: "t1:0",+ name: "npm run deploy",+ tool_name: "Bash",+ status: "failed",+ error: "exit 1",+ },+ ],+ },+ },+ );++ renderView();++ const node = await screen.findByTestId("graph-node-step");+ expect(node.className).toContain("border-destructive");+ });++ it("offers a fit-to-view zoom next to the step buttons", async () => {+ installFetchMock(+ [{ slug: "run-new", utterance: "Draw the architecture", status: "success" }],+ { "run-new": [] },+ { "run-new": CHART_PLAN },+ );++ renderView();++ // jsdom has no layout (clientWidth 0) — the fit guard must keep the+ // click a harmless no-op rather than zooming to nonsense.+ fireEvent.click(await screen.findByTestId("visualization-zoom-fit"));+ expect(screen.getByText("100%")).toBeTruthy();});it("keeps the server-rendered mission map one click away", async () => {diff --git a/jarvis/ui/web/frontend/src/views/VisualizationView.tsx b/jarvis/ui/web/frontend/src/views/VisualizationView.tsxindex 4fc2756704..32a01a16f8 100644--- a/jarvis/ui/web/frontend/src/views/VisualizationView.tsx+++ b/jarvis/ui/web/frontend/src/views/VisualizationView.tsx@@ -1,4 +1,4 @@-import { useCallback, useEffect, useMemo, useState } from "react";+import { useCallback, useEffect, useMemo, useRef, useState } from "react";import {Download,ExternalLink,@@ -87,7 +87,18 @@ import {* the thing people put on a second monitor while the mission is still going.*/-const ZOOM_STEPS = [0.5, 0.65, 0.8, 1, 1.25, 1.5] as const;+/*+ * Zoom: the buttons snap to these steps, the wheel (Ctrl/⌘ + scroll, and the+ * trackpad pinch that browsers report the same way) moves continuously, and+ * "fit" produces whatever ratio the graph needs — so the step logic finds the+ * NEAREST step in the pressed direction rather than requiring an exact match.+ */+const ZOOM_STEPS = [0.25, 0.35, 0.5, 0.65, 0.8, 1, 1.25, 1.5] as const;+const MIN_ZOOM = ZOOM_STEPS[0];+const MAX_ZOOM = ZOOM_STEPS[ZOOM_STEPS.length - 1];++const clampZoom = (value: number): number =>+ Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, value));/** Same status colour language as the Outputs cards — one vocabulary. */const RUN_DOT: Record<OutputStatus, string> = {@@ -152,6 +163,15 @@ function formatSize(bytes: number): string {return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;}+/** Human duration for a step — sub-second precision only where it matters. */+function formatDuration(seconds: number): string {+ if (seconds < 10) return `${seconds.toFixed(1)} s`;+ if (seconds < 60) return `${Math.round(seconds)} s`;+ const minutes = Math.floor(seconds / 60);+ const rest = Math.round(seconds % 60);+ return `${minutes} min ${rest} s`;+}+export function VisualizationView() {const t = useT();const outputs = useOutputsList();@@ -232,15 +252,62 @@ export function VisualizationView() {}, [graph, selectedNodeId]);const [zoom, setZoom] = useState<number>(1);+ /* Once the user has zoomed by hand, the automatic fit keeps its hands off+ * until another run is selected — an explicit choice must never be fought. */+ const userZoomed = useRef(false);+ const [canvasEl, setCanvasEl] = useState<HTMLDivElement | null>(null);+const stepZoom = useCallback((direction: 1 | -1) => {+ userZoomed.current = true;setZoom((current) => {- const index = ZOOM_STEPS.findIndex((s) => Math.abs(s - current) < 0.001);- const base = index >= 0 ? index : ZOOM_STEPS.indexOf(1);- const next = Math.min(ZOOM_STEPS.length - 1, Math.max(0, base + direction));- return ZOOM_STEPS[next];+ if (direction > 0) {+ return ZOOM_STEPS.find((s) => s > current + 0.001) ?? MAX_ZOOM;+ }+ const smaller = [...ZOOM_STEPS].reverse().find((s) => s < current - 0.001);+ return smaller ?? Math.min(current, MIN_ZOOM);});}, []);+ /* Scale the whole story into the visible canvas — never above 100%, so a+ * two-node run stays a pair of cards instead of a pair of billboards. The+ * guard skips hidden/unmeasured hosts (detached warm-up, jsdom). */+ const fitZoom = useCallback(() => {+ if (canvasEl === null || graph === null) return;+ const { clientWidth, clientHeight } = canvasEl;+ if (clientWidth < 80 || clientHeight < 80) return;+ const scale = Math.min(+ (clientWidth - 16) / graph.width,+ (clientHeight - 16) / graph.height,+ 1,+ );+ setZoom(clampZoom(scale));+ }, [canvasEl, graph]);++ useEffect(() => {+ userZoomed.current = false;+ }, [run?.slug]);++ /* Auto-fit whenever the graph's extents change — the first paint, the plan+ * arriving a beat after the run list, and a live run growing new steps. */+ useEffect(() => {+ if (!userZoomed.current) fitZoom();+ }, [fitZoom, graph?.width, graph?.height]);++ /* Ctrl/⌘ + wheel zooms (that's also how browsers deliver a trackpad pinch).+ * Attached natively because React registers wheel listeners passively, and+ * a passive listener cannot preventDefault the browser's own page zoom. */+ useEffect(() => {+ if (canvasEl === null) return;+ const onWheel = (event: WheelEvent) => {+ if (!event.ctrlKey && !event.metaKey) return;+ event.preventDefault();+ userZoomed.current = true;+ setZoom((current) => clampZoom(current * Math.exp(-event.deltaY * 0.002)));+ };+ canvasEl.addEventListener("wheel", onWheel, { passive: false });+ return () => canvasEl.removeEventListener("wheel", onWheel);+ }, [canvasEl]);+const refetch = useCallback(() => {void outputs.refetch();void plan.refetch();@@ -365,6 +432,7 @@ export function VisualizationView() {) : (<><div+ ref={setCanvasEl}className="min-h-0 flex-1 overflow-auto"data-testid="visualization-canvas">@@ -398,9 +466,18 @@ export function VisualizationView() {><ZoomOut className="h-3.5 w-3.5" aria-hidden /></Button>- <span className="w-12 text-center text-[11px] tabular-nums text-muted-foreground">+ <button+ type="button"+ onClick={() => {+ userZoomed.current = true;+ setZoom(1);+ }}+ title={t("visualization.zoom_reset")}+ aria-label={t("visualization.zoom_reset")}+ className="w-12 text-center text-[11px] tabular-nums text-muted-foreground transition-colors hover:text-foreground"+ >{`${Math.round(zoom * 100)}%`}- </span>+ </button><Buttonvariant="ghost"size="sm"@@ -413,9 +490,15 @@ export function VisualizationView() {<Buttonvariant="ghost"size="sm"- onClick={() => setZoom(1)}- title={t("visualization.zoom_reset")}- aria-label={t("visualization.zoom_reset")}+ onClick={() => {+ // An explicit fit re-arms the auto-fit: a live run that+ // grows new steps keeps fitting until zoomed by hand.+ userZoomed.current = false;+ fitZoom();+ }}+ title={t("visualization.zoom_fit")}+ aria-label={t("visualization.zoom_fit")}+ data-testid="visualization-zoom-fit"><Maximize2 className="h-3.5 w-3.5" aria-hidden /></Button>@@ -481,14 +564,25 @@ function GraphCanvas({const from = byId.get(edge.from);const to = byId.get(edge.to);if (!from || !to) return null;+ /* The selected node's own edges brighten, so "what fed this and+ * what came of it" is answered by the picture, not by tracing. */+ const active =+ selectedId !== null &&+ (edge.from === selectedId || edge.to === selectedId);return (<pathkey={edge.id}d={edgePath(from, to)}fill="none"- strokeWidth={1.5}+ strokeWidth={active ? 2.5 : 1.5}className={- edge.failed ? "stroke-destructive/70" : "stroke-primary/50"+ edge.failed+ ? active+ ? "stroke-destructive"+ : "stroke-destructive/70"+ : active+ ? "stroke-primary"+ : "stroke-primary/50"}/>);@@ -515,9 +609,15 @@ function GraphCanvas({style={{ left: node.x, top: node.y, width: NODE_W, height: NODE_H }}className={cn("absolute flex items-center gap-2.5 rounded-xl border bg-card px-3 text-left shadow-sm transition-colors",+ /* A failed or running step announces itself from the card+ * frame — a 6px dot alone is not a glanceable alarm. */selected? "border-primary ring-1 ring-primary/40"- : "border-border hover:border-primary/50",+ : node.status === "failed"+ ? "border-destructive/70 hover:border-destructive"+ : node.status === "running"+ ? "border-primary/60 hover:border-primary"+ : "border-border hover:border-primary/50",)}>{/* Ports — the connectors that make cards read as graph nodes. */}@@ -646,6 +746,18 @@ function NodeInspector({<InspectorField label={t("visualization.field_status")}>{t(`visualization.status_${node.status}`)}</InspectorField>+ {typeof node.step.duration_s === "number" &&+ node.step.duration_s > 0 && (+ <InspectorField label={t("visualization.field_duration")}>+ {formatDuration(node.step.duration_s)}+ </InspectorField>+ )}+ {/* One attempt is the norm — only a retry is worth a line. */}+ {(node.step.attempts ?? 1) > 1 && (+ <InspectorField label={t("visualization.field_attempts")}>+ {String(node.step.attempts)}+ </InspectorField>+ )}</>)}