Sync upstream v3.2.6: Loop checkboxes, Notes drag handle, US English replies, app update fetch (v3.2.6)

- Implement's and Review's confirm panes carry a Loop checkbox in place of
  the dashboard's loop cards; loop end-screen buttons show a spinner.
- The stacked Notes panel gets a drag handle.
- Every skill prompt and the console contracts say to reply in US English.
- The desktop app offers Update to latest when the skills are newer, and
  plan2code update refetches an app that install.json does not record.
- Devin Balanced maps to Sonnet 5.5 Medium.
This commit is contained in:
jparkerweb committed 2026-12-04 22:35:28 -08:00
1 parent 9629961f36
commit 658c813428
70 files changed
+818 -242

No files matched your search

+19
View File
@@ -124,6 +124,25 @@ export async function openSession(browser, { t, workflow, payload: first, projec
return s;
}
// Stands a real window in for the desktop app that frames the page, listening
// to what the page tells it (kept in window.__told); the returned function
// replies the way the app's window does.
export async function frameInFakeApp(s) {
await s.page.evaluate(() => {
const frame = document.createElement("iframe");
frame.hidden = true;
document.body.appendChild(frame);
const app = frame.contentWindow;
window.__told = [];
app.postMessage = (message) => window.__told.push(message);
Object.defineProperty(window, "parent", { value: app, configurable: true });
});
return (data) =>
s.page.evaluate((message) => {
window.dispatchEvent(new MessageEvent("message", { source: window.parent, data: message }));
}, data);
}
// Waits until the document has not changed for `quietMs`, or `maxMs` at most (a page that never
// goes quiet must not block a test). Counts mutations in the page and polls the count from
// here, so it needs no timer in the page.
+10
View File
@@ -119,6 +119,16 @@ test("each version state reads and acts as the old version bar did", () => {
const [ahead] = barNextSteps({ version: { kind: "ahead", skills: "3.2.0", app: "3.1.0" } });
assert.equal(ahead.action, null, "another Update skills run cannot help when the skills are ahead");
assert.match(ahead.title, /newer than this app \(v3\.1\.0\)\. Get the new app\./);
assert.equal(ahead.text, "App v3.1.0 is older than the skills (v3.2.0)", "no release known: the plain facts, never 'Skills ... are newer'");
// A release is out: the same step offers Update and restart, and the release step is not shown twice.
const leadSteps = barNextSteps({ version: { kind: "ahead", skills: "3.2.5", app: "3.2.4" }, newRelease: { latest: "3.2.5" } });
assert.deepEqual(leadSteps.map((step) => [step.id, step.text, step.action]), [["ahead", "Update to latest: v3.2.5", "update-restart"]]);
assert.match(leadSteps[0].title, /Update and restart installs v3\.2\.5/);
assert.equal(leadSteps[0].link.label, "What's new");
// While it runs, fails or waits for the restart, the release's own step says so, with no second button.
for (const newRelease of [{ latest: "3.2.5", updating: "Downloading" }, { latest: "3.2.5", failed: "No." }, { latest: "3.2.5", restartNeeded: true }]) {
assert.deepEqual(barNextSteps({ version: { kind: "ahead", skills: "3.2.5", app: "3.2.4" }, newRelease }).map((step) => step.id), ["new-release"]);
}
const [updating] = barNextSteps({ version: { kind: "updating", line: "Installing skills (4 of 9)" } });
assert.deepEqual([updating.text, updating.busy, updating.action], ["Installing skills (4 of 9)", true, null], "no button while it runs");
const [remains] = barNextSteps({ version: { kind: "remains", skills: "3.0.0", app: "3.1.0" } });
+1 -1
View File
@@ -25,7 +25,7 @@ const OUTSIDE_APP = Object.fromEntries(
export const BUDGETS = {
// The card an agent reads once per session.
card: { "console.md": 9700 },
card: { "console.md": 9800 },
// Each topic file under notes/, read when its workflow starts.
notes: {
"changelog.md": 1400,
+39
View File
@@ -97,6 +97,20 @@ test("install record: recordInstalled and forgetInstalled round trip a sorted se
assert.deepEqual(fs.readdirSync(path.dirname(RECORD)), ["install.json"]);
});
test("install record: appVersion belongs to the app piece, survives other writes and goes with the piece", () => {
clearRecord();
installer.recordInstalled("skills");
installer.recordInstalled("app", { appVersion: "9.9.9" });
assert.equal(installer.readInstallRecord().appVersion, "9.9.9");
installer.recordInstalled("launcher");
installer.recordInstalled("statusline");
assert.equal(installer.readInstallRecord().appVersion, "9.9.9", "another piece's write keeps it");
installer.forgetInstalled("statusline");
assert.equal(installer.readInstallRecord().appVersion, "9.9.9");
installer.forgetInstalled("app");
assert.equal("appVersion" in installer.readInstallRecord(), false, "no app, no appVersion");
});
test("install record: a missing or unparsable record reads as null, and forgetting needs none", () => {
clearRecord();
installer.forgetInstalled("skills");
@@ -279,6 +293,30 @@ test("update: a record on the new version over an older plan2code command instal
assert.deepEqual(idle.ran(), []);
});
test("update: a record on the new version over an app that was never recorded at it installs the app again, without --force", async () => {
// The stuck state: skills and command are new, the app file is still an older release's, and the record already says new.
writeLauncherVersion(VERSION);
for (const appVersion of [undefined, "1.0.0"]) {
fs.mkdirSync(path.dirname(RECORD), { recursive: true });
fs.writeFileSync(RECORD, JSON.stringify({ version: VERSION, scope: "global", pieces: ["app", "launcher", "skills"], ...(appVersion ? { appVersion } : {}) }));
const fake = fakeSteps();
const { code, out } = await runUpdate(fake.steps);
assert.equal(code, 0, out);
assert.doesNotMatch(out, /Already on/);
assert.match(out, /desktop app is not recorded at/);
assert.deepEqual(fake.ran(), ["skills", "app"]);
}
// The app recorded at this version is in place: nothing to do.
fs.writeFileSync(RECORD, JSON.stringify({ version: VERSION, scope: "global", pieces: ["app", "launcher", "skills"], appVersion: VERSION }));
const idle = fakeSteps();
assert.match((await runUpdate(idle.steps)).out, /Already on/);
assert.deepEqual(idle.ran(), []);
// A record without the app never asks about it.
fs.writeFileSync(RECORD, JSON.stringify({ version: VERSION, scope: "global", pieces: ["launcher", "skills"] }));
const noApp = fakeSteps();
assert.match((await runUpdate(noApp.steps)).out, /Already on/);
});
test("update: the record keeps the old version until every piece is in, so a stopped update retries", async () => {
writeRecord(["skills", "launcher", "app"]);
const seen = [];
@@ -824,6 +862,7 @@ test("app installed: the file is downloaded, verified, placed and recorded", { s
assert.equal(outcome.app, true);
assert.deepEqual(fs.readFileSync(installer.APP_DEST), bytes);
assert.deepEqual(installer.readInstallRecord().pieces, ["app", "launcher", "skills"]);
assert.equal(installer.readInstallRecord().appVersion, VERSION, "the record says which release the app file is");
assert.deepEqual(fs.readdirSync(APP_DIR), [path.basename(installer.APP_DEST)], "no temp or .old file is left");
assert.match(out, /Downloading the desktop app \(1 KB\)\.\.\./, "piped: the size, on one plain line");
assert.match(out, /not code-signed/);
+181 -1
View File
@@ -11,7 +11,7 @@ import fs from "node:fs";
import path from "node:path";
import test from "node:test";
import assert from "node:assert/strict";
import { pageSuite, openSession, tempProject, textOf, styleOf } from "./page-test-helpers.mjs";
import { pageSuite, openSession, tempProject, textOf, styleOf, frameInFakeApp } from "./page-test-helpers.mjs";
import { cli, until, CONSOLE_CLI, HOME, JPEG } from "./web-console-test-helpers.mjs";
import { addImage, createTab, deleteTab, markTabSent, saveNote } from "../src/web-console/notepads.mjs";
import { steadyColumns } from "../src/web-console/public/card-rows.js";
@@ -922,3 +922,183 @@ test("with the flag set the dashboard shows the quiet extras line", async (t) =>
await line.waitFor();
assert.match(await textOf(line), /Two optional extras: set your role, switch on Learning\./);
});
// The Loop box: Implement's and Review's confirm panes carry a Loop checkbox
// that opens the desktop app's matching loop setup screen in place of a
// launch. NOTE_PROJECT's documented spec (ready) is the only one here, so the
// picker opens on it and Implement's card is lit.
const LOOP_PROJECT = {
"AGENTS.md": DRAFT_PROJECT["AGENTS.md"],
"specs/ready/overview.md": NOTE_PROJECT["specs/ready/overview.md"],
"specs/ready/phase-1.md": NOTE_PROJECT["specs/ready/phase-1.md"],
};
const IMPLEMENT_LOOP_BOX = "Build every phase unattended (Implementation Loop)";
const REVIEW_LOOP_BOX = "Review and fix in rounds (Review Loop)";
const REVIEW_BOX = "Review each phase with a fresh agent before sign-off";
// The dashboard on LOOP_PROJECT, under the app (PLAN2CODE_IN_APP=1, framed
// by a fake app) or in a plain browser, with the picker on `ready`.
async function openLoopMenu(t, { inApp }) {
const s = await openSession(await suite.browser(), {
t,
workflow: "dashboard",
payload: MENU,
project: tempProject(LOOP_PROJECT),
...(inApp ? { env: { PLAN2CODE_IN_APP: "1" } } : {}),
});
const main = await toTheMenu(s);
if (inApp) await frameInFakeApp(s);
await pickedChip(main, "ready").waitFor();
return { s, main };
}
// Opens `command`'s card on the menu, landing on its confirm pane.
async function openPane(main, command) {
await lightOf(main, command).click();
await main.getByRole("button", { name: "Back" }).waitFor();
}
async function backToMenu(main) {
await main.getByRole("button", { name: "Back" }).click();
await main.getByRole("heading", { name: "What are we doing today?" }).waitFor();
}
// A checkbox's own `disabled`, read in the page: Playwright's isDisabled()
// also counts aria-disabled.
const disabledOf = (box) => box.evaluate((input) => input.disabled);
// What the page holds in `page.<key>`, read through its own state module.
const pageField = (s, key) =>
s.page.evaluate(async (name) => {
const { page } = await import(new URL("state.js", document.baseURI).href);
return JSON.parse(JSON.stringify(page[name] ?? null));
}, key);
// Sets `loop` on the page's copy of the session state and redraws, the way a
// state frame from a loop-driven session would. The server only locks
// implement, implement-review and review sessions with `open --loop`, so the
// dashboard's pane is driven from the page.
async function setLoop(s, loop) {
await s.page.evaluate(async (value) => {
const { page, redraw } = await import(new URL("state.js", document.baseURI).href);
page.S = { ...page.S, loop: value };
redraw();
}, loop);
}
test("under the app, Implement's Loop box is enabled, grays the Review box and swaps the command and Start while ticked", async (t) => {
const { main } = await openLoopMenu(t, { inApp: true });
await openPane(main, "/plan2code-3-implement");
const loop = main.getByRole("checkbox", { name: IMPLEMENT_LOOP_BOX });
const review = main.getByRole("checkbox", { name: REVIEW_BOX });
const cmd = main.locator(".confirm-cmd code");
assert.equal(await disabledOf(loop), false, "the Loop box is enabled in the app");
assert.equal(await loop.isChecked(), false, "the Loop box starts unticked");
assert.equal(await main.locator(".confirm-loop-off").count(), 0, "no reason line while it is enabled");
const command = await textOf(cmd);
assert.match(command, /^\/plan2code-3-implement/);
await main.getByRole("button", { name: "Start Implement" }).waitFor();
await loop.check();
assert.equal(await disabledOf(review), true, "ticking Loop grays the Review box");
assert.equal(await textOf(cmd), "Desktop app only");
await main.getByRole("button", { name: "Set up Implementation Loop" }).waitFor();
assert.equal(await main.getByRole("button", { name: "Start Implement" }).count(), 0, "Start names the loop");
await loop.uncheck();
assert.equal(await disabledOf(review), false, "unticking Loop gives the Review box back");
assert.equal(await textOf(cmd), command, "the command line comes back");
await main.getByRole("button", { name: "Start Implement" }).waitFor();
assert.equal(await main.getByRole("button", { name: "Set up Implementation Loop" }).count(), 0);
});
test("under the app, Start on Implement with Loop ticked opens the Implementation Loop setup for the picked spec", async (t) => {
const { s, main } = await openLoopMenu(t, { inApp: true });
await openPane(main, "/plan2code-3-implement");
await main.getByRole("checkbox", { name: IMPLEMENT_LOOP_BOX }).check();
await main.getByRole("button", { name: "Set up Implementation Loop" }).click();
await s.page.locator("#loop-start").waitFor();
assert.equal((await pageField(s, "loopSetup"))?.spec, "specs/ready");
assert.equal(await textOf(main.locator(".confirm-spec code")), "specs/ready", "the setup screen names the picker's spec");
assert.equal(s.wait(1).code, 10, "nothing was launched");
});
test("under the app, Review's Loop box is enabled and Start opens the Review Loop setup with the spec filled in", async (t) => {
const { s, main } = await openLoopMenu(t, { inApp: true });
await openPane(main, "/plan2code-review");
const loop = main.getByRole("checkbox", { name: REVIEW_LOOP_BOX });
assert.equal(await disabledOf(loop), false, "the Loop box is enabled in the app");
await main.getByRole("button", { name: "Start Review" }).waitFor();
await loop.check();
await main.getByRole("button", { name: "Set up Review Loop" }).click();
await s.page.locator("#review-loop-start").waitFor();
const setup = await pageField(s, "reviewLoopSetup");
assert.equal(setup?.spec, "specs/ready", "the setup opened for the picker's spec");
assert.equal(setup?.form?.spec, "specs/ready", "the picker's spec fills the setup's spec");
assert.equal(s.wait(1).code, 10, "nothing was launched");
});
test("outside the app, both Loop boxes are grayed with the desktop-app line, and Start still launches", async (t) => {
// A launch ends the menu, so each pane gets a session of its own.
// Review's card takes no spec, so its launch carries none.
for (const [command, name, title, skill, spec] of [
["/plan2code-3-implement", IMPLEMENT_LOOP_BOX, "Implement", "plan2code-3-implement-review", "specs/ready"],
["/plan2code-review", REVIEW_LOOP_BOX, "Review", "plan2code-review", undefined],
]) {
const { s, main } = await openLoopMenu(t, { inApp: false });
await openPane(main, command);
const loop = main.getByRole("checkbox", { name });
assert.equal(await disabledOf(loop), true, `${title}'s Loop box is grayed outside the app`);
await loop.click({ force: true });
assert.equal(await loop.isChecked(), false, "a press on the grayed box ticks nothing");
assert.equal(await textOf(main.locator(".confirm-loop-off")), "Runs only in the Plan2Code desktop app.");
if (title === "Implement") assert.equal(await disabledOf(main.getByRole("checkbox", { name: REVIEW_BOX })), false, "the Review box stays usable");
await main.getByRole("button", { name: `Start ${title}` }).click();
const launch = collect(s).actions.find((a) => a.i === "__launch");
assert.ok(launch, `Start launched ${title}`);
assert.deepEqual({ skill: launch.skill, spec: launch.spec }, { skill, spec });
}
});
test("no Implementation Loop or Review Loop card is drawn, in the app or outside it", async (t) => {
for (const inApp of [true, false]) {
const { main } = await openLoopMenu(t, { inApp });
await hideUnavailable(main, false);
const titles = (await main.locator(".dash-card .dash-card-title").allInnerTexts()).map((title) => title.trim());
assert.ok(titles.includes("Implement") && titles.includes("Review"), `the cards the boxes ride on are drawn: ${titles.join(", ")}`);
for (const gone of ["Implementation Loop", "Review Loop"]) {
assert.equal(titles.includes(gone), false, `no ${gone} card ${inApp ? "in the app" : "outside it"}`);
}
}
});
test("while a loop runs, both Loop boxes are grayed with the running line", async (t) => {
const { s, main } = await openLoopMenu(t, { inApp: true });
for (const [command, name] of [
["/plan2code-3-implement", IMPLEMENT_LOOP_BOX],
["/plan2code-review", REVIEW_LOOP_BOX],
]) {
await openPane(main, command);
const loop = main.getByRole("checkbox", { name });
assert.equal(await disabledOf(loop), false, `${command}'s box is enabled before the loop starts`);
await setLoop(s, { driving: true });
const reason = main.locator(".confirm-loop-off");
await reason.waitFor();
assert.equal(await textOf(reason), "A loop is running. Stop it from the banner at the top of the window first.");
assert.equal(await disabledOf(loop), true, `${command}'s box is grayed while a loop runs`);
await loop.click({ force: true });
assert.equal(await loop.isChecked(), false, "a press on the grayed box ticks nothing");
await setLoop(s, null);
await reason.waitFor({ state: "detached" });
await backToMenu(main);
}
});
+41
View File
@@ -51,3 +51,44 @@ test("the one-column layout (900px and narrower) keeps its page scroll", async (
const narrow = await s.page.evaluate(() => getComputedStyle(document.documentElement).overflowY);
assert.equal(narrow, "visible", "its content sits under the first screen, so the lock must not apply");
});
test("a stacked Notes panel has a handle that drags its height, keeps it and resets on double-click", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_QUESTION });
await s.page.setViewportSize({ width: 1000, height: 700 });
await s.page.locator("#main [data-item=\"q1\"]").first().waitFor();
const grip = s.page.locator("#aside .aside-grip");
await grip.waitFor();
const asideHeight = async () => Math.round((await s.page.locator("#aside").boundingBox()).height);
const auto = await asideHeight();
const drag = async (dy) => {
const box = await grip.boundingBox();
const x = box.x + box.width / 2;
const y = box.y + box.height / 2;
await s.page.mouse.move(x, y);
await s.page.mouse.down();
await s.page.mouse.move(x, y + dy / 2, { steps: 4 });
await s.page.mouse.move(x, y + dy, { steps: 4 });
await s.page.mouse.up();
};
await drag(-120);
const taller = await asideHeight();
assert.ok(taller >= auto + 100, `dragging the handle up makes the panel taller (${auto} -> ${taller})`);
await s.page.waitForFunction((h) => Number(document.querySelector("#aside .aside-grip").getAttribute("aria-valuenow")) === h, taller);
await drag(60);
const shorter = await asideHeight();
assert.ok(shorter <= taller - 40 && shorter >= 96, `dragging it down makes the panel shorter (${taller} -> ${shorter})`);
// Kept with the saved looks, so the next session opens at this height.
const saved = async () => s.page.evaluate(async () => (await (await fetch("/looks")).json()).looks?.asideHeight);
await s.page.waitForFunction(async (h) => (await (await fetch("/looks")).json()).looks?.asideHeight === h, shorter);
assert.equal(await saved(), shorter, "the height is kept in the saved looks");
await grip.dblclick();
assert.equal(await asideHeight(), auto, "a double-click goes back to the automatic height");
assert.equal(await s.page.evaluate(() => document.documentElement.hasAttribute("data-aside-h")), false);
await s.page.setViewportSize({ width: 1400, height: 700 });
assert.equal(await grip.isVisible(), false, "side by side, the panel has no handle");
});
+49 -21
View File
@@ -1,6 +1,6 @@
// Page tests for the Implementation Loop's setup screen. The dashboard card
// that opens it only shows inside the desktop app, so these open the screen
// through its own module, then drive the real page. Run with:
// Page tests for the Implementation Loop's setup screen. Its Loop box only
// enables inside the desktop app, so these open the screen through its own
// module, then drive the real page. Run with:
// node --test scripts/test-web-console-page-loop.mjs
import test from "node:test";
@@ -8,7 +8,7 @@ import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { pageSuite, openSession, tempProject, textOf } from "./page-test-helpers.mjs";
import { pageSuite, openSession, tempProject, textOf, frameInFakeApp } from "./page-test-helpers.mjs";
import { MODELS_DIR } from "./web-console-test-helpers.mjs";
const suite = pageSuite(test);
@@ -112,23 +112,6 @@ test("the web address field shows the name only beside an address, warns while t
assert.equal(reread.remembered, true);
});
// Stands a real window in for the app that frames the page, listening to what
// the page tells it; `answer` then replies the way the app's window does.
async function frameInFakeApp(s) {
await s.page.evaluate(() => {
const frame = document.createElement("iframe");
frame.hidden = true;
document.body.appendChild(frame);
const app = frame.contentWindow;
window.__told = [];
app.postMessage = (message) => window.__told.push(message);
Object.defineProperty(window, "parent", { value: app, configurable: true });
});
return (data) =>
s.page.evaluate((message) => {
window.dispatchEvent(new MessageEvent("message", { source: window.parent, data: message }));
}, data);
}
test("Cancel in the app's confirm leaves Start ready to press again; a real start locks it", async (t) => {
const s = await openSetup(t);
@@ -459,6 +442,51 @@ test("after Continue building replaces the Ask agent, the same stop again offers
assert.deepEqual(seen.told, ["loop-ask", "loop-resume"]);
});
const FINISHED = { kind: "finished", line: "All 1 phases built", phases: [{ n: 1, name: "API", commit: "abc1234" }], uncommitted: [], can: ["finalize", "dashboard"] };
test("a pressed Finalize shows a spinner and stays busy after the app's ok answer, and an error frees it", async (t) => {
const s = await openSetup(t);
await frameInFakeApp(s);
const seen = await s.page.evaluate(async (end) => {
const m = await import(new URL("screens/ending.js", document.baseURI).href);
const { page } = await import(new URL("state.js", document.baseURI).href);
const read = () => {
const card = m.renderLoopEnd(end);
const choices = [...card.querySelectorAll(".loop-end-choice")];
const of = (text) => choices.find((c) => c.querySelector("button").textContent.includes(text));
const fin = of("Finalize") || of("Starting Finalize");
const home = of("dashboard");
const b = fin.querySelector("button");
return {
busy: b.classList.contains("is-busy"),
disabled: b.disabled,
spinner: Boolean(b.querySelector(".spinner")),
label: b.textContent,
hint: fin.querySelector(".loop-end-hint").textContent,
otherDisabled: home.querySelector("button").disabled,
};
};
const before = read();
m.renderLoopEnd(end).querySelector(".loop-end-actions button").click();
const waiting = read();
page.loopAction = { kind: "loop-finalize-result", ok: true, error: null };
const started = read();
page.loopAction = { kind: "loop-finalize-result", ok: false, error: "no" };
const failed = read();
m.forgetLoopEnd();
page.loopAction = null;
return { before, waiting, started, failed, told: window.__told.map((x) => x.plan2code) };
}, FINISHED);
assert.deepEqual([seen.before.busy, seen.before.disabled], [false, false]);
for (const phase of [seen.waiting, seen.started]) {
assert.deepEqual([phase.busy, phase.disabled, phase.spinner, phase.otherDisabled], [true, true, true, true]);
assert.equal(phase.label, "Starting Finalize…");
assert.match(phase.hint, /starting in the terminal/);
}
assert.deepEqual([seen.failed.busy, seen.failed.disabled, seen.failed.label], [false, false, "Finalize"], "an error gives the button back");
assert.deepEqual(seen.told, ["loop-finalize"]);
});
// A real loop session: `open --loop` under the app's signal stamps the lock.
async function openLoopPage(t) {
return openSession(await suite.browser(), {
+5 -22
View File
@@ -1,7 +1,7 @@
// Page tests for the Review Loop's setup screen. The dashboard card that opens
// it only shows inside the desktop app, so these open the screen through its
// own module, then drive the real page, the way test-web-console-page-loop.mjs
// does for the Implementation Loop's. Run with:
// Page tests for the Review Loop's setup screen. Its Loop box only enables
// inside the desktop app, so these open the screen through its own module,
// then drive the real page, the way test-web-console-page-loop.mjs does for
// the Implementation Loop's. Run with:
// node --test scripts/test-web-console-page-review-loop.mjs
import test from "node:test";
@@ -9,7 +9,7 @@ import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { pageSuite, openSession, tempProject, textOf } from "./page-test-helpers.mjs";
import { pageSuite, openSession, tempProject, textOf, frameInFakeApp } from "./page-test-helpers.mjs";
import { MODELS_DIR } from "./web-console-test-helpers.mjs";
const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
@@ -26,23 +26,6 @@ const MENU = { menu: { note: "Ready when you are." }, agent: { status: "waiting"
const FACTS = { agent: "claude", agentLabel: "Claude Code", helpers: true, strengthsMapped: true, running: false, promptSupport: true, notifyKind: "query", notifyUrl: "", notifyParam: "message" };
// Stands a real window in for the app that frames the page, listening to what
// the page tells it; the returned function replies the way the app does.
async function frameInFakeApp(s) {
await s.page.evaluate(() => {
const frame = document.createElement("iframe");
frame.hidden = true;
document.body.appendChild(frame);
const app = frame.contentWindow;
window.__told = [];
app.postMessage = (message) => window.__told.push(message);
Object.defineProperty(window, "parent", { value: app, configurable: true });
});
return (data) =>
s.page.evaluate((message) => {
window.dispatchEvent(new MessageEvent("message", { source: window.parent, data: message }));
}, data);
}
// The installed copy of the shipped model menu, with its strengths, as install.js drops it.
function installShippedModels() {
+30 -13
View File
@@ -19,7 +19,8 @@ import {
isWorkflow,
isAgentless,
} from "../src/web-console/public/skills.js";
import { APP_ONLY_ENTRIES, REVIEW_LOOP_ENTRY, cardAvailability, CONSOLE_WORKFLOWS, SKILL_CATALOG, catalogEntry, launchVariant, START_POSES, WORKFLOW_LABEL, dashNoteKind, onInitialPick, startPose, startingHint } from "../src/web-console/public/answers.js";
import * as ANSWERS from "../src/web-console/public/answers.js";
import { cardAvailability, CONSOLE_WORKFLOWS, loopBoxState, loopFor, OUTSIDE_APP_LINE, SKILL_CATALOG, catalogEntry, launchVariant, START_POSES, WORKFLOW_LABEL, dashNoteKind, onInitialPick, startPose, startingHint } from "../src/web-console/public/answers.js";
import { LAUNCH_COUNTED, PROGRESS_WORKFLOWS } from "../src/web-console/public/meter.js";
import { BUILD_WORKFLOWS } from "../src/web-console/public/labels.js";
import { helpTabFor } from "../src/web-console/public/help.js";
@@ -428,8 +429,9 @@ test("helper-strength.md ships in the eighteen skills that start helpers (the da
]);
});
// The Implementation Loop and the Review Loop are cards the desktop app offers,
// not skills: neither has a workflow, so no list built from the workflows may hold them.
// The Implementation Loop and the Review Loop are features the desktop app
// offers, not skills: neither has a workflow, so no list built from the
// workflows may hold them, and neither draws a card of its own.
test("the app-only Implementation Loop and Review Loop entries stay out of every workflow list", () => {
const apps = EVERY_ENTRY.filter((s) => s.appOnly);
assert.deepEqual(apps.map((s) => s.skill), ["plan2code-loop", "plan2code-review-loop"], "both, the Implementation Loop first");
@@ -439,23 +441,38 @@ test("the app-only Implementation Loop and Review Loop entries stay out of every
assert.ok(!isWorkflow(entry.skill));
assert.equal(skillByName(entry.skill), null);
assert.ok(!CONSOLE_WORKFLOWS.includes(entry.command), "no console page is offered for it");
assert.ok(!SKILL_CATALOG.some((e) => e.skill === entry.skill), "the dashboard draws it apart from the catalog");
assert.ok(!SKILL_CATALOG.some((e) => e.skill === entry.skill), "the catalog leaves it out");
assert.equal(entry.subagents, null);
assert.equal(entry.card.group, "pipeline", "beside the Implementation Loop");
assert.equal(entry.card, null, "no card: its parent card's Loop box opens it");
}
assert.ok(!WORKFLOWS.includes(null) && !isWorkflow(null));
assert.ok(!("null" in WORKFLOW_LABEL));
assert.deepEqual([...apps[0].states], ["documented", "building"]);
assert.equal(apps[1].states, "any", "a Review Loop needs no spec");
assert.equal(apps[1].card.title, "Review Loop");
assert.equal(apps[1].card.blurb, "Review and fix in rounds on its own, each round checked by a fresh reviewer.");
});
test("the Review card carries the app-only pointer line, and the app-only cards are the dashboard's extras", () => {
test("Implement's and Review's cards name the loop their Loop box opens, and no card carries an app-only line", () => {
const byId = (skill) => SKILL_CATALOG.find((e) => e.skill === skill);
assert.equal(byId("plan2code-3-implement").loop, "plan2code-loop");
assert.equal(byId("plan2code-review").loop, "plan2code-review-loop");
assert.deepEqual(SKILL_CATALOG.filter((e) => e.loop).map((e) => e.skill), ["plan2code-3-implement", "plan2code-review"], "no other card has a Loop box");
assert.equal(loopFor(byId("plan2code-3-implement")).name, "Implementation Loop");
assert.equal(loopFor(byId("plan2code-review")).name, "Review Loop");
assert.equal(loopFor(byId("plan2code-4-finalize")), null);
assert.deepEqual(EVERY_ENTRY.filter((s) => s.card && s.card.appNote).map((s) => s.skill), [], "no entry carries appNote");
assert.ok(!("APP_ONLY_ENTRIES" in ANSWERS) && !("REVIEW_LOOP_ENTRY" in ANSWERS) && !("LOOP_ENTRY" in ANSWERS), "the app-only card entries are gone");
});
test("the Loop box: grayed outside the app and while a loop runs, else the loop's own availability", () => {
const implement = SKILL_CATALOG.find((e) => e.skill === "plan2code-3-implement");
const review = SKILL_CATALOG.find((e) => e.skill === "plan2code-review");
assert.equal(review.appNote, "In the app, the Review Loop runs review and fix rounds on its own.");
assert.deepEqual(SKILL_CATALOG.filter((e) => e.appNote).map((e) => e.skill), ["plan2code-review"], "no other card has one");
assert.deepEqual(APP_ONLY_ENTRIES.map((e) => e.skill), ["plan2code-loop", "plan2code-review-loop"]);
assert.equal(REVIEW_LOOP_ENTRY.command, "Desktop app only");
assert.equal(cardAvailability(REVIEW_LOOP_ENTRY, { hasAgents: true }, null).on, true, "lit for any project state");
const scanned = { hasAgents: true };
const documented = { dir: "specs/x", state: "documented" };
assert.deepEqual(loopBoxState(implement, scanned, documented, { inApp: false, driving: false }), { on: false, reason: OUTSIDE_APP_LINE });
const running = loopBoxState(review, scanned, null, { inApp: true, driving: true });
assert.equal(running.on, false);
assert.match(running.reason, /A loop is running/);
assert.equal(loopBoxState(implement, scanned, documented, { inApp: true, driving: false }).on, true);
assert.equal(loopBoxState(implement, scanned, null, { inApp: true, driving: false }).on, false, "the Implementation Loop needs a documented or building spec");
assert.equal(loopBoxState(review, scanned, null, { inApp: true, driving: false }).on, true, "the Review Loop is lit for any project state");
});
-4
View File
@@ -411,10 +411,6 @@ test("help: each loop's link opens its own Help topic", () => {
const ids = HELP_TABS.map((t) => t.id);
assert.ok(ids.includes("review-loop"), "Help has a Review Loop topic");
assert.equal(HELP_TABS[ids.indexOf("review-loop")].label, "Review Loop");
const dash = publicSource("screens/dashboard.js");
const link = dash.match(/function loopHelpLink\(entry\) \{([\s\S]*?)\n\}/);
assert.ok(link, "dashboard.js has loopHelpLink");
assert.match(link[1], /openHelpOn\(review \? "review-loop" : "loop"\)/, "the dashboard's Review Loop link opens Review Loop, the other opens Implementation Loop");
const setup = publicSource("screens/review-loop-setup.js");
assert.match(setup, /"How the Review Loop works"/, "the Review Loop setup screen names its own loop");
assert.match(setup, /openHelpOn\("review-loop"\)/, "the Review Loop setup screen opens Review Loop");
+1
View File
@@ -65,6 +65,7 @@ test("state: the rest of the shared state starts as app.js always started it", (
prototypes: { key: null, files: [], open: null, texts: {} },
wake: null,
dashPick: null,
dashLoop: false,
mentionPop: null,
heldPose: null,
newQuestions: new Set(),
+6
View File
@@ -75,6 +75,12 @@ const AMBIENT_ENV_KEYS = [
"SSH_CONNECTION",
"PLAN2CODE_PICKER_ECHO",
"PLAN2CODE_NOW",
// Set by the desktop app for its own terminal: a run from inside the app
// would otherwise frame every plain-browser test as in the app.
"PLAN2CODE_IN_APP",
"PLAN2CODE_CONSOLE_SID",
"PLAN2CODE_APP_ANNOUNCE",
"PLAN2CODE_APP_TOKEN",
];
const scrubbed = { ...process.env };
for (const k of AMBIENT_ENV_KEYS) delete scrubbed[k];