From d32925cccff669e2c8d81978e1ffec5459de4836 Mon Sep 17 00:00:00 2001 From: Justin Parker Date: Mon, 19 Oct 2026 17:55:37 -0700 Subject: [PATCH] Add Continue here, Update CHANGELOG first and Ask prompt blocks to the web console AI Assisted --- .agents-docs/AGENTS-architecture.md | 3 +- .readme/web-console.md | 10 +++ CHANGELOG.md | 4 ++ scripts/test-web-console-chat.mjs | 14 ++++ scripts/test-web-console-logic.mjs | 52 ++++++++++++++- scripts/test-web-console-page-ask.mjs | 25 +++++++ scripts/test-web-console-page-session.mjs | 68 +++++++++++++++++++ scripts/test-web-console-session.mjs | 63 +++++++++++++++++- scripts/test-web-console-speed.mjs | 3 +- src/web-console/building-review.md | 2 +- src/web-console/cmd-help.mjs | 2 +- src/web-console/cmd-post-wait.mjs | 1 + src/web-console/console-chat.md | 28 ++++++++ src/web-console/console-finish.md | 12 ++++ src/web-console/notes/changelog.md | 4 ++ src/web-console/notes/finalize.md | 4 +- src/web-console/notes/quick-task.md | 3 +- src/web-console/patches.mjs | 9 +++ src/web-console/public/answers.js | 39 ++++++++++- src/web-console/public/hops.js | 11 +++- src/web-console/public/index.html | 39 +++++++++-- src/web-console/public/screens/core.js | 2 + src/web-console/public/screens/ending.js | 80 ++++++++++++++++++++--- src/web-console/public/selectors.js | 2 +- src/web-console/public/state.js | 2 +- 25 files changed, 454 insertions(+), 28 deletions(-) diff --git a/.agents-docs/AGENTS-architecture.md b/.agents-docs/AGENTS-architecture.md index f495be9..b824e39 100644 --- a/.agents-docs/AGENTS-architecture.md +++ b/.agents-docs/AGENTS-architecture.md @@ -203,7 +203,7 @@ Optional local browser UI shipped with **every** skill. Source lives in `src/web | `workspace.mjs` | the session's extra folders, and the folders remembered per project and spec | | `public/app.js` | the page's entry and the only page file that starts anything: the start-up block. `index.html` loads it; it imports `screens/core.js` and the screens beside it | | `public/doc-files.js` | a document as the page shows it, and as a file: blocks, Markdown and HTML download | -| `public/hops.js` | no imports: the hop rule, `startsClean(from, to)`, which says whether a hop from one workflow to another starts the new skill on a clean page (to or from the dashboard, or into Git); shared by `cmd-open.mjs`, `server.mjs` (its Ask reset) and `screens/core.js` | +| `public/hops.js` | no imports: the hop rule, `startsClean(from, to)`, which says whether a hop from one workflow to another starts the new skill on a clean page (to or from the dashboard, into Git, or from one skill into another off a finished screen, but never out of Git or into Review); shared by `cmd-open.mjs`, `server.mjs` (its Ask reset) and `screens/core.js` | | `public/looks.js` | how the page looks and sounds: the saved looks, their sync, and the preferences dialog's swatches | | `public/mention-box.js` | the @name suggestions popover under a text box | | `public/net.js` | the page talking to its own server | @@ -316,6 +316,7 @@ Key design points: - **A build tells the page how long silence is normal.** The page calls a working agent stuck after two minutes without a post, which is right for a conversation and wrong for a twenty-minute build task. `agent.quietMinutes` (1 to 60, counted only while `working`) stretches the stuck, adrift and Send-grace thresholds; `quietLimitMs()` in `answers.js` is the one rule. - **A finished quick task's review button is a request through the wait loop**, like the brief: `{ "i": "__review" }` or `{ "i": "__done" }`. The agent keeps waiting after posting a finish that carries `review`, and takes the review up by posting `"finish": null`, which puts the session back to work. Implementation's review needs no such machinery: it is a verdict on the sign-off card, asked before approval, so the session never left work to take it up. - **Back to the dashboard is the same kind of post-finish request.** A finish with `finish.dashboard: true` shows the button; a press arrives as `{ "i": "__dashboard", "type": "dashboard" }`, and the agent runs `open --resume --no-open --workflow dashboard` then posts `"finish": null` with a fresh `menu`. The agent waits ~10 minutes after the finish for it (alongside `__review` / `__done` on a quick task); after that the page swaps the button for the `/plan2code` command. `finish.command` is optional — without one the page shows the "All done" line — and `validate()` rejects a `` command and a non-boolean `dashboard`. The session-level actions are therefore `__brief`, `__stop`, `__launch`, `__review`, `__done` and `__dashboard`; a new post-finish button should copy this precedent. +- **Continue here, Update CHANGELOG first and Ask prompt blocks.** Three small additions on the same pattern. **Continue here** is page-only: `continueOffer(fin)` (`public/answers.js`) reads `finish.command`, and when it starts with a Plan2Code skill (and the finish is not a pause) `screens/ending.js` draws a button beside the Next step block, hidden when the session meter is red; the press is the dashboard's own `{ "i": "__launch", ... }` through `sendAfterBuild("launch", offer)`, so the agent writes nothing new (`startsClean()` cleans the page for the hop, except out of Git and into Review; a same-skill next step keeps the workflow, so the agent posts `"finish": null`). **Update CHANGELOG first** is `finish.changelog: true`, accepted by `validate()` only on `quick-task` and `finalize` (a paused finish is exempt from that check and the page ignores the flag), and it belongs with `commit: true`; the press is `__changelog`, a `HOP_ACTIONS` entry in `cmd-post-wait.mjs` that resumes as `changelog`, whose "Commit this now?" yes carries on to Git. **Ask prompt blocks** are contract only (`console-chat.md` → Prompts to carry away): the page already draws a Copy button on every fenced block. - **`__dashboard` also arrives mid-workflow.** A left-pointing triangle (`#btn-home`, filled with `--accent`) sits left of Stop session on every non-dashboard page. Its state comes from the pure `homeButtonState()` in `answers.js`: hidden on the dashboard, on a finish and during a stop, and otherwise gated by the same `turnGate()` Stop now uses (the person's turn, unless the agent has gone adrift). The confirm (`#home-modal`) reuses `stopWarning()`, and the submit carries the staged answers plus `__dashboard`, with `HOME_REPLY`. With no finish on the page, the agent treats it as a stop that lands on the menu: it saves its place as for `__stop`, then resumes as the dashboard with `"finish": null` + `menu`, with no finish and no stop in between (console-stop.md → "Back to the dashboard, mid-workflow"; building.md for builds). `local.homeward` drives Planny's "Saving your place and opening the dashboard…" line until the through-the-dashboard reset clears it. - **Handoffs live outside every repo, in `~/.plan2code/handoffs/`, and the console owns them** (`handoffs.mjs`; the console ships in every skill, so the Stop flow, the Handoff skill and the dashboard all reach it through `console.mjs`). `handoff new --workflow --skill [--spec specs/] [--title ] [--from-stop]` claims one for this checkout and prints `{ ok, id, path, meta }` (exit 2 bad usage, 3 a bad value). Off the dashboard the Stop modal offers **Stop with a handoff** (`#stop-handoff`, suggested) above **Just stop and save** (`#stop-go`); the first sends `__stop` with `handoff: true` and `STOP_HANDOFF_REPLY`, and `wait` adds `handoffSkill` (the built Handoff skill's `SKILL.md`, `handoffFor()`); console-stop.md gives the order (answers, save, `handoff new --from-stop`, write, paused finish naming the file, `stop`). On a dashboard, `cmdOpen()` adds `scan.handoffs` (`listHandoffs(worktree)`) and `scan.handoffsDir` after `scanProject()`, which stays handoff-free because `specs.mjs list` shares it. The picker draws them as dashed `.spec-chip.is-handoff` chips after the specs (`specSel = "handoff:"`); a picked one replaces the skill cards with `renderHandoffPreview()`: **Pick it up here**, **Read it all** (`GET /handoff?id=`, served only for an id in the dashboard's own `state.scan.handoffs`), **Copy for a new conversation** (`handoffCopyText()`) and **Delete** (`openHandoffDelete()`, one step). Pick it up sends `{ "i": "__pickup", "type": "pickup", "handoff": }`; `HOP_ACTIONS.pickup` (`pickupHop()`) reads the stored `.json` only, never the page, and falls back to Quick Task with `fallback: true` when the record, its skill or its spec is gone, or the Handoff skill wrote it (resuming that skill would only write another handoff); `markPickedUp()` stamps `usedAt` as the hop is printed, so the next scan drops the chip. Delete sends `__delete` with `handoff` in place of `spec`, and the agent runs `delete-handoff --handoff ` (`removeHandoff()`, exit 3 on a refusal, nothing touched). `open` sweeps handoffs untouched for 30 days (`staleHandoffs()`, the `.json`'s mtime, else the `.md`'s), picked up or not, and reports them in `swept.handoffs`; Cleanup never lists the folder (`KEPT_PLAN2CODE_ENTRIES`). - **Notepad: the person's, one per folder, in `~/.plan2code/notepads/`, and never the agent's.** `notepads.mjs` is the store's one owner (`PLAN2CODE_NOTEPADS_DIR` moves it for tests). The folder is the session's worktree, else its project (`notepadRoot()` in `routes.mjs`), keyed `-<12 hex>` by `notepadKey()` (the hash over `foldKey()`, so case-only path differences match on Windows and macOS, and two worktrees get two notepads), and holds `meta.json` (`{ v, folder, created }`, written once), `note.md` and `images/.jpg` with `.thumb.jpg`. Every write takes the folder's `notepad.lock`; a read never creates a file, so only the person's edits age a notepad. The page reaches it through six routes, placed after `/upload` in `ROUTES` (the shape test pins the order): `GET /notepad` (`{ text, savedAt, images: [{ id, url, thumb }] }`), `POST /notepad/text` (`{ text }`, 1 MB, 413 `too-long`), `POST /notepad/image` and `POST /notepad/thumb?id=` (raw `image/jpeg` the page re-encoded with `reencode()`, 4 MB, 200 pictures: 415 `not-jpeg`, 413 `too-large`, 409 `too-many`), `POST /notepad/image/delete` (`{ id }`) and `GET /notepad/images/[.thumb].jpg` (matched on the raw request line like `/uploads/`, served through `imagePath()`'s realpath containment, `no-store`); the four POSTs are origin-checked, and every refusal is a `NotepadError` turned into `{ error }`. None of them writes to the session folder or `events.ndjson`, and `console.mjs` never imports `notepads.mjs`, so nothing in a notepad reaches `state.json` or anything `wait` prints. **The CSP workaround.** OverType 2.6.1 (MIT, vendored unchanged as `public/vendor/overtype.esm.js`) adds a `