@intentius/behold 0.29.30 → 0.29.32

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.
@@ -1,7 +1,7 @@
1
1
  // behold#571: the kiosk's "Pipeline metrics" pane, as words. No DOM: the
2
2
  // model decides what shows, and an answer with nothing in it shows no pane.
3
3
  import { describe, expect, it } from "vitest";
4
- import { changeWords, METRICS_STORE, metricsModel, metricsStored, metricsTarget, metricsUrl, percentWords, perWeekWords, secondsWords } from "./kiosk-metrics.js";
4
+ import { changeWords, METRICS_STORE, metricsModel, metricsStored, metricsTarget, metricsUrl, percentWords, perWeekWords, secondsWords, steadyModel, startMetrics } from "./kiosk-metrics.js";
5
5
 
6
6
  const C1 = "9f3c2a71d04e5b8c6a1f2e3d4c5b6a7980716253";
7
7
  const answer = () => ({
@@ -43,8 +43,8 @@ describe("kiosk metrics: what the pane shows", () => {
43
43
  expect(m.count).toBe("2 waves · 3 delivery");
44
44
  expect(m.run.label).toBe("This run · 9f3c2a71");
45
45
  expect(m.run.waves).toEqual([
46
- { wave: 1, head: "Wave 1", took: "5.4 s in all", rows: [["network", "init 163 ms · plan 70 ms · apply 60 ms", "network"], ["Applied", "1 updated"]] },
47
- { wave: 2, head: "Wave 2", took: null, rows: [["app", "plan 7.2 s · apply 3.4 s", "app"], ["Held at the gate", "1 min 35 s"], ["Applied", "2 created, 1 updated"]] },
46
+ { wave: 1, head: "Wave 1", took: "5.4 s in all", rows: [["network", "init 163 ms · plan 70 ms · apply 60 ms", "network"], ["Applied", "1 updated"]], seconds: "5.4 s", held: null, changed: "1 updated", secondsRaw: 5.36, heldRaw: null, changesRaw: { update: 1 } },
47
+ { wave: 2, head: "Wave 2", took: null, rows: [["app", "plan 7.2 s · apply 3.4 s", "app"], ["Held at the gate", "1 min 35 s"], ["Applied", "2 created, 1 updated"]], seconds: null, held: "1 min 35 s", changed: "2 created, 1 updated", secondsRaw: null, heldRaw: 95, changesRaw: { update: 1, create: 2 } },
48
48
  ]);
49
49
  expect(m.dora).toEqual([["Deploys", "30 a week"], ["Lead time", "15 min"], ["Change failure rate", "10%"]]);
50
50
  });
@@ -105,3 +105,52 @@ describe("kiosk metrics: which repo, and the fold", () => {
105
105
  expect(metricsStored({ getItem: () => { throw new Error("denied"); } })).toBeNull();
106
106
  });
107
107
  });
108
+
109
+ describe("kiosk metrics: a pane that stays put through a cycle (behold#571)", () => {
110
+ const full = () => metricsModel(answer());
111
+ const doraOnly = () => metricsModel({ ...answer(), run: null });
112
+
113
+ it("keeps the last model when a read in the same cycle, or a failed read, has less in it", () => {
114
+ expect(steadyModel(full(), null, { same: true })).toEqual(full());
115
+ expect(steadyModel(full(), null, { failed: true })).toEqual(full());
116
+ const kept = steadyModel(full(), doraOnly(), { same: true });
117
+ expect(kept.run).toEqual(full().run);
118
+ expect(kept.count).toBe("2 waves · 3 delivery");
119
+ });
120
+
121
+ it("takes a new cycle's model as it comes, nothing included", () => {
122
+ expect(steadyModel(full(), null, { same: false })).toBeNull();
123
+ expect(steadyModel(full(), doraOnly(), { same: false })).toEqual(doraOnly());
124
+ expect(steadyModel(null, doraOnly(), { same: true })).toEqual(doraOnly());
125
+ });
126
+
127
+ it("never hides the pane between the steps of one cycle, whatever the reads answer", async () => {
128
+ const C2 = "1111111111111111111111111111111111111111";
129
+ // Cycle 7 steps through a pull request (no run of its commit yet), a failed read, and the merge's run.
130
+ const reads = [
131
+ { step: "pull-request", commit: C2, metrics: { ...answer(), run: { ...answer().run, current: false } } },
132
+ { step: "planned", commit: C2, metrics: { error: "/api/metrics answered 502" } },
133
+ { step: "merged", commit: C1, metrics: { ...answer(), run: null, dora: null } },
134
+ { step: "applying", commit: C1, metrics: answer() },
135
+ ];
136
+ let i = 0;
137
+ const fetchJson = async (url) => {
138
+ const r = reads[Math.min(i, reads.length - 1)];
139
+ if (url === "/api/terragucci/demo") return { demo: { repo: "terragucci-admin/demo", cycle: 7, step: r.step, commit: r.commit } };
140
+ return r.metrics;
141
+ };
142
+ const shown = [];
143
+ const host = { hidden: true, replaceChildren() {}, appendChild() {}, classList: { toggle() {} } };
144
+ const doc = { createElement: () => ({ classList: { toggle() {} }, dataset: {}, setAttribute() {}, addEventListener() {}, append() {}, appendChild() {} }), body: null, head: null, getElementById: () => null };
145
+ const m = startMetrics(host, { fetchJson, store: { getItem: () => "closed", setItem() {} }, setTimer: () => 0, clearTimer() {}, doc });
146
+ await new Promise((r) => setTimeout(r)); // the first read, which the pane starts by itself
147
+ shown.push(m.model() !== null);
148
+ for (i = 1; i < reads.length; i++) {
149
+ await m.tick();
150
+ shown.push(m.model() !== null);
151
+ }
152
+ expect(shown).toEqual([true, true, true, true]);
153
+ // Before: the failed read and the merge's empty answer each hid the pane for a step.
154
+ expect(m.model().run.current).toBe(true);
155
+ });
156
+ });
package/web/kiosk-runs.js CHANGED
@@ -30,6 +30,9 @@ export const STATUS_WORDS = {
30
30
  /** The tone a status is drawn in. `waiting` has its own, never failure's. */
31
31
  export const STATUS_TONE = { queued: "idle", running: "busy", waiting: "wait", success: "ok", failure: "bad", cancelled: "idle", skipped: "idle" };
32
32
 
33
+ /** behold#571: the tone an item's left bar takes from its status (kiosk.html's `[data-k-tone]` rules). */
34
+ export const toneOf = (status) => STATUS_TONE[status] || "idle";
35
+
33
36
  const LIVE = new Set(["queued", "running", "waiting"]);
34
37
 
35
38
  /** A step named by an action's address (`https://…/checkout@v4`, `actions/checkout@v4`), not by the workflow. */
@@ -414,9 +417,9 @@ export function statusIcon(status) {
414
417
  export function renderSidebar(host, index, selectedId, { now = new Date(), scenarios = {}, titles = {}, names = {}, pick = () => {}, merged = null, replay = false } = {}) {
415
418
  host.replaceChildren();
416
419
  const head = el("div", "r-side-head");
417
- head.appendChild(el("div", "r-side-title", "Pipeline runs"));
420
+ head.appendChild(el("div", "r-side-title", "Runs"));
418
421
  // behold#571: a tool's page replays an earlier cycle's runs, and says so.
419
- head.appendChild(el("div", "r-side-note", replay ? "Real CI runs of the replayed cycle, as they stood at this point in it. Newest first." : "Real CI runs of the demo repo, copied from its forge as they go. Newest first."));
422
+ head.appendChild(el("div", "r-side-note", replay ? "The replayed cycle's runs, newest first." : "From the forge, newest first."));
420
423
  host.appendChild(head);
421
424
  if (!index || index.error || index.absent || !index.doc) {
422
425
  host.appendChild(el("p", "r-note", index ? index.absent || index.error : "Reading the runs…"));
@@ -437,6 +440,7 @@ export function renderSidebar(host, index, selectedId, { now = new Date(), scena
437
440
  const li = el("li", `r-run${r.id === selectedId ? " r-selected" : ""}`);
438
441
  li.tabIndex = 0;
439
442
  li.dataset.run = String(r.id);
443
+ li.dataset.kTone = toneOf(r.status);
440
444
  li.appendChild(statusIcon(r.status));
441
445
  const body = el("div", "r-run-body");
442
446
  body.appendChild(el("div", "r-run-title", triggerWords(r)));
@@ -533,11 +537,12 @@ export function renderRun(host, answer, ui, { now = new Date(), pickJob = () =>
533
537
  const ordered = jobOrder(run.jobs);
534
538
  const { shown, skipped } = splitSkipped(ordered);
535
539
  const job = (ui.job && run.jobs.find((j) => j.name === ui.job)) || defaultJob(shown.length ? shown : run.jobs);
536
- host.appendChild(el("div", "r-label", "Jobs, in the order they run"));
540
+ host.appendChild(el("div", "r-label", "Jobs"));
537
541
  const jobsBox = el("ol", "r-jobs");
538
542
  for (const j of shown) {
539
543
  const li = el("li", `r-job${job && j.name === job.name ? " r-selected" : ""}`);
540
544
  li.style.setProperty("--depth", String(j.depth));
545
+ li.dataset.kTone = toneOf(j.status);
541
546
  li.appendChild(statusIcon(j.status));
542
547
  // behold#571: the tools the job runs, each its logo (where its owner allows) and its name, on a
543
548
  // line of their own under the job's name, so the row's line keeps its width.
@@ -576,7 +581,7 @@ export function renderRun(host, answer, ui, { now = new Date(), pickJob = () =>
576
581
  const feats = runFeatures(shown, { hide: hideLine });
577
582
  if (feats.length) {
578
583
  const box = el("div", `r-feats${featsOpen ? " r-feats-open" : ""}`);
579
- box.appendChild(el("div", "r-label r-feats-label", "Features in this run"));
584
+ box.appendChild(el("div", "r-label r-feats-label", "Features"));
580
585
  const list = el("div", "r-feats-list");
581
586
  for (const g of feats) {
582
587
  list.appendChild(el("span", `r-feats-product r-ann-${g.product}`, g.product));
@@ -600,7 +605,7 @@ export function renderRun(host, answer, ui, { now = new Date(), pickJob = () =>
600
605
  // behold#571: a job with a trace in Tempo offers it beside its steps (web/kiosk-trace.js).
601
606
  if (trace && trace.has(job.name)) {
602
607
  const tabs = el("div", "t-tabs");
603
- for (const [view, words] of [["steps", "Steps of the job, with its log"], ["trace", "Trace"]]) {
608
+ for (const [view, words] of [["steps", "Steps"], ["trace", "Trace"]]) {
604
609
  const b = el("button", "t-tab", words);
605
610
  b.type = "button";
606
611
  b.setAttribute("aria-pressed", String((jobView === "trace") === (view === "trace")));
@@ -614,7 +619,7 @@ export function renderRun(host, answer, ui, { now = new Date(), pickJob = () =>
614
619
  host.appendChild(box);
615
620
  return { log: null, steps: box, key: null };
616
621
  }
617
- } else host.appendChild(el("div", "r-label", "Steps of the job, with its log"));
622
+ } else host.appendChild(el("div", "r-label", "Steps"));
618
623
  const stepsBox = el("div", "r-steps");
619
624
  const sh = el("div", "r-steps-head");
620
625
  sh.append(statusIcon(job.status), el("span", "r-steps-job", job.name), el("span", "r-steps-word", job.status === "waiting" ? "waits for an approval at the gate" : STATUS_WORDS[job.status] || job.status));
@@ -634,6 +639,7 @@ export function renderRun(host, answer, ui, { now = new Date(), pickJob = () =>
634
639
  const marks = jobMarks(steps, { hide: hideLine });
635
640
  steps.forEach((s, i) => {
636
641
  const row = el("div", `r-step${i === open ? " r-open" : ""}`);
642
+ row.dataset.kTone = toneOf(s.status);
637
643
  const line = el("div", "r-step-line");
638
644
  line.append(el("span", "r-caret", i === open ? "▾" : "▸"), statusIcon(s.status), el("span", "r-step-name", s.name), el("span", "r-dur", durationWords(s.started_at, s.ended_at, now) || ""));
639
645
  line.addEventListener("click", () => toggleStep(job.name, i === open ? -1 : i));
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import { describe, expect, it } from "vitest";
4
- import { FEATURE_LINES, fitFeatures, FOLLOW_LINES, followsLog, logKey, nearEnd, mergeRun, newerOf, agoWords, defaultJob, defaultStep, durationWords, jobOrder, liveRun, codeish, logLineWords, logRows, placeWords, scenarioTitles, setupLine, sidebarRuns, splitSkipped, STATUS_TONE, triggerWords } from "./kiosk-runs.js";
4
+ import { FEATURE_LINES, fitFeatures, FOLLOW_LINES, followsLog, logKey, nearEnd, mergeRun, newerOf, agoWords, defaultJob, defaultStep, durationWords, jobOrder, liveRun, codeish, logLineWords, logRows, placeWords, scenarioTitles, setupLine, sidebarRuns, splitSkipped, STATUS_TONE, toneOf, triggerWords } from "./kiosk-runs.js";
5
5
 
6
6
  const FIX = join(import.meta.dirname, "..", "src", "__fixtures__", "terragucci-demo", "runs");
7
7
  const run = (id) => JSON.parse(readFileSync(join(FIX, `${id}.json`), "utf8"));
@@ -286,3 +286,13 @@ describe("the features strip, folded to whole lines (behold#571)", () => {
286
286
  expect(items.map((i) => i.hidden)).toEqual([false, false, true, true]);
287
287
  });
288
288
  });
289
+
290
+ describe("the left bar's tone (behold#571)", () => {
291
+ it("takes a run's, job's or step's status: running in the accent, held amber, failed, succeeded, and neutral for the rest", () => {
292
+ expect(["running", "waiting", "failure", "success", "queued", "skipped", "cancelled", "mystery"].map(toneOf)).toEqual(["busy", "wait", "bad", "ok", "idle", "idle", "idle", "idle"]);
293
+ });
294
+ it("has a bar rule in kiosk.html for every tone a status can take", () => {
295
+ const html = readFileSync(join(import.meta.dirname, "kiosk.html"), "utf8");
296
+ for (const tone of new Set(Object.values(STATUS_TONE))) expect(html).toContain(`[data-k-tone="${tone}"]`);
297
+ });
298
+ });
@@ -0,0 +1,103 @@
1
+ // behold#571: the kiosk's Watch mode moves the framed graph like a camera.
2
+ // The kiosk says what a step is about (a `behold:shot`: some roots, some
3
+ // waves, or the whole graph, and how much of the pane its own overlays
4
+ // cover), and the frame pans and zooms its viewBox there. This module is the
5
+ // arithmetic, with no DOM: the frame (web/app.js) measures, this decides.
6
+
7
+ /** How long a shot's pan and zoom takes, in ms. */
8
+ export const SHOT_MS = 750;
9
+
10
+ /** The most a shot zooms in: one svg unit to this many pixels. */
11
+ export const SHOT_MAX_SCALE = 1.3;
12
+
13
+ /** Room kept round a shot's target, in svg units. */
14
+ export const SHOT_PAD = 36;
15
+
16
+ /** A `behold:shot` message: what to frame, and the pane's covered edges in pixels. */
17
+ export function shotMessage({ roots = [], waves = [], whole = false, insets = {}, ms = SHOT_MS, id = null } = {}) {
18
+ const px = (v) => (Number.isFinite(v) && v > 0 ? Math.round(v) : 0);
19
+ return {
20
+ type: "behold:shot",
21
+ id,
22
+ roots: roots.filter((r) => typeof r === "string" && r),
23
+ waves: waves.filter((w) => Number.isInteger(w)),
24
+ whole: !!whole || (!roots.length && !waves.length),
25
+ insets: { top: px(insets.top), right: px(insets.right), bottom: px(insets.bottom), left: px(insets.left) },
26
+ ms: Number.isFinite(ms) && ms >= 0 ? ms : SHOT_MS,
27
+ };
28
+ }
29
+
30
+ /** A `behold:shot` from a message event, or null: only from the host's origin, only well formed. */
31
+ export function shotFromMessage(event, host) {
32
+ if (!event || !host || event.origin !== host) return null;
33
+ const d = event.data;
34
+ if (!d || typeof d !== "object" || d.type !== "behold:shot") return null;
35
+ // Inspect: no shot; the frame fits the graph as it always has.
36
+ if (d.release === true) return { type: "behold:shot", release: true };
37
+ const list = (v) => (Array.isArray(v) ? v : []);
38
+ return shotMessage({ roots: list(d.roots), waves: list(d.waves), whole: d.whole, insets: d.insets && typeof d.insets === "object" ? d.insets : {}, ms: d.ms, id: d.id ?? null });
39
+ }
40
+
41
+ /** The smallest box round several `{x, y, x2, y2}`, or null for none. */
42
+ export function unionBox(boxes) {
43
+ const ok = boxes.filter((b) => b && [b.x, b.y, b.x2, b.y2].every(Number.isFinite));
44
+ if (!ok.length) return null;
45
+ return { x: Math.min(...ok.map((b) => b.x)), y: Math.min(...ok.map((b) => b.y)), x2: Math.max(...ok.map((b) => b.x2)), y2: Math.max(...ok.map((b) => b.y2)) };
46
+ }
47
+
48
+ /**
49
+ * The viewBox `[x, y, w, h]` that puts `target` (svg units) in the middle of
50
+ * the pane's open part: the pane (`{width, height}` in pixels) less the
51
+ * `insets` the kiosk's overlays cover. The box keeps the pane's aspect
52
+ * ratio, so a pixel is the same number of units both ways. It zooms in no
53
+ * further than `maxScale` pixels a unit.
54
+ */
55
+ export function shotViewBox(target, pane, insets = {}, { pad = SHOT_PAD, maxScale = SHOT_MAX_SCALE } = {}) {
56
+ if (!target || !pane || !(pane.width > 0 && pane.height > 0)) return null;
57
+ const i = { top: insets.top || 0, right: insets.right || 0, bottom: insets.bottom || 0, left: insets.left || 0 };
58
+ // An inset that leaves less than a third of the pane is dropped: the overlay then lies over the graph.
59
+ if (pane.width - i.left - i.right < pane.width / 3) i.left = i.right = 0;
60
+ if (pane.height - i.top - i.bottom < pane.height / 3) i.top = i.bottom = 0;
61
+ const openW = pane.width - i.left - i.right;
62
+ const openH = pane.height - i.top - i.bottom;
63
+ const tw = Math.max(1, target.x2 - target.x + 2 * pad);
64
+ const th = Math.max(1, target.y2 - target.y + 2 * pad);
65
+ const s = Math.min(openW / tw, openH / th, maxScale);
66
+ const w = pane.width / s;
67
+ const h = pane.height / s;
68
+ // The target's centre on the open part's centre.
69
+ const cx = (target.x + target.x2) / 2;
70
+ const cy = (target.y + target.y2) / 2;
71
+ const ox = (i.left + openW / 2) / s;
72
+ const oy = (i.top + openH / 2) / s;
73
+ return [cx - ox, cy - oy, w, h];
74
+ }
75
+
76
+ /** Ease in and out, 0..1 to 0..1. */
77
+ export function ease(t) {
78
+ const x = Math.min(1, Math.max(0, t));
79
+ return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
80
+ }
81
+
82
+ /**
83
+ * The viewBox a fraction `t` of the way from `a` to `b`: the zoom moves on a
84
+ * log scale and the centre with it, so a pull back and a push in read as
85
+ * one calm move.
86
+ */
87
+ export function tweenViewBox(a, b, t) {
88
+ const k = ease(t);
89
+ if (k <= 0) return a.slice();
90
+ if (k >= 1) return b.slice();
91
+ const w = Math.exp(Math.log(a[2]) + (Math.log(b[2]) - Math.log(a[2])) * k);
92
+ const h = w * (b[3] / b[2]);
93
+ const ca = [a[0] + a[2] / 2, a[1] + a[3] / 2];
94
+ const cb = [b[0] + b[2] / 2, b[1] + b[3] / 2];
95
+ const cx = ca[0] + (cb[0] - ca[0]) * k;
96
+ const cy = ca[1] + (cb[1] - ca[1]) * k;
97
+ return [cx - w / 2, cy - h / 2, w, h];
98
+ }
99
+
100
+ /** Whether two viewBoxes are the same to within half a unit. */
101
+ export function sameViewBox(a, b) {
102
+ return !!a && !!b && a.length === 4 && b.length === 4 && a.every((v, i) => Math.abs(v - b[i]) < 0.5);
103
+ }
@@ -0,0 +1,79 @@
1
+ // behold#571: Watch mode's camera, as arithmetic: where a shot puts its
2
+ // target, how a move goes, and which messages the frame takes.
3
+ import { describe, expect, it } from "vitest";
4
+ import { SHOT_MS, ease, sameViewBox, shotFromMessage, shotMessage, shotViewBox, tweenViewBox, unionBox } from "./kiosk-shot.js";
5
+
6
+ const pane = { width: 1600, height: 900 };
7
+
8
+ describe("kiosk shot: where the target lands", () => {
9
+ it("centres the target in the pane's open part, the overlays' insets left out", () => {
10
+ const target = { x: 100, y: 100, x2: 300, y2: 200 };
11
+ const vb = shotViewBox(target, pane, { right: 400, bottom: 200 }, { pad: 0, maxScale: 100 });
12
+ // The open part is 1200 x 700 pixels; the target is 200 x 100 units: 6 pixels a unit, by its width.
13
+ const s = pane.width / vb[2];
14
+ expect(s).toBeCloseTo(6);
15
+ expect(vb[3]).toBeCloseTo(pane.height / s);
16
+ // Its centre (200, 150) sits at the open part's centre, (600, 350) in pixels.
17
+ expect((200 - vb[0]) * s).toBeCloseTo(600);
18
+ expect((150 - vb[1]) * s).toBeCloseTo(350);
19
+ });
20
+
21
+ it("zooms in no further than its cap, and keeps the pane's aspect ratio", () => {
22
+ const vb = shotViewBox({ x: 0, y: 0, x2: 10, y2: 10 }, pane, {}, { pad: 0, maxScale: 1.5 });
23
+ expect(pane.width / vb[2]).toBeCloseTo(1.5);
24
+ expect(vb[2] / vb[3]).toBeCloseTo(pane.width / pane.height);
25
+ });
26
+
27
+ it("drops insets that would leave less than a third of the pane", () => {
28
+ const wide = shotViewBox({ x: 0, y: 0, x2: 100, y2: 100 }, pane, { right: 1200 }, { pad: 0, maxScale: 100 });
29
+ const none = shotViewBox({ x: 0, y: 0, x2: 100, y2: 100 }, pane, {}, { pad: 0, maxScale: 100 });
30
+ expect(wide).toEqual(none);
31
+ });
32
+
33
+ it("answers nothing without a target or a pane", () => {
34
+ expect(shotViewBox(null, pane)).toBeNull();
35
+ expect(shotViewBox({ x: 0, y: 0, x2: 1, y2: 1 }, { width: 0, height: 10 })).toBeNull();
36
+ });
37
+
38
+ it("unions boxes, skipping the ones it cannot read", () => {
39
+ expect(unionBox([{ x: 0, y: 5, x2: 10, y2: 6 }, null, { x: -2, y: 1, x2: 3, y2: 4 }])).toEqual({ x: -2, y: 1, x2: 10, y2: 6 });
40
+ expect(unionBox([null])).toBeNull();
41
+ });
42
+ });
43
+
44
+ describe("kiosk shot: the move", () => {
45
+ it("eases in and out, from 0 to 1", () => {
46
+ expect([ease(-1), ease(0), ease(0.5), ease(1), ease(2)]).toEqual([0, 0, 0.5, 1, 1]);
47
+ expect(ease(0.25)).toBeLessThan(0.25);
48
+ expect(ease(0.75)).toBeGreaterThan(0.75);
49
+ });
50
+
51
+ it("starts at the first viewBox, ends at the second, and zooms on a log scale between", () => {
52
+ const a = [0, 0, 1000, 500];
53
+ const b = [400, 200, 250, 125];
54
+ expect(tweenViewBox(a, b, 0)).toEqual(a);
55
+ expect(tweenViewBox(a, b, 1)).toEqual(b);
56
+ const mid = tweenViewBox(a, b, 0.5);
57
+ // Halfway in time is halfway in zoom: the geometric mean of the widths.
58
+ expect(mid[2]).toBeCloseTo(500);
59
+ expect(mid[2] / mid[3]).toBeCloseTo(2);
60
+ expect(sameViewBox(tweenViewBox(a, b, 1), b)).toBe(true);
61
+ expect(sameViewBox(a, b)).toBe(false);
62
+ });
63
+ });
64
+
65
+ describe("kiosk shot: the messages", () => {
66
+ const host = "https://demo.intentius.io";
67
+ it("says what to frame, the whole graph when it names nothing", () => {
68
+ expect(shotMessage({ waves: [2], insets: { right: 420.4, bottom: 160 } })).toEqual({ type: "behold:shot", id: null, roots: [], waves: [2], whole: false, insets: { top: 0, right: 420, bottom: 160, left: 0 }, ms: SHOT_MS });
69
+ expect(shotMessage({}).whole).toBe(true);
70
+ });
71
+
72
+ it("takes a shot only from the host, and Inspect's release as it is", () => {
73
+ const data = shotMessage({ roots: ["app", 3], waves: [1, "x"] });
74
+ expect(shotFromMessage({ origin: host, data }, host)).toMatchObject({ roots: ["app"], waves: [1], whole: false });
75
+ expect(shotFromMessage({ origin: "https://elsewhere.example", data }, host)).toBeNull();
76
+ expect(shotFromMessage({ origin: host, data: { type: "behold:view" } }, host)).toBeNull();
77
+ expect(shotFromMessage({ origin: host, data: { type: "behold:shot", release: true } }, host)).toEqual({ type: "behold:shot", release: true });
78
+ });
79
+ });
@@ -171,6 +171,14 @@ export function waterfallRows(trace, { open = new Set(), shut = new Set() } = {}
171
171
  return rows;
172
172
  }
173
173
 
174
+ /** behold#571: the tone a job's strip row's left bar takes from its trace's result. */
175
+ export function stripTone(result) {
176
+ if (result === "failed" || result === "refused" || result === "changed-after-approval") return "bad";
177
+ if (result === "waiting") return "wait";
178
+ if (result === "applied" || result === "planned" || result === "unchanged") return "ok";
179
+ return "idle";
180
+ }
181
+
174
182
  /** The run's jobs on one time line: each job's newest trace, 0..1 across the run. */
175
183
  export function runStrip(traces) {
176
184
  const newest = new Map();
@@ -257,10 +265,12 @@ export function renderTrace(host, { traces, run = [], job }, { doc = document, t
257
265
  const box = el(doc, "div", "t-trace");
258
266
  const strip = runStrip(run);
259
267
  if (strip.length > 1) {
260
- box.appendChild(el(doc, "div", "t-sec", "The run's jobs"));
268
+ box.appendChild(el(doc, "div", "t-sec", "Jobs"));
261
269
  const rows = el(doc, "div", "t-strip");
262
270
  for (const r of strip) {
263
271
  const row = el(doc, "div", `t-row${pickJob ? " t-can" : ""}${r.job === job ? " t-sel" : ""}${r.result === "failed" ? " t-err" : r.result === "waiting" ? " t-wait" : ""}`);
272
+ // behold#571: the job's left bar takes its result's tone, as its row in the jobs list does.
273
+ row.dataset.kTone = stripTone(r.result);
264
274
  const name = el(doc, "div", "t-name");
265
275
  name.append(el(doc, "span", "t-label", r.job), el(doc, "span", "t-sub", r.result || ""));
266
276
  row.append(name, bar(doc, r.at, r.width), el(doc, "div", "t-ms", msWords(r.ms)));
@@ -271,7 +281,7 @@ export function renderTrace(host, { traces, run = [], job }, { doc = document, t
271
281
  }
272
282
  traces.forEach((t, i) => {
273
283
  const when = new Date(t.start);
274
- const head = traces.length > 1 ? `Attempt ${i + 1} of ${traces.length}, ${when.toISOString().slice(11, 19)} UTC` : `This job, ${msWords(t.ms)}`;
284
+ const head = traces.length > 1 ? `Attempt ${i + 1} of ${traces.length}, ${when.toISOString().slice(11, 19)} UTC` : `This job · ${msWords(t.ms)}`;
275
285
  box.appendChild(el(doc, "div", "t-sec", head));
276
286
  const rows = el(doc, "div", "t-rows");
277
287
  for (const r of waterfallRows(t, { open, shut })) {
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { OPEN_DEPTH, TRACE_POLL_MS, criticalPath, foldState, msWords, runStrip, spanWords, traceSource, traceUrl, waterfallRows } from "./kiosk-trace.js";
2
+ import { OPEN_DEPTH, TRACE_POLL_MS, criticalPath, foldState, msWords, runStrip, spanWords, stripTone, traceSource, traceUrl, waterfallRows } from "./kiosk-trace.js";
3
3
 
4
4
  const T = 1_792_166_000_000;
5
5
  const sp = (id, parent, name, from, to, attrs = {}, service = "terragucci") => ({ id, parent, name, service, start: T + from, ms: to - from, attrs });
@@ -149,3 +149,9 @@ describe("the waterfall", () => {
149
149
  });
150
150
  });
151
151
 
152
+
153
+ describe("the strip's left bars (behold#571)", () => {
154
+ it("take the job's result: failed, waiting, applied, and neutral for none", () => {
155
+ expect(["failed", "changed-after-approval", "waiting", "applied", "planned", undefined, "other"].map(stripTone)).toEqual(["bad", "bad", "wait", "ok", "ok", "idle", "idle"]);
156
+ });
157
+ });
@@ -239,9 +239,11 @@ describe("a tool's page, drawn (behold#571)", () => {
239
239
  const s = { vendor: "terragrunt", mode: "replay", replay: { banner: "Replay of the run at 14:05 UTC" }, noReports: true, demo: { demo: scrubDemo(demo({ tool: "terragrunt", intro: "Big Terraform setups", about }), "terragrunt") }, answer: null, progress: null };
240
240
  renderKiosk(bar, s, new Date("2026-10-20T10:01:00Z"), foot);
241
241
  expect(bar.children[0].className).toBe("k-replay");
242
- const title = all(bar).find((n) => n.className === "k-title");
243
- expect(title.children.map((c) => c.className)).toEqual(["k-brand", "k-kicker", "k-title-text"]);
244
- const brand = title.children[0];
242
+ // behold#571: the tool and the kicker on the quiet line over the title, the scenario's progress at its end.
243
+ const over = all(bar).find((n) => n.className === "k-overline");
244
+ expect(over.children.map((c) => c.className)).toEqual(["k-brand", "k-kicker", "k-strip"]);
245
+ expect(all(bar).find((n) => n.className === "k-title").children.map((c) => c.className)).toEqual(["k-title-text"]);
246
+ const brand = over.children[0];
245
247
  expect([brand.href, brand.target, brand.rel, text(brand)]).toEqual([VENDORS.terragrunt.url, "_blank", "noopener", "Terragrunt"]);
246
248
  expect(text(bar)).not.toMatch(/of 3|Terramate/);
247
249
  // behold#571: no intro band at a live step; the intro fills the card's box at reset.