@intentius/behold 0.29.40 → 0.29.42

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.
Files changed (61) hide show
  1. package/AGENTS.md +180 -10
  2. package/README.md +6 -2
  3. package/dist/cli.js +16121 -13141
  4. package/example-writes/README.md +1 -1
  5. package/example-writes/chant.config.ts +0 -6
  6. package/package.json +5 -2
  7. package/web/app.js +327 -21
  8. package/web/carve-export.js +142 -0
  9. package/web/carve-narration.js +294 -0
  10. package/web/carve-narration.test.js +48 -0
  11. package/web/change-set-overlay.js +147 -0
  12. package/web/change-set-overlay.test.js +83 -0
  13. package/web/dots-border.js +66 -0
  14. package/web/dots-border.test.js +27 -0
  15. package/web/dots-kiosk.js +279 -0
  16. package/web/dots-kiosk.test.js +60 -0
  17. package/web/dots-layout.d.ts +10 -0
  18. package/web/dots-layout.js +201 -0
  19. package/web/dots-live.js +316 -0
  20. package/web/dots-live.test.js +220 -0
  21. package/web/dots-lod.js +122 -0
  22. package/web/dots-lod.test.js +78 -0
  23. package/web/dots-recording.d.ts +7 -0
  24. package/web/dots-recording.js +247 -0
  25. package/web/dots-recording.test.js +71 -0
  26. package/web/dots-scene.js +294 -0
  27. package/web/dots-scene.test.js +118 -0
  28. package/web/dots-timeline.js +128 -0
  29. package/web/dots-timeline.test.js +83 -0
  30. package/web/dots-tour.js +153 -0
  31. package/web/dots.js +2124 -0
  32. package/web/dots.test.js +15 -0
  33. package/web/event-help-modal.js +1 -1
  34. package/web/index.html +215 -121
  35. package/web/kiosk-carve.js +225 -0
  36. package/web/kiosk-carve.test.js +26 -0
  37. package/web/kiosk-event-help-ui.js +7 -1
  38. package/web/kiosk-link.js +68 -0
  39. package/web/kiosk-link.test.js +69 -0
  40. package/web/kiosk-metrics.js +2 -2
  41. package/web/kiosk-trace.js +1 -1
  42. package/web/kiosk.html +186 -135
  43. package/web/kiosk.js +65 -7
  44. package/web/motion.js +42 -0
  45. package/web/motion.test.js +64 -0
  46. package/web/operator.js +1 -1
  47. package/web/run-playhead.js +102 -19
  48. package/web/run-playhead.test.js +81 -11
  49. package/web/terralith.html +2 -2
  50. package/web/theme.js +99 -26
  51. package/web/theme.test.js +70 -6
  52. package/web/tooltip.js +212 -0
  53. package/web/tooltip.test.js +193 -0
  54. package/web/tour-player.js +204 -0
  55. package/web/tour-player.test.js +115 -0
  56. package/web/tours/behold.tour.v1.schema.json +182 -0
  57. package/web/tours/terralith.json +330 -0
  58. package/web/trunk-lane.js +406 -0
  59. package/web/trunk-lane.test.js +224 -0
  60. package/web/workspace-gates.js +29 -4
  61. package/web/workspace-gates.test.js +23 -2
@@ -0,0 +1,225 @@
1
+ // The kiosk's frame for a live carve (#715). When the estate has choudoufu
2
+ // roots or estate rosters, the framed app mounts the dots layer's live driver
3
+ // (web/dots.js, web/dots-live.js). While a migration runs it directs the
4
+ // camera and tells the kiosk, twice a second, what is happening: the beat
5
+ // (title and next line from demo.json, the line under them from the newest
6
+ // progress line), the counts, and where each estate's box is.
7
+ //
8
+ // This draws that: a caption in Watch's caption's place and size (along the
9
+ // stage's bottom on a desktop, under the graph on a phone) with a "live"
10
+ // badge, and Tips bubbles on the first landing in each estate, the first
11
+ // refusal and the end. It hides Watch's own caption only while the carve has
12
+ // the camera, and tells the frame which mode the kiosk is in and how much of
13
+ // it the caption and the cycle's trail cover, so the boxes are framed clear
14
+ // of them. In Inspect the director frames the boxes too while the carve has
15
+ // the camera, unless a person has the graph in hand. A kiosk whose frame
16
+ // never mounts the layer gets no message, and this draws nothing: the kiosk
17
+ // is as it was.
18
+
19
+ import { createNarration } from "./carve-narration.js";
20
+ import { SLOWED } from "./tour-player.js";
21
+
22
+ const STYLE = `
23
+ #k-carve { display: none; }
24
+ body.k-carving #k-caption { display: none; }
25
+ body.k-carving.k-watch #k-carve { display: grid; }
26
+ /* The same place and size as Watch's own caption (web/kiosk.html #k-caption): along the bottom of the stage on a desktop, in the flow under the graph on a phone. */
27
+ #k-carve { position: absolute; left: 5px; right: 5px; bottom: 5px; z-index: 6; grid-template-rows: auto calc(2 * 1.25em * 1.3) calc(2 * 1.25em * 1.3); gap: 0.25em; padding: var(--s3) 1.4em var(--s4); background: var(--surface-pane-b, var(--panel)); border-top: 1px solid var(--rule, var(--line)); border-radius: 0 0 8px 8px; box-shadow: 0 -10px 30px color-mix(in srgb, var(--bg) 70%, transparent); }
28
+ #k-carve .cx-top { display: flex; align-items: baseline; gap: var(--s4); min-width: 0; }
29
+ #k-carve .cx-title { margin: 0; font-size: 1.55em; line-height: 1.2; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
30
+ #k-carve .cx-next { margin: 0 0 0 auto; color: var(--muted); font: 0.92em var(--font-mono); position: relative; padding-bottom: 6px; white-space: nowrap; flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
31
+ #k-carve .cx-nbar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 2px; background: color-mix(in srgb, var(--rule, var(--line)) 55%, transparent); overflow: hidden; }
32
+ #k-carve .cx-nbar-in { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar, var(--bar-pending)); border-radius: inherit; }
33
+ #k-carve .cx-row { margin: 0; display: grid; grid-template-columns: var(--k-label-w, 6.5em) minmax(0, 1fr); column-gap: var(--s4); align-items: start; align-self: stretch; padding-left: var(--s3); line-height: 1.25; box-shadow: inset 3px 0 0 var(--bar, var(--bar-neutral)); color: var(--ink2, var(--fg)); }
34
+ #k-carve .cx-row:first-of-type { box-shadow: inset 5px 0 0 var(--bar, var(--bar-neutral)); }
35
+ #k-carve .cx-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; max-width: 72ch; }
36
+ #k-carve .cx-label { font: 600 0.8rem/1.3 var(--font-ui); color: var(--bar, var(--muted)); padding-top: var(--s3); }
37
+ #k-carve .cx-lead { font-size: 1.3em; font-weight: 600; color: var(--fg); }
38
+ /* behold#725: RECORDED and LIVE stay in capitals: a status badge, not a label. */
39
+ #k-carve .cx-rec { display: inline-block; font: 700 max(11.5px, 0.8rem) var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg); border: 1px solid var(--rule, var(--line)); border-radius: 999px; padding: 1px 8px; cursor: help; vertical-align: 0.15em; margin-right: 8px; }
40
+ #k-carve .cx-badge-live { color: var(--bar-managed); border-color: var(--bar-managed); }
41
+ #k-carve .cx-badge-live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 0.05em; }
42
+ /* behold#725: while the kiosk can't read from behold, the live badge says STALE, dimmed, its dot hollow. */
43
+ #k-carve .cx-badge-stale { color: var(--muted); border-style: dashed; }
44
+ #k-carve .cx-badge-stale::before { content: ""; display: inline-block; width: 7px; height: 7px; box-sizing: border-box; border-radius: 50%; border: 1.5px solid currentColor; margin-right: 6px; vertical-align: 0.05em; }
45
+ #k-carve .cx-tone-busy { --bar: var(--bar-pending); }
46
+ #k-carve .cx-tone-ok { --bar: var(--bar-managed); }
47
+ #k-carve .cx-tone-bad { --bar: var(--bar-degraded); }
48
+ #k-carve .cx-tone-idle { --bar: var(--bar-neutral); }
49
+ /* The live badge's lag: how long since the newest write (web/tour-player.js lagText). */
50
+ #k-carve .cx-lag { font: 600 max(11.5px, 0.8rem) var(--font-mono); color: var(--muted); margin-right: 8px; vertical-align: 0.15em; white-space: nowrap; }
51
+ #k-carve .cx-lag-wait { color: var(--bar-pending); }
52
+ /* The tour (behold.tour/v1): the rail, the chapter's card docked in the caption, the numbers, the notes. */
53
+ #k-carve.cx-tour { grid-template-rows: auto auto auto auto; gap: var(--s1); }
54
+ #k-carve .cx-tour-top { align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s4); }
55
+ #k-carve .cx-tour-top .cx-rec { margin-right: 0; }
56
+ #k-carve .cx-rail { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; align-items: center; min-width: 0; }
57
+ #k-carve .cx-ch { position: relative; display: flex; align-items: baseline; gap: 6px; padding: 2px 8px 4px; border: 1px solid var(--rule, var(--line)); border-radius: 6px; font: 600 max(11.5px, 0.8rem) var(--font-mono); color: var(--muted); white-space: nowrap; }
58
+ #k-carve .cx-ch-done { color: color-mix(in srgb, var(--fg) 70%, var(--muted)); }
59
+ #k-carve .cx-ch-current { color: var(--fg); border-color: var(--bar-pending); }
60
+ #k-carve .cx-ch-name { font: 600 max(11.5px, 0.8rem) var(--font-ui); max-width: 26ch; overflow: hidden; text-overflow: ellipsis; }
61
+ #k-carve .cx-ch-bar { position: absolute; left: 6px; right: 6px; bottom: 2px; height: 2px; border-radius: 1px; background: color-mix(in srgb, var(--rule, var(--line)) 60%, transparent); overflow: hidden; }
62
+ #k-carve .cx-ch-bar::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p, 0) * 100%); background: var(--bar-managed); }
63
+ #k-carve .cx-ch-current .cx-ch-bar::after { background: var(--bar-pending); }
64
+ #k-carve .cx-follow { margin: 0 0 0 auto; display: flex; gap: 8px; align-items: baseline; font: 12px var(--font-ui); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
65
+ #k-carve .cx-follow-label { display: inline-block; font: 600 0.8rem var(--font-ui); }
66
+ #k-carve .cx-follow a { color: var(--focus, var(--fg)); }
67
+ #k-carve .cx-card { padding-left: var(--s3); box-shadow: inset 5px 0 0 var(--bar-pending); }
68
+ #k-carve .cx-card.cx-enter { animation: cx-dock 0.45s ease-out; }
69
+ @keyframes cx-dock { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
70
+ @media (prefers-reduced-motion: reduce) { #k-carve .cx-card.cx-enter { animation: none; } }
71
+ #k-carve .cx-card-title { white-space: normal; font-size: 1.4em; }
72
+ #k-carve .cx-ch-kicker { display: inline-block; font: 600 0.8rem var(--font-ui); color: var(--muted); margin-right: var(--s4); vertical-align: 0.3em; }
73
+ #k-carve .cx-card-line { margin: 0.15em 0 0; color: var(--ink2, var(--fg)); line-height: 1.35; max-width: 90ch; }
74
+ #k-carve .cx-numbers { margin: 0.2em 0 0; display: flex; flex-wrap: wrap; gap: 6px 22px; }
75
+ #k-carve .cx-num { display: flex; flex-direction: column; }
76
+ #k-carve .cx-num dt { font: 600 0.8rem var(--font-ui); color: var(--muted); }
77
+ /* behold#725: sentence case. The tour file writes its labels in lower case ("cycle time"), so the label raises its first letter. */
78
+ #k-carve .cx-label::first-letter, #k-carve .cx-follow-label::first-letter, #k-carve .cx-ch-kicker::first-letter, #k-carve .cx-num dt::first-letter { text-transform: uppercase; }
79
+ #k-carve .cx-num dd { margin: 0; font-size: 1.25em; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
80
+ #k-carve .cx-notes { margin: 0; font: 12px/1.35 var(--font-mono); color: var(--ink2, var(--muted)); padding-left: var(--s3); overflow-wrap: anywhere; }
81
+ /* A phone: in the page's flow under the graph, where Watch's caption goes (web/kiosk.html). */
82
+ @media (max-width: 600px) {
83
+ body.k-watch #k-carve { position: static; order: 1; flex-direction: column; gap: 4px; border-radius: 0; box-shadow: none; border: 0; border-top: 1px solid var(--line); padding: 8px 12px 8px; }
84
+ body.k-carving.k-watch #k-carve { display: flex; }
85
+ #k-carve .cx-top { flex-wrap: wrap; gap: 4px 16px; }
86
+ #k-carve .cx-title { font-size: 16px; white-space: normal; }
87
+ #k-carve .cx-next { margin-left: 0; flex: 1 1 100%; max-width: none; font-size: 13px; padding-bottom: 6px; }
88
+ #k-carve .cx-row { grid-template-columns: 5em minmax(0, 1fr); gap: 8px; padding-left: 8px; }
89
+ #k-carve .cx-row:first-of-type { box-shadow: inset 3px 0 0 var(--bar, var(--bar-neutral)); }
90
+ #k-carve .cx-label { font-size: 11px; padding-top: 3px; }
91
+ #k-carve .cx-lead { font-size: 14px; }
92
+ #k-carve .cx-text { -webkit-line-clamp: unset; display: block; }
93
+ #k-carve .cx-rail { flex-wrap: wrap; }
94
+ #k-carve .cx-ch-name { display: none; }
95
+ #k-carve .cx-follow { margin-left: 0; flex-wrap: wrap; white-space: normal; }
96
+ #k-carve .cx-card-title { font-size: 17px; }
97
+ #k-carve .cx-card-line { font-size: 14px; }
98
+ #k-carve .cx-num dd { font-size: 16px; }
99
+ }
100
+ /* Slowed playback, in Inspect's quiet rows: off (real time) unless a person picks it. */
101
+ .k-slowed { font: 12px var(--font-ui); background: var(--well, transparent); color: var(--fg); border: 1px solid var(--line); border-radius: 5px; padding: 2px 8px; cursor: pointer; }
102
+ .k-slowed[aria-pressed="true"] { border-color: var(--bar-pending); }
103
+ `;
104
+
105
+ /** Whether a message is the framed dots layer's live state, from this origin. */
106
+ export function liveCarveMessage(e, origin) {
107
+ return !!(e && e.origin === origin && e.data && e.data.type === "behold:dots-state" && e.data.live === true);
108
+ }
109
+
110
+ /**
111
+ * Start listening. `frame()`: the iframe shown now; `watch`: Watch's
112
+ * elements (its layer and caption); `eh`: the Tips hosts; `isWatch()`: whether
113
+ * the kiosk is in Watch. Returns `tellMode()`, for the kiosk to call when its
114
+ * mode changes.
115
+ */
116
+ export function startKioskCarve({ frame, watch, eh, origin = location.origin, isWatch = () => true }) {
117
+ const trail = eh && eh.trailHost ? eh.trailHost : null;
118
+ if (typeof window === "undefined" || typeof document === "undefined" || !watch || !watch.layer) return { tellMode() {}, caption: () => (watch ? watch.caption : null), slowedControl: () => null };
119
+ let node = null;
120
+ let narration = null;
121
+ let carving = false;
122
+ // The frame last told the kiosk's mode: a frame swapped in (a new view) is told again.
123
+ let told = null;
124
+ let lastBottom = -1;
125
+ // Slowed playback: a person's choice, real time until then. One button, kept across the header's redraws.
126
+ let slowed = 1;
127
+ let slowedNode = null;
128
+ const slowedButton = () => {
129
+ if (slowedNode || typeof document === "undefined") return slowedNode;
130
+ slowedNode = document.createElement("button");
131
+ slowedNode.type = "button";
132
+ slowedNode.className = "k-slowed";
133
+ const label = () => {
134
+ const at = SLOWED.find((x) => x.n === slowed) || SLOWED[0];
135
+ slowedNode.textContent = at.words;
136
+ slowedNode.setAttribute("aria-pressed", String(slowed !== 1));
137
+ slowedNode.title = slowed === 1 ? "Writes draw as they are read. Click to slow them down." : `Each read's writes are drawn ${at.stepMs} ms apart. Click for the next speed.`;
138
+ };
139
+ label();
140
+ slowedNode.addEventListener("click", () => {
141
+ const i = SLOWED.findIndex((x) => x.n === slowed);
142
+ slowed = SLOWED[(i + 1) % SLOWED.length].n;
143
+ label();
144
+ const f = frame();
145
+ try {
146
+ if (f && f.contentWindow) f.contentWindow.postMessage({ type: "behold:dots-slowed", n: slowed }, origin);
147
+ } catch {
148
+ /* the frame went away */
149
+ }
150
+ });
151
+ return slowedNode;
152
+ };
153
+ const ensure = () => {
154
+ if (node) return;
155
+ const st = document.createElement("style");
156
+ st.textContent = STYLE;
157
+ document.head.appendChild(st);
158
+ node = document.createElement("footer");
159
+ node.id = "k-carve";
160
+ node.setAttribute("aria-live", "polite");
161
+ node.setAttribute("aria-label", "The live carve");
162
+ // Beside Watch's own caption, so it takes the same place in the layout.
163
+ if (watch.caption && watch.caption.parentNode) watch.caption.parentNode.insertBefore(node, watch.caption.nextSibling);
164
+ else watch.layer.appendChild(node);
165
+ narration = createNarration({
166
+ bar: null,
167
+ caption: node,
168
+ tipsHost: eh && eh.tipsHost ? eh.tipsHost : null,
169
+ modalHost: eh && eh.modalHost ? eh.modalHost : null,
170
+ origin: () => {
171
+ const f = frame();
172
+ return f ? f.getBoundingClientRect() : { left: 0, top: 0, width: window.innerWidth, height: window.innerHeight };
173
+ },
174
+ });
175
+ };
176
+ const insets = () => {
177
+ const f = frame();
178
+ if (!f || !node || !carving) return { top: 0, bottom: 0 };
179
+ const g = f.getBoundingClientRect();
180
+ const c = node.getBoundingClientRect();
181
+ // event-help's trail sits on the caption's top edge: the boxes stay clear of both.
182
+ const tr = trail && !trail.hidden ? trail.getBoundingClientRect() : null;
183
+ const top = tr && tr.height && tr.top < c.top && tr.bottom >= c.top - 2 ? tr.top : c.top;
184
+ const over = c.height && top < g.bottom && c.bottom > g.top ? g.bottom - top : 0;
185
+ return { top: 0, bottom: Math.max(0, Math.round(over)) };
186
+ };
187
+ const tellMode = () => {
188
+ const f = frame();
189
+ try {
190
+ if (f && f.contentWindow) f.contentWindow.postMessage({ type: "behold:dots-mode", mode: isWatch() ? "watch" : "inspect", insets: insets() }, origin);
191
+ } catch {
192
+ /* the frame went away */
193
+ }
194
+ };
195
+ window.addEventListener("message", (e) => {
196
+ if (e.origin !== origin || !e.data) return;
197
+ if (e.data.type === "behold:dots-ready" && e.data.live) return void tellMode();
198
+ if (!liveCarveMessage(e, origin)) return;
199
+ const f = frame();
200
+ if (f && e.source && e.source !== f.contentWindow) return;
201
+ ensure();
202
+ if (e.source && e.source !== told) {
203
+ told = e.source;
204
+ tellMode();
205
+ }
206
+ if (!!e.data.carving !== carving) {
207
+ carving = !!e.data.carving;
208
+ document.body.classList.toggle("k-carving", carving);
209
+ tellMode();
210
+ }
211
+ // The caption shows only while the carve has the camera (body.k-carving); the Tips come either way.
212
+ narration.update(e.data);
213
+ // The caption's height follows its words: the frame keeps the boxes clear of it as it changes.
214
+ const ins = insets();
215
+ if (ins.bottom !== lastBottom) {
216
+ lastBottom = ins.bottom;
217
+ tellMode();
218
+ }
219
+ });
220
+ /** The caption shown now: the carve's while it has the camera, so the trail and the shot stay clear of it. */
221
+ const caption = () => (carving && node && isWatch() ? node : watch.caption);
222
+ /** The slowed control for Inspect's quiet rows, once a frame draws a live carve; null before. */
223
+ const slowedControl = () => (node ? slowedButton() : null);
224
+ return { tellMode, caption, slowedControl };
225
+ }
@@ -0,0 +1,26 @@
1
+ // #715: the kiosk takes the live carve's state only from its own origin's
2
+ // frame, and only when the frame says it is live; a kiosk whose frame never
3
+ // mounts the layer is told nothing and draws nothing new.
4
+ import { describe, it, expect } from "vitest";
5
+ import { liveCarveMessage, startKioskCarve } from "./kiosk-carve.js";
6
+ import { badgeText, recordedWords } from "./carve-narration.js";
7
+
8
+ const O = "http://127.0.0.1:4000";
9
+
10
+ describe("the kiosk's live carve (#715)", () => {
11
+ it("reads only a live state from its own origin", () => {
12
+ expect(liveCarveMessage({ origin: O, data: { type: "behold:dots-state", live: true } }, O)).toBe(true);
13
+ expect(liveCarveMessage({ origin: O, data: { type: "behold:dots-state" } }, O)).toBe(false);
14
+ expect(liveCarveMessage({ origin: "http://elsewhere", data: { type: "behold:dots-state", live: true } }, O)).toBe(false);
15
+ expect(liveCarveMessage({ origin: O, data: { type: "behold:shot" } }, O)).toBe(false);
16
+ });
17
+ it("does nothing without Watch's elements", () => {
18
+ expect(() => startKioskCarve({ frame: () => null, watch: null, eh: null, origin: O }).tellMode()).not.toThrow();
19
+ });
20
+ it("says live over a live carve and recorded over a replay", () => {
21
+ const live = { src: "terralith", recording: { kind: "live", resources: 79, migration: "carve", from: "s3://reports" } };
22
+ expect(badgeText(live)).toBe("live");
23
+ expect(recordedWords(live)).toMatch(/^live carve of terralith, 79 resources, drawn from the estate rosters/);
24
+ expect(badgeText({ src: "x", recording: { kind: "carve" } })).toBe("recorded");
25
+ });
26
+ });
@@ -28,11 +28,13 @@ export const TIPS_TITLE = "Short notes on what just happened, beside the things
28
28
  /** The trail's label. */
29
29
  export const TRAIL_WORDS = "This cycle";
30
30
 
31
+ /** The Tips CSS, for a page that draws Tips of its own (web/kiosk-dots.js, #712). */
32
+ export const TIPS_STYLE_ID = "eh-style";
31
33
  const STYLE = `
32
34
  #eh-trail { display: flex; flex-wrap: nowrap; align-items: center; gap: 0.35em; overflow-x: auto; scrollbar-width: none; contain: inline-size; min-width: 0; padding: 0.15em 0.9em 0.3em; font-size: 0.78em; color: var(--muted); min-height: 1.9em; }
33
35
  #eh-trail::-webkit-scrollbar { display: none; }
34
36
  #eh-trail[hidden] { display: none; }
35
- .eh-trail-label { font: 600 0.85em var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 0.3em; white-space: nowrap; }
37
+ .eh-trail-label { font: 600 0.85em var(--font-ui); margin-right: 0.3em; white-space: nowrap; }
36
38
  .eh-chip { flex: none; white-space: nowrap; padding: 0.05em 0.6em; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--rule) 80%, transparent); background: transparent; color: var(--muted); font: inherit; cursor: pointer; box-shadow: inset 3px 0 0 var(--bar, var(--bar-neutral, var(--muted))); }
37
39
  .eh-chip:hover, .eh-chip:focus-visible { color: var(--fg); border-color: var(--focus); }
38
40
  .eh-chip:last-of-type { color: var(--fg); }
@@ -76,6 +78,10 @@ body.k-watch #eh-trail { position: fixed; z-index: 7; left: 5px; right: 5px; pad
76
78
  * clear of every label wins; with none clear, the one covering least. `arrow` is where the tip's notch sits along it, under
77
79
  * the anchor's middle as far as the tip reaches.
78
80
  */
81
+ export function tipsStyle() {
82
+ return STYLE;
83
+ }
84
+
79
85
  export function tipSpot(rect, size, win, labels = []) {
80
86
  const W = win.w || 1600;
81
87
  const w = size.w || 200;
@@ -0,0 +1,68 @@
1
+ // behold#725: whether the kiosk is still hearing from behold. The kiosk redraws
2
+ // every second whether or not its reads come back, so a server that has gone
3
+ // away leaves a screen that looks live and isn't. Each read the kiosk relies
4
+ // on (the demo poll, the event stream) reports here; while any of them is
5
+ // failing, the status line says since when nothing has come in, and that the
6
+ // kiosk keeps trying. The first good read after that clears it.
7
+
8
+ /** A fresh record: no good read yet, nothing failing. */
9
+ export function linkState() {
10
+ return { lastGood: null, failing: new Set() };
11
+ }
12
+
13
+ /** Note a read from `source` at `at` (a Date): it came back (`ok`) or it failed. */
14
+ export function noteRead(st, source, ok, at) {
15
+ if (ok) {
16
+ st.failing.delete(source);
17
+ st.lastGood = at instanceof Date ? at : new Date(at);
18
+ } else st.failing.add(source);
19
+ return st;
20
+ }
21
+
22
+ /** Note that `source` reconnected, without counting it as a read. */
23
+ export function noteBack(st, source) {
24
+ st.failing.delete(source);
25
+ return st;
26
+ }
27
+
28
+ const two = (n) => String(n).padStart(2, "0");
29
+ /** HH:MM:SS in UTC, the kiosk's clock. */
30
+ export function clockUtc(d) {
31
+ return `${two(d.getUTCHours())}:${two(d.getUTCMinutes())}:${two(d.getUTCSeconds())}`;
32
+ }
33
+
34
+ /** The status line's words while a read is failing; null while all is well. */
35
+ export function linkWords(st) {
36
+ if (!st.failing.size) return null;
37
+ return st.lastGood ? `Not updating since ${clockUtc(st.lastGood)} UTC, retrying` : "Not updating yet, retrying";
38
+ }
39
+
40
+ /**
41
+ * Whether an answer from the kiosk's fetch means the read failed: behold
42
+ * could not be reached, or answered with a server error (the fetch marks
43
+ * both `unreachable`). An answer that carries its own `error` (a source that
44
+ * isn't set up, say) is still a read.
45
+ */
46
+ export function readFailed(answer) {
47
+ return !!(answer && answer.unreachable === true);
48
+ }
49
+
50
+ // behold#725: the page's link, shared with the parts of the kiosk that say
51
+ // "live" (the tour's badge and its "last write N s ago"), so they don't claim
52
+ // it while the cue is up. kiosk.js shares its record after every read.
53
+ let shared = null;
54
+ const listeners = new Set();
55
+ /** Share `st` as the page's link and tell every listener. */
56
+ export function shareLink(st) {
57
+ shared = st;
58
+ for (const cb of listeners) cb();
59
+ }
60
+ /** Call `cb` whenever the page's link is shared again. Returns a function that stops it. */
61
+ export function onLinkChange(cb) {
62
+ listeners.add(cb);
63
+ return () => listeners.delete(cb);
64
+ }
65
+ /** Whether the page's link is failing now, and its last good read (a Date, or null before one). */
66
+ export function pageStaleness() {
67
+ return shared && shared.failing.size ? { stale: true, since: shared.lastGood } : { stale: false, since: null };
68
+ }
@@ -0,0 +1,69 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { clockUtc, linkState, linkWords, noteBack, noteRead, onLinkChange, pageStaleness, readFailed, shareLink } from "./kiosk-link.js";
3
+
4
+ // behold#725: the kiosk's stopped-updating cue.
5
+ describe("the kiosk's link to behold (behold#725)", () => {
6
+ const at = (s) => new Date(`2026-10-17T12:03:${s}Z`);
7
+
8
+ it("says nothing while every read comes back", () => {
9
+ const st = linkState();
10
+ noteRead(st, "poll", true, at("04"));
11
+ noteRead(st, "stream", true, at("05"));
12
+ expect(linkWords(st)).toBe(null);
13
+ });
14
+
15
+ it("says since when nothing has come in once a read fails, keeping the last good read's time", () => {
16
+ const st = linkState();
17
+ noteRead(st, "poll", true, at("04"));
18
+ noteRead(st, "poll", false, at("09"));
19
+ expect(linkWords(st)).toBe("Not updating since 12:03:04 UTC, retrying");
20
+ noteRead(st, "poll", false, at("14"));
21
+ expect(linkWords(st)).toBe("Not updating since 12:03:04 UTC, retrying");
22
+ });
23
+
24
+ it("clears on the first good read after", () => {
25
+ const st = linkState();
26
+ noteRead(st, "poll", true, at("04"));
27
+ noteRead(st, "stream", false, at("09"));
28
+ noteRead(st, "stream", true, at("20"));
29
+ expect(linkWords(st)).toBe(null);
30
+ expect(clockUtc(st.lastGood)).toBe("12:03:20");
31
+ });
32
+
33
+ it("stays up while any one source is still failing", () => {
34
+ const st = linkState();
35
+ noteRead(st, "poll", false, at("09"));
36
+ noteRead(st, "stream", false, at("09"));
37
+ noteRead(st, "poll", true, at("10"));
38
+ expect(linkWords(st)).toBe("Not updating since 12:03:10 UTC, retrying");
39
+ noteBack(st, "stream");
40
+ expect(linkWords(st)).toBe(null);
41
+ });
42
+
43
+ it("has words before any good read", () => {
44
+ expect(linkWords(noteRead(linkState(), "poll", false, at("01")))).toBe("Not updating yet, retrying");
45
+ });
46
+
47
+ it("counts an unreachable behold as a failed read, and an answer with its own error as a read", () => {
48
+ expect(readFailed({ error: "x", unreachable: true })).toBe(true);
49
+ expect(readFailed(null)).toBe(false);
50
+ expect(readFailed({ error: "terragucci reports are not configured" })).toBe(false);
51
+ expect(readFailed({ demo: null })).toBe(false);
52
+ });
53
+
54
+ it("shares the page's link with the parts that say live, and tells them when it changes", () => {
55
+ const st = linkState();
56
+ let told = 0;
57
+ const stop = onLinkChange(() => told++);
58
+ shareLink(st);
59
+ expect(pageStaleness()).toEqual({ stale: false, since: null });
60
+ noteRead(st, "poll", true, at("04"));
61
+ noteRead(st, "poll", false, at("09"));
62
+ shareLink(st);
63
+ expect(pageStaleness()).toEqual({ stale: true, since: at("04") });
64
+ expect(told).toBe(2);
65
+ stop();
66
+ shareLink(linkState());
67
+ expect(told).toBe(2);
68
+ });
69
+ });
@@ -178,13 +178,13 @@ body.k-has-metrics #runs-side { grid-row: 1; grid-column: 1; }
178
178
  body.k-has-metrics #runs-main, body.k-has-metrics #view-pane { grid-row: 1 / span 2; }
179
179
  body.k-has-metrics #k-metrics { grid-row: 2; grid-column: 1; max-height: 46vh; }
180
180
  body.k-has-metrics.k-notyet #view-pane { grid-row: 1; }
181
- .k-metrics-head { display: flex; width: 100%; gap: 0.6em; align-items: baseline; padding: 0.55em 1em; background: transparent; border: 0; color: var(--muted); cursor: pointer; text-align: left; font: 600 0.82em var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
181
+ .k-metrics-head { display: flex; width: 100%; gap: 0.6em; align-items: baseline; padding: 0.55em 1em; background: transparent; border: 0; color: var(--muted); cursor: pointer; text-align: left; font: 600 0.82em var(--font-ui); }
182
182
  .k-metrics-head:hover { color: var(--fg); }
183
183
  .k-metrics-head::after { content: " \\25B8"; margin-left: auto; }
184
184
  .k-metrics-open .k-metrics-head::after { content: " \\25BE"; }
185
185
  .k-metrics-count { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted-ink, var(--muted)); }
186
186
  .k-metrics-body { padding: 0 1em 0.7em; }
187
- .k-metrics-label { margin: 0.35em 0 0.2em; font: 600 0.72em var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
187
+ .k-metrics-label { margin: 0.35em 0 0.2em; font: 600 0.8em var(--font-ui); color: var(--muted); }
188
188
  .k-metrics-waves { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35em; }
189
189
  .k-metrics-wave { background: var(--surface-box); border-radius: 6px; padding: 0.3em 0.6em 0.35em; }
190
190
  .k-metrics-wave-head { display: flex; gap: 0.7em; align-items: baseline; font: 700 0.85em var(--font-mono); color: var(--fg); }
@@ -202,7 +202,7 @@ const STYLE = `
202
202
  .t-seg-small .t-tab { font: 600 0.85em var(--font-mono); padding: 0.05em 0.7em; letter-spacing: 0; }
203
203
  .t-tab:hover { color: var(--fg); }
204
204
  .t-tab[aria-pressed="true"], .t-tab[aria-pressed="true"]:hover { color: var(--bg); background: var(--pending); }
205
- .t-sec { font: 600 0.8em var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0.6em 1em 0.25em; }
205
+ .t-sec { font: 600 0.8em var(--font-ui); color: var(--muted); padding: 0.6em 1em 0.25em; }
206
206
  .t-strip, .t-rows { display: flex; flex-direction: column; }
207
207
  .t-row { display: grid; grid-template-columns: minmax(10em, 38%) minmax(0, 1fr) 4.6em; align-items: center; gap: 0.6em; padding: 0.08em 1em; min-height: 1.55em; cursor: default; }
208
208
  .t-row:nth-child(odd) { background: var(--zebra-row); }