@intentius/behold 0.29.37 → 0.29.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -472,7 +472,8 @@ preview-locked, and one load runs at a time (409 otherwise).
472
472
  `?ops=1` is the ops lens: the project's declared Ops as a phase track, read
473
473
  from each emitted `dist/ops/<name>/op.json`, with the current run painted
474
474
  over it (`meta.run`, `meta.gate`); `/api/ops/<name>/status` reads that Op's
475
- durable run status and pending gate (`chant run status --temporal`). A
475
+ newest run status and pending gate (`chant run status <name>`; chant
476
+ removed `--temporal`, #459). A
476
477
  `ConvergeOp` also gets one card per rule from its `convergeTick` step's
477
478
  `args.rules` (`attrs._step: "rule"`), carrying `when` (chant's JSON predicate,
478
479
  rendered as the condition it states), `then`, and the `why` chant requires of
@@ -901,8 +902,11 @@ field and every one of these paths is a no-op.
901
902
 
902
903
  Two gate cards exist and they are **different acts**:
903
904
 
904
- - The **run gate** — `POST /api/ops/:name/signal/:gate` → `chant run signal`.
905
- Releases the waiting Temporal workflow.
905
+ - The **run gate** — `POST /api/ops/:name/signal/:gate` → `chant run approve
906
+ <op> <gate>` (chant#2121 renamed `chant run signal`, #459). Records the
907
+ resolution; a runtime that parks a run is woken, and the local one reads it
908
+ when the Op runs again (behold runs `chant run <op> --progress-json`, which
909
+ exits 3 at a gate and shows as `gated`).
906
910
  - The **converge gate** — `POST /api/operator/approve/:op/:gate` →
907
911
  `chant approve <op> <gate>`. **Records a fact and unblocks nothing.** chant's
908
912
  gate ledger says it outright: the local executor still refuses a gated op,
package/dist/cli.js CHANGED
@@ -3483,8 +3483,7 @@ async function detectProject(projectDir) {
3483
3483
  const path = chantConfigPath(projectDir);
3484
3484
  if (!path) return { environments: [], lexicons: [] };
3485
3485
  try {
3486
- const mod = await import(pathToFileURL(path).href);
3487
- const cfg = mod.default ?? mod.config ?? mod;
3486
+ const cfg = path.endsWith(".json") ? JSON.parse(readFileSync6(path, "utf8")) : ((m) => m.default ?? m.config ?? m)(await import(pathToFileURL(path).href));
3488
3487
  const info = readInfo(cfg);
3489
3488
  if (info.environments.length || info.lexicons.length || info.sourceDir || info.stacks?.length) return info;
3490
3489
  } catch {
@@ -3601,7 +3600,7 @@ var init_project = __esm({
3601
3600
  "src/project.ts"() {
3602
3601
  "use strict";
3603
3602
  init_member_kind();
3604
- CONFIG_NAMES = ["chant.config.ts", "chant.config.mts", "chant.config.js", "chant.config.mjs"];
3603
+ CONFIG_NAMES = ["chant.config.ts", "chant.config.mts", "chant.config.js", "chant.config.mjs", "chant.config.json"];
3605
3604
  BEHOLD_CONFIG_NAME = ".behold.json";
3606
3605
  EXECUTOR_FORGES = ["github", "gitlab", "forgejo"];
3607
3606
  executorByDir = /* @__PURE__ */ new Map();
@@ -15264,7 +15263,7 @@ function repoTools(dir, config, has = {}) {
15264
15263
  }
15265
15264
  function sqlYodelerProjectIn(dir) {
15266
15265
  if (existsSync11(join17(dir, "yodel.config.ts")) || existsSync11(join17(dir, "yodel-waves.json"))) return true;
15267
- return existsSync11(join17(dir, "migrations")) && (existsSync11(join17(dir, "chant.config.ts")) || sqlYodelerRepo(dir));
15266
+ return existsSync11(join17(dir, "migrations")) && (existsSync11(join17(dir, "chant.config.ts")) || existsSync11(join17(dir, "chant.config.json")) || sqlYodelerRepo(dir));
15268
15267
  }
15269
15268
  var SKIP_DIRS4 = /* @__PURE__ */ new Set(["node_modules", ".terraform", ".terragrunt-cache", ".git"]);
15270
15269
  function rootTools(repo, rootDir) {
@@ -20980,6 +20979,9 @@ async function runCarveBridge(demo, select) {
20980
20979
  };
20981
20980
  }
20982
20981
 
20982
+ // src/server.ts
20983
+ init_ansi();
20984
+
20983
20985
  // src/ops.ts
20984
20986
  import { readdirSync as readdirSync14, readFileSync as readFileSync23, existsSync as existsSync21 } from "node:fs";
20985
20987
  import { join as join31 } from "node:path";
@@ -21105,64 +21107,57 @@ function statusFields(stdout) {
21105
21107
  return out;
21106
21108
  }
21107
21109
  function parseGateLine(line) {
21108
- const m = /^(.*?)(?: — (.*?))? \(waiting since (.+)\)$/.exec(line.trim());
21110
+ const m = /^(.*?)(?: — (.*?))? \((?:pending|waiting) since (.+)\)$/.exec(line.trim());
21109
21111
  if (!m) return null;
21110
21112
  const signalName = m[1].trim();
21111
21113
  if (!signalName) return null;
21112
21114
  return { signalName, ...m[2] ? { description: m[2].trim() } : {}, since: m[3].trim() };
21113
21115
  }
21114
21116
  function readRunStatus(op, run3) {
21117
+ const err = strip2(run3.stderr).trim();
21118
+ const firstLine3 = (m) => m.split("\n")[0].replace(/^error:\s*/, "");
21115
21119
  if (run3.code !== 0) {
21116
- const message2 = strip2(run3.stderr).trim() || strip2(run3.stdout).trim() || `chant run status exited ${run3.code}`;
21117
- if (/not available in local mode|@temporalio\/client is not installed/.test(message2)) {
21118
- return {
21119
- ok: false,
21120
- refusal: {
21121
- error: `No Temporal run state for "${op}" \u2014 ${message2.split("\n")[0].replace(/^error:\s*/, "")}`,
21122
- code: "no-temporal",
21123
- remedy: "Gate state and per-step run records come from a durable run. Configure a Temporal profile in chant.config.ts (and `npm install @temporalio/client`), then run the Op with --temporal."
21124
- }
21125
- };
21126
- }
21127
- if (/not found|NotFound/.test(message2)) {
21128
- return {
21129
- ok: false,
21130
- refusal: {
21131
- error: `No run of "${op}" to report \u2014 ${message2.split("\n")[0].replace(/^error:\s*/, "")}`,
21132
- code: "no-run",
21133
- remedy: "Start the Op (Run) and the playhead fills in as each step settles."
21134
- }
21135
- };
21136
- }
21120
+ const message2 = err || strip2(run3.stdout).trim() || `chant run status exited ${run3.code}`;
21137
21121
  return {
21138
21122
  ok: false,
21139
21123
  refusal: {
21140
- error: `chant run status ${op} failed: ${message2.split("\n")[0].replace(/^error:\s*/, "")}`,
21124
+ error: `chant run status ${op} failed: ${firstLine3(message2)}`,
21141
21125
  code: "run-status",
21142
- remedy: "Run `chant run status " + op + " --temporal` in the project to see the whole error."
21126
+ remedy: "Run `chant run status " + op + "` in the project to see the whole error."
21143
21127
  }
21144
21128
  };
21145
21129
  }
21146
21130
  const f = statusFields(run3.stdout);
21147
- const activities = /^(\d+)\/(\d+)/.exec(f.get("Activities") ?? "");
21131
+ if (!f.has("State")) {
21132
+ return {
21133
+ ok: false,
21134
+ refusal: {
21135
+ error: `No run of "${op}" to report \u2014 ${firstLine3(err) || "chant printed no run status"}`,
21136
+ code: "no-run",
21137
+ remedy: "Start the Op (Run) and the playhead fills in when it settles."
21138
+ }
21139
+ };
21140
+ }
21141
+ const steps = /^(\d+)\/(\d+)/.exec(f.get("Steps") ?? "");
21148
21142
  const gateLine = f.get("Gate");
21149
21143
  return {
21150
21144
  ok: true,
21151
21145
  read: {
21152
21146
  op,
21153
- ...f.get("Workflow ID") ? { workflowId: f.get("Workflow ID") } : {},
21147
+ ...f.get("Runtime") ? { runtime: f.get("Runtime") } : {},
21154
21148
  ...f.get("Run ID") ? { runId: f.get("Run ID") } : {},
21155
- ...f.get("Status") ? { status: f.get("Status") } : {},
21149
+ ...f.get("State") ? { status: f.get("State") } : {},
21156
21150
  ...f.get("Started") ? { startedAt: f.get("Started") } : {},
21157
- ...f.get("Closed") ? { closedAt: f.get("Closed") } : {},
21158
- ...activities ? { activities: { completed: Number(activities[1]), scheduled: Number(activities[2]) } } : {},
21159
- // No Gate line means chant printed none, which it does both when the
21160
- // query says "nothing pending" and when the Op registers no handler.
21161
- // Either way: no gate is waiting on a human right now.
21151
+ ...f.get("Ended") ? { endedAt: f.get("Ended") } : {},
21152
+ ...steps ? { steps: { settled: Number(steps[1]), total: Number(steps[2]) } } : {},
21153
+ ...f.get("Error") ? { error: f.get("Error") } : {},
21154
+ // chant prints a Gate line only for a gated run; no line means no gate is
21155
+ // waiting on a human right now.
21162
21156
  gate: gateLine ? parseGateLine(gateLine) : null
21163
21157
  }
21164
21158
  };
21165
21159
  }
21160
+ var GATED_EXIT_CODE = 3;
21166
21161
  var initialRunState = {
21167
21162
  op: null,
21168
21163
  mode: null,
@@ -21186,6 +21181,9 @@ function runGate(state, result) {
21186
21181
  function runEnded(state, exitCode, at2) {
21187
21182
  if (state.status !== "running") return state;
21188
21183
  if (exitCode === 0) return { ...state, status: "ok", endedAt: at2 };
21184
+ if (exitCode === GATED_EXIT_CODE && !state.records.some((r) => r.status === "fail")) {
21185
+ return { ...state, status: "gated", endedAt: at2 };
21186
+ }
21189
21187
  if (state.records.some((r) => r.status === "fail")) return { ...state, status: "failed", endedAt: at2 };
21190
21188
  return {
21191
21189
  ...state,
@@ -21205,6 +21203,8 @@ function slotsFor(placed) {
21205
21203
  if (nested.kind === "activity") out.push({ id: p.id, phase: p.phase, fn: nested.fn });
21206
21204
  }
21207
21205
  out.push({ id: p.id, phase: p.phase, fn: RECEIPT_WRITE_FN });
21206
+ } else if (p.step.kind === "gate") {
21207
+ out.push({ id: p.id, phase: p.phase, fn: `gate:${p.step.signalName}` });
21208
21208
  }
21209
21209
  }
21210
21210
  return out;
@@ -21324,17 +21324,16 @@ function playheadNote(state, join57) {
21324
21324
  }
21325
21325
  const settled = join57 ? join57.byNode.size : state.records.length;
21326
21326
  const bits = [];
21327
- const head = state.status === "idle" ? `Run state for ${state.op}: no per-step records \u2014 this behold session didn't start the run, so only the gate query answers` : `Run: ${state.op} (${state.mode === "temporal" ? "durable" : "local executor"}) \u2014 ${settled} step${settled === 1 ? "" : "s"} settled`;
21327
+ const head = state.status === "idle" ? `Run state for ${state.op}: no per-step records \u2014 this behold session didn't start the run, so only the gate query answers` : `Run: ${state.op} (local executor) \u2014 ${settled} step${settled === 1 ? "" : "s"} settled`;
21328
21328
  if (state.status === "running") {
21329
- bits.push(
21330
- state.mode === "local" ? "still running; the local executor reports every step at once when it ends, so the track fills in on completion" : "still running; only settled steps are painted"
21331
- );
21329
+ bits.push("still running; only settled steps are painted");
21332
21330
  }
21333
21331
  if (state.status === "ok") bits.push("the run exited cleanly");
21334
21332
  if (state.status === "failed") bits.push("a step failed");
21333
+ if (state.status === "gated") bits.push("the run stopped at a gate; nothing after it ran");
21335
21334
  if (state.status === "lost") bits.push(`stream lost \u2014 ${state.lost ?? "the progress stream ended without a verdict"}`);
21336
21335
  if (state.gate) {
21337
- bits.push(`waiting on gate ${state.gate.signalName} since ${state.gate.since} \u2014 approve is a delegated signal, behold never signals on its own`);
21336
+ bits.push(`waiting on gate ${state.gate.signalName} since ${state.gate.since} \u2014 approve records the resolution (chant run approve) and the Op runs again; behold never approves on its own`);
21338
21337
  } else if (state.gateNote) {
21339
21338
  bits.push(`gate state unavailable \u2014 ${state.gateNote}`);
21340
21339
  }
@@ -21765,7 +21764,7 @@ var OpRunner = class {
21765
21764
  */
21766
21765
  noteGate(op, result) {
21767
21766
  if (this.lastRunState.op !== null && this.lastRunState.op !== op) return this.lastRunState;
21768
- const base = this.lastRunState.op === op ? this.lastRunState : { ...initialRunState, op, mode: "temporal" };
21767
+ const base = this.lastRunState.op === op ? this.lastRunState : { ...initialRunState, op, mode: "local" };
21769
21768
  const next = runGate(base, result);
21770
21769
  const changed = JSON.stringify(next) !== JSON.stringify(this.lastRunState);
21771
21770
  this.lastRunState = next;
@@ -21777,23 +21776,21 @@ var OpRunner = class {
21777
21776
  * sync path). `cwd` is the Op's own project dir (#31 multi-estate); defaults to
21778
21777
  * the primary. Returns true if it started, false if busy.
21779
21778
  *
21780
- * `temporal` — pass `--temporal` so the run gets the durable runtime. Callers
21781
- * set it from the Op's declared gate: chant refuses a gated Op outright in
21782
- * local mode ("gates and schedules need a durable runtime"), so without the
21783
- * flag a gated Op could never run from behold at all.
21779
+ * Every run is `chant run <name> --progress-json` on the project's resolved
21780
+ * runtime. chant removed `--temporal` with the temporal lexicon (chant#2131),
21781
+ * and a gated Op now runs locally too: it stops at its gate and exits 3,
21782
+ * which `runEnded` reads as `gated` (#459).
21784
21783
  *
21785
- * Either way the run is asked for structured per-step records (#284 item 2,
21786
- * chant#1676) — `--progress-json` streams one NDJSON `StepRecord` per settled
21787
- * step on the durable path; `--json` prints the whole `OpRunResult` at the end
21788
- * on the local one. Same record shape, which is what lets one playhead render
21789
- * both. `--json` replaces chant's own human per-step summary on the local
21790
- * path, so each parsed record is re-emitted to the `op` now-line
21791
- * ({@link recordLine}) and the operator loses no narration.
21784
+ * `--progress-json` streams one NDJSON `StepRecord` per settled step on
21785
+ * stdout (#284 item 2, chant#1676), and chant's human summary goes to
21786
+ * stderr. Not `--json`: chant's `--json` now prints the run's ledger record
21787
+ * (`phases[].steps[]`), which carries no `StepRecord`s for the playhead.
21788
+ * Each parsed record is re-emitted to the `op` now-line ({@link recordLine}).
21792
21789
  */
21793
- trigger(name, opEnv, cwd, temporal) {
21790
+ trigger(name, opEnv, cwd) {
21794
21791
  if (this.current) return false;
21795
- const mode = temporal ? "temporal" : "local";
21796
- const args = temporal ? ["run", name, "--temporal", "--progress-json"] : ["run", name, "--json"];
21792
+ const mode = "local";
21793
+ const args = ["run", name, "--progress-json"];
21797
21794
  this.lastRunState = runStarted(name, mode, (/* @__PURE__ */ new Date()).toISOString());
21798
21795
  this.emitRun();
21799
21796
  return this.start(
@@ -22126,7 +22123,13 @@ function scriptBringUp(projectDir, relPath, label) {
22126
22123
  }
22127
22124
  function projectLexicons(projectDir) {
22128
22125
  try {
22129
- const src = readFileSync25(join33(projectDir, "chant.config.ts"), "utf-8");
22126
+ const ts = join33(projectDir, "chant.config.ts");
22127
+ const json2 = join33(projectDir, "chant.config.json");
22128
+ if (!existsSync22(ts) && existsSync22(json2)) {
22129
+ const doc = JSON.parse(readFileSync25(json2, "utf-8"));
22130
+ return Array.isArray(doc.lexicons) ? doc.lexicons.filter((l) => typeof l === "string") : [];
22131
+ }
22132
+ const src = readFileSync25(ts, "utf-8");
22130
22133
  const m = src.match(/lexicons\s*:\s*\[([^\]]*)\]/);
22131
22134
  if (!m) return [];
22132
22135
  return [...m[1].matchAll(/["']([^"']+)["']/g)].map((x) => x[1]);
@@ -28784,7 +28787,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28784
28787
  }
28785
28788
  const designatedEnv = info.kind === "apply" ? executorDesignation(info.dir, info.env) : void 0;
28786
28789
  if (designatedEnv && info.env) return c.json(forgeRefusal(info.env, designatedEnv, `running ${name}`), 409);
28787
- if (!runner.trigger(name, info.env, info.dir, Boolean(info.gate))) {
28790
+ if (!runner.trigger(name, info.env, info.dir)) {
28788
28791
  return c.json({ error: `an Op is already running (${runner.running})` }, 409);
28789
28792
  }
28790
28793
  return c.json({ started: true, name });
@@ -28828,7 +28831,7 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28828
28831
  app.get("/api/ops/:name/status", async (c) => {
28829
28832
  const name = c.req.param("name");
28830
28833
  const info = estateOps().find((o) => o.name === name);
28831
- const run3 = await runChantRaw(["run", "status", name, "--temporal"], info?.dir ?? cfg.projectDir);
28834
+ const run3 = await runChantRaw(["run", "status", name], info?.dir ?? cfg.projectDir);
28832
28835
  const result = readRunStatus(name, run3);
28833
28836
  const runState = runner.noteGate(name, result);
28834
28837
  if (!result.ok) return c.json({ ...result.refusal, runState }, 422);
@@ -28931,10 +28934,11 @@ function createApp(cfg, broadcaster = new Broadcaster(), frames = new FrameBuffe
28931
28934
  if (cfg.previewMode) return c.json({ error: "approving is disabled in preview mode", code: "preview" }, 403);
28932
28935
  const { name, gate } = c.req.param();
28933
28936
  const info = estateOps().find((o) => o.name === name);
28934
- broadcaster.emit("op", `\u270E signal ${name} ${gate}`);
28935
- const { code, stderr } = await runChantRaw(["run", "signal", name, gate, "--temporal"], info?.dir ?? cfg.projectDir);
28936
- if (code !== 0) return c.json({ error: stderr.trim() || `signal exited ${code}` }, 500);
28937
- return c.json({ signalled: true });
28937
+ broadcaster.emit("op", `\u270E approve ${name} ${gate}`);
28938
+ const { code, stderr, stdout } = await runChantRaw(["run", "approve", name, gate], info?.dir ?? cfg.projectDir);
28939
+ if (code !== 0) return c.json({ error: stripAnsi(stderr).trim() || stripAnsi(stdout).trim() || `approve exited ${code}` }, 500);
28940
+ const next = stripAnsi(stderr).trim().split("\n").filter(Boolean).at(-1) ?? null;
28941
+ return c.json({ approved: true, op: name, gate, next });
28938
28942
  });
28939
28943
  app.get("/api/workspace/gates", async (c) => {
28940
28944
  const ws = servedWorkspace();
@@ -30396,7 +30400,7 @@ async function startServer(cfg) {
30396
30400
  }
30397
30401
  for (const { op, lexicons } of picks) {
30398
30402
  const scope2 = lexicons.join("+");
30399
- if (runner.trigger(op.name, op.env, op.dir, Boolean(op.gate))) {
30403
+ if (runner.trigger(op.name, op.env, op.dir)) {
30400
30404
  broadcaster.emit("op", `\u27F3 auto-sync (${autoSync})${memberTag(dir)} ${scope2} \u2192 ${op.name}`);
30401
30405
  } else {
30402
30406
  broadcaster.emit("op", `\u27F3 auto-sync (${autoSync})${memberTag(dir)} ${scope2} \u2192 ${op.name} waiting \u2014 ${runner.running} is running`);
@@ -31586,7 +31590,7 @@ function warnIfNotChantProject(dir) {
31586
31590
  return;
31587
31591
  }
31588
31592
  process.stderr.write(
31589
- `behold: warning \u2014 ${dir} has no chant.config.ts; this doesn't look like a chant project.
31593
+ `behold: warning \u2014 ${dir} has no chant.config.ts or chant.config.json; this doesn't look like a chant project.
31590
31594
  \`behold doctor ${dir}\` says what's missing. No project yet? \`behold demo\` serves a bundled working example (needs Docker).
31591
31595
  `
31592
31596
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/behold",
3
- "version": "0.29.37",
3
+ "version": "0.29.39",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
@@ -46,7 +46,7 @@
46
46
  "@intentius/chant-k8s-client": "^0.124.24",
47
47
  "@intentius/pinhole": "^0.5.0",
48
48
  "ajv": "^8.20.0",
49
- "hono": "^4.12.34"
49
+ "hono": "^4.13.13"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@intentius/chant-lexicon-terraform": "^0.124.0",
package/web/app.js CHANGED
@@ -23,7 +23,7 @@ import { renderYodelLane } from "./sql-yodeler-lane.js";
23
23
  import { initTerragucciEstate } from "./terragucci-estate.js";
24
24
  import { chantComponentMarks } from "./chant-pr-marks.js";
25
25
  import { noStateFill } from "./frame-fill.js";
26
- import { componentMarks as tgComponentMarks, runsCommit as tgRunsCommit, waveOfKey as tgWaveOfKey } from "./terragucci-components-live.js";
26
+ import { componentMarks as tgComponentMarks, runsCommit as tgRunsCommit, statusShort as tgStatusShort, waveOfKey as tgWaveOfKey } from "./terragucci-components-live.js";
27
27
  import { FORGES, MARK, componentsForge, forgeOfName, iconSvg, markLink, markTitle, waveJobUrl } from "./forge-mark.js";
28
28
  import { TOOLS, orderTools } from "./tool-mark.js";
29
29
  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 } from "./terragucci-change.js";
@@ -87,6 +87,7 @@ import {
87
87
  straightEdge,
88
88
  writeLayout,
89
89
  } from "./layout-store.js";
90
+ import { PHONE_QUERY as INSPECT_PHONE_QUERY, inspectStartsFolded } from "./inspect-pane.js";
90
91
  // #259: every JSON value this page shows goes through one renderer — pretty
91
92
  // printed, collapsible, copyable per subtree. `valueCell`/`pairCell` below are
92
93
  // the call-site shorthands: a container becomes the tree, a scalar stays text.
@@ -122,7 +123,7 @@ const embedOpts = readEmbed(location.search);
122
123
  if (embedOpts.theme && !setTheme(embedOpts.theme, { persist: false })) console.warn(`behold: no theme named ${embedOpts.theme}`);
123
124
  if (embedOpts.embed) document.documentElement.classList.add("embed");
124
125
  if (embedOpts.embed && embedOpts.bare) document.documentElement.classList.add("bare"); // #569: the graph alone, for a kiosk
125
- initPanel({ embed: embedOpts.embed });
126
+ initPanel({ embed: embedOpts.embed, phone: typeof matchMedia === "function" && matchMedia(INSPECT_PHONE_QUERY).matches });
126
127
  mountThemePicker(document.getElementById("panel-theme"));
127
128
 
128
129
  // Colour node fills by category/kind using the theme's FULL palette (spicypath-style, so the
@@ -4111,6 +4112,9 @@ function drawTgComponentMarks(svg, { drawnAnswer, focus, boxOf, make, edgePoints
4111
4112
  const cy = (tb.y + tb.y2) / 2;
4112
4113
  // Right after the title, as "apply-wave-2 · held at the gate"; else alone at the right of the title's line.
4113
4114
  const spots = [{ words: `· ${w.status.words}`, at: () => tb.x2 + 6 }, { words: w.status.words, at: (wd) => b.x2 - 16 - wd }];
4115
+ // behold#693: a narrow box whose full words would cross an edge says the short form.
4116
+ const short = tgStatusShort(w.status);
4117
+ if (short && short !== w.status.words) spots.push({ words: `· ${short}`, at: () => tb.x2 + 6 }, { words: short, at: (wd) => b.x2 - 16 - wd });
4114
4118
  for (const { words, at } of spots) {
4115
4119
  const wd = width(words, size, 700);
4116
4120
  const x = at(wd);
@@ -8008,13 +8012,9 @@ loadSubstrates();
8008
8012
  // Poll readiness so pills update as things come up on their own (Docker
8009
8013
  // starting, a bring-up provisioning) without needing a `changed` event.
8010
8014
  setInterval(loadSubstrates, 5000);
8011
- // #284 item 2: while a DURABLE run is in flight, a gate can open at any moment
8012
- // — and the record stream falls silent exactly when it does, so a stalled
8013
- // playhead is not evidence of anything. Ask. Only while a run is actually
8014
- // running, so an idle behold shells nothing.
8015
- setInterval(() => {
8016
- if (runState && runState.status === "running" && runState.mode === "temporal") pollRunStatus();
8017
- }, 5000);
8015
+ // #284 item 2, #459: every run is local now, and a gated one exits at its gate
8016
+ // (status `gated`), so there is nothing to poll while one runs. The `run`
8017
+ // event below asks for the gate once the run stops there.
8018
8018
  // #234 join 3: the operating loop ticks on its own schedule (chant's operator
8019
8019
  // defaults to a 60s round, a CronJob to whatever it declares), so the strip goes
8020
8020
  // stale without anyone clicking. Same discipline as the gate tick above rather
@@ -8145,11 +8145,15 @@ events.addEventListener("apply", (e) => {
8145
8145
  // re-pull the graph only when the ops lens is what's on screen, since that's
8146
8146
  // the view the run state paints over.
8147
8147
  events.addEventListener("run", (e) => {
8148
+ let wasGated = false;
8148
8149
  try {
8150
+ wasGated = !!runState && runState.status === "gated";
8149
8151
  runState = JSON.parse(e.data);
8150
8152
  } catch {
8151
8153
  return;
8152
8154
  }
8155
+ // #459: a run that just stopped at its gate: ask which gate, once.
8156
+ if (runState && runState.status === "gated" && !runState.gate && !wasGated) pollRunStatus();
8153
8157
  renderDial();
8154
8158
  if (view.ops) load({ quiet: true });
8155
8159
  });
@@ -8190,9 +8194,8 @@ function pollRunStatus() {
8190
8194
  if (staticMode || publicMode || runStatusInFlight) return; // #569: a public serve refuses the op tools
8191
8195
  const name = runStatusTarget();
8192
8196
  if (!name) return;
8193
- // Only a durable run has gate state at all. A local run's playhead is
8194
- // complete without it, so don't shell chant to be told so.
8195
- if (runState && runState.mode === "local") return;
8197
+ // A run still in flight has no settled status to read yet (#459).
8198
+ if (runState && runState.status === "running") return;
8196
8199
  runStatusInFlight = true;
8197
8200
  apiFetch(`/api/ops/${encodeURIComponent(name)}/status`)
8198
8201
  .then((r) => r.json())
@@ -8326,7 +8329,9 @@ function signal(name, gate) {
8326
8329
  showToast(`✗ approve ${gate}: ${j.error}`, false);
8327
8330
  nowline("✗ " + j.error);
8328
8331
  } else {
8329
- showToast(`✓ approved ${gate}`, true);
8332
+ // #459: the local runtime reads the approval when the Op runs again;
8333
+ // chant's own line says so, and comes back as `next`.
8334
+ showToast(`✓ approved ${gate}${j.next ? ` — ${j.next}` : ""}`, true);
8330
8335
  }
8331
8336
  // #284 item 2: re-ask gateState either way. On success the gate should be
8332
8337
  // gone (the pending card must not linger as if a human were still owed);
@@ -8541,7 +8546,7 @@ async function initActions() {
8541
8546
  bar.appendChild(deploy);
8542
8547
  if (opsApply.gate) {
8543
8548
  const approve = button(`Approve ${opsApply.gate}`, "approve", () => signal(opsApply.name, opsApply.gate));
8544
- approve.title = `chant run signal ${opsApply.name} ${opsApply.gate} — releases the Op's human gate.`;
8549
+ approve.title = `chant run approve ${opsApply.name} ${opsApply.gate} — records the gate's resolution; the Op runs on from it.`;
8545
8550
  bar.appendChild(approve);
8546
8551
  }
8547
8552
  } else if (opsInitialEnv || view.env) {
@@ -8603,7 +8608,9 @@ function initInspectPane() {
8603
8608
  } catch {
8604
8609
  /* private mode */
8605
8610
  }
8606
- if (folded === "1" || (folded === null && embedOpts.embed)) app.classList.add("inspect-collapsed");
8611
+ // behold#696: folded on a phone too, where the pane beside the graph left it a sliver.
8612
+ const phone = typeof matchMedia === "function" && matchMedia(INSPECT_PHONE_QUERY).matches;
8613
+ if (inspectStartsFolded(folded, { embed: embedOpts.embed, phone })) app.classList.add("inspect-collapsed");
8607
8614
 
8608
8615
  document.getElementById("inspect-collapse").addEventListener("click", () => setInspectCollapsed(true));
8609
8616
  document.getElementById("inspect-reopen").addEventListener("click", () => setInspectCollapsed(false));
package/web/index.html CHANGED
@@ -57,6 +57,13 @@
57
57
  height: 100%; }
58
58
  #app.inspect-collapsed { grid-template-columns: 1fr 0; }
59
59
  #app.inspect-collapsed #inspect { display: none; }
60
+ /* behold#696: on a phone the pane stacks under the graph, which keeps the full width (web/inspect-pane.js starts it folded). */
61
+ @media (max-width: 600px) {
62
+ #app, #app.inspect-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; }
63
+ #app #inspect { grid-row: 2; grid-column: 1; border-left: 0; border-top: 1px solid var(--rule); max-height: 45vh; }
64
+ #app #inspect-resize { display: none; }
65
+ #app #nowline { grid-column: 1; grid-row: 3; }
66
+ }
60
67
  #graph { grid-row: 1; grid-column: 1; overflow: auto; position: relative; }
61
68
  #inspect { grid-row: 1; grid-column: 2; border-left: 1px solid var(--rule); background: var(--panel);
62
69
  padding: 14px; overflow: auto; position: relative; }
@@ -0,0 +1,16 @@
1
+ // The inspect pane's opening state (#15, #476, behold#696), without the DOM:
2
+ // app.js reads the stored choice and the viewport and asks here.
3
+
4
+ /** A phone's width: under it the pane stacks under the graph (index.html) and starts folded. */
5
+ export const PHONE_QUERY = "(max-width: 600px)";
6
+
7
+ /**
8
+ * Whether the pane starts folded: as the viewer last left it ("1" folded,
9
+ * "0" open), else folded in a frame (#476) and on a phone, where an open
10
+ * pane beside the graph left the graph a sliver (behold#696).
11
+ */
12
+ export function inspectStartsFolded(saved, { embed = false, phone = false } = {}) {
13
+ if (saved === "1") return true;
14
+ if (saved === "0") return false;
15
+ return !!(embed || phone);
16
+ }
@@ -0,0 +1,15 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { inspectStartsFolded } from "./inspect-pane.js";
3
+
4
+ // behold#696: on a phone the inspect pane starts folded, so the graph has the width.
5
+ describe("inspectStartsFolded", () => {
6
+ it("starts folded on a phone and in a frame, open on a wide screen", () => {
7
+ expect(inspectStartsFolded(null, { phone: true })).toBe(true);
8
+ expect(inspectStartsFolded(null, { embed: true })).toBe(true);
9
+ expect(inspectStartsFolded(null, {})).toBe(false);
10
+ });
11
+ it("keeps the viewer's own choice", () => {
12
+ expect(inspectStartsFolded("0", { phone: true })).toBe(false);
13
+ expect(inspectStartsFolded("1", {})).toBe(true);
14
+ });
15
+ });
@@ -48,7 +48,7 @@ body.k-watch #eh-trail { position: fixed; z-index: 7; left: 5px; right: 5px; pad
48
48
  box-shadow: 0 6px 22px color-mix(in srgb, var(--shadow) 70%, transparent); transform-origin: 50% 100%; }
49
49
  .eh-tip.eh-tip-go { pointer-events: auto; cursor: pointer; }
50
50
  .eh-tip.eh-tip-go:hover { background: var(--active); }
51
- .eh-tip::after { content: ""; position: absolute; left: calc(50% - 6px); bottom: -7px; width: 12px; height: 12px; background: inherit; border: inherit; border-top: 0; border-left: 0; transform: rotate(45deg); }
51
+ .eh-tip::after { content: ""; position: absolute; left: calc(var(--eh-arrow, 50%) - 6px); bottom: -7px; width: 12px; height: 12px; background: inherit; border: inherit; border-top: 0; border-left: 0; transform: rotate(45deg); }
52
52
  .eh-tip.eh-below::after { bottom: auto; top: -7px; transform: rotate(-135deg); }
53
53
  .eh-tip[data-eh-tone="ok"] { --bar: var(--bar-managed, var(--managed)); }
54
54
  .eh-tip[data-eh-tone="wait"] { --bar: var(--bar-foreign, var(--foreign)); }
@@ -66,6 +66,54 @@ body.k-watch #eh-trail { position: fixed; z-index: 7; left: 5px; right: 5px; pad
66
66
  @media (max-width: 600px) { #eh-trail { padding: 0.2em 16px; } body.k-watch #eh-trail { position: static; background: transparent; border: 0; } .eh-tip { max-width: 18em; } }
67
67
  `;
68
68
 
69
+ /**
70
+ * behold#695: where a tip stands, in the window's coordinates. Above the thing
71
+ * it points at (`rect`), centred, else below it when there is no room above;
72
+ * then, when that covers one of the frame's edge labels (`labels`, in the
73
+ * window's coordinates), the same side moved along to the anchor's left or
74
+ * right edge or past the label's ends (still over the anchor), then lifted
75
+ * clear above the labels it covers, then the same below. The first spot
76
+ * clear of every label wins; with none clear, the one covering least. `arrow` is where the tip's notch sits along it, under
77
+ * the anchor's middle as far as the tip reaches.
78
+ */
79
+ export function tipSpot(rect, size, win, labels = []) {
80
+ const W = win.w || 1600;
81
+ const w = size.w || 200;
82
+ const h = size.h || 30;
83
+ const mid = rect.left + rect.width / 2;
84
+ const clampX = (x) => Math.max(8, Math.min(x, W - w - 8));
85
+ // A spot along the anchor: the tip keeps at least 24px over it, so its notch still points at it.
86
+ const reaches = (x) => Math.min(x + w, rect.left + rect.width) - Math.max(x, rect.left) >= Math.min(24, rect.width);
87
+ const hits = (p) => labels.filter((l) => p.x < l.x + l.w && p.x + w > l.x && p.y < l.y + l.h && p.y + h > l.y);
88
+ const covered = (p) => hits(p).reduce((sum, l) => sum + (Math.min(p.x + w, l.x + l.w) - Math.max(p.x, l.x)) * (Math.min(p.y + h, l.y + l.h) - Math.max(p.y, l.y)), 0);
89
+ const along = (y, below) => {
90
+ const centred = { x: clampX(mid - w / 2), y, below };
91
+ const xs = [centred.x, clampX(rect.left), clampX(rect.left + rect.width - w)];
92
+ for (const l of hits(centred)) xs.push(clampX(l.x - w - 8), clampX(l.x + l.w + 8));
93
+ return xs.filter((x, i) => xs.indexOf(x) === i && reaches(x)).map((x) => ({ x, y, below }));
94
+ };
95
+ const aboveY = rect.top - h - 12;
96
+ const spots = [];
97
+ if (aboveY >= 8) {
98
+ spots.push(...along(aboveY, false));
99
+ // Lifted: above the labels the centred spot covers.
100
+ const hit = hits(spots[0]);
101
+ if (hit.length) {
102
+ const y = Math.min(...hit.map((l) => l.y)) - h - 6;
103
+ if (y >= 8) spots.push({ x: spots[0].x, y, below: false });
104
+ }
105
+ }
106
+ spots.push(...along(rect.top + rect.height + 12, true));
107
+ let best = null;
108
+ for (const p of spots) {
109
+ const c = covered(p);
110
+ if (!best || c < best.c) best = { ...p, c };
111
+ if (c === 0) break;
112
+ }
113
+ const arrow = Math.max(12, Math.min(w - 12, mid - best.x));
114
+ return { x: Math.round(best.x), y: Math.round(best.y), below: best.below, arrow: Math.round(arrow) };
115
+ }
116
+
69
117
  /** A fact's tone, for its chip, its tip and its modal: the state colours the bars use. */
70
118
  export function toneOf(kind) {
71
119
  if (kind === "held") return "wait";
@@ -181,17 +229,15 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
181
229
  };
182
230
 
183
231
  // ---- tips ----------------------------------------------------------------
184
- const place = (node, rect) => {
185
- const W = doc.defaultView ? doc.defaultView.innerWidth : 1600;
186
- const w = node.offsetWidth || 200;
187
- const hgt = node.offsetHeight || 30;
188
- let x = rect.left + rect.width / 2 - w / 2;
189
- x = Math.max(8, Math.min(x, W - w - 8));
190
- let y = rect.top - hgt - 12;
191
- const below = y < 8;
192
- if (below) y = rect.top + rect.height + 12;
193
- node.classList.toggle("eh-below", below);
194
- const at = `translate(${Math.round(x)}px, ${Math.round(y)}px)`;
232
+ const place = (node, rect, h) => {
233
+ const win = { w: doc.defaultView ? doc.defaultView.innerWidth : 1600 };
234
+ // The frame's edge labels, in the window's coordinates (behold#695).
235
+ const F = h ? frameRect(h) : null;
236
+ const labels = F && h.boxes && Array.isArray(h.boxes.labels) ? h.boxes.labels.map((l) => ({ x: F.left + l.x, y: F.top + l.y, w: l.w, h: l.h })) : [];
237
+ const p = tipSpot(rect, { w: node.offsetWidth || 200, h: node.offsetHeight || 30 }, win, labels);
238
+ node.classList.toggle("eh-below", p.below);
239
+ node.style.setProperty("--eh-arrow", `${p.arrow}px`);
240
+ const at = `translate(${p.x}px, ${p.y}px)`;
195
241
  node.style.setProperty("--eh-at", at);
196
242
  node.style.transform = at;
197
243
  };
@@ -237,7 +283,7 @@ export function startEventHelp({ doc = document, store = null, switchHost = null
237
283
  st.nodes.set(event.id, node);
238
284
  }
239
285
  node.style.visibility = "";
240
- place(node, anchors[0].rect);
286
+ place(node, anchors[0].rect, h);
241
287
  if (isNew) {
242
288
  // The things it is about glow while it is up, and light together across the panes.
243
289
  for (const a of anchors) if (a.el) glowOn(a.el, toneOf(event.kind));
@@ -0,0 +1,42 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { tipSpot } from "./kiosk-event-help-ui.js";
3
+
4
+ // behold#695: a tip stands clear of the frame's edge labels where it can.
5
+ describe("tipSpot", () => {
6
+ const box = { left: 400, top: 300, width: 300, height: 200 }; // a wave box
7
+ const size = { w: 240, h: 30 };
8
+ const win = { w: 1440 };
9
+
10
+ it("stands above the box, centred, when nothing is in the way", () => {
11
+ expect(tipSpot(box, size, win)).toEqual({ x: 430, y: 258, below: false, arrow: 120 });
12
+ });
13
+
14
+ it("goes below when there is no room above", () => {
15
+ expect(tipSpot({ ...box, top: 20 }, size, win)).toMatchObject({ y: 232, below: true });
16
+ });
17
+
18
+ it("moves along the box's top when the centred spot covers an edge label", () => {
19
+ // A read's label over the middle of the box's top, as the demo's "edge reads app's applied state" sits.
20
+ const label = { x: 520, y: 255, w: 90, h: 24 };
21
+ const p = tipSpot(box, size, win, [label]);
22
+ expect(p.below).toBe(false);
23
+ expect(p.y).toBe(258);
24
+ const clear = p.x + size.w <= label.x || p.x >= label.x + label.w || p.y + size.h <= label.y || p.y >= label.y + label.h;
25
+ expect(clear).toBe(true);
26
+ // The notch still points at the box's middle as far as the tip reaches.
27
+ expect(p.arrow).toBe(Math.max(12, Math.min(size.w - 12, 550 - p.x)));
28
+ });
29
+
30
+ it("lifts the tip above a label that spans the box's top", () => {
31
+ const wide = { x: 380, y: 360, w: 360, h: 24 };
32
+ const p = tipSpot({ ...box, top: 400 }, size, win, [wide, { x: 380, y: 615, w: 360, h: 24 }]);
33
+ expect(p).toMatchObject({ y: 360 - 30 - 6, below: false });
34
+ });
35
+
36
+ it("takes the spot covering least when none is clear", () => {
37
+ // Above, the tip overlaps the label by 32px of its height; below, by 10px.
38
+ const labels = [{ x: 0, y: 0, w: 1440, h: 290 }, { x: 0, y: 532, w: 1440, h: 400 }];
39
+ const p = tipSpot(box, size, win, labels);
40
+ expect(p).toMatchObject({ y: 512, below: true });
41
+ });
42
+ });
package/web/kiosk.html CHANGED
@@ -178,7 +178,7 @@
178
178
  * with a fade, inside it) with a rail down its left: neutral, and the
179
179
  * step's rail in the step's state colour (theme.js barInks).
180
180
  */
181
- :root { --k-label-w: 7.6rem; --k-title-h: 3.15em; --k-beat-h: 3em; --k-step-h: 4.45em; --k-next-h: 1.35em; --k-watch-h: 3.75em; --k-shows-h: 2.5em; --k-facts-h: 3.75em; }
181
+ :root { --k-label-w: 7.6rem; --k-title-h: 3.15em; --k-beat-h: 3em; --k-step-h: 4.45em; --k-next-h: 2.15em; --k-watch-h: 3.75em; --k-shows-h: 2.5em; --k-facts-h: 3.75em; }
182
182
  .k-lead { display: grid; grid-template-rows: var(--k-title-h) var(--k-beat-h) var(--k-step-h) var(--k-next-h) var(--k-watch-h) var(--k-shows-h) var(--k-facts-h) auto; gap: 0.2em; min-width: 0;
183
183
  padding: 0.25em 0.9em 0.35em; background: var(--surface-pane-b); border-radius: 8px; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fg) 14%, transparent); }
184
184
  .k-box { min-height: 0; overflow-y: auto; scrollbar-width: thin; border-radius: 6px; padding: 0.1em 0.2em; }
@@ -224,9 +224,10 @@
224
224
  * pulses until the step changes; with no deadline a quiet shimmer runs. Under reduced motion
225
225
  * the due bar is steady and full, and there is no shimmer.
226
226
  */
227
- .k-row-next { position: relative; }
228
- .k-nbar { position: absolute; left: calc(0.75em + var(--k-label-w) + 0.8em); right: 0.2em; bottom: 0; height: 3px; border-radius: 2px; overflow: hidden; pointer-events: none;
229
- background: color-mix(in srgb, var(--rule) 55%, transparent); }
227
+ /* behold#694: the bar has its own track below the words, with room between, never an underline of them. */
228
+ .k-row-next { position: relative; padding-bottom: calc(0.45em + 4px); }
229
+ .k-nbar { position: absolute; left: calc(0.75em + var(--k-label-w) + 0.8em); right: 0.2em; bottom: 0; height: 4px; border-radius: 2px; overflow: hidden; pointer-events: none;
230
+ background: color-mix(in srgb, var(--muted) 22%, transparent); }
230
231
  .k-nbar-none { display: none; }
231
232
  .k-nbar-in { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--k-nbar-fill, 0) * 100%); border-radius: inherit; background: var(--bar, var(--bar-neutral)); }
232
233
  .k-nbar-due .k-nbar-in { width: 100%; }
@@ -361,6 +362,7 @@
361
362
  .k-row-empty { display: none; }
362
363
  .k-row-label { padding-top: 0; }
363
364
  .k-nbar { left: 0.75em; right: 0; }
365
+ .k-row-next { padding-bottom: calc(0.45em + 4px); }
364
366
  #views { flex-wrap: wrap; gap: 0.3em 0.9em; }
365
367
  .k-strip { flex-wrap: wrap; }
366
368
  .k-right > .k-cycle { padding: 0; }
@@ -431,7 +433,7 @@
431
433
  .k-cap-next { margin-left: auto; color: var(--muted); font-size: 0.92em; white-space: nowrap; flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
432
434
  .k-cap-next .k-action { font-family: var(--font-mono); color: var(--fg); }
433
435
  .k-cap-next { position: relative; padding-bottom: 6px; }
434
- .k-cap-next .k-nbar { left: 0; right: 0; bottom: 0; }
436
+ .k-cap-next .k-nbar { left: 0; right: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--rule) 55%, transparent); }
435
437
  /* behold#571: the caption's beats are the lead block's rows: the label in a fixed column, the words beside it (two lines, at most 72ch), a rail down the left; only the step's rail takes its state's colour (theme.js barInks). */
436
438
  .k-cap-row { margin: 0; display: grid; grid-template-columns: var(--k-label-w) minmax(0, 1fr); column-gap: 0.8em; align-items: start; align-self: stretch; padding-left: 0.75em; line-height: 1.25; font-size: 1em; color: color-mix(in srgb, var(--fg) 78%, var(--muted)); box-shadow: inset 3px 0 0 var(--bar, var(--bar-neutral)); }
437
439
  .k-cap-row:empty { box-shadow: none; }
package/web/panel.js CHANGED
@@ -170,7 +170,7 @@ export function isPanelCollapsed() {
170
170
  return !!state.collapsed;
171
171
  }
172
172
 
173
- export function initPanel({ embed = false } = {}) {
173
+ export function initPanel({ embed = false, phone = false } = {}) {
174
174
  panel = document.getElementById("panel");
175
175
  if (!panel) return;
176
176
  if (embed) {
@@ -178,6 +178,11 @@ export function initPanel({ embed = false } = {}) {
178
178
  state.collapsed = true;
179
179
  state.y = 12;
180
180
  }
181
+ // behold#696: on a phone it starts folded to its bar too, so the graph is what the viewer sees first.
182
+ if (phone) {
183
+ state.collapsed = true;
184
+ state.y = 12;
185
+ }
181
186
  state = loadState();
182
187
  const bar = document.getElementById("panel-tabs");
183
188
  initDrag(bar);
@@ -74,15 +74,13 @@ export function runVerdict(run) {
74
74
  }
75
75
  if (run.status === "running") {
76
76
  return {
77
- text:
78
- run.mode === "local"
79
- ? `${run.op}: running on the local executor — steps arrive together when it ends`
80
- : `${run.op}: running — ${settled}`,
77
+ text: `${run.op}: running — ${settled}`,
81
78
  tone: "running",
82
79
  };
83
80
  }
84
81
  if (run.status === "ok") return { text: `${run.op}: exited cleanly — ${settled}`, tone: "ok" };
85
82
  if (run.status === "failed") return { text: `${run.op}: a step failed — ${settled}`, tone: "failed" };
83
+ if (run.status === "gated") return { text: `${run.op}: stopped at a gate — ${settled}; approve it, then run the Op again`, tone: "running" };
86
84
  return { text: `${run.op}: stream lost — frozen at ${settled}`, tone: "lost" };
87
85
  }
88
86
 
@@ -196,7 +194,7 @@ export function renderGateCard(gate, actions = {}) {
196
194
  return box;
197
195
  }
198
196
  const approve = el("button", "approve", actions.approver ? `Approve ${gate.signalName} as ${actions.approver}` : `Approve ${gate.signalName}`);
199
- approve.title = `${gate.approve.method} ${gate.approve.path} — the same delegated signal as chant run signal ${gate.op} ${gate.signalName}. behold never approves on its own.`;
197
+ approve.title = `${gate.approve.method} ${gate.approve.path} — the same delegated write as chant run approve ${gate.op} ${gate.signalName}. behold never approves on its own.`;
200
198
  approve.addEventListener("click", () => actions.approve?.(gate.op, gate.signalName));
201
199
  box.appendChild(approve);
202
200
  return box;
@@ -63,8 +63,15 @@ describe("runVerdict", () => {
63
63
  expect(runVerdict({ ...withRecords(2), status: "failed" }).text).toContain("a step failed");
64
64
  });
65
65
 
66
- it("explains why a local run shows nothing until it ends", () => {
67
- expect(runVerdict({ ...base, mode: "local" }).text).toContain("steps arrive together when it ends");
66
+ it("counts settled steps while a local run streams them (#459: --progress-json)", () => {
67
+ expect(runVerdict({ ...withRecords(1), mode: "local" }).text).toContain("running — 1 step settled");
68
+ });
69
+
70
+ it("says a gated run stopped at its gate and runs again after approval (#459)", () => {
71
+ const v = runVerdict({ ...withRecords(1), status: "gated" });
72
+ expect(v.text).toContain("stopped at a gate");
73
+ expect(v.text).toContain("run the Op again");
74
+ expect(v.text).not.toMatch(/lost|failed/);
68
75
  });
69
76
 
70
77
  it("doesn't claim to have watched a run it didn't start", () => {
@@ -66,14 +66,20 @@ export function jobStatus(index, commit, jobName) {
66
66
  // another (a /terragucci apply re-run applies every wave in its
67
67
  // apply-comment job) is the latest run for the wave.
68
68
  let later = null;
69
+ // behold#693: and whether that run waits at its gate, which the run view
70
+ // doesn't say until the approval: the reports still hold the failure.
71
+ let held = false;
69
72
  for (const run of runs) {
70
73
  if (!sameSha(run.commit, commit)) continue;
71
74
  const job = (run.jobs || []).find((j) => j.name === jobName);
72
75
  if (!job) continue;
73
76
  if (job.status !== "skipped") {
74
- return { status: job.status, words: JOB_WORDS[job.status] || job.status, tone: JOB_TONE[job.status] || "idle", run: run.id, ...(later ? { superseded: later } : {}) };
77
+ return { status: job.status, words: JOB_WORDS[job.status] || job.status, tone: JOB_TONE[job.status] || "idle", run: run.id, ...(later ? { superseded: later } : {}), ...(later && held ? { held: true } : {}) };
78
+ }
79
+ if (!later && (run.jobs || []).some((j) => j.status !== "skipped")) {
80
+ later = run.id;
81
+ held = run.status === "waiting" || (run.jobs || []).some((j) => j.status === "waiting");
75
82
  }
76
- if (!later && (run.jobs || []).some((j) => j.status !== "skipped")) later = run.id;
77
83
  skipped = skipped || { status: "skipped", words: JOB_WORDS.skipped, tone: "idle", run: run.id };
78
84
  }
79
85
  return skipped;
@@ -85,13 +91,25 @@ export const WAVE_WORDS = { waiting: "held at the gate", applying: "running", ap
85
91
  /**
86
92
  * The status a wave's box shows: its job's, unless a later run on the commit
87
93
  * took the wave over (`superseded`); then the run view's state for the wave,
88
- * which is the latest run's.
94
+ * which is the latest run's. While that later run waits at its gate (`held`),
95
+ * a wave its job failed reads "held at the gate": the run view keeps the
96
+ * failure until the approval lets the re-run write (behold#693).
89
97
  */
90
98
  export function waveStatus(status, state) {
91
- if (!status || !status.superseded || !state || !WAVE_WORDS[state]) return status;
99
+ if (!status || !status.superseded) return status;
100
+ const undone = state !== "applied" && state !== "applying";
101
+ const failed = status.status === "failure" || status.status === "cancelled" || state === "failed" || state === "refused";
102
+ if (status.held && undone && failed) return { status: "waiting", words: WAVE_WORDS.waiting, tone: toneOf("waiting"), run: status.superseded, held: true };
103
+ if (!state || !WAVE_WORDS[state]) return status;
92
104
  return { status: state, words: WAVE_WORDS[state], tone: toneOf(state), run: status.superseded };
93
105
  }
94
106
 
107
+ /** A status's words in a narrow box, where the full words cross an edge (behold#693): "held" for a wave held at its gate. */
108
+ export function statusShort(status) {
109
+ if (!status) return null;
110
+ return status.status === "waiting" ? "held" : status.words;
111
+ }
112
+
95
113
  /** "apply-wave-2 · held at the gate", or the job alone without a status. */
96
114
  export function waveTitle(jobName, status) {
97
115
  return status ? `${jobName} · ${status.words}` : jobName;
@@ -155,7 +173,8 @@ export function componentMarks(answer, progress, facets, { runs = null, pin = nu
155
173
  number: n,
156
174
  job: jobName,
157
175
  state: w,
158
- tone: w ? toneOf(w) : status ? status.tone : "idle",
176
+ // A re-run held at its gate (behold#693) tones the box as its title says.
177
+ tone: status && status.held && status.status === "waiting" ? status.tone : w ? toneOf(w) : status ? status.tone : "idle",
159
178
  status,
160
179
  title: waveTitle(jobName, status),
161
180
  facts,
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { JOB_WORDS, componentMarks, jobStatus, runsCommit, waveOfKey, waveStatus, waveTitle } from "./terragucci-components-live.js";
2
+ import { JOB_WORDS, componentMarks, jobStatus, runsCommit, statusShort, waveOfKey, waveStatus, waveTitle } from "./terragucci-components-live.js";
3
3
 
4
4
  // #571: the live marks on a terragucci repo's components zoom. The facets are
5
5
  // the components graph's (src/__fixtures__/terragucci-components: network and
@@ -129,6 +129,14 @@ describe("the component marks (#571)", () => {
129
129
  // While the re-run waits at the gate, the box says so.
130
130
  const held = componentMarks(answer, progress("waiting"), facets, { runs: runs(comment(12, "waiting"), merge), pin: MERGE });
131
131
  expect(held.waves[2].title).toBe("apply-wave-2 · held at the gate");
132
+ // behold#693: the run view still holds the merge's failure while the re-run
133
+ // waits for its approval; the box reads the gate, not the failure.
134
+ const gated = componentMarks(answer, progress("failed"), facets, { runs: runs(comment(12, "waiting"), merge), pin: MERGE });
135
+ expect(gated.waves[2]).toMatchObject({ title: "apply-wave-2 · held at the gate", tone: "wait" });
136
+ expect(gated.waves[1].title).toBe("apply-wave-1 · applied");
137
+ // Once a later re-run has gone past its gate, the run view's state again.
138
+ const after = componentMarks(answer, progress("failed"), facets, { runs: runs(comment(13, "failure"), comment(12, "waiting"), merge), pin: MERGE });
139
+ expect(after.waves[2]).toMatchObject({ title: "apply-wave-2 · failed", tone: "bad" });
132
140
  // Before any re-run, the merge's own failure.
133
141
  const failed = componentMarks(answer, progress("failed"), facets, { runs: runs(merge), pin: MERGE });
134
142
  expect(failed.waves[2].title).toBe("apply-wave-2 · failed");
@@ -140,6 +148,14 @@ describe("the component marks (#571)", () => {
140
148
  expect(waveStatus({ ...st, superseded: 12 }, null)).toMatchObject({ status: "failure" });
141
149
  expect(waveStatus({ ...st, superseded: 12 }, "applied")).toEqual({ status: "applied", words: "applied", tone: "ok", run: 12 });
142
150
  expect(waveStatus(null, "applied")).toBe(null);
151
+ // behold#693: a later run waiting at its gate holds a failed wave, never an applied one.
152
+ expect(waveStatus({ ...st, superseded: 12, held: true }, "failed")).toEqual({ status: "waiting", words: "held at the gate", tone: "wait", run: 12, held: true });
153
+ expect(waveStatus({ ...st, superseded: 12, held: true }, null)).toMatchObject({ words: "held at the gate" });
154
+ expect(waveStatus({ ...st, superseded: 12, held: true }, "applied")).toMatchObject({ words: "applied" });
155
+ // In a box too narrow for the full words, "held".
156
+ expect(statusShort(waveStatus({ ...st, superseded: 12, held: true }, "failed"))).toBe("held");
157
+ expect(statusShort(st)).toBe("failed");
158
+ expect(statusShort(null)).toBe(null);
143
159
  });
144
160
 
145
161
  it("draws the pull request's plan before the merge, with no job status", () => {