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/router.mjs -- path routing and the view lifecycle.
|
2026-11-14 23:48:27 +00:00
|
|
|
//
|
|
|
|
|
// Views register { el, enter, leave? } at boot (app.mjs). render()
|
|
|
|
|
// routes the path, then show() runs the previous view's leave and
|
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 next view's enter -- each view owns its own teardown, so the
|
2026-11-14 23:48:27 +00:00
|
|
|
// router never has to know a pane's internals. Stale async work is
|
|
|
|
|
// dropped by the seq guard: a view captures seq at enter and checks
|
|
|
|
|
// it after every await.
|
|
|
|
|
|
|
|
|
|
import { $ } from './dom.mjs';
|
|
|
|
|
import { state } from './state.mjs';
|
|
|
|
|
import { banner, hideBanner, renderMeter, setWho, setSessionInfo } from './chrome.mjs';
|
|
|
|
|
import { logEvent } from './log.mjs';
|
|
|
|
|
|
|
|
|
|
const views = {};
|
|
|
|
|
export function registerViews(map) { Object.assign(views, map); }
|
|
|
|
|
|
|
|
|
|
export function navigate(p) {
|
|
|
|
|
history.pushState({}, '', p);
|
|
|
|
|
render();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener('popstate', () => render());
|
|
|
|
|
|
|
|
|
|
export async function render() {
|
|
|
|
|
const seq = ++state.seq;
|
|
|
|
|
hideBanner();
|
|
|
|
|
const p = location.pathname;
|
|
|
|
|
let name = null;
|
|
|
|
|
let arg = null;
|
|
|
|
|
let m;
|
|
|
|
|
if (p === '/') name = 'home';
|
|
|
|
|
else if (p === '/new') name = 'new';
|
|
|
|
|
else if ((m = p.match(/^\/runs\/([a-z0-9-]+)\/setup$/))) { name = 'setup'; arg = m[1]; }
|
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
|
|
|
else if ((m = p.match(/^\/runs\/([a-z0-9-]+)\/story$/))) { name = 'story'; arg = m[1]; }
|
2026-11-14 23:48:27 +00:00
|
|
|
else if ((m = p.match(/^\/runs\/([a-z0-9-]+)$/))) { name = 'play'; arg = m[1]; }
|
|
|
|
|
else return navigate('/');
|
|
|
|
|
if (!state.me) name = 'claim'; // signed out: every path leads to the claim
|
|
|
|
|
await show(name, arg, seq);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function show(name, arg, seq) {
|
|
|
|
|
const prev = state.view;
|
|
|
|
|
if (prev && prev !== name && views[prev].leave) views[prev].leave();
|
|
|
|
|
state.view = name;
|
|
|
|
|
for (const [n, v] of Object.entries(views)) $(v.el).hidden = n !== name;
|
|
|
|
|
document.body.classList.toggle('play', name === 'play');
|
|
|
|
|
setWho(state.me);
|
|
|
|
|
setSessionInfo('');
|
|
|
|
|
renderMeter(null);
|
|
|
|
|
await views[name].enter(arg, seq);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// a run that vanished under us (deleted, 404): leave loudly for home.
|
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
|
|
|
// render() clears the banner first -- set it after the navigate.
|
2026-11-14 23:48:27 +00:00
|
|
|
export function runGone(id, from) {
|
|
|
|
|
navigate('/');
|
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
|
|
|
banner(`run ${id} is gone -- deleted?`);
|
2026-11-14 23:48:27 +00:00
|
|
|
logEvent('nav', `left ${from} for home: run gone (404)`);
|
|
|
|
|
}
|