mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 08:15:41 -08:00
Fail the macOS smoke run when the dashboard frame never connects, and update the checklist
AI Assisted
This commit is contained in:
1 parent
a9e0bf49f0
commit
615e98e11e
10 files changed
+418
-3
No files matched your search
@@ -33,6 +33,7 @@ There is no dot while busy or once a finished step has nothing left to press; a
|
||||
| `src-tauri/` | The Rust app |
|
||||
| `ui/` | The app page (plain HTML, CSS and JavaScript, no framework) |
|
||||
| `fake-agent/` | A stand-in agent program the tests run in a real pseudo-terminal |
|
||||
| `scripts/` | `vendor.mjs` (copies the xterm files into `ui/vendor/`), and CI's macOS frame check: `smoke-agent.mjs`, a stand-in agent that opens a real console, and `smoke-frame.mjs`, which waits for the console's `/health` to count the app's frame |
|
||||
| `package.json` | The app's own npm packages (xterm, the Tauri CLI). Separate from the repo root so the root and the console stay dependency-free |
|
||||
|
||||
## Build and run
|
||||
|
||||
@@ -37,11 +37,26 @@ file directly after checking it against the release's checksum list.
|
||||
- [ ] `plan2code --classic` runs the agent in the terminal with the app installed
|
||||
- [ ] Linux only: with `DISPLAY` and `WAYLAND_DISPLAY` unset, `plan2code` runs the terminal flow
|
||||
- [ ] The desktop shortcut opens the folder menu (Choose a folder first, recent folders under it) and then the app
|
||||
- [ ] macOS: started from the desktop shortcut or `plan2code` in Terminal, the app's window opens in
|
||||
front of Terminal, as the active app
|
||||
- [ ] macOS: the first start is stopped by Gatekeeper, **Open Anyway** in System Settings (Privacy &
|
||||
Security) lets it through, and `docs/desktop-app.md` describes what you saw
|
||||
- [ ] macOS and Linux: start the app from the Dock, Finder or a `.desktop` file (not a terminal) on
|
||||
a machine where Node is only on PATH through nvm, Homebrew or Volta: the first-run checklist
|
||||
still finds Node and the installed CLIs, and the console and an agent still start
|
||||
- [ ] macOS: the same from Finder with Node set up by nvm in `~/.zshrc` only (not `~/.zprofile`):
|
||||
Node and the agent are still found. With Node and an agent on the login PATH instead
|
||||
(Homebrew, or nvm in `~/.zprofile`), `~/.zshrc` is not read at start, only on Check again;
|
||||
with Homebrew's Node there but the agent installed by npm under nvm in `~/.zshrc`, the agent
|
||||
is still found at start. A hung `~/.zprofile`
|
||||
delays the start by 3 s at most and a hung `~/.zshrc` by 2 s; only a slow `~/.zprofile`
|
||||
followed by a hung `~/.zshrc` reaches 5 s
|
||||
- [ ] macOS and Linux: when the installer puts the `plan2code` command in a folder that is not on
|
||||
PATH, its closing steps say so and name the line to add and the startup file to add it to;
|
||||
done as written, `plan2code` runs in a new terminal
|
||||
- [ ] macOS: canceling the folder picker (the `plan2code` launcher's, or Workspace's add folder)
|
||||
reads as a cancel; a picker that fails instead (an `osascript` error other than -128) shows
|
||||
an error in the console, and makes the launcher ask for the folder path to be typed
|
||||
- [ ] Windows: SmartScreen's **More info**, then **Run anyway**, lets it through, and
|
||||
`docs/desktop-app.md` describes what you saw
|
||||
- [ ] `plan2code update` updates the skills, the command and the app, including while the app is
|
||||
@@ -55,6 +70,8 @@ file directly after checking it against the release's checksum list.
|
||||
## The window (each system)
|
||||
|
||||
- [ ] The dashboard shows in the frame and the terminal panel is visible beneath it
|
||||
- [ ] macOS: the frame signs in by itself (WebKit gives it no cookie, so the console moves it under
|
||||
its own `/f/<key>/` path on `127.0.0.1`); a blank frame or a sign-in page in it is a failure
|
||||
- [ ] Resizing the window keeps both usable; dragging the handle resizes the panel
|
||||
- [ ] The bar shows the project folder; the permission note appears only while an agent started
|
||||
with checks off is running, never otherwise
|
||||
@@ -112,7 +129,9 @@ Do each of Claude Code, Devin and Codex for a few minutes:
|
||||
- [ ] Pasting several lines
|
||||
- [ ] A line with Unicode and emoji
|
||||
- [ ] Select text in the terminal: it copies on its own; Ctrl+Shift+C (Windows, Linux) or Cmd+C
|
||||
(macOS) copies the selection too; Ctrl+V / Cmd+V pastes
|
||||
(macOS) copies the selection too; Ctrl+V (Windows, Linux) or Cmd+V (macOS) pastes
|
||||
- [ ] macOS: Cmd+V pastes the text once, at once, with no **Paste** menu popping up first
|
||||
- [ ] macOS: Ctrl+V reaches the agent instead of pasting (Claude Code pastes a copied image with it)
|
||||
- [ ] Exiting the agent: the agent menu reads "ended" with the reason beside it, and New Session stays
|
||||
just left of it
|
||||
|
||||
@@ -121,10 +140,22 @@ Do each of Claude Code, Devin and Codex for a few minutes:
|
||||
- [ ] Start, then **New Session**: it confirms once, with Planny on a coffee break and no claim about unsaved
|
||||
work, then a fresh agent starts on the same agent, model, effort and permission mode, and the
|
||||
dashboard shows the pick-up chip with a brief that matches the session
|
||||
- [ ] macOS and Linux: once New Session's dashboard shows, `ps -Ao pid,command | grep server.mjs` lists
|
||||
the new console only; the old one stopped when the window moved on from it
|
||||
- [ ] An agent that ends by itself leaves the app asking nothing until New Session or **Change agent**
|
||||
(in the agent menu) is pressed; Change agent reopens the launch card with a real choice to make again
|
||||
- [ ] Closing the window while an agent runs asks first, and "no" keeps the window open
|
||||
- [ ] Cmd+Q on macOS asks the same
|
||||
- [ ] macOS: Cmd+Q and the app menu's Quit ask the same while an agent works, in the window; Quit
|
||||
from the Dock's menu quits at once with no question, and its cleanup still runs
|
||||
- [ ] macOS: with another app in front, the window's close button asks in front of it, and one
|
||||
click on Quit quits; Cmd+Q with the window minimized brings the window back with the question
|
||||
- [ ] macOS and Linux: after each way of quitting (Cmd+Q, the app menu's Quit, closing the window,
|
||||
a plain `kill` of the app, Ctrl+C or closing the terminal when the app's program was run from
|
||||
one, and on macOS Quit from the Dock), with an agent running, nothing is left:
|
||||
`ps -Ao pid,pgid,command | grep -E 'plan2code-app|server.mjs'` shows no app, no agent or
|
||||
process of its group, and no console the agent opened. After an agent that ended by itself,
|
||||
the same shows no app and no console it opened, while a process it left running in its
|
||||
group on purpose (a backgrounded dev server) is still there
|
||||
- [ ] Windows only: start a CLI installed through npm (a `.cmd` shim), then New Session; check Task
|
||||
Manager and confirm no leftover `node.exe` (or the CLI's own process) is left running
|
||||
|
||||
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
// A stand-in agent for CI's smoke run of the built app (.github/workflows/app.yml).
|
||||
// Point PLAN2CODE_APP_AGENT_BIN at this file. Like a real agent, it opens a web
|
||||
// console dashboard, with the environment the app gave it, so the console
|
||||
// announces itself to the window and the dashboard frame has something to
|
||||
// connect to (smoke-frame.mjs then checks it did). The repo's fake-agent opens
|
||||
// no console, so it cannot stand in for this.
|
||||
//
|
||||
// It needs PLAN2CODE_CONSOLE_DIR (the folder holding console.mjs), ignores the
|
||||
// arguments the app passes a real agent, and then waits on its input until it
|
||||
// closes. It starts nothing else: the console server is detached, and the
|
||||
// smoke run stops it with `console.mjs stop --all`.
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const consoleDir = process.env.PLAN2CODE_CONSOLE_DIR;
|
||||
if (!consoleDir) {
|
||||
console.error('smoke-agent: PLAN2CODE_CONSOLE_DIR is not set; it names the folder holding console.mjs');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const open = spawnSync(process.execPath, [join(consoleDir, 'console.mjs'), 'open', '--workflow', 'dashboard'], {
|
||||
stdio: ['ignore', 'inherit', 'inherit'],
|
||||
});
|
||||
if (open.error || open.status !== 0) {
|
||||
console.error(`smoke-agent: console.mjs open failed (${open.error ? open.error.message : `exit ${open.status}`})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('smoke-agent: dashboard open; waiting on input');
|
||||
process.stdin.resume();
|
||||
process.stdin.on('end', () => process.exit(0));
|
||||
@@ -0,0 +1,100 @@
|
||||
// Checks the app's dashboard frame connected to its console, for CI's macOS smoke
|
||||
// run (.github/workflows/app.yml). A window that comes up but never signs its
|
||||
// frame in looks alive to a process check; the console's own browser count
|
||||
// does not lie.
|
||||
//
|
||||
// node smoke-frame.mjs [<console home>] [--timeout-ms N]
|
||||
//
|
||||
// The console home defaults to PLAN2CODE_CONSOLE_HOME. Waits for a session
|
||||
// handle there (runtime/<project hash>/<sid>.json), then polls that session's
|
||||
// open GET /health until it counts a browser. Exit 0 once one connects; exit 1
|
||||
// when the time (60 s by default, for both waits together) runs out, with the
|
||||
// last answer printed; exit 2 for a usage error.
|
||||
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { parseArgs } from 'node:util';
|
||||
|
||||
const POLL_MS = 500;
|
||||
const REQUEST_MS = 2000;
|
||||
|
||||
let parsed;
|
||||
try {
|
||||
parsed = parseArgs({ allowPositionals: true, options: { 'timeout-ms': { type: 'string' } } });
|
||||
} catch (err) {
|
||||
usage(err.message);
|
||||
}
|
||||
const home = parsed.positionals[0] || process.env.PLAN2CODE_CONSOLE_HOME;
|
||||
if (!home) usage('no console home: pass one, or set PLAN2CODE_CONSOLE_HOME');
|
||||
const timeoutMs = Number(parsed.values['timeout-ms'] ?? 60000);
|
||||
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) usage('--timeout-ms takes a positive number');
|
||||
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
let last = null;
|
||||
while (Date.now() < deadline) {
|
||||
// Read again each round: a reconnect can resume the session on a new port.
|
||||
const handle = newestHandle(home);
|
||||
if (handle) {
|
||||
last = await health(handle);
|
||||
if (last.body && last.body.sid === handle.sid && last.body.browsers >= 1) {
|
||||
console.log(`smoke-frame: the dashboard frame connected (browsers ${last.body.browsers}, port ${handle.port})`);
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, POLL_MS));
|
||||
}
|
||||
if (!last) {
|
||||
console.error(`smoke-frame: no session appeared under ${home} within ${timeoutMs} ms`);
|
||||
} else {
|
||||
console.error(`smoke-frame: no browser connected within ${timeoutMs} ms; last /health answer from port ${last.port}: ${last.text}`);
|
||||
}
|
||||
process.exit(1);
|
||||
|
||||
function usage(message) {
|
||||
console.error(`smoke-frame: ${message}\nusage: node smoke-frame.mjs [<console home>] [--timeout-ms N]`);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
// The most recently written session handle under the home, or null.
|
||||
function newestHandle(consoleHome) {
|
||||
const runtime = join(consoleHome, 'runtime');
|
||||
let newest = null;
|
||||
for (const hash of safeList(runtime)) {
|
||||
for (const name of safeList(join(runtime, hash))) {
|
||||
if (!name.endsWith('.json')) continue;
|
||||
const file = join(runtime, hash, name);
|
||||
try {
|
||||
const handle = JSON.parse(readFileSync(file, 'utf8'));
|
||||
const mtime = statSync(file).mtimeMs;
|
||||
if (Number.isInteger(handle.port) && handle.sid && (!newest || mtime > newest.mtime)) newest = { ...handle, mtime };
|
||||
} catch {
|
||||
// Half written or removed between the listing and the read: the next round sees it whole.
|
||||
}
|
||||
}
|
||||
}
|
||||
return newest;
|
||||
}
|
||||
|
||||
function safeList(dir) {
|
||||
try {
|
||||
return readdirSync(dir);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// One /health answer: the raw text for the failure message, and the body when it parsed.
|
||||
async function health(handle) {
|
||||
try {
|
||||
const res = await fetch(`http://127.0.0.1:${handle.port}/health`, { signal: AbortSignal.timeout(REQUEST_MS) });
|
||||
const text = await res.text();
|
||||
let body = null;
|
||||
try {
|
||||
body = JSON.parse(text);
|
||||
} catch {
|
||||
// Not JSON: kept as text for the message.
|
||||
}
|
||||
return { port: handle.port, text: `${res.status} ${text}`, body };
|
||||
} catch (err) {
|
||||
return { port: handle.port, text: `no answer (${err.message})`, body: null };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user