@intentius/behold 0.30.2 → 0.32.0
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 +791 -16
- package/README.md +78 -23
- package/THIRD_PARTY.md +6 -5
- package/demos.json +14 -9
- package/dist/cli.js +51926 -20221
- package/example-carve/README.md +19 -23
- package/example-carve/app/package.json +1 -1
- package/example-carve/app/src/carved.ts +3 -3
- package/example-carve/carve-report.json +1 -1
- package/example-carve/{legacy-tf → tf-root}/terraform.tfstate +1 -1
- package/example-choudoufu-estate/README.md +7 -0
- package/example-choudoufu-estate/chant.workspace.json +1 -1
- package/example-choudoufu-estate/scripts/choudoufu-down.sh +2 -1
- package/example-choudoufu-estate/scripts/choudoufu-up.sh +10 -3
- package/example-terraform-estate/README.md +32 -5
- package/example-terraform-estate/chant.workspace.json +1 -1
- package/example-terraform-estate/recorded/adoption/platform.json +72 -0
- package/example-terraform-estate/recorded/adoption/prod.json +224 -0
- package/example-three-cloud/README.md +111 -18
- package/example-three-cloud/aws/Pulumi.yaml +15 -0
- package/example-three-cloud/aws/index.ts +174 -0
- package/example-three-cloud/aws/package-lock.json +2725 -0
- package/example-three-cloud/aws/package.json +14 -0
- package/example-three-cloud/aws/tsconfig.json +17 -0
- package/example-three-cloud/azure/main.tf +48 -0
- package/example-three-cloud/azure/site.tf +104 -0
- package/example-three-cloud/chant.config.json +9 -0
- package/example-three-cloud/chant.workspace.json +30 -4
- package/example-three-cloud/dns/chant.config.ts +26 -1
- package/example-three-cloud/dns/src/records.component.ts +32 -6
- package/example-three-cloud/package-lock.json +48 -27
- package/example-three-cloud/package.json +8 -6
- package/example-three-cloud/scripts/emulators-up.sh +28 -1
- package/example-three-cloud/scripts/front-door.ts +679 -86
- package/package.json +26 -8
- package/schemas/graph/v1/graph.schema.json +140 -0
- package/web/adopt-pulumi.js +114 -0
- package/web/adopt-pulumi.test.js +28 -0
- package/web/adopt.js +203 -0
- package/web/adopt.test.js +27 -0
- package/web/app.js +367 -14
- package/web/boot-motion.js +6 -0
- package/web/carve-steps.js +1 -1
- package/web/carve-steps.test.js +2 -2
- package/web/change-set-overlay.js +12 -5
- package/web/change-set-overlay.test.js +22 -0
- package/web/cut-around.d.ts +30 -0
- package/web/cut-around.js +138 -0
- package/web/drift-stream.js +241 -0
- package/web/drift-stream.test.js +146 -0
- package/web/edge-weight.d.ts +8 -2
- package/web/edge-weight.js +38 -4
- package/web/edge-weight.test.js +55 -1
- package/web/graph-query.js +180 -0
- package/web/graph-query.test.js +49 -0
- package/web/graph.html +107 -0
- package/web/index-diff.js +109 -0
- package/web/index-diff.test.js +39 -0
- package/web/index.html +45 -20
- package/web/kiosk-ask-tips.js +15 -5
- package/web/kiosk-ask-tips.test.js +14 -1
- package/web/kiosk-estate-scene.js +72 -8
- package/web/kiosk-light-frame.js +1 -0
- package/web/kiosk-light.js +41 -3
- package/web/kiosk-member-kind.test.js +140 -0
- package/web/kiosk-popover.js +4 -1
- package/web/kiosk-side.js +296 -0
- package/web/kiosk-side.test.js +249 -0
- package/web/kiosk-watch.js +12 -0
- package/web/kiosk-watch.test.js +15 -1
- package/web/kiosk.html +47 -1
- package/web/kiosk.js +106 -7
- package/web/member-kind.js +31 -0
- package/web/neighbourhood.js +105 -0
- package/web/neighbourhood.test.js +131 -0
- package/web/outside-refs.js +515 -0
- package/web/outside-refs.test.js +249 -0
- package/web/template-apps.js +245 -0
- package/web/template-apps.test.js +252 -0
- package/web/templates.js +285 -0
- package/web/templates.test.js +155 -0
- package/web/terragucci-lifecycle.js +112 -62
- package/web/terragucci-lifecycle.test.js +29 -1
- package/web/terragucci-timeline.js +39 -2
- package/web/terragucci-timeline.test.js +42 -1
- package/web/theme-paint.js +14 -0
- package/example-three-cloud/aws/chant.config.ts +0 -8
- package/example-three-cloud/aws/site.component.ts +0 -13
- package/example-three-cloud/aws/src/site.ts +0 -27
- package/example-three-cloud/azure/chant.config.ts +0 -1
- package/example-three-cloud/azure/src/site.component.ts +0 -13
- package/example-three-cloud/azure/src/site.ts +0 -18
- /package/example-carve/{legacy-tf → tf-root}/cdn.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/compute.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/floci-override.tf.disabled +0 -0
- /package/example-carve/{legacy-tf → tf-root}/modules/cdn/main.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/naming.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/network.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/observability.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/outputs.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/storage.tf +0 -0
- /package/example-carve/{legacy-tf → tf-root}/versions.tf +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// The Watch side pane of the prompt demo: a column at the right of the graph, above the prompt pane, on a wide
|
|
2
|
+
// screen. At its top the act's run as a trace (the steps with their timings: the plan, the approval, the apply, and
|
|
3
|
+
// each estate's part of the apply), drawn with the rows Inspect's trace box uses; under it one small card about what
|
|
4
|
+
// the terminal's current line names (the boxes its `ask.light` and `ask.paths` light): the resource, its before and
|
|
5
|
+
// after, and which estate's record was written. It says nothing the terminal does not: it shows the run's facts.
|
|
6
|
+
//
|
|
7
|
+
// The models are pure (data in, data out, tested next door); renderSide draws them. web/kiosk.js wires it.
|
|
8
|
+
|
|
9
|
+
import { applyOf, cardLines, cardTitle, lineState, planOf, selectLight, stateMarks, stateWords } from "./kiosk-light.js";
|
|
10
|
+
import { msShort } from "./kiosk-wave-traces.js";
|
|
11
|
+
|
|
12
|
+
/** Where a viewer's choice to fold the pane is kept, in their own browser. */
|
|
13
|
+
export const SIDE_STORE = "behold.kiosk.side";
|
|
14
|
+
|
|
15
|
+
/** Phones (up to this width) keep the graph and the prompt only. */
|
|
16
|
+
export const SIDE_PHONE = "(max-width: 700px)";
|
|
17
|
+
|
|
18
|
+
/** Whether the pane is open: open unless this viewer folded it. A storage that throws counts as open. */
|
|
19
|
+
export function sideStored(store) {
|
|
20
|
+
try {
|
|
21
|
+
return !(store && store.getItem(SIDE_STORE) === "closed");
|
|
22
|
+
} catch {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Keep the viewer's choice; a storage that throws keeps it for this visit only. */
|
|
28
|
+
export function keepSide(store, open) {
|
|
29
|
+
try {
|
|
30
|
+
if (store) store.setItem(SIDE_STORE, open ? "open" : "closed");
|
|
31
|
+
} catch {
|
|
32
|
+
/* private mode: the choice lasts this visit */
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* How the pane shows: "open", "folded" (a tab at the right edge), or "none". Only in Watch with the prompt pane up
|
|
38
|
+
* (ask mode), and never on a phone.
|
|
39
|
+
*/
|
|
40
|
+
export function sideState({ ask, phone, open }) {
|
|
41
|
+
if (!ask || phone) return "none";
|
|
42
|
+
return open ? "open" : "folded";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ms = (v) => {
|
|
46
|
+
const t = typeof v === "string" ? Date.parse(v) : NaN;
|
|
47
|
+
return Number.isFinite(t) ? t : null;
|
|
48
|
+
};
|
|
49
|
+
const lastSegment = (path) => String(path || "").split("/").filter(Boolean).pop() || String(path || "");
|
|
50
|
+
|
|
51
|
+
/** A job's or a step's tone: done, running, waiting, failed, or skipped. */
|
|
52
|
+
export function jobTone(status) {
|
|
53
|
+
if (status === "success" || status === "applied" || status === "approved") return "done";
|
|
54
|
+
if (status === "running" || status === "applying") return "running";
|
|
55
|
+
if (status === "failure" || status === "failed" || status === "cancelled" || status === "partial") return "failed";
|
|
56
|
+
if (status === "waiting" || status === "queued" || status === "blocked") return "waiting";
|
|
57
|
+
return "skipped";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The step the trace is drawn at: the terminal's current turn (`turn`, `{ scenario, step }` from the prompt pane's
|
|
62
|
+
* events), on the cycle its scenario was last seen on (`cycles`, scenario to cycle), since the terminal plays its
|
|
63
|
+
* steps in turn and may be behind demo.json (`demo`). demo.json's step when no turn has played, or the turn's
|
|
64
|
+
* scenario was never seen.
|
|
65
|
+
*/
|
|
66
|
+
export function sideStep(demo, turn, cycles) {
|
|
67
|
+
if (!turn || !cycles || !cycles.has(turn.scenario)) return demo || null;
|
|
68
|
+
const cycle = cycles.get(turn.scenario);
|
|
69
|
+
if (demo && demo.cycle === cycle) return { ...demo, step: turn.step };
|
|
70
|
+
return { ...(demo || {}), cycle, scenario: turn.scenario, step: turn.step };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Whether the step is at or past its act's merge, so the run view the kiosk holds is this act's apply. */
|
|
74
|
+
export function sideApplied(demo) {
|
|
75
|
+
return !!demo && ["merged", "applying", "waiting", "resumed", "applied", "failed", "reset"].includes(demo.step);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The run view the pane may read for the act at `demo`: only once the act has merged, and only the run view of the
|
|
80
|
+
* act's own merge commit (`progress.run.commit`, which the reads name). The kiosk's read can be the last merge's run
|
|
81
|
+
* view (an earlier act's, or another demo's), and before this act's apply nothing of its own has been written: the
|
|
82
|
+
* pane then shows plan-time facts alone. Null when there is none to read.
|
|
83
|
+
*/
|
|
84
|
+
export function actRunView(demo, progress) {
|
|
85
|
+
if (!sideApplied(demo) || !progress || progress.error || !progress.run || progress.run.present === false) return null;
|
|
86
|
+
const have = typeof progress.run.commit === "string" ? progress.run.commit : "";
|
|
87
|
+
const want = typeof demo.commit === "string" ? demo.commit : "";
|
|
88
|
+
if (have.length < 7 || want.length < 7 || !(have.startsWith(want) || want.startsWith(have))) return null;
|
|
89
|
+
return progress;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const APPROVED_STEPS = new Set(["approved", "merged", "applying", "waiting", "resumed", "applied", "failed", "reset"]);
|
|
93
|
+
|
|
94
|
+
/** A pipeline job's place in the trace: "plan", "approval", "apply" (with its wave, for an apply-wave-N job), or null for the bookkeeping jobs. */
|
|
95
|
+
export function jobKind(name) {
|
|
96
|
+
const n = String(name || "");
|
|
97
|
+
if (n === "plan" || n === "replan") return { kind: "plan", label: n === "replan" ? "re-plan" : "plan" };
|
|
98
|
+
if (n === "approval") return { kind: "approval" };
|
|
99
|
+
const w = /^apply-wave-(\d+)$/.exec(n);
|
|
100
|
+
if (w) return { kind: "apply", wave: Number(w[1]) };
|
|
101
|
+
if (n === "apply") return { kind: "apply", wave: null };
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The act's run as trace rows, in the order they ran: `{ rows, from, to }`. Each row is `{ key, label, tone, at, end,
|
|
107
|
+
* ms, depth }`, times in epoch ms (`end` null while it runs), `depth` 1 for an estate's part of the apply. The rows,
|
|
108
|
+
* from the jobs of the act's runs (the bookkeeping jobs, checks, notes and tips, left out):
|
|
109
|
+
* - the plan (and a re-plan);
|
|
110
|
+
* - the approval: the wait from the plan's end to the approval (its job's end, else the first apply's run), or to now
|
|
111
|
+
* while the step still waits on it;
|
|
112
|
+
* - the apply: one row per apply job, named for the estates its wave applies when the run view says (else "wave N"),
|
|
113
|
+
* and, for a single apply job, each estate's part of it from the run view (no time of its own: the run view states
|
|
114
|
+
* each part's outcome, not when it ran).
|
|
115
|
+
* `runs` is the runs index (web/kiosk-runs.js), `demo` the step, `answer` and `progress` the kiosk's terragucci reads.
|
|
116
|
+
*/
|
|
117
|
+
export function runTrace(runs, demo, { answer = null, progress = null, now = Date.now() } = {}) {
|
|
118
|
+
if (!demo || !Number.isInteger(demo.cycle)) return { rows: [], from: null, to: null };
|
|
119
|
+
const mine = (Array.isArray(runs) ? runs : [])
|
|
120
|
+
.filter((r) => r && r.cycle === demo.cycle)
|
|
121
|
+
.sort((a, b) => (ms(a.created_at) || 0) - (ms(b.created_at) || 0) || (a.id || 0) - (b.id || 0));
|
|
122
|
+
const jobs = [];
|
|
123
|
+
for (const run of mine) {
|
|
124
|
+
for (const j of run.jobs || []) {
|
|
125
|
+
const k = jobKind(j.name);
|
|
126
|
+
const at = ms(j.started_at);
|
|
127
|
+
if (!k || (at === null && jobTone(j.status) === "skipped")) continue;
|
|
128
|
+
jobs.push({ run, job: j, ...k, at, end: ms(j.ended_at), created: ms(run.created_at) });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const row = (x, label) => ({ key: `${x.run.id}/${x.job.id ?? x.job.name}`, label, tone: jobTone(x.job.status), at: x.at, end: x.end, ms: x.at !== null ? (x.end ?? now) - x.at : null, depth: 0, run: x.run.id });
|
|
132
|
+
const rows = [];
|
|
133
|
+
const plans = jobs.filter((x) => x.kind === "plan");
|
|
134
|
+
for (const x of plans) rows.push(row(x, x.label));
|
|
135
|
+
const applies = jobs.filter((x) => x.kind === "apply");
|
|
136
|
+
const planEnd = plans.length ? plans[plans.length - 1].end : null;
|
|
137
|
+
if (planEnd !== null) {
|
|
138
|
+
const job = jobs.find((x) => x.kind === "approval" && x.end !== null);
|
|
139
|
+
const firstApply = applies.length ? applies[0].created ?? applies[0].at : null;
|
|
140
|
+
const done = job ? job.end : firstApply;
|
|
141
|
+
const approved = done !== null || APPROVED_STEPS.has(demo.step);
|
|
142
|
+
rows.push({ key: "approval", label: "approval", tone: approved ? "done" : "waiting", at: planEnd, end: done, ms: done !== null ? Math.max(0, done - planEnd) : approved ? null : Math.max(0, now - planEnd), depth: 0 });
|
|
143
|
+
}
|
|
144
|
+
const waveRoots = new Map();
|
|
145
|
+
for (const w of (progress && Array.isArray(progress.states) ? progress.states : [])) {
|
|
146
|
+
const roots = w.composed && Array.isArray(w.composed.members) ? w.composed.members.map((m) => m.root) : Array.isArray(w.roots) ? w.roots : [];
|
|
147
|
+
if (Number.isInteger(w.number) && roots.length) waveRoots.set(w.number, roots.map(lastSegment).join(", "));
|
|
148
|
+
}
|
|
149
|
+
for (const x of applies) {
|
|
150
|
+
const label = x.wave === null ? "apply" : waveRoots.get(x.wave) || `wave ${x.wave}`;
|
|
151
|
+
const r = row(x, label);
|
|
152
|
+
rows.push(r);
|
|
153
|
+
if (applies.length === 1) for (const part of applyParts(answer, progress)) rows.push({ ...part, key: `${r.key}/${part.root}`, at: r.at, end: r.end, ms: null, depth: 1 });
|
|
154
|
+
}
|
|
155
|
+
const times = rows.flatMap((r) => [r.at, r.end]).filter((t) => t !== null);
|
|
156
|
+
const from = times.length ? Math.min(...times) : null;
|
|
157
|
+
const to = rows.some((r) => r.at !== null && r.end === null) ? now : times.length ? Math.max(...times) : null;
|
|
158
|
+
return { rows, from, to: to !== null && from !== null && to <= from ? from + 1 : to };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const PART_WORDS = { applied: "applied", "no-changes": "applied", partial: "partly applied", failed: "partly applied", "not-started": "not applied" };
|
|
162
|
+
|
|
163
|
+
/** Each estate's part of the apply, from the run view: `{ root, label, tone, words }`, in the plan's order. */
|
|
164
|
+
export function applyParts(answer, progress) {
|
|
165
|
+
const plan = planOf(answer, progress);
|
|
166
|
+
const roots = plan.roots.length ? plan.roots.map((r) => r.path) : progress && Array.isArray(progress.reads) ? progress.reads.map((r) => r.root) : [];
|
|
167
|
+
const out = [];
|
|
168
|
+
for (const root of roots) {
|
|
169
|
+
const a = applyOf(root, progress);
|
|
170
|
+
if (!a) continue;
|
|
171
|
+
const words = a.apply ? PART_WORDS[a.apply] || a.apply : a.waveState === "applying" || a.waveState === "running" ? "applying" : "waiting";
|
|
172
|
+
const tone = a.apply ? jobTone(a.apply === "no-changes" ? "applied" : a.apply === "not-started" ? "skipped" : a.apply) : jobTone(words);
|
|
173
|
+
out.push({ root, label: lastSegment(root), tone, words });
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The card about the terminal's current line: what its `ask.light` names (and `ask.paths` reaches), from the plan.
|
|
180
|
+
* `{ items, estates }` or null when the line names nothing the plan has. Each item is `{ key, name, type, action,
|
|
181
|
+
* estate, lines }`, `lines` the attribute lines the graph's card shows (`{ state, text }`: the before and after, or
|
|
182
|
+
* the value known after apply); each estate is `{ name, words }`, its records written or not. At most `max` items.
|
|
183
|
+
*/
|
|
184
|
+
export function detailsModel(answer, progress, ask, { max = 3 } = {}) {
|
|
185
|
+
if (!ask || !answer || answer.error) return null;
|
|
186
|
+
const plan = planOf(answer, progress);
|
|
187
|
+
const sel = selectLight(plan, ask);
|
|
188
|
+
if (!sel) return null;
|
|
189
|
+
const light = Array.isArray(ask.light) ? ask.light : [];
|
|
190
|
+
const lines = cardLines(plan, light);
|
|
191
|
+
const items = sel.lit.slice(0, max).map((key) => {
|
|
192
|
+
const res = plan.resources.get(key);
|
|
193
|
+
const t = cardTitle(res.address);
|
|
194
|
+
return {
|
|
195
|
+
key,
|
|
196
|
+
name: t.name,
|
|
197
|
+
type: t.type,
|
|
198
|
+
action: res.action || null,
|
|
199
|
+
estate: lastSegment(res.root),
|
|
200
|
+
// An id line only for a resource the apply creates: an update keeps its id, and its card shows the value that moves.
|
|
201
|
+
lines: lines.filter((l) => l.key === key && !(l.path === "id" && res.action !== "create")).map((l) => lineState(l, answer, progress)),
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
const marks = stateMarks(answer, progress);
|
|
205
|
+
// An estate is named only once there is something to say of it: its apply's outcome, its records written.
|
|
206
|
+
const estates = sel.roots
|
|
207
|
+
.map((root) => {
|
|
208
|
+
const m = marks[root];
|
|
209
|
+
return { name: lastSegment(root), words: m ? stateWords(m) || null : null, written: !!(m && m.written) };
|
|
210
|
+
})
|
|
211
|
+
.filter((e) => e.words);
|
|
212
|
+
return { items, more: Math.max(0, sel.lit.length - items.length), estates };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// The DOM.
|
|
217
|
+
|
|
218
|
+
const el = (doc, tag, cls, text) => {
|
|
219
|
+
const n = doc.createElement(tag);
|
|
220
|
+
if (cls) n.className = cls;
|
|
221
|
+
if (text !== undefined && text !== null) n.textContent = text;
|
|
222
|
+
return n;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/** The head over the trace and the card. */
|
|
226
|
+
export const SIDE_WORDS = { run: "This act's run", details: "On this line", fold: "Hide", unfold: "Run details" };
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Draw the pane into `host`: the trace (`trace`, from runTrace) as rows of Inspect's trace box (`.k-wf`), then
|
|
230
|
+
* `traces(node)` (the waves' Tempo traces, as Inspect draws them, when it has them), then the card (`details`). The
|
|
231
|
+
* DOM is drawn again only when what it shows changes (`key`).
|
|
232
|
+
*/
|
|
233
|
+
export function renderSide(host, { trace, details }, { doc = typeof document !== "undefined" ? document : null, traces = null, onFold = null } = {}) {
|
|
234
|
+
if (!host || !doc) return;
|
|
235
|
+
const key = JSON.stringify([trace.rows.map((r) => [r.key, r.tone, r.words, r.ms === null ? null : Math.floor(r.ms / 1000)]), details]);
|
|
236
|
+
if (host.dataset && host.dataset.key === key) return;
|
|
237
|
+
if (host.dataset) host.dataset.key = key;
|
|
238
|
+
host.replaceChildren();
|
|
239
|
+
const head = el(doc, "div", "k-side-head");
|
|
240
|
+
head.appendChild(el(doc, "h2", "k-side-title", SIDE_WORDS.run));
|
|
241
|
+
if (onFold) {
|
|
242
|
+
const fold = el(doc, "button", "k-side-fold", SIDE_WORDS.fold);
|
|
243
|
+
fold.type = "button";
|
|
244
|
+
fold.setAttribute("aria-label", "Hide the run details");
|
|
245
|
+
fold.addEventListener("click", onFold);
|
|
246
|
+
head.appendChild(fold);
|
|
247
|
+
}
|
|
248
|
+
host.appendChild(head);
|
|
249
|
+
const wf = el(doc, "div", "k-wf k-side-wf");
|
|
250
|
+
const span = trace.from !== null && trace.to !== null ? trace.to - trace.from : 0;
|
|
251
|
+
for (const r of trace.rows) {
|
|
252
|
+
const row = el(doc, "div", `k-wf-row k-wf-plain k-side-row k-tone-${r.tone}${r.depth ? " k-side-part" : ""}`);
|
|
253
|
+
row.appendChild(el(doc, "span", "k-wf-wave", r.label));
|
|
254
|
+
const track = el(doc, "span", "k-wf-track");
|
|
255
|
+
if (r.depth) track.appendChild(el(doc, "span", "k-side-words", r.words));
|
|
256
|
+
else if (r.at !== null && span > 0) {
|
|
257
|
+
const seg = el(doc, "span", `k-wf-seg k-side-seg k-tone-${r.tone}`);
|
|
258
|
+
const a = (r.at - trace.from) / span;
|
|
259
|
+
const b = ((r.end ?? trace.to) - trace.from) / span;
|
|
260
|
+
seg.style.left = `${(a * 100).toFixed(2)}%`;
|
|
261
|
+
seg.style.width = `${Math.max(0.5, (b - a) * 100).toFixed(2)}%`;
|
|
262
|
+
track.appendChild(seg);
|
|
263
|
+
}
|
|
264
|
+
row.appendChild(track);
|
|
265
|
+
row.appendChild(el(doc, "span", "k-wf-words", r.depth ? "" : r.ms !== null ? msShort(r.ms) : ""));
|
|
266
|
+
wf.appendChild(row);
|
|
267
|
+
}
|
|
268
|
+
if (!trace.rows.length) wf.appendChild(el(doc, "p", "k-side-quiet", "No run yet in this act."));
|
|
269
|
+
host.appendChild(wf);
|
|
270
|
+
if (traces) {
|
|
271
|
+
const t = el(doc, "section", "k-i-traces k-side-traces");
|
|
272
|
+
traces(t);
|
|
273
|
+
if (!t.hidden) host.appendChild(t);
|
|
274
|
+
}
|
|
275
|
+
if (details && (details.items.length || details.estates.length)) {
|
|
276
|
+
const card = el(doc, "section", "k-side-card");
|
|
277
|
+
card.appendChild(el(doc, "h2", "k-side-title", SIDE_WORDS.details));
|
|
278
|
+
for (const it of details.items) {
|
|
279
|
+
const item = el(doc, "div", "k-side-item");
|
|
280
|
+
const name = el(doc, "p", "k-side-name");
|
|
281
|
+
name.appendChild(el(doc, "b", null, it.name));
|
|
282
|
+
name.appendChild(el(doc, "span", "k-side-type", [it.type, it.action, it.estate].filter(Boolean).join(" · ")));
|
|
283
|
+
item.appendChild(name);
|
|
284
|
+
for (const l of it.lines) item.appendChild(el(doc, "p", `k-side-line k-line-${l.state}`, l.text));
|
|
285
|
+
card.appendChild(item);
|
|
286
|
+
}
|
|
287
|
+
if (details.more) card.appendChild(el(doc, "p", "k-side-quiet", `and ${details.more} more`));
|
|
288
|
+
for (const e of details.estates) {
|
|
289
|
+
const p = el(doc, "p", `k-side-estate${e.written ? " k-side-written" : ""}`);
|
|
290
|
+
p.appendChild(el(doc, "b", null, e.name));
|
|
291
|
+
if (e.words) p.appendChild(el(doc, "span", "k-side-type", e.words));
|
|
292
|
+
card.appendChild(p);
|
|
293
|
+
}
|
|
294
|
+
host.appendChild(card);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { reportedRunView } from "./kiosk-light.js";
|
|
5
|
+
import { SIDE_STORE, actRunView, applyParts, jobKind, detailsModel, jobTone, keepSide, runTrace, sideApplied, sideState, sideStep, sideStored } from "./kiosk-side.js";
|
|
6
|
+
|
|
7
|
+
// The three-root estate of behold#937 (src/__fixtures__/terragucci-demo-ask), built as web/kiosk-light.test.js builds it.
|
|
8
|
+
const FIX = join(import.meta.dirname, "..", "src", "__fixtures__", "terragucci-demo-ask");
|
|
9
|
+
const read = (f) => JSON.parse(readFileSync(join(FIX, f), "utf8"));
|
|
10
|
+
const report = read("report-pull-request.json");
|
|
11
|
+
function answerOf(r) {
|
|
12
|
+
const roots = r.roots.map((x) => ({ member: "demo", name: x.path, path: x.path }));
|
|
13
|
+
const cards = {};
|
|
14
|
+
for (const root of r.roots) {
|
|
15
|
+
for (const c of root.changes) {
|
|
16
|
+
cards[`demo/${root.path}/${c.address}`] = [{ verdict: "plan", action: c.action, addresses: [c.address], values: (c.attributes || []).map((a) => ({ ...a, address: c.address })) }];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const reads = r.roots.flatMap((x) => (x.reads || []).map((rd) => ({ ...rd, root: x.path })));
|
|
20
|
+
return { roots, cards, unmatched: { roots: [], changes: [] }, pull_request: { roots: r.roots.map((x) => x.path), reads, blast: r.blast, waves: r.waves } };
|
|
21
|
+
}
|
|
22
|
+
const answer = answerOf(report);
|
|
23
|
+
const progressOf = (run) => ({ states: run.waves.map((w) => ({ number: w.number, state: w.state, roots: w.roots, composed: w.composed })), reads: run.roots.map((x) => ({ root: x.root, wave: x.wave, reads: x.reads, stateKey: x.state && x.state.key })) });
|
|
24
|
+
|
|
25
|
+
const memory = () => {
|
|
26
|
+
const m = new Map();
|
|
27
|
+
return { getItem: (k) => (m.has(k) ? m.get(k) : null), setItem: (k, v) => m.set(k, String(v)), m };
|
|
28
|
+
};
|
|
29
|
+
const throwing = { getItem: () => { throw new Error("denied"); }, setItem: () => { throw new Error("denied"); } };
|
|
30
|
+
|
|
31
|
+
describe("the side pane's place", () => {
|
|
32
|
+
it("shows in ask mode on anything wider than a phone, open until the viewer folds it", () => {
|
|
33
|
+
expect(sideState({ ask: true, phone: false, open: true })).toBe("open");
|
|
34
|
+
expect(sideState({ ask: true, phone: false, open: false })).toBe("folded");
|
|
35
|
+
expect(sideState({ ask: true, phone: true, open: true })).toBe("none");
|
|
36
|
+
expect(sideState({ ask: false, phone: false, open: true })).toBe("none");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("remembers a fold in localStorage, and a storage that throws neither breaks nor folds it", () => {
|
|
40
|
+
const store = memory();
|
|
41
|
+
expect(sideStored(store)).toBe(true);
|
|
42
|
+
keepSide(store, false);
|
|
43
|
+
expect(store.m.get(SIDE_STORE)).toBe("closed");
|
|
44
|
+
expect(sideStored(store)).toBe(false);
|
|
45
|
+
keepSide(store, true);
|
|
46
|
+
expect(sideStored(store)).toBe(true);
|
|
47
|
+
expect(() => keepSide(throwing, false)).not.toThrow();
|
|
48
|
+
expect(sideStored(throwing)).toBe(true);
|
|
49
|
+
expect(sideStored(null)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("the act's run as a trace", () => {
|
|
54
|
+
const t = (s) => `2026-10-25T04:2${s}Z`;
|
|
55
|
+
const runs = [
|
|
56
|
+
{ id: 9, cycle: 471, trigger: "merge", event: "push", created_at: "2026-10-25T04:24:14Z", jobs: [{ id: 2, name: "plan", status: "skipped" }, { id: 3, name: "apply", status: "success", started_at: "2026-10-25T04:24:14.000Z", ended_at: "2026-10-25T04:24:28.000Z" }] },
|
|
57
|
+
{ id: 8, cycle: 471, trigger: "plan", event: "pull_request", created_at: "2026-10-25T04:23:24Z", jobs: [{ id: 1, name: "plan", status: "success", started_at: "2026-10-25T04:23:25.000Z", ended_at: "2026-10-25T04:23:35.000Z" }, { id: 4, name: "apply", status: "skipped" }] },
|
|
58
|
+
{ id: 7, cycle: 470, trigger: "merge", created_at: t("0:00"), jobs: [{ id: 5, name: "apply", status: "success", started_at: t("0:00"), ended_at: t("0:10") }] },
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
it("lists this act's plan, its approval and its apply, in order, with their times", () => {
|
|
62
|
+
const tr = runTrace(runs, { cycle: 471, step: "applied" }, { now: Date.parse("2026-10-25T04:25:00Z") });
|
|
63
|
+
expect(tr.rows.map((r) => [r.label, r.tone, r.ms])).toEqual([
|
|
64
|
+
["plan", "done", 10_000],
|
|
65
|
+
["approval", "done", 39_000],
|
|
66
|
+
["apply", "done", 14_000],
|
|
67
|
+
]);
|
|
68
|
+
expect(tr.from).toBe(Date.parse("2026-10-25T04:23:25Z"));
|
|
69
|
+
expect(tr.to).toBe(Date.parse("2026-10-25T04:24:28Z"));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("times a running job and a waiting approval up to now", () => {
|
|
73
|
+
const now = Date.parse("2026-10-25T04:24:00Z");
|
|
74
|
+
const tr = runTrace([runs[1]], { cycle: 471, step: "planned" }, { now });
|
|
75
|
+
expect(tr.rows.map((r) => [r.label, r.tone, r.ms])).toEqual([["plan", "done", 10_000], ["approval", "waiting", 25_000]]);
|
|
76
|
+
expect(tr.to).toBe(now);
|
|
77
|
+
const running = [{ ...runs[1], jobs: [{ id: 1, name: "plan", status: "running", started_at: "2026-10-25T04:23:25.000Z", ended_at: null }] }];
|
|
78
|
+
const r2 = runTrace(running, { cycle: 471, step: "pull-request" }, { now });
|
|
79
|
+
expect(r2.rows).toHaveLength(1);
|
|
80
|
+
expect(r2.rows[0]).toMatchObject({ label: "plan", tone: "running", ms: 35_000, end: null });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("is empty before the act has a run, and without a step", () => {
|
|
84
|
+
expect(runTrace(runs, { cycle: 472, step: "pull-request" }).rows).toEqual([]);
|
|
85
|
+
expect(runTrace(runs, null).rows).toEqual([]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("puts each estate's part under the apply, from the run view", () => {
|
|
89
|
+
const progress = progressOf(read("run-applied.json"));
|
|
90
|
+
const parts = applyParts(answer, progress);
|
|
91
|
+
expect(parts.map((p) => p.label)).toEqual(["network", "app", "edge"]);
|
|
92
|
+
expect(parts.every((p) => p.tone === "done" && p.words === "applied")).toBe(true);
|
|
93
|
+
const tr = runTrace(runs, { cycle: 471, step: "applied" }, { answer, progress });
|
|
94
|
+
expect(tr.rows.filter((r) => r.depth === 1).map((r) => r.label)).toEqual(["network", "app", "edge"]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("names a job's tone", () => {
|
|
98
|
+
expect(["success", "running", "failure", "waiting", "skipped"].map(jobTone)).toEqual(["done", "running", "failed", "waiting", "skipped"]);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe("the card about the current line", () => {
|
|
103
|
+
it("names what the line lights: the resource, its estate, and its lines", () => {
|
|
104
|
+
const d = detailsModel(answer, null, { light: ["network/terraform_data.subnet"] });
|
|
105
|
+
expect(d.items).toHaveLength(1);
|
|
106
|
+
expect(d.items[0]).toMatchObject({ name: "subnet", type: "terraform_data", action: "create", estate: "network" });
|
|
107
|
+
expect(d.items[0].lines[0]).toMatchObject({ state: "unknown" });
|
|
108
|
+
expect(d.estates).toEqual([{ name: "network", words: "state network.tfstate", written: false }]);
|
|
109
|
+
// An estate with nothing to say yet is not named.
|
|
110
|
+
expect(detailsModel({ ...answer, binaries: { network: "choudoufu" } }, null, { light: ["network/terraform_data.subnet"] }).estates).toEqual([]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("follows the paths downstream, at most three items, and says how many more", () => {
|
|
114
|
+
const d = detailsModel(answer, null, { light: ["network/terraform_data.subnet"], paths: true });
|
|
115
|
+
expect(d.items).toHaveLength(3);
|
|
116
|
+
expect(d.more).toBe(3);
|
|
117
|
+
expect(d.estates.map((e) => e.name).sort()).toEqual(["app", "edge", "network"]);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("says which estate's record was written once the run view has it", () => {
|
|
121
|
+
const progress = progressOf(read("run-applied.json"));
|
|
122
|
+
const d = detailsModel({ ...answer, binaries: { network: "choudoufu", app: "choudoufu", edge: "choudoufu" } }, progress, { light: ["network/terraform_data.subnet"] });
|
|
123
|
+
expect(d.estates[0]).toMatchObject({ name: "network", written: true });
|
|
124
|
+
expect(d.estates[0].words).toContain("records written");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("is empty for a line that lights nothing", () => {
|
|
128
|
+
expect(detailsModel(answer, null, null)).toBeNull();
|
|
129
|
+
expect(detailsModel(answer, null, { prompt: "hi" })).toBeNull();
|
|
130
|
+
expect(detailsModel(answer, null, { light: ["network/terraform_data.nope"] })).toBeNull();
|
|
131
|
+
expect(detailsModel({ error: "x" }, null, { light: ["network/terraform_data.subnet"] })).toBeNull();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe("the step the trace follows", () => {
|
|
136
|
+
const cycles = new Map([["edit", 7], ["create", 8]]);
|
|
137
|
+
it("is the terminal's turn, on the act its scenario ran in, while demo.json is ahead", () => {
|
|
138
|
+
expect(sideStep({ cycle: 8, scenario: "create", step: "planned" }, { scenario: "edit", step: "applying" }, cycles)).toMatchObject({ cycle: 7, scenario: "edit", step: "applying" });
|
|
139
|
+
expect(sideStep({ cycle: 8, scenario: "create", step: "planned" }, { scenario: "create", step: "pull-request" }, cycles)).toMatchObject({ cycle: 8, step: "pull-request" });
|
|
140
|
+
});
|
|
141
|
+
it("is demo.json's step before any turn has played, or for a scenario never seen", () => {
|
|
142
|
+
const d = { cycle: 8, scenario: "create", step: "planned" };
|
|
143
|
+
expect(sideStep(d, null, cycles)).toBe(d);
|
|
144
|
+
expect(sideStep(d, { scenario: "other", step: "applied" }, cycles)).toBe(d);
|
|
145
|
+
expect(sideStep(null, null, cycles)).toBeNull();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe("a pipeline with an approval job and an apply job per wave", () => {
|
|
150
|
+
const J = (name, status, a = null, b = null) => ({ id: name, name, status, started_at: a, ended_at: b });
|
|
151
|
+
const runs = [
|
|
152
|
+
{ id: 13, cycle: 481, trigger: "merge", event: "push", created_at: "2026-10-25T04:38:23Z", jobs: [J("check", "success", "2026-10-25T04:38:23.693Z", "2026-10-25T04:38:28.276Z"), J("apply-wave-1", "success", "2026-10-25T04:38:30.000Z", "2026-10-25T04:38:38.000Z"), J("apply-wave-2", "success", "2026-10-25T04:38:39.000Z", "2026-10-25T04:38:40.500Z"), J("tips", "success", "2026-10-25T04:38:45.000Z", "2026-10-25T04:38:46.000Z")] },
|
|
153
|
+
{ id: 12, cycle: 481, trigger: "push", event: "pull_request_approved", created_at: "2026-10-25T04:38:18Z", jobs: [J("plan", "skipped"), J("approval", "success", "2026-10-25T04:38:18.681Z", "2026-10-25T04:38:19.000Z")] },
|
|
154
|
+
{ id: 10, cycle: 481, trigger: "plan", event: "pull_request", created_at: "2026-10-25T04:38:01Z", jobs: [J("plan", "success", "2026-10-25T04:38:01.000Z", "2026-10-25T04:38:06.000Z"), J("plan-note", "success", "2026-10-25T04:38:06.700Z", "2026-10-25T04:38:07.800Z")] },
|
|
155
|
+
];
|
|
156
|
+
|
|
157
|
+
it("names the jobs it shows and leaves the bookkeeping out", () => {
|
|
158
|
+
expect(["plan", "replan", "approval", "apply", "apply-wave-3", "plan-note", "check", "tips"].map((n) => jobKind(n) && (jobKind(n).label || jobKind(n).kind))).toEqual(["plan", "re-plan", "approval", "apply", "apply", null, null, null]);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("times the approval from the plan to the approval job, and one row per wave named for its estates", () => {
|
|
162
|
+
const progress = { states: [{ number: 1, roots: ["network"] }, { number: 2, roots: ["app"] }] };
|
|
163
|
+
const tr = runTrace(runs, { cycle: 481, step: "applied" }, { progress });
|
|
164
|
+
expect(tr.rows.map((r) => [r.label, r.tone, r.ms])).toEqual([
|
|
165
|
+
["plan", "done", 5_000],
|
|
166
|
+
["approval", "done", 13_000],
|
|
167
|
+
["network", "done", 8_000],
|
|
168
|
+
["app", "done", 1_500],
|
|
169
|
+
]);
|
|
170
|
+
expect(runTrace(runs, { cycle: 481, step: "applied" }).rows.map((r) => r.label).slice(2)).toEqual(["wave 1", "wave 2"]);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe("the run view the pane reads", () => {
|
|
175
|
+
it("is this act's only from its merge on: before it, the kiosk still holds the last act's", () => {
|
|
176
|
+
expect(["pull-request", "planned", "approved"].map((step) => sideApplied({ step }))).toEqual([false, false, false]);
|
|
177
|
+
expect(["merged", "applying", "applied", "reset"].map((step) => sideApplied({ step }))).toEqual([true, true, true, true]);
|
|
178
|
+
expect(sideApplied(null)).toBe(false);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe("an act before its own apply says nothing applied", () => {
|
|
183
|
+
// The kiosk's run view read is the last merge's: an earlier act's, applied, written, its values filled.
|
|
184
|
+
const leaked = { ...progressOf(read("run-applied.json")), run: { commit: "2a64938856a4ccddeb8bf662b5ee5686e220d751", present: true } };
|
|
185
|
+
const scene = { ...answer, binaries: { network: "choudoufu", app: "choudoufu", edge: "choudoufu" } };
|
|
186
|
+
const ask = { light: ["network/terraform_data.subnet"], paths: true };
|
|
187
|
+
const words = (d) => JSON.stringify(d);
|
|
188
|
+
const APPLIED = /created|filled from|applied|records written|written/;
|
|
189
|
+
|
|
190
|
+
it("at the approval step, with the last merge's run view in hand, the card and the trace keep to plan-time facts", () => {
|
|
191
|
+
for (const step of ["pull-request", "planned", "approved"]) {
|
|
192
|
+
const demo = { cycle: 488, step, commit: "b6326854b7a54d55f7aecf032c73cd4ca52300f8" };
|
|
193
|
+
const view = actRunView(demo, leaked);
|
|
194
|
+
expect(view).toBeNull();
|
|
195
|
+
const d = detailsModel(scene, view, ask);
|
|
196
|
+
expect(words(d)).not.toMatch(APPLIED);
|
|
197
|
+
expect(d.items.flatMap((i) => i.lines.map((l) => l.state))).not.toContain("applied");
|
|
198
|
+
expect(d.items.some((i) => i.lines.some((l) => /known after apply/.test(l.text)))).toBe(true);
|
|
199
|
+
expect(d.estates).toEqual([]);
|
|
200
|
+
expect(applyParts(scene, view)).toEqual([]);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("after the merge, a run view of another commit is still not this act's", () => {
|
|
205
|
+
const demo = { cycle: 488, step: "applying", commit: "eeceb433a52885525dcd1365a7e794b13d906714" };
|
|
206
|
+
expect(actRunView(demo, leaked)).toBeNull();
|
|
207
|
+
expect(words(detailsModel(scene, actRunView(demo, leaked), ask))).not.toMatch(APPLIED);
|
|
208
|
+
expect(actRunView({ ...demo, step: "reset", commit: "adf41a02" }, leaked)).toBeNull();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("says applied once the act's own merge has written it", () => {
|
|
212
|
+
const demo = { cycle: 488, step: "applied", commit: "2a649388" };
|
|
213
|
+
const view = actRunView(demo, leaked);
|
|
214
|
+
expect(view).toBe(leaked);
|
|
215
|
+
const d = detailsModel(scene, view, ask);
|
|
216
|
+
expect(d.estates.map((e) => e.words)).toEqual(expect.arrayContaining(["applied \u00b7 records written"]));
|
|
217
|
+
expect(actRunView(demo, { ...leaked, run: { ...leaked.run, present: false } })).toBeNull();
|
|
218
|
+
expect(actRunView(demo, { ...leaked, run: undefined })).toBeNull();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe("a pipeline that writes reports and no run view (Terragrunt on choudoufu)", () => {
|
|
223
|
+
// The live demo's Terragrunt act II, read after its apply: the reports are in, and its merge commit has no run.json.
|
|
224
|
+
const answer = read("answer-terragrunt-applied.json");
|
|
225
|
+
const none = read("progress-no-run-view.json");
|
|
226
|
+
const demo = { cycle: 4450, step: "applied", commit: "4b80d08fb9558addeda8a51681c4a2988d2bf428" };
|
|
227
|
+
const ask = { light: ["network/aws_subnet.subnet_b", "app/aws_network_interface.worker"], paths: true };
|
|
228
|
+
const texts = (d) => d.items.flatMap((i) => i.lines.map((l) => l.text));
|
|
229
|
+
|
|
230
|
+
it("fills the cards from the act's apply reports once they are in", () => {
|
|
231
|
+
expect(actRunView(demo, none)).toBeNull();
|
|
232
|
+
const view = actRunView(demo, reportedRunView(none, answer));
|
|
233
|
+
expect(view && view.run.reported).toBe(true);
|
|
234
|
+
const d = detailsModel(answer, view, ask);
|
|
235
|
+
expect(texts(d).join("\n")).not.toMatch(/known after apply/);
|
|
236
|
+
expect(texts(d)).toContain("id: eni-23d149dc22983274b");
|
|
237
|
+
expect(d.estates.map((e) => e.words)).toEqual(expect.arrayContaining(["applied \u00b7 records written"]));
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("keeps to plan-time facts while the reports are of another commit, and leaves a run view that is there alone", () => {
|
|
241
|
+
const other = { ...none, run: { ...none.run, commit: "bbe939d348bb135e6a5902f6a395e08194e5070e" } };
|
|
242
|
+
expect(reportedRunView(other, answer)).toBe(other);
|
|
243
|
+
expect(actRunView({ ...demo, commit: other.run.commit }, reportedRunView(other, answer))).toBeNull();
|
|
244
|
+
const waiting = { ...answer, roots: answer.roots.map((r) => ({ ...r, apply: { ...r.apply, approval: "waiting" } })) };
|
|
245
|
+
expect(reportedRunView(none, waiting)).toBe(none);
|
|
246
|
+
const there = { ...none, run: { ...none.run, present: true } };
|
|
247
|
+
expect(reportedRunView(there, answer)).toBe(there);
|
|
248
|
+
});
|
|
249
|
+
});
|
package/web/kiosk-watch.js
CHANGED
|
@@ -154,6 +154,18 @@ export function coneCaption(demo, answer) {
|
|
|
154
154
|
return line ? { line, backend: backendLine(cone) } : null;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Whether a viewer's hold on Watch's shot (a click, a pan or a zoom on the graph holds it for PICK_HOLD_MS) ends with
|
|
159
|
+
* this step: at the act's reset, and when another act (cycle) starts. Each puts a different graph in the pane (the
|
|
160
|
+
* base checkout's, then the next act's), where the place the viewer moved to in the last one means nothing, so the
|
|
161
|
+
* shot frames it afresh. `prev` and `next` are the steps (demo.json's `demo`), either null.
|
|
162
|
+
*/
|
|
163
|
+
export function holdEnds(prev, next) {
|
|
164
|
+
if (!prev || !next) return false;
|
|
165
|
+
if (prev.cycle !== next.cycle) return true;
|
|
166
|
+
return next.step === "reset" && prev.step !== "reset";
|
|
167
|
+
}
|
|
168
|
+
|
|
157
169
|
/**
|
|
158
170
|
* What may sit over the graph in Watch. On a held small stage (`held`: one
|
|
159
171
|
* framing holds it, web/kiosk-shot.js heldFrame), nothing the step puts
|
package/web/kiosk-watch.test.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// takes, what the caption leads with, the badges, the delivery line, the
|
|
3
3
|
// result card, the drawer's folded lines, and where an overlay goes.
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { MODE_STORE, QUIET_MS, activeWave, badgeTitle, badgeWords, badges, behindStep, firstSentence, steadyRun, captionModel, changeRoots, doraLine, modeStored, placeBeside, quietDuration, quietWords, recordKey, resultModel, runningStep, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
5
|
+
import { MODE_STORE, QUIET_MS, activeWave, badgeTitle, badgeWords, badges, behindStep, firstSentence, holdEnds, steadyRun, captionModel, changeRoots, doraLine, modeStored, placeBeside, quietDuration, quietWords, recordKey, resultModel, runningStep, shotFor, stepTone, tailLines } from "./kiosk-watch.js";
|
|
6
6
|
|
|
7
7
|
const C = "9f3c2a71d04e5b8c6a1f2e3d4c5b6a7980716253";
|
|
8
8
|
const P = "1111111111111111111111111111111111111111";
|
|
@@ -263,3 +263,17 @@ describe("the quiet line", () => {
|
|
|
263
263
|
expect(firstSentence("main moved to 1234abcd: port 8080 -> 9090. Wave 1 plans again")).toBe("main moved to 1234abcd: port 8080 -> 9090");
|
|
264
264
|
});
|
|
265
265
|
});
|
|
266
|
+
|
|
267
|
+
describe("a viewer's hold on the shot ends at the reset and at a new act", () => {
|
|
268
|
+
it("ends when the reset step comes, and when another cycle starts", () => {
|
|
269
|
+
expect(holdEnds({ cycle: 4, step: "applied" }, { cycle: 4, step: "reset" })).toBe(true);
|
|
270
|
+
expect(holdEnds({ cycle: 4, step: "applied" }, { cycle: 5, step: "pull-request" })).toBe(true);
|
|
271
|
+
expect(holdEnds({ cycle: 4, step: "reset" }, { cycle: 5, step: "pull-request" })).toBe(true);
|
|
272
|
+
});
|
|
273
|
+
it("holds through the act's own steps, and through the reset's repeated reads", () => {
|
|
274
|
+
expect(holdEnds({ cycle: 4, step: "planned" }, { cycle: 4, step: "applying" })).toBe(false);
|
|
275
|
+
expect(holdEnds({ cycle: 4, step: "reset" }, { cycle: 4, step: "reset" })).toBe(false);
|
|
276
|
+
expect(holdEnds(null, { cycle: 4, step: "reset" })).toBe(false);
|
|
277
|
+
expect(holdEnds({ cycle: 4, step: "applied" }, null)).toBe(false);
|
|
278
|
+
});
|
|
279
|
+
});
|