Runs is the queue's elements and a Problems log; a Kill lands between boards

Run one stage goes: the cascade is the unit of work and app job keeps the
per-stage entry points. The pull button is disabled while a pull runs and
the lede no longer hardcodes the cadence. Messages folds into Runs as
Problems. pull_batch checks for a cancel before every board, one plugin per
target, and both plugins now close their HTTP client.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-28 16:10:38 +02:00
1 parent cebe62ddc9
commit 8532e4e739
15 files changed
+284 -242

No files matched your search

-7
View File
@@ -275,13 +275,6 @@ button.secondary {
font-size: 0.8rem;
}
/* -- pulls ------------------------------------------------------------------ */
/* "Run one stage" on the Pulls page: extract, embed and score on their own,
under the schedule rather than beside Pull now. */
details.stage summary { cursor: pointer; color: var(--dim); font-size: 0.95rem; font-weight: 600; }
details.stage[open] summary { margin-bottom: 0.75rem; }
/* -- the notice log ------------------------------------------------------- */
.notice {
+50 -55
View File
@@ -1,11 +1,12 @@
/* The Runs section of Sources: Pull now on top, one button per remaining
* kind under "Run one stage".
/* The Runs section of Sources: "Run the pull now" and the idle line.
*
* The list comes from `/api/jobs/kinds`, which is the registry, so a new
* `@job` in `app/jobs.py` is a new button and this file is not edited --
* except that `pull` itself is pulled out of the list and wired to the
* dedicated button instead of appearing twice. What the queue is doing is
* `<desk-jobs>`'s business, and it draws itself.
* What the queue is doing and when it runs next are `<desk-jobs>`' and
* `<desk-schedules>`' business, and they draw themselves. The single stages
* have no buttons: the cascade is the unit of work, and `app job <stage>`
* keeps the per-stage entry points.
*
* Both read the `app:jobs` snapshot from live.js rather than asking the
* elements, which keep to a shadow root and owe nobody an answer.
*
* Failures are the server's sentence through `api()`, which toasts it -- so
* there is no error handling here beyond keeping the button usable.
@@ -14,63 +15,57 @@
(function () {
"use strict";
const host = document.getElementById("kinds");
const pullButton = document.getElementById("pull-now");
async function start(kind, button) {
button.disabled = true;
try {
const job = await window.api("/api/jobs", { method: "POST", body: { kind } });
window.toast.good(`${job.label || kind}: queued.`);
} catch (e) {
/* already toasted */
} finally {
button.disabled = false;
}
let pending = false; // the POST is in the air
let pulling = false; // the latest snapshot has a live pull cascade
/* A pull queued by the button or a schedule is the `pull` job, which
begins a cascade of its own named `pull on its own`, and the chain's
tasks join it; `pull` is the name a cascade started as one would have.
Live while any task has a job queued or running: the pipeline keeps a
finished cascade in the snapshot for a few seconds, and that is not a
pull still going. As newsdesk's Fetch: the whole cascade, not the `pull`
task, which is over seconds in with five tasks to go. */
const isPull = (c) => c.name === "pull" || c.name === "pull on its own";
const live = (c) => (c.tasks || []).some((t) => t.running || t.queued);
function paint() {
if (!pullButton) return;
pullButton.disabled = pending || pulling;
pullButton.title = pulling ? "A pull is running." : "";
}
if (pullButton) {
pullButton.addEventListener("click", () => start("pull", pullButton));
}
async function draw() {
if (!host) return;
let kinds;
try {
kinds = await window.api("/api/jobs/kinds");
} catch (e) {
host.innerHTML = '<span class="muted">could not read the job kinds</span>';
return;
}
kinds = kinds.filter((k) => k.kind !== "pull");
if (!kinds.length) {
host.innerHTML = '<span class="muted">nothing is registered</span>';
return;
}
host.innerHTML = "";
kinds.forEach((k) => {
const button = document.createElement("button");
button.type = "button";
button.className = "secondary";
button.textContent = k.label || k.kind;
button.title = k.solo ? `${k.kind} -- one at a time` : k.kind;
button.dataset.kind = k.kind;
button.addEventListener("click", () => start(k.kind, button));
host.appendChild(button);
pullButton.addEventListener("click", async () => {
pending = true;
paint();
try {
const job = await window.api("/api/jobs", { method: "POST", body: { kind: "pull" } });
window.toast.good(`${job.label || "pull"}: queued.`);
} catch (e) {
/* already toasted */
} finally {
pending = false;
paint();
}
});
}
/* `<desk-jobs>` takes up no space while the queue is idle, so the line that
says so is the app's to show and hide. Off the same socket the element
reads, through live.js, rather than by asking the element: it keeps to a
shadow root and owes nobody an answer about its own height. */
document.addEventListener("app:jobs", (e) => {
says so is the app's to show and hide. It starts hidden: until the first
snapshot nobody knows whether the queue is idle. */
function update(state) {
const idle = document.getElementById("idle");
if (!idle) return;
const state = e.detail || {};
const busy = (state.running || []).length + (state.queued || []).length;
idle.hidden = busy > 0;
});
if (idle) {
const busy = (state.running || []).length + (state.queued || []).length;
idle.hidden = busy > 0;
}
pulling = (state.cascades || []).some((c) => isPull(c) && live(c));
paint();
}
document.addEventListener("DOMContentLoaded", draw);
document.addEventListener("app:jobs", (e) => update(e.detail || {}));
// A snapshot that arrived before this script loaded.
if (window.live && window.live.jobs) update(window.live.jobs);
})();
+14 -9
View File
@@ -206,17 +206,19 @@
// ------------------------------------------------------ one section shown
// Sources shows one section: the one the fragment names, or the first when
// there is none or it names none, so `/settings/sources#runs` (a rail link,
// an old path's 301, the Search agents page's "follow it under Runs") opens
// Runs. The rest are hidden, not removed, so their scripts still find their
// roots. It runs as the script loads rather than on DOMContentLoaded, so the
// page never paints all four first.
// Sources shows one section: the one the fragment names or contains, or the
// first when there is none or it names none, so `/settings/sources#runs` (a
// rail link, an old path's 301, the Search agents page's "follow it under
// Runs") opens Runs, and so does `#messages`, the log at its end. The rest
// are hidden, not removed, so their scripts still find their roots. It runs
// as the script loads rather than on DOMContentLoaded, so the page never
// paints all three first.
function showSection() {
const sections = [...document.querySelectorAll("section[data-section]")];
if (!sections.length) return;
const want = decodeURIComponent(location.hash.slice(1));
const shown = sections.find((s) => s.id === want) || sections[0];
const target = want && document.getElementById(want);
const shown = sections.find((s) => target && s.contains(target)) || sections[0];
for (const section of sections) section.hidden = section !== shown;
for (const link of document.querySelectorAll(".settings-rail a[data-section]")) {
if (link.dataset.section === shown.id) {
@@ -229,10 +231,13 @@
}
showSection();
// A switch starts the section at the top of the page, as opening it would.
// A switch starts the section at the top of the page, as opening it would;
// a fragment inside one (`#messages`) scrolls to itself.
window.addEventListener("hashchange", () => {
showSection();
window.scrollTo(0, 0);
const target = document.getElementById(decodeURIComponent(location.hash.slice(1)));
if (target && !target.matches("section[data-section]")) target.scrollIntoView();
else window.scrollTo(0, 0);
});
// -------------------------------------------------------------------- init