the progress round: the provider streams, and the two long waits get honest meters -- the refine battery and her turn. The provider (provider.mjs): every completion now streams (vLLM SSE, probed live first: reasoning_content deltas arrive before content deltas, stream_options include_usage puts the full usage on the tail chunk) and assembles back into the one ChatResponse shape every caller already consumed -- content and reasoning in order, tool_calls stitched by index (id and name on the first fragment, arguments concatenated from shards, the assembled arguments parse), usage from the tail; a malformed data line fails loud where a skipped one would silently truncate, the log still records the assembled message whole, and an optional fifth param onProgress({phase, chars}) fires per delta as the meters' feed (ChatResponse names finish_reason, the wire shape the old typedef omitted). One cosmetic wire delta, named: streamed messages carry no provider_specific_fields (vLLM's duplicate reasoning channel plus refusal:null) -- nothing reads it. The refine meter (discovery.mjs + the home admin block): the job carries steps {total, done, label, chars} where the total is the scrape's model count plus the curator's two (thinking, writing), known the moment the scrape lands; the bar moves ONLY on real completions (GM, 2026-11-17: no step has a knowable duration, the point is meaningful feedback, not smooth fill), the label names the running call down to the effort-ladder sample, every completion lands a receipt line (elapsed seconds + the battery verdict), and the lines SURVIVE the job -- the receipt renders until the next refine (GM ruling: no reason to delete the log) and a rejected pass keeps its post-mortem; the curator's thinking step closes at the first prose delta (the streaming boundary -- why the provider went first), writing at the call's resolve, and a dead call closes both honestly; the 2s poll stays the transport (GM-ruled; SSE was rejected -- EventSource cannot send the Bearer header, and tokens in query strings are worse). The turn meter (loop.mjs + the progress route + the play view): the session carries a live progress record, one per provider call (a heal or tool round restarts it), fed by the streaming callback and cleared at every exit (the ask pause, the 422, the completing return, the failed request); GET /runs/:id/progress (owner-only, never queued) returns it plus the scale the bar guesstimates against -- the only true budget is max_tokens when the knobs set one (reasoning counts inside it, the usage arithmetic proves it; the route mirrors the loop's own param resolution at ~4 chars a token), else her own history: the longest past assistant turn in chars, thinking and prose both, the authored opening included (GM: a guesstimate, but an informed one). The 100% crossing pushes back geometrically: the scale grows by a quarter until the count fits, so the bar re-lands in the 80-100% band and climbs again, the same arithmetic every poll, never pinning (a count just under a grown bracket can still round to 100% for a moment -- named and accepted). No scale at all falls to the chunk-driven fallback: a twelve-segment strip, one lit, stepping ONLY when characters actually arrived -- never a free-running spinner, which would claim liveness the stream may not have; a stall shows as a stall. NO live partial prose in the transcript (the log is the one truth; streaming raw text would leak unpicked variants and half-formed heals onto the surface that shows them composed) -- the placeholder is a live div at the transcript foot, rebuilt when a render wipes it, sticking to bottom only when the scroller was already there, and the poll runs at 1s for turns (2s for refine). Verified: the provider live-probed against the real endpoint (prose+usage, thinking+progress transitions, a forced tool call with parseable arguments, the 403 path), a REAL refine run end to end on the GM's authorization (13 models, 541s, the meter exactly to spec with the curator's thinking ticking 4k-17k chars across polls) which also landed the effort measurements the registry was waiting for -- the deterministic re-pick is glm-5.3-max, and server.json's own pin still beats it until the op edits it -- smoke ALL PASS with the new assertions (the refine steps closed, the receipt's lines, the meter idle on a dormant run, idle-between-turns scaled by history, owner-gating; the first cut of the receipt assertion named the wrong mock tie-winner and the first cut of the dormant check clobbered a shared response variable -- both assertion bugs, the code was right), restart + reminder + repo checks green, typecheck green on both programs, and a disposable live run (created, three real turns, housekept, deleted) proving the meter in the browser with zero console errors: chars ticking, the phase flip at the streaming boundary, the scale re-anchoring to her new longest after each turn. Live findings on record: the measured effort default now rides every unset turn, and the test run's turns thought 12.1k/3.9k/6.5k chars against ~1.4k prose -- the max-observable default working as ruled, and the fresh-run decision the GM will make with the knob one click away; and the browser lesson pinned in AGENTS: the meter's DOM is invisible to a11y wait-text matching, so a whole frozen-meter scare during testing was a sampling artifact (the waits matched instantly against unrelated text) -- probe such widgets by DOM, never by wait

This commit is contained in:
2026-11-17 02:21:38 +00:00
parent eebc1993dd
commit bbaf33635c
13 changed files with 481 additions and 26 deletions
+8
View File
@@ -50,6 +50,14 @@
<button id="models-discover">discover</button>
<button id="models-refine">refine</button>
</div>
<div id="refine-progress" hidden>
<div id="refine-topline">
<span id="refine-count"></span>
<span id="refine-label" class="hint"></span>
</div>
<div id="refine-bar"><div id="refine-fill"></div></div>
</div>
<div id="refine-lines"></div>
<div id="models-list"></div>
</div>
</section>
+17
View File
@@ -66,6 +66,23 @@ body.play #context-meter { visibility: visible; }
#context-fill { height: 100%; width: 0; background: var(--ok); transition: width 0.4s; }
#context-fill.hot { background: var(--danger); }
#refine-progress { margin: 10px 0 2px; }
#refine-topline { display: flex; align-items: baseline; gap: 8px; font-size: 12px; margin-bottom: 4px; }
#refine-count { color: var(--accent); font-weight: 600; white-space: nowrap; }
#refine-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#refine-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#refine-fill { height: 100%; width: 0; background: var(--ok); }
#refine-lines { margin: 6px 0; font-size: 11px; color: var(--dim); max-height: 180px; overflow-y: auto; }
.refine-line { font-family: monospace; white-space: pre-wrap; }
.turn-live { margin: 10px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.turn-live-line { font-size: 12px; margin-bottom: 6px; }
.turn-live-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.turn-live-fill { height: 100%; width: 0; background: var(--ok); }
.turn-live-segs { display: flex; gap: 4px; }
.turn-live-seg { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.turn-live-seg.on { background: var(--ok); }
#diag-btn { font-size: 11px; padding: 1px 8px; color: var(--dim); }
#diag {
position: fixed;
+1 -1
View File
@@ -200,7 +200,7 @@ function noteText(e) {
// 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) {
export function stickBottom(t) {
const sc = t.closest('main');
if (!sc) return;
sc.scrollTop = sc.scrollHeight;
+23
View File
@@ -132,6 +132,29 @@ function renderModelsAdmin(reg, seq) {
/** @type {HTMLButtonElement} */ ($('models-discover')).disabled = running;
/** @type {HTMLButtonElement} */ ($('models-refine')).disabled = running || reg.phase === 'none';
// the refine meter: the bar moves only on real step completions
// (no speed to interpolate -- a stuck bar means a stuck step), the
// label names the call running now, and the lines are the receipt
// -- they survive the job, so a landed pass keeps its verdicts and
// a rejected one keeps its post-mortem
const meter = $('refine-progress');
const linesBox = $('refine-lines');
if (reg.job?.steps) {
const j = reg.job;
const st = j.steps ?? { total: 0, done: 0, label: '' };
meter.hidden = false;
$('refine-count').textContent = `${st.done}/${st.total} \u00b7 ${j.state}`;
$('refine-label').textContent = j.state === 'running'
? `${st.label}${st.chars != null ? ` \u00b7 ${st.chars} chars` : ''}`
: (j.state === 'rejected' ? `rejected -- ${j.reason ?? ''}` : st.label);
/** @type {HTMLDivElement} */ ($('refine-fill')).style.width = `${st.total ? Math.min(100, Math.round((100 * st.done) / st.total)) : 0}%`;
linesBox.textContent = '';
for (const l of j.lines ?? []) linesBox.appendChild(el('div', 'refine-line', l));
} else {
meter.hidden = true;
linesBox.textContent = '';
}
const list = $('models-list');
list.textContent = '';
for (const m of reg.models) {
+123 -1
View File
@@ -17,7 +17,7 @@ import { banner, hideBanner, renderMeter, setBusy, setSessionInfo } from './chro
import { navigate, render, runGone } from './router.mjs';
import { logEvent } from './log.mjs';
import { armedButton, modelList, modelsBox, paneEditor } from './widgets.mjs';
import { renderRaw, renderTranscript, viaLine } from './transcript.mjs';
import { renderRaw, renderTranscript, stickBottom, viaLine } from './transcript.mjs';
// the table's two faces: the curated projection (the table) and the
// raw audit log. Sticky across the re-renders a turn triggers;
@@ -280,6 +280,7 @@ async function startRun() {
const override = /** @type {HTMLInputElement} */ ($('hk-override')).checked;
hideBanner();
setBusy(true, 'starting...');
meterStart(); // the start can auto-send her opening turn -- meter it too
/** @type {?string} */ let failed = null;
let failedCls = undefined;
try {
@@ -296,6 +297,7 @@ async function startRun() {
failed = e.message;
}
}
meterStop();
setBusy(false);
render();
if (failed) banner(failed, failedCls); // render() clears the banner -- set it after
@@ -335,6 +337,122 @@ function setInput(ok) {
$('gm-stack').classList.toggle('off', !ok); // the overlay dims with the box
}
// --- the turn meter ------------------------------------------------------
//
// Her turn can run for minutes on a max-effort model, and a held-open
// request gives no sign of life. The progress route carries the
// streaming callback's live record (the phase in flight, its running
// chars) plus the scale the bar guesstimates against (GM, 2026-11-17:
// a guesstimate, but an informed one): the only true budget is
// max_tokens when the knobs set one (reasoning counts inside it),
// else her own history -- the longest turn she has completed in this
// session, in the same chars the meter counts. Reaching 100% and
// continuing pushes the bar back: the scale grows by quarters until
// the count fits, so the bar lands near 80% and climbs again -- the
// same arithmetic every poll, nothing accumulates. No scale at all
// (a fresh run, her opening turn) falls back to a chunk-driven
// animation: a segment strip that steps ONLY when characters
// actually arrived -- never a free-running spinner, which would
// claim liveness the stream may not have.
let meterSeq = 0;
/** @type {?ReturnType<typeof setTimeout>} */ let meterTimer = null;
/** @type {?HTMLElement} */ let meterBox = null;
let meterSeg = 0; // the fallback strip's lit segment
let meterChars = 0; // the last seen count -- growth steps the strip
/** @returns {void} */
function meterStart() {
meterSeq++;
meterSeg = 0;
meterChars = 0;
meterSchedule(300);
}
/** @returns {void} */
function meterStop() {
meterSeq++;
if (meterTimer) clearTimeout(meterTimer ?? undefined);
meterTimer = null;
meterBox?.remove();
meterBox = null;
}
/** @param {number} delay @returns {void} */
function meterSchedule(delay) {
const seq = meterSeq;
if (meterTimer) clearTimeout(meterTimer ?? undefined);
meterTimer = setTimeout(() => { void meterTick(seq); }, delay);
}
/** @param {number} seq @returns {Promise<void>} */
async function meterTick(seq) {
if (seq !== meterSeq || !state.runId) return;
try {
const p = await api(`/runs/${state.runId}/progress`);
if (seq !== meterSeq) return;
meterDraw(p);
} catch { /* a missed poll keeps the last frame -- the next tick retries */ }
if (seq === meterSeq) meterSchedule(1000);
}
/** One progress read.
* @typedef {{ inFlight: boolean, phase?: 'thinking'|'prose', thinking?: number, prose?: number, started?: number, scale?: ?number, scaleKind?: ?'budget'|'history' }} ProgressRead */
/** @param {ProgressRead} p @returns {void} */
function meterDraw(p) {
const t = $('transcript');
// a tab switch or a render wiped the transcript -- rebuild in place
const fresh = !meterBox || !meterBox.isConnected;
if (fresh) {
meterBox = el('div', 'turn-live');
t.appendChild(meterBox);
}
const box = /** @type {HTMLElement} */ (meterBox); // the local carries the narrowing
// never yank the scroller: stick only if the GM was already at the
// bottom -- reading back while she writes stays put
const sc = /** @type {?HTMLElement} */ (t.closest('main'));
const atBottom = sc ? sc.scrollHeight - sc.scrollTop - sc.clientHeight < 40 : false;
box.textContent = '';
const total = (p.thinking ?? 0) + (p.prose ?? 0);
const elapsed = p.started ? Math.max(0, Math.round((Date.now() - p.started) / 1000)) : 0;
const line = el('div', 'turn-live-line');
const who = el('span', null, p.inFlight
? `her turn -- ${p.phase === 'prose' ? 'writing' : 'thinking'}`
: 'her turn...');
line.appendChild(who);
/** @type {string[]} */ const facts = [];
if (p.inFlight) facts.push(`${total} chars`, `${elapsed}s`);
if (p.inFlight && p.scale && p.scaleKind) {
// the push-back arithmetic: grow the scale by quarters until the
// count fits -- a 100% crossing lands the bar near 80% again
let s = p.scale;
while (s < total) s *= 1.25;
const pct = Math.round((100 * total) / s);
facts.push(`${pct}% of ${p.scaleKind === 'budget' ? 'the budget' : 'her longest'}`);
}
if (facts.length) line.appendChild(el('span', 'hint', ` \u00b7 ${facts.join(' \u00b7 ')}`));
box.appendChild(line);
if (p.inFlight && p.scale) {
let s = p.scale;
while (s < total) s *= 1.25;
const bar = el('div', 'turn-live-bar');
const fill = el('div', 'turn-live-fill');
fill.style.width = `${Math.min(100, Math.round((100 * total) / s))}%`;
bar.appendChild(fill);
box.appendChild(bar);
} else if (p.inFlight) {
// the fallback strip: twelve segments, one lit, stepping only on
// real arrivals -- a stall shows as a stall
if (total > meterChars) meterSeg = (meterSeg + 1) % 12;
const segs = el('div', 'turn-live-segs');
for (let i = 0; i < 12; i++) segs.appendChild(el('span', i === meterSeg ? 'turn-live-seg on' : 'turn-live-seg'));
box.appendChild(segs);
}
meterChars = total;
if (fresh || atBottom) stickBottom(t);
}
// --- actions -----------------------------------------------------------
/** @returns {Promise<void>} */
@@ -354,6 +472,7 @@ async function sendTurn() {
renderInputHl();
setInput(false);
setBusy(true);
meterStart();
let failed = null;
try {
await api(`/runs/${state.runId}/turn`, { method: 'POST', body });
@@ -364,6 +483,7 @@ async function sendTurn() {
/** @type {HTMLInputElement} */ ($('gm-input')).value = line; // a failed send must not eat the line
renderInputHl();
}
meterStop();
setBusy(false);
render();
if (failed) banner(failed); // render() clears the banner -- set it after (the runGone lesson)
@@ -375,6 +495,7 @@ async function sendAnswer() {
if (!answer || !state.runId) return;
/** @type {HTMLInputElement} */ ($('ask-answer')).value = '';
setBusy(true);
meterStart();
let failed = null;
try {
await api(`/runs/${state.runId}/ask`, { method: 'POST', body: { answer } });
@@ -382,6 +503,7 @@ async function sendAnswer() {
failed = e.message;
/** @type {HTMLInputElement} */ ($('ask-answer')).value = answer;
}
meterStop();
setBusy(false);
render();
if (failed) banner(failed); // render() clears the banner -- set it after