@intentius/behold 0.29.57 → 0.30.1

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 (48) hide show
  1. package/AGENTS.md +388 -57
  2. package/README.md +67 -50
  3. package/demos.json +1 -1
  4. package/dist/cli.js +9958 -3080
  5. package/example-choudoufu-estate/chant.workspace.json +1 -1
  6. package/example-terraform-estate/README.md +10 -10
  7. package/example-terraform-estate/chant.workspace.json +1 -1
  8. package/example-three-cloud/README.md +17 -9
  9. package/example-three-cloud/aws/chant.config.ts +1 -1
  10. package/example-three-cloud/aws/site.component.ts +13 -0
  11. package/example-three-cloud/azure/chant.config.ts +1 -1
  12. package/example-three-cloud/azure/src/site.component.ts +13 -0
  13. package/example-three-cloud/azure/src/site.ts +5 -7
  14. package/example-three-cloud/dns/chant.config.ts +1 -1
  15. package/example-three-cloud/dns/src/records.component.ts +14 -0
  16. package/example-three-cloud/dns/src/route53.ts +4 -5
  17. package/example-three-cloud/gcp/chant.config.ts +1 -1
  18. package/example-three-cloud/gcp/src/site.component.ts +13 -0
  19. package/example-three-cloud/gcp/src/site.ts +7 -7
  20. package/example-three-cloud/package-lock.json +19 -19
  21. package/example-three-cloud/package.json +4 -4
  22. package/example-three-cloud/scripts/front-door.ts +89 -15
  23. package/package.json +10 -11
  24. package/web/agent-move.js +60 -0
  25. package/web/agent-move.test.js +55 -0
  26. package/web/app.js +622 -79
  27. package/web/dots-lod.js +1 -1
  28. package/web/embed.d.ts +3 -0
  29. package/web/embed.js +5 -3
  30. package/web/embed.test.js +8 -0
  31. package/web/index.html +64 -9
  32. package/web/layout-store.js +3 -3
  33. package/web/panel.js +28 -4
  34. package/web/release.js +6 -4
  35. package/web/release.test.js +2 -2
  36. package/web/search-view.d.ts +27 -0
  37. package/web/search-view.js +213 -0
  38. package/web/search-view.test.js +144 -0
  39. package/web/shot-frame.d.ts +5 -0
  40. package/web/shot-frame.js +116 -0
  41. package/web/shot-frame.test.js +90 -0
  42. package/web/themes.js +1 -1
  43. package/web/view-url.d.ts +18 -0
  44. package/web/view-url.js +153 -6
  45. package/web/view-url.test.js +72 -1
  46. package/example-three-cloud/azure/composites/container-app-site.ts +0 -77
  47. package/example-three-cloud/dns/composites/latency-entry.ts +0 -73
  48. package/example-three-cloud/gcp/composites/public-cloud-run.ts +0 -102
package/web/app.js CHANGED
@@ -11,7 +11,8 @@
11
11
  import "./view-repo.js"; // behold#571: first, so every read carries the page's ?repo=
12
12
  import { createRefreshQueue } from "./refresh-queue.js";
13
13
  import { indexCompositeMembers } from "./composite-members.js";
14
- import { readViewQuery, writeViewQuery, settleView, settlePlace, refusalLine, withOpening, defaultEnv } from "./view-url.js";
14
+ import { readViewQuery, writeViewQuery, settleView, settlePlace, refusalLine, withOpening, defaultEnv, restoreViewQuery, viewFromObject } from "./view-url.js";
15
+ import { agentBanner, agentEntry, wholeQuestion } from "./agent-move.js";
15
16
  import { quietCardLines, readEmbed, selectMessage, viewFromMessage, wheelPx, wheelZoomsBare } from "./embed.js";
16
17
  import { WORDS as POP_WORDS, cardRoot as popCardRoot, placePopover, popReduce, popState, resourcePopover, rootPopover } from "./kiosk-popover.js";
17
18
  import { waveListKey, waveListOf } from "./kiosk-wave-list.js";
@@ -73,7 +74,7 @@ import {
73
74
  totalsText,
74
75
  deltaRows,
75
76
  } from "./behaviour-scale.js";
76
- import { addPanelTab, initPanel, setPanelTab, togglePanelCollapsed, isPanelCollapsed } from "./panel.js";
77
+ import { addPanelTab, initPanel, setPanelTab, togglePanelCollapsed, isPanelCollapsed, foldPanelOnPhone } from "./panel.js";
77
78
  // #254: the carve walkthrough's stepper — everything it DECIDES is a pure
78
79
  // function in there; this file owns the fetches, the graph selection, and the
79
80
  // "carved" marker the last step leaves on a card.
@@ -129,6 +130,8 @@ import { comparisonRow, comparisonSummary } from "./cross-env.js";
129
130
  // The marker-vs-derived mark on a choudoufu card: how its identity was found.
130
131
  import { identityMark, tagGlyphSvg } from "./identity-mark.js";
131
132
  import { shotFromMessage, shotViewBox, tweenViewBox, unionBox, sameViewBox, heldFrame, heldInsets, heldTarget, holdsStage, medianWidth, smallStage } from "./kiosk-shot.js"; // behold#571: Watch's camera
133
+ 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
+ import { countsLine, groupLabel, groupMarks, queryLine, queryMarks, searchKey, searchUrl, stackIndex, uncapturedLine } from "./search-view.js"; // behold#913: `q` drawn; behold#922: groups
132
135
  // #712, #715: the dots layer, the zoom past the cards. Mounted for a live
133
136
  // carve when the estate has choudoufu roots or estate rosters
134
137
  // (/api/terragucci/carve, liveCarveGate below), or when /api/graph's meta
@@ -152,7 +155,7 @@ if (embedOpts.embed && embedOpts.bare) document.documentElement.classList.add("b
152
155
  // screen, so any scroll over the graph moved it and paused Watch.
153
156
  const kioskTouch = () => !!(embedOpts.embed && embedOpts.bare) && typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches;
154
157
  if (kioskTouch()) document.documentElement.classList.add("kiosk-touch");
155
- initPanel({ embed: embedOpts.embed, phone: typeof matchMedia === "function" && matchMedia(INSPECT_PHONE_QUERY).matches });
158
+ initPanel({ embed: embedOpts.embed, phone: typeof matchMedia === "function" && matchMedia(INSPECT_PHONE_QUERY).matches, phoneQuery: INSPECT_PHONE_QUERY });
156
159
  mountThemePicker(document.getElementById("panel-theme"));
157
160
 
158
161
  // Colour node fills by category/kind using the theme's FULL palette (spicypath-style, so the
@@ -186,9 +189,9 @@ try {
186
189
  let savedColourMode = colourMode;
187
190
 
188
191
  const COLOUR_MODE_TITLE = {
189
- drift: "Colour each card by what chant observed live — the overlay behold has always drawn",
190
- cost: "Colour each card by the engine's cost per hour, low to high across this estate. An entity nothing priced draws neutral, never the cheap end.",
191
- headroom: "Colour each card by how far it is from saturation — the LOWER of the axes the engine reported. An entity nothing priced draws neutral.",
192
+ drift: "Color each card by what chant observed live — the overlay behold has always drawn",
193
+ cost: "Color each card by the engine's cost per hour, low to high across this estate. An entity nothing priced draws neutral, never the cheap end.",
194
+ headroom: "Color each card by how far it is from saturation — the LOWER of the axes the engine reported. An entity nothing priced draws neutral.",
192
195
  };
193
196
 
194
197
  /** `meta.behaviour` off the last render, or null. */
@@ -405,11 +408,15 @@ onThemeChange(() => (recolorNodesByCategory(), drawTgReads())); // behold#571: d
405
408
  // viewer (a "legend" button brings it back).
406
409
  const LEGEND_KEY = "behold.graph.legend.hidden";
407
410
  function legendHidden() {
411
+ let saved = null;
408
412
  try {
409
- return localStorage.getItem(LEGEND_KEY) === "1";
410
- } catch {
411
- return false;
412
- }
413
+ saved = localStorage.getItem(LEGEND_KEY);
414
+ } catch {}
415
+ // On a phone the legend starts folded to its button: open, it covers a third of the graph.
416
+ return saved === "1" || (saved === null && onPhone());
417
+ }
418
+ function onPhone() {
419
+ return typeof matchMedia === "function" && matchMedia(INSPECT_PHONE_QUERY).matches;
413
420
  }
414
421
  function renderGraphLegend() {
415
422
  const host = document.getElementById("graph");
@@ -431,7 +438,7 @@ function renderGraphLegend() {
431
438
  el.className = "closed";
432
439
  el.appendChild(button("legend", "act", () => {
433
440
  try {
434
- localStorage.removeItem(LEGEND_KEY);
441
+ localStorage.setItem(LEGEND_KEY, "0");
435
442
  } catch {}
436
443
  renderGraphLegend();
437
444
  }));
@@ -485,9 +492,9 @@ function renderGraphLegend() {
485
492
  f.title = names[c];
486
493
  sw.appendChild(f);
487
494
  }
488
- line(sw, `box colour: cloud (${["aws", "azure", "gcp"].filter((c) => clouds.includes(c)).map((c) => names[c]).join(", ")})`);
495
+ line(sw, `box color: cloud (${["aws", "azure", "gcp"].filter((c) => clouds.includes(c)).map((c) => names[c]).join(", ")})`);
489
496
  }
490
- line(fills, "card colour: resource kind");
497
+ line(fills, "card color: resource kind");
491
498
  const sub = document.createElement("div");
492
499
  sub.className = "gl-sub";
493
500
  sub.textContent = "bar and outline: state";
@@ -603,12 +610,14 @@ if (staticMode) {
603
610
 
604
611
  /** Canonical key for a read URL — path + the lens params (whitelisted, sorted)
605
612
  * that select a distinct snapshot. MUST match src/export.ts `canonicalKey`. */
606
- const LENS_PARAMS = ["alike", "collapse", "components", "detail", "env", "logical", "ops", "radial", "runtime", "stacks", "tier"];
613
+ const LENS_PARAMS = ["alike", "collapse", "components", "countBy", "detail", "env", "logical", "ops", "plan", "q", "radial", "runtime", "snapshot", "stacks", "tier"]; // q, snapshot: behold#913's /api/search; countBy, plan: behold#922
607
614
  function canonicalKey(path, params) {
608
615
  // Components + logical + ops views ignore detail/radial — drop them so they
609
616
  // match the single captured snapshot (MUST match src/export.ts).
610
617
  const flat = params.get("components") === "1" || params.get("logical") === "1" || params.get("ops") === "1" || params.get("stacks") === "1";
611
- const q = LENS_PARAMS.filter((k) => params.has(k) && !(flat && (k === "detail" || k === "radial")))
618
+ // behold#922: `plan` picks a snapshot of /api/graph (the cards' plan facts) and /api/search only; #404's one-shot plan on an overlay replays the overlay as captured.
619
+ const planned = path === "/api/graph" || path === "/api/search";
620
+ const q = LENS_PARAMS.filter((k) => params.has(k) && !(flat && (k === "detail" || k === "radial")) && !(k === "plan" && !planned))
612
621
  .map((k) => `${k}=${params.get(k)}`)
613
622
  .join("&");
614
623
  return q ? `${path}?${q}` : path;
@@ -1147,7 +1156,7 @@ function renderBehaviourSection(section, b) {
1147
1156
  if (typeof b.headroom.cpu === "number") axes.push(`cpu ${fmtHeadroom(b.headroom.cpu)}`);
1148
1157
  if (typeof b.headroom.latency === "number") axes.push(`latency ${fmtHeadroom(b.headroom.latency)}`);
1149
1158
  const worst = headroomOf(b);
1150
- add("headroom", figureWithBadge(`${axes.join(" · ")} — colours on ${fmtHeadroom(worst)}`, one, meta));
1159
+ add("headroom", figureWithBadge(`${axes.join(" · ")} — colors on ${fmtHeadroom(worst)}`, one, meta));
1151
1160
  add("error rate", figureWithBadge(`${(b.errorRate * 100).toFixed(2)}% of requests at ${b.at.traffic}`, one, meta));
1152
1161
  add("resilience", figureWithBadge(`${RESILIENCE_WORD[b.resilience.verdict] || b.resilience.verdict} — ${b.resilience.failure}`, one, meta));
1153
1162
  if (b.resilience.note) add("resilience note", b.resilience.note);
@@ -1501,7 +1510,7 @@ function inspect(node) {
1501
1510
  tick("at", tickStatus.at);
1502
1511
  if (tickStatus.tickId) tick("tick", tickStatus.tickId);
1503
1512
  if (tickStatus.stale) {
1504
- tick("", "older than the operator's own cadence allows for — this verdict is history, so no colour was taken from it");
1513
+ tick("", "older than the operator's own cadence allows for — this verdict is history, so no color was taken from it");
1505
1514
  }
1506
1515
  }
1507
1516
 
@@ -1559,12 +1568,18 @@ function inspect(node) {
1559
1568
  rel(k, v);
1560
1569
  }
1561
1570
  }
1571
+ // #899: a run that ended after this release and did not pass, from chant's run index.
1572
+ const since = node.attrs._runSince;
1573
+ if (since) {
1574
+ rel("since", `${since.job} ${since.status === "fail" ? "failed" : since.status} at ${since.commit.slice(0, 12)}`);
1575
+ rel("", `run ${since.runId}, ended ${since.ended}, ${since.member ? `for ${since.member}` : "for the whole workspace"}. A release records only a success, so this is what came after it.`);
1576
+ }
1562
1577
  }
1563
1578
 
1564
1579
  // Declared attributes — the source-of-truth values / cross-resource refs.
1565
1580
  // The `release` chip is the card's abbreviation of the section above, not a
1566
1581
  // declared value, so it stays out of this list when the section rendered.
1567
- const attrKeys = Object.keys(node.attrs || {}).filter((k) => !k.startsWith("_") && !(k === "release" && release));
1582
+ const attrKeys = Object.keys(node.attrs || {}).filter((k) => !k.startsWith("_") && !((k === "release" || k === "since") && release));
1568
1583
  if (attrKeys.length) {
1569
1584
  const decl = section("declared");
1570
1585
  // #393 item 10: a choudoufu card that can be adopted leads with the write
@@ -1711,6 +1726,9 @@ let bulkDiffCache = null; // { env, nodes: { <id>: { observed, diff, health } }
1711
1726
  // from its own cache on the loads that follow, so the drift stays on screen
1712
1727
  // without anyone paying for a second full pass over the account.
1713
1728
  let planDriftOnce = false;
1729
+ // #910: ONE-SHOT, the same way: set by "Read the plan on the Terraform roots",
1730
+ // consumed by the source-graph load that carries `plan=1`.
1731
+ let terraformPlanOnce = false;
1714
1732
  async function loadNodeDiff(id) {
1715
1733
  if (publicMode) return null; // #569: /api/diff is refused in a public view
1716
1734
  if (!bulkDiffCache || bulkDiffCache.env !== view.env) {
@@ -1945,12 +1963,23 @@ function wire(ir) {
1945
1963
  host.querySelectorAll(".sel").forEach((n) => n.classList.remove("sel"));
1946
1964
  g.classList.add("sel");
1947
1965
  inspect(node);
1966
+ // On a phone the pane is folded under the graph; a tap on a card is asking for it.
1967
+ if (onPhone()) document.getElementById("app").classList.remove("inspect-collapsed");
1948
1968
  noteSelection(node.id);
1949
1969
  // #254: in carve mode a click is also the walkthrough's Pick step — the
1950
1970
  // inspect pane already shows the score arithmetic the lens spelled out,
1951
1971
  // and the stepper picks up the same node.
1952
1972
  carvePick(node);
1953
1973
  });
1974
+ // A double-click goes one zoom finer, at the fit.
1975
+ g.addEventListener("dblclick", (e) => {
1976
+ const next = DRILL[zoomValue()];
1977
+ if (panMoved || !next || !availableZooms().some(([, z]) => z === next)) return;
1978
+ e.preventDefault();
1979
+ applyZoom(next);
1980
+ renderStatusbar();
1981
+ load();
1982
+ });
1954
1983
  }
1955
1984
  // #475/#476: a member's box picks the member. Only boxes that are members
1956
1985
  // (a wave or a VPC box is not one), and only a click on the box itself, not
@@ -1991,7 +2020,9 @@ function wire(ir) {
1991
2020
  // member (#475) is the estate member the view is on: a host opens behold with
1992
2021
  // ?member=, and picking a card or a member box moves it. It changes no fetch;
1993
2022
  // the graph is the whole estate, framed on that member's box.
1994
- const view = { member: null, env: null, gates: null, focus: null, run: null, detail: 2, components: true, logical: false, runtime: false, ops: false, tier: null, target: null, stack: null, radial: false, collapse: false, alike: false, compareTo: null };
2023
+ // q, snapshot (#913, #914): the question the view asks and the recorded snapshot it reads. Carried in the URL and
2024
+ // moved by an agent; nothing draws q until #913's search read lands.
2025
+ const view = { member: null, env: null, gates: null, focus: null, run: null, q: null, snapshot: null, plan: false, countBy: null, detail: 2, components: true, logical: false, runtime: false, ops: false, tier: null, target: null, stack: null, radial: false, collapse: false, alike: true, compareTo: null };
1995
2026
 
1996
2027
  // #182: `components` is the boot default, but a project that declares no
1997
2028
  // components renders it as ZERO nodes — the first screen was a blank graph
@@ -2015,8 +2046,10 @@ let autoZoomFallback = true;
2015
2046
  // #571: a terragucci repo that declares its roots as components
2016
2047
  // (`terragucci.components.json`, /api/project's `terragucciComponents`) does
2017
2048
  // have a components picture, so it opens there whatever its member kind.
2018
- function bootZoom(memberKinds, terragucciComponents) {
2049
+ function bootZoom(memberKinds, terragucciComponents, componentsDeclared) {
2019
2050
  if (terragucciComponents) return "components";
2051
+ // #897: an estate whose members declare no component has no components picture.
2052
+ if (componentsDeclared === false) return "resources";
2020
2053
  return memberKinds && memberKinds.length && !memberKinds.includes("chant") ? "resources" : "components";
2021
2054
  }
2022
2055
 
@@ -2085,13 +2118,19 @@ let pendingTotal = 0;
2085
2118
  * `stacksCapable`, which is false for an estate and for a single-lexicon
2086
2119
  * project, where the answer could only ever be one box. */
2087
2120
  let stacksCapable = false;
2121
+ /** #897: false when an estate's members declare no component (/api/project); undefined for a single project. */
2122
+ let componentsDeclared;
2088
2123
  /** The zoom stops this project can actually offer — `runtime` needs an env AND
2089
2124
  * a member whose substrate has an owner chain, `ops` needs emitted op.json
2090
2125
  * files. Both the panel and ⌘K read this, so a stop never appears in one
2091
2126
  * surface and not the other. */
2092
2127
  function availableZooms() {
2093
- return ZOOM_OPTS.filter(([, z]) => (z === "runtime" ? Boolean(view.env) && runtimeCapable : z === "ops" ? opsAvailable > 0 : z === "stacks" ? stacksCapable : true));
2128
+ return ZOOM_OPTS.filter(([, z]) =>
2129
+ z === "runtime" ? Boolean(view.env) && runtimeCapable : z === "ops" ? opsAvailable > 0 : z === "stacks" ? stacksCapable : z === "components" ? componentsDeclared !== false : true,
2130
+ );
2094
2131
  }
2132
+ /** The zoom a double-clicked card goes to: the next finer one. */
2133
+ const DRILL = { components: "logical", logical: "composites", composites: "resources", resources: "attributes" };
2095
2134
  /** Current zoom value from (components, logical, ops, detail). */
2096
2135
  function zoomValue() {
2097
2136
  if (view.components) return "components";
@@ -2111,6 +2150,55 @@ function applyZoom(z) {
2111
2150
  if (z !== "components" && z !== "logical" && z !== "ops" && z !== "stacks") view.detail = ZOOM_DETAIL[z] ?? 2;
2112
2151
  }
2113
2152
 
2153
+ /** An estate of several projects: the stacked view and its toggle apply. */
2154
+ function isEstate() {
2155
+ return !!(lastMeta && lastMeta.estate > 1);
2156
+ }
2157
+ /** The zooms the server stacks alike cards on: the ones that draw every card. */
2158
+ function alikeZoom() {
2159
+ return ["composites", "resources", "attributes"].includes(zoomValue());
2160
+ }
2161
+ const ALIKE_TITLE =
2162
+ "Three or more cards of one kind in a box draw as one card with a count; a card many others refer to carries the number instead of the lines";
2163
+ /** Stack or unstack alike cards. From a zoom that doesn't stack, go to resources stacked. */
2164
+ function toggleAlike() {
2165
+ if (!alikeZoom()) {
2166
+ applyZoom("resources");
2167
+ view.alike = true;
2168
+ nowline("stack alike draws on the resources zoom, so the view moved there");
2169
+ } else view.alike = !view.alike;
2170
+ renderStatusbar();
2171
+ load();
2172
+ }
2173
+
2174
+ /** Toggles over the canvas's top edge: the view features one click away. */
2175
+ function ensureViewToggles(host) {
2176
+ if (!host) return;
2177
+ let bar = document.getElementById("view-toggles");
2178
+ if (!bar || bar.parentElement !== host) {
2179
+ bar = document.createElement("div");
2180
+ bar.id = "view-toggles";
2181
+ host.appendChild(bar);
2182
+ }
2183
+ bar.innerHTML = "";
2184
+ if (isEstate()) {
2185
+ const b = button("▦ stack alike", "vt" + (view.alike && alikeZoom() ? " active" : ""), toggleAlike);
2186
+ b.title = ALIKE_TITLE;
2187
+ bar.appendChild(b);
2188
+ }
2189
+ if (!view.components && !view.ops) {
2190
+ const b = button("⇢ trace", "vt", () => {
2191
+ setPanelTab("model");
2192
+ renderPanelModel();
2193
+ const sec = document.querySelector(".net-trace");
2194
+ if (sec) sec.scrollIntoView({ block: "nearest" });
2195
+ });
2196
+ b.title = "Trace traffic hop by hop to a card, and see the network findings (Model tab)";
2197
+ bar.appendChild(b);
2198
+ }
2199
+ bar.style.display = bar.children.length ? "" : "none";
2200
+ }
2201
+
2114
2202
  // --- Floating control panel content ---------------------------------------
2115
2203
  // panel.js owns the chrome (drag, snap to edges/corners, collapse, tabs);
2116
2204
  // these functions own what's IN the tabs, re-rendered from renderStatusbar()
@@ -2159,6 +2247,7 @@ function renderPanelView() {
2159
2247
  panelOpt(label.replace(/^zoom: /, ""), v === current, () => {
2160
2248
  applyZoom(v);
2161
2249
  renderStatusbar();
2250
+ foldPanelOnPhone();
2162
2251
  load();
2163
2252
  }),
2164
2253
  );
@@ -2167,7 +2256,7 @@ function renderPanelView() {
2167
2256
  // this tab is for is "what am I looking at", and colour is half that answer.
2168
2257
  // Sits below the stops because it is not a granularity: every zoom paints in
2169
2258
  // whichever of the three you picked.
2170
- zoom.appendChild(panelHeading("colour by"));
2259
+ zoom.appendChild(panelHeading("color by"));
2171
2260
  for (const mode of COLOUR_MODES) {
2172
2261
  const gate = mode === "drift" ? { available: true, reason: "" } : modeAvailability(lastMeta, mode);
2173
2262
  const b = panelOpt(
@@ -2206,21 +2295,13 @@ function renderPanelView() {
2206
2295
  );
2207
2296
  if (estate) radial.disabled = true;
2208
2297
  zoom.appendChild(radial);
2209
- // #877: cards of one kind in a box stack into one with a count. An estate
2210
- // lens, like collapse: the server stacks within each project's box.
2211
- if (estate) {
2212
- zoom.appendChild(
2213
- panelOpt(
2214
- "stack alike",
2215
- view.alike,
2216
- () => {
2217
- view.alike = !view.alike;
2218
- load();
2219
- },
2220
- "Three or more cards of one kind in a box draw as one card with a count; a card many others refer to carries the number instead of the lines",
2221
- ),
2222
- );
2223
- }
2298
+ }
2299
+ // #877: cards of one kind in a box stack into one with a count. An estate
2300
+ // lens, like collapse: the server stacks within each project's box. Offered
2301
+ // on every zoom: from one that doesn't stack, it moves to resources.
2302
+ if (isEstate()) {
2303
+ if (view.components || view.logical || view.ops) zoom.appendChild(panelHeading("layout"));
2304
+ zoom.appendChild(panelOpt("stack alike", view.alike && alikeZoom(), toggleAlike, ALIKE_TITLE));
2224
2305
  }
2225
2306
  const tools = document.getElementById("panel-viewtools");
2226
2307
  tools.innerHTML = "";
@@ -2929,6 +3010,7 @@ function applyWantedView(want) {
2929
3010
  zooms: availableZooms().map(([, z]) => z),
2930
3011
  tiers,
2931
3012
  lenses: COLOUR_MODES,
3013
+ env: view.env, // a snapshot is of the env the view is on
2932
3014
  });
2933
3015
  urlRefusals.push(...first.refused, ...refused);
2934
3016
  if (apply.tier) view.tier = apply.tier;
@@ -2943,6 +3025,13 @@ function applyWantedView(want) {
2943
3025
  if ("focus" in apply) view.focus = apply.focus; // #569: drawn by drawTgReads, no new read
2944
3026
  if ("run" in apply) view.run = apply.run; // #569: which run the view draws; read in the message handler
2945
3027
  if ("pull" in apply) view.pull = apply.pull; // the cycle's pull request: a commit's run never draws another's plan
3028
+ if ("q" in apply) view.q = apply.q; // #914 carries it; #913 draws it (drawQuery)
3029
+ if ("snapshot" in apply) view.snapshot = apply.snapshot;
3030
+ if (!view.env) view.snapshot = null; // a snapshot is of an env: the source graph has none
3031
+ // behold#922: the plan read (the cards' plan facts, q at the plan depth) and q's grouping.
3032
+ if ("plan" in apply) view.plan = apply.plan;
3033
+ if (view.plan) view.snapshot = null; // settleView refuses the two together; a plan is now
3034
+ if ("countBy" in apply) view.countBy = apply.countBy;
2946
3035
  if (want.member === null) {
2947
3036
  view.member = null;
2948
3037
  selectedNodeId = null;
@@ -2956,7 +3045,7 @@ function applyWantedView(want) {
2956
3045
  return fetchKey() !== before;
2957
3046
  }
2958
3047
  function fetchKey() {
2959
- return [view.env, zoomValue(), view.tier, view.radial, view.alike].join("|");
3048
+ return [view.env, zoomValue(), view.tier, view.radial, view.alike, view.plan].join("|"); // plan: behold#922's plan facts on the cards
2960
3049
  }
2961
3050
 
2962
3051
  // #476: the host moves the view with a `behold:view` message carrying the same
@@ -2964,11 +3053,19 @@ function fetchKey() {
2964
3053
  window.addEventListener("message", (e) => {
2965
3054
  const want = viewFromMessage(e, embedOpts.host);
2966
3055
  if (!want) return;
3056
+ moveViewTo(want);
3057
+ });
3058
+
3059
+ /** Move the view the way a host's `behold:view` does: settle it, re-read what
3060
+ * it changed, and say what couldn't be opened. An agent's move (#914) and Back
3061
+ * from one come through here too. */
3062
+ function moveViewTo(want) {
2967
3063
  const lensBefore = colourMode;
2968
3064
  const gatesBefore = view.gates;
2969
3065
  const focusBefore = view.focus;
2970
3066
  const runBefore = view.run;
2971
3067
  const pullBefore = view.pull;
3068
+ const queryBefore = searchKey(view);
2972
3069
  const moved = applyWantedView(want);
2973
3070
  if (view.run !== runBefore || view.pull !== pullBefore) {
2974
3071
  if (tgServed) void loadTgProgress({ fresh: true }); // #569: the run the narration is about
@@ -2988,14 +3085,90 @@ window.addEventListener("message", (e) => {
2988
3085
  return;
2989
3086
  }
2990
3087
  if (colourMode !== lensBefore) recolorNodesByCategory();
3088
+ if (searchKey(view) !== queryBefore) void drawQuery(); // #913: a new question over the same graph
2991
3089
  if (pendingPlace && lastGraphIr) afterPaint(lastGraphIr);
2992
3090
  else if (want.member === null) fitGraph();
2993
3091
  const line = refusalLine(urlRefusals);
2994
3092
  urlRefusals = [];
2995
3093
  if (line) nowline(line);
2996
3094
  renderStatusbar();
3095
+ }
3096
+
3097
+ // --- #914: an agent moved the tab --------------------------------------------
3098
+ // POST /api/view sends a `view` event on /api/events. The tab moves the way a
3099
+ // host's message moves it, says who asked and when, and pushes a history entry
3100
+ // so the banner's Back and the browser's Back both return to the view it left.
3101
+ // The person's own changes keep replacing the entry they are on (syncViewUrl).
3102
+ // An embedded frame with a host ignores the event: its view is the host's (#476).
3103
+ function agentMove(data) {
3104
+ if (embedOpts.embed && embedOpts.host) return;
3105
+ let ev;
3106
+ try {
3107
+ ev = JSON.parse(data);
3108
+ } catch {
3109
+ return;
3110
+ }
3111
+ if (!ev || typeof ev !== "object") return;
3112
+ const want = wholeQuestion(viewFromObject(ev.view).want, view);
3113
+ if (!Object.keys(want).length) return;
3114
+ const move = { id: String(ev.id || ""), by: String(ev.by || "an agent"), movedAt: String(ev.movedAt || ""), q: typeof want.q === "string" ? want.q : "" };
3115
+ syncViewUrl(); // the entry being left holds the view as it is now
3116
+ const entry = agentEntry(history.state, move);
3117
+ try {
3118
+ // The new entry starts as a copy of the one being left; moveViewTo's syncViewUrl writes the new view into it.
3119
+ if (entry.push) history.pushState(entry.state, "", location.href);
3120
+ else history.replaceState(entry.state, "", location.href);
3121
+ } catch {
3122
+ /* a sandboxed frame may refuse; the move still happens */
3123
+ }
3124
+ moveViewTo(want);
3125
+ showAgentBanner(move);
3126
+ }
3127
+
3128
+ // Back, from the banner or the browser: the URL is the view to go back to.
3129
+ window.addEventListener("popstate", (e) => {
3130
+ if (!viewUrlReady) return;
3131
+ const defaults = { env: defaultEnv(manifest && manifest.opening, projectInfo && projectInfo.currentEnv), lens: savedColourMode };
3132
+ moveViewTo(restoreViewQuery(location.search, defaults));
3133
+ const move = e.state && e.state.beholdMove;
3134
+ if (move) showAgentBanner(move);
3135
+ else hideAgentBanner();
2997
3136
  });
2998
3137
 
3138
+ function showAgentBanner(move) {
3139
+ let el = document.getElementById("agent-banner");
3140
+ if (!el) {
3141
+ el = document.createElement("div");
3142
+ el.id = "agent-banner";
3143
+ el.setAttribute("role", "status");
3144
+ document.body.appendChild(el);
3145
+ }
3146
+ const b = agentBanner(move, new Date(move.movedAt));
3147
+ el.innerHTML = "";
3148
+ const text = document.createElement("span");
3149
+ text.className = "agent-banner-text";
3150
+ text.textContent = b.text;
3151
+ el.appendChild(text);
3152
+ const back = document.createElement("button");
3153
+ back.className = "agent-banner-back";
3154
+ back.textContent = "Back";
3155
+ back.title = "Return to the view before this move";
3156
+ back.addEventListener("click", () => history.back());
3157
+ el.appendChild(back);
3158
+ const close = document.createElement("button");
3159
+ close.className = "agent-banner-close";
3160
+ close.textContent = "×";
3161
+ close.title = "Dismiss; Back in the browser still returns";
3162
+ close.addEventListener("click", hideAgentBanner);
3163
+ el.appendChild(close);
3164
+ el.hidden = false;
3165
+ el.dataset.request = move.id;
3166
+ }
3167
+ function hideAgentBanner() {
3168
+ const el = document.getElementById("agent-banner");
3169
+ if (el) el.hidden = true;
3170
+ }
3171
+
2999
3172
  /** Tell the host what was picked: a card (member + node) or a member's box. */
3000
3173
  function embedSelected(member, node) {
3001
3174
  if (embedOpts.embed && member) setInspectCollapsed(!node);
@@ -3175,17 +3348,168 @@ function afterPaint(ir) {
3175
3348
  if (place.apply.node) {
3176
3349
  selectNode(place.apply.node, { quiet: true });
3177
3350
  revealNode(place.apply.node);
3178
- }
3351
+ } else if (view.member) revealMember(view.member);
3179
3352
  renderStatusbar();
3180
3353
  } else if (selectedNodeId && !ids.has(selectedNodeId)) {
3181
- // The pick isn't on this view any more; the URL stops naming it.
3354
+ // The pick isn't on this view any more; the URL stops naming it. The view
3355
+ // stays at the fit: a member a pick implied is no reason to zoom in on it.
3182
3356
  selectedNodeId = null;
3183
3357
  syncViewUrl();
3358
+ const panel = document.getElementById("inspect-body");
3359
+ if (panel) panel.innerHTML = '<h2>Inspect</h2><p style="color:var(--ink2)">Click a node</p>';
3184
3360
  }
3185
- if (view.member && !selectedNodeId) revealMember(view.member);
3186
3361
  const line = refusalLine(urlRefusals);
3187
3362
  urlRefusals = [];
3188
3363
  if (line) nowline(line);
3364
+ void drawQuery(); // #913: every paint draws the view's question over the new svg
3365
+ }
3366
+
3367
+ // --- behold#913: `q` drawn ----------------------------------------------------
3368
+ // The view's query is read through GET /api/search (chant answers, behold
3369
+ // draws: src/search.ts), once per query, env and snapshot, and again after a
3370
+ // `changed` event. Each paint lights the matches, draws the edges on their
3371
+ // paths, dims the rest, and says the query and chant's provenance in one line
3372
+ // (web/search-view.js decides; this applies). A refused query lights and dims
3373
+ // nothing; no matches dims everything and outlines the near-misses.
3374
+ let queryAnswer = null; // {key, answer} once read
3375
+ let queryReading = null; // {key, promise} while a read is in flight
3376
+ async function readQuery(key) {
3377
+ if (queryAnswer && queryAnswer.key === key) return queryAnswer.answer;
3378
+ if (queryReading && queryReading.key === key) return queryReading.promise;
3379
+ const promise = (async () => {
3380
+ let answer;
3381
+ try {
3382
+ const res = await apiFetch(searchUrl(view));
3383
+ answer = await res.json().catch(() => ({ error: `the search answered ${res.status}` }));
3384
+ if (staticMode && res.status === 404) answer = { error: uncapturedLine(view.q, manifest && manifest.queries), uncaptured: true };
3385
+ } catch (err) {
3386
+ answer = { error: `the search failed: ${err.message}` };
3387
+ }
3388
+ if (searchKey(view) === key) queryAnswer = { key, answer };
3389
+ return answer;
3390
+ })();
3391
+ queryReading = { key, promise };
3392
+ try {
3393
+ return await promise;
3394
+ } finally {
3395
+ if (queryReading && queryReading.key === key) queryReading = null;
3396
+ }
3397
+ }
3398
+ /** The answer the shot frame draws: null while none is wanted, undefined while it is read. */
3399
+ function queryAnswerNow() {
3400
+ const key = searchKey(view);
3401
+ if (!key) return null;
3402
+ return queryAnswer && queryAnswer.key === key ? queryAnswer.answer : undefined;
3403
+ }
3404
+ function clearQueryMarks(svg) {
3405
+ if (!svg) return;
3406
+ for (const el of svg.querySelectorAll("[data-q]")) el.removeAttribute("data-q");
3407
+ for (const el of svg.querySelectorAll("[data-q-near]")) {
3408
+ el.removeAttribute("data-q-near");
3409
+ const t = el.querySelector(":scope > title.q-near-title");
3410
+ if (t) t.remove();
3411
+ }
3412
+ for (const el of svg.querySelectorAll("[data-q-unobserved]")) el.removeAttribute("data-q-unobserved");
3413
+ // behold#922: a counts answer's group colours and labels.
3414
+ for (const el of svg.querySelectorAll("[data-q-group]")) {
3415
+ el.removeAttribute("data-q-group");
3416
+ el.style.removeProperty("--q-group");
3417
+ }
3418
+ for (const el of svg.querySelectorAll(".q-group-label")) el.remove();
3419
+ }
3420
+ async function drawQuery() {
3421
+ const key = searchKey(view);
3422
+ const lineEl = document.getElementById("q-line");
3423
+ if (!key) {
3424
+ clearQueryMarks(currentSvg());
3425
+ if (lineEl) lineEl.hidden = true;
3426
+ return;
3427
+ }
3428
+ const answer = await readQuery(key);
3429
+ if (searchKey(view) !== key) return; // the view moved on while it was read
3430
+ const svg = currentSvg();
3431
+ clearQueryMarks(svg);
3432
+ const cardEls = svg ? [...svg.querySelectorAll("[data-node-id]")] : [];
3433
+ const edgeEls = svg ? [...svg.querySelectorAll("g[data-edge-from]")] : [];
3434
+ const cardIds = new Set(cardEls.map((g) => g.getAttribute("data-node-id")));
3435
+ const stackOf = stackIndex(lastGraphIr && lastGraphIr.nodes, cardIds);
3436
+ const marks = queryMarks(
3437
+ answer,
3438
+ cardIds,
3439
+ edgeEls.map((g) => ({ from: g.getAttribute("data-edge-from"), to: g.getAttribute("data-edge-to") })),
3440
+ stackOf,
3441
+ );
3442
+ for (const g of cardEls) {
3443
+ const id = g.getAttribute("data-node-id");
3444
+ const m = marks.cardMarks.get(id);
3445
+ if (m) g.setAttribute("data-q", m);
3446
+ if (marks.unobserved.has(id)) g.setAttribute("data-q-unobserved", "1");
3447
+ if (marks.near.has(id)) {
3448
+ g.setAttribute("data-q-near", "1");
3449
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "title");
3450
+ t.setAttribute("class", "q-near-title");
3451
+ t.textContent = `near miss: fails ${marks.near.get(id)}`;
3452
+ g.prepend(t);
3453
+ }
3454
+ }
3455
+ edgeEls.forEach((g, i) => {
3456
+ if (marks.edgeMarks[i]) g.setAttribute("data-q", marks.edgeMarks[i]);
3457
+ });
3458
+ drawGroups(svg, answer, cardEls, stackOf);
3459
+ if (embedOpts.bare) return; // a bare frame has no chrome: the shot frame draws its own caption
3460
+ const line = queryLine(view, answer, marks);
3461
+ let el = lineEl;
3462
+ if (!el) {
3463
+ el = document.createElement("div");
3464
+ el.id = "q-line";
3465
+ el.setAttribute("role", "status");
3466
+ document.body.appendChild(el);
3467
+ }
3468
+ el.hidden = false;
3469
+ el.dataset.tone = line.tone;
3470
+ el.innerHTML = "";
3471
+ const main = document.createElement("div");
3472
+ main.className = "q-line-main";
3473
+ main.textContent = line.text;
3474
+ el.appendChild(main);
3475
+ if (line.notSearched) {
3476
+ const ns = document.createElement("div");
3477
+ ns.className = "q-line-not-searched";
3478
+ ns.textContent = line.notSearched;
3479
+ el.appendChild(ns);
3480
+ }
3481
+ }
3482
+
3483
+ /**
3484
+ * behold#922: a counts answer drawn: each group's cards outlined in the
3485
+ * group's colour, and the group's first drawn card labelled with the group
3486
+ * and chant's count (web/search-view.js groupMarks). The cards are already
3487
+ * lit by drawQuery; this says which group each is in.
3488
+ */
3489
+ function drawGroups(svg, answer, cardEls, stackOf) {
3490
+ if (!svg) return;
3491
+ const gm = groupMarks(answer, new Set(cardEls.map((g) => g.getAttribute("data-node-id"))), stackOf);
3492
+ if (!gm.groups.length) return;
3493
+ const byId = new Map(cardEls.map((g) => [g.getAttribute("data-node-id"), g]));
3494
+ for (const [id, i] of gm.cardGroup) {
3495
+ const g = byId.get(id);
3496
+ g.setAttribute("data-q-group", gm.groups[i].group);
3497
+ g.style.setProperty("--q-group", gm.groups[i].colour);
3498
+ }
3499
+ for (const grp of gm.groups) {
3500
+ const g = grp.label && byId.get(grp.label);
3501
+ const rect = g && g.querySelector(":scope > rect");
3502
+ if (!rect) continue;
3503
+ const x = Number(rect.getAttribute("x") || 0);
3504
+ const y = Number(rect.getAttribute("y") || 0);
3505
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "text");
3506
+ t.setAttribute("class", "q-group-label");
3507
+ t.setAttribute("x", String(x));
3508
+ t.setAttribute("y", String(y - 4));
3509
+ t.setAttribute("fill", grp.colour);
3510
+ t.textContent = groupLabel(grp);
3511
+ g.appendChild(t);
3512
+ }
3189
3513
  }
3190
3514
 
3191
3515
  /** A card was picked (graph click, panel row, palette, the link). */
@@ -3258,10 +3582,15 @@ function syncViewUrl() {
3258
3582
  lens: colourMode,
3259
3583
  node: place.node || selectedNodeId,
3260
3584
  radial: view.radial && !view.components && !view.logical && !view.ops,
3261
- alike: view.alike && !view.components && !view.logical && !view.ops,
3585
+ // Stacked is the default, so only an estate's every-card view is written.
3586
+ alike: isEstate() && alikeZoom() ? view.alike : undefined,
3262
3587
  gates: view.gates,
3263
3588
  focus: view.focus,
3264
3589
  run: view.run,
3590
+ q: view.q,
3591
+ snapshot: view.snapshot,
3592
+ plan: view.plan,
3593
+ countBy: view.countBy,
3265
3594
  };
3266
3595
  const defaults = { env: defaultEnv(manifest && manifest.opening, projectInfo && projectInfo.currentEnv), lens: savedColourMode };
3267
3596
  const next = location.pathname + writeViewQuery(location.search, state, defaults) + location.hash;
@@ -3399,7 +3728,7 @@ function renderPanelModel() {
3399
3728
  }
3400
3729
  }
3401
3730
  renderEdgeLegend(host, ir);
3402
- renderNetworkSection(host, ir);
3731
+ renderNetworkSection(host);
3403
3732
  renderBehaviourRefusal(host);
3404
3733
  renderBehaviourDiagnostics(host);
3405
3734
  }
@@ -3496,9 +3825,12 @@ function netRow(color, what, text, tag, onClick) {
3496
3825
  return row;
3497
3826
  }
3498
3827
 
3499
- function renderNetworkSection(host, ir) {
3500
- if (view.components || view.ops || !(ir.nodes || []).some((n) => NETWORK_KIND.test(n.kind || ""))) return;
3828
+ function renderNetworkSection(host) {
3829
+ if (view.components || view.ops) return;
3830
+ // The section reads its own every-card graph, so a zoom that folds the
3831
+ // network away (composites, logical) still traces it.
3501
3832
  loadNetworkGraph();
3833
+ if (net.ir && !net.ir.nodes.some((n) => NETWORK_KIND.test(n.kind || ""))) return;
3502
3834
  host.appendChild(panelHeading("network"));
3503
3835
  if (net.error) {
3504
3836
  host.appendChild(panelMuted(`the network couldn't be read: ${net.error}`));
@@ -4066,7 +4398,7 @@ function markDriftedCards(ir) {
4066
4398
  const count_ = mark.attributes.length;
4067
4399
  tag.textContent = `~ ${count_} attribute${count_ === 1 ? "" : "s"}`;
4068
4400
  const title = document.createElementNS("http://www.w3.org/2000/svg", "title");
4069
- title.textContent = `The plan would ${(mark.actions || ["update"]).join("+")} this: ${mark.attributes.join(", ")}. Ownership is unchanged — the card's colour is still its ownership verdict.`;
4401
+ title.textContent = `The plan would ${(mark.actions || ["update"]).join("+")} this: ${mark.attributes.join(", ")}. Ownership is unchanged — the card's color is still its ownership verdict.`;
4070
4402
  g.appendChild(title);
4071
4403
  g.appendChild(tag);
4072
4404
  }
@@ -6280,15 +6612,22 @@ function kioskTellBoxes() {
6280
6612
  * so the graph pane never shows an empty frame.
6281
6613
  */
6282
6614
  var drawnTold = false;
6283
- function kioskTellDrawn() {
6284
- if (drawnTold || !embedOpts.host || window.parent === window) return;
6615
+ /** Whether the graph has drawn with its marks: "failed" when it could not, true once drawn, false while it is still coming. */
6616
+ function graphDrawnState() {
6285
6617
  const svg = currentSvg();
6286
- const failed = !!document.querySelector("#graph > .err");
6287
- if (!failed && !(svg && svg.querySelector("[data-node-id]"))) return;
6618
+ if (document.querySelector("#graph > .err")) return "failed";
6619
+ if (!(svg && svg.querySelector("[data-node-id]"))) return false;
6288
6620
  // The marks: terragucci's reports answered (or refused), or chant's loop has its own.
6289
- if (!failed && terragucciComponentsRepo && !tgAnswer && !chantPrDrawn()) return;
6621
+ if (terragucciComponentsRepo && !tgAnswer && !chantPrDrawn()) return false;
6290
6622
  // behold#631: a chant repo's loop: its first read of /api/chant/pr, answered or not.
6291
- if (!failed && !terragucciComponentsRepo && view.components && chantFacets && !staticMode && !chantPrRead) return;
6623
+ if (!terragucciComponentsRepo && view.components && chantFacets && !staticMode && !chantPrRead) return false;
6624
+ return true;
6625
+ }
6626
+ function kioskTellDrawn() {
6627
+ if (drawnTold || !embedOpts.host || window.parent === window) return;
6628
+ const drawnState = graphDrawnState();
6629
+ if (!drawnState) return;
6630
+ const failed = drawnState === "failed";
6292
6631
  drawnTold = true;
6293
6632
  try {
6294
6633
  window.parent.postMessage({ type: "behold:drawn", failed }, embedOpts.host);
@@ -6299,6 +6638,97 @@ function kioskTellDrawn() {
6299
6638
  // A graph that failed draws no svg and no reads: say so too, so the kiosk is never left waiting.
6300
6639
  if (embedOpts.bare) setInterval(kioskTellDrawn, 1000);
6301
6640
 
6641
+ // --- behold#915: the page `behold shot` photographs ---------------------------
6642
+ // `?embed=1&bare=1&frame=matches` (web/shot-frame.js). Once the graph has
6643
+ // drawn, the cards the view asks for are lit and the rest dimmed, the lit
6644
+ // cards are framed with the kiosk's arithmetic at once (no move), one caption
6645
+ // line says what was asked, from where and when, and <html> gets
6646
+ // `data-behold-shot`. A graph that never draws never sets it, so the driver
6647
+ // times out and writes nothing.
6648
+ const shotFrameOn = !!embedOpts.bare && readShotFrame(location.search) === "matches";
6649
+ // The link as loaded: the page rewrites its URL as it settles the view (a card it lacks drops out), and the shot answers what was asked.
6650
+ const shotAsked = new URLSearchParams(location.search);
6651
+ var shotFrameDone = false; // var: setupGraphViewBox reads it, and may run before this line is reached
6652
+ var shotQueryFailed = false; // behold#913: the query was refused, or its live read failed
6653
+ function shotFrameTick() {
6654
+ if (!shotFrameOn || shotFrameDone) return;
6655
+ const drawnState = graphDrawnState();
6656
+ if (!drawnState) return;
6657
+ // behold#913: a query is drawn once chant has answered it (drawQuery marks the cards first).
6658
+ if (drawnState !== "failed" && queryAnswerNow() === undefined) return;
6659
+ shotFrameDone = true;
6660
+ const state = shotFrameApply(drawnState === "failed");
6661
+ // Two frames, so what was set above is painted before the driver looks.
6662
+ requestAnimationFrame(() => requestAnimationFrame(() => document.documentElement.setAttribute(SHOT_ATTR, state)));
6663
+ }
6664
+ /** Light, dim, frame and caption the graph as it is drawn now; the state the shot reports. */
6665
+ function shotFrameApply(failed = !!document.querySelector("#graph > .err")) {
6666
+ const params = shotAsked;
6667
+ const svg = currentSvg();
6668
+ const host = document.getElementById("graph");
6669
+ let lit = { ids: [], asked: false, label: null };
6670
+ if (!failed && svg && host) {
6671
+ const ownRect = (g) => g.querySelector(":scope > rect") || g;
6672
+ const cards = [...svg.querySelectorAll("[data-node-id]")].map((g) => ({ id: g.getAttribute("data-node-id"), g, box: userBoxOf(svg, ownRect(g)) }));
6673
+ const groups = [...svg.querySelectorAll("rect[data-group-id]")].map((r) => ({ id: r.getAttribute("data-group-id"), box: userBoxOf(svg, r) }));
6674
+ // behold#913: the query's matched node ids (drawQuery has marked the cards and the path edges). Without a
6675
+ // query, the link's own node and focus, as asked: a card the graph lacks is a question with no answer, never the whole graph.
6676
+ const qa = queryAnswerNow();
6677
+ // #908 stage 3: the matches and the frame come from drawQuery's marks, so a stack holding a match counts and the path is in the picture.
6678
+ const qf = qa && qa.draw ? queryFrame(cards.map((c) => ({ id: c.id, mark: c.g.getAttribute("data-q") }))) : null;
6679
+ lit = shotLit({ node: params.get("node"), focus: params.get("focus") }, cards, groups, qa ? (qf ? qf.lit : []) : null);
6680
+ shotQueryFailed = !!qa && (!qa.draw || !!qa.draw.failure);
6681
+ const on = new Set(lit.ids);
6682
+ for (const c of cards) {
6683
+ // A query's on-path cards stay at full weight; a refused query dims nothing.
6684
+ const dim = qa ? c.g.getAttribute("data-q") === "dim" : lit.asked && !on.has(c.id);
6685
+ c.g.style.opacity = dim ? String(SHOT_DIM) : "";
6686
+ if (dim || (qa && !on.has(c.id))) c.g.setAttribute("data-shot-dim", "1");
6687
+ else c.g.removeAttribute("data-shot-dim");
6688
+ }
6689
+ for (const e of svg.querySelectorAll("[data-edge-from]")) {
6690
+ const mark = e.getAttribute("data-q");
6691
+ const dim = qa ? mark === "dim" : lit.asked && !(on.has(e.getAttribute("data-edge-from")) && on.has(e.getAttribute("data-edge-to")));
6692
+ e.style.opacity = dim ? String(SHOT_DIM) : "";
6693
+ }
6694
+ // The lit cards, or with none lit the whole graph as drawn (its boxes' titles and all).
6695
+ const whole = vbInit && { x: vbInit[0], y: vbInit[1], x2: vbInit[0] + vbInit[2], y2: vbInit[1] + vbInit[3] };
6696
+ const framed = qf ? new Set(qf.frame) : on;
6697
+ const target = (lit.ids.length && unionBox(cards.filter((c) => framed.has(c.id)).map((c) => c.box))) || whole;
6698
+ const pane = host.getBoundingClientRect();
6699
+ const to = target && shotViewBox(target, { width: pane.width, height: pane.height }, { bottom: SHOT_CAPTION_PX });
6700
+ if (to) {
6701
+ vb = to;
6702
+ vbAtFit = false;
6703
+ applyVB();
6704
+ }
6705
+ }
6706
+ const qa = queryAnswerNow();
6707
+ const state = shotState({ failed: failed || shotQueryFailed, lit });
6708
+ const err = document.querySelector("#graph > .err");
6709
+ let cap = document.getElementById("shot-caption");
6710
+ if (!cap) {
6711
+ cap = document.createElement("div");
6712
+ cap.id = "shot-caption";
6713
+ cap.style.cssText = `position:fixed;left:0;right:0;bottom:0;height:${SHOT_CAPTION_PX}px;padding:0 12px;font:13px/1 system-ui,sans-serif;line-height:${SHOT_CAPTION_PX}px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;z-index:50;background:var(--bg, #0d1117);color:var(--fg, #e6edf3);border-top:1px solid var(--border, #30363d)`;
6714
+ document.body.appendChild(cap);
6715
+ }
6716
+ cap.style.color = state === "failed" ? "var(--degraded, #f85149)" : "var(--fg, #e6edf3)";
6717
+ // behold#913: chant's own provenance line, and its failure, when a query was asked.
6718
+ const qFailure = qa ? (qa.draw ? qa.draw.failure && [qa.draw.failure.message, qa.draw.failure.hint].filter(Boolean).join(". ") : qa.error || "the search failed") : null;
6719
+ cap.textContent = shotCaption({
6720
+ query: params.get("q") || (params.get("countBy") ? "the whole graph" : null),
6721
+ counts: qa && qa.draw && qa.draw.counts ? countsLine(qa.draw.counts) : null,
6722
+ label: lit.label,
6723
+ provenance: (qa && qa.draw && qa.draw.provenance) || shotProvenance({ env: view.env, snapshot: params.get("snapshot") }),
6724
+ failure: state === "failed" ? (err ? (err.textContent || "the graph failed to draw").split("\n")[0] : qFailure || "the graph failed to draw") : null,
6725
+ state,
6726
+ plan: !!view.plan,
6727
+ });
6728
+ return state;
6729
+ }
6730
+ if (shotFrameOn) setInterval(shotFrameTick, 250);
6731
+
6302
6732
  window.addEventListener("message", (e) => {
6303
6733
  if (!embedOpts.bare) return;
6304
6734
  const shot = shotFromMessage(e, embedOpts.host);
@@ -6800,6 +7230,70 @@ function renderFlagsTab() {
6800
7230
  }
6801
7231
  initFlags();
6802
7232
 
7233
+ // behold#931: the Repos tab of an org-level workspace. One entry per repo
7234
+ // member: its URL and pinned revision, then the members of that repository's
7235
+ // workspace with each one's status and reason, from /api/workspace/repos (one
7236
+ // chant workspace graph). A failed fetch shows chant's reason as given.
7237
+ let orgHost = null;
7238
+ let orgRead = false;
7239
+ async function initOrgRepos() {
7240
+ if (staticMode || publicMode) return; // /api/workspace/* is refused in a public view
7241
+ const project = await apiFetch("/api/project").then((r) => r.json()).catch(() => ({}));
7242
+ if (!project.workspace || !project.workspace.org) return;
7243
+ 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.");
7244
+ if (!orgHost) return;
7245
+ orgHost.id = "tab-repos";
7246
+ const tab = document.querySelector('#panel-tabs button[data-tab="repos"]');
7247
+ if (tab) tab.addEventListener("click", () => orgRead || loadOrgRepos());
7248
+ if (orgHost.classList.contains("active")) loadOrgRepos();
7249
+ }
7250
+ async function loadOrgRepos() {
7251
+ orgRead = true;
7252
+ const reading = document.createElement("div");
7253
+ reading.className = "tg-legend";
7254
+ reading.textContent = "reading the repositories from chant (it fetches each pinned revision)";
7255
+ orgHost.replaceChildren(reading);
7256
+ const answer = await apiFetch("/api/workspace/repos")
7257
+ .then((r) => r.json())
7258
+ .catch((e) => ({ error: String(e) }));
7259
+ renderOrgRepos(answer);
7260
+ }
7261
+ function renderOrgRepos(answer) {
7262
+ orgHost.replaceChildren();
7263
+ const line = (cls, text, title, host = orgHost) => {
7264
+ const d = document.createElement("div");
7265
+ d.className = cls;
7266
+ d.textContent = text;
7267
+ if (title) d.title = title;
7268
+ host.appendChild(d);
7269
+ return d;
7270
+ };
7271
+ if (answer.error || answer.refusal) {
7272
+ const r = answer.refusal || { error: answer.error, remedy: "" };
7273
+ line("tg-refusal", [r.error, r.remedy].filter(Boolean).join(" "));
7274
+ if (answer.degraded) line("tg-legend", "Without it, " + answer.degraded + ".");
7275
+ return;
7276
+ }
7277
+ line("fl-title", answer.repos.length + " repositor" + (answer.repos.length === 1 ? "y" : "ies") + (answer.repo ? " in " + answer.repo : ""));
7278
+ for (const r of answer.repos) {
7279
+ const box = document.createElement("div");
7280
+ box.className = "fl-flag";
7281
+ line("fl-flag-title", r.name + " · " + r.url + " @ " + r.rev.slice(0, 12), r.rev, box);
7282
+ line("fl-facts", (r.workspaceName ? "workspace " + r.workspaceName + " · " : "") + (r.read ? "read as " + r.read + " · " : "") + r.status, "", box);
7283
+ if (r.reason) line("tg-refusal", r.reason.code + ": " + r.reason.message, "", box);
7284
+ for (const m of r.members) {
7285
+ line("fl-facts", m.name + " (" + m.kind + ") " + m.status + (m.reason ? " · " + m.reason.code + ": " + m.reason.message : ""), "", box);
7286
+ }
7287
+ orgHost.appendChild(box);
7288
+ }
7289
+ if (!staticMode) {
7290
+ const again = button("Read again", "", () => loadOrgRepos());
7291
+ again.title = "Fetch and read every repository's pinned revision again.";
7292
+ orgHost.appendChild(again);
7293
+ }
7294
+ }
7295
+ initOrgRepos();
7296
+
6803
7297
  // --- #684: collision marks, nodes touched by two in-flight work items --------
6804
7298
  // The Collisions tab reads /api/workspace/collisions when it is opened: the
6805
7299
  // in-flight work items chant reports (workspace status overlap, chant#4025),
@@ -7431,7 +7925,7 @@ function renderStatusbar() {
7431
7925
  // #399: which colour the graph is in is state, not a control, so it belongs
7432
7926
  // on the strip the same way the zoom and the env do. Only when it is not
7433
7927
  // drift — drift is what the strip has always implied.
7434
- if (activeColourMode() !== "drift") parts.push(`colour: ${activeColourMode()}`);
7928
+ if (activeColourMode() !== "drift") parts.push(`color: ${activeColourMode()}`);
7435
7929
  if (view.stack) parts.push(`stack: ${view.stack}`);
7436
7930
  if (axes.tier) parts.push(`tier: ${axes.tier}`);
7437
7931
  if (view.radial && !view.components && !view.logical && !view.ops) parts.push("radial");
@@ -8342,10 +8836,20 @@ function wireEdgeHighlight(svgEl, ir) {
8342
8836
  // behold#744: raised under the terragucci reads' layer, whose lines and pills stay over every edge.
8343
8837
  const raise = (g) => g.parentNode && g.parentNode.insertBefore(g, g.parentNode.querySelector(":scope > [data-tg-reads]"));
8344
8838
  wireEdgeLabelPeek(svgEl);
8345
- // Delegated: raise whichever edge the pointer is over (its hit-path catches it).
8839
+ // Delegated: light and raise whichever edge the pointer is over (its hit-path
8840
+ // catches it). Lit by a class, not `:hover`: raising re-inserts the element,
8841
+ // and a re-inserted element loses `:hover` until the pointer moves again, so
8842
+ // the line flickered rather than lit.
8346
8843
  svgEl.addEventListener("mouseover", (e) => {
8347
8844
  const g = e.target.closest && e.target.closest("g[data-edge-from]");
8348
- if (g) raise(g);
8845
+ if (!g) return;
8846
+ g.classList.add("edge-over");
8847
+ const top = g.parentNode && g.parentNode.querySelector(":scope > [data-tg-reads]");
8848
+ if (g.nextElementSibling !== top) raise(g);
8849
+ });
8850
+ svgEl.addEventListener("mouseout", (e) => {
8851
+ const g = e.target.closest && e.target.closest("g[data-edge-from]");
8852
+ if (g && !(e.relatedTarget && g.contains(e.relatedTarget))) g.classList.remove("edge-over");
8349
8853
  });
8350
8854
  // Hovering a node lights (and raises) every edge on it.
8351
8855
  for (const card of svgEl.querySelectorAll("[data-node-id]")) {
@@ -9113,6 +9617,8 @@ function setupGraphViewBox(svg) {
9113
9617
  applyVB();
9114
9618
  // behold#571: in the kiosk's Watch mode a re-render keeps the shot the kiosk asked for.
9115
9619
  if (kioskShot) queueMicrotask(() => applyKioskShot(false));
9620
+ // behold#915: a re-render keeps the shot's lights and framing.
9621
+ if (shotFrameDone) queueMicrotask(() => shotFrameApply());
9116
9622
  } else {
9117
9623
  vbInit = vb = null;
9118
9624
  }
@@ -9245,9 +9751,16 @@ function watchPaneForFit(host) {
9245
9751
  // every pan and zoom; only the type gets bigger.
9246
9752
  //
9247
9753
  // The floor yields to the box: a label may not grow past a fraction of the
9248
- // box's height, nor past its width. A sub-box too small to hold readable type
9249
- // at this zoom says so by staying small, rather than by writing across its
9250
- // neighbours.
9754
+ // box's height, nor past its width. A sub-box too small to hold readable type at this zoom says
9755
+ // so by staying small, rather than by writing across its neighbours. A title
9756
+ // pinhole's own size can't fit across its box shrinks to fit.
9757
+ //
9758
+ // pinhole's baseline is set for its own size, so a title grown in place would
9759
+ // rise out through the box's top edge. As it grows its baseline steps down
9760
+ // by the same amount, keeping its top inside the box.
9761
+ const BOX_LABEL_PAD = 6; // units between a box's top edge and the top of its grown title
9762
+ const BOX_LABEL_ASCENT = 0.95; // the font's ascent above the baseline, as a fraction of the size
9763
+ const BOX_LABEL_MIN = 7; // the smallest a title shrinks to fit across its box
9251
9764
  const BOX_LABEL_GUTTER = 34; // units below a box's top edge that the title row occupies
9252
9765
  const BOX_LABEL_MAX_H = 8; // a label may be at most box height / this
9253
9766
  const BOX_LABEL_EM = 0.62; // rough advance width per char, as a fraction of the size
@@ -9290,7 +9803,7 @@ function boxLabelsOf(svg) {
9290
9803
  const box = boxes.find((b) => y > b.y && y <= b.y + BOX_LABEL_GUTTER && x >= b.x - 2 && x <= b.x + b.w + 2);
9291
9804
  if (!box) continue;
9292
9805
  t.dataset.pinFont = String(base);
9293
- labels.push({ el: t, box, base });
9806
+ labels.push({ el: t, box, base, y, shift: 0 });
9294
9807
  }
9295
9808
  }
9296
9809
  boxLabelCache = { svg, labels };
@@ -9313,9 +9826,18 @@ function scaleBoxLabels() {
9313
9826
  boxLabelScale = scale;
9314
9827
  for (const l of labels) {
9315
9828
  const chars = Math.max(4, (l.el.textContent || "").length);
9316
- const cap = Math.max(l.base, Math.min(l.box.h / BOX_LABEL_MAX_H, l.box.w / (chars * BOX_LABEL_EM)));
9317
- const size = Math.max(l.base, Math.min(l.base / scale, cap));
9318
- l.el.setAttribute("font-size", String(Math.round(size * 10) / 10));
9829
+ const across = (l.box.w - 2 * BOX_LABEL_PAD) / (chars * BOX_LABEL_EM);
9830
+ const floor = Math.max(BOX_LABEL_MIN, Math.min(l.base, across));
9831
+ const cap = Math.max(floor, Math.min(l.box.h / BOX_LABEL_MAX_H, across));
9832
+ const size = Math.round(Math.max(floor, Math.min(l.base / scale, cap)) * 10) / 10;
9833
+ l.el.setAttribute("font-size", String(size));
9834
+ // Step the baseline down as far as the title grew; read y live, since a placement move shifts it.
9835
+ const shift = Math.max(0, l.box.y + BOX_LABEL_PAD + size * BOX_LABEL_ASCENT - l.y);
9836
+ if (shift !== l.shift) {
9837
+ const y = parseFloat(l.el.getAttribute("y"));
9838
+ if (Number.isFinite(y)) l.el.setAttribute("y", String(Math.round((y - l.shift + shift) * 10) / 10));
9839
+ l.shift = shift;
9840
+ }
9319
9841
  }
9320
9842
  declutterBoxHeads(labels);
9321
9843
  }
@@ -9589,11 +10111,11 @@ function ensureZoomControls(host) {
9589
10111
  // the end of every render(), so the graph underneath stays chant's and a
9590
10112
  // delta for a node that left the estate is simply not applied.
9591
10113
  //
9592
- // Two tiers now (#228's second half): localStorage, and the project's own
9593
- // `.behold/layout.json` behind GET/POST /api/layout. On load the server's map
10114
+ // Two tiers now (#228's second half): localStorage, and the server's per-user
10115
+ // layout cache (outside the project, #469) behind GET/POST /api/layout. On load the server's map
9594
10116
  // merges UNDER the local one (`mergeLayouts` — the drag you can see always
9595
10117
  // wins); on a finished gesture the current lens is POSTed, debounced. A server
9596
- // that refuses — a static export, preview mode, a read-only project, an older
10118
+ // that refuses — a static export, preview mode, an unwritable cache, an older
9597
10119
  // behold with no such route — leaves the localStorage tier working exactly as
9598
10120
  // it did before, and says nothing.
9599
10121
  //
@@ -9947,6 +10469,7 @@ function applyLayout() {
9947
10469
  indexLayout(svgEl);
9948
10470
  reloadLayoutDeltas();
9949
10471
  ensureLayoutReset(host);
10472
+ ensureViewToggles(host);
9950
10473
  ensureLayoutDrag(host);
9951
10474
  const lens = currentLensKey();
9952
10475
  if (currentLayoutKey() && layoutServer.lens !== lens) pullServerLayout(lens);
@@ -10090,17 +10613,17 @@ function ensureLayoutDrag(host) {
10090
10613
  });
10091
10614
  }
10092
10615
 
10093
- /** The "↺ layout" control beside ⤢ fit — shown only while something is hand-placed. */
10616
+ /** The "↺ placement" control beside ⤢ fit — shown only while something is hand-placed. */
10094
10617
  function ensureLayoutReset(host) {
10095
10618
  if (!host) return;
10096
10619
  let btn = document.getElementById("layout-reset");
10097
10620
  if (!btn || btn.parentElement !== host) {
10098
10621
  btn = document.createElement("button");
10099
10622
  btn.id = "layout-reset";
10100
- btn.textContent = "↺ layout";
10623
+ btn.textContent = "↺ placement";
10101
10624
  btn.title =
10102
- "Drop the hand-placed layout for this project + this lens and go back to dagre's. " +
10103
- "(A resized box never reflows what's inside it — only the next layout does that.)";
10625
+ "Put every card and box you moved on this lens back where behold placed them. " +
10626
+ "(A resized box never reflows what's inside it; only the next layout does that.)";
10104
10627
  btn.addEventListener("click", (e) => {
10105
10628
  e.stopPropagation();
10106
10629
  const key = currentLayoutKey();
@@ -10113,7 +10636,7 @@ function ensureLayoutReset(host) {
10113
10636
  layoutDeltas = {};
10114
10637
  renderLayout();
10115
10638
  ensureLayoutReset(host);
10116
- nowline("↺ layout reset — back to dagre's placement");
10639
+ nowline("↺ placement reset: every card is back where behold placed it");
10117
10640
  });
10118
10641
  host.appendChild(btn);
10119
10642
  }
@@ -10270,10 +10793,15 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
10270
10793
  if (view.runtime) q.set("runtime", "1");
10271
10794
  // #404: the attribute-drift read, when this load is the one the person
10272
10795
  // asked for it on. Consumed here — the next load goes without it.
10273
- if (planDriftOnce) {
10274
- q.set("plan", "1");
10796
+ if (planDriftOnce || view.plan) {
10797
+ q.set("plan", "1"); // behold#922: a view with plan=1 reads the plan on every load
10275
10798
  planDriftOnce = false;
10276
10799
  }
10800
+ } else if ((terraformPlanOnce || view.plan) && !view.components) {
10801
+ // #910: the plan on the stock Terraform roots, read through chant onto
10802
+ // the source graph's cards. One-shot, like #404's above.
10803
+ q.set("plan", "1");
10804
+ terraformPlanOnce = false;
10277
10805
  }
10278
10806
  // Radial layout (entity view only) — curl the wide DAG onto concentric rings.
10279
10807
  if (view.radial && !view.components && !view.logical && !view.ops) q.set("radial", "1");
@@ -10282,8 +10810,8 @@ async function loadOnce(opts = {}, isCurrent = () => true) {
10282
10810
  // and the ops view have no member boxes to shut — and it rides both the
10283
10811
  // source graph and the overlay, so picking an env doesn't undo it.
10284
10812
  if (view.collapse && !view.components && !view.ops) q.set("collapse", "1");
10285
- // #877: stack alike cards, the same estate-box lens on both routes.
10286
- if (view.alike && !view.components && !view.logical && !view.ops) q.set("alike", "1");
10813
+ // #877: an estate stacks alike cards by default; `alike=0` draws every card.
10814
+ if (!view.alike && !view.components && !view.logical && !view.ops) q.set("alike", "0");
10287
10815
  // The CI + resources facets are component-DAG-mode-only details. Load
10288
10816
  // both whenever components mode is on, env picked or not — #59 unifies
10289
10817
  // the CI facet (#58), the live-status join (#57), and resources (#59) so
@@ -10386,6 +10914,14 @@ function replayMemberFrames(load) {
10386
10914
  * of `GET /api/overlay`, which is where the drift read lives — so this row
10387
10915
  * goes through `load()`, the path that actually renders those cards.
10388
10916
  */
10917
+ async function readTerraformPlan() {
10918
+ terraformPlanOnce = true;
10919
+ nowline("↻ reading the plan on the Terraform roots…");
10920
+ await load();
10921
+ const note = lastMeta && lastMeta.note ? String(lastMeta.note).split(" · ").find((p) => p.startsWith("plan: ")) : null;
10922
+ nowline(note ? `↻ ${note}` : "↻ the plan could not be read");
10923
+ }
10924
+
10389
10925
  async function refreshWithPlan() {
10390
10926
  planDriftOnce = true;
10391
10927
  bulkDiffCache = null; // the pane's rows come from /api/diff — re-fetch them against the new plan
@@ -10467,7 +11003,8 @@ async function initPickers() {
10467
11003
  runtimeCapable = !!info.runtimeCapable;
10468
11004
  stacksCapable = !!info.stacksCapable;
10469
11005
  terragucciComponentsRepo = !!info.terragucciComponents;
10470
- const boot = bootZoom(info.memberKinds, terragucciComponentsRepo);
11006
+ componentsDeclared = info.componentsDeclared;
11007
+ const boot = bootZoom(info.memberKinds, terragucciComponentsRepo, componentsDeclared);
10471
11008
  if (boot !== "components") {
10472
11009
  applyZoom(boot);
10473
11010
  autoZoomFallback = false;
@@ -10527,7 +11064,11 @@ events.addEventListener("member", (e) => {
10527
11064
  renderStatusbar();
10528
11065
  });
10529
11066
 
11067
+ // #914: an agent's POST /api/view.
11068
+ events.addEventListener("view", (e) => agentMove(e.data));
11069
+
10530
11070
  events.addEventListener("changed", () => {
11071
+ queryAnswer = null; // #913: the source or the estate moved: the next paint asks again
10531
11072
  bulkDiffCache = null; // an op ran → per-node live state may have changed
10532
11073
  whyAnswers.clear(); // #471: a why read before the change may no longer hold
10533
11074
  load();
@@ -11487,6 +12028,10 @@ function paletteCommands() {
11487
12028
  : ["Re-check live with plan (attribute drift) — pick an environment first", () => showToast("attribute drift is read from a plan, which needs an environment to plan against", false)],
11488
12029
  );
11489
12030
  }
12031
+ // #910: a stock Terraform root's plan, through chant, onto its cards.
12032
+ if (!staticMode && !publicMode && !view.env && projectInfo && (projectInfo.memberKinds || []).includes("terraform")) {
12033
+ c.push(["Read the plan on the Terraform roots (replaces, forcing attributes, unknowns, drift)", () => readTerraformPlan()]);
12034
+ }
11490
12035
  c.push(["Fit graph to view", () => fitGraph()]);
11491
12036
  c.push(["Export: current graph as SVG", () => exportSvg()]);
11492
12037
  const inspectCollapsed = document.getElementById("app").classList.contains("inspect-collapsed");
@@ -11525,7 +12070,7 @@ function paletteCommands() {
11525
12070
  const gate = mode === "drift" ? { available: true, reason: "" } : modeAvailability(lastMeta, mode);
11526
12071
  const why = gate.available ? "" : ` — ${gate.reason}`;
11527
12072
  c.push([
11528
- `colour by: ${mode}${mode === activeColourMode() ? " ✓" : ""}${why}`,
12073
+ `color by: ${mode}${mode === activeColourMode() ? " ✓" : ""}${why}`,
11529
12074
  () => {
11530
12075
  if (!gate.available) return showToast(gate.reason, false);
11531
12076
  setColourMode(mode);
@@ -11550,9 +12095,7 @@ function paletteCommands() {
11550
12095
  if (!staticMode && !view.components && !view.ops) {
11551
12096
  c.push([view.collapse ? "Expand all" : "Collapse large boxes", () => { view.collapse = !view.collapse; load(); }]);
11552
12097
  }
11553
- if (!view.components && !view.logical && !view.ops && lastMeta && lastMeta.estate > 1) {
11554
- c.push([view.alike ? "Unstack alike cards" : "Stack alike cards", () => { view.alike = !view.alike; load(); }]);
11555
- }
12098
+ if (isEstate()) c.push([view.alike && alikeZoom() ? "Unstack alike cards" : "Stack alike cards", toggleAlike]);
11556
12099
 
11557
12100
  // Env/stack/tier/target selection — replaces the old header pickers.
11558
12101
  if (view.member) c.push([`member: whole estate (leave ${view.member})`, () => { view.member = null; selectedNodeId = null; renderStatusbar(); fitGraph(); }]);