Files
archie/ui/test/routing.test.js
T
sam d31c279658 feat(webui): add the per-run task detail page
A per-task page at #/tasks/{id} with tabs for the attempt's stages and log, changed
files, configuration and a raw debug view. Reachable from the task list, deep
linkable via ?tab= and ?attempt=, and reload safe. Existing URLs (#/tasks?task=N
and #/tasks?status=...) are unchanged.

- A stage rail per attempt: name, duration, terminal status and error text, with
  unattributed events surfaced and the agent's own verdict shown separately.
- No pass/fail badge and no exit code anywhere: the backend has neither, and a stage
  that returned nil after producing a poor diff is a success. Status word, duration
  and error text are shown instead.
- The log pane filters by attempt, stage and level, states the coverage caveat for
  stage filters (agent and tool output records no stage), and keeps the three read
  outcomes distinct: no log reader in this deployment, no file for this attempt, and
  no entries matching the filter.
- Retry is labelled as a new run and its confirm says the previous attempt's commits
  are discarded, because it hard-resets the branch onto the base.
- An absent capture reads "not captured for this run" rather than implying nothing
  changed, and no elapsed-run figure is shown since only per-stage durations exist.
- The events cache is invalidated on retry (it previously kept the ended attempt's
  events) and the log cache is keyed by attempt, so two attempts cannot be conflated.
- ui/dist is rebuilt and committed: the gate runs the node tests but never rebuilds
  the bundle, so a stale one would otherwise ship behind a green gate.
- docs/prds/task-run-detail.md records the surface and its limits, and
  docs/architecture/observability.md describes it alongside the read endpoints.

Both new vocabularies are pinned by tests on each side (config schema, change
statuses) so a one-sided rename fails a test instead of silently degrading the page.
2026-09-18 18:33:03 +10:00

58 lines
2.3 KiB
JavaScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { matchRoute, navPath } from "../src/routing.jsx";
// The route table mirrors main.jsx's: a literal section and the parameterised
// detail page declared after it, which is the ordering that stops /tasks/:id
// from swallowing /tasks.
const routes = [
{ path: "/", label: "Dashboard" },
{ path: "/tasks", label: "Tasks", view: () => null },
{ path: "/tasks/:id", label: "Task run", view: () => null, nav: false, navPath: "/tasks" },
{ path: "/logs", label: "Logs", view: () => null },
];
test("a literal path matches its own route, not a parameterised one", () => {
const match = matchRoute(routes, "/tasks");
assert.equal(match.route.path, "/tasks");
assert.deepEqual(match.params, {});
});
test("a path segment is captured as a route param", () => {
const match = matchRoute(routes, "/tasks/42");
assert.equal(match.route.path, "/tasks/:id");
assert.deepEqual(match.params, { id: "42" });
});
test("the query string is not part of the path", () => {
const match = matchRoute(routes, "/tasks/42?tab=changes&attempt=2");
assert.equal(match.route.path, "/tasks/:id");
assert.equal(match.params.id, "42");
});
test("a trailing slash names the same route", () => {
assert.equal(matchRoute(routes, "/tasks/").route.path, "/tasks");
assert.equal(matchRoute(routes, "/tasks/42/").params.id, "42");
});
// A prefix rule would send every unknown path under a section to that section's
// page, so a typo would render something plausible instead of the dashboard.
test("an unmatched path matches nothing rather than the nearest prefix", () => {
assert.equal(matchRoute(routes, "/nope"), null);
assert.equal(matchRoute(routes, "/tasks/42/extra"), null);
assert.equal(matchRoute(routes, "/task"), null);
});
test("an encoded segment is decoded into the param", () => {
assert.equal(matchRoute(routes, "/tasks/a%20b").params.id, "a b");
});
// W9: a detail route is not a nav entry, so it names the section it belongs to.
// Without this the Tasks item loses aria-current the moment the operator opens
// a run, and the whole nav reads as "nothing is current".
test("a parameterised route reports the section it keeps current", () => {
assert.equal(navPath(routes[2]), "/tasks");
assert.equal(navPath(routes[1]), "/tasks");
assert.equal(navPath(undefined), "/");
});