Make terminal a button that expands the collapsed agent panel

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-03 10:22:08 -08:00
1 parent bd5daa7972
commit a450604d8f
9 files changed
+131 -11

No files matched your search

+11
View File
@@ -85,6 +85,17 @@ test("app.js types the continue button's keystrokes through continueKeys, for th
assert.doesNotMatch(typeContinue, /data: 'continue'/, "no hand-typed word left beside it");
});
// The console page's What to check lines make "terminal" a button while the
// pane is collapsed (core.js renderStatus), so it must hear the pane's state.
test("app.js tells the console page whether the terminal pane is collapsed, and expands only a collapsed pane on terminal-open", () => {
const layout = APP_JS.slice(APP_JS.indexOf("function applyPaneLayout"), APP_JS.indexOf("function savePaneSettings"));
assert.match(layout, /updateBadge\(\);\s+tellTerminalState\(\);\s+\}/, "every layout change is told");
assert.match(layout, /plan2code: 'terminal-state', collapsed: paneCollapsed/, "a named message with one boolean");
assert.match(layout, /if \(!force && toldCollapsed === paneCollapsed\) return;/, "only a change is told, not every drag");
assert.match(APP_JS, /plan2code: 'taskbar-state', on \}, '\*'\);\s+tellTerminalState\(true\);/, "the page hears it on its hello");
assert.match(APP_JS, /kind === 'terminal-open'\) \{[^}]*if \(paneCollapsed\) termCollapseBtn\.click\(\);/, "the pane's own button expands it");
});
test("the bar reads project menu, New Session, agent menu, with both menus outside the scrolling row", () => {
const row = INDEX_HTML.slice(INDEX_HTML.indexOf('<div id="bar-row">'), INDEX_HTML.indexOf('<div id="project-menu"'));
const at = (id) => row.indexOf(`id="${id}"`);
+58
View File
@@ -330,6 +330,64 @@ test("under the app, the not running line's continue is a button that asks the a
assert.ok(await press.isDisabled(), "held off, so a double press does not type it twice");
});
// The app's word on its terminal panel, from a real window standing in as the
// parent (onAppMessage hears the parent only). Keeps FAKE_APP_FRAME's record.
async function tellTerminal(s, collapsed) {
await s.page.evaluate((c) => {
if (!window.__app) {
const frame = document.createElement("iframe");
document.body.append(frame);
const app = frame.contentWindow;
app.postMessage = (m) => window.__toApp.push(m);
Object.defineProperty(window, "parent", { configurable: true, get: () => app });
window.__app = app;
}
dispatchEvent(new MessageEvent("message", { data: { plan2code: "terminal-state", collapsed: c }, source: window.__app }));
}, collapsed);
}
test("under the app with the terminal panel collapsed, terminal in every What to check line is a button that asks the app to expand it", async (t) => {
const s = await openSession(await suite.browser(), {
t,
workflow: "implement",
clock: true,
payload: { headline: { stage: "Phase 1", cleared: 0, total: 3 }, agent: { status: "working", activity: "Task 1 of 3: the reader" } },
env: { PLAN2CODE_IN_APP: "1" },
init: FAKE_APP_FRAME,
});
const press = s.page.locator("#agent-text .agent-terminal-btn");
await lineSays(s, /Task 1 of 3: the reader/);
await tellTerminal(s, true);
assert.equal(await press.count(), 0, "the plain working line has no button");
// Quiet for 30 s: the approval hint.
await s.page.clock.fastForward(40_000);
await lineSays(s, /waiting on an approval in the terminal panel/);
assert.equal(await press.textContent(), "terminal");
await press.click();
await until(async () => (await toApp(s, "terminal-open")).length === 1, 5000);
assert.deepEqual(await toApp(s, "terminal-open"), [{ plan2code: "terminal-open" }], "a named request, nothing else in it");
// Quiet for two minutes: the stale line, then the panel opens.
await s.page.clock.fastForward(100_000);
await lineSays(s, /^Still working on it\./);
assert.equal(await press.count(), 1, "the stale line carries the button");
await tellTerminal(s, false);
await until(async () => (await press.count()) === 0, 5000);
assert.match(await textOf(statusLine(s)), /check your terminal/, "expanded, the word is plain again");
// Nobody listening, panel collapsed again: the not running line.
await tellTerminal(s, true);
await s.page.clock.setSystemTime(Date.now());
s.post({ items: [{ id: "q1", kind: "text", title: "What to call it", body: "A short name." }], agent: { status: "waiting" } });
await lineSays(s, /^Your turn: 1 question waiting\./);
assert.equal(await press.count(), 0, "the your-turn line has no button");
await s.page.clock.fastForward(200_000);
await lineSays(s, /^Plan2Code is not running right now\./);
assert.equal(await press.count(), 1, "the not running line carries the button");
assert.equal(await s.page.locator("#agent-text .agent-key-btn").textContent(), "continue", "continue keeps its own button");
});
// The app's webview opens no new windows, so a link off the page asks the
// console to open it in the default browser instead, and says where to paste
// it when that fails.