spa modules and terminology: app.mjs split into flat es modules (router lifecycle, shared widgets, views own their state), mock smoke in test/; DICTIONARY.md rules the terms, four renames swept clean through the machinery - paper->status (run summary command is report now), window->session, wrap->housekeeping, context window->contwin; no dual-accepts by ruling, old data migrates once in the clerk (restore self-heals old dumps)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
// web/chrome.mjs — the shared page chrome: header identity, session
|
||||
// info, the context meter, the busy note, the notice banner.
|
||||
//
|
||||
// In-page notices only — no JS alert()/confirm(): they block the
|
||||
// embedded browser pane. Errors and notices land in the banner
|
||||
// instead; destructive confirms are two-click armed (widgets.mjs).
|
||||
|
||||
import { $ } from './dom.mjs';
|
||||
|
||||
// identity chrome: who is signed in. Signing in is permanent and
|
||||
// per-browser (the token lives in localStorage); there is no sign-out
|
||||
// — the lifecycle story is a roadmap extension point
|
||||
export function setWho(me) {
|
||||
$('who').textContent = me ? `${me.name}${me.superuser ? ' · op' : ''}` : '';
|
||||
$('who').title = me?.id ?? '';
|
||||
}
|
||||
|
||||
export function setSessionInfo(text) {
|
||||
$('session-info').textContent = text;
|
||||
}
|
||||
|
||||
export function renderMeter(detail) {
|
||||
const fill = $('context-fill');
|
||||
const label = $('context-label');
|
||||
const c = detail?.context;
|
||||
if (!c || c.used == null) {
|
||||
fill.style.width = '0';
|
||||
label.textContent = '';
|
||||
return;
|
||||
}
|
||||
const pct = c.pct ?? 0;
|
||||
fill.style.width = `${Math.min(100, pct)}%`;
|
||||
fill.classList.toggle('hot', pct > 85);
|
||||
label.textContent = c.contwin ? `${pct}% — close & housekeep past 85%` : '';
|
||||
}
|
||||
|
||||
export function setBusy(on, text = 'her turn…') {
|
||||
$('busy').hidden = !on; // model calls take their time — say so
|
||||
if (on) $('busy').textContent = text;
|
||||
}
|
||||
|
||||
let bannerTimer = null;
|
||||
export function banner(text, kind = 'error') {
|
||||
const b = $('banner');
|
||||
b.textContent = text;
|
||||
b.className = kind;
|
||||
b.hidden = false;
|
||||
clearTimeout(bannerTimer);
|
||||
bannerTimer = setTimeout(() => { b.hidden = true; }, 10000);
|
||||
}
|
||||
|
||||
export function hideBanner() {
|
||||
$('banner').hidden = true;
|
||||
}
|
||||
Reference in New Issue
Block a user