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:
33 files changed
+4195
-91
No files matched your search
@@ -1,7 +1,8 @@
|
||||
# Task Observability
|
||||
|
||||
**Status:** Implemented
|
||||
**Date:** 2026-08-09
|
||||
**Status:** Implemented. The per-run detail surface was added on 2026-09-18 and
|
||||
is described below.
|
||||
**Date:** 2026-08-09 (revised 2026-09-18)
|
||||
|
||||
## Historical problem
|
||||
|
||||
@@ -135,6 +136,183 @@ lifecycle rather than accumulating independently.
|
||||
Telegram or the webui chat — this is the surface that actually matters
|
||||
for the deployment model in `CLAUDE.md`, where an operator may not be
|
||||
looking at a dashboard at all.
|
||||
- The per-attempt read surface described in the next section, on top of the
|
||||
same task-scoped stream.
|
||||
|
||||
## Per-run task detail (attempts, stages, changes, config)
|
||||
|
||||
**Status:** landed, together with the change set that carries this revision
|
||||
(workflow run `76f8e877`). The provenance half is in the tree: `events.Event.Attempt`,
|
||||
the `changes_captured` and `config_captured` event kinds, and the two protobuf field
|
||||
additions. So is the read half: the three per-attempt endpoints
|
||||
(`/api/tasks/{id}/attempts`, `/changes`, `/debug`) and the dashboard run-detail page
|
||||
that consumes them. The decision record, the rejected alternatives and the honest
|
||||
limits are `docs/prds/task-run-detail.md`.
|
||||
|
||||
The task log surface above answers *why did this park?*. This surface answers
|
||||
*what did this run actually do?*, per attempt.
|
||||
|
||||
### Attempt attribution
|
||||
|
||||
One task can run many times, and the task's event stream is the durable record
|
||||
of all of them. `events.Event.Attempt` attributes each event to one run; `0`
|
||||
means **not attributable** — every event written before this change, plus the
|
||||
deliberately task-agnostic producers. An unattributed event is reported as a
|
||||
count and is never presented as an attempt.
|
||||
|
||||
Attribution is a column, not a fold over `task_queued`/`task_retried`: a fold
|
||||
would have to guess which side of a boundary an event belongs to across a daemon
|
||||
restart, a stale-run recovery, or two interleaved attempts, and a guess rendered
|
||||
as structure is exactly the false fidelity this surface exists to avoid.
|
||||
|
||||
The column reaches an existing database through the presence-gated arm in
|
||||
`internal/store`'s `migrateTasks` — `eventsSchema` is `CREATE TABLE IF NOT
|
||||
EXISTS`, so on an existing database the migrator is the *only* thing that adds
|
||||
it. `PRAGMA user_version` is unchanged because the loop is presence-gated
|
||||
rather than version-gated, and nothing is backfilled.
|
||||
|
||||
### Read surface
|
||||
|
||||
The routes are registered beside the existing task routes in
|
||||
`internal/webui`'s `registerTaskRoutes` and all resolve the task through the
|
||||
store's `TaskByID`; a task that does not exist is a `404`, never a `200` with an
|
||||
empty body.
|
||||
|
||||
- `GET /api/tasks/{id}/attempts` — every attempt with its stages inline, so the
|
||||
rail and the attempt selector can never disagree. Stages are ordered by
|
||||
occurrence within their attempt. An attempt with no stages is legitimate and
|
||||
renders as "no stages recorded", never as an unexplained empty rail.
|
||||
- `GET /api/tasks/{id}/changes?attempt=N` — the change captures for one
|
||||
attempt, ordered by capture time; more than one per attempt is normal (a
|
||||
mid-workflow commit such as TDD's `commit-repro`, then `commit-push`, then a
|
||||
final `open-pr` capture that carries the pull-request number).
|
||||
`found: false` means no capture was recorded for that attempt, which is
|
||||
**not** "no files changed"; a capture that was recorded but could not be read
|
||||
is reported as exactly that, and never as a diffstat of zeroes.
|
||||
- `GET /api/tasks/{id}` — unchanged: the raw event array, each event now
|
||||
carrying `attempt`. The per-attempt configuration is read from this response,
|
||||
selected by kind **and** attempt.
|
||||
- `GET /api/tasks/{id}/logs` — gains `stage` beside its existing filters. The
|
||||
match is exact and case-insensitive, and an entry that records no stage never
|
||||
matches (see `logging.Query.Stage`).
|
||||
- `GET /api/tasks/{id}/debug?attempt=N` — the stored task record and the task's
|
||||
events, deliberately unfiltered, so an operator can attribute everything the
|
||||
task did even when a panel has nothing to show.
|
||||
|
||||
The `attempt` parameter follows one rule on every route: absent or `0` selects
|
||||
the task's current attempt, and the resolved attempt is echoed in the response.
|
||||
|
||||
### Stage status
|
||||
|
||||
`stage_start` and `stage_finish` are the only inputs, so the derivation is
|
||||
explicit and each case is pinned by a test:
|
||||
|
||||
| Events seen for the stage | Reported |
|
||||
| --- | --- |
|
||||
| `stage_finish` with `data.error` | `failed`, with the error text |
|
||||
| `stage_finish` with `data.interrupted` | `interrupted` |
|
||||
| `stage_finish`, neither | `ok` — "returned without error" |
|
||||
| `stage_start` unmatched, and this is the task's current in-flight attempt | `running` |
|
||||
| `stage_start` unmatched on any dead attempt | `interrupted` — the run ended without finishing it |
|
||||
| `stage_finish` with no matching start | the stage, with no start time invented |
|
||||
| no stage information at all for that attempt | `unknown` |
|
||||
|
||||
**There is no exit code.** `stage_finish` carries a duration and an optional
|
||||
error string and nothing else, so no stage can be shown as pass/fail and the
|
||||
page must not imply verification. A stage that finished cleanly and then parked
|
||||
stays `ok` on a failed task, which is why the attempt status is read together
|
||||
with the task status rather than on its own.
|
||||
|
||||
### Changed files
|
||||
|
||||
The change an attempt produced is read from the worktree at the moment it is
|
||||
committed or pushed, and persisted as a `changes_captured` durable event — plus
|
||||
one final capture when `OpenPR` records the pull-request number, which is the
|
||||
only point at which a capture can carry one. It has to be captured there: the
|
||||
worktree is deleted on merge, close and no-PR terminal states, a retry resets
|
||||
the branch onto its base, and no forge contract exposes a changed-file read.
|
||||
`internal/domain/workflow/task/changes.go` owns the value types and the status
|
||||
strings they persist.
|
||||
|
||||
- One capture carries per-file `added`/`modified`/`deleted`/`renamed`/
|
||||
`typechange` status with added and deleted line counts, and totals.
|
||||
- Each capture names its schema (`archie/task-changes@1`, in `internal/events`)
|
||||
and a reader refuses a payload whose schema or key set it does not know,
|
||||
rather than rendering the zero value of every field it could not find. That
|
||||
refusal surfaces as "a capture was recorded but could not be read", which is
|
||||
a different statement from "no capture was recorded".
|
||||
- `base_sha` is the merge base the file list was diffed against, not the base
|
||||
branch's tip, so the pair describes one change set even when the base branch
|
||||
moved during the run.
|
||||
- `files` is capped; `totals` always covers the **full** set, and a truncated
|
||||
capture says so rather than silently dropping entries.
|
||||
- `binary` means "no textual hunks" — never a claim about the file's type on
|
||||
disk — and a path the repository recorded as a rename pair is reported as the
|
||||
repository recorded it.
|
||||
- Capture **degrades and never parks**: an implementation without the capture
|
||||
seam captures nothing, logs, and lets the run continue.
|
||||
|
||||
### Per-attempt configuration
|
||||
|
||||
The effective configuration an attempt ran under is persisted as a once-per-
|
||||
attempt `config_captured` durable event carrying the schema constant
|
||||
`archie/task-config@1` and the non-secret task-runtime subset from
|
||||
`config.Config.ForTask()`. It is not stored in a table and has no endpoint of
|
||||
its own: the dashboard reads it out of the events response it already fetches.
|
||||
The single-row `config_snapshot` table is left alone — it answers what the
|
||||
running configuration is now and is replaced on every publish.
|
||||
|
||||
Redaction is proven positively by a test that builds a full configuration
|
||||
containing canary values and asserts none of them survive serialising, rather
|
||||
than being inferred from the producer's contract. The timeline carries one
|
||||
human line for this kind; the document itself is rendered by the panel.
|
||||
|
||||
**Trust boundary, stated honestly.** A task-scoped grant may insert events on
|
||||
its own task ID — that is how `tool_call` and `agent_finish` already work — so a
|
||||
task could in principle write its own `config_captured` event. This widens no
|
||||
capability, because the grant could already insert arbitrary events on itself,
|
||||
but it does mean this provenance is exactly as trustworthy as the rest of that
|
||||
task's event stream, and no more. It is not tamper-proofing and must never be
|
||||
described as such.
|
||||
|
||||
### The wire
|
||||
|
||||
The whole wire change is two fields on existing messages: `Event.attempt`
|
||||
(field 11) and `ReadTaskLogRequest.stage` (field 9) in
|
||||
`proto/state/v1/state.proto`. No RPC, no table and no configuration field was
|
||||
added, so the ratified state-store contract in
|
||||
`docs/prds/state-store-contract.md` rev 2c is unchanged.
|
||||
|
||||
Version skew degrades instead of failing, and each degrade is a statement the
|
||||
page has to make rather than hide: an old server makes `attempt` read as `0` and
|
||||
`stage` match nothing, so the page says it cannot attribute events to attempts
|
||||
instead of labelling the whole stream "attempt 1"; an old client sees
|
||||
`config_captured` as an unfamiliar kind, and the panel must then say it cannot
|
||||
read per-run configuration — a different claim from "not captured for this
|
||||
attempt".
|
||||
|
||||
### Rules the surface keeps
|
||||
|
||||
- "No record" and "this deployment cannot read this" stay different answers,
|
||||
for logs and for configuration alike.
|
||||
- No run-duration figure is shown. A run can spend days in `waiting_human`, so
|
||||
one number would understate wall time; per-stage durations only.
|
||||
- No duration is invented for a stage with no start; it reads "not recorded".
|
||||
- The stage filter is a narrowing, not a coverage claim: agent and tool output
|
||||
carries no stage and is never matched, and the pane says so beside the
|
||||
control.
|
||||
- An attempt predating the change shows "not captured for this run" for its
|
||||
configuration and its change capture, never an empty view that implies
|
||||
defaults applied or nothing changed.
|
||||
|
||||
### Failure and rollback
|
||||
|
||||
Every part is additive. A capture or a configuration emit that cannot happen
|
||||
leaves the run alone — reporting must never park a task. Reverting the change
|
||||
set removes the endpoints and the page; the extra column and the extra event
|
||||
kinds are inert to the previous revision (SQLite ignores a column no statement
|
||||
names, and an unfamiliar event kind already renders as unfamiliar), and there is
|
||||
no data transformation to undo.
|
||||
|
||||
## Dependency direction
|
||||
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
# Per-run task detail: attempts, stages, changes, config, debug
|
||||
|
||||
**Status:** Settled design, landing with this change set (workflow run
|
||||
`76f8e877`). The persistence foundation is already in the tree
|
||||
(`events.attempt`, the two new event kinds, the two proto fields); the read
|
||||
endpoints and the page land with it. The surface contract itself is
|
||||
`docs/architecture/observability.md`.
|
||||
**Date:** 2026-09-18
|
||||
**Compounds with:** `docs/prds/task-logs-pagination.md` (a bounded read says
|
||||
what it does not show), `docs/prds/status-health-surface.md` (no surface that
|
||||
answers something already answered elsewhere).
|
||||
|
||||
## Decision
|
||||
|
||||
A task gets one detail page that answers "what did this run actually do?" per
|
||||
**attempt**: an ordered stage rail, the change each commit/push produced, the
|
||||
effective configuration the attempt ran under, the attempt's log, and the raw
|
||||
record behind all of it.
|
||||
|
||||
The single organising idea is **attempt attribution**. Today the dashboard
|
||||
renders a task's whole event stream as one flat timeline, so a retried task
|
||||
reads as one long run with two of everything. Every new panel is scoped to one
|
||||
attempt and says which one.
|
||||
|
||||
The second organising idea is **provenance, not re-derivation**. What a run
|
||||
produced is captured at the producer, while the evidence exists, and persisted
|
||||
durably. Nothing in this surface tries to reconstruct a past run from state
|
||||
that has since moved on.
|
||||
|
||||
## The requirement set
|
||||
|
||||
| # | Requirement | Mechanism |
|
||||
| --- | --- | --- |
|
||||
| R1 | Per-attempt stage rail: stages with name, start, duration, terminal status and error, ordered within one attempt | `GET /api/tasks/{id}/attempts` reads the task's events and groups them by `attempt` |
|
||||
| R2 | Events carry an attempt, migrated safely and carried on the wire | `events.attempt` column + presence-gated migrator arm; `Event.attempt = 11` |
|
||||
| R3 | Changed files captured at commit/push, persisted per task, exposed, shown with repo/PR links | `changes_captured` durable event written by the commit/push steps; `GET /api/tasks/{id}/changes` |
|
||||
| R4 | The effective configuration an attempt ran under, secrets redacted, shown | `config_captured` durable event written once per attempt; read from the events response the page already holds |
|
||||
| R5 | Log pane filters by attempt, stage and level; absence stays distinct from an unreadable deployment | `logging.Query.Stage` + `ReadTaskLogRequest.stage = 9`; the pane keeps `disabled` and `found=false` apart |
|
||||
| R6 | Retry is reachable from the run view and produces a new attempt shown as a new run | Existing retry action, labelled as a NEW run whose confirm states the previous attempt's commits are discarded |
|
||||
| R7 | Raw JSON of the task record and its events for the selected attempt | `GET /api/tasks/{id}/debug` |
|
||||
| R8 | Deep-linkable, reload-safe per-task detail page that keeps existing URLs working | `#/tasks/{id}` route beside the existing `#/tasks?task=N` and `#/tasks?status=...` |
|
||||
| R9 | Design polish: hierarchy, tokens, both themes, responsive rail, a11y, loading/empty/error states | UI lane; measured at 480px and 700px in both themes |
|
||||
| R10 | Documentation of record | This document plus `docs/architecture/observability.md` |
|
||||
| R11 | Red-first tests for every new behaviour, full gate, `task ui`, forced `go build ./...`, `go test -race` on touched packages | Per lane; the anti-cost-cutting requirement lives here |
|
||||
|
||||
## Attempt attribution: a column, not a guess
|
||||
|
||||
`events.Event.Attempt`, persisted by `internal/store` as the `events.attempt`
|
||||
column (`internal/store/events.go`, `eventsSchema`), is a real column,
|
||||
`NOT NULL DEFAULT 0`. It was chosen over segmenting the stream on `task_queued` /
|
||||
`task_retried` because a fold would have to guess which side of a boundary an
|
||||
event belongs to when the daemon restarts mid-attempt, when `RecoverStale`
|
||||
requeues, or when two attempts interleave across a crash. A guess rendered as
|
||||
structure is exactly the false fidelity this surface exists to avoid; a column
|
||||
is durable, queryable and ordered by construction.
|
||||
|
||||
**`0` means "not attributable".** It is every row written before this change
|
||||
plus the deliberately task-agnostic producers. It is not an attempt number and
|
||||
is never rendered as one. The attempts endpoint reports the count of
|
||||
unattributed events so the page can say so instead of presenting old history as
|
||||
attempt 1.
|
||||
|
||||
## Migration against an existing `archie.db`
|
||||
|
||||
The store's migrator (`migrateTasks` in `internal/store/store.go`) already reads
|
||||
`PRAGMA table_info` through `tableColumns` and applies a presence-gated
|
||||
`ALTER TABLE ... ADD COLUMN` list. This change adds an `events` arm: a
|
||||
`tableColumns(ctx, tx, "events")` read beside the other two, and the entry
|
||||
`ALTER TABLE events ADD COLUMN attempt INTEGER NOT NULL DEFAULT 0`.
|
||||
|
||||
Three consequences a future maintainer must not get wrong:
|
||||
|
||||
- `eventsSchema` is `CREATE TABLE IF NOT EXISTS` (`internal/store/events.go`),
|
||||
so on an existing database it is a **no-op**. The migrator arm is the only
|
||||
thing that adds the column there. This is why the red test builds a raw
|
||||
SQLite file with the pre-change `events` DDL and must fail before the arm
|
||||
exists: every temp-database test passes either way.
|
||||
- **`user_version` stays 3.** The loop is presence-gated, not version-gated;
|
||||
bumping it would force an edit to the test that exists to prove a newer
|
||||
schema is refused.
|
||||
- **No backfill, ever.** Existing rows keep `attempt = 0`. Inferring an attempt
|
||||
number for them would be fabrication.
|
||||
|
||||
## Changed files: captured at the producer
|
||||
|
||||
The measurement is taken inside the shared step library immediately after a
|
||||
successful commit and after a successful push (`StageCommit` and
|
||||
`StageCommitPush` in `internal/domain/workflow/steps.go`) — the one place
|
||||
where the worktree, the branch, the base, the task and the store are all in
|
||||
scope, and the only place that knows a push actually happened.
|
||||
|
||||
Both alternatives were rejected on evidence, not taste:
|
||||
|
||||
- **Reading the diff on demand** is impossible. The worktree is deleted on
|
||||
merge, close and no-PR terminal states (`internal/worktree.(*Manager).Cleanup`,
|
||||
called from the daemon's terminal paths) and a retry resets the branch onto
|
||||
its base (`internal/worktree.(*Manager).refresh` → `resetOnto`). There is
|
||||
nothing left to read.
|
||||
- **Reading it from the forge** is impossible today. The forge contract exposes
|
||||
no changed-file capability, and adding one would cost three implementations
|
||||
plus an RPC and would still fail for chat-sourced tasks with no PR.
|
||||
|
||||
Binding consequences:
|
||||
|
||||
- Capture **degrades, never parks**. A `Trees` implementation without the
|
||||
capture seam captures nothing, logs, and lets the run continue. A reporting
|
||||
failure must never fail a task.
|
||||
- The value types live in `internal/domain/workflow/task` (`changes.go`), not in
|
||||
package `workflow` and not in `internal/worktree`. Package `workflow` has no
|
||||
import of `internal/worktree`, and this subpackage is not projected into the
|
||||
interpreted-stage symbol table, so declaring the types here widens nothing and
|
||||
needs no symbol-table regeneration. The capture method stays off that surface
|
||||
entirely.
|
||||
- `files` is capped at 200 entries because an event's `data` is not
|
||||
length-limited by the store. `totals` always covers the **full** set and
|
||||
`truncated: true` says when entries were dropped.
|
||||
- `binary` means "no textual hunks", not "a binary file". Rename pairing is
|
||||
go-git behaviour the lane pins with a test; where the repository records a
|
||||
rename as add + delete, the surface reports what was recorded.
|
||||
|
||||
## Per-run configuration: a durable event, not a table
|
||||
|
||||
**Decision.** The effective configuration an attempt ran under is persisted as a
|
||||
`config_captured` durable event (`internal/events.KindConfigCaptured`), on the
|
||||
same attempt key R2 adds — not in a table, and not behind new RPCs.
|
||||
|
||||
**Why.** Three reasons, in order of weight:
|
||||
|
||||
1. Events are already this system's durable per-attempt provenance stream, and
|
||||
they demonstrably carry aggregation (`StageStats`, `TokensByDay` both
|
||||
aggregate over persisted events). R3 puts its diffstat there in this same
|
||||
change. A table plus two RPCs would have given one feature **two provenance
|
||||
mechanisms for one purpose**.
|
||||
2. It adds no RPC, so the ratified state-store surface is untouched and nothing
|
||||
in `docs/prds/state-store-contract.md` (rev 2c) changes.
|
||||
3. The page already fetches the task's events to build the rail (R1) and to read
|
||||
the diffstat (R3), so the document arrives in a fetch it already makes. There
|
||||
is nothing to join.
|
||||
|
||||
The single-row `config_snapshot` table is deliberately **left alone**. It
|
||||
answers "what is the running configuration now", is replaced on every publish,
|
||||
and is pinned to one row by a test. It could not answer "what did attempt 2 run
|
||||
under" in any case.
|
||||
|
||||
**Payload.** The result of `config.Config.ForTask()` — the non-secret
|
||||
task-runtime subset — plus the schema constant `archie/task-config@1`. Not the
|
||||
dashboard's configuration view: that is a larger projection carrying the full
|
||||
schema catalog, and it is the wrong object for this. Stored shape and the tab's
|
||||
read rule are in `docs/architecture/observability.md`.
|
||||
|
||||
**Binding conditions.** It is emitted through the durable path, never the
|
||||
lossy bus; it is written once per attempt, not once per stage; redaction is
|
||||
proven **positively** by a canary-secrets test rather than assumed from the
|
||||
producer's contract; the timeline gains one human line for it rather than
|
||||
dumping a JSON blob; and an attempt with no such event renders "not captured for
|
||||
this run", never an empty table implying defaults applied.
|
||||
|
||||
**Documented residual — the honest trust claim.** A task-scoped grant may insert
|
||||
events on its own task ID; that is how `tool_call` and `agent_finish` already
|
||||
work, so a task can in principle write its own `config_captured` event. This
|
||||
**widens no capability** — the grant could already insert arbitrary events on
|
||||
itself — but it does mean this provenance is exactly as trustworthy as the rest
|
||||
of that task's event stream, and no more. It is not tamper-proofing and must
|
||||
never be described as such.
|
||||
|
||||
## No new RPC and no new table
|
||||
|
||||
The entire wire change is two fields on existing messages:
|
||||
|
||||
```proto
|
||||
// proto/state/v1/state.proto
|
||||
message Event { int64 attempt = 11; }
|
||||
message ReadTaskLogRequest { string stage = 9; }
|
||||
```
|
||||
|
||||
No RPC was added, no store table was added, and no new configuration field was
|
||||
introduced. `docs/prds/state-store-contract.md` is unchanged because no ratified
|
||||
contract changed; the JSON document rides an existing `data` column over an
|
||||
existing RPC.
|
||||
|
||||
Both fields are tolerant in both directions, and the degrade is stated rather
|
||||
than hidden: an old server makes `attempt` read as `0` and `stage` match
|
||||
nothing, so the page must say the deployment cannot attribute events to attempts
|
||||
rather than show one run labelled "attempt 1". An old client shows
|
||||
`config_captured` as an unknown kind, and the Config tab must then say "this
|
||||
deployment cannot read per-run configuration" — a different claim from "not
|
||||
captured for this attempt".
|
||||
|
||||
## Retry is a new run
|
||||
|
||||
The retry action is reachable from the run view and produces a new attempt that
|
||||
appears as a new run. It is a **fresh** run: it resets the branch onto
|
||||
`origin/<base>` (`internal/worktree.(*Manager).refresh` → `resetOnto`) and
|
||||
**discards the previous attempt's commits**. Labelling it "restart" would imply
|
||||
resumption that does not happen, so the control and its confirm copy say so.
|
||||
|
||||
## Honest limits the surface carries
|
||||
|
||||
These are the claims that would otherwise be overstated. Each is a copy or
|
||||
rendering rule, not a caveat in a comment:
|
||||
|
||||
- **There is no exit code, so no stage shows pass/fail.** `stage_finish` carries
|
||||
a duration and an optional error string and nothing else. A stage `ok` means
|
||||
"returned without error", not "the work was correct". The agent's own verdict
|
||||
is shown separately from the rail. A stage that parks after finishing cleanly
|
||||
leaves that stage `ok` on a failed task, so attempt status is read together
|
||||
with task status.
|
||||
- **The log stage filter only matches lines the workflow bound a stage to.**
|
||||
Agent and tool output carries no stage and never matches. The pane states that
|
||||
coverage limit next to the control rather than presenting a filtered view as
|
||||
the whole story.
|
||||
- **Absence and unreadability are different answers.** A deployment that cannot
|
||||
read task logs says so; an attempt whose log does not exist says that. They
|
||||
are never collapsed, in either direction, for logs or for configuration.
|
||||
- **An empty changed-files view never means "nothing changed".** No capture
|
||||
exists for runs predating this change and the forge cannot supply one, so the
|
||||
empty state reads "not captured for this run".
|
||||
- **No run-duration figure is shown.** Per-stage durations only: a run can spend
|
||||
days in `waiting_human`, and one number would understate wall time.
|
||||
- **No duration is invented** for a stage with no `stage_start`; it reads "not
|
||||
recorded".
|
||||
- **Unattributed history is never presented as an attempt.** Events with
|
||||
`attempt = 0` are reported as a count, not guessed into a run.
|
||||
- **The configuration shown is the attempt's non-secret task-runtime subset** —
|
||||
bot identity, models, limits, budgets, dispatch, diff cap, notifications,
|
||||
forge host, tool policy. It is not the full dashboard configuration and must
|
||||
never imply it contains providers, repositories, identities or credentials.
|
||||
|
||||
## Route and compatibility
|
||||
|
||||
`#/tasks/{id}` is the detail route; it is deep-linkable and reload-safe.
|
||||
`#/tasks?task=N` and `#/tasks?status=...` keep working and keep their existing
|
||||
behaviour, including the nav highlight. The debug view is why the raw view
|
||||
exists at all: the task list response is capped, so a client-side join has no
|
||||
row for an older task, and a debug view that silently hid events would be worse
|
||||
than useless.
|
||||
|
||||
## What this deliberately does not do
|
||||
|
||||
- **No new RPC, table, store interface or configuration field.** Nothing here
|
||||
needed one, and each would have widened a ratified surface.
|
||||
- **No exit status, no pass/fail gate badge, no "steps" in the CI sense.** The
|
||||
reference layout is a CI pipeline; archie's stages are agent runs and the page
|
||||
must not borrow CI's claims.
|
||||
- **No backfill** of attempts, change captures or configurations onto runs that
|
||||
predate the change.
|
||||
- **No client-side join for configuration.** It arrives in the events response
|
||||
the page already fetches; there is nothing to join.
|
||||
- **No change to `docs/prds/state-store-contract.md`.** No ratified contract
|
||||
moved.
|
||||
|
||||
## Files this change touches
|
||||
|
||||
- `internal/store/`: the `events.attempt` column, its migrator arm, and the
|
||||
schema-presence test.
|
||||
- `internal/events/`: `Event.Attempt`, `KindChangesCaptured`,
|
||||
`KindConfigCaptured`, `ConfigCapturedSchema`.
|
||||
- `internal/domain/workflow/task/changes.go`: the change value types.
|
||||
- `internal/worktree/` + `internal/app/agentworker/`: the capture primitive and
|
||||
its production forwarding.
|
||||
- `internal/domain/workflow/steps.go`: the capture at commit and push.
|
||||
- `internal/daemon/`: the per-attempt configuration emit at dispatch.
|
||||
- `internal/logging/`: `Query.Stage`.
|
||||
- `internal/webui/`: the three read endpoints and the `stage` log parameter.
|
||||
- `proto/state/v1/state.proto` + generated stubs: the two field additions.
|
||||
- `ui/src/`: the detail page, the tab primitive, the rail, and the panel copy.
|
||||
- `docs/`: this document and `docs/architecture/observability.md`.
|
||||
|
||||
## Acceptance
|
||||
|
||||
1. Two attempts of one task render as two runs, and attempt 1's rail excludes
|
||||
attempt 2's stages.
|
||||
2. A task with no stages renders "no stages recorded", never an unexplained
|
||||
empty rail.
|
||||
3. A pre-change `archie.db` gains the `attempt` column with `user_version`
|
||||
still 3, and its old events are reported as unattributed.
|
||||
4. An attempt with a capture shows per-file added/deleted counts, status, repo
|
||||
and PR links; an attempt without one says so and never says "no changes".
|
||||
5. The Config tab shows the attempt's document for the selected attempt only,
|
||||
with no secret value present in the serialized document.
|
||||
6. Retry from the run view produces a new attempt shown as a new run, with copy
|
||||
stating the previous attempt's commits are discarded.
|
||||
7. The log stage filter narrows to stage-bound lines and the pane states the
|
||||
coverage limit; `disabled` and `found=false` remain distinguishable.
|
||||
8. `#/tasks/{id}` survives reload, and `#/tasks?task=N` / `#/tasks?status=...`
|
||||
are unchanged.
|
||||
9. The debug view returns the task record and its unfiltered events, each
|
||||
carrying `attempt`.
|
||||
10. Run the gate and the dashboard build: `task check` passes clean, `task ui`
|
||||
has been run so `ui/dist` matches the sources, and every touched package
|
||||
builds and passes under `-race`.
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.icon-btn:hover{color:var(--fg);background:var(--surface-hover)}.avatar{border-radius:var(--radius-pill);width:32px;height:32px;font-size:var(--text-xs);color:#fff;background:linear-gradient(135deg, var(--accenLine truncated
|
||||
:root{--font-sans:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;--font-mono:ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;--text-xs:.6875rem;--text-sm:.8125rem;--text-base:.875rem;--text-lg:1.0625rem;--text-xl:1.375rem;--text-2xl:1.875rem;--text-3xl:2.5rem;--sp-1:.25rem;--sp-2:.5rem;--sp-3:.75rem;--sp-4:1rem;--sp-5:1.5rem;--sp-6:2rem;--sp-7:3rem;--radius-sm:6px;--radius-md:10px;--radius-lg:14px;--radius-xl:20px;--radius-pill:999px;--transition:.14s cubic-bezier(.4, 0, .2, 1)}[data-theme=dark]{--bg:#0d1014;--bg-raised:#141920;--surface:#171d25;--surface-hover:#1d242e;--border:#232b36;--border-strong:#303a48;--fg:#e8edf4;--fg-muted:#8b97a8;--fg-subtle:#5d6878;--accent:#4c8dff;--accent-fg:#fff;--accent-soft:#4c8dff24;--ok:#3fbf7f;--ok-soft:#3fbf7f24;--warn:#e8a33d;--warn-soft:#e8a33d24;--danger:#f0616d;--danger-soft:#f0616d24;--info:#4c8dff;--info-soft:#4c8dff24;--idle:#6b7688;--idle-soft:#6b768824;--accent-2:#7b5cff;--bg-blur:#1419208c;--surface-glass:#171d259e;--surface-glass-strong:#141920c7;--workspace:#11151b8c;--hairline:#ffffff0f;--wash-a:#4c8dff1a;--wash-b:#7b5cff1f;--wash-c:#3fbf7f0f;--shadow-workspace:0 24px 70px #00000080;--shadow-sm:0 1px 2px #0006;--shadow-md:0 8px 28px #0000006b}[data-theme=light]{--bg:#f6f8fb;--bg-raised:#fff;--surface:#fff;--surface-hover:#f1f4f9;--border:#e2e8f0;--border-strong:#cbd5e1;--fg:#16202e;--fg-muted:#5a6779;--fg-subtle:#8c99ab;--accent:#2563eb;--accent-fg:#fff;--accent-soft:#2563eb1a;--ok:#10935c;--ok-soft:#10935c1f;--warn:#b87514;--warn-soft:#b875141f;--danger:#d4344a;--danger-soft:#d4344a1f;--info:#2563eb;--info-soft:#2563eb1a;--idle:#64748b;--idle-soft:#64748b1f;--accent-2:#7c3aed;--bg-blur:#fff9;--surface-glass:#ffffffb8;--surface-glass-strong:#ffffffe0;--workspace:#ffffff8c;--hairline:#0f172a0f;--wash-a:#2563eb1a;--wash-b:#7c3aed1f;--wash-c:#10935c12;--shadow-workspace:0 24px 70px #0f172a24;--shadow-sm:0 1px 2px #0f172a0f;--shadow-md:0 8px 28px #0f172a1a}*,:before,:after{box-sizing:border-box}html,body{height:100%;margin:0}body{color:var(--fg);font-family:var(--font-sans);font-size:var(--text-base);-webkit-font-smoothing:antialiased;line-height:1.5}a{color:inherit;text-decoration:none}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.visually-hidden{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}body{background:radial-gradient(70rem 40rem at 8% -10%, var(--wash-a), transparent 62%), radial-gradient(56rem 34rem at 92% 4%, var(--wash-b), transparent 58%), radial-gradient(48rem 30rem at 50% 108%, var(--wash-c), transparent 60%), var(--bg);padding:var(--sp-4);background-attachment:fixed}.shell{min-height:calc(100vh - var(--sp-4) * 2);border-radius:var(--radius-xl);border:1px solid var(--hairline);background:var(--workspace);-webkit-backdrop-filter:blur(28px)saturate(120%);backdrop-filter:blur(28px)saturate(120%);box-shadow:var(--shadow-workspace);flex-direction:column;display:flex;overflow:hidden}.topbar{align-items:center;gap:var(--sp-4);padding:var(--sp-3) var(--sp-4);border-bottom:1px solid var(--hairline);background:var(--bg-blur);z-index:10;display:flex;position:sticky;top:0}.brand{align-items:center;gap:var(--sp-2);font-weight:600;font-size:var(--text-sm);letter-spacing:-.01em;flex:none;display:flex}.brand-mark{background:linear-gradient(135deg, var(--accent), var(--accent-2));color:#fff;width:26px;height:26px;font-size:var(--text-xs);border-radius:8px;place-items:center;font-weight:700;display:grid}.nav{border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);align-items:center;gap:2px;margin:0 auto;padding:3px;display:flex}.nav-item{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);color:var(--fg-muted);font-size:var(--text-sm);white-space:nowrap;cursor:pointer;transition:background var(--transition), color var(--transition);display:inline-flex}.nav-item:hover{color:var(--fg);background:var(--surface-hover)}.nav-item[aria-current=page]{background:var(--accent);color:var(--accent-fg);font-weight:500}.nav-item .nav-label{display:inline}.topbar-end{align-items:center;gap:var(--sp-2);flex:none;display:flex}.topbar-search{align-items:center;gap:var(--sp-2);padding:var(--sp-2) var(--sp-3);border-radius:var(--radius-pill);background:var(--surface-glass-strong);border:1px solid var(--hairline);color:var(--fg-subtle);display:flex}.topbar-search input{color:var(--fg);font:inherit;font-size:var(--text-sm);background:0 0;border:0;outline:none;width:8rem}.topbar-search input::placeholder{color:var(--fg-subtle)}.mobile-search-toggle{display:none}.icon-btn{border-radius:var(--radius-pill);border:1px solid var(--hairline);background:var(--surface-glass-strong);width:32px;height:32px;color:var(--fg-muted);cursor:pointer;transition:color var(--transition), background var(--transition);place-items:center;display:grid}.Line truncated
|
||||
Vendored
+8
-8
@@ -1,16 +1,16 @@
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),te(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,re(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=te(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&L(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ee(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),R(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ee(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function M(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function N(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||M(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||M(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function P(e){return function(n){if(this.l){var r=Line truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var ue=class extends Error{constructor(e,t){super(e),this.status=t}};function de(e){let t=e instanceof ue?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function fe(e,t){let n=await fetch(e,t);if(!n.ok)throw new ue(await le(n),n.status);return n}async function z(e,{method:t=`GET`,body:n,timeoutMs:r=se,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await fe(e,o);return i?s.json():void 0}var B={summary:()=>z(`/api/summary`),tasks:()=>z(`/api/tasks`),taskMeta:()=>z(`/api/task-meta`),task:e=>z(`/api/tasks/${e}`),taskAction:(e,t)=>z(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>z(`/api/setup`),capabilities:()=>z(`/api/capabilities`),workflows:()=>z(`/api/workflows`),workRequest:e=>z(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>z(`/api/skills`),channels:()=>z(`/api/channels`),curators:()=>z(`/api/curators`),channelReload:e=>z(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>z(`/api/config`),version:()=>z(`/api/version`),configUpdate:e=>z(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>z(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>z(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>z(`/api/logs`+ce(e)),taskLogs:(e,t)=>z(`/api/tasks/${e}/logs`+ce(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>z(`/api/captures`+ce({limit:e})),mappings:()=>z(`/api/mappings`),mappingCreate:e=>z(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>z(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>z(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>z(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>z(`/api/bindings`),bindingCreate:e=>z(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>z(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>z(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>z(`/api/bindings/${e}/approve`,{method:`POST`}),memory:()=>z(`/api/memory`),chatSessions:()=>z(`/api/chat/sessions`),chatMessages:e=>z(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>z(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>z(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>z(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:oe(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>z(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>z(`/api/chat/update`),chatUpdateDefer:e=>z(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>z(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>z(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>z(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>z(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>fe(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function V(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function pe(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function me(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var he=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],ge=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm:`Reject "{title}"? This closes the forge issue.`},{id:`retry`,label:`Retry`,kind:`primary`},{id:`abandon`,label:`Abandon`,kind:`quiet`,confirm:`ALine truncated
|
||||
(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),I(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,te(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function k(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y=r&&r.__k||h,b=t.length;for(c=A(n,t,y,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&y[p.__i]||m,p.__i=d,v=I(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ne(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),4&p.__u?(c=j(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=M(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),z(s,s));return r}function j(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=j(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=w(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function N(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function P(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||N(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||N(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function F(e){return function(n){if(this.l){var r=thiLine truncated
|
||||
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var se=class extends Error{constructor(e,t){super(e),this.status=t}};function ce(e){let t=e instanceof se?e.status:void 0,n=e?.message||`Action failed`;return t===401?{kind:`session-expired`,message:n}:t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function le(e,t){let n=await fetch(e,t);if(!n.ok)throw new se(await oe(n),n.status);return n}async function H(e,{method:t=`GET`,body:n,timeoutMs:r=ae,parse:i=!0}={}){let a={Accept:`application/json`},o={method:t,headers:a,signal:AbortSignal.timeout(r)};t!==`GET`&&(a[`Content-Type`]=`application/json`,a[`X-Archie-CSRF`]=`1`),n!==void 0&&(o.body=JSON.stringify(n));let s=await le(e,o);return i?s.json():void 0}var U={summary:()=>H(`/api/summary`),tasks:()=>H(`/api/tasks`),taskMeta:()=>H(`/api/task-meta`),task:e=>H(`/api/tasks/${e}`),taskAttempts:e=>H(`/api/tasks/${e}/attempts`),taskChanges:(e,t)=>H(`/api/tasks/${e}/changes`+V(t)),taskDebug:(e,t)=>H(`/api/tasks/${e}/debug`+V(t)),taskAction:(e,t)=>H(`/api/tasks/${e}/action`,{method:`POST`,body:{action:t}}),setup:()=>H(`/api/setup`),capabilities:()=>H(`/api/capabilities`),workflows:()=>H(`/api/workflows`),workRequest:e=>H(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>H(`/api/skills`),channels:()=>H(`/api/channels`),curators:()=>H(`/api/curators`),channelReload:e=>H(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>H(`/api/config`),version:()=>H(`/api/version`),configUpdate:e=>H(`/api/config`,{method:`PATCH`,body:{updates:e}}),configRepoUpdate:(e,t,n,r)=>H(`/api/config/repos/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`PATCH`,body:{field:n,value:r}}),configReset:e=>H(`/api/config/reset`,{method:`POST`,body:{key:e}}),logs:e=>H(`/api/logs`+V(e)),taskLogs:(e,t)=>H(`/api/tasks/${e}/logs`+V(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${e}/logs/download`+(t==null?``:`?attempt=${t}`),captures:e=>H(`/api/captures`+V({limit:e})),mappings:()=>H(`/api/mappings`),mappingCreate:e=>H(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>H(`/api/mappings/${e}`,{method:`PATCH`,body:t}),mappingDelete:e=>H(`/api/mappings/${e}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>H(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>H(`/api/bindings`),bindingCreate:e=>H(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>H(`/api/bindings/${e}`,{method:`PATCH`,body:t}),bindingDelete:e=>H(`/api/bindings/${e}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>H(`/api/bindings/${e}/approve`,{method:`POST`}),memory:()=>H(`/api/memory`),chatSessions:()=>H(`/api/chat/sessions`),chatMessages:e=>H(`/api/chat/sessions/${encodeURIComponent(e)}/messages`),chatTurns:e=>H(`/api/chat/sessions/${encodeURIComponent(e)}/turns`),chatCancel:e=>H(`/api/chat/cancel`,{method:`POST`,body:{session_id:e}}),chatMessage:(e,t)=>H(`/api/chat/message`,{method:`POST`,body:{channel_id:e,source_id:ie(),text:t,page:location.hash.slice(1)||`/`}}),chatPersona:(e,t)=>H(`/api/chat/persona`,{method:`POST`,body:{session_id:e,name:t}}),chatUpdate:()=>H(`/api/chat/update`),chatUpdateDefer:e=>H(`/api/chat/update/defer`,{method:`POST`,body:{snapshot:e}}),chatUpdateInstall:e=>H(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:12e4}),chatDangerous:()=>H(`/api/chat/dangerous`),chatDangerousRequest:(e,t)=>H(`/api/chat/dangerous/${encodeURIComponent(e)}`,{method:`POST`,body:{spec:t}}),chatDangerousDecision:(e,t)=>H(`/api/chat/dangerous/${encodeURIComponent(e)}/decision`,{method:`POST`,body:{decision:t}}),chatStream:(e,{signal:t}={})=>le(`/api/chat/stream`,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`,"X-Archie-CSRF":`1`},body:JSON.stringify(e),signal:t})};function ue(e,t){let n=new EventSource(`/events`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function de(e,t){let n=new EventSource(`/api/logs/stream`);return n.onopen=()=>t?.(`live`),n.onerror=()=>t?.(`reconnecting`),n.onmessage=t=>{try{e(JSON.parse(t.data))}catch{}},()=>n.close()}function fe(e,t){return e?t.filter(t=>t.section&&e[t.section]===!1).map(e=>e.path):[]}var pe=[{id:`queued`,label:`Queued`,kind:`idle`},{id:`running`,label:`Working`,kind:`info`},{id:`waiting_human`,label:`Waiting for you`,kind:`warn`,needs_you:!0},{id:`pr_open`,label:`In review`,kind:`ok`},{id:`merged`,label:`Merged`,kind:`ok`},{id:`parked`,label:`Parked`,kind:`warn`,needs_you:!0},{id:`dead`,label:`Stopped (too many retries)`,kind:`danger`},{id:`rejected`,label:`Rejected`,kind:`danger`},{id:`closed_wont_do`,label:`Won't do`,kind:`idle`}],me=[{id:`cancel`,label:`Cancel`,kind:`quiet`,confirm:`Cancel "{title}"? This closes the forge issue.`},{id:`stop`,label:`Stop`,kind:`primary`,confirm:`Stop "{title}"? Recoverable work will remain parked.`},{id:`approve`,label:`Approve`,kind:`primary`},{id:`reject`,label:`Reject`,kind:`quiet`,confirm
Line truncated
|
||||
<path d="${c(150,240)}" fill="none" stroke="var(--border)"
|
||||
stroke-width="12" stroke-linecap="round"/>
|
||||
<path d="${c(150,240)}" fill="none" stroke="${i}"
|
||||
stroke-width="12" stroke-linecap="round"
|
||||
stroke-dasharray="${s}"
|
||||
stroke-dashoffset="${s*(1-r/100)}"
|
||||
class="gauge-value"/>`,U(`div.gauge-wrap`,l,U(`div.gauge-center`,U(`div.gauge-pct`,`${Math.round(r)}%`),U(`div.gauge-label`,t)))}function et(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return U(`div`,U(`div.segbar`,...e.filter(e=>e.value>0).map(e=>U(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),U(`div.segbar-legend`,...e.map(e=>U(`span.segbar-key`,U(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var tt=0;Array.isArray;function X(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--tt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function Z({text:e,kind:t=`idle`}){return X(`span`,{className:`pill pill-${t}`,children:e})}var nt=`archie.setup-complete.dismissed.v1`;function rt(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(nt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function it(e=globalThis.localStorage){e?.setItem?.(nt,`1`)}var at=new Set([`waiting_human`,`parked`]);function ot(e=[]){let t=e.filter(e=>at.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function st({node:e}){let t=Y();return J(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function ct(e){return X(st,{node:Ze(e)})}function lt(e){return X(st,{node:$e(e)})}function ut({segments:e}){return X(st,{node:et(e)})}function dt({name:e,opts:t}){return X(st,{node:W(e,t)})}function ft({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function pt(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function mt(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function ht(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function gt(){let[e,t]=q([]),[n,r]=q(`connecting`),[i,a]=q(`idle`),[o,s]=q(new Map),[c,l]=q(null),[u,d]=q(null),[f,p]=q(null),[m,h]=q(null),[g,_]=q(null),[,v]=q(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([B.summary(),B.setup().catch(()=>null),B.workflows().catch(()=>null),B.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};J(()=>(y(),V(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{it(),v(e=>!e)},x=u?.operator?`${mt()}, ${u.operator}`:mt(),C=null;if(g)C=X(`button`,{className:`btn btn-primary`,onClick:y,children:[X(dt,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(m!==null){let e=ot(m),t=e.attention.count,n=e.running.count;C=X(S,{children:[t>0&&X(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[X(dt,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&X(`a`,{className:`btn`,href:e.running.href,children:[X(dt,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),X(`a`,{className:`btn`,href:`#/logs`,children:[X(dt,{name:`logs`,opts:{size:15}}),` Logs`]}),X(`button`,{className:`btn btn-primary`,onClick:y,children:[X(dt,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let w=null;if(g)w=X(`div`,{className:`card`,children:X(ft,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=X(S,{children:[X(ct,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),X(ct,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),X(ct,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),X(ct,{label:`Tokens used`,value:Oe(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:ht(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=rt(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=X(`div`,{className:`card setup`,children:[X(`div`,{className:`card-head`,children:
Line truncated
|
||||
`),children:[X(`td`,{className:`strong`,children:e.label||e.id}),X(`td`,{className:`mono`,children:e.install_type||`—`}),X(`td`,{className:`mono`,children:e.running_version||`—`}),X(`td`,{className:`mono`,children:e.latest_available||`—`}),X(`td`,{children:X(Z,{text:mn[e.status]||e.status,kind:hn[e.status]||`idle`})})]},e.id||e.label))})]})})})}function Q({title:e,detail:t}){return X(`div`,{className:`empty`,children:[X(`div`,{className:`empty-title`,children:e}),t&&X(`div`,{children:t})]})}function $({title:e,sub:t,children:n}){return X(`div`,{className:`card cfg-section`,children:[X(`div`,{className:`card-head`,children:X(`div`,{children:[X(`h2`,{className:`card-title`,children:e}),X(`p`,{className:`card-sub`,children:t})]})}),n]})}function _n({origins:e}){return e?.length?X($,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:X(`div`,{className:`kv-list`,children:e.map((e,t)=>X(un,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):X($,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:X(Q,{title:`Source provenance is unavailable.`})})}function vn(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function yn({data:e,error:t}){if(t)return X($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:X(Q,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return X($,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[X(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?X(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??xe(e.id),n=e.kind??Se(e.id);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(Z,{text:t,kind:n})})]},e.id)})}):X(Q,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),X(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?X(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=vn(e.kind);return X(`div`,{className:`kv`,children:[X(`span`,{className:`kv-label`,children:e.id}),X(`span`,{className:`kv-value`,children:X(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):X(Q,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function bn({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=q(!1),[o,s]=q(null),[c,l]=q(!!e[t]);return r?X(`td`,{children:[X(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await B.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{children:c?`yes`:`no`})}function xn({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=q(String(e[t]??0)),[o,s]=q(null),[c,l]=q(!1);return r?X(`td`,{children:[X(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await B.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&X(`span`,{className:`kv-note is-error`,children:o})]}):X(`td`,{className:`mono`,children:i})}function Sn({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return X($,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:X(Q,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return X($,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:X(`div`,{className:`table-scroll`,children:X(`table`,{className:`table`,children:[X(`thead`,{children:X(`tr`,{children:[X(`th`,{children:`Repository`}),X(`th`,{children:`Base branch`}),X(`th`,{children:`Ecosystem`}),X(`th`,{children:`Quality gate`}),X(`th`,{children:`Protected paths`}),X(`th`,{children:`Concurrent`}),X(`th`,{children:`Max retries`}),X(`th`,{children:`Self-review`})]})}),X(`tbody`,{children:e.map((e,i)=>X(`tr`,{children:[X(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),X(`td`,{className:`mono`,children:e.base}),X(`td`,{children:e.ecosystem||`go`}),X(`td`,{className:`mono`,children:r(e.gate)}),X(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),X(bn,{r:e,field:`allow_concuLine truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(U(`p`,pr(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(U(`pre`,U(`code`,a.join(`
|
||||
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=hr(c),u=e+1<n.length?hr(n[e+1]):null;if(l&&u&&gr(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=hr(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=U(`tbody`);for(let e of r)i.append(U(`tr`,...e.map(e=>U(`td`,pr(e)))));t.append(U(`table`,U(`thead`,U(`tr`,...l.map(e=>U(`th`,pr(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(U(`h${d[1].length}`,pr(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=U(e)),i.append(U(`li`,pr((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(U(`blockquote`,pr(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(U(`pre`,U(`code`,a.join(`
|
||||
`)))),t}function hr(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function gr(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var _r=`archie.web.chat.channel`;function vr(){let e=localStorage.getItem(_r);return e||(e=oe(),localStorage.setItem(_r,e)),e}function yr(e){return{text:e,sourceID:oe()}}function br(e){return{...e}}function xr(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?br(e.turn):yr(r),isRetry:n}}function Sr(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function Cr(e){return e?.status===501?null:`Could not check for updates.`}function wr(){return location.hash.slice(1)||`/`}function Tr({text:e}){let t=Y(null);return J(()=>{t.current&&t.current.replaceChildren(mr(e||``))},[e]),X(`div`,{ref:t,style:{display:`contents`}})}function Er(){let[e,t]=q([]),[n,r]=q(``),[i,a]=q([]),[o,s]=q(``),[c,l]=q(`Ready`),[u,d]=q(!1),[f,p]=q({}),[m,h]=q(``),[g,_]=q(``),[v,y]=q(``),[b,x]=q([]),[C,w]=q([]),[T,E]=q(0),[D,O]=q(!1),[k,A]=q(null),[j,ee]=q(null),[M,N]=q(null),[P,te]=q(``),[ne,re]=q(``),[F,I]=q(null),L=Y(null),R=Y(null),ie=Y(null),ae=Y(null),oe=Y(null),se=Y(u);se.current=u,J(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[i,F]),J(()=>{V().catch(e=>{l(e.message||`Chat unavailable`)}),ce();let e=()=>{ie.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),ie.current?.abort()}},[]);async function ce(){try{let e=await B.chatUpdate();ee(e?.snapshot||null),A(e)}catch(e){let t=Cr(e);A(t?{error:t}:null)}}async function le(){if(j)try{await B.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function ue(){if(j)try{l(`Installing…`);let e=await B.chatUpdateInstall(j);ee(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function de(){try{let e=await B.chatDangerous();N(e)}catch(e){N({error:e.message||`Dangerous actions unavailable`})}}async function fe(e,t){if(t)try{await B.chatDangerousRequest(e,t),l(`Approval requested`),await de()}catch(e){l(e.message||`Could not request action`)}}async function z(e,t){try{await B.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await de()}catch(e){l(e.message||`Approval failed`)}}async function V(){let e=await B.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await de(),!n&&r[0]&&await pe(r[0].session_id,e,r)}async function pe(e,t,n){let i=t||f;r(e),a([]),I(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await B.chatMessage(vr(),`/resume ${e}`);let[t,n]=await Promise.all([B.chatMessages(e),B.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function me(e){if(n)try{l(`Working…`);let t=await B.chatMessage(vr(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await V(),(t.session_id||n)&&await pe(t.session_id||n),ae.current&&(ae.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function he(e,t){let n=window.prompt(t);n?.trim()&&me(`${e} ${n.trim()}`)}function ge(e){let t=e.target.value;h(t),!(!n||!t)&&B.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function _e(e){let t=e.target.value;if(_(t),t)try{let e=await B.chatMessage(vr(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await V()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function ve(e){let t=e.target.value;if(y(t),t)try{let e=await B.chatMessage(vr(),`/model ${t}`);l(e.reply||`Model updated`),await V()}catch(e){l(`Model update failed: ${e.message||e}`)}}function ye(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),H({textOverride:`/restart`}))}function be(){s(`/new`),H({textOverride:`/new`})}function xe(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function Se(e){let t=C[e];if(!t||!R.current)return;let n=R.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.search
Line truncated
|
||||
class="gauge-value"/>`,W(`div.gauge-wrap`,l,W(`div.gauge-center`,W(`div.gauge-pct`,`${Math.round(r)}%`),W(`div.gauge-label`,t)))}function $e(e){let t=e.reduce((e,t)=>e+(t.value||0),0)||1;return W(`div`,W(`div.segbar`,...e.filter(e=>e.value>0).map(e=>W(`span`,{class:`segbar-part segbar-${e.kind||`idle`}`,style:`width:${(e.value/t*100).toFixed(1)}%`,title:`${e.label}: ${e.value}`}))),W(`div.segbar-legend`,...e.map(e=>W(`span.segbar-key`,W(`span`,{class:`segbar-dot segbar-${e.kind||`idle`}`}),e.label))))}var et=0;Array.isArray;function Z(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--et,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function Q({text:e,kind:t=`idle`}){return Z(`span`,{className:`pill pill-${t}`,children:e})}var tt=`archie.setup-complete.dismissed.v1`;function nt(e,t=globalThis.localStorage){if(!e?.steps?.length)return{kind:`omit`,remaining:[]};let n=e.steps.filter(e=>!e.done);return n.length?(t?.removeItem?.(tt),{kind:`incomplete`,remaining:n}):t?.getItem?.(`archie.setup-complete.dismissed.v1`)===`1`?{kind:`dismissed`,remaining:[]}:{kind:`complete`,remaining:[]}}function rt(e=globalThis.localStorage){e?.setItem?.(tt,`1`)}var it=new Set([`waiting_human`,`parked`]);function at(e=[]){let t=e.filter(e=>it.has(e.status)),n=e.filter(e=>e.status===`running`);return{attention:{count:t.length,href:t.length===1?`#/tasks?task=${encodeURIComponent(t[0].id)}`:`#/tasks?status=needs_you`},running:{count:n.length,href:`#/tasks?status=running`}}}function ot({node:e}){let t=X();return Y(()=>{t.current&&e&&t.current.replaceChildren(e)},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function st(e){return Z(ot,{node:Xe(e)})}function ct(e){return Z(ot,{node:Qe(e)})}function lt({segments:e}){return Z(ot,{node:$e(e)})}function ut({name:e,opts:t}){return Z(ot,{node:G(e,t)})}function dt({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function ft(e,t){return Number(e.task_id)>0?Number(e.task_id):!e.repo||!e.issue?0:Number(t.get(`${e.repo}#${e.issue}`))||0}function pt(){let e=new Date().getHours();return e<5?`Still up?`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`}function mt(e){if(e.length<4)return null;let t=Math.floor(e.length/2),n=e.slice(0,t).reduce((e,t)=>e+t,0),r=e.slice(t).reduce((e,t)=>e+t,0);return n?(r-n)/n*100:null}function ht(){let[e,t]=J([]),[n,r]=J(`connecting`),[i,a]=J(`idle`),[o,s]=J(new Map),[c,l]=J(null),[u,d]=J(null),[f,p]=J(null),[m,h]=J(null),[g,_]=J(null),[,v]=J(!1),y=async()=>{_(null);try{let[e,t,n,r]=await Promise.all([U.summary(),U.setup().catch(()=>null),U.workflows().catch(()=>null),U.tasks().catch(()=>[])]),i=new Map;for(let e of r)e.owner&&e.repo&&e.issue_number&&i.set(`${e.owner}/${e.repo}#${e.issue_number}`,e.id);s(i),l(e),d(t),p(n),h(r)}catch(e){_(String(e.message||e))}};Y(()=>(y(),ue(e=>{t(t=>{let n=[e,...t];return n.splice(50),n})},e=>{r(e),a(e===`live`?`ok`:`warn`)})),[]);let b=()=>{rt(),v(e=>!e)},x=u?.operator?`${pt()}, ${u.operator}`:pt(),C=null;if(g)C=Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ut,{name:`refresh`,opts:{size:15}}),` Retry`]});else if(m!==null){let e=at(m),t=e.attention.count,n=e.running.count;C=Z(S,{children:[t>0&&Z(`a`,{className:`btn btn-attention`,href:e.attention.href,children:[Z(ut,{name:`tasks`,opts:{size:15}}),` `,t,` need`,t===1?`s`:``,` you`]}),n>0&&Z(`a`,{className:`btn`,href:e.running.href,children:[Z(ut,{name:`workflows`,opts:{size:15}}),` `,n,` running`]}),Z(`a`,{className:`btn`,href:`#/logs`,children:[Z(ut,{name:`logs`,opts:{size:15}}),` Logs`]}),Z(`button`,{className:`btn btn-primary`,onClick:y,children:[Z(ut,{name:`refresh`,opts:{size:15}}),` Refresh`]})]})}let w=null;if(g)w=Z(`div`,{className:`card`,children:Z(dt,{title:`Cannot reach archied`,detail:g})});else if(c){let e=c?.statuses||{},t=(e.merged||0)+(e.pr_open||0),n=(e.parked||0)+(e.waiting_human||0),r=Object.values(e).reduce((e,t)=>e+t,0),i=c?.tokens_by_day||[];w=Z(S,{children:[Z(st,{label:`Working now`,value:e.running||0,compare:`${e.queued||0} waiting to start`,series:i.map(e=>e.tokens||0)}),Z(st,{label:`Needs you`,value:n,compare:n?`Parked or awaiting a reply`:`Nothing is blocked`,goodDirection:`down`}),Z(st,{label:`Delivered`,value:t,compare:r?`${Math.round(t/r*100)}% of all tasks`:`No tasks yet`}),Z(st,{label:`Tokens used`,value:De(i.reduce((e,t)=>e+(t.tokens||0),0)),compare:`Across ${i.length||0} days`,trend:mt(i.map(e=>e.tokens||0)),goodDirection:`down`,series:i.map(e=>e.tokens||0)})]})}let T=null,E=nt(u),D=E.kind===`omit`||E.kind===`dismissed`;if(!D){let e=E.remaining;if(e.length){let t=Math.round((u.steps.length-e.length)/u.steps.length*100);T=Z(`div`,{className:`card setup`,children:[Z(`div`,{className:`card-head`,children
Line truncated
|
||||
`),children:[Z(`td`,{className:`strong`,children:e.label||e.id}),Z(`td`,{className:`mono`,children:e.install_type||`—`}),Z(`td`,{className:`mono`,children:e.running_version||`—`}),Z(`td`,{className:`mono`,children:e.latest_available||`—`}),Z(`td`,{children:Z(Q,{text:rr[e.status]||e.status,kind:ir[e.status]||`idle`})})]},e.id||e.label))})]})})})}function $({title:e,detail:t}){return Z(`div`,{className:`empty`,children:[Z(`div`,{className:`empty-title`,children:e}),t&&Z(`div`,{children:t})]})}function or({title:e,sub:t,children:n}){return Z(`div`,{className:`card cfg-section`,children:[Z(`div`,{className:`card-head`,children:Z(`div`,{children:[Z(`h2`,{className:`card-title`,children:e}),Z(`p`,{className:`card-sub`,children:t})]})}),n]})}function sr({origins:e}){return e?.length?Z(or,{title:`Configuration sources`,sub:`Applied from top to bottom; later entries take precedence over earlier ones.`,children:Z(`div`,{className:`kv-list`,children:e.map((e,t)=>Z($n,{label:`${e.layer} ${e.role}${e.feature?` (${e.feature})`:``}`,value:e.path},t))})}):Z(or,{title:`Configuration sources`,sub:`The files that supplied the running configuration.`,children:Z($,{title:`Source provenance is unavailable.`})})}function cr(e){return e===`quiet`?`btn-quiet`:e===`danger`?`btn-danger`:``}function lr({data:e,error:t}){if(t)return Z(or,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships.`,children:Z($,{title:`Lifecycle unavailable`,detail:t})});let n=e?.statuses||[],r=e?.actions||[];return Z(or,{title:`Work lifecycle`,sub:`The task statuses and operator actions archied ships. Add one on the backend and it appears here without a frontend change.`,children:[Z(`h3`,{className:`cfg-subhead`,children:`Statuses`}),n.length?Z(`div`,{className:`kv-list`,children:n.map(e=>{let t=e.label??ye(e.id),n=e.kind??be(e.id);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(Q,{text:t,kind:n})})]},e.id)})}):Z($,{title:`No statuses reported`,detail:`The server did not return any lifecycle statuses.`}),Z(`h3`,{className:`cfg-subhead`,children:`Actions`}),r.length?Z(`div`,{className:`kv-list`,children:r.map(e=>{let t=e.label??e.id,n=cr(e.kind);return Z(`div`,{className:`kv`,children:[Z(`span`,{className:`kv-label`,children:e.id}),Z(`span`,{className:`kv-value`,children:Z(`button`,{className:`btn btn-small ${n}`,type:`button`,disabled:!0,children:t})})]},e.id)})}):Z($,{title:`No actions reported`,detail:`The server did not return any operator actions.`})]})}function ur({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=J(!1),[o,s]=J(null),[c,l]=J(!!e[t]);return r?Z(`td`,{children:[Z(`input`,{className:`repo-field-checkbox`,type:`checkbox`,checked:c,onChange:async r=>{let i=r.target.checked;l(i),a(!0),s(null);try{await U.configRepoUpdate(e.owner,e.name,t,i),n?.()}catch(e){l(!i),s(String(e.message||e))}finally{a(!1)}},disabled:i}),o&&Z(`span`,{className:`kv-note is-error`,children:o})]}):Z(`td`,{children:c?`yes`:`no`})}function dr({r:e,field:t,onSaved:n,editable:r=!0}){let[i,a]=J(String(e[t]??0)),[o,s]=J(null),[c,l]=J(!1);return r?Z(`td`,{children:[Z(`input`,{className:`kv-input`,type:`text`,value:i,onChange:e=>a(e.target.value),onBlur:async()=>{let r=parseInt(i,10);if(Number.isNaN(r)){s(`Enter a whole number`);return}l(!0),s(null);try{await U.configRepoUpdate(e.owner,e.name,t,r),n?.()}catch(e){s(String(e.message||e))}finally{l(!1)}},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.target.blur())},disabled:c}),o&&Z(`span`,{className:`kv-note is-error`,children:o})]}):Z(`td`,{className:`mono`,children:i})}function fr({repos:e,onSaved:t,editable:n=!0}){if(!e?.length)return Z(or,{title:`Repositories`,sub:`The repositories Archie polls for work.`,children:Z($,{title:`No repositories configured`,detail:`Add a [[repos]] entry in config.toml so Archie has somewhere to work.`})});let r=e=>e?.length?e.map(e=>e.join(` `)).join(` → `):`—`;return Z(or,{title:`Repositories`,sub:`Each repository Archie polls, and the quality gate a change must pass before it opens a pull request. Concurrent tasks, retries, and self-review are per-repository overrides -- PATCH /api/config/repos/{owner}/{name}, not the file config.toml directly.`,children:Z(`div`,{className:`table-scroll`,children:Z(`table`,{className:`table`,children:[Z(`thead`,{children:Z(`tr`,{children:[Z(`th`,{children:`Repository`}),Z(`th`,{children:`Base branch`}),Z(`th`,{children:`Ecosystem`}),Z(`th`,{children:`Quality gate`}),Z(`th`,{children:`Protected paths`}),Z(`th`,{children:`Concurrent`}),Z(`th`,{children:`Max retries`}),Z(`th`,{children:`Self-review`})]})}),Z(`tbody`,{children:e.map((e,i)=>Z(`tr`,{children:[Z(`td`,{className:`strong`,children:[e.owner,`/`,e.name]}),Z(`td`,{className:`mono`,children:e.base}),Z(`td`,{children:e.ecosystem||`go`}),Z(`td`,{className:`mono`,children:r(e.gate)}),Z(`td`,{className:`mono`,children:e.protect?.length?e.protect.join(`, `):`—`}),Z(ur,{r:e,field:`alloLine truncated
|
||||
`),r=[],i=null,a=null,o=()=>{r.length&&(t.append(W(`p`,ni(r.join(` `)))),r=[])},s=()=>{i&&t.append(i),i=null};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.append(W(`pre`,W(`code`,a.join(`
|
||||
`)))),a=null):a=[];continue}if(a){a.push(c);continue}let l=ii(c),u=e+1<n.length?ii(n[e+1]):null;if(l&&u&&ai(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=ii(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}let i=W(`tbody`);for(let e of r)i.append(W(`tr`,...e.map(e=>W(`td`,ni(e)))));t.append(W(`table`,W(`thead`,W(`tr`,...l.map(e=>W(`th`,ni(e))))),i));continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.append(W(`h${d[1].length}`,ni(d[2])));continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tagName.toLowerCase()!==e)&&(s(),i=W(e)),i.append(W(`li`,ni((f||p)[1])));continue}if(c.startsWith(`>`)){o(),s(),t.append(W(`blockquote`,ni(c.replace(/^>\s?/,``))));continue}r.push(c)}return o(),s(),a&&t.append(W(`pre`,W(`code`,a.join(`
|
||||
`)))),t}function ii(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function ai(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var oi=`archie.web.chat.channel`;function si(){let e=localStorage.getItem(oi);return e||(e=ie(),localStorage.setItem(oi,e)),e}function ci(e){return{text:e,sourceID:ie()}}function li(e){return{...e}}function ui(e,t){let n=!!(e&&typeof e==`object`&&e.turn&&typeof e.turn.text==`string`),r=n?e.turn.text:t.trim();return{text:r,turn:n?li(e.turn):ci(r),isRetry:n}}function di(e){return e.title||e.branch_name||`Conversation ${e.session_id.slice(0,8)}`}function fi(e){return e?.status===501?null:`Could not check for updates.`}function pi(){return location.hash.slice(1)||`/`}function mi({text:e}){let t=X(null);return Y(()=>{t.current&&t.current.replaceChildren(ri(e||``))},[e]),Z(`div`,{ref:t,style:{display:`contents`}})}function hi(){let[e,t]=J([]),[n,r]=J(``),[i,a]=J([]),[o,s]=J(``),[c,l]=J(`Ready`),[u,d]=J(!1),[f,p]=J({}),[m,h]=J(``),[g,_]=J(``),[v,y]=J(``),[b,x]=J([]),[C,w]=J([]),[T,E]=J(0),[D,O]=J(!1),[k,A]=J(null),[j,M]=J(null),[N,P]=J(null),[F,I]=J(``),[ee,te]=J(``),[L,R]=J(null),ne=X(null),z=X(null),B=X(null),re=X(null),ie=X(null),ae=X(u);ae.current=u,Y(()=>{ne.current&&(ne.current.scrollTop=ne.current.scrollHeight)},[i,L]),Y(()=>{ue().catch(e=>{l(e.message||`Chat unavailable`)}),V();let e=()=>{B.current?.abort()};return window.addEventListener(`archie:teardown`,e),()=>{window.removeEventListener(`archie:teardown`,e),B.current?.abort()}},[]);async function V(){try{let e=await U.chatUpdate();M(e?.snapshot||null),A(e)}catch(e){let t=fi(e);A(t?{error:t}:null)}}async function oe(){if(j)try{await U.chatUpdateDefer(j),A({snapshot:{deferred:!0},available:[]}),l(`Update deferred`)}catch(e){l(e.message||`Could not defer update`)}}async function se(){if(j)try{l(`Installing…`);let e=await U.chatUpdateInstall(j);M(null),A({snapshot:{},available:[]}),l(e?.result?.restart_requested?`Update installed; restart queued`:`Update complete`)}catch(e){l(e.message||`Update install failed`)}}async function ce(){try{let e=await U.chatDangerous();P(e)}catch(e){P({error:e.message||`Dangerous actions unavailable`})}}async function le(e,t){if(t)try{await U.chatDangerousRequest(e,t),l(`Approval requested`),await ce()}catch(e){l(e.message||`Could not request action`)}}async function H(e,t){try{await U.chatDangerousDecision(e,t),l(t===`deny`?`Action denied`:`Action approved`),await ce()}catch(e){l(e.message||`Approval failed`)}}async function ue(){let e=await U.chatSessions(),r=e.sessions||[];t(r),p(e),h(e.active_persona||``);let i=e.providers||[],a=e.active_provider||i[0]||``;_(a),y(e.active_model||``);let o=(e.commands||[]).map(e=>typeof e==`string`?{command:e,usage:e,description:``}:e);x(o),e.dangerous_available&&await ce(),!n&&r[0]&&await de(r[0].session_id,e,r)}async function de(e,t,n){let i=t||f;r(e),a([]),R(null);let o=i.active_personas?.[e]||i.active_persona||``;h(o);try{await U.chatMessage(si(),`/resume ${e}`);let[t,n]=await Promise.all([U.chatMessages(e),U.chatTurns(e)]),r=new Map;for(let e of n||[]){let t=e.assistant_message_id||e.AssistantMessageID;t&&r.set(t,e)}let i=(t||[]).map(e=>{let t=e.message_id||e.MessageID,n=r.get(t);return n?{...e,tool_calls:n.tool_calls||n.ToolCalls||[]}:e});a(i)}catch(e){l(e.message||`Could not load session messages`)}}async function fe(e){if(n)try{l(`Working…`);let t=await U.chatMessage(si(),e);t.session_id&&r(t.session_id),l(t.reply||`Session updated`),await ue(),(t.session_id||n)&&await de(t.session_id||n),re.current&&(re.current.open=!1)}catch(e){l(e.message||`Session action failed`)}}function pe(e,t){let n=window.prompt(t);n?.trim()&&fe(`${e} ${n.trim()}`)}function me(e){let t=e.target.value;h(t),!(!n||!t)&&U.chatPersona(n,t).then(()=>{p(e=>({...e,active_personas:{...e.active_personas||{},[n]:t}})),l(`Personality: ${t}`)}).catch(e=>{l(e.message||`Failed to set personality`)})}async function he(e){let t=e.target.value;if(_(t),t)try{let e=await U.chatMessage(si(),`/model --provider ${t}`);l(e.reply||`Provider updated`),await ue()}catch(e){l(`Provider update failed: ${e.message||e}`)}}async function ge(e){let t=e.target.value;if(y(t),t)try{let e=await U.chatMessage(si(),`/model ${t}`);l(e.reply||`Model updated`),await ue()}catch(e){l(`Model update failed: ${e.message||e}`)}}function _e(){window.confirm(`Reload the Telegram chat adapter?`)&&(s(`/restart`),Se({textOverride:`/restart`}))}function ve(){s(`/new`),Se({textOverride:`/new`})}function ye(e){let t=e.target.value;s(t);let n=t.slice(0,e.target.selectionStart).match(/(?:^|\s)\/([^\s]*)$/);if(n){let e=n[1].toLowerCase(),t=b.filter(t=>`${t.command} ${t.description}`.toLowerCase().includes(e)).slice(0,8);if(t.length){w(t),E(0),O(!0);return}}O(!1),w([])}function be(e){let t=C[e];if(!t||!z.current)return;let n=z.current,r=n.value.slice(0,n.selectionStart),i=n.value.slice(n.selectionStart),a=r.sear
Line truncated
|
||||
|
||||
`);o=a.pop()||``;for(let e of a){let t=e.split(`
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,I(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],I(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),I(null),l(`Ready`),await V()}catch(e){if(e.name===`AbortError`&&!m)I({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;I({text:t,tools:u,isError:!0,turn:br(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),ie.current=null,d(!1),R.current&&R.current.focus()}}function we(){l(`Stopping…`),n&&B.chatCancel(n).catch(()=>{}),ie.current?.abort()}let U=f.models_by_provider||{},Te=g&&U[g]?U[g]:f.models||[];return X(`div`,{className:`chat-page-content`,children:[X(`header`,{className:`chat-topbar`,children:[X(`div`,{children:[X(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),X(`h1`,{className:`page-title`,children:`Chat`})]}),X(`div`,{className:`chat-topbar-actions`,children:[X(`span`,{className:`chat-status`,children:c}),f.restart_available&&X(`button`,{className:`btn`,type:`button`,onClick:ye,children:`Reload Telegram`}),X(`button`,{className:`btn`,type:`button`,onClick:ce,children:`Check updates`}),X(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:ge,children:[X(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>X(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&X(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:_e,children:[X(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>X(`option`,{value:e,children:e},e))]}),X(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:ve,children:[X(`option`,{value:``,children:`Model`}),Te.map(e=>X(`option`,{value:e,children:e},e))]})]})]}),k&&X(`div`,{className:`chat-update-panel`,children:k.error?X(`span`,{children:k.error}):k.available?.length?X(S,{children:[X(`div`,{children:[X(`strong`,{children:`Update available`}),X(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:le,children:`Defer`}),k.can_install&&X(`button`,{className:`btn btn-primary`,type:`button`,onClick:ue,children:`Install update`})]})]}):X(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&M&&X(`div`,{className:`chat-dangerous-panel`,children:[X(`div`,{className:`chat-dangerous-head`,children:[X(`strong`,{children:`Dangerous actions`}),X(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),X(`div`,{className:`chat-dangerous-controls`,children:[X(`div`,{children:[X(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:P,onChange:e=>te(e.target.value),children:[X(`option`,{value:``,children:`Select checkpoint`}),(M.checkpoints||[]).map(e=>X(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),X(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`rollback`,P),children:`Request rollback`})]}),X(`div`,{children:[X(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ne,onInput:e=>re(e.target.value)}),X(`button`,{className:`btn`,type:`button`,onClick:()=>fe(`stop`,ne),children:`Request stop`})]})]}),X(`div`,{className:`chat-dangerous-pending-list`,children:(M.pending||[]).length?M.pending.map(e=>X(`div`,{className:`chat-dangerous-pending`,children:[X(`span`,{children:e.description}),X(`div`,{className:`chat-update-actions`,children:[X(`button`,{className:`btn`,type:`button`,onClick:()=>z(e.id,`approve`),children:`Approve`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>z(e.id,`permanent`),children:`Approve for 24h`}),X(`button`,{className:`btn`,type:`button`,onClick:()=>z(e.id,`deny`),children:`Deny`})]})]},e.id)):X(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),X(`div`,{className:`chat-layout`,children:[X(`aside`,{className:`chat-sidebar`,children:[X(`div`,{className:`chat-sidebar-head`,children:[X(`strong`,{children:`Conversations`}),X(`button`,{className:`btn btn-primary`,type:`button`,onClick:be,children:`+ New chat`})]}),X(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>X(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>pe(e.session_id),children:[X(`strong`,{children:Sr(e)}),X(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):X(`div`,{className:`chat-empty`,children:`Your conversations will aLine truncated
|
||||
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&r(n.session_id),n.type===`delta`&&(f+=n.text,R(e=>e?{...e,text:f}:null)),n.type===`tool`&&(u=[...u,n],R(e=>e?{...e,tools:u}:null)),n.type===`navigate`&&(u=[...u,n],R(e=>e?{...e,tools:u}:null)),n.type===`done`&&(p=!0,f||=n.text),n.type===`error`)throw Error(n.text)}if(i)break}if(!p)throw Error(`chat stream ended before completion`);a(e=>[...e,{from:`assistant`,text:f,tool_calls:u}]),R(null),l(`Ready`),await ue()}catch(e){if(e.name===`AbortError`&&!m)R({text:`Turn stopped.`,tools:u,isError:!1,turn:i,isRetry:c}),l(`Stopped`);else{let t=`Unable to complete that turn: ${e.message||e}`;R({text:t,tools:u,isError:!0,turn:li(i),isRetry:c}),l(`Error — retry available`)}}finally{clearTimeout(h),B.current=null,d(!1),z.current&&z.current.focus()}}function Ce(){l(`Stopping…`),n&&U.chatCancel(n).catch(()=>{}),B.current?.abort()}let W=f.models_by_provider||{},we=g&&W[g]?W[g]:f.models||[];return Z(`div`,{className:`chat-page-content`,children:[Z(`header`,{className:`chat-topbar`,children:[Z(`div`,{children:[Z(`span`,{className:`chat-kicker`,children:`ARCHIE WORKSPACE`}),Z(`h1`,{className:`page-title`,children:`Chat`})]}),Z(`div`,{className:`chat-topbar-actions`,children:[Z(`span`,{className:`chat-status`,children:c}),f.restart_available&&Z(`button`,{className:`btn`,type:`button`,onClick:_e,children:`Reload Telegram`}),Z(`button`,{className:`btn`,type:`button`,onClick:V,children:`Check updates`}),Z(`select`,{className:`chat-select`,"aria-label":`Personality`,value:m,onChange:me,children:[Z(`option`,{value:``,children:`Personality`}),(f.personas||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),(f.providers||[]).length>0&&Z(`select`,{className:`chat-select`,"aria-label":`Provider`,value:g,onChange:he,children:[Z(`option`,{value:``,children:`Provider`}),(f.providers||[]).map(e=>Z(`option`,{value:e,children:e},e))]}),Z(`select`,{className:`chat-select`,"aria-label":`Model`,value:v,onChange:ge,children:[Z(`option`,{value:``,children:`Model`}),we.map(e=>Z(`option`,{value:e,children:e},e))]})]})]}),k&&Z(`div`,{className:`chat-update-panel`,children:k.error?Z(`span`,{children:k.error}):k.available?.length?Z(S,{children:[Z(`div`,{children:[Z(`strong`,{children:`Update available`}),Z(`span`,{children:k.available.map(e=>`${e.Label||e.label}: ${e.Available||e.available}`).join(` · `)})]}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:oe,children:`Defer`}),k.can_install&&Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:se,children:`Install update`})]})]}):Z(`span`,{children:k.snapshot?.deferred?`Update deferred.`:`Archie is up to date.`})}),f.dangerous_available&&N&&Z(`div`,{className:`chat-dangerous-panel`,children:[Z(`div`,{className:`chat-dangerous-head`,children:[Z(`strong`,{children:`Dangerous actions`}),Z(`span`,{className:`chat-hint`,children:`Every action requires approval.`})]}),Z(`div`,{className:`chat-dangerous-controls`,children:[Z(`div`,{children:[Z(`select`,{className:`chat-select`,"aria-label":`Checkpoint`,value:F,onChange:e=>I(e.target.value),children:[Z(`option`,{value:``,children:`Select checkpoint`}),(N.checkpoints||[]).map(e=>Z(`option`,{value:e.Number??e.number,children:[e.Number??e.number,` — `,e.Label??e.label??`checkpoint`]},e.Number??e.number))]}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>le(`rollback`,F),children:`Request rollback`})]}),Z(`div`,{children:[Z(`input`,{className:`chat-dangerous-input`,placeholder:`Process name or id`,"aria-label":`Process name or id`,value:ee,onInput:e=>te(e.target.value)}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>le(`stop`,ee),children:`Request stop`})]})]}),Z(`div`,{className:`chat-dangerous-pending-list`,children:(N.pending||[]).length?N.pending.map(e=>Z(`div`,{className:`chat-dangerous-pending`,children:[Z(`span`,{children:e.description}),Z(`div`,{className:`chat-update-actions`,children:[Z(`button`,{className:`btn`,type:`button`,onClick:()=>H(e.id,`approve`),children:`Approve`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>H(e.id,`permanent`),children:`Approve for 24h`}),Z(`button`,{className:`btn`,type:`button`,onClick:()=>H(e.id,`deny`),children:`Deny`})]})]},e.id)):Z(`span`,{className:`chat-hint`,children:`No pending dangerous actions.`})})]}),Z(`div`,{className:`chat-layout`,children:[Z(`aside`,{className:`chat-sidebar`,children:[Z(`div`,{className:`chat-sidebar-head`,children:[Z(`strong`,{children:`Conversations`}),Z(`button`,{className:`btn btn-primary`,type:`button`,onClick:ve,children:`+ New chat`})]}),Z(`div`,{className:`chat-session-list`,children:e.length?e.map(e=>Z(`button`,{className:`chat-session ${n===e.session_id?`active`:``}`,type:`button`,onClick:()=>de(e.session_id),children:[Z(`strong`,{children:di(e)}),Z(`span`,{children:new Date(e.last_active_at).toLocaleString()})]},e.session_id)):Z(`div`,{className:`chat-empty`,children:`Your conversations will appeLine truncated
|
||||
@@ -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"),
|
||||
|
||||
@@ -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":
|
||||
|
||||
@@ -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,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
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -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}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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
@@ -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)} />
|
||||
|
||||
@@ -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 || "" };
|
||||
}
|
||||
@@ -44,6 +44,9 @@ const READS = [
|
||||
["tasks", []],
|
||||
["taskMeta", []],
|
||||
["task", [1]],
|
||||
["taskAttempts", [1]],
|
||||
["taskChanges", [1, { attempt: 2 }]],
|
||||
["taskDebug", [1, { attempt: 2 }]],
|
||||
["setup", []],
|
||||
["capabilities", []],
|
||||
["workflows", []],
|
||||
@@ -191,6 +194,28 @@ test("a 415 keeps the server's explanation and reads as refused", async () => {
|
||||
);
|
||||
});
|
||||
|
||||
// The run detail page's reads. `qs` drops empty values, so an attempt the page
|
||||
// has not resolved yet must not be sent as an empty string: the server treats an
|
||||
// absent attempt as "the task's current attempt", and `attempt=` would be a
|
||||
// different, malformed request.
|
||||
test("the run detail reads build their URLs with absent filters absent", async () => {
|
||||
stubFetch(okResponse);
|
||||
await api.taskAttempts(42);
|
||||
await api.taskChanges(42, { attempt: 2 });
|
||||
await api.taskDebug(42, { attempt: 0 });
|
||||
await api.taskChanges(42, {});
|
||||
|
||||
assert.deepEqual(
|
||||
calls.map((call) => call.path),
|
||||
[
|
||||
"/api/tasks/42/attempts",
|
||||
"/api/tasks/42/changes?attempt=2",
|
||||
"/api/tasks/42/debug?attempt=0",
|
||||
"/api/tasks/42/changes",
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test("every api method is classified by this suite", () => {
|
||||
const classified = new Set([
|
||||
...MUTATIONS.map(([name]) => name),
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render, cleanup } from "@testing-library/preact";
|
||||
import { AttemptConfig, CONFIG_SCHEMA, selectConfigEvent } from "../src/tasks/attempt-config.jsx";
|
||||
|
||||
const EVENTS = [
|
||||
{
|
||||
kind: "config_captured",
|
||||
attempt: 1,
|
||||
at: "2026-09-18T07:00:00.100Z",
|
||||
stage: "",
|
||||
data: { schema: CONFIG_SCHEMA, document: { BotUser: "archie-attempt-one", Models: { main: "openai/gpt" } } },
|
||||
},
|
||||
{
|
||||
kind: "config_captured",
|
||||
attempt: 2,
|
||||
at: "2026-09-18T07:05:00.100Z",
|
||||
stage: "",
|
||||
data: { schema: CONFIG_SCHEMA, document: { BotUser: "archie-attempt-two", Models: { main: "openai/gpt" } } },
|
||||
},
|
||||
];
|
||||
|
||||
function mount(props) {
|
||||
const { container, unmount } = render(<AttemptConfig {...props} />);
|
||||
return { root: container, unmount };
|
||||
}
|
||||
|
||||
// Selecting by kind alone would show the newest attempt's configuration on
|
||||
// every attempt -- the merge-attempts bug the attempt column exists to prevent.
|
||||
test("the configuration is selected by kind and attempt together", () => {
|
||||
const { root, unmount } = mount({ events: EVENTS, attempt: 1 });
|
||||
assert.match(root.textContent, /archie-attempt-one/);
|
||||
assert.doesNotMatch(root.textContent, /archie-attempt-two/);
|
||||
assert.match(root.textContent, /attempt 1's effective task-runtime configuration/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("an attempt with no config event of its own says so, never another attempt's", () => {
|
||||
const { root, unmount } = mount({ events: EVENTS, attempt: 3 });
|
||||
assert.equal(root.querySelector(".empty-title").textContent, "Not captured for this run");
|
||||
assert.doesNotMatch(root.textContent, /archie-attempt-one|archie-attempt-two/);
|
||||
assert.match(root.textContent, /Nothing here says the run used the defaults/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("the document is passed through verbatim, pretty-printed", () => {
|
||||
const { root, unmount } = mount({ events: EVENTS, attempt: 2 });
|
||||
const json = root.querySelector(".run-json").textContent;
|
||||
assert.match(json, /"BotUser": "archie-attempt-two"/);
|
||||
assert.match(json, /"Models"/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// The page must not imply this document is the whole configuration: it is the
|
||||
// non-secret task-runtime subset.
|
||||
test("the panel states the scope of what was captured", () => {
|
||||
const { root, unmount } = mount({ events: EVENTS, attempt: 1 });
|
||||
assert.match(root.textContent, /non-secret subset/);
|
||||
assert.match(root.textContent, /not the dashboard configuration view/);
|
||||
assert.match(root.textContent, /providers, repositories, identities, credentials and lock state/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("an unrecognised schema is named and its payload is still shown", () => {
|
||||
const events = [
|
||||
{ kind: "config_captured", attempt: 2, at: "2026-09-18T07:05:00.100Z", data: { schema: "archie/task-config@9", document: { future: true } } },
|
||||
];
|
||||
const { root, unmount } = mount({ events, attempt: 2 });
|
||||
assert.match(root.textContent, /unknown schema \(archie\/task-config@9\)/);
|
||||
assert.match(root.querySelector(".run-json").textContent, /"future": true/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("a config event with no data at all renders the raw payload rather than guessing", () => {
|
||||
const events = [{ kind: "config_captured", attempt: 2, at: "2026-09-18T07:05:00.100Z" }];
|
||||
const { root, unmount } = mount({ events, attempt: 2 });
|
||||
assert.match(root.textContent, /unknown schema/);
|
||||
assert.ok(root.querySelector(".run-json"));
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("loading and failure states are distinct, and the failure offers a retry", () => {
|
||||
const loading = mount({ events: undefined, attempt: 1 });
|
||||
assert.match(loading.root.textContent, /Loading this task's events/);
|
||||
loading.unmount();
|
||||
|
||||
const failed = mount({ events: null, attempt: 1, onRetry: () => {} });
|
||||
assert.match(failed.root.textContent, /Could not load this task's events/);
|
||||
assert.equal(failed.root.querySelector("button").textContent, "Retry");
|
||||
failed.unmount();
|
||||
});
|
||||
|
||||
test("selectConfigEvent ignores other kinds and other attempts", () => {
|
||||
const events = [
|
||||
{ kind: "stage_finish", attempt: 2, data: {} },
|
||||
...EVENTS,
|
||||
];
|
||||
assert.equal(selectConfigEvent(events, 2).attempt, 2);
|
||||
assert.equal(selectConfigEvent(events, 3), null);
|
||||
assert.equal(selectConfigEvent(undefined, 1), null);
|
||||
});
|
||||
|
||||
// CONFIG_SCHEMA mirrors events.ConfigCapturedSchema (internal/events/events.go),
|
||||
// which the Go suite pins by the same literal. Pinning both sides is what makes
|
||||
// a one-sided rename a failing test rather than every attempt rendering as
|
||||
// "unknown schema".
|
||||
test("the config schema is the one the producer stamps", () => {
|
||||
assert.equal(CONFIG_SCHEMA, "archie/task-config@1");
|
||||
});
|
||||
|
||||
test.after(() => cleanup());
|
||||
@@ -0,0 +1,169 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render, cleanup } from "@testing-library/preact";
|
||||
import { ChangedFiles, fileStatusLabel } from "../src/tasks/changed-files.jsx";
|
||||
|
||||
const CAPTURE = {
|
||||
captured_at: "2026-09-18T07:03:00.000Z",
|
||||
captured_after: "commit",
|
||||
stage: "commit",
|
||||
owner: "o",
|
||||
repo: "r",
|
||||
base: "main",
|
||||
branch: "feat/42-x",
|
||||
head_sha: "abcdef1234567890",
|
||||
base_sha: "0987654321fedcba",
|
||||
pr_number: 7,
|
||||
totals: { files: 3, additions: 40, deletions: 5 },
|
||||
truncated: false,
|
||||
files: [
|
||||
{ path: "internal/x.go", old_path: "", status: "modified", additions: 12, deletions: 3, binary: false },
|
||||
{ path: "bin/app", old_path: "", status: "added", additions: 0, deletions: 0, binary: true },
|
||||
{ path: "internal/new.go", old_path: "internal/old.go", status: "renamed", additions: 1, deletions: 1, binary: false },
|
||||
],
|
||||
};
|
||||
|
||||
const TASK = {
|
||||
id: 42,
|
||||
repo_url: "https://forge.example.internal/o/r",
|
||||
pr_number: 7,
|
||||
pr_url: "https://forge.example.internal/o/r/pull/7",
|
||||
};
|
||||
|
||||
function mount(props) {
|
||||
const { container, unmount } = render(<ChangedFiles {...props} />);
|
||||
return { root: container, unmount };
|
||||
}
|
||||
|
||||
function rowFor(root, path) {
|
||||
return [...root.querySelectorAll(".run-changes-table tbody tr")].find((row) =>
|
||||
row.querySelector(".run-changes-path")?.textContent.includes(path),
|
||||
);
|
||||
}
|
||||
|
||||
// F5: nothing predating the capture has one, and the forge cannot supply one, so
|
||||
// an empty view must not read as "this run changed nothing".
|
||||
test("no capture recorded is not reported as no files changed", () => {
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: false, captures: [] } });
|
||||
assert.equal(root.querySelector(".empty-title").textContent, "No change capture was recorded for this attempt");
|
||||
assert.match(root.textContent, /not the same as "no files changed"/);
|
||||
assert.doesNotMatch(root.textContent, /Nothing changed/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("a capture renders its per-file counts and statuses", () => {
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [CAPTURE] }, task: TASK });
|
||||
const modified = rowFor(root, "internal/x.go");
|
||||
assert.match(modified.textContent, /Modified/);
|
||||
assert.doesNotMatch(modified.textContent, /modified/, "the raw status code must not be shown as a word");
|
||||
assert.match(modified.textContent, /\+12/);
|
||||
assert.equal(root.querySelector(".run-capture-totals").textContent, "3 files · +40 · −5");
|
||||
unmount();
|
||||
});
|
||||
|
||||
// found:true with no readable capture is a READ failure, not "nothing was
|
||||
// captured": the server reports found from the capture event's existence, so
|
||||
// conflating the two tells the operator no capture was recorded when one
|
||||
// demonstrably was.
|
||||
test("a capture that was recorded but could not be read is not reported as missing", () => {
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [] } });
|
||||
assert.match(root.textContent, /could not be read/i);
|
||||
assert.doesNotMatch(root.textContent, /No change capture was recorded/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("a renamed file shows the path it came from", () => {
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [CAPTURE] } });
|
||||
const renamed = rowFor(root, "internal/new.go");
|
||||
assert.match(renamed.textContent, /Renamed/);
|
||||
assert.match(renamed.textContent, /internal\/old\.go → internal\/new\.go/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// A zero-hunk file is "no textual hunks", which is what the capture actually
|
||||
// recorded -- not a claim about the file's type on disk.
|
||||
test("a file with no textual hunks is described that way, not as a binary", () => {
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [CAPTURE] } });
|
||||
const binary = rowFor(root, "bin/app");
|
||||
assert.match(binary.textContent, /no textual hunks/);
|
||||
assert.match(binary.textContent, /Added/);
|
||||
assert.doesNotMatch(binary.textContent, /binary/i);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("a truncated capture says so while still reporting complete totals", () => {
|
||||
const truncated = { ...CAPTURE, truncated: true, totals: { files: 210, additions: 900, deletions: 40 } };
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [truncated] } });
|
||||
assert.match(root.textContent, /Showing the first 3 of 210 files/);
|
||||
assert.match(root.textContent, /210 files · \+900 · −40/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("the capture links to the repository and the pull request", () => {
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [CAPTURE] }, task: TASK });
|
||||
const hrefs = [...root.querySelectorAll("a")].map((a) => a.getAttribute("href"));
|
||||
assert.ok(hrefs.includes("https://forge.example.internal/o/r"));
|
||||
assert.ok(hrefs.includes("https://forge.example.internal/o/r/pull/7"));
|
||||
assert.match(root.textContent, /feat\/42-x → main/);
|
||||
assert.match(root.textContent, /abcdef12/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// A link is only rendered when there is a URL behind it: a capture with no forge
|
||||
// coordinates shows its owner/repo and PR number as text rather than a dead link.
|
||||
test("a capture with no forge URL shows plain text instead of a dead link", () => {
|
||||
const bare = { ...CAPTURE, pr_number: 9 };
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [bare] } });
|
||||
assert.match(root.textContent, /PR #9/);
|
||||
assert.equal(root.querySelectorAll("a").length, 0);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("multiple captures in one attempt all render, oldest first", () => {
|
||||
const second = {
|
||||
...CAPTURE,
|
||||
captured_at: "2026-09-18T07:06:00.000Z",
|
||||
captured_after: "commit-push",
|
||||
stage: "push",
|
||||
};
|
||||
const { root, unmount } = mount({ state: { task_id: 42, attempt: 2, found: true, captures: [CAPTURE, second] } });
|
||||
const heads = [...root.querySelectorAll(".run-capture-when")].map((n) => n.textContent);
|
||||
assert.deepEqual(heads, ["Captured after commit in stage commit", "Captured after commit-push in stage push"]);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("loading and failure states are distinct, and the failure offers a retry", () => {
|
||||
const loading = mount({ state: undefined });
|
||||
assert.match(loading.root.textContent, /Loading changed files/);
|
||||
loading.unmount();
|
||||
|
||||
const failed = mount({ state: null, onRetry: () => {} });
|
||||
assert.match(failed.root.textContent, /Could not load this attempt's changed files/);
|
||||
assert.equal(failed.root.querySelector("button").textContent, "Retry");
|
||||
failed.unmount();
|
||||
});
|
||||
|
||||
test("the status vocabulary is words, and an unknown status is passed through", () => {
|
||||
assert.equal(fileStatusLabel("added"), "Added");
|
||||
assert.equal(fileStatusLabel("typechange"), "Type changed");
|
||||
assert.equal(fileStatusLabel("submodule"), "submodule");
|
||||
});
|
||||
|
||||
// The five statuses are the producer's own vocabulary
|
||||
// (internal/domain/workflow/task/changes.go), pinned by literal in the Go suite.
|
||||
// This pins the dashboard half to the same five strings: without it, a rename on
|
||||
// one side renders raw status codes beside words and both suites stay green.
|
||||
test("the status vocabulary matches the strings the producer persists", () => {
|
||||
const persisted = {
|
||||
added: "Added",
|
||||
modified: "Modified",
|
||||
deleted: "Deleted",
|
||||
renamed: "Renamed",
|
||||
typechange: "Type changed",
|
||||
};
|
||||
for (const [status, label] of Object.entries(persisted)) {
|
||||
assert.equal(fileStatusLabel(status), label, `${status} must be a known status, not passed through`);
|
||||
}
|
||||
});
|
||||
|
||||
test.after(() => cleanup());
|
||||
@@ -0,0 +1,93 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { waitFor } from "@testing-library/preact";
|
||||
|
||||
// The router as the browser actually uses it: main.jsx is imported once (it
|
||||
// starts on import), and every step below navigates by changing the hash and
|
||||
// waiting for the app to follow. This is the only place the wiring between the
|
||||
// route table, the matcher and the navigation highlight is exercised -- the
|
||||
// matcher's own unit tests cannot see whether `show` hands the nav the section
|
||||
// path or the detail path.
|
||||
//
|
||||
// archied is absent on purpose: every request fails, which is itself a state
|
||||
// these pages must render honestly rather than blankly.
|
||||
globalThis.fetch = async () => {
|
||||
throw new Error("no daemon in this test");
|
||||
};
|
||||
|
||||
// jsdom has no EventSource, and the dashboard subscribes to the daemon's event
|
||||
// stream the moment it mounts. An inert stand-in keeps this test about routing
|
||||
// rather than about the stream.
|
||||
class InertEventSource {
|
||||
close() {}
|
||||
}
|
||||
globalThis.EventSource = InertEventSource;
|
||||
|
||||
function navCurrent(path) {
|
||||
return document.querySelector(`a.nav-item[href="#${path}"]`)?.getAttribute("aria-current");
|
||||
}
|
||||
|
||||
function title() {
|
||||
return document.querySelector(".page-title")?.textContent;
|
||||
}
|
||||
|
||||
async function navigate(hash) {
|
||||
location.hash = hash;
|
||||
// jsdom queues its own hashchange for the assignment; waitFor lets it land.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
}
|
||||
|
||||
test("the app routes deep links and keeps the navigation highlight honest", async (t) => {
|
||||
document.body.innerHTML = '<div id="app"></div>';
|
||||
location.hash = "#/tasks/42";
|
||||
await import("../src/main.jsx");
|
||||
await waitFor(() => assert.equal(title(), "Task #42"));
|
||||
|
||||
await t.test("a per-task route renders the run page and keeps Tasks current", () => {
|
||||
assert.equal(title(), "Task #42");
|
||||
assert.ok(document.querySelector(".run-restart"), "the run controls should render");
|
||||
assert.equal(
|
||||
navCurrent("/tasks"),
|
||||
"page",
|
||||
"W9: a detail route must hand the nav its section, or Tasks silently loses aria-current",
|
||||
);
|
||||
});
|
||||
|
||||
await t.test("the tasks list route still works", async () => {
|
||||
await navigate("#/tasks");
|
||||
await waitFor(() => assert.equal(title(), "Tasks"));
|
||||
assert.equal(navCurrent("/tasks"), "page");
|
||||
assert.equal(document.querySelector(".tab-bar"), null, "the run page is no longer mounted");
|
||||
});
|
||||
|
||||
// W10: #/tasks?task=N and #/tasks?status=... are pinned deep links. The steps
|
||||
// below enter this route from the run page on purpose: the query string is an
|
||||
// entry state, so a navigation that only changes the query of the page already
|
||||
// mounted keeps the operator's own filter selection instead.
|
||||
await t.test("a tab and attempt in the query string open that panel", async () => {
|
||||
await navigate("#/tasks/7?tab=log&attempt=1");
|
||||
await waitFor(() => assert.equal(title(), "Task #7"));
|
||||
const selected = [...document.querySelectorAll('[role="tab"]')].find(
|
||||
(tab) => tab.getAttribute("aria-selected") === "true",
|
||||
);
|
||||
assert.equal(selected.textContent, "Log");
|
||||
// The panels read one attempt, and this deployment answered no reads at
|
||||
// all -- so the panel says that rather than claiming there is no attempt.
|
||||
await waitFor(() => assert.match(document.body.textContent, /Could not load this task's attempts/));
|
||||
assert.equal(navCurrent("/tasks"), "page");
|
||||
});
|
||||
|
||||
await t.test("the existing task deep links keep working", async () => {
|
||||
await navigate("#/tasks?task=7&status=needs_you");
|
||||
await waitFor(() => assert.equal(title(), "Tasks"));
|
||||
assert.equal(document.querySelector(".task-filter").value, "needs_you");
|
||||
assert.equal(navCurrent("/tasks"), "page");
|
||||
});
|
||||
|
||||
await t.test("an unmatched path falls back to the dashboard", async () => {
|
||||
await navigate("#/nope/deep");
|
||||
await waitFor(() => assert.ok(document.querySelector(".hero-title"), "the dashboard should render"));
|
||||
assert.equal(document.querySelector(".tab-bar"), null);
|
||||
assert.equal(navCurrent("/"), "page");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,57 @@
|
||||
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), "/");
|
||||
});
|
||||
@@ -0,0 +1,229 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render, cleanup } from "@testing-library/preact";
|
||||
import { StageRail } from "../src/tasks/stage-rail.jsx";
|
||||
|
||||
// The frozen shape of GET /api/tasks/{id}/attempts. Attempt 1 failed on
|
||||
// `implement`; attempt 2 is still running. The attempt-level duration_ms is
|
||||
// present on purpose: the rail must not render it.
|
||||
const ATTEMPTS = {
|
||||
task_id: 42,
|
||||
current_attempt: 2,
|
||||
unattributed_events: 3,
|
||||
attempts: [
|
||||
{
|
||||
attempt: 1,
|
||||
status: "failed",
|
||||
started_at: "2026-09-18T07:00:00.000Z",
|
||||
finished_at: "2026-09-18T07:04:00.000Z",
|
||||
duration_ms: 1_000_000,
|
||||
event_count: 14,
|
||||
stages: [
|
||||
{ name: "prepare", seq: 0, status: "ok", started_at: "2026-09-18T07:00:00.123Z", duration_ms: 1200, error: "" },
|
||||
{
|
||||
name: "implement",
|
||||
seq: 1,
|
||||
status: "failed",
|
||||
started_at: "2026-09-18T07:00:01.323Z",
|
||||
duration_ms: 230000,
|
||||
error: "stage implement: builder exited 1",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
attempt: 2,
|
||||
status: "running",
|
||||
started_at: "2026-09-18T07:05:00.000Z",
|
||||
event_count: 2,
|
||||
stages: [{ name: "analyse", seq: 0, status: "running", started_at: "2026-09-18T07:05:00.000Z" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function mount(props) {
|
||||
const { container, unmount } = render(<StageRail {...props} />);
|
||||
return { root: container, unmount };
|
||||
}
|
||||
|
||||
function stageRow(root, name) {
|
||||
return [...root.querySelectorAll(".run-stage")].find(
|
||||
(row) => row.querySelector(".run-stage-name")?.textContent === name,
|
||||
);
|
||||
}
|
||||
|
||||
test("each stage renders its name, duration and terminal status", () => {
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 1, events: [] });
|
||||
const prepare = stageRow(root, "prepare");
|
||||
assert.ok(prepare, "the prepare stage should render");
|
||||
assert.match(prepare.textContent, /prepare/);
|
||||
assert.match(prepare.textContent, /ok/);
|
||||
assert.match(prepare.textContent, /ran for 1\.2 s/);
|
||||
const implement = stageRow(root, "implement");
|
||||
assert.match(implement.textContent, /ran for 3 min 50 s/);
|
||||
assert.match(implement.textContent, /stage implement: builder exited 1/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// W2: merging attempts by stage name is the failure this whole feature exists to
|
||||
// prevent.
|
||||
test("the rail shows only the selected attempt's stages", () => {
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 1, events: [] });
|
||||
assert.ok(stageRow(root, "prepare"));
|
||||
assert.ok(stageRow(root, "implement"));
|
||||
assert.equal(stageRow(root, "analyse"), undefined, "attempt 2's stages must not appear in attempt 1's rail");
|
||||
assert.match(root.textContent, /Attempt 1/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("an interrupted stage is not labelled failed", () => {
|
||||
const state = {
|
||||
...ATTEMPTS,
|
||||
attempts: [
|
||||
{
|
||||
attempt: 1,
|
||||
status: "interrupted",
|
||||
started_at: "2026-09-18T07:00:00.000Z",
|
||||
stages: [{ name: "implement", seq: 0, status: "interrupted", duration_ms: 4200, error: "context canceled" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
const { root, unmount } = mount({ state, attemptNumber: 1, events: [] });
|
||||
const row = stageRow(root, "implement");
|
||||
assert.match(row.textContent, /interrupted/);
|
||||
assert.doesNotMatch(row.textContent, /failed/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("a stage with no recorded start shows no invented duration", () => {
|
||||
const state = {
|
||||
...ATTEMPTS,
|
||||
attempts: [
|
||||
{
|
||||
attempt: 1,
|
||||
status: "ok",
|
||||
stages: [{ name: "commit", seq: 0, status: "ok" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
const { root, unmount } = mount({ state, attemptNumber: 1, events: [] });
|
||||
const row = stageRow(root, "commit");
|
||||
assert.match(row.textContent, /duration not recorded/);
|
||||
assert.doesNotMatch(row.textContent, /ran for/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// F3: waiting_human can span days, so an attempt's wall time is not a duration
|
||||
// of work and the page must not present it as one.
|
||||
test("the attempt's own duration is never rendered", () => {
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 1, events: [] });
|
||||
assert.doesNotMatch(root.textContent, /ran for 16 min/);
|
||||
assert.doesNotMatch(root.textContent, /1,000,000|1000000/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("events with no attempt are reported rather than guessed at", () => {
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 1, events: [] });
|
||||
assert.match(root.textContent, /3 events on this task predate attempt attribution/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// F1: a stage is `ok` when its function returned without error. There is no
|
||||
// exit code and no verification, and the agent's own verdict is a separate
|
||||
// claim -- neither may be presented as a check result.
|
||||
test("the agent's own verdict is shown separately from the stage's status", () => {
|
||||
const events = [
|
||||
{
|
||||
kind: "agent_finish",
|
||||
attempt: 1,
|
||||
stage: "implement",
|
||||
data: { status: "passed", iterations: 7, tokens: 1234, model: "openai/gpt-5.6-luna" },
|
||||
},
|
||||
];
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 1, events });
|
||||
const row = stageRow(root, "implement");
|
||||
assert.match(row.textContent, /Agent's own report, not verified by archie/);
|
||||
assert.match(row.textContent, /Agent passed: implement/);
|
||||
assert.match(row.textContent, /failed/, "the stage keeps its own terminal status");
|
||||
assert.doesNotMatch(row.textContent, /exit code|exit status/i);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("an agent report for another attempt is not attached to this attempt's stage", () => {
|
||||
const events = [
|
||||
{ kind: "agent_finish", attempt: 2, stage: "implement", data: { status: "passed" } },
|
||||
];
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 1, events });
|
||||
assert.doesNotMatch(root.textContent, /Agent's own report/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("the rail says what ok means instead of implying a gate ran", () => {
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 1, events: [] });
|
||||
assert.match(root.textContent, /ok means the stage returned without error/);
|
||||
assert.match(root.textContent, /does not verify/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("an attempt with no stages says so instead of showing an empty rail", () => {
|
||||
const state = {
|
||||
task_id: 42,
|
||||
current_attempt: 1,
|
||||
unattributed_events: 0,
|
||||
attempts: [{ attempt: 1, status: "unknown", stages: [] }],
|
||||
};
|
||||
const { root, unmount } = mount({ state, attemptNumber: 1, events: [] });
|
||||
assert.match(root.textContent, /No stages recorded for this attempt/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("a task with no attempts says so", () => {
|
||||
const { root, unmount } = mount({
|
||||
state: { task_id: 42, current_attempt: 0, unattributed_events: 0, attempts: [] },
|
||||
attemptNumber: null,
|
||||
events: [],
|
||||
});
|
||||
assert.match(root.textContent, /No attempts recorded/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("a selected attempt that was never recorded is reported, not faked", () => {
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 9, events: [] });
|
||||
assert.match(root.textContent, /Attempt 9 is not recorded for this task/);
|
||||
assert.match(root.textContent, /attempt 1, 2/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// A deployment where every event predates the attempt column answers with no
|
||||
// attempts at all -- but the events are still there, unattributed. The count
|
||||
// must be surfaced in the EMPTY rail too, not only beside a populated one, or
|
||||
// the page presents unattributable history as "nothing happened".
|
||||
test("unattributed events are surfaced even when no attempt is recorded", () => {
|
||||
const { root, unmount } = mount({
|
||||
state: { task_id: 42, current_attempt: 0, unattributed_events: 4, attempts: [] },
|
||||
attemptNumber: null,
|
||||
events: [],
|
||||
});
|
||||
assert.match(root.textContent, /No attempts recorded/);
|
||||
assert.match(root.textContent, /4 events on this task predate attempt attribution/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("unattributed events are surfaced when the selected attempt is not recorded", () => {
|
||||
const { root, unmount } = mount({ state: ATTEMPTS, attemptNumber: 9, events: [] });
|
||||
assert.match(root.textContent, /Attempt 9 is not recorded/);
|
||||
assert.match(root.textContent, /3 events on this task predate attempt attribution/);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("loading and failure states are distinct, and the failure offers a retry", () => {
|
||||
const loading = mount({ state: undefined, attemptNumber: null, events: [] });
|
||||
assert.match(loading.root.textContent, /Loading/);
|
||||
loading.unmount();
|
||||
|
||||
const failed = mount({ state: null, attemptNumber: null, events: [], onRetry: () => {} });
|
||||
assert.match(failed.root.textContent, /Could not load this task's attempts/);
|
||||
assert.equal(failed.root.querySelector("button").textContent, "Retry");
|
||||
failed.unmount();
|
||||
});
|
||||
|
||||
test.after(() => cleanup());
|
||||
@@ -0,0 +1,401 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render, cleanup, fireEvent, waitFor } from "@testing-library/preact";
|
||||
import { api, ApiError } from "../src/base/api.jsx";
|
||||
import { taskDetailPage } from "../src/tasks/task-detail.jsx";
|
||||
|
||||
const CONFIG_SCHEMA = "archie/task-config@1";
|
||||
|
||||
const TASK = {
|
||||
id: 42,
|
||||
title: "Fix the flaky test",
|
||||
status: "parked",
|
||||
owner: "o",
|
||||
repo: "r",
|
||||
workflow: "tdd",
|
||||
attempt: 2,
|
||||
actions: ["retry", "abandon", "reject"],
|
||||
repo_url: "https://forge.example.internal/o/r",
|
||||
issue_url: "https://forge.example.internal/o/r/issues/5",
|
||||
issue_number: 5,
|
||||
pr_number: 7,
|
||||
pr_url: "https://forge.example.internal/o/r/pull/7",
|
||||
};
|
||||
|
||||
const ATTEMPTS = {
|
||||
task_id: 42,
|
||||
current_attempt: 2,
|
||||
unattributed_events: 0,
|
||||
attempts: [
|
||||
{
|
||||
attempt: 1,
|
||||
status: "failed",
|
||||
started_at: "2026-09-18T07:00:00.000Z",
|
||||
finished_at: "2026-09-18T07:04:00.000Z",
|
||||
duration_ms: 240333,
|
||||
event_count: 3,
|
||||
stages: [
|
||||
{ name: "prepare", seq: 0, status: "ok", started_at: "2026-09-18T07:00:00.123Z", duration_ms: 1200, error: "" },
|
||||
{ name: "implement", seq: 1, status: "failed", duration_ms: 230000, error: "stage implement: builder exited 1" },
|
||||
],
|
||||
},
|
||||
{
|
||||
attempt: 2,
|
||||
status: "running",
|
||||
started_at: "2026-09-18T07:05:00.000Z",
|
||||
event_count: 1,
|
||||
stages: [{ name: "analyse", seq: 0, status: "running", started_at: "2026-09-18T07:05:00.000Z" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const EVENTS = [
|
||||
{
|
||||
kind: "config_captured",
|
||||
attempt: 2,
|
||||
at: "2026-09-18T07:05:00.100Z",
|
||||
stage: "",
|
||||
data: { schema: CONFIG_SCHEMA, document: { BotUser: "archie", Models: { main: "openai/gpt" } } },
|
||||
},
|
||||
{ kind: "stage_start", attempt: 2, stage: "analyse", at: "2026-09-18T07:05:00.000Z", data: {} },
|
||||
];
|
||||
|
||||
function install(overrides = {}) {
|
||||
const original = {
|
||||
tasks: api.tasks,
|
||||
task: api.task,
|
||||
taskAttempts: api.taskAttempts,
|
||||
taskLogs: api.taskLogs,
|
||||
taskChanges: api.taskChanges,
|
||||
taskDebug: api.taskDebug,
|
||||
taskAction: api.taskAction,
|
||||
};
|
||||
const calls = { tasks: 0, task: 0, attempts: 0, logs: [], changes: [], debug: [], actions: [] };
|
||||
api.tasks = async () => {
|
||||
calls.tasks += 1;
|
||||
return [TASK];
|
||||
};
|
||||
api.task = async (id) => {
|
||||
calls.task += 1;
|
||||
return EVENTS;
|
||||
};
|
||||
api.taskAttempts = async (id) => {
|
||||
calls.attempts += 1;
|
||||
return ATTEMPTS;
|
||||
};
|
||||
api.taskLogs = async (id, params) => {
|
||||
calls.logs.push(params);
|
||||
return { found: true, attempt: params?.attempt ?? 2, disabled: false, entries: [{ level: "info", msg: "line", time: "2026-09-18T07:05:00Z" }] };
|
||||
};
|
||||
api.taskChanges = async (id, params) => {
|
||||
calls.changes.push(params);
|
||||
return { task_id: 42, attempt: params?.attempt ?? 2, found: false, captures: [] };
|
||||
};
|
||||
api.taskDebug = async (id, params) => {
|
||||
calls.debug.push(params);
|
||||
return { task_id: 42, attempt: params?.attempt ?? 2, task: TASK, events: EVENTS };
|
||||
};
|
||||
api.taskAction = async (id, action) => {
|
||||
calls.actions.push({ id, action });
|
||||
return {};
|
||||
};
|
||||
for (const [key, value] of Object.entries(overrides)) api[key] = value;
|
||||
const restore = () => Object.assign(api, original);
|
||||
return { calls, restore };
|
||||
}
|
||||
|
||||
function mount(queryString, id = "42") {
|
||||
const { container, unmount } = render(
|
||||
taskDetailPage(new URLSearchParams(queryString), { id }),
|
||||
);
|
||||
return { root: container, unmount };
|
||||
}
|
||||
|
||||
test("the page offers every panel as a tab and opens Stages by default", async () => {
|
||||
const { restore } = install();
|
||||
const { root, unmount } = mount("tab=");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages"), "the rail should render"));
|
||||
const tabs = [...root.querySelectorAll('[role="tab"]')].map((tab) => tab.textContent);
|
||||
assert.deepEqual(tabs, ["Stages", "Log", "Changed files", "Configuration", "Debug"]);
|
||||
assert.equal(root.querySelector('[role="tab"]').getAttribute("aria-selected"), "true");
|
||||
// The panel is bound to the selected tab.
|
||||
const panel = root.querySelector('[role="tabpanel"]');
|
||||
assert.equal(panel.getAttribute("aria-labelledby"), root.querySelector('[role="tab"]').id);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("the panel element is the selected tab's panel", () => {
|
||||
const { root, unmount } = mount("tab=changes");
|
||||
const selected = [...root.querySelectorAll('[role="tab"]')].find(
|
||||
(tab) => tab.getAttribute("aria-selected") === "true",
|
||||
);
|
||||
assert.equal(selected.textContent, "Changed files");
|
||||
assert.equal(root.querySelector('[role="tabpanel"]').id, selected.getAttribute("aria-controls"));
|
||||
unmount();
|
||||
});
|
||||
|
||||
// R8: the tabs are deep-linkable, so the query string alone decides which panel
|
||||
// opens -- including on a reload with no client state.
|
||||
test("?tab= decides which panel opens", async () => {
|
||||
const { restore, calls } = install();
|
||||
const { root, unmount } = mount("tab=debug");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-json"), "the debug view should render"));
|
||||
const json = root.querySelector(".run-json").textContent;
|
||||
assert.match(json, /"title": "Fix the flaky test"/);
|
||||
assert.match(json, /"attempt": 2/);
|
||||
assert.match(root.textContent, /Attempt 2 is the one selected above/);
|
||||
assert.deepEqual(calls.debug, [{ attempt: 2 }]);
|
||||
// The debug envelope is only fetched for the visible tab.
|
||||
assert.equal(calls.changes.length, 0);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("the debug view states that its event list is unfiltered", async () => {
|
||||
const { restore } = install();
|
||||
const { root, unmount } = mount("tab=debug");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-json")));
|
||||
assert.match(root.textContent, /Events are unfiltered on purpose/);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("the default attempt is the task's current one", async () => {
|
||||
const { restore } = install();
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages")));
|
||||
assert.match(root.textContent, /Attempt 2/);
|
||||
assert.equal(
|
||||
[...root.querySelectorAll(".run-stage-name")].map((n) => n.textContent).join(","),
|
||||
"analyse",
|
||||
"attempt 1's stages must not appear on the current attempt's rail",
|
||||
);
|
||||
const chips = [...root.querySelectorAll(".run-attempt")];
|
||||
assert.equal(chips.length, 2);
|
||||
assert.equal(chips[1].getAttribute("aria-pressed"), "true");
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("?attempt= pins an earlier attempt and the rail follows it", async () => {
|
||||
const { restore } = install();
|
||||
const { root, unmount } = mount("tab=stages&attempt=1");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages")));
|
||||
assert.deepEqual(
|
||||
[...root.querySelectorAll(".run-stage-name")].map((n) => n.textContent),
|
||||
["prepare", "implement"],
|
||||
);
|
||||
assert.equal(root.querySelectorAll(".run-attempt")[0].getAttribute("aria-pressed"), "true");
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("selecting another attempt re-reads the panels for that attempt", async () => {
|
||||
const { restore } = install();
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages")));
|
||||
fireEvent.click(root.querySelectorAll(".run-attempt")[0]);
|
||||
await waitFor(() =>
|
||||
assert.deepEqual(
|
||||
[...root.querySelectorAll(".run-stage-name")].map((n) => n.textContent),
|
||||
["prepare", "implement"],
|
||||
),
|
||||
);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("the log pane sends the selected attempt and the filters to the server", async () => {
|
||||
const { restore, calls } = install();
|
||||
const { root, unmount } = mount("tab=log&attempt=1");
|
||||
await waitFor(() => assert.ok(root.querySelector(".log-list")));
|
||||
assert.deepEqual(calls.logs, [{ attempt: 1, level: "", stage: "", limit: 500 }]);
|
||||
|
||||
const stageSelect = [...root.querySelectorAll(".task-log-filter select")][1];
|
||||
fireEvent.change(stageSelect, { target: { value: "prepare" } });
|
||||
await waitFor(() => assert.equal(calls.logs.length, 2));
|
||||
assert.deepEqual(calls.logs[1], { attempt: 1, level: "", stage: "prepare", limit: 500 });
|
||||
await waitFor(() => assert.match(root.textContent, /A stage filter matches only log lines that record a stage/));
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
// R4: the Config tab consumes the events response the page already holds, so it
|
||||
// must issue no request of its own.
|
||||
test("the configuration tab reads the captured document from the fetched events", async () => {
|
||||
const { restore, calls } = install();
|
||||
const { root, unmount } = mount("tab=config");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-json")));
|
||||
assert.match(root.querySelector(".run-json").textContent, /"BotUser": "archie"/);
|
||||
assert.equal(calls.task, 1, "the events are fetched once, by the page");
|
||||
assert.equal(calls.changes.length, 0);
|
||||
assert.equal(calls.debug.length, 0);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("the configuration tab says nothing was captured for an attempt with no record", async () => {
|
||||
const { restore } = install();
|
||||
const { root, unmount } = mount("tab=config&attempt=1");
|
||||
await waitFor(() =>
|
||||
assert.equal(root.querySelector(".empty-title").textContent, "Not captured for this run"),
|
||||
);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("changed files are read for the selected attempt and say a capture is missing", async () => {
|
||||
const { restore, calls } = install();
|
||||
const { root, unmount } = mount("tab=changes&attempt=1");
|
||||
await waitFor(() =>
|
||||
assert.equal(root.querySelector(".empty-title").textContent, "No change capture was recorded for this attempt"),
|
||||
);
|
||||
assert.deepEqual(calls.changes, [{ attempt: 1 }]);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
// R6: the control is labelled as a new run, and the copy says what it destroys.
|
||||
test("the new-run control states that the previous attempt's commits are discarded", async () => {
|
||||
const { restore } = install();
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-restart")));
|
||||
const button = root.querySelector(".run-restart button");
|
||||
assert.equal(button.textContent, "Start a new run");
|
||||
assert.match(root.textContent, /The previous attempt's commits are discarded/);
|
||||
assert.match(root.textContent, /fresh worktree reset onto the base branch/);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("a declined confirmation starts no run", async () => {
|
||||
const { restore, calls } = install();
|
||||
const originalConfirm = window.confirm;
|
||||
let asked = "";
|
||||
window.confirm = (text) => {
|
||||
asked = text;
|
||||
return false;
|
||||
};
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-restart button")));
|
||||
fireEvent.click(root.querySelector(".run-restart button"));
|
||||
assert.match(asked, /previous attempt's commits are discarded/);
|
||||
assert.deepEqual(calls.actions, []);
|
||||
unmount();
|
||||
window.confirm = originalConfirm;
|
||||
restore();
|
||||
});
|
||||
|
||||
test("a confirmed new run drops the old attempt's caches and selects the new run", async () => {
|
||||
const NEW_ATTEMPTS = {
|
||||
task_id: 42,
|
||||
current_attempt: 3,
|
||||
unattributed_events: 0,
|
||||
attempts: [
|
||||
...ATTEMPTS.attempts,
|
||||
{ attempt: 3, status: "running", started_at: "2026-09-18T07:09:00.000Z", event_count: 1, stages: [{ name: "bootstrap", seq: 0, status: "ok", duration_ms: 500 }] },
|
||||
],
|
||||
};
|
||||
let attemptReads = 0;
|
||||
const { restore, calls } = install({
|
||||
taskAttempts: async () => {
|
||||
attemptReads += 1;
|
||||
return attemptReads === 1 ? ATTEMPTS : NEW_ATTEMPTS;
|
||||
},
|
||||
});
|
||||
const originalConfirm = window.confirm;
|
||||
window.confirm = () => true;
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages")));
|
||||
fireEvent.click(root.querySelector(".run-restart button"));
|
||||
await waitFor(() => assert.equal(root.querySelectorAll(".run-attempt").length, 3));
|
||||
await waitFor(() =>
|
||||
assert.deepEqual(
|
||||
[...root.querySelectorAll(".run-stage-name")].map((n) => n.textContent),
|
||||
["bootstrap"],
|
||||
"the new run's stages are shown, not the previous attempt's",
|
||||
),
|
||||
);
|
||||
assert.deepEqual(calls.actions, [{ id: 42, action: "retry" }]);
|
||||
assert.equal(root.querySelectorAll(".run-attempt")[2].getAttribute("aria-pressed"), "true");
|
||||
assert.equal(calls.task, 2, "the ended attempt's events are refetched for the new run");
|
||||
unmount();
|
||||
window.confirm = originalConfirm;
|
||||
restore();
|
||||
});
|
||||
|
||||
test("a task outside the listed rows is reported honestly rather than blank", async () => {
|
||||
const { restore } = install({ tasks: async () => [] });
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages")));
|
||||
assert.match(root.textContent, /not among the tasks this dashboard lists/);
|
||||
assert.match(root.textContent, /Debug tab holds the stored record verbatim/);
|
||||
assert.match(root.textContent, /operator controls could not be read/);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("a deployment that lists no tasks for this id still shows the recorded run", async () => {
|
||||
const { restore } = install({ tasks: async () => [] });
|
||||
const { root, unmount } = mount("tab=stages&attempt=1");
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages")));
|
||||
assert.match(root.textContent, /Task #42/);
|
||||
assert.match(root.textContent, /prepare/);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("an unknown task renders an honest failure, not an empty page", async () => {
|
||||
const { restore } = install({
|
||||
taskAttempts: async () => {
|
||||
throw new ApiError("no such task", 404);
|
||||
},
|
||||
});
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.ok(root.querySelector(".page-title")));
|
||||
assert.match(root.querySelector(".page-title").textContent, /Task not found/);
|
||||
assert.match(root.textContent, /No task with id 42/);
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("a non-numeric id is refused without asking the server anything", () => {
|
||||
const { restore, calls } = install();
|
||||
const { root, unmount } = mount("tab=stages", "not-an-id");
|
||||
assert.match(root.textContent, /is not a task id/);
|
||||
assert.deepEqual(calls, { tasks: 0, task: 0, attempts: 0, logs: [], changes: [], debug: [], actions: [] });
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("a task with no attempts says so on every panel", async () => {
|
||||
const { restore } = install({
|
||||
taskAttempts: async () => ({ task_id: 42, current_attempt: 0, unattributed_events: 4, attempts: [] }),
|
||||
});
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.match(root.textContent, /No attempts recorded/));
|
||||
fireEvent.click([...root.querySelectorAll('[role="tab"]')][3]);
|
||||
await waitFor(() => assert.match(root.textContent, /No attempt recorded/));
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test("a failure to load the attempts offers a retry", async () => {
|
||||
let reads = 0;
|
||||
const { restore } = install({
|
||||
taskAttempts: async () => {
|
||||
reads += 1;
|
||||
if (reads === 1) throw new Error("boom");
|
||||
return ATTEMPTS;
|
||||
},
|
||||
});
|
||||
const { root, unmount } = mount("tab=stages");
|
||||
await waitFor(() => assert.match(root.textContent, /Could not load this task's attempts/));
|
||||
fireEvent.click([...root.querySelectorAll(".run-error button")][0]);
|
||||
await waitFor(() => assert.ok(root.querySelector(".run-stages")));
|
||||
unmount();
|
||||
restore();
|
||||
});
|
||||
|
||||
test.after(() => cleanup());
|
||||
+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());
|
||||
@@ -0,0 +1,115 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { render, cleanup, fireEvent } from "@testing-library/preact";
|
||||
import { TabBar, panelId, tabId } from "../src/tasks/tab-bar.jsx";
|
||||
|
||||
const TABS = [
|
||||
{ id: "stages", label: "Stages" },
|
||||
{ id: "log", label: "Log" },
|
||||
{ id: "changes", label: "Changed files" },
|
||||
];
|
||||
|
||||
import { useState } from "preact/hooks";
|
||||
|
||||
function Harness({ initial = "stages", onSelect }) {
|
||||
const [active, setActive] = useState(initial);
|
||||
return (
|
||||
<TabBar
|
||||
tabs={TABS}
|
||||
active={active}
|
||||
onSelect={(id) => {
|
||||
onSelect?.(id);
|
||||
setActive(id);
|
||||
}}
|
||||
prefix="run"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function mount(active = "stages", onSelect) {
|
||||
const { container, unmount } = render(<Harness initial={active} onSelect={onSelect} />);
|
||||
return { root: container, unmount };
|
||||
}
|
||||
|
||||
test("the tab list is a tablist of tabs with the active one selected", () => {
|
||||
const { root, unmount } = mount("log");
|
||||
const list = root.querySelector('[role="tablist"]');
|
||||
assert.ok(list, "a tablist should render");
|
||||
const tabs = [...root.querySelectorAll('[role="tab"]')];
|
||||
assert.equal(tabs.length, 3);
|
||||
assert.equal(tabs[0].getAttribute("aria-selected"), "false");
|
||||
assert.equal(tabs[1].getAttribute("aria-selected"), "true");
|
||||
assert.equal(tabs[0].textContent, "Stages");
|
||||
unmount();
|
||||
});
|
||||
|
||||
// The panel is a separate element in the page, so the relationship has to be
|
||||
// declared explicitly or assistive technology cannot connect them.
|
||||
test("each tab points at the panel it controls", () => {
|
||||
const { root, unmount } = mount("stages");
|
||||
const tabs = [...root.querySelectorAll('[role="tab"]')];
|
||||
const expected = ["stages", "log", "changes"].map((id) => panelId("run", id));
|
||||
assert.deepEqual(tabs.map((tab) => tab.getAttribute("aria-controls")), expected);
|
||||
assert.deepEqual(tabs.map((tab) => tab.id), ["stages", "log", "changes"].map((id) => tabId("run", id)));
|
||||
unmount();
|
||||
});
|
||||
|
||||
// Roving tabindex: the tab list is one stop in the page's tab order, not three.
|
||||
test("only the active tab is in the page tab order", () => {
|
||||
const { root, unmount } = mount("changes");
|
||||
const tabs = [...root.querySelectorAll('[role="tab"]')];
|
||||
assert.deepEqual(tabs.map((tab) => tab.getAttribute("tabindex")), ["-1", "-1", "0"]);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("clicking a tab selects it", () => {
|
||||
const selected = [];
|
||||
const { root, unmount } = mount("stages", (id) => selected.push(id));
|
||||
fireEvent.click(root.querySelectorAll('[role="tab"]')[2]);
|
||||
assert.deepEqual(selected, ["changes"]);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("arrow keys move between tabs, wrap around, and select as they go", () => {
|
||||
const selected = [];
|
||||
const { root, unmount } = mount("stages", (id) => selected.push(id));
|
||||
const first = root.querySelectorAll('[role="tab"]')[0];
|
||||
first.focus();
|
||||
fireEvent.keyDown(first, { key: "ArrowRight" });
|
||||
fireEvent.keyDown(root.querySelectorAll('[role="tab"]')[1], { key: "ArrowRight" });
|
||||
fireEvent.keyDown(root.querySelectorAll('[role="tab"]')[2], { key: "ArrowRight" });
|
||||
assert.deepEqual(selected, ["log", "changes", "stages"], "arrow-right wraps to the first tab");
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("Home and End jump to the ends of the tab list", () => {
|
||||
const selected = [];
|
||||
const { root, unmount } = mount("log", (id) => selected.push(id));
|
||||
const active = root.querySelectorAll('[role="tab"]')[1];
|
||||
fireEvent.keyDown(active, { key: "End" });
|
||||
fireEvent.keyDown(root.querySelectorAll('[role="tab"]')[2], { key: "Home" });
|
||||
assert.deepEqual(selected, ["changes", "stages"]);
|
||||
unmount();
|
||||
});
|
||||
|
||||
// Keyboard focus must follow selection: a roving-tabindex widget that moves the
|
||||
// selection but leaves focus behind loses the keyboard user.
|
||||
test("an arrow key moves keyboard focus with the selection", () => {
|
||||
const { root, unmount } = mount("stages");
|
||||
const first = root.querySelectorAll('[role="tab"]')[0];
|
||||
first.focus();
|
||||
fireEvent.keyDown(first, { key: "ArrowRight" });
|
||||
const tabs = [...root.querySelectorAll('[role="tab"]')];
|
||||
assert.equal(document.activeElement, tabs[1]);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test("an unrelated key does nothing", () => {
|
||||
const selected = [];
|
||||
const { root, unmount } = mount("stages", (id) => selected.push(id));
|
||||
fireEvent.keyDown(root.querySelectorAll('[role="tab"]')[0], { key: "a" });
|
||||
assert.deepEqual(selected, []);
|
||||
unmount();
|
||||
});
|
||||
|
||||
test.after(() => cleanup());
|
||||
@@ -1,7 +1,7 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { register } from "node:module";
|
||||
import { render, waitFor } from "@testing-library/preact";
|
||||
import { render, waitFor, fireEvent } from "@testing-library/preact";
|
||||
|
||||
const cssLoad = "data:text/javascript," + encodeURIComponent(`
|
||||
export async function load(url, context, nextLoad) {
|
||||
@@ -186,3 +186,107 @@ test("a link-kind action renders an anchor to the forge", async () => {
|
||||
assert.equal(link.textContent, "Open PR");
|
||||
assert.equal(link.getAttribute("href"), "https://forge.example.internal/sam/archie/pull/42");
|
||||
});
|
||||
|
||||
// The stuck-pane case: an open log pane whose row is collapsed while the task
|
||||
// is retried. If the pane only ever loaded from the click that opened it, the
|
||||
// new attempt's pane would sit on "Loading…" with nothing fetching it.
|
||||
test("a log pane left open across a retry loads the new attempt when the row is reopened", async () => {
|
||||
const first = { id: 9, title: "Restart me", status: "parked", repo: "sam/archie", workflow: "tdd", attempt: 1, actions: ["retry"] };
|
||||
const second = { ...first, attempt: 2, status: "running" };
|
||||
const original = { tasks: api.tasks, task: api.task, taskAction: api.taskAction, taskLogs: api.taskLogs };
|
||||
let listReads = 0;
|
||||
const logReads = [];
|
||||
api.tasks = async () => {
|
||||
listReads += 1;
|
||||
return [listReads === 1 ? first : second];
|
||||
};
|
||||
api.task = async () => [
|
||||
{ kind: "stage_start", attempt: listReads, stage: listReads === 1 ? "prepare" : "bootstrap", at: "2026-09-18T07:00:00Z" },
|
||||
];
|
||||
api.taskLogs = async (id, params) => {
|
||||
logReads.push(params);
|
||||
return { found: true, attempt: params.attempt, disabled: false, entries: [{ level: "info", msg: "line" }] };
|
||||
};
|
||||
api.taskAction = async () => ({});
|
||||
try {
|
||||
const { container } = render(tasksPage(new URLSearchParams("task=9")));
|
||||
await waitFor(() => assert.match(container.textContent, /Started stage: prepare/));
|
||||
fireEvent.click(container.querySelector(".task-logs-section button"));
|
||||
await waitFor(() => assert.equal(logReads.length, 1));
|
||||
|
||||
// Collapse the row, retry from the collapsed row, then reopen it.
|
||||
fireEvent.click(container.querySelector(".task-expand"));
|
||||
fireEvent.click(container.querySelector(".task-actions button"));
|
||||
await waitFor(() => assert.equal(listReads, 2));
|
||||
fireEvent.click(container.querySelector(".task-expand"));
|
||||
|
||||
await waitFor(() => assert.match(container.textContent, /Started stage: bootstrap/));
|
||||
await waitFor(() => assert.equal(logReads.length, 2), { timeout: 2000 });
|
||||
assert.deepEqual(logReads[1], { attempt: 2, limit: 500 });
|
||||
assert.doesNotMatch(container.textContent, /Loading attempt log/);
|
||||
} finally {
|
||||
Object.assign(api, original);
|
||||
}
|
||||
});
|
||||
|
||||
// R8: the run detail page is a per-task route, and the list is how an operator
|
||||
// reaches it. The existing #/tasks?task=N deep link is a different affordance
|
||||
// and stays working (pinned in operator-controls.test.js).
|
||||
test("a task row links to its run detail page", async () => {
|
||||
const root = await renderTask({ id: 7, title: "Fix the flaky test", status: "parked", repo: "sam/archie", actions: [] });
|
||||
const link = root.querySelector(".task-detail-link");
|
||||
assert.ok(link, "the title should link to the run detail page");
|
||||
assert.equal(link.getAttribute("href"), "#/tasks/7");
|
||||
assert.equal(link.textContent, "Fix the flaky test");
|
||||
});
|
||||
|
||||
// W8: the per-task caches used to be written and never invalidated, so a retry
|
||||
// left the previous attempt's timeline (and, because the log cache was keyed by
|
||||
// task, its log) on screen under the new run.
|
||||
test("a retry drops the ended attempt's caches and reloads the new run", async () => {
|
||||
const first = { id: 8, title: "Flaky", status: "parked", repo: "sam/archie", workflow: "tdd", attempt: 1, actions: ["retry"] };
|
||||
const second = { ...first, attempt: 2, status: "running" };
|
||||
const original = { tasks: api.tasks, task: api.task, taskAction: api.taskAction, taskLogs: api.taskLogs };
|
||||
let listReads = 0;
|
||||
const timelineReads = [];
|
||||
const logReads = [];
|
||||
api.tasks = async () => {
|
||||
listReads += 1;
|
||||
return [listReads === 1 ? first : second];
|
||||
};
|
||||
api.task = async () => {
|
||||
timelineReads.push(timelineReads.length + 1);
|
||||
const attempt = timelineReads.length;
|
||||
return [
|
||||
{
|
||||
kind: "stage_start",
|
||||
attempt,
|
||||
stage: attempt === 1 ? "prepare" : "bootstrap",
|
||||
at: "2026-09-18T07:00:00Z",
|
||||
},
|
||||
];
|
||||
};
|
||||
api.taskLogs = async (id, params) => {
|
||||
logReads.push(params);
|
||||
return { found: true, attempt: params.attempt, disabled: false, entries: [{ level: "info", msg: "line" }] };
|
||||
};
|
||||
api.taskAction = async () => ({});
|
||||
try {
|
||||
const { container } = render(tasksPage(new URLSearchParams("task=8")));
|
||||
await waitFor(() => assert.match(container.textContent, /Started stage: prepare/));
|
||||
|
||||
fireEvent.click(container.querySelector(".task-logs-section button"));
|
||||
await waitFor(() => assert.equal(logReads.length, 1));
|
||||
assert.deepEqual(logReads[0], { attempt: 1, limit: 500 });
|
||||
|
||||
fireEvent.click(container.querySelector(".task-actions button"));
|
||||
await waitFor(() => assert.match(container.textContent, /Started stage: bootstrap/));
|
||||
assert.equal(timelineReads.length, 2, "the timeline is refetched, not kept from the ended attempt");
|
||||
assert.doesNotMatch(container.textContent, /Started stage: prepare/);
|
||||
|
||||
await waitFor(() => assert.equal(logReads.length, 2), { timeout: 2000 });
|
||||
assert.deepEqual(logReads[1], { attempt: 2, limit: 500 }, "the log pane follows the new attempt");
|
||||
} finally {
|
||||
Object.assign(api, original);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { register } from "node:module";
|
||||
import { render, waitFor } from "@testing-library/preact";
|
||||
|
||||
// tasks.jsx imports its feature CSS, which node cannot load; the same inline
|
||||
// loader the sibling tasks tests register lets the module be imported here.
|
||||
const cssLoad = "data:text/javascript," + encodeURIComponent(`
|
||||
export async function load(url, context, nextLoad) {
|
||||
if (url.endsWith(".css")) {
|
||||
return { format: "module", shortCircuit: true, source: "export default {};" };
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
`);
|
||||
register(cssLoad, import.meta.url);
|
||||
|
||||
const { api } = await import("../src/base/api.jsx");
|
||||
const { tasksPage } = await import("../src/tasks/tasks.jsx");
|
||||
|
||||
// jsdom implements neither matchMedia nor scrollIntoView, so both are provided
|
||||
// here to observe the one decision under test: which scroll behaviour a
|
||||
// deep-linked row is revealed with.
|
||||
function stubMotion(reduced) {
|
||||
window.matchMedia = (query) => ({
|
||||
matches: Boolean(reduced) && String(query).includes("prefers-reduced-motion: reduce"),
|
||||
media: String(query),
|
||||
onchange: null,
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
addListener() {},
|
||||
removeListener() {},
|
||||
dispatchEvent() {
|
||||
return false;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function revealWithMotion(reduced) {
|
||||
const seen = [];
|
||||
const originalScroll = Element.prototype.scrollIntoView;
|
||||
const originalMatchMedia = window.matchMedia;
|
||||
const originalTasks = api.tasks;
|
||||
Element.prototype.scrollIntoView = (opts) => seen.push(opts);
|
||||
stubMotion(reduced);
|
||||
api.tasks = async () => [
|
||||
{ id: 7, title: "Deep link", status: "running", repo: "o/r", workflow: "tdd", actions: [], attempt: 1 },
|
||||
];
|
||||
try {
|
||||
const { unmount } = render(tasksPage(new URLSearchParams("task=7")));
|
||||
await waitFor(() => assert.ok(seen.length, "the deep-linked row should be revealed"));
|
||||
unmount();
|
||||
return seen[0];
|
||||
} finally {
|
||||
Element.prototype.scrollIntoView = originalScroll;
|
||||
window.matchMedia = originalMatchMedia;
|
||||
api.tasks = originalTasks;
|
||||
}
|
||||
}
|
||||
|
||||
// The global reduced-motion rule switches CSS transitions, NOT JS smooth
|
||||
// scrolling: a deep-linked row is revealed by scrollIntoView, so the behaviour
|
||||
// has to be chosen in JS or a reduced-motion user still gets an animated scroll.
|
||||
test("a revealed row scrolls smoothly only when motion is not reduced", async () => {
|
||||
const opts = await revealWithMotion(false);
|
||||
assert.equal(opts.behavior, "smooth");
|
||||
assert.equal(opts.block, "center");
|
||||
});
|
||||
|
||||
test("a revealed row scrolls instantly when motion is reduced", async () => {
|
||||
const opts = await revealWithMotion(true);
|
||||
assert.equal(opts.behavior, "auto");
|
||||
});
|
||||
@@ -102,6 +102,26 @@ test("cancelled stages are described as interrupted rather than failed", () => {
|
||||
);
|
||||
});
|
||||
|
||||
// Condition (d): the two provenance events render as human timeline lines and
|
||||
// must never dump the captured payload inline -- the Configuration tab renders
|
||||
// the document; the timeline only says that it was captured.
|
||||
test("capture events describe themselves without dumping their payload", () => {
|
||||
const config = describeTimelineEvent({
|
||||
kind: "config_captured",
|
||||
data: { schema: "archie/task-config@1", document: { BotUser: "archie" } },
|
||||
});
|
||||
assert.equal(config.title, "Configuration captured");
|
||||
assert.doesNotMatch(config.detail, /BotUser/);
|
||||
|
||||
const changes = describeTimelineEvent({
|
||||
kind: "changes_captured",
|
||||
data: { captured_after: "commit", totals: { files: 3, additions: 40, deletions: 5 } },
|
||||
});
|
||||
assert.equal(changes.title, "Change capture recorded");
|
||||
assert.match(changes.detail, /3 files changed/);
|
||||
assert.match(changes.detail, /captured after commit/);
|
||||
});
|
||||
|
||||
test("unknown event kinds become readable labels", () => {
|
||||
assert.deepEqual(describeTimelineEvent({ kind: "human_approved", detail: "approved via dashboard" }), {
|
||||
title: "Human Approved",
|
||||
|
||||
Reference in new issue
Block a user