@intentius/behold 0.29.48 → 0.29.50
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/AGENTS.md +103 -4
- package/dist/cli.js +1571 -737
- package/package.json +3 -2
- package/web/app.js +118 -17
- package/web/decision-points.js +70 -0
- package/web/decision-points.test.js +87 -0
- package/web/dots-kiosk.js +4 -1
- package/web/dots-live.test.js +10 -0
- package/web/dots.js +41 -4
- package/web/index.html +45 -0
- package/web/kiosk-popover.js +29 -1
- package/web/kiosk-popover.test.js +32 -0
- package/web/kiosk-replay.test.js +79 -0
- package/web/kiosk-runs.js +51 -5
- package/web/kiosk-runs.test.js +42 -1
- package/web/kiosk-source.js +23 -0
- package/web/kiosk-source.test.js +19 -1
- package/web/kiosk-track.js +89 -9
- package/web/kiosk-track.test.js +49 -1
- package/web/kiosk.html +33 -3
- package/web/kiosk.js +156 -16
- package/web/local-run.js +276 -0
- package/web/local-run.test.js +46 -0
- package/web/sql-yodeler-lane.js +1 -1
- package/web/terragucci-timeline.js +5 -4
- package/web/terragucci-timeline.test.js +1 -1
- package/web/trunk-lane.js +54 -5
- package/web/trunk-lane.test.js +86 -3
- package/web/why.js +1 -1
- package/web/why.test.js +1 -1
- package/web/workspace-gates.js +35 -18
package/web/kiosk-popover.js
CHANGED
|
@@ -148,6 +148,32 @@ export function resourceCardId(answer, root, resourceId) {
|
|
|
148
148
|
return `${r.member}/${r.name}/${rest}`;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
/**
|
|
152
|
+
* behold#796: the rows for a root's planned changes no card of the checkout
|
|
153
|
+
* is (`answer.unmatched.changes`): a resource the change adds is in the plan
|
|
154
|
+
* but not yet in the checkout's source, so the resources facet never lists
|
|
155
|
+
* it. One row a block, instance keys dropped; drift is not a plan.
|
|
156
|
+
*/
|
|
157
|
+
function plannedOnly(answer, root, declared) {
|
|
158
|
+
const changes = answer && !answer.error && answer.unmatched && Array.isArray(answer.unmatched.changes) ? answer.unmatched.changes : [];
|
|
159
|
+
const r = Array.isArray(answer && answer.roots) ? answer.roots.find((x) => x.name === root || x.path === root) : null;
|
|
160
|
+
const path = r ? r.path : root;
|
|
161
|
+
const seen = new Set(declared.map((d) => d.address));
|
|
162
|
+
const byBlock = new Map();
|
|
163
|
+
for (const c of changes) {
|
|
164
|
+
if (c.root !== path || c.verdict === "drift") continue;
|
|
165
|
+
const address = c.address.replace(/\[(?:"(?:[^"\\]|\\.)*"|[^\]])*\]/g, "");
|
|
166
|
+
if (seen.has(address)) continue;
|
|
167
|
+
// A waiting wave's (the newest plan) before the pull request's plan, as planMark reads cards.
|
|
168
|
+
const had = byBlock.get(address);
|
|
169
|
+
if (!had || (c.verdict === "wave" && had.verdict !== "wave")) byBlock.set(address, c);
|
|
170
|
+
}
|
|
171
|
+
return [...byBlock].map(([address, c]) => ({ address, state: "change", words: PLANNED_WORDS[c.action] || WORDS.changes }));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** behold#796: a row's words for a planned change the checkout has no card for. */
|
|
175
|
+
const PLANNED_WORDS = { create: "to create", delete: "to destroy", replace: "to replace" };
|
|
176
|
+
|
|
151
177
|
/**
|
|
152
178
|
* What the popover says about one root's card (Components): its
|
|
153
179
|
* resources, each "changes", "no change" or "known after apply", and how
|
|
@@ -156,7 +182,7 @@ export function resourceCardId(answer, root, resourceId) {
|
|
|
156
182
|
*/
|
|
157
183
|
export function rootPopover(answer, root, resources) {
|
|
158
184
|
const list = Array.isArray(resources) ? resources : [];
|
|
159
|
-
const
|
|
185
|
+
const declared = list.map((res) => {
|
|
160
186
|
const id = answer && !answer.error ? resourceCardId(answer, root, res.id) : null;
|
|
161
187
|
const mark = id && answer.cards ? planMark(answer.cards[id]) : null;
|
|
162
188
|
const address = res.id.startsWith(`${root}/`) ? res.id.slice(root.length + 1).split("/").join(".") : res.id;
|
|
@@ -164,6 +190,8 @@ export function rootPopover(answer, root, resources) {
|
|
|
164
190
|
const unknown = (mark.values || []).some((v) => v.unknown);
|
|
165
191
|
return { address, state: unknown ? "unknown" : "change", words: unknown ? WORDS.unknown2 : WORDS.changes };
|
|
166
192
|
});
|
|
193
|
+
// behold#796: first, so "and N more" never hides them.
|
|
194
|
+
const rows = [...plannedOnly(answer, root, declared), ...declared];
|
|
167
195
|
const changed = rows.filter((r) => r.state !== "same").length;
|
|
168
196
|
const head = !rows.length ? WORDS.noResources : changed === 0 ? WORDS.noRootChange : `${changed} of ${rows.length} ${rows.length === 1 ? "resource changes" : "resources change"}.`;
|
|
169
197
|
const shown = rows.slice(0, MAX_LINES + 2);
|
|
@@ -113,6 +113,38 @@ describe("what the popover says about a root, in Components (behold#571)", () =>
|
|
|
113
113
|
expect(rootPopover(answer(), "other", [{ kind: "terraform_data", id: "other/terraform_data.backup_schedule" }]).head).toBe(WORDS.noRootChange);
|
|
114
114
|
expect(rootPopover(answer(), "other", []).head).toBe(WORDS.noResources);
|
|
115
115
|
});
|
|
116
|
+
|
|
117
|
+
it("lists a create the plan holds but the checkout does not declare yet, first, as a create (behold#796)", () => {
|
|
118
|
+
const resources = [
|
|
119
|
+
{ kind: "terraform_remote_state", id: "cluster-a/data.terraform_remote_state.network" },
|
|
120
|
+
{ kind: "aws_dynamodb_table", id: "cluster-a/aws_dynamodb_table.jobs" },
|
|
121
|
+
];
|
|
122
|
+
const a = answer({
|
|
123
|
+
roots: [{ member: "repo", name: "cluster-a", path: "cluster-a", plan: { changes: 1 } }],
|
|
124
|
+
pull_request: { roots: ["cluster-a"] },
|
|
125
|
+
unmatched: {
|
|
126
|
+
roots: [],
|
|
127
|
+
changes: [
|
|
128
|
+
{ root: "cluster-a", address: "aws_sqs_queue.events", action: "create", verdict: "plan" },
|
|
129
|
+
{ root: "cluster-a", address: "aws_sqs_queue.events", action: "create", verdict: "wave" },
|
|
130
|
+
{ root: "cluster-a", address: "aws_s3_bucket.logs", action: "delete", verdict: "drift" },
|
|
131
|
+
{ root: "cluster-b", address: "aws_sqs_queue.other", action: "create", verdict: "plan" },
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
const p = rootPopover(a, "cluster-a", resources);
|
|
136
|
+
expect(p.head).toBe("1 of 3 resources change.");
|
|
137
|
+
expect(p.changed).toBe(1);
|
|
138
|
+
expect(p.rows).toEqual([
|
|
139
|
+
{ address: "aws_sqs_queue.events", state: "change", words: "to create" },
|
|
140
|
+
{ address: "data.terraform_remote_state.network", state: "same", words: "no change" },
|
|
141
|
+
{ address: "aws_dynamodb_table.jobs", state: "same", words: "no change" },
|
|
142
|
+
]);
|
|
143
|
+
// An answer from before behold#796 carries no action: it still counts as a change.
|
|
144
|
+
const old = rootPopover(answer({ roots: a.roots, unmatched: { roots: [], changes: [{ root: "cluster-a", address: 'aws_sqs_queue.q["a"]' }] } }), "cluster-a", []);
|
|
145
|
+
expect(old.rows).toEqual([{ address: "aws_sqs_queue.q", state: "change", words: "changes" }]);
|
|
146
|
+
expect(old.head).toBe("1 of 1 resource changes.");
|
|
147
|
+
});
|
|
116
148
|
});
|
|
117
149
|
|
|
118
150
|
describe("when the popover shows (behold#571)", () => {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// behold#787: on /kiosk a visitor replays a step already past, or the failure, and goes back to live.
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { BACK_WORDS, FAILURE_WORDS, REPLAY_IDLE_MS, askedLine, drawResult, replayOver, viewerReplay } from "./kiosk.js";
|
|
4
|
+
import { REPLAY_LAST_HOLD_MS } from "./kiosk-vendor.js";
|
|
5
|
+
|
|
6
|
+
const fakeDocument = () => {
|
|
7
|
+
const make = (tag) => {
|
|
8
|
+
const n = { tagName: tag, className: "", textContent: "", children: [], dataset: {}, style: {}, hidden: false, attrs: {}, on: {} };
|
|
9
|
+
n.appendChild = (c) => (n.children.push(c), c);
|
|
10
|
+
n.append = (...cs) => cs.forEach((c) => n.children.push(c));
|
|
11
|
+
n.replaceChildren = () => (n.children = []);
|
|
12
|
+
n.setAttribute = (k, v) => (n.attrs[k] = v);
|
|
13
|
+
n.addEventListener = (ev, fn) => (n.on[ev] = fn);
|
|
14
|
+
return n;
|
|
15
|
+
};
|
|
16
|
+
return { createElement: make };
|
|
17
|
+
};
|
|
18
|
+
const withDocument = (fn) => {
|
|
19
|
+
const was = globalThis.document;
|
|
20
|
+
globalThis.document = fakeDocument();
|
|
21
|
+
try {
|
|
22
|
+
return fn();
|
|
23
|
+
} finally {
|
|
24
|
+
globalThis.document = was;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const steps = [
|
|
29
|
+
{ at: "2026-10-19T20:05:36Z", step: "pull-request" },
|
|
30
|
+
{ at: "2026-10-19T20:06:47Z", step: "applying" },
|
|
31
|
+
{ at: "2026-10-19T20:08:30Z", step: "failed" },
|
|
32
|
+
{ at: "2026-10-19T20:12:12Z", step: "applied" },
|
|
33
|
+
{ at: "2026-10-19T20:14:09Z", step: "reset" },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
describe("a replay the viewer asked for (behold#787)", () => {
|
|
37
|
+
it("is the one the live poll leaves alone; a tool page's own replay is not", () => {
|
|
38
|
+
expect(viewerReplay({ mode: "replay", replay: { asked: true } })).toBe(true);
|
|
39
|
+
expect(viewerReplay({ mode: "replay", replay: { asked: false } })).toBe(false);
|
|
40
|
+
expect(viewerReplay({ mode: "live", replay: null })).toBe(false);
|
|
41
|
+
expect(viewerReplay(null)).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("ends at the cycle's end, or after a while with no input", () => {
|
|
45
|
+
const toApplied = Date.parse(steps[3].at) - Date.parse(steps[0].at);
|
|
46
|
+
const toReset = Date.parse(steps[4].at) - Date.parse(steps[0].at);
|
|
47
|
+
expect(replayOver(steps, toApplied, 0)).toBe(false);
|
|
48
|
+
expect(replayOver(steps, toReset, 0)).toBe(true);
|
|
49
|
+
expect(replayOver(steps, toReset + REPLAY_LAST_HOLD_MS - 1, 0)).toBe(true);
|
|
50
|
+
expect(replayOver(steps, 0, REPLAY_IDLE_MS)).toBe(false);
|
|
51
|
+
expect(replayOver(steps, 0, REPLAY_IDLE_MS + 1)).toBe(true);
|
|
52
|
+
expect(replayOver([], 0, 0)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("says it is a replay, with a button back to live", () =>
|
|
56
|
+
withDocument(() => {
|
|
57
|
+
let back = 0;
|
|
58
|
+
const p = askedLine({ replay: { banner: "Replay of the run at 20:05 UTC" }, backToLive: () => back++ });
|
|
59
|
+
expect(p.className).toBe("k-replay k-replay-asked");
|
|
60
|
+
expect(p.children.map((c) => c.textContent)).toEqual(["Replay of the run at 20:05 UTC", BACK_WORDS]);
|
|
61
|
+
p.children[1].on.click();
|
|
62
|
+
expect(back).toBe(1);
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
it("puts a Replay the failure chip on the done card when the cycle failed", () =>
|
|
66
|
+
withDocument(() => {
|
|
67
|
+
const host = document.createElement("aside");
|
|
68
|
+
const model = { head: "Applied", counts: ["3 waves applied"], waves: [] };
|
|
69
|
+
let seek = null;
|
|
70
|
+
drawResult(host, model, { waveTraces: {}, failureAt: () => "2026-10-19T20:08:00Z", seekTo: (at) => (seek = at) });
|
|
71
|
+
const chip = host.children.find((c) => c.className === "k-result-replay");
|
|
72
|
+
expect(chip.textContent).toBe(FAILURE_WORDS);
|
|
73
|
+
host.on.click({ target: { closest: (sel) => (sel === ".k-result-replay" ? chip : null) } });
|
|
74
|
+
expect(seek).toBe("2026-10-19T20:08:00Z");
|
|
75
|
+
// A cycle with no failure: no chip.
|
|
76
|
+
drawResult(host, model, { waveTraces: {}, failureAt: () => null });
|
|
77
|
+
expect(host.children.some((c) => c.className === "k-result-replay")).toBe(false);
|
|
78
|
+
}));
|
|
79
|
+
});
|
package/web/kiosk-runs.js
CHANGED
|
@@ -281,6 +281,39 @@ export function placeWords(run, scenarios, titles = {}, names = {}) {
|
|
|
281
281
|
return [sc, run.cycle !== null && run.cycle !== undefined ? `cycle ${run.cycle}` : null].filter(Boolean).join(" · ");
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
/**
|
|
285
|
+
* behold#815: what chant's run index says of a run beside its trigger: its
|
|
286
|
+
* workspace member, why it failed, and who signed its record. A run nobody
|
|
287
|
+
* signed says nothing of it (signing is opt-in, chant#4156). An apply that
|
|
288
|
+
* exited 3 says its plan moved or waits, never that it failed, with the
|
|
289
|
+
* refusal that says so or (#818, chant#4165) its exit code. Empty for a run
|
|
290
|
+
* from anywhere else.
|
|
291
|
+
*/
|
|
292
|
+
export function indexWords(run) {
|
|
293
|
+
// behold#685: a plan behold ran locally (src/ci-local-run.ts) says the same of itself.
|
|
294
|
+
if (!run || (run.from !== "ci-run-index" && run.from !== "chant-ci-local")) return [];
|
|
295
|
+
// The status beside it already says failed: chant's reason is added only when it says more than that.
|
|
296
|
+
const why = run.moved ? `${run.moved} (${run.heldBy || run.failure})` : run.failure && run.failure !== "failed" ? `failed: ${run.failure}` : null;
|
|
297
|
+
return [run.member || null, why, typeof run.signer === "string" && run.signer ? `signed by ${run.signer}` : null].filter(Boolean);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* behold#815: where a run of chant's run index says it ran, as a link: its
|
|
302
|
+
* runOrigin's URL, named by the URL's own host (a Forgejo run is recorded as
|
|
303
|
+
* forge `github`, so the forge's name is never taken from the record). Null
|
|
304
|
+
* without an http(s) URL.
|
|
305
|
+
*/
|
|
306
|
+
export function originLink(run) {
|
|
307
|
+
if (!run || run.from !== "ci-run-index" || typeof run.origin !== "string") return null;
|
|
308
|
+
let u;
|
|
309
|
+
try {
|
|
310
|
+
u = new URL(run.origin);
|
|
311
|
+
} catch {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
return u.protocol === "http:" || u.protocol === "https:" ? { href: u.href, text: `the run on ${u.host}` } : null;
|
|
315
|
+
}
|
|
316
|
+
|
|
284
317
|
/**
|
|
285
318
|
* behold#571: a runner's or an action's set-up line, not terragucci's own:
|
|
286
319
|
* git's hints, the checkout's `[command]` lines and groups, the runner's
|
|
@@ -414,13 +447,14 @@ export function statusIcon(status) {
|
|
|
414
447
|
}
|
|
415
448
|
|
|
416
449
|
/** The sidebar: the live run pinned, then the recent ones. `pick(id)` selects one; nothing here writes. */
|
|
417
|
-
export function renderSidebar(host, index, selectedId, { now = new Date(), scenarios = {}, titles = {}, names = {}, pick = () => {}, merged = null, replay = false, chant = false } = {}) {
|
|
450
|
+
export function renderSidebar(host, index, selectedId, { now = new Date(), scenarios = {}, titles = {}, names = {}, pick = () => {}, merged = null, replay = false, chant = false, from = null } = {}) {
|
|
418
451
|
host.replaceChildren();
|
|
419
452
|
const head = el("div", "r-side-head");
|
|
420
453
|
head.appendChild(el("div", "r-side-title", "Runs"));
|
|
421
454
|
// behold#571: a tool's page replays an earlier cycle's runs, and says so.
|
|
422
455
|
// behold#752: chant's demo's runs are built from chant's run events, not copied from the forge.
|
|
423
|
-
|
|
456
|
+
// behold#815: `from` names where else they come from (chant's run index).
|
|
457
|
+
head.appendChild(el("div", "r-side-note", replay ? "The replayed cycle's runs, newest first." : from || (chant ? "From chant's run events, newest first." : "From the forge, newest first.")));
|
|
424
458
|
host.appendChild(head);
|
|
425
459
|
if (!index || index.error || index.absent || !index.doc) {
|
|
426
460
|
host.appendChild(el("p", "r-note", index ? index.absent || index.error : "Reading the runs…"));
|
|
@@ -445,7 +479,7 @@ export function renderSidebar(host, index, selectedId, { now = new Date(), scena
|
|
|
445
479
|
li.appendChild(statusIcon(r.status));
|
|
446
480
|
const body = el("div", "r-run-body");
|
|
447
481
|
body.appendChild(el("div", "r-run-title", triggerWords(r)));
|
|
448
|
-
const place = placeWords(r, scenarios, named, names);
|
|
482
|
+
const place = [placeWords(r, scenarios, named, names), ...indexWords(r)].filter(Boolean).join(" · ");
|
|
449
483
|
if (place) body.appendChild(el("div", "r-run-place", place));
|
|
450
484
|
const meta = el("div", "r-run-meta");
|
|
451
485
|
meta.append(
|
|
@@ -525,13 +559,24 @@ export function renderRun(host, answer, ui, { now = new Date(), pickJob = () =>
|
|
|
525
559
|
const meta = el("div", "r-head-meta");
|
|
526
560
|
const bits = [
|
|
527
561
|
`#${run.id}`,
|
|
528
|
-
run
|
|
562
|
+
// A run of chant's index whose plan moved says why on its own (indexWords): "held" is all the status adds.
|
|
563
|
+
run.status === "waiting" ? (run.moved ? "held" : `held at a ${run.from === "ci-run-index" ? "" : "terragucci "}gate, waiting for an approval`) : STATUS_WORDS[run.status] || run.status,
|
|
529
564
|
run.ref ? `on ${run.ref}` : null,
|
|
530
565
|
run.commit ? `commit ${run.commit.slice(0, 8)}` : null,
|
|
566
|
+
...indexWords(run),
|
|
531
567
|
run.started_at ? `started ${agoWords(run.started_at, now)}` : null,
|
|
532
568
|
durationWords(run.started_at, run.ended_at, now),
|
|
533
569
|
].filter(Boolean);
|
|
534
570
|
meta.textContent = bits.join(" · ");
|
|
571
|
+
// behold#815: the forge's own run, when chant's run index names one.
|
|
572
|
+
const link = originLink(run);
|
|
573
|
+
if (link) {
|
|
574
|
+
const a = el("a", "r-origin", link.text);
|
|
575
|
+
a.href = link.href;
|
|
576
|
+
a.target = "_blank";
|
|
577
|
+
a.rel = "noopener noreferrer";
|
|
578
|
+
meta.append(" · ", a);
|
|
579
|
+
}
|
|
535
580
|
head.appendChild(meta);
|
|
536
581
|
host.appendChild(head);
|
|
537
582
|
|
|
@@ -831,6 +876,7 @@ export function startRuns(
|
|
|
831
876
|
replay = () => false,
|
|
832
877
|
hideLine = null,
|
|
833
878
|
// behold#752: where the live runs are read: terragucci's copies of forge runs, or chant's demo's runs built from its run events.
|
|
879
|
+
// behold#815: or chant's run index, whose `from` is the sidebar's line.
|
|
834
880
|
urls = { runs: "/api/terragucci/runs", run: (id) => `/api/terragucci/runs/${id}` },
|
|
835
881
|
} = {},
|
|
836
882
|
) {
|
|
@@ -880,7 +926,7 @@ export function startRuns(
|
|
|
880
926
|
}
|
|
881
927
|
// One merged read of the selected run for both the sidebar and its page.
|
|
882
928
|
const merged = ans && ans.doc ? mergeRun(entry, ans.doc) : null;
|
|
883
|
-
renderSidebar(side, s.index, id, { now: shown(), scenarios, titles: titles(), names: names(), pick, merged, replay: replay(), chant: urls.runs.startsWith("/api/chant/") });
|
|
929
|
+
renderSidebar(side, s.index, id, { now: shown(), scenarios, titles: titles(), names: names(), pick, merged, replay: replay(), chant: urls.runs.startsWith("/api/chant/"), from: urls.from || null });
|
|
884
930
|
// The redraw replaces the scrollers: keep where a viewer left them.
|
|
885
931
|
const old = main.querySelector(".r-log");
|
|
886
932
|
const oldSteps = main.querySelector(".r-steps");
|
package/web/kiosk-runs.test.js
CHANGED
|
@@ -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, toneOf, triggerWords } from "./kiosk-runs.js";
|
|
4
|
+
import { FEATURE_LINES, fitFeatures, FOLLOW_LINES, followsLog, logKey, nearEnd, mergeRun, newerOf, agoWords, defaultJob, defaultStep, durationWords, indexWords, jobOrder, originLink, 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"));
|
|
@@ -296,3 +296,44 @@ describe("the left bar's tone (behold#571)", () => {
|
|
|
296
296
|
for (const tone of new Set(Object.values(STATUS_TONE))) expect(html).toContain(`[data-k-tone="${tone}"]`);
|
|
297
297
|
});
|
|
298
298
|
});
|
|
299
|
+
|
|
300
|
+
// behold#815: chant's run index, as src/ci-run-index.ts hands it to the pane.
|
|
301
|
+
describe("runs from chant's run index (behold#815)", () => {
|
|
302
|
+
const ci = (over = {}) => ({ schema: "demo.run/v1", from: "ci-run-index", id: "6782", status: "failure", trigger: "merge", pull: 773, ref: null, member: null, failure: "failed", signer: null, started_at: "2026-10-19T02:26:01.917Z", ended_at: "2026-10-19T02:26:10.991Z", jobs: [{ id: "6782", name: "pr-apply", needs: [], status: "failure" }], ...over });
|
|
303
|
+
it("names the member, why it failed, and who signed it, beside the trigger", () => {
|
|
304
|
+
expect(triggerWords(ci())).toBe("Merge of #773 to main");
|
|
305
|
+
// "failed" beside a failed status says nothing more; a reason that does is kept.
|
|
306
|
+
expect(indexWords(ci())).toEqual([]);
|
|
307
|
+
expect(indexWords(ci({ failure: "command-failed" }))).toEqual(["failed: command-failed"]);
|
|
308
|
+
expect(indexWords(ci({ member: "web", failure: null, signer: "ci-runner@chant-demo", status: "success" }))).toEqual(["web", "signed by ci-runner@chant-demo"]);
|
|
309
|
+
});
|
|
310
|
+
it("says nothing of a signer a run doesn't have: signing is opt-in (chant#4156)", () => {
|
|
311
|
+
for (const signer of [null, undefined, ""]) expect(indexWords(ci({ signer, failure: null })).join(" ")).not.toMatch(/sign/);
|
|
312
|
+
});
|
|
313
|
+
it("words an apply that exited 3 as a plan that moved or waits, not a failure (chant#4156)", () => {
|
|
314
|
+
expect(indexWords(ci({ status: "waiting", failure: "plan-changed", moved: "the plan moved or waits: re-plan and re-approve" }))).toEqual(["the plan moved or waits: re-plan and re-approve (plan-changed)"]);
|
|
315
|
+
expect(toneOf("waiting")).not.toBe(toneOf("failure"));
|
|
316
|
+
});
|
|
317
|
+
it("words an apply held by its exit code alone the same way, naming the code (#818, chant#4165)", () => {
|
|
318
|
+
expect(indexWords(ci({ status: "waiting", failure: "failed", moved: "the plan moved or waits: re-plan and re-approve", heldBy: "exit 3", exitCode: 3 }))).toEqual(["the plan moved or waits: re-plan and re-approve (exit 3)"]);
|
|
319
|
+
});
|
|
320
|
+
it("links the forge's run by its URL's host, never by runOrigin's forge name", () => {
|
|
321
|
+
expect(originLink(ci({ origin: "http://forgejo:3000/chant-demo/fan-out-estate/actions/runs/6782" }))).toEqual({ href: "http://forgejo:3000/chant-demo/fan-out-estate/actions/runs/6782", text: "the run on forgejo:3000" });
|
|
322
|
+
expect(originLink(ci({ origin: "javascript:alert(1)" }))).toBeNull();
|
|
323
|
+
expect(originLink(ci())).toBeNull();
|
|
324
|
+
expect(originLink({ origin: "https://x.example/r/1" })).toBeNull();
|
|
325
|
+
});
|
|
326
|
+
it("adds nothing to a run from anywhere else", () => {
|
|
327
|
+
expect(indexWords({ ...ci(), from: undefined, member: "web" })).toEqual([]);
|
|
328
|
+
expect(indexWords(null)).toEqual([]);
|
|
329
|
+
});
|
|
330
|
+
it("calls a job chant adds later a run, and draws a status it adds by its own word", () => {
|
|
331
|
+
expect(triggerWords(ci({ trigger: null, event: null }))).toBe("a run");
|
|
332
|
+
expect(toneOf("cancelled-by-host")).toBe("idle");
|
|
333
|
+
});
|
|
334
|
+
it("keys runs by chant's run id, a string, through the merge and the live pick", () => {
|
|
335
|
+
const entry = ci({ status: "waiting", ended_at: null });
|
|
336
|
+
expect(mergeRun(entry, ci({ status: "waiting", ended_at: null, jobs: [{ id: "6782", name: "pr-apply", needs: [], status: "waiting", steps: [] }] })).id).toBe("6782");
|
|
337
|
+
expect(liveRun([ci({ id: "b" }), ci({ id: "a" })]).id).toBe("b");
|
|
338
|
+
});
|
|
339
|
+
});
|
package/web/kiosk-source.js
CHANGED
|
@@ -41,3 +41,26 @@ export function pageSource(doc) {
|
|
|
41
41
|
const s = m ? m.getAttribute("content") : null;
|
|
42
42
|
return s === "chant-demo" ? s : null;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* behold#815: the runs pane's reads when serve was given `--ci-report-url`:
|
|
47
|
+
* chant's run index and each run's events (src/ci-run-index.ts), in place of
|
|
48
|
+
* the forge's runs. Only the runs pane reads them; the demo's cycle and its
|
|
49
|
+
* approval panel read as before. `from` is the pane's line under "Runs".
|
|
50
|
+
*/
|
|
51
|
+
export const CI_RUNS_READS = {
|
|
52
|
+
runs: "/api/chant/ci/runs",
|
|
53
|
+
run: (id) => `/api/chant/ci/runs/${encodeURIComponent(id)}`,
|
|
54
|
+
from: "From chant's run index, newest first.",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** The runs the page was served for (`<meta name="kiosk-runs">`): `chant-ci`, or null for the source's own. */
|
|
58
|
+
export function pageRuns(doc) {
|
|
59
|
+
const m = doc && doc.querySelector ? doc.querySelector('meta[name="kiosk-runs"]') : null;
|
|
60
|
+
return m && m.getAttribute("content") === "chant-ci" ? "chant-ci" : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The runs pane's reads: chant's run index for `chant-ci`, else the source's (`reads.runs`, `reads.run`). */
|
|
64
|
+
export function runsReadsFor(runs, reads) {
|
|
65
|
+
return runs === "chant-ci" ? CI_RUNS_READS : { runs: reads.runs, run: reads.run };
|
|
66
|
+
}
|
package/web/kiosk-source.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { CHANT_DEMO_READS, TERRAGUCCI_READS, pageSource, readsFor } from "./kiosk-source.js";
|
|
2
|
+
import { CHANT_DEMO_READS, CI_RUNS_READS, TERRAGUCCI_READS, pageRuns, pageSource, readsFor, runsReadsFor } from "./kiosk-source.js";
|
|
3
3
|
import { startMetrics } from "./kiosk-metrics.js";
|
|
4
4
|
|
|
5
5
|
// behold#752: a kiosk page reads terragucci's loop unless the server tells it chant's demo is its source.
|
|
@@ -37,3 +37,21 @@ describe("where a kiosk page reads its demo (behold#752)", () => {
|
|
|
37
37
|
expect(await asked(CHANT_DEMO_READS)).toEqual(["/api/chant/demo", "/api/chant/demo/cycle"]);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
// behold#815: with --ci-report-url, the runs pane alone reads chant's run index.
|
|
42
|
+
const runsDoc = (content) => ({ querySelector: (q) => (q === 'meta[name="kiosk-runs"]' && content !== null ? { getAttribute: () => content } : null) });
|
|
43
|
+
|
|
44
|
+
describe("where the runs pane reads its runs (behold#815)", () => {
|
|
45
|
+
it("a page without the tag reads the source's runs, the forge's or chant's demo's", () => {
|
|
46
|
+
expect(pageRuns(runsDoc(null))).toBeNull();
|
|
47
|
+
expect(runsReadsFor(null, TERRAGUCCI_READS)).toEqual({ runs: "/api/terragucci/runs", run: TERRAGUCCI_READS.run });
|
|
48
|
+
expect(runsReadsFor(null, CHANT_DEMO_READS).runs).toBe("/api/chant/demo/runs");
|
|
49
|
+
});
|
|
50
|
+
it("a page told `chant-ci` reads chant's run index, whatever its source, and says so in the sidebar", () => {
|
|
51
|
+
expect(pageRuns(runsDoc("chant-ci"))).toBe("chant-ci");
|
|
52
|
+
for (const reads of [TERRAGUCCI_READS, CHANT_DEMO_READS]) expect(runsReadsFor("chant-ci", reads)).toBe(CI_RUNS_READS);
|
|
53
|
+
expect([CI_RUNS_READS.runs, CI_RUNS_READS.run("chant-1792376662004"), CI_RUNS_READS.run("a/b")]).toEqual(["/api/chant/ci/runs", "/api/chant/ci/runs/chant-1792376662004", "/api/chant/ci/runs/a%2Fb"]);
|
|
54
|
+
expect(CI_RUNS_READS.from).toBe("From chant's run index, newest first.");
|
|
55
|
+
expect(pageRuns(runsDoc("forge"))).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
});
|
package/web/kiosk-track.js
CHANGED
|
@@ -102,7 +102,8 @@ export function cycleTrack(cycle) {
|
|
|
102
102
|
last.ms += took;
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
// behold#787: the segment's first step's time, where a replay of it starts.
|
|
106
|
+
chapter.segments.push({ label, steps: [s.step], ms: took, labelText: s.label || "", at: s.at });
|
|
106
107
|
});
|
|
107
108
|
const total = chapters.reduce((sum, c) => sum + c.segments.reduce((a, g) => a + g.ms, 0), 0) || 1;
|
|
108
109
|
return { chapters, total, cycle: cycle.cycle, byStory };
|
|
@@ -127,9 +128,11 @@ export function chapterTitle(index, pull) {
|
|
|
127
128
|
* this cycle has opened, in order; `since` when the current segment began
|
|
128
129
|
* (ms); `waves` the apply's waves as the paced graph shows them
|
|
129
130
|
* ([{ wave, state }]), for the applying segment's ticks; `jobs` the apply
|
|
130
|
-
* jobs of this step's run that have started ({@link applyJobs}).
|
|
131
|
+
* jobs of this step's run that have started ({@link applyJobs}). behold#787:
|
|
132
|
+
* a segment already past (in a `replay`, any but the current one) carries
|
|
133
|
+
* `seek`, its first step's time, and a chapter carries its first segment's.
|
|
131
134
|
*/
|
|
132
|
-
export function trackModel(track, { demo, pulls = [], since = null, now = Date.now(), waves = null, jobs = [] } = {}) {
|
|
135
|
+
export function trackModel(track, { demo, pulls = [], since = null, now = Date.now(), waves = null, jobs = [], replay = false } = {}) {
|
|
133
136
|
if (!track || !demo) return null;
|
|
134
137
|
// Where the cycle is: the step's own story chapter when told in them; else the chapter of the current pull request
|
|
135
138
|
// (the reset, the last). Then the segment holding the step.
|
|
@@ -158,14 +161,44 @@ export function trackModel(track, { demo, pulls = [], since = null, now = Date.n
|
|
|
158
161
|
state,
|
|
159
162
|
tone,
|
|
160
163
|
fill: state === "done" ? 1 : state === "current" ? fill : 0,
|
|
164
|
+
// The reset is the cycle's end: nothing to replay from there.
|
|
165
|
+
seek: (replay ? state !== "current" : state === "done") && g.label !== "reset" && typeof g.at === "string" ? g.at : null,
|
|
161
166
|
...(state === "current" && g.label === "applying" && Array.isArray(waves) && waves.length ? { ticks: waves.map((w) => ({ wave: w.wave, state: w.state })) } : {}),
|
|
162
167
|
};
|
|
163
168
|
}),
|
|
164
169
|
}));
|
|
170
|
+
// A chapter's title replays it only once it is over: on the live cycle's current chapter the pill read as a label
|
|
171
|
+
// saying the demo was a replay, and a tap on it left live.
|
|
172
|
+
for (const c of chapters) c.seek = (replay || c.state === "done") && c.segments.length ? c.segments[0].seek : null;
|
|
165
173
|
const nowLine = nowWords({ demo, segment: current, expected, elapsed, overrun, waves, jobs, now, fix: track.byStory ? pulls.indexOf(demo.pull) > 0 : at.chapter > 0 });
|
|
166
174
|
return { chapters, at, elapsed, expected, overrun, now: nowLine, here: hereWords(chapters, at) };
|
|
167
175
|
}
|
|
168
176
|
|
|
177
|
+
/** behold#787: how long before the failed step a replay of the failure starts: the apply's last stretch, where it breaks. */
|
|
178
|
+
export const FAILURE_LEAD_MS = 30_000;
|
|
179
|
+
|
|
180
|
+
/** behold#787: how far into the cycle a time is, in ms from its first step, for the replay's clock (kiosk-vendor.js replayAt). */
|
|
181
|
+
export function seekMs(cycle, at) {
|
|
182
|
+
const first = cycle && Array.isArray(cycle.steps) && cycle.steps[0] ? Date.parse(cycle.steps[0].at) : NaN;
|
|
183
|
+
const t = Date.parse(at || "");
|
|
184
|
+
return Number.isFinite(first) && Number.isFinite(t) ? Math.max(0, t - first) : 0;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* behold#787: where a replay of the cycle's failure starts: FAILURE_LEAD_MS
|
|
189
|
+
* before its failed step, never before the step ahead of it (the apply that
|
|
190
|
+
* broke). Null for a cycle with no failure.
|
|
191
|
+
*/
|
|
192
|
+
export function failureAt(cycle) {
|
|
193
|
+
const steps = cycle && Array.isArray(cycle.steps) ? cycle.steps : [];
|
|
194
|
+
const i = steps.findIndex((x) => x && x.step === "failed");
|
|
195
|
+
if (i < 0) return null;
|
|
196
|
+
const t = Date.parse(steps[i].at);
|
|
197
|
+
const before = i > 0 ? Date.parse(steps[i - 1].at) : t;
|
|
198
|
+
if (!Number.isFinite(t)) return null;
|
|
199
|
+
return new Date(Math.max(Number.isFinite(before) ? before : t, t - FAILURE_LEAD_MS)).toISOString();
|
|
200
|
+
}
|
|
201
|
+
|
|
169
202
|
/**
|
|
170
203
|
* behold#778: the current step by name, "Step: applying, in 3 The fix", for a
|
|
171
204
|
* phone, whose segments are too narrow for their labels. Null when the cycle
|
|
@@ -203,7 +236,8 @@ export function nowWords({ demo, segment, expected = 0, elapsed = 0, overrun = f
|
|
|
203
236
|
case "fix opened":
|
|
204
237
|
return say("The pipeline is starting the plan job", "the pipeline to start the plan");
|
|
205
238
|
case "planned":
|
|
206
|
-
|
|
239
|
+
// behold#784: no review is asked unless a wave would destroy something; the driver's line says what comes next.
|
|
240
|
+
return say(fix ? "The fix is planned" : "The plan is in");
|
|
207
241
|
case "review":
|
|
208
242
|
return say("Waiting for the reviewer", "the reviewer to approve the plan");
|
|
209
243
|
case "merged":
|
|
@@ -283,6 +317,12 @@ body.k-watch #k-track { position: fixed; z-index: 7; left: 5px; right: 5px; }
|
|
|
283
317
|
@keyframes kt-sheen { from { background-position: -60% 0; } to { background-position: 160% 0; } }
|
|
284
318
|
}
|
|
285
319
|
#k-track .kt-here { display: none; }
|
|
320
|
+
/* behold#787: a step already past is a button that replays it. */
|
|
321
|
+
#k-track button.kt-seek { font: inherit; margin: 0; cursor: pointer; background: transparent; color: inherit; text-align: inherit; }
|
|
322
|
+
#k-track button.kt-seg.kt-seek { padding: 0; }
|
|
323
|
+
#k-track button.kt-chapter-title.kt-seek { padding: 0; border: 0; color: var(--fg); text-decoration: underline dotted; text-underline-offset: 2px; }
|
|
324
|
+
#k-track button.kt-seg.kt-seek:hover { border-color: var(--pending); }
|
|
325
|
+
#k-track button.kt-seek:focus-visible { outline: 2px solid var(--pending); outline-offset: 1px; }
|
|
286
326
|
/* behold#778: a phone's segments are too narrow for their labels, so a line names the current step, and the chapters wrap to a new line instead of running off the right edge. */
|
|
287
327
|
@media (max-width: 600px) {
|
|
288
328
|
body.k-watch #k-track { position: static; }
|
|
@@ -291,8 +331,13 @@ body.k-watch #k-track { position: fixed; z-index: 7; left: 5px; right: 5px; }
|
|
|
291
331
|
#k-track .kt-chapter-title { font-size: 0.88em; }
|
|
292
332
|
#k-track .kt-segs .kt-label { display: none; }
|
|
293
333
|
#k-track .kt-seg { height: 0.8em; min-width: 0.6em !important; }
|
|
294
|
-
|
|
295
|
-
#k-track .kt-now { font-size:
|
|
334
|
+
/* A phone leads with one line of what is happening now: the chapter in the rail already says which step. */
|
|
335
|
+
#k-track .kt-now { font-size: 1em; font-weight: 600; white-space: normal; margin-top: 0.3em; }
|
|
336
|
+
#k-track .kt-now::before { content: "Now: "; color: var(--pending); }
|
|
337
|
+
/* behold#787: a phone's segments are too thin to press; a past chapter's title is the 44px target. */
|
|
338
|
+
#k-track button.kt-seg.kt-seek { pointer-events: none; }
|
|
339
|
+
#k-track button.kt-chapter-title.kt-seek { align-self: flex-start; max-width: 100%; min-height: 44px; padding: 0 0.8em; border: 1.5px solid color-mix(in srgb, var(--pending) 70%, transparent); border-radius: 999px; text-decoration: none; }
|
|
340
|
+
#k-track button.kt-chapter-title.kt-seek::after { content: " · watch again"; color: var(--pending); font-weight: 500; }
|
|
296
341
|
}
|
|
297
342
|
`;
|
|
298
343
|
|
|
@@ -311,6 +356,25 @@ export function drawTrack(host, model, doc = typeof document !== "undefined" ? d
|
|
|
311
356
|
if (text !== undefined && text !== null) n.textContent = text;
|
|
312
357
|
return n;
|
|
313
358
|
};
|
|
359
|
+
// behold#787: the track is rebuilt every second, so a press is read on the host: a tap whose button was
|
|
360
|
+
// rebuilt between its down and its up still seeks to where it went down, and a focused button keeps its focus.
|
|
361
|
+
host.ktSeek = model && model.onSeek ? model.onSeek : null;
|
|
362
|
+
if (!host.ktWired && host.addEventListener) {
|
|
363
|
+
host.ktWired = true;
|
|
364
|
+
let down = null;
|
|
365
|
+
const seekOf = (t) => (t && t.closest ? t.closest("[data-seek]") : null);
|
|
366
|
+
host.addEventListener("pointerdown", (e) => {
|
|
367
|
+
const b = seekOf(e.target);
|
|
368
|
+
down = b ? { seek: b.dataset.seek, at: Date.now() } : null;
|
|
369
|
+
});
|
|
370
|
+
host.addEventListener("click", (e) => {
|
|
371
|
+
const b = seekOf(e.target);
|
|
372
|
+
const seek = b ? b.dataset.seek : down && Date.now() - down.at < 1500 ? down.seek : null;
|
|
373
|
+
down = null;
|
|
374
|
+
if (seek && host.ktSeek) host.ktSeek(seek);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
const focused = doc.activeElement && host.contains && host.contains(doc.activeElement) && doc.activeElement.dataset ? doc.activeElement.dataset.seek : null;
|
|
314
378
|
host.replaceChildren();
|
|
315
379
|
if (!model) {
|
|
316
380
|
host.hidden = true;
|
|
@@ -324,14 +388,26 @@ export function drawTrack(host, model, doc = typeof document !== "undefined" ? d
|
|
|
324
388
|
const ch = el("div", `kt-chapter kt-${c.state}`);
|
|
325
389
|
// Grow factors summing to well over 1: below 1 a flex row leaves the rest of its width empty.
|
|
326
390
|
ch.style.flex = `${Math.round(share * 1000)} 1 0`;
|
|
327
|
-
|
|
391
|
+
// behold#787: a step already past replays from its start on a press: the chapter's title (a phone's target) and each segment.
|
|
392
|
+
const seekable = (o) => !!(o.seek && model.onSeek);
|
|
393
|
+
const head = el(seekable(c) ? "button" : "div", `kt-chapter-title${seekable(c) ? " kt-seek" : ""}`, c.title);
|
|
394
|
+
if (seekable(c)) {
|
|
395
|
+
head.type = "button";
|
|
396
|
+
head.title = `Replay from ${c.title}`;
|
|
397
|
+
head.dataset.seek = c.seek;
|
|
398
|
+
}
|
|
399
|
+
ch.appendChild(head);
|
|
328
400
|
const segs = el("div", "kt-segs");
|
|
329
401
|
for (const g of c.segments) {
|
|
330
|
-
const seg = el("div", `kt-seg kt-${g.state} kt-${g.tone}`);
|
|
402
|
+
const seg = el(seekable(g) ? "button" : "div", `kt-seg kt-${g.state} kt-${g.tone}${seekable(g) ? " kt-seek" : ""}`);
|
|
403
|
+
if (seekable(g)) {
|
|
404
|
+
seg.type = "button";
|
|
405
|
+
seg.dataset.seek = g.seek;
|
|
406
|
+
}
|
|
331
407
|
seg.style.flex = `${Math.round(g.share * 1000)} 1 0`;
|
|
332
408
|
// Never narrower than its short label, whole.
|
|
333
409
|
seg.style.minWidth = `${(g.short.length * 0.62 + 1).toFixed(2)}em`;
|
|
334
|
-
seg.title = g.label;
|
|
410
|
+
seg.title = seekable(g) ? `Replay from ${g.label}` : g.label;
|
|
335
411
|
const fill = el("div", "kt-fill");
|
|
336
412
|
fill.style.width = `${Math.round(g.fill * 1000) / 10}%`;
|
|
337
413
|
seg.appendChild(fill);
|
|
@@ -359,4 +435,8 @@ export function drawTrack(host, model, doc = typeof document !== "undefined" ? d
|
|
|
359
435
|
for (const lab of host.querySelectorAll ? host.querySelectorAll(".kt-label") : []) {
|
|
360
436
|
if (lab.scrollWidth > lab.clientWidth + 1 && lab.dataset.short) lab.textContent = lab.dataset.short;
|
|
361
437
|
}
|
|
438
|
+
if (focused && host.querySelector) {
|
|
439
|
+
const again = [...host.querySelectorAll("[data-seek]")].find((b) => b.dataset.seek === focused);
|
|
440
|
+
if (again && again.focus) again.focus();
|
|
441
|
+
}
|
|
362
442
|
}
|
package/web/kiosk-track.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { FILL_CAP, applyJobs, cycleTrack, hereWords, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
2
|
+
import { FAILURE_LEAD_MS, FILL_CAP, applyJobs, cycleTrack, failureAt, hereWords, nowWords, seekMs, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
3
3
|
|
|
4
4
|
// behold#631: chant-fanout's last finished cycle as cycles/chant-fanout/latest.json had it (cycle 499):
|
|
5
5
|
// fifteen steps, two pull requests, from the change's open to the reset.
|
|
@@ -191,3 +191,51 @@ describe("the apply's jobs end the wait (behold#774)", () => {
|
|
|
191
191
|
expect(waitingSpec(at("applying", []), { quietMs: 5_000 }).what).toBe("the pipeline to start the apply");
|
|
192
192
|
});
|
|
193
193
|
});
|
|
194
|
+
|
|
195
|
+
describe("a past step replays from its start (behold#787)", () => {
|
|
196
|
+
const ch = (n, short) => ({ n, of: 4, headline: short, short });
|
|
197
|
+
const chapters = [ch(1, "The change goes out"), ch(2, "cluster-a breaks"), ch(3, "The fix"), ch(4, "Done")];
|
|
198
|
+
const of = (step, i) => (step === "failed" ? chapters[1] : ["applied", "reset"].includes(step) ? chapters[3] : i < 6 ? chapters[0] : chapters[2]);
|
|
199
|
+
const track = cycleTrack({ ...cycle, steps: cycle.steps.map((s, i) => ({ ...s, chapter: of(s.step, i) })) });
|
|
200
|
+
const now = Date.parse(T("40:00"));
|
|
201
|
+
|
|
202
|
+
it("gives each segment already past its first step's time, and each chapter its first segment's", () => {
|
|
203
|
+
const m = trackModel(track, { demo: { step: "planned", pull: 13, chapter: chapters[2] }, pulls: [12, 13], since: now, now });
|
|
204
|
+
expect(m.chapters[0].segments.map((g) => g.seek)).toEqual([T("18:49"), T("19:01"), T("19:14"), T("19:27"), T("19:30")]);
|
|
205
|
+
// The current chapter's title doesn't replay it: only a chapter that is over does.
|
|
206
|
+
expect(m.chapters.map((c) => c.seek)).toEqual([T("18:49"), T("19:49"), null, null]);
|
|
207
|
+
// The current step and those ahead have no seek in the live cycle.
|
|
208
|
+
expect(m.chapters[2].segments.map((g) => g.seek)).toEqual([T("20:10"), null, null, null, null]);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("lets a replay seek to any step but the one it shows, and never to the reset", () => {
|
|
212
|
+
const m = trackModel(track, { demo: { step: "failed", pull: 12, chapter: chapters[1] }, pulls: [12], since: now, now, replay: true });
|
|
213
|
+
expect(m.chapters[1].segments[0]).toMatchObject({ state: "current", seek: null });
|
|
214
|
+
expect(m.chapters[2].segments[4]).toMatchObject({ state: "ahead", seek: T("20:37") });
|
|
215
|
+
expect(m.chapters[3].segments.map((g) => [g.label, g.seek])).toEqual([["done", T("20:56")], ["reset", null]]);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("measures a seek from the cycle's first step", () => {
|
|
219
|
+
expect(seekMs(cycle, T("19:49"))).toBe(60_000);
|
|
220
|
+
expect(seekMs(cycle, "2026-10-18T17:00:00Z")).toBe(0);
|
|
221
|
+
expect(seekMs(null, T("19:49"))).toBe(0);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("starts a replay of the failure in the apply's last stretch, never before the apply", () => {
|
|
225
|
+
// The apply took 19 s, under the lead: the replay starts with it.
|
|
226
|
+
expect(failureAt(cycle)).toBe(new Date(T("19:30")).toISOString());
|
|
227
|
+
const long = { ...cycle, steps: cycle.steps.map((s) => (s.step === "applying" && s.pull === 641 ? { ...s, at: "2026-10-18T18:17:00Z" } : s)) };
|
|
228
|
+
expect(Date.parse(failureAt(long))).toBe(Date.parse(T("19:49")) - FAILURE_LEAD_MS);
|
|
229
|
+
expect(failureAt({ ...cycle, steps: cycle.steps.filter((s) => s.step !== "failed") })).toBeNull();
|
|
230
|
+
expect(failureAt(null)).toBeNull();
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe("nowWords", () => {
|
|
235
|
+
// behold#784: a plan asks no review unless a wave would destroy something, so the planned line doesn't promise one.
|
|
236
|
+
it("says the plan is in, and nothing about a review", () => {
|
|
237
|
+
const demo = { label: "Fan out." };
|
|
238
|
+
expect(nowWords({ demo, segment: { label: "planned" } }).text).toBe("The plan is in");
|
|
239
|
+
expect(nowWords({ demo, segment: { label: "planned" }, fix: true }).text).toBe("The fix is planned");
|
|
240
|
+
});
|
|
241
|
+
});
|