feat(webui): rebuild the dashboard

The old UI was a single 200-line Go file serving one hand-written HTML
page of task rows. It showed that archied was running and almost nothing
about what it was doing -- skills, workflows, memory, channels, logs and
configuration were all invisible unless you read the source or the
config file.

The dashboard now covers each of those as its own section, built as a
Vite app under ui/ at the repo root: it is a separate artefact from the
Go daemon, not an internal package of it. dist/ is committed so building
archied never needs a Node toolchain, and the !no_ui build tag keeps an
embed-free build available.

Both sides are split by concern rather than by layer -- one Go file per
API area, one folder per UI section with its own CSS -- so a change to
logs cannot disturb tasks.

Pages report consequences, not just state: an empty memory page says
Archie starts every conversation with no recollection of earlier ones,
and the setup checklist names what is missing in plain language instead
of showing a grid of zeroes. Nothing greets by a hardcoded name; the
operator comes from [chat], which is deployment data.

Auth is exposure control, not capability control -- the agent already
holds this user's authority through its own tools. So a loopback bind
needs no token, and only a reachable bind mints one and logs a URL,
which means an instance cannot be exposed merely by omitting config.

Container startup now degrades instead of aborting, for the reason
resolveForge already does: a missing agent image should not deny the
operator chat and the dashboard, and under Restart=on-failure it turns a
recoverable problem into a crash loop with the real error scrolling past.

`task dev` runs the daemon under air and the Vite server together in one
terminal.
This commit is contained in:
sam committed 2026-08-04 01:45:36 +10:00
1 parent 449c925f29
commit 4d44ef76f5
61 files changed
+5889 -576

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
/* Workflows-only styles. */
.wf-stage-card {
margin-top: var(--sp-4);
}
.wf-rate {
font-size: var(--text-sm);
color: var(--fg);
display: flex;
align-items: baseline;
gap: var(--sp-2);
}
.wf-rate-sub {
font-size: var(--text-xs);
color: var(--fg-subtle);
}
.wf-bar {
height: 5px;
border-radius: var(--radius-pill);
background: var(--border);
overflow: hidden;
margin-top: var(--sp-2);
width: 140px;
}
.wf-bar-fill {
height: 100%;
border-radius: var(--radius-pill);
transition: width var(--transition);
}
.wf-bar-ok {
background: var(--ok);
}
.wf-bar-warn {
background: var(--warn);
}
.wf-bar-danger {
background: var(--danger);
}
.wf-bar-info {
background: var(--info);
}
+223
View File
@@ -0,0 +1,223 @@
import "./workflows.css";
import { api } from "../base/api.js";
import { el, empty, mount } from "../base/dom.js";
/**
* Plain-language workflow names. Falls back to a title-cased version of the
* raw identifier for anything not listed here, so a new workflow never
* renders blank.
*/
const WORKFLOW_LABELS = {
bootstrap: "Bootstrap",
implement: "Implement",
tdd: "TDD",
feasibility: "Feasibility check",
};
function workflowLabel(name) {
if (WORKFLOW_LABELS[name]) return WORKFLOW_LABELS[name];
if (!name) return "Unknown";
return name.charAt(0).toUpperCase() + name.slice(1).replace(/_/g, " ");
}
function pct(part, whole) {
if (!whole) return 0;
return Math.round((part / whole) * 100);
}
function bar(fraction, kind = "ok") {
return el(
"div.wf-bar",
el(`div.wf-bar-fill.wf-bar-${kind}`, { style: `width:${Math.min(100, Math.max(0, fraction))}%` }),
);
}
function formatMs(ms) {
if (!ms) return "—";
if (ms < 1000) return `${ms} ms`;
const secs = ms / 1000;
if (secs < 60) return `${secs.toFixed(1)} s`;
return `${(secs / 60).toFixed(1)} min`;
}
/**
* How work actually flows: per-workflow outcomes and spend, then per-stage
* duration and failure counts -- the "where does it get stuck" view. Both
* come from a single /api/workflows call built on the same store queries
* that back the dashboard's summary stats.
*/
export function workflowsPage() {
const root = el("div");
const workflowSlot = el("div");
const stageSlot = el("div");
render();
load();
function render() {
mount(
root,
el(
"div.page-head",
el(
"div",
el("h1.page-title", "Workflows"),
el("p.page-sub", "Run outcomes and spend per workflow, and where stages get stuck."),
),
el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
),
workflowSlot,
stageSlot,
);
}
async function load() {
try {
const data = await api.workflows();
renderWorkflows(data?.workflows || []);
renderStages(data?.stages || []);
} catch (err) {
mount(workflowSlot, el("div.card", empty("Cannot reach archied", String(err.message || err))));
mount(stageSlot);
}
}
function renderWorkflows(workflows) {
if (!workflows.length) {
mount(
workflowSlot,
el(
"div.card",
el("div.card-head", el("div", el("h2.card-title", "Per workflow"))),
empty("No workflow runs yet", "Stats appear here once a task has run through a workflow."),
),
);
return;
}
mount(
workflowSlot,
el(
"div.card",
el(
"div.card-head",
el(
"div",
el("h2.card-title", "Per workflow"),
el("p.card-sub", "Success rate is merged tasks over all runs"),
),
),
el(
"table.table",
el(
"thead",
el(
"tr",
...["Workflow", "Runs", "Success rate", "Avg tokens", "Avg steps"].map((h) => el("th", h)),
),
),
el(
"tbody",
...workflows.map((w) => {
const rate = pct(w.merged, w.runs);
return el(
"tr",
el("td.strong", workflowLabel(w.workflow)),
el("td", `${w.runs} run${w.runs === 1 ? "" : "s"}`),
el(
"td",
el("div.wf-rate", `${rate}%`, el("span.wf-rate-sub", `${w.merged} of ${w.runs} merged`)),
bar(rate, rate >= 50 ? "ok" : "warn"),
),
el("td.mono", w.avg_tokens ? w.avg_tokens.toLocaleString() : "—"),
el("td.mono", w.avg_steps ? w.avg_steps.toFixed(1) : "—"),
);
}),
),
),
),
);
}
function renderStages(stages) {
if (!stages.length) {
mount(
stageSlot,
el(
"div.card.wf-stage-card",
el("div.card-head", el("div", el("h2.card-title", "Per stage"))),
empty("No stage data yet", "Stage timing and failures appear here once workflows have run."),
),
);
return;
}
const maxMs = Math.max(...stages.map((s) => s.avg_ms || 0), 1);
const byDuration = [...stages].sort((a, b) => (b.avg_ms || 0) - (a.avg_ms || 0));
const byErrors = [...stages].filter((s) => s.errors > 0).sort((a, b) => b.errors - a.errors);
mount(
stageSlot,
el(
"div.grid.grid-2.wf-stage-card",
el(
"div.card",
el(
"div.card-head",
el("div", el("h2.card-title", "Slowest stages"), el("p.card-sub", "Average duration, this workflow's stages")),
),
el(
"table.table",
el("thead", el("tr", ...["Workflow", "Stage", "Runs", "Avg duration"].map((h) => el("th", h)))),
el(
"tbody",
...byDuration.map((s) =>
el(
"tr",
el("td", workflowLabel(s.workflow)),
el("td.strong", s.stage),
el("td", `${s.runs}`),
el(
"td",
el("div.wf-rate", formatMs(s.avg_ms)),
bar(pct(s.avg_ms, maxMs), "info"),
),
),
),
),
),
),
el(
"div.card",
el(
"div.card-head",
el("div", el("h2.card-title", "Most failures"), el("p.card-sub", "Stages that error out, over their runs")),
),
byErrors.length
? el(
"table.table",
el("thead", el("tr", ...["Workflow", "Stage", "Failures"].map((h) => el("th", h)))),
el(
"tbody",
...byErrors.map((s) =>
el(
"tr",
el("td", workflowLabel(s.workflow)),
el("td.strong", s.stage),
el(
"td",
el("div.wf-rate", `${s.errors} of ${s.runs}`),
bar(pct(s.errors, s.runs), "danger"),
),
),
),
),
)
: empty("No failures recorded", "Every stage has completed cleanly so far."),
),
),
);
}
return root;
}