Add a Reconnect to agent button where the agent has gone quiet

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-05 10:03:09 -08:00
1 parent 6376a68f85
commit 30fd1134ea
11 files changed
+222 -25

No files matched your search

+6 -2
View File
@@ -861,13 +861,17 @@ export function deleteSummary(spec) {
};
}
export function staleLaunchFeedback(title, adrift) {
// `inApp`: the desktop app puts a Reconnect to agent button on the screen
// (starting.js), so the hint points at it; a browser has only the terminal.
export function staleLaunchFeedback(title, adrift, inApp = false) {
if (!adrift) return null;
return {
kicker: "Saved",
title: `${title || "Your workflow"} is saved and waiting`,
quip: "Plan2Code is not running right now.",
hint: "Return to the terminal and send any message. Plan2Code will collect this launch and continue here.",
hint: inApp
? "Press Reconnect to agent below. Plan2Code will collect this launch and continue here."
: "Return to the terminal and type continue. Plan2Code will collect this launch and continue here.",
};
}
+49
View File
@@ -0,0 +1,49 @@
// Plan2Code Web Console - the one button that wakes a quiet agent.
//
// Under the desktop app the agent's terminal is in the same window, so a press
// asks the app to type "continue" there (the app types that word and nothing
// else). A browser cannot reach a terminal, so those spots say what to type.
import { page } from "./state.js";
import { tellApp } from "./app-bridge.js";
import { el } from "./render.js";
// Held off for a few seconds after a press, so a double press does not send it twice.
const CONTINUE_HOLD_MS = 4000;
// Kept here, not on the button: a screen that redraws builds a fresh button,
// which must still be held off for the rest of the four seconds.
let heldUntil = 0;
/**
* A button asking the app to type continue into the agent's terminal. `label`
* is the button's words; the status line keeps its own small key look, the Ask
* tab and the waiting screens say "Reconnect to agent".
*/
export function continueButton(label = "continue", cls = "agent-key agent-key-btn") {
const btn = el("button", cls, label);
btn.type = "button";
btn.disabled = Date.now() < heldUntil;
btn.title = "Type continue in the agent's terminal";
btn.addEventListener("click", () => {
btn.disabled = true;
heldUntil = Date.now() + CONTINUE_HOLD_MS;
tellApp("agent-continue");
setTimeout(() => (btn.disabled = false), CONTINUE_HOLD_MS);
});
return btn;
}
/**
* What a spot with no agent to talk to offers: the button under the app, and
* under a browser a line telling the person to type continue in their terminal.
* Null when there is nothing to offer.
*/
export function reconnectOffer(cls = "reconnect-offer") {
if (page.inApp) return continueButton("Reconnect to agent", "btn small " + cls);
const note = el("p", cls + " help");
note.appendChild(document.createTextNode("To wake the agent, type "));
note.appendChild(el("strong", "agent-key", "continue"));
note.appendChild(document.createTextNode(" in your terminal."));
return note;
}
+5
View File
@@ -11,6 +11,7 @@ import { attachMentions } from "../mention-box.js";
import { makeMdField } from "../md-field.js";
import { pickerAccept, attachmentKind, noteAwaiting, threadWho, threadText } from "../answers.js";
import { postJson } from "../net.js";
import { reconnectOffer } from "../continue-button.js";
import { suggestState } from "../send-state.js";
import { CHECKIN_LINE, helperRows, showSwitch, switchLabel, defaultInstruction, PATHFINDER_RESEARCH_LINE, STRENGTHS, DEFAULT_STRENGTH, STRENGTH_HELP } from "../subagents.js";
@@ -337,6 +338,10 @@ function askComposer(ss) {
row.appendChild(hint);
}
// No agent there: under the app a button that types continue in its terminal,
// left of Send; in a browser, the line telling the person to.
if (ss.state === "offline" && !finish()) row.appendChild(reconnectOffer("ask-reconnect"));
const go = el("button", "btn small primary", "Send");
go.type = "button";
row.appendChild(go);
+10 -20
View File
@@ -72,6 +72,7 @@ import { board, renderGitBoard, resetBoard } from "./git-host.js";
import { renderWorkspace, tellFolderIssues } from "./workspace.js";
import { openHelpOn } from "./help-dialog.js";
import { linkLeavesPage, onAppMessage, startNewSession, tellApp } from "../app-bridge.js";
import { continueButton } from "../continue-button.js";
import { askOfflineFlipped, askState, declineOpen, renderAside, renderAsk, renderSubagents, renderSubagentsButton } from "./ask.js";
import { renderHandoff, renderLoopEnd, renderHomeButton, renderStopButton, renderStopControls, renderStopping, stopInProgress, stopWarning } from "./ending.js";
import { renderNotepadButton } from "./notepad.js";
@@ -1167,6 +1168,12 @@ 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.";
// The dashboard's quiet lines: the pick or the way home is saved, and typing
// **continue** in the terminal (a button under the app) wakes the agent.
const WAKE_TAIL = "If the terminal is idle, type **continue** there to wake it.";
const DASH_QUIET_LINE = `Plan2Code has gone quiet. A pick still waits here for it. ${WAKE_TAIL}`;
const HOMEWARD_QUIET_LINE = `Your way back to the dashboard is saved and waiting for Plan2Code. ${WAKE_TAIL}`;
// The agent is out of `wait` answering an Ask message (askBusy()), so a send
// waits for it to finish that first.
const ASK_BUSY_LINE = "Plan2Code is answering your Ask message. Your answers are saved, and it picks them up after that.";
@@ -1175,23 +1182,6 @@ const ASK_BUSY_LINE = "Plan2Code is answering your Ask message. Your answers are
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.
const CONTINUE_HOLD_MS = 4000;
function continueButton() {
const btn = el("button", "agent-key agent-key-btn", "continue");
btn.type = "button";
btn.title = "Type continue in the agent's terminal";
btn.addEventListener("click", () => {
btn.disabled = true;
tellApp("agent-continue");
setTimeout(() => (btn.disabled = false), CONTINUE_HOLD_MS);
});
return btn;
}
// Under the app with its terminal panel collapsed (the app's `terminal-state`),
// "terminal" in a What to check line is a button asking the app to expand it.
function terminalButton(word) {
@@ -1325,7 +1315,7 @@ export function renderStatus() {
// until the agent resumes the session as the dashboard.
if (page.local.homeward && !isDashboard()) {
return agentAdrift()
? say("adrift", "Your way back to the dashboard is saved and waiting for Plan2Code.")
? say("adrift", HOMEWARD_QUIET_LINE, "", false, true)
: say("work", "Saving your place and opening the dashboard…", "", true);
}
// The dashboard's three states, ahead of the question logic it never
@@ -1335,13 +1325,13 @@ export function renderStatus() {
if (page.local.launching) {
const stale = staleLaunchFeedback(page.local.launching.title, agentAdrift());
return stale
? say("adrift", `${page.local.launching.title} is saved and waiting for Plan2Code.`)
? say("adrift", `${page.local.launching.title} is saved and waiting for Plan2Code. ${WAKE_TAIL}`, "", false, true)
: say("work", `Waking up ${page.local.launching.title}…`, "", true);
}
if (page.dashPick) return say("point", `Start ${page.dashPick.title} when you're ready.`);
// The cards work before the agent's menu lands, so a pick is always
// theirs; the line still says what the agent is up to, or that it went quiet.
if (agentAdrift()) return say("adrift", "Plan2Code has gone quiet. A pick still waits here for it.");
if (agentAdrift()) return say("adrift", DASH_QUIET_LINE, "", false, true);
const doing = page.S.agent && typeof page.S.agent.activity === "string" ? page.S.agent.activity.trim() : "";
if (agentWorking() && !page.S.menu) return say("point", `Pick what we are doing today. ${doing || "Plan2Code is looking over the project."}`);
return say("point", "Your move: pick what we are doing today.");
+13 -2
View File
@@ -3,6 +3,7 @@
import { page, redraw } from "../state.js";
import { el, approvalTip } from "../render.js";
import { startPose, startingHint, staleLaunchFeedback, workflowTitle } from "../answers.js";
import { continueButton } from "../continue-button.js";
import { skillByName } from "../skills.js";
import { agentAdrift, doingNow, docs, loopDriving } from "../selectors.js";
@@ -119,7 +120,7 @@ export function renderLaunching(main) {
const l = page.local.launching || {};
const pane = posePane(main, "launching", l.skill && skillByName(l.skill)?.workflow);
const stale = staleLaunchFeedback(l.title, agentAdrift());
const stale = staleLaunchFeedback(l.title, agentAdrift(), page.inApp);
pane.appendChild(el("p", "card-kicker", stale ? stale.kicker : "On it"));
pane.appendChild(el("h2", "launch-title", stale ? stale.title : `Waking up ${l.title || "the next mode"}`));
pane.appendChild(el("p", "launch-quip", stale ? stale.quip : LAUNCH_QUIPS[0]));
@@ -130,6 +131,14 @@ export function renderLaunching(main) {
stale ? stale.hint : "This page turns into its home the moment it answers. No need to touch anything."
)
);
// Under the app a saved pick no agent collects gets a button that types
// continue in the terminal; the ticker shows and hides it with the hint.
if (page.inApp) {
const row = el("div", "launch-reconnect");
row.hidden = !stale;
row.appendChild(continueButton("Reconnect to agent", "btn primary"));
pane.appendChild(row);
}
startLaunchTicker();
}
@@ -211,7 +220,9 @@ function startLaunchTicker() {
return;
}
const elapsed = Date.now() - cur.at;
const stale = staleLaunchFeedback(cur.title, agentAdrift());
const stale = staleLaunchFeedback(cur.title, agentAdrift(), page.inApp);
const reconnect = document.querySelector(".launch-reconnect");
if (reconnect) reconnect.hidden = !stale;
if (kicker) kicker.textContent = stale ? stale.kicker : "On it";
if (title) title.textContent = stale ? stale.title : `Waking up ${cur.title || "the next mode"}`;
q.textContent = stale ? stale.quip : LAUNCH_QUIPS[Math.floor(elapsed / 2600) % LAUNCH_QUIPS.length];
+5
View File
@@ -149,6 +149,11 @@
.ask-actions .btn.primary { margin-left: auto; }
.ask-send-hint { margin-left: auto; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.ask-send-hint + .btn.primary { margin-left: 0; }
/* The wake-the-agent offer when nobody is there: a button (or, in a browser, a
line) pushed right so it sits directly left of Send. */
.ask-actions .ask-reconnect { margin-left: auto; }
.ask-actions .ask-reconnect + .btn.primary { margin-left: 0; }
p.ask-reconnect { margin-top: 0; margin-bottom: 0; font-size: 12.5px; }
.ask-count { font: 12px/1 var(--mono); color: var(--ink-3); }
.ask-count.is-over { color: var(--warn); font-weight: 700; }
.ask-error { color: var(--warn); font-size: 13px; margin: 8px 0 0; }
@@ -602,6 +602,9 @@
to { opacity: 1; transform: none; }
}
.launch-hint { margin: 0; font-size: 12.5px; color: var(--ink-3); max-width: 46ch; }
/* Under the app, a saved pick nobody collected: the button that types continue. */
.launch-reconnect { margin-top: 14px; }
.launch-reconnect[hidden] { display: none; }
/* A line, never a banner: no border, no background, no icon. */
.approval-tip { max-width: 70ch; margin: 18px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-3); }
+1
View File
@@ -51,6 +51,7 @@ export const SERVABLE = new Set([
"mentions.js",
"favicon.js",
"app-bridge.js",
"continue-button.js",
"git-board.js",
"git-board-view.js",
"pr-url.js",