Files
archie/ui/src/curators/curators.jsx
T
sam cc95f854de refactor(ui): extract Pill to ui/src/base/, closing archie-core-mlro
Pill was independently duplicated byte-for-byte across 11 files
(tasks, logs, mapping-editor, capture-row, settings, update-status,
skills, dashboard, memory, channels, curators) plus the bindings page
built earlier this session -- a violation of organisation.md's
"extract on the second distinct consumer" rule, predating this
session entirely. Found while building the bindings UI.

Mechanical extraction only, no behavior change: ui/src/base/pill.jsx
is now the single definition; every call site imports from there.
skills.jsx's copy used `class=` instead of `className=` (functionally
identical in Preact) -- normalized to the shared version's className.
captures.jsx's import of Pill (previously re-exported through
capture-row.jsx) now points at the shared module directly.

Verified via task test:ui (120/120 unchanged) and, since this touches
the exact rendering path that had a real app-wide regression earlier
tonight (commit 4fa478a), re-verified in a real browser across all 12
pages: zero "[object Object]" occurrences, and every page's .pill
elements render with real content (settings: 9, bindings: 2, etc.),
not just "the build succeeded."
2026-09-03 06:25:21 +10:00

125 lines
3.6 KiB
React

import { h, Fragment } from "preact";
import { useState, useEffect } from "preact/hooks";
import "./curators.css";
import { api } from "../base/api.jsx";
import { ago } from "../base/dom.jsx";
import { Pill } from "../base/pill.jsx";
function Empty({ title, detail }) {
return (
<div className="empty">
<div className="empty-title">{title}</div>
{detail && <div>{detail}</div>}
</div>
);
}
/**
* Curator observability (archie-core-1786637489932-6). Backed by GET
* /api/curators, which reads the daemon's live curator.Registry: which
* curators are registered, their point-in-time health, and their recent
* activity (last run, action count, and the actions themselves with the
* reason each one happened) -- see internal/webui/api_curators.go.
*/
export function curatorsPage(query) {
return <CuratorsApp query={query} />;
}
function CuratorsApp({ query }) {
const [curators, setCurators] = useState([]);
const [loadError, setLoadError] = useState(null);
const load = async () => {
try {
const res = await api.curators();
setCurators(res?.curators || []);
setLoadError(null);
} catch (err) {
setLoadError(String(err.message || err));
}
};
useEffect(() => {
load();
}, []);
const renderCards = () => {
if (loadError) {
return <Empty title="Cannot reach archied" detail={loadError} />;
}
if (!curators.length) {
return (
<Empty
title="No curators registered"
detail="Curators are background agent loops that maintain memory and skills. None are registered on this daemon."
/>
);
}
return curators.map(c => <CuratorCard key={c.name} curator={c} />);
};
return (
<div>
<div className="page-head">
<div>
<h1 className="page-title">Curators</h1>
<p className="page-sub">Background agents that maintain memory and skills: what ran, and why.</p>
</div>
<div className="page-actions">
<button className="btn" onClick={load}>Refresh</button>
</div>
</div>
<div className="grid grid-2">
{renderCards()}
</div>
</div>
);
}
function healthKind(status) {
switch (status) {
case "healthy":
return "ok";
case "degraded":
return "warn";
case "unhealthy":
return "danger";
default:
return "idle";
}
}
function CuratorCard({ curator: c }) {
const actions = c.recent_actions || [];
return (
<div className="card curator-card">
<div className="card-head">
<h3 className="card-title">{c.name}</h3>
<Pill text={c.health?.status || "unknown"} kind={healthKind(c.health?.status)} />
</div>
{c.health?.message && <p className="curator-health-message">{c.health.message}</p>}
<p className="curator-meta">
{c.last_run_at
? `Last ran ${ago(c.last_run_at)} · ${c.last_run_actions} action${c.last_run_actions === 1 ? "" : "s"}`
: "Has not run yet"}
</p>
{actions.length ? (
<ul className="curator-actions">
{actions.map((a, i) => (
<li className="curator-action" key={i}>
<div className="curator-action-head">
<span className="curator-action-type">{a.type || "action"}</span>
<span className="curator-action-time">{ago(a.at)}</span>
</div>
{a.detail && <p className="curator-action-detail">{a.detail}</p>}
{a.reason && <p className="curator-action-reason">Why: {a.reason}</p>}
</li>
))}
</ul>
) : (
<p className="curator-meta">No recorded activity yet.</p>
)}
</div>
);
}