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:
2026-11-14 23:48:27 +00:00
parent 89a2c161b3
commit c51d31078e
36 changed files with 2643 additions and 1779 deletions
+33
View File
@@ -0,0 +1,33 @@
// web/log.mjs — diagnostics: a rolling event log that survives
// refreshes.
//
// The api() choke point records every server call (status + duration),
// uncaught errors land here, and so do navigation ejections — the
// "why did the app throw me out" history the ten-second banner loses.
// Kept in sessionStorage; the header's "log" button shows it.
import { $ } from './dom.mjs';
const log = [];
try { log.push(...JSON.parse(sessionStorage.getItem('diag') ?? '[]')); } catch { /* fresh or corrupt — start empty */ }
export function logEvent(kind, text) {
log.push(`${new Date().toISOString().slice(11, 19)} ${kind} ${text}`);
if (log.length > 300) log.splice(0, log.length - 300);
try { sessionStorage.setItem('diag', JSON.stringify(log)); } catch { /* storage full or blocked — the in-memory copy lives on */ }
}
function renderDiag() {
const d = $('diag');
d.textContent = log.join('\n');
d.scrollTop = d.scrollHeight;
}
$('diag-btn').addEventListener('click', () => {
const d = $('diag');
d.hidden = !d.hidden;
if (!d.hidden) renderDiag();
});
window.addEventListener('error', (e) => logEvent('error', e.message));
window.addEventListener('unhandledrejection', (e) => logEvent('error', `unhandled: ${e.reason?.message ?? e.reason}`));