Start a clean session in one press under the desktop app

AI Assisted
This commit is contained in:
jparkerweb committed 2026-10-26 17:05:36 -07:00
1 parent 899b3a48d8
commit 10379e3870
11 files changed
+129 -6

No files matched your search

+2
View File
@@ -21,7 +21,9 @@ All notable changes to Plan2Code will be documented in this file.
- **docs**: all prose, help text, skill prompts and comments now use US English spelling (color, gray, behavior, canceled, -ize), and `npm test` checks it (`scripts/test-us-english.mjs`).
- **web console**: **User Preferences → Highlight color** now offers 38 colors in two rows of nineteen, covering the range of a Paint-style picker: new **Maroon**, **Peach**, **Brown**, **Cream**, **Lemon**, **Forest**, **Mint**, **Aqua**, **Lavender**, **Pink** and **Mono** (near-black in light mode, near-white in dark). Five near twins were merged (Copper into Rust, Marigold into Gold, Mustard into Lemon, Jade into Emerald, Lilac into Violet); a saved choice of one of those keeps its twin instead of falling back to Ocean.
- **web console**: the **Subagents** dialog is wider and shorter, like the Notebook: Helpers and At most share a row, and the four Helper strength choices sit side by side, each wearing the Subagents tab's colored level badge (Thrifty light, Balanced standard, Best strongest, Match my session plain), now ordered from lightest to strongest.
- **launcher**: when no agent CLI is installed, `plan2code` now prints each supported agent's install command and official page, and points at User Preferences → Agents for another CLI, before it exits.
- **desktop app**: a clean start is now one press. Pathfinder's **Start fresh** menu option reads **Start New Session** under the app, and sending it asks the app for its New Session (the resume command is copied first; declining the app's confirm leaves the usual finish). A finished step that names a skill to run next shows a **Start a New Session** button beside its command, also copying the command first. The plain web console keeps its wording and does neither. The app's console frame also now allows clipboard writes, so the copied command and every **Copy** button can reach the clipboard there.
- **desktop app**: the launch card's agent choice is built from the agents that are installed, so a machine with only Devin or Codex starts on it with Start enabled, instead of assuming Claude Code.
- **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/`).
- **desktop app**: the app's own bar no longer repeats the open page as a second "page: " label; the console's own bar, inside the window, already names it. The web console now knows when the agent driving it is the desktop app (the same signal that already routed `open` to the app's window) and, only there, drops advice that assumed a plain terminal: its session meter, the finished-step guide and the dashboard's red-session banner point at the app's own **New Session** button instead of a command to paste into a new conversation; its own "update available" banner, a copy-pasted shell command, never shows, since **Update skills** already covers it in one click with no shell involved; and a slash command still offered to continue a step says to paste it into the app's terminal panel, which runs the real agent CLI, rather than "a new conversation" that does not exist there. Running a plain terminal is unchanged.
+1 -1
View File
@@ -255,7 +255,7 @@
</header>
<div id="workspace">
<main id="dashboard">
<iframe id="console-frame" title="Plan2Code console dashboard"></iframe>
<iframe id="console-frame" title="Plan2Code console dashboard" allow="clipboard-write"></iframe>
<div id="dashboard-state" hidden>
<!-- Planny on a coffee break: shown only before a New Session press,
the one state here that is a question rather than a status. The
+1
View File
@@ -174,6 +174,7 @@ test("pathfinder trail: exact footer for forms A, B and C", () => {
assert.ok(c.json.text.endsWith("OR START FRESH · new conversation, paste:\n`/plan2code-0-pathfinder specs/audit-export/pathfinder --web`"));
assert.deepEqual(c.json.menu.options.map((o) => o.label), ["Row-count ceiling", "Start fresh"]);
assert.equal(c.json.menu.recommended, "Start fresh", "the checkpoint after ~3 decisions");
assert.equal(c.json.menu.options.find((o) => o.label === "Start fresh").fresh, true, "the page reads it as a clean start");
assert.equal(P("trail", "audit-export", "--form", "C").json.menu.recommended, "Row-count ceiling");
});
+65
View File
@@ -218,6 +218,71 @@ test("under the app, the meter popover's Start a New Session button asks the app
assert.deepEqual(await toApp(s, "new-session"), [{ plan2code: "new-session" }], "a named request, nothing else in it");
});
// A menu option the agent marks `fresh` (Pathfinder's "Start fresh") is a clean
// start: under the app it reads Start New Session and sending it asks the app
// for its New Session; any other option, and the classic console, do not.
const FRESH_MENU = {
items: [
{
id: "q1",
kind: "menu",
title: "Next step",
body: "Continue here, or start fresh?",
command: "/plan2code-0-pathfinder specs/x/pathfinder",
options: [
{ k: "1", text: "Row-count ceiling" },
{ k: "2", text: "Start fresh", fresh: true },
],
},
],
agent: { status: "waiting" },
};
test("under the app, a fresh menu option reads Start New Session, and picking another option starts nothing", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "pathfinder", payload: FRESH_MENU, env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
assert.equal(await s.page.getByRole("radio", { name: /Start New Session/ }).count(), 1, "the app's wording");
assert.equal(await s.page.getByText("Start fresh", { exact: true }).count(), 0, "replaces the classic one");
await s.page.getByRole("radio", { name: /Row-count ceiling/ }).check();
await s.page.click("#btn-send");
await s.page.locator("#btn-send:has-text('Send to Plan2Code')").waitFor();
assert.equal((await toApp(s, "new-session")).length, 0, "another option starts nothing");
});
test("under the app, picking the fresh menu option and sending it posts new-session", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "pathfinder", payload: FRESH_MENU, env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
await s.page.getByRole("radio", { name: /Start New Session/ }).check();
await s.page.click("#btn-send");
await until(async () => (await toApp(s, "new-session")).length === 1, 5000);
assert.deepEqual(await toApp(s, "new-session"), [{ plan2code: "new-session" }], "a named request, nothing else in it");
});
test("outside the app, a fresh menu option keeps its own wording and starts no session", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "pathfinder", payload: FRESH_MENU });
assert.equal(await s.page.getByRole("radio", { name: /Start New Session/ }).count(), 0);
await s.page.getByRole("radio", { name: /Start fresh/ }).check();
await s.page.click("#btn-send");
await s.page.locator("#btn-send:has-text('Send to Plan2Code')").waitFor();
});
test("under the app, a finish with a skill command offers Start a New Session; outside it does not", async (t) => {
const inApp = await openSession(await suite.browser(), {
t,
workflow: "implement",
payload: { agent: { status: "working", activity: "Task 1 of 1" } },
env: { PLAN2CODE_IN_APP: "1" },
init: FAKE_APP_FRAME,
});
inApp.post({ finish: { headline: "A skill next", command: "/plan2code-4-finalize" } });
await inApp.page.getByRole("heading", { name: "A skill next" }).waitFor();
await inApp.page.getByRole("button", { name: "Start a New Session" }).click();
await until(async () => (await toApp(inApp, "new-session")).length === 1, 5000);
const plain = await openSession(await suite.browser(), { t, workflow: "implement", payload: { agent: { status: "working", activity: "Task 1 of 1" } } });
plain.post({ finish: { headline: "A skill next", command: "/plan2code-4-finalize" } });
await plain.page.getByRole("heading", { name: "A skill next" }).waitFor();
assert.equal(await plain.page.getByRole("button", { name: "Start a New Session" }).count(), 0);
});
test("under the app, the not running line's continue is a button that asks the app to type it, and the page hands the app its highlight", async (t) => {
const s = await openSession(await suite.browser(), {
t,
@@ -947,7 +947,7 @@ async function cmdTrail(loc, args) {
menu = {
header: "Next step",
question: checkpoint ? "Continue here, or start fresh? Everything is saved. I recommend starting fresh, to keep me sharp." : "Continue here, or start fresh? Everything is saved.",
options: [...options, { label: "Start fresh" }],
options: [...options, { label: "Start fresh", fresh: true }],
recommended: checkpoint ? "Start fresh" : options[0].label,
why: checkpoint ? (args.heavy ? "a heavy, contested or locked decision just landed" : `${resolvedThisSession} questions resolved this session`) : "lowest NN on the frontier",
...(f.frontier.length > 3 ? { more: f.frontier.slice(3).map((x) => displayName(map, byNN.get(x.nn))) } : {}),
+1
View File
@@ -6,6 +6,7 @@ Workflow notes for `pathfinder`, part of the web console contract (`console.md`)
- Post `"stopWarning"` while no map exists (Steps 0 to 4) and `"stopWarning": ""`
once it does, and `"specDir": "specs/<idea>"` when the folder is created
(`console-stop.md` → Saying what stopping would cost).
- The menu after a decision is a `menu` card: its `options` are `trail --form C`'s, and the `Start fresh` one keeps its `"fresh": true` (the page words it "Start New Session" under the desktop app and asks the app for one on Send). Set the card's `command` to the resume command printed under `OR START FRESH`: the page copies it first. A declined confirm leaves you the pick: carry on as for any `Start fresh`.
- The fresh-idea card carries `"templates": "idea"` (`console.md` → The kinds).
- A doc that is a file exactly as written (the map once it is on disk, a
brief) goes up as a `file` block (`{ "id": "body", "file":
+17
View File
@@ -36,6 +36,23 @@ export function onAppMessage(kind, handler) {
});
}
/**
* Ask the app for what its bar's New Session button does, confirm and all.
* `command`, when there is one, goes on the clipboard first so it can be
* pasted into the new terminal; a refused copy loses nothing, the page still
* shows it.
*/
export async function startNewSession(command = "") {
if (command) {
try {
await navigator.clipboard.writeText(command);
} catch {
/* the command stays on the page to copy by hand */
}
}
tellApp("new-session");
}
/** Post `message` to the frame's parent, as `{ plan2code: kind, ...extra }`; nothing outside a frame. */
export function tellApp(kind, extra = {}) {
if (!framed()) return;
+4 -2
View File
@@ -1317,11 +1317,13 @@ function buildMenu(card, item, staged) {
radio.id = optionId(item, o, i);
radio.value = o.k;
radio.checked = Boolean(picked);
radio.setAttribute("aria-label", o.k ? `${o.k}: ${o.text}` : o.text);
// Under the app a fresh start is the bar's New Session, so say that.
const text = page.inApp && o.fresh === true ? "Start New Session" : o.text;
radio.setAttribute("aria-label", o.k ? `${o.k}: ${text}` : text);
radio.addEventListener("change", () => stage(item.id, { type: "answer", kind: "menu", k: o.k }));
const body = el("div", "option-body");
const head = el("div", "option-label");
head.appendChild(el("span", null, o.text));
head.appendChild(el("span", null, text));
if (o.recommended) head.appendChild(el("span", "pill suggested", "Suggested"));
body.appendChild(head);
if (o.detail) body.appendChild(el("p", "option-detail", o.detail));
+24 -2
View File
@@ -52,7 +52,7 @@ import { FOOTER_TIERS, footerLabel } from "../workspace.js";
import {
activity, agentAdrift, agentWorking, asked, awaitingReply, byId, dashboardLive, docs, doingNow,
finish, gitAwaiting, isDashboard, isGitBoard, isOpen, items, loadOverview, myTurn, openItems,
overviewSpec, patience, reviewPending, scan, selSpec, sendCollected, stagedCount, stranded,
overviewSpec, patience, pressStranded, reviewPending, scan, selSpec, sendCollected, stagedCount, stranded,
topics, workingMs, WORKING_GRACE_MS,
workspaceFolders,
} from "../selectors.js";
@@ -67,7 +67,7 @@ import { renderBriefButton, renderDoc, renderOverview } from "./docs.js";
import { board, renderGitBoard, resetBoard } from "./git-host.js";
import { renderWorkspace, tellFolderIssues } from "./workspace.js";
import { openHelpOn } from "./help-dialog.js";
import { linkLeavesPage, tellApp } from "../app-bridge.js";
import { linkLeavesPage, startNewSession, tellApp } from "../app-bridge.js";
import { askOfflineFlipped, askState, declineOpen, renderAside, renderAsk, renderSubagents, renderSubagentsButton } from "./ask.js";
import { renderHandoff, renderHomeButton, renderStopButton, renderStopControls, renderStopping, stopInProgress, stopWarning } from "./ending.js";
import { renderNotepadButton } from "./notepad.js";
@@ -1027,6 +1027,10 @@ let moodVar = 0;
const STRANDED_LINE =
"Plan2Code is not running. Your answers are saved and waiting for it. If the terminal is idle, type **continue** there and it will pick them up; it may also be waiting for your permission approval.";
// A finished screen's press that nothing is collecting (pressStranded()).
const PRESS_STRANDED_LINE =
"Plan2Code is not running. Your choice is saved and waiting for it. If the terminal is idle, type **continue** there and it will pick it up; it may also be waiting for your permission approval.";
// The status line's **continue**, under the app: a press asks the app to type
// it into the agent's terminal. Held off for a few seconds after, so a double
// press does not send it twice.
@@ -1109,6 +1113,10 @@ export function renderStatus() {
// Before `gone`, deliberately. Once a session has finished, no server is the
// expected state, and Planny shutting his eye over it reads as a breakage.
if (finish()) {
// A press the agent never came back for: its turn ended while the screen
// waited. The press is saved, and **continue** in the terminal collects
// it (a button that types it there, under the app).
if (pressStranded()) return say("adrift", PRESS_STRANDED_LINE, "", false, true);
// A finish with the review or the way back to the dashboard still on
// offer has something left to press here, and only while the server is
// there to take the press.
@@ -1788,6 +1796,15 @@ export function markSent({ sentIds, sentNotes = {}, summaries, values }) {
save();
}
// The menu card whose staged pick is an option marked `fresh`, if any.
function freshMenuPick(actions) {
for (const a of actions) {
const item = a.kind === "menu" ? byId(a.i) : null;
if (item && (item.options || []).some((o) => o.k === a.k && o.fresh === true)) return item;
}
return null;
}
export async function send() {
if (sendState().disabled) return;
const payload = stagedPayload();
@@ -1818,6 +1835,11 @@ export async function send() {
markSent(payload);
banner("Sent. Plan2Code is picking it up now.", "good");
setTimeout(() => banner(null), 4000);
// A menu option the agent marked `fresh` is a clean start, which under the
// app is the bar's New Session; the agent still gets the pick, so a
// declined confirm carries on with its usual finish.
const freshMenu = page.inApp ? freshMenuPick(actions) : null;
if (freshMenu) startNewSession(freshMenu.command ? handoffText({ command: freshMenu.command }) : "");
} catch (err) {
if (err && err.pending) {
banner(
+12
View File
@@ -44,6 +44,7 @@ import {
isDashboard,
} from "../selectors.js";
import { docSavedNote, downloadDoc } from "../doc-files.js";
import { startNewSession } from "../app-bridge.js";
import { pendingNotes } from "../uploads.js";
// The end of the session, and the only screen in this page whose job is to
@@ -220,6 +221,17 @@ export function renderHandoff(fin) {
row.appendChild(code);
row.appendChild(copyButton(text, "btn small handoff-copy", code));
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) {
const fresh = el("div", "handoff-newsession");
const press = el("button", "btn small", "Start a New Session");
press.type = "button";
press.addEventListener("click", () => startNewSession(text));
fresh.appendChild(press);
fresh.appendChild(el("p", "handoff-note", "The command above is copied first: paste it into the terminal panel once the new session opens."));
step.appendChild(fresh);
}
const next = continueOffer(fin);
if (next && continueLive()) step.appendChild(renderContinueOffer(next));
if (text !== command) {
+1
View File
@@ -50,6 +50,7 @@
hover it may never get. This one IS the screen's reason to exist. */
.handoff-copy { flex: none; }
.handoff-note { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-3); }
.handoff-newsession { margin-top: 10px; }
/* Continue here sits under the command row: keep a gap so the two do not touch. */
.continue-offer { margin-top: 14px; }