@intentius/behold 0.30.0 → 0.30.2

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 (57) hide show
  1. package/AGENTS.md +97 -33
  2. package/README.md +78 -56
  3. package/dist/cli.js +6913 -2448
  4. package/example-choudoufu-estate/chant.workspace.json +1 -1
  5. package/example-terraform-estate/README.md +1 -1
  6. package/example-terraform-estate/chant.workspace.json +1 -1
  7. package/example-terralith/README.md +1 -1
  8. package/example-three-cloud/package-lock.json +19 -19
  9. package/example-three-cloud/package.json +4 -4
  10. package/package.json +5 -5
  11. package/web/app.js +330 -19
  12. package/web/embed.js +2 -2
  13. package/web/event-help-modal.js +18 -12
  14. package/web/event-help-modal.test.js +28 -1
  15. package/web/index.html +18 -0
  16. package/web/kiosk-ask-layout.js +85 -0
  17. package/web/kiosk-ask-layout.test.js +83 -0
  18. package/web/kiosk-ask-tips.js +467 -0
  19. package/web/kiosk-ask-tips.test.js +359 -0
  20. package/web/kiosk-ask.js +774 -0
  21. package/web/kiosk-ask.test.js +593 -0
  22. package/web/kiosk-banner.js +108 -0
  23. package/web/kiosk-banner.test.js +72 -0
  24. package/web/kiosk-center-cards.test.js +110 -0
  25. package/web/kiosk-estate-scene.js +203 -0
  26. package/web/kiosk-estate-scene.test.js +21 -0
  27. package/web/kiosk-event-help.js +4 -1
  28. package/web/kiosk-graph-pane.js +63 -0
  29. package/web/kiosk-graph-pane.test.js +105 -0
  30. package/web/kiosk-light-frame.js +196 -0
  31. package/web/kiosk-light.js +509 -0
  32. package/web/kiosk-light.test.js +297 -0
  33. package/web/kiosk-metrics.js +7 -4
  34. package/web/kiosk-modal-sticky.test.js +2 -1
  35. package/web/kiosk-refit.test.js +81 -0
  36. package/web/kiosk-reset.js +49 -0
  37. package/web/kiosk-reset.test.js +11 -0
  38. package/web/kiosk-shot.js +40 -2
  39. package/web/kiosk-shot.test.js +23 -1
  40. package/web/kiosk-vendor.js +85 -7
  41. package/web/kiosk-vendor.test.js +9 -9
  42. package/web/kiosk-watch.js +8 -4
  43. package/web/kiosk.html +107 -1
  44. package/web/kiosk.js +149 -23
  45. package/web/kiosk.test.js +25 -1
  46. package/web/layout-store.js +3 -3
  47. package/web/small-stage.test.js +4 -0
  48. package/web/terragucci-change.js +30 -13
  49. package/web/tool-mark.js +4 -4
  50. package/web/tool-mark.test.js +1 -1
  51. package/web/vendors/atmos.svg +1 -0
  52. package/web/vendors/chant.svg +1 -0
  53. package/web/vendors/choudoufu.svg +1 -0
  54. package/web/vendors/terragrunt.svg +9 -0
  55. package/web/vendors/terragucci.svg +1 -0
  56. package/web/vendors/choudoufu-128.png +0 -0
  57. package/web/vendors/choudoufu-64.png +0 -0
package/web/app.js CHANGED
@@ -40,6 +40,11 @@ import { FORGES, MARK, componentsForge, forgeOfName, iconSvg, markLink, markTitl
40
40
  import { TOOLS, orderTools } from "./tool-mark.js";
41
41
  import { STATE_WORDS as tgStateWords, changeSection as tgChangeSection, readCardIds as tgReadCardIds, readEdges as tgReadEdges, readLabel as tgReadLabel, readLine as tgReadLine, readTag as tgReadTag, rootStates as tgRootStates, viewCaption as tgViewCaption, pinnedAnswer as tgPinnedAnswer, pinnedCaption as tgPinnedCaption, pinsCommit as tgPinsCommit, pinWaits as tgPinWaits } from "./terragucci-change.js";
42
42
  import { auditLines as yrAuditLines, cornerText as yrCorner, datedWords as yrDated, environmentLines as yrEnvLines, joinMarks as yrJoin, legend as yrLegend, markLine as yrMarkLine } from "./yodel-report.js";
43
+ import { drawLight as klDraw } from "./kiosk-light-frame.js"; // behold#937
44
+ import { badgeWords as klBadge, planOf as klPlanOf } from "./kiosk-light.js"; // behold#940
45
+ import { composedRun } from "./kiosk-light.js";
46
+ import { graphMayShow, keepsSceneInAsk, mayTellDrawn, refusalHoldsScene } from "./kiosk-graph-pane.js";
47
+ import { askDeltas, clearScene, drawScene, sceneModel, slotCounts as klSlotCounts } from "./kiosk-estate-scene.js"; // behold#940
43
48
  import { cardProgress as tgCardProgress, progressLines as tgProgressLines, progressSection as tgProgressSection, stampProgress as tgStampProgress } from "./terragucci-progress.js";
44
49
  import { seconds, whyQuery, whyView } from "./why.js";
45
50
  import { edgeKey, edgeLabel, edgeLegend, edgeTitle, isCiKind, viaIndex } from "./edge-kind.js";
@@ -129,7 +134,7 @@ import { danglingFor, danglingRows, danglingHeading, DANGLING_EXPLAINED } from "
129
134
  import { comparisonRow, comparisonSummary } from "./cross-env.js";
130
135
  // The marker-vs-derived mark on a choudoufu card: how its identity was found.
131
136
  import { identityMark, tagGlyphSvg } from "./identity-mark.js";
132
- import { shotFromMessage, shotViewBox, tweenViewBox, unionBox, sameViewBox, heldFrame, heldInsets, heldTarget, holdsStage, medianWidth, smallStage } from "./kiosk-shot.js"; // behold#571: Watch's camera
137
+ import { ASK_MAX_SCALE, afterFrames, debounced, shotFromMessage, shotViewBox, tweenViewBox, unionBox, sameViewBox, heldFrame, heldInsets, heldTarget, holdsStage, medianWidth, smallStage } from "./kiosk-shot.js"; // behold#571: Watch's camera
133
138
  import { SHOT_ATTR, SHOT_CAPTION_PX, SHOT_DIM, queryFrame, readShotFrame, shotCaption, shotLit, shotProvenance, shotState } from "./shot-frame.js"; // behold#915: the page `behold shot` photographs
134
139
  import { countsLine, groupLabel, groupMarks, queryLine, queryMarks, searchKey, searchUrl, stackIndex, uncapturedLine } from "./search-view.js"; // behold#913: `q` drawn; behold#922: groups
135
140
  // #712, #715: the dots layer, the zoom past the cards. Mounted for a live
@@ -2181,6 +2186,10 @@ function ensureViewToggles(host) {
2181
2186
  host.appendChild(bar);
2182
2187
  }
2183
2188
  bar.innerHTML = "";
2189
+ if (document.documentElement.classList.contains("kiosk-ask")) {
2190
+ bar.style.display = "none"; // behold#940: ask mode shows the graph and the prompt alone
2191
+ return;
2192
+ }
2184
2193
  if (isEstate()) {
2185
2194
  const b = button("▦ stack alike", "vt" + (view.alike && alikeZoom() ? " active" : ""), toggleAlike);
2186
2195
  b.title = ALIKE_TITLE;
@@ -4532,6 +4541,8 @@ async function loadTerragucci({ fresh = false } = {}) {
4532
4541
  .then((r) => r.json())
4533
4542
  .catch((e) => ({ error: String(e), code: "terragucci-report", remedy: "" }));
4534
4543
  tgAnswer = answer;
4544
+ sceneInPlaceOfRefusal();
4545
+ klGate();
4535
4546
  // #506: the timeline, whole; the inspect pane filters it by a card's root.
4536
4547
  tgTimeline = await apiFetch(`/api/terragucci/timeline${fresh ? "?fresh=1" : ""}`)
4537
4548
  .then((r) => r.json())
@@ -4559,6 +4570,7 @@ async function refreshTgAnswer() {
4559
4570
  .then((r) => r.json())
4560
4571
  .catch((e) => ({ error: String(e), code: "terragucci-report", remedy: "" }));
4561
4572
  if (!answer.error || !tgAnswer) tgAnswer = answer;
4573
+ sceneInPlaceOfRefusal();
4562
4574
  renderTerragucciPanel();
4563
4575
  markTerragucciCards();
4564
4576
  drawTgReads();
@@ -4608,11 +4620,135 @@ function tgPushFits(answer) {
4608
4620
  function tgAnswerDrawn() {
4609
4621
  return tgPinnedAnswer(tgAnswer, view.run, view.pull || null);
4610
4622
  }
4623
+ // A prompt-driven step holds the graph from the moment its prompt starts until its reply is done or its status shows
4624
+ // (the kiosk posts behold:hold, then a behold:light): progress that lands in between is queued, the latest one drawn then.
4625
+ let klHold = null;
4626
+ let klHeldPaint = false;
4627
+ function klReleaseHold() {
4628
+ if (klHold) clearTimeout(klHold);
4629
+ klHold = null;
4630
+ if (klHeldPaint) {
4631
+ klHeldPaint = false;
4632
+ paintTgProgress();
4633
+ }
4634
+ }
4611
4635
  function paintTgProgress() {
4636
+ if (klHold) {
4637
+ klHeldPaint = true;
4638
+ return;
4639
+ }
4612
4640
  tgStampProgress(document.querySelector("#graph svg"), tgProgress, new Date());
4613
4641
  drawTgReads(); // #568: the run view's reads, once the change merged
4614
4642
  renderTerragucciPanel();
4615
4643
  }
4644
+ // behold#937: the kiosk's last `behold:light` message and what draws it (web/kiosk-light-frame.js).
4645
+ let klMsg = null;
4646
+ let klCtx = null;
4647
+ const klPulsed = { token: null };
4648
+ function klRedraw() {
4649
+ if (!klCtx || !klMsg || !klCtx.svg.isConnected) return;
4650
+ klDraw(klCtx.svg, klMsg, klCtx.drawnAnswer, tgStoryOn() ? tgPacedProgress() : tgProgress, { cardsOf: klCtx.cardsOf, rootBox: klCtx.rootBox, boxHost: klCtx.boxHost, compMode: klCtx.compMode, pulsed: klCtx.pulsed, below: document.documentElement.classList.contains("kiosk-ask") });
4651
+ klTellLit();
4652
+ }
4653
+ // behold#tips-yield: where the lit cards are on screen (frame pixels), so the kiosk's tip card never covers what the
4654
+ // prompt talks about. Told when the lighting is drawn and again whenever the boxes move (a fit, a zoom), only on change.
4655
+ let klLitSaid = "";
4656
+ function klTellLit() {
4657
+ if (!embedOpts.host || window.parent === window || !document.documentElement.classList.contains("kiosk-ask")) return;
4658
+ const rects = [...document.querySelectorAll('#graph [data-kl="lit"]')]
4659
+ .map((g) => g.getBoundingClientRect())
4660
+ .filter((r) => r.width > 0 && r.height > 0)
4661
+ .map((r) => [Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)]);
4662
+ const said = JSON.stringify(rects);
4663
+ if (said === klLitSaid) return;
4664
+ klLitSaid = said;
4665
+ try {
4666
+ window.parent.postMessage({ type: "behold:lit-rects", rects }, embedOpts.host);
4667
+ } catch {
4668
+ /* the parent went away */
4669
+ }
4670
+ }
4671
+ setInterval(klTellLit, 400);
4672
+ // behold#940: the kiosk's word that ask mode is on, which holds between the shots (the frame's class follows it or a shot's `ask`).
4673
+ let klAskFlag = false;
4674
+ let klAskHeard = false;
4675
+ let klArranged = false;
4676
+ function klSetAsk(on) {
4677
+ const root = document.documentElement.classList;
4678
+ const was = root.contains("kiosk-ask");
4679
+ root.toggle("kiosk-ask", on);
4680
+ klGate();
4681
+ if (was !== on && embedOpts.bare) drawTgReads();
4682
+ }
4683
+ /** The room the graph has in ask mode, in the pane's own pixels: the pane less what the prompt covers. */
4684
+ function klRoom() {
4685
+ const host = document.getElementById("graph");
4686
+ if (!host) return null;
4687
+ const pane = host.getBoundingClientRect();
4688
+ const i = kioskShot ? kioskPaneInsets(kioskShot) : { top: 0, right: 0, bottom: 0, left: 0 };
4689
+ const width = pane.width - i.left - i.right;
4690
+ const height = pane.height - i.top - i.bottom;
4691
+ return width > 0 && height > 0 ? { width, height } : { width: pane.width, height: pane.height };
4692
+ }
4693
+ /**
4694
+ * Ask mode lays the roots out for the room (web/kiosk-ask-layout.js): stacked, upstream on top, so the cards fill a
4695
+ * wide screen. A composed choudoufu run has none of its resources in the graph, so its scene is drawn from the run's
4696
+ * reports in place of the graph's cards (web/kiosk-estate-scene.js). Left, the graph goes back as it was drawn.
4697
+ * Idempotent: each call paints from what the graph drew.
4698
+ */
4699
+ function sceneUpOn(svg) {
4700
+ return !!(svg && svg.querySelector(":scope > [data-kl-scene]"));
4701
+ }
4702
+ /** The frame may show its svg (web/kiosk-graph-pane.js graphMayShow), and the class that lets it (kiosk.html: hidden otherwise in ask mode). */
4703
+ function klGate() {
4704
+ const svg = document.querySelector("#graph svg");
4705
+ const settled = !!(tgAnswer && !tgAnswer.error && Array.isArray(tgAnswer.roots));
4706
+ const mayShow = graphMayShow({ askOn: document.documentElement.classList.contains("kiosk-ask"), components: !!view.components, sceneUp: sceneUpOn(svg), answerSettled: settled, answerHasScene: settled && !!tgAnswer.estateScene });
4707
+ document.documentElement.classList.toggle("kl-show", mayShow);
4708
+ return { mayShow };
4709
+ }
4710
+ function klArrange(svg) {
4711
+ const on = document.documentElement.classList.contains("kiosk-ask") && !view.components;
4712
+ const answer = on ? tgAnswerDrawn() : null;
4713
+ if (!on || !answer || answer.error || !Array.isArray(answer.roots) || !answer.roots.length) {
4714
+ // Ask mode still on and a scene up: a read that is stale or failed for a moment (the reports as they are written)
4715
+ // keeps the last drawn scene. A composed run's graph has no cards of its own, so going back to it would be blank.
4716
+ if (keepsSceneInAsk({ askOn: on, sceneUp: sceneUpOn(svg) })) return;
4717
+ if (klArranged) {
4718
+ clearScene(svg);
4719
+ reloadLayoutDeltas();
4720
+ klArranged = false;
4721
+ }
4722
+ return;
4723
+ }
4724
+ const progress = tgStoryOn() ? tgPacedProgress() : tgProgress;
4725
+ const plan = klPlanOf(answer, progress);
4726
+ const open = klRoom();
4727
+ const model = sceneModel(answer, plan, progress, open);
4728
+ if (model) {
4729
+ const first = !klArranged;
4730
+ drawScene(svg, model);
4731
+ klArranged = true;
4732
+ klGate();
4733
+ // The first draw: fit to it at once (no swoop from the graph's own framing), and again once layout and paint settle.
4734
+ if (first) {
4735
+ refitNow();
4736
+ afterFrames(requestAnimationFrame, refitNow);
4737
+ }
4738
+ return;
4739
+ }
4740
+ // Ask mode: the plain graph never paints. A scene up stays when the pin hides the plan for a moment, and with none up
4741
+ // yet the graph's own drawing is held back (klPlainGate) until the scene comes.
4742
+ if (sceneUpOn(svg) || !klGate().mayShow) return;
4743
+ if (svg.__klStash) clearScene(svg);
4744
+ if (!layoutIndex) return;
4745
+ const extras = Object.fromEntries(Object.entries(klSlotCounts(plan)).map(([id, n]) => [id, n * 22 + 6]));
4746
+ const got = askDeltas({ roots: answer.roots, nodes: layoutIndex.nodes, boxes: layoutIndex.boxes, extras, edges: plan.edges, open });
4747
+ if (!got) return;
4748
+ layoutDeltas = got.deltas;
4749
+ renderLayout();
4750
+ klArranged = true;
4751
+ }
4616
4752
  // #568: the reads edges between roots of one repo, drawn over the card view.
4617
4753
  // #569: drawn so the view shows the change without the panel: each read is a
4618
4754
  // line from the reader (its data card when the checkout draws one, else its
@@ -4627,6 +4763,7 @@ const TG_TONE = { plan: "var(--frame-pending, var(--pending))", wait: "var(--fra
4627
4763
  /** The same, for words on a card: read on the card's own ground. */
4628
4764
  const TG_CARD_TONE = Object.fromEntries(Object.entries(TG_TONE).map(([k, v]) => [k, v.replace("--frame-", "--frame-card-")]));
4629
4765
  function drawTgReads() {
4766
+ klGate();
4630
4767
  if (embedOpts.bare) queueMicrotask(kioskDecorate); // behold#571: once this draw is done
4631
4768
  if (embedOpts.bare) queueMicrotask(() => (kioskShot ? applyKioskShot(false) : kioskTellBoxes())); // behold#571: the marks moved the boxes
4632
4769
  if (embedOpts.bare) queueMicrotask(kioskTellDrawn); // behold#571: the kiosk swaps a reloaded frame in once it has drawn
@@ -4668,6 +4805,7 @@ function drawTgReads() {
4668
4805
  // Report minor 34: last draw's cone lights go; drawConeLights sets this draw's.
4669
4806
  if (chantMode || !tgAnswer || tgAnswer.error || !tgAnswer.roots) drawConeLights(svg, { stage: null });
4670
4807
  if (!chantMode && (!tgAnswer || tgAnswer.error || !tgAnswer.roots)) return;
4808
+ if (embedOpts.bare && !chantMode) klArrange(svg); // behold#940
4671
4809
  const toSvg = svg.getScreenCTM && svg.getScreenCTM();
4672
4810
  if (!toSvg) return;
4673
4811
  const inv = toSvg.inverse();
@@ -4712,6 +4850,16 @@ function drawTgReads() {
4712
4850
  const rect = groupRect(path);
4713
4851
  return (rect && boxOf(rect)) || union(cardsOf(path).map(boxOf).filter(Boolean));
4714
4852
  };
4853
+ // behold#940: the box's own group and rect, in the group's own units, for a label that rides with the box.
4854
+ const boxHost = (path) => {
4855
+ const rect = groupRect(path);
4856
+ const parent = rect && rect.parentNode;
4857
+ if (!parent || !parent.hasAttribute || !parent.hasAttribute("data-layout-box")) return null;
4858
+ const x = parseFloat(rect.getAttribute("x"));
4859
+ const y = parseFloat(rect.getAttribute("y"));
4860
+ const h = parseFloat(rect.getAttribute("height"));
4861
+ return Number.isFinite(x) && Number.isFinite(y) && h > 0 ? { parent, x, y, y2: y + h } : null;
4862
+ };
4715
4863
  const NS = "http://www.w3.org/2000/svg";
4716
4864
  const make = (tag, attrs, text) => {
4717
4865
  const n = document.createElementNS(NS, tag);
@@ -4793,7 +4941,9 @@ function drawTgReads() {
4793
4941
  layer.parentNode.insertBefore(mark, layer);
4794
4942
  // The badge: on the box's top border, right-aligned, like a tab; the "N
4795
4943
  // resources" count in the header row under it gives way.
4796
- const local = rect.getBBox();
4944
+ // In the svg's own units, where the box is now: a box moved by a layout delta sits in a group that carries its offset.
4945
+ const placed = boxOf(rect);
4946
+ const local = placed ? { x: placed.x, y: placed.y, width: placed.x2 - placed.x, height: placed.y2 - placed.y } : rect.getBBox();
4797
4947
  const headY = local.y + 23;
4798
4948
  const tabY = local.y;
4799
4949
  for (const t of svg.querySelectorAll("text")) {
@@ -4806,8 +4956,11 @@ function drawTgReads() {
4806
4956
  }
4807
4957
  // Filled when something happened or waits on the root; an outline when nothing has yet.
4808
4958
  const solid = st.state !== "outside" && st.state !== "not-started" && st.state !== "unchanged";
4809
- const badge = pill(mark, local.x + local.width - 16, tabY, st.words, { stroke: tone, fill: solid ? tone : "var(--panel)", color: solid ? "var(--bg)" : "var(--fg)", size: 14, weight: 700, anchor: "end", cls: st.state === "applying" ? "pin-pulse" : "" });
4810
- badge.g.appendChild(make("title", {}, [st.words, ...st.facts].join("\n") + "\n(from terragucci's reports, not live)"));
4959
+ // behold#940: in ask mode the badge says the step's own word, with no wave.
4960
+ const askWords = embedOpts.bare && document.documentElement.classList.contains("kiosk-ask") ? klBadge(st, r.path, tgStoryOn() ? tgPacedProgress() : tgProgress) : null;
4961
+ const badgeText = askWords || st.words;
4962
+ const badge = pill(mark, local.x + local.width - 16, tabY, badgeText, { stroke: tone, fill: solid ? tone : "var(--panel)", color: solid ? "var(--bg)" : "var(--fg)", size: 14, weight: 700, anchor: "end", cls: st.state === "applying" ? "pin-pulse" : "" });
4963
+ badge.g.appendChild(make("title", {}, [badgeText, ...st.facts].join("\n") + "\n(from terragucci's reports, not live)"));
4811
4964
  // The facts under it, at the box's bottom right: the plan a wave waits on, its changes.
4812
4965
  // Packed into one line that fits the box, most telling first; the rest is in the badge's tooltip.
4813
4966
  if (st.facts.length) {
@@ -4841,7 +4994,7 @@ function drawTgReads() {
4841
4994
  const shown = lines.slice(0, 1);
4842
4995
  if (lines.length > 1) shown[0] += " …";
4843
4996
  shown.forEach((t, i) => {
4844
- mark.appendChild(make("text", { x: local.x + local.width - 14, y: local.y + local.height - 10 - (shown.length - 1 - i) * 15, "text-anchor": "end", "font-size": 12.5, "font-weight": 600, fill }, t));
4997
+ mark.appendChild(make("text", { x: local.x + local.width - 14, y: local.y + local.height - 10 - (shown.length - 1 - i) * 15, "text-anchor": "end", "font-size": 12.5, "font-weight": 600, fill, "data-tg-box-facts": "1" }, t));
4845
4998
  });
4846
4999
  }
4847
5000
  }
@@ -5069,6 +5222,11 @@ function drawTgReads() {
5069
5222
  }
5070
5223
  tgReadEdgesNow = edges;
5071
5224
  tgReadShow(svg);
5225
+ // behold#937: a demo step's lighting, the states' files and looks, the unknown slots, over the marks just drawn.
5226
+ if (embedOpts.bare) {
5227
+ klCtx = { svg, drawnAnswer, rootBox, boxHost, compMode, cardsOf, pulsed: klPulsed };
5228
+ klRedraw();
5229
+ }
5072
5230
 
5073
5231
  // Which run the marks come from, above the boxes.
5074
5232
  // #569: a pin that holds the view off every plan says why in its own words.
@@ -5479,6 +5637,9 @@ function ensureTgReadStyle() {
5479
5637
  #graph g[data-tg-read-pill].tg-flash { animation: tg-read-flash 6s linear both; }
5480
5638
  #graph line[data-tg-read].tg-hot { stroke-width: 5; filter: drop-shadow(0 0 3px var(--bg)); }
5481
5639
  #graph g[data-tg-read-covers] { display: none !important; }
5640
+ /* Ask mode never paints the checkout's plain resource graph: the svg is held (kl-show) until the estate scene is drawn. */
5641
+ html.kiosk-ask:not(.kl-show) #graph svg { visibility: hidden; }
5642
+ html.kiosk-ask #view-toggles, html.kiosk-ask #graph text[data-tg-reads="caption"], html.kiosk-ask #graph text[data-tg-root="wave-fact"], html.kiosk-ask #graph text[data-tg-box-facts] { display: none; }
5482
5643
  @keyframes tg-read-flash { 0% { opacity: 0; } 4%, 80% { opacity: 1; } 100% { opacity: 0; } }
5483
5644
  @keyframes tg-read-flash-step { 0%, 99.9% { opacity: 1; } 100% { opacity: 0; } }
5484
5645
  @media (prefers-reduced-motion: reduce) {
@@ -5812,7 +5973,7 @@ function chantKioskWaves(svg, boxOf, size) {
5812
5973
  else path.setAttribute("marker-end", "url(#k-then-arrow)");
5813
5974
  }
5814
5975
  // The bottom box says which way the waves go, once.
5815
- if (!svg.querySelector("text[data-kiosk-upward]")) {
5976
+ if (!svg.querySelector("text[data-kiosk-upward]") && !composedRun(tgAnswer, tgProgress)) {
5816
5977
  const boxes = [...svg.querySelectorAll("rect[data-group-id]")].filter((r) => tgWaveOfKey(r.getAttribute("data-group-id")) !== null);
5817
5978
  const low = boxes.map((r) => ({ r, b: boxOf(r) })).filter((x) => x.b).sort((a, b) => b.b.y2 - a.b.y2)[0];
5818
5979
  if (low) {
@@ -6382,8 +6543,10 @@ function userBoxOf(svg, el) {
6382
6543
  } catch {
6383
6544
  return null;
6384
6545
  }
6385
- const ctm = el.getCTM && el.getCTM();
6386
- const root = svg.getCTM && svg.getCTM();
6546
+ // getScreenCTM on both: svg.getCTM() is the viewBox's matrix in Chrome but the identity in Firefox, which put every box off
6547
+ // screen there. The screen matrices both include the viewBox, so root^-1 * el is the element's matrix in the svg's user units.
6548
+ const ctm = el.getScreenCTM && el.getScreenCTM();
6549
+ const root = svg.getScreenCTM && svg.getScreenCTM();
6387
6550
  if (!ctm || !root || !(b.width > 0 || b.height > 0)) return null;
6388
6551
  const m = root.inverse().multiply(ctm);
6389
6552
  const pts = [[b.x, b.y], [b.x + b.width, b.y + b.height]].map(([x, y]) => new DOMPoint(x, y).matrixTransform(m));
@@ -6391,14 +6554,23 @@ function userBoxOf(svg, el) {
6391
6554
  }
6392
6555
 
6393
6556
  /** What a shot frames, in svg units: its roots' cards and the reads between them, its waves' boxes, else the whole graph. */
6557
+ /** What hangs under the lowest box in ask mode: its state label. */
6558
+ const ASK_LABEL_ROOM = 32;
6394
6559
  function kioskShotTarget(svg, shot) {
6395
6560
  if (!vbInit) return null;
6396
6561
  const boxes = [];
6397
6562
  if (shot.whole) {
6398
6563
  // The whole graph is what is drawn: the boxes, the cards and the reads, not pinhole's margins round them.
6399
6564
  // behold#744: not the reads' pills, which show and go while the shot stays.
6400
- for (const n of svg.querySelectorAll("rect[data-group-id], [data-node-id], [data-tg-reads] > g:not([data-tg-read-pill]), line[data-tg-read-from], text[data-tg-reads='caption']")) boxes.push(userBoxOf(svg, n));
6401
- return unionBox(boxes) || { x: vbInit[0], y: vbInit[1], x2: vbInit[0] + vbInit[2], y2: vbInit[1] + vbInit[3] };
6565
+ for (const n of svg.querySelectorAll("rect[data-group-id], [data-node-id], [data-tg-reads] > g:not([data-tg-read-pill]), line[data-tg-read-from], text[data-tg-reads='caption'], g[data-kl-state]")) boxes.push(userBoxOf(svg, n));
6566
+ const u = unionBox(boxes);
6567
+ // Ask mode: each box's state label hangs under it, and may not have drawn yet; the fit always leaves room for it, so the
6568
+ // stack sits the same before and after the labels (and centred, not low).
6569
+ if (u && shot.ask) {
6570
+ const low = Math.max(...[...svg.querySelectorAll("rect[data-group-id]")].map((r) => (userBoxOf(svg, r) || { y2: -Infinity }).y2));
6571
+ if (Number.isFinite(low)) u.y2 = Math.max(u.y2, low + ASK_LABEL_ROOM);
6572
+ }
6573
+ return u || { x: vbInit[0], y: vbInit[1], x2: vbInit[0] + vbInit[2], y2: vbInit[1] + vbInit[3] };
6402
6574
  }
6403
6575
  const named = (tgComponentFacets && tgComponentFacets.roots) || {};
6404
6576
  const roots = new Set(shot.roots);
@@ -6464,7 +6636,8 @@ function kioskShotBox() {
6464
6636
  // Only an estate on choudoufu's live backend (the cone scenario's) is held; every other keeps a shot per step, as on main.
6465
6637
  // behold#736: a story's stage (fan-out-choudoufu, a chapter-carrying scenario, behold#741) is never held: it keeps
6466
6638
  // the story's own look, its result card, #745's pills and #748's outside mark.
6467
- if (whole && !tgStoryOn() && holdsStage(tgAnswer && !tgAnswer.error ? tgAnswer.binaries : null) && smallStage(whole, pane, held ? held.insets : docked, cardW)) {
6639
+ // Ask mode is never held: the held framing is the union of every target it has seen (the graph before the scene drew included), which leaves the scene off-centre. It is fitted to the scene as drawn, every time.
6640
+ if (whole && !kioskShot.ask && !tgStoryOn() && holdsStage(tgAnswer && !tgAnswer.error ? tgAnswer.binaries : null) && smallStage(whole, pane, held ? held.insets : docked, cardW)) {
6468
6641
  kioskHeld = heldFrame(kioskHeld, { key: graph, pane, insets: docked, target: whole });
6469
6642
  writeHeld(kioskHeld);
6470
6643
  document.documentElement.classList.add("kiosk-held");
@@ -6474,7 +6647,8 @@ function kioskShotBox() {
6474
6647
  }
6475
6648
  kioskHeld = null;
6476
6649
  document.documentElement.classList.remove("kiosk-held");
6477
- return shotViewBox(kioskShotTarget(svg, kioskShot), pane, { ...insets, right: Math.max(insets.right, railInset(pane)) });
6650
+ // behold#939: a prompt-driven step fills the room above the pane (the graph is small, and the pane says the rest).
6651
+ return shotViewBox(kioskShotTarget(svg, kioskShot), pane, { ...insets, right: Math.max(insets.right, railInset(pane)) }, kioskShot.ask ? { maxScale: ASK_MAX_SCALE } : undefined);
6478
6652
  }
6479
6653
  /** The whole-graph framing Watch holds on a small stage while the graph and the pane stay (web/kiosk-shot.js heldFrame); null on a bigger one. */
6480
6654
  var kioskHeld = null;
@@ -6512,6 +6686,14 @@ function kioskPaneInsets(shot) {
6512
6686
 
6513
6687
  /** Move to the shot: a pan and zoom over its time, or at once (a re-render, a resize, reduced motion). */
6514
6688
  function applyKioskShot(animate) {
6689
+ // "now": a refit (a resize, the fonts, the first draw settling) sets the view directly, over any move under way.
6690
+ if (animate === "now") {
6691
+ animate = false;
6692
+ if (shotAnim) {
6693
+ cancelAnimationFrame(shotAnim.raf);
6694
+ shotAnim = null;
6695
+ }
6696
+ }
6515
6697
  // #715: while a live carve runs, its director has the camera; the shot waits for it to end.
6516
6698
  if (dotsCarving()) return kioskTellBoxes();
6517
6699
  const to = kioskShotBox();
@@ -6627,6 +6809,8 @@ function kioskTellDrawn() {
6627
6809
  if (drawnTold || !embedOpts.host || window.parent === window) return;
6628
6810
  const drawnState = graphDrawnState();
6629
6811
  if (!drawnState) return;
6812
+ // Ask mode: not drawn until the estate scene is (or the kiosk's word that ask mode is on has not come in a while: a failed draw says so at once).
6813
+ if (drawnState !== "failed" && !mayTellDrawn({ askHeard: klAskHeard, waitedMs: performance.now(), askOn: document.documentElement.classList.contains("kiosk-ask"), mayShow: klGate().mayShow })) return;
6630
6814
  const failed = drawnState === "failed";
6631
6815
  drawnTold = true;
6632
6816
  try {
@@ -6738,10 +6922,13 @@ window.addEventListener("message", (e) => {
6738
6922
  shotAnim = null;
6739
6923
  kioskShot = null;
6740
6924
  document.documentElement.classList.remove("kiosk-held"); // Inspect: the zoom rail is the viewer's again
6925
+ klSetAsk(klAskFlag);
6741
6926
  fitGraph();
6742
6927
  return;
6743
6928
  }
6744
6929
  kioskShot = shot;
6930
+ klAskHeard = true;
6931
+ klSetAsk(!!shot.ask || klAskFlag);
6745
6932
  applyKioskShot(true);
6746
6933
  });
6747
6934
 
@@ -6808,6 +6995,38 @@ function wireKioskFrame() {
6808
6995
  window.addEventListener("message", (e) => {
6809
6996
  if (!embedOpts.host || e.origin !== embedOpts.host) return;
6810
6997
  if (e.data && e.data.type === "behold:unpin") return kioskPopEvent({ type: "outside" });
6998
+ // behold#937: the demo step's lighting from the kiosk (web/kiosk-light.js lightMessage).
6999
+ if (e.data && e.data.type === "behold:hold") {
7000
+ if (klHold) clearTimeout(klHold);
7001
+ klHold = setTimeout(klReleaseHold, 120000); // slow typing and queued steps hold it for a while; a step that never finishes does not freeze the graph for good
7002
+ return;
7003
+ }
7004
+ if (e.data && e.data.type === "behold:light") {
7005
+ const wasHeld = !!klHold;
7006
+ if (klHold) {
7007
+ clearTimeout(klHold);
7008
+ klHold = null;
7009
+ }
7010
+ klMsg = { labels: e.data.labels === true, lit: e.data.lit === true, ids: Array.isArray(e.data.ids) ? e.data.ids.filter((x) => typeof x === "string") : [], roots: Array.isArray(e.data.roots) ? e.data.roots.filter((x) => typeof x === "string") : [], ghost: e.data.ghost === true, token: e.data.token ?? null };
7011
+ klRedraw();
7012
+ if (wasHeld && klHeldPaint) {
7013
+ klHeldPaint = false;
7014
+ paintTgProgress();
7015
+ }
7016
+ // behold#940: drawn at once from what the frame holds, and again as soon as its reads are fresh: never at a poll's turn.
7017
+ if (!staticMode && tgAnswer) {
7018
+ void refreshTgAnswer();
7019
+ void loadTgProgress({ fresh: true });
7020
+ }
7021
+ return;
7022
+ }
7023
+ // behold#940: ask mode is on or off for this step, whatever the shots say between prompts.
7024
+ if (e.data && e.data.type === "behold:ask") {
7025
+ klAskFlag = e.data.on === true;
7026
+ klAskHeard = true;
7027
+ klSetAsk(klAskFlag || !!(kioskShot && kioskShot.ask));
7028
+ return;
7029
+ }
6811
7030
  // behold#571: the kiosk's theme picker moved; follow it here without a reload.
6812
7031
  if (e.data && e.data.type === "behold:theme" && typeof e.data.name === "string") return void setTheme(e.data.name, { persist: false });
6813
7032
  // behold#741: the scenario carries chapters (or stopped carrying them): the kiosk's look, and the wave blocks, follow.
@@ -7230,6 +7449,70 @@ function renderFlagsTab() {
7230
7449
  }
7231
7450
  initFlags();
7232
7451
 
7452
+ // behold#931: the Repos tab of an org-level workspace. One entry per repo
7453
+ // member: its URL and pinned revision, then the members of that repository's
7454
+ // workspace with each one's status and reason, from /api/workspace/repos (one
7455
+ // chant workspace graph). A failed fetch shows chant's reason as given.
7456
+ let orgHost = null;
7457
+ let orgRead = false;
7458
+ async function initOrgRepos() {
7459
+ if (staticMode || publicMode) return; // /api/workspace/* is refused in a public view
7460
+ const project = await apiFetch("/api/project").then((r) => r.json()).catch(() => ({}));
7461
+ if (!project.workspace || !project.workspace.org) return;
7462
+ orgHost = addPanelTab("repos", "Repos", "The repositories this org workspace names, each with its pinned revision and the members of its workspace. Read from chant when you open the tab.");
7463
+ if (!orgHost) return;
7464
+ orgHost.id = "tab-repos";
7465
+ const tab = document.querySelector('#panel-tabs button[data-tab="repos"]');
7466
+ if (tab) tab.addEventListener("click", () => orgRead || loadOrgRepos());
7467
+ if (orgHost.classList.contains("active")) loadOrgRepos();
7468
+ }
7469
+ async function loadOrgRepos() {
7470
+ orgRead = true;
7471
+ const reading = document.createElement("div");
7472
+ reading.className = "tg-legend";
7473
+ reading.textContent = "reading the repositories from chant (it fetches each pinned revision)";
7474
+ orgHost.replaceChildren(reading);
7475
+ const answer = await apiFetch("/api/workspace/repos")
7476
+ .then((r) => r.json())
7477
+ .catch((e) => ({ error: String(e) }));
7478
+ renderOrgRepos(answer);
7479
+ }
7480
+ function renderOrgRepos(answer) {
7481
+ orgHost.replaceChildren();
7482
+ const line = (cls, text, title, host = orgHost) => {
7483
+ const d = document.createElement("div");
7484
+ d.className = cls;
7485
+ d.textContent = text;
7486
+ if (title) d.title = title;
7487
+ host.appendChild(d);
7488
+ return d;
7489
+ };
7490
+ if (answer.error || answer.refusal) {
7491
+ const r = answer.refusal || { error: answer.error, remedy: "" };
7492
+ line("tg-refusal", [r.error, r.remedy].filter(Boolean).join(" "));
7493
+ if (answer.degraded) line("tg-legend", "Without it, " + answer.degraded + ".");
7494
+ return;
7495
+ }
7496
+ line("fl-title", answer.repos.length + " repositor" + (answer.repos.length === 1 ? "y" : "ies") + (answer.repo ? " in " + answer.repo : ""));
7497
+ for (const r of answer.repos) {
7498
+ const box = document.createElement("div");
7499
+ box.className = "fl-flag";
7500
+ line("fl-flag-title", r.name + " · " + r.url + " @ " + r.rev.slice(0, 12), r.rev, box);
7501
+ line("fl-facts", (r.workspaceName ? "workspace " + r.workspaceName + " · " : "") + (r.read ? "read as " + r.read + " · " : "") + r.status, "", box);
7502
+ if (r.reason) line("tg-refusal", r.reason.code + ": " + r.reason.message, "", box);
7503
+ for (const m of r.members) {
7504
+ line("fl-facts", m.name + " (" + m.kind + ") " + m.status + (m.reason ? " · " + m.reason.code + ": " + m.reason.message : ""), "", box);
7505
+ }
7506
+ orgHost.appendChild(box);
7507
+ }
7508
+ if (!staticMode) {
7509
+ const again = button("Read again", "", () => loadOrgRepos());
7510
+ again.title = "Fetch and read every repository's pinned revision again.";
7511
+ orgHost.appendChild(again);
7512
+ }
7513
+ }
7514
+ initOrgRepos();
7515
+
7233
7516
  // --- #684: collision marks, nodes touched by two in-flight work items --------
7234
7517
  // The Collisions tab reads /api/workspace/collisions when it is opened: the
7235
7518
  // in-flight work items chant reports (workspace status overlap, chant#4025),
@@ -9664,10 +9947,20 @@ function fitGraph() {
9664
9947
  let vbAtFit = false;
9665
9948
  function watchPaneForFit(host) {
9666
9949
  if (typeof ResizeObserver === "undefined") return;
9667
- new ResizeObserver(() => {
9668
- if (kioskShot) applyKioskShot(false);
9669
- else if (vbAtFit) fitGraph();
9670
- }).observe(host);
9950
+ // The refit waits for the last size change and sets the view directly: no swoop, and a resize burst fits once.
9951
+ // It moves the viewBox, never the host's box, so the observer cannot trigger itself.
9952
+ // Each change also sets the view at once, so a box is never off screen on the old framing while the burst lasts.
9953
+ const refit = debounced(refitNow);
9954
+ const onSize = () => (refitNow(), refit());
9955
+ new ResizeObserver(onSize).observe(host);
9956
+ window.addEventListener("resize", onSize);
9957
+ // Web fonts change the text's width, and with it the boxes.
9958
+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(refitNow, () => {});
9959
+ }
9960
+ /** Fit again as things stand, at once. Idempotent: a fit that is already right sets nothing. */
9961
+ function refitNow() {
9962
+ if (kioskShot) applyKioskShot("now");
9963
+ else if (vbAtFit) fitGraph();
9671
9964
  }
9672
9965
 
9673
9966
  // --- #396 item 7b: box titles and badges that survive the fit ---------------
@@ -10047,11 +10340,11 @@ function ensureZoomControls(host) {
10047
10340
  // the end of every render(), so the graph underneath stays chant's and a
10048
10341
  // delta for a node that left the estate is simply not applied.
10049
10342
  //
10050
- // Two tiers now (#228's second half): localStorage, and the project's own
10051
- // `.behold/layout.json` behind GET/POST /api/layout. On load the server's map
10343
+ // Two tiers now (#228's second half): localStorage, and the server's per-user
10344
+ // layout cache (outside the project, #469) behind GET/POST /api/layout. On load the server's map
10052
10345
  // merges UNDER the local one (`mergeLayouts` — the drag you can see always
10053
10346
  // wins); on a finished gesture the current lens is POSTed, debounced. A server
10054
- // that refuses — a static export, preview mode, a read-only project, an older
10347
+ // that refuses — a static export, preview mode, an unwritable cache, an older
10055
10348
  // behold with no such route — leaves the localStorage tier working exactly as
10056
10349
  // it did before, and says nothing.
10057
10350
  //
@@ -10640,6 +10933,21 @@ function renderPreconditionError(body) {
10640
10933
  host.appendChild(card);
10641
10934
  }
10642
10935
 
10936
+ // A kiosk frame's graph refused its checkout (a precondition: a chant project whose packages the view never
10937
+ // installed fails lint). A composed run's scene is drawn from the run's reports in place of the graph's cards
10938
+ // (web/kiosk-estate-scene.js), so it needs none of the graph: once the reports hold a scene, the frame draws it on an
10939
+ // empty svg instead of the refusal's card. A frame whose reports hold no scene keeps the card.
10940
+ let graphRefusal = null;
10941
+ const SCENE_ONLY_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600" width="800" height="600"></svg>';
10942
+ function sceneInPlaceOfRefusal() {
10943
+ if (!refusalHoldsScene({ refusal: graphRefusal, bare: embedOpts.bare, answer: tgAnswer })) return false;
10944
+ const note = `the graph is not drawn (${graphRefusal.code}): the run's reports draw the scene`;
10945
+ graphRefusal = null;
10946
+ render({ nodes: [], edges: [], groups: [] }, SCENE_ONLY_SVG, { note, noteShort: note });
10947
+ afterPaint({ nodes: [] });
10948
+ return true;
10949
+ }
10950
+
10643
10951
  // Fetch the current view (source graph, or the picked env's live overlay).
10644
10952
  const load = createRefreshQueue(loadOnce);
10645
10953
  async function loadOnce(opts = {}, isCurrent = () => true) {
@@ -10768,6 +11076,8 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
10768
11076
  // tier that needs credentials) gets the calmer entry/error card instead
10769
11077
  // of the generic red error box — see renderPreconditionError().
10770
11078
  if (body.code) {
11079
+ graphRefusal = embedOpts.bare ? body : null;
11080
+ if (sceneInPlaceOfRefusal()) return;
10771
11081
  renderPreconditionError(body);
10772
11082
  meta.textContent = body.code === "tier" ? `tier ${view.tier} unavailable here` : "error";
10773
11083
  renderDial();
@@ -10793,6 +11103,7 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
10793
11103
  pendingMembers = body.meta && body.meta.mode === "progressive" ? [...(body.meta.pending || [])] : [];
10794
11104
  pendingTotal = pendingMembers.length;
10795
11105
  if (view.components) takeTerragucciFacets(body.meta);
11106
+ graphRefusal = null;
10796
11107
  render(body.ir, body.svg, body.meta);
10797
11108
  afterPaint(body.ir);
10798
11109
  if (progressive) replayMemberFrames(frameLoad);
package/web/embed.js CHANGED
@@ -60,8 +60,8 @@ export function viewFromMessage(event, host) {
60
60
  for (const k of VIEW_KEYS) {
61
61
  if (!(k in d)) continue;
62
62
  const v = d[k];
63
- if (k === "radial" || k === "plan") {
64
- // plan (behold#922): true is the plan read, false the declared source again.
63
+ if (k === "radial" || k === "plan" || k === "alike") {
64
+ // plan (behold#922): true is the plan read, false the declared source again. alike (behold#939): false draws every card, true stacks them.
65
65
  if (typeof v === "boolean") want[k] = v;
66
66
  continue;
67
67
  }
@@ -76,6 +76,8 @@ export function modeLine(mode, kind, { at = null, now = 0, resolved = false, out
76
76
  if (kind === "waiting") return null;
77
77
  // behold#757: a highlight's kicker says what it is, in a replay as live: the replay's banner says which run it is.
78
78
  if (kind === "highlight") return HIGHLIGHT_KICKER;
79
+ // The prompt demo's tip cards (web/kiosk-ask-tips.js): the highlight's card, with a kicker of their own.
80
+ if (kind === "tip") return "Tip";
79
81
  if (mode === "replay") return `Replay of the run at ${utc(Number.isFinite(replayAt) ? replayAt : now)} UTC`;
80
82
  if (mode !== "narrated") return null;
81
83
  if (resolved) return outcome ? `Live · ${outcome}` : "Live";
@@ -121,10 +123,10 @@ export const MODAL_STYLE = `
121
123
  border: 2px solid var(--bar, var(--focus)); box-shadow: 0 16px 48px color-mix(in srgb, var(--shadow) 80%, transparent); font-size: 1.05em; }
122
124
  .eh-modal-held { --bar: var(--bar-foreign, var(--foreign)); } .eh-modal-failed { --bar: var(--bar-degraded, var(--degraded)); } .eh-modal-applied { --bar: var(--bar-managed, var(--managed)); }
123
125
  /* behold#757: a step's highlight: the runtime bar's tone (no state's), a kicker in it, and its body set to be read. */
124
- .eh-modal-highlight { --bar: var(--bar-runtime, var(--runtime, var(--focus))); background: linear-gradient(color-mix(in srgb, var(--bar) 9%, transparent), transparent 5em), var(--surface-pane-b, var(--panel)); box-shadow: inset 5px 0 0 var(--bar), 0 16px 48px color-mix(in srgb, var(--shadow) 80%, transparent); }
125
- .eh-modal-highlight .eh-modal-mode { text-transform: uppercase; letter-spacing: 0.08em; }
126
- .eh-modal-highlight .eh-modal-mode::before { content: "\\2605"; margin-right: 0.45em; }
127
- .eh-modal-highlight .eh-modal-line { color: var(--fg); line-height: 1.45; }
126
+ .eh-modal-highlight, .eh-modal-tip { --bar: var(--bar-runtime, var(--runtime, var(--focus))); background: linear-gradient(color-mix(in srgb, var(--bar) 9%, transparent), transparent 5em), var(--surface-pane-b, var(--panel)); box-shadow: inset 5px 0 0 var(--bar), 0 16px 48px color-mix(in srgb, var(--shadow) 80%, transparent); }
127
+ .eh-modal-highlight .eh-modal-mode, .eh-modal-tip .eh-modal-mode { text-transform: uppercase; letter-spacing: 0.08em; }
128
+ .eh-modal-highlight .eh-modal-mode::before, .eh-modal-tip .eh-modal-mode::before { content: "\\2605"; margin-right: 0.45em; }
129
+ .eh-modal-highlight .eh-modal-line, .eh-modal-tip .eh-modal-line { color: var(--fg); line-height: 1.45; }
128
130
  .eh-modal-close { position: absolute; top: 0.4em; right: 0.5em; font-size: 1.3em; background: transparent; border: 0; color: var(--muted); cursor: pointer; }
129
131
  .eh-modal-mode { margin: 0 2em 0.3em 0; font: 600 0.8em var(--font-ui); font-variant-numeric: tabular-nums; color: var(--bar, var(--muted)); }
130
132
  .eh-modal-title { margin: 0 0 0.5em; font-size: 1.35em; }
@@ -260,18 +262,20 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
260
262
  if (st.closeAt !== null) st.closeAt = Math.max(st.closeAt, now() + 2_000);
261
263
  });
262
264
 
265
+ // One close button for the modal's whole life, never detached: render() runs every 250 ms, and taking the button out of
266
+ // the page (or replacing it) between a press and its release (a click lasts 80-150 ms) drops the click, so it never closed.
267
+ const x = el("button", "eh-modal-close", "×");
268
+ x.type = "button";
269
+ x.setAttribute("aria-label", "Close");
270
+ x.addEventListener("click", () => close("viewer"));
271
+ box.appendChild(x);
263
272
  const render = () => {
264
273
  if (st.closed) return;
265
274
  const t = now();
266
- box.replaceChildren();
267
- const x = el("button", "eh-modal-close", "×");
268
- x.type = "button";
269
- x.setAttribute("aria-label", "Close");
270
- x.addEventListener("click", () => close("viewer"));
271
- box.appendChild(x);
275
+ for (const c of [...box.children]) if (c !== x) c.remove();
272
276
  const line = modeLine(mode, kind, { at: data.at, now: t, resolved: st.resolved, outcome: st.outcome, replayAt: data.replayAt, action: data.action, fix: !!data.fix });
273
277
  if (line) box.appendChild(el("p", `eh-modal-mode eh-modal-${mode}`, line));
274
- box.appendChild(el("h2", "eh-modal-title", data.title || ""));
278
+ if (data.title || kind !== "tip") box.appendChild(el("h2", "eh-modal-title", data.title || ""));
275
279
  for (const l of data.lines || []) {
276
280
  const p = el("p", `eh-modal-line${l.lit ? " eh-lit" : ""}`, l.text);
277
281
  if (l.title) p.title = l.title;
@@ -288,7 +292,7 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
288
292
  if (data.progress.words) box.appendChild(el("p", "eh-modal-note", data.progress.words));
289
293
  }
290
294
  // behold#757: a highlight is words to read: no command, no button.
291
- if (kind === "waiting" || kind === "highlight") return;
295
+ if (kind === "waiting" || kind === "highlight" || kind === "tip") return;
292
296
  const routed = mode === "live" && approveRoute(data.gate);
293
297
  // The panel, when there is one, already carries the command.
294
298
  if (data.command && !routed && !(data.panel && mode !== "live")) {
@@ -417,6 +421,8 @@ export function openEventModal(host, { mode, kind, data = {}, actions = {}, doc
417
421
  render();
418
422
  },
419
423
  close: () => close(),
424
+ /** The viewer closed it (a click outside, say): onClose sees `closedBy` "viewer". */
425
+ dismiss: () => close("viewer"),
420
426
  };
421
427
  return api;
422
428
  }