web: tabbed run detail with summary, IO fields and timeline (R3/R6/R7)

The browser run detail becomes a tab strip — Summary, Input, Output,
Timeline — over the selected tab's body, with the Graph tab key reserved
for the R5 item.

- Summary: run label, status chip + outcome, the run identity line, the
  key/value rows (Pipeline, Stage, waiting-for-resource line, Workspace,
  content hash, Started, Finished, live Duration, Retry of, Diagnostic)
  and the collapsed run artifacts gallery.
- Input / Output: one collapsed section per recorded map entry, the value
  as a monospace block; empty states match the app.
- Timeline: one row per visit with the stage-outcome glyph, `{stage} ·
  visit {n}`, an outcome chip, a paperclip when artifacts were recorded,
  the duration and the description; a row opens the per-visit stage pane.
- Stage pane: headline rows, the Verdict block with inline artifact links
  and the Artifacts / Session / Output / Input / This run / Stage
  definition sections, all closable with Escape.

All new logic is the pure, DOM-free src/runDetail.js ported from the
Android sources; app.js keeps only the wiring and every server string is
set with textContent.

PARITY.md: R3, R6 and R7 marked done with their captures.
This commit is contained in:
2026-10-19 03:32:32 +01:00
parent 4be740b461
commit 06965933f4
6 changed files with 2096 additions and 116 deletions
+507
View File
@@ -0,0 +1,507 @@
// Pure unit tests for the run-detail helpers: the tab set, the summary rows and
// identity line, input/output field display, the timeline derivation and its
// one-line text, the stage-pane section ordering and field split, the
// file-change/notification formatters and the verdict reason segmentation.
// No server, no DOM.
import { test } from "node:test";
import assert from "node:assert/strict";
import {
RUN_DETAIL_TABS,
RENDERED_RUN_TABS,
EMPTY_INPUT_MESSAGE,
EMPTY_OUTPUT_MESSAGE,
EMPTY_TIMELINE_MESSAGE,
NO_STAGE_DETAILS_MESSAGE,
STAGE_SESSION_TITLE,
STAGE_EVIDENCE_TITLE,
STAGE_DEFINITION_TITLE,
displayText,
displayMap,
fieldSections,
fieldSectionTitle,
summaryRows,
resourceWaitLine,
runIdentityLine,
runDurationText,
runTimeline,
timelineDescription,
hasArtifacts,
nodeLabel,
resolveTarget,
stageOutcomes,
headlineFields,
evidenceFields,
runStepFields,
stageDefinitionFields,
terminalFields,
controlVisitLabel,
clampVisitIndex,
stageSectionSpecs,
referencedVerdictArtifacts,
verdictReasonSegments,
artifactBaseName,
fileChangeLine,
notificationLine,
fileChangesSummary,
outcomeColorToken,
stateGlyph,
} from "../src/runDetail.js";
function step(overrides = {}) {
return {
sequence: 1,
stage: "implementer",
status: "completed",
outcome: "success",
target: "",
diagnostic: "",
started_at: "",
finished_at: "",
control: null,
artifacts: null,
...overrides,
};
}
const TIME_OPTS = { zone: "UTC", locale: "en-GB" };
// ---------------------------------------------------------------------------
// Tabs and empty states
// ---------------------------------------------------------------------------
test("RUN_DETAIL_TABS is the Android order, Summary first, Timeline keyed 'steps'", () => {
assert.deepEqual(
RUN_DETAIL_TABS.map((tab) => tab.key),
["summary", "graph", "input", "output", "steps"],
);
assert.deepEqual(
RUN_DETAIL_TABS.map((tab) => tab.label),
["Summary", "Graph", "Input", "Output", "Timeline"],
);
// The Graph body is the R5 item; only the other four render today.
assert.deepEqual(
RENDERED_RUN_TABS.map((tab) => tab.label),
["Summary", "Input", "Output", "Timeline"],
);
});
test("the empty-state strings are exactly the app's wording", () => {
assert.equal(EMPTY_INPUT_MESSAGE, "No input recorded.");
assert.equal(EMPTY_OUTPUT_MESSAGE, "No output recorded.");
assert.equal(EMPTY_TIMELINE_MESSAGE, "No visits recorded.");
assert.equal(NO_STAGE_DETAILS_MESSAGE, "No details recorded for this node.");
assert.equal(STAGE_SESSION_TITLE, "Session");
assert.equal(STAGE_EVIDENCE_TITLE, "This run");
assert.equal(STAGE_DEFINITION_TITLE, "Stage definition");
});
// ---------------------------------------------------------------------------
// Field display text
// ---------------------------------------------------------------------------
test("displayText renders primitives, arrays and objects like Format.kt", () => {
assert.equal(displayText("hello"), "hello");
assert.equal(displayText(42), "42");
assert.equal(displayText(true), "true");
assert.equal(displayText(null), "null");
assert.equal(displayText(["a", "b", "c"]), "a, b, c");
assert.equal(displayText({ a: 1, b: "x" }), "a=1, b=x");
assert.equal(displayText([{ k: 1 }, 2]), "k=1, 2");
});
test("displayMap renders one `key: value` line per entry in insertion order", () => {
assert.equal(displayMap({ prompt: "do it", files: ["a", "b"] }), "prompt: do it\nfiles: a, b");
assert.equal(displayMap(null), "");
assert.equal(displayMap({}), "");
});
test("fieldSections keeps insertion order and titles each entry", () => {
const sections = fieldSections({ prompt: "do it", pwd: "/tmp" }, "input");
assert.deepEqual(sections, [
{ key: "prompt", title: "prompt", value: "do it" },
{ key: "pwd", title: "pwd", value: "/tmp" },
]);
assert.deepEqual(fieldSections(null, "input"), []);
});
test("fieldSectionTitle falls back to the prefix and is never empty", () => {
assert.equal(fieldSectionTitle("plan", "input"), "plan");
assert.equal(fieldSectionTitle("", "input"), "input");
assert.equal(fieldSectionTitle(" ", "output"), "output");
});
// ---------------------------------------------------------------------------
// Summary
// ---------------------------------------------------------------------------
test("runIdentityLine carries recorded and completed visits in order", () => {
const run = { id: 430, steps: [step(), step(), step()], completed_steps: 3 };
assert.equal(runIdentityLine(run), "run 430 · 3 recorded visits · 3 completed visits");
assert.equal(
runIdentityLine({ id: 7, steps: [step()], completed_steps: 0 }),
"run 7 · 1 recorded visit · 0 completed visits",
);
});
test("resourceWaitLine appears only when the run is waiting on a resource", () => {
assert.equal(resourceWaitLine({ resource_wait: { resource: "pixel-9" } }), "Waiting for resource pixel-9");
assert.equal(resourceWaitLine({ resource_wait: null }), "");
assert.equal(resourceWaitLine({}), "");
});
test("summaryRows is the Android order, omitting blank values", () => {
const run = {
id: 430,
pipeline_id: 12,
version: 5,
status: "succeeded",
executing: false,
current_stage: "committer",
workspace: "/tmp/wt",
content_hash: "abc123",
created_at: "2026-10-19T09:30:00Z",
finished_at: "2026-10-19T09:32:05Z",
retry_of: 409,
diagnostic: "boom",
resource_wait: { resource: "phone" },
steps: [step(), step(), step()],
completed_steps: 3,
};
const rows = summaryRows(run, 0, TIME_OPTS);
assert.deepEqual(
rows.map((row) => row.key ?? row.kind),
["Pipeline", "Stage", "wait", "Workspace", "Content hash", "Started", "Finished", "Duration", "Retry of", "Diagnostic"],
);
assert.equal(rows[0].value, "id 12 · v5");
assert.equal(rows[2].value, "Waiting for resource phone");
assert.equal(rows[4].monospace, true);
assert.equal(rows[7].value, "2m 5s");
assert.equal(rows[8].value, "run 409");
assert.equal(rows[9].kind, "block");
});
test("summaryRows omits blank values and the wait line when there is none", () => {
const rows = summaryRows(
{ id: 1, pipeline_id: 2, version: 1, status: "running", executing: false, steps: [], completed_steps: 0 },
0,
TIME_OPTS,
);
assert.ok(rows.every((row) => row.kind !== "wait"));
assert.ok(rows.every((row) => row.value.trim() !== ""));
assert.ok(!rows.some((row) => row.key === "Stage" || row.key === "Workspace"));
});
test("runDurationText is live while executing and stored at rest", () => {
assert.equal(
runDurationText({ executing: true, created_at: "2026-10-19T09:30:00Z" }, Date.parse("2026-10-19T09:31:05Z")),
"1m 5s",
);
assert.equal(runDurationText({ executing: false, created_at: "2026-10-19T09:30:00Z", finished_at: "2026-10-19T09:32:05Z" }, 0), "2m 5s");
assert.equal(runDurationText({ executing: false, created_at: "", finished_at: "" }, 0), null);
});
// ---------------------------------------------------------------------------
// Timeline
// ---------------------------------------------------------------------------
test("runTimeline is one entry per visit with the display visit and index", () => {
const { entries, visitsByStage } = runTimeline([
step({ sequence: 5, stage: "reviewer", outcome: "rejected", control: { visit: 2 } }),
step({ sequence: 2, stage: "reviewer", outcome: "success", control: { visit: 1 } }),
]);
assert.deepEqual(entries.map((entry) => entry.step.sequence), [5, 2]);
const bySeq = new Map(entries.map((entry) => [entry.step.sequence, entry]));
assert.equal(bySeq.get(2).visit, 1);
assert.equal(bySeq.get(2).visitIndex, 0);
assert.equal(bySeq.get(5).visit, 2);
assert.equal(bySeq.get(5).visitIndex, 1);
assert.deepEqual(visitsByStage.get("reviewer").map((s) => s.sequence), [2, 5]);
});
test("runTimeline falls back to the position when control is missing", () => {
const { entries } = runTimeline([step({ sequence: 1 }), step({ sequence: 2 })]);
assert.deepEqual(entries.map((entry) => entry.visit), [1, 2]);
assert.deepEqual(entries.map((entry) => entry.visitIndex), [0, 1]);
assert.deepEqual(runTimeline([]).entries, []);
});
test("timeline entry text prefers the first diagnostic line, else → target", () => {
const { entries } = runTimeline([
step({ diagnostic: "\n first line \nsecond" }),
step({ target: "#success" }),
step({ target: "reviewer" }),
step({}),
]);
assert.equal(entries[0].description, "first line");
assert.equal(entries[1].description, "→ SUCCESS");
assert.equal(entries[2].description, "→ reviewer");
assert.equal(entries[3].description, "");
});
test("timelineDescription mirrors nodeLabel for the terminals", () => {
assert.equal(timelineDescription(step({ target: "#failure" })), "→ FAILURE");
assert.equal(nodeLabel("#success"), "SUCCESS");
assert.equal(nodeLabel("#failure"), "FAILURE");
assert.equal(nodeLabel("reviewer"), "reviewer");
});
test("timeline entries carry the outcome label and the artifact flag", () => {
const { entries } = runTimeline([
step({ outcome: "", status: "running" }),
step({ outcome: "approved", status: "completed", artifacts: [{ name: "session.md" }] }),
step({ outcome: "approved", status: "completed", artifacts: [{ name: "shot.png" }] }),
]);
assert.equal(entries[0].outcomeLabel, "running");
assert.equal(entries[1].outcomeLabel, "approved");
assert.equal(entries[1].hasArtifacts, false);
assert.equal(entries[2].hasArtifacts, true);
assert.equal(hasArtifacts(step()), false);
});
test("timeline duration comes from the shared formatter", () => {
const { entries } = runTimeline([
step({ started_at: "2026-10-15T02:00:00Z", finished_at: "2026-10-15T02:02:05Z" }),
]);
assert.equal(entries[0].duration, "2m 5s");
});
// ---------------------------------------------------------------------------
// Stage pane
// ---------------------------------------------------------------------------
test("controlVisitLabel covers a missing max and the limit", () => {
assert.equal(controlVisitLabel({ visit: 2 }), "2");
assert.equal(controlVisitLabel({ visit: 2, max_visits: 4 }), "2 / 4");
assert.equal(controlVisitLabel({ visit: 2, max_visits: 4, limit_reached: true }), "2 / 4 (limit reached)");
});
test("clampVisitIndex keeps a valid visit and handles an empty list", () => {
assert.equal(clampVisitIndex(0, 3), 0);
assert.equal(clampVisitIndex(99, 3), 2);
assert.equal(clampVisitIndex(-4, 3), 0);
assert.equal(clampVisitIndex(5, 0), 0);
});
test("runStepFields skips blanks and formats the visit", () => {
assert.deepEqual(runStepFields({}), []);
const fields = runStepFields({
status: "completed",
outcome: "success",
target: "#success",
session_id: "sess-1",
agent_active: true,
control: { visit: 3, max_visits: 5, limit_reached: true, model_target: "gpt" },
});
assert.equal(fields.find((f) => f.label === "Visit").value, "3 / 5 (limit reached)");
assert.equal(fields.find((f) => f.label === "Agent").value, "active");
assert.ok(fields.every((f) => f.value.trim() !== ""));
});
test("runStepFields carries every evidence kind the timeline dropped", () => {
const fields = runStepFields({
status: "completed",
diagnostic: "why",
transcript: "said something",
input: { prompt: "do it" },
output: { result: "done" },
file_changes: { status: "partial", files: [{ kind: "modified", path: "a.kt" }], skipped: 2 },
notifications: [{ status: "delivered", destination: "ntfy" }],
});
const labels = fields.map((f) => f.label);
for (const label of ["Status", "Diagnostic", "Transcript", "Input", "Output", "File changes", "Changed files", "Notification"]) {
assert.ok(labels.includes(label), `missing ${label}`);
}
assert.equal(fields.find((f) => f.label === "Input").block, true);
});
test("headline and evidence split the visit's facts without duplication", () => {
const fields = runStepFields({
status: "completed",
outcome: "success",
target: "cleanup",
session_id: "sess-1",
diagnostic: "why",
transcript: "said",
control: { visit: 2, max_visits: 4, model_target: "gpt" },
started_at: "2026-01-01T00:00:00Z",
finished_at: "2026-01-01T00:00:05Z",
input: { prompt: "x" },
});
const headline = headlineFields(fields).map((f) => f.label);
assert.deepEqual(headline, ["Status", "Outcome", "Duration", "Visit", "Model target", "Target", "Session"]);
const evidence = evidenceFields(fields).map((f) => f.label);
assert.ok(!evidence.some((label) => headline.includes(label)));
assert.ok(evidence.includes("Diagnostic") && evidence.includes("Transcript"));
assert.ok(!evidence.includes("Input") && !evidence.includes("Output"));
});
test("stageSectionSpecs orders the run sections and puts the definition last", () => {
const graph = {
stages: [{ key: "implementer", type: "model", prompt: "do", output: "done", edges: { success: "reviewer" } }],
};
const step1 = step({
stage: "implementer",
input: { prompt: "do it" },
output: { result: "done" },
diagnostic: "why",
});
const specs = stageSectionSpecs("implementer", graph, [step1], 0, true);
assert.deepEqual(specs.map((spec) => spec.key), ["artifacts", "output", "input", "run", "definition"]);
assert.deepEqual(specs.map((spec) => spec.title), [
"Artifacts",
"Output",
"Input",
"This run",
"Stage definition",
]);
assert.equal(specs[0].artifacts, true);
assert.ok(specs.find((spec) => spec.key === "definition").fields.length > 0);
});
test("a session export inserts the Session section after Artifacts", () => {
const graph = { stages: [{ key: "reviewer", type: "model" }] };
const withSession = step({
stage: "reviewer",
session_export: { html: "session.html" },
artifacts: [{ name: "session.html", url: "/a" }],
});
const specs = stageSectionSpecs("reviewer", graph, [withSession], 0, true);
assert.deepEqual(specs.map((spec) => spec.key), ["artifacts", "session", "definition"]);
assert.equal(specs[1].session, true);
});
test("a visit with no results still lists the artifacts gallery and the definition", () => {
const graph = { stages: [{ key: "s", type: "model" }] };
const specs = stageSectionSpecs("s", graph, [step({ stage: "s" })], 0, true);
assert.deepEqual(specs.map((spec) => spec.key), ["artifacts", "definition"]);
assert.ok(specs.every((spec) => spec.artifacts || spec.fields.length > 0));
});
test("stageDefinitionFields labels outcomes with resolved terminals", () => {
const stage = {
key: "planner",
type: "model",
prompt: "do the thing",
output: "plan",
configs: { model: "gpt", provider: "" },
edges: { success: "#", error: "cleanup" },
blocks: { tools: "read\nwrite" },
limits: { max_visits: 3, on: ["exceeded"] },
memory: { notes: "notes.md" },
notify: { on: ["failure"], destination: "ntfy", artifacts: ["log"] },
};
const fields = stageDefinitionFields(stage);
const labels = fields.map((f) => f.label);
for (const label of ["Type", "Prompt", "Output", "Outcomes", "Model", "Tools", "Max visits", "Limit on", "Memory", "Notify on", "Notify destination", "Notify artifacts"]) {
assert.ok(labels.includes(label), `missing ${label}`);
}
assert.ok(fields.every((f) => f.value.trim() !== ""));
const outcomes = fields.find((f) => f.label === "Outcomes").value;
assert.ok(outcomes.includes("success → SUCCESS (terminal)"));
assert.ok(outcomes.includes("error → cleanup"));
assert.equal(stageDefinitionFields({ key: "p" }).map((f) => f.value)[0], "model");
});
test("terminalFields lists incoming routes only", () => {
const graph = { stages: [{ key: "a", edges: { success: "#success" } }] };
assert.deepEqual(terminalFields(graph, "a"), []);
const incoming = terminalFields(graph, "#success");
assert.deepEqual(incoming.map((f) => f.label), ["Incoming routes"]);
assert.ok(incoming[0].value.includes("a · success → SUCCESS"));
});
test("resolveTarget and stageOutcomes mirror the graph semantics", () => {
assert.equal(resolveTarget("error", "#"), "#failure");
assert.equal(resolveTarget("success", "#"), "#success");
assert.equal(resolveTarget("success", "reviewer"), "reviewer");
assert.deepEqual(stageOutcomes({ edges: { error: "x", success: "y", advisory: "z" } }), [
"success",
"advisory",
"error",
]);
});
// ---------------------------------------------------------------------------
// Verdict
// ---------------------------------------------------------------------------
test("verdictReasonSegments splits a reason around every referenced name", () => {
const png = { name: "review.png", url: "/review.png" };
const txt = { name: "report.txt", url: "/report.txt" };
assert.deepEqual(
verdictReasonSegments("Approved: review.png shows the fix; report.txt lists the checks.", [png, txt]),
[
{ text: "Approved: " },
{ text: "review.png", artifact: png },
{ text: " shows the fix; " },
{ text: "report.txt", artifact: txt },
{ text: " lists the checks." },
],
);
});
test("verdictReasonSegments matches a basename and prefers the longer token", () => {
const nested = { name: "shots/wide.png" };
assert.deepEqual(verdictReasonSegments("See wide.png for the wide layout.", [nested]), [
{ text: "See " },
{ text: "wide.png", artifact: nested },
{ text: " for the wide layout." },
]);
const bare = { name: "wide.png" };
assert.deepEqual(verdictReasonSegments("shots/wide.png is the shot", [bare, nested]), [
{ text: "shots/wide.png", artifact: nested },
{ text: " is the shot" },
]);
assert.deepEqual(verdictReasonSegments("nothing referenced here", [{ name: "x.png" }]), [
{ text: "nothing referenced here" },
]);
assert.deepEqual(verdictReasonSegments("", [{ name: "x.png" }]), []);
assert.equal(artifactBaseName("shots\\x.png"), "x.png");
});
test("referencedVerdictArtifacts resolves names to recorded files in recorded order", () => {
const a = { name: "a.png" };
const b = { name: "b.png" };
const verdict = { option: "approved → success", reason: "b.png then a.png", artifacts: ["b.png", "a.png", "invented.png"] };
assert.deepEqual(referencedVerdictArtifacts(verdict, [a, b]), [a, b]);
assert.deepEqual(referencedVerdictArtifacts(null, [a]), []);
assert.deepEqual(referencedVerdictArtifacts({ artifacts: [] }, [a]), []);
});
// ---------------------------------------------------------------------------
// Formatters and colours
// ---------------------------------------------------------------------------
test("fileChangeLine adds the binary and truncated markers", () => {
assert.equal(fileChangeLine({ kind: "modified", path: "src/a.kt" }), "modified src/a.kt");
assert.equal(
fileChangeLine({ kind: "modified", path: "src/a.kt", binary: true, truncated: true }),
"modified src/a.kt (binary) (truncated)",
);
});
test("notificationLine appends a non-blank diagnostic only", () => {
assert.equal(notificationLine({ status: "delivered", destination: "ntfy" }), "delivered → ntfy");
assert.equal(
notificationLine({ status: "delivered", destination: "ntfy", diagnostic: "ok" }),
"delivered → ntfy · ok",
);
});
test("fileChangesSummary omits blank parts", () => {
assert.equal(fileChangesSummary({ status: "partial", files: [{}, {}], skipped: 1 }), "partial (2 files), 1 skipped");
assert.equal(fileChangesSummary({}), "");
assert.equal(fileChangesSummary(null), "");
});
test("outcomeColorToken uses the status palette then the flow palette", () => {
assert.equal(outcomeColorToken("success"), "state succeeded");
assert.equal(outcomeColorToken("error"), "state failed");
assert.equal(outcomeColorToken("blocked"), "state blocked");
assert.equal(outcomeColorToken("approved"), "flow 3");
assert.equal(outcomeColorToken("rejected"), "flow 0");
assert.equal(outcomeColorToken("", "running"), "state running");
assert.equal(stateGlyph("succeeded"), "✓");
assert.equal(stateGlyph("nonsense"), "?");
});
+192 -16
View File
@@ -361,23 +361,47 @@ try {
// real server (the socket stays on the proxy, see the note above) so the tiles
// and the viewer load real files rather than proxying a path serve.mjs does
// not forward.
step(`opening run 430 and capturing its artifacts gallery`);
step("returning to Runs and opening run 430 (Summary tab)");
await page.fill("#url", artifactServerUrl);
await page.clickText("nav.tabs button.tab", "Runs");
await page.waitForSelector(".list.runs .run-row", { timeout: 25000 });
await page.click('.list.runs .run-row-meta[data-run-id="430"]');
await page.waitForSelector(".artifact-gallery .artifact-tile", { timeout: 25000 });
await page.waitForText("recorded", { timeout: 25000 });
const tileCount = await page.evaluate(
`document.querySelectorAll(".artifact-gallery .artifact-tile").length`,
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
// The run-detail tabs, in the app's order (the Graph body is the R5 item).
const runTabs = await page.evaluate(
`[...document.querySelectorAll(".detail .detail-tabs .detail-tab")].map((n) => n.textContent)`,
);
if (!tileCount) throw new Error("run 430 rendered no artifact tiles");
console.log(` run 430 gallery tiles: ${tileCount}`);
await page.rect(".artifacts-header");
if (JSON.stringify(runTabs) !== JSON.stringify(["Summary", "Input", "Output", "Timeline"])) {
throw new Error(`run tabs are wrong: ${runTabs.join(",")}`);
}
console.log(` run tabs: ${runTabs.join(" / ")}`);
// The run identity line, in the exact recorded/completed vocabulary.
const identity = await page.evaluate(`document.querySelector(".run-identity")?.textContent ?? ""`);
if (!/^run 430 · \d+ recorded visits? · \d+ completed visits?$/.test(identity)) {
throw new Error(`run identity line is wrong: ${identity}`);
}
const runTitle = await page.evaluate(
`document.querySelector(".run-detail-title")?.textContent ?? ""`,
);
console.log(` summary: ${runTitle} — ${identity}`);
shots.push(await page.screenshot(`${out}/20-run-430-summary.png`));
// The run-level artifacts gallery (R8), collapsed by default in Summary.
step("expanding run 430's summary artifacts section (R8)");
await page.clickText(".run-detail .section-toggle", "Artifacts");
await page.waitForSelector(".run-detail .artifact-gallery .artifact-tile", { timeout: 25000 });
const runTiles = await page.evaluate(
`document.querySelectorAll(".run-detail .artifact-gallery .artifact-tile").length`,
);
console.log(` run 430 run-level gallery tiles: ${runTiles}`);
if (runTiles !== 18) throw new Error(`expected 18 run-level artifact tiles, got ${runTiles}`);
await page.rect(".run-detail .artifact-gallery");
shots.push(await page.screenshot(`${out}/04-run-430-artifacts.png`));
step("opening an image artifact in the full-screen viewer");
await page.click(".artifact-tile img");
await page.click(".run-detail .artifact-gallery .artifact-tile img");
await page.waitForSelector(".artifact-viewer", { timeout: 15000 });
await page.waitForText("Close viewer", { timeout: 15000 });
const position = await page.evaluate(
@@ -393,22 +417,174 @@ try {
{ timeout: 8000, what: "the viewer image" },
).catch(() => console.log(" (viewer image still loading)"));
shots.push(await page.screenshot(`${out}/05-artifact-viewer.png`));
step("closing the viewer and capturing the session export link (R9)");
await page.click(".viewer-close");
await eventually(
() => page.evaluate(`!document.querySelector(".artifact-viewer")`),
{ timeout: 5000, what: "the viewer to close" },
await eventually(() => page.evaluate(`!document.querySelector(".artifact-viewer")`), {
timeout: 5000,
what: "the viewer to close",
});
// R6: one collapsed field section per recorded input/output entry.
step("opening the Input tab and expanding a field section");
await page.clickText(".detail .detail-tabs .detail-tab", "Input");
await page.waitForSelector(".detail .run-tab-body .collapsible .section-toggle", { timeout: 15000 });
const inputEmpty = await page.evaluate(
`document.querySelector(".detail .run-tab-body .run-empty")?.textContent ?? ""`,
);
await page.rect(".session-link");
if (inputEmpty !== "") throw new Error(`run 430 input unexpectedly empty: ${inputEmpty}`);
await page.click(".detail .run-tab-body .collapsible .section-toggle");
await page.waitForSelector(".detail .run-tab-body .field-block", { timeout: 15000 });
const inputTitles = await page.evaluate(
`[...document.querySelectorAll(".detail .run-tab-body .section-title")].map((n) => n.textContent)`,
);
console.log(` input fields: ${inputTitles.join(", ")}`);
shots.push(await page.screenshot(`${out}/21-run-430-input.png`));
step("opening the Output tab and expanding a field section");
await page.clickText(".detail .detail-tabs .detail-tab", "Output");
await page.waitForSelector(".detail .run-tab-body .collapsible .section-toggle", { timeout: 15000 });
await page.click(".detail .run-tab-body .collapsible .section-toggle");
await page.waitForSelector(".detail .run-tab-body .field-block", { timeout: 15000 });
const outputTitles = await page.evaluate(
`[...document.querySelectorAll(".detail .run-tab-body .section-title")].map((n) => n.textContent)`,
);
console.log(` output fields: ${outputTitles.join(", ")}`);
shots.push(await page.screenshot(`${out}/22-run-430-output.png`));
// R7: one compact row per visit, in step order.
step("opening the Timeline tab");
await page.clickText(".detail .detail-tabs .detail-tab", "Timeline");
await page.waitForSelector(".detail .timeline-row", { timeout: 15000 });
const timelineRows = await page.evaluate(
`[...document.querySelectorAll(".detail .timeline-row .timeline-title")].map((n) => n.textContent)`,
);
console.log(` timeline: ${timelineRows.join(" | ")}`);
if (timelineRows.length !== 3) throw new Error(`expected 3 timeline rows, got ${timelineRows.length}`);
if (timelineRows[0] !== "reviewer · visit 3") {
throw new Error(`first timeline row is wrong: ${timelineRows[0]}`);
}
shots.push(await page.screenshot(`${out}/23-run-430-timeline.png`));
// R3: the stage pane: headline rows, Verdict block and the visit's gallery.
step("opening the ui_reviewer stage pane: headline, Verdict and its artifact gallery");
await page.click('.detail .timeline-row[data-stage-key="ui_reviewer"]');
await page.waitForSelector(".stage-pane", { timeout: 15000 });
await page.waitForText("Verdict", { timeout: 15000 });
const headline = await page.evaluate(
`[...document.querySelectorAll(".stage-pane-body > .kv-row > .kv-key")].map((n) => n.textContent)`,
);
console.log(` pane headline: ${headline.join(", ")}`);
for (const label of ["Status", "Outcome", "Duration", "Visit", "Target", "Session"]) {
if (!headline.includes(label)) throw new Error(`stage pane headline missing: ${label}`);
}
const verdictTitle = await page.evaluate(
`document.querySelector(".stage-pane .verdict-title")?.textContent ?? ""`,
);
const verdictOption = await page.evaluate(
`document.querySelector(".stage-pane .verdict .outcome-chip")?.textContent ?? ""`,
);
if (verdictTitle !== "Verdict") throw new Error(`verdict heading is wrong: ${verdictTitle}`);
console.log(` verdict: ${verdictTitle} — ${verdictOption}`);
await page.clickText(".stage-pane .section-toggle", "Artifacts");
await page.waitForSelector(".stage-pane .artifact-tile", { timeout: 15000 });
const paneTiles = await page.evaluate(`document.querySelectorAll(".stage-pane .artifact-tile").length`);
console.log(` ui_reviewer visit 2 pane tiles: ${paneTiles}`);
shots.push(await page.screenshot(`${out}/24-run-430-stage-artifacts.png`));
// Escape closes the pane and returns focus to the timeline row that opened it.
step("closing the pane with Escape returns focus to the timeline row");
await page.evaluate(
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
);
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
timeout: 5000,
what: "the stage pane to close on Escape",
});
const restored = await page.evaluate(
`(() => { const el = document.activeElement; return el ? el.getAttribute("data-stage-key") ?? "" : ""; })()`,
);
if (restored !== "ui_reviewer") throw new Error(`focus did not return to the timeline row: ${restored}`);
console.log(` focus returned to timeline row: ${restored}`);
// R9: the visit's exported session file, opened from the pane's Session section.
step("opening the reviewer stage pane and its Session export link (R9)");
await page.click('.detail .timeline-row[data-stage-key="reviewer"]');
await page.waitForSelector(".stage-pane", { timeout: 15000 });
await page.clickText(".stage-pane .section-toggle", "Session");
await page.waitForSelector(".stage-pane .session-link", { timeout: 15000 });
const sessionHref = await page.evaluate(
`document.querySelector(".session-link")?.getAttribute("href") ?? ""`,
`document.querySelector(".stage-pane .session-link")?.getAttribute("href") ?? ""`,
);
if (!/session\.html$/.test(sessionHref)) {
throw new Error(`the session export link did not resolve: ${sessionHref}`);
}
console.log(` session export link: ${sessionHref}`);
shots.push(await page.screenshot(`${out}/06-session-export-link.png`));
await page.click(".stage-pane-back");
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
timeout: 5000,
what: "the stage pane to close on Back",
});
// The verdict-bearing stage pane on the failed run 440.
step("opening run 440 and capturing its verdict-bearing stage pane");
await page.click('.list.runs .run-row-meta[data-run-id="440"]');
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await page.clickText(".detail .detail-tabs .detail-tab", "Timeline");
await page.waitForSelector(".detail .timeline-row", { timeout: 15000 });
await page.click(".detail .timeline-row");
await page.waitForSelector(".stage-pane", { timeout: 15000 });
await page.waitForText("Verdict", { timeout: 15000 });
const verdict440 = await page.evaluate(
`document.querySelector(".stage-pane .verdict .outcome-chip")?.textContent ?? ""`,
);
console.log(` run 440 verdict: ${verdict440}`);
shots.push(await page.screenshot(`${out}/25-run-440-verdict.png`));
await page.evaluate(
`document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))`,
);
await eventually(() => page.evaluate(`!document.querySelector(".stage-pane")`), {
timeout: 5000,
what: "the run 440 pane to close",
});
// The Timeline empty state, on a run that recorded no visits (R7).
step("opening run 428: the Timeline empty state");
await page.click('.list.runs .run-row-meta[data-run-id="428"]');
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await page.clickText(".detail .detail-tabs .detail-tab", "Timeline");
await page.waitForSelector(".detail .run-tab-body .run-empty", { timeout: 15000 });
const emptyTimeline = await page.evaluate(
`document.querySelector(".detail .run-tab-body .run-empty")?.textContent ?? ""`,
);
if (emptyTimeline !== "No visits recorded.") {
throw new Error(`timeline empty state is wrong: ${emptyTimeline}`);
}
console.log(` timeline empty state: ${emptyTimeline}`);
shots.push(await page.screenshot(`${out}/26-run-428-timeline-empty.png`));
// The Output empty state, on the running run that has not produced output yet.
step("opening the Output tab on a run with no output recorded");
const runningId = await page.evaluate(`(() => {
const row = [...document.querySelectorAll(".list.runs .run-row")].find((n) => n.querySelector(".chip-running"));
const meta = row?.querySelector(".run-row-meta[data-run-id]");
return meta ? Number(meta.getAttribute("data-run-id")) : null;
})()`);
if (runningId == null) {
console.log(" -- no running run available; skipped the output empty state");
} else {
await page.click(`.list.runs .run-row-meta[data-run-id="${runningId}"]`);
await page.waitForSelector(".detail .detail-tabs", { timeout: 25000 });
await page.clickText(".detail .detail-tabs .detail-tab", "Output");
await page.waitForSelector(".detail .run-tab-body .run-empty", { timeout: 15000 });
const emptyOutput = await page.evaluate(
`document.querySelector(".detail .run-tab-body .run-empty")?.textContent ?? ""`,
);
if (emptyOutput !== "No output recorded.") {
throw new Error(`output empty state is wrong: ${emptyOutput}`);
}
console.log(` output empty state (run ${runningId}): ${emptyOutput}`);
shots.push(await page.screenshot(`${out}/27-run-output-empty.png`));
}
console.log("\nUI SMOKE PASS");
for (const shot of shots) console.log(` ${shot}`);