Teach the web console to read right inside the desktop app

AI Assisted
This commit is contained in:
jparkerweb committed 2026-10-25 12:46:52 -07:00
1 parent 72043e20fc
commit c1f41e4a82
25 files changed
+951 -85

No files matched your search

+69 -18
View File
@@ -11,11 +11,13 @@ import {
handoffShape,
ALL_DONE_LEAD,
ALL_DONE_REST,
ALL_DONE_REST_IN_APP,
handoffText,
DASHBOARD_COMMAND,
resumeCommand,
afterFinishButton,
DASHBOARD_NOTE,
DASHBOARD_NOTE_IN_APP,
turnGate,
homeButtonState,
HOME_REPLY,
@@ -88,25 +90,43 @@ function renderCloseGuide(shape, fin = {}) {
const title = el("h3", "handoff-guide-title", "Before you close this");
title.id = "handoff-guide-title";
panel.appendChild(title);
// Under the app this reads differently: there is one window, not a tab, and
// the app's own New Session button already starts the agent fresh in one
// click, so nothing here asks anyone to close a session or open another.
const rows = [
["safe", "Safe to close", "This tab is only a window: whatever this session wrote is on disk, and nothing here needs you."],
[
"safe",
"Safe to close",
page.inApp
? "This window is only a view: whatever this session wrote is on disk, and nothing here needs you."
: "This tab is only a window: whatever this session wrote is on disk, and nothing here needs you.",
],
[
"fresh",
"Start fresh",
shape === "paused"
? stopWarning()
? "Restart your agent window, or close the old session and start a new one. The command above starts it again."
: "Restart your agent window, or close the old session and start a new one. Your saved place is picked up by the resume command above."
: "Restart your agent window, or close the old session and start a new one. A new session starts from clean context. This one is full of this step's instructions, so continuing in it is slower and can confuse the next step.",
page.inApp
? "Press New Session at the top of the window to start the agent fresh."
: shape === "paused"
? stopWarning()
? "Restart your agent window, or close the old session and start a new one. The command above starts it again."
: "Restart your agent window, or close the old session and start a new one. Your saved place is picked up by the resume command above."
: "Restart your agent window, or close the old session and start a new one. A new session starts from clean context. This one is full of this step's instructions, so continuing in it is slower and can confuse the next step.",
],
[
"carry",
"Carry on",
// The app's terminal panel runs the agent itself, so a slash command
// still goes there, not into some other "new session" or "new
// conversation" that does not exist under the app.
shape === "all-done"
? `In the new session, start from the dashboard with \`${DASHBOARD_COMMAND}\`.`
? page.inApp
? `In the terminal panel, start from the dashboard with \`${DASHBOARD_COMMAND}\`.`
: `In the new session, start from the dashboard with \`${DASHBOARD_COMMAND}\`.`
: shell
? `Run the command above in your terminal, then start the next step from the dashboard with \`${DASHBOARD_COMMAND}\`.`
: `Paste the command above in the new session, or start from the dashboard with \`${DASHBOARD_COMMAND}\`.`,
: page.inApp
? `Paste the command above into the terminal panel, or start from the dashboard with \`${DASHBOARD_COMMAND}\`.`
: `Paste the command above in the new session, or start from the dashboard with \`${DASHBOARD_COMMAND}\`.`,
],
];
const list = el("ul", "handoff-guide-rows");
@@ -160,7 +180,10 @@ export function renderHandoff(fin) {
const shape = handoffShape(fin);
if (shape === "all-done") {
const done = el("div", "handoff-done");
done.appendChild(md(`${ALL_DONE_LEAD} ${ALL_DONE_REST}`, "md handoff-done-text"));
done.appendChild(md(`${ALL_DONE_LEAD} ${page.inApp ? ALL_DONE_REST_IN_APP : ALL_DONE_REST}`, "md handoff-done-text"));
// The command still works under the app: its terminal panel runs the
// agent itself, so pasting this there reaches the dashboard exactly as
// it would in a plain terminal.
const text = handoffText({ command: DASHBOARD_COMMAND });
const row = el("div", "handoff-command");
const code = el("code", "handoff-code", text);
@@ -182,7 +205,9 @@ export function renderHandoff(fin) {
"handoff-where",
fin.where ||
(command.startsWith("/")
? "Run this in the terminal where you started Plan2Code, in a new conversation:"
? page.inApp
? "Paste this into the terminal panel below:"
: "Run this in the terminal where you started Plan2Code, in a new conversation:"
: "Run this in your terminal:")
)
);
@@ -213,7 +238,12 @@ export function renderHandoff(fin) {
if (shape === "next") {
const offerDash = dashboardLive(fin);
if (offerDash) card.appendChild(renderDashboardOffer(false));
if (!(offerDash && page.gone)) {
// Under the app this paragraph never shows: renderCloseGuide's own
// "carry" row already says the same thing ("Paste the command above
// into the terminal panel, or start from the dashboard with
// `/plan2code`"), right below this card, so repeating it here would
// be the third mention of the one action on this screen.
if (!page.inApp && !(offerDash && page.gone)) {
card.appendChild(
textWithCode(
"p",
@@ -303,9 +333,13 @@ function renderReviewOffer(offer) {
el(
"p",
"review-offer-text",
asked
? "The session closed before the review could start. To run it now, use this in the terminal, in a new conversation:"
: "This session has closed, so the review cannot start from here any more. To run it, use this in the terminal, in a new conversation:"
page.inApp
? asked
? "The session closed before the review could start. To run it now, paste this into the terminal panel:"
: "This session has closed, so the review cannot start from here any more. To run it, paste this into the terminal panel:"
: asked
? "The session closed before the review could start. To run it now, use this in the terminal, in a new conversation:"
: "This session has closed, so the review cannot start from here any more. To run it, use this in the terminal, in a new conversation:"
)
);
const text = "/plan2code-review";
@@ -422,6 +456,19 @@ function renderChangelogOffer() {
function renderDashboardOffer(primary) {
const box = el("section", "dashboard-offer");
if (page.gone) {
if (page.inApp) {
// The app's own bar already notices a dead console and offers to
// reconnect it (its next-step slot, "Reconnect the console"); nothing here
// is a command for anyone to run themselves.
box.appendChild(
el(
"p",
null,
"This session has closed. Plan2Code will try to reconnect the console on its own; if it cannot, the app's bar offers Reconnect the console."
)
);
return box;
}
box.appendChild(
el(
"p",
@@ -447,7 +494,7 @@ function renderDashboardOffer(primary) {
go.disabled = disabled;
go.addEventListener("click", () => sendAfterBuild("dashboard"));
box.appendChild(go);
box.appendChild(textWithCode("p", "dashboard-note", DASHBOARD_NOTE));
box.appendChild(textWithCode("p", "dashboard-note", page.inApp ? DASHBOARD_NOTE_IN_APP : DASHBOARD_NOTE));
return box;
}
@@ -733,9 +780,13 @@ export function renderStopping() {
el(
"p",
"stop-note",
page.gone
? "The session closed without saying how to pick it up. Your answers and the stop are saved, and the next session collects them. To carry on, run this in the terminal, in a new conversation (or alternatively run `/plan2code` to relaunch the dashboard):"
: "Plan2Code is not running right now, so nothing new has been saved yet. Your answers and the stop are held, and the next session collects them. To carry on, run this in the terminal, in a new conversation (or alternatively run `/plan2code` to relaunch the dashboard):"
page.inApp
? (page.gone
? "The session closed without saying how to pick it up. Your answers and the stop are saved, and the next session collects them. Paste this into the terminal panel below to carry on:"
: "Plan2Code is not running right now, so nothing new has been saved yet. Your answers and the stop are held, and the next session collects them. Paste this into the terminal panel below to carry on:")
: page.gone
? "The session closed without saying how to pick it up. Your answers and the stop are saved, and the next session collects them. To carry on, run this in the terminal, in a new conversation (or alternatively run `/plan2code` to relaunch the dashboard):"
: "Plan2Code is not running right now, so nothing new has been saved yet. Your answers and the stop are held, and the next session collects them. To carry on, run this in the terminal, in a new conversation (or alternatively run `/plan2code` to relaunch the dashboard):"
)
);
const text = handoffText({ command: resumeCommand(page.S) });