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

+63
View File
@@ -0,0 +1,63 @@
// Single place that knows how to talk to archied. Every feature folder goes
// through this, so auth handling and error shape live in one file.
async function req(path) {
const res = await fetch(path, { headers: { Accept: "application/json" } });
if (res.status === 401) {
throw new ApiError("unauthorised", 401);
}
if (!res.ok) {
throw new ApiError(`${res.status} ${res.statusText}`, res.status);
}
return res.json();
}
// qs builds a query string, omitting empty values so the server sees an
// absent filter rather than an empty one.
function qs(params) {
const q = new URLSearchParams();
for (const [k, v] of Object.entries(params || {})) {
if (v !== "" && v != null) q.set(k, v);
}
const s = q.toString();
return s ? `?${s}` : "";
}
export class ApiError extends Error {
constructor(message, status) {
super(message);
this.status = status;
}
}
export const api = {
summary: () => req("/api/summary"),
tasks: () => req("/api/tasks"),
task: (id) => req(`/api/tasks/${id}`),
setup: () => req("/api/setup"),
workflows: () => req("/api/workflows"),
skills: () => req("/api/skills"),
channels: () => req("/api/channels"),
config: () => req("/api/config"),
logs: (params) => req("/api/logs" + qs(params)),
memory: () => req("/api/memory"),
};
/**
* Subscribe to archied's event stream. Returns an unsubscribe function.
* Reconnection is the browser's job via EventSource, but a closed stream is
* surfaced to the caller so the UI can show it rather than silently freezing.
*/
export function subscribeEvents(onEvent, onStateChange) {
const src = new EventSource("/events");
src.onopen = () => onStateChange?.("live");
src.onerror = () => onStateChange?.("reconnecting");
src.onmessage = (e) => {
try {
onEvent(JSON.parse(e.data));
} catch {
/* a malformed frame should not kill the stream */
}
};
return () => src.close();
}
+103
View File
@@ -0,0 +1,103 @@
// Tiny DOM helpers. Deliberately not a framework: the dashboard is a handful
// of pages over a read-mostly API, and a build-free vanilla layer keeps the
// embedded bundle small.
/**
* el("div.card", {onclick}, child, child) -> HTMLElement
* The tag string accepts CSS-ish shorthand: "button.btn.btn-primary".
*/
export function el(spec, attrs, ...children) {
const [tag, ...classes] = spec.split(".");
const node = document.createElement(tag || "div");
if (classes.length) node.className = classes.join(" ");
if (attrs && (typeof attrs !== "object" || attrs instanceof Node)) {
children.unshift(attrs);
attrs = null;
}
for (const [k, v] of Object.entries(attrs || {})) {
if (v == null || v === false) continue;
if (k.startsWith("on") && typeof v === "function") {
node.addEventListener(k.slice(2).toLowerCase(), v);
} else if (k === "class") {
node.className = [node.className, v].filter(Boolean).join(" ");
} else if (k === "html") {
node.innerHTML = v;
} else {
node.setAttribute(k, v === true ? "" : String(v));
}
}
append(node, children);
return node;
}
function append(node, children) {
for (const c of children.flat(Infinity)) {
if (c == null || c === false) continue;
node.append(c instanceof Node ? c : document.createTextNode(String(c)));
}
}
export function mount(parent, ...children) {
parent.replaceChildren();
append(parent, children);
return parent;
}
/** Status pill. Kind maps to the semantic colour tokens. */
export function pill(text, kind = "idle") {
return el(`span.pill.pill-${kind}`, text);
}
/**
* Map an archie task status onto a pill kind. Centralised so "merged" is the
* same green everywhere it appears.
*/
export function statusKind(status) {
switch (status) {
case "running":
return "info";
case "merged":
case "pr_open":
return "ok";
case "parked":
case "waiting_human":
return "warn";
case "dead":
case "rejected":
return "danger";
default:
return "idle";
}
}
/** Humanised relative time: "2 min ago". Raw timestamps make people do maths. */
export function ago(value) {
if (!value) return "—";
const then = value instanceof Date ? value : new Date(value);
const secs = Math.floor((Date.now() - then.getTime()) / 1000);
if (!Number.isFinite(secs)) return "—";
if (secs < 45) return "just now";
const units = [
["min", 60],
["hr", 3600],
["day", 86400],
["wk", 604800],
];
let label = "min", size = 60;
for (const [l, s] of units) {
if (secs >= s) [label, size] = [l, s];
}
const n = Math.floor(secs / size);
return `${n} ${label}${n === 1 ? "" : "s"} ago`;
}
/** Compact number: 2_400_000 -> "2.4M". Long digit strings do not scan. */
export function compact(n) {
if (n == null || Number.isNaN(n)) return "—";
return new Intl.NumberFormat(undefined, { notation: "compact", maximumFractionDigits: 1 }).format(n);
}
export function empty(title, detail) {
return el("div.empty", el("div.empty-title", title), detail && el("div", detail));
}
+89
View File
@@ -0,0 +1,89 @@
import { el } from "./dom.js";
/**
* Arc gauge for a single headline percentage.
*
* A percentage that decides whether you need to act deserves more than a line
* of text -- the arc is readable at a glance from across a room, which a
* number is not. Colour follows the value, so "is this bad" is answered before
* the digits are read.
*/
export function gauge({ value, label, size = 168 }) {
const pct = Math.max(0, Math.min(100, Number(value) || 0));
const stroke = pct >= 90 ? "var(--ok)" : pct >= 70 ? "var(--warn)" : "var(--danger)";
// 240-degree arc, opening downward, so the value reads left-to-right.
const r = 62;
const cx = size / 2;
const cy = size / 2;
const sweep = 240;
const start = 150;
const circumference = 2 * Math.PI * r * (sweep / 360);
const arc = (from, deg) => {
const a0 = (from * Math.PI) / 180;
const a1 = ((from + deg) * Math.PI) / 180;
const large = deg > 180 ? 1 : 0;
return [
`M ${cx + r * Math.cos(a0)} ${cy + r * Math.sin(a0)}`,
`A ${r} ${r} 0 ${large} 1 ${cx + r * Math.cos(a1)} ${cy + r * Math.sin(a1)}`,
].join(" ");
};
const svg = el("svg.gauge", {
viewBox: `0 0 ${size} ${size * 0.78}`,
role: "img",
"aria-label": `${label}: ${pct}%`,
});
svg.innerHTML = `
<path d="${arc(start, sweep)}" fill="none" stroke="var(--border)"
stroke-width="12" stroke-linecap="round"/>
<path d="${arc(start, sweep)}" fill="none" stroke="${stroke}"
stroke-width="12" stroke-linecap="round"
stroke-dasharray="${circumference}"
stroke-dashoffset="${circumference * (1 - pct / 100)}"
class="gauge-value"/>`;
return el(
"div.gauge-wrap",
svg,
el("div.gauge-center", el("div.gauge-pct", `${Math.round(pct)}%`), el("div.gauge-label", label)),
);
}
/**
* Segmented proportional bar with a legend.
*
* segments: [{ label, value, kind }] where kind maps to a status token.
* Used for budget composition -- what is spent, committed and still free --
* because three related quantities are easier to compare in one bar than in
* three separate numbers.
*/
export function segmentBar(segments) {
const total = segments.reduce((a, s) => a + (s.value || 0), 0) || 1;
return el(
"div",
el(
"div.segbar",
...segments
.filter((s) => s.value > 0)
.map((s) =>
el("span", {
class: `segbar-part segbar-${s.kind || "idle"}`,
style: `width:${((s.value / total) * 100).toFixed(1)}%`,
title: `${s.label}: ${s.value}`,
}),
),
),
el(
"div.segbar-legend",
...segments.map((s) =>
el(
"span.segbar-key",
el("span", { class: `segbar-dot segbar-${s.kind || "idle"}` }),
s.label,
),
),
),
);
}
+48
View File
@@ -0,0 +1,48 @@
/**
* Icon set.
*
* A single stroked 24-grid system rather than Unicode glyphs: glyphs render at
* different weights and baselines per platform, cannot inherit stroke width,
* and have no consistent optical size. Every icon here shares the same grid,
* stroke and cap style, so a row of them lines up.
*/
const paths = {
dashboard: '<rect x="3" y="3" width="7" height="9" rx="1.5"/><rect x="14" y="3" width="7" height="5" rx="1.5"/><rect x="14" y="12" width="7" height="9" rx="1.5"/><rect x="3" y="16" width="7" height="5" rx="1.5"/>',
tasks: '<path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6l1 1 2-2M4 12l1 1 2-2M4 18l1 1 2-2"/>',
logs: '<path d="M4 5h16M4 10h16M4 15h10M4 20h7"/>',
skills: '<path d="M12 3l2.6 5.6 6.1.8-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6L3.3 9.4l6.1-.8z"/>',
workflows: '<path d="M4 7h6a3 3 0 0 1 3 3v4a3 3 0 0 0 3 3h4"/><path d="M17 4l3 3-3 3"/><path d="M7 21l-3-3 3-3"/>',
memory: '<circle cx="12" cy="12" r="3.2"/><path d="M12 3v3.4M12 17.6V21M3 12h3.4M17.6 12H21M5.6 5.6l2.4 2.4M16 16l2.4 2.4M18.4 5.6L16 8M8 16l-2.4 2.4"/>',
channels: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3.5 7l8.5 6 8.5-6"/>',
settings: '<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2V21a2 2 0 1 1-4 0v-.1A1.7 1.7 0 0 0 7 19.4a1.7 1.7 0 0 0-1.9.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 3 15H3a2 2 0 1 1 0-4h.1A1.7 1.7 0 0 0 4.6 7a1.7 1.7 0 0 0-.3-1.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 9 3.6V3a2 2 0 1 1 4 0v.1A1.7 1.7 0 0 0 15 4.6h.1a1.7 1.7 0 0 0 1.9-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.9V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/>',
search: '<circle cx="11" cy="11" r="7"/><path d="M20 20l-3.6-3.6"/>',
moon: '<path d="M20 14.5A8.5 8.5 0 0 1 9.5 4a8.5 8.5 0 1 0 10.5 10.5z"/>',
sun: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M19.1 4.9l-1.4 1.4M6.3 17.7l-1.4 1.4"/>',
refresh: '<path d="M20 11a8 8 0 1 0-1.2 5.2"/><path d="M20 4v7h-7"/>',
bell: '<path d="M18 9a6 6 0 1 0-12 0c0 6-2 7-2 7h16s-2-1-2-7"/><path d="M13.7 20a2 2 0 0 1-3.4 0"/>',
trendUp: '<path d="M4 17L10 11l4 4 6-6"/><path d="M14 7h6v6"/>',
trendDown: '<path d="M4 7l6 6 4-4 6 6"/><path d="M14 17h6v-6"/>',
check: '<path d="M4.5 12.5l5 5 10-11"/>',
help: '<circle cx="12" cy="12" r="9"/><path d="M9.6 9.4a2.5 2.5 0 1 1 3.3 2.4c-.6.2-.9.8-.9 1.4v.4"/><path d="M12 17.2h.01"/>',
};
/**
* icon("tasks") -> SVGElement. size is the rendered box; the grid is always 24
* so stroke weight stays optically consistent at any size.
*/
export function icon(name, { size = 18, className = "" } = {}) {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("viewBox", "0 0 24 24");
svg.setAttribute("width", String(size));
svg.setAttribute("height", String(size));
svg.setAttribute("fill", "none");
svg.setAttribute("stroke", "currentColor");
svg.setAttribute("stroke-width", "1.6");
svg.setAttribute("stroke-linecap", "round");
svg.setAttribute("stroke-linejoin", "round");
svg.setAttribute("aria-hidden", "true");
svg.setAttribute("class", `ico ${className}`.trim());
svg.innerHTML = paths[name] || paths.dashboard;
return svg;
}
+57
View File
@@ -0,0 +1,57 @@
import { el } from "./dom.js";
import { icon } from "./icons.js";
/**
* A KPI tile: label, big value, trend against a stated comparison window, and
* a sparkline. The comparison line is not decoration -- a number without a
* baseline cannot be acted on, so `compare` is required.
*
* trend > 0 renders as an increase. `goodDirection` says whether that is good,
* because rising latency and rising success rate are not the same news.
*/
export function statTile({ label, value, unit, trend, compare, series = [], goodDirection = "up" }) {
const dir = trend == null ? null : trend >= 0 ? "up" : "down";
const good = dir == null ? null : dir === goodDirection;
return el(
"div.card.stat",
el(
"div.stat-head",
el("span.stat-label", label),
dir &&
el(
`span.stat-trend.${good ? "up" : "down"}`,
icon(dir === "up" ? "trendUp" : "trendDown", { size: 13 }),
`${Math.abs(trend).toFixed(1)}%`,
),
),
el("div.stat-value", value, unit && el("span.stat-unit", unit)),
compare && el("div.stat-compare", compare),
series.length > 1 && sparkline(series, good === false ? "var(--danger)" : "var(--ok)"),
);
}
/**
* Inline SVG sparkline. Shows shape, not exact values -- the tile's headline
* number carries the precision.
*/
export function sparkline(series, stroke = "var(--ok)", { width = 220, height = 34 } = {}) {
const max = Math.max(...series, 1);
const min = Math.min(...series, 0);
const span = max - min || 1;
const step = series.length > 1 ? width / (series.length - 1) : width;
const points = series
.map((v, i) => `${(i * step).toFixed(1)},${(height - ((v - min) / span) * height).toFixed(1)}`)
.join(" ");
const svg = el("svg.spark", {
viewBox: `0 0 ${width} ${height}`,
preserveAspectRatio: "none",
"aria-hidden": "true",
});
svg.innerHTML =
`<polyline points="${points}" fill="none" stroke="${stroke}" stroke-width="1.5" ` +
`stroke-linecap="round" stroke-linejoin="round" vector-effect="non-scaling-stroke"/>`;
return svg;
}
+19
View File
@@ -0,0 +1,19 @@
/* Channels-only styles. */
.channel-card {
display: flex;
flex-direction: column;
gap: var(--sp-1);
}
.channel-desc {
color: var(--fg-muted);
font-size: var(--text-sm);
margin: 0;
}
.channel-detail {
color: var(--fg-subtle);
font-size: var(--text-xs);
margin: 0;
}
+72
View File
@@ -0,0 +1,72 @@
import "./channels.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
/**
* How you reach Archie. Backed by GET /api/channels, which derives from
* [chat] in config.toml -- see internal/webui/api_config.go's
* handleChannels. Each channel is a card with a connected/not-configured
* pill and one line explaining what turning it on gets you, because
* "token_env unset" means nothing to someone who hasn't read config.toml.
*/
export function channelsPage() {
const root = el("div");
const cardGrid = el("div.grid.grid-2");
render();
load();
function render() {
mount(
root,
el(
"div.page-head",
el(
"div",
el("h1.page-title", "Channels"),
el("p.page-sub", "The conversational front-ends Archie can be reached through."),
),
el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
),
cardGrid,
);
}
async function load() {
try {
const res = await api.channels();
renderCards(res?.channels || []);
} catch (err) {
mount(cardGrid, empty("Cannot reach archied", String(err.message || err)));
}
}
function renderCards(channels) {
if (!channels.length) {
mount(
cardGrid,
empty(
"No channels configured",
"Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.",
),
);
return;
}
mount(cardGrid, ...channels.map(channelCard));
}
function channelCard(channel) {
return el(
"div.card.channel-card",
el(
"div.card-head",
el("h3.card-title", channel.name),
channel.configured ? pill("connected", "ok") : pill("not configured", "idle"),
),
el("p.channel-desc", channel.description),
el("p.channel-detail", channel.detail),
);
}
return root;
}
+17
View File
@@ -0,0 +1,17 @@
/*
* Style entry point. One file per concern, imported here in cascade order:
* tokens first (everything depends on them), then element defaults, then
* layout, then components. Feature folders own their own CSS and import it
* from their JS rather than adding to this list.
*/
@import "./tokens.css";
@import "./base.css";
@import "./layout.css";
@import "./page.css";
@import "./button.css";
@import "./card.css";
@import "./pill.css";
@import "./table.css";
@import "./empty.css";
@import "./responsive.css";
+32
View File
@@ -0,0 +1,32 @@
/* Element defaults. Nothing here is component-specific. */
/*
* App shell and shared primitives. Feature folders style their own specifics;
* anything that appears on more than one page lives here so pages cannot
* drift into three visual languages.
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
margin: 0;
height: 100%;
}
body {
color: var(--fg);
font-family: var(--font-sans);
font-size: var(--text-base);
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
a {
color: inherit;
text-decoration: none;
}
+37
View File
@@ -0,0 +1,37 @@
/* Buttons. One shape, three weights. */
.btn {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
padding: var(--sp-2) var(--sp-4);
border-radius: var(--radius-pill);
border: 1px solid var(--border-strong);
background: var(--surface);
color: var(--fg);
font: inherit;
font-size: var(--text-sm);
cursor: pointer;
transition: background var(--transition), border-color var(--transition);
}
.btn:hover {
background: var(--surface-hover);
}
.btn-primary {
background: var(--accent);
border-color: var(--accent);
color: var(--accent-fg);
font-weight: 500;
}
.btn-primary:hover {
filter: brightness(1.08);
background: var(--accent);
}
.btn-icon {
padding: var(--sp-2);
border-radius: var(--radius-sm);
}
+43
View File
@@ -0,0 +1,43 @@
/* Cards and the grids that arrange them. */
.card {
background: var(--surface-glass);
backdrop-filter: blur(14px);
border: 1px solid var(--hairline);
border-radius: var(--radius-lg);
padding: var(--sp-5);
box-shadow: var(--shadow-sm);
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-3);
margin-bottom: var(--sp-4);
}
.card-title {
font-size: var(--text-base);
font-weight: 600;
margin: 0;
}
.card-sub {
font-size: var(--text-xs);
color: var(--fg-muted);
margin: var(--sp-1) 0 0;
}
.grid {
display: grid;
gap: var(--sp-4);
}
.grid-4 {
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid-2 {
grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
+26
View File
@@ -0,0 +1,26 @@
/* Empty and loading states. */
.empty {
text-align: center;
padding: var(--sp-7) var(--sp-4);
color: var(--fg-muted);
}
.empty-title {
color: var(--fg);
font-weight: 500;
margin-bottom: var(--sp-1);
}
.skeleton {
background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
background-size: 200% 100%;
animation: shimmer 1.4s infinite;
border-radius: var(--radius-sm);
}
@keyframes shimmer {
to {
background-position: -200% 0;
}
}
+242
View File
@@ -0,0 +1,242 @@
/* The shell: one contained, rounded application surface floating on a lit
* canvas.
*
* The dashboard is a *workspace*, not a document that fills the viewport --
* framing it gives the panels an edge to sit against, and lets the canvas
* behind read as light rather than wallpaper. Everything inside is translucent
* so that light carries through instead of stopping at the first opaque card.
*/
body {
/* The luminous canvas. Large, off-axis and low-frequency, so it lights the
workspace rather than competing with it. */
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);
background-attachment: fixed;
padding: var(--sp-4);
}
.shell {
min-height: calc(100vh - var(--sp-4) * 2);
display: flex;
flex-direction: column;
border-radius: var(--radius-xl);
border: 1px solid var(--hairline);
background: var(--workspace);
backdrop-filter: blur(28px) saturate(120%);
box-shadow: var(--shadow-workspace);
overflow: hidden;
}
/* ── Command bar ────────────────────────────────────────────────────────── */
.topbar {
display: flex;
align-items: center;
gap: var(--sp-4);
padding: var(--sp-3) var(--sp-4);
border-bottom: 1px solid var(--hairline);
background: var(--bg-blur);
position: sticky;
top: 0;
z-index: 10;
}
.brand {
display: flex;
align-items: center;
gap: var(--sp-2);
font-weight: 600;
font-size: var(--text-sm);
letter-spacing: -0.01em;
flex: none;
}
.brand-mark {
width: 26px;
height: 26px;
border-radius: 8px;
background: linear-gradient(135deg, var(--accent), var(--accent-2));
display: grid;
place-items: center;
color: #fff;
font-size: var(--text-xs);
font-weight: 700;
}
/* Compact icon navigation: one pill, icons only, label on the active item. */
.nav {
display: flex;
align-items: center;
gap: 2px;
margin: 0 auto;
padding: 3px;
border-radius: var(--radius-pill);
background: var(--surface-glass-strong);
border: 1px solid var(--hairline);
}
.nav-item {
display: inline-flex;
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);
}
.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;
padding-right: var(--sp-4);
}
.nav-item .nav-label {
display: none;
}
.nav-item[aria-current="page"] .nav-label {
display: inline;
}
/* ── Utility cluster ────────────────────────────────────────────────────── */
.topbar-end {
display: flex;
align-items: center;
gap: var(--sp-2);
flex: none;
}
.topbar-search {
display: flex;
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);
}
.topbar-search input {
background: none;
border: 0;
color: var(--fg);
font: inherit;
font-size: var(--text-sm);
width: 8rem;
outline: none;
}
.topbar-search input::placeholder {
color: var(--fg-subtle);
}
.icon-btn {
display: grid;
place-items: center;
width: 32px;
height: 32px;
border-radius: var(--radius-pill);
border: 1px solid var(--hairline);
background: var(--surface-glass-strong);
color: var(--fg-muted);
cursor: pointer;
transition: color var(--transition), background var(--transition);
}
.icon-btn:hover {
color: var(--fg);
background: var(--surface-hover);
}
.avatar {
width: 32px;
height: 32px;
border-radius: var(--radius-pill);
display: grid;
place-items: center;
font-size: var(--text-xs);
font-weight: 600;
color: #fff;
background: linear-gradient(135deg, var(--accent), var(--accent-2));
cursor: pointer;
flex: none;
}
.ico {
flex: none;
display: block;
}
/* ── Canvas ─────────────────────────────────────────────────────────────── */
.main {
padding: var(--sp-6);
width: 100%;
flex: 1;
overflow-x: hidden;
}
/* ── Narrow screens ─────────────────────────────────────────────────────── */
/* The frame is a desktop affordance. Below the breakpoint the workspace goes
edge to edge -- a rounded card inset on a phone wastes the only axis that
matters -- and the icon bar becomes a scrollable labelled row. */
@media (max-width: 900px) {
body {
padding: 0;
}
.shell {
min-height: 100vh;
border-radius: 0;
border: 0;
box-shadow: none;
}
.topbar {
flex-wrap: wrap;
padding: var(--sp-3);
gap: var(--sp-2);
}
.nav {
order: 3;
width: 100%;
overflow-x: auto;
justify-content: flex-start;
border-radius: var(--radius-lg);
scrollbar-width: none;
}
.nav::-webkit-scrollbar {
display: none;
}
.nav-item .nav-label {
display: inline;
}
.topbar-search {
display: none;
}
.main {
padding: var(--sp-4);
}
}
+29
View File
@@ -0,0 +1,29 @@
/* Page header: title, subtitle and the actions that belong to a page. */
.page-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: var(--sp-5);
margin-bottom: var(--sp-6);
flex-wrap: wrap;
}
.page-title {
font-size: var(--text-2xl);
font-weight: 600;
letter-spacing: -0.02em;
margin: 0;
}
.page-sub {
color: var(--fg-muted);
font-size: var(--text-sm);
margin: var(--sp-1) 0 0;
}
.page-actions {
display: flex;
gap: var(--sp-2);
align-items: center;
}
+43
View File
@@ -0,0 +1,43 @@
/* Status pills. The only place status colour is decided. */
/* Status is always a pill, never bare text: a colour and a shape are read at
a glance where a word has to be parsed. */
.pill {
display: inline-flex;
align-items: center;
gap: var(--sp-1);
padding: 2px var(--sp-2);
border-radius: var(--radius-pill);
font-size: var(--text-xs);
font-weight: 500;
white-space: nowrap;
}
.pill::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: currentColor;
}
.pill-ok {
color: var(--ok);
background: var(--ok-soft);
}
.pill-warn {
color: var(--warn);
background: var(--warn-soft);
}
.pill-danger {
color: var(--danger);
background: var(--danger-soft);
}
.pill-info {
color: var(--info);
background: var(--info-soft);
}
.pill-idle {
color: var(--idle);
background: var(--idle-soft);
}
+30
View File
@@ -0,0 +1,30 @@
/* Motion preferences and narrow viewports. */
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
.nav-soon {
margin-left: auto;
font-size: var(--text-xs);
color: var(--fg-subtle);
background: var(--surface-hover);
padding: 1px var(--sp-2);
border-radius: var(--radius-pill);
}
.nav-item[aria-disabled] {
opacity: 0.55;
cursor: default;
}
.nav-item[aria-disabled]:hover {
background: none;
color: var(--fg-muted);
}
+42
View File
@@ -0,0 +1,42 @@
/* Data tables. */
.table {
width: 100%;
border-collapse: collapse;
font-size: var(--text-sm);
}
.table th {
text-align: left;
font-weight: 500;
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--fg-subtle);
padding: 0 var(--sp-3) var(--sp-3);
border-bottom: 1px solid var(--border);
}
.table td {
padding: var(--sp-3);
border-bottom: 1px solid var(--border);
color: var(--fg-muted);
}
.table tbody tr:last-child td {
border-bottom: 0;
}
.table tbody tr:hover td {
background: var(--surface-hover);
}
.table td.strong {
color: var(--fg);
font-weight: 500;
}
.mono {
font-family: var(--font-mono);
font-size: 0.95em;
}
+130
View File
@@ -0,0 +1,130 @@
/*
* Design tokens. Dark is the default because archied is a daemon you check at
* odd hours; light is a toggle, not an afterthought, so both themes define the
* same variable set and nothing else in the app references a raw colour.
*
* Semantic names only. Never `--blue`; always `--accent` or `--status-running`,
* so a palette change is one file rather than a grep.
*/
:root {
/* Type */
--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: 0.6875rem;
--text-sm: 0.8125rem;
--text-base: 0.875rem;
--text-lg: 1.0625rem;
--text-xl: 1.375rem;
--text-2xl: 1.875rem;
--text-3xl: 2.5rem;
/* Spacing: a 4px scale. Layout uses these, never magic pixels. */
--sp-1: 0.25rem;
--sp-2: 0.5rem;
--sp-3: 0.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: 140ms cubic-bezier(0.4, 0, 0.2, 1);
}
/* ── Dark (default) ─────────────────────────────────────────────────────── */
[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: #ffffff;
--accent-soft: rgba(76, 141, 255, 0.14);
/* Status. Used for task state, gate results and trend direction alike, so
the same colour always means the same thing wherever it appears. */
--ok: #3fbf7f;
--ok-soft: rgba(63, 191, 127, 0.14);
--warn: #e8a33d;
--warn-soft: rgba(232, 163, 61, 0.14);
--danger: #f0616d;
--danger-soft: rgba(240, 97, 109, 0.14);
--info: #4c8dff;
--info-soft: rgba(76, 141, 255, 0.14);
--idle: #6b7688;
--idle-soft: rgba(107, 118, 136, 0.14);
--accent-2: #7b5cff;
--bg-blur: rgba(20, 25, 32, 0.55);
/* Panels are translucent so the canvas wash shows through and the whole
workspace reads as one lit surface rather than opaque cards on a picture. */
--surface-glass: rgba(23, 29, 37, 0.62);
--surface-glass-strong: rgba(20, 25, 32, 0.78);
--workspace: rgba(17, 21, 27, 0.55);
--hairline: rgba(255, 255, 255, 0.06);
--wash-a: rgba(76, 141, 255, 0.10);
--wash-b: rgba(123, 92, 255, 0.12);
--wash-c: rgba(63, 191, 127, 0.06);
--shadow-workspace: 0 24px 70px rgba(0, 0, 0, 0.5);
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
--shadow-md: 0 8px 28px rgba(0, 0, 0, 0.42);
}
/* ── Light ──────────────────────────────────────────────────────────────── */
[data-theme="light"] {
--bg: #f6f8fb;
--bg-raised: #ffffff;
--surface: #ffffff;
--surface-hover: #f1f4f9;
--border: #e2e8f0;
--border-strong: #cbd5e1;
--fg: #16202e;
--fg-muted: #5a6779;
--fg-subtle: #8c99ab;
--accent: #2563eb;
--accent-fg: #ffffff;
--accent-soft: rgba(37, 99, 235, 0.1);
--ok: #10935c;
--ok-soft: rgba(16, 147, 92, 0.12);
--warn: #b87514;
--warn-soft: rgba(184, 117, 20, 0.12);
--danger: #d4344a;
--danger-soft: rgba(212, 52, 74, 0.12);
--info: #2563eb;
--info-soft: rgba(37, 99, 235, 0.1);
--idle: #64748b;
--idle-soft: rgba(100, 116, 139, 0.12);
--accent-2: #7c3aed;
--bg-blur: rgba(255, 255, 255, 0.6);
--surface-glass: rgba(255, 255, 255, 0.72);
--surface-glass-strong: rgba(255, 255, 255, 0.88);
--workspace: rgba(255, 255, 255, 0.55);
--hairline: rgba(15, 23, 42, 0.06);
--wash-a: rgba(37, 99, 235, 0.10);
--wash-b: rgba(124, 58, 237, 0.12);
--wash-c: rgba(16, 147, 92, 0.07);
--shadow-workspace: 0 24px 70px rgba(15, 23, 42, 0.14);
--shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
--shadow-md: 0 8px 28px rgba(15, 23, 42, 0.10);
}
+368
View File
@@ -0,0 +1,368 @@
/* Dashboard-only styles. Feature folders own their CSS and import it from
their JS, so a section can be added or removed without editing _main.css. */
/* ── Stat tiles ─────────────────────────────────────────────────────────── */
.stat-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-2);
}
.stat-label {
font-size: var(--text-sm);
color: var(--fg-muted);
}
.stat-trend {
display: inline-flex;
align-items: center;
gap: 3px;
font-size: var(--text-xs);
font-weight: 500;
}
.stat-trend.up {
color: var(--ok);
}
.stat-trend.down {
color: var(--danger);
}
.stat-value {
font-size: var(--text-3xl);
font-weight: 600;
letter-spacing: -0.03em;
margin: var(--sp-2) 0 0;
}
.stat-unit {
font-size: var(--text-lg);
color: var(--fg-muted);
margin-left: var(--sp-1);
}
.stat-compare {
font-size: var(--text-xs);
color: var(--fg-subtle);
margin-top: var(--sp-1);
}
.spark {
width: 100%;
height: 34px;
margin-top: var(--sp-3);
display: block;
}
/* ── Getting started checklist ──────────────────────────────────────────── */
.setup {
margin-bottom: var(--sp-4);
}
.setup-pct {
font-size: var(--text-lg);
font-weight: 600;
color: var(--accent);
}
.setup-bar {
height: 5px;
border-radius: var(--radius-pill);
background: var(--border);
overflow: hidden;
margin-bottom: var(--sp-4);
}
.setup-bar-fill {
height: 100%;
background: var(--accent);
border-radius: var(--radius-pill);
transition: width var(--transition);
}
.setup-list {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: var(--sp-3);
}
.setup-step {
display: flex;
gap: var(--sp-3);
align-items: flex-start;
}
.setup-check {
width: 18px;
height: 18px;
flex: none;
border-radius: 50%;
border: 1.5px solid var(--border-strong);
display: grid;
place-items: center;
font-size: var(--text-xs);
color: var(--fg-subtle);
margin-top: 1px;
}
.setup-step.done .setup-check {
background: var(--ok-soft);
border-color: transparent;
color: var(--ok);
}
.setup-step-title {
font-size: var(--text-sm);
}
.setup-step.done .setup-step-title {
color: var(--fg-muted);
text-decoration: line-through;
}
.setup-step-detail {
font-size: var(--text-xs);
color: var(--fg-subtle);
margin-top: 2px;
}
/* ── Hero: greeting and the actions that belong with it ─────────────────── */
.hero {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: var(--sp-5);
flex-wrap: wrap;
margin-bottom: var(--sp-5);
}
.hero-title {
font-size: var(--text-3xl);
font-weight: 600;
letter-spacing: -0.03em;
margin: 0;
}
.hero-sub {
color: var(--fg-muted);
font-size: var(--text-sm);
margin: var(--sp-2) 0 0;
}
.hero-actions {
display: flex;
gap: var(--sp-2);
align-items: center;
flex-wrap: wrap;
}
/* ── Top row: checklist / pulse side by side ────────────────────────────── */
.dash-top {
display: grid;
grid-template-columns: 1.6fr 1fr;
gap: var(--sp-4);
margin-bottom: var(--sp-4);
}
@media (max-width: 1080px) {
.dash-top {
grid-template-columns: 1fr;
}
}
/* ── Gauge ──────────────────────────────────────────────────────────────── */
.gauge-wrap {
position: relative;
display: grid;
place-items: center;
}
.gauge {
width: 100%;
max-width: 200px;
display: block;
}
.gauge-value {
transition: stroke-dashoffset 600ms cubic-bezier(0.4, 0, 0.2, 1);
}
.gauge-center {
position: absolute;
top: 52%;
transform: translateY(-50%);
text-align: center;
}
.gauge-pct {
font-size: var(--text-2xl);
font-weight: 600;
letter-spacing: -0.03em;
}
.gauge-label {
font-size: var(--text-xs);
color: var(--fg-muted);
}
.pulse-list {
list-style: none;
margin: var(--sp-4) 0 0;
padding: 0;
display: flex;
flex-direction: column;
gap: var(--sp-2);
}
.pulse-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--sp-3);
font-size: var(--text-sm);
padding: var(--sp-2) var(--sp-3);
border-radius: var(--radius-sm);
background: var(--bg-raised);
}
.pulse-name {
color: var(--fg-muted);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* ── Segmented bar ──────────────────────────────────────────────────────── */
.segbar {
display: flex;
height: 10px;
border-radius: var(--radius-pill);
overflow: hidden;
background: var(--border);
gap: 2px;
}
.segbar-part {
display: block;
height: 100%;
}
.segbar-ok { background: var(--ok); }
.segbar-warn { background: var(--warn); }
.segbar-danger { background: var(--danger); }
.segbar-info { background: var(--info); }
.segbar-idle { background: var(--idle); }
.segbar-legend {
display: flex;
gap: var(--sp-4);
margin-top: var(--sp-3);
flex-wrap: wrap;
}
.segbar-key {
display: inline-flex;
align-items: center;
gap: var(--sp-2);
font-size: var(--text-xs);
color: var(--fg-muted);
}
.segbar-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.forecast-value {
font-size: var(--text-3xl);
font-weight: 600;
letter-spacing: -0.03em;
margin-bottom: var(--sp-1);
}
.forecast-note {
font-size: var(--text-xs);
color: var(--fg-subtle);
margin-bottom: var(--sp-4);
}
.dash-split {
display: grid;
grid-template-columns: 1fr 1.5fr;
gap: var(--sp-4);
margin-top: var(--sp-4);
}
@media (max-width: 1080px) {
.dash-split {
grid-template-columns: 1fr;
}
}
.stat-card {
position: relative;
overflow: hidden;
}
/* ── Section grouping ───────────────────────────────────────────────────── */
/* Panels are grouped under a quiet section label so the dashboard reads as one
surface with regions, rather than a scatter of unrelated cards. */
.dash-section {
margin-bottom: var(--sp-5);
}
.dash-section-head {
display: flex;
align-items: baseline;
gap: var(--sp-3);
margin-bottom: var(--sp-3);
padding-left: var(--sp-1);
}
.dash-section-title {
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--fg-subtle);
font-weight: 600;
margin: 0;
}
.dash-section-note {
font-size: var(--text-xs);
color: var(--fg-subtle);
}
.hero-actions-inner {
display: flex;
gap: var(--sp-2);
flex-wrap: wrap;
align-items: center;
}
/* An action that exists because something needs attention should look unlike
one that is always present. */
.btn-attention {
border-color: var(--warn);
color: var(--warn);
background: var(--warn-soft);
font-weight: 500;
}
.btn-attention:hover {
background: var(--warn-soft);
filter: brightness(1.1);
}
+353
View File
@@ -0,0 +1,353 @@
import "./dashboard.css";
import { api, subscribeEvents } from "../base/api.js";
import { ago, compact, el, empty, mount, pill, statusKind } from "../base/dom.js";
import { statTile } from "../base/statTile.js";
import { gauge, segmentBar } from "../base/gauge.js";
import { icon } from "../base/icons.js";
/**
* The control room. Answers, in order: is anything wrong, what is Archie doing
* right now, and what have I not finished setting up.
*
* Every panel degrades to an explanatory empty state rather than a blank box,
* because a fresh install has no tasks and a dashboard of zeroes teaches
* nobody anything.
*/
export function dashboardPage() {
const root = el("div");
const runs = el("tbody");
const statsRow = el("div.grid.grid-4");
const setupSlot = el("div");
const pulseSlot = el("div");
const forecastSlot = el("div");
const actions = el("div.hero-actions-inner");
const title = el("h1.hero-title", greeting());
const streamState = pill("connecting", "idle");
render();
load();
const unsubscribe = subscribeEvents(
(event) => prependRun(runs, event),
(state) => {
const kind = state === "live" ? "ok" : "warn";
streamState.className = `pill pill-${kind}`;
streamState.textContent = state;
},
);
root.addEventListener("archie:teardown", unsubscribe);
function render() {
mount(
root,
el(
"div.hero",
el(
"div",
title,
el(
"p.hero-sub",
"Your agent's control room \u2014 what it is working on, what needs you, and what it is spending.",
),
),
el("div.hero-actions", actions),
),
el(
"div.dash-section",
el("div.dash-section-head", el("h2.dash-section-title", "Health")),
el("div.dash-top", setupSlot, pulseSlot),
),
el(
"div.dash-section",
el(
"div.dash-section-head",
el("h2.dash-section-title", "Throughput"),
el("span.dash-section-note", "Across all repositories"),
),
statsRow,
),
el(
"div.dash-section",
el(
"div.dash-section-head",
el("h2.dash-section-title", "Right now"),
),
el(
"div.dash-split",
forecastSlot,
el(
"div.card",
el(
"div.card-head",
el("div", el("h2.card-title", "Live activity"), el("p.card-sub", "Last 50, newest first")),
streamState,
),
el(
"table.table",
el("thead", el("tr", ...["Event", "Task", "Detail", "When"].map((h) => el("th", h)))),
runs,
),
),
),
),
);
mount(runs, el("tr", el("td", { colspan: 4 }, empty("Waiting for activity", "Events appear here as Archie works."))));
}
async function load() {
try {
const [summary, setup, workflows] = await Promise.all([
api.summary(),
api.setup().catch(() => null),
api.workflows().catch(() => null),
]);
renderActions(summary);
// The greeting is only personalised when the deployment says who it
// assists; an unconfigured instance greets without a name rather than
// inventing one.
title.textContent = setup?.operator ? `${greeting()}, ${setup.operator}` : greeting();
renderStats(summary);
renderSetup(setup);
renderPulse(summary, workflows);
renderForecast(summary);
} catch (err) {
mount(statsRow, el("div.card", empty("Cannot reach archied", String(err.message || err))));
}
}
// Actions follow state: what needs you comes first, and the generic ones
// only fill the space when nothing does. A row of buttons that is identical
// whatever is happening teaches nobody anything.
function renderActions(summary) {
const counts = summary?.statuses || {};
const blocked = (counts.parked || 0) + (counts.waiting_human || 0);
const running = counts.running || 0;
mount(
actions,
blocked > 0 &&
el(
"a.btn.btn-attention",
{ href: "#/tasks" },
icon("tasks", { size: 15 }),
`${blocked} need${blocked === 1 ? "s" : ""} you`,
),
running > 0 &&
el("a.btn", { href: "#/tasks" }, icon("workflows", { size: 15 }), `${running} running`),
el("a.btn", { href: "#/logs" }, icon("logs", { size: 15 }), "Logs"),
el("button.btn.btn-primary", { onclick: load }, icon("refresh", { size: 15 }), "Refresh"),
);
}
function renderStats(summary) {
const counts = summary?.statuses || {};
const done = (counts.merged || 0) + (counts.pr_open || 0);
const attention = (counts.parked || 0) + (counts.waiting_human || 0);
const total = Object.values(counts).reduce((a, b) => a + b, 0);
const tokens = summary?.tokens_by_day || [];
mount(
statsRow,
statTile({
label: "Working now",
value: counts.running || 0,
compare: `${counts.queued || 0} waiting to start`,
series: tokens.map((d) => d.tokens || 0),
}),
statTile({
label: "Needs you",
value: attention,
compare: attention ? "Parked or awaiting a reply" : "Nothing is blocked",
goodDirection: "down",
}),
statTile({
label: "Delivered",
value: done,
compare: total ? `${Math.round((done / total) * 100)}% of all tasks` : "No tasks yet",
}),
statTile({
label: "Tokens used",
value: compact(tokens.reduce((a, d) => a + (d.tokens || 0), 0)),
compare: `Across ${tokens.length || 0} days`,
trend: trendPct(tokens.map((d) => d.tokens || 0)),
goodDirection: "down",
series: tokens.map((d) => d.tokens || 0),
}),
);
}
function renderSetup(setup) {
if (!setup?.steps?.length) return mount(setupSlot);
const remaining = setup.steps.filter((s) => !s.done);
if (!remaining.length) return mount(setupSlot);
const pct = Math.round(((setup.steps.length - remaining.length) / setup.steps.length) * 100);
mount(
setupSlot,
el(
"div.card.setup",
el(
"div.card-head",
el(
"div",
el("h2.card-title", "Finish setting up"),
el("p.card-sub", "Archie needs these before it can work on its own."),
),
el("span.setup-pct", `${pct}%`),
),
el("div.setup-bar", el("div.setup-bar-fill", { style: `width:${pct}%` })),
el("ul.setup-list", ...setup.steps.map(setupStep)),
),
);
}
function renderPulse(summary, workflows) {
renderPulseInto(pulseSlot, summary, workflows);
}
function renderForecast(summary) {
renderForecastInto(forecastSlot, summary);
}
function setupStep(step) {
return el(
`li.setup-step${step.done ? ".done" : ""}`,
el("span.setup-check", step.done ? icon("check", { size: 12 }) : ""),
el("div", el("div.setup-step-title", step.title), step.detail && el("div.setup-step-detail", step.detail)),
);
}
return root;
}
function prependRun(tbody, event) {
if (tbody.firstElementChild?.querySelector(".empty")) tbody.replaceChildren();
const row = el(
"tr",
el("td.strong", el("span", event.kind || event.type || "event")),
el("td.mono", event.task_id ? `#${event.task_id}` : "—"),
el("td", event.detail || event.message || ""),
el("td", ago(event.at || Date.now())),
);
tbody.prepend(row);
while (tbody.children.length > 50) tbody.lastElementChild.remove();
}
function greeting() {
const h = new Date().getHours();
if (h < 5) return "Still up?";
if (h < 12) return "Good morning";
if (h < 18) return "Good afternoon";
return "Good evening";
}
/**
* Gate pulse: the share of finished work that got through the quality gates.
*
* This is the dashboard's headline health number -- Archie's whole promise is
* that it does not open a PR until the gates pass, so a falling pass rate is
* the first thing worth seeing.
*/
function renderPulseInto(slot, summary, workflows) {
const stats = workflows?.workflows || [];
const runs = stats.reduce((a, w) => a + (w.runs || 0), 0);
const merged = stats.reduce((a, w) => a + (w.merged || 0) + (w.pr_open || 0), 0);
const parked = stats.reduce((a, w) => a + (w.parked || 0), 0);
if (!runs) {
mount(
slot,
el(
"div.card",
el("div.card-head", el("h2.card-title", "Gate pulse")),
empty("No completed runs yet", "Once Archie finishes a task, its gate pass rate appears here."),
),
);
return;
}
const pct = (merged / runs) * 100;
mount(
slot,
el(
"div.card",
el(
"div.card-head",
el(
"div",
el("h2.card-title", "Gate pulse"),
el("p.card-sub", "Work that passed its quality gates"),
),
),
gauge({ value: pct, label: "pass rate" }),
el(
"ul.pulse-list",
...stats.slice(0, 3).map((w) =>
el(
"li.pulse-item",
el("span.pulse-name", w.workflow || "workflow"),
pill(
`${w.merged || 0}/${w.runs || 0}`,
(w.merged || 0) === (w.runs || 0) ? "ok" : (w.parked || 0) > 0 ? "warn" : "info",
),
),
),
parked > 0 &&
el("li.pulse-item", el("span.pulse-name", "Parked, awaiting you"), pill(String(parked), "warn")),
),
),
);
}
/**
* Budget outlook: what this month's token spend is tracking toward, and how
* much of the configured budget it accounts for.
*/
function renderForecastInto(slot, summary) {
const days = summary?.tokens_by_day || [];
const used = days.reduce((a, d) => a + (d.tokens || 0), 0);
if (!days.length) {
mount(
slot,
el(
"div.card",
el("div.card-head", el("h2.card-title", "Token outlook")),
empty("Nothing spent yet", "Usage appears here once Archie runs its first task."),
),
);
return;
}
const perDay = used / days.length;
const projected = Math.round(perDay * 30);
const recent = days.slice(-7).reduce((a, d) => a + (d.tokens || 0), 0);
mount(
slot,
el(
"div.card",
el(
"div.card-head",
el("div", el("h2.card-title", "Token outlook"), el("p.card-sub", "Next 30 days at the current rate")),
),
el("div.forecast-value", compact(projected)),
el("div.forecast-note", `Based on ${compact(Math.round(perDay))} per day over ${days.length} days`),
segmentBar([
{ label: `Last 7 days (${compact(recent)})`, value: recent, kind: "info" },
{ label: `Earlier (${compact(used - recent)})`, value: Math.max(used - recent, 0), kind: "idle" },
]),
),
);
}
/** Percentage change between the first and second half of a series. */
function trendPct(series) {
if (series.length < 4) return null;
const mid = Math.floor(series.length / 2);
const older = series.slice(0, mid).reduce((a, b) => a + b, 0);
const newer = series.slice(mid).reduce((a, b) => a + b, 0);
if (!older) return null;
return ((newer - older) / older) * 100;
}
+145
View File
@@ -0,0 +1,145 @@
/* Log view. Dense by design: the point is scanning many lines quickly, so the
type is smaller and the rows tighter than elsewhere in the dashboard. */
.log-filters {
display: flex;
gap: var(--sp-2);
align-items: center;
flex-wrap: wrap;
}
.log-status {
display: flex;
gap: var(--sp-3);
align-items: center;
}
.log-meta {
font-size: var(--text-xs);
color: var(--fg-subtle);
font-family: var(--font-mono);
}
.log-select,
.log-search {
background: var(--bg-raised);
border: 1px solid var(--border-strong);
color: var(--fg);
border-radius: var(--radius-sm);
padding: var(--sp-2) var(--sp-3);
font: inherit;
font-size: var(--text-sm);
}
.log-search {
min-width: 220px;
}
.log-select:focus,
.log-search:focus {
outline: 2px solid var(--accent);
outline-offset: -1px;
}
.log-list {
max-height: 62vh;
overflow-y: auto;
font-family: var(--font-mono);
font-size: var(--text-xs);
border-top: 1px solid var(--border);
}
.log-loading {
padding: var(--sp-5);
color: var(--fg-muted);
text-align: center;
}
.log-row {
display: grid;
grid-template-columns: 62px 52px 1fr;
gap: var(--sp-3);
padding: var(--sp-2) var(--sp-1);
border-bottom: 1px solid var(--border);
align-items: baseline;
}
.log-row:hover {
background: var(--surface-hover);
}
.log-time {
color: var(--fg-subtle);
}
.log-level {
font-size: 10px;
font-weight: 600;
letter-spacing: 0.04em;
}
/* Level colour lives on the row so the message inherits emphasis without a
second rule per level. */
.log-danger .log-level {
color: var(--danger);
}
.log-warn .log-level {
color: var(--warn);
}
.log-info .log-level {
color: var(--info);
}
.log-idle .log-level {
color: var(--idle);
}
.log-danger .log-msg {
color: var(--fg);
}
.log-body {
display: flex;
flex-wrap: wrap;
gap: var(--sp-2);
align-items: baseline;
min-width: 0;
}
.log-msg {
color: var(--fg);
word-break: break-word;
}
/* Structured fields read as attached detail, not part of the sentence. */
.log-field {
color: var(--fg-muted);
background: var(--bg-raised);
border-radius: var(--radius-sm);
padding: 0 var(--sp-2);
white-space: nowrap;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
.log-field-key {
color: var(--fg-subtle);
}
.log-field-key::after {
content: "=";
opacity: 0.6;
}
@media (max-width: 860px) {
.log-row {
grid-template-columns: 56px 1fr;
}
.log-level {
display: none;
}
.log-search {
min-width: 0;
flex: 1;
}
}
+233
View File
@@ -0,0 +1,233 @@
import "./logs.css";
import { api, subscribeEvents } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
/**
* The log view: history from the file on disk, then live lines appended from
* the event stream.
*
* Filtering is applied server-side for history (the file is far larger than a
* page of it) and client-side for live lines (they are already in hand). Both
* paths go through the same matcher shape so a filter means the same thing
* either side of the join.
*/
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 levelKind(level) {
switch ((level || "").toUpperCase()) {
case "ERROR":
return "danger";
case "WARN":
return "warn";
case "DEBUG":
return "idle";
default:
return "info";
}
}
export function logsPage() {
const root = el("div");
const list = el("div.log-list");
const streamState = pill("connecting", "idle");
const meta = el("span.log-meta");
let filters = { level: "", component: "", q: "" };
let paused = false;
let componentOptions = [];
const levelSelect = el(
"select.log-select",
{ onchange: (e) => set({ level: e.target.value }) },
...LEVELS.map((l) => el("option", { value: l.value }, l.label)),
);
const componentSelect = el("select.log-select", {
onchange: (e) => set({ component: e.target.value }),
});
const search = el("input.log-search", {
type: "search",
placeholder: "Search messages and fields…",
oninput: debounce((e) => set({ q: e.target.value }), 250),
});
const pauseBtn = el("button.btn", { onclick: togglePause }, "Pause");
render();
load();
const unsubscribe = subscribeEvents(
(event) => appendLive(event),
(state) => {
streamState.className = `pill pill-${state === "live" ? "ok" : "warn"}`;
streamState.textContent = state;
},
);
root.addEventListener("archie:teardown", unsubscribe);
function set(patch) {
filters = { ...filters, ...patch };
load();
}
function togglePause() {
paused = !paused;
pauseBtn.textContent = paused ? "Resume" : "Pause";
pauseBtn.classList.toggle("btn-primary", paused);
}
function render() {
mount(
root,
el(
"div.page-head",
el(
"div",
el("h1.page-title", "Logs"),
el("p.page-sub", "What Archie has been doing, newest last."),
),
el("div.page-actions", pauseBtn, el("button.btn", { onclick: load }, "Refresh")),
),
el(
"div.card",
el(
"div.card-head",
el("div.log-filters", levelSelect, componentSelect, search),
el("div.log-status", meta, streamState),
),
list,
),
);
}
async function load() {
mount(list, el("div.log-loading", "Loading…"));
try {
const res = await api.logs({
level: filters.level,
component: filters.component,
q: filters.q,
limit: 500,
});
if (res.disabled) {
mount(
list,
empty(
"File logging is off",
"Set [log] file in your config to keep a durable record. Live lines below still stream while this page is open.",
),
);
meta.textContent = "";
return;
}
syncComponents(res.components || []);
meta.textContent = res.truncated
? `showing the most recent matches from ${res.file}`
: res.file || "";
const entries = res.entries || [];
if (!entries.length) {
mount(list, empty("Nothing matches", "Try a wider level or clear the search."));
return;
}
mount(list, ...entries.map(row));
list.scrollTop = list.scrollHeight;
} catch (err) {
mount(list, empty("Cannot read logs", String(err.message || err)));
}
}
// Rebuild the component filter from what the log actually contains, so the
// options never drift from reality.
function syncComponents(components) {
if (sameList(components, componentOptions)) return;
componentOptions = components;
const current = filters.component;
mount(
componentSelect,
el("option", { value: "" }, "All components"),
...components.map((c) => el("option", { value: c }, c)),
);
componentSelect.value = current;
}
function appendLive(event) {
if (paused) return;
const entry = {
time: event.at || new Date().toISOString(),
level: event.level || "INFO",
msg: event.detail || event.message || event.kind || "event",
fields: event.task_id ? { task: event.task_id } : null,
};
if (!matchesLocally(entry)) return;
// Only auto-scroll when already at the bottom, so reading history is not
// yanked away by an arriving line.
const atBottom = list.scrollHeight - list.scrollTop - list.clientHeight < 40;
if (list.querySelector(".empty, .log-loading")) list.replaceChildren();
list.append(row({ ...entry, message: entry.msg }));
while (list.children.length > 1000) list.firstElementChild.remove();
if (atBottom) list.scrollTop = list.scrollHeight;
}
function matchesLocally(entry) {
if (filters.level && !filters.level.split(",").includes((entry.level || "").toUpperCase())) {
return false;
}
if (filters.component && entry.fields?.component !== filters.component) return false;
if (filters.q) {
const needle = filters.q.toLowerCase();
const hay = `${entry.msg} ${JSON.stringify(entry.fields || {})}`.toLowerCase();
if (!hay.includes(needle)) return false;
}
return true;
}
return root;
}
function row(entry) {
const fields = entry.fields || {};
return el(
`div.log-row.log-${levelKind(entry.level)}`,
el("span.log-time.mono", shortTime(entry.time)),
el("span.log-level", (entry.level || "info").toUpperCase()),
el(
"span.log-body",
el("span.log-msg", entry.message || entry.msg || ""),
...Object.entries(fields).map(([k, v]) =>
el("span.log-field", el("span.log-field-key", k), String(fmtValue(v))),
),
),
);
}
function fmtValue(v) {
if (v == null) return "";
return typeof v === "object" ? JSON.stringify(v) : v;
}
function shortTime(value) {
const d = value instanceof Date ? value : new Date(value);
if (Number.isNaN(d.getTime())) return "--:--:--";
return d.toTimeString().slice(0, 8);
}
function sameList(a, b) {
return a.length === b.length && a.every((v, i) => v === b[i]);
}
function debounce(fn, ms) {
let t;
return (...args) => {
clearTimeout(t);
t = setTimeout(() => fn(...args), ms);
};
}
+164
View File
@@ -0,0 +1,164 @@
import "./css/_main.css";
import { el, mount } from "./base/dom.js";
import { icon } from "./base/icons.js";
import { dashboardPage } from "./dashboard/dashboard.js";
import { tasksPage } from "./tasks/tasks.js";
import { skillsPage } from "./skills/skills.js";
import { workflowsPage } from "./workflows/workflows.js";
import { channelsPage } from "./channels/channels.js";
import { settingsPage } from "./settings/settings.js";
import { logsPage } from "./logs/logs.js";
import { memoryPage } from "./memory/memory.js";
/**
* Routes are declared once here. Adding a section means adding a feature
* folder and one entry -- there is no switch statement to hunt for.
*
* `soon: true` sections are deliberately visible before they are built: a
* greyed, labelled entry tells you the capability exists and is coming, which
* is more honest than hiding it and more useful than a 404.
*/
const routes = [
{ path: "/", label: "Dashboard", icon: "dashboard", view: dashboardPage },
{ path: "/tasks", label: "Tasks", icon: "tasks", view: tasksPage },
{ path: "/logs", label: "Logs", icon: "logs", view: logsPage },
{ path: "/skills", label: "Skills", icon: "skills", view: skillsPage },
{ path: "/workflows", label: "Workflows", icon: "workflows", view: workflowsPage },
{ path: "/memory", label: "Memory", icon: "memory", view: memoryPage },
{ path: "/channels", label: "Channels", icon: "channels", view: channelsPage },
{ path: "/settings", label: "Configuration", icon: "settings", view: settingsPage },
];
const THEME_KEY = "archie.theme";
function applyTheme(theme) {
document.documentElement.dataset.theme = theme;
localStorage.setItem(THEME_KEY, theme);
}
function currentTheme() {
return localStorage.getItem(THEME_KEY) || "dark";
}
function commandBar(onNavigate) {
const items = new Map();
const nav = el(
"nav.nav",
...[null].flatMap(() => [
...routes
.map((route) => {
const item = el(
"a.nav-item",
{
href: `#${route.path}`,
onclick: (e) => {
if (route.soon) e.preventDefault();
else onNavigate(route.path);
},
"aria-disabled": route.soon || undefined,
title: route.soon ? "Coming soon" : undefined,
},
icon(route.icon),
el("span.nav-label", route.label),
route.soon && el("span.nav-soon", "soon"),
);
items.set(route.path, item);
return item;
}),
]),
);
const themeBtn = el("button.icon-btn", {
title: "Toggle light and dark",
"aria-label": "Toggle light and dark",
onclick: () => {
applyTheme(currentTheme() === "dark" ? "light" : "dark");
mount(themeBtn, icon(currentTheme() === "dark" ? "moon" : "sun"));
},
});
mount(themeBtn, icon(currentTheme() === "dark" ? "moon" : "sun"));
// Search jumps between sections. It is deliberately not a data search: the
// sections own their own filtering, and a second search that means something
// different in each place is worse than none.
const search = el("input", {
type: "search",
placeholder: "Jump to\u2026",
"aria-label": "Jump to a section",
onkeydown: (e) => {
if (e.key !== "Enter") return;
const q = e.target.value.trim().toLowerCase();
const hit = routes.find((r) => !r.soon && r.label.toLowerCase().startsWith(q));
if (hit) {
onNavigate(hit.path);
e.target.value = "";
e.target.blur();
}
},
});
return {
node: el(
"header.topbar",
el("div.brand", el("span.brand-mark", "A"), "Archie"),
nav,
el(
"div.topbar-end",
el("div.topbar-search", icon("search", { size: 15 }), search),
el("button.icon-btn", { title: "Documentation", "aria-label": "Documentation" }, icon("help")),
themeBtn,
el("div.avatar", { title: "Signed in locally" }, "A"),
),
),
highlight(path) {
for (const [p, node] of items) {
if (p === path) node.setAttribute("aria-current", "page");
else node.removeAttribute("aria-current");
}
},
};
}
function start() {
applyTheme(currentTheme());
const outlet = el("main.main");
const bar = commandBar(navigate);
mount(document.getElementById("app"), el("div.shell", bar.node, outlet));
function navigate(path) {
if (location.hash !== `#${path}`) location.hash = path;
else show(path);
}
function show(path) {
// Let a page release its subscriptions before it is replaced, so the SSE
// stream does not leak a connection per navigation.
outlet.firstElementChild?.dispatchEvent(new CustomEvent("archie:teardown"));
const route = routes.find((r) => r.path === path) || routes[0];
bar.highlight(route.path);
mount(outlet, route.view ? route.view() : comingSoon(route));
}
window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/"));
show(location.hash.slice(1) || "/");
}
function comingSoon(route) {
return el(
"div",
el("div.page-head", el("div", el("h1.page-title", route.label))),
el(
"div.card",
el(
"div.empty",
el("div.empty-title", `${route.label} is not built yet`),
el("div", "This section is next up. Nothing is broken."),
),
),
);
}
start();
+44
View File
@@ -0,0 +1,44 @@
/* Memory view: provider cards listing the tools each gives the agent. */
.mem-loading {
padding: var(--sp-5);
text-align: center;
color: var(--fg-muted);
}
.mem-warning {
font-size: var(--text-sm);
color: var(--warn);
background: var(--warn-soft);
border-radius: var(--radius-sm);
padding: var(--sp-2) var(--sp-3);
margin: 0 0 var(--sp-3);
}
.mem-tools {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: var(--sp-2);
}
.mem-tool {
padding: var(--sp-3);
border-radius: var(--radius-sm);
background: var(--bg-raised);
border: 1px solid var(--hairline);
}
.mem-tool-name {
font-size: var(--text-sm);
color: var(--fg);
font-weight: 500;
}
.mem-tool-desc {
font-size: var(--text-xs);
color: var(--fg-muted);
margin-top: 2px;
}
+102
View File
@@ -0,0 +1,102 @@
import "./memory.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
import { icon } from "../base/icons.js";
/**
* Memory: what Archie can recall, and with what.
*
* Memory is otherwise invisible -- it is a set of tools handed to the model at
* discovery time, so without this page the only way to know what the agent can
* remember is to read the provider source.
*/
export function memoryPage() {
const root = el("div");
const body = el("div");
render();
load();
function render() {
mount(
root,
el(
"div.page-head",
el(
"div",
el("h1.page-title", "Memory"),
el("p.page-sub", "What Archie can recall between conversations, and the tools it uses to do it."),
),
el("div.page-actions", el("button.btn", { onclick: load }, icon("refresh", { size: 15 }), "Refresh")),
),
body,
);
}
async function load() {
mount(body, el("div.card", el("div.mem-loading", "Loading…")));
try {
const res = await api.memory();
if (!res.enabled || !res.providers?.length) {
mount(
body,
el(
"div.card",
empty(
"Memory is not configured",
"Without a provider, Archie starts every conversation with no recollection of earlier ones.",
),
),
);
return;
}
mount(body, el("div.grid.grid-2", ...res.providers.map(providerCard)));
} catch (err) {
mount(body, el("div.card", empty("Cannot read memory providers", String(err.message || err))));
}
}
return root;
}
function providerCard(p) {
const tools = p.tools || [];
return el(
"div.card",
el(
"div.card-head",
el(
"div",
el("h2.card-title", p.name || "provider"),
el("p.card-sub", roleLabel(p.role)),
),
p.available
? pill("ready", "ok")
: pill("unavailable", "danger"),
),
!p.available &&
el(
"p.mem-warning",
"Configured but not usable right now — a required binary or connection may be missing.",
),
tools.length
? el(
"ul.mem-tools",
...tools.map((t) =>
el(
"li.mem-tool",
el("div.mem-tool-name.mono", t.name),
t.description && el("div.mem-tool-desc", t.description),
),
),
)
: el("p.mem-warning", "This provider exposes no tools, so the agent cannot use it."),
);
}
// Plain language: "builtin" and "external" are implementation words.
function roleLabel(role) {
return role === "external"
? "Added by you — an external store Archie was given"
: "Built in — always available to Archie";
}
+46
View File
@@ -0,0 +1,46 @@
/* Configuration-only styles. */
.cfg-section {
margin-bottom: var(--sp-4);
}
.cfg-subhead {
font-size: var(--text-sm);
font-weight: 600;
color: var(--fg-muted);
margin: var(--sp-4) 0 var(--sp-2);
}
.cfg-subhead:first-child {
margin-top: 0;
}
.cfg-rows {
display: flex;
flex-direction: column;
gap: var(--sp-2);
}
.cfg-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: var(--sp-4);
padding: var(--sp-2) 0;
border-bottom: 1px solid var(--border);
}
.cfg-row:last-child {
border-bottom: 0;
}
.cfg-label {
font-size: var(--text-sm);
color: var(--fg-muted);
}
.cfg-value {
font-size: var(--text-sm);
color: var(--fg);
text-align: right;
}
+273
View File
@@ -0,0 +1,273 @@
import "./settings.css";
import { api } from "../base/api.js";
import { el, empty, mount, pill } from "../base/dom.js";
/**
* A read-only view of the config archied is actually running with, grouped
* by domain and explained in plain language. Backed by GET /api/config,
* which is built from an explicit, hand-picked allowlist on the Go side
* (internal/webui/api_config.go handleConfig) -- secrets never reach this
* page, so nothing here needs to be hidden or redacted client-side.
*/
export function settingsPage() {
const root = el("div");
const body = el("div");
render();
load();
function render() {
mount(
root,
el(
"div.page-head",
el(
"div",
el("h1.page-title", "Configuration"),
el("p.page-sub", "What archied is actually running with right now."),
),
el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
),
body,
);
}
async function load() {
try {
const cfg = await api.config();
renderBody(cfg);
} catch (err) {
mount(body, el("div.card", empty("Cannot reach archied", String(err.message || err))));
}
}
function renderBody(cfg) {
if (!cfg || Object.keys(cfg).length === 0) {
mount(
body,
el(
"div.card",
empty(
"No configuration loaded",
"archied is running without a config file wired into the dashboard, so there is nothing to show.",
),
),
);
return;
}
mount(
body,
identityCard(cfg.identity),
repositoriesCard(cfg.repositories),
modelsAndProvidersCard(cfg.models, cfg.providers),
budgetsCard(cfg.budgets),
agentCard(cfg.agent),
storageCard(cfg.storage, cfg.containers),
webCard(cfg.web),
);
}
return root;
}
function section(title, sub, ...children) {
return el(
"div.card.cfg-section",
el("div.card-head", el("div", el("h2.card-title", title), el("p.card-sub", sub))),
...children,
);
}
function row(label, value) {
return el("div.cfg-row", el("span.cfg-label", label), el("span.cfg-value.mono", value ?? "—"));
}
function identityCard(identity) {
if (!identity) return section("Identity", "Who Archie is on the forge.", empty("Not available"));
return section(
"Identity",
"Who Archie is on the forge, and how it addresses commits and comments.",
el(
"div.cfg-rows",
row("Bot account", identity.bot_user),
row("Commit author email", identity.bot_email),
row("Pickup label", identity.label),
row("Forge type", identity.forge_type),
row("Forge host", identity.forge_host),
row("Max diff size (lines)", identity.diff_cap_lines),
),
);
}
function repositoriesCard(repos) {
if (!repos?.length) {
return section(
"Repositories",
"The repositories Archie polls for work.",
empty("No repositories configured", "Add a [[repos]] entry in config.toml so Archie has somewhere to work."),
);
}
return section(
"Repositories",
"Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
el(
"table.table",
el(
"thead",
el("tr", ...["Repository", "Base branch", "Ecosystem", "Quality gate", "Protected paths"].map((h) => el("th", h))),
),
el(
"tbody",
...repos.map((r) =>
el(
"tr",
el("td.strong", `${r.owner}/${r.name}`),
el("td.mono", r.base),
el("td", r.ecosystem || "go"),
el("td.mono", gateSummary(r.gate)),
el("td.mono", r.protect?.length ? r.protect.join(", ") : "—"),
),
),
),
),
);
}
function gateSummary(gate) {
if (!gate?.length) return "—";
return gate.map((cmd) => cmd.join(" ")).join(" → ");
}
function modelsAndProvidersCard(models, providers) {
const modelEntries = Object.entries(models || {});
const providerEntries = Object.entries(providers || {});
const modelRows = modelEntries.length
? el("div.cfg-rows", ...modelEntries.map(([role, ref]) => row(roleLabel(role), ref)))
: empty("No model roles configured", "Assign a model to at least one role (e.g. \"builder\") in [models].");
const providerRows = providerEntries.length
? el(
"table.table",
el("thead", el("tr", ...["Provider", "Class", "Base URL", "API key env var", "Status"].map((h) => el("th", h)))),
el(
"tbody",
...providerEntries.map(([name, p]) =>
el(
"tr",
el("td.strong", name),
el("td", p.class),
el("td.mono", p.base_url || "default"),
el("td.mono", p.api_key_env || "—"),
el("td", p.configured ? pill("configured", "ok") : pill("missing credentials", "warn")),
),
),
),
)
: empty("No providers configured", "Add a [providers.<name>] entry so a model role above has something to run on.");
return section(
"Models & providers",
"Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.",
el("h3.cfg-subhead", "Model roles"),
modelRows,
el("h3.cfg-subhead", "Providers"),
providerRows,
);
}
function roleLabel(role) {
if (!role) return "Unknown role";
return role.charAt(0).toUpperCase() + role.slice(1).replace(/_/g, " ");
}
function budgetsCard(budgets) {
if (!budgets) return section("Budgets", "Limits on every agent stage.", empty("Not available"));
return section(
"Budgets",
"The limits every autonomous stage runs under, so a stuck task cannot run forever.",
el(
"div.cfg-rows",
row("Max steps", budgets.max_steps || "Unlimited"),
row("Max tokens", budgets.max_tokens || "Unlimited"),
row("Wall clock", budgets.wall_clock),
row("Max gate failures before parking", budgets.gate_max_failures || "Unlimited"),
),
);
}
function agentCard(agent) {
if (!agent) return section("Agent execution", "How Archie runs autonomous stages.", empty("Not available"));
return section(
"Agent execution",
"How archied actually runs a stage of work.",
el(
"div.cfg-rows",
row("Execution mode", agentModeLabel(agent.mode)),
row("Worker command", agent.command),
row("Extra environment variables passed through", agent.env?.length ? agent.env.join(", ") : "None"),
),
);
}
function agentModeLabel(mode) {
switch (mode) {
case "inprocess":
return "In-process (same binary as the daemon)";
case "subprocess":
return "Subprocess (separate archie-agent process)";
case "nats":
return "NATS (dispatched to a worker over the message bus)";
default:
return mode || "Not set";
}
}
function storageCard(storage, containers) {
const children = [];
if (storage) {
children.push(
el("h3.cfg-subhead", "Paths"),
el(
"div.cfg-rows",
row("Work directory", storage.work_dir),
row("Task database", storage.db_path),
row("Shared skills directory", storage.skills_dir || "None (uses the work directory)"),
row("Daemon plugin directory", storage.plugin_dir || "None"),
row("Secret engine plugin directory", storage.secret_engine_dir || "None (built-in engines only)"),
),
);
}
if (containers) {
children.push(
el("h3.cfg-subhead", "Sandboxed containers"),
el(
"div.cfg-rows",
row("Sandboxing enabled", containers.enabled ? "Yes" : "No"),
row("Agent image", containers.image || "Not set"),
row("Max concurrent tasks", containers.max_concurrency || "Unlimited"),
row("Container max lifetime", containers.max_uptime),
row("Persistent volume retention", containers.volume_ttl),
row("How images are refreshed", pullPolicyLabel(containers.pull_policy)),
row("Docker network", containers.network || "Auto-detected"),
),
);
}
if (!children.length) children.push(empty("Not available"));
return section("Storage & sandboxing", "Where archied keeps its state, and how it isolates task execution.", ...children);
}
function pullPolicyLabel(policy) {
if (policy === "always") return "Always pull the latest image before running";
return "Only pull when the image is missing locally";
}
function webCard(web) {
if (!web) return section("Dashboard", "This dashboard's own listen address.", empty("Not available"));
return section(
"Dashboard",
"This dashboard's own listen address.",
el("div.cfg-rows", row("Listen address", web.listen === "off" ? "Disabled" : web.listen)),
);
}
+34
View File
@@ -0,0 +1,34 @@
/* Skills-only styles. */
.skill-search {
font: inherit;
font-size: var(--text-sm);
color: var(--fg);
background: var(--surface);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
padding: var(--sp-2) var(--sp-3);
width: 220px;
}
.skill-search:focus {
outline: 2px solid var(--accent-soft);
outline-offset: 1px;
}
.skill-card {
display: flex;
flex-direction: column;
}
.skill-desc {
color: var(--fg-muted);
font-size: var(--text-sm);
margin: 0 0 var(--sp-3);
flex: 1;
}
.skill-source {
font-size: var(--text-xs);
color: var(--fg-subtle);
}
+113
View File
@@ -0,0 +1,113 @@
import "./skills.css";
import { api } from "../base/api.js";
import { el, empty, mount } from "../base/dom.js";
/**
* What Archie can actually do, beyond what is in the source. Backed by
* GET /api/skills, which scans .agents/skills/<name>/SKILL.md (see
* internal/skill.Catalog) and returns each skill's name, plain-language
* description, and where it was found.
*
* This page exists for someone who has never read the source: a search box
* over a card grid, and an empty state that explains what a skill is and
* how to add one rather than a blank box.
*/
export function skillsPage() {
const root = el("div");
const cardGrid = el("div.grid.grid-2");
const searchInput = el("input.skill-search", {
type: "search",
placeholder: "Search skills…",
oninput: (e) => {
search = e.target.value.trim().toLowerCase();
renderCards();
},
});
let skills = [];
let search = "";
let loadError = null;
render();
load();
function render() {
mount(
root,
el(
"div.page-head",
el(
"div",
el("h1.page-title", "Skills"),
el("p.page-sub", "What Archie can do, in plain language."),
),
el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
),
el(
"div.card",
el(
"div.card-head",
el("div", el("h2.card-title", "Catalogue"), el("p.card-sub", "Discovered from .agents/skills/")),
searchInput,
),
cardGrid,
),
);
renderCards();
}
async function load() {
try {
const res = await api.skills();
skills = res?.skills || [];
loadError = null;
} catch (err) {
skills = [];
loadError = String(err.message || err);
}
renderCards();
}
function renderCards() {
if (loadError) {
return mount(cardGrid, empty("Cannot reach archied", loadError));
}
if (!skills.length) {
return mount(
cardGrid,
empty(
"No skills discovered yet",
"Skills live as SKILL.md files under .agents/skills/<name>/. Add one, or point skills_dir in config.toml at a shared skills directory, and it will appear here.",
),
);
}
const filtered = skills.filter((s) => matches(s, search));
if (!filtered.length) {
return mount(cardGrid, empty("No skills match", `Nothing found for "${search}".`));
}
mount(cardGrid, ...filtered.map(skillCard));
}
function matches(skill, term) {
if (!term) return true;
const haystack = `${skill.name} ${skill.description}`.toLowerCase();
return haystack.includes(term);
}
function skillCard(skill) {
return el(
"div.card.skill-card",
el(
"div.card-head",
el("h3.card-title", skill.name || "Untitled skill"),
skill.workflow && el("span.pill.pill-info", skill.workflow),
),
el("p.skill-desc", skill.description || "No description provided."),
el("div.skill-source", skill.source || "Unknown source"),
);
}
return root;
}
+84
View File
@@ -0,0 +1,84 @@
/* Tasks-only styles. */
.task-filters {
display: flex;
gap: var(--sp-2);
align-items: center;
}
.task-search,
.task-filter {
font: inherit;
font-size: var(--text-sm);
color: var(--fg);
background: var(--surface);
border: 1px solid var(--border-strong);
border-radius: var(--radius-sm);
padding: var(--sp-2) var(--sp-3);
}
.task-search {
width: 220px;
}
.task-search:focus,
.task-filter:focus {
outline: 2px solid var(--accent-soft);
outline-offset: 1px;
}
.task-row {
cursor: pointer;
}
.task-timeline-row td {
background: var(--bg-raised);
padding: var(--sp-4);
}
.task-timeline-loading {
color: var(--fg-muted);
font-size: var(--text-sm);
}
.task-timeline {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: var(--sp-3);
}
.task-timeline-entry {
display: flex;
gap: var(--sp-3);
align-items: flex-start;
}
.task-timeline-dot {
width: 8px;
height: 8px;
margin-top: 5px;
flex: none;
border-radius: 50%;
background: var(--accent);
}
.task-timeline-kind {
font-size: var(--text-sm);
font-weight: 500;
color: var(--fg);
}
.task-timeline-detail {
font-size: var(--text-xs);
color: var(--fg-muted);
margin-top: 2px;
}
.task-timeline-when {
font-size: var(--text-xs);
color: var(--fg-subtle);
margin-top: 2px;
}
+248
View File
@@ -0,0 +1,248 @@
import "./tasks.css";
import { api } from "../base/api.js";
import { ago, el, empty, mount, pill, statusKind } from "../base/dom.js";
import { statTile } from "../base/statTile.js";
/**
* Plain-language status labels. One place, so "waiting_human" only ever
* reads as "Waiting for you" wherever a task list is shown.
*/
const STATUS_LABELS = {
queued: "Queued",
running: "Working",
waiting_human: "Waiting for you",
pr_open: "In review",
merged: "Merged",
parked: "Parked",
dead: "Stopped (too many retries)",
rejected: "Rejected",
closed_wont_do: "Won't do",
};
function statusLabel(status) {
return STATUS_LABELS[status] || status || "Unknown";
}
/**
* The work board: every task archied knows about, filterable by status and
* text, with a per-task event timeline available on click. Task rows carry
* carries created_at/updated_at, so age is shown in the list and once
* a row's timeline is loaded, sourced from its most recent event.
*/
export function tasksPage() {
const root = el("div");
const summaryRow = el("div.grid.grid-4");
const body = el("tbody");
const searchInput = el("input.task-search", {
type: "search",
placeholder: "Search by title or repo…",
oninput: (e) => {
search = e.target.value.trim().toLowerCase();
renderRows();
},
});
const statusSelect = el(
"select.task-filter",
{
onchange: (e) => {
filterStatus = e.target.value;
renderRows();
},
},
el("option", { value: "" }, "All statuses"),
...Object.entries(STATUS_LABELS).map(([value, label]) => el("option", { value }, label)),
);
let tasks = [];
let filterStatus = "";
let search = "";
let expandedId = null;
const eventCache = new Map();
render();
load();
function render() {
mount(
root,
el(
"div.page-head",
el(
"div",
el("h1.page-title", "Tasks"),
el("p.page-sub", "Every issue archied has picked up, and where it stands."),
),
el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
),
summaryRow,
el(
"div.card",
el(
"div.card-head",
el("div", el("h2.card-title", "All tasks"), el("p.card-sub", "Click a row for its timeline")),
el("div.task-filters", searchInput, statusSelect),
),
el(
"table.table",
el(
"thead",
el(
"tr",
...["Repo", "Issue", "Title", "Status", "Workflow", "Stage", "Last activity"].map((h) => el("th", h)),
),
),
body,
),
),
);
}
async function load() {
try {
tasks = await api.tasks();
renderSummary();
renderRows();
} catch (err) {
mount(summaryRow, el("div.card", empty("Cannot reach archied", String(err.message || err))));
mount(body, el("tr", el("td", { colspan: 7 }, empty("Cannot reach archied", String(err.message || err)))));
}
}
function renderSummary() {
const total = tasks.length;
const counts = {};
for (const t of tasks) counts[t.status] = (counts[t.status] || 0) + 1;
const working = counts.running || 0;
const needsYou = (counts.waiting_human || 0) + (counts.parked || 0);
const delivered = (counts.merged || 0) + (counts.pr_open || 0);
mount(
summaryRow,
statTile({
label: "Total tasks",
value: total,
compare: total ? "Everything archied has ever picked up" : "No tasks yet",
}),
statTile({
label: "Working now",
value: working,
compare: total ? `${working} of ${total} in progress` : "Nothing running",
}),
statTile({
label: "Needs you",
value: needsYou,
compare: needsYou ? "Parked or awaiting a reply" : "Nothing is blocked",
goodDirection: "down",
}),
statTile({
label: "Delivered",
value: delivered,
compare: total ? `${Math.round((delivered / total) * 100)}% of all tasks` : "No tasks yet",
}),
);
}
function filtered() {
return tasks.filter((t) => {
if (filterStatus && t.status !== filterStatus) return false;
if (!search) return true;
const hay = `${t.title} ${t.repo}`.toLowerCase();
return hay.includes(search);
});
}
function renderRows() {
const rows = filtered();
if (!tasks.length) {
mount(
body,
el(
"tr",
el(
"td",
{ colspan: 7 },
empty("No tasks yet", "Tasks appear here once archied picks up an issue to work."),
),
),
);
return;
}
if (!rows.length) {
mount(
body,
el("tr", el("td", { colspan: 7 }, empty("No matching tasks", "Try a different search or status filter."))),
);
return;
}
body.replaceChildren();
for (const t of rows) {
body.append(taskRow(t));
if (expandedId === t.id) body.append(timelineRow(t));
}
}
function taskRow(t) {
return el(
"tr.task-row",
{
onclick: () => {
expandedId = expandedId === t.id ? null : t.id;
renderRows();
if (expandedId === t.id) loadTimeline(t.id);
},
},
el("td.mono", `${t.owner}/${t.repo}`),
el("td.mono", `#${t.issue_number}`),
el("td.strong", t.title || "(untitled)"),
el("td", pill(statusLabel(t.status), statusKind(t.status))),
el("td", t.workflow || "—"),
el("td", t.stage || "—"),
// updated_at moves on every transition, so this reads as "how long has
// it been sitting like this" rather than "how old is the task".
el("td", { title: t.created_at ? `Created ${ago(t.created_at)}` : "" }, ago(t.updated_at)),
);
}
function timelineRow(t) {
const cached = eventCache.get(t.id);
return el(
"tr.task-timeline-row",
el(
"td",
{ colspan: 7 },
cached === undefined
? el("div.task-timeline-loading", "Loading timeline…")
: cached === null
? empty("Could not load timeline", "archied could not be reached for this task's events.")
: cached.length
? el("ul.task-timeline", ...cached.map(timelineEntry))
: empty("No events yet", "This task has not recorded any transitions."),
),
);
}
function timelineEntry(ev) {
return el(
"li.task-timeline-entry",
el("span.task-timeline-dot"),
el(
"div",
el("div.task-timeline-kind", ev.kind || ev.type || "event"),
ev.detail && el("div.task-timeline-detail", ev.detail),
el("div.task-timeline-when", ago(ev.at)),
),
);
}
async function loadTimeline(id) {
try {
const events = await api.task(id);
eventCache.set(id, events || []);
} catch {
eventCache.set(id, null);
}
renderRows();
}
return root;
}
+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;
}