the night rounds: the GM-input rework and the reasoning-effort knob -- the workbench renders no faces: the composer overlay and the transcript share colour-only tokens (.narration dim, .emph accent), source verbatim, asterisks tinted and kept on screen, so the input's caret can never drift (the old overlay's real bold/italic shifted advance widths -- keeping every character preserved count, not width; the scrollbar-gutter match killed the second drift source); the story view carries its OWN renderer (view-story storyBody/storySpans) -- the book keeps real bold/italic with the asterisks spent, narration italic via #story-scoped CSS, one rule for the tool and typography for the deliverable, deliberately separate; the composer is turn-shaped: rows=6 floor, field-sizing: content grows it with the turn (the thing the GM remembered Firefox doing -- it was never in use), max-height 50vh caps with internal scroll, the footer moved under the transcript's column only so the input's width is the pane's; the transcript's stick-to-bottom was DEAD CODE all along (#transcript has no height or overflow -- main is the scroller, the scrollTop assignments were no-ops in every browser): stickBottom scrolls main and re-asserts next frame (Firefox's scroll anchoring can reclaim a same-tick scroll around a content wipe), main carries overflow-anchor: none; the prose pane drops its machinery by ruling: the status/agenda chips and the retired delta tags strip (the panes carry the derived state), the reminder card never renders (it is the same every turn -- the raw tab keeps every copy), and the status/agenda note receipts (the old delta applies and the whole-list sets alike) skip the prose walk while the raw keeps them; the model dropdown collapsed to one plain list of ids sorted, ceilings riding along (the family grouping left the user guessing what a family name means, and the curator's tier labels only made sense inside their groups); and the reasoning-effort round: the battery probes the ladder (probeEfforts -- each of none/minimal/low/medium/high/xhigh/max measured for mean thinking, two samples, efforts recorded per model, effortDefault the argmax mean over minimal..max, 'none' never a candidate -- it is the off switch; null when the model shows no thinking), the knob is first-class and the GM's alone (GM, 2026-11-16: hidden from the model, not her call -- never in the mind verb, never in the <model> display block, and renderView's via-derived block filters it too, both surfaces; it rides the via record for the raw surfaces), its unset state SENDS the measured max-mean default (the one knob with an honestly nameable default -- the registry measured it; layers run override > deployment > registry per-model, explicit null clears to nothing), the first non-numeric knob (RoleParams carries the string, the /model route validates against the ladder, the knob row a select whose unset label names what rides and rebuilds on model-select change); the GLM ladder verified live by hand before the build (low suppresses to a third of baseline, max elevates about double, the whole ladder accepted on both families without 400s, and reasoning_effort 'none' doubles as a standardized thinking-off switch); the model dropdown, the composer, and the knob UX browser-proven with zero console errors (the pass caught the unreachable-helpers bug: code after a factory's return never runs, a hoisted function referencing the uninitialized const throws silently mid-fill and stale rows render); smoke ALL PASS with the effort battery (the canned mock ladders, the default riding a bare turn's via, the override riding the next turn, the bogus-level 400, the null clear, no reasoning_effort in any <model> block) + restart + reminder + repo checks green, typecheck green on both programs; ROADMAP gains the distant extension point (n-choice inference composed by a turn-editor agent) and the operator's queue moved there from QUESTIONS by the GM; HANDOFF prepared as the handoff (the typing-round bullet trimmed into the rounds list, the server line now truthful -- the debug server runs, the registry bullet carries the six-knob state and the pending-effort refine)

This commit is contained in:
2026-11-16 23:52:58 +00:00
parent 5ffecee935
commit eebc1993dd
19 changed files with 571 additions and 179 deletions
+1 -1
View File
@@ -173,7 +173,7 @@
<footer>
<div id="gm-stack">
<pre id="gm-hl" aria-hidden="true"></pre>
<textarea id="gm-input" rows="2" placeholder="GM line -- Ctrl+Space sends" disabled></textarea>
<textarea id="gm-input" rows="6" placeholder="GM turn -- Enter newlines, Ctrl+Space sends" disabled></textarea>
</div>
<span id="busy" hidden>her turn...</span>
<button id="gm-send" disabled>send</button>
+93 -35
View File
@@ -5,17 +5,20 @@
// table is the single home of every knob text -- label, hint, bounds
// -- red-pen the prose here, in place. Bounds are display knowledge
// probed from this endpoint's own validation errors (the /model
// route's validation stays generic: a finite number). The provider's
// serving defaults are unknown and stay unstated; the only default
// anyone can honestly name is the deployment layer (server.json
// params), which rides the run detail as paramDefaults.
// route's validation stays generic: a finite number, or one of the
// effort ladder's levels). The provider's serving defaults are
// unknown and stay unstated; the only default anyone can honestly
// name is the deployment layer (server.json params), which rides the
// run detail as paramDefaults -- reasoning_effort is the one
// exception: the registry measured a per-model default (the maximum
// observed mean thinking), so its unset state honestly sends.
//
// Two defaults, never conflated: a knob unset means its value is NOT
// sent to the provider; a value present is sent, and the row marks it
// when it equals the deployment default. The explicit override toggle
// carries the distinction: off (the visible default) disables the
// input and saving sends nothing for the knob (null clears a
// previously-set value); on demands a number.
// previously-set value); on demands a number (a level, for the enum).
//
// The hint bar is shared by both roles -- one explanation at a time,
// driven by focus (a tap focuses), cleared when focus leaves the
@@ -25,13 +28,20 @@
import { el } from './dom.mjs';
/** One knob's definition: the texts are the product, the shape is
* schema-ready for later kinds (bools: what to expect on and off;
* enums: explanation-only) -- nothing else ships today. All five
// the reasoning-effort ladder -- mirrors server/discovery.mjs's
// EFFORT_LEVELS (the web cannot import server runtime code); keep
// them in step
const EFFORT_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
/** One knob's definition: the texts are the product. Two kinds ship:
* numbers, and the effort enum (a select over the ladder). All six
* knobs are the GM's here; the mind verb (server/loop.mjs) sets
* only the four that are hers -- max_tokens is excluded by ruling
* (a budget, not a mind). */
/** @typedef {{ key: keyof RoleParams, kind: 'number', label: string, hint: string, bounds: string }} KnobDef */
* (a budget, not a mind), reasoning_effort is hidden from her
* entirely (not her call). */
/** @typedef {{ key: keyof RoleParams, kind: 'number', label: string, hint: string, bounds: string }} NumberDef */
/** @typedef {{ key: keyof RoleParams, kind: 'enum', label: string, hint: string }} EnumDef */
/** @typedef {NumberDef|EnumDef} KnobDef */
/** @type {KnobDef[]} */
const DEFS = [
@@ -70,17 +80,35 @@ const DEFS = [
hint: 'The response\'s hard length budget. Higher: room for long turns. Lower: cheaper and shorter, but the turn can cut off mid-sentence -- and on reasoning models thinking counts against this budget first, so a low cap can be eaten entirely before she writes a word.',
bounds: '1 or more on this endpoint; no enforced max (values above the model\'s output ceiling are accepted).',
},
{
key: 'reasoning_effort',
kind: 'enum',
label: 'reasoning effort',
hint: 'How hard the model thinks before answering. Higher levels reason more thoroughly and cost more (thinking bills as output tokens); lower levels answer faster. The level is a request, not a guarantee -- the model adapts to the task. Not hers to set: the mind verb never carries it.',
},
];
/** The hint bar's text for one knob: label, the explanation, the
* bounds, and the honest default statement for this role's
* deployment layer. Never invents an unknown value. */
/** @param {KnobDef} def @param {number|undefined|null} dep @returns {string} */
function hintText(def, dep) {
* deployment layer. Never invents an unknown value. The enum knob
* states its own honest default: the measured pick. */
/** @param {KnobDef} def @param {number|string|undefined|null} dep @param {?{ measured: Record<string, number>, fallback: ?string }} [effort] @returns {string} */
function hintText(def, dep, effort) {
if (def.kind === 'enum') {
const table = effort
? `Measured mean thinking for this model: ${Object.entries(effort.measured).map(([k, v]) => `${k} ${v}`).join(', ')}.`
: 'No effort measurements for this model (an unrefined registry, or the model shows no thinking).';
const rides = (dep !== undefined && dep !== null ? String(dep) : null) ?? effort?.fallback ?? null;
const defLine = rides
? `Unset = ${rides} rides (the measured default: the level with the highest observed thinking).`
: 'Unset = not sent; the model id\'s own baked default applies.';
return `${def.label} -- ${def.hint} ${table} ${defLine}`;
}
const d = /** @type {NumberDef} */ (def);
const defLine = dep !== undefined && dep !== null
? `Unset = the deployment default (${dep}).`
: 'Unset = not sent; the provider\'s own default applies (unknown).';
return `${def.label.replace(/_/g, ' ')} -- ${def.hint} ${def.bounds} ${defLine}`;
return `${d.label.replace(/_/g, ' ')} -- ${d.hint} ${d.bounds} ${defLine}`;
}
/** One role's knob row.
@@ -88,12 +116,13 @@ function hintText(def, dep) {
* @param {RoleParams|undefined} current the run's own knobs
* @param {RoleParams|undefined|null} deployment the deployment layer (server.json params)
* @param {HTMLElement} hintBar the shared hint bar
* @returns {{ wrap: HTMLElement, read: () => Record<string, number|null> }}
* @param {?{ measured: Record<string, number>, fallback: ?string }} [effort] the current model's measured effort ladder (null: none)
* @returns {{ wrap: HTMLElement, read: () => Record<string, number|string|null> }}
*/
export function knobsBox(role, current, deployment, hintBar) {
export function knobsBox(role, current, deployment, hintBar, effort = null) {
const wrap = el('div', 'knobs');
wrap.appendChild(el('div', 'knobs-head', `${role} knobs`));
/** @type {Record<string, { tog: HTMLInputElement, inp: HTMLInputElement }>} */
/** @type {Record<string, { tog: HTMLInputElement, inp: HTMLInputElement, sel: ?HTMLSelectElement }>} */
const rows = {};
for (const def of DEFS) {
const row = el('div', 'knob');
@@ -101,11 +130,28 @@ export function knobsBox(role, current, deployment, hintBar) {
tog.type = 'checkbox';
tog.title = 'override';
const lab = el('label', null, `${def.label.replace(/_/g, ' ')} `);
const inp = /** @type {HTMLInputElement} */ (el('input'));
inp.type = 'number';
inp.step = 'any';
const mark = el('span', 'knob-default', ' \u00b7 deployment default');
lab.appendChild(inp);
/** @type {?HTMLSelectElement} */ let sel = null;
const inp = /** @type {HTMLInputElement} */ (el('input'));
if (def.kind === 'enum') {
// the effort row: a select over the ladder; unset sends the
// measured default (the registry's pick for the current model)
sel = /** @type {HTMLSelectElement} */ (el('select'));
const rides = deployment?.[def.key] ?? effort?.fallback ?? null;
const unset = /** @type {HTMLOptionElement} */ (el('option', null, rides ? `(default: ${rides})` : '(not sent)'));
unset.value = '';
sel.appendChild(unset);
for (const lv of EFFORT_LEVELS) {
const o = /** @type {HTMLOptionElement} */ (el('option', null, lv));
o.value = lv;
sel.appendChild(o);
}
lab.appendChild(sel);
} else {
inp.type = 'number';
inp.step = 'any';
lab.appendChild(inp);
}
lab.appendChild(mark);
row.appendChild(tog);
row.appendChild(lab);
@@ -113,20 +159,26 @@ export function knobsBox(role, current, deployment, hintBar) {
const set = current?.[def.key];
tog.checked = set !== undefined;
if (set !== undefined) inp.value = String(set);
const dep = deployment?.[def.key];
// the toggle owns the state: off disables the input (the value
// stays for a change of mind), on demands a number; a value equal
// to the deployment default is still sent, and the row marks it
// stays for a change of mind), on demands a number (a level);
// a value equal to the deployment default is still sent, and
// the row marks it
const sync = () => {
inp.disabled = !tog.checked;
mark.hidden = !(tog.checked && inp.value.trim() !== '' && Number(inp.value) === dep);
const field = /** @type {HTMLInputElement|HTMLSelectElement} */ (sel ?? inp);
field.disabled = !tog.checked;
const v = sel ? sel.value : inp.value.trim();
mark.hidden = !(tog.checked && v !== '' && v === String(dep ?? '\u0000'));
};
tog.addEventListener('change', sync);
inp.addEventListener('input', sync);
if (sel) sel.addEventListener('change', sync);
else inp.addEventListener('input', sync);
sync();
inp.addEventListener('focus', () => { hintBar.textContent = hintText(def, dep); });
rows[def.key] = { tog, inp };
const focusEl = /** @type {HTMLElement} */ (sel ?? inp);
focusEl.addEventListener('focus', () => { hintBar.textContent = hintText(def, dep, effort); });
if (sel && set !== undefined) sel.value = String(set);
else if (!sel && set !== undefined) inp.value = String(set);
rows[def.key] = { tog, inp, sel };
}
// the bar keeps its text while focus moves inside the row, clears
// when it leaves the knobs entirely
@@ -134,15 +186,21 @@ export function knobsBox(role, current, deployment, hintBar) {
if (!wrap.contains(/** @type {?Node} */ (e.relatedTarget))) hintBar.textContent = '';
});
const read = () => {
/** @type {Record<string, number|null>} */ const out = {};
/** @type {Record<string, number|string|null>} */ const out = {};
for (const def of DEFS) {
const { tog, inp } = rows[def.key];
const { tog, inp, sel } = rows[def.key];
if (tog.checked) {
const v = inp.value.trim();
if (v === '' || !Number.isFinite(Number(v))) {
throw new Error(`${def.label}: a number is required -- or switch the override off`);
if (sel) {
const v = sel.value;
if (!v) throw new Error(`${def.label}: a level is required -- or switch the override off`);
out[def.key] = v;
} else {
const v = inp.value.trim();
if (v === '' || !Number.isFinite(Number(v))) {
throw new Error(`${def.label}: a number is required -- or switch the override off`);
}
out[def.key] = Number(v);
}
out[def.key] = Number(v);
} else if (current?.[def.key] !== undefined) {
out[def.key] = null; // clearing a previously-set knob
}
+23 -9
View File
@@ -33,12 +33,14 @@ body {
height: 100vh;
}
/* play keeps the two-column transcript + aside layout */
/* play keeps the two-column transcript + aside layout; the footer
(the composer) sits under the transcript's column only -- the
input's width is the pane's width (GM, 2026-11-16) */
body.play {
grid-template:
"header header" auto
"main aside" 1fr
"footer footer" auto / 1fr 300px;
"footer ." auto / 1fr 300px;
}
/* --- header --- */
@@ -98,7 +100,7 @@ button.primary { border-color: var(--accent); color: var(--accent); }
/* --- main / views --- */
main { grid-area: main; overflow-y: auto; padding: 18px 22px; }
main { grid-area: main; overflow-y: auto; padding: 18px 22px; overflow-anchor: none; }
h1 { font-size: 15px; letter-spacing: 0.1em; color: var(--dim); font-weight: normal; margin: 4px 0 14px; }
@@ -276,8 +278,8 @@ h1 { font-size: 15px; letter-spacing: 0.1em; color: var(--dim); font-weight: nor
.raw-slot { margin: 10px 0 2px; }
.line { margin: 2px 0; white-space: pre-wrap; }
.narration { color: var(--dim); font-style: italic; }
.narration strong { color: var(--text); font-style: italic; }
.narration { color: var(--dim); } /* colour-only: no italic face -- same glyphs, same widths */
.emph { color: var(--accent); }
.ooc { color: var(--dim); border-left: 2px solid var(--line); padding-left: 8px; font-size: 13px; }
.tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
@@ -290,8 +292,6 @@ h1 { font-size: 15px; letter-spacing: 0.1em; color: var(--dim); font-weight: nor
.chip.drop { text-decoration: line-through; }
.chip.add { color: var(--ok); border-color: var(--ok); }
.chip.mind { color: var(--accent); border-color: var(--accent); }
.chip.status { color: var(--text); }
.chip.agenda { color: var(--accent); border-color: var(--accent); }
.machinery {
margin: 6px 0; font-size: 12px; color: var(--dim);
@@ -351,6 +351,11 @@ details.bundle pre { margin: 0; padding: 0 12px 10px; white-space: pre-wrap; fon
}
.story-head h1 { margin: 0; }
#story { max-width: 760px; }
/* the book earns its typography: the story's narration is italic and
its emphasis is bold -- the workbench's colour-only rule stops at
the story's door (the renderers are separate by the same ruling) */
#story .narration { color: var(--dim); font-style: italic; }
#story .narration strong { color: var(--text); font-style: italic; }
.session-break { margin: 26px 0 12px; border-top: 1px solid var(--line); }
/* --- aside (play) --- */
@@ -417,7 +422,7 @@ body.play #play-aside { display: block; }
footer {
grid-area: footer;
gap: 8px; padding: 10px 14px;
gap: 8px; padding: 10px 22px 14px; /* the composer's edges align with the transcript's column */
background: var(--panel); border-top: 1px solid var(--line);
display: none;
}
@@ -426,16 +431,24 @@ body.play footer { display: flex; }
#gm-stack.off { opacity: 0.4; }
/* the highlight overlay: the setup editor's stack pattern -- a pre
behind a transparent-text textarea, identical metrics, so the
tokens light up in place without moving the caret */
tokens light up in place without moving the caret. The tokens are
colour-only (real faces shift advance widths and dragged the
caret); scrollbar-gutter keeps the columns aligned when the box
starts scrolling; field-sizing grows the box with the turn from
its six-line floor (the rows attribute is the no-support floor) */
#gm-hl, #gm-input {
grid-area: 1 / 1;
margin: 0;
padding: 5px 8px;
font: inherit;
line-height: 1.5;
white-space: pre-wrap;
overflow-wrap: break-word;
border: 1px solid var(--line);
border-radius: 4px;
scrollbar-gutter: stable;
min-height: 6lh;
max-height: 50vh;
}
#gm-hl { pointer-events: none; overflow: hidden; color: var(--text); border-color: transparent; background: transparent; }
#gm-input {
@@ -444,6 +457,7 @@ body.play footer { display: flex; }
caret-color: var(--text);
resize: none;
overflow-y: auto;
field-sizing: content; /* the box grows with the turn; max-height caps it */
}
#gm-input::placeholder { color: var(--dim); }
#gm-send { padding: 5px 18px; }
+50 -29
View File
@@ -4,9 +4,11 @@
// The transcript renders three registers by the ruled markers: plain
// text is speech, *italics* is narration, a line opening with `(` is
// OOC (closing paren optional; a lone paren is an empty OOC line and
// is skipped). The <status>/<agenda> blocks riding GM turns and the
// delta tags on player turns are machinery, not prose -- they render
// as chips and pane state, mirroring the live-context policy.
// is skipped). The machinery never shows here: the status and agenda
// blocks (and the retired delta tags) strip from the prose -- the
// dedicated panes carry the derived state -- and the reminder rides
// only on the raw tab. The mind chip is the one exception: the mind
// is write-only, the chip is its display.
/** @typedef {import('../server/shapes.mjs').LogEvent} LogEvent */
/** @typedef {import('../server/shapes.mjs').BundleEvent} BundleEvent */
@@ -15,21 +17,20 @@
import { $, el } from './dom.mjs';
// splits text into spans: *italics* = narration, **bold** = emphasis
// splits text into spans: *italics* = narration, **bold** = emphasis.
// Colour-only (GM, 2026-11-16): the workbench renders no faces --
// same glyphs, same widths, only paint differs, and the input's
// caret can never drift from what it overlays. The asterisks stay
// on screen: the authored text is the rendered text
/** @param {HTMLElement} target @param {string} text */
function renderSpans(target, text) {
const parts = String(text).split(/(\*\*[^*]+\*\*|\*[^*\n]+\*)/g);
for (const p of parts) {
if (!p) continue;
if (p.startsWith('**') && p.endsWith('**')) {
const b = document.createElement('strong');
b.textContent = p.slice(2, -2);
target.appendChild(b);
target.appendChild(el('span', 'emph', p));
} else if (p.startsWith('*') && p.endsWith('*') && p.length > 2) {
const i = document.createElement('em');
i.className = 'narration';
i.textContent = p.slice(1, -1);
target.appendChild(i);
target.appendChild(el('span', 'narration', p));
} else {
target.appendChild(document.createTextNode(p));
}
@@ -38,10 +39,12 @@ function renderSpans(target, text) {
// one content block (a GM or player turn) -> DOM lines. extract pulls
// the riding blocks (status/conflict/agenda) out of GM prose; the
// delta tags on player turns always render as chips. Exported for
// the story view, which renders the same registers.
// delta tags on player turns always render as chips. The workbench's
// register renderer -- colour-only, source verbatim; the story view
// carries its own (view-story.mjs), the book's typography is not the
// tool's (GM, 2026-11-16).
/** @param {HTMLElement} target @param {?string} text @param {{ extract?: boolean }} opts @returns {{ status: ?string, conflict: ?string, agenda: ?string }} */
export function renderContent(target, text, { extract }) {
function renderContent(target, text, { extract }) {
let body = String(text ?? '');
let status = null;
let conflict = null;
@@ -122,10 +125,16 @@ export function renderContent(target, text, { extract }) {
renderSpans(d, content);
target.appendChild(d);
}
if (tags.length) {
if (tags.some((t) => t.kind === 'mind')) {
// only the mind chips: it is write-only, the chip is its one
// table-side display. The state machinery (status, agenda, the
// retired delta tags) renders nowhere in the prose pane -- the
// dedicated panes carry the derived state, the transcript
// carries the prose (GM, 2026-11-16)
const wrap = document.createElement('div');
wrap.className = 'tags';
for (const t of tags) {
if (t.kind !== 'mind') continue;
for (const item of t.items) {
const c = document.createElement('span');
c.className = `chip ${t.kind}`;
@@ -142,7 +151,7 @@ export function renderContent(target, text, { extract }) {
// params as sent (the merged layer actually sent). Shared by the raw
// walk and the per-turn raw control. fail is present when the call
// failed -- no message resulted.
/** @param {{ model: string, params?: Record<string, number> }} via @param {?string} [fail] @returns {string} */
/** @param {{ model: string, params?: Record<string, number|string> }} via @param {?string} [fail] @returns {string} */
export function viaLine(via, fail = null) {
const ks = Object.entries(via.params ?? {});
const p = ks.length ? ` -- ${ks.map(([k, v]) => `${k}: ${v}`).join(', ')}` : ' (no knobs set)';
@@ -186,6 +195,18 @@ function noteText(e) {
return null;
}
// the transcript's stick-to-bottom: the div itself just grows -- main
// is the scroller. Firefox can also reclaim a same-tick programmatic
// scroll around a content wipe (scroll anchoring re-anchoring after
// the rebuild), so the position re-asserts on the next frame
/** @param {HTMLElement} t */
function stickBottom(t) {
const sc = t.closest('main');
if (!sc) return;
sc.scrollTop = sc.scrollHeight;
requestAnimationFrame(() => { sc.scrollTop = sc.scrollHeight; });
}
// the raw walk: the audit surface over the same log -- everything as
// it rode the wire. Thinking, whole variant blocks, every reminder
// copy, full tool results, the rides inline in the GM prose; plain
@@ -259,7 +280,7 @@ export function renderRaw(entries) {
continue;
}
}
t.scrollTop = t.scrollHeight;
stickBottom(t);
}
// the entry walk. onConflict receives a conflict block found on a GM
@@ -299,16 +320,9 @@ export function renderTranscript(entries, { onConflict, onRaw } = {}) {
}
flushBundle();
if (e.t === 'msg' && e.reminder) {
// the turn reminder: the transcript mirrors the live-context
// policy -- one collapsed card for the newest copy, superseded
// ones elide (the log keeps every as-sent chunk)
const newest = [...entries].reverse().find((x) => x.t === 'msg' && x.reminder);
if (e === newest) {
const d = el('details', 'bundle');
d.appendChild(el('summary', null, 'turn reminder -- rides every GM turn'));
d.appendChild(el('pre', null, e.m.content));
t.appendChild(d);
}
// the reminder never renders in the prose pane (GM, 2026-11-16):
// it is the same every turn -- the raw tab keeps every copy,
// the audit surface is its home
continue;
}
if (e.t === 'opening') {
@@ -330,10 +344,17 @@ export function renderTranscript(entries, { onConflict, onRaw } = {}) {
t.appendChild(el('div', 'machinery', `${e.ask ? '[ruling] ' : '[tool result] '}${String(e.m.content).split('\n')[0]}`));
continue;
}
if (e.t === 'note') renderNote(e);
if (e.t === 'note') {
// the state receipts never render in the prose pane (GM,
// 2026-11-16): the status/agenda notes -- the old delta applies
// and the whole-list sets alike -- duplicate the panes; the raw
// tab keeps every receipt
if (e.kind === 'status' || e.kind === 'agenda') continue;
renderNote(e);
}
}
flushBundle();
t.scrollTop = t.scrollHeight;
stickBottom(t);
/** @param {MsgEvent} e @param {number} idx @param {string} who */
function gmTurn(e, idx, who) {
+4 -3
View File
@@ -497,8 +497,9 @@ $('gm-input').addEventListener('keydown', (e) => {
// the GM input's highlight overlay: the setup editor's stack pattern
// -- the pre behind a transparent-text textarea renders the tokens in
// place. Every character stays (the asterisks too) so the caret never
// desyncs from the visible glyphs: italics and bold style their whole
// token, sigils and vars color theirs
// desyncs from the visible glyphs, and the tokens are colour-only
// (GM, 2026-11-16): real faces shift advance widths and dragged the
// caret with them -- same glyphs, same widths, only paint differs
const SIGIL_RE = /@(PC|Package)\b/g;
const VAR_RE = /\$([A-Za-z_][A-Za-z0-9_]*)/g;
function renderInputHl() {
@@ -508,7 +509,7 @@ function renderInputHl() {
// per-line tokens, matching the transcript's renderer: bold and
// italics never span lines
hl.innerHTML = esc
.replace(/(\*\*[^*\n]+\*\*|\*[^*\n]+\*)/g, (m) => (m.startsWith('**') ? `<strong>${m}</strong>` : `<em>${m}</em>`))
.replace(/(\*\*[^*\n]+\*\*|\*[^*\n]+\*)/g, (m) => (m.startsWith('**') ? `<span class="emph">${m}</span>` : `<span class="narration">${m}</span>`))
.replace(VAR_RE, '<span class="tok-var">$&</span>')
.replace(SIGIL_RE, '<span class="tok-sigil">$&</span>');
hl.scrollTop = ta.scrollTop;
+57 -2
View File
@@ -14,10 +14,65 @@ import { state } from './state.mjs';
import { banner } from './chrome.mjs';
import { logEvent } from './log.mjs';
import { navigate, runGone } from './router.mjs';
import { renderContent } from './transcript.mjs';
/** @typedef {import('./shapes.mjs').StoryResponse} StoryResponse */
// the story's own renderer, deliberately not the workbench's (GM,
// 2026-11-16: one rule -- the table and the composer render
// colour-only, source text verbatim; the book is the deliverable and
// earns its typography). Real faces, asterisks spent: *italics* is
// the narration register, **bold** is emphasis, the prose reads like
// print. The server already stripped rides, verbs, and whole OOC
// turns; mid-turn OOC lines and stray tags can still arrive and
// render in their dim style.
/** @param {HTMLElement} target @param {string} text */
function storySpans(target, text) {
const parts = String(text).split(/(\*\*[^*]+\*\*|\*[^*\n]+\*)/g);
for (const p of parts) {
if (!p) continue;
if (p.startsWith('**') && p.endsWith('**')) {
target.appendChild(el('strong', null, p.slice(2, -2)));
} else if (p.startsWith('*') && p.endsWith('*') && p.length > 2) {
target.appendChild(el('em', 'narration', p.slice(1, -1)));
} else {
target.appendChild(document.createTextNode(p));
}
}
}
/** @param {HTMLElement} target @param {string} text */
function storyBody(target, text) {
let narr = false; // an open multi-line narration block
for (const line of String(text ?? '').split('\n')) {
const t = line.trim();
if (!t) { target.appendChild(document.createElement('br')); continue; }
if (t.startsWith('(') || t.startsWith('<')) {
// a mid-turn OOC line or a stray tag -- dim, kept visible
target.appendChild(el('div', 'line ooc', t));
continue;
}
const stars = (line.match(/\*/g) ?? []).length;
if (!narr && (stars % 2 === 0 || !(t.startsWith('*') && !t.startsWith('**')))) {
// balanced spans, or a stray unpaired * mid-line (not a block
// opener -- the stray stays literal)
const d = el('div', 'line speech');
storySpans(d, line);
target.appendChild(d);
continue;
}
// block narration: an unpaired leading * opens it, a trailing * closes
let content = line.replace(/^\s*\*/, '');
narr = true;
if (t.endsWith('*') && !t.endsWith('**')) {
narr = false;
content = content.trimEnd().slice(0, -1);
}
const d = el('div', 'line narration');
storySpans(d, content);
target.appendChild(d);
}
}
/** @type {?string} */ let storyRun = null;
/** @param {?string} id @param {number} seq @returns {Promise<void>} */
@@ -54,7 +109,7 @@ export async function enter(id, seq) {
d.appendChild(el('div', 'who', turn.who === 'gm' ? 'GM' : 'player'));
const body = el('div');
d.appendChild(body);
renderContent(body, turn.text, { extract: turn.who === 'gm' });
storyBody(body, turn.text);
box.appendChild(d);
}
}
+43 -30
View File
@@ -131,10 +131,12 @@ export function fmtCeiling(tokens) {
// A select's "" value means "deployment default"; a current override
// missing from the registry stays selectable, so a stale pick never
// silently rewrites itself. The registry's usable models group by
// family; the label is the curator's (or the id before refinement),
// and the input ceiling rides along -- the user picks against the
// contwin, so the context limit belongs in the open.
// silently rewrites itself. One plain list, sorted by id (GM,
// 2026-11-16: the family grouping left the user guessing what a
// family name means, and the curator's tier labels only made sense
// inside their groups -- the id is the self-describing name). The
// input ceiling rides along -- the user picks against the contwin,
// so the context limit belongs in the open.
/** @param {HTMLSelectElement} sel @param {?string} current @param {import('./shapes.mjs').ModelsRegistryResponse} reg @param {?string} [def] */
function fillSelect(sel, current, reg, def) {
sel.textContent = '';
@@ -147,23 +149,9 @@ function fillSelect(sel, current, reg, def) {
mk('', `deployment default${def ? ` -- ${def}` : ' (unset)'}`);
const usableModels = reg.models.filter((m) => m.inference !== false && (m.roles?.player ?? true));
const extras = current && !usableModels.some((m) => m.id === current) ? [current] : [];
/** @type {Record<string, import('../server/shapes.mjs').RegistryModel[]>} */ const byFamily = {};
for (const m of usableModels) {
const f = m.family ?? m.id;
(byFamily[f] ??= []).push(m);
}
const families = Object.keys(byFamily).sort();
for (const f of families) {
const group = /** @type {HTMLOptGroupElement} */ (el('optgroup'));
group.label = f;
for (const m of byFamily[f]) {
const label = m.label ?? m.id;
const ceil = fmtCeiling(m.input);
const o = /** @type {HTMLOptionElement} */ (el('option', null, ceil ? `${label} \u00b7 ${ceil}` : label));
o.value = m.id;
group.appendChild(o);
}
sel.appendChild(group);
for (const m of [...usableModels].sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))) {
const ceil = fmtCeiling(m.input);
mk(m.id, ceil ? `${m.id} \u00b7 ${ceil}` : m.id);
}
for (const x of extras) mk(x, `${x} (not in the registry)`);
sel.value = current ?? '';
@@ -171,7 +159,10 @@ function fillSelect(sel, current, reg, def) {
// the models box: player/housekeeper selects over the registry, the
// sampling knobs per role (one shared hint bar under both rows), and
// one save. The mount keeps its id -- the CSS panels it.
// one save. The mount keeps its id -- the CSS panels it. The knob
// rows rebuild when the model select changes: the effort knob's
// default is measured per model, so switching the model switches the
// honest default.
/** @param {string|HTMLElement} mount @param {{ title: string }} opts */
export function modelsBox(mount, { title }) {
const root = typeof mount === 'string' ? $(mount) : mount;
@@ -186,11 +177,37 @@ export function modelsBox(mount, { title }) {
root.appendChild(pField);
root.appendChild(hField);
const knobHint = el('div', 'knob-hint'); // one bar, both roles
/** @type {{ wrap: HTMLElement, read: () => Record<string, number|null> }} */ let playerKnobs = knobsBox('player', undefined, undefined, knobHint);
/** @type {{ wrap: HTMLElement, read: () => Record<string, number|null> }} */ let houseKnobs = knobsBox('housekeeper', undefined, undefined, knobHint);
/** @type {{ wrap: HTMLElement, read: () => Record<string, number|string|null> }} */ let playerKnobs = knobsBox('player', undefined, undefined, knobHint);
/** @type {{ wrap: HTMLElement, read: () => Record<string, number|string|null> }} */ let houseKnobs = knobsBox('housekeeper', undefined, undefined, knobHint);
root.appendChild(playerKnobs.wrap);
root.appendChild(houseKnobs.wrap);
root.appendChild(knobHint);
// the latest fill's inputs -- the select-change refresh rebuilds
// the knob rows against them (the effort context follows the
// newly-picked model)
/** @type {?{ params: ?{ player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams }, paramDefaults: ?{ player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams }, reg: import('./shapes.mjs').ModelsRegistryResponse }} */ let last = null;
// the effort knob's context: the currently-selected model's
// measured ladder (null when the registry has none for it)
/** @param {'player'|'housekeeper'} role @param {import('./shapes.mjs').ModelsRegistryResponse} reg @returns {?{ measured: Record<string, number>, fallback: ?string }} */
const effortOf = (role, reg) => {
const id = (role === 'player' ? playerSel.value : houseSel.value)
|| reg.defaults?.[role] || null;
const m = id ? reg.models.find((x) => x.id === id) : null;
return m?.efforts ? { measured: m.efforts, fallback: m.effortDefault ?? null } : null;
};
/** rebuild both knob rows against the current selects and the
* latest fill (fill and select-change both land here) */
function rebuildKnobs() {
if (!last) return;
const pk = knobsBox('player', last.params?.player ?? undefined, last.paramDefaults?.player ?? undefined, knobHint, effortOf('player', last.reg));
const hk = knobsBox('housekeeper', last.params?.housekeeper ?? undefined, last.paramDefaults?.housekeeper ?? undefined, knobHint, effortOf('housekeeper', last.reg));
playerKnobs.wrap.replaceWith(pk.wrap);
houseKnobs.wrap.replaceWith(hk.wrap);
playerKnobs = pk;
houseKnobs = hk;
}
playerSel.addEventListener('change', rebuildKnobs);
houseSel.addEventListener('change', rebuildKnobs);
if (!root.querySelector('.registry-hint')) {
const hint = el('div', 'hint registry-hint', '');
root.appendChild(hint);
@@ -224,12 +241,8 @@ export function modelsBox(mount, { title }) {
fill(models, defaults, params, paramDefaults, reg) {
fillSelect(playerSel, models?.player ?? null, reg, defaults?.player);
fillSelect(houseSel, models?.housekeeper ?? null, reg, defaults?.housekeeper);
const pk = knobsBox('player', params?.player ?? undefined, paramDefaults?.player ?? undefined, knobHint);
const hk = knobsBox('housekeeper', params?.housekeeper ?? undefined, paramDefaults?.housekeeper ?? undefined, knobHint);
playerKnobs.wrap.replaceWith(pk.wrap);
houseKnobs.wrap.replaceWith(hk.wrap);
playerKnobs = pk;
houseKnobs = hk;
last = { params: params ?? null, paramDefaults: paramDefaults ?? null, reg };
rebuildKnobs();
const hint = root.querySelector('.registry-hint');
if (hint) {
hint.textContent = reg.phase === 'none'