Split the web console into by-job files, add page tests and a docs-table test, plus docs

AI Assisted
This commit is contained in:
jparkerweb committed 2026-10-18 15:39:24 -07:00
1 parent 699a827cae
commit 3edb4468a8
121 files changed
+25603 -20145

No files matched your search

+12 -41
View File
@@ -24,9 +24,6 @@ import {
noteReplyLines,
staleLaunchFeedback,
REVIEW_REPLY,
SKILL_CATALOG,
START_POSES,
startPose,
STOP_REPLY,
STOP_HANDOFF_REPLY,
threadText,
@@ -38,13 +35,9 @@ import { ACCENTS, CARD_WIDTHS, SOUND_EVENTS, soundKey, soundPrefs } from "../src
import { HELP_TABS, helpTabFor, helpKeyTarget } from "../src/web-console/public/help.js";
import { RED_AT, YELLOW_AT } from "../src/web-console/public/meter.js";
import { REMOTE_FOLD } from "../src/web-console/public/git-board.js";
import {
applyPatch,
readLedger,
SESSION_MAX_AGE_MS,
sweepUploads,
UPLOAD_MAX_AGE_MS,
} from "../src/web-console/lib.mjs";
import { readLedger, SESSION_MAX_AGE_MS, sweepUploads, UPLOAD_MAX_AGE_MS } from "../src/web-console/sessions.mjs";
import { applyPatch } from "../src/web-console/patches.mjs";
import { joinedCss } from "./css-helpers.mjs";
import {
ROOT,
HOME,
@@ -475,8 +468,7 @@ test("the way home follows Stop's turn rules and hides where it has no job", ()
test("the page carries the way home: the triangle, its confirm, and the wiring", () => {
const dir = path.join(ROOT, "src", "web-console", "public");
const html = fs.readFileSync(path.join(dir, "index.html"), "utf8");
const app = fs.readFileSync(path.join(dir, "app.js"), "utf8");
const css = fs.readFileSync(path.join(dir, "app.css"), "utf8");
const css = joinedCss();
assert.ok(html.indexOf('id="btn-home"') < html.indexOf('id="btn-stop"'), "the triangle sits left of Stop session");
assert.match(html, /id="btn-home"[\s\S]{0,200}aria-label="Back to the dashboard"/, "the icon button has a name");
for (const id of ["home-modal", "home-blurb", "home-warn", "home-cancel", "home-go"]) {
@@ -484,8 +476,6 @@ test("the page carries the way home: the triangle, its confirm, and the wiring",
}
assert.ok(html.includes("Leave this workflow?"));
assert.match(css, /\.home-btn path\s*\{\s*fill:\s*var\(--accent\)/, "the triangle is filled with the highlight color");
assert.ok(app.includes('{ i: "__dashboard", type: "dashboard" }'), "the confirm sends __dashboard");
assert.ok(app.includes("stagedPayload()") && app.includes("HOME_REPLY"), "the staged answers ride along with the reply line");
});
test("the way home cannot be mistaken for a brief request", () => {
@@ -523,9 +513,12 @@ test("console-launches.md and the dashboard prompt teach the handoff pick-up and
test("every module the page imports is actually served", async () => {
const dir = path.join(ROOT, "src", "web-console", "public");
const wanted = new Set(["app.js"]);
for (const f of fs.readdirSync(dir).filter((f) => f.endsWith(".js"))) {
// The modules beside app.js and the screens under screens/, each import
// resolved from the file that makes it (a screen's "../state.js" is state.js).
const files = [...fs.readdirSync(dir).filter((f) => f.endsWith(".js")), ...fs.readdirSync(path.join(dir, "screens")).map((f) => `screens/${f}`)];
for (const f of files) {
const src = fs.readFileSync(path.join(dir, f), "utf8");
for (const m of src.matchAll(/^\s*import\b[^"']*["']\.\/([^"']+)["']/gm)) wanted.add(m[1]);
for (const m of src.matchAll(/^\s*import\b[^"']*["'](\.\.?\/[^"']+)["']/gm)) wanted.add(path.posix.join(path.posix.dirname(f), m[1]));
}
const html = fs.readFileSync(path.join(dir, "index.html"), "utf8");
for (const m of html.matchAll(/<link rel="modulepreload" href="\/([^"]+)"/g)) wanted.add(m[1]);
@@ -613,28 +606,6 @@ test("the favicon is served as an SVG with a PNG fallback and the page points at
assert.doesNotMatch(html, /rel="icon"[^>]*href="data:/);
});
// Each skill's starting and waiting screens clone its pose from index.html.
// A pose with no drawing silently falls back to the flight, and a style
// attribute in one would be refused by the CSP, so hold the markup to the list.
test("every skill has a pose drawn in the page, with no inline styles", () => {
const html = fs.readFileSync(path.join(ROOT, "src", "web-console", "public", "index.html"), "utf8");
const tpl = html.match(/<template id="start-poses">([\s\S]*?)<\/template>/);
assert.ok(tpl, "index.html has the start-poses template");
const drawn = [...tpl[1].matchAll(/data-pose="([^"]+)"/g)].map((m) => m[1]);
assert.deepEqual(drawn.sort(), [...START_POSES].sort());
assert.doesNotMatch(tpl[1], /\sstyle=/);
for (const pose of START_POSES) {
assert.ok(SKILL_CATALOG.some((e) => e.workflow === pose), `${pose} is a real workflow`);
assert.equal(startPose(pose), pose);
}
assert.equal(startPose("implement-review"), "implement");
assert.equal(startPose("revise-plan"), "plan");
assert.equal(startPose("init-update"), "init");
for (const e of SKILL_CATALOG) assert.ok(startPose(e.workflow), `${e.workflow} has a pose`);
assert.equal(startPose("dashboard"), null);
assert.equal(startPose(undefined), null);
});
/* ---------------------------------------------------------------- help */
@@ -798,9 +769,9 @@ const helpFacts = () => ({
maxDocMb: MAX_DOC_BYTES / 1024 / 1024,
imageEdge: IMAGE_LONG_EDGE,
cleanupDays: SESSION_MAX_AGE_MS / 86400000,
goneSeconds: sourceConst("public/app.js", /const GONE_AFTER_MS = ([^;]+);/, "GONE_AFTER_MS") / 1000,
adriftMinutes: sourceConst("public/app.js", /const ADRIFT_MS = ([^;]+);/, "ADRIFT_MS") / 60000,
maxUploadMb: sourceConst("public/app.js", /const MAX_UPLOAD_BYTES = ([^;]+);/, "MAX_UPLOAD_BYTES") / 1024 / 1024,
goneSeconds: sourceConst("public/screens/core.js", /const GONE_AFTER_MS = ([^;]+);/, "GONE_AFTER_MS") / 1000,
adriftMinutes: sourceConst("public/selectors.js", /const ADRIFT_MS = ([^;]+);/, "ADRIFT_MS") / 60000,
maxUploadMb: sourceConst("public/uploads.js", /const MAX_UPLOAD_BYTES = ([^;]+);/, "MAX_UPLOAD_BYTES") / 1024 / 1024,
idleMinutes: sourceConst("server.mjs", /const IDLE_MS = Number\(args\[[^\]]+\] \|\| ([^)]+)\)/, "IDLE_MS") / 60000,
maxLifeHours: sourceConst("server.mjs", /const MAX_LIFE_MS = Number\(args\[[^\]]+\] \|\| ([^)]+)\)/, "MAX_LIFE_MS") / 3600000,
closedTabMinutes: sourceConst("server.mjs", /\(IDLE_MS - ([^)]+)\)/, "the closed-tab shutdown") / 60000,