mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-17 04:45:33 -08:00
Size the Lessons modal like the Notebook and offer suggestions on the Lessons card
AI Assisted
This commit is contained in:
1 parent
8459836d3b
commit
a90fb8647c
7 files changed
+91
-9
No files matched your search
@@ -834,7 +834,7 @@ export function renderAside() {
|
||||
|
||||
// The cards with options to pick from, where asking what Plan2Code would pick
|
||||
// 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
|
||||
// stays in the panel: on the chip when it is live again, else the note box.
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
// and is disabled whenever a card would be.
|
||||
|
||||
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 { 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";
|
||||
|
||||
const TOP_STATES = new Set(["not-set-up", "off", "paused"]);
|
||||
@@ -345,6 +346,17 @@ export function renderLessonsDialog(on) {
|
||||
ask.appendChild(row);
|
||||
actions.appendChild(ask);
|
||||
} 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");
|
||||
later.type = "button";
|
||||
later.id = "lessons-later";
|
||||
@@ -356,7 +368,7 @@ export function renderLessonsDialog(on) {
|
||||
if (saving) go.appendChild(spinnerLabel("Saving…"));
|
||||
else go.textContent = "Save lessons";
|
||||
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."));
|
||||
}
|
||||
dlg.replaceChildren(card, actions, x);
|
||||
@@ -365,6 +377,29 @@ export function renderLessonsDialog(on) {
|
||||
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,
|
||||
* including the quiet staging of typing (a Reword field emptied, a note): on
|
||||
|
||||
@@ -193,14 +193,19 @@
|
||||
.lessons-first-about { margin: 12px 0 0; }
|
||||
.lessons-later { margin-top: 8px; }
|
||||
|
||||
/* Review from the dashboard: the same card in a dialog over the menu. */
|
||||
.modal.lessons-dialog { width: min(720px, calc(100vw - 32px)); }
|
||||
.lessons-dialog .card { margin: 0; box-shadow: none; border: 0; padding: 0; }
|
||||
/* Review from the dashboard: the same card in a dialog over the menu. Sized
|
||||
like the Notebook dialog; max-width: none lifts the base .modal 440px cap. */
|
||||
.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
|
||||
while Save lessons goes. */
|
||||
.lessons-dialog .modal-actions { align-items: center; justify-content: flex-end; }
|
||||
.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; }
|
||||
.modal-x {
|
||||
position: absolute;
|
||||
|
||||
Reference in new issue
Block a user