mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 00:15:41 -08:00
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:
1 parent
9629961f36
commit
658c813428
70 files changed
+818
-242
No files matched your search
@@ -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);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user