@intentius/behold 0.29.43 → 0.29.45
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 +4065 -1918
- package/package.json +1 -1
- package/web/app.js +1469 -74
- 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 +98 -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-demo-frame.test.js +27 -0
- package/web/kiosk-event-help-ui.js +186 -20
- package/web/kiosk-event-help.js +175 -15
- package/web/kiosk-event-help.test.js +58 -1
- package/web/kiosk-highlight.test.js +249 -0
- 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 +73 -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 +583 -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 +145 -0
- package/web/tg-read-pills.test.js +158 -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.` },
|
|
@@ -588,6 +722,18 @@ export function readStored(store) {
|
|
|
588
722
|
}
|
|
589
723
|
}
|
|
590
724
|
|
|
725
|
+
/**
|
|
726
|
+
* behold#765: whether chant's demo (`--chant-demo`, the page's own reads) has its graph on this behold. A behold
|
|
727
|
+
* serving one checkout (/api/project names no `viewRepos`) was paired with the demo by its operator, so the frame is
|
|
728
|
+
* the demo's repo; one serving several (`--repos`) draws it when it serves the step's repo by name. `single` is null
|
|
729
|
+
* until /api/project answers. Neither terragucci's answer nor a report naming the repo is asked for: there is none.
|
|
730
|
+
*/
|
|
731
|
+
export function demoFrameOk(own, single, repo, viewRepos) {
|
|
732
|
+
if (!own) return false;
|
|
733
|
+
if (single === true) return true;
|
|
734
|
+
return !!repoParam(repo, viewRepos);
|
|
735
|
+
}
|
|
736
|
+
|
|
591
737
|
/** Whether a tool's pipeline writes no terragucci reports or run view (VENDORS' `reports: false`). */
|
|
592
738
|
export function reportless(vendor) {
|
|
593
739
|
return !!vendor && vendor.reports === false;
|
|
@@ -709,6 +855,13 @@ export function holdHead({ wave = null, run = null, digest = null, pull = null,
|
|
|
709
855
|
return parts.length ? parts.join(" · ") : null;
|
|
710
856
|
}
|
|
711
857
|
|
|
858
|
+
/** 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. */
|
|
859
|
+
export function coneLines(demo, answer) {
|
|
860
|
+
const c = coneCaption(demo, answer);
|
|
861
|
+
if (!c) return [];
|
|
862
|
+
return [{ cls: "k-note k-cone-note", text: c.line }, ...(c.backend ? [{ cls: "k-note k-cone-backend", text: c.backend }] : [])];
|
|
863
|
+
}
|
|
864
|
+
|
|
712
865
|
/**
|
|
713
866
|
* behold#571: what the hold panel holds, or null for nothing: how the hold
|
|
714
867
|
* ends (from the records), else the driver's approval, else the run's note.
|
|
@@ -719,9 +872,9 @@ export function holdModel(s, demo) {
|
|
|
719
872
|
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
873
|
const appr = pendingApproval(demo, s.progress);
|
|
721
874
|
if (appr) return { kind: "driver", wave: appr.wave, head: holdHead({ wave: appr.wave, digest: appr.digest }), appr };
|
|
722
|
-
if (s.noReports || reportless(vendor ||
|
|
875
|
+
if (s.noReports || reportless(vendor || kioskVendorOf(demo.tool))) return null;
|
|
723
876
|
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 })) : [];
|
|
877
|
+
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
878
|
if (!lines.length) return null;
|
|
726
879
|
const head = holdHead(panel.stage === "pull-request" ? { pull: demo.pull } : { commit: demo.commit });
|
|
727
880
|
return { kind: "note", wave: null, head, lines };
|
|
@@ -768,12 +921,15 @@ function drawBar(bar, s, now) {
|
|
|
768
921
|
const titleBox = box("title", "k-box-title");
|
|
769
922
|
const over = el("div", "k-overline");
|
|
770
923
|
// behold#571: /kiosk names the tool each scenario runs on, as its own page does.
|
|
771
|
-
|
|
924
|
+
// behold#746: but for a fan-out, whose brand its own page alone carries.
|
|
925
|
+
const shownTool = vendor || (demo.scenario !== "base" ? kioskVendorOf(demo.tool) : null);
|
|
772
926
|
if (shownTool) over.appendChild(brandEl(shownTool));
|
|
773
927
|
over.appendChild(el("span", "k-kicker", head.kicker));
|
|
774
928
|
// The scenario's progress: the strip's stops, at the end of the line over the title.
|
|
775
929
|
const strip = el("ol", "k-strip");
|
|
776
|
-
|
|
930
|
+
// behold#631: a chant pull request's wait for its approval comes before its merge. Without a stop of its own on the
|
|
931
|
+
// strip it shows as "planned", for the fix's pull request as for the first.
|
|
932
|
+
for (const stop of stripStops(railStep(s, demo), s.strip || STRIP)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
777
933
|
over.appendChild(strip);
|
|
778
934
|
const title = el("h1", "k-title");
|
|
779
935
|
title.appendChild(el("span", "k-title-text", head.title));
|
|
@@ -902,13 +1058,28 @@ function drawWatchHead(bar, s, now) {
|
|
|
902
1058
|
const demo = s.demo.demo;
|
|
903
1059
|
const vendor = vendorOf(s.vendor);
|
|
904
1060
|
const place = el("div", "k-w-place");
|
|
905
|
-
const shownTool = vendor || (demo.scenario !== "base" ?
|
|
906
|
-
if (
|
|
907
|
-
|
|
1061
|
+
const shownTool = vendor || (demo.scenario !== "base" ? kioskVendorOf(demo.tool) : null);
|
|
1062
|
+
if (storyOn(s) && s.trackOn) {
|
|
1063
|
+
// behold#631: a chant kiosk names what this is in one line; the cycle number and its clock are Inspect's.
|
|
1064
|
+
// behold#741: a terragucci repo's chapter-carrying scenario names terragucci, its engine and its forge.
|
|
1065
|
+
// behold#746: a tool's page leaves out the parts (and the tooltip's sentence) that name what it may not.
|
|
1066
|
+
// On its replay the line's "live demo" goes; the replay's banner follows the line instead.
|
|
1067
|
+
const hide = vendor ? (t) => namesOther(t, s.vendor) || (s.mode === "replay" && /^live\b/.test(t)) : null;
|
|
1068
|
+
if (s.chantLoop) place.appendChild(whatLineEl(demo, s.chantForge ? s.chantForge() : null, null, hide, s.source === "chant-demo"));
|
|
1069
|
+
else place.appendChild(whatLineEl(demo, s.tgForge || null, { tools: s.tools || [] }, hide));
|
|
1070
|
+
} else {
|
|
1071
|
+
if (shownTool) place.appendChild(brandEl(shownTool));
|
|
1072
|
+
place.appendChild(el("span", "k-cycle", cycleWords(demo, now)));
|
|
1073
|
+
}
|
|
1074
|
+
// behold#746: a tool's page says in Watch too that it replays an earlier run.
|
|
1075
|
+
if (vendor && s.mode === "replay" && s.replay && s.replay.banner) place.appendChild(el("span", "k-cycle k-w-replay", s.replay.banner));
|
|
908
1076
|
bar.appendChild(place);
|
|
909
1077
|
const strip = el("ol", "k-strip");
|
|
910
|
-
|
|
911
|
-
|
|
1078
|
+
// behold#631: a chant pull request's wait for its approval comes before its merge. Without a stop of its own on the
|
|
1079
|
+
// strip it shows as "planned", for the fix's pull request as for the first.
|
|
1080
|
+
for (const stop of stripStops(railStep(s, demo), s.strip || STRIP)) strip.appendChild(el("li", `k-stop k-${stop.state}`, stop.words));
|
|
1081
|
+
// behold#631: a chant kiosk's projected track says where the cycle is; the rail goes.
|
|
1082
|
+
if (!s.trackOn) bar.appendChild(strip);
|
|
912
1083
|
if (s.watchHeld) {
|
|
913
1084
|
const p = el("span", "k-w-held", heldWords(s.watchHeld.secs));
|
|
914
1085
|
const b = el("button", null, FOLLOW_WORDS);
|
|
@@ -929,21 +1100,56 @@ function drawWatchHead(bar, s, now) {
|
|
|
929
1100
|
function drawCaption(host, s, now) {
|
|
930
1101
|
host.replaceChildren();
|
|
931
1102
|
const demo = s.demo && s.demo.demo;
|
|
932
|
-
const cap = captionModel(demo, { vendor: s.vendor || null, now });
|
|
1103
|
+
const cap = captionModel(demo, { vendor: s.vendor || null, now, answer: s.answer });
|
|
933
1104
|
if (!cap) return;
|
|
1105
|
+
if (s.chantCaptionStep) cap.step = s.chantCaptionStep(demo, cap.step);
|
|
934
1106
|
const top = el("div", "k-cap-top");
|
|
935
1107
|
const title = el("h1", "k-cap-title");
|
|
936
|
-
|
|
937
|
-
|
|
1108
|
+
// behold#631: a chant kiosk with its track drops "Scenario 1 of 1": the track says where the cycle is.
|
|
1109
|
+
const told = s.storyDemo ? s.storyDemo(demo) : demo;
|
|
1110
|
+
const ch = storyOn(s) && told && told.chapter && Number.isInteger(told.chapter.n) ? told.chapter : null;
|
|
1111
|
+
if (!(storyOn(s) && s.trackOn)) title.append(el("span", "k-kicker", cap.kicker));
|
|
1112
|
+
if (ch) {
|
|
1113
|
+
// behold#631: the story's chapter is the headline, "1 of 4 · A change to the shared network goes out to all 15 stacks",
|
|
1114
|
+
// fading in when the chapter turns; the scenario's point stays under it as one constant small line.
|
|
1115
|
+
chapterStyle();
|
|
1116
|
+
const words = `${ch.n} of ${ch.of} · ${ch.headline}`;
|
|
1117
|
+
const head = el("span", "k-title-text k-chapter-head", words);
|
|
1118
|
+
if (s.capChapter !== words) {
|
|
1119
|
+
s.capChapter = words;
|
|
1120
|
+
s.capChapterAt = now.getTime ? now.getTime() : Date.now();
|
|
1121
|
+
}
|
|
1122
|
+
const t = now.getTime ? now.getTime() : Date.now();
|
|
1123
|
+
// A redraw mid-fade carries on from where the fade is, never from the start.
|
|
1124
|
+
if (t - (s.capChapterAt || 0) < 900 && head.classList) {
|
|
1125
|
+
head.classList.add("k-chapter-in");
|
|
1126
|
+
if (head.style) head.style.animationDelay = `-${t - s.capChapterAt}ms`;
|
|
1127
|
+
}
|
|
1128
|
+
title.append(head);
|
|
1129
|
+
if (title.setAttribute) title.setAttribute("title", words);
|
|
1130
|
+
} else {
|
|
1131
|
+
title.append(el("span", "k-title-text", cap.title));
|
|
1132
|
+
if (title.setAttribute) title.setAttribute("title", `${cap.kicker} · ${cap.title}`);
|
|
1133
|
+
}
|
|
938
1134
|
top.appendChild(title);
|
|
939
1135
|
if (cap.next) {
|
|
940
1136
|
const nx = el("p", "k-cap-next");
|
|
941
|
-
|
|
942
|
-
|
|
1137
|
+
// behold#631: a chant kiosk says what comes next as one plain sentence in one font: the demo is scripted, and
|
|
1138
|
+
// "plan note" and "the plan's digest" are chant's own terms. A failure's next step reads as the modal's does.
|
|
1139
|
+
if (s.chantLoop) {
|
|
1140
|
+
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");
|
|
1141
|
+
const sentence = `next (scripted): ${action}${/^when\b/.test(cap.next.when) ? ", " : " "}${cap.next.when}`.replace(/\s+/g, " ").trim();
|
|
1142
|
+
nx.append(sentence);
|
|
1143
|
+
if (nx.setAttribute) nx.setAttribute("title", sentence);
|
|
1144
|
+
} else {
|
|
1145
|
+
nx.append("next, by the driver: ", elRoots("span", "k-action", cap.next.action, s), " ", el("span", "k-when", cap.next.when));
|
|
1146
|
+
if (nx.setAttribute) nx.setAttribute("title", `next, by the driver: ${cap.next.action}`);
|
|
1147
|
+
}
|
|
943
1148
|
nx.appendChild(nextBar(demo, now, s));
|
|
944
1149
|
top.appendChild(nx);
|
|
945
1150
|
}
|
|
946
1151
|
host.appendChild(top);
|
|
1152
|
+
if (ch && cap.title) host.appendChild(el("p", "k-cap-point", cap.title));
|
|
947
1153
|
const beat = cap.intro || cap.changes;
|
|
948
1154
|
const changes = el("p", `k-cap-row k-cap-changes${cap.lead === "changes" ? " k-cap-lead" : ""}`);
|
|
949
1155
|
if (beat) {
|
|
@@ -955,6 +1161,54 @@ function drawCaption(host, s, now) {
|
|
|
955
1161
|
step.append(el("span", "k-cap-label", cap.step.word), elRoots("span", "k-cap-text", cap.step.text, s));
|
|
956
1162
|
if (step.setAttribute) step.setAttribute("title", cap.step.text);
|
|
957
1163
|
host.appendChild(step);
|
|
1164
|
+
// Report minor 34: a cone plan, in one quiet line: what it planned, and the estates' backend when the reports say it.
|
|
1165
|
+
if (cap.cone) host.appendChild(coneEl("k-cap-cone", cap.cone));
|
|
1166
|
+
// What used to be a card over the graph (the result, the approval): one quiet line under the label, in the caption.
|
|
1167
|
+
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 });
|
|
1168
|
+
if (said) {
|
|
1169
|
+
const p = el("p", "k-cap-quiet k-cap-step-line", said);
|
|
1170
|
+
if (p.setAttribute) {
|
|
1171
|
+
p.setAttribute("data-step-line", demo.step);
|
|
1172
|
+
p.setAttribute("title", said);
|
|
1173
|
+
}
|
|
1174
|
+
host.appendChild(p);
|
|
1175
|
+
}
|
|
1176
|
+
// A long step with nothing new coming in: what runs, and for how long (kiosk-watch.js quietWords).
|
|
1177
|
+
if (s.quiet) {
|
|
1178
|
+
const q = quietEl("k-cap-quiet", s.quiet);
|
|
1179
|
+
if (q.setAttribute) {
|
|
1180
|
+
q.setAttribute("role", "status");
|
|
1181
|
+
q.setAttribute("title", s.quiet.title);
|
|
1182
|
+
}
|
|
1183
|
+
host.appendChild(q);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/** The cone plan's line (kiosk-watch.js coneCaption): the plan's words, then the backend's, quieter. */
|
|
1188
|
+
export function coneEl(cls, c) {
|
|
1189
|
+
const p = el("p", `${cls} k-cone`);
|
|
1190
|
+
if (p.setAttribute) {
|
|
1191
|
+
p.setAttribute("data-cone-line", "");
|
|
1192
|
+
p.setAttribute("title", c.backend ? `${c.line} · ${c.backend}` : c.line);
|
|
1193
|
+
}
|
|
1194
|
+
p.appendChild(el("span", "k-cone-plan", c.line));
|
|
1195
|
+
if (c.backend) p.appendChild(el("span", "k-cone-backend", c.backend));
|
|
1196
|
+
return p;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/** 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. */
|
|
1200
|
+
export const FRAME_CONTROLS = { w: 240, h: 44 };
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* The quiet line's element: the driver's words, which may be cut short with an
|
|
1204
|
+
* ellipsis, then the running job and the time, always whole. A phone puts the
|
|
1205
|
+
* job and the time on a second line.
|
|
1206
|
+
*/
|
|
1207
|
+
export function quietEl(cls, q) {
|
|
1208
|
+
const p = el("p", `${cls} k-quiet`);
|
|
1209
|
+
if (q.said) p.append(el("span", "k-quiet-said", q.said), el("span", "k-quiet-sep", " · "));
|
|
1210
|
+
p.append(el("span", "k-quiet-tail", q.tail || q.text));
|
|
1211
|
+
return p;
|
|
958
1212
|
}
|
|
959
1213
|
|
|
960
1214
|
/** The approval on the held wave's box: the step's word, the wave, its numbers, and how the hold ends. */
|
|
@@ -1075,7 +1329,8 @@ function box(name, cls = "") {
|
|
|
1075
1329
|
export function approvalPanel(model, s = {}) {
|
|
1076
1330
|
const wrap = el("div", "k-ap");
|
|
1077
1331
|
// behold#571: the hold panel's head names the wave, the run and the plan; this one says what the rows are.
|
|
1078
|
-
|
|
1332
|
+
// behold#631: a chant kiosk's rows carry no times, so its head says none.
|
|
1333
|
+
wrap.appendChild(el("p", "k-ap-head", model.kiosk ? PANEL_TITLE : `${PANEL_TITLE} · times in UTC`));
|
|
1079
1334
|
const list = el("ol", "k-ap-rows");
|
|
1080
1335
|
for (const r of model.rows) {
|
|
1081
1336
|
const li = el("li", `k-ap-row k-ap-${r.state}`);
|
|
@@ -1152,6 +1407,8 @@ export const HELD_JOB_RULE = "background: color-mix(in srgb, var(--foreign) 14%,
|
|
|
1152
1407
|
|
|
1153
1408
|
/** behold#571: how often the approval panel reads the cycle's runs, and the gate ledger (which the server caches 30 s). */
|
|
1154
1409
|
export const APPROVAL_POLL_MS = 4_000;
|
|
1410
|
+
/** behold#631: how often a chant kiosk reads its loop while the apply runs: as often as the graph's frame does. */
|
|
1411
|
+
export const CHANT_APPLY_POLL_MS = 1_500;
|
|
1155
1412
|
export const LEDGER_POLL_MS = 10_000;
|
|
1156
1413
|
|
|
1157
1414
|
/** behold#571: the approval panel's words for the approval the driver gives next, over its command. */
|
|
@@ -1159,6 +1416,8 @@ export const DRIVER_SIGNS = "Next the driver plays a reviewer outside the change
|
|
|
1159
1416
|
|
|
1160
1417
|
/** behold#571: "What is this?" says what behold is; the demo's own intro stays on the card between scenarios. */
|
|
1161
1418
|
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.";
|
|
1419
|
+
/** behold#752: the same, for chant's fan-out demo, whose stacks are CloudFormation's. */
|
|
1420
|
+
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
1421
|
export const WHAT_DOCS = { text: "behold's documentation", url: "https://intentius.io/behold/" };
|
|
1163
1422
|
|
|
1164
1423
|
/** behold#571: a fade at a box's edge where its text goes on past it. */
|
|
@@ -1183,6 +1442,8 @@ export const FRAME_BOOT_WAIT_MS = 4_000;
|
|
|
1183
1442
|
|
|
1184
1443
|
/** How often the kiosk asks for demo.json. The server shares one read between kiosks. */
|
|
1185
1444
|
export const DEMO_POLL_MS = 3_000;
|
|
1445
|
+
/** 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. */
|
|
1446
|
+
export const CHANT_SIDE_ROOM = 520;
|
|
1186
1447
|
|
|
1187
1448
|
/**
|
|
1188
1449
|
* Boot the kiosk: the bar, the frame and the graph pane's legend. Ask demo.json every few
|
|
@@ -1191,8 +1452,10 @@ export const DEMO_POLL_MS = 3_000;
|
|
|
1191
1452
|
* countdown. When the roots the step is about change, move the framed view
|
|
1192
1453
|
* with a `behold:view` message; the frame takes them only from this origin.
|
|
1193
1454
|
*/
|
|
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
|
-
|
|
1455
|
+
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 } = {}) {
|
|
1456
|
+
// behold#752: terragucci's loop, or chant's fan-out demo from its own records (web/kiosk-source.js).
|
|
1457
|
+
const reads = readsFor(source);
|
|
1458
|
+
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
1459
|
// behold#571: Watch or Inspect, the viewer's pick kept in their browser; Watch until they pick Inspect.
|
|
1197
1460
|
const shelf = typeof localStorage !== "undefined" ? (() => { try { return localStorage; } catch { return null; } })() : null;
|
|
1198
1461
|
s.metrics = null;
|
|
@@ -1234,6 +1497,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1234
1497
|
/** behold#571: the frame and the plan's facts are the served repo's, so a tool's page shows them only for its own repo. */
|
|
1235
1498
|
const frameOk = () => {
|
|
1236
1499
|
if (!vendor) return true;
|
|
1500
|
+
// behold#765: chant's demo has no terragucci answer to name its repo, and one checkout served sends no viewRepos.
|
|
1501
|
+
if (demoFrameOk(reads.own, s.single, s.repo, s.viewRepos)) return true;
|
|
1237
1502
|
// Before the tool's first cycle: its repo's checkout, when this behold serves it.
|
|
1238
1503
|
if (s.mode === "none") return !!notRunRepo(tool, s.viewRepos) && s.aimed === notRunRepo(tool, s.viewRepos);
|
|
1239
1504
|
if (servesRepo(s.answer && !s.answer.error ? s.answer.project : null, s.repo)) return true;
|
|
@@ -1245,6 +1510,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1245
1510
|
// graph's reads from the checkout of the repo the page is about, asked by
|
|
1246
1511
|
// name. `viewRepos` is what it serves, `aimed` the repo the reads are for.
|
|
1247
1512
|
s.viewRepos = null;
|
|
1513
|
+
// behold#765: whether this behold serves one checkout (no viewRepos), null until /api/project answers.
|
|
1514
|
+
s.single = null;
|
|
1248
1515
|
s.aimed = null;
|
|
1249
1516
|
s.viewCommits = null;
|
|
1250
1517
|
const repoNamed = () => repoParam(s.repo, s.viewRepos) || (vendor && s.mode === "none" ? notRunRepo(tool, s.viewRepos) : null);
|
|
@@ -1272,11 +1539,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1272
1539
|
const roots = d ? focusRoots(d, s.answer, s.progress) : null;
|
|
1273
1540
|
const focus = roots ? roots.join(",") : null;
|
|
1274
1541
|
const run = d ? runPin(d) : "base";
|
|
1542
|
+
// The cycle's pull request, so a merge's frame never draws another cycle's plan (web/terragucci-change.js pinnedAnswer).
|
|
1543
|
+
const pull = framePull(d);
|
|
1275
1544
|
const zoom = viewZoom(shownView().view);
|
|
1276
|
-
const key = `${focus}|${run}|${zoom}`;
|
|
1545
|
+
const key = `${focus}|${run}|${pull}|${zoom}`;
|
|
1277
1546
|
if (!force && key === lastFocus) return;
|
|
1278
1547
|
lastFocus = key;
|
|
1279
|
-
post({ type: "behold:view", member: null, focus, run, zoom });
|
|
1548
|
+
post({ type: "behold:view", member: null, focus, run, pull, zoom });
|
|
1280
1549
|
tellHover(s.hover);
|
|
1281
1550
|
};
|
|
1282
1551
|
const pickView = (view) => {
|
|
@@ -1404,6 +1673,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1404
1673
|
const draw = () => {
|
|
1405
1674
|
followRepo();
|
|
1406
1675
|
replayTick();
|
|
1676
|
+
// behold#741: the story gate for this step, and the frame told so (it draws the wedge, the blocks and the paced waves).
|
|
1677
|
+
{
|
|
1678
|
+
const d = s.demo && s.demo.demo;
|
|
1679
|
+
s.tgStory = storyGate({ chantLoop: s.chantLoop, terragucciRepo: s.tgRepo, demo: d }) === "terragucci";
|
|
1680
|
+
// behold#743: and the step's apply made outside the pipeline, which the frame draws on its estate's card.
|
|
1681
|
+
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 });
|
|
1682
|
+
}
|
|
1407
1683
|
s.light = typeof document !== "undefined" && document.documentElement ? isLightBg(getComputedStyle(document.documentElement).getPropertyValue("--bg")) : false;
|
|
1408
1684
|
s.rootNames = rootList();
|
|
1409
1685
|
const shown = shownView();
|
|
@@ -1439,6 +1715,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1439
1715
|
}
|
|
1440
1716
|
// behold#571: Watch's overlays, then the shot they leave room for.
|
|
1441
1717
|
holdTick();
|
|
1718
|
+
if (s.quietTick) s.quietTick();
|
|
1442
1719
|
drawWatch(shownNow());
|
|
1443
1720
|
renderViewToggle(views, shown, { components: s.components && ok, onPick: pickView });
|
|
1444
1721
|
drawReading(shown.view, ok);
|
|
@@ -1526,9 +1803,11 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1526
1803
|
}
|
|
1527
1804
|
/** The caption shown now: Watch's own, or the live carve's while it has the camera (#715). */
|
|
1528
1805
|
const shownCaption = () => (carveCtl && carveCtl.caption ? carveCtl.caption() || watch.caption : watch.caption);
|
|
1806
|
+
/** behold#631: a chant kiosk's projected track (drawChantTrack), in the trail's place. */
|
|
1807
|
+
let trackHost = null;
|
|
1529
1808
|
/** behold#571: the caption's top, or event-help's trail's when it sits over the caption. */
|
|
1530
1809
|
const captionTop = (cap) => {
|
|
1531
|
-
const trail = eh && eh.trailHost;
|
|
1810
|
+
const trail = trackHost && !trackHost.hidden ? trackHost : eh && eh.trailHost;
|
|
1532
1811
|
const r = trail && !trail.hidden && trail.getBoundingClientRect ? trail.getBoundingClientRect() : null;
|
|
1533
1812
|
return r && r.height && r.top < cap.top ? r.top : cap.top;
|
|
1534
1813
|
};
|
|
@@ -1540,9 +1819,31 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1540
1819
|
const bottom = Math.max(0, f.bottom - captionTop(cap)) + 16;
|
|
1541
1820
|
const side = shot.kind === "held" ? watch.callout : shot.kind === "active" ? watch.drawer : shot.kind === "result" ? watch.result : null;
|
|
1542
1821
|
// 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
|
|
1822
|
+
const measured = side && !side.hidden && side.offsetWidth ? side.offsetWidth + (shot.kind === "result" ? 18 : 44) : 0;
|
|
1823
|
+
// 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.
|
|
1824
|
+
const right = s.chantLoop ? Math.max(measured, CHANT_SIDE_ROOM) : measured;
|
|
1544
1825
|
return { top: 20, right, bottom, left: 20 };
|
|
1545
1826
|
};
|
|
1827
|
+
/**
|
|
1828
|
+
* The tallest the caption gets in a cycle, as a bottom inset in px (kiosk-watch.js captionRoom), measured from the
|
|
1829
|
+
* caption as it is: a held small stage keeps this room from the first step, so the cone line, the step line, the
|
|
1830
|
+
* quiet line or the trail that comes later moves nothing. None on a phone, where the caption is under the graph.
|
|
1831
|
+
*/
|
|
1832
|
+
function captionRoomPx() {
|
|
1833
|
+
if (!watch || !frame || isPhone() || !frame.getBoundingClientRect || typeof getComputedStyle !== "function") return 0;
|
|
1834
|
+
const f = frame.getBoundingClientRect();
|
|
1835
|
+
const cap = watch.caption;
|
|
1836
|
+
const c = cap.getBoundingClientRect();
|
|
1837
|
+
const fs = parseFloat(getComputedStyle(cap).fontSize) || 16;
|
|
1838
|
+
const gap = fs * 0.25;
|
|
1839
|
+
const extras = [...cap.querySelectorAll(":scope > .k-cap-cone, :scope > .k-cap-quiet")].map((n) => n.getBoundingClientRect().height + gap);
|
|
1840
|
+
const rowH = extras.length ? Math.max(...extras) : fs * 0.92 * 1.35 + gap;
|
|
1841
|
+
const trail = eh && eh.trailHost && !eh.trailHost.hidden ? eh.trailHost.getBoundingClientRect() : null;
|
|
1842
|
+
const trailH = trail && trail.height && trail.top < c.top ? c.top - trail.top : 0;
|
|
1843
|
+
const chip = eh && eh.trailHost ? eh.trailHost.querySelector(".eh-chip") : null;
|
|
1844
|
+
const trailLineH = chip ? chip.getBoundingClientRect().height + 4 : 26;
|
|
1845
|
+
return captionRoom({ capHeight: c.height, extras, rowH, trailH, trailLineH, below: Math.max(0, f.bottom - c.bottom) });
|
|
1846
|
+
}
|
|
1546
1847
|
function tellShot(force) {
|
|
1547
1848
|
if (!frame || !frame.contentWindow || !watch) return;
|
|
1548
1849
|
if (!s.watchMode) {
|
|
@@ -1554,25 +1855,75 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1554
1855
|
}
|
|
1555
1856
|
if (s.watchHeld || !s.shot) return;
|
|
1556
1857
|
const insets = shotInsets(s.shot);
|
|
1557
|
-
|
|
1858
|
+
// The caption's tallest, for a held small stage's one framing; a stage that isn't held never reads it.
|
|
1859
|
+
const room = captionRoomPx();
|
|
1860
|
+
const key = `${s.shot.id}|${insets.right || 0}|${Math.round((insets.bottom || 0) / 12)}|${s.shot.roots.join(",")}|${Math.round(room / 12)}`;
|
|
1558
1861
|
if (!force && key === lastShot) return;
|
|
1559
1862
|
lastShot = key;
|
|
1560
|
-
post(shotMessage({ roots: s.shot.roots, waves: s.shot.waves, whole: s.shot.whole, insets, id: s.shot.id }));
|
|
1863
|
+
post(shotMessage({ roots: s.shot.roots, waves: s.shot.waves, whole: s.shot.whole, insets, id: s.shot.id, room }));
|
|
1864
|
+
}
|
|
1865
|
+
// behold#631: the projected cycle track, a chant kiosk's bottom band in place of the chip strip and the rail.
|
|
1866
|
+
const trackState = { cycle: null, pulls: [], key: null, since: null };
|
|
1867
|
+
function drawChantTrack(d, at) {
|
|
1868
|
+
if (!trackHost && eh && eh.trailHost && eh.trailHost.parentNode && typeof document !== "undefined") {
|
|
1869
|
+
trackHost = document.createElement("div");
|
|
1870
|
+
trackHost.id = "k-track";
|
|
1871
|
+
trackHost.hidden = true;
|
|
1872
|
+
eh.trailHost.parentNode.insertBefore(trackHost, eh.trailHost);
|
|
1873
|
+
}
|
|
1874
|
+
const t = at instanceof Date ? at.getTime() : now().getTime();
|
|
1875
|
+
const track = storyOn(s) && d ? cycleTrack(s.lastCycle()) : null;
|
|
1876
|
+
s.trackOn = !!track;
|
|
1877
|
+
if (!trackHost) return;
|
|
1878
|
+
if (!track) {
|
|
1879
|
+
s.trackModel = null;
|
|
1880
|
+
drawTrack(trackHost, null);
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
// This cycle's pull requests in the order it opened them; the reset closes the last.
|
|
1884
|
+
if (trackState.cycle !== d.cycle) Object.assign(trackState, { cycle: d.cycle, pulls: [], key: null, since: null });
|
|
1885
|
+
// The story's step, which may be a chapter ahead of demo.json's (s.storyDemo).
|
|
1886
|
+
d = s.storyDemo ? s.storyDemo(d) : d;
|
|
1887
|
+
if (Number.isInteger(d.pull) && !trackState.pulls.includes(d.pull)) trackState.pulls.push(d.pull);
|
|
1888
|
+
const live = s.chantLoop ? (s.chantWavesNow ? s.chantWavesNow(d) : null) : s.tgWavesNow ? s.tgWavesNow(d) : null;
|
|
1889
|
+
// When the current segment began: the step's own start where demo.json says it, else when the kiosk first saw it.
|
|
1890
|
+
const probe = trackModel(track, { demo: d, pulls: trackState.pulls, since: t, now: t });
|
|
1891
|
+
const key = probe ? `${probe.at.chapter}|${probe.at.segment}` : null;
|
|
1892
|
+
if (key !== trackState.key) {
|
|
1893
|
+
const from = !d.storyAhead && d.next && d.next.from ? Date.parse(d.next.from) : NaN;
|
|
1894
|
+
trackState.key = key;
|
|
1895
|
+
trackState.since = Number.isFinite(from) && from <= t && t - from < 600_000 ? from : t;
|
|
1896
|
+
}
|
|
1897
|
+
const model = trackModel(track, { demo: d, pulls: trackState.pulls, since: trackState.since, now: t, waves: live ? live.waves : null });
|
|
1898
|
+
s.trackModel = model;
|
|
1899
|
+
drawTrack(trackHost, model);
|
|
1900
|
+
// In the trail's place: over the caption.
|
|
1901
|
+
const cap = shownCaption().getBoundingClientRect();
|
|
1902
|
+
if (trackHost.style) trackHost.style.bottom = cap.height ? `${Math.round((typeof window !== "undefined" ? window.innerHeight : 0) - cap.top)}px` : "";
|
|
1903
|
+
// The "Waiting on…" modal: a quiet stretch on a step that waits on something, never while the apply's events come in.
|
|
1904
|
+
// Once the play shows anything of this run under way (a wave or a card), nothing waits on the apply to start.
|
|
1905
|
+
// behold#741: a terragucci apply is under way once any wave of its run view has moved.
|
|
1906
|
+
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")));
|
|
1907
|
+
s.waitingNow = waitingSpec(model, { quietMs: s.quietFor || 0, applyLive });
|
|
1561
1908
|
}
|
|
1562
1909
|
function drawWatch(at) {
|
|
1563
1910
|
if (!watch || !s.watchMode) return;
|
|
1564
1911
|
const d = s.demo && s.demo.demo;
|
|
1565
1912
|
drawCaption(watch.caption, s, at);
|
|
1913
|
+
drawChantTrack(d, at);
|
|
1566
1914
|
const hold = d ? holdModel(s, d) : null;
|
|
1567
1915
|
const gate = !!hold && (hold.kind === "approval" || hold.kind === "driver");
|
|
1568
1916
|
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
1917
|
s.shot = shot;
|
|
1570
1918
|
const nums = waveBadges(s.metrics);
|
|
1571
|
-
const
|
|
1919
|
+
const opened = drawerWave !== null;
|
|
1920
|
+
// On a held small stage nothing overlays the graph (web/kiosk-watch.js watchOverlays): the approval, the result and the
|
|
1921
|
+
// running job are the caption's quiet lines there. Any other stage shows its cards as it always has.
|
|
1922
|
+
const shows = watchOverlays({ kind: shot.kind, opened, held: !!s.stageHeld });
|
|
1923
|
+
const call = shows.callout && shot.kind === "held" && gate;
|
|
1572
1924
|
watch.callout.hidden = !call;
|
|
1573
1925
|
if (call) drawCallout(watch.callout, s, hold, badgeTitle(nums[hold.wave]));
|
|
1574
|
-
const
|
|
1575
|
-
const drawer = shot.kind === "active" || opened;
|
|
1926
|
+
const drawer = shows.drawer;
|
|
1576
1927
|
const drawerOn = opened ? drawerWave : shot.waves[0];
|
|
1577
1928
|
const open = drawer && (drawerOpen || drawerHover || opened);
|
|
1578
1929
|
watch.drawer.hidden = !drawer;
|
|
@@ -1584,7 +1935,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1584
1935
|
if (drawer) drawDrawer(watch.drawer, tail, badgeTitle(nums[drawerOn]), open);
|
|
1585
1936
|
if (drawer) traceDrawer(d, drawerOn);
|
|
1586
1937
|
// 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;
|
|
1938
|
+
const result = shows.result && shot.kind === "result" && !opened ? resultModel(d, s.metrics, s.steady) || (s.chantResult ? s.chantResult(d) : null) : null;
|
|
1588
1939
|
watch.result.hidden = !result;
|
|
1589
1940
|
if (result) drawResult(watch.result, result, s);
|
|
1590
1941
|
// On a phone the delivery numbers stack under the rest, where the header has no room for them.
|
|
@@ -1596,8 +1947,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1596
1947
|
foot.textContent = doraLine(s.metrics) || "";
|
|
1597
1948
|
watch.badges.replaceChildren();
|
|
1598
1949
|
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)) {
|
|
1950
|
+
// At applied the result card lists every wave's numbers, so the boxes carry none; a held small stage carries none at all.
|
|
1951
|
+
for (const [n, words] of !shows.badges || (shot.kind === "result" && result) ? [] : Object.entries(nums)) {
|
|
1601
1952
|
if (Number(n) === skip) continue;
|
|
1602
1953
|
const b = el("span", "k-badge", words);
|
|
1603
1954
|
b.dataset.kWave = n;
|
|
@@ -1658,14 +2009,17 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1658
2009
|
};
|
|
1659
2010
|
const taken = [];
|
|
1660
2011
|
// 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
|
-
|
|
2012
|
+
// On a held small stage a drawer the viewer opened sits at the stage top right.
|
|
2013
|
+
const carvingNow = shownCaption() !== watch.caption || !!s.stageHeld;
|
|
1662
2014
|
const put = (node, n) => {
|
|
1663
2015
|
if (node.hidden) return;
|
|
1664
2016
|
const size = { w: node.offsetWidth, h: node.offsetHeight };
|
|
1665
2017
|
const box = carvingNow ? null : boxOf(n);
|
|
1666
2018
|
// Before the frame says where the box is: the right of the view, under its top.
|
|
1667
|
-
|
|
1668
|
-
const
|
|
2019
|
+
// The frame's own controls at its top right (⤢ fit, ↺ layout: web/index.html) are kept clear too.
|
|
2020
|
+
const chrome = { x: view.x + view.w - FRAME_CONTROLS.w, y: view.y, w: FRAME_CONTROLS.w, h: FRAME_CONTROLS.h };
|
|
2021
|
+
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];
|
|
2022
|
+
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
2023
|
// The result card stands level with the middle of the graph it sums up.
|
|
1670
2024
|
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
2025
|
node.style.transform = `translate(${Math.round(p.x)}px, ${Math.round(p.y)}px)`;
|
|
@@ -1704,6 +2058,14 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1704
2058
|
if (e.data.type === "behold:viewer") return holdShot();
|
|
1705
2059
|
if (e.data.type !== "behold:boxes") return;
|
|
1706
2060
|
s.boxes = e.data;
|
|
2061
|
+
// A held small stage: nothing the step shows overlays the graph (watchOverlays), and a drawer the viewer opens
|
|
2062
|
+
// sits at the stage's top right, not by a box. body.k-held says so, for a check from outside.
|
|
2063
|
+
const held = !!e.data.held;
|
|
2064
|
+
if (held !== !!s.stageHeld) {
|
|
2065
|
+
s.stageHeld = held;
|
|
2066
|
+
if (document.body && document.body.classList) document.body.classList.toggle("k-held", held);
|
|
2067
|
+
draw();
|
|
2068
|
+
}
|
|
1707
2069
|
if (ehApi) ehApi.follow();
|
|
1708
2070
|
if (queued) return;
|
|
1709
2071
|
queued = true;
|
|
@@ -1772,7 +2134,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1772
2134
|
return {
|
|
1773
2135
|
demo: d,
|
|
1774
2136
|
answer: s.answer,
|
|
1775
|
-
|
|
2137
|
+
// behold#741: told at the pace the graph plays the waves, while a terragucci story is on.
|
|
2138
|
+
progress: s.tgStory && s.tgPaced ? s.tgPaced() : s.steady,
|
|
1776
2139
|
runDoc: runsApi && runsApi.run ? runsApi.run.doc : null,
|
|
1777
2140
|
// The cycle's runs the approval panel reads, for the failures of runs the pane no longer shows.
|
|
1778
2141
|
runDocs: ap.list,
|
|
@@ -1780,6 +2143,15 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1780
2143
|
metrics: s.metrics,
|
|
1781
2144
|
waves: s.waves,
|
|
1782
2145
|
boxes: s.boxes,
|
|
2146
|
+
// behold#631: a chant repo's pull-request loop, whose story Tips tell its own way.
|
|
2147
|
+
chant: !!s.chantLoop,
|
|
2148
|
+
// behold#741: a terragucci repo's chapter-carrying scenario gets the kiosk's look (one tip at a time, modals
|
|
2149
|
+
// off the cards and above the band) but keeps its own story order: its gates come after the merge.
|
|
2150
|
+
story: storyOn(s),
|
|
2151
|
+
// Its projected track replaces the chip strip, and its quiet stretches get a "Waiting on…" modal,
|
|
2152
|
+
// which the approval card beside the graph wins over.
|
|
2153
|
+
hideTrail: !!(storyOn(s) && s.trackOn && s.watchMode),
|
|
2154
|
+
waiting: storyOn(s) && s.watchMode && !(watch && watch.callout && !watch.callout.hidden) ? s.waitingNow || null : null,
|
|
1783
2155
|
frame,
|
|
1784
2156
|
watch: s.watchMode,
|
|
1785
2157
|
// The caption shown now: the live carve's while it has the camera (web/kiosk-carve.js).
|
|
@@ -1787,7 +2159,9 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1787
2159
|
replay: s.mode === "replay",
|
|
1788
2160
|
approveLine: appr ? appr.approve : null,
|
|
1789
2161
|
label: d.label || "",
|
|
1790
|
-
result: resultModel(d, s.metrics, s.steady),
|
|
2162
|
+
result: resultModel(d, s.metrics, s.steady) || (s.chantResult ? s.chantResult(d) : null),
|
|
2163
|
+
// A held small stage (one framing): no modal and no Tips bubble over the graph in Watch there.
|
|
2164
|
+
held: !!s.stageHeld,
|
|
1791
2165
|
waveTraces: s.waveTraces,
|
|
1792
2166
|
strip: s.stripReady() ? s.strip : null,
|
|
1793
2167
|
stripReady: s.stripReady(),
|
|
@@ -1834,7 +2208,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1834
2208
|
drawerWave = null;
|
|
1835
2209
|
drawerView = null;
|
|
1836
2210
|
}
|
|
1837
|
-
|
|
2211
|
+
// behold#752: chant's demo has no forge runs for Tempo to have traced.
|
|
2212
|
+
if (tracesBusy || reads.own || !d || !d.repo || !runsApi || !runsApi.index || !runsApi.index.doc) return;
|
|
1838
2213
|
if (!["merged", "applying", "waiting", "approved", "failed", "resumed", "applied"].includes(d.step)) return;
|
|
1839
2214
|
tracesBusy = true;
|
|
1840
2215
|
try {
|
|
@@ -1865,6 +2240,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1865
2240
|
// 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
2241
|
const strips = new Map();
|
|
1867
2242
|
s.strip = null;
|
|
2243
|
+
/** behold#631: the running tool's last finished cycle, when one is published. */
|
|
2244
|
+
s.lastCycle = () => {
|
|
2245
|
+
const d = s.demo && s.demo.demo;
|
|
2246
|
+
const t = vendor ? tool : d && typeof d.tool === "string" ? d.tool : null;
|
|
2247
|
+
const r = t ? strips.get(t) : null;
|
|
2248
|
+
return r && r.cycle ? r.cycle : null;
|
|
2249
|
+
};
|
|
1868
2250
|
/** 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
2251
|
s.stripReady = () => {
|
|
1870
2252
|
const d = s.demo && s.demo.demo;
|
|
@@ -1885,10 +2267,11 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1885
2267
|
}
|
|
1886
2268
|
return;
|
|
1887
2269
|
}
|
|
1888
|
-
strips.set(t, { at: now().getTime(), strip: had ? had.strip : null, done: had ? had.done : false });
|
|
1889
|
-
const a = await fetchServed(
|
|
2270
|
+
strips.set(t, { at: now().getTime(), strip: had ? had.strip : null, done: had ? had.done : false, cycle: had ? had.cycle : null });
|
|
2271
|
+
const a = await fetchServed(reads.cycle(t));
|
|
1890
2272
|
const strip = a && a.cycle && Array.isArray(a.cycle.steps) ? stripFromSteps(a.cycle.steps.map((x) => x.step)) : null;
|
|
1891
|
-
|
|
2273
|
+
// behold#631: the cycle itself too, for a chant kiosk's projected track.
|
|
2274
|
+
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
2275
|
s.strip = strips.get(t).strip;
|
|
1893
2276
|
draw();
|
|
1894
2277
|
};
|
|
@@ -1902,13 +2285,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1902
2285
|
// 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
2286
|
const runDocs = new Map();
|
|
1904
2287
|
const runDoc = (id) => {
|
|
1905
|
-
if (!runDocs.has(id)) runDocs.set(id, fetchJson(
|
|
2288
|
+
if (!runDocs.has(id)) runDocs.set(id, fetchJson(reads.run(id)).then((a) => (a && a.doc ? a.doc : null)));
|
|
1906
2289
|
return runDocs.get(id);
|
|
1907
2290
|
};
|
|
1908
2291
|
const replayRuns = async () => {
|
|
1909
2292
|
const r = s.replay;
|
|
1910
2293
|
if (r.runs) return r.runs;
|
|
1911
|
-
const idx = await fetchJson(
|
|
2294
|
+
const idx = await fetchJson(reads.runs);
|
|
1912
2295
|
const listed = new Map((idx && idx.doc && Array.isArray(idx.doc.runs) ? idx.doc.runs : []).map((x) => [x.id, x]));
|
|
1913
2296
|
const runs = [];
|
|
1914
2297
|
for (const id of r.cycle.runs) {
|
|
@@ -1935,25 +2318,31 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1935
2318
|
const d = s.demo && s.demo.demo;
|
|
1936
2319
|
if (!d || !(PANEL_STEPS.includes(d.step) || (s.chantLoop && CHANT_PANEL_STEPS.includes(d.step))) || ap.busy) return;
|
|
1937
2320
|
const t = now().getTime();
|
|
1938
|
-
|
|
2321
|
+
// behold#631: a new step reads at once (the applied step's card shows the moment the play ends, not a poll later).
|
|
2322
|
+
const stepKey = `${d.cycle}|${d.pull}|${d.step}`;
|
|
2323
|
+
// 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.
|
|
2324
|
+
const every = s.chantLoop && ["merged", "applying", "resumed"].includes(d.step) ? CHANT_APPLY_POLL_MS : APPROVAL_POLL_MS;
|
|
2325
|
+
if (t - ap.at < every && !(s.chantLoop && ap.stepKey !== stepKey)) return;
|
|
2326
|
+
ap.stepKey = stepKey;
|
|
1939
2327
|
ap.busy = true;
|
|
1940
2328
|
ap.at = t;
|
|
1941
2329
|
try {
|
|
1942
2330
|
const src = runsSource();
|
|
1943
|
-
const raw = src ? await src.index() : await fetchJson(
|
|
2331
|
+
const raw = src ? await src.index() : await fetchJson(reads.runs);
|
|
1944
2332
|
const idx = vendor ? filterIndex(raw, { tool, repo: s.repo }) : raw;
|
|
1945
2333
|
const mine = cycleRuns(idx && idx.doc && Array.isArray(idx.doc.runs) ? idx.doc.runs : [], d);
|
|
1946
2334
|
for (const e of mine) {
|
|
1947
2335
|
const key = `${s.mode}|${e.status}|${e.ended_at}|${src ? Math.floor(shownNow().getTime() / 5000) : ""}`;
|
|
1948
2336
|
const had = ap.runs.get(e.id);
|
|
1949
2337
|
if (had && had.key === key) continue;
|
|
1950
|
-
const r = src ? await src.run(e.id) : await fetchJson(
|
|
2338
|
+
const r = src ? await src.run(e.id) : await fetchJson(reads.run(e.id));
|
|
1951
2339
|
if (r && r.doc) ap.runs.set(e.id, { key, doc: mergeRun(e, r.doc) });
|
|
1952
2340
|
}
|
|
1953
2341
|
ap.list = mine.map((e) => ap.runs.get(e.id)).filter(Boolean).map((x) => x.doc);
|
|
1954
2342
|
if (t - ap.ledgerAt >= LEDGER_POLL_MS) {
|
|
1955
2343
|
ap.ledgerAt = t;
|
|
1956
|
-
|
|
2344
|
+
// behold#752: chant's demo has no terragucci lane; the gate ledger is chant/lifecycle's alone.
|
|
2345
|
+
const [lifecycle, history] = await Promise.all([reads.own ? null : fetchJson("/api/terragucci/lifecycle"), fetchJson("/api/lifecycle/history?limit=200")]);
|
|
1957
2346
|
ap.lifecycle = lifecycle && !lifecycle.error ? lifecycle : null;
|
|
1958
2347
|
ap.history = history && !history.error ? history : null;
|
|
1959
2348
|
}
|
|
@@ -1968,10 +2357,99 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1968
2357
|
}
|
|
1969
2358
|
draw();
|
|
1970
2359
|
};
|
|
2360
|
+
// behold#631: a fast chant apply played at the pace the graph plays it (web/chant-live-pace.js).
|
|
2361
|
+
const chantPacer = createLivePacer();
|
|
2362
|
+
// behold#631: the result card at a chant repo's applied step, from the apply's run events.
|
|
2363
|
+
s.chantResult = (d) => {
|
|
2364
|
+
if (!s.chantLoop || !ap.chant) return null;
|
|
2365
|
+
const a = chantPacer.answer(ap.chant);
|
|
2366
|
+
// Held, as the caption is, until the paced play reaches the end: never a card that counts "0 applied this run".
|
|
2367
|
+
if (chantPacer.pending || !(a.live && a.live.apply && a.live.apply.settled)) return null;
|
|
2368
|
+
return chantResultModel(d, a);
|
|
2369
|
+
};
|
|
2370
|
+
// behold#631: a chant repo's failed and applied steps are told by the graph's paced play: the caption's step line waits
|
|
2371
|
+
// for the play to reach them, and shows the step before until then. The strip still moves.
|
|
2372
|
+
let capShown = null;
|
|
2373
|
+
/** 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. */
|
|
2374
|
+
s.chantWavesNow = (demo) => {
|
|
2375
|
+
if (!s.chantLoop || !ap.chant || !ap.chant.live || !ap.chant.live.apply) return null;
|
|
2376
|
+
if (demo && Number.isInteger(demo.pull) && Number.isInteger(ap.chant.pull) && demo.pull !== ap.chant.pull) return null;
|
|
2377
|
+
const a = chantPacer.answer(ap.chant);
|
|
2378
|
+
return { waves: graphWaves(a.live.apply).map((w) => ({ wave: w.wave, state: w.state })), live: a.live.apply };
|
|
2379
|
+
};
|
|
2380
|
+
// behold#741: a terragucci story's run view, its waves played at the pace chant's are (web/terragucci-live-pace.js).
|
|
2381
|
+
const tgPacer = createProgressPacer();
|
|
2382
|
+
s.tgPaced = () => tgPacer.progress(s.steady);
|
|
2383
|
+
/** behold#741: the run view's waves as the paced graph shows them now, for the track's ticks; null off a terragucci story. */
|
|
2384
|
+
s.tgWavesNow = (demo) => {
|
|
2385
|
+
if (!s.tgStory || !demo || !["merged", "applying", "resumed", "waiting", "approved", "failed", "applied"].includes(demo.step)) return null;
|
|
2386
|
+
const p = s.tgPaced();
|
|
2387
|
+
// Another commit's run view (the change's, while the fix's apply starts) says nothing of this step's.
|
|
2388
|
+
const c = p && p.run && typeof p.run.commit === "string" ? p.run.commit : null;
|
|
2389
|
+
if (c && typeof demo.commit === "string" && demo.commit && !(c.startsWith(demo.commit) || demo.commit.startsWith(c))) return null;
|
|
2390
|
+
const waves = trackWaves(p);
|
|
2391
|
+
if (!waves || !waves.length) return null;
|
|
2392
|
+
const failed = waves.some((w) => w.state === "failed");
|
|
2393
|
+
const done = !tgPacer.pending && !!p && p.watching === false && waves.every((w) => w.state === "applied");
|
|
2394
|
+
return { waves, live: null, tg: true, failed, done };
|
|
2395
|
+
};
|
|
2396
|
+
/**
|
|
2397
|
+
* behold#631: the step as the story tells it now. The driver writes the failed step only once the apply job ends,
|
|
2398
|
+
* seconds after the paced graph has shown the failure, and the applied step after the fix's apply ends. So when the
|
|
2399
|
+
* play reaches a failure, or finishes the fix's apply, while demo.json still names the apply's chapter, the story
|
|
2400
|
+
* moves to the next chapter of the last cycle (its headline, and its first step for the track). demo.json catches
|
|
2401
|
+
* up; the story never goes back within a cycle.
|
|
2402
|
+
*/
|
|
2403
|
+
const story = { cycle: null, n: 0, chapter: null, step: null };
|
|
2404
|
+
/** behold#631: the forge chant's pipeline runs on, from its loop as /api/chant/pr read it. */
|
|
2405
|
+
s.chantForge = () => (ap.chant && ap.chant.loop && ap.chant.loop.forge) || null;
|
|
2406
|
+
s.storyDemo = (d) => {
|
|
2407
|
+
if (!storyOn(s) || !d || !d.chapter || !Number.isInteger(d.chapter.n)) return d;
|
|
2408
|
+
if (story.cycle !== d.cycle) Object.assign(story, { cycle: d.cycle, n: 0, chapter: null, step: null });
|
|
2409
|
+
const steps = (s.lastCycle() || {}).steps || [];
|
|
2410
|
+
const first = (n) => steps.find((x) => x.chapter && x.chapter.n === n) || null;
|
|
2411
|
+
let n = d.chapter.n;
|
|
2412
|
+
let chapter = d.chapter;
|
|
2413
|
+
let step = d.step;
|
|
2414
|
+
const applyStep = ["applying", "merged", "resumed"].includes(d.step);
|
|
2415
|
+
const w = applyStep && s.chantLoop && s.chantWavesNow ? s.chantWavesNow(d) : null;
|
|
2416
|
+
const comps = w && w.live && w.live.components ? Object.values(w.live.components) : [];
|
|
2417
|
+
// behold#741: a terragucci story moves on when the paced run view shows a failure, or every wave applied.
|
|
2418
|
+
const tw = applyStep && !s.chantLoop && s.tgWavesNow ? s.tgWavesNow(d) : null;
|
|
2419
|
+
const ahead = first(n + 1);
|
|
2420
|
+
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)))) {
|
|
2421
|
+
n = ahead.chapter.n;
|
|
2422
|
+
chapter = ahead.chapter;
|
|
2423
|
+
step = ahead.step;
|
|
2424
|
+
}
|
|
2425
|
+
// Never back: a chapter the story has told stays told until demo.json moves past it.
|
|
2426
|
+
if (n > story.n) Object.assign(story, { n, chapter, step });
|
|
2427
|
+
else if (story.n > n && story.chapter) {
|
|
2428
|
+
n = story.n;
|
|
2429
|
+
chapter = story.chapter;
|
|
2430
|
+
step = story.step;
|
|
2431
|
+
}
|
|
2432
|
+
return chapter === d.chapter && step === d.step ? d : { ...d, chapter, step, storyAhead: true };
|
|
2433
|
+
};
|
|
2434
|
+
s.chantCaptionStep = (demo, step) => {
|
|
2435
|
+
const held = s.chantLoop && ap.chant && ap.chant.live && ap.chant.live.apply && demo && ["failed", "applied"].includes(demo.step);
|
|
2436
|
+
if (held) {
|
|
2437
|
+
chantPacer.answer(ap.chant);
|
|
2438
|
+
if (chantPacer.pending && capShown && capShown.id !== demo.step) return capShown;
|
|
2439
|
+
}
|
|
2440
|
+
// behold#741: a terragucci story's failed and applied steps wait, as chant's do, for the paced waves to reach them.
|
|
2441
|
+
if (s.tgStory && demo && ["failed", "applied"].includes(demo.step) && s.tgPaced) {
|
|
2442
|
+
s.tgPaced();
|
|
2443
|
+
if (tgPacer.pending && capShown && capShown.id !== demo.step) return capShown;
|
|
2444
|
+
}
|
|
2445
|
+
capShown = step;
|
|
2446
|
+
return step;
|
|
2447
|
+
};
|
|
1971
2448
|
const approvalNow = () => {
|
|
1972
2449
|
const d = s.demo && s.demo.demo;
|
|
1973
2450
|
// behold#631: chant's gate, one per pull request on the plan's digest, when the repo runs chant's loop.
|
|
1974
|
-
|
|
2451
|
+
// The kiosk's card names the plan by its short id; the approve command is Inspect's.
|
|
2452
|
+
const chant = s.chantLoop && ap.chant ? chantApprovalModel({ demo: d, answer: chantPacer.answer(ap.chant), kiosk: true }) : null;
|
|
1975
2453
|
if (chant) return chant;
|
|
1976
2454
|
if (!d || !PANEL_STEPS.includes(d.step)) return null;
|
|
1977
2455
|
const appr = pendingApproval(d, s.progress);
|
|
@@ -2000,7 +2478,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2000
2478
|
docs.rel = "noopener";
|
|
2001
2479
|
const more = el("p", "k-what-more");
|
|
2002
2480
|
more.append(docs);
|
|
2003
|
-
tools.pop.replaceChildren(el("p", null, WHAT_TEXT), more);
|
|
2481
|
+
tools.pop.replaceChildren(el("p", null, s.source === "chant-demo" ? WHAT_TEXT_CHANT : WHAT_TEXT), more);
|
|
2004
2482
|
};
|
|
2005
2483
|
if (tools && tools.what && tools.pop) {
|
|
2006
2484
|
const setWhat = (open) => {
|
|
@@ -2045,6 +2523,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2045
2523
|
filter: vendor ? (index) => filterIndex(index, { tool, repo: s.repo }) : (index) => index,
|
|
2046
2524
|
replay: () => s.mode === "replay",
|
|
2047
2525
|
hideLine: vendor ? (line) => namesOther(line, tool) : null,
|
|
2526
|
+
urls: { runs: reads.runs, run: reads.run },
|
|
2048
2527
|
},
|
|
2049
2528
|
);
|
|
2050
2529
|
}
|
|
@@ -2146,10 +2625,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2146
2625
|
s.viewCommits = p.viewCommits || null;
|
|
2147
2626
|
if (s.aimed === null && p.viewRepo) s.aimed = p.viewRepo;
|
|
2148
2627
|
}
|
|
2628
|
+
if (p && !p.error) s.single = !Array.isArray(p.viewRepos);
|
|
2149
2629
|
// A chant project's graph is its components (web/app.js bootZoom), so it has that view too.
|
|
2150
2630
|
s.components = !!(p && !p.error && (p.terragucciComponents || chantProject(p)));
|
|
2151
2631
|
// behold#631: a chant project may run chant's pull-request loop; /api/chant/pr says (its `loop`).
|
|
2152
2632
|
s.chantLoop = !!(p && !p.error && !p.terragucciComponents && chantProject(p));
|
|
2633
|
+
// behold#741: a terragucci repo, whose chapter-carrying scenarios get the same look (storyGate).
|
|
2634
|
+
s.tgRepo = !!(p && !p.error && p.terragucciComponents);
|
|
2153
2635
|
// behold#571: the declared roots (their colours' order) and the wave jobs that apply them.
|
|
2154
2636
|
if (p && p.terragucciRoots) {
|
|
2155
2637
|
s.roots = Array.isArray(p.terragucciRoots.roots) ? p.terragucciRoots.roots : [];
|
|
@@ -2157,6 +2639,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2157
2639
|
// behold#571: the tools the repo's jobs run, for a job row whose log isn't read yet.
|
|
2158
2640
|
s.tools = Array.isArray(p.terragucciRoots.tools) ? p.terragucciRoots.tools : [];
|
|
2159
2641
|
s.rootTools = p.terragucciRoots.rootTools && typeof p.terragucciRoots.rootTools === "object" ? p.terragucciRoots.rootTools : {};
|
|
2642
|
+
// behold#741: the forge, for a chapter-carrying scenario's title line.
|
|
2643
|
+
s.tgForge = typeof p.terragucciRoots.forge === "string" ? p.terragucciRoots.forge : null;
|
|
2160
2644
|
} else if (s.aimed) {
|
|
2161
2645
|
s.roots = [];
|
|
2162
2646
|
s.waves = [];
|
|
@@ -2169,6 +2653,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2169
2653
|
void readProject();
|
|
2170
2654
|
|
|
2171
2655
|
const reports = async (fresh) => {
|
|
2656
|
+
// behold#752: chant's demo writes no terragucci reports or run view; its facts come through /api/chant/pr.
|
|
2657
|
+
if (reads.own) return;
|
|
2172
2658
|
s.answer = await fetchJson(`/api/terragucci${fresh ? "?fresh=1" : ""}`);
|
|
2173
2659
|
draw();
|
|
2174
2660
|
};
|
|
@@ -2178,6 +2664,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2178
2664
|
return pinsCommit(pin) ? pin : null;
|
|
2179
2665
|
};
|
|
2180
2666
|
const progress = async (fresh) => {
|
|
2667
|
+
if (reads.own) return;
|
|
2181
2668
|
const pin = pinnedCommit();
|
|
2182
2669
|
const q = new URLSearchParams();
|
|
2183
2670
|
if (pin) q.set("commit", pin);
|
|
@@ -2191,7 +2678,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2191
2678
|
let cycleRead = 0;
|
|
2192
2679
|
const readCycle = async () => {
|
|
2193
2680
|
cycleRead = now().getTime();
|
|
2194
|
-
const a = await fetchJson(
|
|
2681
|
+
const a = await fetchJson(reads.cycle(tool));
|
|
2195
2682
|
if (s.mode === "live") return; // its scenario started while the read was out
|
|
2196
2683
|
if (a && a.cycle) {
|
|
2197
2684
|
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 +2717,51 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2230
2717
|
linkLine.textContent = words || "";
|
|
2231
2718
|
};
|
|
2232
2719
|
|
|
2720
|
+
// A quiet step: when nothing new has come in for a while during a step
|
|
2721
|
+
// that runs, the caption says what is running and for how long
|
|
2722
|
+
// (kiosk-watch.js quietWords). A record is the driver's step, a job or
|
|
2723
|
+
// step changing state in the run's view, or a progress line the carve's
|
|
2724
|
+
// frame has drawn. Never on a replay, and never while the link cue is up.
|
|
2725
|
+
let recordWas = null;
|
|
2726
|
+
let recordAt = null;
|
|
2727
|
+
let stepSeenAt = null;
|
|
2728
|
+
// 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.
|
|
2729
|
+
let quietDemo = null;
|
|
2730
|
+
let writeSeen = null;
|
|
2731
|
+
s.quietTick = () => {
|
|
2732
|
+
const t = now().getTime();
|
|
2733
|
+
const read = s.demo && s.demo.demo;
|
|
2734
|
+
if (read) quietDemo = read;
|
|
2735
|
+
else if (s.mode !== "live") quietDemo = null;
|
|
2736
|
+
const d = quietDemo;
|
|
2737
|
+
const runDoc = runsApi && runsApi.run ? runsApi.run.doc : null;
|
|
2738
|
+
const run = runningStep(runDoc);
|
|
2739
|
+
const w = carveCtl ? carveCtl.lastWriteAt() : null;
|
|
2740
|
+
if (typeof w === "number" && (writeSeen === null || w > writeSeen)) writeSeen = w;
|
|
2741
|
+
// Only a new driver step or a new progress line restarts the clock; a job or step changing state only changes the words.
|
|
2742
|
+
const key = recordKey(d, writeSeen);
|
|
2743
|
+
if (key !== recordWas) {
|
|
2744
|
+
const first = recordWas === null;
|
|
2745
|
+
const stepChanged = !first && recordWas.split("#")[0] !== key.split("#")[0];
|
|
2746
|
+
// 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.
|
|
2747
|
+
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) : [];
|
|
2748
|
+
if (first || stepChanged) stepSeenAt = t;
|
|
2749
|
+
recordWas = key;
|
|
2750
|
+
recordAt = known.length ? Math.max(...known) : t;
|
|
2751
|
+
}
|
|
2752
|
+
s.quiet = quietWords(d, { now: t, lastRecordAt: recordAt, run, stepAt: stepSeenAt, replay: s.mode === "replay", stale: !!linkWords(link) });
|
|
2753
|
+
// behold#631: how long nothing new has come in, for the "Waiting on…" modal.
|
|
2754
|
+
s.quietFor = typeof recordAt === "number" ? t - recordAt : 0;
|
|
2755
|
+
// 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.
|
|
2756
|
+
// With the projected track up, its now line says it: the caption's quiet line goes.
|
|
2757
|
+
if (s.chantLoop && s.quiet && (!(run && run.job) || s.trackOn)) s.quiet = null;
|
|
2758
|
+
// behold#741: with the projected track up on a terragucci story, its now line says it too.
|
|
2759
|
+
else if (s.tgStory && s.quiet && s.trackOn) s.quiet = null;
|
|
2760
|
+
if (carveCtl) carveCtl.setQuiet(s.quiet);
|
|
2761
|
+
};
|
|
2762
|
+
|
|
2233
2763
|
const demo = async () => {
|
|
2234
|
-
const live = await fetchJson(
|
|
2764
|
+
const live = await fetchJson(reads.demo);
|
|
2235
2765
|
noteRead(link, "poll", !readFailed(live), now());
|
|
2236
2766
|
paintLink();
|
|
2237
2767
|
s.live = live;
|
|
@@ -2261,7 +2791,7 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2261
2791
|
setInterval(() => void readApproval(), 1000);
|
|
2262
2792
|
setInterval(draw, 1000);
|
|
2263
2793
|
|
|
2264
|
-
if (typeof EventSource !== "undefined") {
|
|
2794
|
+
if (typeof EventSource !== "undefined" && !reads.own) {
|
|
2265
2795
|
const es = new EventSource("/api/terragucci/events");
|
|
2266
2796
|
// behold#725: the browser retries a dropped stream by itself (CONNECTING);
|
|
2267
2797
|
// one it closed for good (a 404, say) leaves the polls to carry the cue.
|