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:
sam committed 2026-09-18 18:33:03 +10:00
1 parent 862ac46e8b
commit 7414713d61
33 files changed
+4195 -91

No files matched your search

+3
View File
@@ -95,6 +95,9 @@ export const api = {
tasks: () => request("/api/tasks"),
taskMeta: () => request("/api/task-meta"),
task: (id) => request(`/api/tasks/${id}`),
taskAttempts: (id) => request(`/api/tasks/${id}/attempts`),
taskChanges: (id, params) => request(`/api/tasks/${id}/changes` + qs(params)),
taskDebug: (id, params) => request(`/api/tasks/${id}/debug` + qs(params)),
taskAction: (id, action) => request(`/api/tasks/${id}/action`, { method: "POST", body: { action } }),
setup: () => request("/api/setup"),
capabilities: () => request("/api/capabilities"),
+12
View File
@@ -9,6 +9,18 @@ import { el } from "./dom.jsx";
* second distinct consumer".
*/
// The level filter vocabulary. Server-side level filtering takes a CSV of
// levels (`splitCSV` in internal/webui/api_tasks_logs.go), so the combined
// options are a wire concern too, not a display choice. It lives here because
// both the daemon log page and a task attempt's log pane filter by level.
export const LOG_LEVELS = [
{ value: "", label: "All levels" },
{ value: "ERROR", label: "Errors" },
{ value: "WARN,ERROR", label: "Warnings and errors" },
{ value: "INFO,WARN,ERROR", label: "Info and above" },
{ value: "DEBUG", label: "Debug only" },
];
export function levelKind(level) {
switch ((level || "").toUpperCase()) {
case "ERROR":
+24
View File
@@ -30,3 +30,27 @@ a {
color: inherit;
text-decoration: none;
}
/* The focus floor. A component may style its own focus state; this guarantees
that nothing is ever focused and invisible for a keyboard user. `:focus-visible`
rather than `:focus` so a mouse click does not draw a ring around what was
clicked. */
:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
/* Accessible-only text: present to assistive technology, out of the visual
layout. Used for live-region status lines, which announce a change without
drawing a second, visible copy of the pane's own copy. */
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
border: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
+2 -8
View File
@@ -2,6 +2,7 @@ import { h } from "preact";
import { useState, useEffect, useRef, useMemo } from "preact/hooks";
import "./logs.css";
import { api, subscribeLogs } from "../base/api.jsx";
import { LOG_LEVELS } from "../base/log-row.jsx";
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
@@ -52,13 +53,6 @@ function LogRow({ entry }) {
);
}
const LEVELS = [
{ value: "", label: "All levels" },
{ value: "ERROR", label: "Errors" },
{ value: "WARN,ERROR", label: "Warnings and errors" },
{ value: "INFO,WARN,ERROR", label: "Info and above" },
{ value: "DEBUG", label: "Debug only" },
];
function entryKey(entry) {
return `${entry.time || ""}|${entry.level || ""}|${entry.message || entry.msg || ""}|${JSON.stringify(entry.fields || {})}`;
@@ -191,7 +185,7 @@ function LogsApp() {
value={filters.level}
onChange={(e) => setFilters(f => ({ ...f, level: e.target.value }))}
>
{LEVELS.map(l => <option key={l.value} value={l.value}>{l.label}</option>)}
{LOG_LEVELS.map(l => <option key={l.value} value={l.value}>{l.label}</option>)}
</select>
<select
className="log-select"
+19 -4
View File
@@ -6,6 +6,7 @@ import { el, mount } from "./base/dom.jsx";
import { icon } from "./base/icons.jsx";
import { dashboardPage } from "./dashboard/dashboard.jsx";
import { tasksPage } from "./tasks/tasks.jsx";
import { taskDetailPage } from "./tasks/task-detail.jsx";
import { skillsPage } from "./skills/skills.jsx";
import { workflowsPage } from "./workflows/workflows.jsx";
import { channelsPage } from "./channels/channels.jsx";
@@ -17,6 +18,7 @@ import { mappingsPage } from "./mappings/mappings.jsx";
import { bindingsPage } from "./bindings/bindings.jsx";
import { memoryPage } from "./memory/memory.jsx";
import { chatPage } from "./chat/chat.jsx";
import { matchRoute, navPath } from "./routing.jsx";
/**
* Routes are declared once here. Adding a section means adding a feature
@@ -32,10 +34,19 @@ import { chatPage } from "./chat/chat.jsx";
// daemon and the extracted UI service -- and a section the serving process
// cannot back would otherwise render as permanently empty rather than as
// absent (archie-core-8cda.5.4).
//
// A route may also carry:
// nav:false -- addressed by URL but not a navigation entry (a detail page
// reached from its section)
// navPath -- the navigation entry this route keeps current; a parameterised
// route is not itself in the nav, so without this the section it
// belongs to would lose its aria-current highlight
// :name -- one captured path segment, e.g. /tasks/:id
const routes = [
{ path: "/", label: "Dashboard", icon: "dashboard", view: dashboardPage },
{ path: "/chat", label: "Chat", icon: "chat", view: chatPage, section: "chat" },
{ path: "/tasks", label: "Tasks", icon: "tasks", view: tasksPage },
{ path: "/tasks/:id", label: "Task run", view: taskDetailPage, nav: false, navPath: "/tasks" },
{ path: "/logs", label: "Logs", icon: "logs", view: logsPage, section: "logs" },
{ path: "/captures", label: "Event inspector", icon: "captures", view: capturesPage, section: "captures" },
{ path: "/mappings", label: "Field mappings", icon: "mappings", view: mappingsPage, section: "mappings" },
@@ -66,6 +77,7 @@ function commandBar(onNavigate, onToggleChat) {
"nav.nav",
...[null].flatMap(() => [
...routes
.filter((route) => route.nav !== false)
.map((route) => {
const item = el(
"a.nav-item",
@@ -135,7 +147,7 @@ function commandBar(onNavigate, onToggleChat) {
}
if (e.key !== "Enter") return;
const q = e.target.value.trim().toLowerCase();
const hit = routes.find((r) => !r.soon && r.label.toLowerCase().startsWith(q));
const hit = routes.find((r) => r.nav !== false && !r.soon && r.label.toLowerCase().startsWith(q));
if (hit) {
onNavigate(hit.path);
e.target.value = "";
@@ -230,8 +242,11 @@ function start() {
// stream does not leak a connection per navigation.
outlet.firstElementChild?.dispatchEvent(new CustomEvent("archie:teardown"));
const [path, query = ""] = rawPath.split("?", 2);
const route = routes.find((r) => r.path === path) || routes[0];
bar.highlight(route.path);
const match = matchRoute(routes, path);
const route = match?.route || routes[0];
// A detail route highlights the section it belongs to, so the nav item for
// Tasks stays current on #/tasks/42 instead of every item losing it.
bar.highlight(navPath(route));
// The chat is a drawer, not a page: /chat opens it rather than mounting a
// second chatPage() (which would duplicate session state and the stream).
if (route.path === "/chat") {
@@ -250,7 +265,7 @@ function start() {
// mount()/replaceChildren() should not alternate on the same outlet
// across navigations, since Preact tracks its own vdom state on the
// container node; if a `soon: true` route is ever added, revisit this.
const rendered = route.view ? route.view(new URLSearchParams(query)) : comingSoon(route);
const rendered = route.view ? route.view(new URLSearchParams(query), match?.params || {}) : comingSoon(route);
if (rendered instanceof Node) {
mount(outlet, rendered);
} else {
+59
View File
@@ -0,0 +1,59 @@
// Hash-route matching.
//
// Every route is declared with a literal path in main.jsx and matched in full:
// `#/tasks` and `#/tasks/42` are different pages, and a prefix rule would send
// every path under a section to the same view, so a typo would render a page
// instead of the dashboard. A segment written `:name` captures exactly one path
// segment, which is how a task id rides in the URL (`#/tasks/42`) rather than
// only in the query string (`#/tasks?task=42` -- an existing deep link that
// keeps working).
//
// This lives in its own module because main.jsx renders on import and cannot be
// imported by a test; the matcher is the piece with decisions in it.
/**
* matchRoute returns `{ route, params }` for the first route whose pattern
* matches, or null. `params` is an object, empty for a literal route.
*/
export function matchRoute(routes, rawPath) {
const path = normalisePath(rawPath);
for (const route of routes) {
const params = matchPattern(route.path, path);
if (params) return { route, params };
}
return null;
}
/**
* navPath is the navigation section a route belongs to. A parameterised route
* is not a nav entry itself, so it names the section it was opened from -- the
* per-task page keeps the Tasks item current instead of blanking the highlight.
*/
export function navPath(route) {
return route?.navPath || route?.path || "/";
}
function normalisePath(rawPath) {
const path = String(rawPath ?? "/").split("?", 1)[0].split("#", 1)[0];
if (!path) return "/";
// A trailing slash names the same route: #/tasks/ is #/tasks, and #/tasks/42/
// is #/tasks/42.
return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
}
function matchPattern(pattern, path) {
const want = String(pattern).split("/");
const got = String(path).split("/");
if (want.length !== got.length) return null;
const params = {};
for (let i = 0; i < want.length; i += 1) {
const segment = want[i];
if (segment.startsWith(":")) {
if (!got[i]) return null;
params[segment.slice(1)] = decodeURIComponent(got[i]);
continue;
}
if (segment !== got[i]) return null;
}
return params;
}
+86
View File
@@ -0,0 +1,86 @@
// The per-attempt effective configuration (R4).
//
// There is no config endpoint: the document arrives inside the task's event
// stream, which this page already fetches for the stage rail's agent reports
// and the timeline. So this panel issues no request of its own and adds nothing
// to the API client contract.
//
// Selection is by kind AND attempt. Selecting by kind alone would show the
// newest attempt's configuration on every attempt, which is exactly the
// merge-attempts bug the attempt column exists to prevent.
export const CONFIG_SCHEMA = "archie/task-config@1";
export function selectConfigEvent(events, attempt) {
return (
(events || []).find(
(ev) => ev && ev.kind === "config_captured" && Number(ev.attempt) === Number(attempt),
) || null
);
}
export function AttemptConfig({ events, attempt, onRetry }) {
if (events === undefined) {
return <div className="run-loading">Loading this task's events…</div>;
}
if (events === null) {
return (
<div className="run-error">
<div className="run-error-title">Could not load this task's events</div>
<div className="run-error-detail">
The configuration is recorded as an event on the task, so it cannot be shown while the
event stream is unreadable. archied did not answer — retry, or check the daemon.
</div>
{onRetry ? (
<button className="btn" type="button" onClick={onRetry}>
Retry
</button>
) : null}
</div>
);
}
const event = selectConfigEvent(events, attempt);
if (!event) {
return (
<div className="empty">
<div className="empty-title">Not captured for this run</div>
<div>
Archie records the effective configuration when it dispatches an attempt. Attempt {attempt}{" "}
has no such record — it predates the record, or the capture did not run. Nothing here says
the run used the defaults.
</div>
</div>
);
}
const data = event.data || {};
const schema = data.schema || "";
const document = data.document;
return (
<div className="run-config">
<p className="run-config-scope">
This is attempt {event.attempt}'s effective task-runtime configuration: a non-secret subset
covering bot identity, models, limits, budgets, dispatch, diff cap, notifications, forge host
and tool policy. It is not the dashboard configuration view — providers, repositories,
identities, credentials and lock state are not part of it.
</p>
<div className="run-config-when">
Captured {event.at || "at an unrecorded time"}
{event.stage ? ` in stage ${event.stage}` : ""}
</div>
{schema === CONFIG_SCHEMA ? (
<pre className="run-json">{JSON.stringify(document ?? {}, null, 2)}</pre>
) : (
<>
<div className="run-config-unknown">
Recorded in an unknown schema{schema ? ` (${schema})` : ""}. The raw payload is shown
verbatim; nothing here reinterprets it.
</div>
<pre className="run-json">{JSON.stringify(data, null, 2)}</pre>
</>
)}
</div>
);
}
+196
View File
@@ -0,0 +1,196 @@
import { ago } from "../base/dom.jsx";
// Changed files for one attempt (R3), from `GET /api/tasks/{id}/changes`.
//
// The capture happens at the producer: archied records the diffstat at the
// moment it commits or pushes an attempt's work. So the honest empty state is
// "no capture was recorded for this attempt", never "no files changed" -- a run
// that predates capture, or one that produced no commit, has no capture and
// nothing here can turn that into a claim about the repository.
const FILE_STATUS = {
added: "Added",
modified: "Modified",
deleted: "Deleted",
renamed: "Renamed",
typechange: "Type changed",
};
export function fileStatusLabel(status) {
return FILE_STATUS[status] || status || "unknown";
}
// The forge links come from the same projection the task list uses: the task's
// own repo/PR URLs, or the capture's if the server attached them. A link is
// rendered only when there is a URL to render -- a capture with no forge
// coordinates shows its owner/repo and PR number as text rather than a dead
// link.
export function captureLinks(capture, task) {
const repo = capture?.repo_url || task?.repo_url || "";
const samePR =
task && String(task.pr_number ?? "") !== "" && String(task.pr_number) === String(capture?.pr_number ?? "");
const pr = capture?.pr_url || (samePR ? task.pr_url || "" : "");
return { repo, pr };
}
export function totalsLabel(totals = {}) {
const files = Number(totals.files) || 0;
const parts = [`${files} file${files === 1 ? "" : "s"}`];
if (totals.additions) parts.push(`+${totals.additions}`);
if (totals.deletions) parts.push(`−${totals.deletions}`);
return parts.join(" · ");
}
function FileTable({ capture }) {
const files = capture.files || [];
const total = Number(capture.totals?.files) || files.length;
if (!files.length) {
return (
<div className="run-changes-empty">
This capture recorded no file entries
{total ? `, though its totals cover ${total} file${total === 1 ? "" : "s"}` : ""}.
</div>
);
}
return (
<>
<table className="table run-changes-table">
<thead>
<tr>
<th>Path</th>
<th>Change</th>
<th className="run-changes-count">Added</th>
<th className="run-changes-count">Deleted</th>
</tr>
</thead>
<tbody>
{files.map((file, i) => (
<tr key={`${file.path}:${i}`}>
<td className="mono run-changes-path">
{file.old_path ? <span className="run-changes-old">{file.old_path} → </span> : null}
{file.path}
</td>
<td>
{fileStatusLabel(file.status)}
{/* binary means "no textual hunks were recorded", not "this is a
binary file on disk": the counts beside it are still real. */}
{file.binary ? <span className="run-changes-hint">no textual hunks</span> : null}
</td>
<td className="run-changes-count mono">{file.additions ? `+${file.additions}` : "—"}</td>
<td className="run-changes-count mono">{file.deletions ? `−${file.deletions}` : "—"}</td>
</tr>
))}
</tbody>
</table>
{capture.truncated ? (
<p className="run-changes-note">
Showing the first {files.length} of {total} files. The totals above cover every file in
this capture.
</p>
) : null}
</>
);
}
function Capture({ capture, task }) {
const links = captureLinks(capture, task);
const prNumber = capture.pr_number;
return (
<section className="run-capture">
<div className="run-capture-head">
<span className="run-capture-when">
{capture.captured_after ? `Captured after ${capture.captured_after}` : "Captured"}
{capture.stage ? ` in stage ${capture.stage}` : ""}
</span>
<span className="run-capture-at">{capture.captured_at ? ago(capture.captured_at) : ""}</span>
</div>
<div className="run-capture-meta">
<span className="mono">
{links.repo ? (
<a className="run-capture-link" href={links.repo} target="_blank" rel="noreferrer">
{capture.owner}/{capture.repo}
</a>
) : (
`${capture.owner || ""}/${capture.repo || ""}`
)}
</span>
{capture.branch ? (
<span className="mono run-capture-branch">
{capture.branch}
{capture.base ? ` → ${capture.base}` : ""}
</span>
) : null}
{capture.head_sha ? <span className="mono run-capture-sha">{String(capture.head_sha).slice(0, 8)}</span> : null}
{prNumber ? (
links.pr ? (
<a className="run-capture-link" href={links.pr} target="_blank" rel="noreferrer">
PR #{prNumber}
</a>
) : (
<span className="mono">PR #{prNumber}</span>
)
) : null}
<span className="run-capture-totals">{totalsLabel(capture.totals)}</span>
</div>
<FileTable capture={capture} />
</section>
);
}
export function ChangedFiles({ state, task, onRetry }) {
if (state === undefined) {
return <div className="run-loading">Loading changed files…</div>;
}
if (state === null) {
return (
<div className="run-error">
<div className="run-error-title">Could not load this attempt's changed files</div>
<div className="run-error-detail">
archied did not answer for this attempt. It may be restarting — retry, or check the daemon.
</div>
{onRetry ? (
<button className="btn" type="button" onClick={onRetry}>
Retry
</button>
) : null}
</div>
);
}
const captures = state.captures || [];
// A capture event WAS recorded but its payload could not be read. The server
// reports `found` from the event's existence precisely so this is not
// reported as "no capture was recorded", which would be a false statement
// about a run whose diffstat demonstrably was captured.
if (state.found === true && !captures.length) {
return (
<div className="empty">
<div className="empty-title">A change capture was recorded but could not be read</div>
<div>
This attempt has a change capture event, but this dashboard could not decode its
payload. That is a read failure, not a statement about what the attempt changed.
</div>
</div>
);
}
if (!state.found || !captures.length) {
return (
<div className="empty">
<div className="empty-title">No change capture was recorded for this attempt</div>
<div>
Archie records what an attempt changed when it commits or pushes that work. Nothing was
recorded here — the attempt may predate capture, or it produced no commit. This is not the
same as "no files changed".
</div>
</div>
);
}
return (
<div className="run-changes">
{captures.map((capture, i) => (
<Capture key={`${capture.captured_at || ""}:${i}`} capture={capture} task={task} />
))}
</div>
);
}
+41
View File
@@ -0,0 +1,41 @@
// Raw debug view (R7): the stored task record and the task's events, verbatim.
//
// The events are deliberately NOT filtered to the selected attempt. A debug
// view that silently hid events would be worse than useless, so every event is
// shown and each carries its own `attempt` for the operator to attribute. The
// selected attempt is reported in the note and in the envelope's own `attempt`
// field; nothing here is summarised, projected or prettified beyond JSON
// indentation.
export function DebugView({ state, attempt, onRetry }) {
if (state === undefined) {
return <div className="run-loading">Loading the stored record…</div>;
}
if (state === null) {
return (
<div className="run-error">
<div className="run-error-title">Could not load the stored record</div>
<div className="run-error-detail">
archied did not answer for this task's debug view. It may be restarting — retry, or check
the daemon.
</div>
{onRetry ? (
<button className="btn" type="button" onClick={onRetry}>
Retry
</button>
) : null}
</div>
);
}
return (
<div className="run-debug">
<p className="run-debug-note">
The stored task record and its events, verbatim. Events are unfiltered on purpose: this is
every event the task has, and each one carries the attempt it belongs to. Attempt {attempt}{" "}
is the one selected above.
</p>
<pre className="run-json">{JSON.stringify(state, null, 2)}</pre>
</div>
);
}
+196
View File
@@ -0,0 +1,196 @@
import { Pill } from "../base/pill.jsx";
import { describeTimelineEvent, duration } from "./timeline-event.jsx";
// The per-attempt stage rail (R1).
//
// The rail is built from `GET /api/tasks/{id}/attempts`, which returns each
// attempt with its stages inline, so the selector and the rail can never
// disagree about which attempt is on screen. The rail only ever renders one
// attempt: merging two attempts by stage name is the failure this design
// exists to avoid.
//
// What a stage status means, and what it does not:
//
// a stage fails when its Go function returned an error. There is NO exit
// code, no pass/fail verdict, and no notion of "the work was correct" --
// a stage that returned nil after producing a poor diff is `ok`. So the rail
// never renders a checkmark, a badge or an exit status; it renders the
// status word, the duration and the error text, and says plainly what `ok`
// means. The agent's own self-reported outcome (`agent_finish`) is shown
// separately, labelled as the agent's report rather than as archie's verdict.
//
// A per-run elapsed time is deliberately NOT rendered. `waiting_human` can span
// days, so wall time from an attempt's start is not a duration of work; only
// per-stage durations exist and only those are shown.
const STAGE_STATUS = {
ok: { label: "ok", kind: "ok" },
failed: { label: "failed", kind: "danger" },
interrupted: { label: "interrupted", kind: "warn" },
running: { label: "running", kind: "info" },
unknown: { label: "unknown", kind: "idle" },
};
export function stageStatusMeta(status) {
return STAGE_STATUS[status] || { label: status || "unknown", kind: "idle" };
}
// agentReports returns the agent's own account of a stage: the `agent_finish`
// events whose attempt and stage both match. Returning an array rather than one
// value keeps a stage that ran two agents honest instead of showing the last.
export function agentReports(events, attemptNumber, stage) {
return (events || [])
.filter(
(ev) =>
ev &&
ev.kind === "agent_finish" &&
Number(ev.attempt) === Number(attemptNumber) &&
(ev.stage || "") === (stage || ""),
)
.map((ev) => describeTimelineEvent(ev));
}
// An attempt's start is rendered as an absolute instant, never as "started 2
// days ago": on a still-running attempt a relative stamp reads as two days of
// work, which is exactly the elapsed-time claim the design forbids. The
// attempt's own `duration_ms` is never rendered for the same reason -- it is
// wall time, and waiting_human can span days.
function startedAt(value) {
const when = value instanceof Date ? value : new Date(value);
if (Number.isNaN(when.getTime())) return "start time not recorded";
return `started ${when.toISOString().replace("T", " ").slice(0, 16)} UTC`;
}
function StageRow({ stage, attemptNumber, events }) {
const meta = stageStatusMeta(stage.status);
const ran = duration(stage.duration_ms);
const reports = agentReports(events, attemptNumber, stage.name);
return (
<li className="run-stage" data-status={stage.status || "unknown"}>
<span className="run-stage-node" aria-hidden="true" />
<div className="run-stage-body">
<div className="run-stage-head">
<span className="run-stage-name mono">{stage.name || "(unnamed stage)"}</span>
<Pill text={meta.label} kind={meta.kind} />
<span className="run-stage-duration">
{ran ? `ran for ${ran}` : "duration not recorded"}
</span>
</div>
{stage.error ? <div className="run-stage-error">{stage.error}</div> : null}
{reports.map((report, i) => (
<div className="run-agent-report" key={i}>
<span className="run-agent-report-label">Agent's own report, not verified by archie: </span>
{[report.title, report.detail].filter(Boolean).join(" · ")}
</div>
))}
</div>
</li>
);
}
function Empty({ title, detail }) {
return (
<div className="empty">
<div className="empty-title">{title}</div>
{detail && <div>{detail}</div>}
</div>
);
}
// The events no attempt owns. It renders in EVERY rail state, the empty ones
// included: a deployment where every event predates the attempt column answers
// with no attempts at all, and reporting "No attempts recorded" there without
// the count would present unattributable history as nothing having happened.
function UnattributedNote({ count }) {
const n = Number(count) || 0;
if (!n) return null;
return (
<p className="run-rail-note">
{n} event{n === 1 ? "" : "s"} on this task predate attempt attribution and cannot be assigned to a
run.
</p>
);
}
export function StageRail({ state, attemptNumber, events, onRetry }) {
if (state === undefined) {
return <div className="run-loading">Loading this task's attempts…</div>;
}
if (state === null) {
return (
<div className="run-error">
<div className="run-error-title">Could not load this task's attempts</div>
<div className="run-error-detail">
archied did not answer for this task's run history. It may be restarting — retry, or check
the daemon.
</div>
{onRetry ? (
<button className="btn" type="button" onClick={onRetry}>
Retry
</button>
) : null}
</div>
);
}
const attempts = state?.attempts || [];
if (!attempts.length) {
return (
<>
<Empty
title="No attempts recorded"
detail="This task has no recorded run. An attempt is written when a stage event is emitted, and none exist here."
/>
<UnattributedNote count={state?.unattributed_events} />
</>
);
}
const attempt = attempts.find((a) => Number(a.attempt) === Number(attemptNumber));
if (!attempt) {
return (
<>
<Empty
title={`Attempt ${attemptNumber} is not recorded for this task`}
detail={`This task recorded attempt ${attempts.map((a) => a.attempt).join(", ")}.`}
/>
<UnattributedNote count={state?.unattributed_events} />
</>
);
}
const stages = attempt.stages || [];
const meta = stageStatusMeta(attempt.status);
return (
<div className="run-rail">
<div className="run-rail-head">
<span className="run-rail-attempt">Attempt {attempt.attempt}</span>
<Pill text={meta.label} kind={meta.kind} />
<span className="run-rail-when">{startedAt(attempt.started_at)}</span>
</div>
{stages.length ? (
<ol className="run-stages" aria-label={`Stages recorded in attempt ${attempt.attempt}`}>
{stages.map((stage, i) => (
<StageRow
key={`${stage.seq ?? i}:${stage.name}`}
stage={stage}
attemptNumber={attempt.attempt}
events={events}
/>
))}
</ol>
) : (
<Empty
title="No stages recorded for this attempt"
detail="The attempt exists, but nothing recorded a stage for it."
/>
)}
<p className="run-rail-legend">
<strong>ok</strong> means the stage returned without error. Archie records no exit code and
does not verify that the work was correct, so this is a progress status, not a check result.
</p>
<UnattributedNote count={state?.unattributed_events} />
</div>
);
}
+69
View File
@@ -0,0 +1,69 @@
import { useRef } from "preact/hooks";
// A tab bar for the run detail page. There is no other consumer yet, so it
// stays in tasks/ rather than in base (organisation.md extracts on the second
// distinct consumer).
//
// Keyboard behaviour follows the WAI-ARIA tabs pattern with automatic
// activation: the tab list is one stop in the page's tab order (roving
// tabindex), Left/Right move between tabs and select as they go, Home/End jump
// to the ends. Automatic activation is the right choice here because every
// panel is a local render, not a fetch: there is no cost to switching.
export function tabId(prefix, id) {
return `${prefix}-tab-${id}`;
}
export function panelId(prefix, id) {
return `${prefix}-panel-${id}`;
}
export function TabBar({ tabs, active, onSelect, prefix = "run", label = "Run detail views" }) {
const refs = useRef([]);
const select = (index) => {
const tab = tabs[index];
if (!tab) return;
onSelect?.(tab.id);
refs.current[index]?.focus?.();
};
const onKeyDown = (event) => {
const current = tabs.findIndex((tab) => tab.id === active);
if (current < 0) return;
let next;
if (event.key === "ArrowRight") next = (current + 1) % tabs.length;
else if (event.key === "ArrowLeft") next = (current - 1 + tabs.length) % tabs.length;
else if (event.key === "Home") next = 0;
else if (event.key === "End") next = tabs.length - 1;
else return;
event.preventDefault();
select(next);
};
return (
<div className="tab-bar" role="tablist" aria-label={label} onKeyDown={onKeyDown}>
{tabs.map((tab, index) => {
const selected = tab.id === active;
return (
<button
key={tab.id}
ref={(node) => {
refs.current[index] = node;
}}
id={tabId(prefix, tab.id)}
className={`tab${selected ? " is-selected" : ""}`}
type="button"
role="tab"
aria-selected={selected}
aria-controls={panelId(prefix, tab.id)}
tabIndex={selected ? 0 : -1}
onClick={() => onSelect?.(tab.id)}
>
{tab.label}
</button>
);
})}
</div>
);
}
+617
View File
@@ -0,0 +1,617 @@
/* The per-task run detail page.
Colour comes only from the shared tokens in css/tokens.css, so both themes
are covered by construction; the layout is one column of panels that
collapses on narrow viewports. Motion is limited to hover/selection
transitions and is switched off for reduced-motion users. */
.run-meta {
display: flex;
align-items: center;
gap: var(--sp-4);
flex-wrap: wrap;
margin: calc(var(--sp-2) * -1) 0 var(--sp-4);
font-size: var(--text-sm);
}
.run-meta-item {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
}
.run-meta-label {
color: var(--fg-muted);
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.run-meta-value {
color: var(--fg);
}
.run-meta-muted {
color: var(--fg-muted);
}
.run-meta-link {
color: var(--accent);
}
.run-meta-link:hover {
text-decoration: underline;
}
.run-note {
margin: 0 0 var(--sp-4);
padding: var(--sp-3) var(--sp-4);
border-left: 3px solid var(--warn);
background: var(--warn-soft);
border-radius: var(--radius-sm);
color: var(--fg);
font-size: var(--text-sm);
}
/* ── New run ─────────────────────────────────────────────────────────────── */
.run-restart {
display: flex;
align-items: center;
gap: var(--sp-3);
flex-wrap: wrap;
margin-bottom: var(--sp-4);
}
.run-restart-copy {
flex: 1 1 22rem;
margin: 0;
color: var(--fg-muted);
font-size: var(--text-sm);
}
.run-restart-unavailable {
flex: 1 1 22rem;
margin: 0;
color: var(--fg-muted);
font-size: var(--text-sm);
}
.run-restart-error {
flex: 1 1 100%;
margin: 0;
font-size: var(--text-sm);
}
.run-restart-error-refused {
color: var(--warn);
}
.run-restart-error-broken {
color: var(--danger);
}
.run-restart-error-session-expired {
color: var(--warn);
}
/* ── Attempt selector ────────────────────────────────────────────────────── */
.run-attempts {
display: flex;
gap: var(--sp-2);
flex-wrap: wrap;
margin-bottom: var(--sp-4);
}
.run-attempt {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
padding: var(--sp-2) var(--sp-3);
border: 1px solid var(--border);
border-radius: var(--radius-pill);
background: var(--surface);
color: var(--fg-muted);
font: inherit;
font-size: var(--text-sm);
cursor: pointer;
transition: border-color var(--transition), color var(--transition);
}
.run-attempt:hover {
border-color: var(--border-strong);
color: var(--fg);
}
.run-attempt.is-selected {
border-color: var(--accent);
background: var(--accent-soft);
color: var(--fg);
}
.run-attempt-id {
font-weight: 500;
}
.run-attempt-meta {
color: var(--fg-muted);
font-size: var(--text-xs);
}
/* ── Tabs ────────────────────────────────────────────────────────────────── */
.run-card {
padding-top: var(--sp-4);
}
.tab-bar {
display: flex;
gap: var(--sp-1);
border-bottom: 1px solid var(--border);
margin-bottom: var(--sp-4);
overflow-x: auto;
scrollbar-width: thin;
}
.tab {
position: relative;
padding: var(--sp-2) var(--sp-3);
border: 0;
border-bottom: 2px solid transparent;
border-radius: var(--radius-sm) var(--radius-sm) 0 0;
background: transparent;
color: var(--fg-muted);
font: inherit;
font-size: var(--text-sm);
white-space: nowrap;
cursor: pointer;
transition: color var(--transition), background var(--transition);
}
.tab:hover {
color: var(--fg);
background: var(--surface-hover);
}
.tab.is-selected {
color: var(--fg);
border-bottom-color: var(--accent);
font-weight: 500;
}
.run-panel {
min-width: 0;
min-height: 6rem;
}
.run-panel:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 4px;
}
/* ── Shared panel states ─────────────────────────────────────────────────── */
.run-loading {
padding: var(--sp-5) 0;
color: var(--fg-muted);
font-size: var(--text-sm);
}
.run-error {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: var(--sp-2);
padding: var(--sp-3) 0;
}
.run-error-title {
color: var(--fg);
font-weight: 500;
}
.run-error-detail {
color: var(--fg-muted);
font-size: var(--text-sm);
max-width: 60ch;
}
.run-json {
margin: 0;
padding: var(--sp-3);
max-height: 60vh;
overflow: auto;
background: var(--bg-raised);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
font-family: var(--font-mono);
font-size: var(--text-xs);
line-height: 1.5;
/* pre-wrap keeps the indentation the JSON is printed with while letting a
long value wrap instead of forcing the panel to scroll sideways. */
white-space: pre-wrap;
overflow-wrap: anywhere;
}
/* ── Stage rail ──────────────────────────────────────────────────────────── */
.run-rail-head {
display: flex;
align-items: center;
gap: var(--sp-3);
flex-wrap: wrap;
margin-bottom: var(--sp-4);
}
.run-rail-attempt {
font-weight: 600;
}
.run-rail-when {
color: var(--fg-muted);
font-size: var(--text-xs);
}
.run-stages {
list-style: none;
margin: 0;
padding: 0;
}
.run-stage {
position: relative;
display: grid;
grid-template-columns: 1.75rem 1fr;
gap: var(--sp-2);
padding-bottom: var(--sp-4);
}
/* The rail line: a single vertical stroke behind the stage nodes, so the
sequence reads as one run rather than as unrelated rows. */
.run-stage::before {
content: "";
position: absolute;
left: 0.6875rem;
top: 1rem;
bottom: 0;
width: 1px;
background: var(--border-strong);
}
.run-stage:last-child::before {
display: none;
}
.run-stage-node {
position: relative;
z-index: 1;
width: 0.875rem;
height: 0.875rem;
margin: 0.25rem 0 0 0.25rem;
border-radius: 50%;
border: 2px solid var(--border-strong);
background: var(--bg-raised);
}
.run-stage[data-status="ok"] .run-stage-node {
border-color: var(--ok);
}
.run-stage[data-status="failed"] .run-stage-node {
border-color: var(--danger);
}
.run-stage[data-status="interrupted"] .run-stage-node {
border-color: var(--warn);
}
.run-stage[data-status="running"] .run-stage-node {
border-color: var(--info);
}
.run-stage-body {
min-width: 0;
}
.run-stage-head {
display: flex;
align-items: center;
gap: var(--sp-2);
flex-wrap: wrap;
}
.run-stage-name {
font-weight: 500;
color: var(--fg);
/* A stage name is one unbroken token often enough that it has to be allowed
to break, or a long one pushes the status and duration off the row. */
overflow-wrap: anywhere;
min-width: 0;
}
.run-stage-duration {
color: var(--fg-muted);
font-size: var(--text-xs);
}
.run-stage-error {
margin-top: var(--sp-2);
padding: var(--sp-2) var(--sp-3);
border-left: 3px solid var(--danger);
background: var(--danger-soft);
border-radius: var(--radius-sm);
color: var(--fg-muted);
font-size: var(--text-sm);
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.run-agent-report {
margin-top: var(--sp-2);
color: var(--fg-muted);
font-size: var(--text-xs);
}
.run-agent-report-label {
color: var(--fg-muted);
}
.run-rail-legend,
.run-rail-note {
margin: var(--sp-3) 0 0;
color: var(--fg-muted);
font-size: var(--text-xs);
max-width: 70ch;
}
.run-rail-legend strong {
color: var(--fg-muted);
}
/* ── Changed files ───────────────────────────────────────────────────────── */
.run-capture + .run-capture {
margin-top: var(--sp-5);
padding-top: var(--sp-4);
border-top: 1px solid var(--border);
}
.run-capture-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: var(--sp-3);
flex-wrap: wrap;
}
.run-capture-when {
color: var(--fg);
font-size: var(--text-sm);
font-weight: 500;
}
.run-capture-at {
color: var(--fg-muted);
font-size: var(--text-xs);
}
.run-capture-meta {
display: flex;
align-items: center;
gap: var(--sp-3);
flex-wrap: wrap;
margin: var(--sp-2) 0 var(--sp-3);
color: var(--fg-muted);
font-size: var(--text-xs);
}
.run-capture-link {
color: var(--accent);
}
.run-capture-link:hover {
text-decoration: underline;
}
.run-capture-branch,
.run-capture-sha {
color: var(--fg-muted);
}
.run-capture-totals {
color: var(--fg-muted);
}
.run-changes-table td {
padding: var(--sp-2) var(--sp-3);
vertical-align: top;
}
.run-changes-path {
color: var(--fg);
word-break: break-all;
}
.run-changes-old {
color: var(--fg-muted);
}
.run-changes-count {
text-align: right;
white-space: nowrap;
}
.run-changes-hint,
.run-changes-note,
.run-changes-empty {
color: var(--fg-muted);
font-size: var(--text-xs);
}
.run-changes-hint {
display: block;
}
.run-changes-empty {
padding: var(--sp-3) 0;
}
/* ── Configuration ───────────────────────────────────────────────────────── */
.run-config-scope {
margin: 0 0 var(--sp-2);
color: var(--fg-muted);
font-size: var(--text-sm);
max-width: 75ch;
}
.run-config-when {
margin-bottom: var(--sp-3);
color: var(--fg-muted);
font-size: var(--text-xs);
}
.run-config-unknown {
margin-bottom: var(--sp-2);
color: var(--warn);
font-size: var(--text-sm);
}
/* ── Log pane ────────────────────────────────────────────────────────────── */
.task-log-filters {
padding-bottom: var(--sp-3);
border-bottom: 1px solid var(--border);
}
.task-log-attempt {
color: var(--fg);
font-size: var(--text-sm);
font-weight: 500;
}
.task-log-filter {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
}
.task-log-filter-label {
color: var(--fg-muted);
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.task-log-filter-note {
flex: 1 1 100%;
margin: 0;
color: var(--fg-muted);
font-size: var(--text-xs);
max-width: 80ch;
}
/* On the detail page the log is the primary content, so it takes the tallest
read surface and a framed edge of its own rather than the bare top rule the
inline list-page pane uses. Scoped to .run-panel so the list-page pane keeps
its 40vh cap. */
.run-panel .task-log-list {
max-height: 62vh;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
background: var(--bg-raised);
padding: 0 var(--sp-2);
}
/* ── Status pills on this page ───────────────────────────────────────────── */
/* The shared .pill palette draws its small status WORD in the semantic hue on
that hue's own tint. Measured against the card this page renders on, that
fails WCAG AA 4.5:1 for small text in the light theme (ok 3.39:1, warn
3.26:1, danger 4.03:1, idle 4.09:1) and for `unknown` in the dark theme
(idle 3.31:1). Raising the shared tokens is an app-wide design change, not
this page's to make, so here the status word is drawn in the full-contrast
foreground colour (>=12.6:1 both themes) and the hue is carried by the dot
the pill already has -- which still clears the 3:1 non-text minimum
(worst pair 3.26:1). */
.run-page .pill {
color: var(--fg);
}
.run-page .pill-ok::before {
background: var(--ok);
}
.run-page .pill-warn::before {
background: var(--warn);
}
.run-page .pill-danger::before {
background: var(--danger);
}
.run-page .pill-info::before {
background: var(--info);
}
.run-page .pill-idle::before {
background: var(--idle);
}
/* ── Narrow viewports: the rail collapses ────────────────────────────────── */
@media (max-width: 700px) {
.run-meta {
margin-bottom: var(--sp-3);
}
.run-restart {
align-items: flex-start;
}
.run-attempts {
overflow-x: auto;
flex-wrap: nowrap;
padding-bottom: var(--sp-1);
}
/* The connector line and its gutter are what make the rail a timeline; on a
phone they cost the width the stage names need, so the rail becomes a plain
list of stages in order. */
.run-stage {
grid-template-columns: 1fr;
padding-bottom: var(--sp-3);
border-bottom: 1px solid var(--border);
}
.run-stage::before {
display: none;
}
.run-stage-node {
display: none;
}
.run-capture-head {
flex-direction: column;
align-items: flex-start;
gap: var(--sp-1);
}
}
@media (max-width: 480px) {
.tab {
padding: var(--sp-2);
}
.run-json {
max-height: 45vh;
}
}
@media (prefers-reduced-motion: reduce) {
.run-attempt,
.tab {
transition: none;
}
}
+548
View File
@@ -0,0 +1,548 @@
import { useState, useEffect, useRef } from "preact/hooks";
import "./task-detail.css";
import { api, classifyActionError } from "../base/api.jsx";
import { Pill } from "../base/pill.jsx";
import { actionFor, statusKind, statusLabel } from "../base/task-meta.jsx";
import { TabBar, panelId, tabId } from "./tab-bar.jsx";
import { StageRail, stageStatusMeta } from "./stage-rail.jsx";
import { ChangedFiles } from "./changed-files.jsx";
import { AttemptConfig } from "./attempt-config.jsx";
import { DebugView } from "./debug-view.jsx";
import { EMPTY_LOG_FILTERS, TaskLogPanel, logCacheKey } from "./task-logs.jsx";
// The per-task run detail page (R1, R3-R9), reached at #/tasks/{id}.
//
// One page, one task: which run it is showing, what each stage of that run did,
// its log, what it changed, the configuration it ran under, and the raw record.
// The task id rides in the path and the view state (`tab`, `attempt`) rides in
// the query string, so every view of this page is a deep link that survives a
// reload -- #/tasks/42?tab=changes&attempt=2.
//
// The attempt is the unit of every panel. Nothing on this page merges two
// attempts: the rail, the log, the capture and the config are all selected by
// attempt, and the two views of the same task's attempts (the selector and the
// rail) come from a single response.
export const RUN_TABS = [
{ id: "stages", label: "Stages" },
{ id: "log", label: "Log" },
{ id: "changes", label: "Changed files" },
{ id: "config", label: "Configuration" },
{ id: "debug", label: "Debug" },
];
const TAB_PREFIX = "run";
const TAB_IDS = new Set(RUN_TABS.map((tab) => tab.id));
export function parseTaskId(raw) {
const value = String(raw ?? "").trim();
if (!/^\d+$/.test(value)) return null;
const n = Number(value);
return Number.isSafeInteger(n) && n > 0 ? n : null;
}
export function initialTab(query) {
const requested = query?.get?.("tab") || "";
return TAB_IDS.has(requested) ? requested : RUN_TABS[0].id;
}
// `?attempt=2` pins attempt 2. An absent, empty or non-numeric value follows
// whatever the server reports as current, and 0 is the wire's own spelling of
// "the current attempt" (taskLogTarget, internal/webui/api_tasks_logs.go), so it
// selects the current attempt rather than a nonexistent attempt 0.
export function initialAttempt(query) {
const raw = query?.get?.("attempt");
if (raw == null || raw === "") return null;
const n = Number(raw);
return Number.isInteger(n) && n > 0 ? n : null;
}
export function runHash(id, tab, attempt) {
const params = new URLSearchParams();
params.set("tab", tab || RUN_TABS[0].id);
if (attempt) params.set("attempt", String(attempt));
return `#/tasks/${id}?${params.toString()}`;
}
// Selection is written back with replaceState rather than by assigning
// location.hash: replaceState does not fire a hashchange, so the router does not
// remount and refetch the page on every tab click, while the address bar still
// holds the full state for a copy, a bookmark or a reload.
export function writeRunHash(id, tab, attempt) {
try {
window.history.replaceState(null, "", `${location.pathname}${location.search}${runHash(id, tab, attempt)}`);
} catch {
// A deployment that refuses the history write still renders every panel;
// only the shareable URL is lost, and the page never depends on it.
}
}
function attemptKey(id, attempt) {
return `${id}|${Number(attempt) || 0}`;
}
function Empty({ title, detail }) {
return (
<div className="empty">
<div className="empty-title">{title}</div>
{detail && <div>{detail}</div>}
</div>
);
}
function NotFound({ id }) {
return (
<div>
<div className="page-head">
<div>
<h1 className="page-title">Task not found</h1>
<p className="page-sub">No task with id {id} in this deployment.</p>
</div>
<div className="page-actions">
<a className="btn" href="#/tasks">
Back to tasks
</a>
</div>
</div>
<div className="card">
<div className="empty">
<div className="empty-title">Nothing is recorded for task {id}</div>
<div>archied answered that this task does not exist, so there is no run history to show.</div>
</div>
</div>
</div>
);
}
function InvalidId({ raw }) {
return (
<div>
<div className="page-head">
<div>
<h1 className="page-title">Not a task id</h1>
<p className="page-sub">The run view addresses one task by its id: #/tasks/42</p>
</div>
<div className="page-actions">
<a className="btn" href="#/tasks">
Back to tasks
</a>
</div>
</div>
<div className="card">
<div className="empty">
<div className="empty-title">“{raw}” is not a task id</div>
<div>A task id is a positive whole number. Nothing was requested.</div>
</div>
</div>
</div>
);
}
function AttemptSelector({ attempts, selected, onSelect }) {
const list = attempts?.attempts || [];
if (!list.length) return null;
return (
<div className="run-attempts" role="group" aria-label="Attempts of this task">
{list.map((attempt) => {
const meta = stageStatusMeta(attempt.status);
const selectedNow = Number(attempt.attempt) === Number(selected);
return (
<button
key={attempt.attempt}
type="button"
className={`run-attempt${selectedNow ? " is-selected" : ""}`}
aria-pressed={selectedNow}
onClick={() => onSelect(attempt.attempt)}
>
<span className="run-attempt-id">Attempt {attempt.attempt}</span>
<Pill text={meta.label} kind={meta.kind} />
<span className="run-attempt-meta">
{(attempt.stages || []).length} stage{(attempt.stages || []).length === 1 ? "" : "s"}
</span>
</button>
);
})}
</div>
);
}
function RunDetail({ id, query }) {
const [tab, setTab] = useState(() => initialTab(query));
const [requestedAttempt, setRequestedAttempt] = useState(() => initialAttempt(query));
const [taskList, setTaskList] = useState(undefined);
const [attempts, setAttempts] = useState(undefined);
const [missing, setMissing] = useState(false);
const [events, setEvents] = useState(undefined);
const [filters, setFilters] = useState(EMPTY_LOG_FILTERS);
const [logs, setLogs] = useState(new Map());
const [changes, setChanges] = useState(new Map());
const [debug, setDebug] = useState(new Map());
const [retryBusy, setRetryBusy] = useState(false);
const [retryError, setRetryError] = useState(null);
const [refreshToken, setRefreshToken] = useState(0);
const started = useRef(new Set());
const task = Array.isArray(taskList) ? taskList.find((t) => String(t.id) === String(id)) || null : null;
const currentAttempt = Number(attempts?.current_attempt) > 0 ? Number(attempts.current_attempt) : null;
// The wire spells "the task's current attempt" as 0, which is not an attempt
// number: a task with no run at all must not address attempt 0.
const attemptNumber = requestedAttempt ?? currentAttempt;
const selectedAttempt = (attempts?.attempts || []).find(
(a) => Number(a.attempt) === Number(attemptNumber),
);
const stageNames = [
...new Set((selectedAttempt?.stages || []).map((stage) => stage.name).filter(Boolean)),
];
// Every keyed fetch goes through here: the key is what the response belongs
// to, so a late response for an attempt the operator has already left lands
// under its own key and is never shown against another attempt.
const keyedLoad = (cacheKey, fetcher, setter, { force = false } = {}) => {
if (started.current.has(cacheKey) && !force) return;
started.current.add(cacheKey);
setter((prev) => new Map(prev).set(cacheKey, undefined));
fetcher()
.then((res) => setter((prev) => new Map(prev).set(cacheKey, res)))
.catch(() => setter((prev) => new Map(prev).set(cacheKey, null)));
};
const loadTaskList = () => {
setTaskList(undefined);
api
.tasks()
.then((res) => setTaskList(res))
.catch(() => setTaskList(null));
};
const loadAttempts = () => {
setAttempts(undefined);
setMissing(false);
api
.taskAttempts(id)
.then((res) => setAttempts(res))
.catch((err) => {
if (err?.status === 404) setMissing(true);
setAttempts(null);
});
};
const loadEvents = () => {
setEvents(undefined);
api
.task(id)
.then((res) => setEvents(res || []))
.catch(() => setEvents(null));
};
const loadLogs = (attempt, opts) =>
keyedLoad(
logCacheKey(id, attempt, filters),
() =>
api.taskLogs(id, {
attempt: attempt || undefined,
level: filters.level,
stage: filters.stage,
limit: 500,
}),
setLogs,
opts,
);
const loadChanges = (attempt, opts) =>
keyedLoad(attemptKey(id, attempt), () => api.taskChanges(id, { attempt }), setChanges, opts);
const loadDebug = (attempt, opts) =>
keyedLoad(attemptKey(id, attempt), () => api.taskDebug(id, { attempt }), setDebug, opts);
const refreshAll = () => {
// Drop every cache and let the effects refetch: a manual refresh must not
// show a stale capture or log beside fresh attempt history.
started.current = new Set();
setLogs(new Map());
setChanges(new Map());
setDebug(new Map());
loadTaskList();
loadAttempts();
loadEvents();
setRefreshToken((n) => n + 1);
};
useEffect(() => {
loadTaskList();
loadAttempts();
loadEvents();
// The page loads once for the task it was opened for; the route remounts it
// when that changes.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
if (attemptNumber == null) return;
// Only the visible tab's lazy payload is fetched: the debug envelope repeats
// the whole event list, so fetching it on every page load would duplicate a
// large body for nothing.
if (tab === "log") loadLogs(attemptNumber);
else if (tab === "changes") loadChanges(attemptNumber);
else if (tab === "debug") loadDebug(attemptNumber);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tab, attemptNumber, filters, refreshToken]);
useEffect(() => {
writeRunHash(id, tab, attemptNumber);
}, [id, tab, attemptNumber]);
const performRetry = async () => {
const title = task?.title || `task ${id}`;
const confirmed = window.confirm(
`Start a new run for "${title}"? This is a new attempt, and the previous attempt's commits are discarded.`,
);
if (!confirmed) return;
setRetryError(null);
setRetryBusy(true);
try {
await api.taskAction(id, "retry");
// A new attempt starts here. Everything cached belongs to the attempt
// that just ended, so it is dropped rather than shown against the new
// run: the attempt history, the events, every cached log, capture and
// debug payload. The new attempt then becomes the selected run without a
// reload.
started.current = new Set();
setLogs(new Map());
setChanges(new Map());
setDebug(new Map());
setRequestedAttempt(null);
loadTaskList();
loadAttempts();
loadEvents();
setRefreshToken((n) => n + 1);
} catch (err) {
setRetryError(classifyActionError(err));
} finally {
setRetryBusy(false);
}
};
if (missing) return <NotFound id={id} />;
const logKey = attemptNumber == null ? null : logCacheKey(id, attemptNumber, filters);
const changeKey = attemptKey(id, attemptNumber);
const debugKey = attemptKey(id, attemptNumber);
const panel = () => {
// The rail owns its own loading, failure and empty-rail states.
if (tab === "stages") {
return (
<StageRail
state={attempts}
attemptNumber={attemptNumber}
events={events}
onRetry={loadAttempts}
/>
);
}
// Every other panel is scoped to one attempt, and "no attempt" is a claim
// only a successful read of the run history can make -- a failed read is
// reported as a failed read.
if (attempts === undefined) {
return <div className="run-loading">Loading this task's attempts…</div>;
}
if (attempts === null) {
return (
<div className="run-error">
<div className="run-error-title">Could not load this task's attempts</div>
<div className="run-error-detail">
This panel reads one attempt, and the task's run history could not be read.
</div>
<button className="btn" type="button" onClick={loadAttempts}>
Retry
</button>
</div>
);
}
if (attemptNumber == null) {
return (
<Empty
title="No attempt recorded"
detail="This task has no recorded run, so there is nothing to read for an attempt."
/>
);
}
switch (tab) {
case "log":
return (
<TaskLogPanel
state={logKey && logs.has(logKey) ? logs.get(logKey) : undefined}
attempt={attemptNumber}
stages={stageNames}
filters={filters}
onFilterChange={setFilters}
taskId={id}
onRetry={() => loadLogs(attemptNumber, { force: true })}
/>
);
case "changes":
return (
<ChangedFiles
state={changes.has(changeKey) ? changes.get(changeKey) : undefined}
task={task}
onRetry={() => loadChanges(attemptNumber, { force: true })}
/>
);
case "config":
return <AttemptConfig events={events} attempt={attemptNumber} onRetry={loadEvents} />;
case "debug":
return (
<DebugView
state={debug.has(debugKey) ? debug.get(debugKey) : undefined}
attempt={attemptNumber}
onRetry={() => loadDebug(attemptNumber, { force: true })}
/>
);
default:
return (
<StageRail
state={attempts}
attemptNumber={attemptNumber}
events={events}
onRetry={loadAttempts}
/>
);
}
};
const retryMeta = actionFor("retry");
const canRetry = Boolean(retryMeta && (task?.actions || []).includes("retry"));
return (
<div className="run-page">
<div className="page-head">
<div>
<h1 className="page-title">{task?.title || `Task #${id}`}</h1>
<p className="page-sub">
One run of task {id}
{task?.workflow ? ` · ${task.workflow} workflow` : ""}
{task?.repo ? ` · ${task.owner}/${task.repo}` : ""}
</p>
</div>
<div className="page-actions">
<a className="btn" href="#/tasks">
Back to tasks
</a>
<button className="btn" type="button" onClick={refreshAll}>
Refresh
</button>
</div>
</div>
<div className="run-meta">
<span className="run-meta-item">
<span className="run-meta-label">Task status</span>
{taskList === undefined ? (
<span className="run-meta-muted">loading…</span>
) : task ? (
<Pill text={statusLabel(task.status)} kind={statusKind(task.status)} />
) : (
<span className="run-meta-muted">not read</span>
)}
</span>
<span className="run-meta-item">
<span className="run-meta-label">Attempt</span>
<span className="run-meta-value">
{attempts === null
? "run history unreadable"
: attempts === undefined
? "loading…"
: attemptNumber == null
? "none recorded"
: `attempt ${attemptNumber} of ${currentAttempt ?? attemptNumber}`}
</span>
</span>
{task?.repo_url ? (
<a className="run-meta-link" href={task.repo_url} target="_blank" rel="noreferrer">
{task.owner}/{task.repo}
</a>
) : null}
{task?.issue_url && task.issue_number ? (
<a className="run-meta-link" href={task.issue_url} target="_blank" rel="noreferrer">
Issue #{task.issue_number}
</a>
) : null}
{task?.pr_url && task.pr_number ? (
<a className="run-meta-link" href={task.pr_url} target="_blank" rel="noreferrer">
PR #{task.pr_number}
</a>
) : null}
</div>
{taskList === null ? (
<p className="run-note">
The task list could not be read, so this page cannot show the task's current status or its
operator controls. The run history below comes from the task's own endpoints.
</p>
) : null}
{Array.isArray(taskList) && !task ? (
<p className="run-note">
Task {id} is not among the tasks this dashboard lists (the list covers the 100 most
recently updated). Its recorded attempts are shown below; the Debug tab holds the stored
record verbatim.
</p>
) : null}
<section className="run-restart" aria-label="Start a new run">
<button
className={`btn ${retryMeta?.kind === "primary" ? "btn-primary" : ""}`}
type="button"
disabled={!canRetry || retryBusy}
title="Retry this task as a new run"
onClick={performRetry}
>
{retryBusy ? "Starting…" : "Start a new run"}
</button>
<p className="run-restart-copy">
Starts a new attempt for this task: a fresh worktree reset onto the base branch. The
previous attempt's commits are discarded — they are not carried into the new run.
</p>
{!canRetry && taskList !== undefined ? (
<p className="run-restart-unavailable">
{task
? `A new run can only start from a parked task. This task is ${statusLabel(task.status)}.`
: "This task's operator controls could not be read, so a new run cannot be started from here."}
</p>
) : null}
{retryError ? (
<p className={`run-restart-error run-restart-error-${retryError.kind}`}>
{retryError.kind === "session-expired"
? "Your session has expired. Reload to sign in."
: retryError.kind === "refused"
? `${retryError.message} — this run cannot be restarted from here.`
: `${retryError.message} — try again, or check the daemon.`}
</p>
) : null}
</section>
<AttemptSelector
attempts={attempts}
selected={attemptNumber}
onSelect={(value) => setRequestedAttempt(value)}
/>
<div className="card run-card">
<TabBar tabs={RUN_TABS} active={tab} onSelect={setTab} prefix={TAB_PREFIX} />
<div
className="run-panel"
role="tabpanel"
id={panelId(TAB_PREFIX, tab)}
aria-labelledby={tabId(TAB_PREFIX, tab)}
tabIndex={0}
>
{panel()}
</div>
</div>
</div>
);
}
export function taskDetailPage(query, params) {
const raw = params?.id;
const id = parseTaskId(raw);
if (id === null) return <InvalidId raw={raw ?? ""} />;
return <RunDetail id={id} query={query} />;
}
+176 -44
View File
@@ -1,13 +1,32 @@
import { h } from "preact";
import { useRef, useEffect } from "preact/hooks";
import { logRow as renderLogRow } from "../base/log-row.jsx";
import { logRow as renderLogRow, LOG_LEVELS } from "../base/log-row.jsx";
// A task attempt's log pane (R5).
//
// Three read outcomes are kept apart, because only one of them is about the
// operator's configuration or about this attempt:
//
// disabled -- this process cannot read task logs at all (deployment)
// found: false -- a reader exists and this attempt has no log file
// entries: [] -- a log exists and nothing matches the current filter
//
// The filter controls render ABOVE all three, and above the loading and failed
// states too. Putting them inside the success branch is how a deployment that
// cannot read logs ends up showing an empty filtered pane instead of saying so.
// They render when the page can act on a filter change (the list page's inline
// pane has no filter state, and a control that filters nothing is worse than no
// control); the ordering rule belongs here either way.
//
// The attempt is not a filter here: the page selects the attempt and this pane
// reports which one it is showing, so the pane can never read attempt 1's log
// while claiming attempt 2.
function LogRowNode({ entry }) {
const ref = useRef(null);
useEffect(() => {
if (ref.current) ref.current.replaceChildren(renderLogRow(entry));
}, [entry]);
return <div ref={ref} style={{ display: 'contents' }} />;
return <div ref={ref} style={{ display: "contents" }} />;
}
// Task-log download URL. The attempt is named explicitly so a download matches
@@ -17,66 +36,179 @@ export function taskLogDownloadURL(id, attempt) {
return `/api/tasks/${id}/logs/download` + (attempt == null ? "" : `?attempt=${attempt}`);
}
export function TaskLogPanel({ state, onRetry, taskId }) {
export const EMPTY_LOG_FILTERS = { level: "", stage: "" };
// The identity of a log read: a task, an attempt, and the filters that produced
// the response. Keying by task alone cannot represent two attempts -- the bug
// this replaces -- and keying without the filters would serve attempt 2's
// unfiltered log in answer to a filtered request.
export function logCacheKey(id, attempt, filters = EMPTY_LOG_FILTERS) {
const applied = filters || EMPTY_LOG_FILTERS;
return [id, Number(attempt) || 0, applied.level || "", applied.stage || ""].join("|");
}
function FilterBar({ filters, onFilterChange, stages, attempt }) {
const change = (patch) => onFilterChange?.({ ...filters, ...patch });
const shown = Number(attempt) || 0;
return (
<div className="log-filters task-log-filters">
<span className="task-log-attempt">{shown > 0 ? `Attempt ${shown}` : "Current attempt"}</span>
{/* Controls appear only where the page can act on a change: a filter that
filters nothing is worse than no filter. */}
{onFilterChange ? (
<>
<label className="task-log-filter">
<span className="task-log-filter-label">Level</span>
<select
className="task-filter"
value={filters.level}
aria-label="Filter log entries by level"
onChange={(e) => change({ level: e.target.value })}
>
{LOG_LEVELS.map((level) => (
<option key={level.value} value={level.value}>
{level.label}
</option>
))}
</select>
</label>
<label className="task-log-filter">
<span className="task-log-filter-label">Stage</span>
<select
className="task-filter"
value={filters.stage}
aria-label="Filter log entries by stage"
onChange={(e) => change({ stage: e.target.value })}
>
<option value="">All stages</option>
{(stages || []).map((stage) => (
<option key={stage} value={stage}>
{stage}
</option>
))}
</select>
</label>
{/* A stage filter is a narrowing, not a clean sweep: only lines a
stage tagged carry a stage, and agent/tool output never does.
Saying so beside the control is what keeps a sparse result from
reading as a broken pane. */}
{filters.stage ? (
<p className="task-log-filter-note">
A stage filter matches only log lines that record a stage. Agent and tool output
carries none, so it is not shown while this filter is set.
</p>
) : null}
{!filters.stage && !(stages || []).length ? (
<p className="task-log-filter-note">
This attempt recorded no stage names, so the stage filter has nothing to match.
</p>
) : null}
</>
) : null}
</div>
);
}
// The pane's state, announced once. It is a live region for STATE, not for the
// log's lines: putting aria-live on the list itself would read every entry
// aloud on every load, which for a 500-entry pane is unusable. `aria-atomic`
// makes the whole sentence re-announce rather than a fragment of it.
function LogStatus({ text }) {
return (
<p className="visually-hidden" role="status" aria-live="polite" aria-atomic="true">
{text}
</p>
);
}
export function TaskLogPanel({
state,
onRetry,
taskId,
attempt,
filters = EMPTY_LOG_FILTERS,
onFilterChange,
stages = [],
}) {
const resolvedAttempt = Number(attempt) || Number(state?.attempt) || 0;
// One live-region sentence per read outcome, so the pane announces WHICH case
// it is in. The two unavailable cases stay distinct in the announcement the
// same way they stay distinct on screen.
let status;
let body;
if (state === undefined) {
return <div className="task-log-loading">Loading attempt log…</div>;
}
if (state === null) {
return (
status = "Loading this attempt's log";
body = <div className="task-log-loading">Loading attempt log…</div>;
} else if (state === null) {
status = "This attempt's log could not be loaded";
body = (
<div className="task-log-error">
<div className="task-timeline-detail">Could not load this attempt's log.</div>
<button className="btn" onClick={onRetry}>Retry</button>
<button className="btn" onClick={onRetry}>
Retry
</button>
</div>
);
}
// A reader exists in this process but the attempt has no log file. That is a
// fact about the attempt, and saying "logging was not enabled" here (which
// this panel used to do) told the operator to go and change a setting that
// was already correct.
if (state.found === false && !state.disabled) {
return (
} else if (state.found === false && !state.disabled) {
// A reader exists in this process but the attempt has no log file. That is
// a fact about the attempt, and saying "logging was not enabled" here (which
// this panel used to do) told the operator to go and change a setting that
// was already correct.
status = "No log recorded for this attempt";
body = (
<div className="empty">
<div className="empty-title">No log recorded for this attempt</div>
<div>This attempt produced no output, or it has not started writing yet.</div>
</div>
);
}
// This process cannot read task logs at all. That IS about the deployment,
// and it is the only case where the panel may say so.
if (state.disabled) {
return (
} else if (state.disabled) {
// This process cannot read task logs at all. That IS about the deployment,
// and it is the only case where the panel may say so.
status = "This dashboard cannot read task logs";
body = (
<div className="empty">
<div className="empty-title">No persisted log for this attempt</div>
<div>This dashboard cannot read task logs. The service that owns the log files is not reporting a log reader.</div>
</div>
);
} else {
const entries = state.entries || [];
const download = taskId != null ? taskLogDownloadURL(taskId, resolvedAttempt || null) : null;
const footer = download ? (
<a className="btn btn-small task-log-download" href={download} download>
Download log
</a>
) : null;
if (!entries.length) {
status = "This attempt's log has no entries matching the current filter";
body = (
<div className="empty">
<div className="empty-title">Nothing recorded</div>
<div>This attempt's log file has no entries matching the current filter.</div>
{footer}
</div>
);
} else {
status = `${entries.length} log entr${entries.length === 1 ? "y" : "ies"} shown`;
body = (
<>
<div className="log-list task-log-list">
{entries.map((entry, i) => (
<LogRowNode key={i} entry={entry} />
))}
</div>
{footer}
</>
);
}
}
const entries = state.entries || [];
const download = taskId != null ? taskLogDownloadURL(taskId, state.attempt) : null;
const footer = download ? (
<a className="btn btn-small task-log-download" href={download} download>Download log</a>
) : null;
if (!entries.length) {
return (
<div className="empty">
<div className="empty-title">Nothing recorded</div>
<div>This attempt's log file has no entries matching the current filter.</div>
{footer}
</div>
);
}
return (
<>
<div className="log-list task-log-list">
{entries.map((entry, i) => (
<LogRowNode key={i} entry={entry} />
))}
</div>
{footer}
<FilterBar filters={filters} onFilterChange={onFilterChange} stages={stages} attempt={resolvedAttempt} />
<LogStatus text={status} />
{body}
</>
);
}
+13
View File
@@ -79,6 +79,19 @@
text-decoration: underline;
}
/* The title cell links to the task's run detail page. It inherits the title's
colour so the row still reads as a list, and underlines on hover so the link
is discoverable. */
.task-detail-link {
color: inherit;
}
.task-detail-link:hover,
.task-detail-link:focus-visible {
text-decoration: underline;
text-decoration-color: var(--accent);
}
.task-actions {
display: flex;
gap: var(--sp-1);
+91 -19
View File
@@ -8,9 +8,22 @@ import { statTile as renderStatTile } from "../base/statTile.jsx";
import { taskRowA11y } from "./task-row.jsx";
import { initialTaskFilter, taskMatchesStatus } from "./task-filters.jsx";
import { describeTimelineEvent } from "./timeline-event.jsx";
import { TaskLogPanel } from "./task-logs.jsx";
import { TaskLogPanel, logCacheKey } from "./task-logs.jsx";
import { actionFor, statusIds, statusKind, statusLabel } from "../base/task-meta.jsx";
// The shell's global reduced-motion rule switches CSS transitions and
// animations, NOT the JS smooth scroll this page performs when it reveals a
// deep-linked row. The decision therefore has to be made here, in JavaScript,
// and is exported so it can be tested directly (jsdom implements neither
// matchMedia nor scrollIntoView).
export function prefersReducedMotion() {
return typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches === true;
}
export function revealBehavior() {
return prefersReducedMotion() ? "auto" : "smooth";
}
function StatTileNode(props) {
const ref = useRef(null);
useEffect(() => {
@@ -50,6 +63,20 @@ function Empty({ title, detail }) {
);
}
// The open log pane loads its own attempt's log whenever it is showing an
// attempt it has no cached entry for: a retry moves the pane to a new attempt,
// a forced reload drops its own entry, and a row can be reopened long after the
// click that first opened it. Loading only from that click is what would leave
// the pane sitting on "Loading…" with nothing fetching it.
function TaskLogSection({ taskId, attempt, state, onLoad, onRetry }) {
const load = useRef(onLoad);
load.current = onLoad;
useEffect(() => {
if (state === undefined) load.current();
}, [state]);
return <TaskLogPanel state={state} taskId={taskId} attempt={attempt} onRetry={onRetry} />;
}
function TasksApp({ query }) {
const [tasks, setTasks] = useState(null);
const [error, setError] = useState(null);
@@ -63,6 +90,7 @@ function TasksApp({ query }) {
const [eventCache, setEventCache] = useState(new Map());
const [logCache, setLogCache] = useState(new Map());
const logRequests = useRef(new Set());
const [logsExpanded, setLogsExpanded] = useState(new Set());
const [actionErrors, setActionErrors] = useState(new Map());
const [actionsInFlight, setActionsInFlight] = useState(new Set());
@@ -77,9 +105,11 @@ function TasksApp({ query }) {
loadTimeline(expandedId);
}
}
return res;
} catch (err) {
setError(String(err.message || err));
setTasks(null);
return null;
}
};
@@ -97,18 +127,40 @@ function TasksApp({ query }) {
}
};
const loadTaskLogs = async (id) => {
setLogCache(prev => {
const loadTaskLogs = async (id, attempt, { force = false } = {}) => {
// The cache entry is identified by the task AND the attempt: a task alone
// cannot tell two runs apart, so a retry used to leave the previous
// attempt's log on screen under the new run. One request per key, unless a
// control explicitly asks for the read again.
const key = logCacheKey(id, attempt);
if (logRequests.current.has(key) && !force) return;
logRequests.current.add(key);
if (force) {
setLogCache(prev => {
const next = new Map(prev);
next.delete(key);
return next;
});
}
try {
const res = await api.taskLogs(id, { attempt: attempt || undefined, limit: 500 });
setLogCache(prev => new Map(prev).set(key, res));
} catch {
setLogCache(prev => new Map(prev).set(key, null));
}
};
// An operator action can change a task's timeline -- a retry begins a new
// attempt -- so the events cached for that task are dropped rather than served
// against the new state. The log cache needs no invalidation here: its key
// already carries the attempt, so the new run is a different entry and can
// never be answered by the ended attempt's log.
const invalidateTaskCaches = (id) => {
setEventCache(prev => {
const next = new Map(prev);
next.delete(id);
return next;
});
try {
const res = await api.taskLogs(id, { limit: 500 });
setLogCache(prev => new Map(prev).set(id, res));
} catch {
setLogCache(prev => new Map(prev).set(id, null));
}
};
const performAction = async (id, action) => {
@@ -127,7 +179,14 @@ function TasksApp({ query }) {
return next;
});
if (action === "archive") setExpandedId(null);
await load();
invalidateTaskCaches(id);
const res = await load();
// A row that is still open reloads against the attempt the task now has;
// otherwise it would sit on "Loading…" with its cache entry gone.
const updated = Array.isArray(res) ? res.find(t => String(t.id) === String(id)) : null;
if (updated && expandedId === id) {
loadTimeline(id);
}
} catch (err) {
setActionsInFlight(prev => {
const next = new Set(prev);
@@ -146,7 +205,9 @@ function TasksApp({ query }) {
const row = document.getElementById(`task-row-${expandedId}`);
if (row) {
row.focus({ preventScroll: true });
row.scrollIntoView({ block: "center", behavior: "smooth" });
// Optional call: focusing a deep-linked row is a nicety, and not every
// environment implements scrollIntoView on an element.
row.scrollIntoView?.({ block: "center", behavior: revealBehavior() });
}
});
}
@@ -164,12 +225,8 @@ function TasksApp({ query }) {
const toggleLogs = (id) => {
setLogsExpanded(prev => {
const next = new Set(prev);
if (next.has(id)) {
next.delete(id);
} else {
next.add(id);
if (!logCache.has(id)) loadTaskLogs(id);
}
if (next.has(id)) next.delete(id);
else next.add(id);
return next;
});
};
@@ -302,6 +359,7 @@ function TasksApp({ query }) {
};
const renderTimelineRow = (t) => {
const logKey = logCacheKey(t.id, t.attempt);
const cached = eventCache.get(t.id);
const logsExpandedForTask = logsExpanded.has(t.id);
@@ -359,7 +417,13 @@ function TasksApp({ query }) {
</button>
</div>
{logsExpandedForTask && (
<TaskLogPanel state={logCache.get(t.id)} taskId={t.id} onRetry={() => loadTaskLogs(t.id)} />
<TaskLogSection
taskId={t.id}
attempt={t.attempt}
state={logCache.has(logKey) ? logCache.get(logKey) : undefined}
onLoad={() => loadTaskLogs(t.id, t.attempt)}
onRetry={() => loadTaskLogs(t.id, t.attempt, { force: true })}
/>
)}
</div>
</td>
@@ -448,7 +512,15 @@ function TasksApp({ query }) {
{issueLink(t) ?? `#${t.issue_number}`}
</td>
<td className="strong" data-label="Title">
{t.title || "(untitled)"}
<a
className="task-detail-link"
href={`#/tasks/${t.id}`}
title="Open the run detail for this task"
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => e.stopPropagation()}
>
{t.title || "(untitled)"}
</a>
</td>
<td data-label="Status">
<Pill text={statusLabel(t.status)} kind={statusKind(t.status)} />
+19 -1
View File
@@ -4,7 +4,9 @@ function words(value) {
.replace(/\b\w/g, (letter) => letter.toUpperCase());
}
function duration(milliseconds) {
// Exported so the stage rail renders a duration exactly the way the timeline
// does; a second formatter would eventually disagree with this one.
export function duration(milliseconds) {
const ms = Number(milliseconds);
if (!Number.isFinite(ms) || ms < 0) return "";
if (ms < 1000) return `${Math.round(ms)} ms`;
@@ -79,5 +81,21 @@ export function describeTimelineEvent(ev = {}) {
};
}
// Condition (d): the two provenance kinds render as one human line. The
// captured payload is rendered by its own panel, never dumped into the
// timeline, so these cases name what was recorded and nothing more.
if (ev.kind === "config_captured") {
return {
title: "Configuration captured",
detail: "The effective task-runtime configuration for this run.",
};
}
if (ev.kind === "changes_captured") {
const fileCount = Number(data.totals?.files);
const files = Number.isFinite(fileCount) && fileCount > 0 ? `${fileCount} file${fileCount === 1 ? "" : "s"} changed` : "";
const after = data.captured_after ? `captured after ${data.captured_after}` : "";
return { title: "Change capture recorded", detail: [files, after].filter(Boolean).join(" · ") };
}
return { title: words(ev.kind || ev.type), detail: ev.detail || "" };
}