create-pmos 0.482.0 → 0.483.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,12 +14,25 @@
14
14
  * while the shown version is not the saved one, what the look follows (its samples and rules), Current beside New look, the preview, then
15
15
  * Use it (accept) and Keep current (revert to the saved look). GET /api/report-design and its version renders. A confirm asks in the card.
16
16
  *
17
+ * THE REPORT BUILDING FLOW (batch 22 item 14, "A+ on Home", canvas RfH1–RfH7) now leads:
18
+ * A NEW REPORT opens its questions first, Claude's picks filled in (report-flow.js questionsHtml): Format, Readers, Goes out, Look, Sources,
19
+ * "Nothing goes out" and Draft it. Draft it sets it up (POST /api/report-setups/setup), records T1 and the conversation it came from
20
+ * (POST /api/report-flow/start), and opens the report's current state.
21
+ * A SET-UP REPORT opens its current state (GET /api/report-flow): the newest cycle in the reader (premium-report-read.js, with Claude's review),
22
+ * or, while no cycle is written, the drafting line of the report's own session.
23
+ * A CHANGE Claude passes from the chat (block.change) goes to the report's own session (POST /api/report-flow/ask), then the report opens.
24
+ * THE TEMPLATE (panel 'template', the header icon): the same questions on the current version, "changed" marks, Template history with Go back
25
+ * (POST /api/report-flow/restore), Keep the current template and Make a different template (POST /api/report-flow/template). Its sections and
26
+ * look, the cycles and Delete template stay one press further (panel 'manage', the view described above).
27
+ *
17
28
  * Every write is a press here, behind the launch nonce (http.js pmPost). Claude writes nothing: the routes refuse an agent session. A render is
18
29
  * HTML the server sanitized, shown in a frame with an empty sandbox, so nothing in it runs. Nothing is sent outward. */
19
30
  import { pmGet, pmPost } from './http.js';
20
- import { open as vOpen, current as vCur, body as vBody, czSections } from './cozy-viewer.js';
21
- import { rpSumHtml, rpBarHtml, cadenceWords, FORMATS } from './rp-parts.js';
31
+ import { open as vOpen, current as vCur, body as vBody } from './cozy-viewer.js';
32
+ import { FORMATS } from './rp-parts.js';
22
33
  import { vzStyle } from './premium-vw-open.js';
34
+ import * as RF from './report-flow.js';
35
+ import { adler } from './cozy-adler.js';
23
36
 
24
37
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
25
38
  const OUT = FORMATS;
@@ -48,28 +61,75 @@ export function schedChoices(cur) {
48
61
  }
49
62
 
50
63
  const T = new Map(); // view id → its state
64
+ const PASSED = new Set(); // the chat changes passed to a report's session on this page: a second press of the same chip passes nothing
51
65
  /** The report parts' sheet (cozy-vw-rp.css), added to the page once (premium-report-read.js adds the same one). */
52
66
  function rpStyle() {
53
67
  if (typeof document === 'undefined' || document.querySelector('link[data-rp-css]')) return;
54
68
  const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./cozy-vw-rp.css', import.meta.url).href; l.setAttribute('data-rp-css', ''); document.head.appendChild(l);
55
69
  }
56
70
  const SV = (d, n = 16) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true"><path d="${d}"/></svg>`;
57
- /** Open (or refresh) the view of a checked report block (report-chat.js cleanBlock). */
58
- export function openReportTab(block) {
71
+ /** Open (or refresh) the view of a checked report block (report-chat.js cleanBlock). o = { chat (the conversation key), panel: 'template' | 'manage', auto (opened by a new answer, not a press) } */
72
+ export function openReportTab(block, o = {}) {
59
73
  if (!block) return null;
60
74
  vzStyle(); rpStyle();
61
75
  const id = 'report:' + (block.id || block.proposal.name).toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 60);
62
76
  let t = T.get(id);
63
- // a proposal that is set up already opens its report, never "New · Set it up" again (Wawan, 2026-11-01, batch 22 item 13: "it goes back here again")
64
- if (t && block.proposal && t.block.id && !t.gone) return show(t);
77
+ // a proposal that is set up already opens its report, never the questions again (Wawan, 2026-11-01, batch 22 item 13: "it goes back here again")
78
+ if (t && block.proposal && t.block.id && !t.gone) return current(t);
65
79
  if (!t && block.proposal) { setTimeout(() => adoptSetUp(id, block.proposal.name), 0); }
66
- if (!t || JSON.stringify(t.block) !== JSON.stringify(block)) {
67
- t = { id, block, nv: 'deck', sched: block.proposal ? (block.proposal.schedule || 'off') : null, open: false, view: 'structure', busy: false, msg: '', setup: null, docs: [], S: null, Z: null, sv: null, dv: null, render: new Map(), gone: false, loaded: false, i: 0, ask: null };
80
+ if (!t || JSON.stringify(t.block) !== JSON.stringify(block) || (o.panel && o.panel !== t.panel)) {
81
+ t = { id, block, nv: 'deck', sched: block.proposal ? (block.proposal.schedule || 'off') : null, open: false, view: 'structure', busy: false, msg: '', setup: null, docs: [], S: null, Z: null, sv: null, dv: null, render: new Map(), gone: false, loaded: false, i: 0, ask: null,
82
+ q: block.proposal ? RF.picksOf(block.proposal) : null, panel: block.proposal ? 'new' : o.panel || 'current', chat: o.chat || (t && t.chat) || null, F: null, tq: null, passed: t ? t.passed : false };
68
83
  T.set(id, t);
69
- if (block.id) load(t);
70
- }
84
+ if (block.id && t.panel === 'manage') load(t);
85
+ } else if (o.chat) t.chat = o.chat;
86
+ // a change passes on the PM's press of the chip only; an answer that opens the view by itself shows the report as it is
87
+ if (block.id && block.change && !t.passed && !o.auto && !PASSED.has(JSON.stringify(block))) { PASSED.add(JSON.stringify(block)); t.passed = true; passChange(t); return show(t); }
88
+ if (block.id && t.panel === 'current') return current(t);
89
+ if (block.id && t.panel === 'template') { const v = show(t); loadFlow(t).then(() => redraw(t)); return v; }
71
90
  return show(t);
72
91
  }
92
+ /** The report's state from GET /api/report-flow; for the template, the answers start from its current version. */
93
+ async function loadFlow(t) {
94
+ const F = await get('/api/report-flow', { id: t.block.id });
95
+ t.F = F && F.ok ? F : { err: (F && F.error) || 'The report could not be read.' };
96
+ if (t.F.ok) { const v = (t.F.template.versions || []).find((x) => x.current); t.base = v ? v.settings : { output: t.F.output, audience: t.F.audience, schedule: t.F.status === 'paused' ? 'off' : t.F.schedule }; t.tq = RF.picksOfSettings(t.base); }
97
+ return t.F;
98
+ }
99
+ /** The report's current state: its newest cycle in the reader, or the drafting line until one is written (then the cycle opens by itself). */
100
+ async function current(t, say) {
101
+ t.panel = 'current'; t.F = null; show(t);
102
+ const F = await loadFlow(t);
103
+ if (T.get(t.id) !== t || t.panel !== 'current') return;
104
+ if (F.ok && F.latest) {
105
+ const M = await import('./premium-report-read.js');
106
+ return M.openReportView(F.latest.path, { ws: ws(), name: F.name, ...(say || t.msg ? { say: say || t.msg } : {}) });
107
+ }
108
+ if (say) t.msg = say;
109
+ redraw(t);
110
+ if (F.ok && !t.waiting) waitFor(t);
111
+ }
112
+ /** While the report's own session drafts, read its state every few seconds; the first cycle opens when it lands. */
113
+ async function waitFor(t) {
114
+ t.waiting = true;
115
+ const end = Date.now() + 20 * 60000;
116
+ while (Date.now() < end && T.get(t.id) === t && t.panel === 'current' && paneOf(t)) {
117
+ await new Promise((ok) => setTimeout(ok, 3000));
118
+ if (T.get(t.id) !== t || t.panel !== 'current' || !paneOf(t)) break;
119
+ const F = await get('/api/report-flow', { id: t.block.id });
120
+ if (F && F.ok && F.latest) { t.waiting = false; return current(t); }
121
+ if (F && F.ok && JSON.stringify(F.drafting) !== JSON.stringify(t.F && t.F.drafting)) { t.F = F; redraw(t); }
122
+ }
123
+ t.waiting = false;
124
+ }
125
+ /** A change Claude passed from the chat: to the report's own session, then the report opens (RfH2). */
126
+ async function passChange(t) {
127
+ const r = await post('/api/report-flow/ask', { id: t.block.id, text: t.block.change });
128
+ const said = r && r.ok ? (r.started ? "The report's session started with your change. It shows in the report as it writes it. Nothing is issued." : "Passed to the report's session. It shows in the report as it writes it. Nothing is issued.")
129
+ : 'The change was not passed on: ' + why(r, 'the page could not reach PMOS') + '.';
130
+ t.block = { kind: 'report', id: t.block.id }; t.passed = false;
131
+ return current(t, said);
132
+ }
73
133
  /** The chat's proposal names a report that is set up already (an earlier page, or a reload): open that report instead of the proposal. */
74
134
  async function adoptSetUp(id, name) {
75
135
  const L = await get('/api/report-setups');
@@ -77,13 +137,16 @@ async function adoptSetUp(id, name) {
77
137
  const hit = t && t.block.proposal && L && Array.isArray(L.setups) ? L.setups.find((x) => x.status !== 'removed' && String(x.name || '').trim().toLowerCase() === String(name || '').trim().toLowerCase()) : null;
78
138
  if (!hit) return;
79
139
  t.block = { kind: 'report', id: hit.id }; t.loaded = false;
80
- if (paneOf(t)) show(t);
81
- await load(t);
140
+ if (paneOf(t)) await current(t);
82
141
  }
142
+ const TPL = { act: 'template', label: 'Template: format, readers, look, sources', icon: RF.ICON.tune };
143
+ const BACK = { act: 'back', label: 'Back to the report', icon: RF.ICON.back };
83
144
  function show(t) {
84
145
  const P = t.block.proposal;
85
- return vOpen({ id: t.id, kind: P ? 'Report' + (P.audience ? ' · ' + P.audience : '') : 'Report template', title: P ? P.name : (t.setup && t.setup.name) || t.block.id, icon: 'report',
86
- render: (el) => { el.onclick = (e) => press(t, e); draw(t, el); } });
146
+ const presses = P ? [] : t.panel === 'template' || t.panel === 'manage' ? [BACK] : [TPL];
147
+ return vOpen({ id: t.id, kind: P ? 'Report' + (P.audience ? ' · ' + P.audience : '') : t.panel === 'current' ? 'Report' : 'Report template', title: P ? P.name : (t.F && t.F.name) || (t.setup && t.setup.name) || t.block.id, icon: 'report',
148
+ presses, onPress: (a) => { if (a === 'template') { t.panel = 'template'; show(t); loadFlow(t).then(() => redraw(t)); } else if (a === 'back') current(t); },
149
+ render: (el) => { el.onclick = (e) => press(t, e); el.oninput = (e) => typed(t, e); el.onchange = (e) => picked(t, e); draw(t, el); } });
87
150
  }
88
151
  const paneOf = (t) => (vCur() && vCur().id === t.id ? vBody() : null);
89
152
  const redraw = (t) => { const el = paneOf(t); if (el) draw(t, el); };
@@ -154,7 +217,10 @@ function askHtml(t) {
154
217
  return `<div class="vz-ask2" role="group" aria-label="${esc(A.yes)}"><span>${esc(A.text)}</span><div><button type="button" class="vz-issue vz-hv vz-h36" data-rt="askyes" data-k="bad">${esc(A.yes)}</button><button type="button" class="vz-sec2 vz-hv vz-h36" data-rt="askno">${esc(A.no)}</button></div></div>`;
155
218
  }
156
219
  function draw(t, el) {
157
- el.innerHTML = `<div class="vz ${t.block.proposal ? 'vz-dk' : 'vz-rtp'}" data-vw="${esc(t.id)}">${askHtml(t)}${t.block.proposal ? newHtml(t) : setupHtml(t)}${t.msg ? `<p class="vz-msg" role="status">${esc(t.msg)}</p>` : ''}</div>`;
220
+ const P = t.block.proposal, flow = !!P || t.panel === 'template';
221
+ const inner = P ? RF.questionsHtml(t.q, { look: t.block.design || (t.block.sample ? 'Follow ' + String(t.block.sample).split('/').pop() : ''), sources: P.sources, busy: t.busy, msg: t.msg })
222
+ : t.panel === 'template' ? templateHtml(t) : t.panel === 'manage' ? setupHtml(t) : currentHtml(t);
223
+ el.innerHTML = `<div class="vz vz-rtp" data-vw="${esc(t.id)}"${t.panel ? ` data-panel="${esc(t.panel)}"` : ''}>${askHtml(t)}${inner}${t.msg && !flow ? `<p class="vz-msg" role="status">${esc(t.msg)}</p>` : ''}</div>`;
158
224
  el.querySelectorAll('iframe[data-rt-frame]').forEach((f) => { f.srcdoc = t.render.get(+f.dataset.rtFrame) || ''; });
159
225
  }
160
226
  /** The new report as slides: its title slide, then one slide per section every new report has. */
@@ -163,37 +229,37 @@ export function deckOf(p, sections) {
163
229
  }
164
230
  /** The sections a new report will have: the ones the PM named in the chat (block.sections), else the standard frame. */
165
231
  export const frameOf = (sections) => (Array.isArray(sections) && sections.length ? sections.map((h) => [h, '']) : FRAME);
166
- /**
167
- * A new report from the chat: the one report Viewer in its first state (canvas OvReport). The summary says it is new and not set up, what
168
- * it will hold, and its one primary, Set it up (a check icon); its chips are the schedule (Once until one is picked; it opens the choices)
169
- * and the format. Slides | Document, then the deck (the slide, ‹ Slide n of N ›, the thumbnails) or the outline as a page. The folds are
170
- * At a glance and Structure and look ("new"). Edit, Present, Share and Download have nothing to act on until it is set up, so they are not drawn.
171
- */
172
- function newHtml(t) {
173
- const p = t.block.proposal, named = t.block.sections, F = frameOf(named), L = deckOf(p, named), i = t.i = Math.max(0, Math.min(t.i, L.length - 1)), s = L[i];
174
- const sum = rpSumHtml({ line: 'New · from your chat', tone: 'you', right: 'Not set up yet',
175
- text: named ? 'One slide per section: ' + F.map(([h]) => h).join(', ') + '. Press the check to set it up: it keeps these sections and drafts the first report with them. Nothing goes out.'
176
- : t.block.structure ? 'It starts with the standard sections. When you set it up, Claude reshapes them to your change, and you keep it with one press. Nothing goes out until you set it up.'
177
- : 'One slide per section: ' + FRAME.map(([h]) => h).join(', ') + '. Press the check to set it up. Nothing goes out.',
178
- chips: [{ icon: 'repeat', label: cadenceWords(t.sched), act: 'sched', exp: t.open }, { icon: 'file', label: OUT[p.output] || p.output || 'PDF' }],
179
- primary: { act: 'setup', label: t.busy ? 'Setting it up' : 'Set it up', icon: 'check', disabled: t.busy } }, 'data-rt');
180
- const bar = rpBarHtml({ view: t.nv, views: [['deck', 'Slides'], ['doc', 'Document']] }, 'data-rt');
181
- const deck = `<div class="vz-dks" role="group" aria-roledescription="slide" aria-label="Slide ${i + 1} of ${L.length}: ${esc(s.h)}"><p class="vz-dke">${esc(s.eye)}</p><h2>${esc(s.h)}</h2>${s.t ? `<p>${esc(s.t)}</p>` : ''}</div>`
182
- + `<div class="vz-dkn"><button type="button" class="vz-dkb vz-hv" data-rt="sl|-1" aria-label="Previous slide"${i === 0 ? ' disabled' : ''}>${SV('M15 6l-6 6 6 6')}</button><span aria-live="polite">Slide ${i + 1} of ${L.length}</span><button type="button" class="vz-dkb vz-hv" data-rt="sl|1" aria-label="Next slide"${i === L.length - 1 ? ' disabled' : ''}>${SV('M9 6l6 6-6 6')}</button></div>`
183
- + `<div class="vz-dkt" role="group" aria-label="Slides">${L.map((x, k) => `<button type="button" class="vz-hv" data-rt="go|${k}" aria-label="Slide ${k + 1}: ${esc(x.h)}"${k === i ? ' aria-current="true"' : ''}><span>${esc(x.h)}</span></button>`).join('')}</div>`;
184
- const page = `<article class="vz-dkp"><h2>${esc(p.name)}</h2>${p.purpose ? `<p class="vz-note">${esc(p.purpose)}</p>` : ''}${sectionsHtml(F)}</article>`;
185
- // the look Claude proposed with the report (batch 22 item 13): the PM's words, or the file it follows
186
- const smp = t.block.sample ? String(t.block.sample).split('/').pop() : '';
187
- const lookAsk = t.block.design || smp ? `<div class="vz-ask"><p>Look: <b>“${esc(t.block.design || 'Follow ' + smp)}”</b></p><p class="vz-note">Claude ${smp ? 'follows ' + esc(smp) : 'makes this look'} as soon as the report is set up.</p></div>` : '';
188
- const folds = czSections([
189
- { id: 'glance', title: 'At a glance', count: 'For, read by, goes out', render: () => `<div class="rp-brief">${glance(p.purpose, p.audience, esc(schedWords(t.sched)), OUT[p.output] || p.output)}</div>` },
190
- { id: 'look', title: 'Structure and look', count: named ? F.length + ' sections' : t.block.structure ? 'change' : 'new', render: () => named
191
- ? `${lookAsk}${sectionsHtml(F)}<p class="vz-note">The sections you named in the chat.${lookAsk ? '' : ' It uses the standard PMOS look until you say how it should look.'}</p>`
192
- : (t.block.structure ? `<div class="vz-ask"><p>Your change: <b>“${esc(t.block.structure)}”</b></p><p class="vz-note">Claude makes this change as soon as the report is set up. When you keep it, Claude writes the draft again with it.</p></div>` : '')
193
- + lookAsk
194
- + `${sectionsHtml(FRAME)}<p class="vz-note">Every new report has these sections. ${t.block.structure ? '' : 'Once it is set up, ask in the chat to shape them. '}${lookAsk ? '' : 'It uses the standard PMOS look until you say how it should look.'}</p>` },
195
- ], { key: 'report-new' });
196
- return sum + schedMenu(t, t.sched) + bar + (t.nv === 'doc' ? page : deck) + folds;
232
+ /** The report's current state while no cycle is written yet (RfH1). */
233
+ function currentHtml(t) {
234
+ if (!t.F) return '<p class="vz-empty" role="status">Reading the report.</p>';
235
+ if (t.F.err) return `<p class="vz-msg" data-tone="bad">${esc(t.F.err)}</p>`;
236
+ return RF.waitHtml(t.F, adler(t.F.drafting && t.F.drafting.state === 'ended' ? 'honest' : 'thinking', 36));
237
+ }
238
+ /** The template (RfH3): the questions on its current version, what changed, its history, Keep the current template | Make a different template. */
239
+ function templateHtml(t) {
240
+ if (!t.F) return '<p class="vz-empty" role="status">Reading the template.</p>';
241
+ if (t.F.err) return `<p class="vz-msg" data-tone="bad">${esc(t.F.err)}</p>`;
242
+ const T0 = t.F.template || {};
243
+ const tpl = { base: t.base, current: T0.current, versions: T0.versions || [], diff: RF.diffOf(t.tq, t.base) };
244
+ return RF.questionsHtml(t.tq, { template: tpl, busy: t.busy, msg: t.msg })
245
+ + `<p class="vz-note">Its sections and look, and its cycles: <button type="button" class="rp-linkbtn vz-hv" data-rt="manage">Sections, look and cycles</button></p>`;
246
+ }
247
+ const qOf = (t) => (t.block.proposal ? t.q : t.tq);
248
+ /** Readers, typed: kept as typed; Draft it and Make a different template wait for a name. */
249
+ function typed(t, e) {
250
+ const k = e.target && e.target.dataset ? e.target.dataset.rt : '';
251
+ const q = qOf(t); if (k !== 'aud' || !q) return;
252
+ q.audience = e.target.value;
253
+ const b = paneOf(t) && paneOf(t).querySelector(t.block.proposal ? '[data-rt="draftit"]' : '[data-rt="maketpl"]');
254
+ if (b) b.disabled = t.busy || !q.audience.trim() || (!t.block.proposal && !RF.diffOf(q, t.base).length);
255
+ }
256
+ /** A pick in Goes out (how often, the day, the time). The template redraws, so its "changed" marks follow. */
257
+ function picked(t, e) {
258
+ const k = e.target && e.target.dataset ? e.target.dataset.rt : '';
259
+ const q = qOf(t); if (!q) return;
260
+ if (k === 'aud') { q.audience = e.target.value; redraw(t); return; }
261
+ if (k === 'cad') q.cadence = e.target.value; else if (k === 'day') q.day = e.target.value; else if (k === 'dom') q.dayOfMonth = +e.target.value || 1; else if (k === 'time') q.time = e.target.value; else return;
262
+ redraw(t);
197
263
  }
198
264
  function setupHtml(t) {
199
265
  const s = t.setup;
@@ -274,6 +340,33 @@ async function press(t, e) {
274
340
  const b = e.target.closest('[data-rt]'); if (!b || b.disabled) return;
275
341
  const [a, v] = [b.dataset.rt.split('|')[0], b.dataset.rt.slice(b.dataset.rt.indexOf('|') + 1)];
276
342
  const cur = t.block.proposal ? t.sched : t.setup && (t.setup.status === 'paused' ? 'off' : t.setup.schedule);
343
+ if (a === 'fmt' || a === 'rep') { const q = qOf(t); if (!q) return; if (a === 'fmt') q.output = v; else q.repeat = v === '1'; redraw(t); return; }
344
+ if (a === 'draftit') { await setUp(t); return; }
345
+ if (a === 'keep') { await current(t); return; }
346
+ if (a === 'manage') { t.panel = 'manage'; t.loaded = false; show(t); await load(t); return; }
347
+ if (a === 'maketpl') {
348
+ await act(t, async () => {
349
+ const r = await post('/api/report-flow/template', { id: t.block.id, settings: RF.settingsOfPicks(t.tq) });
350
+ if (!r || !r.ok) return 'The template did not change: ' + why(r, 'the page could not reach PMOS') + '.';
351
+ if (r.state) t.F = r.state; await loadFlow(t);
352
+ return 'T' + r.n + ' is the current template. The next draft follows it; the earlier drafts and cycles stay with their own.';
353
+ });
354
+ return;
355
+ }
356
+ if (a === 'restore') {
357
+ await act(t, async () => {
358
+ const r = await post('/api/report-flow/restore', { id: t.block.id, n: +v });
359
+ if (!r || !r.ok) return 'It did not go back: ' + why(r, 'the page could not reach PMOS') + '.';
360
+ await loadFlow(t);
361
+ return 'Back to T' + r.n + '. It is the current template again. Nothing is deleted.';
362
+ });
363
+ return;
364
+ }
365
+ if (a === 'redraft') {
366
+ await act(t, async () => { const r = await post('/api/report-setups/draft', { id: t.block.id }); if (!r || !r.ok) return 'The draft did not start: ' + why(r, 'the page could not reach PMOS') + '.'; return null; });
367
+ await current(t);
368
+ return;
369
+ }
277
370
  if (a === 'askno') { t.ask = null; redraw(t); return; }
278
371
  if (a === 'askyes') { const A = t.ask; t.ask = null; if (A) await A.run(); return; }
279
372
  if (a === 'sl') { t.i += +v; redraw(t); return; }
@@ -348,33 +441,29 @@ async function startLook(t, id, look) {
348
441
  t.Z = Object.assign({}, t.Z, { running: true }); poll(t, 'design');
349
442
  return ' Claude is making the look' + (added ? ' from ' + added : '') + ' now.';
350
443
  }
444
+ /** Draft it (RfH4, RfH7): the answers set the report up, T1 and the conversation are recorded, and its current state opens (RfH1). */
351
445
  async function setUp(t) {
352
- const p = t.block.proposal;
353
- const schedule = t.sched === 'off' ? { cadence: 'weekly', day: 'Mon', time: '09:00' } : t.sched;
354
- await act(t, async () => {
355
- const named = t.block.sections;
356
- const r = await post('/api/report-setups/setup', { proposal: { name: p.name, purpose: p.purpose || p.name, audience: p.audience, source: 'work', output: p.output, schedule,
357
- sources: p.sources.length ? p.sources : ['The records of this workspace'], learned_from: 'Set up from a chat.' }, ...(named ? { sections: named } : {}) });
358
- if (!r || !r.ok) return 'It was not set up: ' + why(r, 'the page could not reach PMOS') + '.';
359
- if (t.sched === 'off') await post('/api/report-setups/edit', { id: r.setup.id, schedule: { cadence: 'off' } });
360
- // the view now shows the set-up report, under the same id, so the card stays on it
361
- const look = { text: t.block.design || '', sample: t.block.sample || '' };
362
- const shape = r.structure ? null : named ? 'Use exactly these sections, in this order: ' + named.join('; ') + '.' : t.block.structure;
363
- t.block = { kind: 'report', id: r.setup.id }; t.loaded = false; show(t); await load(t);
364
- const d = r.drafted || {};
365
- // the change Claude proposed with the new report: start it now, the PM keeps it with Use this (batch 20 item 9)
366
- let shaping = '';
367
- if (shape) {
368
- const s = await post('/api/report-structure/turn', { id: r.setup.id, text: shape });
369
- if (s && s.ok) { t.S = Object.assign({}, t.S, { running: true }); t.view = 'structure'; poll(t, 'structure'); shaping = ' Claude is reshaping the sections to your change now.'; }
370
- else { t.block = Object.assign({}, t.block, { structure: shape }); shaping = ' The change to its sections did not start: ' + why(s, 'no answer') + '. Press Make the next version to try again.'; }
371
- }
372
- // the look Claude proposed with it (the PM's words, and the file to follow, such as a draft deck): add the sample, then start the look
373
- // (Wawan, 2026-11-01, batch 22 item 13: "Deck format and layout follow the draft deck" was dropped at set-up)
374
- if (look.text || look.sample) shaping += await startLook(t, r.setup.id, look);
375
- if (r.structure) t.view = 'structure';
376
- const first = d.drafting ? 'Claude is writing the first draft with your ' + named.length + ' sections. It opens under Reports when it lands.'
377
- : d.path ? 'The first draft is written.' : 'The first draft was not written' + (d.error ? ': ' + d.error : '') + '.';
378
- return 'Set up' + (r.structure ? ' with your sections. ' : '. ') + first + (t.sched === 'off' ? ' Schedule is Off, so it runs once.' : '') + shaping;
379
- });
446
+ const p = t.block.proposal, q = t.q, st = RF.settingsOfPicks(q), once = st.schedule === 'off';
447
+ const schedule = once ? { cadence: 'weekly', day: 'Mon', time: '09:00' } : st.schedule;
448
+ const named = t.block.sections;
449
+ t.busy = true; t.msg = ''; redraw(t);
450
+ const r = await post('/api/report-setups/setup', { proposal: { name: p.name, purpose: p.purpose || p.name, audience: st.audience || p.audience, source: 'work', output: st.output, schedule,
451
+ sources: p.sources.length ? p.sources : ['The records of this workspace'], learned_from: 'Set up from a chat.' }, ...(named ? { sections: named } : {}) });
452
+ if (!r || !r.ok) { t.busy = false; t.msg = 'It was not drafted: ' + why(r, 'the page could not reach PMOS') + '.'; redraw(t); return; }
453
+ if (once) await post('/api/report-setups/edit', { id: r.setup.id, schedule: { cadence: 'off' } });
454
+ await post('/api/report-flow/start', { id: r.setup.id, ...(t.chat ? { chat: t.chat } : {}) });
455
+ const look = { text: t.block.design || '', sample: t.block.sample || '' };
456
+ const shape = r.structure ? null : named ? 'Use exactly these sections, in this order: ' + named.join('; ') + '.' : t.block.structure;
457
+ t.block = { kind: 'report', id: r.setup.id }; t.busy = false;
458
+ // the change Claude proposed with the new report starts now; the PM keeps it with Use this under Sections, look and cycles (batch 20 item 9)
459
+ let shaping = '';
460
+ if (shape) {
461
+ const s2 = await post('/api/report-structure/turn', { id: r.setup.id, text: shape });
462
+ shaping = s2 && s2.ok ? ' Claude is reshaping the sections to your change.' : ' The change to its sections did not start: ' + why(s2, 'no answer') + '.';
463
+ }
464
+ // the look Claude proposed with it (batch 22 item 13): the PM's words, and the file to follow
465
+ if (look.text || look.sample) shaping += await startLook(t, r.setup.id, look);
466
+ const d = r.drafted || {};
467
+ const first = d.drafting ? "The report's own session is drafting it." : d.path ? 'The first draft is written. Claude reads it as your readers would.' : 'The first draft was not written' + (d.error ? ': ' + d.error : '') + '.';
468
+ return current(t, first + (once ? ' It goes out once.' : '') + shaping);
380
469
  }
@@ -64,7 +64,7 @@ export function cleanBlock(b) {
64
64
  if (typeof b.id === 'string' && ID_RE.test(b.id)) {
65
65
  const out = { kind: 'report', id: b.id };
66
66
  if (b.schedule !== undefined) { const s = cleanSchedule(b.schedule); if (s) out.schedule = s; }
67
- for (const k of ['structure', 'design']) { const v = clip(b[k], 600); if (v) out[k] = v; }
67
+ for (const k of ['structure', 'design', 'change']) { const v = clip(b[k], 600); if (v) out[k] = v; }
68
68
  const secs = cleanSections(b.sections); if (secs) out.sections = secs;
69
69
  return out;
70
70
  }
@@ -98,10 +98,12 @@ export function reportChipHtml(block, i) {
98
98
  const k = block.kind, P = block.proposal;
99
99
  const name = k === 'report' ? (P ? P.name : block.id) : P ? (k === 'chart' ? P.title || P.measure : P.name) : block.id;
100
100
  const noun = k === 'report' ? 'report' : k;
101
- const what = k === 'report' && !P ? (block.schedule ? 'Schedule change' : block.structure || block.design ? 'Report change' : 'Report')
101
+ const what = k === 'report' && !P ? (block.change ? 'Change to the draft' : block.schedule ? 'Schedule change' : block.structure || block.design ? 'Report change' : 'Report')
102
102
  : P && !block.id ? 'New ' + noun : P ? noun[0].toUpperCase() + noun.slice(1) + ' change' : noun[0].toUpperCase() + noun.slice(1);
103
103
  const tab = k === 'report' ? 'Report' : k === 'chart' ? 'Chart' : 'Dashboard';
104
104
  // a new report waits for one press, so the chip names it (Wawan, 2026-11-01: "I still don't know how to set it up")
105
- const next = k === 'report' && P && !block.id ? 'Set it up in the Report tab' : 'View in the ' + tab + ' tab';
105
+ // a new report: the questions come first, with Claude's picks filled in, then Draft it (batch 22 item 14, canvas RfH4).
106
+ // A set-up report's chip opens its current state; a change goes to the report's own session (RfH2).
107
+ const next = k === 'report' && P && !block.id ? 'Answer a few questions, then Draft it' : k === 'report' && block.change ? "Pass it to the report's session" : k === 'report' ? 'Open the report' : 'View in the ' + tab + ' tab';
106
108
  return `<div class="ctxc"><button type="button" class="ctxchip lead" data-report-open="${i}"><span><b>${esc(name)}</b><em>${esc(what)} · ${esc(next)}</em></span></button></div>`;
107
109
  }
@@ -0,0 +1,163 @@
1
+ /* pm/report-flow.js — the report building flow's parts, drawn as html (batch 22 item 14, "A+ on Home", canvas RfH1–RfH7). Pure: no DOM and no
2
+ * fetch, so node tests it (report-flow.test.mjs). premium-report-tab.js draws the questions and the template; premium-report-read.js draws the review.
3
+ *
4
+ * picksOf(proposal) → the answers a new report starts with: Claude's picks (format, who reads it, when it goes out)
5
+ * picksOfSettings(settings) → the same, from a template version (lib/report-templates.js settings)
6
+ * settingsOfPicks(q) → { output, audience, schedule } as the routes take them
7
+ * changedOf(q, base) → ['output' | 'audience' | 'schedule'] what differs from the current template
8
+ * diffOf(q, base) → ['Format: Slides → Document', …] the same, in words
9
+ * questionsHtml(q, o) the questions (RfH4, RfH7): Format, Readers, Goes out, Look, Sources, then Draft it.
10
+ * o.template draws them as the template (RfH3): "changed" marks, the history, Keep the current template and
11
+ * Make a different template
12
+ * historyHtml(versions) Template history: T<n>, what it is, when, the cycles issued with it, Go back to T<n>
13
+ * waitHtml(F) the report's current state while no cycle is written yet: drafting, ended, or no draft (RfH1)
14
+ * reviewHtml(rv, o) Claude's review of a draft in the proposal pattern (RfH2): one line, a ✦ row per fix with Not now and Do it,
15
+ * Do all, and "N other checks found nothing"
16
+ * Every press is an attribute (data-rt for the tab, data-r for the reader), so the caller wires it. Nothing here sends anything outward.
17
+ * Not drawn, as the agreed note says they are not proven: stakeholder groups (Readers is the words Claude picked), example issue dates, a look read
18
+ * from an attached PDF, and a review score. */
19
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
20
+ const SV = (d, n = 16) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
21
+ export const ICON = { go: 'M5 12h14M13 6l6 6-6 6', x: 'M6 6l12 12M18 6L6 18', check: 'M5 12.5l4.5 4.5L19 7.5', back: 'M9 14 4 9l5-5M4 9h11a5 5 0 0 1 0 10h-3',
22
+ tune: 'M4 7h10M18 7h2M4 17h2M10 17h10M14 5v4M8 15v4' };
23
+ export const FORMAT_NAMES = { 'google-slides': ['Slides', 'Read aloud or presented.'], 'google-doc': ['Document', 'Read alone, with tables and footnotes.'],
24
+ pdf: ['PDF', 'A fixed page to read or print.'], 'google-sheets': ['Sheets', 'The numbers as a table.'], confluence: ['Confluence page', 'A page in your wiki.'] };
25
+ export const CADENCES = [['weekly', 'Every week'], ['bi-weekly', 'Every two weeks'], ['monthly', 'Every month'], ['daily', 'Every day']];
26
+ const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
27
+ const TIMES = ['07:00', '08:00', '09:00', '10:00', '12:00', '14:00', '16:00', '17:00'];
28
+
29
+ /** The answers a new report starts with: Claude's picks. */
30
+ export function picksOf(p = {}) {
31
+ const s = p.schedule && typeof p.schedule === 'object' && p.schedule.cadence ? p.schedule : null;
32
+ return { output: p.output || 'google-slides', audience: p.audience || '', repeat: !!s, cadence: s ? s.cadence : 'weekly', day: (s && s.day) || 'Mon', dayOfMonth: (s && s.dayOfMonth) || 1, time: (s && s.time) || '09:00',
33
+ pick: { output: p.output || 'google-slides', audience: p.audience || '' } };
34
+ }
35
+ export function picksOfSettings(st = {}) {
36
+ const q = picksOf({ output: st.output, audience: st.audience, schedule: st.schedule === 'off' ? null : st.schedule });
37
+ q.pick = null;
38
+ return q;
39
+ }
40
+ /** The answers as the routes take them. Once is schedule 'off'. */
41
+ export function settingsOfPicks(q) {
42
+ const schedule = !q.repeat ? 'off' : { cadence: q.cadence, ...(q.cadence === 'weekly' || q.cadence === 'bi-weekly' ? { day: q.day || 'Mon' } : {}), ...(q.cadence === 'monthly' ? { dayOfMonth: +q.dayOfMonth || 1 } : {}), time: q.time || '09:00' };
43
+ return { output: q.output, audience: String(q.audience || '').replace(/\s+/g, ' ').trim(), schedule };
44
+ }
45
+ const schedKey = (s) => JSON.stringify(!s || s === 'off' ? 'off' : [s.cadence, s.day || null, s.dayOfMonth || null, s.time || '09:00']);
46
+ /** What differs from the current template's settings. */
47
+ export function changedOf(q, base) {
48
+ if (!base) return [];
49
+ const now = settingsOfPicks(q), out = [];
50
+ if (now.output !== base.output) out.push('output');
51
+ if (now.audience !== (base.audience || '')) out.push('audience');
52
+ if (schedKey(now.schedule) !== schedKey(base.schedule)) out.push('schedule');
53
+ return out;
54
+ }
55
+ /** What changed, in words: ["Format: Slides → Document", …]. base is a template version's settings. */
56
+ export function diffOf(q, base) {
57
+ if (!base) return [];
58
+ const now = settingsOfPicks(q), was = picksOfSettings(base), out = [], fmt = (k) => (FORMAT_NAMES[k] || [k || 'none'])[0];
59
+ for (const c of changedOf(q, base)) {
60
+ if (c === 'output') out.push('Format: ' + fmt(base.output) + ' → ' + fmt(now.output));
61
+ if (c === 'audience') out.push('Readers: ' + (base.audience || 'none') + ' → ' + (now.audience || 'none'));
62
+ if (c === 'schedule') out.push('Goes out: ' + goesWords(was) + ' → ' + goesWords(q));
63
+ }
64
+ return out;
65
+ }
66
+ /** When it goes out, in words. */
67
+ export function goesWords(q) {
68
+ if (!q.repeat) return 'Once';
69
+ const c = (CADENCES.find((x) => x[0] === q.cadence) || CADENCES[0])[1];
70
+ return c + (q.cadence === 'weekly' || q.cadence === 'bi-weekly' ? ', ' + (q.day || 'Mon') : q.cadence === 'monthly' ? ', day ' + (q.dayOfMonth || 1) : '') + ' ' + (q.time || '09:00');
71
+ }
72
+
73
+ const tag = (t, k) => `<span class="rf-tag"${k ? ` data-k="${k}"` : ''}>${esc(t)}</span>`;
74
+ function formatHtml(q, ch, a) {
75
+ const keys = ['google-slides', 'google-doc'].concat(q.output && !['google-slides', 'google-doc'].includes(q.output) ? [q.output] : []);
76
+ const rows = keys.map((k) => {
77
+ const [name, what] = FORMAT_NAMES[k] || [k, ''];
78
+ const on = q.output === k;
79
+ return `<button type="button" class="rf-opt vz-hv" role="radio" aria-checked="${on}" ${a}="fmt|${esc(k)}"><span class="vz-ring"></span><span class="rf-ot"><b>${esc(name)}</b>`
80
+ + `${on && q.pick && q.pick.output === k ? tag('my pick') : ''}${on && ch.includes('output') ? tag('changed', 'ch') : ''}<span>${esc(what)}</span></span></button>`;
81
+ }).join('');
82
+ return `<fieldset class="rf-q"><legend>Format</legend><div role="radiogroup" aria-label="Format">${rows}</div><p class="vz-note">PDF, PowerPoint, Word and Excel are all in Download, whichever you pick.</p></fieldset>`;
83
+ }
84
+ function readersHtml(q, ch, a, o) {
85
+ return `<fieldset class="rf-q"><legend>Readers${ch.includes('audience') ? ' ' + tag('changed', 'ch') : ''}</legend><label class="rf-in"><span class="rf-sr">Who the report is written for</span>`
86
+ + `<input type="text" maxlength="120" value="${esc(q.audience)}" ${a}="aud" placeholder="Who reads it"></label>`
87
+ + `<p class="vz-note">Who the report is written for. Nothing is sent to them: after you issue it, you share it yourself.${o.template ? ' Changing readers makes a different template.' : ''}</p></fieldset>`;
88
+ }
89
+ function goesHtml(q, ch, a) {
90
+ const opt = (v, label) => `<button type="button" class="rf-seg vz-hv" role="radio" aria-checked="${q.repeat === v}" ${a}="rep|${v ? 1 : 0}">${esc(label)}</button>`;
91
+ const sel = (key, list, cur, label) => `<label class="rf-sel"><span class="rf-sr">${esc(label)}</span><select ${a}="${key}">${list.map(([v, t]) => `<option value="${esc(v)}"${String(v) === String(cur) ? ' selected' : ''}>${esc(t)}</option>`).join('')}</select></label>`;
92
+ const more = q.repeat ? `<div class="rf-row">${sel('cad', CADENCES, q.cadence, 'How often')}`
93
+ + (q.cadence === 'weekly' || q.cadence === 'bi-weekly' ? sel('day', DAYS.map((d) => [d, d]), q.day, 'Day') : '')
94
+ + (q.cadence === 'monthly' ? sel('dom', Array.from({ length: 28 }, (_, i) => [i + 1, 'Day ' + (i + 1)]), q.dayOfMonth, 'Day of the month') : '')
95
+ + sel('time', TIMES.concat(TIMES.includes(q.time) ? [] : [q.time]).sort().map((t) => [t, t]), q.time, 'Time') + '</div>' : '';
96
+ return `<fieldset class="rf-q"><legend>Goes out${ch.includes('schedule') ? ' ' + tag('changed', 'ch') : ''}</legend><div class="rf-row" role="radiogroup" aria-label="Goes out">${opt(false, 'Once')}${opt(true, 'Repeats')}</div>${more}`
97
+ + `<p class="vz-note">${q.repeat ? 'Claude drafts each cycle on its day. ' : ''}You approve each issue; nothing goes out by itself.</p></fieldset>`;
98
+ }
99
+ function lookHtml(o) {
100
+ const words = o.look ? `<p class="vz-note">Your words: “${esc(o.look)}”. Claude makes this look after the first draft; until then it uses the standard look.</p>` : '';
101
+ return `<fieldset class="rf-q"><legend>Look</legend><p class="rf-fix"><b>Standard PMOS look</b><span>Nunito, navy title slides, 16:9</span></p>${words}</fieldset>`;
102
+ }
103
+ function sourcesHtml(o) {
104
+ const L = (o.sources || []).filter(Boolean);
105
+ if (!L.length) return '';
106
+ return `<fieldset class="rf-q"><legend>Sources</legend><ul class="rf-src">${L.map((x) => `<li>${esc(x)}</li>`).join('')}</ul><p class="vz-note">Claude reads these for the draft. Each slide names what it read, and what it could not reach.</p></fieldset>`;
107
+ }
108
+ /** Template history (RfH3): newest first; each one that is not the current one has Go back. */
109
+ export function historyHtml(versions = [], a = 'data-rt', o = {}) {
110
+ if (!versions.length) return '';
111
+ const day = (iso) => { const d = new Date(iso || ''); return Number.isFinite(d.getTime()) ? d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }) : ''; };
112
+ const pend = o.pending ? `<li class="rf-hv" data-k="new"><b>T${(versions[0] ? versions[0].n : 0) + 1}</b><span>${esc(o.pending)}<em>Unsaved · waits for Make a different template</em></span></li>` : '';
113
+ const rows = versions.map((v) => `<li class="rf-hv"${v.current ? ' aria-current="true"' : ''}><b>T${v.n}</b><span>${esc(v.why || v.words || '')}<em>${esc([day(v.at), v.current ? 'current' : '', v.cycles ? v.cycles + (v.cycles === 1 ? ' cycle issued' : ' cycles issued') : ''].filter(Boolean).join(' · '))}</em></span>`
114
+ + (v.current ? '' : `<button type="button" class="rf-ib vz-hv" ${a}="restore|${v.n}" aria-label="Go back to T${v.n}" title="Go back to T${v.n}"${o.busy ? ' disabled' : ''}>${SV(ICON.back)}</button>`) + '</li>').join('');
115
+ return `<section class="rf-hist"><h3>Template history</h3><ol>${pend}${rows}</ol><p class="vz-note">Going back makes that version the current one. Nothing is deleted.</p></section>`;
116
+ }
117
+ /**
118
+ * The questions. q = picksOf(…) as the PM changed it. o = { template?: { base, versions, diff }, look, sources, busy, msg }.
119
+ * A new report ends with "Nothing goes out" and Draft it; a template ends with its history and Keep the current template | Make a different template.
120
+ */
121
+ export function questionsHtml(q, o = {}, a = 'data-rt') {
122
+ const T = o.template, ch = T ? changedOf(q, T.base) : [];
123
+ const st = T ? (ch.length ? 'Template · changed, not saved yet' : 'Template · T' + (T.current || 1)) : 'Waits on your answers';
124
+ const head = `<p class="rf-st"><i class="rf-dot" data-k="you" aria-hidden="true"></i>${esc(st)}</p>`;
125
+ const body = formatHtml(q, ch, a) + readersHtml(q, ch, a, o) + goesHtml(q, ch, a) + lookHtml(o) + (T ? '' : sourcesHtml(o));
126
+ const msg = o.msg ? `<p class="vz-msg" role="status">${esc(o.msg)}</p>` : '';
127
+ if (!T) {
128
+ return `<div class="rf-qs">${head}${body}${msg}<div class="rf-foot"><span class="vz-note">Nothing goes out</span><button type="button" class="rf-ib pri vz-hv" ${a}="draftit" aria-label="Draft it" title="Draft it"${o.busy || !q.audience.trim() ? ' disabled' : ''}>${SV(ICON.go, 18)}</button></div></div>`;
129
+ }
130
+ const words = ch.length ? T.diff : [];
131
+ const note = words.length ? `<p class="rf-chg">${tag('changed', 'ch')} ${esc(words.join('; '))}. This makes a different template. The current one keeps its draft and its cycles.</p>` : '';
132
+ return `<div class="rf-qs">${head}${body}${note}${historyHtml(T.versions, a, { pending: words.length ? words.join('; ') : '', busy: o.busy })}${msg}`
133
+ + `<div class="rf-foot"><button type="button" class="rf-ib vz-hv" ${a}="keep" aria-label="Keep the current template" title="Keep the current template">${SV(ICON.back)}</button>`
134
+ + `<button type="button" class="rf-ib pri vz-hv" ${a}="maketpl" aria-label="Make a different template" title="Make a different template"${o.busy || !words.length || !q.audience.trim() ? ' disabled' : ''}>${SV(ICON.check, 18)}</button></div></div>`;
135
+ }
136
+
137
+ /** The current state while no cycle is written yet (RfH1): drafting in the report's own session, a session that ended, or no draft. */
138
+ export function waitHtml(F = {}, face = '') {
139
+ const d = F.drafting;
140
+ if (d && d.state === 'held') return `<div class="rf-wait">${face}<p><b>The draft waits for a check of ${esc((d.sources || []).join(', '))}.</b><span>It starts by itself when the check passes.</span></p></div>`;
141
+ if (d && d.state === 'ended') return `<div class="rf-wait" data-k="bad">${face}<p><b>The drafting session ended before a draft was written.</b><span>${esc(d.reason || '')}</span></p><button type="button" class="rf-ib pri vz-hv" data-rt="redraft" aria-label="Draft it again" title="Draft it again">${SV(ICON.go)}</button></div>`;
142
+ if ((d && d.state === 'drafting') || (F.session && F.session.alive)) return `<div class="rf-wait" role="status">${face}<p><b>The report's own session is drafting it.</b><span>It opens here when it lands. Keep talking to Claude in the chat.</span></p></div>`;
143
+ return `<div class="rf-wait">${face}<p><b>No draft yet.</b><span>Draft it now, or it drafts on its day.</span></p><button type="button" class="rf-ib pri vz-hv" data-rt="redraft" aria-label="Draft it now" title="Draft it now">${SV(ICON.go)}</button></div>`;
144
+ }
145
+
146
+ /**
147
+ * Claude's review of a draft (RfH2), in the proposal pattern. rv = { fix: [{ id, title, why }], passed: [label] } from GET /api/report-flow/review.
148
+ * o = { hidden: Set of fix ids (Not now), face (the M face html), busy, passed: ids already passed to the session }.
149
+ */
150
+ export function reviewHtml(rv, o = {}, a = 'data-r') {
151
+ if (!rv) return '';
152
+ const hid = o.hidden || new Set(), sent = o.sent || new Set();
153
+ const L = (rv.fix || []).filter((f) => !hid.has(f.id));
154
+ const n = L.filter((f) => !sent.has(f.id)).length;
155
+ const line = n ? `I read it as your readers would. ${n === 1 ? 'One thing' : n + ' things'} to fix.` : (rv.fix || []).length ? 'Your changes are with the report\'s session.' : 'I read it as your readers would. Nothing to fix.';
156
+ const all = n > 1 ? `<button type="button" class="rf-ib pri vz-hv" ${a}="rv-all" aria-label="Do all ${n}" title="Do all ${n}"${o.busy ? ' disabled' : ''}>${SV(ICON.go)}</button>` : '';
157
+ const rows = L.map((f) => `<div class="rf-fx"><span class="rf-star" aria-hidden="true">✦</span><span class="rf-fxt"><b>${esc(f.title)}</b><span>${esc(f.why || '')}</span></span>`
158
+ + (sent.has(f.id) ? '<span class="rf-tag">passed to the report\'s session</span>'
159
+ : `<button type="button" class="rf-ib vz-hv" ${a}="rv-no|${esc(f.id)}" aria-label="Not now" title="Not now">${SV(ICON.x)}</button><button type="button" class="rf-ib pri vz-hv" ${a}="rv-do|${esc(f.id)}" aria-label="Do it" title="Do it"${o.busy ? ' disabled' : ''}>${SV(ICON.go)}</button>`) + '</div>').join('');
160
+ const P = rv.passed || [];
161
+ const pass = P.length ? `<p class="rf-pass"><b>${P.length} other ${P.length === 1 ? 'check' : 'checks'} found nothing</b><span>${esc(P.join(' · '))}</span></p>` : '';
162
+ return `<section class="rf-rv" aria-label="Claude's review"><div class="rf-rvh">${o.face || ''}<b>${esc(line)}</b>${all}</div>${rows}${pass}</section>`;
163
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "_comment": "Batch 22 item 14: the report building flow (A+ on Home). The backend (template versions, review, the report's own session, goal points at Issued) and the page parts, in node.",
3
+ "modules": [
4
+ "report-flow.test.js",
5
+ "report-flow-page.test.mjs"
6
+ ],
7
+ "seconds": {
8
+ "report-flow.test.js": 3,
9
+ "report-flow-page.test.mjs": 1
10
+ }
11
+ }