--- title: Interventions --- ```js import {API, POLL_HEAVY, apiFetch, pollDelay, waitForVisible} from "./components/config.js"; ``` ```js // Live poll: all tasks (filtered client-side) + workstreams + topics const interventionState = (async function*() { let failures = 0; while (true) { let tasks = [], wsMap = {}, ok = false; try { const [rt, rw, rto, rr] = await Promise.all([ apiFetch("/tasks/?limit=500"), apiFetch("/workplans/"), apiFetch("/topics/"), apiFetch("/repos/"), ]); ok = rt.ok && rw.ok && rto.ok && rr.ok; if (ok) { const [taskList, wsList, topicList, repoList] = await Promise.all([ rt.json(), rw.json(), rto.json(), rr.json(), ]); const topicMap = Object.fromEntries(topicList.map(t => [t.id, t])); const repoMap = Object.fromEntries(repoList.map(r => [r.id, r])); wsMap = Object.fromEntries(wsList.map(w => [w.id, { ...w, domain: repoMap[w.repo_id]?.domain_slug ?? topicMap[w.topic_id]?.domain_slug ?? "unknown", }])); tasks = taskList.map(t => ({ ...t, workstream_title: wsMap[t.workstream_id]?.title ?? "—", domain: wsMap[t.workstream_id]?.domain ?? "unknown", })); } } catch {} failures = ok ? 0 : failures + 1; yield {tasks, ok, ts: new Date()}; await waitForVisible(pollDelay({ok, base: POLL_HEAVY, failures})); } })(); ``` ```js const tasks = interventionState.tasks ?? []; const _ok = interventionState.ok ?? false; const _ts = interventionState.ts; ``` ```js const OPEN_STATUSES = new Set(["wait", "todo", "progress"]); // open = currently flagged for human action // closed = previously flagged (intervention_note records the resolution comment) const open = tasks.filter(t => t.needs_human === true); const closed = tasks.filter(t => t.intervention_note && !OPEN_STATUSES.has(t.status) && !t.needs_human); // Domain breakdown for top-3 const domainCounts = {}; for (const t of open) { domainCounts[t.domain] = (domainCounts[t.domain] ?? 0) + 1; } const top3Domains = Object.entries(domainCounts) .sort((a, b) => b[1] - a[1]) .slice(0, 3); const critHighCount = open.filter(t => t.priority === "critical" || t.priority === "high").length; ``` # Interventions ```js import {injectTocTop} from "./components/toc-sidebar.js"; import {withDocHelp} from "./components/doc-overlay.js"; // ── KPI sidebar card ────────────────────────────────────────────────────────── const _kpiBox = html`
make api`}
No open interventions — you're clear! ✓
`); } else { display(html`No completed interventions yet.
`); } else { display(html`