create-pmos 0.611.0 → 0.612.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 +86 -14
  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/briefing-premium-board-test.js +1 -1
  8. package/workspace/briefing-premium-calendar-2-test.js +3 -2
  9. package/workspace/briefing-premium-calendar-3-test.js +1 -1
  10. package/workspace/briefing-premium-calendar-test.js +1 -1
  11. package/workspace/briefing-premium-insights-test.js +1 -1
  12. package/workspace/briefing-premium-test.js +1 -1
  13. package/workspace/changelog.json +85 -0
  14. package/workspace/guide/layout.md +52 -18
  15. package/workspace/guide/programs.md +3 -3
  16. package/workspace/guide/routine.md +28 -13
  17. package/workspace/guide/settings-and-switches.md +1 -1
  18. package/workspace/lib/board-premium.js +12 -4
  19. package/workspace/lib/cos-chat.js +1 -0
  20. package/workspace/lib/doc-library.js +43 -12
  21. package/workspace/lib/doc-path.js +30 -0
  22. package/workspace/lib/engine/boards.js +4 -2
  23. package/workspace/lib/events-place.js +190 -38
  24. package/workspace/lib/events-stated.js +129 -0
  25. package/workspace/lib/initiative-chat.js +1 -0
  26. package/workspace/lib/insights-premium.js +13 -1
  27. package/workspace/lib/library-find.js +162 -0
  28. package/workspace/lib/library-items.js +196 -24
  29. package/workspace/lib/notes.js +3 -0
  30. package/workspace/lib/plan-items.js +17 -3
  31. package/workspace/lib/routes-artefacts.js +5 -2
  32. package/workspace/lib/routes-boards.js +6 -2
  33. package/workspace/lib/routes-doc-sheet.js +1 -0
  34. package/workspace/lib/routes-events-place.js +47 -10
  35. package/workspace/lib/routes-library.js +74 -8
  36. package/workspace/lib/routes-report-setups.js +13 -2
  37. package/workspace/lib/routine-reports.js +36 -4
  38. package/workspace/lib/status-when.js +36 -0
  39. package/workspace/lib/task-items.js +5 -3
  40. package/workspace/package-lock.json +2 -2
  41. package/workspace/package.json +1 -1
  42. package/workspace/premium-vw-meet-test.js +2 -1
  43. package/workspace/premium-vw-notes-test.js +3 -2
  44. package/workspace/public/pm/artefact-kind.js +87 -0
  45. package/workspace/public/pm/bd-ini-panel.js +6 -6
  46. package/workspace/public/pm/bd-span.js +5 -0
  47. package/workspace/public/pm/bd-work.css +62 -0
  48. package/workspace/public/pm/bd-work.js +195 -68
  49. package/workspace/public/pm/cozy-bar.css +11 -0
  50. package/workspace/public/pm/cozy-bar.js +99 -0
  51. package/workspace/public/pm/cozy-day-pick.css +27 -0
  52. package/workspace/public/pm/cozy-day-pick.js +97 -0
  53. package/workspace/public/pm/cozy-ev.css +0 -4
  54. package/workspace/public/pm/cozy-events-view.js +165 -33
  55. package/workspace/public/pm/cozy-events.css +75 -3
  56. package/workspace/public/pm/cozy-events.js +86 -18
  57. package/workspace/public/pm/cozy-goals.css +172 -0
  58. package/workspace/public/pm/cozy-library.css +106 -17
  59. package/workspace/public/pm/cozy-nav.js +2 -3
  60. package/workspace/public/pm/cozy-pick.css +3 -0
  61. package/workspace/public/pm/cozy-pop-work.css +83 -24
  62. package/workspace/public/pm/cozy-pop-work.js +313 -72
  63. package/workspace/public/pm/cozy-popup.css +11 -2
  64. package/workspace/public/pm/cozy-popup.js +67 -9
  65. package/workspace/public/pm/cozy-routine-job.js +203 -0
  66. package/workspace/public/pm/cozy-routine-model.js +139 -31
  67. package/workspace/public/pm/cozy-routine-pop.js +164 -42
  68. package/workspace/public/pm/cozy-routine.css +61 -8
  69. package/workspace/public/pm/cozy-routine.js +207 -28
  70. package/workspace/public/pm/cozy-settings.js +1 -5
  71. package/workspace/public/pm/cozy-status-when.js +48 -0
  72. package/workspace/public/pm/cozy-viewer.js +19 -8
  73. package/workspace/public/pm/cozy-vw-mtg.css +39 -0
  74. package/workspace/public/pm/goals-model.js +205 -0
  75. package/workspace/public/pm/goals-open.js +124 -0
  76. package/workspace/public/pm/home-chat.js +4 -2
  77. package/workspace/public/pm/home-ini.js +8 -6
  78. package/workspace/public/pm/ini-edit.js +3 -1
  79. package/workspace/public/pm/ini-view-model.js +1 -1
  80. package/workspace/public/pm/library-model.js +170 -42
  81. package/workspace/public/pm/library-open.js +8 -5
  82. package/workspace/public/pm/page-chat.js +12 -2
  83. package/workspace/public/pm/pop-work-model.js +199 -41
  84. package/workspace/public/pm/premium-board.js +108 -43
  85. package/workspace/public/pm/premium-goals.js +213 -0
  86. package/workspace/public/pm/premium-library.js +376 -62
  87. package/workspace/public/pm/premium-shell.js +1 -1
  88. package/workspace/public/pm/premium-vw-mtg.js +79 -1
  89. package/workspace/public/pm/scope-chip.js +204 -0
  90. package/workspace/public/premium-events.html +3 -1
  91. package/workspace/public/premium-goals.html +37 -0
  92. package/workspace/public/premium-library.html +15 -7
  93. package/workspace/public/premium-routine.html +2 -0
  94. package/workspace/server.js +2 -1
  95. package/workspace/test-lists/doc-path.json +9 -0
  96. package/workspace/test-lists/goals-place.json +9 -0
  97. package/workspace/test-lists/status-when.json +9 -0
@@ -28,6 +28,8 @@
28
28
  * cancels, an empty or unchanged name saves nothing. jira draws "Rename the Jira … too" under the field, off by default.
29
29
  * The caller writes the record and says "Renamed" with Undo; the header shows the saved name at once.
30
30
  * true goes to Home with ?about=<kind>:<id>&label=<title>; { href } goes there; fn() runs instead.
31
+ * from the page the item was opened from ('Library', 'Routine'): in the popup the header reads ← and "from › title"; both close to the page
32
+ * kindChip the small kind chip after the title in the popup ('Meeting notes', 'Report', 'Prototype')
31
33
  * back true: keep the item shown now, so ← comes back to it. Without back, opening an item forgets what was behind it.
32
34
  * keep true: this item takes the place of the one shown now, and what was behind that one stays behind this one (a view switch)
33
35
  * add { label, on(button) }: a quiet + before ⋯ (Home's "New session" on an initiative, canvas HbC). Not drawn on a phone.
@@ -192,24 +194,31 @@ export function headHtml(it) {
192
194
  const kind = o.kind && !sameAs(o.kind, o.title) ? `<p class="cz-vw-kind">${esc(o.kind)}</p>` : '';
193
195
  const disc = o.discuss && !o.pop && (!o.home || o.discussHome) ? ib('discuss', 'Discuss in chat', P.chat) : ''; // in the popup the chat is beside it
194
196
  // a press marked menu (the initiative's Dashboard, batch 18 item 1) goes into ⋯ on a phone, so the title keeps the room
195
- const inMenu = phone && (o.presses || []).some((x) => x && x.menu && x.act && x.label);
197
+ // in the popup the work side's header is the title and ⋯ only (board 20): its quiet icon presses go into ⋯; a solid primary stays
198
+ const toMenu = (x) => (phone && x.menu) || (o.pop && !x.solid);
199
+ const inMenu = (o.presses || []).some((x) => x && x.act && x.label && toMenu(x));
196
200
  const more = inMenu || typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
197
201
  const add = o.add && o.add.label && !phone ? ib('add', o.add.label, P.add) : '';
198
202
  const pressHtml = (x) => (x.solid
199
203
  ? `<button type="button" class="cz-vw-pri${x.text && !phone ? '' : ' i'}${x.blue ? ' blue' : ''}" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 15, 2.2)}${x.text && !phone ? `<span>${esc(x.text)}</span>` : ''}</button>`
200
204
  : `<button type="button" class="cz-vw-ib" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}"${x.pressed != null ? ` aria-pressed="${x.pressed ? 'true' : 'false'}"` : ''}${x.lead ? ' aria-haspopup="menu"' : ''}>${svg(path(x.icon), 18)}</button>`);
201
- const shown = (o.presses || []).filter((x) => x && x.act && x.label && !(phone && x.menu));
205
+ const shown = (o.presses || []).filter((x) => x && x.act && x.label && !toMenu(x));
202
206
  // lead: a press that stands before Discuss (the initiative's kind of work, batch 29 item 11, KdV1-3)
203
207
  const lead = shown.filter((x) => x.lead).map(pressHtml).join(''), own = shown.filter((x) => !x.lead).map(pressHtml).join('');
204
208
  const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
205
209
  // the popup's path (board 22: initiative › suggestion): each step behind is a press that goes back to it
206
- const pth = o.pop && (o.path || []).length ? `<nav class="cz-vw-path" aria-label="Path">${o.path.map((t, i, a) => `<button type="button" data-cz-vw-path="${i - a.length}">${esc(t || 'Back')}</button><span aria-hidden="true">›</span>`).join('')}</nav>` : '';
210
+ // from: the page the item was opened from (Library, Routine; board 34): its name is the path's first step, and it closes back to the page
211
+ const from = o.pop && o.from ? `<button type="button" data-cz-vw-path="from">${esc(o.from)}</button><span aria-hidden="true">›</span>` : '';
212
+ const pth = o.pop && ((o.path || []).length || from) ? `<nav class="cz-vw-path" aria-label="Path">${from}${(o.path || []).map((t, i, a) => `<button type="button" data-cz-vw-path="${i - a.length}">${esc(t || 'Back')}</button><span aria-hidden="true">›</span>`).join('')}</nav>` : '';
213
+ // kindChip: the small kind chip after the title in the popup (Meeting notes, Report, Prototype)
214
+ const kchip = o.pop && o.kindChip ? `<span class="cz-vw-kchip">${esc(o.kindChip)}</span>` : '';
207
215
  const chip = o.chip && (o.chip.n > 0 || o.chip.looking) ? `<button type="button" class="cz-vw-chip${o.chip.looking ? ' live' : ''}" data-cz-vw="chip" aria-haspopup="dialog" aria-label="${esc(o.chip.label || 'PMOS proposes ' + o.chip.n + '. Open')}" title="${esc(o.chip.label || 'PMOS proposes')}">${svg(ICONS.spark, 13, 2)}${o.chip.n > 0 && !o.chip.quiet ? `<b>${esc(o.chip.n)}</b>` : ''}</button>` : '';
208
- return (o.canBack || phone ? ib('back', o.canBack ? (o.backTo ? 'Back to ' + o.backTo : 'Back') : 'Close the viewer', P.back) : '')
216
+ const canBack = o.canBack || !!from;
217
+ return (canBack || phone ? ib('back', o.canBack ? (o.backTo ? 'Back to ' + o.backTo : 'Back') : from ? 'Back to ' + o.from : 'Close the viewer', P.back) : '')
209
218
  + (o.fwdTo ? ib('fwd', 'Forward to ' + o.fwdTo, P.fwd) : '')
210
219
  + (o.check ? `<button type="button" class="cz-vw-tile cz-vw-chk s-${esc(o.check.state || 'todo')}" data-cz-vw="press" data-cz-vw-p="check" aria-label="${esc(o.check.label || 'Mark done')}" title="${esc(o.check.title || o.check.label || 'Mark done')}"${o.check.disabled ? ' disabled' : ''}><span class="bx"></span></button>`
211
220
  : `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
212
- + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${pth || kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}${o.wrap ? ' wrap' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
221
+ + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${pth || kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}${o.wrap ? ' wrap' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${kchip}${sub}</div>`)
213
222
  + lead + disc + own + add + more
214
223
  // ⧉ (batch 18 item 15, TbT7Place): where a page arranges panels, one placement press takes the place of ⤢ (Full screen is in it)
215
224
  + (phone || o.pop ? '' : o.place ? ib('place', 'Arrange', P.place, ' aria-haspopup="menu" aria-expanded="false"')
@@ -434,7 +443,7 @@ function moreMenu(b) {
434
443
  if (old) { old.remove(); b.setAttribute('aria-expanded', 'false'); return; }
435
444
  const items = ((typeof V.cur.more === 'function' ? V.cur.more() : V.cur.more) || []).filter(Boolean).slice(); // a function is asked each time ⋯ opens, so its notes are current
436
445
  // on a phone the presses marked menu lead the menu (they left the header)
437
- if (V.ph) { const mp = (V.cur.presses || []).filter((x) => x && x.menu && x.act && x.label); if (mp.length) items.unshift(...mp.map((x) => ({ label: x.label, icon: x.icon, on: () => { if (typeof V.cur.onPress === 'function') V.cur.onPress(x.act, b); } })), { sep: true }); }
446
+ if (V.ph || V.pop) { const mp = (V.cur.presses || []).filter((x) => x && x.act && x.label && (V.ph ? x.menu : !x.solid)); if (mp.length) items.unshift(...mp.map((x) => ({ label: x.label, icon: x.icon, on: () => { if (typeof V.cur.onPress === 'function') V.cur.onPress(x.act, b); } })), { sep: true }); }
438
447
  if (V.cur.url) { // the item's own address looks back, so it goes before the red stop-or-remove group, which stays last
439
448
  const at = items.findIndex((x) => x && x.danger), tab = { label: V.cur.full ? 'Open in full' : 'Open in a new tab', on: () => window.open(V.cur.url, '_blank', 'noopener') };
440
449
  if (at < 0) items.push({ sep: true }, tab); else items.splice(at > 0 && items[at - 1].sep ? at - 1 : at, 0, { sep: true }, tab);
@@ -493,7 +502,7 @@ function mount() {
493
502
  use(x);
494
503
  const f = e.target.closest('[data-czs-fold]'); if (f && el.contains(f)) { toggleFold(f); return; }
495
504
  if (e.target.closest('[data-cz-vw-rn]')) { startRename(); return; } // the title is the rename press (RnATask)
496
- const pa = e.target.closest('[data-cz-vw-path]'); if (pa) { const n = +pa.dataset.czVwPath; guarded(() => step(n), pa); return; } // the popup's path
505
+ const pa = e.target.closest('[data-cz-vw-path]'); if (pa) { if (pa.dataset.czVwPath === 'from') { guarded(() => close(), pa); return; } const n = +pa.dataset.czVwPath; guarded(() => step(n), pa); return; } // the popup's path
497
506
  const b = e.target.closest('[data-cz-vw]'); if (!b || b.disabled || !el.querySelector('.cz-vw-hd').contains(b)) return;
498
507
  const a = b.dataset.czVw;
499
508
  if (a === 'close') guarded(close, b);
@@ -615,6 +624,8 @@ export function open(it) {
615
624
  // pop (the popup, slice 2): on a desk the item goes in the popup's own Viewer, and the popup shows the chat about pop beside it
616
625
  const pn = !o._inst && G.popNext && Date.now() - G.popNext.t < 8000 ? G.popNext : null; if (pn) G.popNext = null; // popNext(): this open pops
617
626
  const popArg = o.pop || (pn && pn.pop);
627
+ // the header's from and kindChip may come with the pending popNext(about) (Library's POP.openWork), so no opener has to pass them
628
+ if (pn && pn.pop && typeof pn.pop === 'object' && (pn.pop.from || pn.pop.kindChip) && !o.from && !o.kindChip) o = { ...o, from: pn.pop.from || '', kindChip: pn.pop.kindChip || '' };
618
629
  // a published read-only Board has no chat; 'beside' (the PM's choice, cozy-popup.js) keeps work beside the page, unless the popup shows
619
630
  // already (it takes what opens next) or the open is the chat icon's own (force)
620
631
  const toPop = !o._inst && !!popArg && !!G.popH && !isPhone() && !window.PMOS_READONLY && (!!popArg.force || popShown() || !popBeside());
@@ -648,7 +659,7 @@ export function open(it) {
648
659
  V.drill = false; H.adopt = false;
649
660
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
650
661
  leave();
651
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, wrap: !!o.wrap, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
662
+ V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, wrap: !!o.wrap, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, from: o.from || '', kindChip: o.kindChip || '', args: o };
652
663
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
653
664
  redraw();
654
665
  el.querySelectorAll('.cz-vw-menu,.cz-vw-trail').forEach((m) => m.remove());
@@ -533,3 +533,42 @@
533
533
  /* the meeting share popover (shareable-meeting-notes): on a cozy page that does not load premium.css or cozy-viewer.css (premium-viewer.html), it names the cozy tokens itself. It lives here, not in premium-vw-doc.css, because the console type check (premium-console-type S1) would turn --sans and --mono back to the console fonts */
534
534
  .cz-vw-hd > .vwshp{--hair:var(--cz-hair);--ink:var(--cz-ink);--ink-2:var(--cz-ink2);--ink-3:var(--cz-ink3);--ember:var(--cz-blue);--card:var(--cz-card);--card-solid:var(--cz-card);
535
535
  --well:var(--cz-well);--ok:var(--cz-ok);--bad:var(--cz-red);--sans:var(--cz-sans);--mono:var(--cz-mono);--card-shadow:var(--cz-lift);border-radius:18px;padding:10px;max-height:calc(100dvh - 140px);overflow:auto}
536
+
537
+ /* a held meeting's notes, one view from every place (board 34, StLibMeetingOpen; Library audit item 6) */
538
+ .vzh-w { display: grid; grid-template-columns: minmax(0, 1fr) 300px; column-gap: 22px; align-items: start; }
539
+ .vzh-o { padding: 4px 2px 24px; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--cz-ink); }
540
+ .vzh-o p { margin: 0 0 6px; }
541
+ .vzh-o h6 { margin: 20px 0 4px; font-size: var(--fs-label); font-weight: var(--fw-strong); line-height: var(--lh-label); color: var(--cz-ink2); }
542
+ .vzh-o ul { margin: 0; padding-left: 18px; }
543
+ .vzh-o li + li { margin-top: 3px; }
544
+ .vzh-t { border-radius: 12px; box-shadow: inset 0 0 0 1px var(--cz-hair); overflow: hidden; }
545
+ .vzh-r { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }
546
+ .vzh-r:disabled { cursor: default; }
547
+ .vzh-r + .vzh-r { box-shadow: inset 0 1px 0 var(--cz-hair); }
548
+ .vzh-r:not(:disabled):hover { background: var(--cz-well); }
549
+ .vzh-r i { width: 7px; height: 7px; border-radius: 50%; background: var(--cz-ink); flex: 0 0 auto; }
550
+ .vzh-r span { flex: 1 1 0%; min-width: 0; }
551
+ .vzh-r em { font-style: normal; font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ink3); white-space: nowrap; }
552
+ .vzh-sg { margin: 16px 0; border-radius: 12px; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); padding: 8px 12px; }
553
+ .vzh-sg .vzh-sgh { margin: 0 0 2px; font-size: var(--fs-badge); font-weight: var(--fw-strong); line-height: var(--lh-badge); color: var(--cz-blueink); }
554
+ .vzh-sg div { display: flex; align-items: center; gap: 8px; font-size: var(--fs-meta); line-height: var(--lh-meta); }
555
+ .vzh-sg div span { flex: 1 1 0%; min-width: 0; }
556
+ .vzh-sg button { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 0; background: var(--cz-card); box-shadow: inset 0 0 0 1px var(--cz-hair); color: var(--cz-ink); cursor: pointer; font-size: var(--fs-meta); }
557
+ .vzh-sg button.y { background: var(--cz-solid); color: var(--cz-onsolid); box-shadow: none; }
558
+ .vzh-s { border-radius: 16px; background: var(--cz-well); padding: 12px 14px 14px; font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ink); }
559
+ .vzh-s h6 { margin: 4px 2px; font-size: var(--fs-badge); font-weight: var(--fw-strong); line-height: var(--lh-badge); color: var(--cz-ink3); }
560
+ .vzh-s .r { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 2px; box-shadow: inset 0 1px 0 var(--cz-hair); }
561
+ .vzh-s h6 + .r { box-shadow: none; }
562
+ .vzh-s .r span { flex: 1 1 0%; min-width: 0; color: var(--cz-ink2); }
563
+ .vzh-s .r em { font-style: normal; text-align: right; }
564
+ .vzh-s .vzh-sel { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 999px; background: var(--cz-card); font: inherit; font-weight: var(--fw-strong); white-space: nowrap; color: var(--cz-ink); cursor: pointer; }
565
+ .vzh-s .vzh-sel svg { fill: none; stroke: currentColor; stroke-width: 2; }
566
+ .vzh-s .r .vzh-sel svg[width="12"] { fill: currentColor; stroke: none; }
567
+ .vzh-s p { margin: 12px 2px 0; color: var(--cz-ink3); }
568
+ .vzh-s .vzh-more { margin: 8px 2px 0; }
569
+ .vzh-back { margin: 0 0 8px; }
570
+ @media (max-width: 760px) { .vzh-w { grid-template-columns: minmax(0, 1fr); row-gap: 12px; } }
571
+ .vzh-s .vzh-sel { max-width: 190px; }
572
+ .vzh-s .vzh-sel span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
573
+ .vzh-s .vzh-sel svg { flex: 0 0 auto; }
574
+ .vzh-sg button svg { fill: none; stroke: currentColor; stroke-width: 2.2; }
@@ -0,0 +1,205 @@
1
+ /* pm/goals-model.js — what Goals shows, from one product's GET /api/insights-premium model (initiative goals-place, slice 9 of the six-place
2
+ * navigation; boards 8, 13, 31, 32 and 33 on Exploring 2, handover /mnt/project-files/goals-handover/). PURE: no DOM, no fetch, no clock of its
3
+ * own; `today` ('YYYY-MM-DD') comes in.
4
+ *
5
+ * periodOf(F) → { label, sub } | null the OKR period chip: "H2 2026", "Jul 1 – Dec 31 · day 141 of 184"
6
+ * northStarOf(model, drafts) → { state: set | draft | none, title, sub, row?, goal? } the card above the table
7
+ * tableOf(model, today, filter) → { objectives, budgets, unlinked, total, shown } the one table: Objective › Key result › Levers › Initiative
8
+ * krPage(model, key, today) → the key result in the popup (board 31) | null
9
+ * setupOf(model, ns) → the setup page (board 32): names to confirm, sources to connect, targets and levers
10
+ * verdictOf(model, id, today) → the verdict page of an outcome (board 33) | null
11
+ * iniItem(r, model, today) → { id, title, line, tone, dm, verdict } one initiative's line in the Initiative column
12
+ * krTokens(tokens) → "KR-A1, A2, A3" · "KR-C1 to C4"
13
+ * FILTERS the filter: All, Slipping, Not read, Read
14
+ *
15
+ * NOTHING HERE MAKES A NUMBER UP (the proven-only rule). A key result with no reading shows "—" and says what it waits on. A target is the KR metric
16
+ * record's target, else the OKR file's own words, else "No target in your OKR file". An objective's name is the file's; a North Star is a kept
17
+ * record or an open PMOS draft, never a guess. Zero is silence: an objective with no key result shown, a budget with no work and an empty Unlinked
18
+ * row are not drawn. */
19
+
20
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
21
+ const DAY = 864e5;
22
+ const ms = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
23
+ export const mdy = (d) => { const t = ms(d); if (t === null) return ''; const x = new Date(t); return MON[x.getUTCMonth()] + ' ' + x.getUTCDate(); };
24
+ /** Whole days from a to b (b − a); null when either is not a day. */
25
+ export const daysTo = (a, b) => { const x = ms(a), y = ms(b); return x === null || y === null ? null : Math.round((y - x) / DAY); };
26
+ const noun = (n, one, many) => n + ' ' + (n === 1 ? one : many);
27
+
28
+ export const FILTERS = Object.freeze([['all', 'All'], ['slip', 'Slipping'], ['unread', 'Not read'], ['read', 'Read']]);
29
+
30
+ /** "O-A" → "Objective A", "O1" → "Objective 1", "Objective 2" stays. */
31
+ export function objLabel(token) {
32
+ const s = String(token || '').trim();
33
+ const m = /^O-?([A-Za-z0-9]+)$/i.exec(s);
34
+ return m ? 'Objective ' + m[1].toUpperCase() : s.replace(/^objective/i, 'Objective');
35
+ }
36
+ /** Key result ids said short: the first in full, the rest without their shared prefix; four or more in a row of one letter say "KR-C1 to C4". */
37
+ export function krTokens(tokens) {
38
+ const T = (tokens || []).filter(Boolean);
39
+ if (!T.length) return '';
40
+ const pre = (t) => (/^(KR-?)(.*)$/i.exec(t) || [null, '', t]);
41
+ const parts = T.map((t) => { const p = pre(t); return { pre: p[1], rest: p[2] }; });
42
+ const run = parts.map((p) => /^([A-Za-z]*)(\d+)$/.exec(p.rest));
43
+ if (T.length >= 4 && run.every((m) => m && m[1] === run[0][1]) && run.every((m, i) => i === 0 || +m[2] === +run[i - 1][2] + 1)) return T[0] + ' to ' + parts[T.length - 1].rest;
44
+ return T[0] + T.slice(1).map((t, i) => ', ' + (parts[i + 1].pre && parts[i + 1].pre === parts[0].pre ? parts[i + 1].rest : t)).join('');
45
+ }
46
+
47
+ export function periodOf(F) {
48
+ const P = F && F.period;
49
+ if (!P || !P.label) return null;
50
+ const span = P.fromAt && P.toAt ? mdy(P.fromAt) + ' – ' + mdy(P.toAt) : '';
51
+ const day = P.day && P.days ? 'day ' + P.day + ' of ' + P.days : '';
52
+ return { label: P.label, sub: [span, day].filter(Boolean).join(' · ') };
53
+ }
54
+
55
+ /** The North Star: a kept record (role north-star), else an open PMOS draft (GET /api/metric-drafts, group North Star), else none. */
56
+ export function northStarOf(model, drafts) {
57
+ const g = ((model && model.goals) || []).find((x) => x && x.role === 'north-star');
58
+ if (g) return { state: 'set', goal: g.id, title: g.title, sub: g.nowTxt ? 'Now ' + g.nowTxt + (g.targetTxt ? ' · target ' + g.targetTxt : '') : 'Not read yet' };
59
+ const rows = (drafts && Array.isArray(drafts.rows) ? drafts.rows : []).filter((r) => r && r.group === 'North Star' && r.state === 'open');
60
+ if (rows.length) {
61
+ const r = rows[0];
62
+ return { state: 'draft', row: r.id, title: String(r.name || r.metric || '').trim() || 'A North Star', sub: String(r.why || r.basis || '').trim() || 'PMOS drafted it from your key results. The rest hangs from it once you approve.' };
63
+ }
64
+ return { state: 'none', title: 'No North Star yet', sub: 'Your OKR file names none. Ask PMOS to draft one from your key results; you approve it with a tick.' };
65
+ }
66
+
67
+ const DOT = { on: 'ok', close: 'rk', behind: 'rk', broken: 'rd' };
68
+ const goalOf = (model, id) => (id && ((model && model.goals) || []).find((g) => g.id === id)) || null;
69
+
70
+ /** One key result row. */
71
+ function krRow(model, o, k, today) {
72
+ const g = goalOf(model, k.goal), F = model.okrFile || {};
73
+ const read = !!(k.read && g);
74
+ const dot = read ? DOT[(g.reading || {}).dot] || '' : '';
75
+ const due = k.due || (F.period && F.period.toAt) || null, d = due ? daysTo(today, due) : null;
76
+ const sub = read ? 'read ' + mdy((g.reading && g.reading.at) || (g.lastRead && g.lastRead.day) || '') + (g.reading && g.reading.source ? ' · ' + g.reading.source : '')
77
+ : k.decision ? 'waits on a decision' + (k.due ? ', due ' + mdy(k.due) : '')
78
+ : k.need ? 'waits on ' + k.need : g && g.recipe ? 'PMOS reads it' : 'no source named';
79
+ return {
80
+ key: k.key, token: k.token, title: k.title, dot, sub: sub.replace(/\s·\s$/, ''), read, goal: k.goal || null, need: read ? '' : k.need || '',
81
+ act: read ? g.nowTxt : '', target: g && g.targetTxt ? g.targetTxt : '', tone: dot === 'rk' ? 'risk' : dot === 'rd' ? 'late' : '',
82
+ left: d === null ? '' : d > 0 ? noun(d, 'day', 'days') : d === 0 ? 'today' : noun(-d, 'day', 'days') + ' over', due,
83
+ moves: (k.moves || []).map((r) => r.id),
84
+ };
85
+ }
86
+ const passes = (row, filter) => filter === 'slip' ? row.dot === 'rk' || row.dot === 'rd' : filter === 'unread' ? !row.read : filter === 'read' ? row.read : true;
87
+
88
+ /** The outcome promise of an initiative (model.outcomes), by id. */
89
+ const outcomeOf = (model, id) => ((model && model.outcomes) || []).find((r) => r && r.id === id) || null;
90
+
91
+ export function iniItem(r, model, today) {
92
+ const o = outcomeOf(model, r.id), p = o && o.promise;
93
+ const base = { id: r.id, title: r.title, ws: r.ws || '', line: '', tone: '', dm: '', verdict: false };
94
+ if (o && o.verdict) return { ...base, line: 'judged: ' + o.verdict.verdict, dm: 'ok' };
95
+ if (p && p.horizon) {
96
+ if (p.overdue) return { ...base, line: 'overdue · due ' + mdy(p.horizon), tone: 'late', dm: 'rd', verdict: true };
97
+ return { ...base, line: 'check due ' + mdy(p.horizon), dm: 'q' };
98
+ }
99
+ const d = r.endAt ? daysTo(today, r.endAt) : null;
100
+ if (d !== null && d < 0 && r.status !== 'done') return { ...base, line: noun(-d, 'day', 'days') + ' over', tone: 'late' };
101
+ if (r.status === 'late') return { ...base, line: 'late', tone: 'late' };
102
+ if (d !== null && d >= 0) return { ...base, line: d === 0 ? 'ships today' : 'ships in ' + noun(d, 'day', 'days') };
103
+ return { ...base, line: r.stageLabel || '' };
104
+ }
105
+
106
+ /** The levers of an objective: KR metric records with role input whose kr anchor names one of its key results. */
107
+ function leversOf(model, o) {
108
+ const toks = o.krs.map((k) => String(k.token).toLowerCase());
109
+ return ((model && model.goals) || []).filter((g) => g && g.role === 'input' && g.kr && toks.some((t) => new RegExp('(^|[^a-z0-9])' + t.replace(/[-.]/g, '\\$&') + '($|[^a-z0-9.])', 'i').test(g.kr)))
110
+ .map((g) => ({ id: g.id, title: g.title, txt: g.nowTxt || 'not read', tone: DOT[(g.reading || {}).dot] === 'rk' ? 'risk' : DOT[(g.reading || {}).dot] === 'rd' ? 'late' : '' }));
111
+ }
112
+
113
+ /** The work of an objective's rows, each initiative once, laid over the rows of the key results it moves; overlapping spans share one cell. */
114
+ function iniSpans(rows, model, today, byId) {
115
+ const at = new Map();
116
+ rows.forEach((k, i) => { for (const id of k.moves) { const s = at.get(id); if (s) s.last = i; else at.set(id, { first: i, last: i }); } });
117
+ const list = [...at.entries()].map(([id, s]) => ({ ...s, item: iniItem(byId.get(id) || { id, title: id }, model, today) })).sort((a, b) => a.first - b.first || a.last - b.last);
118
+ const cells = [];
119
+ for (const x of list) {
120
+ const c = cells[cells.length - 1];
121
+ if (c && x.first <= c.last) { c.last = Math.max(c.last, x.last); c.items.push(x.item); } else cells.push({ first: x.first, last: x.last, items: [x.item] });
122
+ }
123
+ return cells.map((c) => ({ from: c.first + 1, span: c.last - c.first + 1, items: c.items }));
124
+ }
125
+
126
+ export function tableOf(model, today, filter = 'all') {
127
+ const F = model && model.okrFile;
128
+ const byId = new Map();
129
+ if (F) for (const o of F.objectives) for (const k of o.krs) for (const r of k.moves || []) byId.set(r.id, r);
130
+ const objectives = [];
131
+ let total = 0, shown = 0;
132
+ for (const o of (F && F.objectives) || []) {
133
+ const all = o.krs.map((k) => krRow(model, o, k, today));
134
+ total += all.length;
135
+ const rows = all.filter((r) => passes(r, filter));
136
+ shown += rows.length;
137
+ if (!rows.length) continue;
138
+ const slip = all.filter((r) => r.dot === 'rk' || r.dot === 'rd').length;
139
+ objectives.push({ id: o.id, label: objLabel(o.token), title: o.title || '', slip: slip ? slip + ' slipping' : '', krs: rows, levers: leversOf(model, o), inis: iniSpans(rows, model, today, byId) });
140
+ }
141
+ const whole = filter === 'all';
142
+ const budgets = whole ? ((model && model.budgets) || []).filter((b) => b && (b.moves || []).length).map((b) => ({
143
+ id: b.id, label: b.id, share: b.reading && b.reading.share !== null && b.reading.share !== undefined && typeof b.cap === 'number' ? Math.round(b.reading.share * 100) + '% of ' + Math.round(b.cap * 100) + '%' : '',
144
+ over: !!(b.reading && b.reading.over), covers: b.covers || '', items: b.moves.map((r) => iniItem(r, model, today)),
145
+ })) : [];
146
+ const unlinked = whole ? ((model && model.unlinked) || []).map((r) => iniItem(r, model, today)) : [];
147
+ return { objectives, budgets, unlinked, total, shown };
148
+ }
149
+
150
+ /** Every key result of the file, flat, with its objective. */
151
+ const flat = (F) => ((F && F.objectives) || []).flatMap((o) => o.krs.map((k) => ({ o, k })));
152
+
153
+ export function krPage(model, key, today) {
154
+ const F = model && model.okrFile, hit = flat(F).find((x) => x.k.key === key);
155
+ if (!hit) return null;
156
+ const { o, k } = hit, row = krRow(model, o, k, today), g = goalOf(model, k.goal);
157
+ const read = row.read
158
+ ? { head: row.act + (g.reading && g.reading.at ? ' on ' + mdy(g.reading.at) : ''), sub: g.reading && g.reading.source ? 'From ' + g.reading.source + '.' : '' }
159
+ : { head: 'Not read yet', sub: k.decision ? 'It waits on a decision' + (k.due ? ', due ' + mdy(k.due) : '') + '.' : row.need ? 'It waits on ' + row.need + '. PMOS has not read it yet.' : 'Your OKR file names no source for it.' };
160
+ const target = g && g.targetTxt ? { head: g.targetTxt + (g.by ? ' by ' + g.by : ''), sub: '' } : k.line ? { head: k.line, sub: 'In your OKR file, not yet a number PMOS can read against.' } : { head: 'No target in your OKR file', sub: '' };
161
+ const leftTxt = row.left ? (row.left === 'today' ? 'Due today' : /over$/.test(row.left) ? row.left : row.left + ' left') + (row.due ? ', to ' + mdy(row.due) : '') : '';
162
+ target.sub = [target.sub, leftTxt].filter(Boolean).join(' ');
163
+ const levers = leversOf(model, { krs: [k] });
164
+ const byId = new Map((k.moves || []).map((r) => [r.id, r]));
165
+ const inis = [...byId.values()].map((r) => iniItem(r, model, today));
166
+ const frees = row.need ? flat(F).filter((x) => !x.k.read && x.k.need === row.need).map((x) => x.k.token) : [];
167
+ return {
168
+ key, token: k.token, title: k.title, sub: k.token + ' · ' + objLabel(o.token) + (o.title ? ', ' + o.title : ''), goal: k.goal || null,
169
+ read, target, levers, inis,
170
+ sug: row.need ? { need: row.need, say: 'Connect ' + row.need, why: 'Frees ' + krTokens(frees) + '. PMOS tests a read before it keeps it.' } : null,
171
+ };
172
+ }
173
+
174
+ export function setupOf(model, ns) {
175
+ const F = model && model.okrFile;
176
+ if (!F) return null;
177
+ const names = F.objectives.map((o) => ({ id: o.id, label: objLabel(o.token) + (o.title ? ': ' + o.title : ''), krs: krTokens(o.krs.map((k) => k.token)), named: !!o.title }));
178
+ const by = new Map();
179
+ for (const { k } of flat(F)) if (!k.read && k.need) { if (!by.has(k.need)) by.set(k.need, []); by.get(k.need).push(k.token); }
180
+ const sources = [...by.entries()].sort((a, b) => b[1].length - a[1].length).map(([need, toks]) => ({ need, frees: 'Frees ' + krTokens(toks) }));
181
+ const withTarget = flat(F).filter(({ k }) => { const g = goalOf(model, k.goal); return g && g.targetTxt; }).length;
182
+ return { ns: ns || northStarOf(model, null), names, sources, targets: withTarget ? '' : 'Your OKR file gives no target number and names no levers. Once a key result is read, PMOS drafts a target and the levers behind it. You approve each with a tick.' };
183
+ }
184
+
185
+ export function verdictOf(model, id, today) {
186
+ const o = outcomeOf(model, id);
187
+ if (!o) return null;
188
+ const p = o.promise || {}, late = p.horizon ? daysTo(p.horizon, today) : null;
189
+ const hit = flat(model.okrFile).find((x) => (x.k.moves || []).some((r) => r.id === id));
190
+ const g = hit ? goalOf(model, hit.k.goal) : null;
191
+ const krGot = hit ? (hit.k.read && g ? g.nowTxt : hit.k.need ? 'Waits on ' + hit.k.need : 'Not read yet') : '';
192
+ const head = p.horizon ? 'Outcome · check ' + (late > 0 ? 'was due ' + mdy(p.horizon) + ', ' + noun(late, 'day', 'days') + ' ago' : 'due ' + mdy(p.horizon)) : 'Outcome';
193
+ return {
194
+ id, title: o.title, head,
195
+ sub: (o.endAt ? 'Shipped ' + mdy(o.endAt) + '. ' : '') + (p.metric || p.horizon ? 'PMOS has the promise and can read what you got.' : 'No promise was written when it was approved.'),
196
+ rows: [
197
+ ['Result', p.metric || 'As approved with the initiative', 'Not read yet'],
198
+ hit ? ['Key result it moves', hit.k.token + ' ' + hit.k.title, krGot] : null,
199
+ ['Verdict', o.verdict ? o.verdict.verdict : 'Not judged', o.verdict ? o.verdict.learned || '' : 'Worked, partly, or did not'],
200
+ ].filter(Boolean),
201
+ reads: [{ label: 'The promise written when the initiative was approved', val: o.title, ini: id },
202
+ hit ? { label: 'Key result ' + hit.k.token + ' and its source', val: hit.k.read ? 'read' : hit.k.need || hit.k.source || 'no source named', key: hit.k.key, late: !hit.k.read } : null].filter(Boolean),
203
+ judged: !!o.verdict,
204
+ };
205
+ }
@@ -0,0 +1,124 @@
1
+ /* pm/goals-open.js — what Goals opens in the one popup (initiative goals-place, slice 9 of the six-place navigation; boards 31, 32 and 33 on
2
+ * Exploring 2). The thing is on the left, Ask PMOS about it on the right (cozy-popup.js openWork). The look is the popup's own (cozy-pop-work.css,
3
+ * the .pw classes slice 3 drew the suggestion page with) plus cozy-goals.css.
4
+ *
5
+ * openKr(ctx, key) a key result (board 31): What PMOS read, Target and time left, Levers, Initiative that names it, one ✦ to connect its source
6
+ * openSetup(ctx) Set up (board 32): the North Star, Names to confirm, Sources to connect, Targets and levers
7
+ * openVerdict(ctx, id) the verdict on an outcome whose check is due (board 33): Did it do what it promised?, When you say yes, What PMOS reads
8
+ * openIni(ctx, id) an initiative, as every place opens it (premium-vw-item.js), slice 3's popup
9
+ * ctx = { model, ws, today, ns, keepNs(row), dropNs(row), toast(text) }
10
+ *
11
+ * A ✓ that asks PMOS to act (connect a source, draft the North Star, judge an outcome, name an objective) puts the words in the chat on the right
12
+ * for the PM to send: nothing is sent or written by the press itself. The North Star draft's ✓ and ✕ are the metric-drafts keep and drop the page
13
+ * owns (ctx.keepNs, ctx.dropNs), with Undo. The UI says PMOS only; icon-only buttons carry aria-label. */
14
+ import * as POP from './cozy-popup.js';
15
+ import * as VW from './cozy-viewer.js';
16
+ import * as GM from './goals-model.js';
17
+
18
+ const CSS = ['./cozy-pop-work.css', './cozy-goals.css'].map((p) => new URL(p, import.meta.url).href);
19
+ if (typeof document !== 'undefined' && document.head) for (const h of CSS) if (!document.querySelector(`link[href="${h}"]`)) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = h; document.head.appendChild(l); }
20
+
21
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
22
+ 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>`;
23
+ const P = { check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', right: 'M10 7l5 5-5 5', chat: 'M4 5h16v11H9l-5 4z', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z' };
24
+ const ib = (attr, label, d, cls = '') => `<button type="button" class="pw-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(d)}</button>`;
25
+ const row = (attr, label, val, cls = '') => `<button type="button" class="pw-src gl-src" ${attr}><span>${esc(label)}</span><span class="gl-srcv"><small class="${cls}">${esc(val || '')}</small>${SVG(P.right, 14)}</span></button>`;
26
+ const ask = '<button type="button" class="pw-ask" data-gl-ask>' + SVG(P.chat, 15) + 'Ask PMOS about this</button>';
27
+
28
+ /** The words go in the chat on the right, as a draft the PM sends. The chat shows first when it was hidden. */
29
+ export function toChat(text) {
30
+ const a = document.querySelector('.cz-pop [data-pop="ask"]'); if (a && !a.closest('[hidden]')) a.click();
31
+ let n = 0;
32
+ const put = () => {
33
+ const ta = document.querySelector('.cz-pop-chat textarea, .cz-pop-chat [contenteditable="true"]');
34
+ if (!ta) { if (++n < 30) setTimeout(put, 50); return; }
35
+ if ('value' in ta) { ta.value = text; ta.dispatchEvent(new Event('input', { bubbles: true })); } else ta.textContent = text;
36
+ ta.focus();
37
+ };
38
+ put();
39
+ }
40
+
41
+ function show(ctx, it, html, on) {
42
+ const about = { id: String(it.id).replace(/[^A-Za-z0-9._:-]+/g, '-').slice(0, 100), kind: 'goal', title: it.about || it.title, ws: ctx.ws || undefined };
43
+ const item = { kind: it.kind, title: it.title, icon: it.icon || 'chart', id: it.id, back: !!it.back,
44
+ render: (b) => { b.innerHTML = html(); b.onclick = (e) => { const t = e.target.closest('button,a'); if (t) on(t, e, b); }; } };
45
+ if (it.back && POP.isOpen()) { VW.drill(); VW.open(item); return; }
46
+ POP.openWork({ about, open: () => VW.open(item) });
47
+ }
48
+
49
+ /* ── a key result (board 31) ── */
50
+ export function openKr(ctx, key, back = false) {
51
+ const K = GM.krPage(ctx.model, key, ctx.today); if (!K) return false;
52
+ const fact = (label, head, sub) => `<div class="gl-f"><small>${esc(label)}</small><b>${esc(head)}</b>${sub ? `<span>${esc(sub)}</span>` : ''}</div>`;
53
+ const html = () => `<div class="pw pw-sp gl-pg">`
54
+ + `<div class="pw-spc gl-top"><p class="pw-sugh">Key result · ${esc(K.sub)}</p><h3>${esc(K.title)}</h3></div>`
55
+ + `<div class="gl-fs">${fact('What PMOS read', K.read.head, K.read.sub)}${fact('Target and time left', K.target.head, K.target.sub)}`
56
+ + fact('Levers', K.levers.length ? K.levers.map((l) => l.title + ' ' + l.txt).join(' · ') : 'None named', '') + '</div>'
57
+ + (K.inis.length ? `<h4>Initiative that names it</h4><div class="pw-card">${K.inis.map((i) => row(`data-gl-ini="${esc(i.id)}"${i.verdict ? ' data-gl-verdict' : ''}`, i.title, i.line, i.tone === 'late' ? 'warn' : 'grey')).join('')}</div>` : '')
58
+ + (K.goal ? `<div class="pw-card">${row(`data-gl-chart="${esc(K.goal)}"`, 'Readings and chart', 'Intelligence', 'grey')}</div>` : '')
59
+ + (K.sug ? `<div class="gl-sg"><i class="pw-spark" aria-hidden="true">${SVG(P.spark, 14, 2)}</i><div><b>${esc(K.sug.say)}</b><span>${esc(K.sug.why)}</span></div>${ib('data-gl-connect', 'Yes, ask PMOS to connect ' + K.sug.need, P.check, 'sm')}</div>` : '')
60
+ + ask + '</div>';
61
+ show(ctx, { id: 'kr:' + key, kind: 'Key result', title: K.token + ' · ' + K.title, icon: 'goal', back }, html, (t) => {
62
+ const d = t.dataset;
63
+ if (d.glIni) { if ('glVerdict' in d) openVerdict(ctx, d.glIni, true); else openIni(ctx, d.glIni); return; }
64
+ if (d.glChart) { location.assign('/premium-intelligence.html?' + (ctx.ws ? 'ws=' + encodeURIComponent(ctx.ws) + '&' : '') + 'goal=' + encodeURIComponent(d.glChart)); return; }
65
+ if ('glConnect' in d) { toChat('Connect ' + K.sug.need + ' so you can read ' + K.token + '. ' + K.sug.why + ' Tell me what you need from me.'); return; }
66
+ if ('glAsk' in d) toChat('About ' + K.token + ' ' + K.title + ': am I on track, and what should I do next?');
67
+ });
68
+ return true;
69
+ }
70
+
71
+ /* ── Set up (board 32) ── */
72
+ export function openSetup(ctx) {
73
+ const S = GM.setupOf(ctx.model, ctx.ns); if (!S) return false;
74
+ const ns = S.ns;
75
+ const top = ns.state === 'draft'
76
+ ? `<div class="pw-spc gl-top"><p class="pw-sugh">${SVG(P.spark, 13, 2)} PMOS drafted this</p><h3>${esc(ns.title)}</h3><p>Your North Star. ${esc(ns.sub)}</p><span class="pw-spb">${ib('data-gl-nskeep', 'Approve this North Star', P.check, 'solid')}${ib('data-gl-nsdrop', 'No', P.x)}</span></div>`
77
+ : ns.state === 'set'
78
+ ? `<div class="pw-spc gl-top gl-set"><p class="pw-sugh">North Star</p><h3>${esc(ns.title)}</h3><p>${esc(ns.sub)}</p></div>`
79
+ : `<div class="pw-spc gl-top"><p class="pw-sugh">North Star · not set</p><h3>${esc(ns.title)}</h3><p>${esc(ns.sub)}</p><span class="pw-spb">${ib('data-gl-nsdraft', 'Ask PMOS to draft the North Star', P.spark)}</span></div>`;
80
+ const html = () => `<div class="pw pw-sp gl-pg">${top}`
81
+ + `<h4>Names to confirm</h4><div class="pw-card">${S.names.map((n) => row(`data-gl-name="${esc(n.id)}"`, n.label, n.krs, 'grey')).join('')}</div>`
82
+ + (S.sources.length ? `<h4>Sources to connect, so a grey dot can turn into a reading</h4><div class="pw-card">${S.sources.map((s) => row(`data-gl-src="${esc(s.need)}"`, s.need, s.frees, 'warn')).join('')}</div>` : '')
83
+ + (S.targets ? `<h4>Targets and levers</h4><p>${esc(S.targets)}</p>` : '')
84
+ + ask + '</div>';
85
+ show(ctx, { id: 'goals:setup:' + (ctx.ws || ''), kind: 'Goals', title: 'Set up', about: 'Setting up Goals', icon: 'chart' }, html, async (t, e, b) => {
86
+ const d = t.dataset;
87
+ if ('glNskeep' in d) { t.disabled = true; await ctx.keepNs(ns.row); b.innerHTML = '<div class="pw gl-pg"><p class="grey">Kept. The North Star is set.</p></div>'; return; }
88
+ if ('glNsdrop' in d) { t.disabled = true; await ctx.dropNs(ns.row); return; }
89
+ if ('glNsdraft' in d) { toChat('Draft a North Star for this product from its key results. I approve it with a tick.'); return; }
90
+ if (d.glName) { const n = S.names.find((x) => x.id === d.glName); if (n) toChat((n.named ? 'Check the name of ' : 'Name ') + n.label + ' (' + n.krs + '). Draft it from its key results; I approve it with a tick.'); return; }
91
+ if (d.glSrc) { const s = S.sources.find((x) => x.need === d.glSrc); if (s) toChat('Connect ' + s.need + '. ' + s.frees + '. Test a read before you keep it, and tell me what you need from me.'); return; }
92
+ if ('glAsk' in d) toChat('About setting up Goals: what should I confirm or connect first?');
93
+ });
94
+ return true;
95
+ }
96
+
97
+ /* ── the verdict on an outcome (board 33) ── */
98
+ export function openVerdict(ctx, id, back = false) {
99
+ const V = GM.verdictOf(ctx.model, id, ctx.today); if (!V) { openIni(ctx, id); return false; }
100
+ const html = () => `<div class="pw pw-sp gl-pg">`
101
+ + `<div class="pw-spc gl-top"><p class="pw-sugh">${esc(V.head)}</p><h3>${esc(V.title)}</h3><p>${esc(V.sub)}</p>${V.judged ? '' : `<span class="pw-spb">${ib('data-gl-judge', 'Judge this outcome now', P.check, 'solid')}</span>`}</div>`
102
+ + `<h4>Did it do what it promised?</h4><div class="pw-card pw-chg" role="table"><div class="pw-cr pw-th" role="row"><span role="columnheader">What</span><span role="columnheader">Promised</span><span role="columnheader">Got</span></div>`
103
+ + V.rows.map((r, i) => `<div class="pw-cr" role="row"><span role="cell">${esc(r[0])}</span><span role="cell"${i === V.rows.length - 1 && !V.judged ? ' class="grey"' : ''}>${esc(r[1])}</span><span role="cell" class="grey">${esc(r[2])}</span></div>`).join('') + '</div>'
104
+ + (V.judged ? '' : '<h4>When you say yes</h4><p>PMOS reads the result, sets it beside the promise and gives a verdict with the reason. It also lines the result up against what shipped around it. Nothing changes in your plan until you approve the lesson.</p>')
105
+ + `<h4>What PMOS reads</h4><div class="pw-card">${V.reads.map((r) => row(r.key ? `data-gl-kr="${esc(r.key)}"` : `data-gl-ini="${esc(r.ini)}"`, r.label, r.val, r.late ? 'warn' : 'grey')).join('')}</div>`
106
+ + ask + '</div>';
107
+ show(ctx, { id: 'outcome:' + id, kind: 'Outcome', title: V.title, back }, html, (t) => {
108
+ const d = t.dataset;
109
+ if ('glJudge' in d) { toChat('Judge the outcome of ' + V.title + ': read the result, set it beside the promise and give me a verdict with the reason. Change nothing in the plan until I approve the lesson.'); return; }
110
+ if (d.glKr) { openKr(ctx, d.glKr, true); return; }
111
+ if (d.glIni) { openIni(ctx, d.glIni); return; }
112
+ if ('glAsk' in d) toChat('About the outcome of ' + V.title + ': did it do what it promised?');
113
+ });
114
+ return true;
115
+ }
116
+
117
+ /* ── an initiative: as every place opens it (slice 3) ── */
118
+ export function openIni(ctx, id) {
119
+ const r = (ctx.model.outcomes || []).find((x) => x.id === id) || ((ctx.model.okrFile && ctx.model.okrFile.objectives) || []).flatMap((o) => o.krs.flatMap((k) => k.moves || [])).find((x) => x.id === id)
120
+ || (ctx.model.unlinked || []).find((x) => x.id === id) || (ctx.model.budgets || []).flatMap((b) => b.moves || []).find((x) => x.id === id) || { id, title: id };
121
+ if (POP.isOpen()) VW.drill();
122
+ POP.openWork({ about: { id, kind: 'initiative', title: r.title, ws: ctx.ws || undefined },
123
+ open: () => import('./premium-vw-item.js').then((M) => M.openWorkItem({ kind: 'initiative', id, ws: ctx.ws || '', title: r.title })) });
124
+ }
@@ -159,8 +159,10 @@ export function mountChat(el, host) {
159
159
  }
160
160
  if (it.t === 'worked') {
161
161
  const id = 'w' + i, on = C.open.has(id);
162
- const what = toolLine(it.tools).replace(/^Used /, '');
163
- return `<div class="hm-worked"><button type="button" class="hm-wk" data-hm-wk="${id}" aria-expanded="${on}">${SVG(CHEV, 12, 2.4)}<span>Worked${it.took ? ' ' + esc(it.took) : ''}${what ? ' · ' + esc(what) : ''}</span></button>`
162
+ // the tool steps of one answer fold into one grey line, "5 steps" (popup round 3 point 9); the press opens them
163
+ const n = it.calls.length || Object.values(it.tools || {}).reduce((k, v) => k + (Number(v) || 0), 0);
164
+ const what = n ? n + (n === 1 ? ' step' : ' steps') : 'Worked' + (it.took ? ' ' + it.took : '');
165
+ return `<div class="hm-worked"><button type="button" class="hm-wk" data-hm-wk="${id}" aria-expanded="${on}" title="${esc(toolLine(it.tools) + (it.took ? ' · ' + it.took : ''))}">${SVG(CHEV, 12, 2.4)}<span>${esc(what)}</span></button>`
164
166
  + (on ? `<ol class="hm-calls">${it.calls.slice(0, 40).map((c) => `<li><b>${esc(c.tool.split(/__|\//).pop())}</b><code>${esc(c.target || '')}</code></li>`).join('')}</ol>` : '') + '</div>'
165
167
  + (it.ask ? askHtmlOf(it, R) : '');
166
168
  }
@@ -37,6 +37,7 @@ import * as DB from './dash-view.js'; // the ready-made Dashboard view (batch
37
37
  import * as TL from './ini-tail.js';
38
38
  import * as PW from './cozy-pop-work.js'; // what the popup shows for work (slice 3 of the six-place navigation): in the popup, in place of the old page
39
39
  import * as PP from './ini-props.js'; // everything PMOS suggests, as a drill-in (the popup's ⋯) // under Linked, as the Board draws it (UI grill U1): drafted tickets, the PRD drift, Your impact
40
+ import * as SWN from './cozy-status-when.js'; // the day a status move really happened, in the toast (round 3 point 18)
40
41
 
41
42
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
42
43
  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>`;
@@ -264,7 +265,7 @@ function holdPop(anchor, id) {
264
265
  /** In the popup: what pm/cozy-pop-work.js shows for work, from the same view model and the page's own read. */
265
266
  function popOpts(id, M) {
266
267
  const v = X.ctx.view(id) || {};
267
- return { today: v.today, docs: M ? MD.docRows(M) : [], product: (M && M.board && (M.board.name || M.board.ws)) || rowOf(id).ws || '', program: (v.summary && v.summary.program) || null, ws: (M && M.board && M.board.ws) || rowOf(id).ws || '', id };
268
+ return { today: v.today, docs: M ? MD.docRows(M) : [], product: (M && M.board && (M.board.name || M.board.ws)) || rowOf(id).ws || '', program: (v.summary && v.summary.program) || null, ws: (M && M.board && M.board.ws) || rowOf(id).ws || '', board: (M && M.board && M.board.id) || '', id };
268
269
  }
269
270
  function popHtml(id, M) {
270
271
  X.ctx.head(id);
@@ -299,7 +300,7 @@ function wirePage(b, id) {
299
300
  check: async (uid, btn) => {
300
301
  await setState(id, uid, btn.getAttribute('aria-pressed') === 'true' ? 'To do' : 'Done');
301
302
  },
302
- status: (uid, state) => setState(id, uid, state),
303
+ status: (uid, state, w) => setState(id, uid, state, w),
303
304
  dates: (uid, patch) => setDates(id, uid, patch),
304
305
  milestone: (uid, on) => setDates(id, uid, { milestone: !!on }), // the ◇ in the status picker (batch 11 item 3)
305
306
  remove: (uid) => removeTask(id, uid), // the trash in the status picker (batch 11 item 16)
@@ -361,14 +362,15 @@ function taskAt(id, uid) {
361
362
  }
362
363
  /** The quick status (the box, its caret, a Kanban drag): POST /api/boards/tasks/state, Undo puts the old state back. A breakdown item set
363
364
  * to Won't do is withdrawn, which the ledger cannot undo, so that toast has no Undo. */
364
- async function setState(id, uid, state) {
365
+ async function setState(id, uid, state, w) {
365
366
  const M = curM(); if (!M) return;
366
- const k = taskAt(id, uid), C = X.ctx, body = { ...bw(M), task: uid };
367
- const r = await C.pmPost('/api/boards/tasks/state', { ...body, state });
367
+ const k = taskAt(id, uid), C = X.ctx, body = { ...bw(M), task: uid }, happened = (w && w.happened) || null;
368
+ const r = await C.pmPost('/api/boards/tasks/state', { ...body, state, ...(happened ? { happened } : {}) });
368
369
  if (!r || r.ok === false) { C.toast((r && r.error) || 'Nothing was changed.'); return; }
369
370
  await C.load(); redrawView();
370
371
  const was = k && k.status;
371
- if (was && was !== state && !(k.item && state === "Won't do")) undoToast(state + ': ' + k.title + '.', async () => { const u = await C.pmPost('/api/boards/tasks/state', { ...body, state: was }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
372
+ // the day it really happened is said beside the title (round 3 point 18): "Done on 14 Nov, noted today."
373
+ if (was && was !== state && !(k.item && state === "Won't do")) undoToast(happened ? SWN.whenWords(state, happened).replace(/\.$/, '') + ': ' + k.title + '.' : state + ': ' + k.title + '.', async () => { const u = await C.pmPost('/api/boards/tasks/state', { ...body, state: was }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
372
374
  else C.toast(state + (k ? ': ' + k.title : '') + '.');
373
375
  }
374
376
  /** The status picker's trash (batch 11 item 16): POST /api/boards/tasks/delete, a Board task or a breakdown item; Undo restores it. */
@@ -17,6 +17,8 @@
17
17
  * wire(body) once per body: the name field (Enter or blur saves, Esc closes), the add field (Enter adds and stays open),
18
18
  * a press outside the open row closes it, and the drag (StA10Drag): a grip on hover on a desktop, a long press
19
19
  * on the title on a phone; the target stage lights up and a blue line shows where the task lands
20
+ * milestone(H, x, on) a task made a milestone (one date: the due day, else the start) or a task again, through H.dates; the
21
+ * host's toast carries Undo. The popup for work (pm/cozy-pop-work.js) calls the same, so there is one way
20
22
  * writes(h) the host's handlers with the writes this file needs, where the host has none: h.rename(uid, title),
21
23
  * h.move(uid, { to, from, ids, name }) (a stage, and the order inside it), each with Undo in the toast,
22
24
  * h.jiraMove({ key, to, from, fromRaw }) (a Jira ticket's status, moved in Jira: pm/jira-move.js)
@@ -290,7 +292,7 @@ function moreMenu(b, uid, id, v, H) {
290
292
  }
291
293
  /** A milestone has one date (StA4Milestone): turning ◇ on keeps the due day (or the start, when it has no due day) and clears the start; the
292
294
  * host's Undo puts both back. */
293
- function milestone(H, x, on) {
295
+ export function milestone(H, x, on) {
294
296
  if (!H.dates) return;
295
297
  const p = { milestone: on };
296
298
  if (on && x.start) { p.start = ''; if (!x.end) p.due = x.start; }
@@ -136,7 +136,7 @@ function rowOf(k0, today, J = null) {
136
136
  // the List's meta draws the dates as their own press (batch 9 item 5b): days is the dates alone, lateText what follows them
137
137
  return { uid: k.uid, title: k.title, status: k.status || 'To do', closed, done: k.status === 'Done', wont: k.status === "Won't do", prog: k.status === 'In progress', late, due,
138
138
  days, lateText: late ? plural(between(d, today), 'day', 'days') + ' late' : '', item: !!k.item, ms: !!k.milestone, // ms: the ◇ flag (batch 11 item 3)
139
- start: k.start || '', end: k.end || '', owner: who, av: initials(k.owner),
139
+ start: k.start || '', end: k.end || '', since: k.since || '', owner: who, av: initials(k.owner),
140
140
  // the open row's date chips (batch 18 item 16): each day alone; rank: the PM's order inside its stage (a task-order line)
141
141
  startText: k.start ? dateY(k.start, today) : '', dueText: d ? dateY(k.end, today) : '', rank: Number.isFinite(k.rank) ? k.rank : null,
142
142
  sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid && !k.draft && !J, order: k.order,