Restyle the web console and tidy its labels, Ask tab, cleanup and help

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-17 18:08:01 -08:00
1 parent 710c751c2f
commit e9679c47b9
103 files changed
+4054 -2273

No files matched your search

@@ -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);