From 9a23b15fc9af94f0a55e1385ba5593a83c825cfd Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Mon, 9 Nov 2026 08:08:43 -0800 Subject: [PATCH] Give a stranded finish screen a way out AI Assisted --- scripts/test-web-console-page-session.mjs | 32 +++++++++++++++ src/web-console/public/screens/core.js | 15 ++++++- src/web-console/public/screens/ending.js | 48 ++++++++++++++++++++++- 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/scripts/test-web-console-page-session.mjs b/scripts/test-web-console-page-session.mjs index 6c5d3f6..64efd88 100644 --- a/scripts/test-web-console-page-session.mjs +++ b/scripts/test-web-console-page-session.mjs @@ -1059,6 +1059,38 @@ test("a different finish posted over a pressed Review starts with its own button assert.equal(await main.getByRole("button", { name: "Commit it now" }).isEnabled(), true, "Commit stayed dead after the new finish"); }); +// What a person sees break: a finish screen whose every button is disabled while nothing answers them, with no way off the page but a toolbar button, and a footer pointing at buttons that do nothing. +const STRANDED_FINISH = { ...OFFERS, command: 'git commit -m "Fix it"' }; +async function strandedFinish(t, opts) { + const s = await openSession(await suite.browser(), { t, workflow: "quick-task", clock: true, ...opts, payload: { agent: { status: "working", activity: "Task 1 of 1" } } }); + s.post({ finish: STRANDED_FINISH }); + const main = s.page.locator("#main"); + await main.getByRole("button", { name: "Review it now" }).click(); + await main.getByRole("button", { name: "Review requested…" }).waitFor(); + await s.page.clock.fastForward(200_000); + await s.page.waitForFunction(() => document.body.innerText.includes("Plan2Code is not running")); + return { s, main }; +} + +test("a finish press nothing collects offers Start a New Session under the app, which asks the app for one", async (t) => { + const { s, main } = await strandedFinish(t, { env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME }); + const press = main.getByRole("button", { name: "Start a New Session" }); + assert.equal(await press.isEnabled(), true, "the escape hatch must not be disabled"); + assert.equal(await closeGuide(s).count(), 1, "the guide stays while the press is stranded"); + const foot = await textOf(s.page.locator("#footer-summary")); + assert.doesNotMatch(foot, /next step is above/i); + assert.match(foot, /New Session/); + await press.click(); + await until(async () => (await toApp(s, "new-session")).length === 1, 5000); +}); + +test("a finish press nothing collects shows the dashboard command in a browser, with no button", async (t) => { + const { s, main } = await strandedFinish(t, {}); + assert.equal(await main.getByRole("button", { name: "Start a New Session" }).count(), 0); + assert.match(await textOf(main), /\/plan2code\b/); + assert.doesNotMatch(await textOf(s.page.locator("#footer-summary")), /next step is above/i); +}); + // What a person sees break: the guide missing while a commit or the dashboard // is starting (it would say "start a new one" under "Opening Git"), or missing // once they said they are done or the server is gone. diff --git a/src/web-console/public/screens/core.js b/src/web-console/public/screens/core.js index 180b3a1..8af1cbc 100644 --- a/src/web-console/public/screens/core.js +++ b/src/web-console/public/screens/core.js @@ -1812,6 +1812,17 @@ export function renderFooter() { // already gone. Say what is actually outstanding instead: their own send. next.appendChild(el("strong", null, stranded() ? `${sent.length} saved, not picked up yet` : `${sent.length} with Plan2Code`)); next.appendChild(document.createTextNode(" · " + sent.map((i) => i.title).join(" · "))); + } else if (finish() && pressStranded()) { + // Every button on the screen waits on an agent that is gone; say so, and + // name the one way off. + next.appendChild(el("strong", null, "Plan2Code is not running.")); + next.appendChild( + document.createTextNode( + page.inApp + ? " Press New Session at the top of the window, or the button above." + : " Start a new conversation with the command above." + ) + ); } else if (finish()) { // Not "nothing to send yet". There is no yet. const fin = finish(); @@ -1823,7 +1834,9 @@ export function renderFooter() { : finishPaused(fin) ? " Run the command above to pick this up." : fin.command - ? " The next step is above." + ? String(fin.command).trim().startsWith("/") + ? " The next step is above." + : " Run the command above in your terminal." : " Nothing left to run." ) ); diff --git a/src/web-console/public/screens/ending.js b/src/web-console/public/screens/ending.js index d92b5ad..61dec4e 100644 --- a/src/web-console/public/screens/ending.js +++ b/src/web-console/public/screens/ending.js @@ -39,6 +39,7 @@ import { docs, finish, finishKey, + pressStranded, agentAdrift, agentWorking, awaitingReply, @@ -154,7 +155,7 @@ function renderCloseGuide(shape, fin = {}) { // A review, a commit in Git, the dashboard or the next step the person just asked for is starting // here, so the page is about to carry on rather than end. function closeGuideHeld() { - if (page.gone) return false; + if (page.gone || pressStranded()) return false; return ["review", "commit", "changelog", "dashboard", "launch"].includes(page.local.afterBuild) || reviewPending() === "asked"; } @@ -269,6 +270,10 @@ export function renderHandoff(fin) { card.appendChild(el("h2", null, fin.headline)); if (fin.body) card.appendChild(md(fin.body, "md prompt")); + // Every press below is waiting on an agent that is gone: the way off this + // page must not be one of them. + if (pressStranded()) card.appendChild(renderStrandedEscape()); + // A finished build offers its review first, above the next step, because it // is the one thing on this screen that has to happen before they leave. const offer = reviewOffer(fin); @@ -334,7 +339,7 @@ export function renderHandoff(fin) { step.appendChild(row); // Under the app a clean start is the bar's New Session: one press, with // the command already on the clipboard to paste into the new terminal. - if (page.inApp && command.startsWith("/") && !page.gone) { + if (page.inApp && command.startsWith("/") && !page.gone && !pressStranded()) { const fresh = el("div", "handoff-newsession"); const press = el("button", "btn small", "Start a New Session"); press.type = "button"; @@ -436,6 +441,45 @@ export function renderHandoff(fin) { return card; } +// The escape hatch of a finished screen whose press nothing collects (the +// agent's turn ended while the page waited). Always enabled: under the app a +// New Session, with the dashboard command copied first; in a browser the +// command itself to run in a new conversation. +function renderStrandedEscape() { + const box = el("section", "review-offer stranded-escape"); + box.appendChild(el("p", "handoff-label", "Nothing is answering")); + const text = handoffText({ command: DASHBOARD_COMMAND }); + if (page.inApp) { + box.appendChild( + el( + "p", + "review-offer-text", + "The buttons here cannot reach Plan2Code any more. Start a new session to carry on; the dashboard command is copied first, so paste it into the terminal panel once the new session opens." + ) + ); + const row = el("div", "btn-row"); + const go = el("button", "btn primary", "Start a New Session"); + go.type = "button"; + go.addEventListener("click", () => startNewSession(text)); + row.appendChild(go); + box.appendChild(row); + return box; + } + box.appendChild( + el( + "p", + "review-offer-text", + "The buttons here cannot reach Plan2Code any more. To carry on, run this in a new conversation:" + ) + ); + const row = el("div", "handoff-command"); + const code = el("code", "handoff-code", text); + row.appendChild(code); + row.appendChild(copyButton(text, "btn small handoff-copy", code)); + box.appendChild(row); + return box; +} + // The review button, on the hand-off of a finished build (a finished quick // task; an implementation phase gets its review offer earlier, as a verdict // on the sign-off card).