create-pmos 0.478.0 → 0.479.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 (32) hide show
  1. package/package.json +13 -14
  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 +12 -0
  8. package/workspace/guide/home.md +2 -1
  9. package/workspace/guide/programs.md +15 -5
  10. package/workspace/lib/board-pack-route.js +10 -1
  11. package/workspace/lib/board-pack.js +31 -2
  12. package/workspace/lib/briefing-premium-products.js +5 -2
  13. package/workspace/lib/briefing-premium.js +5 -3
  14. package/workspace/lib/ready-reports.js +31 -6
  15. package/workspace/metric-drafts-ui-test.js +2 -1
  16. package/workspace/milestone-suggest-test.js +12 -6
  17. package/workspace/package-lock.json +2 -2
  18. package/workspace/package.json +1 -1
  19. package/workspace/program-charter-test.js +5 -5
  20. package/workspace/program-panel-test.js +28 -25
  21. package/workspace/public/pm/bd-prog-panel.js +84 -60
  22. package/workspace/public/pm/chat-md.js +5 -2
  23. package/workspace/public/pm/cozy-home.css +3 -0
  24. package/workspace/public/pm/dash-view.js +9 -5
  25. package/workspace/public/pm/goal-chat.js +3 -1
  26. package/workspace/public/pm/home-app.js +53 -21
  27. package/workspace/public/pm/home-chat.js +2 -2
  28. package/workspace/public/pm/premium.css +1 -0
  29. package/workspace/public/pm/prog-page.css +76 -0
  30. package/workspace/public/pm/prog-page.js +112 -0
  31. package/workspace/public/pm/readonly.js +8 -1
  32. package/workspace/ready-dash-ui-test.js +53 -73
@@ -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).
@@ -2258,6 +2258,7 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2258
2258
  .md{font-size:var(--fs-3);line-height:1.6;color:var(--ink);max-width:64ch;overflow-wrap:anywhere}
2259
2259
  .md>:first-child{margin-top:0}.md>:last-child{margin-bottom:0}
2260
2260
  .md p{margin:0 0 10px}
2261
+ .ub .md{max-width:none;color:inherit}
2261
2262
  .md h4,.md h5,.md h6{margin:18px 0 6px;line-height:1.35;font-weight:600}
2262
2263
  .md h4{font-size:var(--fs-4)}.md h5{font-size:var(--fs-3)}
2263
2264
  .md h6{font:600 var(--fs-2) var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--ink-2)}
@@ -0,0 +1,76 @@
1
+ /* pm/prog-page.css — the one program and product page (pm/prog-page.js; canvas Ready for development RdProgL–RdProgP, batch 21 item 2).
2
+ * Token vars only, over pm/cozy.css; the type scale is --fs-1..--fs-6. Every class starts with pv-. The rows inside a tab keep the classes of
3
+ * the parts they came from (pp- for the program's tree, db- for the reports). */
4
+
5
+ .pv { display: flex; flex-direction: column; gap: 14px; padding: 2px 0 18px; color: var(--cz-ink); font-family: var(--cz-sans); min-width: 0; }
6
+
7
+ /* the ✦ line: the next step, with the M face once */
8
+ .pv-line { display: flex; align-items: center; gap: 12px; border-radius: 16px; padding: 8px 12px 8px 12px; background: var(--cz-bluebg); border: 1px solid color-mix(in srgb, var(--cz-blueink) 18%, transparent); }
9
+ .pv-line p { margin: 0; flex: 1; min-width: 0; font-size: var(--fs-4); line-height: 1.4; color: var(--cz-ink3); }
10
+ .pv-line b { color: var(--cz-ink); font-weight: 800; }
11
+ .pv-face { flex: none; width: 36px; height: 36px; display: inline-flex; }
12
+ .pv-face svg, .pv-face img { width: 36px; height: 36px; }
13
+
14
+ /* the goal card, with the milestones inside it; a proposed goal is dashed */
15
+ .pv-gc { background: var(--cz-card); border: 1px solid var(--cz-hair); border-radius: 16px; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
16
+ .pv-gc.p { border: 1.5px dashed color-mix(in srgb, var(--cz-blueink) 40%, transparent); }
17
+ .pv-gc > .md-card { border: 0; padding: 0; background: transparent; box-shadow: none; }
18
+ .pv-gc .pp-sec { margin: 0; }
19
+ .pv-gc .pp-lh { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
20
+ .pv-gc .pp-lh { margin-bottom: 4px; }
21
+ .pv-gc .pp-lh .lbl { margin: 0; }
22
+ .pv-k { margin: 0; font-size: var(--fs-1); font-weight: 800; color: var(--cz-blueink); }
23
+ .pv-gr { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; }
24
+ button.pv-gr { cursor: pointer; }
25
+ .pv-gr:focus-visible, .pv-one:focus-visible, .pv-tab:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; border-radius: 10px; }
26
+ .pv-rt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
27
+ .pv-rt b { font-size: var(--fs-4); font-weight: 800; line-height: 1.3; }
28
+ .pv-gr .pv-rt b { font-size: var(--fs-5); }
29
+ .pv-rt small { font-size: var(--fs-2); color: var(--cz-ink3); line-height: 1.4; }
30
+ .pv-kr { flex: none; font-size: var(--fs-1); font-weight: 800; border-radius: 6px; padding: 2px 6px; background: var(--cz-bluebg); color: var(--cz-blueink); }
31
+ .pv-fc { display: flex; align-items: center; gap: 10px; padding-left: 19px; }
32
+ .pv-fc small { flex: none; font-size: var(--fs-2); color: var(--cz-ink3); }
33
+ .pv-bar { position: relative; flex: 1; height: 10px; border-radius: 5px; background: var(--cz-well); }
34
+ .pv-bar i { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: var(--cz-ink3); }
35
+ .pv-bar i.ok { background: var(--cz-dot-ok); } .pv-bar i.risk { background: var(--cz-dot-risk); } .pv-bar i.late { background: var(--cz-dot-late); }
36
+ .pv-bar.held { opacity: .55; }
37
+ .pv-bar .tg { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--cz-ink); }
38
+ .pv-bar .lk { position: absolute; top: 1px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--cz-card); border: 2px solid var(--cz-ink); box-sizing: border-box; }
39
+
40
+ /* the top cards of a product: Programs, Health budgets */
41
+ .pv-card { background: var(--cz-card); border: 1px solid var(--cz-hair); border-radius: 16px; padding: 10px 16px; display: flex; flex-direction: column; min-width: 0; }
42
+ .pv-ch { display: flex; align-items: center; gap: 10px; padding: 2px 0 4px; }
43
+ .pv-ch h4 { margin: 0; font-size: var(--fs-4); font-weight: 800; }
44
+ .pv-ch small { flex: 1; font-size: var(--fs-2); color: var(--cz-ink3); }
45
+ .pv-row { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--cz-hair); min-width: 0; width: 100%; }
46
+ .pv-ch + .pv-row { border-top: 0; }
47
+ button.pv-row, a.pv-row { cursor: pointer; }
48
+ .pv-row > svg, .pv-chev { flex: none; color: var(--cz-ink3); display: inline-flex; }
49
+ .pv-pill { flex: none; font-size: var(--fs-2); color: var(--cz-ink2); background: var(--cz-well); border-radius: 99px; padding: 2px 10px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
50
+ .pv-late { flex: none; font-size: var(--fs-2); font-weight: 800; color: var(--cz-late); }
51
+ .pv-none { margin: 0; padding: 6px 0; font-size: var(--fs-3); color: var(--cz-ink3); line-height: 1.5; }
52
+
53
+ /* the proposals, folded to one row (the owner only) */
54
+ .pv-props { display: flex; flex-direction: column; gap: 8px; }
55
+ .pv-one { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 12px; background: var(--cz-card); border: 1px solid color-mix(in srgb, var(--cz-blueink) 25%, transparent); border-radius: 16px; padding: 10px 14px; min-width: 0; }
56
+ .pv-ic { flex: none; color: var(--cz-blueink); display: inline-flex; }
57
+ .pv-one[aria-expanded="true"] .pv-chev { transform: rotate(180deg); }
58
+ .pv-pbody { display: flex; flex-direction: column; gap: 8px; }
59
+
60
+ /* the tabs */
61
+ .pv-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--cz-hair); overflow-x: auto; scrollbar-width: none; }
62
+ .pv-tab { all: unset; box-sizing: border-box; cursor: pointer; flex: 1 1 auto; justify-content: center; min-height: 44px; padding: 10px 8px; font-size: var(--fs-4); font-weight: 700; color: var(--cz-ink3); display: flex; align-items: center; gap: 8px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
63
+ .pv-tab.on { color: var(--cz-ink); font-weight: 800; border-bottom-color: var(--cz-blue); }
64
+ .pv-n { font-size: var(--fs-1); font-weight: 800; color: var(--cz-ink3); }
65
+ .pv-sg { width: 8px; height: 8px; border-radius: 50%; flex: none; }
66
+ .pv-sg.late { background: var(--cz-dot-late); } .pv-sg.ready { background: var(--cz-blue); }
67
+ .pv-panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
68
+
69
+ @media (max-width: 480px) {
70
+ .pv-tab { padding: 10px 4px; gap: 5px; font-size: var(--fs-3); }
71
+ .pv-pill { display: none; }
72
+ }
73
+
74
+ /* a tab names its part once: the Reports block's own heading is the tab's (say it once) */
75
+ .pv-panel .db-b > .db-h { display: none; }
76
+ .pv-pbody .db-b > .db-h { display: none; }
@@ -0,0 +1,112 @@
1
+ /* pm/prog-page.js — the ONE page of a program and of a product in the Viewer (feedback batch 21 item 2; canvas Ready for development,
2
+ * RdProgL Initiatives, RdProgM Tasks, RdProgN Reports, RdProgO a teammate on a shared board, RdProgP the phone; note rdProgAgreed).
3
+ * It replaces the batch 17 Work | Dashboard pair: there is no toggle. The program panel (bd-prog-panel.js, on the Board and in Home) and the
4
+ * product page (home-app.js) draw it; each host gives the parts it already has, and this file only lays them out and wires the tabs.
5
+ *
6
+ * pageHtml(m) the page. m: {
7
+ * page 'program:<id>' | 'product:<ws>', the key the last tab is kept under (this browser only)
8
+ * line { lead, rest } the ✦ line with the next step (the M face leads it, once per screen); a shared copy says who shared it
9
+ * goal html of the goal card: the goal's short title with its KR chip, its range bar, and the milestones inside it
10
+ * cards html of more cards in the top area (a product: Programs, Health budgets)
11
+ * props { n, sub, html } the proposals that wait on the owner, folded to one row; never on a shared board (RdProgO)
12
+ * tabs [{ id: 'tasks'|'initiatives'|'reports'|'documents', label, n?, sig?: 'late'|'ready', html() }]
13
+ * shared true on a teammate's read-only copy
14
+ * }
15
+ * tabOf(page) the tab that opens: the viewer's last one on this page, else Initiatives (Wawan 2026-11-01: "initiative as default")
16
+ * wirePage(body, h) once per body: a tab press, the arrow keys on the tab list, the proposals fold. h: { redraw() }
17
+ *
18
+ * Zero is silence: a tab count of 0 is not drawn, an empty top part is left out. Icon-only presses carry their words in aria-label and title. */
19
+ import { adler } from './cozy-adler.js';
20
+
21
+ const CSS = new URL('./prog-page.css', import.meta.url).href;
22
+ if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
23
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
24
+ }
25
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
26
+ const SV = (d, w = 16) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
27
+ const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', DOWN = 'M7 10l5 5 5-5';
28
+
29
+ export const TABS = Object.freeze(['tasks', 'initiatives', 'reports', 'documents']);
30
+ const KEY = 'pmos.pv.tab:';
31
+ const OPEN = new Set(); // pages whose proposals row is open, this page load
32
+ const get = (k) => { try { return localStorage.getItem(k); } catch { return null; } };
33
+ const set = (k, v) => { try { localStorage.setItem(k, v); } catch { /* a private window */ } };
34
+ export const tabOf = (page) => { const v = get(KEY + page); return TABS.includes(v) ? v : 'initiatives'; };
35
+ export const keepTab = (page, t) => { if (TABS.includes(t)) set(KEY + page, t); };
36
+
37
+ const SIG = { late: ['late', 'Something is late'], ready: ['ready', 'A report is ready'] };
38
+ function tabsHtml(m, on) {
39
+ return `<div class="pv-tabs" role="tablist" aria-label="${esc('Parts of the page')}">${m.tabs.map((t) => {
40
+ const s = SIG[t.sig];
41
+ return `<button type="button" class="pv-tab${t.id === on ? ' on' : ''}" role="tab" id="pvt-${esc(t.id)}" aria-controls="pvp" aria-selected="${t.id === on}" tabindex="${t.id === on ? 0 : -1}" data-pv="tab" data-k="${esc(t.id)}">`
42
+ + `${esc(t.label)}${t.n ? `<span class="pv-n">${esc(t.n)}</span>` : ''}${s ? `<i class="pv-sg ${s[0]}" role="img" aria-label="${esc(s[1])}"></i>` : ''}</button>`;
43
+ }).join('')}</div>`;
44
+ }
45
+ function lineHtml(l) {
46
+ if (!l || !(l.lead || l.rest)) return '';
47
+ return `<div class="pv-line" role="status"><span class="pv-face">${adler(l.warn ? 'honest' : 'handled', 36, { label: false, id: 'pv' })}</span><p>${l.lead ? `<b>${esc(l.lead)}</b>` : ''}${l.rest ? ' <span>' + esc(l.rest) + '</span>' : ''}</p></div>`;
48
+ }
49
+ function propsHtml(m) {
50
+ const P = m.props; if (m.shared || !P || !P.n) return '';
51
+ const open = OPEN.has(m.page);
52
+ return `<div class="pv-props"><button type="button" class="pv-one" data-pv="props" aria-expanded="${open}"><span class="pv-ic">${SV(SPARK)}</span>`
53
+ + `<span class="pv-rt"><b>${esc(P.n + (P.n === 1 ? ' proposal waits on you' : ' proposals wait on you'))}</b>${P.sub ? `<small>${esc(P.sub)}</small>` : ''}</span><span class="pv-chev">${SV(DOWN)}</span></button>`
54
+ + (open && P.html ? `<div class="pv-pbody">${P.html}</div>` : '') + '</div>';
55
+ }
56
+ /** The whole page: the top (✦ line, goal card, more cards, proposals), the tabs, the open tab's part. */
57
+ export function pageHtml(m) {
58
+ const on = m.tabs.some((t) => t.id === tabOf(m.page)) ? tabOf(m.page) : (m.tabs.find((t) => t.id === 'initiatives') || m.tabs[0] || {}).id;
59
+ const t = m.tabs.find((x) => x.id === on);
60
+ return `<div class="pv${m.shared ? ' shared' : ''}" data-pv-page="${esc(m.page)}">${lineHtml(m.line)}${m.goal || ''}${m.cards || ''}${propsHtml(m)}`
61
+ + (m.tabs.length ? tabsHtml(m, on) + `<div class="pv-panel" id="pvp" role="tabpanel" aria-labelledby="pvt-${esc(on)}">${t ? t.html() : ''}</div>` : '') + (m.tail || '') + '</div>';
62
+ }
63
+ /** The tab presses and the proposals fold, once per body. A press keeps the tab for this page and draws again (h.redraw). */
64
+ export function wirePage(body, h) {
65
+ if (body.dataset.pvWired) return; body.dataset.pvWired = '1';
66
+ const pageOf = () => { const p = body.querySelector('[data-pv-page]'); return p ? p.dataset.pvPage : ''; };
67
+ const go = (k) => { keepTab(pageOf(), k); h.redraw(); const t = body.querySelector(`[data-pv="tab"][data-k="${k}"]`); if (t) t.focus(); };
68
+ body.addEventListener('click', (e) => {
69
+ const b = e.target.closest('[data-pv]'); if (!b || !body.contains(b)) return;
70
+ if (b.dataset.pv === 'tab') go(b.dataset.k);
71
+ else if (b.dataset.pv === 'props') { const p = pageOf(); if (OPEN.has(p)) OPEN.delete(p); else OPEN.add(p); h.redraw(); const x = body.querySelector('[data-pv="props"]'); if (x) x.focus(); }
72
+ });
73
+ body.addEventListener('keydown', (e) => {
74
+ const b = e.target.closest && e.target.closest('[data-pv="tab"]'); if (!b || !['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(e.key)) return;
75
+ const L = [...body.querySelectorAll('[data-pv="tab"]')].map((x) => x.dataset.k), i = L.indexOf(b.dataset.k);
76
+ const j = e.key === 'Home' ? 0 : e.key === 'End' ? L.length - 1 : (i + (e.key === 'ArrowRight' ? 1 : -1) + L.length) % L.length;
77
+ e.preventDefault(); go(L[j]);
78
+ });
79
+ }
80
+
81
+ /* ── the goal card's parts, the same on a program and a product ── */
82
+ const DOT = { ahead: 'ok', on: 'ok', ok: 'ok', done: 'ok', behind: 'risk', risk: 'risk', late: 'late', none: 'q' };
83
+ const dotWord = (d) => (d === 'none' ? 'No reading yet' : d === 'behind' ? 'Behind its line' : d === 'ahead' ? 'Ahead of its line' : 'On its line');
84
+ const FC = { 'on-track': ['ok', 'On track'], 'at-risk': ['risk', 'At risk'], 'will-miss': ['late', 'Will miss'], held: ['q', 'Held'] };
85
+ const num = (v, u) => { const s = String(Math.round(v * 10) / 10), t = String(u || '').trim(); return t ? (/^[A-Za-z$]/.test(t) ? (t === '$' ? '$' + s : s + ' ' + t) : s + t) : s; };
86
+ /** Forecast's range bar on the goal card (FcIntel, rdProgAgreed): low to high, the goal as a tick, likely as a dot. Too early draws nothing. */
87
+ export function rangeHtml(fc) {
88
+ const w = fc && FC[fc.state], ok = (v) => typeof v === 'number' && Number.isFinite(v);
89
+ if (!w || !ok(fc.low) || !ok(fc.high)) return '';
90
+ const vs = [fc.low, fc.high].concat(ok(fc.target) ? [fc.target] : []), a = Math.min(...vs), b = Math.max(...vs), pad = (b - a) * 0.15 || Math.abs(b) * 0.1 || 1;
91
+ const x = (v) => Math.max(0, Math.min(100, ((v - (a - pad)) / (b - a + 2 * pad)) * 100)).toFixed(1);
92
+ const say = 'Forecast ' + num(fc.low, fc.unit) + ' to ' + num(fc.high, fc.unit) + (ok(fc.likely) ? ', likely ' + num(fc.likely, fc.unit) : '') + (ok(fc.target) ? ', goal ' + num(fc.target, fc.unit) : '');
93
+ return `<div class="pv-fc"><div class="pv-bar${fc.state === 'held' ? ' held' : ''}" role="img" aria-label="${esc(say)}"><i class="${w[0]}" style="left:${x(fc.low)}%;width:${(x(fc.high) - x(fc.low)).toFixed(1)}%"></i>`
94
+ + (ok(fc.target) ? `<span class="tg" style="left:${x(fc.target)}%"></span>` : '') + (ok(fc.likely) && fc.state !== 'held' ? `<span class="lk" style="left:${x(fc.likely)}%"></span>` : '') + `</div><small>${esc(w[1])}</small></div>`;
95
+ }
96
+ /** One goal of the card: its dot, the KR chip, the SHORT title (lib/ready-reports.js shortTitle), its reading; a press opens the goal. */
97
+ export function goalRow(g, o = {}) {
98
+ const tag = o.button === false ? 'div' : 'button type="button"', end = o.button === false ? 'div' : 'button';
99
+ return `<${tag} class="pv-gr"${o.button === false ? '' : ` data-db="goal" data-k="${esc(g.id)}"${g.ws ? ` data-ws="${esc(g.ws)}"` : ''}`} title="${esc(g.title || '')}">`
100
+ + `<span class="db-dot ${DOT[g.dot] || 'q'}" role="img" aria-label="${esc(dotWord(g.dot))}"></span>${g.kr ? `<span class="pv-kr">${esc(g.kr)}</span>` : ''}`
101
+ + `<span class="pv-rt"><b>${esc(g.short || g.title)}</b>${g.sub ? `<small>${esc(g.sub)}</small>` : ''}</span></${end}>${rangeHtml(g.fc)}`;
102
+ }
103
+ /** The goal card: the goals (or the one Claude proposes), then the milestones inside it; '' when it holds nothing. */
104
+ const GOALS_SHOWN = 3; // the card stays one card: the goals behind their line first, 3 shown, the rest one fold away (a product has many)
105
+ export function goalCard({ goals = [], proposed = '', inner = '', label = 'Goal', shared = false, open = null } = {}) {
106
+ const RANK = { behind: 0, risk: 0, late: 0, none: 2 }, L = goals.slice().sort((a, b) => (RANK[a.dot] ?? 1) - (RANK[b.dot] ?? 1));
107
+ const all = !!(open && open.has('goals')), shown = all || L.length <= GOALS_SHOWN + 1 ? L : L.slice(0, GOALS_SHOWN), rest = L.length - shown.length;
108
+ const more = L.length > GOALS_SHOWN + 1 ? `<button type="button" class="db-fold" data-db="fold" data-k="goals" aria-expanded="${all}"><span class="db-rt"><b>${all ? 'Show fewer' : rest + ' more'}</b>${all ? '' : `<small>${esc(L.slice(GOALS_SHOWN).map((g) => g.short || g.title).slice(0, 3).join(' · '))}</small>`}</span>${SV(DOWN)}</button>` : '';
109
+ const rows = shown.map((g) => goalRow(g, { button: !shared })).join('') + more;
110
+ if (!rows && !proposed && !inner) return '';
111
+ return `<section class="pv-gc${!rows && proposed ? ' p' : ''}" aria-label="${esc(goals.length > 1 ? label + 's' : label)}">${rows ? `<p class="pv-k">${esc(goals.length > 1 ? label + 's' : label)}</p>${rows}` : proposed}${inner}</section>`;
112
+ }
@@ -24,6 +24,9 @@ export const VIEW_CONTROLS = [
24
24
  // the viewer: the layout, the close, the folds, the Tasks view menu, a stage's fold and its done tasks
25
25
  '.cz-vw-ib[aria-label="Arrange"]', '.cz-vw-ib[aria-label="Close the viewer"]', '.cz-pn-menu', '[class*="cz-dv"]',
26
26
  '.iv-mctg', '.iv-gx-t', '.iv-ws', '.iv-grp', '.iv-ab-h', '.iv-fr', '.ivx-vb', '.tkc-pop [data-ivs-view]', '.tkc-pop [data-ivs-by]', '.tkc-pop [data-ivs-zoom]',
27
+ // the one program page (batch 21 item 2, RdProgO): open the program, its tabs, its folds, the period of its goals, an initiative of it
28
+ 'button.tg-pgo', 'button.bt-pgo', 'button.bd-lho', '#czViewer .pv-tab', '#czViewer [data-czs-fold]', '#czViewer .pp-nd .tw', '#czViewer [data-pp="ms"]', '#czViewer [data-pp="itasks"]',
29
+ '#czViewer [data-db="fold"]', '#czViewer [data-pp="period"]', '#czViewer [data-pp="per"]', '#czViewer [data-pp="early"]', '#czViewer [data-pp="ini"]',
27
30
  // the line above the Board
28
31
  '.ro-back',
29
32
  ].join(',');
@@ -36,11 +39,15 @@ const REMOVE = [
36
39
  '#bdChipset > :not(.tg-lgd)', '#askDates', '.tg-ft',
37
40
  '.cz-vw-ib[aria-label="Discuss in chat"]', '.cz-vw-ib[aria-label="More"]', '.iv-addp', '.iv-prog', '.iv-plus', '.iv-car', '.iv-scgn', '.iv-gx-a',
38
41
  '.sm-card', '.pp-p', '.lk-chip.mv', // what Claude proposes to the publisher (batch 20 item 1): the pack carries none, and none is drawn
42
+ // the program page's writes and what a share does not hold (batch 21 item 2): proposals, adding, the charter, a document's file, the talk line
43
+ '.pv-props', '.pp-needs', '.msg-list', '.pp-add', '[data-pp="add"]', '[data-pp="first"]', '[data-pp="edit"]', '[data-pp="charter"]', '[data-pp="talk"]', '[data-doc]', '[data-db="milestones"]', '#czViewer .md-card',
39
44
  '.ab-lk', '[data-ivs-view="kanban"]', '.ivs-cols', '.ivs-h:has(+ .ivs-cols)', '[data-ivs-more]', '.iv-tasks .ig-emp', '.iv-tasks .ivk-h', '.iv-tasks .ig-read', '.iv-th .iv-ib', '.iv-th .iv-plus',
40
45
  ];
41
46
  /** Controls whose words are the content (a title, a date, a name, a program's milestone in the Deliveries lane): set as plain text, same look. A program's
42
47
  * milestone opens the program's charter in the workspace; a share does not hold the charter. */
43
- const PLAIN = ['button.dl-e[aria-label*="Program milestone"]:not([aria-label*="press to open"])', 'button.cz-vw-rn', 'button.iv-tt', 'button.iv-dc', 'button.iv-stc', 'button.iv-dtc', 'button.iv-wf', 'button.iv-cb', 'button.tg-pgo', 'button.bt-pgo', 'button.tg-end'];
48
+ const PLAIN = ['button.dl-e[aria-label*="Program milestone"]:not([aria-label*="press to open"])', 'button.cz-vw-rn', 'button.iv-tt', 'button.iv-dc', 'button.iv-stc', 'button.iv-dtc', 'button.iv-wf', 'button.iv-cb', 'button.tg-end',
49
+ // the program page (batch 21 item 2): a task's check box, a goal (its Viewer is in Intelligence), a report (its file is the publisher's), a program check
50
+ 'button.pp-ck', 'button.pv-gr', 'button.db-rep', 'button.pp-dm'];
44
51
  /** A fold whose body goes with it: Documents and Linked are not listed. */
45
52
  const WITH_BODY = ['[data-iv-fold="docs"]', '[data-iv-docs]', '[data-iv-fold="linked"]'];
46
53