fix: close the duplicate-work loop and the dead paths around it
Applies the four-reviewer pass over the forge/dashboard-actions work. The through-line is that several capabilities were wired but inert, and one of them could cost real work. DUPLICATE WORK. "Closes #N" was dropped from PR bodies in favour of LinkBranch, which is sidebar linkage on Gitea and a no-op stub on GitHub -- neither closes anything, and nothing else did either. So a merged task left its issue open, labelled and assigned; the next poll re-enqueued it, and once the dashboard's Clear removed the task row that became a second implementation and a second PR for work already merged. reconcilePRs now closes the issue on merge, and a rejected task closes its issue too. A PR closed without merging deliberately leaves the issue open: that usually means "try again". MAX RETRIES. Configured, defaulted and reported by /api/config, and enforced nowhere -- markDead was unreachable and EffectiveMaxRetries had no callers, so the dashboard's retry incremented retry_count forever. The retry action now retires a task to dead at the cap. DEAD ON ARRIVAL. Tasks() never selected plan or source, so the "Decision required" panel could not render and chat tasks -- whose issue number is synthetic -- linked to forge issues that do not exist. COSMETIC FAILURE, FATAL RESULT. OpenPR failed the whole stage when LinkBranch errored, so the pull request was never opened and the task parked; a retry re-links the same branch, which Gitea answers with a conflict, so every retry parked again. It is best-effort now. INVISIBLE ACTIONS. Approve/retry/reject wrote store rows and nothing else, so the timeline and activity stream never showed that a human had intervened. They emit events now. Also: store write failures answer 500 rather than 409; the dashboard surfaces the server's actual reason instead of "409 Conflict"; action buttons stop propagation (acting on a task no longer also expands it), disable in flight, keep per-task errors instead of one shared string, and confirm before rejecting. Removed: the maybeRetryParked shim and markDead with their now-vacuous tests, WaitingTasks (no consumers; its tests were rewritten to assert the same routing through TaskByID), write-only Daemon.Runtime, and dir/dirs response bloat from /api/skills. skillSource checked workDir before sharedDir, mislabelling every shared skill when the two are equal. DefaultRoots now dedupes roots differing only by a trailing separator. The air build rule claiming to keep ui/dist current never ran -- it required one file to satisfy include_dir and include_file together, and ui/ is excluded from the walk. Deleted with the comment that promised it. task test:ui joins task check and CI; it ran nowhere before, so the dashboard suite could rot silently. Docs corrected where they described behaviour that no longer exists: parks no longer comment on the issue, state labels no longer drive retries, and forgerpc's doc claimed four proxied methods while listing three of five.
This commit is contained in:
1 parent
a751be66b3
commit
170fe0250b
60 files changed
+2081
-768
No files matched your search
+31
-1
@@ -2,7 +2,13 @@
|
||||
// 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" } });
|
||||
// A daemon that accepts the connection but never answers would otherwise
|
||||
// leave the UI stuck in a loading state with no way back; the retry
|
||||
// affordances rely on fetch settling, so bound it.
|
||||
const res = await fetch(path, {
|
||||
headers: { Accept: "application/json" },
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (res.status === 401) {
|
||||
throw new ApiError("unauthorised", 401);
|
||||
}
|
||||
@@ -23,6 +29,20 @@ function qs(params) {
|
||||
return s ? `?${s}` : "";
|
||||
}
|
||||
|
||||
// errorMessage prefers what the server actually said. archied answers these
|
||||
// with http.Error, i.e. a plain-text reason -- "task is not awaiting
|
||||
// approval", "max retries reached (3/3)" -- and discarding it in favour of
|
||||
// "409 Conflict" throws away the only part an operator can act on.
|
||||
async function errorMessage(res) {
|
||||
try {
|
||||
const body = (await res.text()).trim();
|
||||
if (body) return body.split("\n")[0].slice(0, 200);
|
||||
} catch {
|
||||
// Body already consumed or unreadable; fall through to the status.
|
||||
}
|
||||
return `${res.status} ${res.statusText}`;
|
||||
}
|
||||
|
||||
export class ApiError extends Error {
|
||||
constructor(message, status) {
|
||||
super(message);
|
||||
@@ -34,6 +54,16 @@ export const api = {
|
||||
summary: () => req("/api/summary"),
|
||||
tasks: () => req("/api/tasks"),
|
||||
task: (id) => req(`/api/tasks/${id}`),
|
||||
taskAction: async (id, action) => {
|
||||
const res = await fetch(`/api/tasks/${id}/action`, {
|
||||
method: "POST",
|
||||
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ action }),
|
||||
signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
|
||||
return res.json();
|
||||
},
|
||||
setup: () => req("/api/setup"),
|
||||
workflows: () => req("/api/workflows"),
|
||||
skills: () => req("/api/skills"),
|
||||
|
||||
+4
-1
@@ -11,7 +11,10 @@ export function el(spec, attrs, ...children) {
|
||||
const node = document.createElement(tag || "div");
|
||||
if (classes.length) node.className = classes.join(" ");
|
||||
|
||||
if (attrs && (typeof attrs !== "object" || attrs instanceof Node)) {
|
||||
// A falsy scalar first child (0, "", false) is a value, not a missing
|
||||
// attrs object: unshift it so append() renders it instead of dropping it.
|
||||
// undefined stays "no attrs" so `el("div", undefined, child)` still works.
|
||||
if (attrs !== undefined && (typeof attrs !== "object" || attrs instanceof Node)) {
|
||||
children.unshift(attrs);
|
||||
attrs = null;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
border-radius: var(--radius-lg);
|
||||
padding: var(--sp-5);
|
||||
box-shadow: var(--shadow-sm);
|
||||
/* Wide content (data tables, long values) scrolls inside the card on
|
||||
narrow screens instead of stretching the page. */
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.card-head {
|
||||
@@ -15,6 +18,7 @@
|
||||
justify-content: space-between;
|
||||
gap: var(--sp-3);
|
||||
margin-bottom: var(--sp-4);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
@@ -34,6 +38,12 @@
|
||||
gap: var(--sp-4);
|
||||
}
|
||||
|
||||
/* Grid tracks never grow past the viewport: an item that would blow out
|
||||
scrolls inside its own scroll container instead. */
|
||||
.grid > * {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.grid-4 {
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,19 @@
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
/* Contained horizontal scrolling for wide tables: the page stays put and the
|
||||
table scrolls inside this wrapper, so a 7-column table is usable at 390px. */
|
||||
.table-scroll {
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.table-scroll > .table {
|
||||
min-width: 42rem;
|
||||
}
|
||||
|
||||
.table th {
|
||||
text-align: left;
|
||||
font-weight: 500;
|
||||
|
||||
@@ -69,6 +69,10 @@
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.setup-done .setup-pct {
|
||||
color: var(--ok);
|
||||
}
|
||||
|
||||
.setup-bar {
|
||||
height: 5px;
|
||||
border-radius: var(--radius-pill);
|
||||
@@ -168,14 +172,27 @@
|
||||
|
||||
.dash-top {
|
||||
display: grid;
|
||||
grid-template-columns: 1.6fr 1fr;
|
||||
grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
|
||||
gap: var(--sp-4);
|
||||
margin-bottom: var(--sp-4);
|
||||
}
|
||||
|
||||
/* Either column must be allowed to shrink below its content width so the
|
||||
other one does not get pushed off-screen on narrow viewports. */
|
||||
.dash-top > *,
|
||||
.dash-split > * {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* No setup panel to show: the gate pulse spans the whole row instead of
|
||||
leaving an empty half. */
|
||||
.dash-top-standalone {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) {
|
||||
.dash-top {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,14 +317,14 @@
|
||||
|
||||
.dash-split {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1.5fr;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
|
||||
gap: var(--sp-4);
|
||||
margin-top: var(--sp-4);
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) {
|
||||
.dash-split {
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+103
-23
@@ -19,16 +19,23 @@ export function dashboardPage() {
|
||||
const statsRow = el("div.grid.grid-4");
|
||||
const setupSlot = el("div");
|
||||
const pulseSlot = el("div");
|
||||
const topRow = el("div.dash-top", setupSlot, pulseSlot);
|
||||
const forecastSlot = el("div");
|
||||
const actions = el("div.hero-actions-inner");
|
||||
const title = el("h1.hero-title", greeting());
|
||||
const streamState = pill("connecting", "idle");
|
||||
const activity = [];
|
||||
const taskIDsBySource = new Map();
|
||||
|
||||
render();
|
||||
load();
|
||||
|
||||
const unsubscribe = subscribeEvents(
|
||||
(event) => prependRun(runs, event),
|
||||
(event) => {
|
||||
activity.unshift(event);
|
||||
activity.splice(50);
|
||||
renderActivity();
|
||||
},
|
||||
(state) => {
|
||||
const kind = state === "live" ? "ok" : "warn";
|
||||
streamState.className = `pill pill-${kind}`;
|
||||
@@ -55,7 +62,7 @@ export function dashboardPage() {
|
||||
el(
|
||||
"div.dash-section",
|
||||
el("div.dash-section-head", el("h2.dash-section-title", "Health")),
|
||||
el("div.dash-top", setupSlot, pulseSlot),
|
||||
topRow,
|
||||
),
|
||||
el(
|
||||
"div.dash-section",
|
||||
@@ -83,24 +90,43 @@ export function dashboardPage() {
|
||||
streamState,
|
||||
),
|
||||
el(
|
||||
"table.table",
|
||||
el("thead", el("tr", ...["Event", "Task", "Detail", "When"].map((h) => el("th", h)))),
|
||||
runs,
|
||||
"div.table-scroll",
|
||||
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."))));
|
||||
renderActivity();
|
||||
}
|
||||
|
||||
function renderActivity() {
|
||||
if (!activity.length) {
|
||||
mount(runs, el("tr", el("td", { colspan: 4 }, empty("Waiting for activity", "Events appear here as Archie works."))));
|
||||
return;
|
||||
}
|
||||
mount(runs, ...activity.map((event) => activityRow(event, taskIDsBySource)));
|
||||
}
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const [summary, setup, workflows] = await Promise.all([
|
||||
const [summary, setup, workflows, tasks] = await Promise.all([
|
||||
api.summary(),
|
||||
api.setup().catch(() => null),
|
||||
api.workflows().catch(() => null),
|
||||
api.tasks().catch(() => []),
|
||||
]);
|
||||
taskIDsBySource.clear();
|
||||
for (const task of tasks) {
|
||||
if (task.owner && task.repo && task.issue_number) {
|
||||
taskIDsBySource.set(`${task.owner}/${task.repo}#${task.issue_number}`, task.id);
|
||||
}
|
||||
}
|
||||
renderActivity();
|
||||
renderActions(summary);
|
||||
// The greeting is only personalised when the deployment says who it
|
||||
// assists; an unconfigured instance greets without a name rather than
|
||||
@@ -112,6 +138,13 @@ export function dashboardPage() {
|
||||
renderForecast(summary);
|
||||
} catch (err) {
|
||||
mount(statsRow, el("div.card", empty("Cannot reach archied", String(err.message || err))));
|
||||
// The hero actions are only rendered on success, so a failed first load
|
||||
// must offer its own retry rather than leaving the operator without a
|
||||
// recovery path.
|
||||
mount(
|
||||
actions,
|
||||
el("button.btn.btn-primary", { onclick: load }, icon("refresh", { size: 15 }), "Retry"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,26 +210,50 @@ export function dashboardPage() {
|
||||
}
|
||||
|
||||
function renderSetup(setup) {
|
||||
if (!setup?.steps?.length) return mount(setupSlot);
|
||||
// Unknown setup (endpoint unreachable) or no checklist configured: omit
|
||||
// the panel and let the gate pulse take the full row, so the Health row
|
||||
// never shows an empty half beside the pulse.
|
||||
const omit = !setup?.steps?.length;
|
||||
topRow.classList.toggle("dash-top-standalone", omit);
|
||||
if (omit) 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);
|
||||
if (remaining.length) {
|
||||
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)),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Every step done: show completion so the row beside the gate pulse is
|
||||
// not an empty hole on an otherwise healthy dashboard.
|
||||
topRow.classList.remove("dash-top-standalone");
|
||||
mount(
|
||||
setupSlot,
|
||||
el(
|
||||
"div.card.setup",
|
||||
"div.card.setup.setup-done",
|
||||
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("h2.card-title", "Setup complete"),
|
||||
el("p.card-sub", "Archie is configured and ready to work."),
|
||||
),
|
||||
el("span.setup-pct", `${pct}%`),
|
||||
el("span.setup-pct", icon("check", { size: 16 })),
|
||||
),
|
||||
el("div.setup-bar", el("div.setup-bar-fill", { style: `width:${pct}%` })),
|
||||
el("ul.setup-list", ...setup.steps.map(setupStep)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -220,17 +277,40 @@ export function dashboardPage() {
|
||||
return root;
|
||||
}
|
||||
|
||||
function prependRun(tbody, event) {
|
||||
if (tbody.firstElementChild?.querySelector(".empty")) tbody.replaceChildren();
|
||||
function activityRow(event, taskIDsBySource) {
|
||||
const taskID = taskIDForEvent(event, taskIDsBySource);
|
||||
const hasTask = taskID > 0;
|
||||
const openTask = () => {
|
||||
if (hasTask) location.hash = `#/tasks?task=${encodeURIComponent(taskID)}`;
|
||||
};
|
||||
const row = el(
|
||||
"tr",
|
||||
`tr${hasTask ? ".activity-row" : ""}`,
|
||||
hasTask
|
||||
? {
|
||||
role: "link",
|
||||
tabindex: "0",
|
||||
title: "Open task details",
|
||||
onclick: openTask,
|
||||
onkeydown: (e) => {
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
openTask();
|
||||
}
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
el("td.strong", el("span", event.kind || event.type || "event")),
|
||||
el("td.mono", event.task_id ? `#${event.task_id}` : "—"),
|
||||
el("td.mono", hasTask ? `#${taskID}` : "—"),
|
||||
el("td", event.detail || event.message || ""),
|
||||
el("td", ago(event.at || Date.now())),
|
||||
);
|
||||
tbody.prepend(row);
|
||||
while (tbody.children.length > 50) tbody.lastElementChild.remove();
|
||||
return row;
|
||||
}
|
||||
|
||||
function taskIDForEvent(event, taskIDsBySource) {
|
||||
if (Number(event.task_id) > 0) return Number(event.task_id);
|
||||
if (!event.repo || !event.issue) return 0;
|
||||
return Number(taskIDsBySource.get(`${event.repo}#${event.issue}`)) || 0;
|
||||
}
|
||||
|
||||
function greeting() {
|
||||
|
||||
+3
-2
@@ -133,13 +133,14 @@ function start() {
|
||||
else show(path);
|
||||
}
|
||||
|
||||
function show(path) {
|
||||
function show(rawPath) {
|
||||
// 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 [path, query = ""] = rawPath.split("?", 2);
|
||||
const route = routes.find((r) => r.path === path) || routes[0];
|
||||
bar.highlight(route.path);
|
||||
mount(outlet, route.view ? route.view() : comingSoon(route));
|
||||
mount(outlet, route.view ? route.view(new URLSearchParams(query)) : comingSoon(route));
|
||||
}
|
||||
|
||||
window.addEventListener("hashchange", () => show(location.hash.slice(1) || "/"));
|
||||
|
||||
+31
-25
@@ -112,21 +112,24 @@ function repositoriesCard(repos) {
|
||||
"Repositories",
|
||||
"Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
|
||||
el(
|
||||
"table.table",
|
||||
"div.table-scroll",
|
||||
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(", ") : "—"),
|
||||
"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(", ") : "—"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -149,18 +152,21 @@ function modelsAndProvidersCard(models, providers) {
|
||||
|
||||
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)))),
|
||||
"div.table-scroll",
|
||||
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")),
|
||||
"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")),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -4,9 +4,9 @@ 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.
|
||||
* GET /api/skills, which scans project, shared, and user-global
|
||||
* .agents/skills/<name>/SKILL.md files 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
|
||||
@@ -47,7 +47,7 @@ export function skillsPage() {
|
||||
"div.card",
|
||||
el(
|
||||
"div.card-head",
|
||||
el("div", el("h2.card-title", "Catalogue"), el("p.card-sub", "Discovered from .agents/skills/")),
|
||||
el("div", el("h2.card-title", "Catalogue"), el("p.card-sub", "Project, shared, and user-global skills")),
|
||||
searchInput,
|
||||
),
|
||||
cardGrid,
|
||||
@@ -77,7 +77,7 @@ export function skillsPage() {
|
||||
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.",
|
||||
"Skills live as SKILL.md files under project, shared, or user-global .agents/skills/<name>/ directories. Add one and refresh to make it available.",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
/* Tasks-only styles. */
|
||||
|
||||
.task-summary {
|
||||
margin-bottom: var(--sp-5);
|
||||
}
|
||||
|
||||
.task-filters {
|
||||
display: flex;
|
||||
gap: var(--sp-2);
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.task-search,
|
||||
@@ -31,6 +36,85 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.activity-row {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.activity-row:hover td,
|
||||
.activity-row:focus td {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.activity-row:focus {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.task-source-link {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.task-source-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.task-actions {
|
||||
display: flex;
|
||||
gap: var(--sp-1);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.btn-small {
|
||||
padding: var(--sp-1) var(--sp-2);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
|
||||
.btn-quiet {
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
|
||||
.task-action-error {
|
||||
max-width: 180px;
|
||||
color: var(--danger);
|
||||
font-size: var(--text-xs);
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.task-decision {
|
||||
margin-bottom: var(--sp-4);
|
||||
padding: var(--sp-3);
|
||||
border-left: 3px solid var(--accent);
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.task-decision-title {
|
||||
color: var(--fg);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.task-decision-plan {
|
||||
margin-top: var(--sp-2);
|
||||
color: var(--fg-muted);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
/* On phones the filter controls take their own row and full width instead of
|
||||
crowding the card title. */
|
||||
@media (max-width: 700px) {
|
||||
.task-filters {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.task-search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.task-filter {
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.task-timeline-row td {
|
||||
background: var(--bg-raised);
|
||||
padding: var(--sp-4);
|
||||
@@ -41,6 +125,18 @@
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
.task-timeline-error {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: var(--sp-2);
|
||||
}
|
||||
|
||||
.task-timeline-error .task-timeline-title {
|
||||
font-weight: 500;
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.task-timeline {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
|
||||
+144
-16
@@ -29,9 +29,9 @@ function statusLabel(status) {
|
||||
* 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() {
|
||||
export function tasksPage(params = new URLSearchParams()) {
|
||||
const root = el("div");
|
||||
const summaryRow = el("div.grid.grid-4");
|
||||
const summaryRow = el("div.grid.grid-4.task-summary");
|
||||
const body = el("tbody");
|
||||
const searchInput = el("input.task-search", {
|
||||
type: "search",
|
||||
@@ -56,8 +56,16 @@ export function tasksPage() {
|
||||
let tasks = [];
|
||||
let filterStatus = "";
|
||||
let search = "";
|
||||
let expandedId = null;
|
||||
const requestedTask = Number(params.get("task"));
|
||||
let expandedId = Number.isFinite(requestedTask) && requestedTask > 0 ? requestedTask : null;
|
||||
let forgeHost = "";
|
||||
const eventCache = new Map();
|
||||
// Keyed by task id. A single shared string leaked one row's failure into
|
||||
// every other row's action cell.
|
||||
const actionErrors = new Map();
|
||||
// Tasks with an action in flight, so the buttons can be disabled rather
|
||||
// than letting an impatient second click fire the same action twice.
|
||||
const actionsInFlight = new Set();
|
||||
|
||||
render();
|
||||
load();
|
||||
@@ -83,15 +91,18 @@ export function tasksPage() {
|
||||
el("div.task-filters", searchInput, statusSelect),
|
||||
),
|
||||
el(
|
||||
"table.table",
|
||||
"div.table-scroll",
|
||||
el(
|
||||
"thead",
|
||||
"table.table",
|
||||
el(
|
||||
"tr",
|
||||
...["Repo", "Issue", "Title", "Status", "Workflow", "Stage", "Last activity"].map((h) => el("th", h)),
|
||||
"thead",
|
||||
el(
|
||||
"tr",
|
||||
...["Repo", "Issue", "Title", "Status", "Workflow", "Stage", "Last activity", "Action"].map((h) => el("th", h)),
|
||||
),
|
||||
),
|
||||
body,
|
||||
),
|
||||
body,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -99,12 +110,18 @@ export function tasksPage() {
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
tasks = await api.tasks();
|
||||
[tasks, forgeHost] = await Promise.all([
|
||||
api.tasks(),
|
||||
api.config().then((cfg) => cfg?.identity?.forge_host || "").catch(() => ""),
|
||||
]);
|
||||
renderSummary();
|
||||
renderRows();
|
||||
if (expandedId && tasks.some((task) => String(task.id) === String(expandedId))) {
|
||||
loadTimeline(expandedId);
|
||||
}
|
||||
} 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)))));
|
||||
mount(body, el("tr", el("td", { colspan: 8 }, empty("Cannot reach archied", String(err.message || err)))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +177,7 @@ export function tasksPage() {
|
||||
"tr",
|
||||
el(
|
||||
"td",
|
||||
{ colspan: 7 },
|
||||
{ colspan: 8 },
|
||||
empty("No tasks yet", "Tasks appear here once archied picks up an issue to work."),
|
||||
),
|
||||
),
|
||||
@@ -170,7 +187,7 @@ export function tasksPage() {
|
||||
if (!rows.length) {
|
||||
mount(
|
||||
body,
|
||||
el("tr", el("td", { colspan: 7 }, empty("No matching tasks", "Try a different search or status filter."))),
|
||||
el("tr", el("td", { colspan: 8 }, empty("No matching tasks", "Try a different search or status filter."))),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -191,8 +208,8 @@ export function tasksPage() {
|
||||
if (expandedId === t.id) loadTimeline(t.id);
|
||||
},
|
||||
},
|
||||
el("td.mono", `${t.owner}/${t.repo}`),
|
||||
el("td.mono", `#${t.issue_number}`),
|
||||
el("td.mono", repoLink(t) ?? `${t.owner}/${t.repo}`),
|
||||
el("td.mono", issueLink(t) ?? `#${t.issue_number}`),
|
||||
el("td.strong", t.title || "(untitled)"),
|
||||
el("td", pill(statusLabel(t.status), statusKind(t.status))),
|
||||
el("td", t.workflow || "—"),
|
||||
@@ -200,6 +217,104 @@ export function tasksPage() {
|
||||
// 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)),
|
||||
el("td", taskActions(t)),
|
||||
);
|
||||
}
|
||||
|
||||
function taskActions(t) {
|
||||
const message = actionErrors.get(t.id);
|
||||
const error = message ? el("span.task-action-error", message) : null;
|
||||
const busy = actionsInFlight.has(t.id);
|
||||
|
||||
// The row itself toggles the timeline on click, so every button has to
|
||||
// stop the event or acting on a task also expands it.
|
||||
const button = (cls, action, label, confirmText) =>
|
||||
el(
|
||||
cls,
|
||||
{
|
||||
type: "button",
|
||||
disabled: busy,
|
||||
onclick: (e) => {
|
||||
e.stopPropagation();
|
||||
if (confirmText && !window.confirm(confirmText)) return;
|
||||
performAction(t.id, action);
|
||||
},
|
||||
},
|
||||
label,
|
||||
);
|
||||
|
||||
if (t.status === "waiting_human") {
|
||||
return el(
|
||||
"div.task-actions",
|
||||
error,
|
||||
button("button.btn.btn-small", "approve", "Approve"),
|
||||
button(
|
||||
"button.btn.btn-small.btn-quiet",
|
||||
"reject",
|
||||
"Reject",
|
||||
`Reject "${t.title || "this task"}"? This closes the forge issue and cannot be undone from here.`,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (t.status === "parked") {
|
||||
return el("div.task-actions", error, button("button.btn.btn-small", "retry", "Retry"));
|
||||
}
|
||||
return error || "—";
|
||||
}
|
||||
|
||||
async function performAction(id, action) {
|
||||
actionErrors.delete(id);
|
||||
actionsInFlight.add(id);
|
||||
renderRows();
|
||||
try {
|
||||
await api.taskAction(id, action);
|
||||
actionsInFlight.delete(id);
|
||||
await load();
|
||||
} catch (err) {
|
||||
actionsInFlight.delete(id);
|
||||
actionErrors.set(id, err.message || "Action failed");
|
||||
renderRows();
|
||||
}
|
||||
}
|
||||
|
||||
// Both forge links derive from the same host so they can never drift apart:
|
||||
// one place builds the base, both anchors reuse it.
|
||||
function forgeBase(t) {
|
||||
if (!forgeHost || !t.owner || !t.repo) return null;
|
||||
return `${forgeHost.replace(/\/+$/, "")}/${encodeURIComponent(t.owner)}/${encodeURIComponent(t.repo)}`;
|
||||
}
|
||||
|
||||
function repoLink(t) {
|
||||
const base = forgeBase(t);
|
||||
if (!base) return null;
|
||||
return el(
|
||||
"a.task-source-link",
|
||||
{
|
||||
href: base,
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
title: `Open ${t.owner}/${t.repo} on the forge`,
|
||||
onclick: (e) => e.stopPropagation(),
|
||||
},
|
||||
`${t.owner}/${t.repo}`,
|
||||
);
|
||||
}
|
||||
|
||||
function issueLink(t) {
|
||||
const base = forgeBase(t);
|
||||
// A chat-sourced task has no issue on the forge, but its repo may still
|
||||
// exist -- the repo link stays, the issue link does not.
|
||||
if (t.source === "chat" || !base || !t.issue_number) return null;
|
||||
return el(
|
||||
"a.task-source-link",
|
||||
{
|
||||
href: `${base}/issues/${t.issue_number}`,
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
title: `Open issue #${t.issue_number} on the forge`,
|
||||
onclick: (e) => e.stopPropagation(),
|
||||
},
|
||||
`#${t.issue_number}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -209,11 +324,24 @@ export function tasksPage() {
|
||||
"tr.task-timeline-row",
|
||||
el(
|
||||
"td",
|
||||
{ colspan: 7 },
|
||||
{ colspan: 8 },
|
||||
t.status === "waiting_human" && t.plan
|
||||
? el("div.task-decision", el("div.task-decision-title", "Decision required"), el("div.task-decision-plan", t.plan))
|
||||
: t.status === "parked" && t.park_reason
|
||||
? el("div.task-decision", el("div.task-decision-title", "Park reason"), el("div.task-decision-plan", t.park_reason))
|
||||
: null,
|
||||
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.")
|
||||
? el(
|
||||
"div.task-timeline-error",
|
||||
el("div.task-timeline-title", "Could not load timeline"),
|
||||
el(
|
||||
"div.task-timeline-detail",
|
||||
"archied did not answer for this task's events. It may be restarting — retry, or check the daemon.",
|
||||
),
|
||||
el("button.btn", { onclick: () => loadTimeline(t.id) }, "Retry"),
|
||||
)
|
||||
: cached.length
|
||||
? el("ul.task-timeline", ...cached.map(timelineEntry))
|
||||
: empty("No events yet", "This task has not recorded any transitions."),
|
||||
|
||||
@@ -108,31 +108,34 @@ export function workflowsPage() {
|
||||
),
|
||||
),
|
||||
el(
|
||||
"table.table",
|
||||
"div.table-scroll",
|
||||
el(
|
||||
"thead",
|
||||
"table.table",
|
||||
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(
|
||||
"thead",
|
||||
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) : "—"),
|
||||
);
|
||||
}),
|
||||
...["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) : "—"),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -167,20 +170,23 @@ export function workflowsPage() {
|
||||
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)))),
|
||||
"div.table-scroll",
|
||||
el(
|
||||
"tbody",
|
||||
...byDuration.map((s) =>
|
||||
el(
|
||||
"tr",
|
||||
el("td", workflowLabel(s.workflow)),
|
||||
el("td.strong", s.stage),
|
||||
el("td", `${s.runs}`),
|
||||
"table.table",
|
||||
el("thead", el("tr", ...["Workflow", "Stage", "Runs", "Avg duration"].map((h) => el("th", h)))),
|
||||
el(
|
||||
"tbody",
|
||||
...byDuration.map((s) =>
|
||||
el(
|
||||
"td",
|
||||
el("div.wf-rate", formatMs(s.avg_ms)),
|
||||
bar(pct(s.avg_ms, maxMs), "info"),
|
||||
"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"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -195,19 +201,22 @@ export function workflowsPage() {
|
||||
),
|
||||
byErrors.length
|
||||
? el(
|
||||
"table.table",
|
||||
el("thead", el("tr", ...["Workflow", "Stage", "Failures"].map((h) => el("th", h)))),
|
||||
"div.table-scroll",
|
||||
el(
|
||||
"tbody",
|
||||
...byErrors.map((s) =>
|
||||
el(
|
||||
"tr",
|
||||
el("td", workflowLabel(s.workflow)),
|
||||
el("td.strong", s.stage),
|
||||
"table.table",
|
||||
el("thead", el("tr", ...["Workflow", "Stage", "Failures"].map((h) => el("th", h)))),
|
||||
el(
|
||||
"tbody",
|
||||
...byErrors.map((s) =>
|
||||
el(
|
||||
"td",
|
||||
el("div.wf-rate", `${s.errors} of ${s.runs}`),
|
||||
bar(pct(s.errors, s.runs), "danger"),
|
||||
"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"),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user