@intentius/behold 0.29.34 → 0.29.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.29.34",
3
+ "version": "0.29.36",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
package/web/kiosk.html CHANGED
@@ -217,6 +217,28 @@
217
217
  .k-action { font-family: var(--font-mono); color: var(--fg); }
218
218
  .k-when { color: var(--foreign); font-family: var(--font-mono); }
219
219
  .k-next-by { color: var(--muted); }
220
+ /*
221
+ * behold#571: the bar under "next, by the driver", in both layouts: how far the driver's wait
222
+ * has gone (kiosk.js nextProgress), in the step's tone (theme.js barInks, 3:1 in every theme).
223
+ * It is placed, never in the flow, so no row moves when it comes or goes. At the deadline it
224
+ * pulses until the step changes; with no deadline a quiet shimmer runs. Under reduced motion
225
+ * the due bar is steady and full, and there is no shimmer.
226
+ */
227
+ .k-row-next { position: relative; }
228
+ .k-nbar { position: absolute; left: calc(0.75em + var(--k-label-w) + 0.8em); right: 0.2em; bottom: 0; height: 3px; border-radius: 2px; overflow: hidden; pointer-events: none;
229
+ background: color-mix(in srgb, var(--rule) 55%, transparent); }
230
+ .k-nbar-none { display: none; }
231
+ .k-nbar-in { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--k-nbar-fill, 0) * 100%); border-radius: inherit; background: var(--bar, var(--bar-neutral)); }
232
+ .k-nbar-due .k-nbar-in { width: 100%; }
233
+ .k-nbar-wait { background: transparent; }
234
+ .k-nbar-wait .k-nbar-in { width: 30%; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bar, var(--bar-neutral)) 60%, transparent), transparent); }
235
+ @media (prefers-reduced-motion: no-preference) {
236
+ .k-nbar-due .k-nbar-in { animation: k-nbar-pulse 2.4s ease-in-out var(--k-nbar-phase, 0ms) infinite; }
237
+ .k-nbar-wait .k-nbar-in { animation: k-nbar-sweep 2.4s linear var(--k-nbar-phase, 0ms) infinite; }
238
+ }
239
+ @media (prefers-reduced-motion: reduce) { .k-nbar-wait { display: none; } }
240
+ @keyframes k-nbar-pulse { 50% { opacity: 0.5; } }
241
+ @keyframes k-nbar-sweep { from { transform: translateX(-100%); } to { transform: translateX(334%); } }
220
242
  /* The pull request's facts, smallest: each part a chip that wraps whole, never cut off. */
221
243
  .k-row-facts .k-row-label { padding-top: 0.25em; }
222
244
  .k-row-box > p.k-facts { display: flex; flex-wrap: wrap; gap: 0 0.5em; max-width: none; font-size: 0.84em; line-height: 1.45; color: var(--fg); }
@@ -290,19 +312,23 @@
290
312
  .k-brand-logo { width: 1.25em; height: 1.25em; }
291
313
  .k-replay { margin: 0; padding: 0.2em 0.7em; padding-right: 16em; border-left: 4px solid var(--neutral); background: var(--surface-box); color: var(--fg); font-size: 0.92em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
292
314
  /* behold#571: "What is this?" and the theme, at the header's top right, outside the boxes that redraw. */
293
- #k-tools { position: absolute; top: 0.4em; right: 1em; z-index: 5; display: flex; gap: 0.7em; align-items: center; font-size: 0.8em; }
294
- .k-what { font: inherit; color: var(--pending); background: transparent; border: 0; padding: 0.1em 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
315
+ #k-tools { position: absolute; top: 0.35em; right: 1em; z-index: 5; display: flex; gap: 0.6em; align-items: center; font-size: 1em; }
316
+ /* behold#571: the header's controls read as controls: one pill shape, full-size type. */
317
+ .k-pill, .k-menu summary, .eh-switch { display: inline-flex; align-items: center; gap: 0.4em; height: 2em; padding: 0 0.85em; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface-pane-a); color: var(--fg); font: 600 0.92em var(--font-ui); cursor: pointer; }
318
+ .k-menu summary:hover, .eh-switch:hover { border-color: var(--focus); }
319
+ .eh-switch input { accent-color: var(--pending); margin: 0; width: 1em; height: 1em; }
320
+ .k-what { font: 600 0.92em var(--font-ui); color: var(--pending); background: transparent; border: 0; padding: 0.1em 0.2em; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
295
321
  #k-what-pop { position: absolute; top: 1.8em; right: 0; width: min(34em, calc(100vw - 32px)); padding: 0.7em 0.9em; background: var(--surface-pane-b); color: var(--fg); border: 1px solid var(--focus);
296
322
  border-radius: 8px; box-shadow: 0 6px 24px color-mix(in srgb, var(--shadow) 70%, transparent); font-size: 1.15em; line-height: 1.45; }
297
323
  #k-what-pop[hidden] { display: none; }
298
324
  #k-what-pop p { margin: 0; }
299
325
  #k-what-pop .k-what-more { margin-top: 0.5em; }
300
326
  #k-what-pop a { color: var(--focus); }
301
- .k-menu summary { cursor: pointer; color: var(--muted); list-style: none; }
327
+ .k-menu summary { list-style: none; gap: 0; }
302
328
  .k-menu summary::-webkit-details-marker { display: none; }
303
329
  .k-menu summary::after { content: " ▾"; }
304
- .k-menu[open] summary { color: var(--fg); }
305
- .k-menu-body { position: absolute; right: 0; top: 1.8em; padding: 0.5em; background: var(--surface-pane-b); border: 1px solid var(--rule); border-radius: 8px; }
330
+ .k-menu[open] summary { border-color: var(--focus); }
331
+ .k-menu-body { position: absolute; right: 0; top: 2.4em; padding: 0.5em; background: var(--surface-pane-b); border: 1px solid var(--rule); border-radius: 8px; }
306
332
  .k-credit { color: var(--muted); }
307
333
  .k-credit-link { color: var(--fg); }
308
334
  .k-nograph-note { margin: 0; color: var(--muted); font-size: 0.88em; }
@@ -334,6 +360,7 @@
334
360
  .k-row { grid-template-columns: minmax(0, 1fr); row-gap: 0.1em; padding: 0.1em 0 0.1em 0.75em; }
335
361
  .k-row-empty { display: none; }
336
362
  .k-row-label { padding-top: 0; }
363
+ .k-nbar { left: 0.75em; right: 0; }
337
364
  #views { flex-wrap: wrap; gap: 0.3em 0.9em; }
338
365
  .k-strip { flex-wrap: wrap; }
339
366
  .k-right > .k-cycle { padding: 0; }
@@ -342,7 +369,9 @@
342
369
  .k-read-rows { position: static; grid-template-columns: 1fr; border-radius: 6px; box-shadow: none; margin-bottom: 0.3em; }
343
370
  #views { padding-right: 1em; }
344
371
  .k-replay { padding-right: 0.7em; white-space: normal; }
345
- #k-tools { position: static; justify-content: flex-end; margin: 0; padding: 0.4em 16px 0; }
372
+ #k-tools { position: static; justify-content: flex-end; flex-wrap: wrap; row-gap: 0.4em; margin: 0; padding: 0.4em 16px 0; }
373
+ .k-theme-n { display: none; }
374
+ .k-what { white-space: nowrap; }
346
375
  #k-what-pop { right: 16px; left: 16px; width: auto; top: 2.2em; }
347
376
  .k-ap-row { grid-template-columns: 1.1em 5.6em minmax(0, 1fr); }
348
377
  #stage, body.k-nograph #stage { display: flex; flex-direction: column; padding: 0; gap: 0; }
@@ -370,8 +399,8 @@
370
399
  * result a card at the end. The header is one quiet line. Inspect is
371
400
  * the layout above, one click away.
372
401
  */
373
- .k-modes { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
374
- .k-mode { font: 600 0.95em var(--font-ui); color: var(--muted); background: transparent; border: 0; padding: 0.25em 0.9em; cursor: pointer; }
402
+ .k-modes { display: inline-flex; height: 2em; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; background: var(--surface-pane-a); }
403
+ .k-mode { font: 600 0.92em var(--font-ui); color: var(--muted); background: transparent; border: 0; padding: 0 1.1em; cursor: pointer; }
375
404
  .k-mode + .k-mode { border-left: 1px solid var(--rule); }
376
405
  .k-mode:hover { color: var(--fg); }
377
406
  .k-mode-on, .k-mode-on:hover { color: var(--bg); background: var(--pending); }
@@ -384,7 +413,7 @@
384
413
  body.k-watch #view-pane { position: absolute; inset: 0 5px 5px; border-radius: 8px; overflow: hidden; background: var(--bg); }
385
414
  body.k-watch #view { height: 100%; }
386
415
  /* The header, one line: the scenario's place, the steps, the delivery numbers. */
387
- body.k-watch #bar { display: flex; align-items: center; gap: 0.5em 1.2em; min-height: 2.6em; padding: 0.35em 1em; padding-right: 24em; }
416
+ body.k-watch #bar { display: flex; align-items: center; gap: 0.5em 1.2em; min-height: 2.6em; padding: 0.35em 1em; padding-right: calc(var(--k-tools-w, 30em) + 2em); }
388
417
  .k-w-place { display: flex; align-items: baseline; gap: 0.7em; flex: none; white-space: nowrap; }
389
418
  body.k-watch #bar .k-strip { flex: none; }
390
419
  .k-w-place .k-brand { margin: 0; }
@@ -401,6 +430,8 @@
401
430
  .k-cap-title .k-brand { vertical-align: 0; }
402
431
  .k-cap-next { margin-left: auto; color: var(--muted); font-size: 0.92em; white-space: nowrap; flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
403
432
  .k-cap-next .k-action { font-family: var(--font-mono); color: var(--fg); }
433
+ .k-cap-next { position: relative; padding-bottom: 6px; }
434
+ .k-cap-next .k-nbar { left: 0; right: 0; bottom: 0; }
404
435
  /* behold#571: the caption's beats are the lead block's rows: the label in a fixed column, the words beside it (two lines, at most 72ch), a rail down the left; only the step's rail takes its state's colour (theme.js barInks). */
405
436
  .k-cap-row { margin: 0; display: grid; grid-template-columns: var(--k-label-w) minmax(0, 1fr); column-gap: 0.8em; align-items: start; align-self: stretch; padding-left: 0.75em; line-height: 1.25; font-size: 1em; color: color-mix(in srgb, var(--fg) 78%, var(--muted)); box-shadow: inset 3px 0 0 var(--bar, var(--bar-neutral)); }
406
437
  .k-cap-row:empty { box-shadow: none; }
@@ -508,7 +539,7 @@
508
539
  .k-cap-step { order: 2; } .k-cap-changes { order: 3; }
509
540
  .k-cap-title { white-space: normal; font-size: 1.12em; }
510
541
  .k-cap-title .k-kicker { display: block; margin-bottom: 0.1em; }
511
- .k-cap-next { display: none; }
542
+ .k-cap-next { margin-left: 0; flex: 1 1 100%; max-width: none; white-space: normal; }
512
543
  .k-cap-row { grid-template-columns: minmax(0, 1fr); row-gap: 0.1em; } .k-cap-text { -webkit-line-clamp: unset; display: block; } .k-cap-label { padding-top: 0; }
513
544
  .k-cap-lead { font-size: 1.12em; }
514
545
  .k-over, #k-result { position: static; visibility: visible; width: auto; margin: 0 16px; max-height: none; transform: none !important; }
@@ -525,7 +556,7 @@
525
556
  <div id="k-tools">
526
557
  <div id="k-mode" class="k-modes" role="group" aria-label="Layout"></div>
527
558
  <button type="button" class="k-what" aria-expanded="false" aria-controls="k-what-pop">What is this?</button>
528
- <details class="k-menu"><summary>Theme</summary><div class="k-menu-body" id="k-theme"></div></details>
559
+ <details class="k-menu"><summary id="k-theme-name">Theme</summary><div class="k-menu-body" id="k-theme"></div></details>
529
560
  <div id="k-what-pop" role="dialog" aria-label="What is this?" hidden></div>
530
561
  </div>
531
562
  <header id="bar" aria-live="polite"></header>
@@ -561,10 +592,18 @@
561
592
  <div id="eh-tips" aria-live="polite"></div>
562
593
  <div id="eh-modals"></div>
563
594
  <script type="module">
564
- import { initTheme, KIOSK_THEME } from "/theme.js";
595
+ import { initTheme, KIOSK_THEME, getThemeName, onThemeChange } from "/theme.js";
565
596
  import { startKiosk } from "/kiosk.js";
566
597
  import { pageTool } from "/kiosk-vendor.js";
567
598
  initTheme(KIOSK_THEME);
599
+ // behold#571: the theme control names the theme in use.
600
+ const themeName = document.getElementById("k-theme-name");
601
+ const nameTheme = () => { if (!themeName) return; const n = document.createElement("span"); n.className = "k-theme-n"; n.textContent = `: ${getThemeName()}`; themeName.replaceChildren("Theme", n); };
602
+ nameTheme();
603
+ onThemeChange(nameTheme);
604
+ // behold#571: the header keeps clear of the controls at the top right, however wide they are.
605
+ const toolsEl = document.getElementById("k-tools");
606
+ if (toolsEl && typeof ResizeObserver === "function") new ResizeObserver(() => document.documentElement.style.setProperty("--k-tools-w", `${toolsEl.offsetWidth}px`)).observe(toolsEl);
568
607
  // behold#571: /<tool> serves this page with its tool in a meta tag; /kiosk has none.
569
608
  const kiosk = startKiosk(
570
609
  {
package/web/kiosk.js CHANGED
@@ -172,6 +172,64 @@ export function countdownWords(secs) {
172
172
  return `in ${Math.floor(secs / 60)} m ${String(secs % 60).padStart(2, "0")} s`;
173
173
  }
174
174
 
175
+ /**
176
+ * behold#571: how far the driver's wait for its next action has gone, for the
177
+ * bar under "next, by the driver". The bar fills from `next.from` (when the
178
+ * driver started waiting; an older driver leaves it out) to `next.at`. Without `from`
179
+ * it fills from `seen`, when this page first saw that deadline; null when the
180
+ * page joined the countdown midway, and then there is no bar, only the words.
181
+ *
182
+ * kind is "fill" (fraction 0..1), "due" (the deadline passed: a full bar that
183
+ * pulses until the step changes), "wait" (no deadline: the driver waits on the
184
+ * pipeline, a quiet shimmer) or "none" (no bar).
185
+ */
186
+ export function nextProgress(next, now = new Date(), seen = null) {
187
+ if (!next) return { kind: "none", fraction: null };
188
+ if (!next.at) return { kind: "wait", fraction: null };
189
+ const at = Date.parse(next.at);
190
+ if (Number.isNaN(at)) return { kind: "none", fraction: null };
191
+ const t = now.getTime();
192
+ if (t >= at) return { kind: "due", fraction: 1 };
193
+ const parsed = next.from ? Date.parse(next.from) : NaN;
194
+ const from = Number.isNaN(parsed) ? seen : parsed;
195
+ if (typeof from !== "number" || !Number.isFinite(from) || from >= at) return { kind: "none", fraction: null };
196
+ return { kind: "fill", fraction: Math.min(1, Math.max(0, (t - from) / (at - from))) };
197
+ }
198
+
199
+ /**
200
+ * behold#571: when this page first saw each deadline, for nextProgress's
201
+ * `seen`. The deadline on screen when the page loaded, or when the mode
202
+ * changed (live, replay), was seen midway: its `seen` is null. One that came
203
+ * after is seen at `nowMs`. `next` is demo.json's next (null when it has
204
+ * none), or undefined while no demo.json has been read. Returns the memo to
205
+ * keep for the next call.
206
+ */
207
+ export function nextSeen(memo, next, mode, nowMs) {
208
+ // No demo.json read yet: nothing watched.
209
+ if (next === undefined) return memo;
210
+ const key = next && next.at ? `${next.action}|${next.at}` : null;
211
+ if (memo && memo.mode === mode && memo.key === key) return memo;
212
+ return { key, mode, seen: memo && memo.mode === mode && key ? nowMs : null };
213
+ }
214
+
215
+ /** The period of the due bar's pulse and the shimmer's sweep; the redraw rebuilds the bar each second, so it carries its phase. */
216
+ export const NEXT_BAR_MS = 2400;
217
+
218
+ /** behold#571: the bar under "next, by the driver", in the step's tone (theme.js barInks). It never takes room: CSS places it. */
219
+ function nextBar(demo, now, s) {
220
+ const p = nextProgress(demo.next, now, s && s.nextSeen ? s.nextSeen.seen : null);
221
+ const bar = el("span", `k-nbar k-nbar-${p.kind}`);
222
+ if (bar.dataset) bar.dataset.kTone = stepTone(demo.step);
223
+ if (bar.setAttribute) bar.setAttribute("aria-hidden", "true");
224
+ const fill = el("span", "k-nbar-in");
225
+ if (fill.style && fill.style.setProperty) {
226
+ if (p.fraction !== null) fill.style.setProperty("--k-nbar-fill", String(Math.round(p.fraction * 1000) / 1000));
227
+ fill.style.setProperty("--k-nbar-phase", `-${Date.now() % NEXT_BAR_MS}ms`);
228
+ }
229
+ bar.appendChild(fill);
230
+ return bar;
231
+ }
232
+
175
233
  /** The driver's next action, as the kiosk says it. */
176
234
  export function nextWords(demo, now = new Date()) {
177
235
  if (!demo.next) return { action: "reset and start the next cycle", when: "the driver stalled; it resets and starts the next cycle", secs: null };
@@ -737,7 +795,9 @@ function drawBar(bar, s, now) {
737
795
  const nx = nextWords(demo, now);
738
796
  const next = el("p", "k-next");
739
797
  next.append(elRoots("span", "k-action", nx.action, s), " ", el("span", "k-when", nx.when), " ", el("span", "k-next-by", "by the driver"));
740
- left.appendChild(leadRow("next", "k-row-next", "Next", next));
798
+ const nextRow = leadRow("next", "k-row-next", "Next", next);
799
+ nextRow.appendChild(nextBar(demo, now, s));
800
+ left.appendChild(nextRow);
741
801
 
742
802
  // The rest of the card, quieter: each field on its own row (watch for, then what the scenario shows).
743
803
  const more = demo.step === "reset" && intro ? [] : rows.filter((r) => r !== changes);
@@ -875,6 +935,7 @@ function drawCaption(host, s, now) {
875
935
  const nx = el("p", "k-cap-next");
876
936
  nx.append("next, by the driver: ", elRoots("span", "k-action", cap.next.action, s), " ", el("span", "k-when", cap.next.when));
877
937
  if (nx.setAttribute) nx.setAttribute("title", `next, by the driver: ${cap.next.action}`);
938
+ nx.appendChild(nextBar(demo, now, s));
878
939
  top.appendChild(nx);
879
940
  }
880
941
  host.appendChild(top);
@@ -1308,6 +1369,8 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
1308
1369
  const setDemo = (answer) => {
1309
1370
  s.demo = answer;
1310
1371
  const d = answer && answer.demo;
1372
+ // behold#571: when this page first saw the driver's deadline, for the next bar when demo.json has no next.from.
1373
+ s.nextSeen = nextSeen(s.nextSeen, d ? d.next || null : undefined, s.mode, shownNow().getTime());
1311
1374
  if (d && d.scenario && typeof d.title === "string" && d.title) titles[d.scenario] = d.title;
1312
1375
  if (d && d.scenario && scenarioName(d)) names[d.scenario] = scenarioName(d);
1313
1376
  const key = d ? `${s.mode}|${d.cycle}|${d.step}|${d.commit}|${d.pull}` : "";
package/web/kiosk.test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { stepTone, BEAT_CHANGES, INTRO_HEAD, READ_STORE, READ_TITLE, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, factsLine, focusRoots, holdHead, holdModel, introText, readStored, readingRows, renderReading, scenarioHead, frameSrc, factLines, kioskView, matchingPull, pendingApproval, renderKiosk, renderViewToggle, reportless, runPanel, runPin, stepView, viewZoom } from "./kiosk.js";
2
+ import { stepTone, nextProgress, nextSeen, BEAT_CHANGES, INTRO_HEAD, READ_STORE, READ_TITLE, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, factsLine, focusRoots, holdHead, holdModel, introText, readStored, readingRows, renderReading, scenarioHead, frameSrc, factLines, kioskView, matchingPull, pendingApproval, renderKiosk, renderViewToggle, reportless, runPanel, runPin, stepView, viewZoom } from "./kiosk.js";
3
3
  import { VENDORS } from "./kiosk-vendor.js";
4
4
  import { PICK_HOLD_MS } from "./kiosk-runs.js";
5
5
 
@@ -155,7 +155,10 @@ describe("the scenario's card under the title (behold#571)", () => {
155
155
  expect(left.children.map((c) => c.className)).toEqual([
156
156
  "k-box k-box-title", "k-row k-row-beat", "k-row k-row-step k-step-failed", "k-row k-row-next", "k-row k-row-more", "k-row k-row-more", "k-row k-row-facts k-row-empty",
157
157
  ]);
158
- expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-overline", "k-title"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], []]);
158
+ expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-overline", "k-title"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], ["k-row-label", "k-box", "k-nbar"], ["k-row-label", "k-box"], ["k-row-label", "k-box"], []]);
159
+ // The next row's bar is placed by CSS, in the step's tone; a stalled driver's next has none.
160
+ const nbar = find(bar, "k-nbar")[0];
161
+ expect(nbar.className).toBe("k-nbar k-nbar-none");
159
162
  // Each row: its label in the fixed column, its words in the box beside it.
160
163
  const rowsOf = (cls) => find(bar, cls).map((r) => [r.children[0].textContent, r.children[1].children[0].className, r.children[1].children[0].textContent]);
161
164
  expect(rowsOf("k-row-beat")).toEqual([[BEAT_CHANGES, "k-beat", about.changes]]);
@@ -499,3 +502,59 @@ describe("kiosk: the strip in a scenario's own order (behold#571, #631)", async
499
502
  expect(stripFromSteps(["pull-request", "planned", "merged", "applying", "applied", "reset"]).map((x) => x.id)).toEqual(STRIP.map((x) => x.id));
500
503
  });
501
504
  });
505
+
506
+ // behold#571: the bar under "next, by the driver".
507
+ describe("nextProgress and nextSeen", () => {
508
+ const at = "2026-10-16T22:34:35Z";
509
+ const t = (iso) => new Date(iso);
510
+ const ms = (iso) => Date.parse(iso);
511
+
512
+ it("fills from next.from to next.at", () => {
513
+ const next = { action: "approve wave-2", from: "2026-10-16T22:34:15Z", at };
514
+ expect(nextProgress(next, t("2026-10-16T22:34:15Z"))).toEqual({ kind: "fill", fraction: 0 });
515
+ expect(nextProgress(next, t("2026-10-16T22:34:20Z"))).toEqual({ kind: "fill", fraction: 0.25 });
516
+ expect(nextProgress(next, t("2026-10-16T22:34:30Z"))).toEqual({ kind: "fill", fraction: 0.75 });
517
+ // A clock a little behind the driver's never draws below empty.
518
+ expect(nextProgress(next, t("2026-10-16T22:34:10Z")).fraction).toBe(0);
519
+ // from wins over when the page saw it.
520
+ expect(nextProgress(next, t("2026-10-16T22:34:30Z"), ms("2026-10-16T22:34:25Z")).fraction).toBe(0.75);
521
+ });
522
+
523
+ it("is due at and past the deadline, whatever from says", () => {
524
+ expect(nextProgress({ action: "x", from: "2026-10-16T22:34:15Z", at }, t(at))).toEqual({ kind: "due", fraction: 1 });
525
+ expect(nextProgress({ action: "x", at }, t("2026-10-16T22:40:00Z"))).toEqual({ kind: "due", fraction: 1 });
526
+ });
527
+
528
+ it("fills from when the page first saw the deadline when from is missing, and draws no bar when it joined midway", () => {
529
+ const next = { action: "approve wave-2", at };
530
+ expect(nextProgress(next, t("2026-10-16T22:34:25Z"), ms("2026-10-16T22:34:15Z"))).toEqual({ kind: "fill", fraction: 0.5 });
531
+ expect(nextProgress(next, t("2026-10-16T22:34:25Z"), null)).toEqual({ kind: "none", fraction: null });
532
+ // A from that cannot be read falls back the same way.
533
+ expect(nextProgress({ ...next, from: "soon" }, t("2026-10-16T22:34:25Z"), ms("2026-10-16T22:34:15Z")).fraction).toBe(0.5);
534
+ expect(nextProgress({ ...next, from: "2026-10-16T22:34:35Z" }, t("2026-10-16T22:34:25Z"))).toEqual({ kind: "none", fraction: null });
535
+ });
536
+
537
+ it("shimmers with no deadline, and draws nothing when there is no next", () => {
538
+ expect(nextProgress({ action: "follow the waves", from: "2026-10-16T22:34:15Z", at: null }, t(at))).toEqual({ kind: "wait", fraction: null });
539
+ expect(nextProgress(null, t(at))).toEqual({ kind: "none", fraction: null });
540
+ expect(nextProgress({ action: "x", at: "not a time" }, t(at))).toEqual({ kind: "none", fraction: null });
541
+ });
542
+
543
+ it("remembers when the page first saw each deadline: midway for the one on screen at load or after a mode change", () => {
544
+ const a = { action: "approve wave-2", at };
545
+ const b = { action: "merge pull request 41", at: "2026-10-16T22:35:40Z" };
546
+ let m = nextSeen(undefined, a, "live", 1000);
547
+ expect(m.seen).toBeNull();
548
+ expect(nextSeen(m, a, "live", 2000)).toBe(m);
549
+ m = nextSeen(m, { action: "follow the waves", at: null }, "live", 3000);
550
+ expect(m.seen).toBeNull();
551
+ m = nextSeen(m, b, "live", 4000);
552
+ expect(m.seen).toBe(4000);
553
+ expect(nextSeen(m, b, "live", 5000).seen).toBe(4000);
554
+ expect(nextSeen(m, b, "replay", 5000).seen).toBeNull();
555
+ // Until demo.json is read (undefined), the page has watched nothing: the first deadline it reads was joined midway.
556
+ expect(nextSeen(nextSeen(undefined, undefined, "live", 0), a, "live", 6000).seen).toBeNull();
557
+ // Once read, a deadline that comes after a step with none is seen to begin.
558
+ expect(nextSeen(nextSeen(undefined, null, "live", 0), a, "live", 6000).seen).toBe(6000);
559
+ });
560
+ });