From bdc4decbb43903758dad5308ca7d7a717c7c3252 Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Sun, 25 Oct 2026 12:46:37 -0700 Subject: [PATCH] Add a Combine phases quick answer to a plan's Build order card AI Assisted --- CHANGELOG.md | 1 + scripts/test-web-console-page-cards.mjs | 17 +++++++++++++ src/web-console/public/screens/cards.js | 31 +++++++++++++++--------- src/web-console/public/styles/pieces.css | 1 + 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c14c6..01dfca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to Plan2Code will be documented in this file. ### 🔧 Changed - **launcher**: `plan2code` no longer treats an SSH or service session on macOS or Windows as having a desktop, and asks before opening a folder that looks like it is not a project (no `.git`, `AGENTS.md` or `specs/`). +- **web console**: a plan's **Build order** card has a **Combine phases** button beside **No changes**. One click fills the box with a request to merge phases where possible while keeping each to a clear concern. It shows only in Plan and Revise plan, where the breakdown is phases. ## v2.11.1 diff --git a/scripts/test-web-console-page-cards.mjs b/scripts/test-web-console-page-cards.mjs index 223eb1d..3347b78 100644 --- a/scripts/test-web-console-page-cards.mjs +++ b/scripts/test-web-console-page-cards.mjs @@ -395,6 +395,23 @@ test("Skip this one and a comment box's quick answer are the same small accent b assert.equal(colour, await accentOf(s.page), "in the accent"); }); +// What a person sees break: Combine phases is missing from a plan's breakdown, +// fills nothing, or shows on a list that is not phases. +test("a plan's breakdown offers Combine phases beside No changes, and other workflows do not", async (t) => { + const rows = [{ id: "a", title: "Read the data", body: "x" }]; + let s = await openSession(await suite.browser(), { t, workflow: "plan" }); + let card = await ask(s, { id: "l1", kind: "list", title: "Build order", body: "Reorder.", rows }); + const quicks = card.locator(".quick-answer"); + assert.deepEqual(await quicks.allTextContents(), ["No changes", "Combine phases"]); + await card.getByRole("button", { name: "Combine phases" }).click(); + const got = await sendAndCollect(s); + assert.match(answerTo(got, "l1").text, /^Combine phases where possible/); + + s = await openSession(await suite.browser(), { t, workflow: "quick-task" }); + card = await ask(s, { id: "l2", kind: "list", title: "Steps", body: "Reorder.", rows }); + assert.deepEqual(await card.locator(".quick-answer").allTextContents(), ["No changes"]); +}); + // What a person sees break: a safe yes looks like any button, or a risky yes // stops warning. test("a confirm's safe yes and a recap's yes are outlined in the accent, and a dangerous yes stays red", async (t) => { diff --git a/src/web-console/public/screens/cards.js b/src/web-console/public/screens/cards.js index 30cc116..ddc59fc 100644 --- a/src/web-console/public/screens/cards.js +++ b/src/web-console/public/screens/cards.js @@ -1495,22 +1495,29 @@ function buildList(card, item, staged) { } card.appendChild(row); card.appendChild(el("p", "help", "Drag to reorder, click a name to rename it.")); - commentField(card, item, "Anything else about this breakdown?", false, "no changes"); + const quick = [{ label: "No changes", text: "no changes" }]; + // Only a plan's breakdown is phases; a list card elsewhere is something else. + if (PHASE_WORKFLOWS.includes(page.S.workflow)) quick.push({ label: "Combine phases", text: COMBINE_PHASES }); + commentField(card, item, "Anything else about this breakdown?", false, quick); } -function commentField(card, item, labelText, required, quickText) { +const PHASE_WORKFLOWS = ["plan", "revise-plan"]; +const COMBINE_PHASES = + "Combine phases where possible to simplify and reduce the total number of phases, while still keeping a clear separation of concerns."; + +function commentField(card, item, labelText, required, quickAnswers = []) { const wrap = el("div", "field"); const id = "note-" + item.id; const label = el("label", null, labelText); label.htmlFor = id; wrap.appendChild(label); - let quick = null; - if (quickText) { - quick = el("button", "btn tiny", quickText.charAt(0).toUpperCase() + quickText.slice(1)); - quick.type = "button"; - quick.title = "Fill in \"" + quickText + "\""; - wrap.appendChild(quick); - } + const quicks = quickAnswers.map(({ label, text }) => { + const b = el("button", "btn tiny quick-answer", label); + b.type = "button"; + b.title = "Fill in \"" + text + "\""; + wrap.appendChild(b); + return [b, text]; + }); const ta = el("textarea"); ta.id = id; ta.placeholder = required ? "Tell Plan2Code what to change." : "Optional."; @@ -1531,9 +1538,9 @@ function commentField(card, item, labelText, required, quickText) { stagedChanged(); }); wrap.appendChild(ta); - if (quick) - quick.addEventListener("click", () => { - ta.value = quickText; + for (const [b, text] of quicks) + b.addEventListener("click", () => { + ta.value = text; ta.dispatchEvent(new Event("input", { bubbles: true })); ta.focus(); }); diff --git a/src/web-console/public/styles/pieces.css b/src/web-console/public/styles/pieces.css index 759e306..4f8445f 100644 --- a/src/web-console/public/styles/pieces.css +++ b/src/web-console/public/styles/pieces.css @@ -441,6 +441,7 @@ input[type="text"].invalid { border-color: var(--warn); } margin-bottom: 6px; } .btn.tiny:hover:not(:disabled) { background: var(--accent-soft); filter: brightness(1.04); } +.quick-answer + .quick-answer { margin-left: 6px; } .btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }