mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Make terminal a button that expands the collapsed agent panel
AI Assisted
This commit is contained in:
1 parent
bd5daa7972
commit
a450604d8f
9 files changed
+131
-11
No files matched your search
@@ -26,7 +26,8 @@ export function linkLeavesPage(href, origin) {
|
||||
/**
|
||||
* Call `handler(data)` for each `{ plan2code: kind, ... }` message the frame's
|
||||
* parent sends, and for nothing from anywhere else (another frame, the page
|
||||
* itself). The app's only answer today is `taskbar-state`.
|
||||
* itself). The app sends `taskbar-state`, `terminal-state` and the loop's
|
||||
* answers (wireLoopMessages).
|
||||
*/
|
||||
export function onAppMessage(kind, handler) {
|
||||
window.addEventListener("message", (event) => {
|
||||
|
||||
@@ -1095,7 +1095,7 @@
|
||||
<dl>
|
||||
<dt>You see</dt><dd><strong>Not running</strong> (Planny gray and still).</dd>
|
||||
<dt>Likely cause</dt><dd>Plan2Code has not checked in for a few minutes.</dd>
|
||||
<dt>Do this</dt><dd class="for-browser">Look at the terminal. If it is idle, type <code>continue</code> there.</dd><dd class="for-app">Look at the terminal panel. If it is idle, press <strong>continue</strong> in the line beside Planny, which types it there for you.</dd>
|
||||
<dt>Do this</dt><dd class="for-browser">Look at the terminal. If it is idle, type <code>continue</code> there.</dd><dd class="for-app">Look at the terminal panel. If it is idle, press <strong>continue</strong> in the line beside Planny, which types it there for you. Panel collapsed? Press <strong>terminal</strong> in that line to expand it.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="help-row">
|
||||
|
||||
@@ -68,7 +68,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, startNewSession, tellApp } from "../app-bridge.js";
|
||||
import { linkLeavesPage, onAppMessage, startNewSession, tellApp } from "../app-bridge.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";
|
||||
@@ -1175,6 +1175,22 @@ function continueButton() {
|
||||
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) {
|
||||
const btn = el("button", "agent-terminal-btn", word);
|
||||
btn.type = "button";
|
||||
btn.title = "Expand the agent terminal panel";
|
||||
btn.addEventListener("click", () => tellApp("terminal-open"));
|
||||
return btn;
|
||||
}
|
||||
|
||||
// A line's plain text with its first "terminal" turned into terminalButton().
|
||||
function withTerminalButton(part) {
|
||||
const word = /\bterminal\b/.exec(part);
|
||||
return [document.createTextNode(part.slice(0, word.index)), terminalButton(word[0]), document.createTextNode(part.slice(word.index + word[0].length))];
|
||||
}
|
||||
|
||||
// The favicon state last told to the app (attention.rs turns it into the
|
||||
// taskbar's dot). Told only when it changes, never on every status redraw.
|
||||
let lastAttention = null;
|
||||
@@ -1204,11 +1220,17 @@ export function renderStatus() {
|
||||
moodVar = Math.floor(Math.random() * MOOD_VARIANTS[mood]);
|
||||
}
|
||||
bot.setAttribute("class", `planny is-${mood} v${moodVar}`);
|
||||
const shown = check ? `${line}|check` : line;
|
||||
const terminalLink = Boolean(check && page.inApp && page.terminalCollapsed);
|
||||
const shown = check ? `${line}|check${terminalLink ? "|terminal" : ""}` : line;
|
||||
if (text.dataset.line !== shown) {
|
||||
text.dataset.line = shown;
|
||||
const parts = line.split(/\*\*(.+?)\*\*/).map((part, i) => {
|
||||
if (i % 2 === 0) return document.createTextNode(part);
|
||||
let linked = !terminalLink;
|
||||
const parts = line.split(/\*\*(.+?)\*\*/).flatMap((part, i) => {
|
||||
if (i % 2 === 0) {
|
||||
if (linked || !/\bterminal\b/.test(part)) return document.createTextNode(part);
|
||||
linked = true;
|
||||
return withTerminalButton(part);
|
||||
}
|
||||
// Under the app the terminal is in the same window, so the word to
|
||||
// type is a button that types it there instead.
|
||||
if (page.inApp && part === "continue") return continueButton();
|
||||
@@ -2153,6 +2175,13 @@ export function wireChrome() {
|
||||
tellAttention("plain");
|
||||
});
|
||||
|
||||
// The app says whether its terminal panel is collapsed, on the page's hello
|
||||
// and on every change; the status line's terminal button follows it.
|
||||
onAppMessage("terminal-state", (data) => {
|
||||
page.terminalCollapsed = data.collapsed === true;
|
||||
renderStatus();
|
||||
});
|
||||
|
||||
// Under the app, a link off the page goes to the default browser through
|
||||
// the console: the app's window opens no new ones, so the click alone would
|
||||
// do nothing. Capture phase, ahead of any handler on the link itself.
|
||||
|
||||
@@ -111,6 +111,9 @@ export const page = {
|
||||
// false until the first frame lands, same as every other flag here, and
|
||||
// from an older server that sends none.
|
||||
inApp: false,
|
||||
// The app's terminal panel is collapsed (its `terminal-state`): the status
|
||||
// line's What to check lines then make "terminal" a button that expands it.
|
||||
terminalCollapsed: false,
|
||||
// The Implementation Loop, as the desktop app drives it: `loop` is the
|
||||
// state's `{ driving: true }` or null (it locks the page, selectors.js
|
||||
// loopDriving); `loopFacts` is what the app answered to `loop-facts`
|
||||
|
||||
@@ -118,15 +118,16 @@
|
||||
color: var(--accent);
|
||||
font-weight: 700;
|
||||
}
|
||||
/* Under the app, the word is a button that types it into the agent's terminal. */
|
||||
.agent-key-btn {
|
||||
/* Under the app, the word is a button that types it into the agent's terminal;
|
||||
"terminal" itself, while the app's panel is collapsed, expands it. */
|
||||
.agent-key-btn, .agent-terminal-btn {
|
||||
font: inherit; font-weight: 700; color: var(--accent);
|
||||
background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 6px;
|
||||
padding: 0 6px; cursor: pointer;
|
||||
}
|
||||
.agent-key-btn:hover:not(:disabled) { border-color: var(--accent); }
|
||||
.agent-key-btn:hover:not(:disabled), .agent-terminal-btn:hover { border-color: var(--accent); }
|
||||
.agent-key-btn:disabled { opacity: 0.55; cursor: default; }
|
||||
.agent-key-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
|
||||
.agent-key-btn:focus-visible, .agent-terminal-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
|
||||
|
||||
/* "What to check", beside the quiet and Not running lines. A link in a button's clothes. */
|
||||
.status-help {
|
||||
|
||||
Reference in new issue
Block a user