@intentius/behold 0.29.47 → 0.29.49
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/dist/cli.js +14 -11
- package/package.json +1 -1
- package/web/app.js +22 -0
- package/web/event-help-modal.js +13 -3
- package/web/kiosk-annotations.js +2 -2
- package/web/kiosk-event-help-ui.js +46 -9
- package/web/kiosk-event-help.js +6 -3
- package/web/kiosk-metrics.js +39 -8
- package/web/kiosk-metrics.test.js +36 -1
- package/web/kiosk-modal-sticky.test.js +27 -3
- package/web/kiosk-popover.js +29 -1
- package/web/kiosk-popover.test.js +32 -0
- package/web/kiosk-replay.test.js +79 -0
- package/web/kiosk-result.test.js +36 -0
- package/web/kiosk-runs.js +12 -0
- package/web/kiosk-story-gate.test.js +22 -1
- package/web/kiosk-trace.js +84 -21
- package/web/kiosk-trace.test.js +56 -10
- package/web/kiosk-track.js +138 -12
- package/web/kiosk-track.test.js +84 -1
- package/web/kiosk-watch.js +3 -1
- package/web/kiosk-watch.test.js +2 -0
- package/web/kiosk-wave-list.js +130 -0
- package/web/kiosk-wave-list.test.js +103 -0
- package/web/kiosk.html +85 -10
- package/web/kiosk.js +328 -54
- package/web/kiosk.test.js +112 -2
- package/web/small-stage.test.js +8 -0
package/web/kiosk.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { linkState, linkWords, noteBack, noteRead, readFailed, shareLink } from "./kiosk-link.js";
|
|
17
17
|
import { CHANT_PANEL_STEPS, chantApprovalModel, chantResultModel } from "./chant-pr-marks.js";
|
|
18
18
|
import { createLivePacer } from "./chant-live-pace.js";
|
|
19
|
-
import { cycleTrack, drawTrack, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
19
|
+
import { applyJobs, cycleTrack, drawTrack, failureAt, seekMs, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
20
20
|
import { FORGES, iconSvg } from "./forge-mark.js";
|
|
21
21
|
import { TOOLS } from "./tool-mark.js";
|
|
22
22
|
import { graphWaves } from "./chant-pr-marks.js";
|
|
@@ -33,6 +33,7 @@ import { cssString, hoverCss, hoverFromMessage, hoverLinks, hoverMessage, isLigh
|
|
|
33
33
|
import { creditLines, filterIndex, keepRun, kioskVendorOf, liveEstimate, liveFor, namesOther, notRunRepo, notRunWords, replayAt, replayBanner, replayIndex, rootNoun, rootWord, runAsOf, scrubDemo, servesRepo, vendorOf } from "./kiosk-vendor.js";
|
|
34
34
|
import { repoParam, repoUrl, stepCheckout } from "./kiosk-repo.js";
|
|
35
35
|
import { startKioskCarve } from "./kiosk-carve.js";
|
|
36
|
+
import { drawWaveList, waveListKey } from "./kiosk-wave-list.js";
|
|
36
37
|
import { readsFor } from "./kiosk-source.js";
|
|
37
38
|
import { STATE_WORDS, changingRoots, costLine, pinsCommit, planFitsPin, pullPin, readEdges, rootsCount, totalsLine, waveRows, blastRows } from "./terragucci-change.js";
|
|
38
39
|
|
|
@@ -759,10 +760,11 @@ export function viewZoom(view) {
|
|
|
759
760
|
|
|
760
761
|
/**
|
|
761
762
|
* The toggle, "Resources | Components", over the frame: the view shown
|
|
762
|
-
* pressed, and a line saying whether the step leads or a click holds it
|
|
763
|
-
* Not drawn at all when the repo
|
|
763
|
+
* pressed, and a line saying whether the step leads or a click holds it
|
|
764
|
+
* (behold#779: a tap, on a touch screen). Not drawn at all when the repo
|
|
765
|
+
* offers no components zoom.
|
|
764
766
|
*/
|
|
765
|
-
export function renderViewToggle(host, shown, { components = false, onPick = () => {} } = {}) {
|
|
767
|
+
export function renderViewToggle(host, shown, { components = false, onPick = () => {}, touch = touchScreen() } = {}) {
|
|
766
768
|
if (!host) return;
|
|
767
769
|
host.replaceChildren();
|
|
768
770
|
host.hidden = !components;
|
|
@@ -780,7 +782,7 @@ export function renderViewToggle(host, shown, { components = false, onPick = ()
|
|
|
780
782
|
}
|
|
781
783
|
host.appendChild(group);
|
|
782
784
|
const on = VIEWS.find((v) => v.id === shown.view);
|
|
783
|
-
const lead = shown.pinned ? `held by a click; the step leads again in ${shown.secs} s` : "follows the step";
|
|
785
|
+
const lead = shown.pinned ? `held by a ${touch ? "tap" : "click"}; the step leads again in ${shown.secs} s` : "follows the step";
|
|
784
786
|
host.appendChild(el("span", "k-view-note", on ? `${on.shows} · ${lead}` : lead));
|
|
785
787
|
}
|
|
786
788
|
|
|
@@ -910,7 +912,8 @@ function drawBar(bar, s, now) {
|
|
|
910
912
|
const head = scenarioHead(demo, { vendor: s.vendor || null });
|
|
911
913
|
|
|
912
914
|
// behold#571: a tool's page says plainly when it replays an earlier run, and when it can't draw the repo's graph.
|
|
913
|
-
if (s.replay && s.replay.
|
|
915
|
+
if (s.replay && s.replay.asked) bar.appendChild(askedLine(s));
|
|
916
|
+
else if (s.replay && s.replay.banner) bar.appendChild(el("p", "k-replay", s.replay.banner));
|
|
914
917
|
if (vendor && s.noReports && (s.mode === "live" || s.mode === "replay")) bar.appendChild(el("p", "k-nograph-note", NO_GRAPH_WORDS));
|
|
915
918
|
const intro = introText(demo);
|
|
916
919
|
|
|
@@ -935,6 +938,9 @@ function drawBar(bar, s, now) {
|
|
|
935
938
|
title.appendChild(el("span", "k-title-text", head.title));
|
|
936
939
|
if (title.setAttribute) title.setAttribute("title", `${head.kicker} · ${head.title || ""}`);
|
|
937
940
|
titleBox.append(over, title);
|
|
941
|
+
// behold#777: a phone's line on what this is, under the title (hidden wider, so the title's box keeps its height).
|
|
942
|
+
const introWords = introFor(s);
|
|
943
|
+
if (introWords) titleBox.appendChild(el("p", "k-w-intro", introWords));
|
|
938
944
|
left.appendChild(titleBox);
|
|
939
945
|
|
|
940
946
|
// The first beat: what changes; between scenarios, what the demo is about.
|
|
@@ -1001,6 +1007,10 @@ function drawBar(bar, s, now) {
|
|
|
1001
1007
|
holdBox.appendChild(a);
|
|
1002
1008
|
} else for (const l of hold.lines) holdBox.appendChild(elRoots("p", l.cls, l.text, s));
|
|
1003
1009
|
}
|
|
1010
|
+
// behold#801: each finished wave's trace, as Watch's result card shows them, under the hold (or in its place).
|
|
1011
|
+
const traces = el("section", "k-i-traces");
|
|
1012
|
+
drawWaveTraces(traces, s);
|
|
1013
|
+
if (!traces.hidden) holdBox.appendChild(traces);
|
|
1004
1014
|
// behold#571: render what's present: an empty hold keeps its place (nothing moves when one comes) but draws no box.
|
|
1005
1015
|
if (!holdBox.children.length) holdBox.className += " k-box-empty";
|
|
1006
1016
|
right.appendChild(holdBox);
|
|
@@ -1047,11 +1057,51 @@ export function renderModeToggle(host, mode, onPick) {
|
|
|
1047
1057
|
}
|
|
1048
1058
|
}
|
|
1049
1059
|
|
|
1050
|
-
/** behold#
|
|
1051
|
-
export function
|
|
1052
|
-
return
|
|
1060
|
+
/** behold#779: a touch screen (a phone), where the viewer taps rather than clicks. */
|
|
1061
|
+
export function touchScreen() {
|
|
1062
|
+
return typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches;
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* behold#571: the words over a held shot, and the button that follows the step again.
|
|
1067
|
+
* behold#779: on a touch screen a tap held it, often a stray one, so the words say so and the button is a big one.
|
|
1068
|
+
*/
|
|
1069
|
+
export function heldWords(secs, touch = false) {
|
|
1070
|
+
return touch ? `Paused where you tapped · the steps go on in ${secs} s` : `Held where you left it · the steps lead again in ${secs} s`;
|
|
1071
|
+
}
|
|
1072
|
+
/** behold#787: the button that ends a replay the viewer asked for. */
|
|
1073
|
+
export const BACK_WORDS = "Back to live";
|
|
1074
|
+
/** behold#787: the done card's chip that replays the cycle's failure. */
|
|
1075
|
+
export const FAILURE_WORDS = "Replay the failure";
|
|
1076
|
+
/** behold#787: how long a replay the viewer asked for runs with no input before the kiosk is live again. */
|
|
1077
|
+
export const REPLAY_IDLE_MS = 180_000;
|
|
1078
|
+
|
|
1079
|
+
/** behold#787: whether the replay is one the viewer asked for, which the live poll leaves alone. */
|
|
1080
|
+
export function viewerReplay(s) {
|
|
1081
|
+
return !!s && s.mode === "replay" && !!s.replay && !!s.replay.asked;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/** behold#787: whether a replay the viewer asked for is over: it reached the cycle's last step (the reset), or `idle` ms went by with no input. */
|
|
1085
|
+
export function replayOver(steps, elapsed, idle) {
|
|
1086
|
+
if (!Array.isArray(steps) || !steps.length) return true;
|
|
1087
|
+
return replayAt(steps, elapsed).index === steps.length - 1 || idle > REPLAY_IDLE_MS;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/** behold#787: the banner of a replay the viewer asked for, with its way back to live. */
|
|
1091
|
+
export function askedLine(s) {
|
|
1092
|
+
const p = el("p", "k-replay k-replay-asked", null);
|
|
1093
|
+
p.setAttribute("role", "status");
|
|
1094
|
+
p.appendChild(el("span", "k-replay-words", s.replay.banner || "Replay of the latest run"));
|
|
1095
|
+
const b = el("button", "k-replay-back", BACK_WORDS);
|
|
1096
|
+
b.type = "button";
|
|
1097
|
+
b.addEventListener("click", () => s.backToLive && s.backToLive());
|
|
1098
|
+
p.appendChild(b);
|
|
1099
|
+
return p;
|
|
1053
1100
|
}
|
|
1054
1101
|
export const FOLLOW_WORDS = "Follow the steps";
|
|
1102
|
+
export const RESUME_WORDS = "Resume now";
|
|
1103
|
+
/** behold#779: how long a tap on a touch screen holds Watch's shot (a click holds it PICK_HOLD_MS). */
|
|
1104
|
+
export const TAP_HOLD_MS = 20_000;
|
|
1055
1105
|
|
|
1056
1106
|
/** Watch's header: the scenario's place and the strip on the left, the delivery numbers on the right. */
|
|
1057
1107
|
function drawWatchHead(bar, s, now) {
|
|
@@ -1064,7 +1114,9 @@ function drawWatchHead(bar, s, now) {
|
|
|
1064
1114
|
// behold#741: a terragucci repo's chapter-carrying scenario names terragucci, its engine and its forge.
|
|
1065
1115
|
// behold#746: a tool's page leaves out the parts (and the tooltip's sentence) that name what it may not.
|
|
1066
1116
|
// On its replay the line's "live demo" goes; the replay's banner follows the line instead.
|
|
1067
|
-
|
|
1117
|
+
// behold#787: and on a replay the viewer asked for.
|
|
1118
|
+
const asked = !!(s.replay && s.replay.asked);
|
|
1119
|
+
const hide = vendor || asked ? (t) => (!!vendor && namesOther(t, s.vendor)) || (s.mode === "replay" && /^live\b/.test(t)) : null;
|
|
1068
1120
|
if (s.chantLoop) place.appendChild(whatLineEl(demo, s.chantForge ? s.chantForge() : null, null, hide, s.source === "chant-demo"));
|
|
1069
1121
|
else place.appendChild(whatLineEl(demo, s.tgForge || null, { tools: s.tools || [] }, hide));
|
|
1070
1122
|
} else {
|
|
@@ -1072,8 +1124,11 @@ function drawWatchHead(bar, s, now) {
|
|
|
1072
1124
|
place.appendChild(el("span", "k-cycle", cycleWords(demo, now)));
|
|
1073
1125
|
}
|
|
1074
1126
|
// 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));
|
|
1127
|
+
if (vendor && s.mode === "replay" && s.replay && s.replay.banner && !s.replay.asked) place.appendChild(el("span", "k-cycle k-w-replay", s.replay.banner));
|
|
1076
1128
|
bar.appendChild(place);
|
|
1129
|
+
if (s.mode === "replay" && s.replay && s.replay.asked) bar.appendChild(askedLine(s));
|
|
1130
|
+
const intro = introFor(s);
|
|
1131
|
+
if (intro) bar.appendChild(el("p", "k-w-intro", intro));
|
|
1077
1132
|
const strip = el("ol", "k-strip");
|
|
1078
1133
|
// behold#631: a chant pull request's wait for its approval comes before its merge. Without a stop of its own on the
|
|
1079
1134
|
// strip it shows as "planned", for the fix's pull request as for the first.
|
|
@@ -1081,8 +1136,9 @@ function drawWatchHead(bar, s, now) {
|
|
|
1081
1136
|
// behold#631: a chant kiosk's projected track says where the cycle is; the rail goes.
|
|
1082
1137
|
if (!s.trackOn) bar.appendChild(strip);
|
|
1083
1138
|
if (s.watchHeld) {
|
|
1084
|
-
const
|
|
1085
|
-
const
|
|
1139
|
+
const touch = touchScreen();
|
|
1140
|
+
const p = el("span", "k-w-held", heldWords(s.watchHeld.secs, touch));
|
|
1141
|
+
const b = el("button", "k-w-resume", touch ? RESUME_WORDS : FOLLOW_WORDS);
|
|
1086
1142
|
b.type = "button";
|
|
1087
1143
|
b.addEventListener("click", () => s.followSteps && s.followSteps());
|
|
1088
1144
|
p.appendChild(b);
|
|
@@ -1091,7 +1147,7 @@ function drawWatchHead(bar, s, now) {
|
|
|
1091
1147
|
const dora = doraLine(s.metrics);
|
|
1092
1148
|
if (dora) {
|
|
1093
1149
|
const p = el("p", "k-w-dora", dora);
|
|
1094
|
-
if (p.setAttribute) p.setAttribute("title", s.metrics && s.metrics.
|
|
1150
|
+
if (p.setAttribute) p.setAttribute("title", [dora, s.metrics && s.metrics.windowNote, s.metrics && s.metrics.note].filter(Boolean).join(". "));
|
|
1095
1151
|
bar.appendChild(p);
|
|
1096
1152
|
}
|
|
1097
1153
|
}
|
|
@@ -1184,6 +1240,25 @@ function drawCaption(host, s, now) {
|
|
|
1184
1240
|
}
|
|
1185
1241
|
}
|
|
1186
1242
|
|
|
1243
|
+
/**
|
|
1244
|
+
* behold#781: Inspect's "The change" block (factLines: the pull request's
|
|
1245
|
+
* totals, its blast radius, what it leaves unchanged), for a phone's Watch,
|
|
1246
|
+
* where the graph's colours were its only telling. CSS shows it on a phone.
|
|
1247
|
+
*/
|
|
1248
|
+
function drawChange(host, s) {
|
|
1249
|
+
const demo = s.demo && s.demo.demo;
|
|
1250
|
+
const parts = demo && !s.noReports ? factLines(demo, s.answer, nounTool(s)) : [];
|
|
1251
|
+
host.hidden = !parts.length;
|
|
1252
|
+
const key = JSON.stringify([parts, s.light, s.rootNames]);
|
|
1253
|
+
if (host.dataset.key === key) return;
|
|
1254
|
+
host.dataset.key = key;
|
|
1255
|
+
host.replaceChildren();
|
|
1256
|
+
if (!parts.length) return;
|
|
1257
|
+
const p = el("p", "k-facts");
|
|
1258
|
+
for (const part of parts) p.appendChild(elRoots("span", "k-fact", part, s));
|
|
1259
|
+
host.append(el("p", "k-change-label", FACTS_LABEL), p);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1187
1262
|
/** The cone plan's line (kiosk-watch.js coneCaption): the plan's words, then the backend's, quieter. */
|
|
1188
1263
|
export function coneEl(cls, c) {
|
|
1189
1264
|
const p = el("p", `${cls} k-cone`);
|
|
@@ -1253,14 +1328,19 @@ export const DRAWER_EMPTY = "The job's lines show here as it writes them.";
|
|
|
1253
1328
|
export const DRAWER_MORE = "Open the log";
|
|
1254
1329
|
export const DRAWER_LESS = "Close";
|
|
1255
1330
|
|
|
1256
|
-
/**
|
|
1257
|
-
|
|
1331
|
+
/**
|
|
1332
|
+
* The result card at the end of the run: the counts, and each wave's numbers.
|
|
1333
|
+
* behold#782: the caption under the graph already says "Applied" and the
|
|
1334
|
+
* step's line, so the card leads with its first count ("3 waves applied") and
|
|
1335
|
+
* leaves the line to the caption.
|
|
1336
|
+
*/
|
|
1337
|
+
export function drawResult(host, model, s) {
|
|
1258
1338
|
host.replaceChildren();
|
|
1259
|
-
|
|
1260
|
-
|
|
1339
|
+
const [lead, ...rest] = model.counts.length ? model.counts : [model.head];
|
|
1340
|
+
host.appendChild(el("p", "k-result-head", lead));
|
|
1261
1341
|
const counts = el("ul", "k-result-counts");
|
|
1262
|
-
for (const c of
|
|
1263
|
-
host.appendChild(counts);
|
|
1342
|
+
for (const c of rest) counts.appendChild(el("li", null, c));
|
|
1343
|
+
if (rest.length) host.appendChild(counts);
|
|
1264
1344
|
// behold#571: a row for every wave, in wave order: its trace as one bar of its phases (a click opens the whole trace),
|
|
1265
1345
|
// else its numbers, else a quiet line until they land. Never fewer rows than the count says.
|
|
1266
1346
|
const bars = new Map(miniWaterfall(s.waveTraces || {}).map((r) => [r.wave, r]));
|
|
@@ -1276,34 +1356,84 @@ function drawResult(host, model, s) {
|
|
|
1276
1356
|
wf.appendChild(row);
|
|
1277
1357
|
continue;
|
|
1278
1358
|
}
|
|
1279
|
-
|
|
1280
|
-
row.type = "button";
|
|
1281
|
-
const held = r.bars.find((b) => b.phase === "held");
|
|
1282
|
-
row.title = `${TRACE_OPEN_WORDS} · ${r.bars.map(phaseWords).join(" · ")}`;
|
|
1283
|
-
const track = el("span", "k-wf-track");
|
|
1284
|
-
for (const b of r.bars) {
|
|
1285
|
-
const seg = el("i", `k-wf-seg k-wf-${b.phase}`);
|
|
1286
|
-
seg.style.left = `${(b.at * 100).toFixed(2)}%`;
|
|
1287
|
-
seg.style.width = `${Math.max(0.6, b.width * 100).toFixed(2)}%`;
|
|
1288
|
-
seg.title = phaseWords(b);
|
|
1289
|
-
track.appendChild(seg);
|
|
1290
|
-
}
|
|
1291
|
-
row.append(el("span", "k-wf-wave", `Wave ${r.wave}`), track, el("span", "k-wf-ms", held ? phaseWords(held) : r.words), el("span", "k-wf-go", TRACE_LINK_WORDS));
|
|
1292
|
-
row.addEventListener("click", () => s.openWave && s.openWave(r.wave, "trace"));
|
|
1293
|
-
wf.appendChild(row);
|
|
1294
|
-
}
|
|
1295
|
-
if (bars.size) {
|
|
1296
|
-
const key = el("p", "k-wf-key");
|
|
1297
|
-
for (const [cls, words] of PHASE_KEY) {
|
|
1298
|
-
const k = el("span");
|
|
1299
|
-
k.append(el("i", `k-wf-sw k-wf-${cls}`), words);
|
|
1300
|
-
key.appendChild(k);
|
|
1301
|
-
}
|
|
1302
|
-
wf.appendChild(key);
|
|
1359
|
+
wf.appendChild(traceRow(r, s));
|
|
1303
1360
|
}
|
|
1361
|
+
if (bars.size) wf.appendChild(phaseKey());
|
|
1304
1362
|
host.appendChild(wf);
|
|
1305
1363
|
}
|
|
1364
|
+
// behold#787: a visitor who missed the failure's few seconds replays them from here.
|
|
1365
|
+
// The card is rebuilt every second: the press is read on the card, so a tap across a rebuild still counts.
|
|
1366
|
+
if (s.failureAt && s.failureAt()) {
|
|
1367
|
+
const b = el("button", "k-result-replay", FAILURE_WORDS);
|
|
1368
|
+
b.type = "button";
|
|
1369
|
+
host.appendChild(b);
|
|
1370
|
+
if (!host.krWired && host.addEventListener) {
|
|
1371
|
+
host.krWired = true;
|
|
1372
|
+
let down = 0;
|
|
1373
|
+
const on = (e) => !!(e.target && e.target.closest && e.target.closest(".k-result-replay"));
|
|
1374
|
+
host.addEventListener("pointerdown", (e) => { down = on(e) ? Date.now() : 0; });
|
|
1375
|
+
host.addEventListener("click", (e) => {
|
|
1376
|
+
const hit = on(e) || (down && Date.now() - down < 1500 && e.target === host);
|
|
1377
|
+
down = 0;
|
|
1378
|
+
if (hit && s.seekTo && s.failureAt()) s.seekTo(s.failureAt());
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/** behold#571: a wave's trace as one bar of its phases, a button that opens the whole trace. */
|
|
1385
|
+
function traceRow(r, s) {
|
|
1386
|
+
const row = el("button", "k-wf-row");
|
|
1387
|
+
row.type = "button";
|
|
1388
|
+
const held = r.bars.find((b) => b.phase === "held");
|
|
1389
|
+
row.title = `${TRACE_OPEN_WORDS} · ${r.bars.map(phaseWords).join(" · ")}`;
|
|
1390
|
+
const track = el("span", "k-wf-track");
|
|
1391
|
+
for (const b of r.bars) {
|
|
1392
|
+
const seg = el("i", `k-wf-seg k-wf-${b.phase}`);
|
|
1393
|
+
seg.style.left = `${(b.at * 100).toFixed(2)}%`;
|
|
1394
|
+
seg.style.width = `${Math.max(0.6, b.width * 100).toFixed(2)}%`;
|
|
1395
|
+
seg.title = phaseWords(b);
|
|
1396
|
+
track.appendChild(seg);
|
|
1397
|
+
}
|
|
1398
|
+
row.append(el("span", "k-wf-wave", `Wave ${r.wave}`), track, el("span", "k-wf-ms", held ? phaseWords(held) : r.words), el("span", "k-wf-go", TRACE_LINK_WORDS));
|
|
1399
|
+
row.addEventListener("click", () => s.openWave && s.openWave(r.wave, "trace"));
|
|
1400
|
+
return row;
|
|
1306
1401
|
}
|
|
1402
|
+
|
|
1403
|
+
/** The phases' key under the trace rows. */
|
|
1404
|
+
function phaseKey() {
|
|
1405
|
+
const key = el("p", "k-wf-key");
|
|
1406
|
+
for (const [cls, words] of PHASE_KEY) {
|
|
1407
|
+
const k = el("span");
|
|
1408
|
+
k.append(el("i", `k-wf-sw k-wf-${cls}`), words);
|
|
1409
|
+
key.appendChild(k);
|
|
1410
|
+
}
|
|
1411
|
+
return key;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/**
|
|
1415
|
+
* behold#775: on a phone, each wave's trace as soon as the wave has one, under
|
|
1416
|
+
* the step: the badges that open a trace on a wider screen have no room
|
|
1417
|
+
* there. The result card carries the same rows at the end, so this goes then.
|
|
1418
|
+
*/
|
|
1419
|
+
export function drawWaveTraces(host, s, { shown = true } = {}) {
|
|
1420
|
+
const rows = shown ? miniWaterfall(s.waveTraces || {}) : [];
|
|
1421
|
+
host.hidden = !rows.length;
|
|
1422
|
+
const key = rows.map((r) => `${r.wave}|${r.run}|${r.ms}`).join(",");
|
|
1423
|
+
// A host built fresh each draw (Inspect's header) may have no dataset to remember its key by.
|
|
1424
|
+
const ds = host.dataset || {};
|
|
1425
|
+
if (ds.key === key) return;
|
|
1426
|
+
ds.key = key;
|
|
1427
|
+
host.replaceChildren();
|
|
1428
|
+
if (!rows.length) return;
|
|
1429
|
+
host.appendChild(el("p", "k-w-traces-head", WAVE_TRACES_WORDS));
|
|
1430
|
+
const wf = el("div", "k-wf");
|
|
1431
|
+
for (const r of rows) wf.appendChild(traceRow(r, s));
|
|
1432
|
+
wf.appendChild(phaseKey());
|
|
1433
|
+
host.appendChild(wf);
|
|
1434
|
+
}
|
|
1435
|
+
/** behold#775: the head over the phone's trace rows. */
|
|
1436
|
+
export const WAVE_TRACES_WORDS = "Each wave's trace, as it finishes";
|
|
1307
1437
|
/** behold#571: a wave's row on the result card before its numbers land. */
|
|
1308
1438
|
export const NUMBERS_SOON = "its numbers land in a moment";
|
|
1309
1439
|
/** behold#571: the words of a trace's links, and the phases' key. */
|
|
@@ -1418,6 +1548,24 @@ export const DRIVER_SIGNS = "Next the driver plays a reviewer outside the change
|
|
|
1418
1548
|
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
1549
|
/** behold#752: the same, for chant's fan-out demo, whose stacks are CloudFormation's. */
|
|
1420
1550
|
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.";
|
|
1551
|
+
/** behold#777: the same, for a terragucci repo's demo, so the popover names what the phone's intro line names. */
|
|
1552
|
+
export const WHAT_TEXT_TG = "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 terragucci, which applies one change to many Terraform or OpenTofu states in waves, run its demo pipeline in a loop.";
|
|
1553
|
+
/** behold#777: "What is this?"'s words for the page: chant's pipeline, a terragucci repo's, or any other. */
|
|
1554
|
+
export function whatTextFor({ chant = false, tg = false } = {}) {
|
|
1555
|
+
return chant ? WHAT_TEXT_CHANT : tg ? WHAT_TEXT_TG : WHAT_TEXT;
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* behold#777: the phone's one line under the title, the popover's first two
|
|
1559
|
+
* sentences cut to one: what behold is, and whose pipeline it watches. None on
|
|
1560
|
+
* a tool's page, which may not name the others.
|
|
1561
|
+
*/
|
|
1562
|
+
export function introLine({ chant = false, tg = false, vendor = false } = {}) {
|
|
1563
|
+
if (vendor) return null;
|
|
1564
|
+
if (tg) return "behold, a live view of infrastructure, watching terragucci apply one change to many states, wave by wave.";
|
|
1565
|
+
if (chant) return "behold, a live view of infrastructure, watching chant's pull-request pipeline apply one change across many stacks.";
|
|
1566
|
+
return "behold, a live view of infrastructure, watching a demo pipeline run one change in a loop.";
|
|
1567
|
+
}
|
|
1568
|
+
const introFor = (s) => introLine({ chant: !!(s.chantLoop || s.source === "chant-demo"), tg: !!s.tgRepo, vendor: !!vendorOf(s.vendor) });
|
|
1421
1569
|
export const WHAT_DOCS = { text: "behold's documentation", url: "https://intentius.io/behold/" };
|
|
1422
1570
|
|
|
1423
1571
|
/** behold#571: a fade at a box's edge where its text goes on past it. */
|
|
@@ -1665,10 +1813,65 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1665
1813
|
if (s.mode !== "replay" || !s.replay) return;
|
|
1666
1814
|
const steps = s.replay.cycle.steps;
|
|
1667
1815
|
const r = replayAt(steps, now().getTime() - s.replay.start);
|
|
1816
|
+
// behold#787: a replay the viewer asked for ends at the cycle's end (its reset), or after a while with no input.
|
|
1817
|
+
if (s.replay.asked && replayOver(steps, now().getTime() - s.replay.start, now().getTime() - s.replay.input)) return leaveReplay();
|
|
1668
1818
|
s.replay.at = r.at;
|
|
1669
|
-
s.replay.banner = replayBanner(s.replay.cycle, liveEstimate(s.live && s.live.demo, s.replay.cycle, now()));
|
|
1670
|
-
setDemo({ source: "replay", read: steps[r.index].at, demo: scrubDemo(steps[r.index], tool) });
|
|
1819
|
+
s.replay.banner = replayBanner(s.replay.cycle, s.replay.asked ? null : liveEstimate(s.live && s.live.demo, s.replay.cycle, now()));
|
|
1820
|
+
setDemo({ source: "replay", read: steps[r.index].at, demo: vendor ? scrubDemo(steps[r.index], tool) : steps[r.index] });
|
|
1821
|
+
};
|
|
1822
|
+
/** behold#787: what a seek or the end of a replay leaves behind: the story's place, the track's, the run view's memo and Watch's hold. */
|
|
1823
|
+
const rewind = () => {
|
|
1824
|
+
if (s.resetStory) s.resetStory();
|
|
1825
|
+
Object.assign(trackState, { cycle: null, pulls: [], key: null, since: null });
|
|
1826
|
+
runMemo = null;
|
|
1827
|
+
watchHoldAt = null;
|
|
1828
|
+
s.watchHeld = null;
|
|
1829
|
+
drawerWave = null;
|
|
1830
|
+
drawerView = null;
|
|
1831
|
+
lastShot = null;
|
|
1832
|
+
};
|
|
1833
|
+
/**
|
|
1834
|
+
* behold#787: replay the track's cycle from `at` (a step's time): the replay a tool's page shows, the viewer's
|
|
1835
|
+
* this time. Within a replay it seeks; the live poll leaves it alone until it ends.
|
|
1836
|
+
*/
|
|
1837
|
+
s.seekTo = (at) => {
|
|
1838
|
+
const cycle = s.mode === "replay" && s.replay ? s.replay.cycle : s.lastCycle();
|
|
1839
|
+
if (!cycle || !Array.isArray(cycle.steps) || !cycle.steps.length) return;
|
|
1840
|
+
const start = now().getTime() - seekMs(cycle, at);
|
|
1841
|
+
if (s.mode === "replay" && s.replay) s.replay.start = start;
|
|
1842
|
+
else {
|
|
1843
|
+
s.replay = { cycle, start, at: null, banner: null, runs: null, asked: true };
|
|
1844
|
+
s.mode = "replay";
|
|
1845
|
+
s.repo = cycle.repo || s.repo;
|
|
1846
|
+
}
|
|
1847
|
+
s.replay.input = now().getTime();
|
|
1848
|
+
rewind();
|
|
1849
|
+
draw();
|
|
1850
|
+
};
|
|
1851
|
+
/** behold#787: the cycle's failure, where the done card's chip replays it from; null for a cycle with none. */
|
|
1852
|
+
s.failureAt = () => failureAt(s.mode === "replay" && s.replay ? s.replay.cycle : s.lastCycle());
|
|
1853
|
+
const leaveReplay = () => {
|
|
1854
|
+
if (!s.replay || !s.replay.asked) return;
|
|
1855
|
+
s.replay = null;
|
|
1856
|
+
s.mode = "live";
|
|
1857
|
+
rewind();
|
|
1858
|
+
if (!vendor && s.live) {
|
|
1859
|
+
s.repo = s.live.demo ? s.live.demo.repo : s.repo;
|
|
1860
|
+
setDemo(s.live);
|
|
1861
|
+
}
|
|
1862
|
+
void demo();
|
|
1863
|
+
};
|
|
1864
|
+
s.backToLive = () => {
|
|
1865
|
+
leaveReplay();
|
|
1866
|
+
draw();
|
|
1671
1867
|
};
|
|
1868
|
+
// behold#787: any input keeps the viewer's replay going.
|
|
1869
|
+
if (typeof document !== "undefined" && document.addEventListener) {
|
|
1870
|
+
const touched = () => {
|
|
1871
|
+
if (s.replay && s.replay.asked) s.replay.input = now().getTime();
|
|
1872
|
+
};
|
|
1873
|
+
for (const ev of ["pointerdown", "keydown", "wheel"]) document.addEventListener(ev, touched, { passive: true, capture: true });
|
|
1874
|
+
}
|
|
1672
1875
|
|
|
1673
1876
|
const draw = () => {
|
|
1674
1877
|
followRepo();
|
|
@@ -1789,7 +1992,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1789
1992
|
};
|
|
1790
1993
|
function holdTick() {
|
|
1791
1994
|
if (watchHoldAt === null) return void (s.watchHeld = null);
|
|
1792
|
-
|
|
1995
|
+
// behold#779: on a touch screen most holds are a stray tap or a scroll over the graph: they hold a shorter time.
|
|
1996
|
+
const left = watchHoldAt + (touchScreen() ? TAP_HOLD_MS : PICK_HOLD_MS) - now().getTime();
|
|
1793
1997
|
if (left <= 0) {
|
|
1794
1998
|
watchHoldAt = null;
|
|
1795
1999
|
s.watchHeld = null;
|
|
@@ -1894,8 +2098,12 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1894
2098
|
trackState.key = key;
|
|
1895
2099
|
trackState.since = Number.isFinite(from) && from <= t && t - from < 600_000 ? from : t;
|
|
1896
2100
|
}
|
|
1897
|
-
|
|
2101
|
+
// behold#774: the run's own jobs say the apply started before its run view does.
|
|
2102
|
+
const jobs = applyJobs(runsApi && runsApi.run ? runsApi.run.doc : null, d);
|
|
2103
|
+
const model = trackModel(track, { demo: d, pulls: trackState.pulls, since: trackState.since, now: t, waves: live ? live.waves : null, jobs, replay: s.mode === "replay" });
|
|
1898
2104
|
s.trackModel = model;
|
|
2105
|
+
// behold#787: a past step's segment replays it.
|
|
2106
|
+
if (model) model.onSeek = s.seekTo;
|
|
1899
2107
|
drawTrack(trackHost, model);
|
|
1900
2108
|
// In the trail's place: over the caption.
|
|
1901
2109
|
const cap = shownCaption().getBoundingClientRect();
|
|
@@ -1945,6 +2153,17 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1945
2153
|
watch.layer.appendChild(foot);
|
|
1946
2154
|
}
|
|
1947
2155
|
foot.textContent = doraLine(s.metrics) || "";
|
|
2156
|
+
// behold#781, behold#776: a phone's Watch says the change in words by the story, and lists the graph's marks.
|
|
2157
|
+
if (watch.change) drawChange(watch.change, s);
|
|
2158
|
+
drawWaves();
|
|
2159
|
+
// behold#775: on a phone, each finished wave's trace under the step (hidden on a wider screen, where the badges open them).
|
|
2160
|
+
let traces = watch.layer.querySelector(":scope > .k-w-traces");
|
|
2161
|
+
if (!traces) {
|
|
2162
|
+
traces = el("section", "k-w-traces");
|
|
2163
|
+
if (traces.setAttribute) traces.setAttribute("aria-label", WAVE_TRACES_WORDS);
|
|
2164
|
+
watch.caption.after ? watch.caption.after(traces) : watch.layer.appendChild(traces);
|
|
2165
|
+
}
|
|
2166
|
+
drawWaveTraces(traces, s, { shown: !result });
|
|
1948
2167
|
watch.badges.replaceChildren();
|
|
1949
2168
|
const skip = call ? hold.wave : drawer ? drawerOn : null;
|
|
1950
2169
|
// At applied the result card lists every wave's numbers, so the boxes carry none; a held small stage carries none at all.
|
|
@@ -1964,6 +2183,40 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
1964
2183
|
}
|
|
1965
2184
|
placeWatch();
|
|
1966
2185
|
}
|
|
2186
|
+
/**
|
|
2187
|
+
* behold#776: the frame's marks as a list (web/kiosk-wave-list.js), drawn
|
|
2188
|
+
* again only when they or the roots opened change, so a tap's row keeps its
|
|
2189
|
+
* place. A tap on a root opens its resources under it and lights its card.
|
|
2190
|
+
*/
|
|
2191
|
+
// Its state lives on `s`, made on first use: drawWatch may run before this part of startKiosk has. Each frame's last
|
|
2192
|
+
// marks are kept by its window, since the next frame posts its own while it loads out of sight, before it swaps in.
|
|
2193
|
+
function waveState() {
|
|
2194
|
+
return s.wl || (s.wl = { by: new WeakMap(), open: new Set(), drawn: null });
|
|
2195
|
+
}
|
|
2196
|
+
if (watch && watch.waves && typeof window !== "undefined" && window.addEventListener) {
|
|
2197
|
+
window.addEventListener("message", (e) => {
|
|
2198
|
+
if (e.origin !== origin || !e.source || !e.data || e.data.type !== "behold:marks") return;
|
|
2199
|
+
waveState().by.set(e.source, e.data.list && Array.isArray(e.data.list.waves) ? e.data.list : null);
|
|
2200
|
+
drawWaves();
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
function drawWaves() {
|
|
2204
|
+
if (!watch || !watch.waves) return;
|
|
2205
|
+
const wl = waveState();
|
|
2206
|
+
s.waveList = (frame && frame.contentWindow && wl.by.get(frame.contentWindow)) || null;
|
|
2207
|
+
const key = `${waveListKey(s.waveList)}|${[...wl.open].join(",")}|${s.light}`;
|
|
2208
|
+
if (key === wl.drawn) return;
|
|
2209
|
+
wl.drawn = key;
|
|
2210
|
+
drawWaveList(watch.waves, s.waveList, {
|
|
2211
|
+
open: wl.open,
|
|
2212
|
+
paint: (_doc, root) => elRoots("span", null, root, s),
|
|
2213
|
+
onToggle: (root) => {
|
|
2214
|
+
if (wl.open.has(root)) wl.open.delete(root);
|
|
2215
|
+
else wl.open.add(root);
|
|
2216
|
+
drawWaves();
|
|
2217
|
+
},
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
1967
2220
|
/**
|
|
1968
2221
|
* behold#571: the active wave's job's trace waterfall (web/kiosk-trace.js),
|
|
1969
2222
|
* in the drawer's mount point: the job that applies the wave, in the run
|
|
@@ -2202,7 +2455,14 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2202
2455
|
const v = view === "trace" && tr ? "trace" : "log";
|
|
2203
2456
|
const w = (s.waves || []).find((x) => x.wave === n);
|
|
2204
2457
|
if (!s.watchMode) {
|
|
2205
|
-
if (runsApi
|
|
2458
|
+
if (!runsApi || !runsApi.showJob || !(tr || w)) return;
|
|
2459
|
+
// behold#775: on a phone the runs fold under "Runs and logs": it opens, and the job's trace comes into view.
|
|
2460
|
+
if (tools && tools.runsToggle) setRunsOpen(true);
|
|
2461
|
+
runsApi.showJob(tr && v === "trace" ? tr.run : runsApi.run && runsApi.run.doc ? runsApi.run.doc.id : null, tr && v === "trace" ? tr.job : w.job, v === "trace" ? "trace" : "steps");
|
|
2462
|
+
if (isPhone() && main && main.querySelector) setTimeout(() => {
|
|
2463
|
+
const at = main.querySelector(".t-tabs") || main.querySelector(".r-steps");
|
|
2464
|
+
if (at && at.scrollIntoView) at.scrollIntoView({ block: "start", behavior: "smooth" });
|
|
2465
|
+
}, 400);
|
|
2206
2466
|
return;
|
|
2207
2467
|
}
|
|
2208
2468
|
drawerWave = n;
|
|
@@ -2264,6 +2524,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2264
2524
|
s.strip = null;
|
|
2265
2525
|
/** behold#631: the running tool's last finished cycle, when one is published. */
|
|
2266
2526
|
s.lastCycle = () => {
|
|
2527
|
+
// behold#787: while it replays, the replayed cycle, though a newer one has ended since.
|
|
2528
|
+
if (s.mode === "replay" && s.replay && s.replay.cycle) return s.replay.cycle;
|
|
2267
2529
|
const d = s.demo && s.demo.demo;
|
|
2268
2530
|
const t = vendor ? tool : d && typeof d.tool === "string" ? d.tool : null;
|
|
2269
2531
|
const r = t ? strips.get(t) : null;
|
|
@@ -2312,19 +2574,23 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2312
2574
|
};
|
|
2313
2575
|
const replayRuns = async () => {
|
|
2314
2576
|
const r = s.replay;
|
|
2577
|
+
// behold#787: a replay the viewer ended while this read was out.
|
|
2578
|
+
if (!r) return [];
|
|
2315
2579
|
if (r.runs) return r.runs;
|
|
2316
2580
|
const idx = await fetchJson(reads.runs);
|
|
2317
2581
|
const listed = new Map((idx && idx.doc && Array.isArray(idx.doc.runs) ? idx.doc.runs : []).map((x) => [x.id, x]));
|
|
2318
2582
|
const runs = [];
|
|
2319
|
-
for (const id of r.cycle.runs) {
|
|
2583
|
+
for (const id of Array.isArray(r.cycle.runs) ? r.cycle.runs : []) {
|
|
2320
2584
|
const e = listed.get(id) || (await runDoc(id));
|
|
2321
2585
|
if (e) runs.push(e);
|
|
2322
2586
|
}
|
|
2323
|
-
|
|
2587
|
+
// behold#787: /kiosk names no tool; the cycle does.
|
|
2588
|
+
r.runs = runs.filter((x) => keepRun(x, { tool: tool || r.cycle.tool, repo: r.cycle.repo }));
|
|
2324
2589
|
return r.runs;
|
|
2325
2590
|
};
|
|
2326
2591
|
const runsSource = () => {
|
|
2327
|
-
|
|
2592
|
+
// behold#787: /kiosk replays too, when the viewer asks.
|
|
2593
|
+
if (s.mode === "live") return null;
|
|
2328
2594
|
if (s.mode !== "replay" || !s.replay) return { index: async () => ({ doc: { schema: "demo.runs/v1", runs: [] } }), run: async () => ({ doc: null, absent: "No run to show yet." }) };
|
|
2329
2595
|
return {
|
|
2330
2596
|
index: async () => replayIndex(await replayRuns(), shownNow().getTime()),
|
|
@@ -2423,6 +2689,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2423
2689
|
* up; the story never goes back within a cycle.
|
|
2424
2690
|
*/
|
|
2425
2691
|
const story = { cycle: null, n: 0, chapter: null, step: null };
|
|
2692
|
+
// behold#787: a seek may go back within a cycle; the story starts from where it lands.
|
|
2693
|
+
s.resetStory = () => Object.assign(story, { cycle: null, n: 0, chapter: null, step: null });
|
|
2426
2694
|
/** behold#631: the forge chant's pipeline runs on, from its loop as /api/chant/pr read it. */
|
|
2427
2695
|
s.chantForge = () => (ap.chant && ap.chant.loop && ap.chant.loop.forge) || null;
|
|
2428
2696
|
s.storyDemo = (d) => {
|
|
@@ -2493,14 +2761,18 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2493
2761
|
|
|
2494
2762
|
// behold#571: "What is this?" opens what behold is over the page (no layout moves); a click elsewhere or Escape closes it.
|
|
2495
2763
|
const whatText = () => {
|
|
2496
|
-
if (!tools || !tools.pop
|
|
2764
|
+
if (!tools || !tools.pop) return;
|
|
2765
|
+
// behold#777: written again once the repo turns out to be terragucci's, so it names what the intro line names.
|
|
2766
|
+
const words = whatTextFor({ chant: !!(s.chantLoop || s.source === "chant-demo"), tg: !!s.tgRepo });
|
|
2767
|
+
if (tools.pop.firstElementChild && tools.pop.dataset.words === words) return;
|
|
2768
|
+
tools.pop.dataset.words = words;
|
|
2497
2769
|
const docs = el("a", null, WHAT_DOCS.text);
|
|
2498
2770
|
docs.href = WHAT_DOCS.url;
|
|
2499
2771
|
docs.target = "_blank";
|
|
2500
2772
|
docs.rel = "noopener";
|
|
2501
2773
|
const more = el("p", "k-what-more");
|
|
2502
2774
|
more.append(docs);
|
|
2503
|
-
tools.pop.replaceChildren(el("p", null,
|
|
2775
|
+
tools.pop.replaceChildren(el("p", null, words), more);
|
|
2504
2776
|
};
|
|
2505
2777
|
if (tools && tools.what && tools.pop) {
|
|
2506
2778
|
const setWhat = (open) => {
|
|
@@ -2788,6 +3060,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2788
3060
|
noteRead(link, "poll", !readFailed(live), now());
|
|
2789
3061
|
paintLink();
|
|
2790
3062
|
s.live = live;
|
|
3063
|
+
// behold#787: the poll leaves a replay the viewer asked for alone; its end takes the live step from here.
|
|
3064
|
+
if (viewerReplay(s)) return draw();
|
|
2791
3065
|
if (!vendor) {
|
|
2792
3066
|
s.repo = live && live.demo ? live.demo.repo : null;
|
|
2793
3067
|
setDemo(live);
|