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
@@ -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."),
|
||||
|
||||
Reference in new issue
Block a user