@intentius/behold 0.29.43 → 0.29.44
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 +77 -0
- package/dist/cli.js +3969 -1918
- package/package.json +1 -1
- package/web/app.js +1452 -73
- package/web/carve-narration.js +33 -1
- package/web/chant-live-pace.js +138 -0
- package/web/chant-live-pace.test.js +116 -0
- package/web/chant-pr-marks.js +417 -39
- package/web/chant-pr-marks.test.js +208 -4
- package/web/collision-marks.js +124 -0
- package/web/collision-marks.test.js +89 -0
- package/web/cone.js +269 -0
- package/web/cone.test.js +213 -0
- package/web/dots-live.test.js +151 -1
- package/web/dots-lod.js +20 -0
- package/web/dots-lod.test.js +19 -1
- package/web/dots-scene.js +110 -10
- package/web/dots.js +144 -31
- package/web/embed.js +1 -1
- package/web/event-help-modal.js +85 -3
- package/web/event-help-modal.test.js +85 -1
- package/web/feature-flags.js +143 -0
- package/web/feature-flags.test.js +96 -0
- package/web/index.html +33 -0
- package/web/kiosk-carve.js +59 -6
- package/web/kiosk-event-help-ui.js +150 -19
- package/web/kiosk-event-help.js +102 -15
- package/web/kiosk-event-help.test.js +58 -1
- package/web/kiosk-metrics.js +4 -3
- package/web/kiosk-runs.js +8 -5
- package/web/kiosk-shot.js +157 -3
- package/web/kiosk-shot.test.js +223 -1
- package/web/kiosk-source.js +43 -0
- package/web/kiosk-source.test.js +39 -0
- package/web/kiosk-story-gate.test.js +44 -0
- package/web/kiosk-track.js +312 -0
- package/web/kiosk-track.test.js +148 -0
- package/web/kiosk-unknown-step.test.js +58 -0
- package/web/kiosk-vendor.js +71 -4
- package/web/kiosk-vendor.test.js +103 -3
- package/web/kiosk-watch.js +154 -1
- package/web/kiosk-watch.test.js +53 -1
- package/web/kiosk.html +57 -22
- package/web/kiosk.js +566 -53
- package/web/kiosk.test.js +2 -1
- package/web/small-stage.test.js +150 -0
- package/web/terragucci-blocked.test.js +192 -0
- package/web/terragucci-change.js +197 -17
- package/web/terragucci-components-live.js +189 -13
- package/web/terragucci-live-pace.js +92 -0
- package/web/terragucci-wave-results.test.js +125 -0
- package/web/terralith.html +7 -7
- package/web/tg-outside.js +124 -0
- package/web/tg-outside.test.js +100 -0
- package/web/tg-read-pills.js +122 -0
- package/web/tg-read-pills.test.js +117 -0
- package/web/theme.js +13 -1
- package/web/theme.test.js +21 -1
- package/web/tooltip.js +19 -7
- package/web/tooltip.test.js +15 -0
- package/web/tours/terralith.json +4 -4
- package/web/trunk-lane.test.js +1 -1
- package/web/view-url.js +8 -2
- package/web/why.js +129 -1
- package/web/why.test.js +113 -1
package/web/kiosk.js
CHANGED
|
@@ -14,9 +14,15 @@
|
|
|
14
14
|
// Nothing here is all-or-nothing, and nothing says so.
|
|
15
15
|
|
|
16
16
|
import { linkState, linkWords, noteBack, noteRead, readFailed, shareLink } from "./kiosk-link.js";
|
|
17
|
-
import { CHANT_PANEL_STEPS, chantApprovalModel } from "./chant-pr-marks.js";
|
|
17
|
+
import { CHANT_PANEL_STEPS, chantApprovalModel, chantResultModel } from "./chant-pr-marks.js";
|
|
18
|
+
import { createLivePacer } from "./chant-live-pace.js";
|
|
19
|
+
import { cycleTrack, drawTrack, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
20
|
+
import { FORGES, iconSvg } from "./forge-mark.js";
|
|
21
|
+
import { TOOLS } from "./tool-mark.js";
|
|
22
|
+
import { graphWaves } from "./chant-pr-marks.js";
|
|
23
|
+
import { createProgressPacer, trackWaves } from "./terragucci-live-pace.js";
|
|
18
24
|
import { PICK_HOLD_MS, annMark, mergeRun, startRuns, statusIcon } from "./kiosk-runs.js";
|
|
19
|
-
import { MODES, MODE_STORE, badges as waveBadges, badgeTitle, behindStep, steadyRun, captionModel, doraLine, modeStored, placeBeside, resultModel, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
25
|
+
import { MODES, MODE_STORE, badges as waveBadges, badgeTitle, behindStep, steadyRun, captionModel, captionRoom, coneCaption, stepLine, watchOverlays, doraLine, modeStored, placeBeside, quietWords, recordKey, resultModel, runningStep, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
20
26
|
import { shotMessage } from "./kiosk-shot.js";
|
|
21
27
|
import { mountTrace } from "./kiosk-trace.js";
|
|
22
28
|
import { startEventHelp } from "./kiosk-event-help-ui.js";
|
|
@@ -24,9 +30,10 @@ import { miniWaterfall, phaseWords, waveTraces } from "./kiosk-wave-traces.js";
|
|
|
24
30
|
import { PANEL_STEPS, PANEL_TITLE, approvalModel, cycleRuns, digestHex, rowFacts } from "./kiosk-approval.js";
|
|
25
31
|
import { getThemeName, mountThemePicker, onThemeChange } from "./theme.js";
|
|
26
32
|
import { cssString, hoverCss, hoverFromMessage, hoverLinks, hoverMessage, isLightBg, rootSegments, rootText } from "./kiosk-roots.js";
|
|
27
|
-
import { creditLines, filterIndex, keepRun, liveEstimate, liveFor, namesOther, notRunRepo, notRunWords, replayAt, replayBanner, replayIndex, rootNoun, rootWord, runAsOf, scrubDemo, servesRepo, vendorOf } from "./kiosk-vendor.js";
|
|
33
|
+
import { creditLines, filterIndex, keepRun, kioskVendorOf, liveEstimate, liveFor, namesOther, notRunRepo, notRunWords, replayAt, replayBanner, replayIndex, rootNoun, rootWord, runAsOf, scrubDemo, servesRepo, vendorOf } from "./kiosk-vendor.js";
|
|
28
34
|
import { repoParam, repoUrl, stepCheckout } from "./kiosk-repo.js";
|
|
29
35
|
import { startKioskCarve } from "./kiosk-carve.js";
|
|
36
|
+
import { readsFor } from "./kiosk-source.js";
|
|
30
37
|
import { STATE_WORDS, changingRoots, costLine, pinsCommit, planFitsPin, pullPin, readEdges, rootsCount, totalsLine, waveRows, blastRows } from "./terragucci-change.js";
|
|
31
38
|
|
|
32
39
|
/** The scenarios terragucci#1014 numbers. An id not here is shown by the title demo.json carries. */
|
|
@@ -127,6 +134,126 @@ export function stripStops(step, strip = STRIP) {
|
|
|
127
134
|
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" }));
|
|
128
135
|
}
|
|
129
136
|
|
|
137
|
+
/** behold#631: the chapter headline's look: it fades in when the chapter turns (no motion under reduced motion), the point small under it. */
|
|
138
|
+
function chapterStyle() {
|
|
139
|
+
if (typeof document === "undefined" || !document.head || document.getElementById("k-chapter-style")) return;
|
|
140
|
+
const st = document.createElement("style");
|
|
141
|
+
st.id = "k-chapter-style";
|
|
142
|
+
st.textContent = `.k-cap-point { margin: 0.1em 0 0.35em; font: 600 0.95em var(--font-ui); color: var(--muted); }
|
|
143
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
144
|
+
.k-chapter-head.k-chapter-in { animation: k-chapter-in 0.8s ease-out both; }
|
|
145
|
+
@keyframes k-chapter-in { from { opacity: 0; } to { opacity: 1; } }
|
|
146
|
+
}`;
|
|
147
|
+
document.head.appendChild(st);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* behold#741: whether a kiosk tells its scenario the way #631 built for chant's loop (the projected track, the
|
|
152
|
+
* chapter headline, the reach wedge, the waiting modal, paced waves, the wave blocks, applied earlier, one tip at a
|
|
153
|
+
* time and the title line): a chant repo's loop, or a terragucci repo whose demo.json step carries `chapter`.
|
|
154
|
+
* b-waves, failure and tg-planned-outputs carry none, so they take today's path.
|
|
155
|
+
*/
|
|
156
|
+
export function storyGate({ chantLoop = false, terragucciRepo = false, demo = null } = {}) {
|
|
157
|
+
if (chantLoop) return "chant";
|
|
158
|
+
if (terragucciRepo && demo && demo.chapter && Number.isInteger(demo.chapter.n)) return "terragucci";
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
const storyOn = (s) => !!(s.chantLoop || s.tgStory);
|
|
162
|
+
|
|
163
|
+
/** behold#631: a chant kiosk's one line naming what it shows: the pipeline is chant's own; terragucci runs the demo around it. */
|
|
164
|
+
export const SCENARIO_WORDS = { "fan-out": "fan-out" };
|
|
165
|
+
export function whatLine(demo, forge = null, tg = null) {
|
|
166
|
+
return whatParts(demo, forge, tg).map((p) => p.text).join(" · ");
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The line's parts, each `{ text, short, logo? }`: a logo (a mark behold ships) only where a product is named,
|
|
170
|
+
* chant's beside chant, the forge's beside the forge. `short` is the phone's words.
|
|
171
|
+
*/
|
|
172
|
+
export function whatParts(demo, forge = null, tg = null, hide = null) {
|
|
173
|
+
// behold#746: a tool's page leaves out each part that names what it may not.
|
|
174
|
+
if (hide) return whatParts(demo, forge, tg).filter((p) => !hide(p.text) && !hide(p.short));
|
|
175
|
+
const sc = demo && typeof demo.scenario === "string" ? demo.scenario : null;
|
|
176
|
+
const f = forge && FORGES[forge] ? FORGES[forge] : null;
|
|
177
|
+
// behold#741: a terragucci repo's line: terragucci (behold ships no terragucci mark, so its name alone), the engine
|
|
178
|
+
// its jobs run with its mark where behold ships one (OpenTofu's; Terraform's name alone), then the same as chant's.
|
|
179
|
+
const tool = tg ? whatTool(tg.tools) : null;
|
|
180
|
+
const head = tg
|
|
181
|
+
? [{ text: "terragucci", short: "terragucci" }, ...(tool ? [{ text: tool.name, short: tool.name, ...(tool.logo ? { logo: tool.logo } : {}) }] : [])]
|
|
182
|
+
: [{ text: "chant's pull-request pipeline", short: "chant pipeline", logo: "chant" }];
|
|
183
|
+
return [
|
|
184
|
+
...head,
|
|
185
|
+
...(f ? [{ text: `on ${f.label}`, short: f.label, logo: forge }] : []),
|
|
186
|
+
...(sc ? [{ text: SCENARIO_WORDS[sc] || sc.replace(/-/g, " "), short: SCENARIO_WORDS[sc] || sc.replace(/-/g, " ") }] : []),
|
|
187
|
+
{ text: "live demo", short: "live" },
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
/** behold#741: the engine a terragucci repo's jobs run, from its declared tools: OpenTofu with its mark, Terraform by name alone. */
|
|
191
|
+
export function whatTool(tools) {
|
|
192
|
+
const ts = Array.isArray(tools) ? tools : [];
|
|
193
|
+
for (const id of ["opentofu", "terraform"]) {
|
|
194
|
+
if (!ts.includes(id) || !TOOLS[id]) continue;
|
|
195
|
+
return { id, name: TOOLS[id].name, ...(TOOLS[id].icon && !TOOLS[id].icon.image ? { logo: id } : {}) };
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
/** The line drawn: each part's logo at the words' height, at its own aspect (the marks are square), then the words. */
|
|
200
|
+
function whatLineEl(demo, forge, tg = null, hide = null, own = false) {
|
|
201
|
+
const line = el("span", "k-cycle k-what-line");
|
|
202
|
+
const light = typeof document !== "undefined" && typeof getComputedStyle === "function" ? isLightBg(getComputedStyle(document.documentElement).getPropertyValue("--bg")) : false;
|
|
203
|
+
whatParts(demo, forge, tg, hide).forEach((p, i) => {
|
|
204
|
+
if (i) line.appendChild(el("span", "k-what-sep", "·"));
|
|
205
|
+
const part = el("span", "k-what-part");
|
|
206
|
+
const spec = p.logo && TOOLS[p.logo] && TOOLS[p.logo].icon ? TOOLS[p.logo].icon : p.logo && FORGES[p.logo] ? FORGES[p.logo] : null;
|
|
207
|
+
if (spec && typeof document !== "undefined" && document.createElementNS) {
|
|
208
|
+
const icon = iconSvg(document, spec, 22, { light });
|
|
209
|
+
icon.setAttribute("class", `k-what-logo k-what-logo-${p.logo}`);
|
|
210
|
+
// A mark drawn in its theme's one colour (chant's gold) carries it inline, so no stylesheet's fill greys it.
|
|
211
|
+
if (spec.fill) {
|
|
212
|
+
const gold = light ? spec.fill.light : spec.fill.dark;
|
|
213
|
+
for (const n of icon.querySelectorAll("rect, path, circle, polygon, g")) n.style.fill = gold;
|
|
214
|
+
}
|
|
215
|
+
part.appendChild(icon);
|
|
216
|
+
}
|
|
217
|
+
part.append(el("span", "k-what-full", p.text), el("span", "k-what-short", p.short));
|
|
218
|
+
line.appendChild(part);
|
|
219
|
+
});
|
|
220
|
+
if (line.setAttribute) line.setAttribute("title", whatTitle(tg, hide, own));
|
|
221
|
+
whatStyle();
|
|
222
|
+
return line;
|
|
223
|
+
}
|
|
224
|
+
/** The line's look: half again the old size; on a phone the logos stay and the words shorten. */
|
|
225
|
+
function whatStyle() {
|
|
226
|
+
if (typeof document === "undefined" || !document.head || document.getElementById("k-what-style")) return;
|
|
227
|
+
const st = document.createElement("style");
|
|
228
|
+
st.id = "k-what-style";
|
|
229
|
+
st.textContent = `.k-what-line { display: inline-flex; align-items: center; gap: 0.45em; font-size: 1.5em; font-weight: 600; color: var(--fg); }
|
|
230
|
+
.k-what-part { display: inline-flex; align-items: center; gap: 0.3em; white-space: nowrap; }
|
|
231
|
+
.k-what-logo { width: 1.25em; height: 1.25em; flex: none; }
|
|
232
|
+
/* chant's mark is pixel-sparse in its square: drawn larger, it carries the weight of Forgejo's. */
|
|
233
|
+
.k-what-logo-chant { width: 1.7em; height: 1.7em; }
|
|
234
|
+
.k-what-sep { color: var(--muted); }
|
|
235
|
+
.k-what-short { display: none; }
|
|
236
|
+
@media (max-width: 600px) { .k-what-line { font-size: 1.1em; } .k-what-full { display: none; } .k-what-short { display: inline; } }`;
|
|
237
|
+
document.head.appendChild(st);
|
|
238
|
+
}
|
|
239
|
+
/** Its tooltip: whose pipeline it is, and whose demo. */
|
|
240
|
+
export const WHAT_TITLE = "The pipeline is chant's (chant components pr-plan / pr-apply on Forgejo). The demo stack and its driver are terragucci's.";
|
|
241
|
+
/** behold#741: a terragucci repo's: the pipeline, the stack and the driver are all terragucci's. */
|
|
242
|
+
export const WHAT_TITLE_TG = "The pipeline is terragucci's (its waves, one job per wave). The demo stack and its driver are terragucci's.";
|
|
243
|
+
/** behold#752: chant's own fan-out demo, from its own records: the pipeline, the stack and the driver are all chant's. */
|
|
244
|
+
export const WHAT_TITLE_CHANT = "The pipeline is chant's (chant components pr-plan / pr-apply on Forgejo). The demo stack and its driver are chant's too.";
|
|
245
|
+
/** behold#746: the tooltip, less each sentence a tool's page may not say (`/chant-fanout` keeps whose pipeline it is). */
|
|
246
|
+
export function whatTitle(tg = null, hide = null, own = false) {
|
|
247
|
+
const t = tg ? WHAT_TITLE_TG : own ? WHAT_TITLE_CHANT : WHAT_TITLE;
|
|
248
|
+
return hide ? t.split(/(?<=\.) /).filter((x) => !hide(x)).join(" ") : t;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** behold#631: the step a chant kiosk's strip lights: a wait for approval before the merge is "planned" when the strip has no approval stop. */
|
|
252
|
+
export function railStep(s, demo) {
|
|
253
|
+
const strip = s.strip || STRIP;
|
|
254
|
+
return s.chantLoop && ["waiting", "approved"].includes(demo.step) && !strip.some((x) => x.id === APPROVAL_STOP.id) ? "planned" : demo.step;
|
|
255
|
+
}
|
|
256
|
+
|
|
130
257
|
/** behold#571 (#631): the words of the strip's approval stop, a gate before the merge. */
|
|
131
258
|
export const APPROVAL_STOP = { id: "approval", words: "approval" };
|
|
132
259
|
|
|
@@ -441,6 +568,12 @@ export function runPin(demo) {
|
|
|
441
568
|
return demo.commit || "none";
|
|
442
569
|
}
|
|
443
570
|
|
|
571
|
+
/** The cycle's pull request number for the frame (`pull` view key), or null before one opens and on the base. */
|
|
572
|
+
export function framePull(demo) {
|
|
573
|
+
if (!demo || demo.scenario === "base" || demo.step === "reset") return null;
|
|
574
|
+
return demo.pull !== null && demo.pull !== undefined && /^\d+$/.test(String(demo.pull)) ? String(demo.pull) : null;
|
|
575
|
+
}
|
|
576
|
+
|
|
444
577
|
/** The framed view's address: behold's own page, bare, at a zoom (the resources zoom unless told), told who its host is. */
|
|
445
578
|
export function frameSrc(origin, zoom = "resources", repo = null, theme = null) {
|
|
446
579
|
const q = new URLSearchParams({ embed: "1", bare: "1", zoom, host: origin });
|
|
@@ -522,7 +655,8 @@ export const READ_STORE = "behold.kiosk.read";
|
|
|
522
655
|
export function readingRows(view, tool = null) {
|
|
523
656
|
const root = rootWord(tool);
|
|
524
657
|
const n = rootNoun(tool);
|
|
525
|
-
|
|
658
|
+
// behold#746: a fan-out's page keeps the legend /kiosk shows for it.
|
|
659
|
+
if (reportless(kioskVendorOf(tool))) {
|
|
526
660
|
if (view !== "components") return [{ mark: "box", words: `Box: ${root} with its own state.` }];
|
|
527
661
|
return [
|
|
528
662
|
{ mark: "card", words: `Card: ${root} with its own state.` },
|
|
@@ -709,6 +843,13 @@ export function holdHead({ wave = null, run = null, digest = null, pull = null,
|
|
|
709
843
|
return parts.length ? parts.join(" · ") : null;
|
|
710
844
|
}
|
|
711
845
|
|
|
846
|
+
/** Report minor 34: Inspect's note lines for a cone plan, the same words as Watch's caption (kiosk-watch.js coneCaption); none for any other plan. */
|
|
847
|
+
export function coneLines(demo, answer) {
|
|
848
|
+
const c = coneCaption(demo, answer);
|
|
849
|
+
if (!c) return [];
|
|
850
|
+
return [{ cls: "k-note k-cone-note", text: c.line }, ...(c.backend ? [{ cls: "k-note k-cone-backend", text: c.backend }] : [])];
|
|
851
|
+
}
|
|
852
|
+
|
|
712
853
|
/**
|
|
713
854
|
* behold#571: what the hold panel holds, or null for nothing: how the hold
|
|
714
855
|
* ends (from the records), else the driver's approval, else the run's note.
|
|
@@ -719,9 +860,9 @@ export function holdModel(s, demo) {
|
|
|
719
860
|
if (s.approval) return { kind: "approval", wave: s.approval.wave, head: holdHead({ wave: s.approval.wave, run: s.approval.run, digest: s.approval.digest }), model: s.approval };
|
|
720
861
|
const appr = pendingApproval(demo, s.progress);
|
|
721
862
|
if (appr) return { kind: "driver", wave: appr.wave, head: holdHead({ wave: appr.wave, digest: appr.digest }), appr };
|
|
722
|
-
if (s.noReports || reportless(vendor ||
|
|
863
|
+
if (s.noReports || reportless(vendor || kioskVendorOf(demo.tool))) return null;
|
|
723
864
|
const panel = runPanel(demo, s.answer, s.progress);
|
|
724
|
-
const lines = panel.note ? [{ cls: "k-note", text: panel.note }] : panel.stage === "pull-request" ? unreviewedLines(s.answer).map((u) => ({ cls: "k-note k-unknown", text: u })) : [];
|
|
865
|
+
const lines = panel.note ? [{ cls: "k-note", text: panel.note }] : panel.stage === "pull-request" ? [...coneLines(demo, s.answer), ...unreviewedLines(s.answer).map((u) => ({ cls: "k-note k-unknown", text: u }))] : [];
|
|
725
866
|
if (!lines.length) return null;
|
|
726
867
|
const head = holdHead(panel.stage === "pull-request" ? { pull: demo.pull } : { commit: demo.commit });
|
|
727
868
|
return { kind: "note", wave: null, head, lines };
|
|
@@ -768,12 +909,15 @@ function drawBar(bar, s, now) {
|
|
|
768
909
|
const titleBox = box("title", "k-box-title");
|
|
769
910
|
const over = el("div", "k-overline");
|
|
770
911
|
// behold#571: /kiosk names the tool each scenario runs on, as its own page does.
|
|
771
|
-
|
|
912
|
+
// behold#746: but for a fan-out, whose brand its own page alone carries.
|
|
913
|
+
const shownTool = vendor || (demo.scenario !== "base" ? kioskVendorOf(demo.tool) : null);
|
|
772
914
|
if (shownTool) over.appendChild(brandEl(shownTool));
|
|
773
915
|
over.appendChild(el("span", "k-kicker", head.kicker));
|
|
774
916
|
// The scenario's progress: the strip's stops, at the end of the line over the title.
|
|
775
917
|
const strip = el("ol", "k-strip");
|
|
776
|
-
|
|
918
|
+
// behold#631: a chant pull request's wait for its approval comes before its merge. Without a stop of its own on the
|
|
919
|
+
// strip it shows as "planned", for the fix's pull request as for the first.
|
|
920
|
+
for (const stop of stripStops(railStep(s, demo), s.strip || STRIP)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
777
921
|
over.appendChild(strip);
|
|
778
922
|
const title = el("h1", "k-title");
|
|
779
923
|
title.appendChild(el("span", "k-title-text", head.title));
|
|
@@ -902,13 +1046,28 @@ function drawWatchHead(bar, s, now) {
|
|
|
902
1046
|
const demo = s.demo.demo;
|
|
903
1047
|
const vendor = vendorOf(s.vendor);
|
|
904
1048
|
const place = el("div", "k-w-place");
|
|
905
|
-
const shownTool = vendor || (demo.scenario !== "base" ?
|
|
906
|
-
if (
|
|
907
|
-
|
|
1049
|
+
const shownTool = vendor || (demo.scenario !== "base" ? kioskVendorOf(demo.tool) : null);
|
|
1050
|
+
if (storyOn(s) && s.trackOn) {
|
|
1051
|
+
// behold#631: a chant kiosk names what this is in one line; the cycle number and its clock are Inspect's.
|
|
1052
|
+
// behold#741: a terragucci repo's chapter-carrying scenario names terragucci, its engine and its forge.
|
|
1053
|
+
// behold#746: a tool's page leaves out the parts (and the tooltip's sentence) that name what it may not.
|
|
1054
|
+
// On its replay the line's "live demo" goes; the replay's banner follows the line instead.
|
|
1055
|
+
const hide = vendor ? (t) => namesOther(t, s.vendor) || (s.mode === "replay" && /^live\b/.test(t)) : null;
|
|
1056
|
+
if (s.chantLoop) place.appendChild(whatLineEl(demo, s.chantForge ? s.chantForge() : null, null, hide, s.source === "chant-demo"));
|
|
1057
|
+
else place.appendChild(whatLineEl(demo, s.tgForge || null, { tools: s.tools || [] }, hide));
|
|
1058
|
+
} else {
|
|
1059
|
+
if (shownTool) place.appendChild(brandEl(shownTool));
|
|
1060
|
+
place.appendChild(el("span", "k-cycle", cycleWords(demo, now)));
|
|
1061
|
+
}
|
|
1062
|
+
// behold#746: a tool's page says in Watch too that it replays an earlier run.
|
|
1063
|
+
if (vendor && s.mode === "replay" && s.replay && s.replay.banner) place.appendChild(el("span", "k-cycle k-w-replay", s.replay.banner));
|
|
908
1064
|
bar.appendChild(place);
|
|
909
1065
|
const strip = el("ol", "k-strip");
|
|
910
|
-
|
|
911
|
-
|
|
1066
|
+
// behold#631: a chant pull request's wait for its approval comes before its merge. Without a stop of its own on the
|
|
1067
|
+
// strip it shows as "planned", for the fix's pull request as for the first.
|
|
1068
|
+
for (const stop of stripStops(railStep(s, demo), s.strip || STRIP)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
1069
|
+
// behold#631: a chant kiosk's projected track says where the cycle is; the rail goes.
|
|
1070
|
+
if (!s.trackOn) bar.appendChild(strip);
|
|
912
1071
|
if (s.watchHeld) {
|
|
913
1072
|
const p = el("span", "k-w-held", heldWords(s.watchHeld.secs));
|
|
914
1073
|
const b = el("button", null, FOLLOW_WORDS);
|
|
@@ -929,21 +1088,56 @@ function drawWatchHead(bar, s, now) {
|
|
|
929
1088
|
function drawCaption(host, s, now) {
|
|
930
1089
|
host.replaceChildren();
|
|
931
1090
|
const demo = s.demo && s.demo.demo;
|
|
932
|
-
const cap = captionModel(demo, { vendor: s.vendor || null, now });
|
|
1091
|
+
const cap = captionModel(demo, { vendor: s.vendor || null, now, answer: s.answer });
|
|
933
1092
|
if (!cap) return;
|
|
1093
|
+
if (s.chantCaptionStep) cap.step = s.chantCaptionStep(demo, cap.step);
|
|
934
1094
|
const top = el("div", "k-cap-top");
|
|
935
1095
|
const title = el("h1", "k-cap-title");
|
|
936
|
-
|
|
937
|
-
|
|
1096
|
+
// behold#631: a chant kiosk with its track drops "Scenario 1 of 1": the track says where the cycle is.
|
|
1097
|
+
const told = s.storyDemo ? s.storyDemo(demo) : demo;
|
|
1098
|
+
const ch = storyOn(s) && told && told.chapter && Number.isInteger(told.chapter.n) ? told.chapter : null;
|
|
1099
|
+
if (!(storyOn(s) && s.trackOn)) title.append(el("span", "k-kicker", cap.kicker));
|
|
1100
|
+
if (ch) {
|
|
1101
|
+
// behold#631: the story's chapter is the headline, "1 of 4 · A change to the shared network goes out to all 15 stacks",
|
|
1102
|
+
// fading in when the chapter turns; the scenario's point stays under it as one constant small line.
|
|
1103
|
+
chapterStyle();
|
|
1104
|
+
const words = `${ch.n} of ${ch.of} · ${ch.headline}`;
|
|
1105
|
+
const head = el("span", "k-title-text k-chapter-head", words);
|
|
1106
|
+
if (s.capChapter !== words) {
|
|
1107
|
+
s.capChapter = words;
|
|
1108
|
+
s.capChapterAt = now.getTime ? now.getTime() : Date.now();
|
|
1109
|
+
}
|
|
1110
|
+
const t = now.getTime ? now.getTime() : Date.now();
|
|
1111
|
+
// A redraw mid-fade carries on from where the fade is, never from the start.
|
|
1112
|
+
if (t - (s.capChapterAt || 0) < 900 && head.classList) {
|
|
1113
|
+
head.classList.add("k-chapter-in");
|
|
1114
|
+
if (head.style) head.style.animationDelay = `-${t - s.capChapterAt}ms`;
|
|
1115
|
+
}
|
|
1116
|
+
title.append(head);
|
|
1117
|
+
if (title.setAttribute) title.setAttribute("title", words);
|
|
1118
|
+
} else {
|
|
1119
|
+
title.append(el("span", "k-title-text", cap.title));
|
|
1120
|
+
if (title.setAttribute) title.setAttribute("title", `${cap.kicker} · ${cap.title}`);
|
|
1121
|
+
}
|
|
938
1122
|
top.appendChild(title);
|
|
939
1123
|
if (cap.next) {
|
|
940
1124
|
const nx = el("p", "k-cap-next");
|
|
941
|
-
|
|
942
|
-
|
|
1125
|
+
// behold#631: a chant kiosk says what comes next as one plain sentence in one font: the demo is scripted, and
|
|
1126
|
+
// "plan note" and "the plan's digest" are chant's own terms. A failure's next step reads as the modal's does.
|
|
1127
|
+
if (s.chantLoop) {
|
|
1128
|
+
const action = demo && demo.step === "failed" && /\bfix\b/.test(cap.next.action) ? "the fix opens" : cap.next.action.replace(/\bplan note\b/g, "plan").replace(/\bthe plan's digest\b/g, "the plan");
|
|
1129
|
+
const sentence = `next (scripted): ${action}${/^when\b/.test(cap.next.when) ? ", " : " "}${cap.next.when}`.replace(/\s+/g, " ").trim();
|
|
1130
|
+
nx.append(sentence);
|
|
1131
|
+
if (nx.setAttribute) nx.setAttribute("title", sentence);
|
|
1132
|
+
} else {
|
|
1133
|
+
nx.append("next, by the driver: ", elRoots("span", "k-action", cap.next.action, s), " ", el("span", "k-when", cap.next.when));
|
|
1134
|
+
if (nx.setAttribute) nx.setAttribute("title", `next, by the driver: ${cap.next.action}`);
|
|
1135
|
+
}
|
|
943
1136
|
nx.appendChild(nextBar(demo, now, s));
|
|
944
1137
|
top.appendChild(nx);
|
|
945
1138
|
}
|
|
946
1139
|
host.appendChild(top);
|
|
1140
|
+
if (ch && cap.title) host.appendChild(el("p", "k-cap-point", cap.title));
|
|
947
1141
|
const beat = cap.intro || cap.changes;
|
|
948
1142
|
const changes = el("p", `k-cap-row k-cap-changes${cap.lead === "changes" ? " k-cap-lead" : ""}`);
|
|
949
1143
|
if (beat) {
|
|
@@ -955,6 +1149,54 @@ function drawCaption(host, s, now) {
|
|
|
955
1149
|
step.append(el("span", "k-cap-label", cap.step.word), elRoots("span", "k-cap-text", cap.step.text, s));
|
|
956
1150
|
if (step.setAttribute) step.setAttribute("title", cap.step.text);
|
|
957
1151
|
host.appendChild(step);
|
|
1152
|
+
// Report minor 34: a cone plan, in one quiet line: what it planned, and the estates' backend when the reports say it.
|
|
1153
|
+
if (cap.cone) host.appendChild(coneEl("k-cap-cone", cap.cone));
|
|
1154
|
+
// What used to be a card over the graph (the result, the approval): one quiet line under the label, in the caption.
|
|
1155
|
+
const said = stepLine(demo, { held: !!s.stageHeld, result: demo && demo.step === "applied" ? resultModel(demo, s.metrics, s.steady) : null, hold: demo && (demo.step === "waiting" || demo.step === "approved") ? holdModel(s, demo) : null });
|
|
1156
|
+
if (said) {
|
|
1157
|
+
const p = el("p", "k-cap-quiet k-cap-step-line", said);
|
|
1158
|
+
if (p.setAttribute) {
|
|
1159
|
+
p.setAttribute("data-step-line", demo.step);
|
|
1160
|
+
p.setAttribute("title", said);
|
|
1161
|
+
}
|
|
1162
|
+
host.appendChild(p);
|
|
1163
|
+
}
|
|
1164
|
+
// A long step with nothing new coming in: what runs, and for how long (kiosk-watch.js quietWords).
|
|
1165
|
+
if (s.quiet) {
|
|
1166
|
+
const q = quietEl("k-cap-quiet", s.quiet);
|
|
1167
|
+
if (q.setAttribute) {
|
|
1168
|
+
q.setAttribute("role", "status");
|
|
1169
|
+
q.setAttribute("title", s.quiet.title);
|
|
1170
|
+
}
|
|
1171
|
+
host.appendChild(q);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/** The cone plan's line (kiosk-watch.js coneCaption): the plan's words, then the backend's, quieter. */
|
|
1176
|
+
export function coneEl(cls, c) {
|
|
1177
|
+
const p = el("p", `${cls} k-cone`);
|
|
1178
|
+
if (p.setAttribute) {
|
|
1179
|
+
p.setAttribute("data-cone-line", "");
|
|
1180
|
+
p.setAttribute("title", c.backend ? `${c.line} · ${c.backend}` : c.line);
|
|
1181
|
+
}
|
|
1182
|
+
p.appendChild(el("span", "k-cone-plan", c.line));
|
|
1183
|
+
if (c.backend) p.appendChild(el("span", "k-cone-backend", c.backend));
|
|
1184
|
+
return p;
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/** The corner the framed graph's own controls take at its top right (⤢ fit at 8 px, ↺ layout at 66 px from the right edge, web/index.html), in px. Watch's overlays stay out of it. */
|
|
1188
|
+
export const FRAME_CONTROLS = { w: 240, h: 44 };
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* The quiet line's element: the driver's words, which may be cut short with an
|
|
1192
|
+
* ellipsis, then the running job and the time, always whole. A phone puts the
|
|
1193
|
+
* job and the time on a second line.
|
|
1194
|
+
*/
|
|
1195
|
+
export function quietEl(cls, q) {
|
|
1196
|
+
const p = el("p", `${cls} k-quiet`);
|
|
1197
|
+
if (q.said) p.append(el("span", "k-quiet-said", q.said), el("span", "k-quiet-sep", " · "));
|
|
1198
|
+
p.append(el("span", "k-quiet-tail", q.tail || q.text));
|
|
1199
|
+
return p;
|
|
958
1200
|
}
|
|
959
1201
|
|
|
960
1202
|
/** The approval on the held wave's box: the step's word, the wave, its numbers, and how the hold ends. */
|
|
@@ -1075,7 +1317,8 @@ function box(name, cls = "") {
|
|
|
1075
1317
|
export function approvalPanel(model, s = {}) {
|
|
1076
1318
|
const wrap = el("div", "k-ap");
|
|
1077
1319
|
// behold#571: the hold panel's head names the wave, the run and the plan; this one says what the rows are.
|
|
1078
|
-
|
|
1320
|
+
// behold#631: a chant kiosk's rows carry no times, so its head says none.
|
|
1321
|
+
wrap.appendChild(el("p", "k-ap-head", model.kiosk ? PANEL_TITLE : `${PANEL_TITLE} · times in UTC`));
|
|
1079
1322
|
const list = el("ol", "k-ap-rows");
|
|
1080
1323
|
for (const r of model.rows) {
|
|
1081
1324
|
const li = el("li", `k-ap-row k-ap-${r.state}`);
|
|
@@ -1152,6 +1395,8 @@ export const HELD_JOB_RULE = "background: color-mix(in srgb, var(--foreign) 14%,
|
|
|
1152
1395
|
|
|
1153
1396
|
/** behold#571: how often the approval panel reads the cycle's runs, and the gate ledger (which the server caches 30 s). */
|
|
1154
1397
|
export const APPROVAL_POLL_MS = 4_000;
|
|
1398
|
+
/** behold#631: how often a chant kiosk reads its loop while the apply runs: as often as the graph's frame does. */
|
|
1399
|
+
export const CHANT_APPLY_POLL_MS = 1_500;
|
|
1155
1400
|
export const LEDGER_POLL_MS = 10_000;
|
|
1156
1401
|
|
|
1157
1402
|
/** behold#571: the approval panel's words for the approval the driver gives next, over its command. */
|
|
@@ -1159,6 +1404,8 @@ export const DRIVER_SIGNS = "Next the driver plays a reviewer outside the change
|
|
|
1159
1404
|
|
|
1160
1405
|
/** behold#571: "What is this?" says what behold is; the demo's own intro stays on the card between scenarios. */
|
|
1161
1406
|
export const WHAT_TEXT = "This is behold, a live view of infrastructure. It draws the setup as a graph and shows its pipeline runs, their logs and the approvals they wait for, as they happen. Here it watches a demo pipeline that runs one change through several Terraform states in a loop.";
|
|
1407
|
+
/** behold#752: the same, for chant's fan-out demo, whose stacks are CloudFormation's. */
|
|
1408
|
+
export const WHAT_TEXT_CHANT = "This is behold, a live view of infrastructure. It draws the setup as a graph and shows its pipeline runs, their logs and the approvals they wait for, as they happen. Here it watches chant's pull-request pipeline run one change across fifteen stacks in a loop.";
|
|
1162
1409
|
export const WHAT_DOCS = { text: "behold's documentation", url: "https://intentius.io/behold/" };
|
|
1163
1410
|
|
|
1164
1411
|
/** behold#571: a fade at a box's edge where its text goes on past it. */
|
|
@@ -1183,6 +1430,8 @@ export const FRAME_BOOT_WAIT_MS = 4_000;
|
|
|
1183
1430
|
|
|
1184
1431
|
/** How often the kiosk asks for demo.json. The server shares one read between kiosks. */
|
|
1185
1432
|
export const DEMO_POLL_MS = 3_000;
|
|
1433
|
+
/** behold#631: the room a chant cycle's graph always leaves at its right for the side panels (the approval card, the result card), in px. */
|
|
1434
|
+
export const CHANT_SIDE_ROOM = 520;
|
|
1186
1435
|
|
|
1187
1436
|
/**
|
|
1188
1437
|
* Boot the kiosk: the bar, the frame and the graph pane's legend. Ask demo.json every few
|
|
@@ -1191,8 +1440,10 @@ export const DEMO_POLL_MS = 3_000;
|
|
|
1191
1440
|
* countdown. When the roots the step is about change, move the framed view
|
|
1192
1441
|
* with a `behold:view` message; the frame takes them only from this origin.
|
|
1193
1442
|
*/
|
|
1194
|
-
export function startKiosk({ bar, frame, side, main, views, read = null, tools = null, watch = null, eh = null }, { fetchJson = defaultFetch, now = () => new Date(), origin = location.origin, tool = null } = {}) {
|
|
1195
|
-
|
|
1443
|
+
export function startKiosk({ bar, frame, side, main, views, read = null, tools = null, watch = null, eh = null }, { fetchJson = defaultFetch, now = () => new Date(), origin = location.origin, tool = null, source = null } = {}) {
|
|
1444
|
+
// behold#752: terragucci's loop, or chant's fan-out demo from its own records (web/kiosk-source.js).
|
|
1445
|
+
const reads = readsFor(source);
|
|
1446
|
+
const s = { source: reads.source, demo: null, answer: null, progress: null, components: false, pick: null, view: "resources", roots: [], waves: [], light: false, hover: null, frameHover: null, held: null };
|
|
1196
1447
|
// behold#571: Watch or Inspect, the viewer's pick kept in their browser; Watch until they pick Inspect.
|
|
1197
1448
|
const shelf = typeof localStorage !== "undefined" ? (() => { try { return localStorage; } catch { return null; } })() : null;
|
|
1198
1449
|
s.metrics = null;
|
|
@@ -1272,11 +1523,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1272
1523
|
const roots = d ? focusRoots(d, s.answer, s.progress) : null;
|
|
1273
1524
|
const focus = roots ? roots.join(",") : null;
|
|
1274
1525
|
const run = d ? runPin(d) : "base";
|
|
1526
|
+
// The cycle's pull request, so a merge's frame never draws another cycle's plan (web/terragucci-change.js pinnedAnswer).
|
|
1527
|
+
const pull = framePull(d);
|
|
1275
1528
|
const zoom = viewZoom(shownView().view);
|
|
1276
|
-
const key = `${focus}|${run}|${zoom}`;
|
|
1529
|
+
const key = `${focus}|${run}|${pull}|${zoom}`;
|
|
1277
1530
|
if (!force && key === lastFocus) return;
|
|
1278
1531
|
lastFocus = key;
|
|
1279
|
-
post({ type: "behold:view", member: null, focus, run, zoom });
|
|
1532
|
+
post({ type: "behold:view", member: null, focus, run, pull, zoom });
|
|
1280
1533
|
tellHover(s.hover);
|
|
1281
1534
|
};
|
|
1282
1535
|
const pickView = (view) => {
|
|
@@ -1404,6 +1657,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1404
1657
|
const draw = () => {
|
|
1405
1658
|
followRepo();
|
|
1406
1659
|
replayTick();
|
|
1660
|
+
// behold#741: the story gate for this step, and the frame told so (it draws the wedge, the blocks and the paced waves).
|
|
1661
|
+
{
|
|
1662
|
+
const d = s.demo && s.demo.demo;
|
|
1663
|
+
s.tgStory = storyGate({ chantLoop: s.chantLoop, terragucciRepo: s.tgRepo, demo: d }) === "terragucci";
|
|
1664
|
+
// behold#743: and the step's apply made outside the pipeline, which the frame draws on its estate's card.
|
|
1665
|
+
if (s.tgRepo) post({ type: "behold:story", on: s.tgStory, cycle: d && Number.isInteger(d.cycle) ? d.cycle : null, outside: (s.tgStory && d && d.outside) || null });
|
|
1666
|
+
}
|
|
1407
1667
|
s.light = typeof document !== "undefined" && document.documentElement ? isLightBg(getComputedStyle(document.documentElement).getPropertyValue("--bg")) : false;
|
|
1408
1668
|
s.rootNames = rootList();
|
|
1409
1669
|
const shown = shownView();
|
|
@@ -1439,6 +1699,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1439
1699
|
}
|
|
1440
1700
|
// behold#571: Watch's overlays, then the shot they leave room for.
|
|
1441
1701
|
holdTick();
|
|
1702
|
+
if (s.quietTick) s.quietTick();
|
|
1442
1703
|
drawWatch(shownNow());
|
|
1443
1704
|
renderViewToggle(views, shown, { components: s.components && ok, onPick: pickView });
|
|
1444
1705
|
drawReading(shown.view, ok);
|
|
@@ -1526,9 +1787,11 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1526
1787
|
}
|
|
1527
1788
|
/** The caption shown now: Watch's own, or the live carve's while it has the camera (#715). */
|
|
1528
1789
|
const shownCaption = () => (carveCtl && carveCtl.caption ? carveCtl.caption() || watch.caption : watch.caption);
|
|
1790
|
+
/** behold#631: a chant kiosk's projected track (drawChantTrack), in the trail's place. */
|
|
1791
|
+
let trackHost = null;
|
|
1529
1792
|
/** behold#571: the caption's top, or event-help's trail's when it sits over the caption. */
|
|
1530
1793
|
const captionTop = (cap) => {
|
|
1531
|
-
const trail = eh && eh.trailHost;
|
|
1794
|
+
const trail = trackHost && !trackHost.hidden ? trackHost : eh && eh.trailHost;
|
|
1532
1795
|
const r = trail && !trail.hidden && trail.getBoundingClientRect ? trail.getBoundingClientRect() : null;
|
|
1533
1796
|
return r && r.height && r.top < cap.top ? r.top : cap.top;
|
|
1534
1797
|
};
|
|
@@ -1540,9 +1803,31 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1540
1803
|
const bottom = Math.max(0, f.bottom - captionTop(cap)) + 16;
|
|
1541
1804
|
const side = shot.kind === "held" ? watch.callout : shot.kind === "active" ? watch.drawer : shot.kind === "result" ? watch.result : null;
|
|
1542
1805
|
// The result card sits right beside the graph (placeBeside's gap): an inset of its width and that gap centres the two together.
|
|
1543
|
-
const
|
|
1806
|
+
const measured = side && !side.hidden && side.offsetWidth ? side.offsetWidth + (shot.kind === "result" ? 18 : 44) : 0;
|
|
1807
|
+
// behold#631: a chant cycle keeps one framing from start to end: the side panel's room is kept whether or not one is up, so the graph never shifts.
|
|
1808
|
+
const right = s.chantLoop ? Math.max(measured, CHANT_SIDE_ROOM) : measured;
|
|
1544
1809
|
return { top: 20, right, bottom, left: 20 };
|
|
1545
1810
|
};
|
|
1811
|
+
/**
|
|
1812
|
+
* The tallest the caption gets in a cycle, as a bottom inset in px (kiosk-watch.js captionRoom), measured from the
|
|
1813
|
+
* caption as it is: a held small stage keeps this room from the first step, so the cone line, the step line, the
|
|
1814
|
+
* quiet line or the trail that comes later moves nothing. None on a phone, where the caption is under the graph.
|
|
1815
|
+
*/
|
|
1816
|
+
function captionRoomPx() {
|
|
1817
|
+
if (!watch || !frame || isPhone() || !frame.getBoundingClientRect || typeof getComputedStyle !== "function") return 0;
|
|
1818
|
+
const f = frame.getBoundingClientRect();
|
|
1819
|
+
const cap = watch.caption;
|
|
1820
|
+
const c = cap.getBoundingClientRect();
|
|
1821
|
+
const fs = parseFloat(getComputedStyle(cap).fontSize) || 16;
|
|
1822
|
+
const gap = fs * 0.25;
|
|
1823
|
+
const extras = [...cap.querySelectorAll(":scope > .k-cap-cone, :scope > .k-cap-quiet")].map((n) => n.getBoundingClientRect().height + gap);
|
|
1824
|
+
const rowH = extras.length ? Math.max(...extras) : fs * 0.92 * 1.35 + gap;
|
|
1825
|
+
const trail = eh && eh.trailHost && !eh.trailHost.hidden ? eh.trailHost.getBoundingClientRect() : null;
|
|
1826
|
+
const trailH = trail && trail.height && trail.top < c.top ? c.top - trail.top : 0;
|
|
1827
|
+
const chip = eh && eh.trailHost ? eh.trailHost.querySelector(".eh-chip") : null;
|
|
1828
|
+
const trailLineH = chip ? chip.getBoundingClientRect().height + 4 : 26;
|
|
1829
|
+
return captionRoom({ capHeight: c.height, extras, rowH, trailH, trailLineH, below: Math.max(0, f.bottom - c.bottom) });
|
|
1830
|
+
}
|
|
1546
1831
|
function tellShot(force) {
|
|
1547
1832
|
if (!frame || !frame.contentWindow || !watch) return;
|
|
1548
1833
|
if (!s.watchMode) {
|
|
@@ -1554,25 +1839,75 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1554
1839
|
}
|
|
1555
1840
|
if (s.watchHeld || !s.shot) return;
|
|
1556
1841
|
const insets = shotInsets(s.shot);
|
|
1557
|
-
|
|
1842
|
+
// The caption's tallest, for a held small stage's one framing; a stage that isn't held never reads it.
|
|
1843
|
+
const room = captionRoomPx();
|
|
1844
|
+
const key = `${s.shot.id}|${insets.right || 0}|${Math.round((insets.bottom || 0) / 12)}|${s.shot.roots.join(",")}|${Math.round(room / 12)}`;
|
|
1558
1845
|
if (!force && key === lastShot) return;
|
|
1559
1846
|
lastShot = key;
|
|
1560
|
-
post(shotMessage({ roots: s.shot.roots, waves: s.shot.waves, whole: s.shot.whole, insets, id: s.shot.id }));
|
|
1847
|
+
post(shotMessage({ roots: s.shot.roots, waves: s.shot.waves, whole: s.shot.whole, insets, id: s.shot.id, room }));
|
|
1848
|
+
}
|
|
1849
|
+
// behold#631: the projected cycle track, a chant kiosk's bottom band in place of the chip strip and the rail.
|
|
1850
|
+
const trackState = { cycle: null, pulls: [], key: null, since: null };
|
|
1851
|
+
function drawChantTrack(d, at) {
|
|
1852
|
+
if (!trackHost && eh && eh.trailHost && eh.trailHost.parentNode && typeof document !== "undefined") {
|
|
1853
|
+
trackHost = document.createElement("div");
|
|
1854
|
+
trackHost.id = "k-track";
|
|
1855
|
+
trackHost.hidden = true;
|
|
1856
|
+
eh.trailHost.parentNode.insertBefore(trackHost, eh.trailHost);
|
|
1857
|
+
}
|
|
1858
|
+
const t = at instanceof Date ? at.getTime() : now().getTime();
|
|
1859
|
+
const track = storyOn(s) && d ? cycleTrack(s.lastCycle()) : null;
|
|
1860
|
+
s.trackOn = !!track;
|
|
1861
|
+
if (!trackHost) return;
|
|
1862
|
+
if (!track) {
|
|
1863
|
+
s.trackModel = null;
|
|
1864
|
+
drawTrack(trackHost, null);
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
// This cycle's pull requests in the order it opened them; the reset closes the last.
|
|
1868
|
+
if (trackState.cycle !== d.cycle) Object.assign(trackState, { cycle: d.cycle, pulls: [], key: null, since: null });
|
|
1869
|
+
// The story's step, which may be a chapter ahead of demo.json's (s.storyDemo).
|
|
1870
|
+
d = s.storyDemo ? s.storyDemo(d) : d;
|
|
1871
|
+
if (Number.isInteger(d.pull) && !trackState.pulls.includes(d.pull)) trackState.pulls.push(d.pull);
|
|
1872
|
+
const live = s.chantLoop ? (s.chantWavesNow ? s.chantWavesNow(d) : null) : s.tgWavesNow ? s.tgWavesNow(d) : null;
|
|
1873
|
+
// When the current segment began: the step's own start where demo.json says it, else when the kiosk first saw it.
|
|
1874
|
+
const probe = trackModel(track, { demo: d, pulls: trackState.pulls, since: t, now: t });
|
|
1875
|
+
const key = probe ? `${probe.at.chapter}|${probe.at.segment}` : null;
|
|
1876
|
+
if (key !== trackState.key) {
|
|
1877
|
+
const from = !d.storyAhead && d.next && d.next.from ? Date.parse(d.next.from) : NaN;
|
|
1878
|
+
trackState.key = key;
|
|
1879
|
+
trackState.since = Number.isFinite(from) && from <= t && t - from < 600_000 ? from : t;
|
|
1880
|
+
}
|
|
1881
|
+
const model = trackModel(track, { demo: d, pulls: trackState.pulls, since: trackState.since, now: t, waves: live ? live.waves : null });
|
|
1882
|
+
s.trackModel = model;
|
|
1883
|
+
drawTrack(trackHost, model);
|
|
1884
|
+
// In the trail's place: over the caption.
|
|
1885
|
+
const cap = shownCaption().getBoundingClientRect();
|
|
1886
|
+
if (trackHost.style) trackHost.style.bottom = cap.height ? `${Math.round((typeof window !== "undefined" ? window.innerHeight : 0) - cap.top)}px` : "";
|
|
1887
|
+
// The "Waiting on…" modal: a quiet stretch on a step that waits on something, never while the apply's events come in.
|
|
1888
|
+
// Once the play shows anything of this run under way (a wave or a card), nothing waits on the apply to start.
|
|
1889
|
+
// behold#741: a terragucci apply is under way once any wave of its run view has moved.
|
|
1890
|
+
const applyLive = !!(live && (live.live ? live.waves.some((w) => w.state !== "waiting") || Object.values(live.live.components || {}).some((c) => !["waiting", "planned", "planning"].includes(c.state)) : live.tg && live.waves.some((w) => w.state !== "waiting")));
|
|
1891
|
+
s.waitingNow = waitingSpec(model, { quietMs: s.quietFor || 0, applyLive });
|
|
1561
1892
|
}
|
|
1562
1893
|
function drawWatch(at) {
|
|
1563
1894
|
if (!watch || !s.watchMode) return;
|
|
1564
1895
|
const d = s.demo && s.demo.demo;
|
|
1565
1896
|
drawCaption(watch.caption, s, at);
|
|
1897
|
+
drawChantTrack(d, at);
|
|
1566
1898
|
const hold = d ? holdModel(s, d) : null;
|
|
1567
1899
|
const gate = !!hold && (hold.kind === "approval" || hold.kind === "driver");
|
|
1568
1900
|
const shot = shotFor(d, { answer: s.answer, progress: s.progress, held: s.held, gate, runDoc: runsApi && runsApi.run ? runsApi.run.doc : null, waves: s.waves });
|
|
1569
1901
|
s.shot = shot;
|
|
1570
1902
|
const nums = waveBadges(s.metrics);
|
|
1571
|
-
const
|
|
1903
|
+
const opened = drawerWave !== null;
|
|
1904
|
+
// On a held small stage nothing overlays the graph (web/kiosk-watch.js watchOverlays): the approval, the result and the
|
|
1905
|
+
// running job are the caption's quiet lines there. Any other stage shows its cards as it always has.
|
|
1906
|
+
const shows = watchOverlays({ kind: shot.kind, opened, held: !!s.stageHeld });
|
|
1907
|
+
const call = shows.callout && shot.kind === "held" && gate;
|
|
1572
1908
|
watch.callout.hidden = !call;
|
|
1573
1909
|
if (call) drawCallout(watch.callout, s, hold, badgeTitle(nums[hold.wave]));
|
|
1574
|
-
const
|
|
1575
|
-
const drawer = shot.kind === "active" || opened;
|
|
1910
|
+
const drawer = shows.drawer;
|
|
1576
1911
|
const drawerOn = opened ? drawerWave : shot.waves[0];
|
|
1577
1912
|
const open = drawer && (drawerOpen || drawerHover || opened);
|
|
1578
1913
|
watch.drawer.hidden = !drawer;
|
|
@@ -1584,7 +1919,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1584
1919
|
if (drawer) drawDrawer(watch.drawer, tail, badgeTitle(nums[drawerOn]), open);
|
|
1585
1920
|
if (drawer) traceDrawer(d, drawerOn);
|
|
1586
1921
|
// A drawer the viewer opened on a wave takes the card's place beside the graph until it folds.
|
|
1587
|
-
const result = shot.kind === "result" && !opened ? resultModel(d, s.metrics, s.steady) : null;
|
|
1922
|
+
const result = shows.result && shot.kind === "result" && !opened ? resultModel(d, s.metrics, s.steady) || (s.chantResult ? s.chantResult(d) : null) : null;
|
|
1588
1923
|
watch.result.hidden = !result;
|
|
1589
1924
|
if (result) drawResult(watch.result, result, s);
|
|
1590
1925
|
// On a phone the delivery numbers stack under the rest, where the header has no room for them.
|
|
@@ -1596,8 +1931,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1596
1931
|
foot.textContent = doraLine(s.metrics) || "";
|
|
1597
1932
|
watch.badges.replaceChildren();
|
|
1598
1933
|
const skip = call ? hold.wave : drawer ? drawerOn : null;
|
|
1599
|
-
// At applied the result card lists every wave's numbers, so the boxes carry none.
|
|
1600
|
-
for (const [n, words] of shot.kind === "result" && result ? [] : Object.entries(nums)) {
|
|
1934
|
+
// At applied the result card lists every wave's numbers, so the boxes carry none; a held small stage carries none at all.
|
|
1935
|
+
for (const [n, words] of !shows.badges || (shot.kind === "result" && result) ? [] : Object.entries(nums)) {
|
|
1601
1936
|
if (Number(n) === skip) continue;
|
|
1602
1937
|
const b = el("span", "k-badge", words);
|
|
1603
1938
|
b.dataset.kWave = n;
|
|
@@ -1658,14 +1993,17 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1658
1993
|
};
|
|
1659
1994
|
const taken = [];
|
|
1660
1995
|
// While the live carve has the camera, the graph shows dots, not the wave boxes: the panes sit at the view's top right.
|
|
1661
|
-
|
|
1996
|
+
// On a held small stage a drawer the viewer opened sits at the stage top right.
|
|
1997
|
+
const carvingNow = shownCaption() !== watch.caption || !!s.stageHeld;
|
|
1662
1998
|
const put = (node, n) => {
|
|
1663
1999
|
if (node.hidden) return;
|
|
1664
2000
|
const size = { w: node.offsetWidth, h: node.offsetHeight };
|
|
1665
2001
|
const box = carvingNow ? null : boxOf(n);
|
|
1666
2002
|
// Before the frame says where the box is: the right of the view, under its top.
|
|
1667
|
-
|
|
1668
|
-
const
|
|
2003
|
+
// The frame's own controls at its top right (⤢ fit, ↺ layout: web/index.html) are kept clear too.
|
|
2004
|
+
const chrome = { x: view.x + view.w - FRAME_CONTROLS.w, y: view.y, w: FRAME_CONTROLS.w, h: FRAME_CONTROLS.h };
|
|
2005
|
+
const labels = [...((s.boxes && s.boxes.labels) || []).map((r) => ({ x: r.x + view.x, y: r.y + view.y, w: r.w, h: r.h })), chrome];
|
|
2006
|
+
const p = box ? placeBeside(box, size, view, 18, labels) : { x: view.x + view.w - size.w - 20, y: view.y + FRAME_CONTROLS.h + 8, side: "below" };
|
|
1669
2007
|
// The result card stands level with the middle of the graph it sums up.
|
|
1670
2008
|
if (box && node === watch.result) p.y = Math.max(view.y + 8, Math.min(box.y + box.h / 2 - size.h / 2, view.y + view.h - size.h - 8));
|
|
1671
2009
|
node.style.transform = `translate(${Math.round(p.x)}px, ${Math.round(p.y)}px)`;
|
|
@@ -1704,6 +2042,14 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1704
2042
|
if (e.data.type === "behold:viewer") return holdShot();
|
|
1705
2043
|
if (e.data.type !== "behold:boxes") return;
|
|
1706
2044
|
s.boxes = e.data;
|
|
2045
|
+
// A held small stage: nothing the step shows overlays the graph (watchOverlays), and a drawer the viewer opens
|
|
2046
|
+
// sits at the stage's top right, not by a box. body.k-held says so, for a check from outside.
|
|
2047
|
+
const held = !!e.data.held;
|
|
2048
|
+
if (held !== !!s.stageHeld) {
|
|
2049
|
+
s.stageHeld = held;
|
|
2050
|
+
if (document.body && document.body.classList) document.body.classList.toggle("k-held", held);
|
|
2051
|
+
draw();
|
|
2052
|
+
}
|
|
1707
2053
|
if (ehApi) ehApi.follow();
|
|
1708
2054
|
if (queued) return;
|
|
1709
2055
|
queued = true;
|
|
@@ -1772,7 +2118,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1772
2118
|
return {
|
|
1773
2119
|
demo: d,
|
|
1774
2120
|
answer: s.answer,
|
|
1775
|
-
|
|
2121
|
+
// behold#741: told at the pace the graph plays the waves, while a terragucci story is on.
|
|
2122
|
+
progress: s.tgStory && s.tgPaced ? s.tgPaced() : s.steady,
|
|
1776
2123
|
runDoc: runsApi && runsApi.run ? runsApi.run.doc : null,
|
|
1777
2124
|
// The cycle's runs the approval panel reads, for the failures of runs the pane no longer shows.
|
|
1778
2125
|
runDocs: ap.list,
|
|
@@ -1780,6 +2127,15 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1780
2127
|
metrics: s.metrics,
|
|
1781
2128
|
waves: s.waves,
|
|
1782
2129
|
boxes: s.boxes,
|
|
2130
|
+
// behold#631: a chant repo's pull-request loop, whose story Tips tell its own way.
|
|
2131
|
+
chant: !!s.chantLoop,
|
|
2132
|
+
// behold#741: a terragucci repo's chapter-carrying scenario gets the kiosk's look (one tip at a time, modals
|
|
2133
|
+
// off the cards and above the band) but keeps its own story order: its gates come after the merge.
|
|
2134
|
+
story: storyOn(s),
|
|
2135
|
+
// Its projected track replaces the chip strip, and its quiet stretches get a "Waiting on…" modal,
|
|
2136
|
+
// which the approval card beside the graph wins over.
|
|
2137
|
+
hideTrail: !!(storyOn(s) && s.trackOn && s.watchMode),
|
|
2138
|
+
waiting: storyOn(s) && s.watchMode && !(watch && watch.callout && !watch.callout.hidden) ? s.waitingNow || null : null,
|
|
1783
2139
|
frame,
|
|
1784
2140
|
watch: s.watchMode,
|
|
1785
2141
|
// The caption shown now: the live carve's while it has the camera (web/kiosk-carve.js).
|
|
@@ -1787,7 +2143,9 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1787
2143
|
replay: s.mode === "replay",
|
|
1788
2144
|
approveLine: appr ? appr.approve : null,
|
|
1789
2145
|
label: d.label || "",
|
|
1790
|
-
result: resultModel(d, s.metrics, s.steady),
|
|
2146
|
+
result: resultModel(d, s.metrics, s.steady) || (s.chantResult ? s.chantResult(d) : null),
|
|
2147
|
+
// A held small stage (one framing): no modal and no Tips bubble over the graph in Watch there.
|
|
2148
|
+
held: !!s.stageHeld,
|
|
1791
2149
|
waveTraces: s.waveTraces,
|
|
1792
2150
|
strip: s.stripReady() ? s.strip : null,
|
|
1793
2151
|
stripReady: s.stripReady(),
|
|
@@ -1834,7 +2192,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1834
2192
|
drawerWave = null;
|
|
1835
2193
|
drawerView = null;
|
|
1836
2194
|
}
|
|
1837
|
-
|
|
2195
|
+
// behold#752: chant's demo has no forge runs for Tempo to have traced.
|
|
2196
|
+
if (tracesBusy || reads.own || !d || !d.repo || !runsApi || !runsApi.index || !runsApi.index.doc) return;
|
|
1838
2197
|
if (!["merged", "applying", "waiting", "approved", "failed", "resumed", "applied"].includes(d.step)) return;
|
|
1839
2198
|
tracesBusy = true;
|
|
1840
2199
|
try {
|
|
@@ -1865,6 +2224,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1865
2224
|
// behold#571 (#631): the strip in the running tool's own order, from its recorded cycle's steps; the default until it is read.
|
|
1866
2225
|
const strips = new Map();
|
|
1867
2226
|
s.strip = null;
|
|
2227
|
+
/** behold#631: the running tool's last finished cycle, when one is published. */
|
|
2228
|
+
s.lastCycle = () => {
|
|
2229
|
+
const d = s.demo && s.demo.demo;
|
|
2230
|
+
const t = vendor ? tool : d && typeof d.tool === "string" ? d.tool : null;
|
|
2231
|
+
const r = t ? strips.get(t) : null;
|
|
2232
|
+
return r && r.cycle ? r.cycle : null;
|
|
2233
|
+
};
|
|
1868
2234
|
/** Whether the running tool's step order has been read (or there is none to read), so the story can be told in it. */
|
|
1869
2235
|
s.stripReady = () => {
|
|
1870
2236
|
const d = s.demo && s.demo.demo;
|
|
@@ -1885,10 +2251,11 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1885
2251
|
}
|
|
1886
2252
|
return;
|
|
1887
2253
|
}
|
|
1888
|
-
strips.set(t, { at: now().getTime(), strip: had ? had.strip : null, done: had ? had.done : false });
|
|
1889
|
-
const a = await fetchServed(
|
|
2254
|
+
strips.set(t, { at: now().getTime(), strip: had ? had.strip : null, done: had ? had.done : false, cycle: had ? had.cycle : null });
|
|
2255
|
+
const a = await fetchServed(reads.cycle(t));
|
|
1890
2256
|
const strip = a && a.cycle && Array.isArray(a.cycle.steps) ? stripFromSteps(a.cycle.steps.map((x) => x.step)) : null;
|
|
1891
|
-
|
|
2257
|
+
// behold#631: the cycle itself too, for a chant kiosk's projected track.
|
|
2258
|
+
strips.set(t, { at: now().getTime(), strip: strip || (had ? had.strip : null), done: true, cycle: a && a.cycle ? a.cycle : had ? had.cycle : null });
|
|
1892
2259
|
s.strip = strips.get(t).strip;
|
|
1893
2260
|
draw();
|
|
1894
2261
|
};
|
|
@@ -1902,13 +2269,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1902
2269
|
// behold#571: on a tool's page the runs pane shows the tool's repo alone; in the replay, the cycle's runs as they stood.
|
|
1903
2270
|
const runDocs = new Map();
|
|
1904
2271
|
const runDoc = (id) => {
|
|
1905
|
-
if (!runDocs.has(id)) runDocs.set(id, fetchJson(
|
|
2272
|
+
if (!runDocs.has(id)) runDocs.set(id, fetchJson(reads.run(id)).then((a) => (a && a.doc ? a.doc : null)));
|
|
1906
2273
|
return runDocs.get(id);
|
|
1907
2274
|
};
|
|
1908
2275
|
const replayRuns = async () => {
|
|
1909
2276
|
const r = s.replay;
|
|
1910
2277
|
if (r.runs) return r.runs;
|
|
1911
|
-
const idx = await fetchJson(
|
|
2278
|
+
const idx = await fetchJson(reads.runs);
|
|
1912
2279
|
const listed = new Map((idx && idx.doc && Array.isArray(idx.doc.runs) ? idx.doc.runs : []).map((x) => [x.id, x]));
|
|
1913
2280
|
const runs = [];
|
|
1914
2281
|
for (const id of r.cycle.runs) {
|
|
@@ -1935,25 +2302,31 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1935
2302
|
const d = s.demo && s.demo.demo;
|
|
1936
2303
|
if (!d || !(PANEL_STEPS.includes(d.step) || (s.chantLoop && CHANT_PANEL_STEPS.includes(d.step))) || ap.busy) return;
|
|
1937
2304
|
const t = now().getTime();
|
|
1938
|
-
|
|
2305
|
+
// behold#631: a new step reads at once (the applied step's card shows the moment the play ends, not a poll later).
|
|
2306
|
+
const stepKey = `${d.cycle}|${d.pull}|${d.step}`;
|
|
2307
|
+
// While a chant apply runs, read every CHANT_APPLY_POLL_MS so the panel, the track and the waiting modal follow the graph's play.
|
|
2308
|
+
const every = s.chantLoop && ["merged", "applying", "resumed"].includes(d.step) ? CHANT_APPLY_POLL_MS : APPROVAL_POLL_MS;
|
|
2309
|
+
if (t - ap.at < every && !(s.chantLoop && ap.stepKey !== stepKey)) return;
|
|
2310
|
+
ap.stepKey = stepKey;
|
|
1939
2311
|
ap.busy = true;
|
|
1940
2312
|
ap.at = t;
|
|
1941
2313
|
try {
|
|
1942
2314
|
const src = runsSource();
|
|
1943
|
-
const raw = src ? await src.index() : await fetchJson(
|
|
2315
|
+
const raw = src ? await src.index() : await fetchJson(reads.runs);
|
|
1944
2316
|
const idx = vendor ? filterIndex(raw, { tool, repo: s.repo }) : raw;
|
|
1945
2317
|
const mine = cycleRuns(idx && idx.doc && Array.isArray(idx.doc.runs) ? idx.doc.runs : [], d);
|
|
1946
2318
|
for (const e of mine) {
|
|
1947
2319
|
const key = `${s.mode}|${e.status}|${e.ended_at}|${src ? Math.floor(shownNow().getTime() / 5000) : ""}`;
|
|
1948
2320
|
const had = ap.runs.get(e.id);
|
|
1949
2321
|
if (had && had.key === key) continue;
|
|
1950
|
-
const r = src ? await src.run(e.id) : await fetchJson(
|
|
2322
|
+
const r = src ? await src.run(e.id) : await fetchJson(reads.run(e.id));
|
|
1951
2323
|
if (r && r.doc) ap.runs.set(e.id, { key, doc: mergeRun(e, r.doc) });
|
|
1952
2324
|
}
|
|
1953
2325
|
ap.list = mine.map((e) => ap.runs.get(e.id)).filter(Boolean).map((x) => x.doc);
|
|
1954
2326
|
if (t - ap.ledgerAt >= LEDGER_POLL_MS) {
|
|
1955
2327
|
ap.ledgerAt = t;
|
|
1956
|
-
|
|
2328
|
+
// behold#752: chant's demo has no terragucci lane; the gate ledger is chant/lifecycle's alone.
|
|
2329
|
+
const [lifecycle, history] = await Promise.all([reads.own ? null : fetchJson("/api/terragucci/lifecycle"), fetchJson("/api/lifecycle/history?limit=200")]);
|
|
1957
2330
|
ap.lifecycle = lifecycle && !lifecycle.error ? lifecycle : null;
|
|
1958
2331
|
ap.history = history && !history.error ? history : null;
|
|
1959
2332
|
}
|
|
@@ -1968,10 +2341,99 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1968
2341
|
}
|
|
1969
2342
|
draw();
|
|
1970
2343
|
};
|
|
2344
|
+
// behold#631: a fast chant apply played at the pace the graph plays it (web/chant-live-pace.js).
|
|
2345
|
+
const chantPacer = createLivePacer();
|
|
2346
|
+
// behold#631: the result card at a chant repo's applied step, from the apply's run events.
|
|
2347
|
+
s.chantResult = (d) => {
|
|
2348
|
+
if (!s.chantLoop || !ap.chant) return null;
|
|
2349
|
+
const a = chantPacer.answer(ap.chant);
|
|
2350
|
+
// Held, as the caption is, until the paced play reaches the end: never a card that counts "0 applied this run".
|
|
2351
|
+
if (chantPacer.pending || !(a.live && a.live.apply && a.live.apply.settled)) return null;
|
|
2352
|
+
return chantResultModel(d, a);
|
|
2353
|
+
};
|
|
2354
|
+
// behold#631: a chant repo's failed and applied steps are told by the graph's paced play: the caption's step line waits
|
|
2355
|
+
// for the play to reach them, and shows the step before until then. The strip still moves.
|
|
2356
|
+
let capShown = null;
|
|
2357
|
+
/** behold#631: the apply's waves as the paced graph shows them now, for the track's ticks; null for another pull request's apply. */
|
|
2358
|
+
s.chantWavesNow = (demo) => {
|
|
2359
|
+
if (!s.chantLoop || !ap.chant || !ap.chant.live || !ap.chant.live.apply) return null;
|
|
2360
|
+
if (demo && Number.isInteger(demo.pull) && Number.isInteger(ap.chant.pull) && demo.pull !== ap.chant.pull) return null;
|
|
2361
|
+
const a = chantPacer.answer(ap.chant);
|
|
2362
|
+
return { waves: graphWaves(a.live.apply).map((w) => ({ wave: w.wave, state: w.state })), live: a.live.apply };
|
|
2363
|
+
};
|
|
2364
|
+
// behold#741: a terragucci story's run view, its waves played at the pace chant's are (web/terragucci-live-pace.js).
|
|
2365
|
+
const tgPacer = createProgressPacer();
|
|
2366
|
+
s.tgPaced = () => tgPacer.progress(s.steady);
|
|
2367
|
+
/** behold#741: the run view's waves as the paced graph shows them now, for the track's ticks; null off a terragucci story. */
|
|
2368
|
+
s.tgWavesNow = (demo) => {
|
|
2369
|
+
if (!s.tgStory || !demo || !["merged", "applying", "resumed", "waiting", "approved", "failed", "applied"].includes(demo.step)) return null;
|
|
2370
|
+
const p = s.tgPaced();
|
|
2371
|
+
// Another commit's run view (the change's, while the fix's apply starts) says nothing of this step's.
|
|
2372
|
+
const c = p && p.run && typeof p.run.commit === "string" ? p.run.commit : null;
|
|
2373
|
+
if (c && typeof demo.commit === "string" && demo.commit && !(c.startsWith(demo.commit) || demo.commit.startsWith(c))) return null;
|
|
2374
|
+
const waves = trackWaves(p);
|
|
2375
|
+
if (!waves || !waves.length) return null;
|
|
2376
|
+
const failed = waves.some((w) => w.state === "failed");
|
|
2377
|
+
const done = !tgPacer.pending && !!p && p.watching === false && waves.every((w) => w.state === "applied");
|
|
2378
|
+
return { waves, live: null, tg: true, failed, done };
|
|
2379
|
+
};
|
|
2380
|
+
/**
|
|
2381
|
+
* behold#631: the step as the story tells it now. The driver writes the failed step only once the apply job ends,
|
|
2382
|
+
* seconds after the paced graph has shown the failure, and the applied step after the fix's apply ends. So when the
|
|
2383
|
+
* play reaches a failure, or finishes the fix's apply, while demo.json still names the apply's chapter, the story
|
|
2384
|
+
* moves to the next chapter of the last cycle (its headline, and its first step for the track). demo.json catches
|
|
2385
|
+
* up; the story never goes back within a cycle.
|
|
2386
|
+
*/
|
|
2387
|
+
const story = { cycle: null, n: 0, chapter: null, step: null };
|
|
2388
|
+
/** behold#631: the forge chant's pipeline runs on, from its loop as /api/chant/pr read it. */
|
|
2389
|
+
s.chantForge = () => (ap.chant && ap.chant.loop && ap.chant.loop.forge) || null;
|
|
2390
|
+
s.storyDemo = (d) => {
|
|
2391
|
+
if (!storyOn(s) || !d || !d.chapter || !Number.isInteger(d.chapter.n)) return d;
|
|
2392
|
+
if (story.cycle !== d.cycle) Object.assign(story, { cycle: d.cycle, n: 0, chapter: null, step: null });
|
|
2393
|
+
const steps = (s.lastCycle() || {}).steps || [];
|
|
2394
|
+
const first = (n) => steps.find((x) => x.chapter && x.chapter.n === n) || null;
|
|
2395
|
+
let n = d.chapter.n;
|
|
2396
|
+
let chapter = d.chapter;
|
|
2397
|
+
let step = d.step;
|
|
2398
|
+
const applyStep = ["applying", "merged", "resumed"].includes(d.step);
|
|
2399
|
+
const w = applyStep && s.chantLoop && s.chantWavesNow ? s.chantWavesNow(d) : null;
|
|
2400
|
+
const comps = w && w.live && w.live.components ? Object.values(w.live.components) : [];
|
|
2401
|
+
// behold#741: a terragucci story moves on when the paced run view shows a failure, or every wave applied.
|
|
2402
|
+
const tw = applyStep && !s.chantLoop && s.tgWavesNow ? s.tgWavesNow(d) : null;
|
|
2403
|
+
const ahead = first(n + 1);
|
|
2404
|
+
if (ahead && (comps.some((c) => c.state === "failed") || (w && w.live && w.live.settled && w.live.status === "ok" && !w.live.paced) || (tw && (tw.failed || tw.done)))) {
|
|
2405
|
+
n = ahead.chapter.n;
|
|
2406
|
+
chapter = ahead.chapter;
|
|
2407
|
+
step = ahead.step;
|
|
2408
|
+
}
|
|
2409
|
+
// Never back: a chapter the story has told stays told until demo.json moves past it.
|
|
2410
|
+
if (n > story.n) Object.assign(story, { n, chapter, step });
|
|
2411
|
+
else if (story.n > n && story.chapter) {
|
|
2412
|
+
n = story.n;
|
|
2413
|
+
chapter = story.chapter;
|
|
2414
|
+
step = story.step;
|
|
2415
|
+
}
|
|
2416
|
+
return chapter === d.chapter && step === d.step ? d : { ...d, chapter, step, storyAhead: true };
|
|
2417
|
+
};
|
|
2418
|
+
s.chantCaptionStep = (demo, step) => {
|
|
2419
|
+
const held = s.chantLoop && ap.chant && ap.chant.live && ap.chant.live.apply && demo && ["failed", "applied"].includes(demo.step);
|
|
2420
|
+
if (held) {
|
|
2421
|
+
chantPacer.answer(ap.chant);
|
|
2422
|
+
if (chantPacer.pending && capShown && capShown.id !== demo.step) return capShown;
|
|
2423
|
+
}
|
|
2424
|
+
// behold#741: a terragucci story's failed and applied steps wait, as chant's do, for the paced waves to reach them.
|
|
2425
|
+
if (s.tgStory && demo && ["failed", "applied"].includes(demo.step) && s.tgPaced) {
|
|
2426
|
+
s.tgPaced();
|
|
2427
|
+
if (tgPacer.pending && capShown && capShown.id !== demo.step) return capShown;
|
|
2428
|
+
}
|
|
2429
|
+
capShown = step;
|
|
2430
|
+
return step;
|
|
2431
|
+
};
|
|
1971
2432
|
const approvalNow = () => {
|
|
1972
2433
|
const d = s.demo && s.demo.demo;
|
|
1973
2434
|
// behold#631: chant's gate, one per pull request on the plan's digest, when the repo runs chant's loop.
|
|
1974
|
-
|
|
2435
|
+
// The kiosk's card names the plan by its short id; the approve command is Inspect's.
|
|
2436
|
+
const chant = s.chantLoop && ap.chant ? chantApprovalModel({ demo: d, answer: chantPacer.answer(ap.chant), kiosk: true }) : null;
|
|
1975
2437
|
if (chant) return chant;
|
|
1976
2438
|
if (!d || !PANEL_STEPS.includes(d.step)) return null;
|
|
1977
2439
|
const appr = pendingApproval(d, s.progress);
|
|
@@ -2000,7 +2462,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2000
2462
|
docs.rel = "noopener";
|
|
2001
2463
|
const more = el("p", "k-what-more");
|
|
2002
2464
|
more.append(docs);
|
|
2003
|
-
tools.pop.replaceChildren(el("p", null, WHAT_TEXT), more);
|
|
2465
|
+
tools.pop.replaceChildren(el("p", null, s.source === "chant-demo" ? WHAT_TEXT_CHANT : WHAT_TEXT), more);
|
|
2004
2466
|
};
|
|
2005
2467
|
if (tools && tools.what && tools.pop) {
|
|
2006
2468
|
const setWhat = (open) => {
|
|
@@ -2045,6 +2507,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2045
2507
|
filter: vendor ? (index) => filterIndex(index, { tool, repo: s.repo }) : (index) => index,
|
|
2046
2508
|
replay: () => s.mode === "replay",
|
|
2047
2509
|
hideLine: vendor ? (line) => namesOther(line, tool) : null,
|
|
2510
|
+
urls: { runs: reads.runs, run: reads.run },
|
|
2048
2511
|
},
|
|
2049
2512
|
);
|
|
2050
2513
|
}
|
|
@@ -2150,6 +2613,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2150
2613
|
s.components = !!(p && !p.error && (p.terragucciComponents || chantProject(p)));
|
|
2151
2614
|
// behold#631: a chant project may run chant's pull-request loop; /api/chant/pr says (its `loop`).
|
|
2152
2615
|
s.chantLoop = !!(p && !p.error && !p.terragucciComponents && chantProject(p));
|
|
2616
|
+
// behold#741: a terragucci repo, whose chapter-carrying scenarios get the same look (storyGate).
|
|
2617
|
+
s.tgRepo = !!(p && !p.error && p.terragucciComponents);
|
|
2153
2618
|
// behold#571: the declared roots (their colours' order) and the wave jobs that apply them.
|
|
2154
2619
|
if (p && p.terragucciRoots) {
|
|
2155
2620
|
s.roots = Array.isArray(p.terragucciRoots.roots) ? p.terragucciRoots.roots : [];
|
|
@@ -2157,6 +2622,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2157
2622
|
// behold#571: the tools the repo's jobs run, for a job row whose log isn't read yet.
|
|
2158
2623
|
s.tools = Array.isArray(p.terragucciRoots.tools) ? p.terragucciRoots.tools : [];
|
|
2159
2624
|
s.rootTools = p.terragucciRoots.rootTools && typeof p.terragucciRoots.rootTools === "object" ? p.terragucciRoots.rootTools : {};
|
|
2625
|
+
// behold#741: the forge, for a chapter-carrying scenario's title line.
|
|
2626
|
+
s.tgForge = typeof p.terragucciRoots.forge === "string" ? p.terragucciRoots.forge : null;
|
|
2160
2627
|
} else if (s.aimed) {
|
|
2161
2628
|
s.roots = [];
|
|
2162
2629
|
s.waves = [];
|
|
@@ -2169,6 +2636,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2169
2636
|
void readProject();
|
|
2170
2637
|
|
|
2171
2638
|
const reports = async (fresh) => {
|
|
2639
|
+
// behold#752: chant's demo writes no terragucci reports or run view; its facts come through /api/chant/pr.
|
|
2640
|
+
if (reads.own) return;
|
|
2172
2641
|
s.answer = await fetchJson(`/api/terragucci${fresh ? "?fresh=1" : ""}`);
|
|
2173
2642
|
draw();
|
|
2174
2643
|
};
|
|
@@ -2178,6 +2647,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2178
2647
|
return pinsCommit(pin) ? pin : null;
|
|
2179
2648
|
};
|
|
2180
2649
|
const progress = async (fresh) => {
|
|
2650
|
+
if (reads.own) return;
|
|
2181
2651
|
const pin = pinnedCommit();
|
|
2182
2652
|
const q = new URLSearchParams();
|
|
2183
2653
|
if (pin) q.set("commit", pin);
|
|
@@ -2191,7 +2661,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2191
2661
|
let cycleRead = 0;
|
|
2192
2662
|
const readCycle = async () => {
|
|
2193
2663
|
cycleRead = now().getTime();
|
|
2194
|
-
const a = await fetchJson(
|
|
2664
|
+
const a = await fetchJson(reads.cycle(tool));
|
|
2195
2665
|
if (s.mode === "live") return; // its scenario started while the read was out
|
|
2196
2666
|
if (a && a.cycle) {
|
|
2197
2667
|
if (!s.replay || s.replay.cycle.cycle !== a.cycle.cycle) s.replay = { cycle: a.cycle, start: now().getTime(), at: null, banner: null, runs: null };
|
|
@@ -2230,8 +2700,51 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2230
2700
|
linkLine.textContent = words || "";
|
|
2231
2701
|
};
|
|
2232
2702
|
|
|
2703
|
+
// A quiet step: when nothing new has come in for a while during a step
|
|
2704
|
+
// that runs, the caption says what is running and for how long
|
|
2705
|
+
// (kiosk-watch.js quietWords). A record is the driver's step, a job or
|
|
2706
|
+
// step changing state in the run's view, or a progress line the carve's
|
|
2707
|
+
// frame has drawn. Never on a replay, and never while the link cue is up.
|
|
2708
|
+
let recordWas = null;
|
|
2709
|
+
let recordAt = null;
|
|
2710
|
+
let stepSeenAt = null;
|
|
2711
|
+
// The last driver step read and the newest progress line seen: a failed poll or a frame between carves does not count as a new record.
|
|
2712
|
+
let quietDemo = null;
|
|
2713
|
+
let writeSeen = null;
|
|
2714
|
+
s.quietTick = () => {
|
|
2715
|
+
const t = now().getTime();
|
|
2716
|
+
const read = s.demo && s.demo.demo;
|
|
2717
|
+
if (read) quietDemo = read;
|
|
2718
|
+
else if (s.mode !== "live") quietDemo = null;
|
|
2719
|
+
const d = quietDemo;
|
|
2720
|
+
const runDoc = runsApi && runsApi.run ? runsApi.run.doc : null;
|
|
2721
|
+
const run = runningStep(runDoc);
|
|
2722
|
+
const w = carveCtl ? carveCtl.lastWriteAt() : null;
|
|
2723
|
+
if (typeof w === "number" && (writeSeen === null || w > writeSeen)) writeSeen = w;
|
|
2724
|
+
// Only a new driver step or a new progress line restarts the clock; a job or step changing state only changes the words.
|
|
2725
|
+
const key = recordKey(d, writeSeen);
|
|
2726
|
+
if (key !== recordWas) {
|
|
2727
|
+
const first = recordWas === null;
|
|
2728
|
+
const stepChanged = !first && recordWas.split("#")[0] !== key.split("#")[0];
|
|
2729
|
+
// The first look: the newest record's own time, where one says it, so a page opened in a long step shows the line at once.
|
|
2730
|
+
const known = first && d ? [d.next && d.next.from ? Date.parse(d.next.from) : NaN, writeSeen].filter((x) => typeof x === "number" && Number.isFinite(x) && x <= t) : [];
|
|
2731
|
+
if (first || stepChanged) stepSeenAt = t;
|
|
2732
|
+
recordWas = key;
|
|
2733
|
+
recordAt = known.length ? Math.max(...known) : t;
|
|
2734
|
+
}
|
|
2735
|
+
s.quiet = quietWords(d, { now: t, lastRecordAt: recordAt, run, stepAt: stepSeenAt, replay: s.mode === "replay", stale: !!linkWords(link) });
|
|
2736
|
+
// behold#631: how long nothing new has come in, for the "Waiting on…" modal.
|
|
2737
|
+
s.quietFor = typeof recordAt === "number" ? t - recordAt : 0;
|
|
2738
|
+
// behold#631: a chant kiosk's "· N s so far" counts only while a job of the step runs; a step that is done has no timer.
|
|
2739
|
+
// With the projected track up, its now line says it: the caption's quiet line goes.
|
|
2740
|
+
if (s.chantLoop && s.quiet && (!(run && run.job) || s.trackOn)) s.quiet = null;
|
|
2741
|
+
// behold#741: with the projected track up on a terragucci story, its now line says it too.
|
|
2742
|
+
else if (s.tgStory && s.quiet && s.trackOn) s.quiet = null;
|
|
2743
|
+
if (carveCtl) carveCtl.setQuiet(s.quiet);
|
|
2744
|
+
};
|
|
2745
|
+
|
|
2233
2746
|
const demo = async () => {
|
|
2234
|
-
const live = await fetchJson(
|
|
2747
|
+
const live = await fetchJson(reads.demo);
|
|
2235
2748
|
noteRead(link, "poll", !readFailed(live), now());
|
|
2236
2749
|
paintLink();
|
|
2237
2750
|
s.live = live;
|
|
@@ -2261,7 +2774,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2261
2774
|
setInterval(() => void readApproval(), 1000);
|
|
2262
2775
|
setInterval(draw, 1000);
|
|
2263
2776
|
|
|
2264
|
-
if (typeof EventSource !== "undefined") {
|
|
2777
|
+
if (typeof EventSource !== "undefined" && !reads.own) {
|
|
2265
2778
|
const es = new EventSource("/api/terragucci/events");
|
|
2266
2779
|
// behold#725: the browser retries a dropped stream by itself (CONNECTING);
|
|
2267
2780
|
// one it closed for good (a 404, say) leaves the polls to carry the cue.
|