Show the saved diagnosis in full on the Diagnose finish, with Copy report for a ticket elsewhere

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-11 08:08:02 -08:00
1 parent 8bb1b11296
commit 15d66aa19c
6 files changed
+156 -5

No files matched your search

@@ -30,7 +30,7 @@ One row per file under `src/web-console/public/` (the games and their sound are
| `public/screens/dashboard.js` | the dashboard: cards, the spec picker, handoff chips, delete, and the first-open wake-up |
| `public/screens/loop-setup.js` | the Implementation Loop's setup screen on the dashboard (app only): the fields, their defaults and read-only facts, the Start checks, and the request to the app. The **Strength per phase** field (`strengthField`) is a grid: four headed columns (Match my session, Thrifty, Balanced, Best; level 0 to 3) and one `radiogroup` row per phase left, one radio per column (`#loop-strength-<n>-<word>`, `match` for Match my session; an unmapped word's radio is disabled and its header says "(not mapped)"), the cell's dot (`strengthBars`) over the hidden radio, and the model the pick becomes at the row's end. **Set all to** stays a select (`#loop-strength-all`, blank again after use). `drawStrengthLine(grid)` draws the grid's SVG from the checked nodes' measured positions, never from state: a very light dashed `line.col` per column and a thick square-step `path.step` from each row's node to the next (one path fewer than rows, none under two rows or with the toggle off). It redraws on the window's resize, a `ResizeObserver` on the grid (Preferences' page width), fonts loading and every redraw of the section, and stops once the grid is gone. The colors are the `--lvl-0` to `--lvl-3` tokens (`--lvl-0` is the neutral gray of Match my session); tests wait for the drawn state before reading the line. The page locks while `state.loop.driving` is set (`loopDriving()` in `selectors.js`) until the app posts `loopEnd`; Activities, Notebook, Help and Preferences stay usable. `loopEnd.can` accepts `ask` (`LOOP_CAN` in `patches.mjs`); the app adds it first to every stop that offers `resume`, and the stopped screen's **Ask a question** wakes an ordinary agent on the same session |
| `public/screens/docs.js` | documents: tabs, blocks, print and download, and the brief button |
| `public/screens/ending.js` | how a session ends: the finished screen, its offers, Stop and the way home |
| `public/screens/ending.js` | how a session ends: the finished screen, its offers, Stop and the way home; a Diagnose finish whose `doc` is saved shows that file whole as a Bug report box with Copy report (the raw Markdown), above Next step |
| `public/screens/git-host.js` | hosts the git board: tabs, panels and what each click sends |
| `public/screens/help-dialog.js` | the Help dialog and the first-run Welcome (named so it is never confused with the pure help.js). Help reads right in both modes: a phrase that differs under the desktop app carries its app wording in `data-app` (swapped in by `renderAppWording()`), and a paragraph that differs is a `.for-browser` / `.for-app` sibling pair, switched by `:root.in-app` (set in `core.js` from `page.inApp`, rule in `help.css`). The older `render*Help()` functions patch a few ids the same way. `scripts/test-web-console-page-help.mjs` sweeps every topic's visible text in each mode for the other mode's wording |
| `public/screens/looks.js` | User Preferences: the look and sound controls, which save as they change |
@@ -60,7 +60,7 @@ One row per file under `src/web-console/public/` (the games and their sound are
| `public/styles/responsive.css` | Print, then the narrow-window rules: last, so its overrides come after everything they override |
| `public/styles/shell.css` | The page shell: banner, top bar and meter, layout, sidebar, aside, footer, waiting and arrival |
| `public/styles/tokens.css` | Colors, type, sizes and the light and dark themes: the variables every other file reads |
| `public/help.js` | the Help dialog's PURE rules: `HELP_TABS` (20 tabs: ids, order, labels, diagram flags; every tab uses the chosen highlight color; Implementation Loop sits right after Watching a build, The git board right after it, and Activities right after Ask a quick question), `helpTabFor()` (which tab opens, FR-8 order, first match wins: finished → Stopping and finishing, server gone or agent adrift → When something looks stuck, opened from the Workspace dialog → Your workspace, then Ask, the Subagents tab → Helpers (subagents), a red-meter dashboard → Session meter, dashboard, a doc or the Overview, a git session → The git board, a build, else What this page is) and `helpKeyTarget()` (roving arrow keys, Home, End, wrapping; a re-export of `tabs.js`'s `tabKeyTarget`). No module-scope DOM, so `node --test` covers it |
| `public/help.js` | the Help dialog's PURE rules: `HELP_TABS` (21 tabs: ids, order, labels, diagram flags; every tab uses the chosen highlight color; Implementation Loop sits right after Watching a build, The git board right after it, and Activities right after Ask a quick question), `helpTabFor()` (which tab opens, FR-8 order, first match wins: finished → Stopping and finishing, server gone or agent adrift → When something looks stuck, opened from the Workspace dialog → Your workspace, then Ask, the Subagents tab → Helpers (subagents), a red-meter dashboard → Session meter, dashboard, a doc or the Overview, a git session → The git board, a build, else What this page is) and `helpKeyTarget()` (roving arrow keys, Home, End, wrapping; a re-export of `tabs.js`'s `tabKeyTarget`). No module-scope DOM, so `node --test` covers it |
| `public/tabs.js` | the WAI-ARIA tabs shared by Help and User Preferences: `wireTabs()` (buttons and panel links, roving tabindex, automatic activation, `aria-orientation` switching at 720 px, an optional `beforeSelect` guard) and the pure `tabKeyTarget()` |
| `public/prefs.js` | User Preferences' PURE rules: `PREFS_TABS` (Appearance, Agents & models, System, Sounds & activities, with hints and the sections each holds), `prefsOpenTab()` and `prefsResetScope()` (the looks keys Back to default resets per tab, or null) |
| `public/git-board.js` | PURE, one import (`pr-url.js`): the git board's rules from a `state.git` snapshot: branch order and the Remote only fold at `REMOTE_FOLD` 50, whether a new branch name is free, which buttons show and are enabled, whether the board still waits on the agent (`boardAwaiting()`: from a click until the agent's next post, not just until `wait` collects it), the plain sentence each click sends as `reply`, the "Last refreshed" line, which files start ticked in the commit dialog, and the pull-request link; the next step (ten rules, `nextStep()`), the tab that owns it, per-tab badges (`tabBadges()`), the busy mode and per-control gate (`busyMode()`, `controlAllowed()`), the tab to show (`pickTab()`), and the create-panel sources and clean-up groups. `app.js` only renders what it says |
+88 -1
View File
@@ -11,7 +11,7 @@ import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import { pageSuite, openSession, itemCard, drawn, textOf, tempProject , fillBox, boxValue, sendAsk } from "./page-test-helpers.mjs";
import { pageSuite, openSession, itemCard, drawn, textOf, tempProject , fillBox, boxValue, sendAsk, styleOf } from "./page-test-helpers.mjs";
import { cli, until } from "./web-console-test-helpers.mjs";
import { STOP_HANDOFF_REPLY, HOME_REPLY } from "../src/web-console/public/answers.js";
import { CHAT_OFFLINE_TEXT } from "../src/web-console/public/chat.js";
@@ -46,6 +46,23 @@ function collect(s) {
return got;
}
// A diagnosis as Diagnose writes it, for the finish screen's report box.
const DIAGNOSIS = [
"# Diagnosis: CSV export drops rows",
"",
"**Date:** 2026-11-10",
"**Status:** Diagnosed",
"",
"## The Cause",
"",
"`exportCsv` stops at the first empty cell. **Proven**",
"",
"## Suggested Fix",
"",
"Skip empty cells instead of breaking. **Size:** Small (Quick Task)",
"",
].join("\n");
// Local helper: checks `fn` keeps returning true for `ms`. A sleep would
// prove nothing; this fails the moment the page shows what it must not.
async function holds(fn, ms) {
@@ -94,6 +111,76 @@ test("the finished screen shows the next command with --web, copies it, turns Se
);
});
// A diagnosed bug often goes into another team's ticket system instead of
// being fixed here, so Diagnose's finish shows the whole saved write-up and
// copies it, word for word, as Markdown.
test("a Diagnose finish shows the saved report in full above Next step, and Copy report copies its Markdown", async (t) => {
const project = tempProject({ "specs/csv-export-drops-rows/DIAGNOSIS-20261110.md": DIAGNOSIS });
const s = await openSession(await suite.browser(), { t, workflow: "diagnose", project, payload: { agent: { status: "working" } } });
await s.context.grantPermissions(["clipboard-read", "clipboard-write"], { origin: new URL(s.url).origin });
s.post({
docs: [
{
id: "cause",
title: "The cause",
saved: "specs/csv-export-drops-rows/DIAGNOSIS-20261110.md",
blocks: [{ id: "diagnosis", file: "specs/csv-export-drops-rows/DIAGNOSIS-20261110.md" }],
},
],
});
s.post({
settle: true,
finish: {
headline: "The bug is diagnosed",
body: "The cause is proven.",
command: "/plan2code-quick-task specs/csv-export-drops-rows",
doc: "cause",
dashboard: true,
},
});
const main = s.page.locator("#main");
await main.getByRole("heading", { name: "The bug is diagnosed" }).waitFor();
const report = main.locator(".handoff-report");
await report.waitFor();
await report.getByRole("heading", { name: "Diagnosis: CSV export drops rows" }).waitFor();
assert.ok(await report.getByRole("heading", { name: "Suggested Fix" }).isVisible(), "the report is not shown in full");
const above = await s.page.evaluate(() => {
const box = document.querySelector("#main .handoff-report");
const next = document.querySelector("#main .handoff-step");
return Boolean(box && next && box.compareDocumentPosition(next) & Node.DOCUMENT_POSITION_FOLLOWING);
});
assert.ok(above, "the report does not sit above Next step");
// It scrolls, so a keyboard must be able to reach it.
await s.page.getByRole("region", { name: "Bug report" }).focus();
assert.ok(await s.page.evaluate(() => document.activeElement?.classList.contains("handoff-report-body")), "the report text takes no keyboard focus");
// Printed, it comes out whole rather than cut at its on-screen height.
await s.page.emulateMedia({ media: "print" });
assert.equal(await styleOf(main.locator(".handoff-report-body"), "maxHeight"), "none", "the printed report is cut short");
await s.page.emulateMedia({ media: "screen" });
await report.getByRole("button", { name: "Copy report" }).click();
await s.page.waitForFunction(async (want) => (await navigator.clipboard.readText()) === want, DIAGNOSIS);
});
// A finish that saved nothing (a bug that did not reproduce) has no report,
// and no other workflow's finish grows one from its doc.
test("no report box on a Diagnose finish without a saved doc, nor on another workflow's finish", async (t) => {
const s = await openSession(await suite.browser(), { t, workflow: "diagnose", payload: { agent: { status: "working" } } });
s.post({ docs: [{ id: "cause", title: "The cause", blocks: [{ id: "repro", md: "## Reproduction\n\nIt passed." }] }] });
s.post({ finish: { headline: "It did not reproduce", body: "Nothing was kept.", doc: "cause", dashboard: true } });
await s.page.locator("#main").getByRole("heading", { name: "It did not reproduce" }).waitFor();
assert.equal(await s.page.locator("#main .handoff-report").count(), 0, "an unsaved diagnosis grew a report box");
const project = tempProject({ "specs/x/PLAN-DRAFT-20261110.md": "# Plan draft\n" });
const plan = await openSession(await suite.browser(), { t, workflow: "plan", project, payload: PLAN_QUESTION });
plan.post({ docs: [{ id: "draft", title: "Draft", saved: "specs/x/PLAN-DRAFT-20261110.md", blocks: [{ id: "d", file: "specs/x/PLAN-DRAFT-20261110.md" }] }] });
plan.post({ settle: true, finish: { headline: "The plan is written", command: "/plan2code-2-document", doc: "draft", dashboard: true } });
await plan.page.locator("#main").getByRole("heading", { name: "The plan is written" }).waitFor();
assert.equal(await plan.page.locator("#main .handoff-report").count(), 0, "a plan finish grew a report box");
});
// A finish card is long: the way home must not hide below its fold. The footer
// carries the same button while the dashboard is on offer and the server is
// there, and not on a pause or a finish that never offered it.
+1 -1
View File
@@ -33,6 +33,6 @@ Once written, re-send `cause` with `"saved":"specs/<name>/DIAGNOSIS-<date>.md"`
## The finish
`command` is `/plan2code-quick-task specs/<name>` (small fix) or `/plan2code-1-plan specs/<name>` (big fix), real folder filled in. `body`: the cause, how sure, and that the next step reads the diagnosis first. `"doc":"cause"`, `"dashboard":true`. Nothing kept (did not reproduce, no guess held): no `command`, say so in `body`.
`command` is `/plan2code-quick-task specs/<name>` (small fix) or `/plan2code-1-plan specs/<name>` (big fix), real folder filled in. `body`: the cause, how sure, and that the next step reads the diagnosis first. `"doc":"cause"`, `"dashboard":true` (saved: shown whole, with Copy report). Nothing kept (did not reproduce, no guess held): no `command`, say so in `body`.
A stop before the file is written: `body` says nothing was kept (and names any throwaway script or kept test), `"command":"/plan2code-diagnose"`.
+45 -1
View File
@@ -1,6 +1,6 @@
// Plan2Code Web Console - how a session ends: the finished screen, its offers, Stop and the way home; defines only.
import { el, md, copyButton, textWithCode, SVG_NS } from "../render.js";
import { el, md, copyButton, copyText, selectContents, textWithCode, SVG_NS } from "../render.js";
import {
finishPaused,
reviewOffer,
@@ -345,6 +345,45 @@ export function renderLoopEnd(end) {
return card;
}
// The Markdown of Diagnose's saved write-up, or null: only a diagnose finish
// whose doc mirrors a file on disk (nothing is saved when the bug did not
// reproduce, and a doc living only on the page is no report yet).
function diagnosisReport(fin) {
if (!page.S || page.S.workflow !== "diagnose") return null;
const doc = docs().find((d) => d.id === fin.doc);
if (!doc || !doc.saved) return null;
const text = (doc.blocks || [])
.map((b) => (typeof b.md === "string" ? b.md : ""))
.filter((t) => t.trim())
.join("\n\n");
return text.trim() ? text : null;
}
function renderReport(text) {
const box = el("section", "handoff-report");
const head = el("div", "handoff-report-head");
head.appendChild(el("p", "handoff-label", "Bug report"));
const body = md(text, "md handoff-report-body");
// It scrolls past a set height and holds nothing focusable, so it takes a
// keyboard stop of its own to be read without a mouse.
body.tabIndex = 0;
body.setAttribute("role", "region");
body.setAttribute("aria-label", "Bug report");
const copy = el("button", "btn small", "Copy report");
copy.type = "button";
// Word for word what the file holds, so it pastes into a ticket as Markdown.
copy.addEventListener("click", () =>
copyText(text, copy, "Copy report", () => {
selectContents(body);
copy.textContent = "Press Ctrl+C";
})
);
head.appendChild(copy);
box.appendChild(head);
box.appendChild(body);
return box;
}
export function renderHandoff(fin) {
if (page.S && page.S.loopEnd) return renderLoopEnd(page.S.loopEnd);
const card = el("article", "card handoff");
@@ -352,6 +391,11 @@ export function renderHandoff(fin) {
card.appendChild(el("h2", null, fin.headline));
if (fin.body) card.appendChild(md(fin.body, "md prompt"));
// A diagnosed bug often goes into another team's ticket system rather than
// being fixed here, so the saved write-up is shown whole, above the hand-off.
const report = diagnosisReport(fin);
if (report) card.appendChild(renderReport(report));
// Every press below is waiting on an agent that is gone: the way off this
// page must not be one of them.
if (pressStranded()) card.appendChild(renderStrandedEscape());
+18
View File
@@ -13,6 +13,24 @@
border: 1px solid var(--accent-line);
border-radius: var(--radius);
}
/* Diagnose's saved write-up, whole, for pasting into a ticket elsewhere. It
scrolls past a set height so Next step stays close below it. */
.handoff-report {
margin: 20px 0 0;
padding: 14px 18px 16px;
border: 1px solid var(--rule-2);
border-radius: var(--radius);
}
.handoff-report-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 8px;
}
.handoff-report-head .handoff-label { margin: 0; }
.handoff-report-body { max-height: 420px; overflow-y: auto; }
.handoff-label {
margin: 0 0 6px;
font-size: 11px;
@@ -11,6 +11,8 @@
.layout { display: block; overflow: visible; }
.main { overflow: visible; padding: 0; max-width: none; }
.main > * { max-width: none; }
/* The diagnosis prints whole, not cut at the box's on-screen height. */
.handoff-report-body { max-height: none; overflow: visible; }
.block, .card { break-inside: avoid; box-shadow: none; }
.doc-head { border-bottom: 1px solid #ccc; }
.md a { color: #000; }