create-pmos 0.423.0 → 0.425.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 (97) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +41 -26
  8. package/workspace/briefing-premium-board-test.js +7 -4
  9. package/workspace/briefing-premium-insights-test.js +31 -15
  10. package/workspace/briefing-premium-products-test.js +62 -46
  11. package/workspace/changelog.json +24 -0
  12. package/workspace/guide/briefing-premium.md +3 -2
  13. package/workspace/guide/claude-proposes.md +37 -0
  14. package/workspace/guide/home.md +2 -2
  15. package/workspace/guide/index.md +2 -0
  16. package/workspace/guide/notes.md +39 -1
  17. package/workspace/guide/present-in-a-meeting.md +57 -0
  18. package/workspace/guide/programs.md +2 -2
  19. package/workspace/home-pill-test.js +138 -0
  20. package/workspace/lib/briefing-premium-products.js +18 -4
  21. package/workspace/lib/headless.js +14 -1
  22. package/workspace/lib/meeting-focus.js +64 -14
  23. package/workspace/lib/pmos-verbs.js +3 -0
  24. package/workspace/lib/proposal-runs.js +148 -0
  25. package/workspace/lib/proposals.js +370 -0
  26. package/workspace/lib/propose-cli.js +96 -0
  27. package/workspace/lib/route-modules.js +1 -0
  28. package/workspace/lib/routes-board-premium.js +11 -0
  29. package/workspace/lib/routes-boards.js +1 -1
  30. package/workspace/lib/routes-briefing-premium.js +19 -0
  31. package/workspace/lib/routes-meeting-focus.js +28 -6
  32. package/workspace/lib/routes-proposals.js +325 -0
  33. package/workspace/lib/routes-task-links.js +35 -28
  34. package/workspace/lib/settings-store.js +2 -1
  35. package/workspace/package-lock.json +2 -2
  36. package/workspace/package.json +1 -1
  37. package/workspace/premium-board-actions-test.js +2 -2
  38. package/workspace/premium-briefing-depth-test.js +1 -1
  39. package/workspace/premium-rec-now-test.js +153 -0
  40. package/workspace/premium-rec-tab-test.js +167 -0
  41. package/workspace/public/pm/bd-asks.js +3 -0
  42. package/workspace/public/pm/cozy-aud.css +9 -0
  43. package/workspace/public/pm/cozy-aud.js +80 -0
  44. package/workspace/public/pm/cozy-live-pill.js +3 -0
  45. package/workspace/public/pm/cozy-pick.css +41 -0
  46. package/workspace/public/pm/cozy-pick.js +134 -0
  47. package/workspace/public/pm/cozy-rec-bridge.js +32 -0
  48. package/workspace/public/pm/cozy-rec-now.css +104 -0
  49. package/workspace/public/pm/cozy-rec-now.js +330 -0
  50. package/workspace/public/pm/cozy-rec-present.css +69 -0
  51. package/workspace/public/pm/cozy-rec-present.js +467 -0
  52. package/workspace/public/pm/cozy-rec-tab.css +90 -0
  53. package/workspace/public/pm/cozy-rec-tab.js +219 -0
  54. package/workspace/public/pm/cozy-settings.js +8 -2
  55. package/workspace/public/pm/cozy-today.css +23 -0
  56. package/workspace/public/pm/cozy-viewer.js +14 -3
  57. package/workspace/public/pm/cozy-vw-shell.css +8 -0
  58. package/workspace/public/pm/home-app.js +56 -27
  59. package/workspace/public/pm/home-list.js +17 -10
  60. package/workspace/public/pm/home-more.js +2 -31
  61. package/workspace/public/pm/home-task.js +2 -1
  62. package/workspace/public/pm/home-today.js +69 -19
  63. package/workspace/public/pm/ini-groups.js +30 -5
  64. package/workspace/public/pm/ini-links.js +6 -48
  65. package/workspace/public/pm/ini-props.js +218 -0
  66. package/workspace/public/pm/ini-view-model.js +6 -1
  67. package/workspace/public/pm/ini-view.css +47 -0
  68. package/workspace/public/pm/ini-view.js +23 -6
  69. package/workspace/public/pm/live-model.js +1 -1
  70. package/workspace/public/pm/premium-board.js +56 -25
  71. package/workspace/public/pm/premium-insights.js +42 -24
  72. package/workspace/public/pm/premium-meeting.js +17 -4
  73. package/workspace/public/pm/premium-mtg-present.js +4 -3
  74. package/workspace/public/pm/premium-report-read.js +2 -0
  75. package/workspace/public/pm/premium-vw-item.js +2 -1
  76. package/workspace/public/pm/premium-vw-mtg.js +15 -7
  77. package/workspace/public/pm/rec-state.js +13 -5
  78. package/workspace/public/pm/rec-tab-core.js +92 -0
  79. package/workspace/public/pm/task-card.css +13 -0
  80. package/workspace/public/pm/task-card.js +37 -2
  81. package/workspace/public/pm/view-notes.js +9 -0
  82. package/workspace/public/premium-aud.html +22 -0
  83. package/workspace/public/premium-board.html +1 -0
  84. package/workspace/public/premium-insights.html +2 -1
  85. package/workspace/public/premium-rec.html +30 -0
  86. package/workspace/public/premium.html +1 -0
  87. package/workspace/rec-present-test.js +229 -0
  88. package/workspace/server.js +46 -3
  89. package/workspace/skills/initiative-propose.skill +45 -0
  90. package/workspace/stage-card-test.js +1 -1
  91. package/workspace/task-links-test.js +26 -14
  92. package/workspace/test-lists/claude-proposes.json +5 -0
  93. package/workspace/test-lists/home-sessions-pill.json +6 -0
  94. package/workspace/test-lists/rec-now.json +6 -0
  95. package/workspace/test-lists/rec-present.json +13 -0
  96. package/workspace/test-lists/recording-tab.json +13 -0
  97. package/workspace/tk-tasks-test.js +13 -0
@@ -5,8 +5,10 @@
5
5
  *
6
6
  * of(v) → the links view to draw for the one view's model (the newest of the Board's read and a write's answer), with a
7
7
  * title for every task; null while a draft is shown (Claude adjusts Live only)
8
- * headHtml(lk) the Tasks header's chips, each hidden at zero: the blue ✦ (Claude's proposals), the grey ✦ (the quiet moves since
9
- * last seen; an orange dot when something waits on you), the orange late count
8
+ * headHtml(lk) the Tasks header's chips, each hidden at zero: the grey ✦ (the quiet moves since last seen; an orange dot when
9
+ * something waits on you), the orange late count. Claude's link proposals moved under the initiative's one blue ✦
10
+ * after its title (batch 12 items 2 and 3, pm/ini-props.js)
11
+ * taskTitle(id, uid) a task's title from the links view drawn last (pm/ini-props.js names the tasks of a link proposal)
10
12
  * barExtra(x, lk, quick) what a Timeline bar carries: its two link dots (grey when that end is linked), the orange start edge of a task that
11
13
  * waits on a late one, the small blue ✦ of a quiet move not yet seen
12
14
  * dataOf(lk) the Timeline's links, for the drawing (data-lk on .ivt)
@@ -77,6 +79,7 @@ export function of(v) {
77
79
  return out;
78
80
  }
79
81
  const nameOf = (lk, uid) => { const t = lk && lk.T.get(uid); return t ? t.title : uid; };
82
+ export const taskTitle = (id, uid) => nameOf(VIEWS.get(id), uid);
80
83
  const waitsOn = (lk, uid) => (lk ? lk.links.filter((l) => l.to === uid) : []);
81
84
  const thenOf = (lk, uid) => (lk ? lk.links.filter((l) => l.from === uid) : []);
82
85
 
@@ -84,8 +87,6 @@ const thenOf = (lk, uid) => (lk ? lk.links.filter((l) => l.from === uid) : []);
84
87
  export function headHtml(lk) {
85
88
  if (!lk) return '';
86
89
  let h = '';
87
- const np = (lk.proposals || []).length;
88
- if (np) h += `<button type="button" class="lk-chip pr" data-lk-chip="prop" aria-haspopup="dialog" aria-expanded="${OPEN === 'prop:' + lk.id}" aria-label="${esc('Claude proposes ' + plural(np, 'change', 'changes') + ' to the links. Open')}" title="Claude proposes">${SVG(PL.spark, 14, 2)}<b>${np}</b></button>`;
89
90
  const nm = lk.moved ? lk.moved.n : 0, na = (lk.asks || []).filter((a) => !a.sent).length;
90
91
  if (nm || na) h += `<button type="button" class="lk-chip mv" data-lk-chip="moved" aria-haspopup="dialog" aria-expanded="false" aria-label="${esc((nm ? 'Claude moved ' + plural(nm, 'task', 'tasks') + ' to keep your links' : '') + (nm && na ? '; ' : '') + (na ? plural(na, 'thing waits', 'things wait') + ' on you' : '') + '. Open')}" title="Kept in line">${SVG(PL.spark, 14, 2)}${nm ? `<b>${nm}</b>` : ''}${na ? '<i class="lk-ask" aria-hidden="true"></i>' : ''}</button>`;
91
92
  const nl = (lk.late || []).length;
@@ -349,48 +350,6 @@ async function ownMove(H, id, uid, patch) {
349
350
  return true;
350
351
  }
351
352
 
352
- /* ── the blue ✦: Claude's proposals, ✓ each, Add all, ✕ for good ── */
353
- function propHtml(lk) {
354
- const P = lk.proposals || [];
355
- const nl = P.filter((p) => p.kind === 'link').length;
356
- const head = nl === P.length ? 'Claude proposes ' + plural(nl, 'link', 'links') : 'Claude proposes';
357
- const row = (p) => {
358
- let ic, t, s;
359
- if (p.kind === 'link') { ic = SVG(PL[p.type] || PL.fs, 16, 1.8); t = `${esc(clip(nameOf(lk, p.from), 30))} ${SVG('M5 12h14M13 6l6 6-6 6', 12, 2.2)} ${esc(clip(nameOf(lk, p.to), 30))}`; s = p.why; }
360
- else if (p.kind === 'pull') { ic = SVG(PL.undo, 16, 1.8); t = esc('Pull ' + plural(p.tasks.length, 'task', 'tasks') + ' in by ' + plural(p.days, 'day', 'days')); s = p.why + ': ' + p.tasks.map((u) => clip(nameOf(lk, u), 30)).join(', '); }
361
- else { ic = SVG(PL.cal, 16, 1.8); t = esc('Move ' + plural(p.tasks.length, 'task', 'tasks') + ' to keep your links'); s = p.tasks.map((m) => clip(m.title || nameOf(lk, m.task), 26) + ' ' + span(m.to.start, m.to.due)).join(', '); }
362
- return `<div class="lk-pr"><span class="ic" aria-hidden="true">${ic}</span><span class="w"><b>${t}</b><small>${esc(s)}</small></span>`
363
- + `<button type="button" class="vs-ti ok" data-lk-yes="${esc(p.id)}" aria-label="Approve" title="Approve">${SVG(PL.check, 16, 2.4)}</button><button type="button" class="vs-ti" data-lk-no="${esc(p.id)}" aria-label="Drop it" title="Drop it">${SVG(PL.x, 15, 2)}</button></div>`;
364
- };
365
- return `<div class="tkc-pop lk-m" role="dialog" aria-label="${esc(head)}"><div class="lk-mh">${SVG(PL.spark, 14, 2)}<b>${esc(head)}</b>${P.length > 1 ? `<button type="button" class="vs-ok" data-lk-all aria-label="Add all" title="Add all">${SVG(PL.check, 16, 2.4)}</button>` : ''}</div>${P.map(row).join('')}</div>`;
366
- }
367
- function openProps(b, H, id) {
368
- const lk = VIEWS.get(id); if (!lk) return;
369
- OPEN = 'prop:' + id; redrawAll();
370
- openPop(b, propHtml(lk), async (x) => {
371
- const q = x.dataset;
372
- if ('lkAll' in q || q.lkYes) {
373
- const ids = 'lkAll' in q ? (VIEWS.get(id).proposals || []).map((p) => p.id) : [q.lkYes];
374
- closePop();
375
- const res = await write(H, '/accept', { initiative: id, ids });
376
- if (!res || res.ok === false) { failed(H, res); return; }
377
- took(id, res);
378
- const n = res.linked.length, m = res.moved.length;
379
- say(H, [n ? plural(n, 'link', 'links') + ' added' : '', m ? 'moved ' + plural(m, 'task', 'tasks') + ' to keep ' + (n === 1 ? 'it' : 'them') : ''].filter(Boolean).join(', ').replace(/^./, (c) => c.toUpperCase()) + '.',
380
- n ? async () => { for (const l of res.linked) await write(H, '/unlink', l); CACHE.delete(id); await after(H); } : undefined);
381
- await after(H);
382
- return;
383
- }
384
- if (q.lkNo) {
385
- const res = await write(H, '/drop', { initiative: id, id: q.lkNo });
386
- if (!res || res.ok === false) { failed(H, res); return; }
387
- const v = VIEWS.get(id); if (v) { v.proposals = v.proposals.filter((p) => p.id !== q.lkNo); CACHE.set(id, { v: { ...v, T: undefined }, at: new Date().toISOString() }); }
388
- if (v && v.proposals.length && POP) POP.el.innerHTML = propHtml(v); else closePop();
389
- if (H.redraw) H.redraw();
390
- }
391
- }, { sheet: true, onClose: () => { OPEN = null; redrawAll(); } });
392
- }
393
-
394
353
  /* ── the grey ✦: what Claude moved quietly, Undo all; Needs you (✓ / ✕); the switch for quiet moves ── */
395
354
  function movedHtml(lk) {
396
355
  const B = lk.moved ? lk.moved.batches : [], A = (lk.asks || []).filter((a) => !a.sent);
@@ -521,8 +480,7 @@ export function press(b, d, root, H) {
521
480
  const id = root && root.dataset.iv; if (!id) return false;
522
481
  if (d.lkChip) {
523
482
  if (POP && POP.anchor === b) { closePop(); return true; }
524
- if (d.lkChip === 'prop') openProps(b, H, id);
525
- else if (d.lkChip === 'moved') openMoved(b, H, id);
483
+ if (d.lkChip === 'moved') openMoved(b, H, id);
526
484
  else { PIN = PIN && PIN.uid === '*late' ? null : { id, uid: '*late' }; b.setAttribute('aria-pressed', String(!!PIN)); redrawAll(); }
527
485
  return true;
528
486
  }
@@ -0,0 +1,218 @@
1
+ /* pm/ini-props.js — what Claude proposes on one initiative, under its one blue ✦ (feedback batch 12 items 2, 3 and 4; canvas In development,
2
+ * rows "Populate initiative" (PiA0–PiA5, devPiRules) and "Task proposals" (TpA1–TpA6, devTpRules)). The fold, the engines and the routes
3
+ * are lib/proposals.js and lib/routes-proposals.js; the Board's row carries r.props (null: nothing to show) and r.found (what a ✓ kept).
4
+ *
5
+ * chipOf(props) → the Viewer's chip after the title: { n, looking, label } | null (zero is silence)
6
+ * sync(v, H) after each draw of the initiative: the ✦ in the Viewer's header, and a quiet read while Claude is looking
7
+ * open(v, H) the ✦'s press: "Claude proposes N" as a drill-in. Groups in order: Found elsewhere, Dates, Looks done, Names,
8
+ * Links. ✓ in the header keeps every proposal Claude is sure of; Check these and Not placed need their own ✓.
9
+ * Each proposal: ⌄ its items, ✓ keep, ✕ drop for good; ✕ on one item drops that item. One toast with Undo.
10
+ * lookHtml(v) the Tasks' dashed placeholder while Claude looks and nothing is kept yet (PiA1)
11
+ * foundDocs(v) the documents a ✓ kept from elsewhere, for the Documents fold: [{ title, meta, ref }]
12
+ *
13
+ * The host gives H.where() → { ws, board }, H.reload(), H.toast(text, undo?). Nothing is written until the PM's ✓. */
14
+ import { pmGet, pmPost } from './http.js';
15
+ import { taskTitle } from './ini-links.js';
16
+
17
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
18
+ const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
19
+ const I = {
20
+ spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
21
+ check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', down: 'M6 9l6 6 6-6', up: 'M6 15l6-6 6 6', stop: 'M7 7h10v10H7z',
22
+ doc: 'M7 3h7l5 5v13H7zM14 3v5h5', tasks: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01', stage: 'M5 21V4M5 4h12l-2 4 2 4H5',
23
+ link: 'M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1',
24
+ cal: 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', done: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M8 12l3 3 5-6', name: 'M4 20h4L19 9l-4-4L4 16zM13 7l4 4',
25
+ ask: 'M4 5h16v11H9l-5 4z', maybe: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.6M12 17h.01', keep: 'M5 12l5 5 9-10', ignore: 'M5 12h14',
26
+ };
27
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
28
+ const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
29
+ const md = (iso) => { const m = DAY.exec(String(iso || '')); return m ? MON[+m[2] - 1] + ' ' + +m[3] : ''; };
30
+ const span = (a, b) => (a && b && a !== b ? md(a) + ' – ' + md(b) : md(a || b));
31
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
32
+ const clip = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
33
+ const GROUP = { found: 'Found elsewhere', dates: 'Dates', status: 'Looks done', names: 'Names', links: 'Links' };
34
+
35
+ /* ── the chip and the live look ── */
36
+ export function chipOf(p) {
37
+ if (!p) return null;
38
+ const looking = !!(p.look && !p.look.ended);
39
+ if (!p.n && !looking) return null;
40
+ return { n: p.n || 0, looking, label: p.n ? 'Claude proposes ' + p.n + (looking ? ', and is still looking' : '') + '. Open' : 'Claude is looking for this initiative. Open' };
41
+ }
42
+ const POLL = new Map(); // initiative id → timer, while Claude looks
43
+ export function sync(v, H) {
44
+ const VW = typeof window !== 'undefined' ? window.czViewer : null;
45
+ if (!v || !v.id || !VW) return;
46
+ const cur = VW.current(), body = VW.body();
47
+ if (!cur || !body || !body.querySelector(`[data-iv="${CSS.escape(v.id)}"]`)) return;
48
+ const c = chipOf(v.props);
49
+ VW.setChip(cur.id, c ? { ...c, on: () => open(v, H) } : null);
50
+ // while Claude looks, a quiet read every few seconds; a change reads the Board again
51
+ if (c && c.looking && !POLL.has(v.id)) {
52
+ const t0 = v.props.t;
53
+ POLL.set(v.id, setTimeout(async () => {
54
+ POLL.delete(v.id);
55
+ const r = await read(H, v.id);
56
+ if (r && r.ok && (!r.props || r.props.t !== t0) && H.reload) await H.reload();
57
+ }, 5000));
58
+ }
59
+ }
60
+ async function read(H, id) {
61
+ const at = H.where ? H.where() : {};
62
+ return pmGet('/api/proposals?ws=' + encodeURIComponent(at.ws || '') + '&board=' + encodeURIComponent(at.board || '') + '&initiative=' + encodeURIComponent(id)).catch(() => null);
63
+ }
64
+ async function write(H, route, body) {
65
+ const at = H.where ? H.where() : {};
66
+ return pmPost(route, { ws: at.ws, board: at.board, ...body }).catch(() => null);
67
+ }
68
+ export function lookHtml(v) {
69
+ if (!v || !v.props || !v.props.look || v.props.look.ended) return '';
70
+ return `<div class="pp-ph"><p>Documents, tasks and dates show here when Claude has looked everywhere. Nothing is kept until you say so.</p></div>`;
71
+ }
72
+ export function foundDocs(v) {
73
+ const f = v && v.found;
74
+ return f && f.docs ? f.docs.map((d) => ({ title: d.title, meta: [d.source, md(d.at)].filter(Boolean).join(' · '), ref: d.ref || '' })) : [];
75
+ }
76
+
77
+ /* ── the Viewer ── */
78
+ const S = { id: null, props: null, open: new Set(), choices: {}, H: null, title: '', timer: null };
79
+ const titleOf = (p) => {
80
+ if (p.title) return p.title;
81
+ const n = p.items.length;
82
+ if (p.group === 'found') return p.type === 'stage' ? 'Stage: ' + ((p.data && p.data.stage) || '') : p.type === 'docs' ? plural(n, 'document', 'documents') : p.type === 'tasks' ? plural(n, 'task', 'tasks') : p.type === 'link' ? 'Already in another initiative' : p.type === 'maybe' ? 'Maybe this initiative' : plural(n, 'thing', 'things') + ' not placed';
83
+ if (p.group === 'status') return plural(n, 'task looks', 'tasks look') + ' done';
84
+ if (p.group === 'names') return 'Tidy ' + plural(n, 'name', 'names');
85
+ return '';
86
+ };
87
+ const iconOf = (p) => (p.group === 'found' ? (p.type === 'stage' ? I.stage : p.type === 'docs' ? I.doc : p.type === 'tasks' ? I.tasks : p.type === 'link' ? I.link : I.maybe)
88
+ : p.group === 'dates' ? I.cal : p.group === 'status' ? I.done : p.group === 'names' ? I.name : I.link);
89
+ const ib = (attr, label, icon, cls = '') => `<button type="button" class="pp-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16, 2.2)}</button>`;
90
+ function itemHtml(p, x) {
91
+ let t = '', m = '';
92
+ if (p.group === 'found') {
93
+ if (p.type === 'stage') { t = x.stage; m = [span(x.start, x.due), x.source].filter(Boolean).join(' · '); }
94
+ else if (p.type === 'docs') { t = x.title; m = [x.source, md(x.at)].filter(Boolean).join(' · '); }
95
+ else if (p.type === 'tasks') { t = (x.wbs && !String(x.title || '').startsWith(x.wbs) ? x.wbs + ' ' : '') + (x.title || x.jira || ''); m = [x.jira ? 'Jira epic ' + x.jira : '', x.stage, span(x.start, x.due), x.owner].filter(Boolean).join(' · '); }
96
+ else { t = x.title; m = x.other ? 'In ' + x.other.title : x.why || ''; }
97
+ } else if (p.group === 'dates') { t = x.title || x.task; m = (x.from && x.from.due ? md(x.from.due) + ' → ' : '') + span(x.to && x.to.start, x.to && x.to.due) + (x.jira ? ' · Jira: a drafted comment' : '') + (x.ms ? ' · ◇ a promise' : ''); }
98
+ else if (p.group === 'status') { t = x.title || taskTitle(p.ini, x.task); m = x.jira ? 'Jira: a drafted comment' : ''; }
99
+ else if (p.group === 'names') { t = x.to; m = 'Was: ' + (x.from || '') + (x.jira ? ' · Jira: a drafted comment' : ''); }
100
+ return `<div class="pp-it"><span class="w"><b>${esc(clip(t, 90))}</b>${m ? `<small>${esc(m)}</small>` : ''}</span>${x.sig ? ib(`data-pp-dropit="${esc(x.sig)}"`, 'Leave this one out', I.x) : ''}</div>`;
101
+ }
102
+ function linkHtml(p, l) {
103
+ const pick = S.choices[l.key] || l.rec;
104
+ const seg = l.clash ? '' : `<span class="pp-seg" role="group" aria-label="This link">`
105
+ + `<button type="button" data-pp-ch="${esc(l.key)}" data-v="keep" aria-pressed="${pick === 'keep'}" aria-label="Keep the link: move it too" title="Keep the link: move it too">${SVG(I.keep, 14, 2.2)}${l.rec === 'keep' ? `<i>${SVG(I.spark, 9, 2)}</i>` : ''}</button>`
106
+ + `<button type="button" data-pp-ch="${esc(l.key)}" data-v="ignore" aria-pressed="${pick === 'ignore'}" aria-label="Ignore the link: it stays where it is" title="Ignore the link: it stays where it is">${SVG(I.ignore, 14, 2.2)}${l.rec === 'ignore' ? `<i>${SVG(I.spark, 9, 2)}</i>` : ''}</button></span>`;
107
+ const mv = (l.moves || []).map((m) => m.title + ' to ' + span(m.to.start, m.to.due)).join(', ');
108
+ return `<div class="pp-it pp-lk"><span class="w"><b>${esc(clip(l.toTitle, 70))}</b><small>${esc(l.why)}${mv ? ' · ' + esc(mv) : ''}</small></span>${seg}</div>`;
109
+ }
110
+ function propHtml(p) {
111
+ if (p.group === 'links') {
112
+ const l = p.link || {}, a = taskTitle(p.ini || S.id, l.from), b = taskTitle(p.ini || S.id, l.to);
113
+ const t = l.kind === 'link' ? clip(b, 40) + ' waits on ' + clip(a, 40) : l.kind === 'pull' ? 'Pull ' + plural((l.tasks || []).length, 'task', 'tasks') + ' in' : 'Move ' + plural((l.tasks || []).length, 'task', 'tasks') + ' to keep your links';
114
+ return `<div class="pp-p" data-pp="${esc(p.id)}"><div class="pp-ph1"><span class="pp-ic">${SVG(I.link, 16)}</span><span class="w"><b>${esc(t)}</b><small>${esc(p.why)}</small></span>`
115
+ + ib(`data-pp-keep="${esc(p.id)}"`, 'Keep it', I.check, 'ok') + ib(`data-pp-droplk="${esc(l.id || '')}"`, 'Drop it', I.x) + '</div></div>';
116
+ }
117
+ const op = S.open.has(p.id), n = p.items.length + (p.links || []).length;
118
+ const src = (p.sources || []).map((s) => s.label).join(', ');
119
+ const tag = p.section === 'check' ? 'Check these' : p.section === 'unplaced' ? 'Not placed' : '';
120
+ const plan = p.plan ? 'Plan ' + md(p.plan.from) + ' → ' + md(p.plan.to) + (p.plan.ms ? ' · the ◇ stays where it is' : '') : '';
121
+ const ask = p.ask && p.ask.owner ? ib(`data-pp-ask="${esc(p.id)}"`, 'Ask ' + p.ask.owner + ' why it slipped', I.ask) : '';
122
+ return `<div class="pp-p${p.section !== 'sure' ? ' chk' : ''}" data-pp="${esc(p.id)}">`
123
+ + `<div class="pp-ph1"><span class="pp-ic">${SVG(iconOf(p), 16)}</span><span class="w"><b>${esc(titleOf(p))}</b><small>${esc(p.why)}</small>`
124
+ + (src || tag || plan ? `<small class="pp-src">${[tag ? `<em>${esc(tag)}</em>` : '', esc(plan), esc(src)].filter(Boolean).join(' · ')}</small>` : '') + '</span>'
125
+ + ask + (n ? ib(`data-pp-more="${esc(p.id)}" aria-expanded="${op}"`, op ? 'Hide what it holds' : 'Show what it holds', op ? I.up : I.down) : '')
126
+ + ib(`data-pp-keep="${esc(p.id)}"`, 'Keep it', I.check, 'ok') + ib(`data-pp-drop="${esc(p.sig || '')}"`, 'Drop it for good', I.x) + '</div>'
127
+ + (op ? `<div class="pp-its">${p.items.map((x) => itemHtml(p, x)).join('')}${(p.links || []).map((l) => linkHtml(p, l)).join('')}</div>` : '')
128
+ + '</div>';
129
+ }
130
+ function lookBlock(L) {
131
+ if (!L || L.ended) return '';
132
+ const rows = L.sources.map((s) => `<li class="${s.state === 'reading' ? 'on' : ''}"><b>${esc(s.name)}</b><span>${s.state === 'reading' ? 'Reading…' : esc(s.what || plural(s.n, 'find', 'finds'))}</span></li>`).join('');
133
+ return `<div class="pp-look"><div class="pp-lh">${SVG(I.spark, 14, 2)}<b>${L.why === 'check' ? 'Claude is checking the late tasks' : 'Claude is looking for this initiative'}</b>${ib('data-pp-stop', 'Stop looking', I.stop)}</div>`
134
+ + (rows ? `<ul>${rows}</ul>` : '<p>It starts with your connected sources.</p>') + '</div>';
135
+ }
136
+ function bodyHtml(P) {
137
+ const VW = window.czViewer;
138
+ if (!P || (!P.n && !(P.look && !P.look.ended))) return '<p class="pp-none">Nothing waits here now.</p>';
139
+ const secs = (P.groups || []).map((g) => ({ id: g.group, title: GROUP[g.group] || g.group, count: g.props.length, open: true, html: g.props.map(propHtml).join('') }));
140
+ return `<div class="pp">${lookBlock(P.look)}${VW.czSections(secs, { key: 'props' })}</div>`;
141
+ }
142
+ function presses(P) { return P && P.sure ? [{ act: 'all', label: 'Keep all ' + P.sure + ' Claude is sure of', icon: I.check, solid: true }] : []; }
143
+ function draw() {
144
+ const VW = window.czViewer, b = VW.body(), cur = VW.current();
145
+ if (!b || !cur || cur.id !== 'pp:' + S.id) return;
146
+ const top = b.scrollTop;
147
+ b.innerHTML = bodyHtml(S.props);
148
+ b.scrollTop = top;
149
+ VW.setPresses(cur.id, presses(S.props));
150
+ const t = 'Claude proposes' + (S.props && S.props.n ? ' ' + S.props.n : '');
151
+ if (VW.retitle && cur.title !== t) VW.retitle(cur.id, t);
152
+ clearTimeout(S.timer);
153
+ if (S.props && S.props.look && !S.props.look.ended) S.timer = setTimeout(fresh, 4000);
154
+ }
155
+ async function fresh() {
156
+ const id = S.id, r = await read(S.H, id);
157
+ if (S.id !== id || !r || r.ok === false) return;
158
+ S.props = r.props; draw();
159
+ }
160
+ const say = (m, undo) => { if (S.H && S.H.toast) S.H.toast(m, undo); };
161
+ const after = () => { if (S.H && S.H.reload) Promise.resolve(S.H.reload()).catch(() => {}); };
162
+ async function keep(ids, all) {
163
+ const res = await write(S.H, '/api/proposals/keep', { initiative: S.id, ...(all ? { all: true } : { ids }), choices: S.choices });
164
+ if (!res || res.ok === false) { say((res && res.error) || 'Nothing was kept.'); return; }
165
+ S.props = res.props; draw(); after();
166
+ const batch = res.batch, H = S.H, id = S.id;
167
+ say(res.said, async () => {
168
+ const u = await write(H, '/api/proposals/undo', { batch });
169
+ if (!u || u.ok === false) { if (H.toast) H.toast((u && u.error) || 'The undo did not land.'); return; }
170
+ if (u.kept && H.toast) H.toast(plural(u.kept, 'change was', 'changes were') + ' kept: the task changed since.');
171
+ if (S.id === id) await fresh();
172
+ if (H.reload) await H.reload();
173
+ });
174
+ if (!S.props || (!S.props.n && !(S.props.look && !S.props.look.ended))) window.czViewer.back();
175
+ }
176
+ async function drop(sig) {
177
+ const res = await write(S.H, '/api/proposals/drop', { initiative: S.id, sig });
178
+ if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); return; }
179
+ await fresh(); after();
180
+ }
181
+ async function onPress(e) {
182
+ const b = e.target.closest('button'); if (!b) return;
183
+ const d = b.dataset;
184
+ if (d.ppMore) { if (S.open.has(d.ppMore)) S.open.delete(d.ppMore); else S.open.add(d.ppMore); draw(); return; }
185
+ if (d.ppCh) { S.choices[d.ppCh] = d.v; draw(); return; }
186
+ if (d.ppKeep) { b.disabled = true; await keep([d.ppKeep], false); return; }
187
+ if (d.ppDrop) { b.disabled = true; await drop(d.ppDrop); return; }
188
+ if (d.ppDropit) { b.disabled = true; await drop(d.ppDropit); return; }
189
+ if ('ppDroplk' in d) {
190
+ b.disabled = true;
191
+ const res = await write(S.H, '/api/task-links/drop', { initiative: S.id, id: d.ppDroplk });
192
+ if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); b.disabled = false; return; }
193
+ await fresh(); after(); return;
194
+ }
195
+ if ('ppStop' in d) {
196
+ b.disabled = true;
197
+ const res = await write(S.H, '/api/proposals/stop', { initiative: S.id });
198
+ if (!res || res.ok === false) say((res && res.error) || 'Claude could not be stopped.');
199
+ else say('Claude stopped looking. What it found so far stays here.');
200
+ await fresh(); after(); return;
201
+ }
202
+ if (d.ppAsk) {
203
+ const p = (S.props.groups || []).flatMap((g) => g.props).find((x) => x.id === d.ppAsk); if (!p) return;
204
+ const q = 'Hi ' + p.ask.owner + ', ' + p.items.map((x) => x.title).slice(0, 3).join(', ') + (p.items.length > 1 ? ' are' : ' is') + ' past ' + (p.items.length > 1 ? 'their' : 'its') + ' date. What is it waiting on, and when do you expect it?';
205
+ try { await navigator.clipboard.writeText(q); say('A question for ' + p.ask.owner + ' is copied. Paste it where you talk.'); } catch { say(q); }
206
+ }
207
+ }
208
+ /** The ✦'s press: the drill-in. v: the initiative's view (id, title, props). */
209
+ export function open(v, H) {
210
+ const VW = window.czViewer; if (!VW || !v || !v.id) return;
211
+ S.id = v.id; S.props = v.props; S.H = H; S.open = new Set(); S.choices = {}; S.title = v.title;
212
+ VW.drill();
213
+ VW.open({ id: 'pp:' + v.id, kind: 'Claude proposes', title: 'Claude proposes' + (v.props && v.props.n ? ' ' + v.props.n : ''), sub: v.title, icon: I.spark,
214
+ presses: presses(v.props),
215
+ onPress: (act) => { if (act === 'all') keep([], true); },
216
+ render: (b) => { b.innerHTML = bodyHtml(S.props); if (!b.__pp) { b.__pp = true; } b.onclick = onPress; draw(); if (!S.props || S.props.look) fresh(); },
217
+ onClose: () => { clearTimeout(S.timer); if (S.id === v.id) S.id = null; } });
218
+ }
@@ -172,6 +172,9 @@ export function iniView(r, ctx = {}) {
172
172
  moves.forEach((m, i) => { const j = idx(m.to); if (j < 0) return; ran[j].from = m.at; const nx = moves[i + 1]; ran[j].to = nx ? nx.at : null; });
173
173
  if (cur >= 0 && tr.since) ran[cur].from = tr.since;
174
174
  if (list.length && !ran[0].from && r.start) ran[0].from = String(r.start).slice(0, 10);
175
+ // the dates a past stage really ran, as Claude found them elsewhere and the PM kept (batch 12 item 4): they lead over the board's moves
176
+ const fr = (r.found && r.found.ran) || {};
177
+ list.forEach((s, i) => { const f = fr[s.key] || fr[s.name]; if (!f) return; if (f.from) ran[i].from = f.from; if (f.to) ran[i].to = f.to; });
175
178
 
176
179
  /* the stage card */
177
180
  const st = cur >= 0 ? list[cur] : null;
@@ -265,7 +268,9 @@ export function iniView(r, ctx = {}) {
265
268
  const today2 = (n) => String(n).padStart(2, '0');
266
269
  return { vs: r.__vs || null, links: r.__vs && r.__vs.draft ? null : r.links || null, id: r.id || null, key: r.key, title: r.title, today: today.getFullYear() + '-' + today2(today.getMonth() + 1) + '-' + today2(today.getDate()), summary, stage, tasks, docs: ctx.docs != null ? ctx.docs : null, linked: linkedOf(r),
267
270
  // split or merge (batch 11 item 14): Claude's suggestion for it, and where its work went when it was merged
268
- suggest: r.suggest || null, merged: mergedOf(r) };
271
+ suggest: r.suggest || null, merged: mergedOf(r),
272
+ // what Claude proposes under the one blue ✦, and what a ✓ kept from elsewhere (batch 12 items 2, 3 and 4; pm/ini-props.js)
273
+ props: r.props || null, found: r.found || null };
269
274
  }
270
275
  /** A merged initiative's closing line (XsmA7Closed): the one that stays and the day. null for every other row. */
271
276
  export function mergedOf(r) {
@@ -564,6 +564,10 @@ button.lk-mt:hover { color: var(--cz-ink) !important; }
564
564
  .tkc.ivq.vs-pop.sheet .lk-m { width: 100%; box-sizing: border-box; }
565
565
  /* Group by and Send to Jira in Tasks (feedback batch 11 item 20; canvas In development, row "Tasks takes over the old All tasks panel"): pm/ini-groups.js */
566
566
  .iv-ib.ig-by.on { background: var(--cz-bluebg); color: var(--cz-blueink); }
567
+ /* the stage the stage card showed, while Tasks is grouped another way (batch 12 item 0): its name and a ✕ */
568
+ .iv-th .ig-only { display: inline-flex; align-items: center; gap: 4px; height: 28px; max-width: 160px; padding: 0 8px 0 10px; border: 0; border-radius: 999px; background: var(--cz-bluebg); color: var(--cz-blueink); font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 4px; }
569
+ .iv-th .ig-only svg { flex: none; opacity: .75; }
570
+ .iv-th .ig-only:hover svg { opacity: 1; }
567
571
  .iv-wsw, .ig-dz { position: relative; }
568
572
  .iv-wsw { display: flex; align-items: center; }
569
573
  .iv-wsw > .iv-ws { flex: 1; min-width: 0; }
@@ -603,3 +607,46 @@ button.lk-mt:hover { color: var(--cz-ink) !important; }
603
607
  .iv-th .ivx-seg { background: transparent; padding: 0; }
604
608
  .iv-th .ivx-seg .ivx-sb[aria-pressed="true"] { box-shadow: none; background: transparent !important; }
605
609
  }
610
+
611
+ /* ── what Claude proposes, under the one blue ✦ after the title (batch 12 items 2, 3 and 4; canvas PiA1–PiA5, TpA1–TpA5; pm/ini-props.js) ── */
612
+ .pp { display: flex; flex-direction: column; gap: 10px; color: var(--cz-ink); font-family: var(--cz-sans); }
613
+ .pp button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
614
+ .pp-p { border-radius: 14px; padding: 4px 0; }
615
+ .pp-p + .pp-p { border-top: 1px solid var(--cz-hair); }
616
+ .pp-ph1 { display: flex; align-items: flex-start; gap: 8px; padding: 6px 2px 6px 4px; }
617
+ .pp-ph1 .w, .pp-it .w { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
618
+ .pp-ph1 b { font-size: 13.5px; font-weight: 800; }
619
+ .pp-ph1 small, .pp-it small { font-size: 12.5px; color: var(--cz-ink2); line-height: 1.4; }
620
+ .pp-ph1 .pp-src { color: var(--cz-ink3); }
621
+ .pp-ph1 .pp-src em { font-style: normal; font-weight: 700; color: var(--cz-risk); }
622
+ .pp-ic { width: 28px; height: 28px; border-radius: 9px; background: var(--cz-bluebg); color: var(--cz-blueink); display: inline-flex; align-items: center; justify-content: center; flex: none; }
623
+ .pp-p.chk .pp-ic { background: var(--cz-well); color: var(--cz-ink2); }
624
+ .pp .pp-ib { width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--cz-ink2); flex: none; }
625
+ .pp .pp-ib:hover { background: var(--cz-well); color: var(--cz-ink); }
626
+ .pp .pp-ib.ok { color: var(--cz-blueink); }
627
+ .pp .pp-ib:focus-visible, .pp-seg button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
628
+ .pp-its { display: flex; flex-direction: column; gap: 2px; margin: 0 0 4px 40px; }
629
+ .pp-it { display: flex; align-items: center; gap: 8px; padding: 4px 0 4px 8px; border-left: 2px solid var(--cz-hair); }
630
+ .pp-it b { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
631
+ .pp-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--cz-well); flex: none; }
632
+ .pp-seg button { position: relative; width: 30px; height: 26px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--cz-ink3); }
633
+ .pp-seg button[aria-pressed="true"] { background: var(--cz-card); color: var(--cz-ink); box-shadow: var(--cz-vlift); }
634
+ .pp-seg button i { position: absolute; top: -2px; right: -1px; color: var(--cz-blue); line-height: 0; }
635
+ .pp-look { border-radius: 14px; background: var(--cz-bluebg); color: var(--cz-blueink); padding: 6px 6px 10px 12px; }
636
+ .pp-lh { display: flex; align-items: center; gap: 8px; }
637
+ .pp-lh b { flex: 1; font-size: 13px; font-weight: 800; }
638
+ .pp-look ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
639
+ .pp-look li { display: flex; gap: 8px; font-size: 12.5px; color: var(--cz-ink2); }
640
+ .pp-look li b { min-width: 84px; font-weight: 700; color: var(--cz-ink); }
641
+ .pp-look li.on span { color: var(--cz-blueink); }
642
+ .pp-look p { margin: 4px 0 0; font-size: 12.5px; }
643
+ .pp-none { margin: 8px 0; font-size: 13px; color: var(--cz-ink3); }
644
+ .pp-ph { border: 1.5px dashed var(--cz-hair); border-radius: 14px; padding: 14px 16px; }
645
+ .pp-ph p { margin: 0; font-size: 13px; color: var(--cz-ink2); }
646
+ /* the documents a ✓ kept from elsewhere, inline under Documents */
647
+ .iv-fds { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
648
+ .iv-fd { display: flex !important; flex-direction: column; gap: 1px; padding: 6px 8px !important; border-radius: 10px !important; color: var(--cz-ink); text-decoration: none; }
649
+ .iv-fd:hover { background: var(--cz-well) !important; }
650
+ .iv-fd b { font-size: 13px; font-weight: 700; }
651
+ .iv-fd small { font-size: 12px; color: var(--cz-ink3); }
652
+ @media (max-width: 760px) { .pp .pp-ib { width: 40px; height: 40px; } .pp-its { margin-left: 12px; } }
@@ -30,7 +30,8 @@
30
30
  import { wfIcon } from './wf-model.js';
31
31
  import * as TV from './ini-tasks.js'; // Tasks as List, Timeline or Kanban, and the quick status and dates (batch 9 item 5b)
32
32
  import * as VS from './ini-versions.js'; // planned versus actual: the version chip, Make live, a draft's writes (batch 11 item 8)
33
- import * as LK from './ini-links.js'; // links between tasks, Claude's proposals and quiet moves (batch 11 item 15)
33
+ import * as LK from './ini-links.js'; // links between tasks and quiet moves (batch 11 item 15)
34
+ import * as PP from './ini-props.js'; // what Claude proposes, under the one blue ✦ after the title (batch 12 items 2, 3 and 4)
34
35
  import * as G from './ini-groups.js'; // Group by and Send to Jira, in place of the old All tasks panel (batch 11 item 20)
35
36
  import { cardHtml as smCard, mergedHtml as smMerged } from './split-merge.js'; // split or merge: Claude's card, the merged summary (batch 11 item 14)
36
37
  import { lineHtml, fitLine } from './stage-line.js'; // the stage card's one line (batch 11 item 21)
@@ -185,6 +186,8 @@ function tasksHtml(v0, o) {
185
186
  o = { ...o, lk };
186
187
  const head = `<div class="iv-th"><b>Tasks</b>${cnt ? `<span class="n">${esc(cnt)}</span>` : ''}${LK.headHtml(lk)}${VS.headHtml(v.vs)}<span class="iv-sp"></span>${T.empty ? '' : TV.headExtraHtml(v, mode) + G.headHtml(v) + TV.switchHtml(mode)}${VS.liveHtml(v.vs)}${add}</div>`
187
188
  + (o.adding ? `<form class="iv-addf" data-iv-addform><input id="ivAddTask" type="text" maxlength="160" autocomplete="off" placeholder="A task for ${esc(v.title)}${o.addHint ? esc(', ' + o.addHint) : ''}" aria-label="New task"><button type="submit" class="iv-go" aria-label="Add the task" title="Add (Enter). Esc cancels.">${SVG(P.check, 16, 2.2)}</button></form>` : '');
189
+ // while Claude looks for a new initiative elsewhere, Tasks waits for what it finds (PiA1)
190
+ if (T.empty && PP.lookHtml(v)) return head + PP.lookHtml(v);
188
191
  if (T.empty) {
189
192
  const sk = T.empty.stages.map((s) => `<span class="iv-sk"><span class="iv-no dash${s.ms ? ' ms' : ''}" aria-hidden="true">${s.ms ? '' : s.n}</span>${esc(s.name)}${s.now ? ' <i>· now</i>' : ''}</span>`).join('');
190
193
  return head + `<div class="iv-empty">${sk}<p class="iv-q">Claude drafts the breakdown, one section per stage. Nothing is saved until you keep it.</p>`
@@ -196,15 +199,22 @@ function tasksHtml(v0, o) {
196
199
  if (mode === 'timeline') return top + `<div class="iv-tk">${TV.timelineHtml(v, q, fold)}</div>`;
197
200
  if (mode === 'kanban') return top + `<div class="iv-tk">${TV.kanbanHtml(v, q, fold)}</div>`;
198
201
  const ol = T.by === 'mine' ? { ...o, gdrag: !!o.quick } : o;
202
+ // the stage the card showed has no task: say so, and the ✕ in the header shows every stage again (batch 12 item 0)
203
+ if (T.only && !T.sections.length) return top + `<p class="iv-q ig-none">No tasks in ${esc(T.only)} yet.</p>`;
199
204
  return top + `<div class="iv-wbs">${T.sections.map((s) => sectionHtml(v, s, ol)).join('')}</div>`;
200
205
  }
201
206
  function foldsHtml(v, o) {
202
207
  const rows = [];
203
- if (o.docs && o.docs.n) {
204
- const op = o.docs.html ? isOpen(v, 'docs', false) : false;
205
- rows.push(`<button type="button" class="iv-fr" ${o.docs.html ? `data-iv-fold="docs" aria-expanded="${op}"` : 'data-iv-docs'}><b>Documents</b><span class="n">${o.docs.n}</span>${chev(op)}</button>` + (op ? `<div class="iv-fb">${o.docs.html}</div>` : ''));
208
+ // the documents a ✓ kept from elsewhere (batch 12 item 4) list inline under Documents, each with its source and date
209
+ const fd = PP.foundDocs(v);
210
+ const fdHtml = fd.map((d) => (/^https?:\/\//.test(d.ref) ? `<a class="iv-fd" href="${esc(d.ref)}" target="_blank" rel="noopener">` : '<span class="iv-fd">') + `<b>${esc(d.title)}</b>${d.meta ? `<small>${esc(d.meta)}</small>` : ''}` + (/^https?:\/\//.test(d.ref) ? '</a>' : '</span>')).join('');
211
+ if ((o.docs && o.docs.n) || fd.length) {
212
+ const n = ((o.docs && o.docs.n) || 0) + fd.length, inl = !!(o.docs && o.docs.html) || fd.length > 0;
213
+ const op = inl ? isOpen(v, 'docs', false) : false;
214
+ const own = o.docs && o.docs.n ? (o.docs.html || `<button type="button" class="iv-fd" data-iv-docs><b>Core documents</b><small>${o.docs.n}</small></button>`) : '';
215
+ rows.push(`<button type="button" class="iv-fr" ${inl ? `data-iv-fold="docs" aria-expanded="${op}"` : 'data-iv-docs'}><b>Documents</b><span class="n">${n}</span>${chev(op)}</button>` + (op ? `<div class="iv-fb">${own}${fd.length ? `<div class="iv-fds">${fdHtml}</div>` : ''}</div>` : ''));
206
216
  }
207
- const L = v.linked || [];
217
+ const L = (v.linked || []).concat(((v.found && v.found.linked) || []).map((x) => ({ kind: 'found', label: x.label, title: x.title, ref: x.ref })));
208
218
  if (L.length) {
209
219
  const op = isOpen(v, 'linked', false);
210
220
  const chip = (x) => (x.kind === 'doc' ? `<button type="button" class="iv-chip" data-iv-doc="${esc(x.path)}" title="${esc(x.path)}">${esc(x.label)}</button>` : `<span class="iv-chip"${x.title ? ` title="${esc(x.title)}"` : ''}>${esc(x.label)}</span>`);
@@ -212,7 +222,9 @@ function foldsHtml(v, o) {
212
222
  }
213
223
  return rows.length ? `<div class="iv-folds">${rows.join('')}</div>` : '';
214
224
  }
225
+ const VIEWED = new Map(); // initiative id → the view drawn last (the ✦ in the Viewer's header reads it)
215
226
  export function viewHtml(v, o = {}) {
227
+ if (v && v.id) VIEWED.set(v.id, v);
216
228
  // a merged initiative leads with where its work went, and draws no stage or tasks (they moved; its folds stay); an open one shows Claude's split or merge card under the summary (batch 11 item 14)
217
229
  const top = v.merged ? smMerged(v.merged) : summaryHtml(v.summary, o) + (o.sm !== false ? smCard(v.suggest, v.title) : '');
218
230
  return `<div class="iv" data-iv="${esc(v.id || v.key || '')}">${top}${v.merged ? '' : stageHtml(v.stage, o, v.id || v.key || '') + tasksHtml(v, o)}${foldsHtml(v, o)}${o.tail || ''}</div>`;
@@ -223,12 +235,15 @@ export function wireView(body, h) {
223
235
  if (!body) return;
224
236
  const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : null; };
225
237
  body.__iv = LK.wrap(VS.wrap(h, body, (id) => SHOWN.get(id)), idOf);
238
+ // the one blue ✦ after the title (pm/ini-props.js), drawn again with each draw of the initiative
239
+ const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); };
240
+ chip();
226
241
  G.attach(body, body.__iv); // the layout and the drafted tickets of the initiative shown (batch 11 item 20)
227
242
  if (body.__ivWired) return;
228
243
  body.__ivWired = true;
229
244
  // the stage line's labels are checked as drawn (pm/stage-line.js fitLine): after each draw and when the panel changes width
230
245
  if (typeof MutationObserver === 'function') {
231
- let q = 0; const fit = () => { if (q) return; q = requestAnimationFrame(() => { q = 0; fitLine(body); }); };
246
+ let q = 0; const fit = () => { if (q) return; q = requestAnimationFrame(() => { q = 0; fitLine(body); chip(); }); };
232
247
  new MutationObserver(fit).observe(body, { childList: true, subtree: true });
233
248
  if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(body);
234
249
  fit();
@@ -312,6 +327,8 @@ function later(b, pick) {
312
327
  }
313
328
  /** Show a stage (and one task of it) in Tasks: its section opens in the List and the Timeline, the Kanban turns to it. */
314
329
  function showIn(b, id, H, key, uid) {
330
+ // grouped by epic (or any grouping but Stage) there is no stage section to open: Tasks shows that stage's tasks only (batch 12 item 0)
331
+ if (key != null && !uid && G.onlyStage(id, key)) { if (H.redraw) H.redraw(); later(b, (root) => root.querySelector('.iv-th')); return; }
315
332
  if (key != null) { FOLD.set(id + '|sec:' + (key || 'none'), true); TV.setKanbanStage(id, key); }
316
333
  if (uid) { const v = SHOWN.get(id), f = v && findRow(v, uid); if (f && f.fold) FOLD.set(id + '|' + f.fold, true); }
317
334
  if (H.redraw) H.redraw();
@@ -64,7 +64,7 @@ export function liveItems(sessions, o = {}) {
64
64
  const out = [];
65
65
  const rec = o.rec;
66
66
  if (rec && rec.on && !rec.here) {
67
- out.push({ id: 'rec:' + rec.id, kind: 'rec', mark: 'rec', name: rec.title || 'Meeting', sub: 'Meeting', time: clock(elapsed(rec, now)), at: now, href: rec.href || '/premium.html', paused: !!rec.paused, open: false });
67
+ out.push({ id: 'rec:' + rec.id, kind: 'rec', mark: 'rec', name: rec.title || 'Meeting', sub: rec.silent ? 'Not hearing the meeting' : 'Meeting', time: clock(elapsed(rec, now)), at: now, href: rec.href || '/premium.html', paused: !!rec.paused, open: false });
68
68
  }
69
69
  const rows = [];
70
70
  for (const s of Array.isArray(sessions) ? sessions : []) {
@@ -19,7 +19,8 @@
19
19
  * Where no record holds a value for an initiative, the element says so: nothing is invented. */
20
20
  import { pmPost } from './http.js';
21
21
  import { followDoc } from './doc-follow.js';
22
- import { $, $$, esc, store, crumbHtml, wireCrumb, chatAbout, setPageGaps } from './premium-shell.js';
22
+ import { $, $$, esc, store, chatAbout, setPageGaps } from './premium-shell.js';
23
+ import * as PK from './cozy-pick.js'; // the one product picker Home, Board and Insights share (batch 12 item 5)
23
24
  import { mountNav } from './cozy-nav.js';
24
25
  import { mountLivePill } from './cozy-live-pill.js';
25
26
  import { stepsHelpHtml } from './bd-stages.js';
@@ -58,9 +59,14 @@ const F = { chips: new Set(), q: '', owners: new Set(), cats: new Set(), sprints
58
59
  let GR = {}; // the first questions still open per initiative (GET /api/board-grill?ids=): { [id]: { open, total, later } }
59
60
  let PGS = []; // the programs (GET /api/programs): every view groups the rows a program holds under it (PgBoard)
60
61
  let XR = {}; // the other products' rows a program here holds, read once (GET /api/board-premium?ws=): { [ws]: { name, rows } }
61
- // the products picked (batch 11 item 7): ?all=1 every product, ?pick=<ws>|<board> repeated several, else one board
62
- const PICK = new URLSearchParams(location.search).getAll('pick').filter((x) => /\|/.test(x));
63
- const ALL = new URLSearchParams(location.search).get('all') === '1' || PICK.length > 1; // All products, or several: their boards on one page (PgBoard)
62
+ // the boards shown: the one product pick Home and Insights share (batch 12 item 5, saved, never in the address), read at the first load
63
+ // (resolvePick). A link with ?ws=&board= (or the older ?all=1, ?pick=<ws>|<board>) is a one-off view: it shows that and leaves the pick alone.
64
+ const Q0 = new URLSearchParams(location.search);
65
+ let PICK = Q0.getAll('pick').filter((x) => /\|/.test(x));
66
+ let ALL = Q0.get('all') === '1' || PICK.length > 1; // All products, or several: their boards on one page (PgBoard)
67
+ const DEEP = ALL || PICK.length > 0 || Q0.has('ws') || Q0.has('board');
68
+ let ONE = null; // the one ticked product's board, 'ws|id', when the pick holds one
69
+ let PKP = null, picked = false; // the saved pick (GET /api/briefing-premium/products), and whether it has been turned into boards
64
70
  let byProduct = store.get(GROUPING_KEY) === 'product'; // the grouping: programs first (default) or By product (PgBoardProduct)
65
71
  let DM = {}; // the documents' history (GET /api/board-docs): { [path]: { changed, by, log } }
66
72
  let peek = null; // what the Viewer shows for the Board: { kind: 'ini', key } an initiative or its ticket, { kind: 'acts' } an acts panel
@@ -138,27 +144,50 @@ function say(msg, undo) {
138
144
  clearTimeout(toastT); toastT = setTimeout(() => { t.hidden = true; }, undo ? 10000 : 5000);
139
145
  }
140
146
 
147
+ /* ── the product chip (batch 12 item 5, canvas XhpA5Pages): the same chip and list as Home's; it replaces "pmos-idpf +1" ── */
148
+ /** The pick as this page shows it: the saved one, or for a one-off link the products on screen. */
149
+ function shownPick() {
150
+ if (!PKP) return null;
151
+ if (!DEEP) return PKP;
152
+ const ws = new Set(M.board.all ? (M.board.products || []).map((p) => p.ws) : [M.board.ws]);
153
+ return { ...PKP, products: PKP.products.map((p) => ({ ...p, on: ws.has(p.ws) })) };
154
+ }
155
+ function drawPick() {
156
+ const P = shownPick(), host = $('#crumbHost'); if (!host) return;
157
+ host.innerHTML = P ? PK.chipHtml(P, { id: 'bdPick', label: 'Products' }) : `<span class="crpg">${esc(M.board.name || 'Board')}</span>`;
158
+ const chip = $('#bdPick'); if (!chip) return;
159
+ // a product's line: its open initiatives on this page (zero is silence)
160
+ const lines = (ws) => { const rows = (M.initiatives.list.rows || []).filter((r) => (M.board.all ? r.ws === ws : M.board.ws === ws)); return rows.length ? rows.length + (rows.length === 1 ? ' initiative' : ' initiatives') : ''; };
161
+ chip.onclick = (e) => { e.stopPropagation(); PK.openPicker(chip, { P: shownPick(), label: 'Products', lines, note: 'One pick for Home, Board and Insights: unticking a product here also takes it off Home.', onApply: async (on) => { const r = await PK.savePick(on); if (!r.ok) say(r.error); } }); };
162
+ }
163
+ // a saved pick (this chip, or Settings): the Board opens on the ticked products, without a one-off link's ws or board
164
+ addEventListener('pp:changed', () => { const q = new URLSearchParams(location.search); ['ws', 'board', 'all', 'pick'].forEach((k) => q.delete(k)); const s = q.toString(); location.assign(location.pathname + (s ? '?' + s : '')); });
165
+ /** Turn the saved pick into the boards to read: every product's board (All), several (PICK), one (ONE) or the default board. false while the
166
+ * default board is still being read (its switcher lists the boards). A one-off link keeps its own. */
167
+ async function resolvePick() {
168
+ if (picked) return true;
169
+ if (!PKP) PKP = await PK.readPick();
170
+ if (DEEP || !PKP) { picked = true; return true; }
171
+ const h = await readBoard('');
172
+ if (h.r && h.r.state === 'reading') return false;
173
+ picked = true;
174
+ const sw = (h.r && h.r.ok && h.r.model && h.r.model.board.switcher) || null;
175
+ if (!sw) return true; // one board: nothing to pick between
176
+ const on = new Set(PKP.products.filter((p) => p.on).map((p) => p.ws)), keys = sw.filter((b) => on.has(b.ws)).map((b) => b.ws + '|' + b.id);
177
+ if (!keys.length) return true;
178
+ if (keys.length === sw.length) { ALL = true; PICK = []; return true; }
179
+ if (keys.length === 1) { ONE = keys[0]; return true; }
180
+ PICK = keys; ALL = true;
181
+ return true;
182
+ }
183
+
141
184
  /* ── the toolbar: picker, chips ───────────────────────────────────────────────────────────────────────────────────── */
142
185
  let crumbed = false;
143
186
  function drawHead() {
144
187
  if (!crumbed) {
145
188
  crumbed = true;
146
- // the picker: All products first when there is more than one product, then each product's board
147
- const list = M.board.switcher || [], boards = list.length > 1 ? [{ ws: '*', id: '*', name: 'All products' }, ...list] : list;
148
- // the button says it once: All products, the one product, or the first product and "+N" (several)
189
+ drawPick();
149
190
  const names = (M.board.products || []).map((p) => p.name), some = ALL && PICK.length > 1;
150
- const label = some ? esc(names[0] || 'Products') + ' <b>+' + (names.length - 1) + '</b>' : esc(M.board.name || 'Board');
151
- $('#crumbHost').innerHTML = crumbHtml({ page: '', board: M.board.name || 'Board', boards });
152
- $('#crBoard').innerHTML = label;
153
- // several products can be ticked (batch 11 item 7); the pick goes into the address, so a reload keeps it
154
- const picked = !ALL ? [M.board.ws + '|' + M.board.id] : (M.board.products || []).map((p) => p.ws + '|' + p.id);
155
- const goBoard = (ws, id) => location.assign(id === '*' ? '/premium-board.html?all=1' : '/premium-board.html?ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(id));
156
- wireCrumb({ boards, board: ALL ? '*' : M.board.id, goBoard, picked: list.length > 1 ? picked : null, goPicked: (keys) => {
157
- if (keys.length === list.length) return goBoard('*', '*');
158
- if (keys.length === 1) { const [ws, id] = keys[0].split('|'); return goBoard(ws, id); }
159
- location.assign('/premium-board.html?' + keys.map((k) => 'pick=' + encodeURIComponent(k)).join('&'));
160
- } });
161
- $('#crBoard').setAttribute('aria-label', 'Product: ' + (some ? names.join(', ') : M.board.name || 'Board'));
162
191
  chatAbout('board:this-board', some ? 'the ' + names.join(', ') + ' boards' : ALL ? 'all products' : M.board.name ? 'the ' + M.board.name + ' board' : 'this board');
163
192
  }
164
193
  $('#snap').textContent = M.header.text;
@@ -881,15 +910,17 @@ async function readAll(q) {
881
910
  return { r: { ok: true, model, stale: got.some((g) => g.r && g.r.stale) || h.r.stale }, status: 200 };
882
911
  }
883
912
  async function load() {
884
- const p = new URLSearchParams(location.search), [pw, pb] = PICK.length > 1 ? PICK[0].split('|') : [p.get('ws'), p.get('board')], q = [pw ? 'ws=' + encodeURIComponent(pw) : '', pb ? 'board=' + encodeURIComponent(pb) : ''].filter(Boolean).join('&');
885
- const { r, status } = ALL ? await readAll(q) : await readBoard(q);
886
- clearInterval(readTimer);
887
- if (r && r.state === 'reading') {
913
+ // while the board is read (the pick's default board, then the picked ones) the page says so and shows no row instead of a guess
914
+ const reading = () => {
888
915
  const t0 = Date.now(), tick = () => { const s = 'Reading the board · ' + Math.round((Date.now() - t0) / 1000) + ' s so far'; $('#snap').textContent = s; if (!M) $('#ibBody').innerHTML = `<p class="bd-msg"><b>${esc(s)}</b> The board derives each initiative from its records. This page shows nothing until it has read, rather than guess.</p>`; };
889
916
  tick(); readTimer = setInterval(tick, 1000);
890
917
  setTimeout(load, 3000);
891
- return;
892
- }
918
+ };
919
+ if (!(await resolvePick())) { clearInterval(readTimer); reading(); return; }
920
+ const p = new URLSearchParams(location.search), [pw, pb] = PICK.length > 1 ? PICK[0].split('|') : ONE ? ONE.split('|') : [p.get('ws'), p.get('board')], q = [pw ? 'ws=' + encodeURIComponent(pw) : '', pb ? 'board=' + encodeURIComponent(pb) : ''].filter(Boolean).join('&');
921
+ const { r, status } = ALL ? await readAll(q) : await readBoard(q);
922
+ clearInterval(readTimer);
923
+ if (r && r.state === 'reading') { reading(); return; }
893
924
  if (!r || !r.ok) {
894
925
  $('#snap').textContent = 'The board could not be read';
895
926
  if (!M) $('#ibBody').innerHTML = `<p class="bd-msg err" role="alert"><b>The board could not be read</b>, so this page shows nothing rather than guess.${r && r.error ? ' The reason: ' + esc(r.error) : status ? ' The server answered ' + status + '.' : ' The server did not answer.'}</p>`;