Size the Lessons modal like the Notebook and offer suggestions on the Lessons card

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-15 14:58:02 -08:00
1 parent 8459836d3b
commit a90fb8647c
7 files changed
+91 -9

No files matched your search

+17
View File
@@ -1,10 +1,27 @@
# General # General
### A new dialog wider than 440px needs max-width: none next to its width, sized like the Notebook dialog (min(1200px, 90vw)); the base .modal caps every dialog at 440px, so a width alone has no effect.
- Kind: correction
- About: src/web-console/public/styles/learning.css, src/web-console/public/styles/pieces.css
- Why: The Lessons dialog declared width: min(720px, ...) without max-width: none and rendered about 440px wide.
- Noted: 2026-11-15, quick-task
### A new file under src/web-console/ needs a row in the AGENTS-architecture console files tables; run scripts/test-web-console-shape.mjs after adding one, since it fails until the row exists. ### A new file under src/web-console/ needs a row in the AGENTS-architecture console files tables; run scripts/test-web-console-shape.mjs after adding one, since it fails until the row exists.
- Kind: convention - Kind: convention
- About: scripts/test-web-console-shape.mjs, .agents-docs/AGENTS-architecture-console-page.md - About: scripts/test-web-console-shape.mjs, .agents-docs/AGENTS-architecture-console-page.md
- Noted: 2026-11-14, implement-review - Noted: 2026-11-14, implement-review
### In a node:test file, start fixtures such as a test server in a root before hook, never with a top-level await after the first test(), which lets the runner run after hooks early
- Kind: correction
- About: scripts/test-script-deps.mjs
- Why: test-script-deps.mjs awaited its server mid-file and 7 tests failed on Ubuntu and macOS CI only.
- Noted: 2026-11-15, Failure log
### The launcher's prompts each open a new readline on stdin, so a test piping several answers at once loses all but the first; drive a multi-prompt flow by writing each answer after a short delay.
- Kind: how-it-works
- About: src/launcher/plan2code.js
- Noted: 2026-11-15, implement-review
### When a card in src/plan2code-deps.md changes (what it lists or asks), change the same card in src/web-console/notes/deps.md in the same edit: the console builds the card from the notes. ### When a card in src/plan2code-deps.md changes (what it lists or asks), change the same card in src/web-console/notes/deps.md in the same edit: the console builds the card from the notes.
- Kind: correction - Kind: correction
- About: src/plan2code-deps.md, src/web-console/notes/deps.md - About: src/plan2code-deps.md, src/web-console/notes/deps.md
+2
View File
@@ -14,6 +14,7 @@ All notable changes to Plan2Code will be documented in this file.
- **web console**: a swaying question mark beside Ask for suggestions, and a chevron before Send. - **web console**: a swaying question mark beside Ask for suggestions, and a chevron before Send.
- **Snake**: lives, bonus lives at score marks, and three bosses (Grumpy Golem, Comet Queen, Thunder Toad). - **Snake**: lives, bonus lives at score marks, and three bosses (Grumpy Golem, Comet Queen, Thunder Toad).
- **Bounce Road**: four new music tracks and extras. - **Bounce Road**: four new music tracks and extras.
- **web console**: Ask for suggestions is on the Lessons to keep card, in the Notes panel and in the Lessons modal, where the reply shows in a Suggestions box.
### 🔧 Changed ### 🔧 Changed
@@ -28,6 +29,7 @@ All notable changes to Plan2Code will be documented in this file.
### 🐛 Fixed ### 🐛 Fixed
- **Quick Task**: a finish that offers the review again after a review already ran in that launch is refused. - **Quick Task**: a finish that offers the review again after a review already ran in that launch is refused.
- **web console**: the Lessons modal is as wide as the Notebook (it was stuck at the 440px default).
## v3.0.6 ## v3.0.6
+3 -2
View File
@@ -392,7 +392,7 @@ const chipOf = (s) => s.page.locator("#aside").getByRole("button", { name: "Ask
// What a person sees break: the chip on a card where there is nothing to pick, // What a person sees break: the chip on a card where there is nothing to pick,
// on a settled record, or missing where they are unsure what to pick. // on a settled record, or missing where they are unsure what to pick.
test("the Ask for suggestions chip shows on open choice, multi and confirm cards only", async (t) => { test("the Ask for suggestions chip shows on open choice, multi, confirm and lessons cards only", async (t) => {
const s = await openSession(await suite.browser(), { const s = await openSession(await suite.browser(), {
t, t,
workflow: "plan", workflow: "plan",
@@ -401,13 +401,14 @@ test("the Ask for suggestions chip shows on open choice, multi and confirm cards
{ id: "c1", kind: "choice", title: "Export format", body: "Which format?", options: [opt("A", "CSV"), opt("B", "JSON")] }, { id: "c1", kind: "choice", title: "Export format", body: "Which format?", options: [opt("A", "CSV"), opt("B", "JSON")] },
{ id: "m1", kind: "multi", title: "Columns", body: "Which?", options: [opt("1", "Date"), opt("2", "User")] }, { id: "m1", kind: "multi", title: "Columns", body: "Which?", options: [opt("1", "Date"), opt("2", "User")] },
{ id: "y1", kind: "confirm", title: "Keep going", body: "Carry on?" }, { id: "y1", kind: "confirm", title: "Keep going", body: "Carry on?" },
{ id: "l1", kind: "lessons", title: "Lessons to keep", body: "Choose for each one.", required: false, rows: [{ id: "r1", type: "lesson", text: "A lesson.", why: "", origin: "You said this.", note: "", flags: [], refused: null, area: "General", kind: "convention", about: ["a.js"], areas: ["General"], choices: ["Keep", "Reword", "Drop"] }] },
{ id: "t1", kind: "text", title: "What to call it", body: "A name.", required: false }, { id: "t1", kind: "text", title: "What to call it", body: "A name.", required: false },
{ id: "d1", kind: "choice", title: "Old pick", body: "Which?", options: [opt("A", "CSV"), opt("B", "JSON")], status: "answered", answer: { k: "B" } }, { id: "d1", kind: "choice", title: "Old pick", body: "Which?", options: [opt("A", "CSV"), opt("B", "JSON")], status: "answered", answer: { k: "B" } },
], ],
agent: { status: "waiting" }, agent: { status: "waiting" },
}, },
}); });
for (const [id, title, shown] of [["c1", "Export format", 1], ["m1", "Columns", 1], ["y1", "Keep going", 1], ["t1", "What to call it", 0], ["d1", "Old pick", 0]]) { for (const [id, title, shown] of [["c1", "Export format", 1], ["m1", "Columns", 1], ["y1", "Keep going", 1], ["l1", "Lessons to keep", 1], ["t1", "What to call it", 0], ["d1", "Old pick", 0]]) {
await goTo(s, id, title); await goTo(s, id, title);
assert.equal(await chipOf(s).count(), shown, `chip on ${id}`); assert.equal(await chipOf(s).count(), shown, `chip on ${id}`);
if (shown) assert.equal(await textOf(chipOf(s)), "Ask for suggestions"); if (shown) assert.equal(await textOf(chipOf(s)), "Ask for suggestions");
@@ -517,6 +517,28 @@ test("lessons card: Not now and the corner close leave every lesson waiting and
} }
}); });
test("lessons card: the dialog has Ask for suggestions, which sends one request and shows the reply in a Suggestions box", async (t) => {
const { s, dlg } = await reviewOpen(t);
s.wait(10);
postCard(s);
await dlg.locator(".lessons-row").waitFor();
const ask = dlg.getByRole("button", { name: "Ask for suggestions" });
assert.equal(await ask.isDisabled(), false);
assert.equal(await dlg.locator(".lessons-suggestions").count(), 0, "nothing asked yet");
await ask.click();
const got = s.wait(10);
assert.equal(got.code, 0);
const sentAction = got.actions.find((a) => a.suggest === true);
assert.ok(sentAction, JSON.stringify(got.actions));
assert.equal(sentAction.i, "lessons");
assert.match(got.reply, /^Suggestions wanted on Lessons to keep:/m);
await dlg.locator(".lessons-suggestions", { hasText: "Asking Plan2Code" }).waitFor();
assert.equal(await dlg.getByRole("button", { name: "Ask for suggestions" }).isDisabled(), true, "one request waits at a time");
assert.equal(await dlg.getByRole("button", { name: "Keep" }).count(), 1, "the lessons stay open to choose");
s.post({ items: [{ id: "lessons", thread: [{ who: "agent", text: "1. Keep it: a real trap." }] }], agent: { status: "waiting" } });
await dlg.locator(".lessons-suggestions", { hasText: "Keep it: a real trap." }).waitFor();
});
test("lessons card: closing with choices made asks first, and Keep editing goes back", async (t) => { test("lessons card: closing with choices made asks first, and Keep editing goes back", async (t) => {
const { s, dlg } = await reviewOpen(t); const { s, dlg } = await reviewOpen(t);
s.wait(10); s.wait(10);
+1 -1
View File
@@ -834,7 +834,7 @@ export function renderAside() {
// The cards with options to pick from, where asking what Plan2Code would pick // The cards with options to pick from, where asking what Plan2Code would pick
// makes sense. // makes sense.
const SUGGEST_KINDS = ["choice", "multi", "confirm"]; const SUGGEST_KINDS = ["choice", "multi", "confirm", "lessons"];
// Ask for suggestions: its own send, beside the main one (core.js). Focus // Ask for suggestions: its own send, beside the main one (core.js). Focus
// stays in the panel: on the chip when it is live again, else the note box. // stays in the panel: on the chip when it is live again, else the note box.
+38 -3
View File
@@ -10,9 +10,10 @@
// and is disabled whenever a card would be. // and is disabled whenever a card would be.
import { page, redraw, hooks, stage } from "../state.js"; import { page, redraw, hooks, stage } from "../state.js";
import { el, mdInto, lightDismiss } from "../render.js"; import { el, md, mdInto, lightDismiss } from "../render.js";
import { postJson } from "../net.js"; import { postJson } from "../net.js";
import { sendState } from "../send-state.js"; import { sendState, suggestState } from "../send-state.js";
import { threadWho, threadText } from "../answers.js";
import { loopDriving, isOpen, stagedCount, learningBusyNow } from "../selectors.js"; import { loopDriving, isOpen, stagedCount, learningBusyNow } from "../selectors.js";
const TOP_STATES = new Set(["not-set-up", "off", "paused"]); const TOP_STATES = new Set(["not-set-up", "off", "paused"]);
@@ -345,6 +346,17 @@ export function renderLessonsDialog(on) {
ask.appendChild(row); ask.appendChild(row);
actions.appendChild(ask); actions.appendChild(ask);
} else { } else {
const suggest = suggestionsBox(item);
if (suggest) actions.appendChild(suggest);
// The Notes panel is not on this dialog, so its Ask for suggestions chip
// is here: the same request, answered in the Suggestions box above.
const st = suggestState(item);
const ask = el("button", "btn ghost", "Ask for suggestions");
ask.type = "button";
ask.id = "lessons-suggest";
ask.disabled = saving || st.disabled;
ask.title = st.why || "";
ask.addEventListener("click", () => hooks.askSuggestions(item.id));
const later = el("button", "btn ghost", "Not now"); const later = el("button", "btn ghost", "Not now");
later.type = "button"; later.type = "button";
later.id = "lessons-later"; later.id = "lessons-later";
@@ -356,7 +368,7 @@ export function renderLessonsDialog(on) {
if (saving) go.appendChild(spinnerLabel("Saving…")); if (saving) go.appendChild(spinnerLabel("Saving…"));
else go.textContent = "Save lessons"; else go.textContent = "Save lessons";
go.addEventListener("click", () => saveLessons(item)); go.addEventListener("click", () => saveLessons(item));
actions.append(later, go); actions.append(ask, later, go);
if (stagedCount() > 1) actions.appendChild(el("p", "help", "Anything else ready to send goes with it.")); if (stagedCount() > 1) actions.appendChild(el("p", "help", "Anything else ready to send goes with it."));
} }
dlg.replaceChildren(card, actions, x); dlg.replaceChildren(card, actions, x);
@@ -365,6 +377,29 @@ export function renderLessonsDialog(on) {
dlg.scrollTop = scroll; dlg.scrollTop = scroll;
} }
/**
* The Suggestions box above the dialog's buttons: "Asking Plan2Code…" while a
* request waits, then the agent's latest reply in the card's thread after the
* last request. Null when nothing was asked.
*/
function suggestionsBox(item) {
const thread = Array.isArray(item.thread) ? item.thread : [];
let asked = -1;
thread.forEach((m, i) => {
if (m && m.suggest === true && threadWho(m) === "user") asked = i;
});
const waiting = item.sentNote && item.sentNote.suggest === true && !thread.slice(asked + 1).some((m) => threadWho(m) === "agent");
const reply = asked >= 0 ? thread.slice(asked + 1).filter((m) => threadWho(m) === "agent").pop() : null;
if (!waiting && !reply) return null;
const box = el("div", "lessons-suggestions");
box.id = "lessons-suggestions";
box.setAttribute("role", "status");
box.appendChild(el("h3", null, "Suggestions"));
if (reply && !waiting) box.appendChild(md(threadText(reply), "md"));
else box.appendChild(el("p", "help", "Asking Plan2Code. Its answer shows here."));
return box;
}
/** /**
* The dialog's Save lessons, set again whenever what is staged changes, * The dialog's Save lessons, set again whenever what is staged changes,
* including the quiet staging of typing (a Reword field emptied, a note): on * including the quiet staging of typing (a Reword field emptied, a note): on
+8 -3
View File
@@ -193,14 +193,19 @@
.lessons-first-about { margin: 12px 0 0; } .lessons-first-about { margin: 12px 0 0; }
.lessons-later { margin-top: 8px; } .lessons-later { margin-top: 8px; }
/* Review from the dashboard: the same card in a dialog over the menu. */ /* Review from the dashboard: the same card in a dialog over the menu. Sized
.modal.lessons-dialog { width: min(720px, calc(100vw - 32px)); } like the Notebook dialog; max-width: none lifts the base .modal 440px cap. */
.lessons-dialog .card { margin: 0; box-shadow: none; border: 0; padding: 0; } .modal.lessons-dialog { width: min(1200px, 90vw); max-width: none; }
.lessons-dialog .card { margin: 0; box-shadow: none; border: 0; padding: 0; max-width: none; }
/* The lessons dialog: closable (the corner ×, Not now, Escape), and locked /* The lessons dialog: closable (the corner ×, Not now, Escape), and locked
while Save lessons goes. */ while Save lessons goes. */
.lessons-dialog .modal-actions { align-items: center; justify-content: flex-end; } .lessons-dialog .modal-actions { align-items: center; justify-content: flex-end; }
.lessons-dialog .modal-actions .btn { margin: 0; } .lessons-dialog .modal-actions .btn { margin: 0; }
.lessons-suggestions { flex: 1 1 100%; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: calc(var(--radius) * 0.5); }
.lessons-suggestions h3 { margin: 0 0 6px; font-size: 13.5px; }
.lessons-suggestions .md { max-height: 40vh; overflow: auto; font-size: 13.5px; }
.lessons-dialog .modal-actions { flex-wrap: wrap; }
.lessons-dialog .modal-actions .btn .spinner { margin-right: 8px; } .lessons-dialog .modal-actions .btn .spinner { margin-right: 8px; }
.modal-x { .modal-x {
position: absolute; position: absolute;