mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-29 05:11:19 -08:00
Restyle the web console and tidy its labels, Ask tab, cleanup and help
AI Assisted
This commit is contained in:
1 parent
710c751c2f
commit
e9679c47b9
103 files changed
+4054
-2273
No files matched your search
@@ -75,7 +75,7 @@ export function mountAgentsView(container, opts = {}) {
|
||||
const split = el("div", "split");
|
||||
const list = el("div", "split-list");
|
||||
list.dataset.av = "table";
|
||||
const add = el("button", "btn small ghost split-add", "Add agent");
|
||||
const add = el("button", "btn sm ghost split-add", "Add agent");
|
||||
add.type = "button";
|
||||
add.dataset.av = "add";
|
||||
list.appendChild(add);
|
||||
@@ -199,7 +199,7 @@ export function mountAgentsView(container, opts = {}) {
|
||||
}
|
||||
|
||||
// Leaving a form for another row drops its draft, as closing it always did:
|
||||
// a dirty one asks first (the dialog's Save / Discard / Keep editing).
|
||||
// a dirty one asks first (the dialog's Keep editing / Discard / Save).
|
||||
async function leaveForm() {
|
||||
if (!ctx.openKey) return true;
|
||||
if (isDirty(ctx.saved, ctx.drafts, ctx.openKey, ctx.strengthDrafts) && !(await confirmUnsaved())) return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ function agentInput(ctx, agent, key, label, placeholder, trim) {
|
||||
// The command's Test: where it would run from. Never saves.
|
||||
function agentTest(ctx, agent) {
|
||||
const wrap = el("div", "prefs-agents-test");
|
||||
const test = el("button", "btn small", "Test");
|
||||
const test = el("button", "btn sm", "Test");
|
||||
test.type = "button";
|
||||
const result = el("span", "help agent-test-result");
|
||||
result.setAttribute("role", "status");
|
||||
@@ -78,7 +78,7 @@ function modelRow(ctx, m, panel, onRemove) {
|
||||
row.appendChild(name);
|
||||
row.appendChild(panel ? panel.pills(m.id, m.label || m.id) : el("span"));
|
||||
if (onRemove) {
|
||||
const remove = el("button", "btn small ghost", "Remove");
|
||||
const remove = el("button", "btn sm ghost", "Remove");
|
||||
remove.type = "button";
|
||||
remove.setAttribute("aria-label", "Remove " + (m.label || m.id));
|
||||
remove.addEventListener("click", onRemove);
|
||||
@@ -101,7 +101,7 @@ function addModelRow(ctx, list, { nameRequired, taken }) {
|
||||
label.placeholder = nameRequired ? "Name shown in the menu" : "Name shown in the menu (optional)";
|
||||
label.setAttribute("aria-label", "Name shown in the menu");
|
||||
label.dataset.field = "models";
|
||||
const add = el("button", "btn small", "Add a model");
|
||||
const add = el("button", "btn sm", "Add a model");
|
||||
add.type = "button";
|
||||
const submit = () => {
|
||||
const value = id.value.trim();
|
||||
@@ -191,10 +191,10 @@ function modelsTab(ctx, key, draft) {
|
||||
function builtInLaunch(ctx, key) {
|
||||
const cli = cliOf(key);
|
||||
const entry = ctx.saved.builtins.find((b) => b.id === cli);
|
||||
const note = el("div", "note");
|
||||
const note = el("div", "callout is-info note");
|
||||
note.append(el("b", null, "Managed by Plan2Code. "), `The command and arguments for ${BUILT_IN[cli]} ship with the app and update with it. Only its models are yours to change.`);
|
||||
const list = el("dl", "kv");
|
||||
const state = el("span", "prefs-badge");
|
||||
const state = el("span", "pill is-neutral prefs-badge");
|
||||
const known = ctx.found.get(key);
|
||||
drawBadge(state, known ? known.state : "unknown");
|
||||
const command = el("dd");
|
||||
@@ -231,26 +231,26 @@ function addedLaunch(ctx, draft) {
|
||||
// confirm on the form itself (never the browser's confirm()).
|
||||
function formFoot(ctx, key) {
|
||||
const foot = el("div", "agent-foot prefs-agents-foot");
|
||||
const save = el("button", "btn small primary prefs-agents-save", "Save");
|
||||
const save = el("button", "btn sm primary prefs-agents-save", "Save");
|
||||
save.type = "button";
|
||||
save.addEventListener("click", () => ctx.save(key));
|
||||
const discard = el("button", "btn small ghost prefs-agents-discard", "Discard");
|
||||
const discard = el("button", "btn sm ghost prefs-agents-discard", "Discard");
|
||||
discard.type = "button";
|
||||
discard.addEventListener("click", () => ctx.discard());
|
||||
const badge = el("span", "prefs-unsaved-badge", "Unsaved");
|
||||
const badge = el("span", "pill is-warn prefs-unsaved-badge", "Unsaved");
|
||||
foot.append(save, discard, badge);
|
||||
if (ctx.formReplace) {
|
||||
const anyway = el("button", "btn small danger prefs-agents-replace", "Save anyway");
|
||||
const anyway = el("button", "btn sm danger prefs-agents-replace", "Save anyway");
|
||||
anyway.type = "button";
|
||||
anyway.addEventListener("click", () => ctx.save(key, { replace: true }));
|
||||
foot.append(anyway);
|
||||
}
|
||||
if (key.startsWith("agent:") && key !== "agent:new") {
|
||||
if (ctx.confirming) {
|
||||
const yes = el("button", "btn small danger", "Yes, delete");
|
||||
const yes = el("button", "btn sm danger", "Yes, delete");
|
||||
yes.type = "button";
|
||||
yes.addEventListener("click", () => ctx.deleteAgent(key));
|
||||
const keep = el("button", "btn small ghost", "Keep");
|
||||
const keep = el("button", "btn sm ghost", "Keep");
|
||||
keep.type = "button";
|
||||
keep.addEventListener("click", () => {
|
||||
ctx.confirming = false;
|
||||
@@ -258,7 +258,7 @@ function formFoot(ctx, key) {
|
||||
});
|
||||
foot.append(el("span", "help", "Delete this agent?"), yes, keep);
|
||||
} else {
|
||||
const del = el("button", "btn small ghost danger prefs-agents-delete", "Delete agent");
|
||||
const del = el("button", "btn sm ghost danger prefs-agents-delete", "Delete agent");
|
||||
del.type = "button";
|
||||
del.addEventListener("click", () => {
|
||||
ctx.confirming = true;
|
||||
@@ -323,11 +323,11 @@ export function drawForm(ctx) {
|
||||
if (isCli) title.append(el("span", null, BUILT_IN[cliOf(key)]), el("code", null, cliOf(key)));
|
||||
else {
|
||||
title.append(el("span", null, key === "agent:new" ? "New agent" : savedEntry(ctx.saved, key).name));
|
||||
if (key === "agent:new" && ctx.draftFrom) title.append(el("span", "tag", `From the ${ctx.draftFrom} template`));
|
||||
if (key === "agent:new" && ctx.draftFrom) title.append(el("span", "pill is-neutral tag", `From the ${ctx.draftFrom} template`));
|
||||
}
|
||||
head.appendChild(title);
|
||||
if (ctx.$("drawer")) {
|
||||
const close = el("button", "btn small ghost drawer-close", "Close");
|
||||
const close = el("button", "btn sm ghost drawer-close", "Close");
|
||||
close.type = "button";
|
||||
close.setAttribute("aria-label", "Close");
|
||||
close.addEventListener("click", () => ctx.closeDrawer());
|
||||
|
||||
@@ -16,7 +16,7 @@ export function listEditor({ list, kind = "text", field = kind === "models" ? "m
|
||||
box.replaceChildren();
|
||||
list.forEach((item, i) => {
|
||||
const row = el("div", kind === "models" ? "agent-row model" : "agent-row");
|
||||
const remove = el("button", "btn small ghost", "Remove");
|
||||
const remove = el("button", "btn sm ghost", "Remove");
|
||||
remove.type = "button";
|
||||
remove.addEventListener("click", () => {
|
||||
list.splice(i, 1);
|
||||
@@ -59,7 +59,7 @@ export function listEditor({ list, kind = "text", field = kind === "models" ? "m
|
||||
}
|
||||
box.appendChild(row);
|
||||
});
|
||||
const add = el("button", "btn small ghost", addLabel);
|
||||
const add = el("button", "btn sm ghost", addLabel);
|
||||
add.type = "button";
|
||||
add.addEventListener("click", () => {
|
||||
list.push(kind === "models" ? (optionalName ? { id: "" } : { id: "", label: "" }) : "");
|
||||
|
||||
@@ -59,6 +59,15 @@ export function strengthsPanel(ctx, agentId, draft, { models, hasEffort }) {
|
||||
const m = modelList().find((x) => x.id === id);
|
||||
return m ? m.label || m.id : id;
|
||||
};
|
||||
// The picked model as the model rows show it: the label (the description only,
|
||||
// "latest Sonnet") with its id under it, as the launcher prints them side by side.
|
||||
const modelName = (id) => {
|
||||
const label = labelOf(id);
|
||||
const span = el("span", "strength-model model-name");
|
||||
span.append(label);
|
||||
if (label !== id) span.append(el("code", null, id));
|
||||
return span;
|
||||
};
|
||||
|
||||
const box = el("div", "strength-body prefs-agents-strengths");
|
||||
const pillSets = [];
|
||||
@@ -100,7 +109,7 @@ export function strengthsPanel(ctx, agentId, draft, { models, hasEffort }) {
|
||||
label.append(wordChip(word), el("small", "help", HINTS[word]));
|
||||
row.appendChild(label);
|
||||
const pick = resolved[word];
|
||||
row.appendChild(el("span", pick ? "strength-model" : "strength-model none", pick ? labelOf(pick.model) : "not mapped"));
|
||||
row.appendChild(pick ? modelName(pick.model) : el("span", "strength-model none", "not mapped"));
|
||||
if (hasEffort) {
|
||||
const effort = el("select");
|
||||
effort.dataset.field = "effort";
|
||||
@@ -117,7 +126,7 @@ export function strengthsPanel(ctx, agentId, draft, { models, hasEffort }) {
|
||||
row.appendChild(effort);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(user, word)) {
|
||||
const reset = el("button", "btn small ghost strength-reset", "Reset");
|
||||
const reset = el("button", "btn sm ghost strength-reset", "Reset");
|
||||
reset.type = "button";
|
||||
reset.dataset.field = "reset";
|
||||
reset.setAttribute("aria-label", `Reset ${WORDS[word]}`);
|
||||
|
||||
@@ -23,20 +23,21 @@ export const BADGES = {
|
||||
unknown: "Not checked",
|
||||
};
|
||||
|
||||
const TONE_OF = { ok: "is-ok", missing: "is-warn" };
|
||||
|
||||
export function drawBadge(badge, state) {
|
||||
badge.textContent = BADGES[state];
|
||||
badge.classList.remove("ok", "missing");
|
||||
if (state !== "unknown") badge.classList.add(state);
|
||||
badge.classList.remove("ok", "missing", "is-ok", "is-warn");
|
||||
if (state !== "unknown") badge.classList.add(state, TONE_OF[state]);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- the prefs cards */
|
||||
|
||||
// A model's name without its gloss ("Sonnet, latest Sonnet" or "Opus plan: Opus in plan mode" is cut at the first separator), so a card line stays one line.
|
||||
const GLOSS = new RegExp(" " + String.fromCharCode(8212) + " |, |: ");
|
||||
const shortLabel = (label) => label.split(GLOSS)[0];
|
||||
|
||||
// The model each strength resolves to for one row, as [word, label, effort]
|
||||
// triples; empty while the strengths did not load.
|
||||
// The model each strength resolves to for one row, as [word, model, effort]
|
||||
// triples (model a { id, label } row, or null); empty while the strengths did
|
||||
// not load. A card line names the model by its id, the name the launcher's
|
||||
// menu, --model and the loop setup use; a label is the description only
|
||||
// ("latest Sonnet"), so it rides along as the line's tooltip.
|
||||
function strengthLines(ctx, row) {
|
||||
if (!ctx.modelsLoaded) return [];
|
||||
const isCli = row.key.startsWith("cli:");
|
||||
@@ -50,7 +51,7 @@ function strengthLines(ctx, row) {
|
||||
return STRENGTH_ORDER.map((word) => {
|
||||
const pick = resolved[word];
|
||||
const model = pick && row.models.find((m) => m.id === pick.model);
|
||||
return [word, model ? shortLabel(model.label || model.id) : null, pick && pick.effort];
|
||||
return [word, model || null, pick && pick.effort];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,10 +67,10 @@ function agentCard(ctx, row, check) {
|
||||
const top = el("span", "card-top");
|
||||
const who = el("span", "card-who");
|
||||
const name = el("span", "row-name", row.name);
|
||||
if (row.key.startsWith("agent:")) name.append(" ", el("span", "tag", "Custom"));
|
||||
if (row.key.startsWith("agent:")) name.append(" ", el("span", "pill is-neutral tag", "Custom"));
|
||||
who.append(name, el("code", null, row.command));
|
||||
top.appendChild(who);
|
||||
const badge = el("span", "prefs-badge");
|
||||
const badge = el("span", "pill is-neutral prefs-badge");
|
||||
const known = serverStateFor(ctx.saved, row);
|
||||
if (known) {
|
||||
ctx.found.set(row.key, { command: row.command, state: known });
|
||||
@@ -87,9 +88,14 @@ function agentCard(ctx, row, check) {
|
||||
const lines = strengthLines(ctx, row);
|
||||
if (lines.length) {
|
||||
const tiers = el("span", "card-tiers");
|
||||
for (const [word, label, effort] of lines) {
|
||||
for (const [word, model, effort] of lines) {
|
||||
const line = el("span", "card-tier");
|
||||
line.append(wordChip(word), label ? el("span", null, effort ? `${label} · ${effort}` : label) : el("span", "muted", "not mapped"));
|
||||
let named = el("span", "muted", "not mapped");
|
||||
if (model) {
|
||||
named = el("span", null, effort ? `${model.id} · ${effort}` : model.id);
|
||||
if (model.label && model.label !== model.id) named.title = model.label;
|
||||
}
|
||||
line.append(wordChip(word), named);
|
||||
tiers.appendChild(line);
|
||||
}
|
||||
r.appendChild(tiers);
|
||||
@@ -106,16 +112,16 @@ function agentCard(ctx, row, check) {
|
||||
// The badge a setup row's state gets: the glanceable half, with the pane
|
||||
// beside it saying what the state means and what can be done about it.
|
||||
function setupStateBadge(entry) {
|
||||
const badge = el("span", "prefs-badge");
|
||||
const badge = el("span", "pill is-neutral prefs-badge");
|
||||
if (entry.state === "found") {
|
||||
badge.textContent = "Found";
|
||||
badge.classList.add("ok");
|
||||
badge.classList.add("ok", "is-ok");
|
||||
} else if (entry.state === "outside") {
|
||||
badge.textContent = "Found outside PATH";
|
||||
badge.classList.add("missing");
|
||||
badge.classList.add("missing", "is-warn");
|
||||
} else if (entry.state === "missing") {
|
||||
badge.textContent = "Not found";
|
||||
badge.classList.add("missing");
|
||||
badge.classList.add("missing", "is-warn");
|
||||
} else {
|
||||
badge.textContent = "Not checked";
|
||||
}
|
||||
@@ -196,7 +202,7 @@ function setupStateArea(ctx, entry) {
|
||||
area.appendChild(line);
|
||||
// A session opened for one CLI only offers that one's Start.
|
||||
if (ctx.onStart && (!ctx.forCli() || entry.id === ctx.forCli())) {
|
||||
const start = el("button", "btn small primary", "Start with this agent");
|
||||
const start = el("button", "btn sm primary", "Start with this agent");
|
||||
start.type = "button";
|
||||
start.addEventListener("click", () => ctx.onStart(entry));
|
||||
area.appendChild(start);
|
||||
@@ -205,7 +211,7 @@ function setupStateArea(ctx, entry) {
|
||||
const line = el("p", "setup-agent-line");
|
||||
line.append(badge, ` Found at ${entry.path || ""}, but not on PATH`);
|
||||
area.appendChild(line);
|
||||
const use = el("button", "btn small", "Use it from here");
|
||||
const use = el("button", "btn sm", "Use it from here");
|
||||
use.type = "button";
|
||||
use.addEventListener("click", () => ctx.useFromHere(entry));
|
||||
area.appendChild(use);
|
||||
@@ -242,7 +248,7 @@ function templatePane(ctx, template) {
|
||||
head.appendChild(title);
|
||||
box.appendChild(head);
|
||||
if (template.note) box.appendChild(el("p", "help", template.note));
|
||||
const use = el("button", "btn small", "Use this template");
|
||||
const use = el("button", "btn sm", "Use this template");
|
||||
use.type = "button";
|
||||
use.addEventListener("click", () => {
|
||||
// Cloned: the form edits the draft in place, and saved.templates is
|
||||
@@ -274,7 +280,7 @@ export function drawSummaryPane(ctx) {
|
||||
head.appendChild(title);
|
||||
box.append(head, setupStateArea(ctx, entry));
|
||||
if (ctx.saved.agents.includes(entry)) {
|
||||
const edit = el("button", "btn small", "Edit");
|
||||
const edit = el("button", "btn sm", "Edit");
|
||||
edit.type = "button";
|
||||
edit.setAttribute("aria-label", "Edit " + (entry.name || entry.id));
|
||||
edit.addEventListener("click", () => ctx.pick("agent:" + entry.id));
|
||||
@@ -287,7 +293,7 @@ export function drawSummaryPane(ctx) {
|
||||
pane.appendChild(templatePane(ctx, template));
|
||||
return;
|
||||
}
|
||||
pane.appendChild(el("div", "split-empty", "Pick an agent on the left to see its state and the way forward."));
|
||||
pane.appendChild(el("div", "empty", "Pick an agent on the left to see its state and the way forward."));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ the Add agent chooser */
|
||||
@@ -308,7 +314,7 @@ export function drawChooser(ctx) {
|
||||
const head = el("div", "chooser-head");
|
||||
const title = el("h3", null, "Add an agent");
|
||||
title.id = "agents-chooser-title";
|
||||
const close = el("button", "btn small ghost", "Cancel");
|
||||
const close = el("button", "btn sm ghost", "Cancel");
|
||||
close.type = "button";
|
||||
close.addEventListener("click", () => ctx.closeChooser());
|
||||
head.append(title, close);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Plan2Code Web Console - the Ask chat, the Subagents tab, and attaching files to notes.
|
||||
|
||||
import { NOT_CONNECTED } from "../labels.js";
|
||||
import { page, saveNow, redraw, freshChat, hooks, scrollMemory, setDraft } from "../state.js";
|
||||
import { chatAnswering, chatOffline, chatView, sendState as chatSendState, newestReplyId, CHAT_MAX_CHARS, nextAbout, CHAT_MAX_ATTACHMENTS, contextOptions } from "../chat.js";
|
||||
import { finish, activity, agentAdrift, isDashboard, selSpec, byId, isOpen, loopAskLocked, loopDriving } from "../selectors.js";
|
||||
import { el, md, isMac, lightDismiss, shortTime } from "../render.js";
|
||||
import { el, icon, md, isMac, lightDismiss, shortTime } from "../render.js";
|
||||
import { startersFor } from "../starters.js";
|
||||
import { looks } from "../looks.js";
|
||||
import { thumbs, uploadUrl, docChip, attachTray, CHAT_IMAGES, attachFiles, incomingFiles, deleteUrl, sentAttachments, noteImages, attachRow, openPicview, refocusThumb } from "../uploads.js";
|
||||
@@ -89,7 +90,7 @@ export function renderAsk(main, held = null) {
|
||||
const head = el("div", "ask-head");
|
||||
head.appendChild(el("h2", null, "Quick question"));
|
||||
head.appendChild(el("span", "ask-counter", v.counterText));
|
||||
const reset = el("button", "btn small ghost", "New conversation");
|
||||
const reset = el("button", "btn sm ghost", "New conversation");
|
||||
reset.type = "button";
|
||||
reset.disabled = ss.state === "offline" || chatResetting;
|
||||
reset.addEventListener("click", newConversation);
|
||||
@@ -183,7 +184,7 @@ function askStarters(ss) {
|
||||
const box = el("div", "ask-starters");
|
||||
box.appendChild(el("p", "ask-starters-lead", "Not sure what to ask? Try one of these:"));
|
||||
for (const starter of startersFor(page.S.workflow, looks.role, { hasContext: Boolean(page.local.chat.about) })) {
|
||||
const b = el("button", "ask-starter", starter.text);
|
||||
const b = el("button", "btn sm ask-starter", starter.text);
|
||||
b.type = "button";
|
||||
b.disabled = !ss.canType;
|
||||
b.addEventListener("click", () => {
|
||||
@@ -206,7 +207,7 @@ function askRow(r, ss, notes) {
|
||||
const working = r.decision === "approve" && !r.done;
|
||||
const line = el("p", working ? "ask-decision working" : "ask-decision");
|
||||
if (working) line.appendChild(el("span", "spinner tiny"));
|
||||
line.appendChild(document.createTextNode(r.decision !== "approve" ? "You declined the edit." : r.done ? "You approved the edit." : "You approved the edit, please wait..."));
|
||||
line.appendChild(document.createTextNode(r.decision !== "approve" ? "You declined the edit." : r.done ? "You approved the edit." : "You approved the edit. Applying it…"));
|
||||
row.appendChild(line);
|
||||
if (r.text) row.appendChild(el("p", "ask-text", r.text));
|
||||
return row;
|
||||
@@ -259,8 +260,8 @@ function askRow(r, ss, notes) {
|
||||
row.appendChild(tray);
|
||||
}
|
||||
if (r.pending && r.failed) {
|
||||
const fail = el("p", "ask-waiting ask-failed", "Not sent — retry");
|
||||
const retry = el("button", "btn tiny", "Retry");
|
||||
const fail = el("p", "ask-waiting ask-failed", "Not sent: retry");
|
||||
const retry = el("button", "btn xs soft", "Retry");
|
||||
retry.type = "button";
|
||||
retry.disabled = ss.state === "offline" || chatSending;
|
||||
retry.addEventListener("click", () => retryChat(r.tempId));
|
||||
@@ -285,7 +286,7 @@ function askRow(r, ss, notes) {
|
||||
}
|
||||
|
||||
function askProposal(r, ss, note) {
|
||||
const box = el("div", "ask-proposal");
|
||||
const box = el("div", "callout is-stage ask-proposal");
|
||||
box.appendChild(el("p", "note-kicker", "Proposed change"));
|
||||
box.appendChild(md(r.proposal.summary, "md"));
|
||||
const files = el("ul", "ask-proposal-files");
|
||||
@@ -303,13 +304,13 @@ function askProposal(r, ss, note) {
|
||||
}
|
||||
const busy = deciding.has(r.id) || ss.state === "offline";
|
||||
const row = el("div", "ask-proposal-actions");
|
||||
const approve = el("button", "btn small primary", "Approve");
|
||||
const approve = el("button", "btn sm primary", "Approve");
|
||||
approve.type = "button";
|
||||
approve.disabled = busy;
|
||||
approve.addEventListener("click", () => decideChat(r.id, "approve", ""));
|
||||
row.appendChild(approve);
|
||||
if (!declineOpen.has(r.id)) {
|
||||
const decline = el("button", "btn small ghost", "Decline");
|
||||
const decline = el("button", "btn sm ghost", "Decline");
|
||||
decline.type = "button";
|
||||
decline.disabled = busy;
|
||||
decline.addEventListener("click", () => {
|
||||
@@ -333,7 +334,7 @@ function askProposal(r, ss, note) {
|
||||
decideChat(r.id, "decline", input.value);
|
||||
});
|
||||
row.appendChild(input);
|
||||
const go = el("button", "btn small", "Send decline");
|
||||
const go = el("button", "btn sm", "Send decline");
|
||||
go.type = "button";
|
||||
go.disabled = busy;
|
||||
go.addEventListener("click", () => decideChat(r.id, "decline", declineOpen.get(r.id) || ""));
|
||||
@@ -352,7 +353,8 @@ function askComposer(ss) {
|
||||
if (about) {
|
||||
const chip = el("div", "ask-about-chip");
|
||||
chip.appendChild(el("span", null, "About: " + about.label));
|
||||
const x = el("button", "attach-remove", "×");
|
||||
const x = el("button", "attach-remove");
|
||||
x.appendChild(icon("close"));
|
||||
x.type = "button";
|
||||
x.setAttribute("aria-label", "Send without this");
|
||||
x.addEventListener("click", () => {
|
||||
@@ -376,7 +378,7 @@ function askComposer(ss) {
|
||||
comp.appendChild(ta.el);
|
||||
|
||||
const row = el("div", "ask-actions");
|
||||
const add = el("button", "btn small ghost", "+ Attach file");
|
||||
const add = el("button", "btn sm ghost", "+ Attach file");
|
||||
add.type = "button";
|
||||
add.setAttribute("aria-label", "Add files to this question");
|
||||
add.disabled = !ss.canType || page.local.chat.images.length >= CHAT_MAX_ATTACHMENTS;
|
||||
@@ -399,7 +401,7 @@ function askComposer(ss) {
|
||||
const counter = el("span", "ask-count");
|
||||
if (!ss.canType) {
|
||||
const cls = ss.state === "offline" ? "is-offline" : ss.state === "limit" ? "is-limit" : "is-waiting";
|
||||
row.appendChild(el("p", "ask-disabled-note " + cls, ss.text));
|
||||
row.appendChild(el("p", "ask-disabled-note " + cls + (ss.state === "offline" ? " callout is-warn" : ""), ss.text));
|
||||
} else {
|
||||
row.appendChild(counter);
|
||||
const hint = el("span", "ask-send-hint");
|
||||
@@ -413,7 +415,7 @@ function askComposer(ss) {
|
||||
// left of Send; in a browser, the line telling the person to.
|
||||
if (ss.state === "offline" && !finish()) row.appendChild(reconnectOffer("ask-reconnect"));
|
||||
|
||||
const go = el("button", "btn small primary", "Send");
|
||||
const go = el("button", "btn sm primary", "Send");
|
||||
go.type = "button";
|
||||
row.appendChild(go);
|
||||
comp.appendChild(row);
|
||||
@@ -476,7 +478,7 @@ function addContext(ss) {
|
||||
const wrap = el("span", "ask-context");
|
||||
const spec = isDashboard() ? selSpec() : page.S && page.S.specDir ? { dir: page.S.specDir } : null;
|
||||
const options = contextOptions(page.local.chat, spec);
|
||||
const btn = el("button", "btn small ghost", "+ Add context");
|
||||
const btn = el("button", "btn sm ghost", "+ Add context");
|
||||
btn.type = "button";
|
||||
btn.setAttribute("aria-haspopup", "menu");
|
||||
btn.setAttribute("aria-expanded", "false");
|
||||
@@ -551,7 +553,7 @@ function addContext(ss) {
|
||||
}
|
||||
|
||||
const CHAT_ERRORS = {
|
||||
stale: "A new conversation started. Your message is still here — press Send again.",
|
||||
stale: "A new conversation started. Your message is still here: press Send again.",
|
||||
"too-long": `That message is over ${CHAT_MAX_CHARS.toLocaleString()} characters. Shorten it and send again.`,
|
||||
image: "One of the images could not be attached. Remove it and try again.",
|
||||
file: "One of the files could not be attached. Remove it and try again.",
|
||||
@@ -713,8 +715,9 @@ export function renderAside() {
|
||||
// belong to a question stay on its own page.
|
||||
const item = page.view === "end" ? null : byId(page.selected);
|
||||
if (!item) {
|
||||
// The menu has no questions, so no notes either: the pane stays empty.
|
||||
if (!isDashboard()) aside.appendChild(el("p", "aside-empty", askOffered() ? ASK_HINT : "Pick a question to see its notes."));
|
||||
// No question, so no notes either: the pane stays empty (and its column
|
||||
// collapses, shell.css) unless the stopped loop has its one hint to give.
|
||||
if (!isDashboard() && askOffered()) aside.appendChild(el("p", "empty", ASK_HINT));
|
||||
return;
|
||||
}
|
||||
// Off the question's own page (a doc tab, Ask) "this" points at nothing on
|
||||
@@ -727,7 +730,7 @@ export function renderAside() {
|
||||
aside.appendChild(
|
||||
el(
|
||||
"p",
|
||||
"aside-empty",
|
||||
"empty",
|
||||
askOffered()
|
||||
? ASK_HINT
|
||||
: isOpen(item) && !finish()
|
||||
@@ -764,7 +767,7 @@ export function renderAside() {
|
||||
// say so, because the reply may have changed what the question asks.
|
||||
const last = thread[thread.length - 1];
|
||||
if (item.noted === true && isOpen(item) && !finish() && last && threadWho(last) === "agent") {
|
||||
const tag = el("p", "pill noted-tag", "Plan2Code replied, check this still fits");
|
||||
const tag = el("p", "pill is-stage noted-tag", "Plan2Code replied, check this still fits");
|
||||
tag.setAttribute("role", "note");
|
||||
aside.appendChild(tag);
|
||||
}
|
||||
@@ -840,7 +843,7 @@ const SUGGEST_KINDS = ["choice", "multi", "confirm", "lessons"];
|
||||
// stays in the panel: on the chip when it is live again, else the note box.
|
||||
function suggestChip(item) {
|
||||
const st = suggestState(item);
|
||||
const chip = el("button", "btn tiny suggest-chip", "Ask for suggestions");
|
||||
const chip = el("button", "btn xs soft suggest-chip", "Ask for suggestions");
|
||||
chip.type = "button";
|
||||
chip.id = "suggest-" + item.id;
|
||||
chip.setAttribute("aria-label", "Ask Plan2Code for suggestions on this question");
|
||||
@@ -882,7 +885,7 @@ function sentWaitingTag() {
|
||||
}
|
||||
|
||||
function suggestTag() {
|
||||
return el("span", "pill suggest-tag", "Asked for suggestions");
|
||||
return el("span", "pill is-accent suggest-tag", "Asked for suggestions");
|
||||
}
|
||||
|
||||
// The helpers the agent reported, as it last posted them. Everything here is
|
||||
@@ -894,7 +897,7 @@ export function renderSubagents(main) {
|
||||
const { alone, rows } = helperRows(page.S.helpers);
|
||||
if (alone) {
|
||||
card.appendChild(
|
||||
el("p", "sa-alone", "Working alone: your agent has no way to start helpers here, so it is doing this skill's work itself.")
|
||||
el("p", "sa-alone", "Working alone: your agent has no way to start subagents here, so it is doing this skill's work itself.")
|
||||
);
|
||||
main.appendChild(card);
|
||||
return;
|
||||
@@ -947,9 +950,12 @@ export function renderSubagentsButton() {
|
||||
btn.hidden = !offer;
|
||||
if (!offer) return;
|
||||
const label = switchLabel(page.subagentsFrame);
|
||||
btn.setAttribute("aria-pressed", String(Boolean(page.subagentsFrame.on)));
|
||||
// The state lives in the label and a data attribute (the lit look), never in
|
||||
// aria-pressed: the button opens a dialog, it does not toggle.
|
||||
btn.dataset.on = String(Boolean(page.subagentsFrame.on));
|
||||
btn.title = label;
|
||||
btn.setAttribute("aria-label", label);
|
||||
$("subagents-label").textContent = label;
|
||||
// The Subagents switch is the person's setting for the next agent; the loop's phases are already started.
|
||||
btn.disabled = page.gone || loopDriving();
|
||||
}
|
||||
@@ -967,6 +973,7 @@ export function openSubagents() {
|
||||
const strength = STRENGTHS.includes(page.subagentsFrame.strength) ? page.subagentsFrame.strength : DEFAULT_STRENGTH;
|
||||
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.checked = radio.value === strength;
|
||||
syncStrengthHelp();
|
||||
loadedSubagents = subagentsFields();
|
||||
$("subagents-checkin").textContent = CHECKIN_LINE;
|
||||
const research = $("subagents-research");
|
||||
research.textContent = PATHFINDER_RESEARCH_LINE;
|
||||
@@ -979,6 +986,90 @@ export function openSubagents() {
|
||||
if (checked) checked.focus();
|
||||
}
|
||||
|
||||
// The dialog's four fields as they stand now: the Instruction (the default's
|
||||
// text and an empty box both count as the default), the number, the switch and
|
||||
// the strength. Compared with what openSubagents loaded to see an edit.
|
||||
let loadedSubagents = null;
|
||||
function subagentsFields() {
|
||||
const on = document.querySelector('input[name="subagents-on"]:checked');
|
||||
const strength = document.querySelector('input[name="subagents-strength"]:checked');
|
||||
return {
|
||||
on: Boolean(on && on.value === "on"),
|
||||
max: String($("subagents-max").value),
|
||||
strength: strength ? strength.value : DEFAULT_STRENGTH,
|
||||
instruction: instr().value.trim(),
|
||||
};
|
||||
}
|
||||
export function subagentsDirty() {
|
||||
if (!loadedSubagents) return false;
|
||||
const now = subagentsFields();
|
||||
return Object.keys(now).some((k) => now[k] !== loadedSubagents[k]);
|
||||
}
|
||||
|
||||
// The unsaved prompt, inside the dialog (never confirm()), in Preferences'
|
||||
// order: Keep editing, Discard, Save, with focus on Keep editing. Resolves true
|
||||
// when the dialog may close.
|
||||
let askingSubagents = null;
|
||||
function wireSubagentsPrompt() {
|
||||
const box = el("div", "prefs-unsaved");
|
||||
box.id = "subagents-unsaved";
|
||||
box.hidden = true;
|
||||
box.setAttribute("role", "alertdialog");
|
||||
box.setAttribute("aria-labelledby", "subagents-unsaved-title");
|
||||
const inner = el("div", "prefs-unsaved-box");
|
||||
const title = el("h3", null, "Discard your changes?");
|
||||
title.id = "subagents-unsaved-title";
|
||||
const keep = el("button", "btn sm ghost", "Keep editing");
|
||||
keep.type = "button";
|
||||
keep.id = "subagents-unsaved-keep";
|
||||
const discard = el("button", "btn sm ghost", "Discard");
|
||||
discard.type = "button";
|
||||
discard.id = "subagents-unsaved-discard";
|
||||
const save = el("button", "btn sm primary", "Save");
|
||||
save.type = "button";
|
||||
save.id = "subagents-unsaved-save";
|
||||
const end = (go) => {
|
||||
box.hidden = true;
|
||||
for (const n of behindSubagentsPrompt()) n.inert = false;
|
||||
const { resolve } = askingSubagents;
|
||||
askingSubagents = null;
|
||||
resolve(go);
|
||||
};
|
||||
keep.addEventListener("click", () => {
|
||||
end(false);
|
||||
const first = document.querySelector('input[name="subagents-on"]:checked');
|
||||
if (first) first.focus();
|
||||
});
|
||||
discard.addEventListener("click", () => end(true));
|
||||
save.addEventListener("click", async () => {
|
||||
save.disabled = true;
|
||||
const saved = await saveSubagents();
|
||||
save.disabled = false;
|
||||
if (askingSubagents) end(saved === true);
|
||||
});
|
||||
const actions = el("div", "prefs-unsaved-actions");
|
||||
actions.append(keep, discard, save);
|
||||
inner.append(title, actions);
|
||||
box.append(inner);
|
||||
$("subagents-modal").append(box);
|
||||
}
|
||||
const behindSubagentsPrompt = () => [$("subagents-title"), ...$("subagents-modal").querySelectorAll(":scope > :not(#subagents-unsaved)")];
|
||||
export function confirmSubagentsDiscard() {
|
||||
if (!subagentsDirty()) return Promise.resolve(true);
|
||||
if (askingSubagents) return askingSubagents.promise;
|
||||
let resolve;
|
||||
const promise = new Promise((r) => (resolve = r));
|
||||
askingSubagents = { resolve, promise };
|
||||
for (const n of behindSubagentsPrompt()) n.inert = true;
|
||||
$("subagents-unsaved").hidden = false;
|
||||
$("subagents-unsaved-save").disabled = false;
|
||||
$("subagents-unsaved-keep").focus();
|
||||
return promise;
|
||||
}
|
||||
async function closeSubagents() {
|
||||
if (await confirmSubagentsDiscard()) $("subagents-modal").close();
|
||||
}
|
||||
|
||||
// Instruction, "at most" and strength only mean anything with helpers on, so
|
||||
// they are inert under Work alone (kept as picked, for when helpers go back on).
|
||||
export function syncSubagentsFields() {
|
||||
@@ -998,12 +1089,12 @@ function syncStrengthHelp() {
|
||||
const SUBAGENTS_ERRORS = {
|
||||
max: "Pick a number from 1 to 20.",
|
||||
"too-long": "The instruction is over 2,000 characters.",
|
||||
strength: "That strength isn't one of the four choices.",
|
||||
"not-offered": "This skill doesn't use helpers.",
|
||||
bad: "That didn't save. Try again.",
|
||||
strength: "That strength is not one of the four choices.",
|
||||
"not-offered": "This skill does not use subagents.",
|
||||
bad: "That did not save. Try again.",
|
||||
};
|
||||
|
||||
const SUBAGENTS_LOST = "Lost contact with Plan2Code. Try again once it's back.";
|
||||
const SUBAGENTS_LOST = `${NOT_CONNECTED} Try again once it is back.`;
|
||||
|
||||
export async function saveSubagents() {
|
||||
const save = $("subagents-save");
|
||||
@@ -1025,10 +1116,14 @@ export async function saveSubagents() {
|
||||
const res = await postJson("/subagents", body);
|
||||
save.disabled = false;
|
||||
// The next state frame redraws the button.
|
||||
if (res.status === 200) return $("subagents-modal").close();
|
||||
if (res.status === 200) {
|
||||
$("subagents-modal").close();
|
||||
return true;
|
||||
}
|
||||
if (res.status === 400) status.textContent = SUBAGENTS_ERRORS[res.body && res.body.error] || SUBAGENTS_ERRORS.bad;
|
||||
else if (res.status === 403 || res.status === 0) status.textContent = SUBAGENTS_LOST;
|
||||
else status.textContent = SUBAGENTS_ERRORS.bad;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Whether the agent coming or going has changed what the Ask pane painted,
|
||||
@@ -1039,13 +1134,28 @@ export const askOfflineFlipped = () => (askState().send.state === "offline") !==
|
||||
export function wireAsk() {
|
||||
for (const radio of document.querySelectorAll('input[name="subagents-on"]')) radio.addEventListener("change", syncSubagentsFields);
|
||||
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.addEventListener("change", syncStrengthHelp);
|
||||
lightDismiss($("subagents-modal"));
|
||||
wireSubagentsPrompt();
|
||||
lightDismiss($("subagents-modal"), confirmSubagentsDiscard);
|
||||
$("subagents-modal").addEventListener("keydown", (e) => {
|
||||
if (e.key !== "Escape") return;
|
||||
if (askingSubagents) {
|
||||
e.preventDefault();
|
||||
$("subagents-unsaved-keep").click();
|
||||
} else if (subagentsDirty()) {
|
||||
e.preventDefault();
|
||||
closeSubagents();
|
||||
}
|
||||
});
|
||||
$("subagents-modal").addEventListener("cancel", (e) => {
|
||||
if (!askingSubagents && !subagentsDirty()) return;
|
||||
e.preventDefault();
|
||||
});
|
||||
$("btn-subagents").addEventListener("click", openSubagents);
|
||||
$("subagents-default").addEventListener("click", () => {
|
||||
instr().value = defaultInstruction(page.S.workflow);
|
||||
});
|
||||
$("subagents-save").addEventListener("click", saveSubagents);
|
||||
$("subagents-cancel").addEventListener("click", () => $("subagents-modal").close());
|
||||
$("subagents-cancel").addEventListener("click", closeSubagents);
|
||||
$("subagents-modal").addEventListener("close", () => $("btn-subagents").focus());
|
||||
|
||||
// Dropping files onto the notes panel attaches them to the selected
|
||||
|
||||
@@ -42,8 +42,9 @@ import {
|
||||
lessonMissing,
|
||||
lessonEditStart,
|
||||
lessonReworded,
|
||||
startsTicked,
|
||||
} from "../answers.js";
|
||||
import { el, md } from "../render.js";
|
||||
import { el, hiddenText, icon, md, stateMark } from "../render.js";
|
||||
import {
|
||||
sentAttachments,
|
||||
incomingFiles,
|
||||
@@ -68,14 +69,14 @@ export function markFor(item) {
|
||||
// and can no longer be added to, or it was never answered and never can be.
|
||||
if (isOpen(item) && finish()) {
|
||||
return recordedAnswer(item)
|
||||
? { glyph: "✓", cls: "done", label: "sent" }
|
||||
: { glyph: "○", cls: "open", label: "left unanswered" };
|
||||
? { icon: "check", cls: "done", label: "sent" }
|
||||
: { icon: "circle", cls: "open", label: "left unanswered" };
|
||||
}
|
||||
if (page.local.staged[item.id]) return { glyph: "●", cls: "staged", label: "ready to send" };
|
||||
if (page.local.staged[item.id]) return { icon: "dot", cls: "staged", label: "ready to send" };
|
||||
if (isOpen(item) && ((page.local.sent && page.local.sent[item.id]) || submittedInFlight(item)))
|
||||
return { glyph: "◐", cls: "staged", label: "sent, waiting for Plan2Code" };
|
||||
if (!isOpen(item)) return { glyph: "✓", cls: "done", label: "answered" };
|
||||
return { glyph: "○", cls: "open", label: "waiting for you" };
|
||||
return { icon: "half", cls: "staged", label: "sent, waiting for Plan2Code" };
|
||||
if (!isOpen(item)) return { icon: "check", cls: "done", label: "answered" };
|
||||
return { icon: "circle", cls: "open", label: "waiting for you" };
|
||||
}
|
||||
|
||||
// The session's own ending, as a page of its own at the top of the rail.
|
||||
@@ -88,10 +89,10 @@ export function renderEndItem(fin) {
|
||||
const b = el("button", "rail-item");
|
||||
b.type = "button";
|
||||
b.setAttribute("aria-current", String(page.view === "end"));
|
||||
const mark = el("span", "rail-mark " + (paused ? "staged" : "done"), paused ? "❚❚" : "✓");
|
||||
mark.title = paused ? "session paused" : "session ended";
|
||||
b.appendChild(mark);
|
||||
b.appendChild(el("span", "rail-end-label", paused ? "Paused" : "Session ended"));
|
||||
b.appendChild(
|
||||
stateMark("rail-mark " + (paused ? "staged" : "done"), paused ? "half" : "check", paused ? "session stopped" : "session finished")
|
||||
);
|
||||
b.appendChild(el("span", "rail-end-label", paused ? "Stopped" : "Session finished"));
|
||||
b.addEventListener("click", () => {
|
||||
page.view = "end";
|
||||
redraw();
|
||||
@@ -237,7 +238,7 @@ export function buildPager(item) {
|
||||
if (at === -1) {
|
||||
// Reading something already settled. The only move that means anything
|
||||
// here is back to the work.
|
||||
const b = el("button", "btn small pager-btn next");
|
||||
const b = el("button", "btn sm pager-btn next");
|
||||
b.type = "button";
|
||||
const box = el("span", "pager-label");
|
||||
box.appendChild(el("span", "pager-kicker", "Back to what is waiting"));
|
||||
@@ -273,7 +274,7 @@ export function buildPager(item) {
|
||||
if (!target) return el("span", "pager-slot");
|
||||
const b = el(
|
||||
"button",
|
||||
"btn small pager-btn " + (back ? "prev" : "next") + (lead ? " lead" : " ghost")
|
||||
"btn sm pager-btn " + (back ? "prev" : "next") + (lead ? " lead" : " ghost")
|
||||
);
|
||||
b.type = "button";
|
||||
const arrow = el("span", "pager-arrow", back ? "←" : "→");
|
||||
@@ -300,7 +301,7 @@ export function buildPager(item) {
|
||||
// A notice is context for the question it sits beside, so it lives inside the
|
||||
// one card rather than as a second one under it.
|
||||
export function renderNotice(item) {
|
||||
const box = el("div", "card-note card-extra");
|
||||
const box = el("div", "callout is-info card-note card-extra");
|
||||
box.appendChild(el("p", "note-kicker", "Note"));
|
||||
box.appendChild(el("h3", "note-title", item.title));
|
||||
box.appendChild(md(item.body, "md"));
|
||||
@@ -398,7 +399,7 @@ export function renderCard(item) {
|
||||
const skipped = Boolean(staged && staged.skipped);
|
||||
// A small accent chip, like a comment box's quick answer ("No changes"),
|
||||
// rather than an underlined link that reads as fine print.
|
||||
const skip = el("button", "btn tiny", skipped ? "Do not skip" : "Skip this one");
|
||||
const skip = el("button", "btn xs soft", skipped ? "Do not skip" : "Skip this one");
|
||||
skip.type = "button";
|
||||
skip.style.marginTop = "16px";
|
||||
skip.addEventListener("click", () => {
|
||||
@@ -438,7 +439,9 @@ function renderSettled(card, item) {
|
||||
const nothing = !lines.length && !prose;
|
||||
const box = el("div", "answered" + (nothing ? " is-empty" : ""));
|
||||
const head = el("p", "answered-head");
|
||||
head.appendChild(el("span", "answered-mark", nothing ? "·" : "✓"));
|
||||
const doneMark = el("span", "answered-mark");
|
||||
doneMark.appendChild(icon(nothing ? "dot" : "check"));
|
||||
head.appendChild(doneMark);
|
||||
// A note is not an answer: say which it is.
|
||||
head.appendChild(el("span", null, nothing ? "No answer recorded" : fromNote ? "Your last note" : "Your answer"));
|
||||
box.appendChild(head);
|
||||
@@ -455,7 +458,7 @@ function renderSettled(card, item) {
|
||||
"p",
|
||||
"answered-none",
|
||||
isOpen(item)
|
||||
? "The session ended before this was answered."
|
||||
? "The session finished before this was answered."
|
||||
: "This was answered somewhere other than this page, so there is nothing to show."
|
||||
)
|
||||
);
|
||||
@@ -580,12 +583,15 @@ function lockedOptions(card, item, keys) {
|
||||
for (const o of item.options) {
|
||||
const on = picked.has(o.k);
|
||||
const li = el("li", "option is-locked" + (on ? " is-recorded" : ""));
|
||||
li.appendChild(el("span", "option-mark" + (on ? " on" : ""), on ? "✓" : "·"));
|
||||
const optMark = el("span", "option-mark" + (on ? " on" : ""));
|
||||
optMark.appendChild(icon(on ? "check" : "dot"));
|
||||
optMark.appendChild(hiddenText(on ? "chosen" : "not chosen"));
|
||||
li.appendChild(optMark);
|
||||
const body = el("div", "option-body");
|
||||
const head = el("div", "option-label");
|
||||
if (showKey(o.k, o.text)) head.appendChild(el("span", "option-key", o.k));
|
||||
if (showKey(o.k, o.text)) head.appendChild(el("span", "code-tag option-key", o.k));
|
||||
head.appendChild(el("span", null, o.text));
|
||||
if (on) head.appendChild(el("span", "pill done", "Your answer"));
|
||||
if (on) head.appendChild(el("span", "pill is-ok is-caps done", "Your answer"));
|
||||
body.appendChild(head);
|
||||
if (o.detail) body.appendChild(el("p", "option-detail", o.detail));
|
||||
li.appendChild(body);
|
||||
@@ -602,7 +608,10 @@ function lockedSteps(card, item, v) {
|
||||
const li = el("li", "step is-locked");
|
||||
li.appendChild(el("span", "step-num", String(i + 1)));
|
||||
const on = done.has(i);
|
||||
li.appendChild(el("span", "option-mark" + (on ? " on" : ""), on ? "✓" : "·"));
|
||||
const stepMark = el("span", "option-mark" + (on ? " on" : ""));
|
||||
stepMark.appendChild(icon(on ? "check" : "dot"));
|
||||
stepMark.appendChild(hiddenText(on ? "done" : "not done"));
|
||||
li.appendChild(stepMark);
|
||||
const body = el("div", "step-body");
|
||||
body.appendChild(md(typeof step === "string" ? step : step.text, "md"));
|
||||
li.appendChild(body);
|
||||
@@ -629,7 +638,7 @@ function lockedRows(card, item, v) {
|
||||
|
||||
function lockedSummary(card, item) {
|
||||
if (!item.summary) return;
|
||||
const box = el("div", "card-note");
|
||||
const box = el("div", "callout is-info card-note");
|
||||
box.appendChild(md(item.summary, "md"));
|
||||
card.appendChild(box);
|
||||
}
|
||||
@@ -760,7 +769,8 @@ function otherField(card, item, staged) {
|
||||
stageQuiet(item.id, { ...(cur || { type: "answer", kind: item.kind }), text: ta.value.trim() });
|
||||
} else if (cur && cur.text) {
|
||||
const { text, ...rest } = cur;
|
||||
if (rest.k || (rest.ks && rest.ks.length)) stageQuiet(item.id, rest);
|
||||
// On a card with starting ticks an empty pick is itself an answer ("none"), so it stays.
|
||||
if (rest.k || (rest.ks && (rest.ks.length || startsTicked(item)))) stageQuiet(item.id, rest);
|
||||
else stageQuiet(item.id, null);
|
||||
}
|
||||
stagedChanged();
|
||||
@@ -791,13 +801,13 @@ function fillKicker(kicker, item) {
|
||||
kicker.replaceChildren(document.createTextNode(topic ? topic.title : "Question"));
|
||||
|
||||
let pill = null;
|
||||
if (!isOpen(item)) pill = el("span", "pill done", item.status === "skipped" ? "Skipped" : "Answered");
|
||||
if (!isOpen(item)) pill = el("span", "pill is-ok is-caps done", item.status === "skipped" ? "Skipped" : "Answered");
|
||||
// Frozen on a finished session: the send it carries is the record, and a
|
||||
// staged leftover can no longer be sent, so it earns no pill.
|
||||
else if (finish()) pill = recordedAnswer(item) ? el("span", "pill done", "Sent") : null;
|
||||
else if (page.local.staged[item.id]) pill = el("span", "pill staged", "Ready to send");
|
||||
else if (finish()) pill = recordedAnswer(item) ? el("span", "pill is-ok is-caps done", "Sent") : null;
|
||||
else if (page.local.staged[item.id]) pill = el("span", "pill is-stage is-caps staged", "Ready to send");
|
||||
else if ((page.local.sent && page.local.sent[item.id]) || submittedInFlight(item))
|
||||
pill = el("span", "pill staged", "Sent");
|
||||
pill = el("span", "pill is-stage is-caps staged", "Sent");
|
||||
if (!pill) return;
|
||||
pill.style.marginLeft = "8px";
|
||||
kicker.appendChild(pill);
|
||||
@@ -875,9 +885,9 @@ function buildChoice(card, item, staged) {
|
||||
|
||||
const body = el("div", "option-body");
|
||||
const head = el("div", "option-label");
|
||||
if (showKey(o.k, o.text)) head.appendChild(el("span", "option-key", o.k));
|
||||
if (showKey(o.k, o.text)) head.appendChild(el("span", "code-tag option-key", o.k));
|
||||
head.appendChild(el("span", null, o.text));
|
||||
if (o.recommended) head.appendChild(el("span", "pill suggested", "Suggested"));
|
||||
if (o.recommended) head.appendChild(el("span", "pill is-accent is-caps suggested", "Suggested"));
|
||||
body.appendChild(head);
|
||||
if (o.detail) body.appendChild(el("p", "option-detail", o.detail));
|
||||
|
||||
@@ -915,7 +925,7 @@ function clearIcon() {
|
||||
// call it, and they only run for a form that has not been sent.
|
||||
function clearRow(card, item) {
|
||||
const row = el("div", "btn-row options-clear");
|
||||
const b = el("button", "btn small ghost clear-btn");
|
||||
const b = el("button", "btn sm ghost clear-btn");
|
||||
b.type = "button";
|
||||
b.appendChild(clearIcon());
|
||||
b.appendChild(el("span", null, "Clear answer"));
|
||||
@@ -958,6 +968,7 @@ function multiCount(item, ks) {
|
||||
|
||||
function buildMulti(card, item, staged) {
|
||||
const locked = lockedKeys(item);
|
||||
const seeds = startsTicked(item);
|
||||
const chosen = new Set(((staged && staged.ks) || []).filter((k) => !locked.has(k)));
|
||||
const grouped = (item.options || []).some((o) => o && typeof o.group === "string" && o.group);
|
||||
const list = el("ul", "options");
|
||||
@@ -988,7 +999,9 @@ function buildMulti(card, item, staged) {
|
||||
box.id = optionId(item, o, i);
|
||||
box.value = o.k;
|
||||
box.checked = on;
|
||||
box.setAttribute("aria-label", o.k ? `${o.k}: ${o.text}` : o.text);
|
||||
const tag = typeof o.tag === "string" ? o.tag.trim() : "";
|
||||
const named = o.k ? `${o.k}: ${o.text}` : o.text;
|
||||
box.setAttribute("aria-label", tag ? `${named}, ${tag}` : named);
|
||||
if (isLocked) {
|
||||
box.disabled = true;
|
||||
box.setAttribute("aria-disabled", "true");
|
||||
@@ -1002,7 +1015,7 @@ function buildMulti(card, item, staged) {
|
||||
// Unticking the last box keeps what is written in "Anything else".
|
||||
stage(
|
||||
item.id,
|
||||
withNote(item, next.size ? { type: "answer", kind: "multi", ks: [...next] } : null, {
|
||||
withNote(item, next.size ? { type: "answer", kind: "multi", ks: [...next] } : seeds ? { type: "answer", kind: "multi", ks: [] } : null, {
|
||||
type: "answer",
|
||||
kind: "multi",
|
||||
ks: [],
|
||||
@@ -1012,9 +1025,11 @@ function buildMulti(card, item, staged) {
|
||||
|
||||
const body = el("div", "option-body");
|
||||
const head = el("div", "option-label");
|
||||
if (showKey(o.k, o.text)) head.appendChild(el("span", "option-key", o.k));
|
||||
if (showKey(o.k, o.text)) head.appendChild(el("span", "code-tag option-key", o.k));
|
||||
head.appendChild(el("span", null, o.text));
|
||||
if (o.recommended) head.appendChild(el("span", "pill suggested", "Suggested"));
|
||||
if (o.recommended) head.appendChild(el("span", "pill is-accent is-caps suggested", "Suggested"));
|
||||
// The agent's note on the row, drawn as a pill; it never moves with the tick.
|
||||
if (tag) head.appendChild(el("span", "pill is-neutral tag", tag));
|
||||
body.appendChild(head);
|
||||
if (o.detail) body.appendChild(el("p", "option-detail", o.detail));
|
||||
|
||||
@@ -1028,7 +1043,7 @@ function buildMulti(card, item, staged) {
|
||||
const key = moreKey(item, o);
|
||||
const open = openMore.has(key);
|
||||
const bodyId = `more-${item.id}-${o.k || i}`;
|
||||
const toggle = el("button", "option-more-btn", open ? "Less" : "More");
|
||||
const toggle = el("button", "btn xs soft option-more-btn", open ? "Less" : "More");
|
||||
toggle.type = "button";
|
||||
// Stable across redraws, so the click handler can find the new button.
|
||||
toggle.id = `more-btn-${item.id}-${o.k || i}`;
|
||||
@@ -1101,13 +1116,13 @@ function renderPresets(card, item, staged) {
|
||||
const now = new Set((staged && staged.ks) || []);
|
||||
for (const p of presets) {
|
||||
const on = p.ks.length === now.size && p.ks.every((k) => now.has(k));
|
||||
const b = el("button", "btn small" + (on ? " primary" : " ghost"), p.label);
|
||||
const b = el("button", "btn sm" + (on ? " primary" : " ghost"), p.label);
|
||||
b.type = "button";
|
||||
b.setAttribute("aria-pressed", String(on));
|
||||
b.addEventListener("click", () =>
|
||||
stage(
|
||||
item.id,
|
||||
withNote(item, on ? null : { type: "answer", kind: "multi", ks: [...p.ks] }, {
|
||||
withNote(item, on ? (startsTicked(item) ? { type: "answer", kind: "multi", ks: [] } : null) : { type: "answer", kind: "multi", ks: [...p.ks] }, {
|
||||
type: "answer",
|
||||
kind: "multi",
|
||||
ks: [],
|
||||
@@ -1188,7 +1203,7 @@ function buildText(card, item, staged) {
|
||||
input.addEventListener("input", check);
|
||||
|
||||
if (suggestion) {
|
||||
fill = el("button", "btn tiny", "Autofill suggestion");
|
||||
fill = el("button", "btn xs soft", "Autofill suggestion");
|
||||
fill.type = "button";
|
||||
fill.title = "Put the example into the box. It is yours to edit from there.";
|
||||
fill.hidden = Boolean(input.value.trim());
|
||||
@@ -1249,9 +1264,9 @@ function templateRow(item, input, entries, check) {
|
||||
fitGrowBox();
|
||||
};
|
||||
const chips = entries.map((entry) => {
|
||||
const chip = el("button", "tpl-chip", entry.label);
|
||||
const chip = el("button", "btn sm tpl-chip", entry.label);
|
||||
chip.type = "button";
|
||||
if (entry.forYou) chip.appendChild(el("span", "tpl-pill", "For your role"));
|
||||
if (entry.forYou) chip.appendChild(el("span", "pill is-accent tpl-pill", "For your role"));
|
||||
chip.addEventListener("click", () => pick(entry));
|
||||
row.appendChild(chip);
|
||||
return chip;
|
||||
@@ -1286,13 +1301,13 @@ function templateRow(item, input, entries, check) {
|
||||
return;
|
||||
}
|
||||
dropStrip();
|
||||
strip = el("div", "tpl-replace");
|
||||
strip = el("div", "callout is-stage tpl-replace");
|
||||
strip.setAttribute("role", "alert");
|
||||
strip.appendChild(el("span", null, "Replace what you typed?"));
|
||||
const replace = el("button", "btn tiny primary", "Replace");
|
||||
const replace = el("button", "btn xs soft primary", "Replace");
|
||||
replace.type = "button";
|
||||
replace.addEventListener("click", () => apply(entry, sw.text));
|
||||
const keep = el("button", "btn tiny ghost", "Keep mine");
|
||||
const keep = el("button", "btn xs soft", "Keep mine");
|
||||
keep.type = "button";
|
||||
keep.addEventListener("click", () => {
|
||||
dropStrip();
|
||||
@@ -1334,7 +1349,7 @@ function buildConfirm(card, item, staged) {
|
||||
if (item.consequences) {
|
||||
// "is-consequences": the command here is what Yes runs, so no "paste it
|
||||
// into the Ask tab" nudge under it (app.css).
|
||||
const note = el("div", "card-note is-consequences");
|
||||
const note = el("div", "callout is-info card-note is-consequences");
|
||||
note.appendChild(md(item.consequences, "md"));
|
||||
card.appendChild(note);
|
||||
}
|
||||
@@ -1367,7 +1382,7 @@ function buildRecap(card, item, staged) {
|
||||
// The recap is not optional: a click captured the pick, this captures the
|
||||
// agreement. Rendered as a document so it reads like a summary, not a form.
|
||||
if (item.summary) {
|
||||
const box = el("div", "card-note");
|
||||
const box = el("div", "callout is-info card-note");
|
||||
box.appendChild(md(item.summary, "md"));
|
||||
card.appendChild(box);
|
||||
}
|
||||
@@ -1399,7 +1414,7 @@ function buildRecap(card, item, staged) {
|
||||
function docLink(item) {
|
||||
const doc = item.doc && docs().find((d) => d.id === item.doc);
|
||||
if (!doc) return null;
|
||||
const open = el("button", "btn small", `Read “${doc.title || "the document"}” in full`);
|
||||
const open = el("button", "btn sm", `Read “${doc.title || "the document"}” in full`);
|
||||
open.type = "button";
|
||||
open.style.marginTop = "14px";
|
||||
open.addEventListener("click", () => {
|
||||
@@ -1411,7 +1426,7 @@ function docLink(item) {
|
||||
|
||||
function buildReview(card, item, staged) {
|
||||
if (item.summary) {
|
||||
const box = el("div", "card-note");
|
||||
const box = el("div", "callout is-info card-note");
|
||||
box.appendChild(md(item.summary, "md"));
|
||||
card.appendChild(box);
|
||||
}
|
||||
@@ -1542,7 +1557,7 @@ function buildMenu(card, item, staged) {
|
||||
const body = el("div", "option-body");
|
||||
const head = el("div", "option-label");
|
||||
head.appendChild(el("span", null, text));
|
||||
if (o.recommended) head.appendChild(el("span", "pill suggested", "Suggested"));
|
||||
if (o.recommended) head.appendChild(el("span", "pill is-accent is-caps suggested", "Suggested"));
|
||||
body.appendChild(head);
|
||||
if (o.detail) body.appendChild(el("p", "option-detail", o.detail));
|
||||
label.appendChild(radio);
|
||||
@@ -1554,7 +1569,7 @@ function buildMenu(card, item, staged) {
|
||||
clearRow(card, item);
|
||||
|
||||
if (item.command) {
|
||||
const note = el("div", "card-note");
|
||||
const note = el("div", "callout is-info card-note");
|
||||
note.appendChild(el("p", "help", "To pick this up in a fresh session, run:"));
|
||||
note.appendChild(md("```\n" + handoffText({ command: item.command }) + "\n```", "md"));
|
||||
card.appendChild(note);
|
||||
@@ -1614,7 +1629,8 @@ function buildList(card, item, staged) {
|
||||
commit(next);
|
||||
});
|
||||
|
||||
const handle = el("button", "row-handle", "⠿");
|
||||
const handle = el("button", "row-handle");
|
||||
handle.appendChild(icon("grip"));
|
||||
handle.type = "button";
|
||||
handle.title = "Drag to reorder";
|
||||
handle.setAttribute("aria-label", `Move “${row.title}”`);
|
||||
@@ -1660,7 +1676,7 @@ function buildList(card, item, staged) {
|
||||
li.appendChild(main);
|
||||
|
||||
const tools = el("div", "row-tools");
|
||||
const up = el("button", "btn ghost small", "↑");
|
||||
const up = el("button", "btn ghost sm", "↑");
|
||||
up.type = "button";
|
||||
up.title = "Move up";
|
||||
up.disabled = i === 0;
|
||||
@@ -1671,7 +1687,7 @@ function buildList(card, item, staged) {
|
||||
[next[at - 1], next[at]] = [next[at], next[at - 1]];
|
||||
commit(next);
|
||||
});
|
||||
const down = el("button", "btn ghost small", "↓");
|
||||
const down = el("button", "btn ghost sm", "↓");
|
||||
down.type = "button";
|
||||
down.title = "Move down";
|
||||
down.disabled = i === rows.length - 1;
|
||||
@@ -1682,7 +1698,8 @@ function buildList(card, item, staged) {
|
||||
[next[at + 1], next[at]] = [next[at], next[at + 1]];
|
||||
commit(next);
|
||||
});
|
||||
const del = el("button", "btn ghost small", "×");
|
||||
const del = el("button", "btn ghost sm");
|
||||
del.appendChild(icon("close"));
|
||||
del.type = "button";
|
||||
del.title = "Remove";
|
||||
del.setAttribute("aria-label", `Remove “${row.title}”`);
|
||||
@@ -1700,7 +1717,7 @@ function buildList(card, item, staged) {
|
||||
card.appendChild(ul);
|
||||
|
||||
const row = el("div", "btn-row");
|
||||
const add = el("button", "btn small", "Add one");
|
||||
const add = el("button", "btn sm", "Add one");
|
||||
add.type = "button";
|
||||
keepFocus(add);
|
||||
add.addEventListener("click", () =>
|
||||
@@ -1820,7 +1837,7 @@ function buildLessons(card, item, staged) {
|
||||
const foot = el("div", "lessons-foot");
|
||||
foot.appendChild(summary);
|
||||
// Sending with nothing chosen is allowed: everything keeps waiting (FR-14).
|
||||
const leave = el("button", "btn tiny" + (draft.leaveAll ? " primary" : ""), "Leave them all waiting");
|
||||
const leave = el("button", "btn xs soft" + (draft.leaveAll ? " primary" : ""), "Leave them all waiting");
|
||||
leave.type = "button";
|
||||
leave.setAttribute("aria-pressed", String(draft.leaveAll));
|
||||
leave.addEventListener("click", () => {
|
||||
@@ -1871,14 +1888,14 @@ function lessonRow(item, row, draft, commit) {
|
||||
|
||||
for (const f of Array.isArray(row.flags) ? row.flags : []) {
|
||||
const what = FLAG_WORDS[f && f.pattern] || "something personal";
|
||||
li.appendChild(el("p", "lessons-flag", `Holds what looks like ${what}${f && f.part ? ` (“${f.part}”)` : ""}. Keep only if that is intended.`));
|
||||
li.appendChild(el("p", "callout is-stage lessons-flag", `Holds what looks like ${what}${f && f.part ? ` (“${f.part}”)` : ""}. Keep only if that is intended.`));
|
||||
}
|
||||
|
||||
const reworded = lessonReworded(row, draft.edits[row.id] || {});
|
||||
const keepWord = LESSON_KEEP_WORD[row.type];
|
||||
if (row.refused) {
|
||||
const part = row.refused.part ? ` (it starts “${row.refused.part}”)` : "";
|
||||
li.appendChild(el("p", "lessons-refused", `Refused: part of it looks like a secret${part}. Reword it to ${keepWord.toLowerCase()} it.`));
|
||||
li.appendChild(el("p", "callout is-warn lessons-refused", `Refused: part of it looks like a secret${part}. Reword it to ${keepWord.toLowerCase()} it.`));
|
||||
}
|
||||
|
||||
// The choices, in the order given; a refused row shows its keep word
|
||||
@@ -1890,7 +1907,7 @@ function lessonRow(item, row, draft, commit) {
|
||||
group.setAttribute("aria-label", "Choices for: " + (row.text || row.id));
|
||||
choices.forEach((word, i) => {
|
||||
const on = pick === word;
|
||||
const b = el("button", "btn small" + (on ? " primary" : ""), word);
|
||||
const b = el("button", "btn sm" + (on ? " primary" : ""), word);
|
||||
b.type = "button";
|
||||
b.id = `lesson-${item.id}-${row.id}-${i}`;
|
||||
b.setAttribute("aria-pressed", String(on));
|
||||
@@ -2050,7 +2067,7 @@ function commentField(card, item, labelText, required, quickAnswers = []) {
|
||||
label.htmlFor = id;
|
||||
wrap.appendChild(label);
|
||||
const quicks = quickAnswers.map(({ label, text }) => {
|
||||
const b = el("button", "btn tiny quick-answer", label);
|
||||
const b = el("button", "btn xs soft quick-answer", label);
|
||||
b.type = "button";
|
||||
b.title = "Fill in \"" + text + "\"";
|
||||
wrap.appendChild(b);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Plan2Code Web Console - User Preferences, the Cleanup section on the System tab.
|
||||
|
||||
import { NOT_CONNECTED, agoWords, whenTitle } from "../labels.js";
|
||||
import { SKILLS } from "../skills.js";
|
||||
import { formatBytes } from "../answers.js";
|
||||
import { el } from "../render.js";
|
||||
import { postJson } from "../net.js";
|
||||
@@ -11,9 +13,17 @@ const $ = (id) => document.getElementById(id);
|
||||
// server re-checks every one before removing it.
|
||||
let cleanupFound = null;
|
||||
|
||||
// The ids ticked for deletion. A session or a stray file starts ticked; a
|
||||
// Notebook (private writing) or a completed spec starts unticked, so deleting
|
||||
// those is always a choice.
|
||||
let ticked = new Set();
|
||||
const startsTicked = (item) => item.where !== "notepad" && item.where !== "completed";
|
||||
|
||||
// Bumped by every scan, delete and reset: a response from an older one is
|
||||
// dropped, so a scan still in flight when Preferences closes cannot refill it.
|
||||
let cleanupGen = 0;
|
||||
// True while a delete is on its way: a ticked box must not re-enable Delete.
|
||||
let cleanupBusy = false;
|
||||
|
||||
const CLEANUP_SHOWN = 8;
|
||||
|
||||
@@ -25,8 +35,17 @@ function setCleanupStatus(text, isError) {
|
||||
|
||||
const CLEANUP_WHERE = { root: "~/.plan2code/", console: "~/.plan2code/console/", completed: "specs--completed/" };
|
||||
|
||||
// "Pathfinder · shop · 6 weeks ago": the skill, the session's title and when it
|
||||
// was last touched. An older session with no title keeps its folder name.
|
||||
function sessionLabel(item) {
|
||||
const skill = SKILLS.find((s) => s.workflow === item.workflow);
|
||||
const age = item.at && !Number.isNaN(Date.parse(item.at)) ? agoWords(Math.max(0, Date.now() - Date.parse(item.at))) : "";
|
||||
const parts = item.title ? [skill ? skill.name : "", item.title, age] : ["Session " + item.name, age];
|
||||
return parts.filter(Boolean).join(" · ");
|
||||
}
|
||||
|
||||
function cleanupLabel(item) {
|
||||
if (item.where === "session") return "Session " + item.name;
|
||||
if (item.where === "session") return sessionLabel(item);
|
||||
// One notebook is one item, named by the folder it belongs to; its key only
|
||||
// when its meta.json is gone.
|
||||
if (item.where === "notepad") return "Notebook for " + (item.folder || item.name);
|
||||
@@ -52,9 +71,25 @@ function cleanupSummary(items, bytes) {
|
||||
const keptBack = (item) => item.where === "completed" && item.tracked === false;
|
||||
const deletable = () => ((cleanupFound && cleanupFound.items) || []).filter((i) => !keptBack(i));
|
||||
|
||||
// What Delete will do, said on the button: the ticked items and their size.
|
||||
function tickedItems() {
|
||||
return deletable().filter((i) => ticked.has(i.id));
|
||||
}
|
||||
|
||||
function paintDeleteButton() {
|
||||
const chosen = tickedItems();
|
||||
const button = $("cleanup-delete");
|
||||
const bytes = chosen.reduce((n, i) => n + (i.bytes || 0), 0);
|
||||
button.textContent = chosen.length
|
||||
? `Delete ${chosen.length} ${chosen.length === 1 ? "item" : "items"} · ${formatBytes(bytes)}`
|
||||
: "Nothing ticked";
|
||||
button.disabled = cleanupBusy || !chosen.length;
|
||||
}
|
||||
|
||||
function resetCleanup() {
|
||||
cleanupGen++;
|
||||
cleanupFound = null;
|
||||
ticked = new Set();
|
||||
$("cleanup-list").replaceChildren();
|
||||
$("cleanup-delete").hidden = true;
|
||||
$("cleanup-delete").disabled = false;
|
||||
@@ -70,8 +105,18 @@ function renderCleanup() {
|
||||
const kept = all.filter(keptBack);
|
||||
$("cleanup-delete").hidden = !items.length;
|
||||
const rows = (some) => some.map((item) => {
|
||||
const row = el("div", "cleanup-row");
|
||||
row.append(el("span", null, cleanupLabel(item)), el("span", "cleanup-size", formatBytes(item.bytes)));
|
||||
const row = el("label", "cleanup-row");
|
||||
const box = el("input");
|
||||
box.type = "checkbox";
|
||||
box.checked = ticked.has(item.id);
|
||||
box.addEventListener("change", () => {
|
||||
if (box.checked) ticked.add(item.id);
|
||||
else ticked.delete(item.id);
|
||||
paintDeleteButton();
|
||||
});
|
||||
const label = el("span", null, cleanupLabel(item));
|
||||
if (item.at) label.title = whenTitle(item.at);
|
||||
row.append(box, label, el("span", "cleanup-size", formatBytes(item.bytes)));
|
||||
return row;
|
||||
});
|
||||
if (items.length) {
|
||||
@@ -83,6 +128,7 @@ function renderCleanup() {
|
||||
list.appendChild(more);
|
||||
}
|
||||
}
|
||||
paintDeleteButton();
|
||||
for (const item of kept) {
|
||||
const row = el("div", "cleanup-row cleanup-kept");
|
||||
row.append(el("span", null, cleanupLabel(item)), el("span", "cleanup-size", "kept: git does not track it as it stands"));
|
||||
@@ -102,9 +148,10 @@ async function scanCleanup() {
|
||||
if (status !== 200 || !body.ok) {
|
||||
cleanupFound = null;
|
||||
renderCleanup();
|
||||
return setCleanupStatus(status ? body.error || "Could not look." : "Plan2Code isn't reachable.", true);
|
||||
return setCleanupStatus(status ? body.error || "Could not look." : NOT_CONNECTED, true);
|
||||
}
|
||||
cleanupFound = { items: body.items || [], bytes: body.bytes || 0 };
|
||||
ticked = new Set(cleanupFound.items.filter((i) => startsTicked(i)).map((i) => i.id));
|
||||
renderCleanup();
|
||||
// Left in the status line, not cleared: it is the live region, so this is
|
||||
// what a screen reader hears when the scan finishes.
|
||||
@@ -115,18 +162,21 @@ async function scanCleanup() {
|
||||
}
|
||||
|
||||
async function deleteCleanup() {
|
||||
const ids = deletable().map((i) => i.id);
|
||||
const ids = tickedItems().map((i) => i.id);
|
||||
if (!ids.length) return;
|
||||
const gen = ++cleanupGen;
|
||||
$("cleanup-delete").disabled = true;
|
||||
$("cleanup-scan").disabled = true;
|
||||
setCleanupStatus("Deleting…", false);
|
||||
const { status, body } = await postJson("/cleanup", { delete: ids });
|
||||
cleanupBusy = true;
|
||||
const { status, body } = await postJson("/cleanup", { delete: ids }).finally(() => {
|
||||
cleanupBusy = false;
|
||||
});
|
||||
if (gen !== cleanupGen) return;
|
||||
$("cleanup-delete").disabled = false;
|
||||
$("cleanup-scan").disabled = false;
|
||||
paintDeleteButton();
|
||||
if (status !== 200 || !body.ok) {
|
||||
return setCleanupStatus(status ? body.error || "Could not delete." : "Plan2Code isn't reachable.", true);
|
||||
return setCleanupStatus(status ? body.error || "Could not delete." : NOT_CONNECTED, true);
|
||||
}
|
||||
const removed = (body.removed || []).length;
|
||||
const failed = (body.failed || []).length;
|
||||
@@ -137,6 +187,7 @@ async function deleteCleanup() {
|
||||
const asked = ids.length;
|
||||
const kept = Math.max(0, asked - removed - failed - refused);
|
||||
cleanupFound = null;
|
||||
ticked = new Set();
|
||||
renderCleanup();
|
||||
const done = removed ? "Deleted " + removed + (removed === 1 ? " item" : " items") + " · " + formatBytes(body.bytes) + " freed." : "Nothing was deleted.";
|
||||
const keptLine = kept ? ` ${kept} ${kept === 1 ? "was" : "were"} kept because ${kept === 1 ? "it" : "they"} changed since the scan.` : "";
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
// the one that starts it. The screens draw through state.js's redraw() and
|
||||
// keep the draft through saveNow(), never by importing this file.
|
||||
|
||||
import { looks, saveLooks } from "../looks.js";
|
||||
import { notConnected } from "../labels.js";
|
||||
import { fresh, freshChat, page, redraw, saveNow, scrollMemory } from "../state.js";
|
||||
import {
|
||||
CATALOG_GROUPS,
|
||||
@@ -31,7 +33,9 @@ import {
|
||||
progressTotal,
|
||||
pruneStaged,
|
||||
recordedAnswer,
|
||||
seedStaged,
|
||||
sentAnswer,
|
||||
startsTicked,
|
||||
staleLaunchFeedback,
|
||||
submittedAwaiting,
|
||||
suggestAction,
|
||||
@@ -47,7 +51,7 @@ import {
|
||||
shouldChime,
|
||||
unreadDot,
|
||||
} from "../chat.js";
|
||||
import { copyButton, el, isMac, textWithCode } from "../render.js";
|
||||
import { copyButton, el, hiddenText, icon, isMac, stateMark, textWithCode } from "../render.js";
|
||||
import { isBuild, isAgentless } from "../skills.js";
|
||||
import { startsClean } from "../hops.js";
|
||||
import { faviconState, setFavicon } from "../favicon.js";
|
||||
@@ -65,7 +69,7 @@ import { sound } from "../sound.js";
|
||||
import { renderConfirm, renderDashboard } from "./dashboard.js";
|
||||
import { renderLoopSetup } from "./loop-setup.js";
|
||||
import { renderLaunching, renderWaiting } from "./starting.js";
|
||||
import { attachFiles, heldNotes, noteImages, pendingNotes, removeImage } from "../uploads.js";
|
||||
import { attachFiles, findSetAside, heldNotes, noteImages, pendingNotes, purgeImages } from "../uploads.js";
|
||||
import { closeMentions } from "../mention-box.js";
|
||||
import { destroyFields } from "../md-field.js";
|
||||
import { buildPager, fitGrowBox, markFor, markMore, renderCard, renderEndItem, renderNotice } from "./cards.js";
|
||||
@@ -73,8 +77,9 @@ import { sendState, suggestState } from "../send-state.js";
|
||||
import { renderAgentsDoc, renderBriefButton, renderDoc, renderOverview, renderPrototypes } from "./docs.js";
|
||||
import { board, renderGitBoard, resetBoard } from "./git-host.js";
|
||||
import { renderWorkspace, tellFolderIssues } from "./workspace.js";
|
||||
import { openHelpOn } from "./help-dialog.js";
|
||||
import { framed, linkLeavesPage, onAppMessage, startNewSession, tellApp } from "../app-bridge.js";
|
||||
import { openHelp, openHelpOn } from "./help-dialog.js";
|
||||
import { framed, linkLeavesPage, onAppMessage, shortcutIdFor, startNewSession, tellApp } from "../app-bridge.js";
|
||||
import { openPrefs as openPrefsDialog } from "./prefs-dialog.js";
|
||||
import { continueButton } from "../continue-button.js";
|
||||
import { askOfflineFlipped, askState, declineOpen, renderAside, renderAsk, renderSubagents, renderSubagentsButton } from "./ask.js";
|
||||
import { renderHandoff, renderLoopEnd, renderHomeButton, renderStopButton, renderStopControls, renderStopping, renderFooterDashboard, stopInProgress, stopWarning } from "./ending.js";
|
||||
@@ -112,7 +117,16 @@ export const GONE_AFTER_MS = 8000;
|
||||
// wipe an unrelated warning that landed while the page was gone (an upload
|
||||
// failure, a refused send).
|
||||
const GONE_BANNER =
|
||||
"Lost contact with Plan2Code. Nothing you have typed is lost. A blip clears by itself; if Plan2Code starts again, it gives you a new link, so open that one.";
|
||||
notConnected("Nothing you have typed is lost. A blip clears by itself; if Plan2Code starts again, it gives you a new link, so open that one.");
|
||||
// Under the app there is no link to open: its own bar offers the way back
|
||||
// (the same split as Help's Troubleshooting wording, help-dialog.js).
|
||||
const GONE_BANNER_IN_APP =
|
||||
notConnected("Nothing you have typed is lost. A blip clears by itself; otherwise the bar at the top offers Reconnect the console.");
|
||||
const goneBanner = () => (page.inApp ? GONE_BANNER_IN_APP : GONE_BANNER);
|
||||
// The token of the "not connected" banner while it is up (banner() hands it back).
|
||||
let goneBannerToken = 0;
|
||||
// True while the popover that first showed the one-time meter tip is open.
|
||||
let meterTipOpen = false;
|
||||
|
||||
// The server's frame counter as of the last frame, and the last time the page
|
||||
// heard from the server at all.
|
||||
@@ -250,7 +264,7 @@ async function pushDraft() {
|
||||
await fetch("/draft", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ staged: page.local.staged, drafts: page.local.drafts, images: page.local.images }),
|
||||
body: JSON.stringify({ staged: page.local.staged, drafts: page.local.drafts, images: page.local.images, seeded: page.local.seeded }),
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
@@ -302,8 +316,8 @@ export function adopt(body) {
|
||||
// A "still being picked up" banner is over once the send is: it said a
|
||||
// moment, and left up it reads as a fault through every later screen.
|
||||
if (!page.pendingResult && page.pendingBannerUp) {
|
||||
clearBanner(page.pendingBannerUp);
|
||||
page.pendingBannerUp = false;
|
||||
banner(null);
|
||||
}
|
||||
page.pendingStop = Boolean(body.pendingStop);
|
||||
page.chatFrame = body.chat || null;
|
||||
@@ -325,7 +339,7 @@ export function adopt(body) {
|
||||
lastContact = Date.now();
|
||||
if (page.gone) {
|
||||
page.gone = false;
|
||||
if ($("banner").textContent === GONE_BANNER) banner(null);
|
||||
clearBanner(goneBannerToken);
|
||||
}
|
||||
if (firstLoad) {
|
||||
load();
|
||||
@@ -335,6 +349,8 @@ export function adopt(body) {
|
||||
page.local.staged = body.draft.staged;
|
||||
page.local.drafts = body.draft.drafts || {};
|
||||
page.local.images = body.draft.images || {};
|
||||
// A draft saved by an older page has no `seeded`: none were seeded.
|
||||
page.local.seeded = body.draft.seeded || {};
|
||||
settleStaleUploads();
|
||||
}
|
||||
}
|
||||
@@ -447,9 +463,9 @@ export function adopt(body) {
|
||||
// banner wait for the first thing it actually puts on the page.
|
||||
if (!finish() && (asked().length || doingNow() || docs().length)) {
|
||||
sound("skillReady");
|
||||
banner(`${was.title} is ready.`, "good");
|
||||
const ready = banner(`${was.title} is ready.`, "good");
|
||||
clearTimeout(arrivalBannerTimer);
|
||||
arrivalBannerTimer = setTimeout(() => !page.gone && banner(null), 4000);
|
||||
arrivalBannerTimer = setTimeout(() => !page.gone && clearBanner(ready), 4000);
|
||||
}
|
||||
}
|
||||
// Anything the agent has now recorded is no longer "staged" or in flight.
|
||||
@@ -489,9 +505,17 @@ export function adopt(body) {
|
||||
save();
|
||||
const titles = pruned.dropped.map((id) => (byId(id) && byId(id).title) || id).join(", ");
|
||||
staleLine = `A pick on ${titles} no longer matches the reworded question, so it was cleared.`;
|
||||
banner(staleLine, "info");
|
||||
const stale = banner(staleLine, "info");
|
||||
clearTimeout(arrivalBannerTimer);
|
||||
arrivalBannerTimer = setTimeout(() => !page.gone && $("banner").textContent === staleLine && banner(null), 8000);
|
||||
arrivalBannerTimer = setTimeout(() => !page.gone && clearBanner(stale), 8000);
|
||||
}
|
||||
// A multi card that asks to start with ticks gets them staged once, as if the
|
||||
// person had ticked them (an `answer` on the item would settle it instead).
|
||||
const seeding = seedStaged(page.S.items || [], page.local.staged, page.local.seeded || {}, page.local.sent || {});
|
||||
if (seeding.changed) {
|
||||
page.local.staged = seeding.staged;
|
||||
page.local.seeded = seeding.seeded;
|
||||
save();
|
||||
}
|
||||
// A retracted send suppresses exactly that send. Once the item moves --
|
||||
// settled, sent again (a new `at`), or answered by an agent reply -- the
|
||||
@@ -532,7 +556,7 @@ export function adopt(body) {
|
||||
// The question already on screen needs no mark: it is where they are looking.
|
||||
for (const q of arrived) if (!(page.view === "questions" && page.selected === q.id)) page.newQuestions.add(q.id);
|
||||
arrivalNotice = staleLine ? `${staleLine} ${arrivedLine}` : arrivedLine;
|
||||
banner(arrivalNotice, "info");
|
||||
arrivalToken = banner(arrivalNotice, "info");
|
||||
clearTimeout(arrivalBannerTimer);
|
||||
} else {
|
||||
page.selected = arrived[0].id;
|
||||
@@ -614,9 +638,10 @@ function scrollRail(where) {
|
||||
let arrivalBannerTimer = null;
|
||||
// The text of a notice that stays up (see adopt), so only that banner is cleared.
|
||||
let arrivalNotice = "";
|
||||
let arrivalToken = 0;
|
||||
|
||||
function dropArrivalNotice() {
|
||||
if (arrivalNotice && $("banner").textContent === arrivalNotice) banner(null);
|
||||
if (arrivalNotice) clearBanner(arrivalToken);
|
||||
arrivalNotice = "";
|
||||
}
|
||||
|
||||
@@ -713,12 +738,12 @@ function markGone() {
|
||||
// of the server means there, and a banner promising a reconnect would
|
||||
// argue with it.
|
||||
if (!finish() && !stopInProgress()) {
|
||||
banner(GONE_BANNER, "warn");
|
||||
goneBannerToken = banner(goneBanner(), "warn");
|
||||
}
|
||||
render();
|
||||
} else if (!bad && page.gone) {
|
||||
page.gone = false;
|
||||
if ($("banner").textContent === GONE_BANNER) banner(null);
|
||||
clearBanner(goneBannerToken);
|
||||
render();
|
||||
}
|
||||
}
|
||||
@@ -1065,18 +1090,40 @@ function restoreScroll() {
|
||||
scroller.scrollTop = saved ? saved.top : 0;
|
||||
}
|
||||
|
||||
// `extras` are nodes shown after the text: a copyable hint, an action.
|
||||
// `extras` are nodes shown after the text: a copyable hint, an action. Hands
|
||||
// back a token for this message: a timer that wants it gone calls
|
||||
// clearBanner(token), which clears only that message, so a timed success never
|
||||
// erases a newer warning. A warning carries a Dismiss button.
|
||||
let bannerSeq = 0;
|
||||
let bannerShowing = 0;
|
||||
|
||||
export function banner(text, kind, extras) {
|
||||
const n = $("banner");
|
||||
if (!text) {
|
||||
n.hidden = true;
|
||||
n.textContent = "";
|
||||
return;
|
||||
bannerShowing = 0;
|
||||
return 0;
|
||||
}
|
||||
n.hidden = false;
|
||||
n.className = "banner " + (kind || "");
|
||||
n.textContent = text;
|
||||
for (const node of extras || []) n.appendChild(node);
|
||||
bannerShowing = ++bannerSeq;
|
||||
if (kind === "warn") {
|
||||
const close = el("button", "banner-dismiss");
|
||||
close.type = "button";
|
||||
close.setAttribute("aria-label", "Dismiss");
|
||||
close.appendChild(icon("close"));
|
||||
close.addEventListener("click", () => banner(null));
|
||||
n.appendChild(close);
|
||||
}
|
||||
return bannerShowing;
|
||||
}
|
||||
|
||||
// Clears the banner only when it is still the message `token` named.
|
||||
export function clearBanner(token) {
|
||||
if (token && token === bannerShowing) banner(null);
|
||||
}
|
||||
|
||||
// The session meter's pill, straight from the frame's `meter` (meter.js did
|
||||
@@ -1094,6 +1141,18 @@ function renderMeter() {
|
||||
$("meter-words").textContent = page.meterFrame.words;
|
||||
pill.title = page.meterFrame.tooltip;
|
||||
$("meter-tip").textContent = page.meterFrame.tooltip;
|
||||
// The one-time tip (it used to sit in the Welcome dialog): the first time the
|
||||
// pill leaves green, the popover says what to do about it. It counts as read
|
||||
// once the popover has been opened with it showing (toggleMeterPop), and
|
||||
// stays up until that popover closes, so a redraw cannot take it away mid-read.
|
||||
const once = $("meter-once");
|
||||
const showOnce = page.meterFrame.level !== "green" && (looks.meterTipSeen !== true || meterTipOpen);
|
||||
once.hidden = !showOnce;
|
||||
if (showOnce) {
|
||||
once.textContent = page.inApp
|
||||
? "Tip: once the meter passes half, finish the step and press New Session at the top of the window."
|
||||
: "Tip: once the meter passes half, finish the step and start a new conversation.";
|
||||
}
|
||||
// What the points are made of: one row per piece of work that scored.
|
||||
const list = $("meter-list");
|
||||
const rows = Array.isArray(page.meterFrame.items) ? page.meterFrame.items : [];
|
||||
@@ -1121,7 +1180,7 @@ function renderMeter() {
|
||||
fresh.dataset.built = "1";
|
||||
if (page.inApp) {
|
||||
// The same press as the app bar's New Session, confirm and all.
|
||||
const press = el("button", "btn small primary meter-fresh-btn", "Start a New Session");
|
||||
const press = el("button", "btn sm primary meter-fresh-btn", "Start a New Session");
|
||||
press.type = "button";
|
||||
press.addEventListener("click", () => !loopDriving() && tellApp("new-session"));
|
||||
press.disabled = loopDriving();
|
||||
@@ -1131,9 +1190,9 @@ function renderMeter() {
|
||||
const text = handoffText({ command: DASHBOARD_COMMAND });
|
||||
const code = el("code", "handoff-code", text);
|
||||
const row = el("div", "handoff-command meter-fresh-row");
|
||||
row.append(code, copyButton(text, "btn small ghost handoff-copy", code));
|
||||
row.append(code, copyButton(text, "btn sm ghost handoff-copy", code));
|
||||
fresh.append(
|
||||
textWithCode("p", "meter-fresh-text", `To start a new session, run \`${DASHBOARD_COMMAND}\` in a new conversation:`),
|
||||
textWithCode("p", "meter-fresh-text", `To start fresh, run \`${DASHBOARD_COMMAND}\` in a new conversation:`),
|
||||
row
|
||||
);
|
||||
}
|
||||
@@ -1189,7 +1248,7 @@ function renderChrome() {
|
||||
: `${done} of ${total} ${building ? "done" : "answered"}`
|
||||
: h.stage || "Getting started";
|
||||
$("confidence").textContent = h.confidence || "";
|
||||
$("progress-fill").style.width = pct + "%";
|
||||
$("progress-fill").style.setProperty("--p", String(pct / 100));
|
||||
const bar = $("progress-bar");
|
||||
// A stage with nothing to count (a review starting) says its words, no track.
|
||||
bar.hidden = !total && Boolean(h.stage);
|
||||
@@ -1341,7 +1400,7 @@ export function renderStatus() {
|
||||
if (page.local.afterBuild === "dashboard" && !page.gone) return say("work", "Opening the dashboard…", "", true);
|
||||
if (page.local.afterBuild === "commit" && !page.gone) return say("work", "Opening Git…", "", true);
|
||||
if (page.local.afterBuild === "changelog" && !page.gone) return say("work", "Opening Changelog…", "", true);
|
||||
if (page.local.afterBuild === "launch" && !page.gone) return say("work", "Starting the next step…", "", true);
|
||||
if (page.local.afterBuild === "launch" && !page.gone) return say("work", "Starting the next skill…", "", true);
|
||||
const offer = reviewPending();
|
||||
// There is no tab to close under the app, only the one window.
|
||||
const closeWord = page.inApp ? "window" : "tab";
|
||||
@@ -1352,10 +1411,10 @@ export function renderStatus() {
|
||||
if (offer === "open") return say("point", `Done. Review it here first, or close this ${closeWord}.`);
|
||||
// A stop past a warning kept nothing, so it promises no saved place.
|
||||
if (finishPaused(finish()))
|
||||
return say("done", stopWarning() ? "Paused. The command above starts it again." : "Paused. Your place is saved: the command above picks it up.");
|
||||
return say("done", stopWarning() ? "Stopped. The command above starts it again." : "Stopped. Your place is saved: the command above picks it up.");
|
||||
return say("done", `All done. You can close this ${closeWord}.`);
|
||||
}
|
||||
if (page.gone) return say("gone", "Not connected. Your answers are saved.", "", false, true);
|
||||
if (page.gone) return say("gone", notConnected("Your answers are saved."), "", false, true);
|
||||
// The loop's own end screen (the app's `loopEnd`) is no `finish()`: while it
|
||||
// still has presses on offer the move is theirs; with none, it is done.
|
||||
if (page.S.loopEnd) {
|
||||
@@ -1527,11 +1586,15 @@ function renderViews() {
|
||||
}
|
||||
b.setAttribute("aria-current", String(page.view === t.id || (t.id === "questions" && page.view === "end")));
|
||||
if (t.count) {
|
||||
// The number is drawn for the eye; the name reads ", 3 waiting".
|
||||
const c = el("span", "tab-count", String(t.count));
|
||||
c.setAttribute("aria-hidden", "true");
|
||||
b.appendChild(c);
|
||||
b.appendChild(hiddenText(t.id === "questions" ? `, ${t.count} waiting` : `, ${t.count}`));
|
||||
}
|
||||
if (t.dot) {
|
||||
const dot = el("span", "tab-dot");
|
||||
dot.setAttribute("role", "img");
|
||||
dot.setAttribute("aria-label", "New reply");
|
||||
b.appendChild(dot);
|
||||
}
|
||||
@@ -1596,13 +1659,13 @@ export function renderSidebar() {
|
||||
b.setAttribute("aria-current", String(Boolean(page.dashPick && page.dashPick.skill === e.skill)));
|
||||
const isGoing = page.local.launching && (page.local.launching.skill === e.skill || page.local.launching.skill === e.review);
|
||||
const isPicked = page.dashPick && page.dashPick.skill === e.skill;
|
||||
const mark = el(
|
||||
"span",
|
||||
"rail-mark " + (isGoing || isPicked ? "staged" : "open"),
|
||||
isGoing ? "◐" : isPicked ? "●" : "○"
|
||||
b.appendChild(
|
||||
stateMark(
|
||||
"rail-mark " + (isGoing || isPicked ? "staged" : "open"),
|
||||
isGoing ? "half" : isPicked ? "dot" : "circle",
|
||||
isGoing ? "starting" : isPicked ? "picked" : "pick to start"
|
||||
)
|
||||
);
|
||||
mark.title = isGoing ? "starting" : isPicked ? "picked" : "pick to start";
|
||||
b.appendChild(mark);
|
||||
b.appendChild(el("span", null, e.title));
|
||||
// The center pane's own "Suggested" pill scrolls out of view, so the
|
||||
// rail repeats the call-out here as a small dot next to the title.
|
||||
@@ -1626,10 +1689,8 @@ export function renderSidebar() {
|
||||
}
|
||||
|
||||
const list = asked();
|
||||
if (!list.length) {
|
||||
rail.appendChild(el("p", "rail-empty", "Nothing here yet."));
|
||||
return;
|
||||
}
|
||||
// Nothing asked yet: the rail stays empty, with no placeholder line.
|
||||
if (!list.length) return;
|
||||
|
||||
const groups = new Map();
|
||||
for (const item of list) {
|
||||
@@ -1654,12 +1715,10 @@ export function renderSidebar() {
|
||||
// the question that was last selected is not the thing being looked at.
|
||||
b.setAttribute("aria-current", String(page.view === "questions" && page.selected === item.id));
|
||||
const m = markFor(item);
|
||||
const mark = el("span", "rail-mark " + m.cls, m.glyph);
|
||||
mark.title = m.label;
|
||||
b.appendChild(mark);
|
||||
b.appendChild(stateMark("rail-mark " + m.cls, m.icon, m.label));
|
||||
b.appendChild(el("span", null, item.title));
|
||||
if (page.newQuestions.has(item.id)) {
|
||||
const fresh = el("span", "rail-new", "New");
|
||||
const fresh = el("span", "pill is-accent is-caps rail-new", "New");
|
||||
fresh.title = "arrived while you were typing";
|
||||
b.appendChild(fresh);
|
||||
}
|
||||
@@ -1824,7 +1883,7 @@ function paintMain(main) {
|
||||
// an ending, and until there was a way to tell the two apart the page said
|
||||
// it in both. The ending has its own page now, reached from the rail.
|
||||
if (!finish() && !myTurn().length && !stagedCount()) {
|
||||
const lull = el("div", "card-note card-lead");
|
||||
const lull = el("div", "callout is-info card-note card-lead");
|
||||
lull.appendChild(el("p", "note-kicker", "All caught up"));
|
||||
lull.appendChild(el("h3", "note-title", "Nothing needs you right now"));
|
||||
lull.appendChild(
|
||||
@@ -1891,7 +1950,7 @@ export function renderFooter() {
|
||||
} else if (finish()) {
|
||||
// Not "nothing to send yet". There is no yet.
|
||||
const fin = finish();
|
||||
next.appendChild(el("strong", null, finishPaused(fin) ? "Paused." : "All done."));
|
||||
next.appendChild(el("strong", null, finishPaused(fin) ? "Stopped." : "All done."));
|
||||
next.appendChild(
|
||||
document.createTextNode(
|
||||
n || notes.length
|
||||
@@ -1949,6 +2008,8 @@ export function renderFooter() {
|
||||
const state = sendState();
|
||||
const btn = $("btn-send");
|
||||
btn.disabled = state.disabled;
|
||||
// Nothing to send on this view: the button is gone, the status words stay.
|
||||
btn.hidden = Boolean(state.hide);
|
||||
// Filled accent means "this is the step". That is only true of Send once
|
||||
// nothing is left to answer; before then it is the quieter of the two, so
|
||||
// the next question wins the eye. Still one click either way: someone who
|
||||
@@ -1957,7 +2018,7 @@ export function renderFooter() {
|
||||
btn.classList.toggle("primary", state.disabled || sendIsStep);
|
||||
btn.classList.toggle("standby", !state.disabled && !sendIsStep);
|
||||
// The chevron before Send sways only while Send is the filled, live step.
|
||||
$("send-nudge").hidden = !sendIsStep;
|
||||
$("send-nudge").hidden = !sendIsStep || Boolean(state.hide);
|
||||
|
||||
const hint = $("send-hint");
|
||||
hint.replaceChildren();
|
||||
@@ -2156,11 +2217,11 @@ export async function askSuggestions(itemId) {
|
||||
}),
|
||||
});
|
||||
if (res.status === 409) {
|
||||
banner(
|
||||
// The token, so the end of the send clears only this line.
|
||||
page.pendingBannerUp = banner(
|
||||
"Your last answers are still being picked up. Nothing is lost, and nothing was sent twice. Try again in a moment.",
|
||||
"info"
|
||||
);
|
||||
page.pendingBannerUp = true;
|
||||
page.pendingResult = true;
|
||||
} else if (!res.ok) {
|
||||
const body = await res.json().catch(() => null);
|
||||
@@ -2169,8 +2230,8 @@ export async function askSuggestions(itemId) {
|
||||
// A note held back on an upload did not go, so it stays drafted.
|
||||
if (note) clearSentNote(itemId, new Set(images.map((i) => i.key)));
|
||||
save();
|
||||
banner("Asked for suggestions. Plan2Code is picking it up now.", "good");
|
||||
setTimeout(() => banner(null), 4000);
|
||||
const asked = banner("Asked for suggestions. Plan2Code is picking it up now.", "good");
|
||||
setTimeout(() => clearBanner(asked), 4000);
|
||||
}
|
||||
} catch {
|
||||
await sendLost();
|
||||
@@ -2220,8 +2281,8 @@ export async function send() {
|
||||
// for the next, different one.
|
||||
if (loopWaiting()) page.local.askLockedAfterSend = loopWaitingKey();
|
||||
markSent(payload);
|
||||
banner("Sent. Plan2Code is picking it up now.", "good");
|
||||
setTimeout(() => banner(null), 4000);
|
||||
const sentBanner = banner("Sent. Plan2Code is picking it up now.", "good");
|
||||
setTimeout(() => clearBanner(sentBanner), 4000);
|
||||
// A menu option the agent marked `fresh` is a clean start, which under the
|
||||
// app is the bar's New Session; the agent still gets the pick, so a
|
||||
// declined confirm carries on with its usual finish.
|
||||
@@ -2229,11 +2290,11 @@ export async function send() {
|
||||
if (freshMenu) startNewSession(freshMenu.command ? handoffText({ command: freshMenu.command }) : "");
|
||||
} catch (err) {
|
||||
if (err && err.pending) {
|
||||
banner(
|
||||
// The token, so the end of the send clears only this line.
|
||||
page.pendingBannerUp = banner(
|
||||
"Your last answers are still being picked up. Nothing is lost, and nothing was sent twice. Try again in a moment.",
|
||||
"info"
|
||||
);
|
||||
page.pendingBannerUp = true;
|
||||
page.pendingResult = true;
|
||||
} else if (err && err.reason) {
|
||||
banner(refusedLine(err), "warn");
|
||||
@@ -2291,6 +2352,9 @@ function tokenFor(item, v) {
|
||||
const parts = [];
|
||||
if (v.k) parts.push(map[v.k] || v.k);
|
||||
if (Array.isArray(v.ks) && v.ks.length) parts.push(v.ks.map((k) => map[k] || k).join(", "));
|
||||
// A card that opened ticked can be sent with nothing ticked: that is an
|
||||
// answer, said even when a note rides with it ("none; keep the logo").
|
||||
else if (Array.isArray(v.ks) && startsTicked(item)) parts.push("none");
|
||||
if (v.verdict) parts.push(map[v.verdict] || v.verdict);
|
||||
if (typeof v.yes === "boolean") parts.push(map[v.yes ? "yes" : "no"] || (v.yes ? "yes" : "no"));
|
||||
if (typeof v.ok === "boolean") parts.push(v.ok ? "confirmed" : "needs changes");
|
||||
@@ -2323,6 +2387,69 @@ function fmtMs(ms) {
|
||||
return `${m}m ${s % 60}s`;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- Clear, with Undo */
|
||||
|
||||
// Clear throws away what has not been sent, at once, and offers Undo for ten
|
||||
// seconds. The staged answers, the typed boxes and the attachments are kept in
|
||||
// memory meanwhile; the attachments' files on the server are deleted only when
|
||||
// the window closes (or the next Clear), so Undo has something to restore.
|
||||
const UNDO_CLEAR_MS = 10000;
|
||||
let clearedUndo = null;
|
||||
findSetAside((itemId, key) => (clearedUndo && (clearedUndo.images[itemId] || []).find((img) => img.key === key)) || null);
|
||||
|
||||
// The window is over: the set-aside pictures go for good.
|
||||
function settleClear() {
|
||||
if (!clearedUndo) return;
|
||||
clearTimeout(clearedUndo.timer);
|
||||
purgeImages(clearedUndo.images);
|
||||
clearBanner(clearedUndo.banner);
|
||||
clearedUndo = null;
|
||||
}
|
||||
|
||||
function clearUnsent() {
|
||||
// A second Clear closes the first one's window.
|
||||
settleClear();
|
||||
const count = Object.keys(page.local.staged).length + pendingNotes().length;
|
||||
const kept = { staged: page.local.staged, images: page.local.images, drafts: {} };
|
||||
page.local.staged = {};
|
||||
page.local.images = {};
|
||||
// Every typed box, the same set markSent clears: a draft left behind would
|
||||
// refill its box on the next render and look as if nothing was cleared.
|
||||
const typed = ["thread-", "other-", "text-", "note-"];
|
||||
for (const key of Object.keys(page.local.drafts)) {
|
||||
if (!typed.some((p) => key.startsWith(p))) continue;
|
||||
kept.drafts[key] = page.local.drafts[key];
|
||||
delete page.local.drafts[key];
|
||||
}
|
||||
saveNow();
|
||||
redraw();
|
||||
const undo = el("button", "btn xs soft banner-action", "Undo");
|
||||
undo.type = "button";
|
||||
undo.addEventListener("click", () => undoClear());
|
||||
const said = count ? `Cleared ${count} ${count === 1 ? "answer" : "answers"}. ` : "Cleared what you had not sent. ";
|
||||
const token = banner(said, "info", [undo]);
|
||||
clearedUndo = { ...kept, banner: token, timer: setTimeout(settleClear, UNDO_CLEAR_MS) };
|
||||
}
|
||||
|
||||
// Puts back what Clear set aside, except where the person has already typed or
|
||||
// picked something newer for the same question.
|
||||
function undoClear() {
|
||||
const was = clearedUndo;
|
||||
if (!was) return;
|
||||
clearTimeout(was.timer);
|
||||
clearedUndo = null;
|
||||
page.local.staged = { ...was.staged, ...page.local.staged };
|
||||
for (const [key, text] of Object.entries(was.drafts)) if (!(key in page.local.drafts)) page.local.drafts[key] = text;
|
||||
// Per note, so a picture attached during the window sits beside the restored ones.
|
||||
for (const [itemId, list] of Object.entries(was.images)) {
|
||||
const now = page.local.images[itemId] || [];
|
||||
page.local.images[itemId] = [...list.filter((img) => !now.some((x) => x.key === img.key)), ...now];
|
||||
}
|
||||
clearBanner(was.banner);
|
||||
saveNow();
|
||||
redraw();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------- page chrome */
|
||||
|
||||
function toggleMeterPop(open) {
|
||||
@@ -2330,6 +2457,14 @@ function toggleMeterPop(open) {
|
||||
const show = open ?? pop.hidden;
|
||||
pop.hidden = !show;
|
||||
$("meter-pill").setAttribute("aria-expanded", String(show));
|
||||
if (show && !$("meter-once").hidden && looks.meterTipSeen !== true) {
|
||||
meterTipOpen = true;
|
||||
looks.meterTipSeen = true;
|
||||
saveLooks();
|
||||
} else if (!show && meterTipOpen) {
|
||||
meterTipOpen = false;
|
||||
renderMeter();
|
||||
}
|
||||
}
|
||||
|
||||
let whereResizeTimer = null;
|
||||
@@ -2348,7 +2483,7 @@ async function openOutside(href) {
|
||||
.catch(() => false);
|
||||
if (ok) return;
|
||||
const link = el("code", "banner-link", href);
|
||||
banner("That link could not open from here. Copy it and paste it into your browser: ", "warn", [link, document.createTextNode(" "), copyButton(href, "btn small", link)]);
|
||||
banner("That link could not open from here. Copy it and paste it into your browser: ", "warn", [link, document.createTextNode(" "), copyButton(href, "btn sm", link)]);
|
||||
}
|
||||
|
||||
export function wireChrome() {
|
||||
@@ -2367,6 +2502,30 @@ export function wireChrome() {
|
||||
renderStatus();
|
||||
});
|
||||
|
||||
// The app's shortcuts (Ctrl or Cmd with a backtick, 1, 2, Shift+N, O and a comma) are also typed
|
||||
// here, inside its frame, where the shell never hears them: the page forwards the id and nothing
|
||||
// else. And its Preferences shortcut asks this page to open User Preferences.
|
||||
if (framed()) {
|
||||
document.addEventListener(
|
||||
"keydown",
|
||||
(e) => {
|
||||
const id = shortcutIdFor(e, isMac());
|
||||
if (!id) return;
|
||||
e.preventDefault();
|
||||
tellApp("shortcut", { id });
|
||||
},
|
||||
true
|
||||
);
|
||||
}
|
||||
onAppMessage("open-help", () => {
|
||||
if (document.querySelector("dialog[open]")) return;
|
||||
openHelp();
|
||||
});
|
||||
onAppMessage("open-preferences", () => {
|
||||
if (document.querySelector("dialog[open]")) return;
|
||||
openPrefsDialog();
|
||||
});
|
||||
|
||||
// Under the app, a link off the page goes to the default browser through
|
||||
// the console: the app's window opens no new ones, so the click alone would
|
||||
// do nothing. Capture phase, ahead of any handler on the link itself. The
|
||||
@@ -2412,19 +2571,7 @@ export function wireChrome() {
|
||||
});
|
||||
|
||||
$("btn-send").addEventListener("click", send);
|
||||
$("btn-clear").addEventListener("click", () => {
|
||||
if (!confirm("Clear everything you have not sent yet?")) return;
|
||||
page.local.staged = {};
|
||||
// Every typed box, the same set markSent clears: a draft left behind would
|
||||
// refill its box on the next render and look as if nothing was cleared.
|
||||
const typed = ["thread-", "other-", "text-", "note-"];
|
||||
for (const key of Object.keys(page.local.drafts)) if (typed.some((p) => key.startsWith(p))) delete page.local.drafts[key];
|
||||
for (const [itemId, list] of Object.entries(page.local.images)) {
|
||||
for (const img of list) removeImage(itemId, img.key);
|
||||
}
|
||||
saveNow();
|
||||
redraw();
|
||||
});
|
||||
$("btn-clear").addEventListener("click", clearUnsent);
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
||||
@@ -2435,6 +2582,22 @@ export function wireChrome() {
|
||||
send();
|
||||
return;
|
||||
}
|
||||
// ? opens Help where the `?` button does (its contextual tab), but never
|
||||
// from a field, a select, an editor or the Notebook, behind an open dialog
|
||||
// (a game plays in one) or with a modifier held. Matches the typed
|
||||
// character, so a layout that needs Shift for it works.
|
||||
if (e.key === "?" && !e.ctrlKey && !e.metaKey && !e.altKey && !e.defaultPrevented && !document.querySelector("dialog[open]")) {
|
||||
// The Markdown editors live in a shadow root, so the target is their
|
||||
// host (.md-host) at the document: read the whole composed path.
|
||||
const typing = e.composedPath().some(
|
||||
(n) => n.nodeType === 1 && (n.isContentEditable || n.matches("input, textarea, select, .md-host, .cm-editor, [contenteditable]"))
|
||||
);
|
||||
if (!typing) {
|
||||
e.preventDefault();
|
||||
openHelp();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Escape is the confirm pane's Back — but not while a dialog has it. Native
|
||||
// dialogs close themselves on the same key; backing out of the pick at the
|
||||
// same time would be two undos for one press.
|
||||
|
||||
@@ -13,8 +13,9 @@ import {
|
||||
learningBusyNow,
|
||||
LEARNING_BUSY_MS,
|
||||
} from "../selectors.js";
|
||||
import { whenTitle, whenWords } from "../labels.js";
|
||||
import { hooks, page, redraw, saveNow } from "../state.js";
|
||||
import { el, approvalTip, mdInto, releasesLink, copyButton, lightDismiss, SVG_NS } from "../render.js";
|
||||
import { el, approvalTip, mdInto, releasesLink, copyButton, lightDismiss, icon, SVG_NS } from "../render.js";
|
||||
import { needsRoleNudge, ROLE_NOT_SET } from "../starters.js";
|
||||
import { looks, saveLooks } from "../looks.js";
|
||||
import { RED_BANNER, RED_BANNER_IN_APP } from "../meter.js";
|
||||
@@ -75,39 +76,56 @@ export let wakeHoldsChime = false;
|
||||
// the waking click, since browsers refuse sound before one.
|
||||
let snore = null;
|
||||
|
||||
function roleNudge() {
|
||||
const nudge = el("div", "dash-nudge");
|
||||
nudge.setAttribute("role", "status");
|
||||
nudge.appendChild(el("span", "dash-nudge-text", "Pick your role to get starter templates ordered for you."));
|
||||
const actions = el("div", "dash-nudge-actions");
|
||||
const setUp = el("button", "btn small primary", "Set up preferences");
|
||||
setUp.type = "button";
|
||||
setUp.addEventListener("click", () => {
|
||||
// Closed without a role is a "Not now" too: having been to the dialog,
|
||||
// they were asked, and the banner does not come back (Help says so).
|
||||
$("looks-modal").addEventListener(
|
||||
"close",
|
||||
() => {
|
||||
if (looks.role === undefined) {
|
||||
looks.role = ROLE_NOT_SET;
|
||||
saveLooks();
|
||||
redraw();
|
||||
}
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
// The role is asked once; closing Preferences without one, or Not now, counts
|
||||
// as asked and ends the line (Help says so).
|
||||
function roleAsked() {
|
||||
if (looks.role === undefined) {
|
||||
looks.role = ROLE_NOT_SET;
|
||||
saveLooks();
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
// After the first launch: one quiet line for the two optional extras, a role
|
||||
// (starter templates ordered for you) and Learning. Until then both are held,
|
||||
// so the first dashboard offers a card and nothing else.
|
||||
function extrasLine() {
|
||||
const line = el("p", "dash-extras");
|
||||
// Learning is only on offer while it is Not set up; the role is always there
|
||||
// (the line shows only while the role is unasked).
|
||||
const learning = scan() && scan().learning;
|
||||
const withLearning = Boolean(learning && learning.state === "not-set-up");
|
||||
line.appendChild(document.createTextNode(withLearning ? "Two optional extras: " : "One optional extra: "));
|
||||
const role = el("button", "dash-extras-link", "set your role");
|
||||
role.type = "button";
|
||||
role.addEventListener("click", () => {
|
||||
$("looks-modal").addEventListener("close", roleAsked, { once: true });
|
||||
hooks.openPrefs("appearance");
|
||||
});
|
||||
const notNow = el("button", "btn tiny ghost", "Not now");
|
||||
line.appendChild(role);
|
||||
if (withLearning) {
|
||||
line.appendChild(document.createTextNode(", "));
|
||||
const learn = el("button", "dash-extras-link", "switch on Learning");
|
||||
learn.type = "button";
|
||||
learn.addEventListener("click", () => {
|
||||
const row = $("main").querySelector(".learn-row");
|
||||
if (!row) return;
|
||||
row.scrollIntoView({ block: "center" });
|
||||
const go = row.querySelector("button");
|
||||
if (go) go.focus();
|
||||
});
|
||||
line.appendChild(learn);
|
||||
}
|
||||
line.appendChild(document.createTextNode("."));
|
||||
const notNow = el("button", "btn xs soft", "Not now");
|
||||
notNow.type = "button";
|
||||
notNow.addEventListener("click", () => {
|
||||
looks.role = ROLE_NOT_SET;
|
||||
saveLooks();
|
||||
redraw();
|
||||
});
|
||||
actions.append(setUp, notNow);
|
||||
nudge.appendChild(actions);
|
||||
return nudge;
|
||||
line.appendChild(notNow);
|
||||
return line;
|
||||
}
|
||||
|
||||
// × on the update banner hides it for this console session only, and only
|
||||
@@ -131,7 +149,7 @@ function updateDismissed() {
|
||||
const UPDATE_COMMAND = "plan2code update";
|
||||
|
||||
// For a machine without the plan2code command: the full installer, menu and all.
|
||||
const UPDATE_FALLBACK_COMMAND = "npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git";
|
||||
const UPDATE_FALLBACK_COMMAND = "npx --allow-git=all git+https://github.com/jparkerweb/plan2code.git#release";
|
||||
|
||||
function openUpdateModal() {
|
||||
if (!page.updateFrame) return;
|
||||
@@ -139,24 +157,27 @@ function openUpdateModal() {
|
||||
versions.replaceChildren(
|
||||
document.createTextNode("Version "),
|
||||
releasesLink("v" + page.updateFrame.latest),
|
||||
document.createTextNode(" is out — you have "),
|
||||
document.createTextNode(" is out, you have "),
|
||||
el("code", null, page.updateFrame.installed),
|
||||
document.createTextNode(".")
|
||||
);
|
||||
const row = $("update-command");
|
||||
const code = el("code", null, UPDATE_COMMAND);
|
||||
row.replaceChildren(code, copyButton(UPDATE_COMMAND, "btn small ghost handoff-copy", code));
|
||||
row.replaceChildren(code, copyButton(UPDATE_COMMAND, "btn sm ghost handoff-copy", code));
|
||||
const fallbackRow = $("update-fallback");
|
||||
const fallback = el("code", null, UPDATE_FALLBACK_COMMAND);
|
||||
fallbackRow.replaceChildren(fallback, copyButton(UPDATE_FALLBACK_COMMAND, "btn small ghost handoff-copy", fallback));
|
||||
// Under the app, its terminal panel runs the agent, and the app it would
|
||||
// update is the one running this page.
|
||||
$("update-step-run").textContent = page.inApp
|
||||
? "Run this in a terminal outside the app (not in its terminal panel, which runs your agent):"
|
||||
: "Run this in your terminal (not in this page or your agent):";
|
||||
fallbackRow.replaceChildren(fallback, copyButton(UPDATE_FALLBACK_COMMAND, "btn sm ghost handoff-copy", fallback));
|
||||
// Under the app, the bar's Update and restart does all of it in one click;
|
||||
// the command is the fallback, and its terminal panel runs the agent, so
|
||||
// it goes in a terminal outside the app.
|
||||
$("update-step-run").replaceChildren(
|
||||
...(page.inApp
|
||||
? ["Press ", el("strong", null, "Update and restart"), " in the app's top bar. Or run this in a terminal outside the app (not in its terminal panel, which runs your agent):"]
|
||||
: ["Run this in your terminal (not in this page or your agent):"])
|
||||
);
|
||||
$("update-step-restart").replaceChildren(
|
||||
...(page.inApp
|
||||
? ["When it finishes, close the app and open it again."]
|
||||
? ["Update and restart reopens the app by itself. After the command, close the app and open it again."]
|
||||
: ["When it finishes, close this console and start ", el("code", null, "plan2code"), " again."])
|
||||
);
|
||||
$("update-modal").showModal();
|
||||
@@ -173,10 +194,10 @@ export function renderDashboard(main) {
|
||||
settleDeleting();
|
||||
const menu = (page.S && page.S.menu) || {};
|
||||
const wrap = el("div", "dash");
|
||||
if (needsRoleNudge(looks)) wrap.appendChild(roleNudge());
|
||||
const firstRun = looks.skillLaunched !== true;
|
||||
// Advice only: words, never a button, and nothing is blocked.
|
||||
if (page.meterFrame && page.meterFrame.level === "red") {
|
||||
const warn = el("div", "dash-nudge meter-banner", page.inApp ? RED_BANNER_IN_APP : RED_BANNER);
|
||||
const warn = el("div", "callout is-warn dash-nudge meter-banner", page.inApp ? RED_BANNER_IN_APP : RED_BANNER);
|
||||
warn.setAttribute("role", "status");
|
||||
wrap.appendChild(warn);
|
||||
}
|
||||
@@ -186,12 +207,13 @@ export function renderDashboard(main) {
|
||||
// (the bar's one-click Update skills only levels skills to the app's own
|
||||
// version), and the modal words its steps for the app.
|
||||
if (page.updateFrame && !updateDismissed()) {
|
||||
const notice = el("div", "dash-nudge update-banner");
|
||||
const notice = el("div", "callout is-info dash-nudge update-banner");
|
||||
notice.setAttribute("role", "status");
|
||||
const open = el("button", "update-banner-open", "UPDATE AVAILABLE · v" + page.updateFrame.latest);
|
||||
const open = el("button", "update-banner-open", "Update available · v" + page.updateFrame.latest);
|
||||
open.type = "button";
|
||||
open.addEventListener("click", openUpdateModal);
|
||||
const dismiss = el("button", "update-banner-dismiss", "×");
|
||||
const dismiss = el("button", "update-banner-dismiss");
|
||||
dismiss.appendChild(icon("close"));
|
||||
dismiss.type = "button";
|
||||
dismiss.setAttribute("aria-label", "Dismiss until next time");
|
||||
dismiss.addEventListener("click", () => {
|
||||
@@ -207,6 +229,7 @@ export function renderDashboard(main) {
|
||||
// title (the others are more urgent). Hidden while paused or off.
|
||||
const learnBanner = learningBanner(scan());
|
||||
if (learnBanner) wrap.appendChild(learnBanner);
|
||||
if (!firstRun && needsRoleNudge(looks)) wrap.appendChild(extrasLine());
|
||||
wrap.appendChild(el("p", "card-kicker", "Plan2Code"));
|
||||
wrap.appendChild(el("h2", "dash-title", "What are we doing today?"));
|
||||
// The agent's note reads the spec the picker opened on (the same "initial"
|
||||
@@ -286,7 +309,7 @@ export function renderDashboard(main) {
|
||||
}
|
||||
if (!shown) {
|
||||
wrap.appendChild(
|
||||
el("p", "dash-empty", "Nothing fits this pick right now. Turn off the toggle above to see every workflow.")
|
||||
el("p", "empty", "Nothing fits this pick right now. Turn off the toggle above to see every skill.")
|
||||
);
|
||||
}
|
||||
// Learning while on: after the last card group, before the approval tip.
|
||||
@@ -505,7 +528,7 @@ function hideUnavailableToggle() {
|
||||
});
|
||||
label.appendChild(box);
|
||||
label.appendChild(el("span", "dash-toggle-track"));
|
||||
label.appendChild(el("span", "dash-toggle-text", "Hide unavailable workflows"));
|
||||
label.appendChild(el("span", "dash-toggle-text", "Hide unavailable skills"));
|
||||
return label;
|
||||
}
|
||||
|
||||
@@ -563,7 +586,8 @@ function renderSpecPicker(specs) {
|
||||
if (isDeletableSpecDir(spec.dir)) {
|
||||
// A fixed bug is done with, so its Delete is a visible button rather
|
||||
// than the hover ✕ every other spec has.
|
||||
const del = fixed ? el("button", "spec-chip-del-label", "Delete") : el("button", "spec-chip-del", "✕");
|
||||
const del = fixed ? el("button", "spec-chip-del-label", "Delete") : el("button", "spec-chip-del");
|
||||
if (!fixed) del.appendChild(icon("close"));
|
||||
del.type = "button";
|
||||
del.title = `Delete ${spec.dir}/`;
|
||||
del.setAttribute("aria-label", `Delete the spec ${spec.name}`);
|
||||
@@ -611,11 +635,13 @@ function renderHandoffPreview(h) {
|
||||
box.appendChild(el("h3", "handoff-preview-title", h.title || "Handoff"));
|
||||
const entry = catalogEntry(h.skill);
|
||||
const meta = [
|
||||
"Written " + (h.written ? new Date(h.written).toLocaleString() : "at an unknown time"),
|
||||
"Written " + (h.written ? whenWords(h.written) || "at an unknown time" : "at an unknown time"),
|
||||
h.spec ? "spec " + h.spec.replace(/^specs\//, "") : "no spec",
|
||||
"from " + (entry ? entry.title : h.skill),
|
||||
];
|
||||
box.appendChild(el("p", "handoff-preview-meta", meta.join(" · ")));
|
||||
const metaLine = el("p", "handoff-preview-meta", meta.join(" · "));
|
||||
if (h.written) metaLine.title = whenTitle(h.written);
|
||||
box.appendChild(metaLine);
|
||||
if (h.next) {
|
||||
box.appendChild(el("p", "handoff-preview-label", "Next task"));
|
||||
box.appendChild(el("p", "handoff-preview-next", h.next));
|
||||
@@ -740,8 +766,8 @@ function dashCard(entry, menu) {
|
||||
if (!presentation.on && presentation.reason) b.title = presentation.reason;
|
||||
|
||||
const head = el("span", "dash-card-head");
|
||||
head.appendChild(el("span", "dash-chip", entry.chip));
|
||||
if (presentation.recommended) head.appendChild(el("span", "pill suggested", "Suggested"));
|
||||
head.appendChild(el("span", "pill is-neutral is-caps dash-chip", entry.chip));
|
||||
if (presentation.recommended) head.appendChild(el("span", "pill is-accent is-caps suggested", "Suggested"));
|
||||
b.appendChild(head);
|
||||
const title = el("span", "dash-card-title");
|
||||
if (entry.icon) {
|
||||
@@ -770,7 +796,14 @@ function dashCard(entry, menu) {
|
||||
page.dashPick = entry;
|
||||
redraw();
|
||||
});
|
||||
if (entry.appOnly) b.appendChild(loopHelpLink());
|
||||
// "How the loop works" is a link of its own beside the card, never inside
|
||||
// the button (a link in a button is not valid and reads badly aloud).
|
||||
if (entry.appOnly) {
|
||||
const wrap = el("div", "dash-card-wrap");
|
||||
wrap.appendChild(b);
|
||||
wrap.appendChild(loopHelpLink());
|
||||
return wrap;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -782,19 +815,12 @@ function loopPresentation(entry, menu) {
|
||||
return { ...cardPresentation(entry, scan(), selSpec(), menu), recommended: false };
|
||||
}
|
||||
|
||||
// "How the loop works" on the card: a link inside a button is not allowed, so
|
||||
// it is a span that acts like one and keeps the click from opening the setup.
|
||||
// "How the loop works" under the card: a real button styled as a link, a
|
||||
// sibling of the card button inside its wrapper.
|
||||
function loopHelpLink() {
|
||||
const a = el("span", "dash-card-link", "How the loop works");
|
||||
a.setAttribute("role", "link");
|
||||
a.tabIndex = 0;
|
||||
const open = (e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
hooks.openHelpOn("loop");
|
||||
};
|
||||
a.addEventListener("click", open);
|
||||
a.addEventListener("keydown", (e) => (e.key === "Enter" || e.key === " ") && open(e));
|
||||
const a = el("button", "dash-card-link", "How the loop works");
|
||||
a.type = "button";
|
||||
a.addEventListener("click", () => hooks.openHelpOn("loop"));
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -908,7 +934,7 @@ function drawNoteBox(entry, box, cmdNote) {
|
||||
label.append(toggle, el("span", "confirm-note-switch-text", "Start with a note from your Notebook"));
|
||||
// A callout row, so the switch stands out under the card's long text; the
|
||||
// hint sits outside the label to keep the checkbox's name short.
|
||||
const head = el("div", "confirm-note-head" + (state.on ? " is-on" : ""));
|
||||
const head = el("div", "callout is-info confirm-note-head" + (state.on ? " is-on" : ""));
|
||||
head.appendChild(label);
|
||||
if (!state.on) {
|
||||
const hint = el("span", "confirm-note-hint", "Hand it a tab you wrote earlier, with its pictures.");
|
||||
@@ -927,7 +953,12 @@ function drawNoteBox(entry, box, cmdNote) {
|
||||
if (state.tabs === null) {
|
||||
wrap.appendChild(el("p", "confirm-note-msg", "Reading your Notebook…"));
|
||||
} else if (state.failed) {
|
||||
wrap.appendChild(el("p", "confirm-note-msg", "Your Notebook could not be read. Turn the switch off and on to try again."));
|
||||
wrap.appendChild(el("p", "confirm-note-msg", "Your Notebook could not be read."));
|
||||
const retry = el("button", "btn xs soft confirm-note-retry", "Try again");
|
||||
retry.type = "button";
|
||||
retry.dataset.noteFocus = "retry";
|
||||
retry.addEventListener("click", () => refreshNoteTabs(state, true));
|
||||
wrap.appendChild(retry);
|
||||
} else if (!state.tabs.length) {
|
||||
wrap.appendChild(el("p", "confirm-note-msg", "Your Notebook has no tabs yet. Open it from the top bar to write one."));
|
||||
} else {
|
||||
@@ -943,7 +974,7 @@ function drawNoteBox(entry, box, cmdNote) {
|
||||
b.setAttribute("aria-pressed", String(t.id === state.picked));
|
||||
b.appendChild(el("span", "confirm-note-tab-name", t.name));
|
||||
if (t.sent) {
|
||||
const badge = el("span", "notepad-sent-badge", "previously sent");
|
||||
const badge = el("span", "pill is-accent notepad-sent-badge", "previously sent");
|
||||
badge.setAttribute("aria-hidden", "true");
|
||||
b.appendChild(badge);
|
||||
}
|
||||
@@ -1055,8 +1086,8 @@ export function renderConfirm(main, entry) {
|
||||
pane.appendChild(stage);
|
||||
|
||||
const head = el("div", "confirm-head");
|
||||
head.appendChild(el("span", "dash-chip", entry.chip));
|
||||
if (presentation.recommended) head.appendChild(el("span", "pill suggested", "Suggested"));
|
||||
head.appendChild(el("span", "pill is-neutral is-caps dash-chip", entry.chip));
|
||||
if (presentation.recommended) head.appendChild(el("span", "pill is-accent is-caps suggested", "Suggested"));
|
||||
pane.appendChild(head);
|
||||
pane.appendChild(el("h2", "dash-title", entry.title));
|
||||
pane.appendChild(el("p", "confirm-about", entry.about || entry.blurb));
|
||||
@@ -1086,7 +1117,7 @@ export function renderConfirm(main, entry) {
|
||||
page.dashReview = review.checked;
|
||||
cmdCode.textContent = launchVariant(entry, review.checked).command;
|
||||
});
|
||||
label.append(review, el("span", null, "Auto Review: fresh agent pass over the phase's changes before sign-off"));
|
||||
label.append(review, el("span", null, "Review each phase with a fresh agent before sign-off"));
|
||||
pane.appendChild(label);
|
||||
}
|
||||
|
||||
@@ -1151,7 +1182,7 @@ export async function launchSkill(entry) {
|
||||
// The card was clickable, so this should never fire — but a spec picked in
|
||||
// one tab could have shifted the ground under a stale render in another.
|
||||
if (!cardAvailability(entry, scan(), selSpec()).on) {
|
||||
hooks.banner("That card is not available for the spec you picked.", "warn");
|
||||
hooks.banner("That skill is not available for the spec you picked.", "warn");
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
@@ -1210,6 +1241,12 @@ export async function launchSkill(entry) {
|
||||
}
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
sound("startSkill");
|
||||
// The first launch from this machine ends the first-run hold on the
|
||||
// optional extras (never cleared, not even by Back to default).
|
||||
if (looks.skillLaunched !== true) {
|
||||
looks.skillLaunched = true;
|
||||
saveLooks();
|
||||
}
|
||||
page.local.launching = { skill: entry.skill, title: entry.title, at: Date.now() };
|
||||
page.launchScoping = false;
|
||||
page.pendingResult = true;
|
||||
@@ -1251,14 +1288,16 @@ function openHandoffDelete(h) {
|
||||
$("delete-warn-handoff").hidden = false;
|
||||
const facts = $("delete-facts");
|
||||
facts.replaceChildren();
|
||||
const fact = (term, value) => {
|
||||
const fact = (term, value, title) => {
|
||||
if (!value) return;
|
||||
facts.appendChild(el("dt", "", term));
|
||||
facts.appendChild(el("dd", "", value));
|
||||
const dd = el("dd", "", value);
|
||||
if (title) dd.title = title;
|
||||
facts.appendChild(dd);
|
||||
};
|
||||
const entry = catalogEntry(h.skill);
|
||||
fact("Handoff", h.title || h.id);
|
||||
fact("Written", h.written ? new Date(h.written).toLocaleString() : "");
|
||||
fact("Written", h.written ? whenWords(h.written) : "", h.written ? whenTitle(h.written) : "");
|
||||
fact("Spec", h.spec ? h.spec.replace(/^specs\//, "") : "");
|
||||
fact("From", entry ? entry.title : h.skill);
|
||||
$("delete-confirm").hidden = true;
|
||||
@@ -1289,16 +1328,18 @@ function openDeleteConfirm(spec) {
|
||||
$("delete-blurb").textContent = `Everything in ${sum.folder} will be deleted from this project.`;
|
||||
const facts = $("delete-facts");
|
||||
facts.replaceChildren();
|
||||
const fact = (term, value) => {
|
||||
const fact = (term, value, title) => {
|
||||
if (!value) return;
|
||||
facts.appendChild(el("dt", "", term));
|
||||
facts.appendChild(el("dd", "", value));
|
||||
const dd = el("dd", "", value);
|
||||
if (title) dd.title = title;
|
||||
facts.appendChild(dd);
|
||||
};
|
||||
fact("Spec", spec.name);
|
||||
fact("Folder", sum.folder);
|
||||
fact("Stage", sum.stage);
|
||||
fact("Files", sum.files);
|
||||
fact("Last changed", sum.touched ? new Date(sum.touched).toLocaleString() : "");
|
||||
fact("Last changed", sum.touched ? whenWords(sum.touched) : "", sum.touched ? whenTitle(sum.touched) : "");
|
||||
$("delete-name-hint").textContent = spec.name;
|
||||
$("delete-name").value = "";
|
||||
$("delete-confirm").hidden = true;
|
||||
@@ -1402,7 +1443,7 @@ function learningBanner(sc) {
|
||||
const working = busy && (busy.what === "review" || busy.what === "decide") ? busy : null;
|
||||
const text = learningBannerText(sc && sc.learning);
|
||||
if (!text && !working) return null;
|
||||
const banner = el("div", "dash-nudge learn-banner");
|
||||
const banner = el("div", "callout is-info dash-nudge learn-banner");
|
||||
banner.setAttribute("role", "status");
|
||||
if (working) {
|
||||
banner.classList.add("is-busy");
|
||||
@@ -1411,7 +1452,7 @@ function learningBanner(sc) {
|
||||
line.append(el("span", "spinner tiny"), document.createTextNode(working.what === "review" ? "Opening lessons…" : "Saving your lessons…"));
|
||||
banner.appendChild(line);
|
||||
if (working.what === "review") {
|
||||
const review = el("button", "btn small primary", "Review");
|
||||
const review = el("button", "btn sm primary", "Review");
|
||||
review.type = "button";
|
||||
review.disabled = true;
|
||||
banner.appendChild(review);
|
||||
@@ -1419,7 +1460,7 @@ function learningBanner(sc) {
|
||||
return banner;
|
||||
}
|
||||
banner.appendChild(el("span", "dash-nudge-text", text));
|
||||
const review = el("button", "btn small primary", "Review");
|
||||
const review = el("button", "btn sm primary", "Review");
|
||||
review.type = "button";
|
||||
const why = hooks.learningBlocked();
|
||||
review.disabled = Boolean(why);
|
||||
@@ -1453,8 +1494,8 @@ function watchLearningBusy(busy) {
|
||||
clearInterval(timer);
|
||||
page.learningBusy = null;
|
||||
if (busy.what === "review") {
|
||||
hooks.banner("No lessons are waiting any more.", "info");
|
||||
setTimeout(() => hooks.banner(null), 4000);
|
||||
const none = hooks.banner("No lessons are waiting any more.", "info");
|
||||
setTimeout(() => hooks.clearBanner(none), 4000);
|
||||
}
|
||||
redraw();
|
||||
}, 400);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {
|
||||
docs, agentWorking, workingMs, patience, WORKING_GRACE_MS, finish, SPEC_FILES, loadAgentsDoc, openPrototypeDoc, closePrototypeDoc,
|
||||
} from "../selectors.js";
|
||||
import { el, md } from "../render.js";
|
||||
import { el, icon, md } from "../render.js";
|
||||
import { downloadDocHtml, docSavedNote, downloadDoc, blockBody } from "../doc-files.js";
|
||||
import { hooks, page, redraw } from "../state.js";
|
||||
|
||||
@@ -93,8 +93,8 @@ export async function sendBrief() {
|
||||
if (res.status === 409) throw Object.assign(new Error("pending"), { pending: true });
|
||||
if (!res.ok) throw new Error(String(res.status));
|
||||
$("brief-modal").close();
|
||||
hooks.banner("Asked for a brief. It will appear as a tab when it is written.", "good");
|
||||
setTimeout(() => hooks.banner(null), 5000);
|
||||
const asked = hooks.banner("Asked for a brief. It will appear as a tab when it is written.", "good");
|
||||
setTimeout(() => hooks.clearBanner(asked), 5000);
|
||||
page.pendingResult = true;
|
||||
redraw();
|
||||
} catch (err) {
|
||||
@@ -120,17 +120,25 @@ export function renderBriefButton() {
|
||||
if (offer) btn.disabled = page.gone || page.pendingResult || Boolean(finish());
|
||||
}
|
||||
|
||||
// The page's one empty block (.empty): an icon from the sheet and one line.
|
||||
function emptyBlock(text) {
|
||||
const box = el("div", "empty");
|
||||
box.appendChild(icon("document", "empty-icon"));
|
||||
box.appendChild(el("p", null, text));
|
||||
return box;
|
||||
}
|
||||
|
||||
export function renderDoc(main, id) {
|
||||
const doc = docs().find((d) => d.id === id);
|
||||
if (!doc) {
|
||||
main.appendChild(el("p", "doc-empty", "That document is not ready yet."));
|
||||
main.appendChild(emptyBlock("That document is not ready yet."));
|
||||
return;
|
||||
}
|
||||
const head = el("div", "doc-head");
|
||||
head.appendChild(el("h2", null, doc.title || "Document"));
|
||||
head.appendChild(el("span", "doc-version", "v" + (doc.version || 1)));
|
||||
if (doc.stale) {
|
||||
head.appendChild(el("span", "pill staged", "Out of date"));
|
||||
head.appendChild(el("span", "pill is-stage", "Out of date"));
|
||||
}
|
||||
|
||||
const tools = el("div", "doc-tools");
|
||||
@@ -138,7 +146,7 @@ export function renderDoc(main, id) {
|
||||
// A brief is handed to people who were not in the room, so it gets a copy
|
||||
// that opens in any browser, formatting and all.
|
||||
if (doc.id === "brief") {
|
||||
const html = el("button", "btn small", "Save as HTML");
|
||||
const html = el("button", "btn sm", "Save as HTML");
|
||||
html.type = "button";
|
||||
html.addEventListener("click", () => downloadDocHtml(doc));
|
||||
tools.appendChild(html);
|
||||
@@ -148,7 +156,7 @@ export function renderDoc(main, id) {
|
||||
if (doc.saved) {
|
||||
tools.appendChild(docSavedNote(doc));
|
||||
} else {
|
||||
const save = el("button", "btn small", "Download");
|
||||
const save = el("button", "btn sm", "Download");
|
||||
save.type = "button";
|
||||
save.addEventListener("click", () => downloadDoc(doc));
|
||||
tools.appendChild(save);
|
||||
@@ -160,7 +168,7 @@ export function renderDoc(main, id) {
|
||||
|
||||
const blocks = doc.blocks || [];
|
||||
if (!blocks.length) {
|
||||
main.appendChild(el("p", "doc-empty", "Nothing written yet. It fills in as you answer."));
|
||||
main.appendChild(emptyBlock("Nothing written yet. It fills in as you answer."));
|
||||
return;
|
||||
}
|
||||
// The block nearest the top of the column is the section + Add context
|
||||
@@ -202,7 +210,7 @@ export function renderDoc(main, id) {
|
||||
function backButton() {
|
||||
const flow = page.S.workflow;
|
||||
const home = flow === "dashboard" ? "Dashboard" : flow === "git" ? "Git" : "Questions";
|
||||
const back = el("button", "btn small back-home", "Back to " + home);
|
||||
const back = el("button", "btn sm back-home", "Back to " + home);
|
||||
back.type = "button";
|
||||
back.addEventListener("click", () => {
|
||||
page.view = finish() ? "end" : "questions";
|
||||
@@ -213,7 +221,7 @@ function backButton() {
|
||||
}
|
||||
|
||||
function printButton() {
|
||||
const print = el("button", "btn small", "Print");
|
||||
const print = el("button", "btn sm", "Print");
|
||||
print.type = "button";
|
||||
// The print stylesheet drops everything that steers the session, so what
|
||||
// comes out is the document alone. "Save as PDF" in that dialog is also the
|
||||
@@ -237,10 +245,21 @@ export function renderOverview(main, kind = "overview") {
|
||||
main.appendChild(head);
|
||||
main.appendChild(el("p", "help", `${page.overview.key}/${found ? found.file : ""} · read-only, straight from disk`));
|
||||
const box = el("div", "block settled");
|
||||
box.appendChild(md(found ? found.text : "", "md"));
|
||||
if (found) box.appendChild(md(found.text, "md"));
|
||||
else box.appendChild(loadingRows());
|
||||
main.appendChild(box);
|
||||
}
|
||||
|
||||
// Muted rows where a file's lines will be, the diff view's loading look
|
||||
// (they shimmer under no-preference, diff.css).
|
||||
function loadingRows(count = 7) {
|
||||
const rows = el("div", "diff-skeleton doc-skeleton");
|
||||
rows.setAttribute("role", "status");
|
||||
rows.setAttribute("aria-label", "Reading the file");
|
||||
for (let i = 0; i < count; i++) rows.appendChild(el("span", "diff-skel-row"));
|
||||
return rows;
|
||||
}
|
||||
|
||||
// The files the AGENTS.md tab may show: the same two shapes the server serves.
|
||||
const AGENTS_FILE = /^(?:AGENTS\.md|\.agents-docs\/[A-Za-z0-9._-]+\.md)$/;
|
||||
|
||||
@@ -267,7 +286,7 @@ export function renderAgentsDoc(main) {
|
||||
head.appendChild(el("h2", null, open === "AGENTS.md" ? "AGENTS.md" : open));
|
||||
const tools = el("div", "doc-tools");
|
||||
if (open !== "AGENTS.md") {
|
||||
const guide = el("button", "btn small", "Back to AGENTS.md");
|
||||
const guide = el("button", "btn sm", "Back to AGENTS.md");
|
||||
guide.type = "button";
|
||||
guide.addEventListener("click", () => {
|
||||
page.agentsDoc.open = "AGENTS.md";
|
||||
@@ -323,7 +342,7 @@ export function renderPrototypes(main) {
|
||||
head.appendChild(el("h2", null, reading ? open : "Prototypes"));
|
||||
const tools = el("div", "doc-tools");
|
||||
if (reading) {
|
||||
const list = el("button", "btn small", "Back to Prototypes");
|
||||
const list = el("button", "btn sm", "Back to Prototypes");
|
||||
list.type = "button";
|
||||
list.addEventListener("click", () => {
|
||||
closePrototypeDoc();
|
||||
@@ -347,7 +366,7 @@ export function renderPrototypes(main) {
|
||||
const row = el("li", "proto-row");
|
||||
const b = el("button", "proto-open", null);
|
||||
b.type = "button";
|
||||
b.appendChild(el("span", "proto-kind proto-kind-" + f.kind, f.kind === "md" ? "MD" : "HTML"));
|
||||
b.appendChild(el("span", "code-tag" + (f.kind === "md" ? "" : " is-accent") + " proto-kind proto-kind-" + f.kind, f.kind === "md" ? "MD" : "HTML"));
|
||||
b.appendChild(el("span", "proto-name", f.name));
|
||||
b.appendChild(el("span", "proto-how", f.kind === "md" ? "Read it here" : "Opens in your browser ↗"));
|
||||
b.title = f.kind === "md" ? `Read ${f.name} here` : `Open ${f.name} in your default browser`;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Plan2Code Web Console - how a session ends: the finished screen, its offers, Stop and the way home; defines only.
|
||||
|
||||
import { NOT_CONNECTED } from "../labels.js";
|
||||
import { el, md, copyButton, copyText, selectContents, textWithCode, SVG_NS } from "../render.js";
|
||||
import {
|
||||
finishPaused,
|
||||
@@ -246,9 +247,9 @@ export function renderLoopEnd(end) {
|
||||
const reason = !finished && typeof end.reason === "string" && end.reason ? end.reason : "";
|
||||
card.appendChild(el("h2", "loop-end-heading", finished ? "Every phase is built" : reason || end.line));
|
||||
// On a stop the full line is the colored reason, and the advice sits under it.
|
||||
if ((finished || reason) && end.line) card.appendChild(el("p", finished ? "loop-line" : "loop-line loop-why", end.line));
|
||||
if ((finished || reason) && end.line) card.appendChild(el("p", finished ? "loop-line" : "callout is-warn loop-line loop-why", end.line));
|
||||
if (!finished && typeof end.advice === "string" && end.advice) {
|
||||
const next = el("p", "loop-advice");
|
||||
const next = el("p", "callout is-info loop-advice");
|
||||
next.appendChild(el("strong", null, "What to do next: "));
|
||||
next.appendChild(document.createTextNode(end.advice));
|
||||
card.appendChild(next);
|
||||
@@ -260,7 +261,7 @@ export function renderLoopEnd(end) {
|
||||
|
||||
const evidence = end.evidence && docs().find((d) => d.id === end.evidence);
|
||||
if (evidence) {
|
||||
const read = el("button", "btn small", finished ? "Read the full report" : "Read why, and the report so far");
|
||||
const read = el("button", "btn sm", finished ? "Read the full report" : "Read why, and the report so far");
|
||||
read.type = "button";
|
||||
read.addEventListener("click", () => {
|
||||
page.view = "doc:" + evidence.id;
|
||||
@@ -399,7 +400,7 @@ function renderReport(text) {
|
||||
body.tabIndex = 0;
|
||||
body.setAttribute("role", "region");
|
||||
body.setAttribute("aria-label", "Bug report");
|
||||
const copy = el("button", "btn small", "Copy report");
|
||||
const copy = el("button", "btn sm", "Copy report");
|
||||
copy.type = "button";
|
||||
// Word for word what the file holds, so it pastes into a ticket as Markdown.
|
||||
copy.addEventListener("click", () =>
|
||||
@@ -417,7 +418,7 @@ function renderReport(text) {
|
||||
export function renderHandoff(fin) {
|
||||
if (page.S && page.S.loopEnd) return renderLoopEnd(page.S.loopEnd);
|
||||
const card = el("article", "card handoff");
|
||||
card.appendChild(el("p", "card-kicker", finishPaused(fin) ? "Session paused" : "Session ended"));
|
||||
card.appendChild(el("p", "card-kicker", finishPaused(fin) ? "Session stopped" : "Session finished"));
|
||||
card.appendChild(el("h2", null, fin.headline));
|
||||
if (fin.body) card.appendChild(md(fin.body, "md prompt"));
|
||||
|
||||
@@ -451,6 +452,9 @@ export function renderHandoff(fin) {
|
||||
// session with nothing left to run, which gets a quiet pointer at the
|
||||
// dashboard instead of a Next step block.
|
||||
const shape = handoffShape(fin);
|
||||
// The quiet extras of a finish (a second way to start something else, and
|
||||
// "Before you close this") fold into one closed section at the foot.
|
||||
const folded = [];
|
||||
if (shape === "all-done") {
|
||||
const done = el("div", "handoff-done");
|
||||
done.appendChild(md(`${ALL_DONE_LEAD} ${page.inApp ? ALL_DONE_REST_IN_APP : ALL_DONE_REST}`, "md handoff-done-text"));
|
||||
@@ -461,7 +465,7 @@ export function renderHandoff(fin) {
|
||||
const row = el("div", "handoff-command");
|
||||
const code = el("code", "handoff-code", text);
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small ghost handoff-copy", code));
|
||||
row.appendChild(copyButton(text, "btn sm ghost handoff-copy", code));
|
||||
done.appendChild(row);
|
||||
// Once the server is gone, the row above already is the offer's fallback.
|
||||
if (dashboardLive(fin) && !page.gone) done.appendChild(renderDashboardOffer(true));
|
||||
@@ -491,13 +495,13 @@ export function renderHandoff(fin) {
|
||||
const row = el("div", "handoff-command");
|
||||
const code = el("code", "handoff-code", text);
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small handoff-copy", code));
|
||||
row.appendChild(copyButton(text, "btn sm handoff-copy", code));
|
||||
step.appendChild(row);
|
||||
// Under the app a clean start is the bar's New Session: one press, with
|
||||
// the command already on the clipboard to paste into the new terminal.
|
||||
if (page.inApp && command.startsWith("/") && !page.gone && !pressStranded()) {
|
||||
const fresh = el("div", "handoff-newsession");
|
||||
const press = el("button", "btn small", "Start a New Session");
|
||||
const press = el("button", "btn sm", "Start a New Session");
|
||||
press.type = "button";
|
||||
press.addEventListener("click", () => startNewSession(text));
|
||||
fresh.appendChild(press);
|
||||
@@ -528,7 +532,7 @@ export function renderHandoff(fin) {
|
||||
// `/plan2code`"), right below this card, so repeating it here would
|
||||
// be the third mention of the one action on this screen.
|
||||
if (!page.inApp && !(offerDash && page.gone)) {
|
||||
card.appendChild(
|
||||
folded.push(
|
||||
textWithCode(
|
||||
"p",
|
||||
"handoff-fresh",
|
||||
@@ -539,8 +543,8 @@ export function renderHandoff(fin) {
|
||||
const freshRow = el("div", "handoff-command handoff-fresh-row");
|
||||
const freshCode = el("code", "handoff-code", freshText);
|
||||
freshRow.appendChild(freshCode);
|
||||
freshRow.appendChild(copyButton(freshText, "btn small ghost handoff-copy", freshCode));
|
||||
card.appendChild(freshRow);
|
||||
freshRow.appendChild(copyButton(freshText, "btn sm ghost handoff-copy", freshCode));
|
||||
folded.push(freshRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -548,7 +552,8 @@ export function renderHandoff(fin) {
|
||||
// Not while a hand-off they just asked for is starting on this page: "Safe
|
||||
// to close" and "start a new one" would contradict the line above it. The
|
||||
// press re-renders the page, and so does the agent taking it up.
|
||||
if (!closeGuideHeld()) card.appendChild(renderCloseGuide(shape, fin));
|
||||
if (!closeGuideHeld()) folded.push(renderCloseGuide(shape, fin));
|
||||
if (folded.length) card.appendChild(renderFoldedExtras(folded));
|
||||
|
||||
card.appendChild(
|
||||
el(
|
||||
@@ -571,13 +576,14 @@ export function renderHandoff(fin) {
|
||||
if (keep.saved) {
|
||||
tools.appendChild(docSavedNote(keep));
|
||||
} else {
|
||||
const save = el("button", "btn small", `Download ${keep.title || "the document"}`);
|
||||
const save = el("button", "btn sm", `Download ${keep.title || "the document"}`);
|
||||
save.type = "button";
|
||||
save.addEventListener("click", () => downloadDoc(keep));
|
||||
tools.appendChild(save);
|
||||
}
|
||||
card.appendChild(tools);
|
||||
}
|
||||
onePrimary(card);
|
||||
|
||||
// Answers staged and never sent are lost the moment this page closes, and
|
||||
// this page's one promise is that nothing gets lost. Say so plainly rather
|
||||
@@ -587,7 +593,7 @@ export function renderHandoff(fin) {
|
||||
card.appendChild(
|
||||
el(
|
||||
"p",
|
||||
"handoff-unsent",
|
||||
"callout is-stage handoff-unsent",
|
||||
`${stuck} answer${stuck === 1 ? "" : "s"} here ${stuck === 1 ? "was" : "were"} never sent, ` +
|
||||
`and Plan2Code has finished. If ${stuck === 1 ? "it" : "they"} still matter, say so in the ` +
|
||||
`next session: nothing on this page will reach it now.`
|
||||
@@ -597,6 +603,37 @@ export function renderHandoff(fin) {
|
||||
return card;
|
||||
}
|
||||
|
||||
// Whether "Closing or starting fresh" is open, kept across redraws: a section
|
||||
// that closes under a reader who just opened it is worse than one left open.
|
||||
let foldedOpen = null;
|
||||
|
||||
// The fresh-session advice is what a red meter asks for, so it opens by itself
|
||||
// there (until the person closes it).
|
||||
function renderFoldedExtras(nodes) {
|
||||
const box = el("details", "handoff-more");
|
||||
const red = Boolean(page.meterFrame && page.meterFrame.level === "red");
|
||||
box.open = foldedOpen === null ? red : foldedOpen;
|
||||
box.appendChild(el("summary", "handoff-more-title", "Closing or starting fresh"));
|
||||
box.append(...nodes);
|
||||
box.addEventListener("toggle", () => {
|
||||
foldedOpen = box.open;
|
||||
});
|
||||
return box;
|
||||
}
|
||||
|
||||
// Exactly one primary button per finish, by a fixed rule: the review when it is
|
||||
// on offer, else the commit, else Continue here, else Back to the dashboard, else
|
||||
// the stranded screen's New Session, else the next command's Copy button (a
|
||||
// pause, a gone server: the one thing to do is take the command). The rest are
|
||||
// plain buttons.
|
||||
const PRIMARY_RULE = [".review-go", ".commit-go", ".continue-go", ".dashboard-go", ".stranded-go", ".handoff-copy"];
|
||||
|
||||
function onePrimary(card) {
|
||||
const keep = PRIMARY_RULE.map((sel) => card.querySelector(sel)).find(Boolean) || null;
|
||||
for (const b of card.querySelectorAll("button.primary")) if (b !== keep) b.classList.remove("primary");
|
||||
if (keep) keep.classList.add("primary");
|
||||
}
|
||||
|
||||
// The escape hatch of a finished screen whose press nothing collects (the
|
||||
// agent's turn ended while the page waited). Always enabled: under the app a
|
||||
// New Session, with the dashboard command copied first; in a browser the
|
||||
@@ -614,7 +651,7 @@ function renderStrandedEscape() {
|
||||
)
|
||||
);
|
||||
const row = el("div", "btn-row");
|
||||
const go = el("button", "btn primary", "Start a New Session");
|
||||
const go = el("button", "btn primary stranded-go", "Start a New Session");
|
||||
go.type = "button";
|
||||
go.addEventListener("click", () => startNewSession(text));
|
||||
row.appendChild(go);
|
||||
@@ -631,7 +668,7 @@ function renderStrandedEscape() {
|
||||
const row = el("div", "handoff-command");
|
||||
const code = el("code", "handoff-code", text);
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small handoff-copy", code));
|
||||
row.appendChild(copyButton(text, "btn sm handoff-copy", code));
|
||||
box.appendChild(row);
|
||||
return box;
|
||||
}
|
||||
@@ -669,7 +706,7 @@ function renderReviewOffer(offer) {
|
||||
const row = el("div", "handoff-command");
|
||||
const code = el("code", "handoff-code", text);
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small handoff-copy", code));
|
||||
row.appendChild(copyButton(text, "btn sm handoff-copy", code));
|
||||
box.appendChild(row);
|
||||
return box;
|
||||
}
|
||||
@@ -714,7 +751,7 @@ function renderCommitOffer() {
|
||||
);
|
||||
const { asked, disabled } = afterFinishButton(page.local.afterBuild, "commit", page.pendingResult);
|
||||
const row = el("div", "btn-row");
|
||||
const go = el("button", "btn primary", asked ? "Opening Git…" : "Commit it now");
|
||||
const go = el("button", "btn primary commit-go", asked ? "Opening Git…" : "Commit it now");
|
||||
go.type = "button";
|
||||
go.disabled = disabled;
|
||||
go.addEventListener("click", () => sendAfterBuild("commit"));
|
||||
@@ -738,7 +775,7 @@ function continueLive() {
|
||||
function renderContinueOffer(next) {
|
||||
const box = el("div", "continue-offer");
|
||||
const { asked, disabled } = afterFinishButton(page.local.afterBuild, "launch", page.pendingResult);
|
||||
const go = el("button", "btn primary continue-go", asked ? "Starting the next step…" : "Continue here");
|
||||
const go = el("button", "btn primary continue-go", asked ? "Starting the next skill…" : "Continue here");
|
||||
go.type = "button";
|
||||
go.disabled = disabled;
|
||||
go.addEventListener("click", () => sendAfterBuild("launch", next));
|
||||
@@ -803,14 +840,14 @@ function renderDashboardOffer(primary) {
|
||||
const row = el("div", "handoff-command");
|
||||
const code = el("code", "handoff-code", text);
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small handoff-copy", code));
|
||||
row.appendChild(copyButton(text, "btn sm handoff-copy", code));
|
||||
box.appendChild(row);
|
||||
return box;
|
||||
}
|
||||
const { asked, disabled } = afterFinishButton(page.local.afterBuild, "dashboard", page.pendingResult);
|
||||
const go = el(
|
||||
"button",
|
||||
primary ? "btn primary" : "btn",
|
||||
primary ? "btn primary dashboard-go" : "btn dashboard-go",
|
||||
asked ? "Opening the dashboard…" : "Back to the dashboard"
|
||||
);
|
||||
go.type = "button";
|
||||
@@ -854,11 +891,11 @@ async function sendAfterBuild(kind, launch = null) {
|
||||
dashboard: "Opening the dashboard. It appears here in a moment.",
|
||||
commit: "Opening Git. It appears here in a moment.",
|
||||
changelog: "Opening Changelog. It appears here in a moment.",
|
||||
launch: "Starting the next step. It appears here in a moment.",
|
||||
launch: "Starting the next skill. It appears here in a moment.",
|
||||
}[kind];
|
||||
if (started) {
|
||||
hooks.banner(started, "good");
|
||||
setTimeout(() => hooks.banner(null), 5000);
|
||||
const startedBanner = hooks.banner(started, "good");
|
||||
setTimeout(() => hooks.clearBanner(startedBanner), 5000);
|
||||
}
|
||||
} catch {
|
||||
hooks.banner("That did not go through. Nothing was lost; try again.", "warn");
|
||||
@@ -891,6 +928,7 @@ export function renderStopButton() {
|
||||
b.textContent = "Stopping…";
|
||||
b.disabled = false;
|
||||
b.title = "Show how the stop is going";
|
||||
setLocked(b, "");
|
||||
return;
|
||||
}
|
||||
b.textContent = "Stop session";
|
||||
@@ -898,12 +936,78 @@ export function renderStopButton() {
|
||||
const gate = turnGate({ gone: page.gone, pendingResult: page.pendingResult, waiting: agentHasTheBall() });
|
||||
// A way home in flight holds Stop back too, unless the agent went quiet
|
||||
// after collecting it: Stop's resume screen is then the only way out.
|
||||
b.disabled = Boolean(gate) || (Boolean(page.local.homeward) && !agentAdrift()) || loopDriving();
|
||||
// Locked with aria-disabled, never disabled: a press still lands and says why.
|
||||
const locked = Boolean(gate) || (Boolean(page.local.homeward) && !agentAdrift()) || loopDriving();
|
||||
b.title = loopDriving() ? LOOP_LOCK_TITLE : {
|
||||
gone: "Not connected right now.",
|
||||
gone: NOT_CONNECTED,
|
||||
pending: "Your last answers are still being picked up. You can stop once they have been.",
|
||||
waiting: "Plan2Code is working on your answers. You can stop once it replies.",
|
||||
}[gate] || (stopWarning() ? "End this session. Work since the last save is not kept." : "Save your place and end this session. You get a command to pick it up later.");
|
||||
setLocked(b, locked ? lockWhy("Stop", gate, b.title) : "");
|
||||
}
|
||||
|
||||
// What a locked Stop or Back says when pressed. While Plan2Code is mid-task the
|
||||
// lock lifts at its next check-in, and the way to interrupt it is the terminal.
|
||||
function lockWhy(what, gate, fallback) {
|
||||
if (loopDriving()) return LOOP_LOCK_TITLE;
|
||||
if (gate === "waiting") {
|
||||
const where = page.inApp ? "the terminal panel" : "the terminal";
|
||||
return `Plan2Code is mid-task, so ${what} unlocks at its next check-in. To interrupt it now, press Esc in ${where}.`;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function setLocked(b, why) {
|
||||
if (why) {
|
||||
b.setAttribute("aria-disabled", "true");
|
||||
b.dataset.why = why;
|
||||
} else {
|
||||
b.removeAttribute("aria-disabled");
|
||||
delete b.dataset.why;
|
||||
}
|
||||
b.classList.toggle("is-locked", Boolean(why));
|
||||
}
|
||||
|
||||
// The small note a press on a locked button opens, under that button. It goes
|
||||
// on the next press anywhere, on Escape, or after a few seconds.
|
||||
let lockPop = null;
|
||||
let lockPopTimer = null;
|
||||
|
||||
function closeLockPop() {
|
||||
clearTimeout(lockPopTimer);
|
||||
if (lockPop) lockPop.remove();
|
||||
lockPop = null;
|
||||
}
|
||||
|
||||
function showLockPop(b) {
|
||||
closeLockPop();
|
||||
const pop = el("div", "lock-pop", b.dataset.why || "");
|
||||
pop.setAttribute("role", "status");
|
||||
document.body.appendChild(pop);
|
||||
const at = b.getBoundingClientRect();
|
||||
pop.style.top = `${Math.round(at.bottom + 6)}px`;
|
||||
// Anchored by its left edge (Stop and Back sit at the left of the bar), kept
|
||||
// inside the window; right-anchoring squeezed the note into a narrow strip.
|
||||
pop.style.left = `${Math.max(8, Math.min(Math.round(at.left), window.innerWidth - pop.offsetWidth - 8))}px`;
|
||||
lockPop = pop;
|
||||
lockPopTimer = setTimeout(closeLockPop, 8000);
|
||||
const away = (e) => {
|
||||
if (e.type === "keydown" && e.key !== "Escape") return;
|
||||
if (e.type === "click" && b.contains(e.target)) return;
|
||||
closeLockPop();
|
||||
document.removeEventListener("click", away, true);
|
||||
document.removeEventListener("keydown", away, true);
|
||||
};
|
||||
document.addEventListener("click", away, true);
|
||||
document.addEventListener("keydown", away, true);
|
||||
}
|
||||
|
||||
// A locked button answers a press with its reason instead of acting.
|
||||
function whenOpen(b, act) {
|
||||
return () => {
|
||||
if (b.getAttribute("aria-disabled") === "true") showLockPop(b);
|
||||
else act();
|
||||
};
|
||||
}
|
||||
|
||||
// Plan2Code has the ball: it is working, or owes a reply to a send, and has
|
||||
@@ -929,8 +1033,12 @@ export function renderHomeButton() {
|
||||
warned: Boolean(page.S) && Boolean(stopWarning()),
|
||||
});
|
||||
b.hidden = st.hidden;
|
||||
b.disabled = st.disabled || loopDriving();
|
||||
b.title = loopDriving() ? LOOP_LOCK_TITLE : st.title;
|
||||
const gate = turnGate({ gone: page.gone, pendingResult: page.pendingResult, waiting: Boolean(page.S) && agentHasTheBall() });
|
||||
// Already on its way home: say so, never "mid-task, press Esc", which would
|
||||
// invite interrupting the hand-off the person just asked for.
|
||||
const homeward = page.local.homeward && !agentAdrift() && !loopDriving();
|
||||
setLocked(b, st.disabled || loopDriving() ? (homeward ? st.title : lockWhy("Back to the dashboard", gate, b.title)) : "");
|
||||
}
|
||||
|
||||
function openHomeConfirm() {
|
||||
@@ -1117,7 +1225,7 @@ export function renderStopping() {
|
||||
const row = el("div", "handoff-command");
|
||||
const code = el("code", "handoff-code", text);
|
||||
row.appendChild(code);
|
||||
row.appendChild(copyButton(text, "btn small handoff-copy", code));
|
||||
row.appendChild(copyButton(text, "btn sm handoff-copy", code));
|
||||
extra.appendChild(row);
|
||||
} else {
|
||||
extra.appendChild(
|
||||
@@ -1191,10 +1299,10 @@ export function renderFooterDashboard() {
|
||||
// The top bar's way home and Stop, wired once at start-up.
|
||||
export function wireEnding() {
|
||||
$("btn-dashboard").addEventListener("click", () => sendAfterBuild("dashboard"));
|
||||
$("btn-home").addEventListener("click", openHomeConfirm);
|
||||
$("btn-home").addEventListener("click", whenOpen($("btn-home"), openHomeConfirm));
|
||||
$("home-cancel").addEventListener("click", () => $("home-modal").close());
|
||||
$("home-go").addEventListener("click", goHome);
|
||||
$("btn-stop").addEventListener("click", openStopConfirm);
|
||||
$("btn-stop").addEventListener("click", whenOpen($("btn-stop"), openStopConfirm));
|
||||
$("stop-cancel").addEventListener("click", () => $("stop-modal").close());
|
||||
$("stop-handoff").addEventListener("click", () => stopSession(true));
|
||||
$("stop-go").addEventListener("click", () => stopSession(false));
|
||||
|
||||
@@ -135,8 +135,7 @@ const gitLocked = () => gitMode() !== "idle";
|
||||
async function sendGit(op, fields = {}, wording = {}) {
|
||||
if (page.gone || finish()) return;
|
||||
if (page.pendingResult) {
|
||||
hooks.banner("Your last click is still being picked up. One moment.", "info");
|
||||
page.pendingBannerUp = true;
|
||||
page.pendingBannerUp = hooks.banner("Your last click is still being picked up. One moment.", "info");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -150,8 +149,7 @@ async function sendGit(op, fields = {}, wording = {}) {
|
||||
});
|
||||
if (res.status === 409) {
|
||||
page.pendingResult = true;
|
||||
hooks.banner("Your last click is still being picked up. One moment.", "info");
|
||||
page.pendingBannerUp = true;
|
||||
page.pendingBannerUp = hooks.banner("Your last click is still being picked up. One moment.", "info");
|
||||
redraw();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { looksReady, looks, saveLooks } from "../looks.js";
|
||||
import { page } from "../state.js";
|
||||
import { isDashboard, finish, agentAdrift } from "../selectors.js";
|
||||
import { releasesLink, el, copyButton, lightDismiss } from "../render.js";
|
||||
import { HELP_TABS, helpTabFor } from "../help.js";
|
||||
import { HELP_TABS, helpGroupStart, helpTabFor } from "../help.js";
|
||||
import { wireTabs } from "../tabs.js";
|
||||
import { CATALOG_GROUPS, SKILL_CATALOG } from "../answers.js";
|
||||
|
||||
@@ -20,15 +20,14 @@ export function maybeWelcome() {
|
||||
openWelcome();
|
||||
}
|
||||
|
||||
// The same "finish the step and start fresh" tip the meter popover and the
|
||||
// dashboard's own red banner give, worded for the app's New Session button there.
|
||||
function renderWelcomeRefreshHelp() {
|
||||
// Under the app the agent runs in the window's terminal panel, not a terminal.
|
||||
function renderWelcomeTerminalHelp() {
|
||||
if (!page.inApp) return;
|
||||
$("welcome-refresh-text").textContent = "Once the session meter passes half, finish the step and press New Session at the top of the window.";
|
||||
$("welcome-terminal-text").textContent = "If the page goes quiet, your agent may be asking permission in the terminal panel.";
|
||||
}
|
||||
|
||||
export function openWelcome() {
|
||||
renderWelcomeRefreshHelp();
|
||||
renderWelcomeTerminalHelp();
|
||||
if ($("help-modal").open) $("help-modal").close();
|
||||
const slot = $("welcome-bot");
|
||||
if (!slot.firstElementChild) {
|
||||
@@ -67,21 +66,23 @@ function renderAbout() {
|
||||
}
|
||||
}
|
||||
|
||||
// Under the app, a new release still needs a terminal (the app cannot replace
|
||||
// itself), but not the terminal panel, and the restart is the app's, not a
|
||||
// new /plan2code; a skills/app mismatch is the bar's one-click Update
|
||||
// skills (see docs/desktop-app.md). Patched once, the first time Help opens,
|
||||
// since page.inApp never changes for the session's life.
|
||||
// Under the app, a new release is the bar's one click, Update and restart;
|
||||
// the command stays as the fallback, run outside the terminal panel, and the
|
||||
// restart is the app's, not a new /plan2code; a skills/app mismatch is the
|
||||
// bar's one-click Update skills (see docs/desktop-app.md). Patched once, the
|
||||
// first time Help opens, since page.inApp never changes for the session's life.
|
||||
function renderUpdateHelp() {
|
||||
if (!page.inApp) return;
|
||||
$("help-update-text").replaceChildren(
|
||||
"When a newer Plan2Code release is out, the dashboard shows ",
|
||||
el("strong", null, "UPDATE AVAILABLE"),
|
||||
el("strong", null, "Update available"),
|
||||
" at the top and the app's top bar shows ",
|
||||
el("strong", null, "Update available"),
|
||||
". Both give you the same command, ",
|
||||
" with ",
|
||||
el("strong", null, "Update and restart"),
|
||||
", which installs the new release and reopens the app on the same project. If that fails, run ",
|
||||
el("code", null, "plan2code update"),
|
||||
": run it in a terminal outside the app (not its terminal panel), then close the app and open it again. The app cannot replace itself while it runs, so a new release has no one-click update. When the app and the installed skills fall out of step, the bar offers ",
|
||||
" in a terminal outside the app (not its terminal panel), then close the app and open it again. When the app and the installed skills fall out of step, the bar offers ",
|
||||
el("strong", null, "Update skills"),
|
||||
" instead, which brings them level in one click."
|
||||
);
|
||||
@@ -108,7 +109,7 @@ function renderFinishingHelp() {
|
||||
function renderFinishingDashboardHelp() {
|
||||
if (!page.inApp) return;
|
||||
$("help-finishing-dashboard-text").replaceChildren(
|
||||
"A finished screen (never a paused one) has a ",
|
||||
"A finished screen (never a stopped one) has a ",
|
||||
el("strong", null, "Back to the dashboard"),
|
||||
" button. It turns this page back into the cards, in the same conversation, so the next step starts right here. Plan2Code listens for it for as long as the session is open. Once the session has closed, the app's own bar notices and offers to reconnect it, no command needed."
|
||||
);
|
||||
@@ -277,7 +278,7 @@ function buildHelp() {
|
||||
}
|
||||
for (const row of panels.querySelectorAll("[data-copy]")) {
|
||||
const code = row.querySelector("code");
|
||||
row.appendChild(copyButton(code.textContent, "btn small handoff-copy", code));
|
||||
row.appendChild(copyButton(code.textContent, "btn sm handoff-copy", code));
|
||||
}
|
||||
helpTabs = wireTabs({
|
||||
tabs: HELP_TABS,
|
||||
@@ -285,6 +286,8 @@ function buildHelp() {
|
||||
panels,
|
||||
prefix: "help",
|
||||
tabClass: "help-tab",
|
||||
groupStart: helpGroupStart,
|
||||
groupClass: "help-tab-group",
|
||||
renderTab: (t, btn) => {
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
svg.setAttribute("class", "help-tab-icon");
|
||||
@@ -299,6 +302,29 @@ function buildHelp() {
|
||||
$("help-panels").scrollTop = 0;
|
||||
},
|
||||
});
|
||||
// The filter box: a topic stays when every word typed is in its label or its
|
||||
// panel's text (the panels are all in the page once Help is built).
|
||||
const filterBox = $("help-filter");
|
||||
filterBox.addEventListener("input", () => {
|
||||
const words = filterBox.value.toLowerCase().split(/\s+/).filter(Boolean);
|
||||
const shown = helpTabs.filter(
|
||||
words.length
|
||||
? (t) => {
|
||||
const text = (t.label + " " + (panels.querySelector(`[data-tab="${t.id}"]`)?.textContent || "")).toLowerCase();
|
||||
return words.every((w) => text.includes(w));
|
||||
}
|
||||
: null
|
||||
);
|
||||
$("help-filter-empty").hidden = shown > 0;
|
||||
});
|
||||
// From the filter box, the down arrow steps into the topics that are left.
|
||||
filterBox.addEventListener("keydown", (e) => {
|
||||
if (e.key !== "ArrowDown") return;
|
||||
const first = helpTabs.shown()[0];
|
||||
if (!first) return;
|
||||
e.preventDefault();
|
||||
$("help-tab-" + first.id).focus();
|
||||
});
|
||||
helpBuilt = true;
|
||||
}
|
||||
|
||||
@@ -320,6 +346,13 @@ export function openHelp() {
|
||||
renderPlannyDoneHelp();
|
||||
renderHandoffCopyHelp();
|
||||
}
|
||||
// A filter left typed in a closed Help would hide the topic it opens on.
|
||||
const filterBox = $("help-filter");
|
||||
if (filterBox.value) {
|
||||
filterBox.value = "";
|
||||
helpTabs.filter(null);
|
||||
$("help-filter-empty").hidden = true;
|
||||
}
|
||||
const id = helpTabFor({
|
||||
view: page.view,
|
||||
dashboard: isDashboard(),
|
||||
|
||||
@@ -9,20 +9,21 @@
|
||||
// in dashboard.js, reached through hooks: a screen never imports another),
|
||||
// and is disabled whenever a card would be.
|
||||
|
||||
import { NOT_CONNECTED } from "../labels.js";
|
||||
import { page, redraw, hooks, stage } from "../state.js";
|
||||
import { el, md, mdInto, lightDismiss } from "../render.js";
|
||||
import { el, icon, md, mdInto, lightDismiss } from "../render.js";
|
||||
import { postJson } from "../net.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"]);
|
||||
const TOP_STATES = new Set(["off", "paused"]);
|
||||
|
||||
const PILLS = {
|
||||
"not-set-up": { text: "Not set up", cls: "" },
|
||||
off: { text: "Off", cls: "" },
|
||||
on: { text: "On", cls: " is-on" },
|
||||
paused: { text: "Paused for you", cls: " is-hold" },
|
||||
on: { text: "On", cls: " is-accent" },
|
||||
paused: { text: "Paused for you", cls: " is-stage" },
|
||||
};
|
||||
|
||||
// The More menu stays open across the dashboard's redraws until it is closed.
|
||||
@@ -42,9 +43,9 @@ function shortDate(iso) {
|
||||
* same conditions that disable a dashboard card (dashCard()).
|
||||
*/
|
||||
export function learningBlocked() {
|
||||
if (page.gone) return "Plan2Code is not answering right now.";
|
||||
if (page.gone) return NOT_CONNECTED;
|
||||
if (page.pendingResult) return "Plan2Code is still picking up your last choice.";
|
||||
if (page.local && page.local.launching) return "A workflow is starting.";
|
||||
if (page.local && page.local.launching) return "A skill is starting.";
|
||||
if (loopDriving()) return "The Implementation Loop is running.";
|
||||
return "";
|
||||
}
|
||||
@@ -77,7 +78,7 @@ function pauseSwitch(paused) {
|
||||
b.setAttribute("role", "switch");
|
||||
b.setAttribute("aria-checked", paused ? "true" : "false");
|
||||
b.disabled = pausing || Boolean(page.gone);
|
||||
if (page.gone) b.title = "The console is not reachable right now.";
|
||||
if (page.gone) b.title = NOT_CONNECTED;
|
||||
const track = el("span", "learn-track");
|
||||
track.setAttribute("aria-hidden", "true");
|
||||
b.append(track, document.createTextNode("Pause for me"));
|
||||
@@ -107,7 +108,7 @@ function closeMore(focusButton) {
|
||||
|
||||
function moreMenu() {
|
||||
const wrap = document.createDocumentFragment();
|
||||
const btn = el("button", "learn-link learn-more-btn", "More ▴");
|
||||
const btn = el("button", "learn-link learn-more-btn", "More");
|
||||
btn.type = "button";
|
||||
btn.setAttribute("aria-haspopup", "menu");
|
||||
btn.setAttribute("aria-expanded", moreOpen ? "true" : "false");
|
||||
@@ -318,14 +319,15 @@ export function renderLessonsDialog(on) {
|
||||
dlg.setAttribute("aria-busy", saving ? "true" : "false");
|
||||
const card = hooks.renderCard(item);
|
||||
if (saving) card.inert = true;
|
||||
const x = el("button", "modal-x", "×");
|
||||
const x = el("button", "modal-x");
|
||||
x.appendChild(icon("close"));
|
||||
x.type = "button";
|
||||
x.setAttribute("aria-label", "Close without saving");
|
||||
x.disabled = saving;
|
||||
x.addEventListener("click", () => requestClose(item));
|
||||
const actions = el("div", "modal-actions");
|
||||
if (askingClose && !saving) {
|
||||
const ask = el("div", "lessons-unsaved");
|
||||
const ask = el("div", "callout is-warn lessons-unsaved");
|
||||
ask.setAttribute("role", "alert");
|
||||
ask.appendChild(el("p", "lessons-unsaved-text", "You have choices that are not saved."));
|
||||
const row = el("div", "modal-actions");
|
||||
@@ -391,7 +393,7 @@ function suggestionsBox(item) {
|
||||
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");
|
||||
const box = el("div", "callout is-info lessons-suggestions");
|
||||
box.id = "lessons-suggestions";
|
||||
box.setAttribute("role", "status");
|
||||
box.appendChild(el("h3", null, "Suggestions"));
|
||||
@@ -494,7 +496,7 @@ async function openLessons() {
|
||||
|
||||
/**
|
||||
* The Learning row for `position` ("top" or "bottom"), or null: the top place
|
||||
* takes Not set up, Off and Paused, the bottom place takes On, and no row is
|
||||
* takes Off and Paused, the bottom place takes On and Not set up, and no row is
|
||||
* drawn when the scan carries no `learning` (an unknown settings format).
|
||||
*/
|
||||
export function renderLearningRow(scan, position) {
|
||||
@@ -511,7 +513,7 @@ export function renderLearningRow(scan, position) {
|
||||
const line = el("div", "learn-line");
|
||||
line.appendChild(el("span", "learn-label", "Learning"));
|
||||
const pill = PILLS[state];
|
||||
line.appendChild(el("span", "learn-pill" + pill.cls, pill.text));
|
||||
line.appendChild(el("span", "pill is-caps learn-pill" + pill.cls, pill.text));
|
||||
const controls = el("span", "learn-controls");
|
||||
const busy = busySwitch(state);
|
||||
if (busy) {
|
||||
@@ -524,10 +526,10 @@ export function renderLearningRow(scan, position) {
|
||||
controls.appendChild(working);
|
||||
} else if (state === "not-set-up") {
|
||||
line.appendChild(el("span", "learn-say", "Plan2Code can keep lessons about this codebase, approved by you."));
|
||||
controls.appendChild(agentButton("Switch on", "btn small primary", "switch-on"));
|
||||
controls.appendChild(agentButton("Switch on", "btn sm", "switch-on"));
|
||||
} else if (state === "off") {
|
||||
line.appendChild(el("span", "learn-say", "Off for this project."));
|
||||
controls.appendChild(agentButton("Switch on", "btn small", "switch-on"));
|
||||
controls.appendChild(agentButton("Switch on", "btn sm", "switch-on"));
|
||||
} else if (state === "paused") {
|
||||
const since = shortDate(learning.pausedSince);
|
||||
line.appendChild(
|
||||
|
||||
@@ -43,7 +43,7 @@ const fieldsetOf = (node) => node.closest("fieldset");
|
||||
// and Back to default are prefs-dialog.js's.
|
||||
export function wireLooks() {
|
||||
$("looks-modal").addEventListener("close", () => {
|
||||
if (isDashboard() && !needsRoleNudge(looks) && $("main").querySelector(".dash-nudge")) redraw();
|
||||
if (isDashboard() && !needsRoleNudge(looks) && $("main").querySelector(".dash-extras")) redraw();
|
||||
});
|
||||
for (const [value, label] of [[ROLE_NOT_SET, ROLE_NOT_SET_LABEL], ...ROLES.map((r) => [r.id, r.label])]) {
|
||||
const option = el("option", null, label);
|
||||
|
||||
@@ -12,6 +12,8 @@ import { SKILL_CATALOG } from "../answers.js";
|
||||
import { postJson } from "../net.js";
|
||||
import { tellApp, wireLoopMessages } from "../app-bridge.js";
|
||||
|
||||
let justPicked = ""; // the strength node picked a moment ago, which alone plays its grow
|
||||
|
||||
const LEVELS = [
|
||||
["critical", "Critical"],
|
||||
["warning", "Warning"],
|
||||
@@ -532,9 +534,11 @@ function strengthField(s, redo) {
|
||||
if (!input.checked) return;
|
||||
setPick(f, s.spec, p, c.value);
|
||||
s.problems = [];
|
||||
justPicked = input.id; // only this redraw plays the grow
|
||||
redraw();
|
||||
justPicked = "";
|
||||
});
|
||||
const node = el("span", "loop-strength-node");
|
||||
const node = el("span", "loop-strength-node" + (input.id === justPicked ? " is-picked" : ""));
|
||||
node.appendChild(strengthBars(c.level));
|
||||
cell.append(input, node);
|
||||
row.appendChild(cell);
|
||||
@@ -631,7 +635,7 @@ function drawBody(pane, s) {
|
||||
);
|
||||
const kindLabel = el("label", "loop-number");
|
||||
kindLabel.appendChild(el("span", null, "Send to"));
|
||||
const kindSelect = el("select", "loop-text");
|
||||
const kindSelect = el("select", "is-compact loop-text");
|
||||
kindSelect.id = "loop-notify-kind";
|
||||
for (const kind of NOTIFY_KINDS) {
|
||||
const option = el("option", null, kind.label);
|
||||
@@ -641,7 +645,7 @@ function drawBody(pane, s) {
|
||||
kindSelect.value = f.notifyKind;
|
||||
kindLabel.appendChild(kindSelect);
|
||||
const kindHint = el("p", "loop-hint");
|
||||
const notifyInput = el("input", "loop-text");
|
||||
const notifyInput = el("input", "is-compact loop-text");
|
||||
notifyInput.type = "text";
|
||||
notifyInput.inputMode = "url";
|
||||
notifyInput.id = "loop-notify-url";
|
||||
@@ -652,7 +656,7 @@ function drawBody(pane, s) {
|
||||
const paramLabel = el("label", "loop-number");
|
||||
const paramText = el("span");
|
||||
paramLabel.appendChild(paramText);
|
||||
const paramInput = el("input", "loop-text loop-param");
|
||||
const paramInput = el("input", "is-compact loop-text loop-param");
|
||||
paramInput.type = "text";
|
||||
paramInput.id = "loop-notify-param";
|
||||
paramInput.value = f.notifyParam;
|
||||
@@ -716,7 +720,7 @@ function drawBody(pane, s) {
|
||||
form.appendChild(notify);
|
||||
|
||||
const check = field("Quick check", "A command the app runs after each phase, such as npm run build. The page never runs it.");
|
||||
const checkInput = el("input", "loop-text");
|
||||
const checkInput = el("input", "is-compact loop-text");
|
||||
checkInput.type = "text";
|
||||
checkInput.id = "loop-quickcheck";
|
||||
checkInput.value = f.quickCheck;
|
||||
@@ -736,7 +740,7 @@ function drawBody(pane, s) {
|
||||
retry.appendChild(toggle("loop-retry", "Retry it once", f.retryOnce, (v) => ((f.retryOnce = v), redo())));
|
||||
const silence = el("label", "loop-number");
|
||||
silence.appendChild(el("span", null, "Count the agent as stuck after this many minutes with no activity"));
|
||||
const silenceInput = el("input", "loop-text loop-narrow");
|
||||
const silenceInput = el("input", "is-compact loop-text loop-narrow");
|
||||
silenceInput.type = "number";
|
||||
silenceInput.id = "loop-silence";
|
||||
silenceInput.min = "1";
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
// this file runs the timers and requests, and binds every save and every
|
||||
// picture to the tab it was made in, so a switch can never move either.
|
||||
|
||||
import { NOT_CONNECTED } from "../labels.js";
|
||||
import { page } from "../state.js";
|
||||
import {
|
||||
EDITOR_NOT_LOADED,
|
||||
@@ -31,7 +32,7 @@ import {
|
||||
tabSwitch,
|
||||
unsaved,
|
||||
} from "../notepad.js";
|
||||
import { el, lightDismiss } from "../render.js";
|
||||
import { el, icon, lightDismiss } from "../render.js";
|
||||
import { postJson } from "../net.js";
|
||||
import { reencode, openPicview } from "../uploads.js";
|
||||
import { createTabs } from "../notepad-tabs.js";
|
||||
@@ -39,7 +40,6 @@ import { skillFor } from "../skills.js";
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
const NOT_CONNECTED = "Not connected right now.";
|
||||
const STAY = "Not saved yet, so staying on this tab.";
|
||||
|
||||
// One editor for the page's life, made on first open, and the tab bar, made
|
||||
@@ -295,6 +295,8 @@ function show(body, keep = false) {
|
||||
problem = "";
|
||||
rev += 1;
|
||||
loaded = true;
|
||||
$("notepad-retry").hidden = true;
|
||||
$("notepad-retry").disabled = false;
|
||||
editor.setReadOnly(!tab);
|
||||
takeStored(tab ? tab.images : [], activeId);
|
||||
drawTabs();
|
||||
@@ -658,9 +660,9 @@ function thumbItem(entry, n) {
|
||||
if (src) {
|
||||
const pic = el("img");
|
||||
pic.src = src;
|
||||
pic.alt = `Notebook image ${n}`;
|
||||
pic.alt = `Notebook picture ${n}`;
|
||||
open.appendChild(pic);
|
||||
} else open.setAttribute("aria-label", `Notebook image ${n}`);
|
||||
} else open.setAttribute("aria-label", `Notebook picture ${n}`);
|
||||
// Never `disabled`, which would push the focus out of the strip while the
|
||||
// picture uploads: it only does nothing until there is a picture to show.
|
||||
const viewable = Boolean(entry.url) && entry.status !== "uploading";
|
||||
@@ -670,25 +672,26 @@ function thumbItem(entry, n) {
|
||||
});
|
||||
item.appendChild(open);
|
||||
if (entry.status !== "uploading" && !entry.asking) {
|
||||
const x = el("button", "attach-remove notepad-thumb-delete", "×");
|
||||
const x = el("button", "attach-remove notepad-thumb-delete");
|
||||
x.appendChild(icon("close"));
|
||||
x.type = "button";
|
||||
x.setAttribute("aria-label", `Delete image ${n}`);
|
||||
x.setAttribute("aria-label", `Delete picture ${n}`);
|
||||
x.addEventListener("click", () => ask(entry));
|
||||
item.appendChild(x);
|
||||
}
|
||||
if (entry.asking) {
|
||||
// Keep comes first and takes the focus, so Enter keeps the picture.
|
||||
const over = el("div", "attach-overlay notepad-ask");
|
||||
over.appendChild(el("p", null, "Delete this image?"));
|
||||
over.appendChild(el("p", null, "Delete this picture?"));
|
||||
const row = el("div", "notepad-ask-row");
|
||||
const keep = el("button", "btn tiny notepad-ask-keep", "Keep");
|
||||
const keep = el("button", "btn xs soft notepad-ask-keep", "Keep");
|
||||
keep.type = "button";
|
||||
keep.addEventListener("click", () => {
|
||||
entry.asking = false;
|
||||
drawStrip();
|
||||
focusIn(entry.key, ".notepad-thumb-delete");
|
||||
});
|
||||
const del = el("button", "btn tiny notepad-ask-delete", "Delete");
|
||||
const del = el("button", "btn xs soft notepad-ask-delete", "Delete");
|
||||
del.type = "button";
|
||||
del.addEventListener("click", () => remove(entry));
|
||||
keep.disabled = del.disabled = Boolean(entry.deleting);
|
||||
@@ -703,7 +706,7 @@ function thumbItem(entry, n) {
|
||||
} else if (entry.status === "failed") {
|
||||
const over = el("div", "attach-overlay failed");
|
||||
over.appendChild(el("p", null, "Upload failed"));
|
||||
const again = el("button", "btn tiny notepad-retry", "Retry");
|
||||
const again = el("button", "btn xs soft notepad-retry", "Retry");
|
||||
again.type = "button";
|
||||
again.addEventListener("click", () => upload(entry));
|
||||
over.appendChild(again);
|
||||
@@ -796,7 +799,7 @@ function takeStored(list, tabId) {
|
||||
function openPreview(entry) {
|
||||
const list = images.filter((img) => img.url);
|
||||
openPicview(
|
||||
list.map((img) => ({ url: img.url, alt: `Notebook image ${images.indexOf(img) + 1}` })),
|
||||
list.map((img) => ({ url: img.url, alt: `Notebook picture ${images.indexOf(img) + 1}` })),
|
||||
list.indexOf(entry),
|
||||
() => focusIn(entry.key, ".attach-open"),
|
||||
);
|
||||
@@ -869,16 +872,28 @@ function wireImages(dlg) {
|
||||
// show up. Text typed here and not yet saved (or too long to save) is never
|
||||
// replaced; the tab it belongs to stays on screen.
|
||||
async function load() {
|
||||
// Kept on screen (and focused, if it was) while it reads, so a second failure
|
||||
// finds it where it was.
|
||||
$("notepad-retry").disabled = true;
|
||||
const keep = keepsText(save);
|
||||
let res = await readNote(activeId);
|
||||
if (!res.ok && res.code === "no-such-tab" && activeId && !keep) res = await readNote(null);
|
||||
if (!res.ok) {
|
||||
if (loaded) return;
|
||||
if (loaded) {
|
||||
$("notepad-retry").hidden = true;
|
||||
$("notepad-retry").disabled = false;
|
||||
return;
|
||||
}
|
||||
const line = $("notepad-status");
|
||||
line.textContent = NOT_LOADED;
|
||||
line.classList.add("is-problem");
|
||||
$("notepad-retry").hidden = false;
|
||||
$("notepad-retry").disabled = false;
|
||||
$("notepad-retry").focus();
|
||||
return;
|
||||
}
|
||||
$("notepad-retry").hidden = true;
|
||||
$("notepad-retry").disabled = false;
|
||||
show(res.body, keep);
|
||||
paintStatus();
|
||||
if (!tabs.length) $("notepad-empty-new").focus();
|
||||
@@ -930,6 +945,7 @@ export function wireNotepad() {
|
||||
wireImages(dlg);
|
||||
$("btn-notepad").addEventListener("click", openNotepad);
|
||||
$("notepad-close").addEventListener("click", () => dlg.close());
|
||||
$("notepad-retry").addEventListener("click", () => load());
|
||||
$("notepad-tab-new").addEventListener("click", () => openNameForm("new"));
|
||||
$("notepad-empty-new").addEventListener("click", () => openNameForm("new"));
|
||||
$("notepad-delete-keep").addEventListener("click", () => closeDelete(true));
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// to open and close it, the Saved mark, Back to default for the tab on screen
|
||||
// and the prompt that stops an unsaved agent edit being lost.
|
||||
|
||||
import { onSwatchSaved, renderSwatches, resetLooks, saveLooks } from "../looks.js";
|
||||
import { looks, onSwatchSaved, renderSwatches, resetLooks, saveLooks } from "../looks.js";
|
||||
import { ROLE_NOT_SET } from "../starters.js";
|
||||
import { PREFS_TABS, prefsOpenTab, prefsResetScope } from "../prefs.js";
|
||||
import { wireTabs } from "../tabs.js";
|
||||
import { el, lightDismiss } from "../render.js";
|
||||
@@ -12,7 +13,7 @@ const $ = (id) => document.getElementById(id);
|
||||
|
||||
let prefsTabs = null;
|
||||
|
||||
// Back to default only where the tab has looks to reset.
|
||||
// Reset this tab only where the tab has looks to reset.
|
||||
function showResetFor(id) {
|
||||
$("looks-reset").hidden = prefsResetScope(id) === null;
|
||||
}
|
||||
@@ -55,6 +56,36 @@ export async function markSaved(fieldset, result) {
|
||||
}
|
||||
}
|
||||
|
||||
// "Reset. Undo" in the mark's place after Reset this tab: the same corner as
|
||||
// Saved, for a few seconds, with a button that puts the tab's values back.
|
||||
const RESET_UNDO_MS = 8000;
|
||||
|
||||
function markReset(fieldset, undo) {
|
||||
if (!fieldset) return;
|
||||
let mark = fieldset.querySelector(":scope > .prefs-saved");
|
||||
if (!mark) {
|
||||
mark = el("span", "prefs-saved");
|
||||
mark.setAttribute("role", "status");
|
||||
fieldset.appendChild(mark);
|
||||
}
|
||||
clearTimeout(markTimers.get(mark));
|
||||
mark.classList.remove("is-saved", "error");
|
||||
mark.classList.add("is-reset");
|
||||
const button = el("button", "linky prefs-undo", "Undo");
|
||||
button.type = "button";
|
||||
const end = () => {
|
||||
clearTimeout(markTimers.get(mark));
|
||||
mark.classList.remove("is-reset");
|
||||
mark.textContent = "";
|
||||
};
|
||||
button.addEventListener("click", () => {
|
||||
end();
|
||||
undo();
|
||||
});
|
||||
mark.replaceChildren(document.createTextNode("Reset. "), button);
|
||||
markTimers.set(mark, setTimeout(end, RESET_UNDO_MS));
|
||||
}
|
||||
|
||||
// Every way in: the gear, the dashboard's Set up preferences, or a caller
|
||||
// naming the tab it wants. Agents and models load each time it opens.
|
||||
export function openPrefs(tab) {
|
||||
@@ -70,7 +101,7 @@ export function openPrefs(tab) {
|
||||
let asking = null;
|
||||
|
||||
// Everything in the dialog but the prompt, kept out of reach while it asks.
|
||||
const behindPrompt = () => [$("looks-title"), $("looks-modal").querySelector(".prefs-body"), $("looks-modal").querySelector(".modal-actions")];
|
||||
const behindPrompt = () => [$("looks-title"), $("prefs-lead"), $("looks-modal").querySelector(".prefs-body"), $("looks-modal").querySelector(".modal-actions")];
|
||||
|
||||
function endAsking(go) {
|
||||
$("prefs-unsaved").hidden = true;
|
||||
@@ -85,8 +116,9 @@ function endAsking(go) {
|
||||
}
|
||||
|
||||
// Before anything leaves an agent form with an unsaved edit (Close, Esc, a
|
||||
// backdrop click, another tab, another agent's row): Save, Discard or Keep
|
||||
// editing, asked inside the dialog. Resolves true when it may go on.
|
||||
// backdrop click, another tab, another agent's row): Keep editing, Discard or
|
||||
// Save, asked inside the dialog, in the Lessons prompt's order (learning-row.js)
|
||||
// and with focus on the safe choice. Resolves true when it may go on.
|
||||
export function confirmUnsaved() {
|
||||
if (!hooks.hasUnsaved()) return Promise.resolve(true);
|
||||
if (asking) return asking.promise;
|
||||
@@ -97,7 +129,7 @@ export function confirmUnsaved() {
|
||||
for (const node of behindPrompt()) node.inert = true;
|
||||
$("prefs-unsaved").hidden = false;
|
||||
$("prefs-unsaved-save").disabled = false;
|
||||
$("prefs-unsaved-save").focus();
|
||||
$("prefs-unsaved-keep").focus();
|
||||
return promise;
|
||||
}
|
||||
|
||||
@@ -124,13 +156,14 @@ function wireUnsaved() {
|
||||
const name = el("strong");
|
||||
name.id = "prefs-unsaved-name";
|
||||
text.append("You have unsaved changes to ", name, ".");
|
||||
const save = el("button", "btn small primary", "Save");
|
||||
const save = el("button", "btn sm primary", "Save");
|
||||
save.type = "button";
|
||||
save.id = "prefs-unsaved-save";
|
||||
const discard = el("button", "btn small ghost", "Discard");
|
||||
const discard = el("button", "btn sm ghost", "Discard");
|
||||
discard.type = "button";
|
||||
const keep = el("button", "btn small ghost", "Keep editing");
|
||||
const keep = el("button", "btn sm ghost", "Keep editing");
|
||||
keep.type = "button";
|
||||
keep.id = "prefs-unsaved-keep";
|
||||
save.addEventListener("click", async () => {
|
||||
save.disabled = true;
|
||||
const ok = await hooks.saveOpen();
|
||||
@@ -143,7 +176,7 @@ function wireUnsaved() {
|
||||
});
|
||||
keep.addEventListener("click", () => endAsking(false));
|
||||
const actions = el("div", "prefs-unsaved-actions");
|
||||
actions.append(save, discard, keep);
|
||||
actions.append(keep, discard, save);
|
||||
inner.append(title, text, actions);
|
||||
box.append(inner);
|
||||
$("looks-modal").append(box);
|
||||
@@ -197,10 +230,18 @@ export function wirePrefs() {
|
||||
const tab = prefsTabs.current();
|
||||
const keys = prefsResetScope(tab);
|
||||
if (!keys) return;
|
||||
// What the tab held before, so Undo can put it back. A role never chosen
|
||||
// comes back as Not set: the server's file cannot un-have a key.
|
||||
const before = Object.fromEntries(keys.map((k) => [k, k === "role" ? (looks.role ?? ROLE_NOT_SET) : looks[k]]));
|
||||
resetLooks(keys);
|
||||
const saved = saveLooks();
|
||||
saveLooks();
|
||||
redraw();
|
||||
markSaved($("prefs-panel-" + tab).querySelector("fieldset"), saved);
|
||||
markReset($("prefs-panel-" + tab).querySelector("fieldset"), () => {
|
||||
for (const [k, v] of Object.entries(before)) looks[k] = v;
|
||||
const saved = saveLooks();
|
||||
redraw();
|
||||
markSaved($("prefs-panel-" + tab).querySelector("fieldset"), saved);
|
||||
});
|
||||
});
|
||||
onSwatchSaved((saved) => markSaved($("looks-swatches").closest("fieldset"), saved));
|
||||
}
|
||||
@@ -110,7 +110,7 @@ function buildRoot(mountAgents) {
|
||||
const agents = el("div", "setup-agents");
|
||||
box.appendChild(agents);
|
||||
const actions = el("div", "setup-actions");
|
||||
const again = el("button", "btn small", "Check again");
|
||||
const again = el("button", "btn sm", "Check again");
|
||||
again.type = "button";
|
||||
again.addEventListener("click", () => view?.load());
|
||||
actions.appendChild(again);
|
||||
@@ -149,7 +149,7 @@ function startingPane(started) {
|
||||
pane.appendChild(noPage);
|
||||
// A wait that died unmoved should not park the page on "Starting" forever:
|
||||
// once the grace hint is up, the way back to the pick list shows beside it.
|
||||
const back = el("button", "btn small setup-back", "Show the agent list again");
|
||||
const back = el("button", "btn sm setup-back", "Show the agent list again");
|
||||
back.type = "button";
|
||||
back.hidden = !graceShown;
|
||||
back.addEventListener("click", () => {
|
||||
|
||||
@@ -123,7 +123,7 @@ export function renderLaunching(main) {
|
||||
|
||||
const stale = staleLaunchFeedback(l.title, agentAdrift(), page.inApp);
|
||||
pane.appendChild(el("p", "card-kicker", stale ? stale.kicker : "On it"));
|
||||
pane.appendChild(el("h2", "launch-title", stale ? stale.title : `Waking up ${l.title || "the next mode"}`));
|
||||
pane.appendChild(el("h2", "launch-title", stale ? stale.title : `Waking up ${l.title || "the next skill"}`));
|
||||
pane.appendChild(el("p", "launch-quip", stale ? stale.quip : LAUNCH_QUIPS[0]));
|
||||
pane.appendChild(
|
||||
el(
|
||||
@@ -225,7 +225,7 @@ function startLaunchTicker() {
|
||||
const reconnect = document.querySelector(".launch-reconnect");
|
||||
if (reconnect) reconnect.hidden = !stale;
|
||||
if (kicker) kicker.textContent = stale ? stale.kicker : "On it";
|
||||
if (title) title.textContent = stale ? stale.title : `Waking up ${cur.title || "the next mode"}`;
|
||||
if (title) title.textContent = stale ? stale.title : `Waking up ${cur.title || "the next skill"}`;
|
||||
q.textContent = stale ? stale.quip : LAUNCH_QUIPS[Math.floor(elapsed / 2600) % LAUNCH_QUIPS.length];
|
||||
if (hint) {
|
||||
hint.textContent = stale
|
||||
|
||||
@@ -31,19 +31,19 @@ export function tellFolderIssues() {
|
||||
extras.push(document.createTextNode(" "));
|
||||
extras.push(el("code", "banner-hint", fresh.hint));
|
||||
}
|
||||
const open = el("button", "btn tiny banner-action", "Open workspace");
|
||||
const open = el("button", "btn xs soft banner-action", "Open workspace");
|
||||
open.type = "button";
|
||||
open.addEventListener("click", () => {
|
||||
hooks.banner(null);
|
||||
openWorkspace();
|
||||
});
|
||||
extras.push(open);
|
||||
hooks.banner(`The agent can't read @${fresh.name}: ${fresh.reason}`, "warn", extras);
|
||||
const issue = hooks.banner(`The agent cannot read @${fresh.name}: ${fresh.reason}`, "warn", extras);
|
||||
clearTimeout(issueBannerTimer);
|
||||
// Then the next folder waiting to be told, if several came at once.
|
||||
issueBannerTimer = setTimeout(() => {
|
||||
if (page.gone) return;
|
||||
hooks.banner(null);
|
||||
hooks.clearBanner(issue);
|
||||
tellFolderIssues();
|
||||
}, 15000);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ function workspaceScopeText() {
|
||||
|
||||
const NAME_RULE = "Names use lowercase letters, numbers and hyphens.";
|
||||
|
||||
const BROWSE_UNAVAILABLE = "Browse isn't available here — type or paste the path.";
|
||||
const BROWSE_UNAVAILABLE = "Browse is not available here: type or paste the path.";
|
||||
|
||||
// The folder whose Remove is waiting on its inline confirm, by id.
|
||||
let wsConfirm = null;
|
||||
@@ -127,14 +127,14 @@ function workspaceRow(f) {
|
||||
li.dataset.fid = f.id;
|
||||
|
||||
const head = el("div", "ws-head");
|
||||
head.appendChild(el("span", "ws-chip"));
|
||||
if (f.original) head.appendChild(el("span", "ws-original", "started here — can't be removed"));
|
||||
head.appendChild(el("span", "pill is-accent ws-chip"));
|
||||
if (f.original) head.appendChild(el("span", "ws-original", "started here, cannot be removed"));
|
||||
li.appendChild(head);
|
||||
|
||||
const pathRow = el("div", "ws-path-row");
|
||||
const code = el("code", "ws-path");
|
||||
pathRow.appendChild(code);
|
||||
const copy = el("button", "btn small", "Copy path");
|
||||
const copy = el("button", "btn sm", "Copy path");
|
||||
copy.type = "button";
|
||||
copy.addEventListener("click", async () => {
|
||||
const folder = workspaceFolders().find((x) => x.id === f.id);
|
||||
@@ -151,7 +151,7 @@ function workspaceRow(f) {
|
||||
});
|
||||
pathRow.appendChild(copy);
|
||||
if (!f.original) {
|
||||
const remove = el("button", "btn small danger ws-remove", "Remove");
|
||||
const remove = el("button", "btn sm danger ws-remove", "Remove");
|
||||
remove.type = "button";
|
||||
remove.addEventListener("click", () => {
|
||||
wsConfirm = f.id;
|
||||
@@ -175,7 +175,7 @@ function workspaceField(f, field, labelText) {
|
||||
const id = `ws-${field}-${f.id}`;
|
||||
const label = el("label", null, labelText);
|
||||
label.htmlFor = id;
|
||||
const input = el("input");
|
||||
const input = el("input", "is-compact");
|
||||
input.type = "text";
|
||||
input.id = id;
|
||||
input.dataset.field = field;
|
||||
@@ -209,7 +209,7 @@ function workspaceField(f, field, labelText) {
|
||||
setAddMsg("");
|
||||
return showError("");
|
||||
}
|
||||
if (body.reason === "name-taken") showError(`@${value} is taken — try @${body.suggest}.`);
|
||||
if (body.reason === "name-taken") showError(`@${value} is taken, try @${body.suggest}.`);
|
||||
else if (body.reason === "bad-name") showError(NAME_RULE);
|
||||
else showError("That did not save. Try again.");
|
||||
if (leaving) input.value = saved();
|
||||
@@ -241,11 +241,11 @@ function paintWorkspaceRow(li, f) {
|
||||
marks.replaceChildren();
|
||||
if (missing) marks.appendChild(el("p", "ws-mark is-missing", "This folder no longer exists"));
|
||||
if (issue) {
|
||||
marks.appendChild(el("p", "ws-mark is-issue", "The agent can't read this yet: " + issue.reason));
|
||||
marks.appendChild(el("p", "ws-mark is-issue", "The agent cannot read this yet: " + issue.reason));
|
||||
if (issue.hint) {
|
||||
const row = el("div", "ws-hint-row");
|
||||
const code = el("code", "ws-hint", issue.hint);
|
||||
row.append(code, copyButton(issue.hint, "btn tiny", code));
|
||||
row.append(code, copyButton(issue.hint, "btn xs soft", code));
|
||||
marks.appendChild(row);
|
||||
}
|
||||
}
|
||||
@@ -260,14 +260,14 @@ function paintWorkspaceRow(li, f) {
|
||||
const box = el("div", "ws-confirm");
|
||||
box.setAttribute("role", "alert");
|
||||
box.appendChild(el("span", null, `Remove @${f.name}? The agent is told.`));
|
||||
const keep = el("button", "btn small ghost", "Keep it");
|
||||
const keep = el("button", "btn sm ghost", "Keep it");
|
||||
keep.type = "button";
|
||||
keep.addEventListener("click", () => {
|
||||
wsConfirm = null;
|
||||
renderWorkspace();
|
||||
li.querySelector(".ws-remove")?.focus();
|
||||
});
|
||||
const go = el("button", "btn small danger", "Remove");
|
||||
const go = el("button", "btn sm danger", "Remove");
|
||||
go.type = "button";
|
||||
go.addEventListener("click", async () => {
|
||||
go.disabled = true;
|
||||
@@ -305,15 +305,15 @@ async function addWorkspaceFolder(path, name) {
|
||||
}
|
||||
switch (body.reason) {
|
||||
case "not-a-folder":
|
||||
return setAddMsg("That isn't a folder on this machine.", "error");
|
||||
return setAddMsg("That is not a folder on this machine.", "error");
|
||||
case "duplicate":
|
||||
return setAddMsg(`Already in the workspace as @${body.name}.`, "error");
|
||||
case "name-taken": {
|
||||
const taken = name || String(body.suggest || "").replace(/-\d+$/, "");
|
||||
const use = el("button", "btn tiny", `Use @${body.suggest}`);
|
||||
const use = el("button", "btn xs soft", `Use @${body.suggest}`);
|
||||
use.type = "button";
|
||||
use.addEventListener("click", () => addWorkspaceFolder(trimmed, body.suggest));
|
||||
return setAddMsg(`@${taken} is taken — try @${body.suggest}.`, "error", use);
|
||||
return setAddMsg(`@${taken} is taken, try @${body.suggest}.`, "error", use);
|
||||
}
|
||||
case "bad-name":
|
||||
return setAddMsg(NAME_RULE, "error");
|
||||
|
||||
Reference in new issue
Block a user