@intentius/behold 0.29.33 → 0.29.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/kiosk-event-help-ui.js +10 -2
- package/web/kiosk-event-help.js +28 -10
- package/web/kiosk-event-help.test.js +18 -0
- package/web/kiosk-trace.js +64 -10
- package/web/kiosk-trace.test.js +14 -0
- package/web/kiosk-watch.js +43 -3
- package/web/kiosk-watch.test.js +31 -1
- package/web/kiosk.html +30 -2
- package/web/kiosk.js +182 -29
- package/web/kiosk.test.js +79 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.35",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
|
@@ -279,7 +279,7 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
279
279
|
const drawTrail = (h) => {
|
|
280
280
|
if (!trailHost) return;
|
|
281
281
|
const facts = [...st.trail.values()].sort((a, b) => a.order - b.order);
|
|
282
|
-
const key = facts.map((f) => f.id).join(",");
|
|
282
|
+
const key = facts.map((f) => `${f.id}=${f.text}`).join(",");
|
|
283
283
|
trailHost.hidden = !facts.length;
|
|
284
284
|
if (h.watch && h.caption && trailHost.style) {
|
|
285
285
|
const c = h.caption.getBoundingClientRect();
|
|
@@ -347,7 +347,15 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
|
|
|
347
347
|
const tick = () => {
|
|
348
348
|
const h = get();
|
|
349
349
|
if (!h || !h.demo) return;
|
|
350
|
-
|
|
350
|
+
// behold#571 (#631): the story is told in the tool's own step order; until that is read, nothing is said in another's.
|
|
351
|
+
if (h.stripReady === false) return;
|
|
352
|
+
const stripKey = JSON.stringify((h.strip || []).map((x) => x.id));
|
|
353
|
+
if (stripKey !== st.stripKey) {
|
|
354
|
+
// Another tool's order: the trail is told again in it.
|
|
355
|
+
st.stripKey = stripKey;
|
|
356
|
+
st.trail.clear();
|
|
357
|
+
}
|
|
358
|
+
const facts = cycleFacts(ehSnapshot({ demo: h.demo, answer: h.answer, progress: h.progress, runDoc: h.runDoc, runDocs: h.runDocs || [], approval: h.approval, metrics: h.metrics, waveTraces: h.waveTraces || {}, strip: h.strip || null, waves: h.waves || [], failed: [...st.failed] }));
|
|
351
359
|
if (h.demo.cycle !== st.cycle) {
|
|
352
360
|
// A new cycle: a new story. Its first look is the trail so far, not news.
|
|
353
361
|
// The first look at a page sees a cycle already under way: no news. A cycle that turns while the page is open is all news.
|
package/web/kiosk-event-help.js
CHANGED
|
@@ -63,7 +63,7 @@ const jobLines = (job) => (job && Array.isArray(job.steps) ? job.steps.flatMap((
|
|
|
63
63
|
* `waves` is the declared waves (`{ job, wave, roots }`), so a job names its
|
|
64
64
|
* wave and a wave its roots.
|
|
65
65
|
*/
|
|
66
|
-
export function ehSnapshot({ demo = null, answer = null, progress = null, runDoc = null, runDocs = [], approval = null, metrics = null, waveTraces = {}, waves = [], failed = [] } = {}) {
|
|
66
|
+
export function ehSnapshot({ demo = null, answer = null, progress = null, runDoc = null, runDocs = [], approval = null, metrics = null, waveTraces = {}, waves = [], failed = [], strip = null } = {}) {
|
|
67
67
|
if (!demo) return null;
|
|
68
68
|
const pr = matchingPull(answer, demo) || (answer && !answer.error && answer.pull_request && demo.pull !== null && String(answer.pull_request.run && answer.pull_request.run.pull_request) === String(demo.pull) ? answer.pull_request : null);
|
|
69
69
|
const run = matchingRun(progress, demo);
|
|
@@ -78,10 +78,12 @@ export function ehSnapshot({ demo = null, answer = null, progress = null, runDoc
|
|
|
78
78
|
run: runDoc ? { id: runDoc.id, jobs: jobs.map((j) => ({ name: j.name, status: j.status, wave: waveOfJob(j.name, waves), refusal: j.status === "failure" ? yodelRefusal(jobLines(j)) : null, step: j.steps ? defaultStep(j.steps) : -1 })) } : null,
|
|
79
79
|
approval: approval && Array.isArray(approval.rows) ? { wave: approval.wave, rows: approval.rows.filter((r) => r.state === "lit").map((r) => ({ id: r.id, at: r.at || null, actor: r.id === "approved" ? actorOf(r.text) : null, signed: !!(r.seal && /^signed/.test(r.seal.text || "")) })) } : null,
|
|
80
80
|
// The numbers of this cycle's merge only: from the merge on, and only for its commit.
|
|
81
|
-
metrics: metrics && metrics.run && metrics.run.current && stepRank(demo.step) >=
|
|
81
|
+
metrics: metrics && metrics.run && metrics.run.current && stepRank(demo.step, strip) >= stepRank("merged", strip) && (!demo.commit || String(metrics.run.label || "").includes(String(demo.commit).slice(0, 8))) ? metrics.run.waves.map((w) => ({ wave: w.wave, words: [w.seconds, w.held ? `held ${w.held}` : null, w.changed].filter(Boolean).join(" · ") })).filter((w) => w.words) : [],
|
|
82
82
|
// Each wave's trace, once Tempo has it (web/kiosk-wave-traces.js): `{ wave, run, job, words }`.
|
|
83
83
|
traces: Object.keys(waveTraces || {}).map(Number).sort((a, b) => a - b).map((w) => ({ wave: w, run: waveTraces[w].run, job: waveTraces[w].job, words: traceReadyWords(w, waveTraces[w].trace) })).filter((t) => t.words),
|
|
84
84
|
waves,
|
|
85
|
+
// The scenario's own step order (kiosk.js stripFromSteps), so the story keeps the order the steps had: chant gates before its merge.
|
|
86
|
+
strip: Array.isArray(strip) && strip.length ? strip : STRIP,
|
|
85
87
|
// The waves this cycle saw fail, kept by the kiosk: a re-run is news only against a failure seen before it.
|
|
86
88
|
failed: [...new Set(failed)],
|
|
87
89
|
// The cycle's earlier runs' failures (the approval panel reads them): a viewer who arrives after the re-run still gets the refusal.
|
|
@@ -108,7 +110,7 @@ const actorOf = (text) => {
|
|
|
108
110
|
};
|
|
109
111
|
|
|
110
112
|
/** The strip's order of a step: 0 for the pull request, up to 5 for the reset; -1 for one the strip doesn't know. */
|
|
111
|
-
const stepRank = (step) => STRIP.findIndex((s) => s.steps.includes(step));
|
|
113
|
+
const stepRank = (step, strip = STRIP) => (strip || STRIP).findIndex((s) => s.steps.includes(step));
|
|
112
114
|
|
|
113
115
|
/**
|
|
114
116
|
* Everything the snapshot says has happened in its cycle, as facts in the
|
|
@@ -122,15 +124,17 @@ export function cycleFacts(snap) {
|
|
|
122
124
|
if (!snap) return [];
|
|
123
125
|
const out = [];
|
|
124
126
|
const add = (f) => out.push({ subjects: { roots: [], wave: null, job: null, run: null }, trail: true, critical: false, ...f, subjects: { roots: [], wave: null, job: null, run: null, ...(f.subjects || {}) } });
|
|
125
|
-
const
|
|
127
|
+
const strip = snap.strip || STRIP;
|
|
128
|
+
const at = stepRank(snap.step, strip);
|
|
129
|
+
const rank = (step) => stepRank(step, strip);
|
|
126
130
|
const c = snap.cycle;
|
|
127
131
|
const runId = snap.run ? snap.run.id : null;
|
|
128
132
|
// The pull request and its plan.
|
|
129
133
|
if (snap.pull !== null && snap.pull !== undefined && at >= 0) add({ id: `${c}|pr`, kind: "pull-request", text: `pull request #${snap.pull} opened`, order: 0, subjects: { roots: snap.plan ? snap.plan.roots : [] } });
|
|
130
|
-
if (snap.plan && snap.plan.totals && at >=
|
|
134
|
+
if (snap.plan && snap.plan.totals && at >= rank("planned")) {
|
|
131
135
|
add({ id: `${c}|plan`, kind: "planned", text: planWords(snap.plan.totals), order: 1, subjects: { roots: snap.plan.roots } });
|
|
132
136
|
}
|
|
133
|
-
if (at >=
|
|
137
|
+
if (at >= rank("merged") && snap.pull !== null && snap.pull !== undefined) add({ id: `${c}|merged`, kind: "merged", text: `pull request #${snap.pull} merged`, order: 2 });
|
|
134
138
|
// Each wave, from the run view; a wave's job, from the pipeline's run.
|
|
135
139
|
const jobOf = (n) => (snap.run ? snap.run.jobs.find((j) => j.wave === n) : null);
|
|
136
140
|
const approved = snap.approval ? snap.approval.rows.find((r) => r.id === "approved") : null;
|
|
@@ -178,16 +182,30 @@ export function cycleFacts(snap) {
|
|
|
178
182
|
for (const m of snap.metrics) add({ id: `${c}|metrics|${m.wave}`, kind: "metrics", text: `wave ${m.wave}: ${m.words}`, order: 10 + m.wave * 10 + 9, subjects: { roots: rootsOfWave(m.wave, snap.waves, states), wave: m.wave, run: runId }, trail: false });
|
|
179
183
|
// A wave's trace, once Tempo has it: a beat of the story, and a tip that opens it.
|
|
180
184
|
for (const t of snap.traces) add({ id: `${c}|trace|w${t.wave}`, kind: "trace", text: t.words, order: 10 + t.wave * 10 + 9, subjects: { roots: rootsOfWave(t.wave, snap.waves, states), wave: t.wave, job: t.job, run: t.run } });
|
|
185
|
+
// A gate on the whole change (chant's pull-request loop): its approval, no wave named.
|
|
186
|
+
if (snap.approval && !Number.isInteger(snap.approval.wave)) {
|
|
187
|
+
if (snap.approval.rows.some((r) => r.id === "requested" || r.id === "approved")) add({ id: `${c}|held`, kind: "held", text: "the plan waits for an approval", order: 9, critical: true });
|
|
188
|
+
const ok = snap.approval.rows.find((r) => r.id === "approved");
|
|
189
|
+
if (ok) add({ id: `${c}|approved`, kind: "approved", text: ok.actor ? `approved by ${ok.actor}${ok.signed ? ", signed" : ""}` : "approved, signed", order: 9.5 });
|
|
190
|
+
}
|
|
181
191
|
// A gate on the whole change (chant's pull-request loop): the plan waits, no wave named.
|
|
182
192
|
// A repo with declared waves names its held wave once the run view has it; this is for a repo without them.
|
|
183
193
|
if (snap.step === "waiting" && !(snap.waves || []).length && !out.some((f) => f.kind === "held")) add({ id: `${c}|held`, kind: "held", text: "the plan waits for an approval", order: 9, critical: true });
|
|
184
|
-
|
|
185
|
-
if (snap.step === "applied") add({ id: `${c}|applied`, kind: "applied", text: !states.length ? "the change applied" :
|
|
194
|
+
// The step says the run applied: every wave the run view names, even one a read has not caught up on.
|
|
195
|
+
if (snap.step === "applied") add({ id: `${c}|applied`, kind: "applied", text: !states.length ? "the change applied" : states.length === 1 ? "the wave applied" : `all ${states.length} waves applied`, order: 990, critical: true });
|
|
186
196
|
if (snap.step === "reset") add({ id: `${c}|reset`, kind: "reset", text: "states back on the base", order: 995 });
|
|
187
|
-
// One fact per id (a wave's hold is said by the run view and the approval rows alike)
|
|
197
|
+
// One fact per id (a wave's hold is said by the run view and the approval rows alike).
|
|
188
198
|
const byId = new Map();
|
|
189
199
|
for (const f of out) if (!byId.has(f.id)) byId.set(f.id, f);
|
|
190
|
-
|
|
200
|
+
// behold#571 (#631): in the order the scenario's steps went: each fact at its stop of the strip, then in its order within it.
|
|
201
|
+
// An approval before the merge (chant's gate) is its own stop; after it, part of the waves.
|
|
202
|
+
const stopIndex = (id) => {
|
|
203
|
+
const i = strip.findIndex((x) => x.id === id);
|
|
204
|
+
return i >= 0 ? i : strip.findIndex((x) => x.id === "waves");
|
|
205
|
+
};
|
|
206
|
+
const gateStop = strip.some((x) => x.id === "approval") ? "approval" : "waves";
|
|
207
|
+
const stopOf = (f) => (["pull-request", "planned", "merged", "applied", "reset"].includes(f.kind) ? f.kind : f.kind === "pull-request" ? "pull-request" : ["held", "approved", "resumed"].includes(f.kind) && !Number.isInteger(f.subjects.wave) ? gateStop : "waves");
|
|
208
|
+
return [...byId.values()].map((f) => ({ ...f, stop: stopOf(f), order: Math.max(0, stopIndex(stopOf(f))) * 1000 + f.order })).sort((a, b) => a.order - b.order);
|
|
191
209
|
}
|
|
192
210
|
|
|
193
211
|
/** The story trail: the cycle's facts that are beats of its story. */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// told as facts in order, the news since the last look, the Tips switch, and
|
|
3
3
|
// the queues that keep tips and modals calm.
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { stripFromSteps } from "./kiosk.js";
|
|
5
6
|
import { EH_STORE, cycleFacts, ehSnapshot, ehStore, ehStored, modalQueue, newEvents, storyTrail, tipsQueue, yodelRefusal } from "./kiosk-event-help.js";
|
|
6
7
|
|
|
7
8
|
const C = "9f3c2a71d04e5b8c6a1f2e3d4c5b6a7980716253";
|
|
@@ -62,6 +63,23 @@ describe("event-help: a cycle told in order", () => {
|
|
|
62
63
|
expect(facts("waiting").some((f) => f.kind === "held")).toBe(false);
|
|
63
64
|
});
|
|
64
65
|
|
|
66
|
+
it("counts every wave at applied, even one the run view has not caught up on (behold#571)", () => {
|
|
67
|
+
const behind = facts("applied", [st(1, "applied", ["network", "other"]), st(2, "applied", ["app"]), st(3, "not-started", ["edge"])]);
|
|
68
|
+
expect(behind.find((f) => f.kind === "applied").text).toBe("all 3 waves applied");
|
|
69
|
+
expect(facts("applied", [st(1, "applied", ["network", "other"])]).find((f) => f.kind === "applied").text).toBe("the wave applied");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("tells chant's pull-request loop in its own order: the approval before the merge (#631)", () => {
|
|
73
|
+
const strip = stripFromSteps(["pull-request", "planned", "waiting", "approved", "merged", "applying", "applied", "reset"]);
|
|
74
|
+
const chant = (step, approval = null) => cycleFacts(ehSnapshot({ demo: { ...demo(step), scenario: "chant-pr-loop", tool: "chant" }, answer: null, approval, strip }));
|
|
75
|
+
// Waiting for the approval: the pull request is open, not merged.
|
|
76
|
+
expect(storyTrail(chant("waiting")).map((f) => f.text)).toEqual(["pull request #12 opened", "the plan waits for an approval"]);
|
|
77
|
+
const approval = { wave: null, rows: [{ id: "approved", state: "lit", text: "demo-reviewer approved exactly this plan.", seal: { ok: true, text: "signed; matches the repo's allowed signers" } }] };
|
|
78
|
+
expect(storyTrail(chant("applied", approval)).map((f) => f.text)).toEqual(["pull request #12 opened", "the plan waits for an approval", "approved by demo-reviewer, signed", "pull request #12 merged", "the change applied"]);
|
|
79
|
+
// terragucci's waves keep theirs: a wave's hold after the merge.
|
|
80
|
+
expect(storyTrail(facts("waiting", [st(1, "applied", ["network", "other"]), st(2, "waiting", ["app"])])).map((f) => f.kind)).toEqual(["pull-request", "planned", "merged", "applied-wave", "known", "held"]);
|
|
81
|
+
});
|
|
82
|
+
|
|
65
83
|
it("names each event's subjects, so the kiosk can place it", () => {
|
|
66
84
|
const held = facts("waiting", [st(1, "applied", ["network", "other"]), st(2, "waiting", ["app"])], { runDoc: { id: 4801, cycle: 7, jobs: [{ name: "apply-wave-2", status: "waiting", steps: [] }] } });
|
|
67
85
|
expect(held.find((f) => f.kind === "held")).toMatchObject({ critical: true, subjects: { roots: ["app"], wave: 2, job: "apply-wave-2", run: 4801 } });
|
package/web/kiosk-trace.js
CHANGED
|
@@ -198,6 +198,8 @@ const STYLE = `
|
|
|
198
198
|
.t-seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; flex: none; }
|
|
199
199
|
.t-tab { font: 600 0.9em var(--font-ui); color: var(--muted); background: transparent; border: 0; padding: 0.25em 1em; cursor: pointer; }
|
|
200
200
|
.t-tab + .t-tab { border-left: 1px solid var(--rule); }
|
|
201
|
+
.t-attempts { display: flex; align-items: center; justify-content: space-between; gap: 0.6em; }
|
|
202
|
+
.t-seg-small .t-tab { font: 600 0.85em var(--font-mono); padding: 0.05em 0.7em; letter-spacing: 0; }
|
|
201
203
|
.t-tab:hover { color: var(--fg); }
|
|
202
204
|
.t-tab[aria-pressed="true"], .t-tab[aria-pressed="true"]:hover { color: var(--bg); background: var(--pending); }
|
|
203
205
|
.t-sec { font: 600 0.8em var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0.6em 1em 0.25em; }
|
|
@@ -265,7 +267,34 @@ function bar(doc, at, width) {
|
|
|
265
267
|
* the viewer's folds (`open`, `shut`, sets of span ids) and calls `toggle(id)`
|
|
266
268
|
* and `pickJob(name)`.
|
|
267
269
|
*/
|
|
268
|
-
|
|
270
|
+
/**
|
|
271
|
+
* behold#571: which of a job's traces is the one asked about: the trace that
|
|
272
|
+
* started at `start` (the wave's own, as the kiosk picked it), else the
|
|
273
|
+
* newest of `wave`'s, else the newest. A resumed run's job applies several
|
|
274
|
+
* waves, and a wave may run twice, so its traces are attempts.
|
|
275
|
+
*/
|
|
276
|
+
export function attemptFor(traces, { wave = null, start = null } = {}) {
|
|
277
|
+
if (!traces || !traces.length) return -1;
|
|
278
|
+
if (start !== null) {
|
|
279
|
+
const i = traces.findIndex((t) => Math.abs(t.start - start) < 1);
|
|
280
|
+
if (i >= 0) return i;
|
|
281
|
+
}
|
|
282
|
+
if (wave !== null) {
|
|
283
|
+
let best = -1;
|
|
284
|
+
traces.forEach((t, i) => {
|
|
285
|
+
if (Number(t.wave) === Number(wave) && (best < 0 || traces[best].start < t.start)) best = i;
|
|
286
|
+
});
|
|
287
|
+
if (best >= 0) return best;
|
|
288
|
+
}
|
|
289
|
+
return traces.reduce((b, t, i) => (traces[b].start < t.start ? i : b), 0);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** behold#571: the words over one attempt of several, and the switch's label. */
|
|
293
|
+
export function attemptWords(i, n, start) {
|
|
294
|
+
return `Attempt ${i + 1} of ${n}, started at ${new Date(start).toISOString().slice(11, 16)} UTC`;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function renderTrace(host, { traces, run = [], job }, { doc = document, toggle = () => {}, pickJob = null, open = new Set(), shut = new Set(), attempt = null, pickAttempt = null } = {}) {
|
|
269
298
|
traceStyle(doc);
|
|
270
299
|
const box = el(doc, "div", "t-trace");
|
|
271
300
|
const strip = runStrip(run);
|
|
@@ -284,10 +313,29 @@ export function renderTrace(host, { traces, run = [], job }, { doc = document, t
|
|
|
284
313
|
}
|
|
285
314
|
box.appendChild(rows);
|
|
286
315
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
316
|
+
// behold#571: asked about one attempt of several, it shows that one, with a switch to the others.
|
|
317
|
+
const one = attempt !== null && attempt >= 0 && attempt < traces.length && traces.length > 1;
|
|
318
|
+
const shown = one ? [traces[attempt]] : traces;
|
|
319
|
+
shown.forEach((t, k) => {
|
|
320
|
+
const i = one ? attempt : k;
|
|
321
|
+
const head = traces.length > 1 ? attemptWords(i, traces.length, t.start) : `This job · ${msWords(t.ms)}`;
|
|
322
|
+
if (one) {
|
|
323
|
+
const sec = el(doc, "div", "t-sec t-attempts");
|
|
324
|
+
sec.appendChild(el(doc, "span", null, head));
|
|
325
|
+
const seg = el(doc, "span", "t-seg t-seg-small");
|
|
326
|
+
seg.setAttribute("role", "group");
|
|
327
|
+
seg.setAttribute("aria-label", "attempt");
|
|
328
|
+
traces.forEach((x, j) => {
|
|
329
|
+
const b = el(doc, "button", "t-tab", String(j + 1));
|
|
330
|
+
b.type = "button";
|
|
331
|
+
b.title = attemptWords(j, traces.length, x.start);
|
|
332
|
+
b.setAttribute("aria-pressed", String(j === i));
|
|
333
|
+
if (pickAttempt) b.addEventListener("click", () => pickAttempt(j));
|
|
334
|
+
seg.appendChild(b);
|
|
335
|
+
});
|
|
336
|
+
sec.appendChild(seg);
|
|
337
|
+
box.appendChild(sec);
|
|
338
|
+
} else box.appendChild(el(doc, "div", "t-sec", head));
|
|
291
339
|
const rows = el(doc, "div", "t-rows");
|
|
292
340
|
for (const r of waterfallRows(t, { open, shut })) {
|
|
293
341
|
const cls = ["t-row", r.kids ? "t-can" : "", r.service !== "terragucci" ? "t-bin" : "", r.critical ? "t-crit" : "", r.wait ? "t-wait" : "", r.error ? "t-err" : ""].filter(Boolean).join(" ");
|
|
@@ -377,8 +425,8 @@ export function traceSource({ fetchJson, onChange = () => {}, now = () => Date.n
|
|
|
377
425
|
has: (repo, run, job) => of(repo, run, job).length > 0,
|
|
378
426
|
traces: of,
|
|
379
427
|
all: (repo, run) => (read(repo, run) || { traces: [] }).traces,
|
|
380
|
-
draw(host, { repo, run, job, pickJob = null, doc = document }) {
|
|
381
|
-
return renderTrace(host, { traces: of(repo, run, job), run: this.all(repo, run), job }, { doc, pickJob, open: folds.open, shut: folds.shut, toggle: (id, depth) => { folds.toggle(id, depth); onChange(); } });
|
|
428
|
+
draw(host, { repo, run, job, pickJob = null, doc = document, attempt = null, pickAttempt = null }) {
|
|
429
|
+
return renderTrace(host, { traces: of(repo, run, job), run: this.all(repo, run), job }, { doc, pickJob, attempt, pickAttempt, open: folds.open, shut: folds.shut, toggle: (id, depth) => { folds.toggle(id, depth); onChange(); } });
|
|
382
430
|
},
|
|
383
431
|
};
|
|
384
432
|
}
|
|
@@ -389,19 +437,25 @@ export function traceSource({ fetchJson, onChange = () => {}, now = () => Date.n
|
|
|
389
437
|
* it at another job; `stop` ends its reads. With no trace for the job it
|
|
390
438
|
* draws nothing.
|
|
391
439
|
*/
|
|
392
|
-
export function mountTrace(host, { project, run, job, fetchJson = defaultFetch, doc = document, setTimer = setInterval, clearTimer = clearInterval, pickJob = null } = {}) {
|
|
393
|
-
let target = { project, run, job };
|
|
440
|
+
export function mountTrace(host, { project, run, job, wave = null, start = null, fetchJson = defaultFetch, doc = document, setTimer = setInterval, clearTimer = clearInterval, pickJob = null } = {}) {
|
|
441
|
+
let target = { project, run, job, wave, start };
|
|
442
|
+
// behold#571: with a wave named, the attempt that is its; a viewer's pick of another holds until the target moves.
|
|
443
|
+
let picked = null;
|
|
394
444
|
const draw = () => {
|
|
395
445
|
host.replaceChildren();
|
|
396
446
|
if (!source.has(target.project, target.run, target.job)) return;
|
|
397
|
-
source.
|
|
447
|
+
const traces = source.traces(target.project, target.run, target.job);
|
|
448
|
+
const attempt = target.wave === null && target.start === null ? null : picked !== null && picked < traces.length ? picked : attemptFor(traces, target);
|
|
449
|
+
source.draw(host, { repo: target.project, run: target.run, job: target.job, pickJob, doc, attempt, pickAttempt: (i) => ((picked = i), draw()) });
|
|
398
450
|
};
|
|
399
451
|
const source = traceSource({ fetchJson, onChange: draw });
|
|
400
452
|
draw();
|
|
401
453
|
const timer = setTimer(draw, TRACE_POLL_MS);
|
|
402
454
|
return {
|
|
403
455
|
update(next) {
|
|
456
|
+
const was = JSON.stringify(target);
|
|
404
457
|
target = { ...target, ...next };
|
|
458
|
+
if (JSON.stringify(target) !== was) picked = null;
|
|
405
459
|
draw();
|
|
406
460
|
},
|
|
407
461
|
stop() {
|
package/web/kiosk-trace.test.js
CHANGED
|
@@ -155,3 +155,17 @@ describe("the strip's left bars (behold#571)", () => {
|
|
|
155
155
|
expect(["failed", "changed-after-approval", "waiting", "applied", "planned", undefined, "other"].map(stripTone)).toEqual(["bad", "bad", "wait", "ok", "ok", "idle", "idle"]);
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
|
+
|
|
159
|
+
describe("kiosk trace: one attempt of several (behold#571)", () => {
|
|
160
|
+
const t = (wave, start) => ({ wave, start, ms: 10, spans: [] });
|
|
161
|
+
it("picks the attempt that is the asked-about wave's: its own start, else that wave's newest, else the newest", async () => {
|
|
162
|
+
const { attemptFor, attemptWords } = await import("./kiosk-trace.js");
|
|
163
|
+
const traces = [t(1, 100), t(2, 200), t(2, 300)];
|
|
164
|
+
expect(attemptFor(traces, { wave: 2, start: 200 })).toBe(1);
|
|
165
|
+
expect(attemptFor(traces, { wave: 2 })).toBe(2);
|
|
166
|
+
expect(attemptFor(traces, { wave: 1 })).toBe(0);
|
|
167
|
+
expect(attemptFor(traces, { wave: 9 })).toBe(2);
|
|
168
|
+
expect(attemptFor([], { wave: 1 })).toBe(-1);
|
|
169
|
+
expect(attemptWords(0, 2, Date.parse("2026-10-16T19:25:38Z"))).toBe("Attempt 1 of 2, started at 19:25 UTC");
|
|
170
|
+
});
|
|
171
|
+
});
|
package/web/kiosk-watch.js
CHANGED
|
@@ -190,9 +190,11 @@ function roundedWeek(v) {
|
|
|
190
190
|
export function resultModel(demo, metrics, progress = null) {
|
|
191
191
|
if (!demo || demo.step !== "applied") return null;
|
|
192
192
|
const run = matchingRun(progress, demo);
|
|
193
|
-
|
|
193
|
+
// The step says the run applied: every wave the run view names counts, even one a read has not caught up on yet.
|
|
194
|
+
const all = run ? progress.states || [] : [];
|
|
195
|
+
const states = all.filter((w) => w.state === "applied");
|
|
194
196
|
const m = metrics && metrics.run && metrics.run.current ? metrics.run.waves : [];
|
|
195
|
-
const n =
|
|
197
|
+
const n = all.length || m.length;
|
|
196
198
|
if (!n) return null;
|
|
197
199
|
const counts = [`${n} ${n === 1 ? "wave" : "waves"} applied`];
|
|
198
200
|
const changed = states.length ? mergeChanges(states.map((w) => w.totals)) : mergeChanges(m.map((w) => w.changesRaw));
|
|
@@ -204,10 +206,48 @@ export function resultModel(demo, metrics, progress = null) {
|
|
|
204
206
|
const held = m.reduce((a, w) => a + (Number.isFinite(w.heldRaw) ? w.heldRaw : 0), 0);
|
|
205
207
|
if (held > 0) counts.push(`${secondsShort(held)} held for an approval`);
|
|
206
208
|
}
|
|
207
|
-
|
|
209
|
+
// A row for every wave, its numbers when they have landed; never fewer rows than the count says.
|
|
210
|
+
const numbers = new Map(m.map((w) => [w.wave, badgeWords(w)]));
|
|
211
|
+
const numbered = [...new Set([...all.map((w) => w.number), ...m.map((w) => w.wave)])].sort((a, b) => a - b);
|
|
212
|
+
const waves = numbered.map((w) => ({ wave: w, words: numbers.get(w) || null }));
|
|
208
213
|
return { head: "Applied", line: typeof demo.label === "string" ? demo.label : "", counts, waves };
|
|
209
214
|
}
|
|
210
215
|
|
|
216
|
+
/**
|
|
217
|
+
* behold#571: the run view as the cycle has seen it, for the result card and
|
|
218
|
+
* the trail. Reads land one by one and a read can lag behind the last: within
|
|
219
|
+
* one cycle's commit, a wave once read as applied stays applied, a wave a
|
|
220
|
+
* read leaves out keeps what it was, and the run stays the last one that
|
|
221
|
+
* matched. `{ memo, progress }`; pass the memo back in with the next read.
|
|
222
|
+
*/
|
|
223
|
+
export function steadyRun(memo, progress, demo) {
|
|
224
|
+
const key = demo ? `${demo.cycle}|${demo.commit}` : null;
|
|
225
|
+
const run = demo ? matchingRun(progress, demo) : null;
|
|
226
|
+
const was = memo && memo.key === key ? memo : { key, run: null, states: {} };
|
|
227
|
+
const next = { key, run: run || was.run, states: { ...was.states } };
|
|
228
|
+
if (run) {
|
|
229
|
+
for (const st of progress.states || []) {
|
|
230
|
+
const had = next.states[st.number];
|
|
231
|
+
if (had && had.state === "applied" && st.state !== "applied") continue;
|
|
232
|
+
// A re-run's run view says nothing changed for a wave an earlier run applied: the change stays the one that landed.
|
|
233
|
+
if (had && had.state === "applied" && st.state === "applied" && changeCount(had.totals) > 0 && changeCount(st.totals) === 0) continue;
|
|
234
|
+
next.states[st.number] = st;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const states = Object.values(next.states).sort((a, b) => a.number - b.number);
|
|
238
|
+
if (!next.run || !states.length) return { memo: next, progress };
|
|
239
|
+
return { memo: next, progress: { ...(run ? progress : {}), reads: run ? progress.reads || [] : [], run: next.run, states } };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const changeCount = (totals) => ACTION_ORDER.reduce((a, k) => a + (totals && typeof totals[k] === "number" ? totals[k] : 0), 0);
|
|
243
|
+
|
|
244
|
+
/** behold#571: whether a run view is behind the step: the step says applied, and a wave in it still says otherwise. */
|
|
245
|
+
export function behindStep(demo, progress) {
|
|
246
|
+
if (!demo || demo.step !== "applied") return false;
|
|
247
|
+
const run = matchingRun(progress, demo);
|
|
248
|
+
return !!run && (progress.states || []).some((w) => w.state !== "applied");
|
|
249
|
+
}
|
|
250
|
+
|
|
211
251
|
const ACTION_ORDER = ["create", "update", "delete", "replace", "forget", "import", "move"];
|
|
212
252
|
const ACTION_WORDS = { create: "created", update: "updated", delete: "deleted", replace: "replaced", forget: "forgotten", import: "imported", move: "moved" };
|
|
213
253
|
function mergeChanges(list) {
|
package/web/kiosk-watch.test.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// takes, what the caption leads with, the badges, the delivery line, the
|
|
3
3
|
// result card, the drawer's folded lines, and where an overlay goes.
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { MODE_STORE, activeWave, badgeTitle, badgeWords, badges, captionModel, changeRoots, doraLine, modeStored, placeBeside, resultModel, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
5
|
+
import { MODE_STORE, activeWave, badgeTitle, badgeWords, badges, behindStep, steadyRun, captionModel, changeRoots, doraLine, modeStored, placeBeside, resultModel, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
6
6
|
|
|
7
7
|
const C = "9f3c2a71d04e5b8c6a1f2e3d4c5b6a7980716253";
|
|
8
8
|
const P = "1111111111111111111111111111111111111111";
|
|
@@ -144,6 +144,36 @@ describe("kiosk watch: the numbers", () => {
|
|
|
144
144
|
expect(resultModel(demo("applying"), metrics, p)).toBeNull();
|
|
145
145
|
expect(resultModel(demo("applied"), null, null)).toBeNull();
|
|
146
146
|
});
|
|
147
|
+
|
|
148
|
+
it("never counts fewer waves than the step says, nor lists fewer than it counts (behold#571)", () => {
|
|
149
|
+
// The step says applied while the run view still has wave 3 queued: three waves applied, three rows, the third's numbers to come.
|
|
150
|
+
const behind = progress([st(1, "applied", ["network"], { update: 1 }), st(2, "applied", ["app"], { create: 4 }), st(3, "not-started", ["edge"])]);
|
|
151
|
+
const r = resultModel(demo("applied"), metrics, behind);
|
|
152
|
+
expect(r.counts[0]).toBe("3 waves applied");
|
|
153
|
+
expect(r.waves).toEqual([{ wave: 1, words: "1.6 s · 1 updated" }, { wave: 2, words: "9.5 s · held 25 s · 4 created" }, { wave: 3, words: null }]);
|
|
154
|
+
expect(behindStep(demo("applied"), behind)).toBe(true);
|
|
155
|
+
expect(behindStep(demo("applied"), progress([st(1, "applied", ["network"])]))).toBe(false);
|
|
156
|
+
expect(behindStep(demo("applying"), behind)).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("keeps the run view as the cycle has seen it: an applied wave stays applied, a wave a read leaves out stays, a read for another run is set aside", () => {
|
|
160
|
+
const d = demo("applied");
|
|
161
|
+
let { memo, progress: p1 } = steadyRun(null, progress([st(1, "applied", ["network"]), st(2, "applied", ["app"]), st(3, "applied", ["edge"])]), d);
|
|
162
|
+
expect(p1.states.map((w) => w.state)).toEqual(["applied", "applied", "applied"]);
|
|
163
|
+
// A lagging read: the resume's run view, not yet caught up.
|
|
164
|
+
const lag = steadyRun(memo, progress([st(1, "applied", ["network"]), st(2, "not-started", ["app"])]), d);
|
|
165
|
+
expect(lag.progress.states.map((w) => [w.number, w.state])).toEqual([[1, "applied"], [2, "applied"], [3, "applied"]]);
|
|
166
|
+
// A read of another commit (the reset's push): the cycle's run stays.
|
|
167
|
+
const other = steadyRun(lag.memo, { run: { present: true, commit: "0000000000000000000000000000000000000000", updated: "2026-10-16T09:00:00Z" }, states: [st(1, "planned", ["network"])], reads: [] }, d);
|
|
168
|
+
expect(other.progress.states).toHaveLength(3);
|
|
169
|
+
expect(resultModel(d, null, other.progress).counts[0]).toBe("3 waves applied");
|
|
170
|
+
// The resume's run view says the waves an earlier run applied changed nothing now: the changes that landed stay.
|
|
171
|
+
const first = steadyRun(null, progress([st(1, "applied", ["network"], { update: 1 }), st(2, "applied", ["app"], { create: 4 })]), d);
|
|
172
|
+
const resumed = steadyRun(first.memo, progress([st(1, "applied", ["network"], { "no-op": 3 }), st(2, "applied", ["app"], { create: 4 })]), d);
|
|
173
|
+
expect(resultModel(d, null, resumed.progress).counts).toEqual(["2 waves applied", "4 created, 1 updated"]);
|
|
174
|
+
// A new cycle starts over.
|
|
175
|
+
expect(steadyRun(other.memo, null, demo("pull-request", { cycle: 13 })).progress).toBeNull();
|
|
176
|
+
});
|
|
147
177
|
});
|
|
148
178
|
|
|
149
179
|
describe("kiosk watch: the drawer's folded lines", () => {
|
package/web/kiosk.html
CHANGED
|
@@ -217,6 +217,28 @@
|
|
|
217
217
|
.k-action { font-family: var(--font-mono); color: var(--fg); }
|
|
218
218
|
.k-when { color: var(--foreign); font-family: var(--font-mono); }
|
|
219
219
|
.k-next-by { color: var(--muted); }
|
|
220
|
+
/*
|
|
221
|
+
* behold#571: the bar under "next, by the driver", in both layouts: how far the driver's wait
|
|
222
|
+
* has gone (kiosk.js nextProgress), in the step's tone (theme.js barInks, 3:1 in every theme).
|
|
223
|
+
* It is placed, never in the flow, so no row moves when it comes or goes. At the deadline it
|
|
224
|
+
* pulses until the step changes; with no deadline a quiet shimmer runs. Under reduced motion
|
|
225
|
+
* the due bar is steady and full, and there is no shimmer.
|
|
226
|
+
*/
|
|
227
|
+
.k-row-next { position: relative; }
|
|
228
|
+
.k-nbar { position: absolute; left: calc(0.75em + var(--k-label-w) + 0.8em); right: 0.2em; bottom: 0; height: 3px; border-radius: 2px; overflow: hidden; pointer-events: none;
|
|
229
|
+
background: color-mix(in srgb, var(--rule) 55%, transparent); }
|
|
230
|
+
.k-nbar-none { display: none; }
|
|
231
|
+
.k-nbar-in { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--k-nbar-fill, 0) * 100%); border-radius: inherit; background: var(--bar, var(--bar-neutral)); }
|
|
232
|
+
.k-nbar-due .k-nbar-in { width: 100%; }
|
|
233
|
+
.k-nbar-wait { background: transparent; }
|
|
234
|
+
.k-nbar-wait .k-nbar-in { width: 30%; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bar, var(--bar-neutral)) 60%, transparent), transparent); }
|
|
235
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
236
|
+
.k-nbar-due .k-nbar-in { animation: k-nbar-pulse 2.4s ease-in-out var(--k-nbar-phase, 0ms) infinite; }
|
|
237
|
+
.k-nbar-wait .k-nbar-in { animation: k-nbar-sweep 2.4s linear var(--k-nbar-phase, 0ms) infinite; }
|
|
238
|
+
}
|
|
239
|
+
@media (prefers-reduced-motion: reduce) { .k-nbar-wait { display: none; } }
|
|
240
|
+
@keyframes k-nbar-pulse { 50% { opacity: 0.5; } }
|
|
241
|
+
@keyframes k-nbar-sweep { from { transform: translateX(-100%); } to { transform: translateX(334%); } }
|
|
220
242
|
/* The pull request's facts, smallest: each part a chip that wraps whole, never cut off. */
|
|
221
243
|
.k-row-facts .k-row-label { padding-top: 0.25em; }
|
|
222
244
|
.k-row-box > p.k-facts { display: flex; flex-wrap: wrap; gap: 0 0.5em; max-width: none; font-size: 0.84em; line-height: 1.45; color: var(--fg); }
|
|
@@ -334,6 +356,7 @@
|
|
|
334
356
|
.k-row { grid-template-columns: minmax(0, 1fr); row-gap: 0.1em; padding: 0.1em 0 0.1em 0.75em; }
|
|
335
357
|
.k-row-empty { display: none; }
|
|
336
358
|
.k-row-label { padding-top: 0; }
|
|
359
|
+
.k-nbar { left: 0.75em; right: 0; }
|
|
337
360
|
#views { flex-wrap: wrap; gap: 0.3em 0.9em; }
|
|
338
361
|
.k-strip { flex-wrap: wrap; }
|
|
339
362
|
.k-right > .k-cycle { padding: 0; }
|
|
@@ -401,6 +424,8 @@
|
|
|
401
424
|
.k-cap-title .k-brand { vertical-align: 0; }
|
|
402
425
|
.k-cap-next { margin-left: auto; color: var(--muted); font-size: 0.92em; white-space: nowrap; flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
|
|
403
426
|
.k-cap-next .k-action { font-family: var(--font-mono); color: var(--fg); }
|
|
427
|
+
.k-cap-next { position: relative; padding-bottom: 6px; }
|
|
428
|
+
.k-cap-next .k-nbar { left: 0; right: 0; bottom: 0; }
|
|
404
429
|
/* behold#571: the caption's beats are the lead block's rows: the label in a fixed column, the words beside it (two lines, at most 72ch), a rail down the left; only the step's rail takes its state's colour (theme.js barInks). */
|
|
405
430
|
.k-cap-row { margin: 0; display: grid; grid-template-columns: var(--k-label-w) minmax(0, 1fr); column-gap: 0.8em; align-items: start; align-self: stretch; padding-left: 0.75em; line-height: 1.25; font-size: 1em; color: color-mix(in srgb, var(--fg) 78%, var(--muted)); box-shadow: inset 3px 0 0 var(--bar, var(--bar-neutral)); }
|
|
406
431
|
.k-cap-row:empty { box-shadow: none; }
|
|
@@ -470,7 +495,9 @@
|
|
|
470
495
|
#k-drawer.k-trace-only #k-traces:empty { display: block; }
|
|
471
496
|
.k-wf { margin-top: 0.7em; padding-top: 0.5em; border-top: 1px solid var(--rule); display: grid; gap: 0.25em; }
|
|
472
497
|
.k-wf-row { display: grid; grid-template-columns: 4.2em minmax(6em, 1fr) auto auto; align-items: center; gap: 0.6em; width: 100%; padding: 0.2em 0.3em; border: 0; border-radius: 6px; background: transparent; color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
|
|
473
|
-
.k-wf-row:hover, .k-wf-row:focus-visible { background: var(--active); }
|
|
498
|
+
.k-wf-row:not(.k-wf-plain):hover, .k-wf-row:focus-visible { background: var(--active); }
|
|
499
|
+
.k-wf-row.k-wf-plain { grid-template-columns: 4.2em minmax(0, 1fr); cursor: default; }
|
|
500
|
+
.k-wf-words { font-size: 0.9em; font-variant-numeric: tabular-nums; }
|
|
474
501
|
.k-wf-wave { font: 600 0.88em var(--font-mono); color: var(--muted); }
|
|
475
502
|
.k-wf-track { position: relative; height: 0.85em; border-radius: 3px; background: color-mix(in srgb, var(--rule) 45%, transparent); overflow: hidden; }
|
|
476
503
|
.k-wf-seg { position: absolute; top: 0; bottom: 0; min-width: 2px; }
|
|
@@ -491,6 +518,7 @@
|
|
|
491
518
|
.k-result-waves { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.2em 0.9em; margin: 0; padding-top: 0.5em; border-top: 1px solid var(--rule); }
|
|
492
519
|
.k-result-waves dt { font: 600 0.9em var(--font-mono); color: var(--muted); }
|
|
493
520
|
.k-result-waves dd { margin: 0; font-variant-numeric: tabular-nums; }
|
|
521
|
+
.k-result-waves dd.k-result-soon { color: var(--muted); font-style: italic; }
|
|
494
522
|
@media (max-width: 900px) and (min-width: 601px) { body.k-watch #bar { padding-right: 1em; flex-wrap: wrap; } body.k-watch #k-head { display: flex; flex-direction: column-reverse; } body.k-watch #k-tools { position: static; justify-content: flex-end; padding: 0.4em 1em 0; } }
|
|
495
523
|
.k-w-dora-foot { display: none; }
|
|
496
524
|
/* A phone: a short header, the graph, then the step and the approval under it; the rest stacks below, in the page's flow. */
|
|
@@ -505,7 +533,7 @@
|
|
|
505
533
|
.k-cap-step { order: 2; } .k-cap-changes { order: 3; }
|
|
506
534
|
.k-cap-title { white-space: normal; font-size: 1.12em; }
|
|
507
535
|
.k-cap-title .k-kicker { display: block; margin-bottom: 0.1em; }
|
|
508
|
-
.k-cap-next {
|
|
536
|
+
.k-cap-next { margin-left: 0; flex: 1 1 100%; max-width: none; white-space: normal; }
|
|
509
537
|
.k-cap-row { grid-template-columns: minmax(0, 1fr); row-gap: 0.1em; } .k-cap-text { -webkit-line-clamp: unset; display: block; } .k-cap-label { padding-top: 0; }
|
|
510
538
|
.k-cap-lead { font-size: 1.12em; }
|
|
511
539
|
.k-over, #k-result { position: static; visibility: visible; width: auto; margin: 0 16px; max-height: none; transform: none !important; }
|
package/web/kiosk.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { CHANT_PANEL_STEPS, chantApprovalModel } from "./chant-pr-marks.js";
|
|
17
17
|
import { PICK_HOLD_MS, annMark, mergeRun, startRuns, statusIcon } from "./kiosk-runs.js";
|
|
18
|
-
import { MODES, MODE_STORE, badges as waveBadges, badgeTitle, captionModel, doraLine, modeStored, placeBeside, resultModel, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
18
|
+
import { MODES, MODE_STORE, badges as waveBadges, badgeTitle, behindStep, steadyRun, captionModel, doraLine, modeStored, placeBeside, resultModel, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
19
19
|
import { shotMessage } from "./kiosk-shot.js";
|
|
20
20
|
import { mountTrace } from "./kiosk-trace.js";
|
|
21
21
|
import { startEventHelp } from "./kiosk-event-help-ui.js";
|
|
@@ -120,9 +120,40 @@ export function aboutRows(demo) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
/** The strip: each stop, and whether it is done, current or ahead. A stalled cycle marks no stop current. */
|
|
123
|
-
export function stripStops(step) {
|
|
124
|
-
const at =
|
|
125
|
-
return
|
|
123
|
+
export function stripStops(step, strip = STRIP) {
|
|
124
|
+
const at = strip.findIndex((s) => s.steps.includes(step));
|
|
125
|
+
return strip.map((s, i) => ({ id: s.id, words: s.words, state: at < 0 ? "ahead" : i < at ? "done" : i === at ? (step === "failed" ? "failed" : "current") : "ahead" }));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** behold#571 (#631): the words of the strip's approval stop, a gate before the merge. */
|
|
129
|
+
export const APPROVAL_STOP = { id: "approval", words: "approval" };
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* behold#571 (#631): the strip in a scenario's own order, from the steps its
|
|
133
|
+
* tool's recorded cycle went through (/api/terragucci/cycles/<tool>). A wait
|
|
134
|
+
* for an approval before the merge (chant's pull-request loop gates the plan
|
|
135
|
+
* before it merges) is a stop of its own between "planned" and "merged"; after
|
|
136
|
+
* the merge it is part of the waves, as terragucci's waves are. Null when the
|
|
137
|
+
* steps say nothing, so the default strip stands.
|
|
138
|
+
*/
|
|
139
|
+
export function stripFromSteps(steps) {
|
|
140
|
+
if (!Array.isArray(steps) || !steps.length) return null;
|
|
141
|
+
const words = Object.fromEntries(STRIP.map((x) => [x.id, x.words]));
|
|
142
|
+
const stops = [];
|
|
143
|
+
let merged = false;
|
|
144
|
+
for (const step of steps) {
|
|
145
|
+
if (step === "merged") merged = true;
|
|
146
|
+
const id = ["pull-request", "planned", "merged", "applied", "reset"].includes(step) ? step : (step === "waiting" || step === "approved") && !merged ? APPROVAL_STOP.id : "waves";
|
|
147
|
+
let stop = stops.find((x) => x.id === id);
|
|
148
|
+
if (!stop) {
|
|
149
|
+
stop = { id, words: id === APPROVAL_STOP.id ? APPROVAL_STOP.words : words[id] || id, steps: [] };
|
|
150
|
+
stops.push(stop);
|
|
151
|
+
}
|
|
152
|
+
if (!stop.steps.includes(step)) stop.steps.push(step);
|
|
153
|
+
}
|
|
154
|
+
// A stop the default strip has and these steps never reached (the waves of a run that applied in one go) keeps its place.
|
|
155
|
+
for (const d of STRIP) if (!stops.some((x) => x.id === d.id)) stops.splice(Math.min(stops.length, STRIP.indexOf(d)), 0, { id: d.id, words: d.words, steps: d.steps.filter((st) => !stops.some((x) => x.steps.includes(st))) });
|
|
156
|
+
return stops;
|
|
126
157
|
}
|
|
127
158
|
|
|
128
159
|
/** Seconds from now until `at`, never below 0; null when there is no time. */
|
|
@@ -141,6 +172,64 @@ export function countdownWords(secs) {
|
|
|
141
172
|
return `in ${Math.floor(secs / 60)} m ${String(secs % 60).padStart(2, "0")} s`;
|
|
142
173
|
}
|
|
143
174
|
|
|
175
|
+
/**
|
|
176
|
+
* behold#571: how far the driver's wait for its next action has gone, for the
|
|
177
|
+
* bar under "next, by the driver". The bar fills from `next.from` (when the
|
|
178
|
+
* driver started waiting; an older driver leaves it out) to `next.at`. Without `from`
|
|
179
|
+
* it fills from `seen`, when this page first saw that deadline; null when the
|
|
180
|
+
* page joined the countdown midway, and then there is no bar, only the words.
|
|
181
|
+
*
|
|
182
|
+
* kind is "fill" (fraction 0..1), "due" (the deadline passed: a full bar that
|
|
183
|
+
* pulses until the step changes), "wait" (no deadline: the driver waits on the
|
|
184
|
+
* pipeline, a quiet shimmer) or "none" (no bar).
|
|
185
|
+
*/
|
|
186
|
+
export function nextProgress(next, now = new Date(), seen = null) {
|
|
187
|
+
if (!next) return { kind: "none", fraction: null };
|
|
188
|
+
if (!next.at) return { kind: "wait", fraction: null };
|
|
189
|
+
const at = Date.parse(next.at);
|
|
190
|
+
if (Number.isNaN(at)) return { kind: "none", fraction: null };
|
|
191
|
+
const t = now.getTime();
|
|
192
|
+
if (t >= at) return { kind: "due", fraction: 1 };
|
|
193
|
+
const parsed = next.from ? Date.parse(next.from) : NaN;
|
|
194
|
+
const from = Number.isNaN(parsed) ? seen : parsed;
|
|
195
|
+
if (typeof from !== "number" || !Number.isFinite(from) || from >= at) return { kind: "none", fraction: null };
|
|
196
|
+
return { kind: "fill", fraction: Math.min(1, Math.max(0, (t - from) / (at - from))) };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* behold#571: when this page first saw each deadline, for nextProgress's
|
|
201
|
+
* `seen`. The deadline on screen when the page loaded, or when the mode
|
|
202
|
+
* changed (live, replay), was seen midway: its `seen` is null. One that came
|
|
203
|
+
* after is seen at `nowMs`. `next` is demo.json's next (null when it has
|
|
204
|
+
* none), or undefined while no demo.json has been read. Returns the memo to
|
|
205
|
+
* keep for the next call.
|
|
206
|
+
*/
|
|
207
|
+
export function nextSeen(memo, next, mode, nowMs) {
|
|
208
|
+
// No demo.json read yet: nothing watched.
|
|
209
|
+
if (next === undefined) return memo;
|
|
210
|
+
const key = next && next.at ? `${next.action}|${next.at}` : null;
|
|
211
|
+
if (memo && memo.mode === mode && memo.key === key) return memo;
|
|
212
|
+
return { key, mode, seen: memo && memo.mode === mode && key ? nowMs : null };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** The period of the due bar's pulse and the shimmer's sweep; the redraw rebuilds the bar each second, so it carries its phase. */
|
|
216
|
+
export const NEXT_BAR_MS = 2400;
|
|
217
|
+
|
|
218
|
+
/** behold#571: the bar under "next, by the driver", in the step's tone (theme.js barInks). It never takes room: CSS places it. */
|
|
219
|
+
function nextBar(demo, now, s) {
|
|
220
|
+
const p = nextProgress(demo.next, now, s && s.nextSeen ? s.nextSeen.seen : null);
|
|
221
|
+
const bar = el("span", `k-nbar k-nbar-${p.kind}`);
|
|
222
|
+
if (bar.dataset) bar.dataset.kTone = stepTone(demo.step);
|
|
223
|
+
if (bar.setAttribute) bar.setAttribute("aria-hidden", "true");
|
|
224
|
+
const fill = el("span", "k-nbar-in");
|
|
225
|
+
if (fill.style && fill.style.setProperty) {
|
|
226
|
+
if (p.fraction !== null) fill.style.setProperty("--k-nbar-fill", String(Math.round(p.fraction * 1000) / 1000));
|
|
227
|
+
fill.style.setProperty("--k-nbar-phase", `-${Date.now() % NEXT_BAR_MS}ms`);
|
|
228
|
+
}
|
|
229
|
+
bar.appendChild(fill);
|
|
230
|
+
return bar;
|
|
231
|
+
}
|
|
232
|
+
|
|
144
233
|
/** The driver's next action, as the kiosk says it. */
|
|
145
234
|
export function nextWords(demo, now = new Date()) {
|
|
146
235
|
if (!demo.next) return { action: "reset and start the next cycle", when: "the driver stalled; it resets and starts the next cycle", secs: null };
|
|
@@ -682,7 +771,7 @@ function drawBar(bar, s, now) {
|
|
|
682
771
|
over.appendChild(el("span", "k-kicker", head.kicker));
|
|
683
772
|
// The scenario's progress: the strip's stops, at the end of the line over the title.
|
|
684
773
|
const strip = el("ol", "k-strip");
|
|
685
|
-
for (const stop of stripStops(demo.step)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
774
|
+
for (const stop of stripStops(demo.step, s.strip || STRIP)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
686
775
|
over.appendChild(strip);
|
|
687
776
|
const title = el("h1", "k-title");
|
|
688
777
|
title.appendChild(el("span", "k-title-text", head.title));
|
|
@@ -706,7 +795,9 @@ function drawBar(bar, s, now) {
|
|
|
706
795
|
const nx = nextWords(demo, now);
|
|
707
796
|
const next = el("p", "k-next");
|
|
708
797
|
next.append(elRoots("span", "k-action", nx.action, s), " ", el("span", "k-when", nx.when), " ", el("span", "k-next-by", "by the driver"));
|
|
709
|
-
|
|
798
|
+
const nextRow = leadRow("next", "k-row-next", "Next", next);
|
|
799
|
+
nextRow.appendChild(nextBar(demo, now, s));
|
|
800
|
+
left.appendChild(nextRow);
|
|
710
801
|
|
|
711
802
|
// The rest of the card, quieter: each field on its own row (watch for, then what the scenario shows).
|
|
712
803
|
const more = demo.step === "reset" && intro ? [] : rows.filter((r) => r !== changes);
|
|
@@ -811,7 +902,7 @@ function drawWatchHead(bar, s, now) {
|
|
|
811
902
|
place.appendChild(el("span", "k-cycle", cycleWords(demo, now)));
|
|
812
903
|
bar.appendChild(place);
|
|
813
904
|
const strip = el("ol", "k-strip");
|
|
814
|
-
for (const stop of stripStops(demo.step)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
905
|
+
for (const stop of stripStops(demo.step, s.strip || STRIP)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
815
906
|
bar.appendChild(strip);
|
|
816
907
|
if (s.watchHeld) {
|
|
817
908
|
const p = el("span", "k-w-held", heldWords(s.watchHeld.secs));
|
|
@@ -844,6 +935,7 @@ function drawCaption(host, s, now) {
|
|
|
844
935
|
const nx = el("p", "k-cap-next");
|
|
845
936
|
nx.append("next, by the driver: ", elRoots("span", "k-action", cap.next.action, s), " ", el("span", "k-when", cap.next.when));
|
|
846
937
|
if (nx.setAttribute) nx.setAttribute("title", `next, by the driver: ${cap.next.action}`);
|
|
938
|
+
nx.appendChild(nextBar(demo, now, s));
|
|
847
939
|
top.appendChild(nx);
|
|
848
940
|
}
|
|
849
941
|
host.appendChild(top);
|
|
@@ -910,18 +1002,21 @@ function drawResult(host, model, s) {
|
|
|
910
1002
|
const counts = el("ul", "k-result-counts");
|
|
911
1003
|
for (const c of model.counts) counts.appendChild(el("li", null, c));
|
|
912
1004
|
host.appendChild(counts);
|
|
913
|
-
// behold#571:
|
|
914
|
-
|
|
915
|
-
const
|
|
916
|
-
const
|
|
917
|
-
if (
|
|
918
|
-
const list = el("dl", "k-result-waves");
|
|
919
|
-
for (const w of untraced) list.append(el("dt", null, `Wave ${w.wave}`), el("dd", null, w.words));
|
|
920
|
-
host.appendChild(list);
|
|
921
|
-
}
|
|
922
|
-
if (rows.length) {
|
|
1005
|
+
// behold#571: a row for every wave, in wave order: its trace as one bar of its phases (a click opens the whole trace),
|
|
1006
|
+
// else its numbers, else a quiet line until they land. Never fewer rows than the count says.
|
|
1007
|
+
const bars = new Map(miniWaterfall(s.waveTraces || {}).map((r) => [r.wave, r]));
|
|
1008
|
+
const order = [...new Set([...model.waves.map((w) => w.wave), ...bars.keys()])].sort((x, y) => x - y);
|
|
1009
|
+
if (order.length) {
|
|
923
1010
|
const wf = el("div", "k-wf");
|
|
924
|
-
for (const
|
|
1011
|
+
for (const n of order) {
|
|
1012
|
+
const r = bars.get(n);
|
|
1013
|
+
const w = model.waves.find((x) => x.wave === n);
|
|
1014
|
+
if (!r) {
|
|
1015
|
+
const row = el("div", "k-wf-row k-wf-plain");
|
|
1016
|
+
row.append(el("span", "k-wf-wave", `Wave ${n}`), el("span", w && w.words ? "k-wf-words" : "k-wf-words k-result-soon", w && w.words ? w.words : NUMBERS_SOON));
|
|
1017
|
+
wf.appendChild(row);
|
|
1018
|
+
continue;
|
|
1019
|
+
}
|
|
925
1020
|
const row = el("button", "k-wf-row");
|
|
926
1021
|
row.type = "button";
|
|
927
1022
|
const held = r.bars.find((b) => b.phase === "held");
|
|
@@ -938,16 +1033,20 @@ function drawResult(host, model, s) {
|
|
|
938
1033
|
row.addEventListener("click", () => s.openWave && s.openWave(r.wave, "trace"));
|
|
939
1034
|
wf.appendChild(row);
|
|
940
1035
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
1036
|
+
if (bars.size) {
|
|
1037
|
+
const key = el("p", "k-wf-key");
|
|
1038
|
+
for (const [cls, words] of PHASE_KEY) {
|
|
1039
|
+
const k = el("span");
|
|
1040
|
+
k.append(el("i", `k-wf-sw k-wf-${cls}`), words);
|
|
1041
|
+
key.appendChild(k);
|
|
1042
|
+
}
|
|
1043
|
+
wf.appendChild(key);
|
|
946
1044
|
}
|
|
947
|
-
wf.appendChild(key);
|
|
948
1045
|
host.appendChild(wf);
|
|
949
1046
|
}
|
|
950
1047
|
}
|
|
1048
|
+
/** behold#571: a wave's row on the result card before its numbers land. */
|
|
1049
|
+
export const NUMBERS_SOON = "its numbers land in a moment";
|
|
951
1050
|
/** behold#571: the words of a trace's links, and the phases' key. */
|
|
952
1051
|
export const TRACE_LINK_WORDS = "Trace";
|
|
953
1052
|
export const TRACE_OPEN_WORDS = "Open this wave's trace";
|
|
@@ -1063,6 +1162,11 @@ function fade(b) {
|
|
|
1063
1162
|
b.classList.toggle("k-more-above", b.scrollTop > 1);
|
|
1064
1163
|
}
|
|
1065
1164
|
|
|
1165
|
+
/** behold#571 (#631): how often a tool's recorded step order is read again. */
|
|
1166
|
+
export const STRIP_REREAD_MS = 600_000;
|
|
1167
|
+
|
|
1168
|
+
/** behold#571: how often a run view that is behind the step is read again. */
|
|
1169
|
+
export const FRESH_RUN_MS = 4_000;
|
|
1066
1170
|
/** behold#571: how often a cycle's run's traces are read again, and how long after a run ends they still are. */
|
|
1067
1171
|
export const TRACE_POLL_MS = 8_000;
|
|
1068
1172
|
export const TRACE_SETTLE_MS = 90_000;
|
|
@@ -1093,6 +1197,10 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1093
1197
|
s.shot = null;
|
|
1094
1198
|
// behold#571: event-help, started further down once what it reads is in place.
|
|
1095
1199
|
let ehApi = null;
|
|
1200
|
+
// behold#571: the run view as the cycle has seen it (steadyRun), and when a read behind the step last asked again.
|
|
1201
|
+
let runMemo = null;
|
|
1202
|
+
let freshAt = 0;
|
|
1203
|
+
s.steady = null;
|
|
1096
1204
|
// behold#571: each wave's trace, from Tempo (web/kiosk-wave-traces.js).
|
|
1097
1205
|
s.waveTraces = {};
|
|
1098
1206
|
// behold#571: the frame loading out of sight while the shown one stays up (openFrame), and a message to both.
|
|
@@ -1261,6 +1369,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1261
1369
|
const setDemo = (answer) => {
|
|
1262
1370
|
s.demo = answer;
|
|
1263
1371
|
const d = answer && answer.demo;
|
|
1372
|
+
// behold#571: when this page first saw the driver's deadline, for the next bar when demo.json has no next.from.
|
|
1373
|
+
s.nextSeen = nextSeen(s.nextSeen, d ? d.next || null : undefined, s.mode, shownNow().getTime());
|
|
1264
1374
|
if (d && d.scenario && typeof d.title === "string" && d.title) titles[d.scenario] = d.title;
|
|
1265
1375
|
if (d && d.scenario && scenarioName(d)) names[d.scenario] = scenarioName(d);
|
|
1266
1376
|
const key = d ? `${s.mode}|${d.cycle}|${d.step}|${d.commit}|${d.pull}` : "";
|
|
@@ -1312,6 +1422,14 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1312
1422
|
tellHover(s.hover);
|
|
1313
1423
|
}
|
|
1314
1424
|
whatText();
|
|
1425
|
+
// behold#571: the run view as the cycle has seen it, for the result card and the trail; a read behind the step asks again.
|
|
1426
|
+
const sr = steadyRun(runMemo, s.progress, s.demo && s.demo.demo);
|
|
1427
|
+
runMemo = sr.memo;
|
|
1428
|
+
s.steady = sr.progress;
|
|
1429
|
+
if (behindStep(s.demo && s.demo.demo, s.progress) && now().getTime() - freshAt > FRESH_RUN_MS) {
|
|
1430
|
+
freshAt = now().getTime();
|
|
1431
|
+
void progress(true);
|
|
1432
|
+
}
|
|
1315
1433
|
// behold#571: Watch's overlays, then the shot they leave room for.
|
|
1316
1434
|
holdTick();
|
|
1317
1435
|
drawWatch(shownNow());
|
|
@@ -1456,7 +1574,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1456
1574
|
if (drawer) drawDrawer(watch.drawer, tail, badgeTitle(nums[drawerOn]), open);
|
|
1457
1575
|
if (drawer) traceDrawer(d, drawerOn);
|
|
1458
1576
|
// A drawer the viewer opened on a wave takes the card's place beside the graph until it folds.
|
|
1459
|
-
const result = shot.kind === "result" && !opened ? resultModel(d, s.metrics, s.
|
|
1577
|
+
const result = shot.kind === "result" && !opened ? resultModel(d, s.metrics, s.steady) : null;
|
|
1460
1578
|
watch.result.hidden = !result;
|
|
1461
1579
|
if (result) drawResult(watch.result, result, s);
|
|
1462
1580
|
// On a phone the delivery numbers stack under the rest, where the header has no room for them.
|
|
@@ -1498,8 +1616,9 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1498
1616
|
const tr = s.waveTraces[wave];
|
|
1499
1617
|
if (!host || !d || !d.repo || (!tr && (!runDoc || !w))) return;
|
|
1500
1618
|
// The wave's own trace when Tempo has it (its run and job: a resumed run applies waves in one job), else its job in the drawer's run.
|
|
1501
|
-
|
|
1502
|
-
const
|
|
1619
|
+
// The wave's own attempt of its job: a resumed run's job applies several waves, and a wave may run twice.
|
|
1620
|
+
const target = tr ? { project: d.repo, run: tr.run, job: tr.job, wave, start: tr.trace.start } : { project: d.repo, run: String(runDoc.id), job: w.job, wave, start: null };
|
|
1621
|
+
const key = `${target.project}|${target.run}|${target.job}|${target.wave}|${target.start}`;
|
|
1503
1622
|
if (trace && trace.key === key) return;
|
|
1504
1623
|
if (trace) trace.api.update(target);
|
|
1505
1624
|
else trace = { api: mountTrace(host, { ...target, fetchJson: fetchServed }) };
|
|
@@ -1641,7 +1760,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1641
1760
|
return {
|
|
1642
1761
|
demo: d,
|
|
1643
1762
|
answer: s.answer,
|
|
1644
|
-
progress: s.
|
|
1763
|
+
progress: s.steady,
|
|
1645
1764
|
runDoc: runsApi && runsApi.run ? runsApi.run.doc : null,
|
|
1646
1765
|
// The cycle's runs the approval panel reads, for the failures of runs the pane no longer shows.
|
|
1647
1766
|
runDocs: ap.list,
|
|
@@ -1655,8 +1774,10 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1655
1774
|
replay: s.mode === "replay",
|
|
1656
1775
|
approveLine: appr ? appr.approve : null,
|
|
1657
1776
|
label: d.label || "",
|
|
1658
|
-
result: resultModel(d, s.metrics, s.
|
|
1777
|
+
result: resultModel(d, s.metrics, s.steady),
|
|
1659
1778
|
waveTraces: s.waveTraces,
|
|
1779
|
+
strip: s.stripReady() ? s.strip : null,
|
|
1780
|
+
stripReady: s.stripReady(),
|
|
1660
1781
|
};
|
|
1661
1782
|
},
|
|
1662
1783
|
})
|
|
@@ -1728,6 +1849,38 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1728
1849
|
};
|
|
1729
1850
|
setInterval(() => void readTraces(), 2_000);
|
|
1730
1851
|
|
|
1852
|
+
// behold#571 (#631): the strip in the running tool's own order, from its recorded cycle's steps; the default until it is read.
|
|
1853
|
+
const strips = new Map();
|
|
1854
|
+
s.strip = null;
|
|
1855
|
+
/** Whether the running tool's step order has been read (or there is none to read), so the story can be told in it. */
|
|
1856
|
+
s.stripReady = () => {
|
|
1857
|
+
const d = s.demo && s.demo.demo;
|
|
1858
|
+
const t = vendor ? tool : d && typeof d.tool === "string" ? d.tool : null;
|
|
1859
|
+
const r = t ? strips.get(t) : null;
|
|
1860
|
+
if (r && r.done) s.strip = r.strip;
|
|
1861
|
+
return !t || !!(r && r.done);
|
|
1862
|
+
};
|
|
1863
|
+
const readStrip = async () => {
|
|
1864
|
+
const d = s.demo && s.demo.demo;
|
|
1865
|
+
const t = vendor ? tool : d && typeof d.tool === "string" ? d.tool : null;
|
|
1866
|
+
if (!t) return;
|
|
1867
|
+
const had = strips.get(t);
|
|
1868
|
+
if (had && now().getTime() - had.at < STRIP_REREAD_MS) {
|
|
1869
|
+
if (s.strip !== had.strip) {
|
|
1870
|
+
s.strip = had.strip;
|
|
1871
|
+
draw();
|
|
1872
|
+
}
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
strips.set(t, { at: now().getTime(), strip: had ? had.strip : null, done: had ? had.done : false });
|
|
1876
|
+
const a = await fetchServed(`/api/terragucci/cycles/${encodeURIComponent(t)}`);
|
|
1877
|
+
const strip = a && a.cycle && Array.isArray(a.cycle.steps) ? stripFromSteps(a.cycle.steps.map((x) => x.step)) : null;
|
|
1878
|
+
strips.set(t, { at: now().getTime(), strip: strip || (had ? had.strip : null), done: true });
|
|
1879
|
+
s.strip = strips.get(t).strip;
|
|
1880
|
+
draw();
|
|
1881
|
+
};
|
|
1882
|
+
setInterval(() => void readStrip(), 2_000);
|
|
1883
|
+
|
|
1731
1884
|
s.setMetrics = (m) => {
|
|
1732
1885
|
s.metrics = m;
|
|
1733
1886
|
draw();
|
package/web/kiosk.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { stepTone, BEAT_CHANGES, INTRO_HEAD, READ_STORE, READ_TITLE, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, factsLine, focusRoots, holdHead, holdModel, introText, readStored, readingRows, renderReading, scenarioHead, frameSrc, factLines, kioskView, matchingPull, pendingApproval, renderKiosk, renderViewToggle, reportless, runPanel, runPin, stepView, viewZoom } from "./kiosk.js";
|
|
2
|
+
import { stepTone, nextProgress, nextSeen, BEAT_CHANGES, INTRO_HEAD, READ_STORE, READ_TITLE, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, factsLine, focusRoots, holdHead, holdModel, introText, readStored, readingRows, renderReading, scenarioHead, frameSrc, factLines, kioskView, matchingPull, pendingApproval, renderKiosk, renderViewToggle, reportless, runPanel, runPin, stepView, viewZoom } from "./kiosk.js";
|
|
3
3
|
import { VENDORS } from "./kiosk-vendor.js";
|
|
4
4
|
import { PICK_HOLD_MS } from "./kiosk-runs.js";
|
|
5
5
|
|
|
@@ -155,7 +155,10 @@ describe("the scenario's card under the title (behold#571)", () => {
|
|
|
155
155
|
expect(left.children.map((c) => c.className)).toEqual([
|
|
156
156
|
"k-box k-box-title", "k-row k-row-beat", "k-row k-row-step k-step-failed", "k-row k-row-next", "k-row k-row-more", "k-row k-row-more", "k-row k-row-facts k-row-empty",
|
|
157
157
|
]);
|
|
158
|
-
expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-overline", "k-title"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], []]);
|
|
158
|
+
expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-overline", "k-title"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box", "k-nbar"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], []]);
|
|
159
|
+
// The next row's bar is placed by CSS, in the step's tone; a stalled driver's next has none.
|
|
160
|
+
const nbar = find(bar, "k-nbar")[0];
|
|
161
|
+
expect(nbar.className).toBe("k-nbar k-nbar-none");
|
|
159
162
|
// Each row: its label in the fixed column, its words in the box beside it.
|
|
160
163
|
const rowsOf = (cls) => find(bar, cls).map((r) => [r.children[0].textContent, r.children[1].children[0].className, r.children[1].children[0].textContent]);
|
|
161
164
|
expect(rowsOf("k-row-beat")).toEqual([[BEAT_CHANGES, "k-beat", about.changes]]);
|
|
@@ -481,3 +484,77 @@ describe("the lead block's step rail (behold#571)", () => {
|
|
|
481
484
|
expect(["waiting", "failed", "stalled", "applied", "applying", "planned", "resumed", "reset"].map(stepTone)).toEqual(["wait", "bad", "bad", "ok", "busy", "busy", "busy", "idle"]);
|
|
482
485
|
});
|
|
483
486
|
});
|
|
487
|
+
|
|
488
|
+
describe("kiosk: the strip in a scenario's own order (behold#571, #631)", async () => {
|
|
489
|
+
const { stripFromSteps, stripStops, STRIP } = await import("./kiosk.js");
|
|
490
|
+
it("puts chant's approval between planned and merged, and lights it while the plan waits", () => {
|
|
491
|
+
const chant = stripFromSteps(["pull-request", "planned", "waiting", "approved", "merged", "applying", "applied", "reset"]);
|
|
492
|
+
expect(chant.map((x) => x.words)).toEqual(["pull request", "planned", "approval", "merged", "waves", "applied", "reset"]);
|
|
493
|
+
expect(stripStops("waiting", chant).find((x) => x.state === "current").words).toBe("approval");
|
|
494
|
+
expect(stripStops("applying", chant).find((x) => x.state === "current").words).toBe("waves");
|
|
495
|
+
});
|
|
496
|
+
it("keeps terragucci's waves, a hold after the merge part of them, and the default strip without steps", () => {
|
|
497
|
+
const tg = stripFromSteps(["pull-request", "planned", "merged", "applying", "failed", "resumed", "waiting", "approved", "resumed", "applied", "reset"]);
|
|
498
|
+
expect(tg.map((x) => x.id)).toEqual(STRIP.map((x) => x.id));
|
|
499
|
+
expect(stripStops("waiting", tg).find((x) => x.state === "current").words).toBe("waves");
|
|
500
|
+
expect(stripFromSteps([])).toBeNull();
|
|
501
|
+
// A run that applied in one go (no wait at all) still shows its waves stop.
|
|
502
|
+
expect(stripFromSteps(["pull-request", "planned", "merged", "applying", "applied", "reset"]).map((x) => x.id)).toEqual(STRIP.map((x) => x.id));
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
// behold#571: the bar under "next, by the driver".
|
|
507
|
+
describe("nextProgress and nextSeen", () => {
|
|
508
|
+
const at = "2026-10-16T22:34:35Z";
|
|
509
|
+
const t = (iso) => new Date(iso);
|
|
510
|
+
const ms = (iso) => Date.parse(iso);
|
|
511
|
+
|
|
512
|
+
it("fills from next.from to next.at", () => {
|
|
513
|
+
const next = { action: "approve wave-2", from: "2026-10-16T22:34:15Z", at };
|
|
514
|
+
expect(nextProgress(next, t("2026-10-16T22:34:15Z"))).toEqual({ kind: "fill", fraction: 0 });
|
|
515
|
+
expect(nextProgress(next, t("2026-10-16T22:34:20Z"))).toEqual({ kind: "fill", fraction: 0.25 });
|
|
516
|
+
expect(nextProgress(next, t("2026-10-16T22:34:30Z"))).toEqual({ kind: "fill", fraction: 0.75 });
|
|
517
|
+
// A clock a little behind the driver's never draws below empty.
|
|
518
|
+
expect(nextProgress(next, t("2026-10-16T22:34:10Z")).fraction).toBe(0);
|
|
519
|
+
// from wins over when the page saw it.
|
|
520
|
+
expect(nextProgress(next, t("2026-10-16T22:34:30Z"), ms("2026-10-16T22:34:25Z")).fraction).toBe(0.75);
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
it("is due at and past the deadline, whatever from says", () => {
|
|
524
|
+
expect(nextProgress({ action: "x", from: "2026-10-16T22:34:15Z", at }, t(at))).toEqual({ kind: "due", fraction: 1 });
|
|
525
|
+
expect(nextProgress({ action: "x", at }, t("2026-10-16T22:40:00Z"))).toEqual({ kind: "due", fraction: 1 });
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
it("fills from when the page first saw the deadline when from is missing, and draws no bar when it joined midway", () => {
|
|
529
|
+
const next = { action: "approve wave-2", at };
|
|
530
|
+
expect(nextProgress(next, t("2026-10-16T22:34:25Z"), ms("2026-10-16T22:34:15Z"))).toEqual({ kind: "fill", fraction: 0.5 });
|
|
531
|
+
expect(nextProgress(next, t("2026-10-16T22:34:25Z"), null)).toEqual({ kind: "none", fraction: null });
|
|
532
|
+
// A from that cannot be read falls back the same way.
|
|
533
|
+
expect(nextProgress({ ...next, from: "soon" }, t("2026-10-16T22:34:25Z"), ms("2026-10-16T22:34:15Z")).fraction).toBe(0.5);
|
|
534
|
+
expect(nextProgress({ ...next, from: "2026-10-16T22:34:35Z" }, t("2026-10-16T22:34:25Z"))).toEqual({ kind: "none", fraction: null });
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
it("shimmers with no deadline, and draws nothing when there is no next", () => {
|
|
538
|
+
expect(nextProgress({ action: "follow the waves", from: "2026-10-16T22:34:15Z", at: null }, t(at))).toEqual({ kind: "wait", fraction: null });
|
|
539
|
+
expect(nextProgress(null, t(at))).toEqual({ kind: "none", fraction: null });
|
|
540
|
+
expect(nextProgress({ action: "x", at: "not a time" }, t(at))).toEqual({ kind: "none", fraction: null });
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
it("remembers when the page first saw each deadline: midway for the one on screen at load or after a mode change", () => {
|
|
544
|
+
const a = { action: "approve wave-2", at };
|
|
545
|
+
const b = { action: "merge pull request 41", at: "2026-10-16T22:35:40Z" };
|
|
546
|
+
let m = nextSeen(undefined, a, "live", 1000);
|
|
547
|
+
expect(m.seen).toBeNull();
|
|
548
|
+
expect(nextSeen(m, a, "live", 2000)).toBe(m);
|
|
549
|
+
m = nextSeen(m, { action: "follow the waves", at: null }, "live", 3000);
|
|
550
|
+
expect(m.seen).toBeNull();
|
|
551
|
+
m = nextSeen(m, b, "live", 4000);
|
|
552
|
+
expect(m.seen).toBe(4000);
|
|
553
|
+
expect(nextSeen(m, b, "live", 5000).seen).toBe(4000);
|
|
554
|
+
expect(nextSeen(m, b, "replay", 5000).seen).toBeNull();
|
|
555
|
+
// Until demo.json is read (undefined), the page has watched nothing: the first deadline it reads was joined midway.
|
|
556
|
+
expect(nextSeen(nextSeen(undefined, undefined, "live", 0), a, "live", 6000).seen).toBeNull();
|
|
557
|
+
// Once read, a deadline that comes after a step with none is seen to begin.
|
|
558
|
+
expect(nextSeen(nextSeen(undefined, null, "live", 0), a, "live", 6000).seen).toBe(6000);
|
|
559
|
+
});
|
|
560
|
+
});
|