create-pmos 0.478.0 → 0.480.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.
Files changed (40) hide show
  1. package/package.json +26 -27
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-initiative-test.js +1 -1
  7. package/workspace/changelog.json +25 -0
  8. package/workspace/guide/briefing-premium.md +3 -2
  9. package/workspace/guide/home.md +2 -1
  10. package/workspace/guide/programs.md +15 -5
  11. package/workspace/lib/board-pack-route.js +10 -1
  12. package/workspace/lib/board-pack.js +31 -2
  13. package/workspace/lib/briefing-premium-products.js +5 -2
  14. package/workspace/lib/briefing-premium.js +5 -3
  15. package/workspace/lib/ready-reports.js +31 -6
  16. package/workspace/lib/report-chat.js +7 -4
  17. package/workspace/lib/report-draft.js +14 -5
  18. package/workspace/lib/report-structure.js +35 -1
  19. package/workspace/lib/routes-report-setups.js +24 -4
  20. package/workspace/metric-drafts-ui-test.js +2 -1
  21. package/workspace/milestone-suggest-test.js +12 -6
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/program-charter-test.js +5 -5
  25. package/workspace/program-panel-test.js +28 -25
  26. package/workspace/public/pm/bd-prog-panel.js +84 -60
  27. package/workspace/public/pm/chat-md.js +5 -2
  28. package/workspace/public/pm/cozy-home.css +3 -0
  29. package/workspace/public/pm/dash-view.js +9 -5
  30. package/workspace/public/pm/goal-chat.js +3 -1
  31. package/workspace/public/pm/home-app.js +53 -21
  32. package/workspace/public/pm/home-chat.js +2 -2
  33. package/workspace/public/pm/premium-report-read.js +8 -1
  34. package/workspace/public/pm/premium-report-tab.js +34 -20
  35. package/workspace/public/pm/premium.css +1 -0
  36. package/workspace/public/pm/prog-page.css +76 -0
  37. package/workspace/public/pm/prog-page.js +112 -0
  38. package/workspace/public/pm/readonly.js +8 -1
  39. package/workspace/public/pm/report-chat.js +14 -3
  40. package/workspace/ready-dash-ui-test.js +53 -73
@@ -9,25 +9,21 @@
9
9
  * The panel opens on document `bd:program` { id, from? }. A program row of the Board ([data-prog]) and ?program=<id> (Home links there) send
10
10
  * that event through pm/bd-prog.js openProgram, the one path that opens it.
11
11
  *
12
- * What it shows, each part only when a record holds something for it:
13
- * · the shell's header: the program icon, "title · goal" once, Discuss in chat (the question goes to Home), the Dashboard toggle, ⋯ and Close. ⋯
14
- * holds, in the shell's order: add an initiative, move one in, copy link, copy as text, and archive (red, last, with a confirmation)
15
- * · the charter (pm/program-charter.js, canvas MsB*): the one editor of the program's fields and milestones. Ways in: the pencil on the
16
- * Milestones row (and on the Dashboard's Milestones block), and "Add the first milestone" where the track would be. Its header icon gave
17
- * its place to the Dashboard toggle (batch 17 item 1, PbH1Header: two icons left the title 66 px at 390 px)
18
- * · the Dashboard (pm/dash-view.js, GET /api/ready-reports/dashboard scope program:<id>): one toggle icon, a gauge from Work and a list from
19
- * the Dashboard. The PM's last choice per program wins; with none, the Dashboard opens when they came to read (?view=dashboard: a
20
- * report, Intelligence, a notification) and Work when they came to act (a Board row). No toggle until the dashboard is read
21
- * · Claude's milestone suggestions (pm/ms-suggest.js, canvas XmsgB): with no milestone yet, they take the place of "Add the first milestone";
22
- * later changes lead Waits on you. ✓ keeps one (the charter is written at once), the pencil opens the charter with it filled in, ✕ drops it
23
- * · the summary card: the next milestone, else what waits on you; the owner and the span; one primary, "Review the suggested homes", only
24
- * after Turn into a program while tasks of the initiative it came from have no level yet; Claude sorts them in Home
25
- * · the goals: the KRs its initiatives anchor to, for one year half with a period picker; the earlier halves fold into one chip
26
- * · the milestone track: 3 milestones, the earlier done ones in a done cluster and the later ones in "N more"; both open Milestones
27
- * · the folding rows (were tabs): Waits on you · On the program (its tasks, Done folded) · On its initiatives and On their epics (every
28
- * open task, by level; each opens in Home) · Initiatives (per product, with their first tasks, what waits on you and their epics) · Milestones (Done, Next, Later; a program check's diamond marks it) · Documents (the charter, the PRDs, …)
29
- * · first, the goal Claude drafted (pm/metric-drafts.js, canvas Iq9Program): the dashed "✦ Proposed goal" card, and once kept its Goal
30
- * row with Undo; nothing when nothing is drafted (GET /api/metric-drafts, scope program)
12
+ * What it shows: ONE page (feedback batch 21 item 2, canvas RdProgL–RdProgP; pm/prog-page.js lays it out). It replaced the batch 17 Work |
13
+ * Dashboard pair, so the header has no toggle. Each part draws only when a record holds something for it:
14
+ * · the shell's header: the program icon, "title · goal" once, Discuss in chat (the question goes to Home), ⋯ and Close. ⋯ holds, in the
15
+ * shell's order: add an initiative, move one in, add a task, copy link, copy as text, and archive (red, last, with a confirmation)
16
+ * · the ✦ line: the next milestone in bold, then how many things wait on you; on a teammate's shared copy, who shared it and when (RdProgO)
17
+ * · the goal card: the goals of GET /api/ready-reports/dashboard (scope program:<id>) by their SHORT title (lib/ready-reports.js shortTitle)
18
+ * with the KR chip and Forecast's range bar; with none, the goal Claude drafted (pm/metric-drafts.js, the dashed "✦ Proposed goal"), else
19
+ * the KRs its initiatives anchor to. The milestones sit inside it, once: the track (3, with done and "N more" clusters that open every
20
+ * milestone in the card), Claude's first suggestions (pm/ms-suggest.js) or "Add the first milestone"
21
+ * · one folded row "N proposals wait on you": Claude's milestone changes and its other proposals. The owner only; never on a shared copy
22
+ * · four tabs, Initiatives first (Wawan 2026-11-01): Tasks (amber dot when one is late: late first, then Where the work sits: On the program,
23
+ * On its initiatives, On their epics) · Initiatives (per product, each with its first tasks, what waits on you and its epics) · Reports (the
24
+ * ready-made reports, blue dot when one is ready) · Documents (the charter, the PRDs, …). The viewer's last tab per program is kept in this browser
25
+ * · the charter (pm/program-charter.js, canvas MsB*): the one editor of the program's fields and milestones; ways in are the Milestones pencil
26
+ * and "Add the first milestone"
31
27
  * An initiative in another product is read from that product's board (GET /api/board-premium?ws=). Per product the panel also reads, once per
32
28
  * page load: its KRs' names (GET /api/boards/anchors, the OKR files), whether each KR is met (GET /api/insights-premium, the goals Insights
33
29
  * shows) and its PMOS tasks (GET /api/boards/items). A part whose read failed is left out, never guessed. Every fold is kept in this browser. */
@@ -42,7 +38,8 @@ import { programRename } from './rename-press.js';
42
38
  import { openCharter as charterForm, renamed as charterRenamed } from './program-charter.js';
43
39
  import * as MSG from './ms-suggest.js';
44
40
  import * as MD from './metric-drafts.js'; // the goal Claude drafts when the charter has none (batch 15 item 1, canvas Iq9Program)
45
- import * as DB from './dash-view.js'; // the ready-made Dashboard view (batch 17 item 1, canvas PbH1Header, PbA2, PbA7, PbG3, PbG7, PbG10)
41
+ import * as DB from './dash-view.js'; // the page model's parts: the reports and the proposals (batch 17 item 1)
42
+ import * as PV from './prog-page.js'; // the one program page: the top and four tabs (batch 21 item 2, canvas RdProgL–RdProgP)
46
43
 
47
44
  const SV = (d, w) => `<svg viewBox="0 0 24 24" width="${w || 18}" height="${w || 18}" aria-hidden="true"><path d="${d}"/></svg>`;
48
45
  const I = {
@@ -61,7 +58,7 @@ let O = null; // mount's options
61
58
  let cur = null; // { id, from } the program shown and the element it was opened from
62
59
  let period = null; // the year half the goals show (null: the current one)
63
60
  let adding = false; // the add-a-task line of "On the program" is open
64
- const DASH = new Map(); // program id → { view: 'dash' | 'work', d: the dashboard | null, read: bool, open: Set of folds }
61
+ const DASH = new Map(); // program id → { d: the page model | null, read: bool, open: Set of folds }
65
62
  const fold = new Set((() => { try { return JSON.parse(store.get(FOLD_KEY) || '[]'); } catch { return []; } })());
66
63
  const keepFold = () => store.set(FOLD_KEY, JSON.stringify([...fold].slice(-200)));
67
64
  const AWAY = new Map(); // the boards of the other products: ws → { name, board, rows } | 'reading'
@@ -193,7 +190,9 @@ function trackHtml(st, p) {
193
190
  const f = T.shown.length && lastDone === T.shown.length - 1 ? lastDone + 0.5 : lastDone >= 0 ? lastDone + 1 : T.done.length ? 0 : -1;
194
191
  const cl = (L, done) => (L.length ? `<button type="button" class="pp-cap${done ? ' dn' : ''}" data-pp="ms" aria-label="${L.length} ${done ? 'earlier ' + plural(L.length, 'milestone', 'milestones') + ', done' : 'later ' + plural(L.length, 'milestone', 'milestones')}. Show all milestones"><span class="st3" aria-hidden="true">${L.slice(0, 3).map(() => '<i></i>').join('')}</span>${L.length} ${done ? 'done' : 'more'}</button>` : '<span></span>');
195
192
  const one = (m) => `<div class="pp-m${m.late || m.risk ? ' late' : ''}" title="${esc(waitsLine(m))}${m.check ? '' : ' reaching ' + (m.reach || 'its ◆ stage')}${m.risk ? '. At risk: ' + esc(m.risk) : ''}"><span class="pp-dm${m.done ? ' d' : st.next && m.id === st.next.id ? ' n' : ''}" aria-hidden="true"></span><b>${esc(m.name)}</b><span class="pp-md">${esc(m.day)}${m.done ? '' : rdHtml(m)}</span></div>`;
196
- return `<div class="pp-sec"><p class="lbl">Program milestones</p><div class="pp-mt" style="--pp-n:${n};--pp-f:${f}"${f < 0 ? ' data-nofill' : ''}>${cl(T.done, true)}${T.shown.map(one).join('')}${cl(T.more, false)}</div></div>`;
193
+ // the pencil into the charter, at Milestones (kept from the Milestones row when the page became one page)
194
+ const pen = RO ? '' : `<button type="button" class="cz-vw-ib pp-pen" data-pp="edit" aria-label="Edit the milestones in the charter" title="Edit in the charter">${SV(I.pen, 15)}</button>`;
195
+ return `<div class="pp-sec"><div class="pp-lh"><p class="lbl">Program milestones</p>${pen}</div><div class="pp-mt" style="--pp-n:${n};--pp-f:${f}"${f < 0 ? ' data-nofill' : ''}>${cl(T.done, true)}${T.shown.map(one).join('')}${cl(T.more, false)}</div></div>`;
197
196
  }
198
197
  /** What waits on you in the program: your open program tasks, then each initiative's next action that is yours. Each opens in Home. */
199
198
  function needs(p, st) {
@@ -337,24 +336,64 @@ function needsList(p, st) {
337
336
  const L = needs(p, st);
338
337
  return L.map((x) => `<a class="pp-nr" href="${esc(x.href)}" aria-label="${x.task ? 'Task' : 'Waits on you'}: ${esc(x.title)}. Opens in Home"><span class="mk2">${x.task ? `<span class="pp-ck${x.late ? ' late' : ''}"></span>` : '<span class="pp-dt"></span>'}</span><span class="t"><b>${esc(x.title)}</b><span>${esc(x.sub)}</span></span><span class="go">${SV(I.out, 14)}</span></a>`).join('');
339
338
  }
340
- function bodyHtml(p) {
341
- const st = programState(p, rowsOf), N = needs(p, st), D = docsOf(st), T = iniTasks(st), C = changesOf(p, st);
342
- facts(p, st);
339
+ /* ── the one page (batch 21 item 2, RdProgL–RdProgP): the top, then four tabs; it replaced the Work | Dashboard pair ── */
340
+ const RO = typeof window !== 'undefined' && !!window.PMOS_READONLY; // a teammate's read-only copy (pm/readonly-boot.js): no proposals, no presses that write
341
+ const dayOfPack = (iso) => { const d = dayOf(iso); return d ? d.getDate() + ' ' + ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][d.getMonth()] : ''; };
342
+ /** The ✦ line: the next step in bold, then what waits on the owner; on a shared copy, who shared it and when (RdProgO). */
343
+ function lineOf(p, st, n, d) {
344
+ const s = summaryOf(p, st), lead = s.line ? s.line.replace(' · ', ', ') + '.' : d && d.handled && d.handled.lead ? d.handled.lead : '';
345
+ if (RO) { const k = window.PMOS_READONLY || {}; return { lead, rest: [k.by ? 'Shared by ' + k.by + (k.at ? ', a snapshot from ' + dayOfPack(k.at) : '') + '.' : '', k.ends ? 'Ends ' + dayOfPack(k.ends) + '.' : ''].filter(Boolean).join(' ') }; }
346
+ const rest = n ? (n === 1 ? 'One thing waits on you. It is one press.' : n + ' things wait on you. Each is one press.') : d && d.handled ? [s.line ? d.handled.lead : '', d.handled.rest].filter(Boolean).join(' ') : '';
347
+ return { lead, rest, warn: s.tone === 'warn' || !!(d && d.handled && d.handled.tone === 'warn' && !s.line) };
348
+ }
349
+ const LATE_SHOWN = 3; // Tasks: the late ones first, 3 shown (RdProgM)
350
+ function tasksTab(p, st, N, T) {
343
351
  const L = T.filter((t) => t.level === 'initiative'), E = T.filter((t) => t.level === 'epic');
352
+ const late = st.openTasks.filter((t) => { const d = daysTo(t.due); return d != null && d < 0; }).map((t) => ({ prog: true, t }))
353
+ .concat(T.filter((t) => { const d = daysTo(t.due); return d != null && d < 0; }).map((t) => ({ prog: false, t })));
354
+ const more = late.length - LATE_SHOWN;
355
+ const lateCard = late.length ? `<section class="pv-card" aria-label="Late"><div class="pv-ch"><h4>Late first</h4><small>${more > 0 ? LATE_SHOWN + ' shown · ' + more + ' more below' : ''}</small></div>`
356
+ + `<div class="pp-tree" role="tree" aria-label="Late tasks">${late.slice(0, LATE_SHOWN).map((x) => (x.prog ? taskRow(p, x.t) : iniTaskRow(p, x.t, x.t.level === 'epic' ? [x.t.epic, x.t.ini.title].filter(Boolean).join(' · ') : x.t.ini.title))).join('')}</div></section>` : '';
357
+ const yours = !RO && N.length ? `<section class="pv-card" aria-label="Waits on you"><div class="pv-ch"><h4>Waits on you</h4></div><div class="pp-needs" role="group" aria-label="Waits on you">${needsList(p, st)}</div></section>` : '';
344
358
  const rows = [
345
- N.length || C.length ? { id: 'needs', title: 'Waits on you', count: N.length + C.length, open: true, render: () => `<div class="pp-needs" role="group" aria-label="Waits on you">${MSG.rowsHtml(p, C)}${needsList(p, st)}</div>` } : null,
346
359
  { id: 'tasks', title: 'On the program', count: st.openTasks.length, open: adding, render: () => tasksHtml(p, st) },
347
- // every open task of its initiatives, by level (PgProgram "Tasks"): on the initiative itself, then on their epics
348
360
  L.length ? { id: 'itasks', title: 'On its initiatives', count: L.length, render: () => levelHtml(p, L, 'Tasks on its initiatives') } : null,
349
361
  E.length ? { id: 'etasks', title: 'On their epics', count: E.length, render: () => levelHtml(p, E, 'Tasks on their epics') } : null,
350
- st.inis.length || st.missing.length ? { id: 'tree', title: 'Initiatives', count: st.inis.length + st.missing.length, open: true, render: () => treeHtml(p, st) } : null,
351
- st.milestones.length ? { id: 'ms', title: 'Milestones', count: st.milestones.length, render: () => msHtml(st),
352
- tail: `<button type="button" class="cz-vw-ib" data-pp="edit" aria-label="Edit the milestones in the charter" title="Edit in the charter">${SV(I.pen, 15)}</button>` } : null,
353
- { id: 'docs', title: 'Documents', count: D.length + 1, render: () => docsHtml(p, st) },
354
362
  ];
355
- // Home on a phone (O.talk gives a function): the program's own chat is not beside the panel, so the panel ends with the way to it
356
- const talk = O && O.talk && O.talk() ? `<button type="button" class="hi-talk" data-pp="talk">Message Claude about ${esc(p.title)}</button>` : '';
357
- return MD.progHtml(p, p.home || board().ws || '') + VW.czSummary(summaryOf(p, st)) + goalsHtml(st) + trackHtml(st, p) + VW.czSections(rows, { key: 'program' }) + talk;
363
+ return yours + lateCard + `<section class="pv-card" aria-label="Where the work sits"><div class="pv-ch"><h4>Where the work sits</h4></div>${VW.czSections(rows, { key: 'program' })}</section>`;
364
+ }
365
+ function reportsTab(d, x) {
366
+ const R = d ? DB.reportsHtml(d, { open: x.open }) : '';
367
+ if (!R) return `<section class="pv-card" aria-label="Reports"><div class="pv-ch"><h4>Reports</h4></div><p class="pv-none">${d ? 'Claude writes these for you. One shows here when it is due.' : 'The reports could not be read.'}</p></section>`;
368
+ return `<div class="db" data-level="program">${RO ? '' : DB.trustHtml(d)}${R}</div>`;
369
+ }
370
+ /** The program's one page. Each part draws only when a record holds something for it. */
371
+ function viewHtml(p) {
372
+ const st = programState(p, rowsOf), x = dashOf(p.id), d = x.d;
373
+ if (!RO) facts(p, st);
374
+ const N = RO ? [] : needs(p, st), C = RO ? [] : changesOf(p, st), D = docsOf(st), T = iniTasks(st);
375
+ // the proposals that wait on the owner: Claude's milestone changes, then its other proposals on the program (GET /api/proposals through the page)
376
+ const dn = RO || !d ? 0 : d.needsN || (d.needs ? 1 : 0), n = C.length + dn;
377
+ const first = C.length ? MSG.words(p, C[0]).title : d && d.needs ? d.needs.q : '';
378
+ const props = n ? { n, sub: first + (n > 1 ? ' and ' + (n - 1) + ' more' : ''), html: MSG.rowsHtml(p, C) + (dn && d.needs ? DB.needsHtml(d) : '') } : null;
379
+ // the goal card: the dashboard's goals with their short titles, else the goal Claude drafted, else the KRs its initiatives anchor to; the milestones inside
380
+ const G = (d && d.goals) || [], mk = 'msall:' + p.id;
381
+ const inner = trackHtml(st, p) + (st.milestones.length && fold.has(mk) ? msHtml(st) : '');
382
+ const goal = PV.goalCard({ goals: G, proposed: G.length ? '' : MD.progHtml(p, p.home || board().ws || '') || goalsHtml(st), inner, shared: RO, open: x.open });
383
+ const late = st.openTasks.concat(T).some((t) => { const dd = daysTo(t.due); return dd != null && dd < 0; });
384
+ const reps = ((d && d.reports) || []).filter((r) => r.kind !== 'heads-up');
385
+ const tabs = [
386
+ { id: 'tasks', label: 'Tasks', n: st.openTasks.length + T.length, sig: late ? 'late' : '', html: () => tasksTab(p, st, N, T) },
387
+ { id: 'initiatives', label: 'Initiatives', n: st.inis.length + st.missing.length, html: () => treeHtml(p, st) || '<p class="pv-none">No initiative in it yet. Move one in from its own menu.</p>' },
388
+ { id: 'reports', label: 'Reports', n: reps.length, sig: reps.some((r) => r.state === 'drafted') ? 'ready' : '', html: () => reportsTab(d, x) },
389
+ { id: 'documents', label: 'Documents', n: D.length + 1, html: () => docsHtml(p, st) },
390
+ ];
391
+ // Home on a phone (O.talk gives a function): the program's own chat is not beside the panel, so the page ends with the way to it
392
+ const talk = !RO && O && O.talk && O.talk() ? `<button type="button" class="hi-talk" data-pp="talk">Message Claude about ${esc(p.title)}</button>` : '';
393
+ // after Turn into a program: the tasks from before the split that have no level yet, and the way to Claude's suggested homes (kept from the summary card)
394
+ const s = RO ? null : summaryOf(p, st);
395
+ const sort = s && s.primary ? `<section class="pv-card" aria-label="Tasks with no level"><p class="czs-p">${esc(s.text)}</p><a class="czs-pri" href="${esc(s.primary.href)}">${esc(s.primary.label)}</a></section>` : '';
396
+ return PV.pageHtml({ page: 'program:' + p.id, line: lineOf(p, st, N.length + n, d), goal, cards: sort, props, tabs, shared: RO, tail: talk });
358
397
  }
359
398
  /** The ◆ dates this page reads for the program's initiatives (a Jira slip moves one too). A change from what the server last heard asks Claude
360
399
  * to review once (POST /api/programs/facts); each reading is sent once per page load. */
@@ -413,29 +452,13 @@ function textOf(p) {
413
452
  return lines.join('\n');
414
453
  }
415
454
  const titleOf = (p) => p.title + (p.goal ? ' · ' + p.goal : '');
416
- /* ── the Dashboard view (batch 17 item 1) ── */
417
- const dashOf = (id) => { if (!DASH.has(id)) DASH.set(id, { view: 'work', d: null, read: false, open: new Set() }); return DASH.get(id); };
418
- const showsDash = (id) => { const x = dashOf(id); return x.view === 'dash' && !!x.d; };
419
- /** The body: the Dashboard when it is chosen and read, else the work. */
420
- function viewHtml(p) {
421
- if (!showsDash(p.id)) return bodyHtml(p);
422
- const x = dashOf(p.id), talk = O && O.talk && O.talk() ? `<button type="button" class="hi-talk" data-pp="talk">Message Claude about ${esc(p.title)}</button>` : '';
423
- return DB.dashHtml(x.d, { open: x.open, mdHtml: MD.progHtml(p, p.home || board().ws || ''), talk });
424
- }
425
- const dashPresses = (id) => { const x = dashOf(id); return x.d ? [DB.togglePress(x.view)] : []; };
426
- /** Reads the program's dashboard (again); the toggle shows once it is read. via: 'read' | 'act', how the PM arrived. */
455
+ /* ── the dashboard model the page reads (GET /api/ready-reports/dashboard scope program:<id>): goals, reports, proposals ── */
456
+ const dashOf = (id) => { if (!DASH.has(id)) DASH.set(id, { d: null, read: false, open: new Set() }); return DASH.get(id); };
457
+ /** Reads the program's page model (again) and draws the page when it lands. via: 'read' | 'act', how the PM arrived. */
427
458
  async function readDash(p, via) {
428
459
  const x = dashOf(p.id);
429
- const d = await DB.readDash(p.home || board().ws || '', 'program:' + p.id, via);
430
- if (!d) { x.d = null; if (x.view === 'dash') x.view = 'work'; } else { const first = !x.read; x.d = d; if (first) x.view = DB.viewOf('program:' + p.id, d.opens); }
431
- x.read = true;
432
- if (cur && cur.id === p.id && shownHere()) { VW.setPresses('program:' + p.id, dashPresses(p.id)); draw(true); }
433
- }
434
- function toggleDash(p) {
435
- const x = dashOf(p.id); if (!x.d) return;
436
- x.view = x.view === 'dash' ? 'work' : 'dash'; DB.keepView('program:' + p.id, x.view);
437
- VW.setPresses('program:' + p.id, dashPresses(p.id)); draw();
438
- const t = document.querySelector('#czViewer [data-cz-vw-p="dash"]'); if (t) t.focus();
460
+ x.d = await DB.readDash(p.home || board().ws || '', 'program:' + p.id, via); x.read = true;
461
+ if (cur && cur.id === p.id && shownHere()) draw(true);
439
462
  }
440
463
  function openPanel(id, from, via) {
441
464
  if (!O || !O.M() || !progOf(id)) return false;
@@ -451,14 +474,13 @@ function openPanel(id, from, via) {
451
474
  rename.value = p.title;
452
475
  VW.open({ kind: 'Program', title: titleOf(p), icon: I.prog, id: 'program:' + id,
453
476
  discuss: true, more: moreOf(p), rename,
454
- // one Dashboard toggle in the charter's old place (PbH1Header); the charter keeps the Milestones pencil and "Add the first milestone"
455
- presses: dashPresses(id), onPress: (a) => { const q = progOf(id); if (a === 'dash' && q) toggleDash(q); },
456
477
  render: (body) => {
457
478
  { const q = progOf(id); if (q && VW.current() && VW.current().title !== titleOf(q)) VW.retitle('program:' + id, titleOf(q)); } // a rename in the charter, on ←
458
479
  cur = { id, from: from && !(VW.body() && VW.body().contains(from)) ? from : (cur && cur.id === id && cur.from) || null };
459
480
  body.classList.add('pp-vw');
460
481
  const q = progOf(id); if (q) { readAway(q); readMore(q); readDrafts(q); body.innerHTML = viewHtml(q); }
461
- if (!body.dataset.dbWired) { // the Dashboard's own presses, once per body (pm/dash-view.js)
482
+ PV.wirePage(body, { redraw: () => draw(true) }); // the tabs and the proposals fold (pm/prog-page.js)
483
+ if (!body.dataset.dbWired) { // the reports' and the goals' presses, once per body (pm/dash-view.js)
462
484
  body.dataset.dbWired = '1';
463
485
  DB.wireDash(body, { d: () => cur && dashOf(cur.id).d, get open() { return cur ? dashOf(cur.id).open : new Set(); }, ws: (progOf(id) || {}).home || board().ws || '', board: board().id || '',
464
486
  toast: (t) => O.say(t), redraw: () => draw(true), reload: async () => { const q2 = cur && progOf(cur.id); if (q2) await readDash(q2); },
@@ -466,7 +488,7 @@ function openPanel(id, from, via) {
466
488
  openReport: (r) => openReport(r, (progOf(id) || {}).home || board().ws || ''),
467
489
  editNeeds: (n) => { if (n && n.ini) { if (O.drill) VW.drill(); else VW.close(); O.openIni(n.ini); } } });
468
490
  }
469
- body.onclick = (e) => { if (cur && showsDash(cur.id) && e.target.closest('[data-db]')) return; const d = e.target.closest('[data-md]'); if (d && body.contains(d) && !d.disabled) { MD.press(d, { redraw: () => draw(), toast: (t) => O.say(t) }); return; } const m = e.target.closest('[data-ms-act]'); if (m && body.contains(m) && !m.disabled) { suggestPress(m); return; } const b = e.target.closest('[data-pp]'); if (b && body.contains(b)) press(b); };
491
+ body.onclick = (e) => { if (e.target.closest('[data-db], [data-pv]')) return; const d = e.target.closest('[data-md]'); if (d && body.contains(d) && !d.disabled) { MD.press(d, { redraw: () => draw(), toast: (t) => O.say(t) }); return; } const m = e.target.closest('[data-ms-act]'); if (m && body.contains(m) && !m.disabled) { suggestPress(m); return; } const b = e.target.closest('[data-pp]'); if (b && body.contains(b)) press(b); };
470
492
  body.onsubmit = submit;
471
493
  document.querySelectorAll('#ibBody [data-prow]').forEach((x) => x.classList.toggle('sel', x.dataset.prow === id));
472
494
  },
@@ -488,7 +510,9 @@ async function press(b) {
488
510
  const a = b.dataset.pp, p = cur && progOf(cur.id); if (!p) return;
489
511
  if (a === 'talk') { const t = O.talk && O.talk(); if (t) t(); return; }
490
512
  if (a === 'fold') setFold(b.dataset.fold);
491
- else if (a === 'ms' || a === 'itasks') showRow(a);
513
+ else if (a === 'ms') setFold('msall:' + p.id); // the track's clusters open every milestone inside the goal card: drawn once (RdProgL)
514
+ else if (a === 'itasks') { PV.keepTab('program:' + p.id, 'tasks'); showRow(a); }
515
+ else if (RO && /^(add|done|check|edit|first|charter)$/.test(a)) O.say('This is a read-only copy.');
492
516
  else if (a === 'period') { O._perOpen = !O._perOpen; draw(true); }
493
517
  else if (a === 'per' || a === 'early') { period = b.dataset.per; O._perOpen = false; draw(); const pb = VW.body() && VW.body().querySelector('[data-pp="period"]'); if (pb) pb.focus(); }
494
518
  else if (a === 'ini') { const id = b.dataset.ini, from = document.querySelector(`#ibBody [data-prog="${CSS.escape(p.id)}"]`); if (O.drill) VW.drill(); else VW.close(); O.openIni(id, from); }
@@ -120,8 +120,11 @@ export const mdHtml = (text) => `<div class="md">${blocks(esc(String(text == nul
120
120
 
121
121
  /** The PM's turn without Claude Code's paste wrapper tags; the pasted words stay. */
122
122
  export const cleanUser = (text) => String(text == null ? '' : text).replace(/<\/?pasted_content\b[^>]*>/gi, '').replace(/\n{3,}/g, '\n\n').trim();
123
- /** The PM's turn as bubble HTML: escaped, line breaks kept. */
124
- export const userHtml = (text) => esc(cleanUser(text)).replace(/\n/g, '<br>');
123
+ /* A line that makes the PM's turn markdown: a heading, a list item, a fence, a quote, a table row, **bold** or `code`. */
124
+ const MD_RE = /^\s*(#{1,6}\s|[-*+]\s|\d+[.)]\s|```|~~~|>|\|.*\|)|\*\*[^*\n]+\*\*|`[^`\n]+`/m;
125
+ /** The PM's turn as bubble HTML. Pasted markdown shows formatted, as Claude's answers do (batch 21 item 1); plain words stay escaped with
126
+ * their line breaks kept. */
127
+ export const userHtml = (text) => { const t = cleanUser(text); return MD_RE.test(t) ? mdHtml(t) : esc(t).replace(/\n/g, '<br>'); };
125
128
 
126
129
  /** A tool's short name: `mcp__claude_ai_Slack__slack_read_thread` and `claude_ai_Slack/slack_read_thread` both read `slack_read_thread`. */
127
130
  export const toolName = (n) => String(n || '').split(/__|\//).filter(Boolean).pop() || String(n || '');
@@ -214,6 +214,9 @@ body.cz-home { min-height: 100vh; overflow: hidden; }
214
214
  .hm-a { display: flex; gap: 10px; align-items: flex-start; }
215
215
  .hm-ab { flex: 1; min-width: 0; font-size: var(--fs-3); line-height: 1.55; color: var(--cz-ink); }
216
216
  .hm-ab .md p { margin: 0 0 6px; }
217
+ .hm-bub .md, .hm-qb .md { max-width: none; color: inherit; line-height: 1.5; }
218
+ .hm-bub .md p, .hm-qb .md p { margin: 0 0 6px; }
219
+ .hm-bub .md pre, .hm-qb .md pre { background: rgba(255,255,255,.6); }
217
220
  .hm-who { margin: 0; font-size: var(--fs-2); font-weight: 700; color: var(--cz-ink); line-height: 1.55; }
218
221
  .hm-who span { font-weight: 400; color: var(--cz-ink3); }
219
222
  .hm-who .hm-say { font-size: var(--fs-3); color: var(--cz-ink); }
@@ -1,4 +1,6 @@
1
- /* pm/dash-view.js — the ready-made Dashboard view of a program, a product or an initiative (batch 17 item 1, design A+; canvas In development,
1
+ /* pm/dash-view.js — the ready-made Dashboard view of an initiative, and the parts the one program and product page reuses (batch 21 item 2,
2
+ * pm/prog-page.js: the program and the product have no toggle any more; reportsHtml and trustHtml draw its Reports tab) — first built as the
3
+ * Dashboard view of a program, a product or an initiative (batch 17 item 1, design A+; canvas In development,
2
4
  * band "Ready-made dashboards and reports": PbH1Header, PbA1–PbA3, PbA5, PbA7, PbS1, PbS2, PbG2, PbG3, PbG6–PbG10).
3
5
  *
4
6
  * The program panel (bd-prog-panel.js), the initiative view (bd-ini-panel.js on the Board, home-ini.js on Home) and the product page (home-app.js)
@@ -51,7 +53,9 @@ export const togglePress = (v) => ({ act: 'dash', label: v === 'dash' ? 'Show th
51
53
 
52
54
  /** GET /api/ready-reports/dashboard. null when the route is missing or refused, so the host never draws a toggle to nothing. */
53
55
  export async function readDash(ws, scope, from) {
54
- const u = '/api/ready-reports/dashboard?' + new URLSearchParams(Object.entries({ ws: ws || '', scope, from: from || '' }).filter(([, v]) => v)).toString();
56
+ // a shared copy (pm/readonly-boot.js) holds the page keyed by ws and scope only (lib/board-pack.js teammateDash): it asks without `from`
57
+ const ro = typeof window !== 'undefined' && !!window.PMOS_READONLY;
58
+ const u = '/api/ready-reports/dashboard?' + new URLSearchParams(Object.entries({ ws: ws || '', scope, from: ro ? '' : from || '' }).filter(([, v]) => v)).toString();
55
59
  try { const r = await fetch(u, { credentials: 'same-origin' }); if (r.status !== 200) return null; const j = await r.json(); return j && j.ok !== false && (j.dashboard || j.scope) ? (j.dashboard || j) : null; } catch { return null; }
56
60
  }
57
61
 
@@ -141,7 +145,7 @@ function stageHtml(d, o = {}) {
141
145
  }
142
146
  const guardHtml = (d) => ((d.guardrails || []).length ? sec('Guardrails', `<div class="db-card db-list">${d.guardrails.map((g) => `<div class="db-row">${dot(g.dot)}<span class="db-rt"><b>${esc(g.title)}</b>${g.sub ? `<small>${esc(g.sub)}</small>` : ''}</span>${who(g.owner)}</div>`).join('')}</div>`) : '');
143
147
  /** Needs you: one decision with Claude's pick (PbA1): ✕ drops it, ✎ opens it to change, ✓ keeps the pick. */
144
- function needsHtml(d) {
148
+ export function needsHtml(d) {
145
149
  const n = d.needs; if (!n || !n.q) return '';
146
150
  return sec('Needs you', `<div class="db-card db-need"><div class="db-nq">${SV(I.flag, 16)}<span class="db-rt"><b>${esc(n.q)}</b>${n.sub ? `<small>${esc(n.sub)}</small>` : ''}${n.pick ? `<span class="db-pick">✦ My pick: ${esc(n.pick)}</span>` : ''}</span></div>`
147
151
  + `<div class="db-acts">${ib('needs', 'Not now', I.x, { k: 'drop', off: !n.drop })}${ib('needs-edit', 'Change it first', I.pen)}${ib('needs', 'Keep my pick' + (n.pick ? ': ' + n.pick : ''), I.chk, { solid: true, k: 'keep', off: !n.keep })}</div></div>`);
@@ -167,7 +171,7 @@ function headsUpHtml(r) {
167
171
  + `<div class="db-chips">${r.audience ? `<span class="db-chip">${SV(I.people, 14)}${esc(r.audience)}</span>` : ''}${r.channel ? `<span class="db-chip">${SV(I.send, 14)}${esc(r.channel)}</span>` : ''}</div>`
168
172
  + `<div class="db-acts">${ib('hold', 'Not now', I.x, { k: rid(r) + '|skip' })}${r.path ? ib('report', 'Change it first', I.pen, { k: rid(r) }) : ''}${ib('send', 'Send the heads-up', I.send, { solid: true, k: rid(r) })}</div></div>`);
169
173
  }
170
- function reportsHtml(d, o) {
174
+ export function reportsHtml(d, o) {
171
175
  const L = (d.reports || []).filter((r) => r.kind !== 'heads-up');
172
176
  const hu = (d.reports || []).filter((r) => r.kind === 'heads-up' && r.state !== 'sent').map(headsUpHtml).join('');
173
177
  if (!L.length) return hu;
@@ -178,7 +182,7 @@ function reportsHtml(d, o) {
178
182
  return hu + sec(d.level === 'product' ? 'This week' : 'Reports', `<div class="db-card db-reps">${lead.map(repRow).join('')}${more}</div>`);
179
183
  }
180
184
  /** Send by itself (PbG6): calm weeks go by themselves by default (Wawan 2026-10-28); the card shows only where the PM had turned it off. */
181
- function trustHtml(d) {
185
+ export function trustHtml(d) {
182
186
  const t = d.trust; if (!t) return '';
183
187
  return `<div class="db-card db-trust"><div class="db-top"><span class="db-rt"><b>Send by itself</b><small>Only weeks where everything is on its line</small></span></div>`
184
188
  + `<div class="db-acts">${ib('trust', 'Not now', I.x, { k: 'off' })}${ib('trust', 'Send it by itself in calm weeks', I.chk, { solid: true, k: 'on' })}</div></div>`;
@@ -49,7 +49,9 @@ function pmSays(t) { let at = -1, m; SAYS_RE.lastIndex = 0; while ((m = SAYS_RE.
49
49
  /** The PM's turn as the PM typed it (G7): `/goal Ship X` for the grilling prompt, a short line for Start and Cancel, and only the PM's
50
50
  * words for the opening message that carries the row's context. Anything else is shown unchanged. */
51
51
  export function shownUser(text) {
52
- const t = String(text == null ? '' : text);
52
+ // a long or multi-line message reaches Claude Code as a paste, so the session records it inside <pasted_content> tags; take them off
53
+ // first, or the PMOS rule shows as the PM's turn (batch 21 item 1: the report rule filled the bubble)
54
+ const t = String(text == null ? '' : text).replace(/<\/?pasted_content\b[^>]*>/gi, '').trim();
53
55
  if (t.includes(MARK.start)) return 'Start the goal';
54
56
  if (t.startsWith(MARK.method)) { const m = /Use the (.+?) method/.exec(t); return 'Ask with ' + (m ? m[1] : 'another method'); }
55
57
  if (t.startsWith(MARK.plan)) return 'Changed the plan';
@@ -59,7 +59,8 @@ import * as IMP from './home-impact.js'; // Your impact: the weekly check in H
59
59
  import * as LPV from './loose-props.js'; // Claude's clean-up of "Not in an initiative": the ✦ on its header and the Viewer (batch 13 item 3)
60
60
  import * as IM from './impact.js';
61
61
  import { mountPull } from './cozy-pull.js'; // pull to refresh on Your day, Adler peeking up (batch 17 item 4-B, AdP2) // Your impact (batch 16 item 7): Adler's sprout on the greeting, the week in the Viewer, the Friday chapter
62
- import * as DB from './dash-view.js'; // the product page is the product's Dashboard (batch 17 item 1, canvas PbA3, PbG6, PbG8)
62
+ import * as DB from './dash-view.js'; // the page model's parts on the product page: the reports, the proposals (batch 17 item 1)
63
+ import * as PV from './prog-page.js'; // the product page is the one program and product page (batch 21 item 2, canvas RdProgL–RdProgP)
63
64
  import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
64
65
 
65
66
  const $ = (s, r = document) => r.querySelector(s);
@@ -908,31 +909,66 @@ function openProductPage() {
908
909
  const name = ownProductName();
909
910
  VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart', rename: productRename(boardWs(), name, 'product'),
910
911
  render: (b) => {
911
- const U = H.weeklyUpdate(S.D, S.D.now), sent = (U.sent || []).some((x) => x.week === U.week.iso);
912
- const row = (k, icon, t, sub) => `<div class="hm-r hi-r"><button type="button" class="hm-rm" data-hp="${k}"><span class="hm-tile">${SVG(icon, 14)}</span><span class="hm-rt"><b>${esc(t)}</b><em class="q">${esc(sub)}</em></span></button></div>`;
913
- b.innerHTML = `<div class="hi-v hi-page">${goalsBlock(boardWs())}`
914
- + `<section class="hi-pg" aria-label="This week"><div class="hi-pgh"><b>This week</b></div>${row('update', I.doc, 'Weekly update', sent ? 'Sent this week' : 'Ready to send')}${row('metrics', I.chart, 'Metrics review', 'With Strategist')}</section>`
915
- + (isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '') + '</div>';
916
- fillGoals(b, boardWs());
917
- productDash(b, boardWs() || '', 'product', name);
912
+ productDash(b, boardWs() || '', 'product', name, ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary) || null);
918
913
  b.onclick = (e) => {
919
914
  const t = e.target.closest('[data-hp]'); if (!t) return;
920
915
  if (t.dataset.hp === 'update') { VW.drill(); openTarget(updateTarget()); openUpdateViewer(); }
921
916
  else if (t.dataset.hp === 'metrics') { VW.drill(); openMetrics(); }
922
917
  else if (t.dataset.hp === 'talk') talk();
918
+ else if (t.dataset.hp === 'ini') goIni(t.dataset.k);
919
+ else if (t.dataset.hp === 'prog') goProgram(t.dataset.k);
923
920
  };
924
921
  } });
925
922
  }
926
- /** The product page as the product's Dashboard (batch 17 item 1, PbA3): the ✦ line, Goals folded to their dots, Ships next, This week's
927
- * reports. It has no toggle: the page already is the dashboard. Until GET /api/ready-reports/dashboard answers (or when it cannot), the page
928
- * keeps the Goals and This week it drew before. */
923
+ /** The product page (feedback batch 21 item 2, canvas RdProgL–RdProgP and rdProgAgreed): the SAME one page as a program's (pm/prog-page.js),
924
+ * with no toggle. Top: the ✦ line, the goal card (short titles, KR chips, Forecast's range bar), Programs and Health budgets cards, and the
925
+ * proposals folded to one row. Tabs: Tasks · Initiatives (opens here) · Reports (the ready reports, the weekly update, the metrics review) ·
926
+ * Documents. The model is GET /api/ready-reports/dashboard scope product; until it answers (or when it cannot) the page draws the parts Home
927
+ * already has (its programs, initiatives and tasks) and the goals line of GET /api/goal-status. g: the product's group in Home's list. */
929
928
  const PDASH = new Map(); // ws → { d, open }
930
- function productDash(b, ws, vid, name) {
929
+ const lateDays = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); if (!m) return null; const t = new Date(); t.setHours(0, 0, 0, 0); return Math.round((t - new Date(+m[1], +m[2] - 1, +m[3])) / 864e5); };
930
+ function productPageHtml(x, ws, vid, name, g) {
931
+ const d = x.d, own = vid === 'product', ownHome = '/premium.html?ws=' + encodeURIComponent(ws) + '&ini=product';
932
+ const G = ((d && d.goals) || []).filter((y) => !y.budget), B = ((d && d.goals) || []).filter((y) => y.budget);
933
+ const goal = PV.goalCard({ goals: G, proposed: G.length ? '' : goalsBlock(ws), label: 'Goal', open: x.open });
934
+ const row = (attrs, dot, t, sub, right) => `<button type="button" class="pv-row" ${attrs}>${dot}<span class="pv-rt"><b>${esc(t)}</b>${sub ? `<small>${esc(sub)}</small>` : ''}</span>${right || ''}${SVG('M10 7l5 5-5 5', 16)}</button>`;
935
+ // Programs: the programs Home lists that hold something of this product (their own group took those initiatives out of it)
936
+ const P = ((S.M && S.M.groups) || []).filter((y) => y.kind === 'program' && (own || ((y.program && y.program.members) || []).some((m) => m && m.ws === ws)));
937
+ const progs = P.length ? `<section class="pv-card" aria-label="Programs"><div class="pv-ch"><h4>Programs</h4><small>${P.length}</small></div>${P.map((y) => row(`data-hp="prog" data-k="${esc(y.program.id)}"`, '', y.name, y.st && y.st.next ? 'Next: ' + y.st.next.name + (y.st.next.day ? ', ' + y.st.next.day : '') : y.closedLine || '')).join('')}</section>` : '';
938
+ const budgets = B.length ? `<section class="pv-card" aria-label="Health budgets"><div class="pv-ch"><h4>Health budgets</h4></div>${B.map((y) => PV.goalRow(y)).join('')}</section>` : '';
939
+ const props = d && (d.needsN || d.needs) ? { n: d.needsN || 1, sub: (d.needs && d.needs.q) + ((d.needsN || 1) > 1 ? ' and ' + ((d.needsN || 1) - 1) + ' more' : ''), html: DB.needsHtml(d) } : null;
940
+ // the initiatives and their tasks, as Home's list holds them; the launch range from the page model when it has one (Ships next)
941
+ const inis = g ? (g.inis || []).concat(g.rest || []) : [];
942
+ const ships = new Map((((d && d.stage && d.stage.kind === 'ships-next') ? d.stage.items.concat((d.stage.more && d.stage.more.items) || []) : [])).map((y) => [y.id, y]));
943
+ const T = inis.flatMap((i) => (i.tasks || []).map((t) => ({ ...t, of: i.name })));
944
+ const late = T.filter((t) => t.late);
945
+ const iniRows = inis.map((i) => { const sh = ships.get(i.ini); const when = sh ? (sh.lo && sh.hi && sh.lo !== sh.hi ? sh.lo + ' to ' + sh.hi : sh.when) : '';
946
+ return row(`data-hp="ini" data-k="${esc(i.ini)}"`, `<span class="db-dot ${sh && /behind|risk/.test(sh.dot) ? 'risk' : sh && sh.dot === 'on' ? 'ok' : 'q'}" aria-hidden="true"></span>`, i.name, [when ? 'Ships ' + when : '', i.right].filter(Boolean).join(' · '), i.stage ? `<span class="pv-pill">${esc(i.stage)}</span>` : ''); }).join('');
947
+ const tRow = (t) => row(`data-hp="ini" data-k="${esc(t.ini)}"`, '', t.name, t.of, t.late && t.due ? `<span class="pv-late">${esc(lateDays(t.due) + ' days late')}</span>` : '');
948
+ const U = own ? H.weeklyUpdate(S.D, S.D.now) : null, sent = U && (U.sent || []).some((y) => y.week === U.week.iso);
949
+ const R = d ? DB.reportsHtml(d, { open: x.open }) : '';
950
+ const extra = own ? row('data-hp="metrics"', '', 'Metrics review', 'With Strategist') + (R ? '' : row('data-hp="update"', '', 'Weekly update', sent ? 'Sent this week' : 'Ready to send'))
951
+ : `<a class="pv-row" href="${esc(ownHome)}" target="_blank" rel="noopener"><span class="pv-rt"><b>Weekly update and metrics review</b><small>In ${esc(name)}'s own Home, in a new tab</small></span></a>`;
952
+ const reps = ((d && d.reports) || []).filter((r) => r.kind !== 'heads-up');
953
+ const tabs = [
954
+ { id: 'tasks', label: 'Tasks', n: T.length, sig: late.length ? 'late' : '', html: () => (T.length ? (late.length ? `<section class="pv-card" aria-label="Late"><div class="pv-ch"><h4>Late first</h4><small>${late.length > 3 ? '3 shown · ' + (late.length - 3) + ' more below' : ''}</small></div>${late.slice(0, 3).map(tRow).join('')}</section>` : '')
955
+ + `<section class="pv-card" aria-label="Open tasks"><div class="pv-ch"><h4>Open tasks</h4><small>${T.length}</small></div>${T.filter((t) => !late.slice(0, 3).includes(t)).map(tRow).join('')}</section>` : '<p class="pv-none">No open task on its initiatives.</p>') },
956
+ { id: 'initiatives', label: 'Initiatives', n: inis.length, html: () => (inis.length ? `<section class="pv-card" aria-label="Initiatives"><div class="pv-ch"><h4>${esc(name)}</h4><small>${inis.length === 1 ? '1 initiative' : inis.length + ' initiatives'}</small></div>${iniRows}</section>` : '<p class="pv-none">Nothing is open. A new initiative shows here.</p>') },
957
+ { id: 'reports', label: 'Reports', n: reps.length, sig: reps.some((r) => r.state === 'drafted') ? 'ready' : '', html: () => `<div class="db" data-level="product">${d ? DB.trustHtml(d) : ''}${R}</div><section class="pv-card" aria-label="More reports">${extra}</section>` },
958
+ { id: 'documents', label: 'Documents', html: () => '<p class="pv-none">Each initiative keeps its PRD, rubric and release notes on its own page. Open one from Initiatives.</p>' },
959
+ ];
960
+ const lead = d && d.handled ? d.handled.lead : '', rest = d && d.handled ? d.handled.rest : '';
961
+ return PV.pageHtml({ page: 'product:' + (ws || 'own'), line: { lead, rest, warn: !!(d && d.handled && d.handled.tone === 'warn') }, goal, cards: progs + budgets, props, tabs,
962
+ tail: isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '' });
963
+ }
964
+ function productDash(b, ws, vid, name, g) {
931
965
  const x = PDASH.get(ws) || { d: null, open: new Set() }; PDASH.set(ws, x);
932
966
  const paint = () => {
933
- const c = VW.current(); if (!x.d || !b.isConnected || !c || c.id !== vid) return;
934
- b.innerHTML = DB.dashHtml(x.d, { open: x.open, metrics: true, talk: isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '' });
967
+ const c = VW.current(); if (!b.isConnected || !c || c.id !== vid) return;
968
+ b.innerHTML = productPageHtml(x, ws, vid, name, g);
969
+ if (!(x.d && (x.d.goals || []).some((y) => !y.budget))) fillGoals(b, ws); // no goal in the page model yet: the goals line of /api/goal-status
935
970
  };
971
+ PV.wirePage(b, { redraw: paint });
936
972
  if (b.dataset.dbWired !== ws) {
937
973
  b.dataset.dbWired = ws;
938
974
  DB.wireDash(b, { d: () => x.d, open: x.open, ws, toast, redraw: paint,
@@ -1086,16 +1122,12 @@ function goOtherProduct(g) {
1086
1122
  t.newChat = () => newProduct(t);
1087
1123
  openTarget(t);
1088
1124
  pushPage();
1089
- const own = '/premium.html?ws=' + encodeURIComponent(ws) + '&ini=product';
1090
1125
  VW.open({ id: 'product:' + ws, kind: 'Product', title: name, icon: 'chart', rename: productRename(ws, name, 'product:' + ws),
1091
1126
  render: (b) => {
1092
- b.innerHTML = `<div class="hi-v hi-page">${goalsBlock(ws)}`
1093
- + `<section class="hi-pg" aria-label="This week"><div class="hi-pgh"><b>This week</b></div><div class="hm-r hi-r"><a class="hm-rm" href="${esc(own)}" target="_blank" rel="noopener"><span class="hm-tile">${SVG(I.doc, 14)}</span><span class="hm-rt"><b>Weekly update and metrics review</b><em class="q">In ${esc(name)}'s own Home, in a new tab</em></span></a></div></section>`
1094
- + (isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '') + '</div>';
1095
- productDash(b, ws, 'product:' + ws, name);
1127
+ productDash(b, ws, 'product:' + ws, name, g);
1096
1128
  // a phone has no chat beside the page: its own chat is one press away, as on the board's own product (Wawan, 2026-10-25)
1097
- fillGoals(b, ws);
1098
- b.onclick = (e) => { const t = e.target.closest('[data-hp="talk"]'); if (t) talk(); };
1129
+ b.onclick = (e) => { const t = e.target.closest('[data-hp]'); if (!t) return; if (t.dataset.hp === 'talk') talk(); else if (t.dataset.hp === 'prog') goProgram(t.dataset.k);
1130
+ else if (t.dataset.hp === 'ini') window.open('/premium.html?' + new URLSearchParams({ ws, ini: t.dataset.k }).toString(), '_blank', 'noopener'); };
1099
1131
  } });
1100
1132
  }
1101
1133
  /** A program heading's name: the program panel in the Viewer, the program's own chat (HbCProg). */
@@ -159,8 +159,8 @@ export function mountChat(el, host) {
159
159
  }
160
160
  function queuedHtml() {
161
161
  const q = host.queued ? host.queued(sid()) : [];
162
- const said = new Set(((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').map((m) => String(m.text || '').trim()));
163
- return q.filter((x) => !said.has(String(x.text).trim())).map((x) => `<div class="hm-q"><div class="hm-qb">${userHtml(x.text)}</div><span class="hm-qn">${esc(role().name)} reads it after this tool call, in seconds<button type="button" class="hm-qx" data-hm-qdel="${esc(x.at)}" aria-label="Take it back" title="Take it back">${SVG(XX, 13)}</button></span></div>`).join('');
162
+ const said = new Set(((C.conv && C.conv.messages) || []).filter((m) => m.role === 'user').map((m) => shownUser(m.text))); // as typed: PMOS wraps a report ask in its rule
163
+ return q.filter((x) => !said.has(shownUser(x.text))).map((x) => `<div class="hm-q"><div class="hm-qb">${userHtml(x.text)}</div><span class="hm-qn">${esc(role().name)} reads it after this tool call, in seconds<button type="button" class="hm-qx" data-hm-qdel="${esc(x.at)}" aria-label="Take it back" title="Take it back">${SVG(XX, 13)}</button></span></div>`).join('');
164
164
  }
165
165
  const sid = () => (C.t && C.t.sid) || (C.th && C.th.session) || null;
166
166
  // A loose chat that reads like one initiative gets one quiet chip at its top: "Looks like <initiative> · Link it ×" (XvALinkSuggest).
@@ -176,11 +176,18 @@ function slides() {
176
176
  export const longSlot = (s) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s || '')); return m ? +m[3] + ' ' + MONS[+m[2] - 1] + ' ' + m[1] : String(s || ''); };
177
177
  /** The title slide (ReportPanel.dc.html): the audience tag, the title with the audience as its accent line, a subtitle (the file's
178
178
  * subtitle or description, else its first sections) and the as-of line. Nothing is made up: a part with no source is left out. */
179
+ const AUD_MAX = 40;
180
+ /** The note older drafts carried in their description: how the file is made, for PMOS, never a subtitle. */
181
+ const INTERNAL_RE = /pmos report draft writes every number|between the note markers/i;
179
182
  function titleSlide(w) {
180
183
  const heads = (w.sections || []).map((x) => x.h).filter((h) => !/^summary$/i.test(h)).slice(0, 3);
181
184
  const list = heads.length > 1 ? heads.slice(0, -1).join(', ') + ' and ' + heads[heads.length - 1].toLowerCase() : heads.join('');
182
185
  const f = headFigure(w), t = [R.row.slot ? 'As of ' + longSlot(R.row.slot) : '', f && f.data ? 'Data: ' + f.data : ''].filter(Boolean).join(' · ');
183
- return { k: 'title', h: 'Title', title: w.title, eye: R.audience || 'Report', acc: R.audience ? R.audience.toLowerCase() : '', sub: w.sub || list, t,
186
+ // A long audience (a list of people) stays in At a glance: on the slide it would fill the eyebrow and repeat as the accent line (Wawan, 2026-11-01).
187
+ const aud = R.audience && R.audience.length <= AUD_MAX ? R.audience : '';
188
+ // an older draft is titled from the report's id ("Scarlet-assessment-report report 2026-11-02"): show the report's name instead
189
+ const idTitle = R.name && /^[A-Za-z][a-z0-9]*(?:-[a-z0-9]+)+ report \d{4}-\d{2}-\d{2}$/.test(w.title || '');
190
+ return { k: 'title', h: 'Title', title: idTitle ? R.name : w.title, eye: aud || 'Report', acc: aud ? aud.toLowerCase() : '', sub: (!INTERNAL_RE.test(w.sub || '') && w.sub) || list, t,
184
191
  fig: f ? { v: f.v, cap: f.cap } : null };
185
192
  }
186
193
  /** The title slide's headline figure (ReportPanel.dc.html: "81%" over "597 of 733 web logins"): the first bold number of the first