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

+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; }