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.
This commit is contained in:
1 parent
862ac46e8b
commit
7414713d61
33 files changed
+4195
-91
No files matched your search
+146
-3
@@ -1,10 +1,20 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render, cleanup } from "@testing-library/preact";
|
||||
import { TaskLogPanel, taskLogDownloadURL } from "../src/tasks/task-logs.jsx";
|
||||
import { render, cleanup, fireEvent } from "@testing-library/preact";
|
||||
import { TaskLogPanel, logCacheKey, taskLogDownloadURL } from "../src/tasks/task-logs.jsx";
|
||||
|
||||
function renderPanel(state, opts = {}) {
|
||||
const { container, unmount } = render(<TaskLogPanel state={state} onRetry={opts.onRetry} taskId={opts.taskId} />);
|
||||
const { container, unmount } = render(
|
||||
<TaskLogPanel
|
||||
state={state}
|
||||
onRetry={opts.onRetry}
|
||||
taskId={opts.taskId}
|
||||
attempt={opts.attempt}
|
||||
filters={opts.filters}
|
||||
onFilterChange={opts.onFilterChange}
|
||||
stages={opts.stages}
|
||||
/>,
|
||||
);
|
||||
return { root: container, unmount };
|
||||
}
|
||||
|
||||
@@ -103,3 +113,136 @@ test("a panel for an attempt with no log offers no download", () => {
|
||||
assert.equal(root.querySelector(".task-log-download"), null, "there is nothing to download");
|
||||
unmount();
|
||||
});
|
||||
|
||||
// W7: the filter controls must sit ABOVE the three read outcomes. Below the
|
||||
// disabled early return they would replace the deployment-level message with an
|
||||
// empty filtered pane in exactly the deployment that cannot read logs.
|
||||
const FILTER_OPTS = { filters: { level: "", stage: "" }, onFilterChange: () => {}, stages: ["prepare"] };
|
||||
|
||||
test("the three read outcomes survive with the filter bar rendered above them", () => {
|
||||
const disabled = renderPanel({ disabled: true, entries: [] }, FILTER_OPTS);
|
||||
assert.ok(disabled.root.querySelector(".task-log-filters"), "the filter bar renders first");
|
||||
assert.match(disabled.root.textContent, /No persisted log for this attempt/);
|
||||
assert.match(disabled.root.textContent, /cannot read task logs/);
|
||||
disabled.unmount();
|
||||
|
||||
const absent = renderPanel({ found: false, entries: [], attempt: 0 }, FILTER_OPTS);
|
||||
assert.match(absent.root.textContent, /No log recorded for this attempt/);
|
||||
assert.doesNotMatch(absent.root.textContent, /cannot read task logs/);
|
||||
absent.unmount();
|
||||
|
||||
const filtered = renderPanel({ disabled: false, found: true, entries: [], attempt: 0 }, FILTER_OPTS);
|
||||
assert.equal(filtered.root.querySelector(".empty-title").textContent, "Nothing recorded");
|
||||
filtered.unmount();
|
||||
});
|
||||
|
||||
// W6: one cache entry per task could not represent two attempts, so a retry
|
||||
// served the previous run's log under the new run's id.
|
||||
test("the log cache key is keyed by task, attempt and filters", () => {
|
||||
assert.equal(logCacheKey(7, 1), "7|1||");
|
||||
assert.notEqual(logCacheKey(7, 1), logCacheKey(7, 2), "two attempts must not share a cache entry");
|
||||
assert.notEqual(logCacheKey(7, 1), logCacheKey(71, 1), "two tasks must not share a cache entry");
|
||||
assert.notEqual(
|
||||
logCacheKey(7, 1, { level: "ERROR", stage: "" }),
|
||||
logCacheKey(7, 1, { level: "", stage: "" }),
|
||||
"a filtered read is a different response and needs its own entry",
|
||||
);
|
||||
});
|
||||
|
||||
// F2: a stage filter narrows to lines a stage tagged and nothing more. Agent and
|
||||
// tool output has no stage, so a sparse result must be explained next to the
|
||||
// control rather than left to look broken.
|
||||
test("a stage filter states its coverage limit beside the control", () => {
|
||||
const { root, unmount } = renderPanel(
|
||||
{ found: true, entries: [], attempt: 1 },
|
||||
{ ...FILTER_OPTS, filters: { level: "", stage: "prepare" }, stages: ["prepare", "implement"] },
|
||||
);
|
||||
assert.match(root.textContent, /A stage filter matches only log lines that record a stage/);
|
||||
assert.match(root.textContent, /Agent and tool output carries none/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("an attempt with no recorded stage names says the stage filter has nothing to match", () => {
|
||||
const { root, unmount } = renderPanel(
|
||||
{ found: true, entries: [], attempt: 1 },
|
||||
{ ...FILTER_OPTS, stages: [] },
|
||||
);
|
||||
assert.match(root.textContent, /recorded no stage names/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("changing a filter reports the whole filter set to the page", () => {
|
||||
const seen = [];
|
||||
const { root, unmount } = renderPanel(
|
||||
{ found: true, entries: [], attempt: 1 },
|
||||
{ ...FILTER_OPTS, onFilterChange: (next) => seen.push(next) },
|
||||
);
|
||||
const level = root.querySelectorAll("select")[0];
|
||||
const stage = root.querySelectorAll("select")[1];
|
||||
fireEvent.change(level, { target: { value: "ERROR" } });
|
||||
fireEvent.change(stage, { target: { value: "prepare" } });
|
||||
assert.deepEqual(seen, [
|
||||
{ level: "ERROR", stage: "" },
|
||||
{ level: "", stage: "prepare" },
|
||||
]);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// The pane names the attempt it is showing so it can never present attempt 1's
|
||||
// log as attempt 2's.
|
||||
test("the pane names the attempt it is showing", () => {
|
||||
const explicit = renderPanel({ found: true, attempt: 1, entries: [] }, { attempt: 1 });
|
||||
assert.match(explicit.root.textContent, /Attempt 1/);
|
||||
explicit.unmount();
|
||||
|
||||
const resolved = renderPanel({ found: true, attempt: 4, entries: [] }, { attempt: null, taskId: 42 });
|
||||
assert.match(resolved.root.textContent, /Attempt 4/);
|
||||
assert.equal(
|
||||
resolved.root.querySelector(".task-log-download").getAttribute("href"),
|
||||
"/api/tasks/42/logs/download?attempt=4",
|
||||
"a download follows the attempt the pane is showing, not whatever is current",
|
||||
);
|
||||
resolved.unmount();
|
||||
});
|
||||
|
||||
test("a panel without a page to act on a filter renders no filter controls", () => {
|
||||
const { root, unmount } = renderPanel({ found: true, entries: [], attempt: 1 });
|
||||
assert.equal(root.querySelector("select"), null, "a control that filters nothing is worse than none");
|
||||
assert.match(root.textContent, /Attempt 1/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// R9: the pane carries one live region announcing its STATE, never a line at a
|
||||
// time. A per-line live region would read the whole log aloud on every load,
|
||||
// and a pane that loads 500 entries would be unusable with a screen reader.
|
||||
test("the pane announces its state once, not every log line", () => {
|
||||
const { root, unmount } = renderPanel({
|
||||
found: true,
|
||||
attempt: 2,
|
||||
entries: [
|
||||
{ level: "info", msg: "one" },
|
||||
{ level: "info", msg: "two" },
|
||||
],
|
||||
});
|
||||
const live = root.querySelector("[aria-live]");
|
||||
assert.ok(live, "the pane should carry a live region");
|
||||
assert.equal(live.getAttribute("role"), "status");
|
||||
assert.equal(live.getAttribute("aria-atomic"), "true");
|
||||
assert.match(live.textContent, /2 log entries/);
|
||||
assert.ok(live.className.includes("visually-hidden"), "the live text is for assistive technology only");
|
||||
assert.equal(root.querySelector(".log-list").contains(live), false, "the live region is not the list itself");
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("the live region says which of the log-unavailable cases applies", () => {
|
||||
const disabled = renderPanel({ disabled: true, entries: [] });
|
||||
assert.match(disabled.root.querySelector("[aria-live]").textContent, /cannot read task logs/);
|
||||
disabled.unmount();
|
||||
|
||||
const absent = renderPanel({ found: false, entries: [], attempt: 0 });
|
||||
assert.match(absent.root.querySelector("[aria-live]").textContent, /No log recorded for this attempt/);
|
||||
assert.doesNotMatch(absent.root.querySelector("[aria-live]").textContent, /cannot read task logs/);
|
||||
absent.unmount();
|
||||
});
|
||||
|
||||
test.after(() => cleanup());
|
||||
Reference in new issue
Block a user