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.
107 lines
3.3 KiB
JavaScript
107 lines
3.3 KiB
JavaScript
// 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(" ");
|
|
|
|
// 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;
|
|
}
|
|
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));
|
|
}
|