create-pmos 0.427.0 → 0.429.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 (147) hide show
  1. package/package.json +25 -25
  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/board-programs-test.js +16 -2
  7. package/workspace/briefing-premium-board-test.js +27 -22
  8. package/workspace/briefing-premium-insights-test.js +81 -60
  9. package/workspace/briefing-premium-metrics-test.js +5 -3
  10. package/workspace/briefing-premium-sources-test.js +5 -5
  11. package/workspace/briefing-premium-test.js +7 -5
  12. package/workspace/changelog.json +24 -0
  13. package/workspace/ev-everywhere-test.js +2 -2
  14. package/workspace/guide/briefing-premium.md +4 -2
  15. package/workspace/guide/home.md +34 -7
  16. package/workspace/guide/index.md +1 -0
  17. package/workspace/guide/metric-drafts.md +48 -0
  18. package/workspace/guide/programs.md +1 -0
  19. package/workspace/home-other-product-test.js +12 -2
  20. package/workspace/intel-report-ui-test.js +189 -0
  21. package/workspace/lib/board-metrics-premium.js +1 -1
  22. package/workspace/lib/headless.js +15 -2
  23. package/workspace/lib/insights-premium.js +5 -1
  24. package/workspace/lib/insights-records.js +14 -5
  25. package/workspace/lib/intel-report.js +419 -0
  26. package/workspace/lib/metric-draft-runs.js +193 -0
  27. package/workspace/lib/metric-drafts.js +231 -0
  28. package/workspace/lib/metrics-cli.js +104 -0
  29. package/workspace/lib/pmos-verbs.js +3 -0
  30. package/workspace/lib/report-setups.js +29 -13
  31. package/workspace/lib/route-modules.js +1 -0
  32. package/workspace/lib/routes-insights-premium.js +2 -2
  33. package/workspace/lib/routes-insights-records.js +13 -5
  34. package/workspace/lib/routes-meeting-material.js +22 -1
  35. package/workspace/lib/routes-metric-drafts.js +141 -0
  36. package/workspace/lib/routes-phone-day.js +13 -2
  37. package/workspace/lib/routes-report-setups.js +92 -3
  38. package/workspace/lib/routes-viewer.js +5 -2
  39. package/workspace/lib/settings-store.js +14 -0
  40. package/workspace/metric-drafts-ui-test.js +209 -0
  41. package/workspace/milestone-pins-test.js +13 -0
  42. package/workspace/milestone-suggest-test.js +10 -4
  43. package/workspace/package-lock.json +2 -2
  44. package/workspace/package.json +1 -1
  45. package/workspace/premium-board-actions-test.js +40 -13
  46. package/workspace/premium-phone-card-test.js +8 -5
  47. package/workspace/premium-rec-tab-test.js +8 -0
  48. package/workspace/premium-vw-item-test.js +7 -3
  49. package/workspace/premium-vw-jira-test.js +2 -1
  50. package/workspace/program-charter-test.js +1 -1
  51. package/workspace/program-leave-test.js +2 -2
  52. package/workspace/program-order-test.js +3 -2
  53. package/workspace/program-panel-test.js +2 -1
  54. package/workspace/public/pm/bd-acts.js +23 -29
  55. package/workspace/public/pm/bd-ini-panel.js +90 -32
  56. package/workspace/public/pm/bd-pin-card.css +4 -4
  57. package/workspace/public/pm/bd-pin-card.js +4 -1
  58. package/workspace/public/pm/bd-prog-panel.js +9 -4
  59. package/workspace/public/pm/bd-span.js +22 -12
  60. package/workspace/public/pm/cozy-aud.css +1 -1
  61. package/workspace/public/pm/cozy-board.css +256 -256
  62. package/workspace/public/pm/cozy-ev.css +45 -45
  63. package/workspace/public/pm/cozy-evmodel.js +1 -1
  64. package/workspace/public/pm/cozy-home-rows.css +23 -23
  65. package/workspace/public/pm/cozy-home.css +207 -207
  66. package/workspace/public/pm/cozy-insights.css +207 -108
  67. package/workspace/public/pm/cozy-live-pill.css +5 -5
  68. package/workspace/public/pm/cozy-mtg-present.css +23 -23
  69. package/workspace/public/pm/cozy-nav.js +1 -1
  70. package/workspace/public/pm/cozy-news.js +2 -2
  71. package/workspace/public/pm/cozy-panel.css +29 -29
  72. package/workspace/public/pm/cozy-pick.css +5 -5
  73. package/workspace/public/pm/cozy-rec-now.css +20 -20
  74. package/workspace/public/pm/cozy-rec-present.css +11 -11
  75. package/workspace/public/pm/cozy-rec-tab.css +13 -13
  76. package/workspace/public/pm/cozy-rec-tab.js +12 -3
  77. package/workspace/public/pm/cozy-settings.js +1 -1
  78. package/workspace/public/pm/cozy-steps.css +9 -9
  79. package/workspace/public/pm/cozy-today.css +107 -71
  80. package/workspace/public/pm/cozy-viewer.css +7 -7
  81. package/workspace/public/pm/cozy-viewer.js +157 -23
  82. package/workspace/public/pm/cozy-vw-mtg.css +81 -81
  83. package/workspace/public/pm/cozy-vw-rp.css +53 -53
  84. package/workspace/public/pm/cozy-vw-shell.css +34 -21
  85. package/workspace/public/pm/cozy-vw.css +117 -117
  86. package/workspace/public/pm/cozy-xv.css +11 -11
  87. package/workspace/public/pm/cozy.css +18 -15
  88. package/workspace/public/pm/hi-pop.css +82 -0
  89. package/workspace/public/pm/hi-pop.js +65 -0
  90. package/workspace/public/pm/home-app.js +83 -28
  91. package/workspace/public/pm/home-day.js +131 -26
  92. package/workspace/public/pm/home-ini.css +38 -108
  93. package/workspace/public/pm/home-ini.js +50 -68
  94. package/workspace/public/pm/home-line.css +7 -7
  95. package/workspace/public/pm/home-list.js +41 -4
  96. package/workspace/public/pm/home-phone-card.js +18 -15
  97. package/workspace/public/pm/home-today.js +18 -7
  98. package/workspace/public/pm/ini-more.js +67 -0
  99. package/workspace/public/pm/ini-view-model.js +3 -2
  100. package/workspace/public/pm/ini-view.css +104 -102
  101. package/workspace/public/pm/ini-view.js +16 -8
  102. package/workspace/public/pm/loose-props.css +13 -13
  103. package/workspace/public/pm/metric-drafts.css +82 -0
  104. package/workspace/public/pm/metric-drafts.js +165 -0
  105. package/workspace/public/pm/ms-suggest.css +8 -8
  106. package/workspace/public/pm/order-model.js +85 -0
  107. package/workspace/public/pm/ov-view.css +12 -12
  108. package/workspace/public/pm/premium-board.js +57 -11
  109. package/workspace/public/pm/premium-chart-tab.js +6 -6
  110. package/workspace/public/pm/premium-insights.js +306 -105
  111. package/workspace/public/pm/premium-report-intel.css +56 -0
  112. package/workspace/public/pm/premium-report-intel.js +232 -0
  113. package/workspace/public/pm/premium-shell.js +2 -2
  114. package/workspace/public/pm/premium-vw-file.js +2 -2
  115. package/workspace/public/pm/premium-vw-item.js +3 -1
  116. package/workspace/public/pm/premium-vw-jira.js +2 -0
  117. package/workspace/public/pm/premium.css +127 -128
  118. package/workspace/public/pm/prog-order.css +6 -6
  119. package/workspace/public/pm/prog-order.js +15 -2
  120. package/workspace/public/pm/program-charter.css +23 -23
  121. package/workspace/public/pm/rp-parts.js +2 -2
  122. package/workspace/public/pm/sort-order.css +17 -0
  123. package/workspace/public/pm/sort-order.js +108 -0
  124. package/workspace/public/pm/split-merge.css +15 -15
  125. package/workspace/public/pm/task-card.css +21 -21
  126. package/workspace/public/pm/tk-tasks.css +37 -37
  127. package/workspace/public/pm/tk-view.css +6 -6
  128. package/workspace/public/pm/tk-view.js +3 -2
  129. package/workspace/public/pm/wf-page.css +28 -28
  130. package/workspace/public/pm/wf-page.js +1 -1
  131. package/workspace/public/premium-board.html +1 -0
  132. package/workspace/public/premium-intelligence.html +82 -0
  133. package/workspace/server.js +38 -3
  134. package/workspace/skills/metric-draft.skill +47 -0
  135. package/workspace/sort-order-test.js +201 -0
  136. package/workspace/stage-card-test.js +1 -0
  137. package/workspace/task-card-test.js +1 -1
  138. package/workspace/test-lists/intel-report-ui.json +5 -0
  139. package/workspace/test-lists/intel-report.json +9 -0
  140. package/workspace/test-lists/metric-drafts-ui.json +5 -0
  141. package/workspace/test-lists/metric-drafts.json +9 -0
  142. package/workspace/test-lists/sort-order.json +6 -0
  143. package/workspace/test-lists/viewer-trail.json +5 -0
  144. package/workspace/test-run.js +3 -0
  145. package/workspace/tk-tasks-test.js +5 -3
  146. package/workspace/viewer-trail-test.js +145 -0
  147. package/workspace/public/premium-insights.html +0 -81
@@ -27,6 +27,8 @@
27
27
  * page; the phone keeps the Documents | Stage switch. */
28
28
  import * as MD from './home-ini-model.js';
29
29
  import * as WF from './ini-wf.js';
30
+ import { openPop, closePop, undoToast, popEl, ensureCss as ensurePopCss } from './hi-pop.js';
31
+ import { iniMore, iniText, pageHref } from './ini-more.js'; // the one initiative ⋯ menu, the same on the Board (batch 14 item 5) // the popovers and the toast with Undo, shared with the Board
30
32
  import * as SC from './home-stage-card.js';
31
33
  import { viewHtml, wireView } from './ini-view.js'; // the one initiative view, the Board's panel's own renderer
32
34
  import { ensureCss as ensureStepsCss } from './cozy-steps.js'; // stage card D: the card's last node and the move sheet's words // D99: the initiative's own workflow (Change picker, switch, Won't do, Archive)
@@ -39,7 +41,7 @@ const I = {
39
41
  };
40
42
  const PHONE = 760;
41
43
  const isPhone = () => innerWidth <= PHONE;
42
- const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'page', doc: { by: 'stage', filter: 'all', more: new Set() }, pop: null, toastT: 0 };
44
+ const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'page', doc: { by: 'stage', filter: 'all', more: new Set() } };
43
45
 
44
46
  /* ── reading the layout record ── */
45
47
  const curM = () => { const S = X.ctx && X.ctx.S; return S && S.ini && S.ini !== 'product' && S.IMid === S.ini ? S.IM : null; };
@@ -104,15 +106,6 @@ async function doMove(id, M, to, why, o = {}) {
104
106
  await X.ctx.load();
105
107
  return true;
106
108
  }
107
- function undoToast(text, undo) {
108
- let el = document.getElementById('hiToast');
109
- if (!el) { el = document.createElement('div'); el.id = 'hiToast'; el.className = 'hi-toast'; el.setAttribute('role', 'status'); el.setAttribute('aria-live', 'polite'); document.body.appendChild(el); }
110
- el.innerHTML = `<span>${esc(text)}</span><button type="button" data-hi-undo>Undo</button>`;
111
- el.hidden = false; el.classList.add('on');
112
- el.querySelector('[data-hi-undo]').onclick = () => { hide(); undo(); };
113
- const hide = () => { el.classList.remove('on'); el.hidden = true; };
114
- clearTimeout(X.toastT); X.toastT = setTimeout(hide, 9000);
115
- }
116
109
  function autoCheck(id, M, mv) {
117
110
  const L = Lof(id);
118
111
  if (!L.read || !mv.autoReady) return;
@@ -122,42 +115,7 @@ function autoCheck(id, M, mv) {
122
115
  doMove(id, M, mv.next, MD.whyOf('auto'), { auto: true });
123
116
  }
124
117
 
125
- /* ── the popovers: Move anyway, Back, and the small menus ── */
126
- function closePop() {
127
- if (!X.pop) return;
128
- const a = X.pop.anchor; X.pop.el.remove(); if (X.pop.scrim) X.pop.scrim.remove(); X.pop = null;
129
- if (a && a.isConnected) { a.setAttribute('aria-expanded', 'false'); try { a.focus(); } catch { /* gone */ } }
130
- }
131
- function openPop(anchor, kind, html, onClick, o = {}) {
132
- closePop();
133
- const el = document.createElement('div');
134
- const sheet = isPhone() && !o.menu;
135
- el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '') + (o.wide ? ' wide' : '');
136
- el.setAttribute('role', o.role || (o.menu ? 'menu' : 'dialog')); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
137
- el.innerHTML = (sheet ? '<div class="hi-grab" aria-hidden="true"></div>' : '') + html;
138
- let scrim = null;
139
- if (sheet) { scrim = document.createElement('div'); scrim.className = 'hi-scrim'; scrim.onclick = closePop; document.body.appendChild(scrim); }
140
- document.body.appendChild(el);
141
- if (!sheet) { // under the button that opened it, kept inside the window: run-time geometry, set as two custom properties
142
- const r = anchor.getBoundingClientRect(), w = el.offsetWidth, hh = el.offsetHeight;
143
- const col = !o.menu && anchor.closest('#hmList'); // a dialog from the list column opens beside the column (InStage), not over it
144
- let x, y;
145
- if (col) { const c = col.getBoundingClientRect(); x = c.right + 12; y = Math.min(innerHeight - hh - 12, Math.max(12, r.top - 60)); }
146
- else { x = r.left + w > innerWidth - 12 ? r.right - w : r.left; y = r.bottom + 8 + hh > innerHeight - 12 ? r.top - hh - 8 : r.bottom + 8; }
147
- x = Math.max(12, Math.min(innerWidth - w - 12, x)); y = Math.max(12, y);
148
- el.style.setProperty('--hi-x', Math.round(x) + 'px'); el.style.setProperty('--hi-y', Math.round(y) + 'px');
149
- }
150
- anchor.setAttribute('aria-expanded', 'true');
151
- X.pop = { el, scrim, anchor, kind };
152
- el.addEventListener('click', (e) => { const b = e.target.closest('button'); if (b && !b.disabled) onClick(b, el); });
153
- el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); closePop(); } });
154
- const f = el.querySelector((sheet && o.sheetFocus) || o.focus || 'input, textarea, button:not([disabled])'); if (f) setTimeout(() => f.focus(), 0);
155
- return el;
156
- }
157
- // Escape closes the popover first: on window in the capture phase, so Home's own Escape (the phone's list sheet, the Viewer) waits for the next press
158
- if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && X.pop) { e.stopPropagation(); e.preventDefault(); closePop(); } }, true);
159
- if (typeof document !== 'undefined') document.addEventListener('mousedown', (e) => { if (X.pop && !X.pop.el.contains(e.target) && !(X.pop.anchor && X.pop.anchor.contains(e.target)) && !(X.pop.scrim && X.pop.scrim === e.target)) closePop(); }, true);
160
-
118
+ /* ── the popovers: Move anyway, Back, and the small menus (the kit is pm/hi-pop.js, shared with the Board) ── */
161
119
  function popMove(anchor, id, M, mv) {
162
120
  const title = X.ctx.iniTitle(id);
163
121
  const ck = mv.items.map((x) => `<span class="hi-ck${x.done ? ' on' : ''}"><i aria-hidden="true">${x.done ? SVG(I.check, 10, 3.5) : ''}</i>${esc(x.label)}</span>`).join('');
@@ -226,7 +184,7 @@ function menu(anchor, items, label) {
226
184
  function ask(anchor, label, value, go, o = {}) { // one line of words, inline (no browser prompt)
227
185
  openPop(anchor, 'ask', `<label class="hi-field"><span>${esc(label)}</span><input id="hiAsk" maxlength="${o.max || 40}" autocomplete="off" value="${esc(value || '')}"></label><div class="hi-acts"><button type="button" class="hi-btn dark" data-hi-go>Save</button><button type="button" class="hi-btn ghost" data-hi-x>Cancel</button></div>`,
228
186
  (b, el) => { if ('hiX' in b.dataset) { closePop(); return; } if ('hiGo' in b.dataset) { const v = el.querySelector('#hiAsk').value.trim(); if (!v) return; closePop(); go(v); } }, { label });
229
- const i = X.pop.el.querySelector('#hiAsk');
187
+ const i = popEl().querySelector('#hiAsk');
230
188
  i.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); const v = i.value.trim(); if (v) { closePop(); go(v); } } });
231
189
  }
232
190
 
@@ -366,29 +324,52 @@ async function setDates(id, uid, patch) {
366
324
  if (k || (r.from && ('start' in r.from || 'due' in r.from))) undoToast('Dates saved: ' + (k ? k.title : uid + ', kept in PMOS') + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
367
325
  else C.toast('Dates saved.');
368
326
  }
369
- /** ⋯ of the page (HbCMore): change it, look at it elsewhere, then stop it, red and last. */
327
+ /** ⋯ of the page: the ONE initiative menu (pm/ini-more.js, feedback batch 14 item 5), the same words and order as the Board's panel.
328
+ * This page says which items apply and what each press does; the menu decides the order. */
370
329
  function pageMore(id) {
371
330
  const M = curM(); if (!M) return [];
372
- const mv = mvOf(id, M), out = [], row = rowOf(id), self = !!(M.acts && M.acts.self);
373
- // D99 (WfAWontDo): Change workflow and Rename first; the PMOS-self board keeps its derived ladder, so it has no workflow to change
374
- if (!self && !row.ended) out.push({ label: 'Change workflow', note: (row.wf || {}).name || 'Product feature', on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) });
375
- if (X.ctx.renameIni) out.push({ label: 'Rename', on: () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } });
376
- if (!mv.why) out.push({ label: 'Moves on by itself', note: mv.auto ? 'On' : 'Off', on: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) });
377
- if (mv.canBack) out.push({ label: 'Move back a stage', note: mv.prev, on: (b) => popBack(b || document.querySelector('#czViewer [data-cz-vw="more"]'), id, M, mv) });
378
- if ((M.acts.stages || []).length && !M.acts.self) out.push({ label: 'Move to a stage', on: () => iniOverview('stage', { back: true }) });
379
- out.push({ label: 'Add a stakeholder', on: () => X.ctx.addPerson() });
380
- // P7: an initiative in no program can become one; one in a program can move out of it or to another (batch 11 item 2, canvas LpA1More)
381
- const pm = X.ctx.moveItems ? X.ctx.moveItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], 'Move to another program')) : [];
382
- if (X.ctx.turnProgram && !pm.length) out.push({ label: 'Turn into a program', on: () => X.ctx.turnProgram(id) });
383
- // split it into a new initiative, or merge it into another, above the program moves (batch 11 item 14, canvas XsmA1Menu)
384
- const sm = X.ctx.smItems && !row.ended ? X.ctx.smItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], label)) : [];
385
- if (sm.length || pm.length) out.push({ sep: true }, ...sm, ...pm);
386
- out.push({ sep: true }, { label: 'Open on the Board', on: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); } },
387
- { label: 'The record', on: async () => (X.ctx.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }) });
388
- // Won't do and Archive hold from any stage (wfRules); Won't do comes back to Triage. Cancel stays red and last (HbCMore)
389
- if (!self) out.push({ sep: true }, row.ended ? { label: 'Back to Triage', on: () => WF.backToTriage(wfUi(), id) } : { label: 'Won’t do', on: (b) => WF.openWontDo(b || moreBtn(), wfUi(), id) }, { label: 'Archive', on: () => WF.archive(wfUi(), id) });
390
- if (!M.acts.life && !row.ended) out.push({ sep: true }, { label: 'Put on hold', on: () => { iniOverview('stage', { back: true, ask: 'on-hold' }); } }, { label: 'Cancel the initiative', danger: true, on: () => { iniOverview('stage', { back: true, ask: 'cancelled' }); } });
391
- return out;
331
+ const C = X.ctx, mv = mvOf(id, M), row = rowOf(id), self = !!(M.acts && M.acts.self), B = (C.S.D && C.S.D.board) || {};
332
+ const openList = (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], label);
333
+ const copy = (t, said) => navigator.clipboard.writeText(t).then(() => C.toast(said), () => C.toast('This browser did not allow the copy.'));
334
+ const ask = (q) => { if (C.askIn) C.askIn(id, q); };
335
+ return iniMore({
336
+ // D99 (WfAWontDo): the PMOS-self board keeps its derived ladder, so it has no workflow to change
337
+ wf: !self && !row.ended ? { name: (row.wf || {}).name, on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) } : null,
338
+ rename: C.renameIni ? () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } : null,
339
+ auto: !mv.why ? { on: mv.auto, press: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) } : null,
340
+ back: mv.canBack ? { prev: mv.prev, on: (b) => popBack(b || moreBtn(), id, M, mv) } : null,
341
+ toStage: (M.acts.stages || []).length && !self ? () => iniOverview('stage', { back: true }) : null,
342
+ dates: C.askIn ? () => ask('Propose new start and end dates for ' + C.iniTitle(id)) : null,
343
+ person: () => C.addPerson(),
344
+ // split or merge, then the program moves (batch 11 items 2 and 14)
345
+ sm: C.smItems && !row.ended ? C.smItems(id, openList) : [],
346
+ pm: C.moveItems ? C.moveItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], 'Move to another program')) : [],
347
+ turnProgram: C.turnProgram ? () => C.turnProgram(id) : null,
348
+ jira: B.jira ? () => readJira(M) : null,
349
+ board: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); },
350
+ record: async () => (C.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }),
351
+ link: () => copy(new URL(pageHref(id, M.board.ws, M.board.id), location.href).href, 'Link copied.'),
352
+ text: () => copy(iniText(C.iniTitle(id), C.view ? C.view(id) : null, (row.track && row.track.tickets) || []), 'Copied as text.'),
353
+ ended: !!row.ended,
354
+ wontDo: !self ? (b) => WF.openWontDo(b || moreBtn(), wfUi(), id) : null,
355
+ backToTriage: !self ? () => WF.backToTriage(wfUi(), id) : null,
356
+ archive: !self ? () => WF.archive(wfUi(), id) : null,
357
+ hold: !M.acts.life && !row.ended ? () => iniOverview('stage', { back: true, ask: 'on-hold' }) : null,
358
+ resume: M.acts.life === 'hold' && !row.ended ? () => resume(id, M) : null,
359
+ cancel: !M.acts.life && !row.ended ? () => iniOverview('stage', { back: true, ask: 'cancelled' }) : null,
360
+ });
361
+ }
362
+ /** Resume an initiative on hold (POST /api/lifecycle, the Stage view's Resume and the Board's). */
363
+ async function resume(id, M) {
364
+ const r = await X.ctx.pmPost('/api/lifecycle', { ws: M.board.ws, initiative_id: id, state: 'active', reason: 'resumed' });
365
+ if (!r || r.ok === false) { X.ctx.toast((r && r.error) || 'Nothing was changed.'); return; }
366
+ X.ctx.toast('Resumed · ' + X.ctx.iniTitle(id) + '.'); await X.ctx.load(); redrawView();
367
+ }
368
+ /** Read Jira again (the Board's press): the initiative's product reads its Jira source again; the page reads the Board after it lands. */
369
+ async function readJira(M) {
370
+ const r = await X.ctx.pmPost('/api/sources/refresh', { ws: M.board.ws, source: 'jira' });
371
+ X.ctx.toast(r && r.ok ? 'Reading Jira again. The page shows it when the read lands.' : 'Jira was not read again: ' + ((r && r.error) || 'the server did not answer') + '.');
372
+ if (r && r.ok) setTimeout(() => X.ctx.load(), 4000);
392
373
  }
393
374
  const moreBtn = () => document.querySelector('#czViewer [data-cz-vw="more"]') || document.body;
394
375
  /** Moves on by itself for this one initiative, on a workflow of the library (POST /api/boards/ini-auto): the stage sets the default. */
@@ -627,6 +608,7 @@ function pagePress(t, id, M) {
627
608
  export function mountIni(ctx) {
628
609
  X.ctx = ctx;
629
610
  if (typeof document === 'undefined') return X;
611
+ ensurePopCss(); // before home-ini.css, so its phone rules win
630
612
  if (!document.querySelector('link[data-hi-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./home-ini.css', import.meta.url).href; l.dataset.hiCss = ''; document.head.appendChild(l); }
631
613
  ensureStepsCss(); // the stage card's step list (cozy-steps.css), before the first draw
632
614
  if (!document.querySelector('link[data-tk-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./tk-tasks.css', import.meta.url).href; l.dataset.tkCss = ''; document.head.appendChild(l); }
@@ -7,20 +7,20 @@
7
7
  .pl-row { display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 2px 4px 2px 0; }
8
8
  .pl-hit { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 6px 0 14px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 14px; }
9
9
  .pl-hit:focus-visible, .pl-stop:focus-visible, .pl-ib:focus-visible, .pl-dvb:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
10
- .pl-t { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
10
+ .pl-t { flex: 1; min-width: 0; font-size: var(--fs-3); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
11
11
  .hm-pl.open .pl-t { white-space: normal; }
12
12
  .hm-pl.you .pl-t, .hm-goalq .pl-t { color: var(--cz-blueink); }
13
- .pl-n { flex: none; font-size: 12.5px; font-weight: 600; color: var(--cz-ink3); }
13
+ .pl-n { flex: none; font-size: var(--fs-2); font-weight: 600; color: var(--cz-ink3); }
14
14
  .pl-cv { flex: none; display: inline-flex; color: var(--cz-ink3); }
15
15
  .pl-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--cz-blue); }
16
16
  .pl-clk { display: inline-flex; color: var(--cz-ink3); }
17
17
  .pl-stop { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
18
18
  .pl-body { padding: 0 14px 12px; }
19
- .pl-head { margin: 0 0 10px; font-size: 12.5px; color: var(--cz-ink3); line-height: 1.4; }
19
+ .pl-head { margin: 0 0 10px; font-size: var(--fs-2); color: var(--cz-ink3); line-height: 1.4; }
20
20
  .pl-sl { margin-top: 2px; }
21
- .pl-now { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; padding-top: 10px; border-top: 1px solid var(--cz-hair); font-size: 12.5px; min-width: 0; }
21
+ .pl-now { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; padding-top: 10px; border-top: 1px solid var(--cz-hair); font-size: var(--fs-2); min-width: 0; }
22
22
  .pl-now b { flex: none; font-weight: 800; }
23
- .pl-now code { min-width: 0; font-family: var(--cz-mono); font-size: 12px; color: var(--cz-ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
23
+ .pl-now code { min-width: 0; font-family: var(--cz-mono); font-size: var(--fs-2); color: var(--cz-ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
24
24
  .hm-pl.open .pl-now code { white-space: normal; word-break: break-all; }
25
25
  .pl-acts { display: flex; gap: 8px; margin-top: 10px; }
26
26
  .pl-ib { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
@@ -29,10 +29,10 @@
29
29
  /* the Viewer (a desktop) */
30
30
  .pl-vw { padding: 16px 20px; }
31
31
  .pl-vwh { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
32
- .pl-vwh b { flex: 1; min-width: 0; font-size: 16px; font-weight: 800; line-height: 1.3; }
32
+ .pl-vwh b { flex: 1; min-width: 0; font-size: var(--fs-4); font-weight: 800; line-height: 1.3; }
33
33
 
34
34
  /* the divider where a run finished */
35
- .pl-dv { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: 13px; font-weight: 700; color: var(--cz-ink2); }
35
+ .pl-dv { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: var(--fs-2); font-weight: 700; color: var(--cz-ink2); }
36
36
  .pl-dv .ln { flex: 1; height: 1px; background: var(--cz-hair); }
37
37
  .pl-dv.stop { color: var(--cz-risk); }
38
38
  .pl-dvb { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 8px; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; border-radius: 10px; }
@@ -19,6 +19,7 @@ import { needsOf, boardRows, productCard, productName, sessionRow, nameOf, iniOf
19
19
  import { programState, groupRows } from './program-model.js';
20
20
  import { homeSub } from './ms-suggest.js';
21
21
  import { STEPS, stageKey } from './premium-initiative-head.js';
22
+ import { sortTop, sortInis, prodKey } from './order-model.js'; // ONE order for Home and the Board (batch 14 item 8)
22
23
 
23
24
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
24
25
  const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -75,6 +76,16 @@ export function productsOf(D) {
75
76
  return out;
76
77
  }
77
78
 
79
+ /* ── the order (batch 14 item 8): what order-model.js reads from Home's groups and rows ── */
80
+ const minDate = (xs) => xs.filter(Boolean).map(String).sort()[0] || '';
81
+ const TOP_ACC = {
82
+ key: (g) => (g.kind === 'program' ? 'g:' + g.program.id : prodKey(g.name)),
83
+ turn: (g) => !!(g.turnN || g.yours),
84
+ date: (g) => (g.kind === 'program' ? (g.st && g.st.next && g.st.next.date) || '' : minDate(g.inis.concat(g.rest).map((x) => x.board && x.board.end))),
85
+ name: (g) => g.name,
86
+ };
87
+ const INI_ACC = { id: (x) => x.ini || x.id, turn: (x) => !!x.turn, date: (x) => (x.board && x.board.end) || '', stage: (x) => x.at, name: (x) => x.name };
88
+
78
89
  /* ── rows ── */
79
90
  function taskHint(t, now, mine) {
80
91
  const d = t.end ? dayDiff(t.end, now) : null;
@@ -187,11 +198,22 @@ export function programGroups(D, groups, products, o, now) {
187
198
  }
188
199
 
189
200
  /* ── the list ── */
201
+ /** The next steps Home shows: one on a cancelled, done or archived initiative is moot, so it neither brings that initiative back to Home
202
+ * nor falls to "Not in an initiative" (batch 14 item 3). A session that waits on the PM stays. */
203
+ function openNeeds(D) {
204
+ const iniOf = (p) => (p.model && p.model.initiatives) || (p.primary && D.board && D.board.initiatives) || {};
205
+ const shut = new Set();
206
+ for (const p of productsOf(D)) {
207
+ const I = iniOf(p), G = I.gone || {};
208
+ for (const r of ((I.list && I.list.rows) || (p.primary ? boardRows(D) : [])).filter((x) => !OPEN(x)).concat(G.cancelled || [], G.archived || [])) if (r && r.id) shut.add(r.id);
209
+ }
210
+ return needsOf(D).filter((x) => !x.ini || x.needSession || !shut.has(x.ini));
211
+ }
190
212
  const sameName = (a, b) => String(a || '').toLowerCase() === String(b || '').toLowerCase();
191
213
  /** o: { filter ('today' | 'kept' | 'done'), now }. The products are the ticked ones (productsOf). */
192
214
  export function homeList(D, o = {}) {
193
215
  const now = o.now || D.now || Date.now();
194
- const needs = needsOf(D);
216
+ const needs = openNeeds(D);
195
217
  const products = productsOf(D);
196
218
  const primary = products.find((p) => p.primary) || null;
197
219
  const used = new Set();
@@ -216,7 +238,9 @@ export function homeList(D, o = {}) {
216
238
  for (const x of mineNeeds) if (x.ini && x.ini !== 'product' && !ids.has(x.ini) && !x.needSession && !extra.has(x.ini)) extra.set(x.ini, { id: x.ini, title: (x.row && x.row.subject) || x.ini, lane: (x.row && x.row.lane) || '', stage: (x.row && x.row.stage) || '', made: true });
217
239
  for (const id of extra.keys()) ids.add(id);
218
240
  const inis = open.concat([...extra.values()]).map((r) => iniRowOf(D, r, mineNeeds, now));
219
- inis.sort((a, b) => (b.turn - a.turn) || (b.busy - a.busy) || (RANK[b.state] || 0) - (RANK[a.state] || 0));
241
+ // ONE order with the Board (batch 14 item 8): the PM's sort, or the order they arranged; the blue dot still marks your turn
242
+ const sorted = sortInis(prodKey(p.name), inis, D.order, INI_ACC);
243
+ inis.splice(0, inis.length, ...sorted);
220
244
  // the product's own next steps (its weekly update, a decision with no initiative) sit under its header, before the initiatives
221
245
  const flat = mineNeeds.filter((x) => !x.ini || !ids.has(x.ini)).filter((x) => !x.needSession).map((x) => ({ ...x, flat: true, hint: bareHint(x) }));
222
246
  const turnN = inis.filter((x) => x.turn).length + flat.length;
@@ -226,6 +250,8 @@ export function homeList(D, o = {}) {
226
250
  }
227
251
  // programs first (program-hierarchy P3): each program takes its initiatives out of their product groups, so an initiative shows once
228
252
  groups.unshift(...programGroups(D, groups, products, o, now));
253
+ // the programs and products in the PM's sort or own order, the same as the Board's (batch 14 item 8, order-model.js)
254
+ groups.splice(0, groups.length, ...sortTop(groups, D.order, TOP_ACC));
229
255
  // sessions that wait on the PM and belong to no initiative of a product: they are next steps too, under "Not in an initiative"
230
256
  const looseNeeds = needs.filter((x) => !used.has(x.id) && !(x.ini && groups.some((g) => g.inis.concat(g.rest).some((i) => i.ini === x.ini))));
231
257
  const loose = [];
@@ -296,7 +322,7 @@ export function looseSnapshot(M, D) {
296
322
  * { id, name, sub (its initiative, or the hint of a row with none), late, state, when (the weekly update's send time) }. */
297
323
  function moveOf(groups, needs) {
298
324
  const late = [], rest = [], seen = new Set();
299
- const put = (L, r, sub) => { if (!r || seen.has(r.id)) return; seen.add(r.id); L.push({ id: r.id, name: r.name, sub: sub || '', late: !!r.late, state: r.state || 'needs', check: !!(r.check || r.kind === 'task'), when: whenOf(r), ...(r.ms ? { ms: true } : {}) }); };
325
+ const put = (L, r, sub) => { if (!r || seen.has(r.id)) return; seen.add(r.id); L.push({ id: r.id, name: r.name, sub: sub || '', late: !!r.late, state: r.state || 'needs', check: !!(r.check || r.kind === 'task'), when: whenOf(r), kind: r.kind || '', ...(callOf(r) ? { call: true } : {}), ...(pickOf(r) ? { pick: pickOf(r) } : {}), ...(r.ms ? { ms: true } : {}) }); };
300
326
  for (const g of groups) {
301
327
  if (g.kind === 'loose') { for (const r of g.rows) if (r.check && r.late) put(late, r); else if (r.state === 'needs' || r.state === 'blocked') put(rest, r, r.kind === 'session' ? '' : bareHint(r)); continue; }
302
328
  for (const t of g.tasks || []) if (t.mine && t.late) put(late, t, g.name);
@@ -307,6 +333,17 @@ function moveOf(groups, needs) {
307
333
  for (const r of needs) if (!seen.has(r.id) && !r.needSession) put(rest, r, r.kind === 'session' ? '' : bareHint(r));
308
334
  return late.concat(rest);
309
335
  }
336
+ /** Claude's pick on a Needs-you row: the option its dialog selects ({ sel, opts }), else ''. Your day names it in the call's sentence. */
337
+ const pickOf = (r) => {
338
+ const d = r && r.row && r.row.dialog; const o = d && d.sel && (d.opts || []).find((x) => x && x.k === d.sel);
339
+ if (o && o.t) return String(o.t);
340
+ const p = String((r && r.row && r.row.kind === 'source' && r.row.prepared) || ''); // a brief item's prepared line ("Reply: …"), when it has one
341
+ return p && !/^No .* is on record\.$/.test(p) ? p : '';
342
+ };
343
+ /** Is a row a call only the PM can make (Your day's Your move, batch 15 item 3)? A session that asks, the program's milestone changes, a
344
+ * decision, blocked work, failed reviews to weigh, and an item where someone asked the PM by name. Tasks and the rest can wait. */
345
+ const callOf = (r) => r.kind === 'session' || r.kind === 'msreview' || ['decision', 'blocked', 'waited'].includes(r.row && r.row.kind)
346
+ || !!(r.row && r.row.kind === 'source' && /mentions you/.test(String(r.row.subject || '')));
310
347
  /** "Wed 09:00" from the weekly update's "goes out Wed 09:00"; '' for any other row. */
311
348
  export const whenOf = (r) => { const m = /goes out (.+)$/.exec(String((r && r.hint) || '')); return m ? m[1] : ''; };
312
349
 
@@ -354,7 +391,7 @@ const listWords = (a) => (a.length <= 1 ? a.join('') : a.slice(0, -1).join(', ')
354
391
  export function todayCard(D, o = {}) {
355
392
  const now = o.now || D.now || Date.now();
356
393
  const t = todayOf(D);
357
- const needs = needsOf(D);
394
+ const needs = openNeeds(D);
358
395
  const titleOf = o.titleOf || ((id) => id);
359
396
  if (o.rec && !o.rec.meeting) {
360
397
  const s = o.rec.at ? Math.max(0, Math.round((now - Date.parse(o.rec.at)) / 1000)) : null;
@@ -22,7 +22,7 @@ export function mountPhoneCard(o) {
22
22
  el.className = 'hm-phc'; el.id = 'phoneCard'; el.hidden = true; el.setAttribute('aria-label', 'Now');
23
23
 
24
24
  const own = () => ((P.page && P.page.ok && P.page.needs) || []).filter((n) => n && n.id && (n.kind === 'overdue' || n.kind === 'due-today'))
25
- .map((n) => ({ id: n.id, headline: n.headline, label: n.kind === 'overdue' ? (n.days_late === 1 ? '1 day late' : n.days_late + ' days late') : 'Due today', kind: n.kind, looks: !!(n.evidence && n.evidence.text) }));
25
+ .map((n) => ({ id: n.id, headline: n.headline, label: n.kind === 'overdue' ? 'Yours, still open' : 'Due today', kind: n.kind, looks: !!(n.evidence && n.evidence.text) }));
26
26
  const btn = (label, act, id, alt) => `<button type="button" class="cta${alt ? ' alt' : ''}" data-pha="${act}"${id != null ? ` data-id="${esc(id)}"` : ''}>${esc(label)}</button>`;
27
27
  const item = (n) => {
28
28
  const act = P.dec.has(n.id) ? `<p class="phok" role="status">${CHECK}<span>Done.</span></p><div class="phacts">${btn('Undo', 'phundo', n.id, true)}</div>` : `<div class="phacts">${btn(n.looks ? 'Confirm done' : 'Done', 'phdone', n.id)}</div>`;
@@ -32,11 +32,13 @@ export function mountPhoneCard(o) {
32
32
  const open = (m) => btn('Open the meeting', 'phopen', m.id, true);
33
33
  const big = (t) => `<b class="phbig">${esc(t)}</b>`;
34
34
  const L = (t) => `<p class="phl">${esc(t)}</p>`, S = (t) => `<p class="phs">${esc(t)}</p>`;
35
+ // a real thank-you to the PM today, from the brief's mentions (GET /api/brief-page mentions); never written, only quoted
36
+ const thanks = () => { const m = ((P.page && P.page.mentions) || []).find((x) => x && x.text && /\b(thank(s| you)?|thx|appreciate[ds]?)\b/i.test(x.text) && (!x.at || new Date(x.at).toDateString() === new Date().toDateString()));
37
+ return m ? { quote: String(m.text).replace(/\s+/g, ' ').trim().slice(0, 160), who: m.who || '', where: m.source ? m.source.charAt(0).toUpperCase() + m.source.slice(1) : '', at: m.at ? hm(m.at) : '' } : null; };
35
38
  const dayErr = () => (P.day && P.day.ok === false ? S('Today could not be read: ' + P.day.error + '.') : !P.day ? S('Reading your day.') : '');
36
39
 
37
40
  function moment(mo) {
38
41
  const m = mo.meeting, mine = own(), day = P.day && P.day.ok !== false ? P.day : null, fin = day ? day.finished || [] : [];
39
- const waits = mine.length ? num(mine.length, 'item of yours waits', 'items of yours wait') + '.' : 'Nothing of yours is due.';
40
42
  const finRows = (n) => fin.slice(0, n).map((t) => `<div class="phfit"><span class="label">${t.status === 'review' ? 'Waits for you' : t.status === 'sent' ? 'Sent' : 'Finished'}</span><b class="phtt">${esc(t.title)}</b><p class="phs">${esc(t.summary)}</p></div>`).join('');
41
43
  const fits = (list) => items(list.map((n) => mine.find((x) => x.id === n.id)).filter(Boolean));
42
44
  if (mo.kind === 'meeting') return `<span class="label">Under way · ends ${esc(inText(mo.minutes))}</span>${big(m.title)}${who(m) ? L(who(m)) : ''}<div class="phacts">${open(m)}</div>`;
@@ -48,24 +50,25 @@ export function mountPhoneCard(o) {
48
50
  }
49
51
  if (mo.kind === 'after') return `<span class="label">Just ended · ${hm(m.end || m.start)}</span>${big(m.title)}${S('The notes of this meeting, if there are any, are in the meeting.')}<div class="phacts">${open(m)}</div>`;
50
52
  if (mo.kind === 'gap') return `<span class="label">Until ${esc(mo.next.title)} at ${hm(mo.next.start)}</span>${big(mo.minutes + ' free minutes')}${mo.fits.length ? fits(mo.fits) : L('Nothing of yours is due. A good moment to prepare the next meeting.')}`;
51
- if (mo.kind === 'morning') {
52
- const top = mine.slice(0, 3);
53
- const nx = mo.next ? `<div class="phfit"><b class="phtt">First up: ${esc(mo.next.title)} at ${hm(mo.next.start)}</b><p class="phs">${esc(inText((Date.parse(mo.next.start) - Date.now()) / 60000).replace(/^in/, 'In'))}${who(mo.next) ? ' · ' + esc(who(mo.next)) : ''}</p><div class="phacts">${open(mo.next)}</div></div>` : S('No meetings today.');
54
- return `<span class="label">Your morning</span>${big(top.length ? ['', 'One thing', 'Two things', 'Three things'][top.length] + ' this morning' : 'Nothing pressing this morning')}${items(top)}${S(waits)}${nx}`;
53
+ if (mo.kind === 'morning') { // Your day E (YdE1Ready): the day's meetings, time and title; then what of yours is due, with Done
54
+ const t = ((P.page && P.page.today) || []).filter((x) => x && x.state !== 'past'), top = mine.slice(0, 3);
55
+ const rows = t.slice(0, 3).map((x) => `<p class="phrow"><b>${hm(x.start)}</b><span>${esc(x.title)}</span></p>`).join('') + (t.length > 3 ? S((t.length - 3) + ' more later today.') : '');
56
+ return `<span class="label">Your morning</span>${t.length ? rows : S('No meetings today.')}${items(top)}${mo.next ? `<div class="phacts">${open(mo.next)}</div>` : ''}`;
55
57
  }
56
58
  if (mo.kind === 'work') return `<span class="label">${mo.next ? 'Next: ' + esc(mo.next.title) + ' at ' + hm(mo.next.start) : 'No more meetings today'}</span>${big(fin.length ? 'Finished for you' : 'Nothing new from the agent')}${fin.length ? finRows(2) + S('Approving a draft waits for your computer.') : dayErr() || S('When the agent finishes a draft today, it shows here.')}${mo.fits.length ? fits(mo.fits) : ''}${mo.next ? `<div class="phacts">${open(mo.next)}</div>` : ''}`;
57
- if (mo.kind === 'recap') { // canvas HmPhone2's End of day: plain lines, one soft well for the one thing to do
58
- const r = day && day.recap, one = mine[0], rest = mine.length - (one ? 1 : 0);
59
- const KIND = { decision: 'Decided', done: 'Done', agent: 'Agent' };
60
- const sum = r ? L([num(r.meetings, 'meeting', 'meetings'), num(r.decided, 'decision confirmed', 'decisions confirmed'), num(r.done, 'item done', 'items done')].join(' · ')) : dayErr();
61
- const moved = r && (r.moved || []).length ? `<div class="phmv"><span class="label">What moved</span>${r.moved.map((x) => `<p><b>${esc(KIND[x.kind] || '')}</b><span>${esc(x.text)}</span>${x.sub ? `<em>${esc(x.sub)}</em>` : ''}</p>`).join('')}</div>` : '';
59
+ if (mo.kind === 'recap') { // Your day E (YdE3Evening): what today made possible, wins only; a real thank-you when one exists; no zero counts
60
+ const r = day && day.recap, one = mine[0], ty = thanks();
61
+ const KIND = { decision: 'Decided', done: 'Done', agent: 'Claude' };
62
+ const moved = r && (r.moved || []).length ? `<div class="phmv">${r.moved.map((x) => `<p><b>${esc(KIND[x.kind] || '')}</b><span>${esc(x.text)}</span>${x.sub ? `<em>${esc(x.sub)}</em>` : ''}</p>`).join('')}</div>` : dayErr();
63
+ const quote = ty ? `<div class="phty"><p class="phl">“${esc(ty.quote)}”</p><p class="phs">${esc([ty.who, ty.where].filter(Boolean).join(' on '))}${ty.at ? ' · ' + esc(ty.at) : ''}</p></div>` : '';
62
64
  const conf = r && r.to_confirm ? `<p class="phs phq">${esc(num(r.to_confirm, 'decision', 'decisions'))} from today's notes ${r.to_confirm === 1 ? 'is' : 'are'} not confirmed yet, so ${r.to_confirm === 1 ? 'it does' : 'they do'} not count. Confirm them in the meeting's Replay.</p>` : '';
63
- const open = one ? `<div class="phfit" data-id="${esc(one.id)}"><span class="label">One thing tonight · ${esc(one.label)}</span><b class="phtt">${esc(one.headline)}</b>${P.dec.has(one.id) ? `<p class="phok" role="status">${CHECK}<span>Done.</span></p><div class="phacts">${btn('Undo', 'phundo', one.id, true)}</div>` : `<div class="phacts">${btn(one.looks ? 'Confirm done' : 'Done', 'phdone', one.id)}</div>`}${P.err[one.id] ? `<p class="pherr" role="alert">${esc(P.err[one.id])}</p>` : ''}${rest ? S(num(rest, 'more is', 'more are') + ' still open. ' + (rest === 1 ? 'It comes' : 'They come') + ' first on Home tomorrow.') : ''}</div>`
64
- : S('Nothing of yours is still open.');
65
- return `<span class="label">Evening recap</span>${big('How today went')}${sum}${moved}${conf}${open}`;
65
+ const open = one ? `<div class="phfit" data-id="${esc(one.id)}"><span class="label">One thing tonight, if you like</span><b class="phtt">${esc(one.headline)}</b>${P.dec.has(one.id) ? `<p class="phok" role="status">${CHECK}<span>Done.</span></p><div class="phacts">${btn('Undo', 'phundo', one.id, true)}</div>` : `<div class="phacts">${btn(one.looks ? 'Confirm done' : 'Done', 'phdone', one.id)}</div>`}${P.err[one.id] ? `<p class="pherr" role="alert">${esc(P.err[one.id])}</p>` : ''}${mine.length > 1 ? S('The rest can wait for tomorrow.') : ''}</div>` : '';
66
+ const big2 = r && ((r.moved || []).length || ty) ? 'What today made possible' : 'Evening';
67
+ return `<span class="label">Evening recap</span>${big(big2)}${quote}${moved}${conf}${open}`;
66
68
  }
67
69
  const r = day && day.recap, tm = day && day.tomorrow;
68
- return `<span class="label">End of day</span>${big(tm ? 'Tomorrow, ' + tm.label : 'Tomorrow, at a glance')}${r ? L('Today: ' + [num(r.meetings, 'meeting', 'meetings'), num(r.decided, 'decision', 'decisions'), num(r.done, 'item done', 'items done')].join(', ') + '.') : ''}${tm ? `<div class="phfit"><b class="phtt">${tm.meetings.length ? num(tm.meetings.length, 'meeting', 'meetings') : 'No meetings'}</b>${tm.meetings.slice(0, 5).map((x) => `<p class="phs">${hm(x.start)} · ${esc(x.title)}${who(x) ? ' · ' + esc(who(x)) : ''}</p>`).join('')}</div>` : dayErr()}${S(mine.length ? num(mine.length, 'item carries', 'items carry') + ' over. They open first on Home tomorrow.' : 'Nothing carries over.')}`;
70
+ const today = r ? [r.meetings && num(r.meetings, 'meeting', 'meetings'), r.decided && num(r.decided, 'decision', 'decisions'), r.done && num(r.done, 'item done', 'items done')].filter(Boolean) : []; // zero is silence
71
+ return `<span class="label">End of day</span>${big(tm ? 'Tomorrow, ' + tm.label : 'Tomorrow, at a glance')}${today.length ? L('Today: ' + today.join(', ') + '.') : ''}${tm ? `<div class="phfit"><b class="phtt">${tm.meetings.length ? num(tm.meetings.length, 'meeting', 'meetings') : 'No meetings'}</b>${tm.meetings.slice(0, 5).map((x) => `<p class="phs">${hm(x.start)} · ${esc(x.title)}${who(x) ? ' · ' + esc(who(x)) : ''}</p>`).join('')}</div>` : dayErr()}${mine.length ? S('What’s still open waits on Home tomorrow.') : ''}`;
69
72
  }
70
73
  const momentNow = () => momentOf({ today: P.page.today || [], needs: own(), now: new Date() });
71
74
  function draw(focus) {
@@ -15,6 +15,8 @@ import { whenOf } from './home-list.js';
15
15
  import { chipHtml } from './cozy-pick.js'; // the one product picker Home, Board and Insights share (batch 12 item 5)
16
16
  import { ringHtml } from './home-line.js';
17
17
  import { gripHtml, sugHtml } from './prog-order.js'; // a program's order: the grip and ✦ (canvas RoADrag, RoAPhone)
18
+ import * as SO from './sort-order.js'; // the sort button and ONE order with the Board (batch 14 item 8, canvas SoAHomePhone)
19
+ import { prodKey } from './order-model.js';
18
20
  import * as CW from './ctx-wedge.js'; // how full a session's context is: the pie, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
19
21
 
20
22
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -162,17 +164,20 @@ function productHtml(g, o) {
162
164
  const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prodopen="${esc(g.key)}" aria-label="Open ${esc(g.name)}, a product"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
163
165
  + `<span class="hv-tl t${g.tone}" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
164
166
  + `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(say)}. ${open ? 'Close' : 'Open'} the group">${open ? dots(g) : ''}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
165
- if (!open) return `<section class="hm-pg hv-g" aria-label="${esc(g.name)}">${head}</section>`;
167
+ const sec = `<section class="hm-pg hv-g" aria-label="${esc(g.name)}" data-po-id="${esc(prodKey(g.name))}">${SO.gripHtml(g.name)}`;
168
+ if (!open) return `${sec}${head}</section>`;
166
169
  const pinned = (x) => (o.pin.has(x.key) ? 0 : 1);
167
170
  const flat = g.flat.slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
168
171
  const QUIET = 3;
169
172
  const restAll = o.restOpen(g.key);
170
- const rest = restAll ? g.rest : g.rest.slice(0, Math.max(0, QUIET - g.inis.length));
173
+ // the open initiative always shows, wherever the PM's order puts it (batch 14 item 8)
174
+ const rest = restAll ? g.rest : g.rest.filter((r, i) => i < Math.max(0, QUIET - g.inis.length) || r.id === o.sel);
171
175
  const more = g.rest.length - rest.length;
172
- const body = flat + g.inis.concat(rest).map((r) => iniHtml(r, { ...o, gk: g.key })).join('')
176
+ // the product's initiatives are one list the grip arranges, shared with the Board (batch 14 item 8)
177
+ const body = flat + `<div class="po-list" data-po-list="@${esc(prodKey(g.name))}">${g.inis.concat(rest).map((r) => iniHtml(r, { ...o, gk: g.key }, true)).join('')}</div>`
173
178
  + (more > 0 ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="false" aria-label="${more} more ${more === 1 ? 'initiative' : 'initiatives'} with nothing today. Show"><span class="hv-mk"></span>${more} more${svg(P.chevD, 16)}</button>`
174
179
  : restAll && g.rest.length > QUIET ? `<button type="button" class="hv-fold" data-hm-rest="${esc(g.key)}" aria-expanded="true"><span class="hv-mk"></span>Fewer${svg(P.chevU, 16)}</button>` : '');
175
- return `<section class="hm-pg hv-g" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body || `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`}</div></section>`;
180
+ return `${sec}${head}<div class="hv-card">${g.inis.length + rest.length + g.flat.length ? body : `<p class="hm-none">${g.primary ? 'No initiative is open on this board.' : 'Nothing is open here.'}</p>`}</div></section>`;
176
181
  }
177
182
  /** A program's group (canvas PgHomePhone, PgHomeDesk): above the products. Its header: the program tile, the name, the next milestone's
178
183
  * diamond with its date and one small diamond per initiative it waits on (filled when that initiative is past the Deliver milestone), a chevron.
@@ -187,13 +192,16 @@ function programHtml(g, o) {
187
192
  const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}${o.selHead === g.key ? ' sel' : ''}"><button type="button" class="hv-pt" data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program"${o.selHead === g.key ? ' aria-current="true"' : ''}>`
188
193
  + `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>${open && g.st ? sugHtml(g.program, g.st) : ''}`
189
194
  + `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}. ${esc(line)}${g.yours ? '. ' + yoursWords(g) : ''}. ${open ? 'Close' : 'Open'} the group">${ms}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
190
- if (!open) return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}</section>`;
195
+ const sec = `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}" data-po-id="g:${esc(g.program.id)}">${SO.gripHtml(g.name)}`;
196
+ if (!open) return `${sec}${head}</section>`;
191
197
  // the program's tasks are on its panel (On the program), not on Home: Home lists no tasks (Wawan, 2026-10-25)
192
198
  // a product's sub-heading only when the program's rows on Home come from two or more products (batch 12 item 6): one product repeated
193
199
  // under every program said nothing
194
200
  const many = g.subs.length > 1;
195
201
  const body = g.subs.map((x) => `${many ? `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>` : ''}<div class="po-list" data-po-list="${esc(g.program.id)}">${x.inis.map((r) => iniHtml(r, { ...o, gk: g.key }, true)).join('')}</div>`).join('');
196
- return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}<div class="hv-card">${body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`}</div></section>`;
202
+ // the program's milestone changes that wait on the PM lead its card (batch 14 item 4: they were only in Your day, which a desktop no longer has)
203
+ const msr = g.msRow ? `<div class="hm-r hv-r${o.sel === g.msRow.id ? ' sel' : ''}" data-id="${esc(g.msRow.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(g.msRow.id)}" aria-label="${esc(g.msRow.hint)}. Waits on you. Open the program"><span class="hv-mk"><span class="hv-d" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(g.msRow.hint)}</b></span></button></div>` : '';
204
+ return `${sec}${head}<div class="hv-card">${msr}${body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`}</div></section>`;
197
205
  }
198
206
  /** "Not in an initiative" (HvAC .lh): a line under the groups. Folded it shows a blue dot when a row waits on you, an amber square when one
199
207
  * of your own is late, and the count; open, the rows in a card. */
@@ -265,6 +273,7 @@ export function listHtml(M, T, o) {
265
273
  // the product chip, always (it is also the way to add one): the ticked products' tiles, or All (canvas XhpA2States)
266
274
  + (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
267
275
  + (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
276
+ + SO.btnHtml('ut-ib hv-ib' + (SO.layout().sort !== 'mine' ? ' on' : ''))
268
277
  + `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button></div>`
269
278
  + (M.yours ? `<p class="hv-sub">${M.yours} ${M.yours === 1 ? 'is' : 'are'} yours</p>` : '');
270
279
  // the Today card only while the day has a moment; the plain day (its meetings and load) is in Your day
@@ -278,7 +287,9 @@ export function listHtml(M, T, o) {
278
287
  body = `<section class="hm-pg hv-g" aria-label="${esc(M.list.title)}"><div class="hv-lh">${esc(M.list.title)}<span class="n">${M.list.rows.length || ''}</span></div>`
279
288
  + `<div class="hv-card">${M.list.rows.map((r) => rowHtml(r, o)).join('') || `<p class="hm-none">${esc(M.list.empty)}</p>`}</div></section>`;
280
289
  } else {
281
- body += M.groups.map((g) => (g.kind === 'product' ? productHtml(g, o) : g.kind === 'program' ? programHtml(g, o) : looseHtml(g, o))).join('');
290
+ // the programs and products are one list the grip arranges (batch 14 item 8); "Not in an initiative" stays under them
291
+ body += `<div class="po-list" data-po-list="@top">${M.groups.filter((g) => g.kind !== 'loose').map((g) => (g.kind === 'product' ? productHtml(g, o) : programHtml(g, o))).join('')}</div>`
292
+ + M.groups.filter((g) => g.kind === 'loose').map((g) => looseHtml(g, o)).join('');
282
293
  if (!M.groups.some((g) => (g.kind === 'product' && (g.count || g.flat.length)) || g.kind === 'program' || (g.rows && g.rows.length))) body += '<p class="hm-none">Nothing is open. A new initiative or a task you add shows here.</p>';
283
294
  // the capture box shows only after New → A task → Not in an initiative (o.cap); an initiative's task is added in its Tasks view
284
295
  if (o.cap) body += `<form class="hm-cap" id="hmCapF"><label class="vh" for="hmCap">Add a task to your own list</label><input id="hmCap" autocomplete="off" maxlength="250" placeholder="A task for your own list. Esc to cancel">`
@@ -0,0 +1,67 @@
1
+ /* pm/ini-more.js — the ONE initiative ⋯ menu (feedback batch 14 item 5): Home's initiative page (home-ini.js) and the Board's initiative
2
+ * panel (bd-ini-panel.js) both build their ⋯ here, so the items, their words and their order cannot drift apart again.
3
+ *
4
+ * iniMore(c) → the Viewer's more list ([{ label, note?, on(btn), danger? } | { sep: true }]). c holds what the page can do; a missing
5
+ * press (null, false, undefined) hides its item. The page decides when an item applies (the PMOS-self board, an ended
6
+ * initiative, no stages); this module decides only the words and the order:
7
+ * change it wf { name, on }, rename, auto { on: bool, press }, back { prev, on }, toStage, dates, person
8
+ * its place sm [split, merge items], pm [program move items], turnProgram (only when pm is empty)
9
+ * look at it jira, board, record, link, text
10
+ * end it ended (true: Back to Triage in place of Won't do), wontDo, backToTriage, archive
11
+ * stop it hold, or resume when it is on hold; cancel (red, last)
12
+ * iniText(title, view, tickets) the initiative as plain text, for Copy as text: the summary, the stage, the open tasks and tickets.
13
+ * ORDER every label in menu order, for the tests and the guide.
14
+ * "Open in full" is not here: the header's expand already opens it wide (say it once). */
15
+
16
+ export const ORDER = ['Change workflow', 'Rename', 'Moves on by itself', 'Move back a stage', 'Move to a stage', 'Change the plan dates', 'Add a stakeholder',
17
+ 'Split into a new initiative', 'Merge into', 'Move out of', 'Move to another program', 'Turn into a program',
18
+ 'Read Jira again', 'Open on the Board', 'The record', 'Copy link', 'Copy as text',
19
+ 'Won’t do', 'Back to Triage', 'Archive',
20
+ 'Put on hold', 'Resume', 'Cancel the initiative'];
21
+
22
+ export function iniMore(c) {
23
+ const G = [[], [], [], [], []];
24
+ const [change, place, look, end, stop] = G;
25
+ if (c.wf) change.push({ label: 'Change workflow', note: c.wf.name || 'Product feature', on: c.wf.on });
26
+ if (c.rename) change.push({ label: 'Rename', on: c.rename });
27
+ if (c.auto) change.push({ label: 'Moves on by itself', note: c.auto.on ? 'On' : 'Off', on: c.auto.press });
28
+ if (c.back) change.push({ label: 'Move back a stage', note: c.back.prev, on: c.back.on });
29
+ if (c.toStage) change.push({ label: 'Move to a stage', on: c.toStage });
30
+ if (c.dates) change.push({ label: 'Change the plan dates', on: c.dates });
31
+ if (c.person) change.push({ label: 'Add a stakeholder', on: c.person });
32
+ // split or merge above the program moves (batch 11 item 14, canvas XsmA1Menu); an initiative in no program can become one (P7)
33
+ place.push(...(c.sm || []), ...(c.pm || []));
34
+ if (c.turnProgram && !(c.pm || []).length) place.push({ label: 'Turn into a program', on: c.turnProgram });
35
+ if (c.jira) look.push({ label: 'Read Jira again', on: c.jira });
36
+ if (c.board) look.push({ label: 'Open on the Board', on: c.board });
37
+ if (c.record) look.push({ label: 'The record', on: c.record });
38
+ if (c.link) look.push({ label: 'Copy link', on: c.link });
39
+ if (c.text) look.push({ label: 'Copy as text', on: c.text });
40
+ // Won't do and Archive hold from any stage (wfRules); Won't do comes back to Triage (D99, WfAWontDo)
41
+ if (c.ended ? c.backToTriage : c.wontDo) end.push(c.ended ? { label: 'Back to Triage', on: c.backToTriage } : { label: 'Won’t do', on: c.wontDo });
42
+ if (c.archive) end.push({ label: 'Archive', on: c.archive });
43
+ if (c.hold) stop.push({ label: 'Put on hold', on: c.hold });
44
+ else if (c.resume) stop.push({ label: 'Resume', on: c.resume });
45
+ if (c.cancel) stop.push({ label: 'Cancel the initiative', danger: true, on: c.cancel });
46
+ const out = [];
47
+ for (const g of G) if (g.length) out.push(...(out.length ? [{ sep: true }] : []), ...g);
48
+ return out;
49
+ }
50
+
51
+ /** The initiative as plain text, for Copy as text: the summary, the stage and the open tasks (the one view's model, ini-view-model.js). */
52
+ export function iniText(title, v, tickets) {
53
+ const lines = [title];
54
+ if (v) {
55
+ const s = v.summary || {};
56
+ if (s.line) lines.push(s.line + (s.right ? ' · ' + s.right : ''));
57
+ if (s.text) lines.push(s.text);
58
+ const st = v.stage || {};
59
+ if (st.name) lines.push('', st.name + (st.n ? ' · ' + st.n + ' of ' + st.of : '') + (st.doneOf ? ' · ' + st.doneOf : ''));
60
+ for (const sec of (v.tasks && v.tasks.sections) || []) for (const x of sec.top || []) lines.push('- ' + x.title + (x.sub ? ' · ' + x.sub : ''));
61
+ }
62
+ for (const k of (tickets || []).filter((x) => x.status !== 'Done')) lines.push('- ' + k.key + ' ' + k.title + ' · ' + (k.blocked ? 'Blocked' + (k.reason ? ' by ' + k.reason.replace(/^Waiting on /i, '') : '') : k.status || 'To do') + (k.assignee ? ' · ' + k.assignee : ''));
63
+ return lines.join('\n');
64
+ }
65
+
66
+ /** The initiative's own address (the initiative page), for Copy link: the same on Home and the Board. */
67
+ export const pageHref = (id, ws, board) => '/premium-initiative.html?id=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(board || ws) : '');
@@ -124,10 +124,11 @@ function rowOf(k, today) {
124
124
  start: k.start || '', end: k.end || '', owner: who, av: initials(k.owner),
125
125
  sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid && !k.draft, order: k.order,
126
126
  // planned versus actual (batch 11 item 8, pm/ini-versions.js): the compared version's days where they differ, ⊕ added after it, a draft's task
127
- cmp: k.cmp || null, added: !!k.added, dr: !!k.draft };
127
+ cmp: k.cmp || null, added: !!k.added, dr: !!k.draft, jkey: jiraKeyOf(k.title) };
128
128
  }
129
129
  /** The Jira key a task's title starts with ("MSD-4376 Navigation tabs" → 'MSD-4376'), or ''. A task named for a ticket IS that ticket:
130
- * Build's section shows it once, as the task (it carries the dates and the owner), not again as a Jira row (batch 11 item 4). */
130
+ * Build's section shows it once, as the task (it carries the dates and the owner), not again as a Jira row (batch 11 item 4), and it looks
131
+ * like a ticket: the Jira square and the key in blue (batch 14 item 6). */
131
132
  const KEY_RE = /^\s*([A-Z][A-Z0-9]+-\d+)\b/;
132
133
  export const jiraKeyOf = (title) => { const m = KEY_RE.exec(String(title || '')); return m ? m[1] : ''; };
133
134
  const urgent = (a, b) => (b.late - a.late) || (a.end || '9999').localeCompare(b.end || '9999') || (a.order != null && b.order != null ? a.order - b.order : 0);