diff --git a/CHANGELOG.md b/CHANGELOG.md index e78c653..0aafc21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ All notable changes to Plan2Code will be documented in this file. - **desktop app**: dropped the bar's own context-window meter and its restart nudge, front and back: a second, separately-tuned gauge beside the console's own Session meter (how much plan2code work this session has done) read as a duplicate of it, so there is now just the one, and it already points at New Session under the app (see above). The `agent_context` command, the Claude/Codex transcript readers behind it, and the context-nudge setting it read are removed from the Rust side too, not just unwired in the page. Every button that reconnects the console (after it stops, or after Update skills) is now labeled **Reconnect the console**, replacing the earlier mix of "Restart the console" and "Start it again" for the same action, and only one shows at a time. - **web console**: Help's "When an update is out" line now knows when it is read inside the app too: there, it names **Update skills** in the bar instead of describing the dashboard's UPDATE AVAILABLE banner and a terminal command, since that banner never shows under the app and the command has no terminal to run in. - **desktop app**: the top bar's **Restart** button is now **New Session**, and every place the console names it under the app (the session meter, the dashboard's red-session banner, the finished-step guide, the Welcome tip, Help's Ask and Finishing topics, the handoff copy button's description) says so too; the meter's own advice under the app is a single **Start a New Session** button in the user's highlight colour. Its confirmation no longer claims "What it was doing is not saved" (not always true). +- **desktop app**: with nothing saved yet, the terminal panel now starts docked right at a width that keeps the console's own side panels (such as Notes) from stacking under the main content, instead of the bottom dock it always opened with before; a saved choice from before is still kept exactly as it was. +- **desktop app**: docked right and collapsed, the terminal panel's **Expand** label now reads top to bottom instead of running off the edge of the narrow strip. - **desktop app**: the agent no longer prints the console's web address in the terminal panel, since the page is already in the window beside it: `terminalLine` under the app points at the dashboard instead, and the agent contract says to give no link there. - **desktop app**: the console's "Not running... type **continue**" line makes **continue** a button under the app, which types `continue` and Enter into the agent's terminal panel for you; the session meter's **Start a New Session** button presses the bar's own New Session (its confirmation included), replacing a "Press New Session at the top of the window" sentence now that the press works from there. - **desktop app**: **New Session** now starts the fresh agent on a new console session, so the session meter starts over at green. Before, the fresh agent joined the window's old session, and the meter stayed red after the very press it asks for. The brief of where you were is still written from the old session first, and the old console shuts itself down once the window moves on. diff --git a/plan2code-app/RELEASE-CHECKLIST.md b/plan2code-app/RELEASE-CHECKLIST.md index 7faa05a..0c9e84d 100644 --- a/plan2code-app/RELEASE-CHECKLIST.md +++ b/plan2code-app/RELEASE-CHECKLIST.md @@ -59,6 +59,8 @@ failure. dashboard keeps the rest of the width; dock it back to the bottom - [ ] **Collapse** the terminal to a thin strip (either dock) and **Expand** it back; its size from before collapsing is remembered +- [ ] Docked right, collapsed: the **Expand** label reads top-to-bottom and fits inside the strip, + not sideways text running off the edge - [ ] Collapse the terminal (or shrink it small), let the agent go quiet for a while mid-answer: the "agent may need you" badge appears on the strip; expanding it clears the badge - [ ] The top bar's project and agent menus open under their name, close on a click elsewhere (the diff --git a/plan2code-app/ui/app.js b/plan2code-app/ui/app.js index b562638..11578db 100644 --- a/plan2code-app/ui/app.js +++ b/plan2code-app/ui/app.js @@ -2,7 +2,7 @@ // agent's terminal panel docked at the bottom with a drag handle. import { mountTerminal } from './terminal.js'; -import { barNextSteps, folderName, windowTitleFor } from './meter.js'; +import { barNextSteps, defaultRightFraction, folderName, windowTitleFor } from './meter.js'; const { invoke, Channel } = window.__TAURI__.core; @@ -924,6 +924,13 @@ async function main() { paneDock = state.termPanel.dock === 'right' ? 'right' : 'bottom'; paneFraction = state.termPanel.fraction; paneCollapsed = Boolean(state.termPanel.collapsed); + } else { + // Nothing saved yet: start docked right, wide enough to keep the + // console's own side-by-side panels from stacking, where the window + // allows it. + paneDock = 'right'; + paneFraction = defaultRightFraction(window.innerWidth, { minFraction: MIN_PANE, maxFraction: MAX_PANE }); + savePaneSettings(); } applyPaneLayout(); await loadAgentAvailability(); diff --git a/plan2code-app/ui/index.html b/plan2code-app/ui/index.html index ab85be8..cf85349 100644 --- a/plan2code-app/ui/index.html +++ b/plan2code-app/ui/index.html @@ -165,6 +165,13 @@ #term-toolbar button:hover { background: #333; } #term-toolbar button[aria-pressed="true"] { color: #fff; border-color: #888; } #term-panel.collapsed #term-dock, #term-panel.collapsed #term-maximize { display: none; } + /* Docked right and collapsed, the panel is a 28px-wide strip: "Expand" + does not fit sideways, so it reads top-to-bottom instead, rotated the + same way a reader would turn the panel to read it. */ + #workspace.dock-right #term-panel.collapsed #term-toolbar { padding: 6px 2px; align-items: center; } + #workspace.dock-right #term-panel.collapsed #term-collapse { + writing-mode: vertical-rl; text-orientation: mixed; padding: 6px 2px; + } #term-badge { color: #d7ba7d; font-size: 14px; line-height: 1; } #term-badge[hidden] { display: none; } #term { flex: 1; min-height: 0; min-width: 0; padding: 4px; } diff --git a/plan2code-app/ui/meter.js b/plan2code-app/ui/meter.js index 2a66f2b..79991a2 100644 --- a/plan2code-app/ui/meter.js +++ b/plan2code-app/ui/meter.js @@ -59,6 +59,27 @@ export function barNextSteps({ consoleDead = false, version = null } = {}) { return steps.map((step) => ({ ...step, label: step.action ? NEXT_STEP_LABELS[step.action] : null })); } +// Below this many px of its own width, the console's "Notes on this" aside +// stacks under the main column instead of sitting beside it +// (src/web-console/public/styles/responsive.css's 1080px breakpoint). +export const CONSOLE_ASIDE_BREAKPOINT_PX = 1080; +// A roomy default width for the terminal docked at the side, before the +// console's own width is taken into account. +const IDEAL_RIGHT_PANE_PX = 440; + +/** + * The terminal panel's width, as a share of the window, for a first run with + * nothing saved yet: docked right, at whatever width keeps the console's own + * aside panel from stacking, down to `minFraction` when the window is too + * narrow for both (its own minimum still wins over squeezing the console). + */ +export function defaultRightFraction(windowWidth, { minFraction, maxFraction, idealPanePx = IDEAL_RIGHT_PANE_PX, consoleMinPx = CONSOLE_ASIDE_BREAKPOINT_PX } = {}) { + const roomForConsole = Math.max(0, windowWidth - consoleMinPx); + const panePx = Math.min(idealPanePx, roomForConsole); + const fraction = windowWidth > 0 ? panePx / windowWidth : minFraction; + return Math.min(maxFraction, Math.max(minFraction, fraction)); +} + /** * The OS window title for a project folder: its own name (the repo's, most * of the time) after "Plan2Code - ", so two or more windows read apart in a diff --git a/scripts/test-app-meter.mjs b/scripts/test-app-meter.mjs index e34e6cc..f0449f0 100644 --- a/scripts/test-app-meter.mjs +++ b/scripts/test-app-meter.mjs @@ -11,7 +11,7 @@ import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; import { fileURLToPath, pathToFileURL } from "node:url"; -import { barNextSteps, folderName, windowTitleFor, NEXT_STEP_LABELS } from "../plan2code-app/ui/meter.js"; +import { barNextSteps, defaultRightFraction, folderName, windowTitleFor, CONSOLE_ASIDE_BREAKPOINT_PX, NEXT_STEP_LABELS } from "../plan2code-app/ui/meter.js"; import { findBrowser, launchBrowser } from "./browser.mjs"; const HERE = path.dirname(fileURLToPath(import.meta.url)); @@ -111,3 +111,55 @@ test("setProjectDir sets the OS window title through windowTitleFor, with a real assert.ok(caps.permissions.includes("core:window:allow-set-title"), "the capability to call setTitle must be granted, or the call is silently refused at runtime"); }); +test("defaultRightFraction gives the terminal a roomy width when the window has space for it, down to the floor when it does not", () => { + const opts = { minFraction: 0.1, maxFraction: 0.6 }; + // Plenty of room: the ideal 440px pane, well inside both the console's own + // 1080px minimum and the 0.6 ceiling. + assert.equal(defaultRightFraction(1920, opts), 440 / 1920); + // Just enough room for the console at 1080px and nothing more for the pane + // than that leaves: the pane shrinks to fit, never pushing the console under. + assert.equal(defaultRightFraction(1200, opts), 120 / 1200); + // No room at all for the console's own 1080px minimum: the pane's floor + // wins rather than vanishing to 0 or going negative. + assert.equal(defaultRightFraction(1000, opts), 0.1); + // The ceiling still applies even with abundant width. + assert.equal(defaultRightFraction(3000, { minFraction: 0.1, maxFraction: 0.1 }), 0.1); + assert.equal(CONSOLE_ASIDE_BREAKPOINT_PX, 1080, "matches responsive.css's own breakpoint"); +}); + +test("with nothing saved yet, app.js starts the terminal docked right via defaultRightFraction, not the bottom default", () => { + assert.match(APP_JS, /paneDock = 'right';\s*\n\s*paneFraction = defaultRightFraction\(/, "the no-saved-state branch sets dock right"); + assert.match(APP_JS, /\} else \{[\s\S]{0,200}paneDock = 'right'/, "this only runs when state.termPanel is absent, never overriding a saved choice"); +}); + +// Docked right and collapsed, the terminal panel is a 28px-wide strip: the +// Expand/Collapse button's text used to run horizontally off the edge of it +// (visible, unreadable). It now reads top-to-bottom instead. +test("docked right and collapsed, the terminal panel's Expand button fits the strip instead of overflowing it", async (t) => { + if (!findBrowser()) return t.skip("no Chrome or Edge installed"); + const browser = await launchBrowser(); + try { + const page = await browser.newPage({ viewport: { width: 1000, height: 600 } }); + page.on("pageerror", () => {}); // app.js calls into __TAURI__, absent here; the markup and CSS still load fine + await page.goto(pathToFileURL(INDEX_HTML_PATH).href); + await page.evaluate(() => { + document.getElementById("workspace").classList.add("dock-right"); + document.getElementById("term-panel").classList.add("collapsed"); + document.getElementById("term-collapse").textContent = "Expand"; + }); + const fit = await page.evaluate(() => { + const el = document.getElementById("term-collapse"); + return { + writingMode: getComputedStyle(el).writingMode, + overflowsWidth: el.scrollWidth > el.clientWidth, + overflowsPanel: el.getBoundingClientRect().right > document.getElementById("term-panel").getBoundingClientRect().right, + }; + }); + assert.equal(fit.writingMode, "vertical-rl", "the label is set to run top-to-bottom, not sideways"); + assert.equal(fit.overflowsWidth, false, "the label text does not overflow its own box"); + assert.equal(fit.overflowsPanel, false, "the button does not spill past the collapsed panel's edge"); + } finally { + await browser.close(); + } +}); +