variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// web/widgets.mjs -- the small factories the views share.
|
2026-11-14 23:48:27 +00:00
|
|
|
//
|
|
|
|
|
// Three patterns that were hand-copied per use, now one each:
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// - armedButton: the two-click confirm (no JS confirm() -- it blocks
|
2026-11-14 23:48:27 +00:00
|
|
|
// the embedded pane; every destructive act is armed instead)
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// - paneEditor: the status/agenda pattern -- a body line, an edit
|
2026-11-14 23:48:27 +00:00
|
|
|
// button, an inline editor; the section shell stays in index.html
|
|
|
|
|
// - modelsBox: the per-run player/housekeeper selects over the
|
|
|
|
|
// upstream listing; setup and the play aside each carry one
|
|
|
|
|
|
|
|
|
|
import { $, el } from './dom.mjs';
|
|
|
|
|
import { api } from './client.mjs';
|
|
|
|
|
import { state } from './state.mjs';
|
|
|
|
|
import { banner } from './chrome.mjs';
|
|
|
|
|
import { render } from './router.mjs';
|
|
|
|
|
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// two-click confirm -- the second click within 5s fires; anything
|
2026-11-14 23:48:27 +00:00
|
|
|
// else disarms. Each button owns its own arm state.
|
|
|
|
|
export function armedButton(btn, { label, confirm, fire }) {
|
|
|
|
|
let timer = null;
|
|
|
|
|
btn.addEventListener('click', async () => {
|
|
|
|
|
if (timer === null) {
|
|
|
|
|
btn.textContent = confirm;
|
|
|
|
|
timer = setTimeout(() => { timer = null; btn.textContent = label; }, 5000);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
clearTimeout(timer);
|
|
|
|
|
timer = null;
|
|
|
|
|
btn.textContent = label;
|
|
|
|
|
await fire();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// a pane: body line + edit button + inline editor. save(items)
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// resolves on success and throws on failure -- a failed save keeps
|
2026-11-14 23:48:27 +00:00
|
|
|
// the editor open, nothing was changed. setEditable(false) is the
|
|
|
|
|
// spectator state: no edit button, an open editor cancels.
|
|
|
|
|
export function paneEditor({ section, body, empty, placeholder, rows, format, toText, fromText, save }) {
|
|
|
|
|
const sec = typeof section === 'string' ? $(section) : section;
|
|
|
|
|
const bodyEl = typeof body === 'string' ? $(body) : body;
|
|
|
|
|
const editBtn = el('button', null, 'edit');
|
|
|
|
|
sec.querySelector('.pane-head').appendChild(editBtn);
|
|
|
|
|
const editor = el('div', 'pane-editor');
|
|
|
|
|
editor.hidden = true;
|
|
|
|
|
const area = el('textarea');
|
|
|
|
|
area.rows = rows;
|
|
|
|
|
area.placeholder = placeholder;
|
|
|
|
|
const actions = el('div', 'pane-editor-actions');
|
|
|
|
|
const saveBtn = el('button', null, 'save');
|
|
|
|
|
const cancelBtn = el('button', null, 'cancel');
|
|
|
|
|
actions.appendChild(saveBtn);
|
|
|
|
|
actions.appendChild(cancelBtn);
|
|
|
|
|
editor.appendChild(area);
|
|
|
|
|
editor.appendChild(actions);
|
|
|
|
|
bodyEl.after(editor); // before anything that follows the body (#conflict on the status pane)
|
|
|
|
|
|
|
|
|
|
let items = [];
|
|
|
|
|
let mayEdit = false;
|
|
|
|
|
let open = false;
|
|
|
|
|
|
|
|
|
|
const sync = () => {
|
|
|
|
|
bodyEl.hidden = open;
|
|
|
|
|
editBtn.hidden = open || !mayEdit;
|
|
|
|
|
editor.hidden = !open;
|
|
|
|
|
};
|
|
|
|
|
const renderBody = () => {
|
|
|
|
|
bodyEl.textContent = items.length ? format(items) : empty;
|
|
|
|
|
bodyEl.classList.toggle('empty', !items.length);
|
|
|
|
|
};
|
|
|
|
|
const openEditor = () => {
|
|
|
|
|
area.value = toText(items);
|
|
|
|
|
open = true;
|
|
|
|
|
sync();
|
|
|
|
|
area.focus();
|
|
|
|
|
};
|
|
|
|
|
const cancel = () => { open = false; sync(); };
|
|
|
|
|
const doSave = async () => {
|
|
|
|
|
const next = fromText(area.value);
|
|
|
|
|
try {
|
|
|
|
|
await save(next);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
banner(e.message);
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
return; // stay in the editor -- nothing was changed
|
2026-11-14 23:48:27 +00:00
|
|
|
}
|
|
|
|
|
items = next;
|
|
|
|
|
cancel();
|
|
|
|
|
render(); // the server's truth re-renders the panes
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
editBtn.addEventListener('click', openEditor);
|
|
|
|
|
cancelBtn.addEventListener('click', cancel);
|
|
|
|
|
saveBtn.addEventListener('click', doSave);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
set(next) { items = next ?? []; renderBody(); },
|
|
|
|
|
setEditable(ok) { mayEdit = ok; cancel(); },
|
|
|
|
|
reset() { cancel(); },
|
|
|
|
|
get items() { return items; },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// the upstream model listing, fetched once per session -- a live
|
2026-11-14 23:48:27 +00:00
|
|
|
// /models call every render would hammer the endpoint for a list
|
|
|
|
|
// that rarely changes
|
|
|
|
|
let cachedModels = null;
|
|
|
|
|
export async function modelList() {
|
|
|
|
|
if (!cachedModels) cachedModels = await api('/models').catch(() => []);
|
|
|
|
|
return cachedModels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// A select's "" value means "deployment default"; a current override
|
|
|
|
|
// missing from the listing stays selectable, so a stale pick never
|
|
|
|
|
// silently rewrites itself.
|
|
|
|
|
function fillSelect(sel, current, list, def) {
|
|
|
|
|
sel.textContent = '';
|
|
|
|
|
const mk = (v, label) => {
|
|
|
|
|
const o = el('option', null, label);
|
|
|
|
|
o.value = v;
|
|
|
|
|
sel.appendChild(o);
|
|
|
|
|
};
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
mk('', `deployment default${def ? ` -- ${def}` : ' (unset)'}`);
|
2026-11-14 23:48:27 +00:00
|
|
|
const opts = [...list];
|
|
|
|
|
if (current && !opts.includes(current)) opts.push(current);
|
|
|
|
|
for (const m of opts) mk(m, m);
|
|
|
|
|
sel.value = current ?? '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// the models box: player/housekeeper selects + save, posting the
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// per-run overrides. The mount keeps its id -- the CSS panels it.
|
2026-11-14 23:48:27 +00:00
|
|
|
export function modelsBox(mount, { title }) {
|
|
|
|
|
const root = typeof mount === 'string' ? $(mount) : mount;
|
|
|
|
|
root.textContent = '';
|
|
|
|
|
root.appendChild(el('h2', null, title));
|
|
|
|
|
const playerSel = el('select');
|
|
|
|
|
const houseSel = el('select');
|
|
|
|
|
const pField = el('label', 'field', 'player ');
|
|
|
|
|
pField.appendChild(playerSel);
|
|
|
|
|
const hField = el('label', 'field', 'housekeeper ');
|
|
|
|
|
hField.appendChild(houseSel);
|
|
|
|
|
root.appendChild(pField);
|
|
|
|
|
root.appendChild(hField);
|
|
|
|
|
const saveBtn = el('button', null, 'save models');
|
|
|
|
|
const saveState = el('span', 'save-state');
|
|
|
|
|
const actions = el('div', 'form-actions');
|
|
|
|
|
actions.appendChild(saveBtn);
|
|
|
|
|
actions.appendChild(saveState);
|
|
|
|
|
root.appendChild(actions);
|
|
|
|
|
saveBtn.addEventListener('click', async () => {
|
|
|
|
|
try {
|
|
|
|
|
await api(`/runs/${state.runId}/model`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: { player: playerSel.value || null, housekeeper: houseSel.value || null },
|
|
|
|
|
});
|
|
|
|
|
saveState.textContent = 'saved';
|
|
|
|
|
} catch (e) {
|
|
|
|
|
banner(e.message);
|
|
|
|
|
saveState.textContent = 'not saved';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
fill(models, defaults, list) {
|
|
|
|
|
fillSelect(playerSel, models?.player ?? null, list, defaults?.player);
|
|
|
|
|
fillSelect(houseSel, models?.housekeeper ?? null, list, defaults?.housekeeper);
|
|
|
|
|
saveState.textContent = '';
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|