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
This commit is contained in:
+23
-17
@@ -1,11 +1,11 @@
|
||||
// web/transcript.mjs — the transcript: register rendering and the
|
||||
// web/transcript.mjs -- the transcript: register rendering and the
|
||||
// entry walk.
|
||||
//
|
||||
// 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
|
||||
// delta tags on player turns are machinery, not prose -- they render
|
||||
// as chips and pane state, mirroring the live-context policy.
|
||||
|
||||
import { $, el } from './dom.mjs';
|
||||
@@ -32,8 +32,9 @@ 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.
|
||||
function renderContent(target, text, { extract }) {
|
||||
// delta tags on player turns always render as chips. Exported for
|
||||
// the story view, which renders the same registers.
|
||||
export function renderContent(target, text, { extract }) {
|
||||
let body = String(text ?? '');
|
||||
let status = null;
|
||||
let conflict = null;
|
||||
@@ -57,7 +58,7 @@ function renderContent(target, text, { extract }) {
|
||||
const t = line.trim();
|
||||
if (!t) { target.appendChild(document.createElement('br')); continue; }
|
||||
if (t.startsWith('(')) {
|
||||
if (t === '(') continue; // empty OOC — skip
|
||||
if (t === '(') continue; // empty OOC -- skip
|
||||
const d = document.createElement('div');
|
||||
d.className = 'line ooc';
|
||||
d.textContent = t;
|
||||
@@ -67,7 +68,7 @@ function renderContent(target, text, { extract }) {
|
||||
if (t.startsWith('<')) {
|
||||
// substrate lines: an opening <tag> is always OOC (invariants.md).
|
||||
// Known blocks were extracted above; whatever remains is an
|
||||
// unknown or unbalanced tag — keep it visible, styled as OOC
|
||||
// unknown or unbalanced tag -- keep it visible, styled as OOC
|
||||
const d = document.createElement('div');
|
||||
d.className = 'line ooc';
|
||||
d.textContent = t;
|
||||
@@ -76,9 +77,9 @@ function renderContent(target, text, { extract }) {
|
||||
}
|
||||
const stars = (line.match(/\*/g) ?? []).length;
|
||||
if (!narr && stars % 2 === 0) {
|
||||
// balanced: spans carry the registers — mixed lines
|
||||
// balanced: spans carry the registers -- mixed lines
|
||||
// (`*foo* bar *baz*`), whole-line narration (`*she sleeps.*`),
|
||||
// bold — all render correctly
|
||||
// bold -- all render correctly
|
||||
const d = document.createElement('div');
|
||||
d.className = 'line speech';
|
||||
renderSpans(d, line);
|
||||
@@ -86,7 +87,7 @@ function renderContent(target, text, { extract }) {
|
||||
continue;
|
||||
}
|
||||
if (!narr && !(t.startsWith('*') && !t.startsWith('**'))) {
|
||||
// a stray unpaired * mid-line is not a block opener — render
|
||||
// a stray unpaired * mid-line is not a block opener -- render
|
||||
// as-is; the stray stays literal
|
||||
const d = document.createElement('div');
|
||||
d.className = 'line speech';
|
||||
@@ -124,7 +125,9 @@ function renderContent(target, text, { extract }) {
|
||||
}
|
||||
|
||||
// the entry walk. onConflict receives a conflict block found on a GM
|
||||
// turn — the play view owns where it lands (the status pane).
|
||||
// turn -- the play view owns where it lands (the status pane). The
|
||||
// opening event (her opening status) renders as machinery, mirroring
|
||||
// the wire policy: it is set once, never re-sent.
|
||||
export function renderTranscript(entries, { onConflict } = {}) {
|
||||
const t = $('transcript');
|
||||
t.textContent = '';
|
||||
@@ -132,7 +135,7 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
const flushBundle = () => {
|
||||
if (!bundleParts.length) return;
|
||||
const d = el('details', 'bundle');
|
||||
d.appendChild(el('summary', null, `session bundle — ${bundleParts.map((p) => p.part).join(', ')}`));
|
||||
d.appendChild(el('summary', null, `session bundle -- ${bundleParts.map((p) => p.part).join(', ')}`));
|
||||
for (const p of bundleParts) {
|
||||
const sec = el('details');
|
||||
sec.appendChild(el('summary', null, p.part));
|
||||
@@ -153,17 +156,21 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
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
|
||||
// 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.reminder);
|
||||
if (e === newest) {
|
||||
const d = el('details', 'bundle');
|
||||
d.appendChild(el('summary', null, 'turn reminder — rides every GM turn'));
|
||||
d.appendChild(el('summary', null, 'turn reminder -- rides every GM turn'));
|
||||
d.appendChild(el('pre', null, e.m.content));
|
||||
t.appendChild(d);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'opening') {
|
||||
t.appendChild(el('div', 'machinery', `her opening status: ${JSON.stringify(e.status)}`));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'msg') {
|
||||
if (e.m.role === 'user' && e.conflictOnly) {
|
||||
// the self-heal message: error traffic on its own, never GM prose
|
||||
@@ -197,7 +204,6 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
d.appendChild(el('div', 'who', 'player'));
|
||||
const body = el('div');
|
||||
d.appendChild(body);
|
||||
if (e.m.reasoning_content) d.appendChild(el('div', 'machinery', '[thinking is logged for the housekeeper, not shown]'));
|
||||
renderContent(body, e.m.content, { extract: false });
|
||||
for (const c of e.m.tool_calls ?? []) {
|
||||
d.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
|
||||
@@ -206,11 +212,11 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
}
|
||||
function renderNote(e) {
|
||||
let text = null;
|
||||
if (e.kind === 'session') text = `session opened ${e.at}${e.fresh ? ' — fresh' : ''}`;
|
||||
else if (e.kind === 'seed') text = `seed ${e.ok ? 'applied' : 'failed'}: ${e.detail}`;
|
||||
else if (e.kind === 'ingest') text = `turn-0 status ${e.ok === false ? 'INGEST FAILED' : 'ingested'}${e.ok === false ? `: ${(e.detail ?? '').split('\n')[0]}` : ''}`;
|
||||
if (e.kind === 'session') text = `session ${e.n} opened`;
|
||||
else if (e.kind === 'ask') text = `ask_gm: ${e.question}`;
|
||||
else if (e.kind === 'status') text = `status: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
|
||||
else if (e.kind === 'agenda') text = `agenda: added ${JSON.stringify(e.applied?.added ?? [])}, dropped ${JSON.stringify(e.applied?.dropped ?? [])}`;
|
||||
else if (e.kind === 'pick') text = `variant literature: ${e.count} offered, #${e.chosen + 1} picked`;
|
||||
if (text) t.appendChild(el('div', 'machinery', text));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user