@intentius/behold 0.29.49 → 0.29.51
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 +155 -4
- package/demos.json +15 -0
- package/dist/cli.js +2440 -998
- package/example-three-cloud/README.md +38 -0
- package/example-three-cloud/aws/chant.config.ts +8 -0
- package/example-three-cloud/aws/src/site.ts +20 -0
- package/example-three-cloud/azure/chant.config.ts +1 -0
- package/example-three-cloud/azure/src/site.ts +19 -0
- package/example-three-cloud/chant.workspace.json +10 -0
- package/example-three-cloud/dns/chant.config.ts +1 -0
- package/example-three-cloud/dns/ops/front-door.op.ts +21 -0
- package/example-three-cloud/dns/src/route53.ts +54 -0
- package/example-three-cloud/gcp/chant.config.ts +1 -0
- package/example-three-cloud/gcp/src/site.ts +19 -0
- package/example-three-cloud/package-lock.json +715 -0
- package/example-three-cloud/package.json +16 -0
- package/example-three-cloud/scripts/emulators-up.sh +46 -0
- package/example-three-cloud/scripts/front-door.ts +400 -0
- package/package.json +4 -2
- package/web/app.js +250 -23
- package/web/composite-members.js +21 -0
- package/web/composite-members.test.js +25 -0
- package/web/decision-points.js +70 -0
- package/web/decision-points.test.js +87 -0
- package/web/dots-kiosk.js +4 -1
- package/web/dots-live.test.js +10 -0
- package/web/dots.js +41 -4
- package/web/export-note.js +35 -0
- package/web/export-note.test.js +45 -0
- package/web/health-marks.js +146 -0
- package/web/health-marks.test.js +67 -0
- package/web/index.html +52 -0
- package/web/kiosk-runs.js +51 -5
- package/web/kiosk-runs.test.js +42 -1
- package/web/kiosk-source.js +23 -0
- package/web/kiosk-source.test.js +19 -1
- package/web/kiosk-track.js +9 -5
- package/web/kiosk-track.test.js +12 -2
- package/web/kiosk.html +26 -3
- package/web/kiosk.js +28 -6
- package/web/local-run.js +276 -0
- package/web/local-run.test.js +46 -0
- package/web/sql-yodeler-lane.js +1 -1
- package/web/terragucci-timeline.js +5 -4
- package/web/terragucci-timeline.test.js +1 -1
- package/web/trunk-lane.js +54 -5
- package/web/trunk-lane.test.js +86 -3
- package/web/view-url.js +25 -0
- package/web/view-url.test.js +24 -1
- package/web/why.js +1 -1
- package/web/why.test.js +1 -1
- package/web/workspace-gates.js +35 -18
package/web/kiosk-runs.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
|
-
import { FEATURE_LINES, fitFeatures, FOLLOW_LINES, followsLog, logKey, nearEnd, mergeRun, newerOf, agoWords, defaultJob, defaultStep, durationWords, jobOrder, liveRun, codeish, logLineWords, logRows, placeWords, scenarioTitles, setupLine, sidebarRuns, splitSkipped, STATUS_TONE, toneOf, triggerWords } from "./kiosk-runs.js";
|
|
4
|
+
import { FEATURE_LINES, fitFeatures, FOLLOW_LINES, followsLog, logKey, nearEnd, mergeRun, newerOf, agoWords, defaultJob, defaultStep, durationWords, indexWords, jobOrder, originLink, liveRun, codeish, logLineWords, logRows, placeWords, scenarioTitles, setupLine, sidebarRuns, splitSkipped, STATUS_TONE, toneOf, triggerWords } from "./kiosk-runs.js";
|
|
5
5
|
|
|
6
6
|
const FIX = join(import.meta.dirname, "..", "src", "__fixtures__", "terragucci-demo", "runs");
|
|
7
7
|
const run = (id) => JSON.parse(readFileSync(join(FIX, `${id}.json`), "utf8"));
|
|
@@ -296,3 +296,44 @@ describe("the left bar's tone (behold#571)", () => {
|
|
|
296
296
|
for (const tone of new Set(Object.values(STATUS_TONE))) expect(html).toContain(`[data-k-tone="${tone}"]`);
|
|
297
297
|
});
|
|
298
298
|
});
|
|
299
|
+
|
|
300
|
+
// behold#815: chant's run index, as src/ci-run-index.ts hands it to the pane.
|
|
301
|
+
describe("runs from chant's run index (behold#815)", () => {
|
|
302
|
+
const ci = (over = {}) => ({ schema: "demo.run/v1", from: "ci-run-index", id: "6782", status: "failure", trigger: "merge", pull: 773, ref: null, member: null, failure: "failed", signer: null, started_at: "2026-10-19T02:26:01.917Z", ended_at: "2026-10-19T02:26:10.991Z", jobs: [{ id: "6782", name: "pr-apply", needs: [], status: "failure" }], ...over });
|
|
303
|
+
it("names the member, why it failed, and who signed it, beside the trigger", () => {
|
|
304
|
+
expect(triggerWords(ci())).toBe("Merge of #773 to main");
|
|
305
|
+
// "failed" beside a failed status says nothing more; a reason that does is kept.
|
|
306
|
+
expect(indexWords(ci())).toEqual([]);
|
|
307
|
+
expect(indexWords(ci({ failure: "command-failed" }))).toEqual(["failed: command-failed"]);
|
|
308
|
+
expect(indexWords(ci({ member: "web", failure: null, signer: "ci-runner@chant-demo", status: "success" }))).toEqual(["web", "signed by ci-runner@chant-demo"]);
|
|
309
|
+
});
|
|
310
|
+
it("says nothing of a signer a run doesn't have: signing is opt-in (chant#4156)", () => {
|
|
311
|
+
for (const signer of [null, undefined, ""]) expect(indexWords(ci({ signer, failure: null })).join(" ")).not.toMatch(/sign/);
|
|
312
|
+
});
|
|
313
|
+
it("words an apply that exited 3 as a plan that moved or waits, not a failure (chant#4156)", () => {
|
|
314
|
+
expect(indexWords(ci({ status: "waiting", failure: "plan-changed", moved: "the plan moved or waits: re-plan and re-approve" }))).toEqual(["the plan moved or waits: re-plan and re-approve (plan-changed)"]);
|
|
315
|
+
expect(toneOf("waiting")).not.toBe(toneOf("failure"));
|
|
316
|
+
});
|
|
317
|
+
it("words an apply held by its exit code alone the same way, naming the code (#818, chant#4165)", () => {
|
|
318
|
+
expect(indexWords(ci({ status: "waiting", failure: "failed", moved: "the plan moved or waits: re-plan and re-approve", heldBy: "exit 3", exitCode: 3 }))).toEqual(["the plan moved or waits: re-plan and re-approve (exit 3)"]);
|
|
319
|
+
});
|
|
320
|
+
it("links the forge's run by its URL's host, never by runOrigin's forge name", () => {
|
|
321
|
+
expect(originLink(ci({ origin: "http://forgejo:3000/chant-demo/fan-out-estate/actions/runs/6782" }))).toEqual({ href: "http://forgejo:3000/chant-demo/fan-out-estate/actions/runs/6782", text: "the run on forgejo:3000" });
|
|
322
|
+
expect(originLink(ci({ origin: "javascript:alert(1)" }))).toBeNull();
|
|
323
|
+
expect(originLink(ci())).toBeNull();
|
|
324
|
+
expect(originLink({ origin: "https://x.example/r/1" })).toBeNull();
|
|
325
|
+
});
|
|
326
|
+
it("adds nothing to a run from anywhere else", () => {
|
|
327
|
+
expect(indexWords({ ...ci(), from: undefined, member: "web" })).toEqual([]);
|
|
328
|
+
expect(indexWords(null)).toEqual([]);
|
|
329
|
+
});
|
|
330
|
+
it("calls a job chant adds later a run, and draws a status it adds by its own word", () => {
|
|
331
|
+
expect(triggerWords(ci({ trigger: null, event: null }))).toBe("a run");
|
|
332
|
+
expect(toneOf("cancelled-by-host")).toBe("idle");
|
|
333
|
+
});
|
|
334
|
+
it("keys runs by chant's run id, a string, through the merge and the live pick", () => {
|
|
335
|
+
const entry = ci({ status: "waiting", ended_at: null });
|
|
336
|
+
expect(mergeRun(entry, ci({ status: "waiting", ended_at: null, jobs: [{ id: "6782", name: "pr-apply", needs: [], status: "waiting", steps: [] }] })).id).toBe("6782");
|
|
337
|
+
expect(liveRun([ci({ id: "b" }), ci({ id: "a" })]).id).toBe("b");
|
|
338
|
+
});
|
|
339
|
+
});
|
package/web/kiosk-source.js
CHANGED
|
@@ -41,3 +41,26 @@ export function pageSource(doc) {
|
|
|
41
41
|
const s = m ? m.getAttribute("content") : null;
|
|
42
42
|
return s === "chant-demo" ? s : null;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* behold#815: the runs pane's reads when serve was given `--ci-report-url`:
|
|
47
|
+
* chant's run index and each run's events (src/ci-run-index.ts), in place of
|
|
48
|
+
* the forge's runs. Only the runs pane reads them; the demo's cycle and its
|
|
49
|
+
* approval panel read as before. `from` is the pane's line under "Runs".
|
|
50
|
+
*/
|
|
51
|
+
export const CI_RUNS_READS = {
|
|
52
|
+
runs: "/api/chant/ci/runs",
|
|
53
|
+
run: (id) => `/api/chant/ci/runs/${encodeURIComponent(id)}`,
|
|
54
|
+
from: "From chant's run index, newest first.",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** The runs the page was served for (`<meta name="kiosk-runs">`): `chant-ci`, or null for the source's own. */
|
|
58
|
+
export function pageRuns(doc) {
|
|
59
|
+
const m = doc && doc.querySelector ? doc.querySelector('meta[name="kiosk-runs"]') : null;
|
|
60
|
+
return m && m.getAttribute("content") === "chant-ci" ? "chant-ci" : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The runs pane's reads: chant's run index for `chant-ci`, else the source's (`reads.runs`, `reads.run`). */
|
|
64
|
+
export function runsReadsFor(runs, reads) {
|
|
65
|
+
return runs === "chant-ci" ? CI_RUNS_READS : { runs: reads.runs, run: reads.run };
|
|
66
|
+
}
|
package/web/kiosk-source.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { CHANT_DEMO_READS, TERRAGUCCI_READS, pageSource, readsFor } from "./kiosk-source.js";
|
|
2
|
+
import { CHANT_DEMO_READS, CI_RUNS_READS, TERRAGUCCI_READS, pageRuns, pageSource, readsFor, runsReadsFor } from "./kiosk-source.js";
|
|
3
3
|
import { startMetrics } from "./kiosk-metrics.js";
|
|
4
4
|
|
|
5
5
|
// behold#752: a kiosk page reads terragucci's loop unless the server tells it chant's demo is its source.
|
|
@@ -37,3 +37,21 @@ describe("where a kiosk page reads its demo (behold#752)", () => {
|
|
|
37
37
|
expect(await asked(CHANT_DEMO_READS)).toEqual(["/api/chant/demo", "/api/chant/demo/cycle"]);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
// behold#815: with --ci-report-url, the runs pane alone reads chant's run index.
|
|
42
|
+
const runsDoc = (content) => ({ querySelector: (q) => (q === 'meta[name="kiosk-runs"]' && content !== null ? { getAttribute: () => content } : null) });
|
|
43
|
+
|
|
44
|
+
describe("where the runs pane reads its runs (behold#815)", () => {
|
|
45
|
+
it("a page without the tag reads the source's runs, the forge's or chant's demo's", () => {
|
|
46
|
+
expect(pageRuns(runsDoc(null))).toBeNull();
|
|
47
|
+
expect(runsReadsFor(null, TERRAGUCCI_READS)).toEqual({ runs: "/api/terragucci/runs", run: TERRAGUCCI_READS.run });
|
|
48
|
+
expect(runsReadsFor(null, CHANT_DEMO_READS).runs).toBe("/api/chant/demo/runs");
|
|
49
|
+
});
|
|
50
|
+
it("a page told `chant-ci` reads chant's run index, whatever its source, and says so in the sidebar", () => {
|
|
51
|
+
expect(pageRuns(runsDoc("chant-ci"))).toBe("chant-ci");
|
|
52
|
+
for (const reads of [TERRAGUCCI_READS, CHANT_DEMO_READS]) expect(runsReadsFor("chant-ci", reads)).toBe(CI_RUNS_READS);
|
|
53
|
+
expect([CI_RUNS_READS.runs, CI_RUNS_READS.run("chant-1792376662004"), CI_RUNS_READS.run("a/b")]).toEqual(["/api/chant/ci/runs", "/api/chant/ci/runs/chant-1792376662004", "/api/chant/ci/runs/a%2Fb"]);
|
|
54
|
+
expect(CI_RUNS_READS.from).toBe("From chant's run index, newest first.");
|
|
55
|
+
expect(pageRuns(runsDoc("forge"))).toBeNull();
|
|
56
|
+
});
|
|
57
|
+
});
|
package/web/kiosk-track.js
CHANGED
|
@@ -167,7 +167,9 @@ export function trackModel(track, { demo, pulls = [], since = null, now = Date.n
|
|
|
167
167
|
};
|
|
168
168
|
}),
|
|
169
169
|
}));
|
|
170
|
-
|
|
170
|
+
// A chapter's title replays it only once it is over: on the live cycle's current chapter the pill read as a label
|
|
171
|
+
// saying the demo was a replay, and a tap on it left live.
|
|
172
|
+
for (const c of chapters) c.seek = (replay || c.state === "done") && c.segments.length ? c.segments[0].seek : null;
|
|
171
173
|
const nowLine = nowWords({ demo, segment: current, expected, elapsed, overrun, waves, jobs, now, fix: track.byStory ? pulls.indexOf(demo.pull) > 0 : at.chapter > 0 });
|
|
172
174
|
return { chapters, at, elapsed, expected, overrun, now: nowLine, here: hereWords(chapters, at) };
|
|
173
175
|
}
|
|
@@ -234,7 +236,8 @@ export function nowWords({ demo, segment, expected = 0, elapsed = 0, overrun = f
|
|
|
234
236
|
case "fix opened":
|
|
235
237
|
return say("The pipeline is starting the plan job", "the pipeline to start the plan");
|
|
236
238
|
case "planned":
|
|
237
|
-
|
|
239
|
+
// behold#784: no review is asked unless a wave would destroy something; the driver's line says what comes next.
|
|
240
|
+
return say(fix ? "The fix is planned" : "The plan is in");
|
|
238
241
|
case "review":
|
|
239
242
|
return say("Waiting for the reviewer", "the reviewer to approve the plan");
|
|
240
243
|
case "merged":
|
|
@@ -328,12 +331,13 @@ body.k-watch #k-track { position: fixed; z-index: 7; left: 5px; right: 5px; }
|
|
|
328
331
|
#k-track .kt-chapter-title { font-size: 0.88em; }
|
|
329
332
|
#k-track .kt-segs .kt-label { display: none; }
|
|
330
333
|
#k-track .kt-seg { height: 0.8em; min-width: 0.6em !important; }
|
|
331
|
-
|
|
332
|
-
#k-track .kt-now { font-size:
|
|
334
|
+
/* A phone leads with one line of what is happening now: the chapter in the rail already says which step. */
|
|
335
|
+
#k-track .kt-now { font-size: 1em; font-weight: 600; white-space: normal; margin-top: 0.3em; }
|
|
336
|
+
#k-track .kt-now::before { content: "Now: "; color: var(--pending); }
|
|
333
337
|
/* behold#787: a phone's segments are too thin to press; a past chapter's title is the 44px target. */
|
|
334
338
|
#k-track button.kt-seg.kt-seek { pointer-events: none; }
|
|
335
339
|
#k-track button.kt-chapter-title.kt-seek { align-self: flex-start; max-width: 100%; min-height: 44px; padding: 0 0.8em; border: 1.5px solid color-mix(in srgb, var(--pending) 70%, transparent); border-radius: 999px; text-decoration: none; }
|
|
336
|
-
#k-track button.kt-chapter-title.kt-seek::after { content: " ·
|
|
340
|
+
#k-track button.kt-chapter-title.kt-seek::after { content: " · watch again"; color: var(--pending); font-weight: 500; }
|
|
337
341
|
}
|
|
338
342
|
`;
|
|
339
343
|
|
package/web/kiosk-track.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { FAILURE_LEAD_MS, FILL_CAP, applyJobs, cycleTrack, failureAt, hereWords, seekMs, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
2
|
+
import { FAILURE_LEAD_MS, FILL_CAP, applyJobs, cycleTrack, failureAt, hereWords, nowWords, seekMs, trackModel, waitingSpec } from "./kiosk-track.js";
|
|
3
3
|
|
|
4
4
|
// behold#631: chant-fanout's last finished cycle as cycles/chant-fanout/latest.json had it (cycle 499):
|
|
5
5
|
// fifteen steps, two pull requests, from the change's open to the reset.
|
|
@@ -202,7 +202,8 @@ describe("a past step replays from its start (behold#787)", () => {
|
|
|
202
202
|
it("gives each segment already past its first step's time, and each chapter its first segment's", () => {
|
|
203
203
|
const m = trackModel(track, { demo: { step: "planned", pull: 13, chapter: chapters[2] }, pulls: [12, 13], since: now, now });
|
|
204
204
|
expect(m.chapters[0].segments.map((g) => g.seek)).toEqual([T("18:49"), T("19:01"), T("19:14"), T("19:27"), T("19:30")]);
|
|
205
|
-
|
|
205
|
+
// The current chapter's title doesn't replay it: only a chapter that is over does.
|
|
206
|
+
expect(m.chapters.map((c) => c.seek)).toEqual([T("18:49"), T("19:49"), null, null]);
|
|
206
207
|
// The current step and those ahead have no seek in the live cycle.
|
|
207
208
|
expect(m.chapters[2].segments.map((g) => g.seek)).toEqual([T("20:10"), null, null, null, null]);
|
|
208
209
|
});
|
|
@@ -229,3 +230,12 @@ describe("a past step replays from its start (behold#787)", () => {
|
|
|
229
230
|
expect(failureAt(null)).toBeNull();
|
|
230
231
|
});
|
|
231
232
|
});
|
|
233
|
+
|
|
234
|
+
describe("nowWords", () => {
|
|
235
|
+
// behold#784: a plan asks no review unless a wave would destroy something, so the planned line doesn't promise one.
|
|
236
|
+
it("says the plan is in, and nothing about a review", () => {
|
|
237
|
+
const demo = { label: "Fan out." };
|
|
238
|
+
expect(nowWords({ demo, segment: { label: "planned" } }).text).toBe("The plan is in");
|
|
239
|
+
expect(nowWords({ demo, segment: { label: "planned" }, fix: true }).text).toBe("The fix is planned");
|
|
240
|
+
});
|
|
241
|
+
});
|
package/web/kiosk.html
CHANGED
|
@@ -115,6 +115,7 @@
|
|
|
115
115
|
.r-head-title .r-icon { margin: 0; }
|
|
116
116
|
.r-head-sub { color: var(--fg); font-size: 0.88em; margin-top: 0.15em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
117
117
|
.r-head-meta { color: var(--muted); font-size: 0.82em; }
|
|
118
|
+
.r-head-meta .r-origin { color: inherit; }
|
|
118
119
|
/* behold#725: a section heading (Jobs, Features, Steps) keeps a line of its own: the pane is a flex column, and nothing in it but the steps may shrink. */
|
|
119
120
|
.r-label { display: block; flex: none; position: static; font: 600 0.8em/1.3 var(--font-ui); color: var(--muted); padding: var(--s3) var(--s4) var(--s1); }
|
|
120
121
|
#runs-main > :not(.r-steps) { flex: none; }
|
|
@@ -488,7 +489,22 @@
|
|
|
488
489
|
.k-modes { height: auto; }
|
|
489
490
|
.k-theme-arrow { min-width: 44px; }
|
|
490
491
|
.k-w-held { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); flex: 1 1 100%; }
|
|
491
|
-
.k-w-held button.k-w-resume { min-height: 44px; padding: 0 var(--s5); border: 2px solid var(--pending); border-radius: 999px; background: color-mix(in srgb, var(--pending) 18%, transparent); text-decoration: none; font-weight: 600; }
|
|
492
|
+
.k-w-held button.k-w-resume, #k-held-over button.k-w-resume { min-height: 44px; padding: 0 var(--s5); border: 2px solid var(--pending); border-radius: 999px; background: color-mix(in srgb, var(--pending) 18%, transparent); text-decoration: none; font-weight: 600; }
|
|
493
|
+
body.k-watch #k-held-over:not([hidden]) { position: fixed; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); left: 12px; right: 12px; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); padding: var(--s2) var(--s3); border: 2px solid var(--pending); border-radius: 10px; background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: 0 2px 10px rgb(0 0 0 / 0.25); color: var(--fg); font-weight: 600; }
|
|
494
|
+
}
|
|
495
|
+
#k-held-over { display: none; }
|
|
496
|
+
.k-w-point { display: none; }
|
|
497
|
+
/* A phone's Watch says what it shows first and once: the point, the step track, one "Now:" line, the graph.
|
|
498
|
+
The intro, the waiting box and the caption's copy of the point repeat it; the facts under the graph fold. */
|
|
499
|
+
@media (max-width: 600px) {
|
|
500
|
+
body.k-watch .k-w-point { display: block; margin: 0.2em 0 0.1em; font: 700 1.2em/1.25 var(--font-ui); color: var(--fg); }
|
|
501
|
+
body.k-watch .k-w-intro, body.k-watch .k-cap-point, body.k-watch .k-cap-next, body.k-watch .k-cap-step { display: none; }
|
|
502
|
+
body.k-watch .eh-modal-wrap:has(> .eh-modal-waiting) { display: none; }
|
|
503
|
+
body.k-watch #k-change > .k-change-label, body.k-watch #k-waves > .k-wl-head { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: var(--s3); }
|
|
504
|
+
body.k-watch #k-change:not(.k-open) > :not(.k-change-label), body.k-watch #k-waves:not(.k-open) > :not(.k-wl-head) { display: none; }
|
|
505
|
+
body.k-watch #k-change .k-change-label::after, body.k-watch #k-waves .k-wl-title::after { content: " · show"; color: var(--pending); font-weight: 500; }
|
|
506
|
+
body.k-watch #k-change.k-open .k-change-label::after, body.k-watch #k-waves.k-open .k-wl-title::after { content: " · hide"; }
|
|
507
|
+
body.k-watch #k-waves:not(.k-open) .k-wl-hint { display: none; }
|
|
492
508
|
}
|
|
493
509
|
/* The caption: the title, what changes, the step. One of the two beats leads. */
|
|
494
510
|
#k-caption { position: absolute; left: 5px; right: 5px; bottom: 5px; display: grid; grid-template-rows: auto calc(2 * 1.25em * 1.3) calc(2 * 1.25em * 1.3); gap: 0.25em; padding: var(--s3) 1.4em var(--s4);
|
|
@@ -741,6 +757,8 @@
|
|
|
741
757
|
<div id="views" hidden></div>
|
|
742
758
|
<section id="k-read" aria-label="How to read this" hidden></section>
|
|
743
759
|
<iframe id="view" title="behold's view of the change"></iframe>
|
|
760
|
+
<!-- A paused Watch says so at the foot of the screen: on a phone the header that also says it is scrolled away. -->
|
|
761
|
+
<div id="k-held-over" role="status" hidden></div>
|
|
744
762
|
</section>
|
|
745
763
|
<!-- behold#571: Watch mode's overlays, over the graph; web/kiosk-watch.js says what each holds and where it goes. -->
|
|
746
764
|
<div id="k-watch">
|
|
@@ -765,9 +783,14 @@
|
|
|
765
783
|
<div id="eh-modals"></div>
|
|
766
784
|
<script type="module">
|
|
767
785
|
import { initTheme, KIOSK_THEME, getThemeName, onThemeChange, stepTheme } from "/theme.js";
|
|
786
|
+
// A phone's facts under the graph fold to their heads; a tap on a head opens or folds them (the class outlives a redraw).
|
|
787
|
+
document.addEventListener("click", (e) => {
|
|
788
|
+
const head = e.target.closest && e.target.closest("#k-change > .k-change-label, #k-waves > .k-wl-head");
|
|
789
|
+
if (head) head.parentElement.classList.toggle("k-open");
|
|
790
|
+
});
|
|
768
791
|
import { startKiosk } from "/kiosk.js";
|
|
769
792
|
import { pageTool } from "/kiosk-vendor.js";
|
|
770
|
-
import { pageSource, readsFor } from "/kiosk-source.js";
|
|
793
|
+
import { pageRuns, pageSource, readsFor } from "/kiosk-source.js";
|
|
771
794
|
import { installMotion } from "/motion.js";
|
|
772
795
|
initTheme(KIOSK_THEME);
|
|
773
796
|
// behold#725: every looping animation holds while the tab is hidden.
|
|
@@ -788,7 +811,7 @@
|
|
|
788
811
|
eh: { switchHost: document.getElementById("k-tools"), trailHost: document.getElementById("eh-trail"), tipsHost: document.getElementById("eh-tips"), modalHost: document.getElementById("eh-modals") },
|
|
789
812
|
watch: { layer: document.getElementById("k-watch"), caption: document.getElementById("k-caption"), change: document.getElementById("k-change"), waves: document.getElementById("k-waves"), callout: document.getElementById("k-callout"), drawer: document.getElementById("k-drawer"), badges: document.getElementById("k-badges"), result: document.getElementById("k-result") },
|
|
790
813
|
},
|
|
791
|
-
{ tool: pageTool(document), source: pageSource(document) },
|
|
814
|
+
{ tool: pageTool(document), source: pageSource(document), runs: pageRuns(document) },
|
|
792
815
|
);
|
|
793
816
|
// behold#571: the repo's numbers from Prometheus, a pane of its own in Inspect (web/kiosk-metrics.js), and Watch's badges and delivery line.
|
|
794
817
|
import("/kiosk-metrics.js").then((m) => m.startMetrics(document.getElementById("k-metrics"), { tool: pageTool(document), reads: readsFor(pageSource(document)), onModel: (model) => kiosk.setMetrics(model) }));
|
package/web/kiosk.js
CHANGED
|
@@ -34,7 +34,7 @@ import { creditLines, filterIndex, keepRun, kioskVendorOf, liveEstimate, liveFor
|
|
|
34
34
|
import { repoParam, repoUrl, stepCheckout } from "./kiosk-repo.js";
|
|
35
35
|
import { startKioskCarve } from "./kiosk-carve.js";
|
|
36
36
|
import { drawWaveList, waveListKey } from "./kiosk-wave-list.js";
|
|
37
|
-
import { readsFor } from "./kiosk-source.js";
|
|
37
|
+
import { readsFor, runsReadsFor } from "./kiosk-source.js";
|
|
38
38
|
import { STATE_WORDS, changingRoots, costLine, pinsCommit, planFitsPin, pullPin, readEdges, rootsCount, totalsLine, waveRows, blastRows } from "./terragucci-change.js";
|
|
39
39
|
|
|
40
40
|
/** The scenarios terragucci#1014 numbers. An id not here is shown by the title demo.json carries. */
|
|
@@ -1103,6 +1103,21 @@ export const RESUME_WORDS = "Resume now";
|
|
|
1103
1103
|
/** behold#779: how long a tap on a touch screen holds Watch's shot (a click holds it PICK_HOLD_MS). */
|
|
1104
1104
|
export const TAP_HOLD_MS = 20_000;
|
|
1105
1105
|
|
|
1106
|
+
/**
|
|
1107
|
+
* A paused Watch, said at the foot of the screen with its resume (kiosk.html shows it on a touch screen only): on a
|
|
1108
|
+
* phone the header that also says it is scrolled away by the time a tap on the graph paused it.
|
|
1109
|
+
*/
|
|
1110
|
+
function drawHeldOver(doc, s) {
|
|
1111
|
+
const over = doc && doc.getElementById ? doc.getElementById("k-held-over") : null;
|
|
1112
|
+
if (!over) return;
|
|
1113
|
+
over.hidden = !s.watchHeld;
|
|
1114
|
+
if (!s.watchHeld) return void over.replaceChildren();
|
|
1115
|
+
const b = el("button", "k-w-resume", RESUME_WORDS);
|
|
1116
|
+
b.type = "button";
|
|
1117
|
+
b.addEventListener("click", () => s.followSteps && s.followSteps());
|
|
1118
|
+
over.replaceChildren(el("span", "k-held-words", heldWords(s.watchHeld.secs, true)), b);
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1106
1121
|
/** Watch's header: the scenario's place and the strip on the left, the delivery numbers on the right. */
|
|
1107
1122
|
function drawWatchHead(bar, s, now) {
|
|
1108
1123
|
const demo = s.demo.demo;
|
|
@@ -1129,6 +1144,8 @@ function drawWatchHead(bar, s, now) {
|
|
|
1129
1144
|
if (s.mode === "replay" && s.replay && s.replay.asked) bar.appendChild(askedLine(s));
|
|
1130
1145
|
const intro = introFor(s);
|
|
1131
1146
|
if (intro) bar.appendChild(el("p", "k-w-intro", intro));
|
|
1147
|
+
// A phone leads with what the demo shows (kiosk.html shows it there only); the caption's copy of it goes.
|
|
1148
|
+
if (demo && demo.title) bar.appendChild(el("p", "k-w-point", demo.title));
|
|
1132
1149
|
const strip = el("ol", "k-strip");
|
|
1133
1150
|
// behold#631: a chant pull request's wait for its approval comes before its merge. Without a stop of its own on the
|
|
1134
1151
|
// strip it shows as "planned", for the fix's pull request as for the first.
|
|
@@ -1144,6 +1161,7 @@ function drawWatchHead(bar, s, now) {
|
|
|
1144
1161
|
p.appendChild(b);
|
|
1145
1162
|
bar.appendChild(p);
|
|
1146
1163
|
}
|
|
1164
|
+
drawHeldOver(bar.ownerDocument, s);
|
|
1147
1165
|
const dora = doraLine(s.metrics);
|
|
1148
1166
|
if (dora) {
|
|
1149
1167
|
const p = el("p", "k-w-dora", dora);
|
|
@@ -1600,9 +1618,11 @@ export const CHANT_SIDE_ROOM = 520;
|
|
|
1600
1618
|
* countdown. When the roots the step is about change, move the framed view
|
|
1601
1619
|
* with a `behold:view` message; the frame takes them only from this origin.
|
|
1602
1620
|
*/
|
|
1603
|
-
export function startKiosk({ bar, frame, side, main, views, read = null, tools = null, watch = null, eh = null }, { fetchJson = defaultFetch, now = () => new Date(), origin = location.origin, tool = null, source = null } = {}) {
|
|
1621
|
+
export function startKiosk({ bar, frame, side, main, views, read = null, tools = null, watch = null, eh = null }, { fetchJson = defaultFetch, now = () => new Date(), origin = location.origin, tool = null, source = null, runs = null } = {}) {
|
|
1604
1622
|
// behold#752: terragucci's loop, or chant's fan-out demo from its own records (web/kiosk-source.js).
|
|
1605
1623
|
const reads = readsFor(source);
|
|
1624
|
+
// behold#815: the runs pane's own reads, chant's run index when serve has --ci-report-url.
|
|
1625
|
+
const runsReads = runsReadsFor(runs, reads);
|
|
1606
1626
|
const s = { source: reads.source, demo: null, answer: null, progress: null, components: false, pick: null, view: "resources", roots: [], waves: [], light: false, hover: null, frameHover: null, held: null };
|
|
1607
1627
|
// behold#571: Watch or Inspect, the viewer's pick kept in their browser; Watch until they pick Inspect.
|
|
1608
1628
|
const shelf = typeof localStorage !== "undefined" ? (() => { try { return localStorage; } catch { return null; } })() : null;
|
|
@@ -2813,11 +2833,13 @@ export function startKiosk({ bar, frame, side, main, views, read = null, tools =
|
|
|
2813
2833
|
tools: () => s.tools || [],
|
|
2814
2834
|
rootTools: () => s.rootTools || {},
|
|
2815
2835
|
light: () => s.light,
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2836
|
+
// behold#815: chant's run index is the served repo's runs alone and their history, so the pane reads it whole,
|
|
2837
|
+
// on a tool's page and in a replay alike.
|
|
2838
|
+
source: runsReads.from ? () => null : runsSource,
|
|
2839
|
+
filter: vendor && !runsReads.from ? (index) => filterIndex(index, { tool, repo: s.repo }) : (index) => index,
|
|
2840
|
+
replay: () => !runsReads.from && s.mode === "replay",
|
|
2819
2841
|
hideLine: vendor ? (line) => namesOther(line, tool) : null,
|
|
2820
|
-
urls:
|
|
2842
|
+
urls: runsReads,
|
|
2821
2843
|
},
|
|
2822
2844
|
);
|
|
2823
2845
|
}
|
package/web/local-run.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// behold#685: "Run this job locally". behold starts `chant ci run plan
|
|
2
|
+
// --local --events-json` at a commit (POST /api/chant/ci/local), and draws the
|
|
3
|
+
// run from its run-event/v1 lines in the runs pane's run view
|
|
4
|
+
// (web/kiosk-runs.js renderRun), next to CI's run of the same job at the same
|
|
5
|
+
// commit from chant's run index when serve has --ci-report-url. Plan only:
|
|
6
|
+
// apply is never offered here (src/ci-local-run.ts APPLY_REFUSAL). The tab is
|
|
7
|
+
// never drawn in a public view, an embed, a static export or a guarded repo.
|
|
8
|
+
|
|
9
|
+
import { renderRun, STATUS_WORDS } from "./kiosk-runs.js";
|
|
10
|
+
|
|
11
|
+
/** The tab's first line. */
|
|
12
|
+
export const LOCAL_LEGEND =
|
|
13
|
+
"Runs a CI job on this machine with chant ci run --local: a fresh worktree of the commit, no push, no commit status, nothing under the report URL. chant keeps the run's record on the local chant/lifecycle.";
|
|
14
|
+
|
|
15
|
+
const sha8 = (s) => (s ? String(s).slice(0, 8) : "");
|
|
16
|
+
|
|
17
|
+
/** What the tab offers, from GET /api/chant/ci/local's `offer`. */
|
|
18
|
+
export function offerView(answer) {
|
|
19
|
+
const offer = (answer && answer.offer) || null;
|
|
20
|
+
if (!offer) return { can: false, refusal: answer && answer.error ? answer.error : "behold did not say what it offers here", remedy: "", apply: null, env: "", members: [], ciIndex: false };
|
|
21
|
+
return {
|
|
22
|
+
can: (offer.jobs || []).includes("plan"),
|
|
23
|
+
refusal: offer.refusal ? offer.refusal.error : null,
|
|
24
|
+
remedy: offer.refusal && offer.refusal.remedy ? offer.refusal.remedy : "",
|
|
25
|
+
apply: offer.apply || null,
|
|
26
|
+
env: offer.env || "",
|
|
27
|
+
members: offer.members || [],
|
|
28
|
+
ciIndex: !!offer.ciIndex,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** CI's plan jobs from chant's run index (GET /api/chant/ci/runs), each a job a local run can repeat. */
|
|
33
|
+
export function ciPlanRows(index) {
|
|
34
|
+
const runs = index && index.doc && Array.isArray(index.doc.runs) ? index.doc.runs : [];
|
|
35
|
+
return runs
|
|
36
|
+
.filter((r) => r.job === "plan" && r.pull !== null && r.pull !== undefined)
|
|
37
|
+
.map((r) => ({
|
|
38
|
+
id: r.id,
|
|
39
|
+
commit: r.commit,
|
|
40
|
+
pr: r.pull,
|
|
41
|
+
member: r.member || null,
|
|
42
|
+
text: `plan of #${r.pull} at ${sha8(r.commit)}${r.member ? ` · ${r.member}` : ""} · ${STATUS_WORDS[r.status] || r.status}`,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The body POST /api/chant/ci/local takes, from the form's values; null with the reason when one is missing. */
|
|
47
|
+
export function askBody({ commit, pr, env, base, member, forge }) {
|
|
48
|
+
const c = String(commit || "").trim();
|
|
49
|
+
const p = String(pr || "").trim();
|
|
50
|
+
if (!/^[0-9a-f]{7,64}$/.test(c)) return { error: "a commit's sha, 7 hex digits or more" };
|
|
51
|
+
if (!/^[1-9][0-9]*$/.test(p)) return { error: "the pull request's number: chant's plan job reads it" };
|
|
52
|
+
const body = { job: "plan", commit: c, pr: Number(p) };
|
|
53
|
+
if (String(env || "").trim()) body.env = String(env).trim();
|
|
54
|
+
if (String(base || "").trim()) body.base = String(base).trim();
|
|
55
|
+
if (member) body.member = member;
|
|
56
|
+
if (forge) body.forge = forge;
|
|
57
|
+
return { body };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The two halves' headings: where each run ran. */
|
|
61
|
+
export function compareHeads(answer) {
|
|
62
|
+
const doc = answer && answer.doc;
|
|
63
|
+
const local = doc ? `This machine · chant ci run plan --local · base ${sha8(doc.base)} · ${doc.env}${doc.where && doc.where.forge && doc.where.forge !== "local" ? ` · chant said it ran on ${doc.where.forge}` : ""}` : "This machine";
|
|
64
|
+
return { local, ci: "CI · from chant's run index" };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const el = (tag, cls, text) => {
|
|
68
|
+
const n = document.createElement(tag);
|
|
69
|
+
if (cls) n.className = cls;
|
|
70
|
+
if (text !== undefined) n.textContent = text;
|
|
71
|
+
return n;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Draw the tab into `host`. `s` holds `offer` (GET /api/chant/ci/local),
|
|
76
|
+
* `index` (GET /api/chant/ci/runs, or null), `answer` (GET
|
|
77
|
+
* /api/chant/ci/local/:id) and the form's values; `ui.start(body)` posts,
|
|
78
|
+
* `ui.pick(id)` opens a run, `ui.redraw()` draws again.
|
|
79
|
+
*/
|
|
80
|
+
export function renderLocalRuns(host, s, ui) {
|
|
81
|
+
host.replaceChildren();
|
|
82
|
+
const v = offerView(s.offer);
|
|
83
|
+
host.appendChild(el("div", "tg-legend", LOCAL_LEGEND));
|
|
84
|
+
if (v.refusal) {
|
|
85
|
+
const r = el("div", "tg-refusal", v.refusal);
|
|
86
|
+
if (v.remedy) r.title = v.remedy;
|
|
87
|
+
host.appendChild(r);
|
|
88
|
+
}
|
|
89
|
+
if (v.apply) host.appendChild(el("div", "tg-legend", v.apply));
|
|
90
|
+
|
|
91
|
+
// The form: a commit and its pull request, and what CI ran it with.
|
|
92
|
+
const form = el("div", "lr-form");
|
|
93
|
+
const field = (name, label, value, placeholder) => {
|
|
94
|
+
const l = el("label", "lr-field", label);
|
|
95
|
+
const i = el("input");
|
|
96
|
+
i.name = name;
|
|
97
|
+
i.value = value || "";
|
|
98
|
+
if (placeholder) i.placeholder = placeholder;
|
|
99
|
+
i.spellcheck = false;
|
|
100
|
+
i.addEventListener("input", () => (s.form[name] = i.value));
|
|
101
|
+
l.appendChild(i);
|
|
102
|
+
form.appendChild(l);
|
|
103
|
+
};
|
|
104
|
+
s.form = s.form || {};
|
|
105
|
+
if (s.form.env === undefined) s.form.env = v.env;
|
|
106
|
+
field("commit", "commit", s.form.commit, "sha");
|
|
107
|
+
field("pr", "pull request", s.form.pr, "#");
|
|
108
|
+
field("env", "env", s.form.env, "the pipeline's env");
|
|
109
|
+
field("base", "base", s.form.base, "where it leaves the trunk");
|
|
110
|
+
const pick = (name, label, options) => {
|
|
111
|
+
const l = el("label", "lr-field", label);
|
|
112
|
+
const sel = el("select");
|
|
113
|
+
sel.name = name;
|
|
114
|
+
for (const [value, text] of options) {
|
|
115
|
+
const o = el("option", null, text);
|
|
116
|
+
o.value = value;
|
|
117
|
+
if ((s.form[name] || "") === value) o.selected = true;
|
|
118
|
+
sel.appendChild(o);
|
|
119
|
+
}
|
|
120
|
+
sel.addEventListener("change", () => (s.form[name] = sel.value));
|
|
121
|
+
l.appendChild(sel);
|
|
122
|
+
form.appendChild(l);
|
|
123
|
+
};
|
|
124
|
+
pick("member", "member", [["", "the workspace"], ...v.members.map((m) => [m, m])]);
|
|
125
|
+
pick("forge", "forge", [["", "detect"], ["github", "github"], ["gitlab", "gitlab"], ["forgejo", "forgejo"]]);
|
|
126
|
+
const go = el("button", "lr-go", "Run plan locally");
|
|
127
|
+
go.type = "button";
|
|
128
|
+
go.disabled = !v.can || !!s.starting;
|
|
129
|
+
go.title = v.can ? "Start chant ci run plan --local at this commit." : v.refusal || "";
|
|
130
|
+
go.addEventListener("click", () => {
|
|
131
|
+
const a = askBody(s.form);
|
|
132
|
+
if (a.error) {
|
|
133
|
+
s.formError = a.error;
|
|
134
|
+
ui.redraw();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
ui.start(a.body);
|
|
138
|
+
});
|
|
139
|
+
form.appendChild(go);
|
|
140
|
+
host.appendChild(form);
|
|
141
|
+
if (s.formError) host.appendChild(el("div", "tg-refusal", s.formError));
|
|
142
|
+
|
|
143
|
+
// CI's plan jobs, each one click from running here.
|
|
144
|
+
if (v.ciIndex) {
|
|
145
|
+
host.appendChild(el("h3", null, "CI's plan jobs"));
|
|
146
|
+
const rows = ciPlanRows(s.index);
|
|
147
|
+
if (!s.index) host.appendChild(el("div", "tg-legend", "reading chant's run index"));
|
|
148
|
+
else if (s.index.error || s.index.absent) host.appendChild(el("div", "tg-legend", s.index.error || s.index.absent));
|
|
149
|
+
else if (!rows.length) host.appendChild(el("div", "tg-legend", "chant's run index lists no plan job of a pull request"));
|
|
150
|
+
for (const r of rows) {
|
|
151
|
+
const row = el("div", "lr-ci-row");
|
|
152
|
+
row.appendChild(el("span", "lr-ci-text", r.text));
|
|
153
|
+
const b = el("button", "lr-again", "Run this job locally");
|
|
154
|
+
b.type = "button";
|
|
155
|
+
b.disabled = !v.can || !!s.starting;
|
|
156
|
+
b.title = v.can ? `chant ci run plan --local --commit ${r.commit} --pr ${r.pr}${r.member ? ` in ${r.member}` : ""}` : v.refusal || "";
|
|
157
|
+
b.addEventListener("click", () => {
|
|
158
|
+
Object.assign(s.form, { commit: r.commit, pr: String(r.pr), member: r.member || "", base: "" });
|
|
159
|
+
const a = askBody(s.form);
|
|
160
|
+
if (a.body) ui.start(a.body);
|
|
161
|
+
});
|
|
162
|
+
row.appendChild(b);
|
|
163
|
+
host.appendChild(row);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// The runs behold started, newest first.
|
|
168
|
+
const runs = (s.offer && s.offer.runs) || [];
|
|
169
|
+
if (runs.length) {
|
|
170
|
+
host.appendChild(el("h3", null, "run on this machine"));
|
|
171
|
+
for (const r of runs) {
|
|
172
|
+
const row = el("div", `lr-run${s.selected === r.id ? " lr-selected" : ""}`, `${sha8(r.commit)} · #${r.pull}${r.member ? ` · ${r.member}` : ""} · ${STATUS_WORDS[r.status] || r.status}`);
|
|
173
|
+
row.title = r.title;
|
|
174
|
+
row.tabIndex = 0;
|
|
175
|
+
row.addEventListener("click", () => ui.pick(r.id));
|
|
176
|
+
host.appendChild(row);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (!s.selected) return;
|
|
180
|
+
|
|
181
|
+
// The run beside CI's run of the same job at the same commit.
|
|
182
|
+
const heads = compareHeads(s.answer);
|
|
183
|
+
const box = el("div", "lr-compare");
|
|
184
|
+
const half = (title, answer, side) => {
|
|
185
|
+
const col = el("div", "lr-half");
|
|
186
|
+
col.appendChild(el("div", "lr-half-head", title));
|
|
187
|
+
const pane = el("div", "lr-run-view");
|
|
188
|
+
s.ui = s.ui || {};
|
|
189
|
+
const u = (s.ui[side] = s.ui[side] || { job: null, open: null, setup: null });
|
|
190
|
+
renderRun(pane, answer, u, {
|
|
191
|
+
pickJob: (name) => {
|
|
192
|
+
u.job = name;
|
|
193
|
+
u.open = null;
|
|
194
|
+
ui.redraw();
|
|
195
|
+
},
|
|
196
|
+
toggleStep: (job, i) => {
|
|
197
|
+
u.job = job;
|
|
198
|
+
u.open = i;
|
|
199
|
+
ui.redraw();
|
|
200
|
+
},
|
|
201
|
+
toggleSetup: (key) => {
|
|
202
|
+
u.setup = u.setup === key ? null : key;
|
|
203
|
+
ui.redraw();
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
col.appendChild(pane);
|
|
207
|
+
box.appendChild(col);
|
|
208
|
+
};
|
|
209
|
+
half(heads.local, s.answer ? { doc: s.answer.doc, error: s.answer.error, absent: s.answer.absent } : null, "local");
|
|
210
|
+
half(heads.ci, s.answer ? s.answer.ci || { absent: "no CI run to show" } : null, "ci");
|
|
211
|
+
host.appendChild(box);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Mount the tab's reads: the offer and the runs on open, chant's run index
|
|
216
|
+
* when serve names one, and the selected run again whenever behold says it
|
|
217
|
+
* moved (the SSE `local-run` event). `fetchJson(url, init)` answers parsed JSON.
|
|
218
|
+
*/
|
|
219
|
+
export function startLocalRuns(host, { fetchJson, events, toast = () => {} }) {
|
|
220
|
+
const s = { offer: null, index: null, answer: null, selected: null, form: {}, starting: false };
|
|
221
|
+
const redraw = () => renderLocalRuns(host, s, ui);
|
|
222
|
+
const readOffer = async () => {
|
|
223
|
+
s.offer = await fetchJson("/api/chant/ci/local").catch((e) => ({ error: String(e) }));
|
|
224
|
+
if (s.offer && s.offer.offer && s.offer.offer.ciIndex && !s.index) s.index = await fetchJson("/api/chant/ci/runs").catch((e) => ({ error: String(e) }));
|
|
225
|
+
redraw();
|
|
226
|
+
};
|
|
227
|
+
const readRun = async () => {
|
|
228
|
+
if (!s.selected) return;
|
|
229
|
+
const id = s.selected;
|
|
230
|
+
const a = await fetchJson(`/api/chant/ci/local/${encodeURIComponent(id)}`).catch((e) => ({ error: String(e) }));
|
|
231
|
+
if (s.selected !== id) return;
|
|
232
|
+
s.answer = a;
|
|
233
|
+
redraw();
|
|
234
|
+
};
|
|
235
|
+
const ui = {
|
|
236
|
+
redraw,
|
|
237
|
+
pick: (id) => {
|
|
238
|
+
s.selected = id;
|
|
239
|
+
s.answer = null;
|
|
240
|
+
s.ui = {};
|
|
241
|
+
redraw();
|
|
242
|
+
readRun();
|
|
243
|
+
},
|
|
244
|
+
start: async (body) => {
|
|
245
|
+
s.starting = true;
|
|
246
|
+
s.formError = null;
|
|
247
|
+
redraw();
|
|
248
|
+
const r = await fetchJson("/api/chant/ci/local", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }).catch((e) => ({ error: String(e) }));
|
|
249
|
+
s.starting = false;
|
|
250
|
+
if (r.error) {
|
|
251
|
+
s.formError = r.error;
|
|
252
|
+
toast(`✗ run locally: ${r.error}`, false);
|
|
253
|
+
redraw();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
toast(`▶ ${r.command}`, true);
|
|
257
|
+
await readOffer();
|
|
258
|
+
ui.pick(r.id);
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
// One read per burst of lines.
|
|
262
|
+
let pending = null;
|
|
263
|
+
if (events) {
|
|
264
|
+
events.addEventListener("local-run", (e) => {
|
|
265
|
+
if (e.data !== s.selected || pending) return;
|
|
266
|
+
pending = setTimeout(async () => {
|
|
267
|
+
pending = null;
|
|
268
|
+
await readRun();
|
|
269
|
+
const a = s.answer && s.answer.doc;
|
|
270
|
+
if (a && a.status !== "running" && a.status !== "queued") readOffer();
|
|
271
|
+
}, 250);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
readOffer();
|
|
275
|
+
return { reload: readOffer };
|
|
276
|
+
}
|