Pull pipeline/ from boilerplate e397005: the queue chip counts down a retry

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-28 19:43:21 +02:00
1 parent 074a41c6cf
commit 0558ef19ed
2 files changed
+21 -7

No files matched your search

+1 -1
View File
@@ -68,7 +68,7 @@ The same file defines `<desk-queue>`, a chip for a top bar:
<desk-queue href="/jobs">All runs</desk-queue> <desk-queue href="/jobs">All runs</desk-queue>
``` ```
The chip is a dot, the running count and the first running job's label and progress ("Embedding roles, 6 of 6, +2 waiting"), with the job's message as its tooltip. It is grey and says "Idle" when nothing runs, and shows a red dot and "Offline" while the socket is down; under `40rem` it shrinks to the dot and the count. Pressing it opens a popover listing every running and queued job with its message, done/total, a ticking age and Kill, one Stop run per live cascade of more than one job (`POST /api/cascades/{id}/cancel`), and, with `href`, a link to the app's own page whose text is the element's content ("All runs" without any). It reads the `--desk-jobs-*` properties with fallbacks instead of setting them, so a theme on `:root` or an ancestor reaches it and without one it takes the bar's colour and font. It does not re-raise notices, because it sits next to a `<desk-jobs>` on some pages. `idle="hide"` hides it while idle; `base`, `socket` and `probe` are as above. The chip is a dot, the running count and the first running job's label and progress ("Embedding roles, 6 of 6, +2 waiting"), with the job's message as its tooltip. It is grey and says "Idle" when nothing runs, and shows a red dot and "Offline" while the socket is down; under `40rem` it shrinks to the dot and the count. Pressing it opens a popover listing every running and queued job with its message, done/total, a ticking age, a countdown for one waiting out a retry, and Kill, one Stop run per live cascade of more than one job (`POST /api/cascades/{id}/cancel`), and, with `href`, a link to the app's own page whose text is the element's content ("All runs" without any). It reads the `--desk-jobs-*` properties with fallbacks instead of setting them, so a theme on `:root` or an ancestor reaches it and without one it takes the bar's colour and font; `--desk-jobs-warn` colours the countdown. It does not re-raise notices, because it sits next to a `<desk-jobs>` on some pages. `idle="hide"` hides it while idle; `base`, `socket` and `probe` are as above.
## Many jobs and one report ## Many jobs and one report
+20 -6
View File
@@ -323,14 +323,15 @@ class DeskJobs extends Follower {
* tooltip, since a sentence does not fit in a top bar. Grey and "Idle" when * tooltip, since a sentence does not fit in a top bar. Grey and "Idle" when
* nothing runs, a red dot and "Offline" when the socket is down. Pressing it opens a popover that is the queue as * nothing runs, a red dot and "Offline" when the socket is down. Pressing it opens a popover that is the queue as
* the queue holds it: one line per running or queued job with its message, * the queue holds it: one line per running or queued job with its message,
* done/total, how long it has been at it, and Kill; one line per live cascade * done/total, how long it has been at it, when it is due if it is waiting out
* with Stop run; and, with `href`, a link to the app's full page. Anywhere * a retry, and Kill; one line per live cascade with Stop run; and, with
* else, or Escape, closes it. * `href`, a link to the app's full page. Anywhere else, or Escape, closes it.
* *
* Colours are the `--desk-jobs-*` properties read with fallbacks rather than * Colours are the `--desk-jobs-*` properties read with fallbacks rather than
* set on `:host` as `<desk-jobs>` sets them, so a theme on `:root` or on an * set on `:host` as `<desk-jobs>` sets them, so a theme on `:root` or on an
* ancestor reaches it, and with none at all the chip takes the colour and * ancestor reaches it, and with none at all the chip takes the colour and
* font of the bar it sits in. * font of the bar it sits in. `--desk-jobs-warn` is its own: the colour of a
* retry's countdown.
* *
* Notices on the socket are not re-raised: this sits on every page, next to a * Notices on the socket are not re-raised: this sits on every page, next to a
* `<desk-jobs>` on some of them, and one failure would toast twice. * `<desk-jobs>` on some of them, and one failure would toast twice.
@@ -431,6 +432,11 @@ const QUEUE_CSS = `
.pct, .age { font-variant-numeric: tabular-nums; white-space: nowrap; .pct, .age { font-variant-numeric: tabular-nums; white-space: nowrap;
color: var(--desk-jobs-dim, GrayText); } color: var(--desk-jobs-dim, GrayText); }
.age { min-width: 2.6em; text-align: right; } .age { min-width: 2.6em; text-align: right; }
/* A job asleep on a retry stamp is queued and would read as next in line;
* the countdown says a wait was imposed and how much of it is left. */
.due { font-variant-numeric: tabular-nums; white-space: nowrap;
color: var(--desk-jobs-warn, #b26b00); }
.due:empty { display: none; }
.heading { padding: 8px 6px 2px; font-size: 11px; font-weight: 600; .heading { padding: 8px 6px 2px; font-size: 11px; font-weight: 600;
color: var(--desk-jobs-dim, GrayText); } color: var(--desk-jobs-dim, GrayText); }
.idle, .offline { padding: 6px; color: var(--desk-jobs-dim, GrayText); } .idle, .offline { padding: 6px; color: var(--desk-jobs-dim, GrayText); }
@@ -482,6 +488,9 @@ function clock(seconds) {
const age = (stamp) => stamp ? clock((Date.now() - new Date(stamp)) / 1000) : ""; const age = (stamp) => stamp ? clock((Date.now() - new Date(stamp)) / 1000) : "";
/** The other way round: how long until a stamp, for a retry's next attempt. */
const due = (stamp) => stamp ? `due in ${clock((new Date(stamp) - Date.now()) / 1000)}` : "";
/** A running job with nothing left to count: the bar reaches its total well /** A running job with nothing left to count: the bar reaches its total well
* before the handler returns, and "12 of 12" for a minute reads as stuck. */ * before the handler returns, and "12 of 12" for a minute reads as stuck. */
const finishing = (job) => job.state === "running" && job.total > 0 && job.done >= job.total; const finishing = (job) => job.state === "running" && job.total > 0 && job.done >= job.total;
@@ -639,9 +648,11 @@ class DeskQueue extends Follower {
} }
this.#drawPop(running, queued); this.#drawPop(running, queued);
// The ages are the one column no push carries: a job that has said // The ages are the one column no push carries: a job that has said
// nothing for five minutes is the one whose age you want. // nothing for five minutes is the one whose age you want. A retry's
// countdown is the same, the other way round.
this.#ticker ??= setInterval(() => { this.#ticker ??= setInterval(() => {
for (const el of this.#pop.querySelectorAll(".age")) el.textContent = age(el.dataset.since); for (const el of this.#pop.querySelectorAll(".age")) el.textContent = age(el.dataset.since);
for (const el of this.#pop.querySelectorAll(".due")) el.textContent = due(el.dataset.until);
}, 1000); }, 1000);
} }
@@ -677,7 +688,7 @@ class DeskQueue extends Follower {
kill.type = "button"; kill.type = "button";
kill.textContent = "Kill"; kill.textContent = "Kill";
kill.addEventListener("click", () => this.kill(Number(el.dataset.key))); kill.addEventListener("click", () => this.kill(Number(el.dataset.key)));
el.append(span("what"), span("said"), span("pct"), span("age"), kill); el.append(span("what"), span("said"), span("pct"), span("due"), span("age"), kill);
return el; return el;
} }
@@ -695,6 +706,9 @@ class DeskQueue extends Follower {
const when = el.querySelector(".age"); const when = el.querySelector(".age");
when.dataset.since = since || ""; when.dataset.since = since || "";
when.textContent = age(since); when.textContent = age(since);
const until = el.querySelector(".due");
until.dataset.until = job.waiting ? job.run_after : "";
until.textContent = due(until.dataset.until);
el.querySelector("button").disabled = this.killing.has(job.id) || !!job.cancel_requested; el.querySelector("button").disabled = this.killing.has(job.id) || !!job.cancel_requested;
} }