Give a stranded finish screen a way out

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-09 08:08:43 -08:00
1 parent d4b604ba7f
commit 9a23b15fc9
3 files changed
+92 -3

No files matched your search

+32
View File
@@ -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.
+14 -1
View File
@@ -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."
)
);
+46 -2
View File
@@ -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).