create-pmos 0.402.0 → 0.404.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 (110) hide show
  1. package/package.json +25 -30
  2. package/payload/AGENTS.md +2 -0
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/mods/pmos-cockpit/hooks/lib/session-facts.mjs +1 -1
  5. package/payload/planning/evals/eval-calibration.md +1 -1
  6. package/payload/planning/okrs/health-budgets.md +1 -1
  7. package/payload/state/discoveries.md +1 -1
  8. package/workspace/board-programs-test.js +32 -5
  9. package/workspace/briefing-premium-adddoc-test.js +28 -22
  10. package/workspace/briefing-premium-board-test.js +91 -73
  11. package/workspace/briefing-premium-calendar-2-test.js +23 -10
  12. package/workspace/briefing-premium-calendar-3-test.js +23 -19
  13. package/workspace/briefing-premium-calendar-test.js +19 -17
  14. package/workspace/briefing-premium-initiative-test.js +25 -12
  15. package/workspace/briefing-premium-insights-test.js +31 -18
  16. package/workspace/briefing-premium-metrics-test.js +8 -8
  17. package/workspace/briefing-premium-test.js +4 -3
  18. package/workspace/changelog.json +24 -0
  19. package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
  20. package/workspace/guide/jira.md +38 -6
  21. package/workspace/guide/programs.md +2 -0
  22. package/workspace/home-rows-test.js +184 -0
  23. package/workspace/lib/briefing-premium-agent.js +3 -0
  24. package/workspace/lib/calendar-layers.js +8 -4
  25. package/workspace/lib/initiative-layout.js +4 -3
  26. package/workspace/lib/jira-cli.js +17 -12
  27. package/workspace/lib/jira-status.js +1 -1
  28. package/workspace/lib/jira-tickets.js +126 -24
  29. package/workspace/lib/meeting-files.js +58 -0
  30. package/workspace/lib/meeting-learn.js +139 -0
  31. package/workspace/lib/meeting-material.js +12 -5
  32. package/workspace/lib/notes.js +3 -0
  33. package/workspace/lib/program-chat.js +32 -0
  34. package/workspace/lib/routes-brief-page.js +8 -1
  35. package/workspace/lib/routes-calendar-views.js +24 -3
  36. package/workspace/lib/routes-meeting-material.js +38 -0
  37. package/workspace/lib/routes-meeting-points.js +23 -3
  38. package/workspace/package-lock.json +2 -2
  39. package/workspace/package.json +1 -1
  40. package/workspace/premium-board-actions-test.js +30 -24
  41. package/workspace/premium-chat-context-test.js +1 -1
  42. package/workspace/premium-chat-goal-view-test.js +1 -1
  43. package/workspace/premium-chat-viewer-test.js +1 -1
  44. package/workspace/premium-core-doc-issue-test.js +13 -7
  45. package/workspace/premium-discuss-landing-test.js +83 -0
  46. package/workspace/premium-link-suggest-test.js +103 -0
  47. package/workspace/premium-report-read-test.js +86 -82
  48. package/workspace/premium-vw-backlog-test.js +6 -5
  49. package/workspace/premium-vw-cal-test.js +46 -23
  50. package/workspace/premium-vw-item-test.js +8 -6
  51. package/workspace/premium-vw-jira-test.js +3 -2
  52. package/workspace/premium-vw-meet-test.js +122 -66
  53. package/workspace/premium-vw-notes-test.js +7 -6
  54. package/workspace/premium-vw-rec-test.js +14 -13
  55. package/workspace/premium-vw-slides-test.js +11 -5
  56. package/workspace/program-panel-test.js +64 -55
  57. package/workspace/public/pm/bd-acts.js +1 -1
  58. package/workspace/public/pm/bd-asks.js +22 -7
  59. package/workspace/public/pm/bd-ini-panel.js +232 -0
  60. package/workspace/public/pm/bd-pop.js +2 -2
  61. package/workspace/public/pm/bd-prog-panel.js +176 -191
  62. package/workspace/public/pm/cozy-board.css +5 -28
  63. package/workspace/public/pm/cozy-evui.js +4 -2
  64. package/workspace/public/pm/cozy-home-rows.css +54 -0
  65. package/workspace/public/pm/cozy-home.css +9 -0
  66. package/workspace/public/pm/cozy-insights.css +1 -2
  67. package/workspace/public/pm/cozy-mtg-present.css +160 -0
  68. package/workspace/public/pm/cozy-panel.css +11 -34
  69. package/workspace/public/pm/cozy-rec-pill.css +12 -0
  70. package/workspace/public/pm/cozy-rec-pill.js +46 -0
  71. package/workspace/public/pm/cozy-viewer.js +307 -43
  72. package/workspace/public/pm/cozy-vw-mtg.css +96 -94
  73. package/workspace/public/pm/cozy-vw-rp.css +40 -25
  74. package/workspace/public/pm/cozy-vw-shell.css +127 -0
  75. package/workspace/public/pm/cozy-xv.css +51 -0
  76. package/workspace/public/pm/cozy-xv.js +34 -0
  77. package/workspace/public/pm/goal-chat.js +1 -1
  78. package/workspace/public/pm/home-app.js +122 -58
  79. package/workspace/public/pm/home-chat.js +11 -2
  80. package/workspace/public/pm/home-day.js +64 -0
  81. package/workspace/public/pm/home-ini-model.js +1 -1
  82. package/workspace/public/pm/home-ini.js +197 -54
  83. package/workspace/public/pm/home-list.js +6 -14
  84. package/workspace/public/pm/home-mentions.js +187 -0
  85. package/workspace/public/pm/home-rec-row.js +67 -0
  86. package/workspace/public/pm/home-review.js +20 -10
  87. package/workspace/public/pm/home-task.js +19 -18
  88. package/workspace/public/pm/home-today.js +3 -3
  89. package/workspace/public/pm/premium-board.js +83 -235
  90. package/workspace/public/pm/premium-insights.js +118 -82
  91. package/workspace/public/pm/premium-mtg-present.js +408 -100
  92. package/workspace/public/pm/premium-mtg-replay.js +70 -10
  93. package/workspace/public/pm/premium-report-read.js +118 -63
  94. package/workspace/public/pm/premium-vw-cal.js +62 -34
  95. package/workspace/public/pm/premium-vw-mtg.js +348 -192
  96. package/workspace/public/pm/rec-state.js +63 -0
  97. package/workspace/public/pm/rp-parts.js +33 -8
  98. package/workspace/public/pm/tk-draft.js +107 -0
  99. package/workspace/public/pm/tk-model.js +134 -0
  100. package/workspace/public/pm/tk-send.js +124 -0
  101. package/workspace/public/pm/tk-tasks.css +120 -0
  102. package/workspace/public/premium-board.html +0 -1
  103. package/workspace/server.js +4 -2
  104. package/workspace/skills/jira-push.skill +3 -3
  105. package/workspace/test-lists/prd-to-jira.json +6 -0
  106. package/workspace/test-lists/program-chat.json +6 -0
  107. package/workspace/test-lists/viewer-home-rows.json +9 -0
  108. package/workspace/test-lists/viewer-meetings.json +9 -0
  109. package/workspace/test-lists/viewer-shell-a.json +15 -0
  110. package/workspace/tk-tasks-test.js +199 -0
@@ -25,8 +25,11 @@ import { mountPhoneCard } from './home-phone-card.js';
25
25
  import { mountFirst } from './premium-first.js';
26
26
  import * as L from './home-list.js';
27
27
  import * as TD from './home-today.js';
28
+ import * as YD from './home-day.js'; // Your day in the Viewer (XvAPhDay)
28
29
  import { canDictate, dictate } from './home-dictate.js';
29
30
  import { mountIni, iniList, iniOverview } from './home-ini.js'; // the initiative's stage move, Tasks and Core documents (premium-uncovered-features)
31
+ import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
32
+ import { mountRecRow } from './home-rec-row.js'; // the pinned recording row above it (XvARecHome)
30
33
 
31
34
  const $ = (s, r = document) => r.querySelector(s);
32
35
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -195,7 +198,8 @@ function recOf() { // a recording that is on and is no calendar meeting: the T
195
198
  return { id: r.id, title: r.title || (n && n.title) || '', at: (REC && REC.started && REC.started()) || (n && (n.started || n.created)) || null, paused: !!(n && n.state === 'paused'), meeting };
196
199
  }
197
200
  function todayModel() {
198
- const T = L.todayCard(S.D, { now: NOW(), rec: recOf(), hidden: S.eodHidden, titleOf: (id) => iniTitle(id) });
201
+ // a recording that is on is the pinned row at the top of the list (XvARecHome): the Today card does not say it again; its pause and stop are in the meeting
202
+ const T = L.todayCard(S.D, { now: NOW(), rec: RECROW.state().on ? null : recOf(), hidden: S.eodHidden, titleOf: (id) => iniTitle(id) });
199
203
  const R = L.reviewModel(S.D, NOW());
200
204
  if (T.mode === 'day' && R.open && R.started) {
201
205
  const left = R.steps.filter((x) => !x.done).length;
@@ -214,14 +218,30 @@ function homeListHtml() {
214
218
  const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1 || (!!S.product && !!g.product && S.product === g.product.key));
215
219
  return TD.listHtml(M, todayModel(), {
216
220
  sel: S.sel, isOpen: open, pOpen, restOpen: (k) => S.rest.has(k), cap: S.cap, tasksOpen: (k) => S.tasks.has(k), pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
217
- product: S.product, review: R, mic: canDictate(), phone: isPhone(), day: S.day,
221
+ product: S.product, review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
218
222
  });
219
223
  }
220
- /** Your day (HvAOpen): the sheet "Good morning" opens over the list. */
221
- function dayHtml() { return S.day && !S.ini && S.M ? TD.dayHtml(S.M, todayModel(), L.reviewModel(S.D, NOW()), { sel: S.sel, now: NOW(), phone: isPhone() }) : ''; }
224
+ /** Your day (XvAPhDay, was the HvAOpen sheet): "Good morning" opens it in the Viewer, shell A. Full screen on a phone, beside the chat on a
225
+ * desktop; on a phone the moment card (TfPhone) is its Now section, and the calendar is under ⋯. */
226
+ function dayHtml() { return ''; }
222
227
  function day(on) {
223
- S.day = !!on; drawList();
224
- const f = $(on ? '#hmList .hv-sheet' : '#hmList [data-hm-day]'); if (f) f.focus();
228
+ S.day = !!on;
229
+ if (!on) { const c = VW.current(); if (c && c.id === 'day') VW.close(); return; }
230
+ if (!S.M) return;
231
+ const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW());
232
+ const ph = isPhone() && PHC;
233
+ const P = YD.dayParts(Y, { moment: !!ph });
234
+ VW.open({ id: 'day', kind: 'Your day', title: 'Your day', icon: YD.DAY_ICON, more: [{ label: 'Open the calendar', on: () => openCalendar() }],
235
+ onClose: () => { S.day = false; },
236
+ render: (body) => {
237
+ YD.drawDay(body, P, VW, ph ? (el) => { el.append(PHC.el); PHC.read(true); } : null);
238
+ body.onclick = (e) => { // the rows are the list's own rows: the same presses open them
239
+ const b = e.target.closest('button'); if (!b) return;
240
+ if (b.dataset.hmSel) { select(b.dataset.hmSel); return; }
241
+ if ('hmReview' in b.dataset) { openReviewVw(); return; }
242
+ if ('hdMeet' in b.dataset && Y.next) openMeeting(Y.next.meeting);
243
+ };
244
+ } });
225
245
  }
226
246
  /* the list's filter (HvACDesk): Today, Kept or Done, behind the icon in the list's top bar */
227
247
  function filterMenu(b) {
@@ -384,6 +404,9 @@ const chat = mountChat($('#hmChat'), {
384
404
  queue: (sid, text) => pmPost('/api/home-desk/queue', { session: sid, text }).then((r) => { if (r && r.ok && S.D.desk) { const q = { ...(S.D.desk.queued || {}) }; q[sid] = (q[sid] || []).concat({ text, at: r.at }); S.D.desk.queued = q; chat.refresh(); } }),
385
405
  unqueue: (sid, at) => { pmPost('/api/home-desk/queue-drop', { session: sid, at }); if (S.D.desk && S.D.desk.queued && S.D.desk.queued[sid]) S.D.desk.queued[sid] = S.D.desk.queued[sid].filter((x) => x.at !== at); },
386
406
  onScope: (b) => menu(b, scopeItems(), 'Where this goes'),
407
+ suggestLink: (t, first) => suggestLink(t, first),
408
+ linkTo: (sid, ini) => link(sid, ini),
409
+ dismissLink: (sid) => { try { localStorage.setItem('cz-linksug-x:' + sid, '1'); } catch { /* a private window: it shows again next time */ } },
387
410
  onLink: (b, t) => menu(b, H.boardRows(S.D).map((r) => ({ label: r.title, sub: r.stage, go: () => link(t.sid, r.id) })), 'Link it to an initiative'),
388
411
  onTo: (b, t) => menu(b, toItems(t), 'Send your messages to'), // @ and the To: chip: which conversation of this initiative you are writing in
389
412
  workItem: (text, t) => workItem(text, t),
@@ -420,6 +443,24 @@ function toItems(cur) {
420
443
  .concat(ses.map((s) => { const r = H.roleOf(s, S.D.desk && S.D.desk.roles), st = sessionTarget(s); return { label: (s.hx && s.hx.title) || s.name, sub: r.name + ' · another session of this initiative', checked: at === st.key, go: () => openTarget(st) }; }))
421
444
  .concat([{ label: 'A new session', sub: 'A fresh conversation in ' + iniTitle(id), go: () => newIn(id) }]);
422
445
  }
446
+ /* A loose chat's best guess at its initiative, by the words its title and first message share with an initiative's title (XvALinkSuggest).
447
+ * Two shared words, or one that is half the initiative's title, are enough; a dismissed guess does not come back for that chat. */
448
+ const STOP = new Set('the and for with from this that into about what when your our are was were has have not but can how new page work chat its'.split(' '));
449
+ const wordsOf = (x) => String(x || '').toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length >= 3 && !STOP.has(w));
450
+ function suggestLink(t, first) {
451
+ try { if (localStorage.getItem('cz-linksug-x:' + t.sid)) return null; } catch { /* no storage: still guess */ }
452
+ const have = new Set(wordsOf(t.title + ' ' + (first || '').slice(0, 400)));
453
+ if (!have.size) return null;
454
+ let best = null;
455
+ for (const r of H.boardRows(S.D)) {
456
+ const ws = [...new Set(wordsOf(r.title))]; if (!ws.length) continue;
457
+ const n = ws.filter((w) => have.has(w)).length;
458
+ if (!(n >= 2 || (n >= 1 && n / ws.length >= 0.5))) continue;
459
+ const sc = n + n / ws.length;
460
+ if (!best || sc > best.sc) best = { id: r.id, title: r.title, sc };
461
+ }
462
+ return best && { id: best.id, title: best.title };
463
+ }
423
464
  async function link(sid, ini) {
424
465
  const r = await pmPost('/api/session/initiative', { id: sid, initiative: ini });
425
466
  if (!r || !r.ok) { toast((r && r.error) || 'The session was not linked.'); return; }
@@ -551,7 +592,6 @@ function select(id, o = {}) {
551
592
  else if (r.kind === 'ptask') { S.phoneChat = isPhone(); openTarget(programTarget(r.program, r)); }
552
593
  else if (r.kind === 'task') { openBoardTask(r.task); }
553
594
  else if (r.kind === 'item') { import('./home-work.js').then((M) => M.openWorkItem(r.key)); }
554
- else if (r.kind === 'mention') { openMention(r); }
555
595
  else if (r.kind === 'finished') { openFinished(r.finished); }
556
596
  else if (r.kind === 'meeting') { openMeeting(r.meeting); }
557
597
  else if (r.kind === 'routine') { if (isMetrics(r.schedule)) openMetrics(o); else openRoutine(r.schedule); }
@@ -574,7 +614,7 @@ async function goIni(id) {
574
614
  function goHome() { S.ini = null; S.sel = null; S.IM = null; syncUrl(); drawList(); openTarget(homeTarget()); }
575
615
  function syncUrl() {
576
616
  const q = new URLSearchParams(location.search);
577
- ['ini', 'open', 'item', 'session', 'ask', 'say', 'q', 'about', 'label', 'meeting', 'id', 'view'].forEach((k) => { if (!(k === 'open' && /^(report|chart|dashboard):/.test(q.get('open') || ''))) q.delete(k); });
617
+ ['ini', 'open', 'item', 'session', 'ask', 'say', 'q', 'about', 'label', 'meeting', 'id', 'view', 'vk', 'vid'].forEach((k) => { if (!(k === 'open' && /^(report|chart|dashboard):/.test(q.get('open') || ''))) q.delete(k); });
578
618
  if (S.ini) q.set('ini', S.ini);
579
619
  const r = S.sel ? rowById(S.sel) : null;
580
620
  if (r && r.kind === 'ptask') q.set('item', r.id); // a program task: pt:<program>:<key>, the link the program panel makes
@@ -603,21 +643,6 @@ function openBoardTask(t) {
603
643
  onChange: () => load(),
604
644
  }));
605
645
  }
606
- function openMention(r) {
607
- const m = r.mention || {};
608
- const draw = (b) => {
609
- b.innerHTML = `<div class="ut-vc"><div><h2 class="ut-h2">${esc(r.name)}</h2><p class="ut-sub">${esc(['Mention', m.where || m.source, m.at ? H.hm(m.at) : ''].filter(Boolean).join(' · '))}</p></div>`
610
- + (m.text ? `<div class="ut-box">${esc(m.text)}</div>` : '') + (m.reply ? `<p class="ut-lbl">A reply you could send</p><div class="ut-box">${esc(m.reply)}</div>` : '')
611
- + `<div class="ut-foot">${HTTPS.test(m.link || '') ? `<a class="ut-btn pri" href="${esc(m.link)}" target="_blank" rel="noopener noreferrer">Open it</a>` : ''}<button type="button" class="ut-btn" data-mn-read>Mark it read</button></div>`
612
- + '<p class="ut-small ut-mut">PMOS sends nothing. Reply where the mention is.</p></div>';
613
- };
614
- const body = VW.open({ id: 'mention:' + (m.id || r.id), kind: 'Mention', title: r.name, icon: 'info', render: draw });
615
- body.onclick = async (e) => {
616
- if (!e.target.closest('[data-mn-read]')) return;
617
- const res = await pmPost('/api/mentions/read', { id: m.id, read: true });
618
- if (res && res.ok) { toast('Marked read.'); VW.close(); load(); } else toast((res && res.error) || 'Not marked read.');
619
- };
620
- }
621
646
  function openFinished(f) {
622
647
  if (!f) return;
623
648
  VW.open({ id: 'fin:' + (f.id || f.title), kind: f.status === 'review' ? 'Finished · waits for your review' : 'Finished', title: f.title, icon: 'doc',
@@ -710,13 +735,17 @@ function openNeedViewer(r, focusWhy) {
710
735
  // the decision is recorded on the chat's card (HmDecide); the Viewer keeps the facts it rests on
711
736
  rec = '<p class="ut-small ut-mut">Record your decision on the card in the chat.</p>';
712
737
  } else if (w.kind === 'return') {
713
- // HmDecide, the Viewer's "Return a run": why it goes back, what to change, Return it or Keep it as is
714
- b.innerHTML = `<div class="ut-vc"><div><h2 class="ut-h2">${esc(r.name)}</h2><p class="ut-sub">${esc(r.hint || pane.h || '')}</p></div>${facts}`
715
- + `<p class="ut-lbl">Why it goes back</p><div class="ut-chips" role="group" aria-label="Why it goes back">${RET_REASONS.map((x) => `<button type="button" class="cz-chip${st.ret === x ? ' on' : ''}" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(RET_LABEL[x] || x)}</button>`).join('')}</div>`
716
- + `<div class="ut-field"><label for="hvNote">What to change</label><textarea id="hvNote" rows="3" placeholder="Say what the agent should change">${esc(st.note || '')}</textarea></div>`
717
- + '<div class="ut-box ut-small">The agent gets this note in its conversation and tries again. It counts as one correction.</div>'
718
- + `<div class="ut-foot"><button type="button" class="ut-btn dark" data-hv-rec${st.ret ? '' : ' disabled'}>Return it</button><button type="button" class="ut-btn ghost" data-hv-keep>Keep it as is</button></div>`
719
- + '<p class="ut-small ut-mut" role="status" id="hvMsg"></p></div>';
738
+ // shell A (canvas XvAReturn): the summary says what the review found and holds Return it with Keep it as is beside it;
739
+ // why it goes back and what to change are open rows below, the facts the review rests on fold under them
740
+ const score = (pane.rows || d.facts || []).find((x) => /score|rubric/i.test(String(x[0] || '')));
741
+ b.innerHTML = VW.czSummary({ line: score ? String(score[1]) : r.hint || pane.h || 'Waits for your review', tone: 'warn', text: pane.intro || (pane.paras || [])[0] || r.hint || '',
742
+ meta: (w.agent || 'The agent') + ' gets this note and tries again. It counts as one correction.', primary: { label: 'Return it', act: 'return', disabled: !st.ret }, second: { label: 'Keep it as is', act: 'keep' } })
743
+ + VW.czSections([
744
+ { id: 'why', title: 'Why it goes back', open: true, html: `<div class="ut-chips" role="group" aria-label="Why it goes back">${RET_REASONS.map((x) => `<button type="button" class="cz-chip${st.ret === x ? ' on' : ''}" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(RET_LABEL[x] || x)}</button>`).join('')}</div>` },
745
+ { id: 'note', title: 'What to change', open: true, html: `<div class="ut-field"><label for="hvNote" class="hi-vh">What to change</label><textarea id="hvNote" rows="3" placeholder="Say what the agent should change">${esc(st.note || '')}</textarea></div>` },
746
+ facts ? { id: 'facts', title: pane.h || 'The review', count: (pane.rows || d.facts || []).length, html: facts } : null,
747
+ ], { key: 'return' })
748
+ + '<p class="ut-small ut-mut" role="status" id="hvMsg"></p>';
720
749
  if (focusWhy) { const t = b.querySelector('#hvNote'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
721
750
  return;
722
751
  } else if (w.kind === 'start') {
@@ -736,8 +765,8 @@ function openNeedViewer(r, focusWhy) {
736
765
  if (t.dataset.hvUntil) { const res = await bpPost('put-off', { key: r.key, until: t.dataset.hvUntil }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); VW.close(); await load(); select(null); } else say(res.error); return; }
737
766
  if ('hvPin' in t.dataset) { if (S.pin.has(r.key)) S.pin.delete(r.key); else S.pin.add(r.key); store.set('pmos.home.pin', JSON.stringify([...S.pin])); draw(body); drawList(); return; }
738
767
  if ('hvStart' in t.dataset) { start(r); return; }
739
- if ('hvKeep' in t.dataset) { delete S.rec[r.key]; VW.close(); return; }
740
- if ('hvRec' in t.dataset) {
768
+ if ('hvKeep' in t.dataset || t.dataset.czsAct === 'keep') { delete S.rec[r.key]; VW.close(); return; }
769
+ if ('hvRec' in t.dataset || t.dataset.czsAct === 'return') {
741
770
  t.disabled = true;
742
771
  const res = w.kind === 'decision' ? await bpPost('decide', { key: r.key, choice: st.choice, why: st.why }) : await bpPost('return', { run: w.run, reason: st.ret, ...(w.ws ? { ws: w.ws } : {}) });
743
772
  if (!res.ok) { t.disabled = false; say(res.error); return; }
@@ -763,25 +792,42 @@ async function start(r) {
763
792
  }
764
793
 
765
794
  /* the weekly update: the recipients are editable; Send opens a mail draft in the PM's own mail and records that it was sent */
766
- function openUpdateViewer() {
795
+ function openUpdateViewer(o = {}) {
796
+ // shell A (XvAWeekly, XvAWeeklyMore): the summary card says where it stands and holds the one primary, Send; the three groups fold;
797
+ // who gets it, copy as text and the past updates are under ⋯ (the xvMore note). Every line still opens its initiative.
798
+ let edit = !!o.edit, past = false;
767
799
  const draw = (b) => {
768
800
  const U = H.weeklyUpdate(S.D, S.D.now);
769
801
  const sent = (U.sent || []).find((x) => x.week === U.week.iso);
770
- const sec = U.sections.map(([k, h, L]) => `<section class="hv-up ${k}"><h4><i aria-hidden="true"></i>${esc(h)}</h4>${L.length ? L.map((x) => `<button type="button" class="hv-ui" data-hv-ini="${esc(x.id)}"><span class="t"><b>${esc(x.title)}</b><em>${esc(x.meta)}</em></span><span class="d">${esc(x.text)}</span>${x.flag ? `<span class="flag">${esc(x.flag)}</span>` : ''}</button>`).join('') : '<p class="hx-n">None this week.</p>'}</section>`).join('');
771
- b.innerHTML = `<div class="hv"><p class="hv-note">Drafted by Communicator from the ladders and run logs at ${esc(H.hm(new Date(S.D.now).toISOString()))}. Every line links to its source.</p>`
772
- + `<div class="hv-to"><span>To</span>${U.to.map((x, i) => `<button type="button" class="hv-chip" data-hv-rm="${i}" aria-label="Remove ${esc(x)}" title="Remove">${esc(x)}</button>`).join('')}<input id="hvTo" placeholder="${U.to.length ? 'Add' : 'Who gets it: a name, a mail or #channel'}" aria-label="Add a recipient"></div>`
773
- + sec + `<div class="hv-acts">${sent ? `<p class="hx-n">Sent from your mail ${esc(new Date(sent.at).toDateString())} to ${esc(sent.to.join(', '))}.</p>` : ''}<button type="button" class="hx-b pri" data-hv-send>${sent ? 'Send again' : 'Send now'}</button></div>`
774
- + '<p class="hx-n">Send opens a draft in your own mail app. PMOS sends nothing by itself; it records that you opened the draft.</p><p class="hx-n" role="status" id="hvMsg"></p></div>';
802
+ const [ok, risk, dec] = U.sections.map((x) => x[2].length);
803
+ const words = [ok ? ok + ' on track' : '', risk ? risk + ' at risk' : '', dec ? dec + (dec === 1 ? ' needs' : ' need') + ' a decision' : ''].filter(Boolean);
804
+ const flag = U.sections.flatMap((x) => x[2]).find((x) => x.flag);
805
+ const text = (words.length ? words.join(', ').replace(/, ([^,]*)$/, ' and $1') + '.' : 'No initiative is open this week.') + (flag ? ' ' + flag.title + ': ' + flag.flag.toLowerCase() + '.' : '');
806
+ const sum = VW.czSummary({ line: sent ? 'Sent ' + new Date(sent.at).toDateString().slice(0, 10) : 'Ready to send', tone: sent ? '' : 'you', text,
807
+ meta: 'Communicator · ' + (U.to.length ? 'to ' + U.to.join(', ') : 'say who gets it under More'), primary: { label: sent ? 'Send again' : 'Send now', act: 'send' } });
808
+ const it = (x) => `<button type="button" class="czs-it" data-hv-ini="${esc(x.id)}"><span class="w">${esc(x.title)}<span>${esc([x.meta, x.text].filter(Boolean).join(' · '))}</span>${x.flag ? `<span class="flag">${esc(x.flag)}</span>` : ''}</span></button>`;
809
+ const secs = VW.czSections(U.sections.map(([k, h, L]) => ({ id: k, title: h, count: L.length, open: k !== 'ok' && L.length > 0, html: L.map(it).join('') }))
810
+ .concat([{ id: 'src', title: 'Sources', count: 'ladders and run logs · ' + H.hm(new Date(S.D.now).toISOString()), html: '<p>Drafted by Communicator from the ladders and run logs. Every line links to its source.</p>' }]), { key: 'weekly' });
811
+ const to = edit ? `<div class="hv-to"><span>To</span>${U.to.map((x, i) => `<button type="button" class="hv-chip" data-hv-rm="${i}" aria-label="Remove ${esc(x)}" title="Remove">${esc(x)}</button>`).join('')}<input id="hvTo" placeholder="${U.to.length ? 'Add' : 'Who gets it: a name, a mail or #channel'}" aria-label="Add a recipient"></div>` : '';
812
+ const old = past ? `<div class="czs-secs"><div class="czs-body" style="padding-top:12px">${(U.sent || []).length ? U.sent.slice().reverse().map((x) => `<div class="czs-it"><span class="w">Week ${esc(x.week)}<span>${esc(new Date(x.at).toDateString())} · to ${esc((x.to || []).join(', '))}</span></span></div>`).join('') : '<p>No update was sent yet.</p>'}</div></div>` : '';
813
+ b.innerHTML = to + sum + old + secs + '<p class="hx-n">Send opens a draft in your own mail app. PMOS sends nothing by itself; it records that you opened the draft.</p><p class="hx-n" role="status" id="hvMsg"></p>';
814
+ if (edit) { const i = b.querySelector('#hvTo'); if (i) i.focus(); }
775
815
  };
776
816
  const U0 = H.weeklyUpdate(S.D, S.D.now);
777
- const body = VW.open({ id: 'update', kind: 'Weekly update', title: H.productName(S.D) + ' · week of ' + U0.week.label, icon: 'doc', url: selfUrl({ ini: 'product' }), render: draw });
817
+ const copy = async () => { try { await navigator.clipboard.writeText(H.updateText(H.weeklyUpdate(S.D, S.D.now), H.productName(S.D))); toast('The update is copied as text.'); } catch { toast('The text could not be copied.'); } };
818
+ const more = () => [
819
+ { label: 'Change who gets it', note: U0.to.length ? U0.to.length + (U0.to.length === 1 ? ' person' : ' people') : '', on: () => { edit = !edit; draw(body); } },
820
+ { label: 'Copy as text', on: copy },
821
+ { label: 'Past updates', note: (U0.sent || []).length ? U0.sent.length + ((U0.sent.length === 1) ? ' week' : ' weeks') : '', on: () => { past = !past; draw(body); } },
822
+ ];
823
+ const body = VW.open({ id: 'update', kind: 'Weekly update', title: H.productName(S.D) + ' · week of ' + U0.week.label, icon: 'doc', url: selfUrl({ ini: 'product' }), more: more(), render: draw });
778
824
  const saveTo = async (to) => { const r = await pmPost('/api/home-desk/recipients', { ws: deskWs(), to }); if (r && r.ok) { S.D.desk.product = { ...(S.D.desk.product || {}), recipients: r.recipients }; draw(body); drawList(); } else toast((r && r.error) || 'The recipients were not saved.'); };
779
825
  body.onkeydown = (e) => { if (e.target.id === 'hvTo' && (e.key === 'Enter' || e.key === ',')) { e.preventDefault(); const v = e.target.value.trim(); if (v) saveTo(H.weeklyUpdate(S.D).to.concat(v)); } };
780
826
  body.onclick = async (e) => {
781
827
  const t = e.target.closest('button'); if (!t) return;
782
828
  if (t.dataset.hvRm) { const to = H.weeklyUpdate(S.D).to.slice(); to.splice(+t.dataset.hvRm, 1); saveTo(to); return; }
783
829
  if (t.dataset.hvIni) { goIni(t.dataset.hvIni); return; }
784
- if ('hvSend' in t.dataset) sendUpdate();
830
+ if (t.dataset.czsAct === 'send' || 'hvSend' in t.dataset) sendUpdate();
785
831
  };
786
832
  }
787
833
  /** This page's address for one view (the Viewer's Open in a new tab): the workspace and board of this page, and the view's own keys. */
@@ -789,7 +835,7 @@ const selfUrl = (o) => { const q = new URLSearchParams(); if (WS) q.set('ws', WS
789
835
  const deskWs = () => (S.D.desk && S.D.desk.ws) || ((S.D.board && S.D.board.board) || {}).ws || WS || undefined;
790
836
  async function sendUpdate() {
791
837
  const U = H.weeklyUpdate(S.D, S.D.now);
792
- if (!U.to.length) { openUpdateViewer(); toast('Say who the update goes to first.'); setTimeout(() => { const i = $('#hvTo'); if (i) i.focus(); }, 0); return; }
838
+ if (!U.to.length) { openUpdateViewer({ edit: true }); toast('Say who the update goes to first.'); setTimeout(() => { const i = $('#hvTo'); if (i) i.focus(); }, 0); return; }
793
839
  const name = H.productName(S.D), subject = name + ' · week of ' + U.week.label;
794
840
  const mails = U.to.filter((x) => /@/.test(x));
795
841
  location.href = 'mailto:' + mails.map(encodeURIComponent).join(',') + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(H.updateText(U, name) + (U.to.length > mails.length ? '\n\nAlso for: ' + U.to.filter((x) => !/@/.test(x)).join(', ') : ''));
@@ -925,10 +971,15 @@ function openMetricsViewer() {
925
971
  const draw = (b) => {
926
972
  const m = MET && MET.model, V = metricsView(m);
927
973
  if (!m) { b.innerHTML = `<div class="hv"><p class="hx-n" role="status">${MET && MET.error ? 'The metrics were not read: ' + esc(MET.error) + '.' : 'Reading the metrics.'}</p></div>`; return; }
928
- b.innerHTML = `<div class="hv hm-met"><div class="hm-kpis">${V.tiles.map((t) => `<div class="hm-kpi"><p>${esc(t.label)}</p><b>${esc(t.value)}</b><span>${esc(t.note || '')}</span></div>`).join('')}</div>`
974
+ // shell A (canvas XvAMetrics): the summary card leads with the correction rate and the month in one line; the weekly bars follow;
975
+ // the other tiles and what moved it are rows below. There is no primary: nothing here writes (honest state).
976
+ const [first, ...rest] = V.tiles;
977
+ const fell = /fell/.test(V.line), rose = /rose/.test(V.line);
978
+ b.innerHTML = VW.czSummary({ line: first ? first.label + ' ' + first.value : '', tone: rose ? 'warn' : fell ? 'ok' : '', text: V.line, meta: (m && m.note) || '' })
929
979
  + (V.bars.length ? `<figure class="hm-fig"><figcaption>Correction rate per agent run, by week (lower is better)</figcaption><div class="hm-chart" role="img" aria-label="${esc('Correction rate by week: ' + V.bars.map((x) => x.w + ' ' + x.v).join(', '))}">${V.bars.map((x) => `<div title="${esc(x.week ? 'Week to ' + x.week : x.w)}"><span>${esc(x.v)}</span><i class="${x.now ? 'now' : ''}" data-h="${x.h}"></i></div>`).join('')}</div><div class="hm-chx" aria-hidden="true">${V.bars.map((x) => `<span>${x.w}</span>`).join('')}</div></figure>` : '')
930
- + `<table class="hm-moved"><thead><tr><th scope="col">What moved it</th><th scope="col">Effect</th></tr></thead><tbody>${V.moved.map(([n, e]) => `<tr><td>${esc(n)}</td><td>${esc(e)}</td></tr>`).join('') || '<tr><td colspan="2">Nothing moved since the week before.</td></tr>'}</tbody></table>`
931
- + `<p class="hx-n">${esc((m && m.note) || '')}</p></div>`;
980
+ + VW.czSections([{ id: 'moved', title: 'What moved it', count: V.moved.length, open: true,
981
+ html: `<table class="hm-moved"><thead><tr><th scope="col">What moved it</th><th scope="col">Effect</th></tr></thead><tbody>${V.moved.map(([n, e]) => `<tr><td>${esc(n)}</td><td>${esc(e)}</td></tr>`).join('') || '<tr><td colspan="2">Nothing moved since the week before.</td></tr>'}</tbody></table>` }]
982
+ .concat(rest.map((t, i) => ({ id: 't' + i, title: t.label, count: t.value, html: t.note ? `<p>${esc(t.note)}</p>` : '' }))), { key: 'metrics' }); // the first tile's note (was N the week before) is already in the line: said once
932
983
  b.querySelectorAll('.hm-chart i[data-h]').forEach((i) => i.style.setProperty('--bd-h', i.dataset.h + 'px')); // each bar's height: run-time geometry
933
984
  };
934
985
  const body = VW.open({ id: 'metrics', kind: 'Metrics review', title: H.productName(S.D) + ' · ' + MONTHS[new Date(S.D.now).getMonth()], icon: I.chart, url: selfUrl({ ini: 'product', view: 'metrics' }), render: draw });
@@ -968,15 +1019,6 @@ async function openMeeting(m) {
968
1019
  if (typeof v.openMeeting === 'function') return v.openMeeting(m.note ? { note: m.note } : m, { ws: deskWs() });
969
1020
  try { const M = await import('./premium-vw-mtg.js'); return M.openMeeting(m.note ? { note: m.note } : m, { ws: deskWs() }); } catch { return VW.placeholder('Meeting', { icon: 'meet' }); }
970
1021
  }
971
- /** A phone: the greeting's detail, the moment card of the day (home-phone-card.js) in the Viewer, with the calendar one press on. */
972
- function openMoment() {
973
- VW.open({ id: 'moment', kind: 'Your day', title: L.greetWord(), icon: 'cal', render: (body) => {
974
- body.append(PHC.el);
975
- body.insertAdjacentHTML('beforeend', '<p class="ut-acts hm-mcal"><button type="button" class="ut-btn sm soft" data-hm-mcal>Open the calendar</button></p>');
976
- body.onclick = (e) => { if (e.target.closest('[data-hm-mcal]')) openCalendar(); };
977
- PHC.read(true);
978
- } });
979
- }
980
1022
  async function openCalendar() {
981
1023
  const v = await V();
982
1024
  if (typeof v.openCalendar === 'function') return v.openCalendar({ ws: deskWs(), view: 'day' });
@@ -987,6 +1029,19 @@ async function openCalendar() {
987
1029
  let REC = null;
988
1030
  import('./premium-meeting.js').then((M) => { REC = M.recCore({ pmGet, pmPost, ws: () => WS || null }); REC.refresh().then(() => drawList()); }).catch(() => { REC = null; });
989
1031
  addEventListener('premium-rec', () => drawList());
1032
+ const RECROW = mountRecRow({ notes: () => (REC && REC.notes ? REC.notes() : []), refresh: () => REC && REC.refresh(), redraw: () => drawList() });
1033
+ /* what the Mentions Viewer needs from Home (home-mentions.js) */
1034
+ function menCtx() {
1035
+ return { D: () => S.D, pmPost, toast, reload: () => load(), iniTitle, goIni: (id) => goIni(id), stageOf: (id) => (iniRowOf(id) || {}).stage || '',
1036
+ draft: (m) => { // Draft a reply: Home's chat writes it with the PM; PMOS sends nothing, the PM answers where the mention is
1037
+ const who = String(m.who || 'them').split(/\s+/)[0];
1038
+ S.phoneChat = isPhone(); if (isPhone()) VW.close();
1039
+ openTarget({ ...homeTarget(), key: 'chat:mention-' + m.id, title: 'Reply to ' + who, scope: { text: MEN.placeOf(m), icon: I.chat },
1040
+ intro: { role: CLAUDE, text: (m.who || 'Someone') + (m.reply ? ' asks: “' : ' wrote: “') + (m.text || '') + '” Tell me what to answer and I will draft it. You send it in ' + MEN.placeOf(m) + '.' },
1041
+ placeholder: 'What should the reply say?', context: 'A mention of the PM to answer. ' + (m.who || 'Someone') + ' in ' + MEN.placeOf(m) + ': ' + (m.text || '') + (m.initiative ? ' (initiative ' + m.initiative + ')' : '') });
1042
+ drawList(); chat.focus();
1043
+ } };
1044
+ }
990
1045
  function recLive() {
991
1046
  if (!REC) return null;
992
1047
  const h = REC.holding && REC.holding();
@@ -1108,7 +1163,7 @@ $('#hmNeeds').onclick = () => sheet(!S.sheet);
1108
1163
  // My work's "Weekly review" (home-work.js) asks Home, which holds the data the review reads
1109
1164
  addEventListener('hm:review', (e) => { e.preventDefault(); openReviewVw(); });
1110
1165
  // a phone: the day's moment card opens on the greeting's press, and on this event from any other place that asks for the day
1111
- addEventListener('hm:day', () => { if (isPhone() && PHC) openMoment(); });
1166
+ addEventListener('hm:day', () => day(true));
1112
1167
  $('#hmBack').onclick = () => { S.phoneChat = false; S.sel = null; drawList(); syncUrl(); const f = $('#hmList .hm-rm'); if (f) f.focus(); };
1113
1168
  $('#hmMoreP').onclick = (e) => moreMenu(e.currentTarget);
1114
1169
  $('#hmDesk').onclick = (e) => { if (S.sheet && e.target === $('#hmDesk')) sheet(false); }; // a press beside the sheet closes it; Escape and the N need you button do too
@@ -1118,6 +1173,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1118
1173
  const b = e.target.closest('button'); if (!b) return;
1119
1174
  const d = b.dataset;
1120
1175
  if (d.hmSel) { if (S.day) S.day = false; select(d.hmSel); return; }
1176
+ if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
1121
1177
  if ('hmDay' in d) { day(!S.day); return; }
1122
1178
  if ('hmDayx' in d) { day(false); return; }
1123
1179
  if ('hmFlt' in d) { filterMenu(b); return; }
@@ -1178,7 +1234,7 @@ function capMic(input, b) {
1178
1234
  /* the Today card's presses (HmDay, HmMic): the calendar, the meeting's prep, the live meeting, the recording, the end of the day */
1179
1235
  async function todayPress(k, b) {
1180
1236
  const T = todayModel();
1181
- if (k === 'cal') { if (isPhone() && PHC) openMoment(); else openCalendar(); return; }
1237
+ if (k === 'cal') { if (isPhone()) day(true); else openCalendar(); return; }
1182
1238
  if ((k === 'prep' || k === 'open') && T.meeting) { openMeeting(T.meeting); return; }
1183
1239
  if (k === 'record') { MORE.openRecorder().then(() => drawList()); return; }
1184
1240
  if (k === 'hl') { const r = REC && await REC.highlight(); toast(r && r.ok ? 'Highlighting the last 30 seconds and the next ones.' : (r && r.error) || 'The highlight did not start.'); return; }
@@ -1228,9 +1284,17 @@ drawList(); drawTop();
1228
1284
  : sidAt ? { ...homeTarget(), key: '', title: 'Reading', empty: 'Reading the session.' }
1229
1285
  : S.ini ? (S.ini === 'product' ? { ...homeTarget(), title: 'Reading' } : iniTarget(S.ini)) : homeTarget());
1230
1286
  }
1287
+ /* "Discuss in chat" on another page (cozy-viewer.js discuss): the chat about the item opens, and the item opens in the Viewer beside it when
1288
+ * Home has a view of its own for it: a document by its path, a work-item by its key. Anything else is the chat alone, named by its label. */
1289
+ function discussed(about, vid, label) {
1290
+ if (!vid || isPhone()) return;
1291
+ if (/^doc:/.test(about) && /^[\w./-]+\.\w+$/.test(vid)) openFile({ path: vid, name: label || vid.split('/').pop() });
1292
+ else if (/^work:/.test(about)) import('./home-work.js').then((M) => M.openWorkItem(vid)).catch(() => {});
1293
+ }
1231
1294
  /* The address: ?ini=<id> an initiative's layout · ?open=<row key> a Needs-you row · ?session=<id> a session · ?ask=<initiative id> | board:<key> |
1232
1295
  * insights | verdict with the question in ?q, or ?about=<key>&label=<name>: that conversation · ?open=report:|chart:|dashboard:<id> that one in the
1233
- * Viewer · ?say=<words> or ?q a first message in the box, not sent · ?meeting=<note id> the meeting card. */
1296
+ * Viewer · ?say=<words> or ?q a first message in the box, not sent · ?meeting=<note id> the meeting card · ?vk=<kind>&vid=<id> with ?about: the
1297
+ * item Discuss in chat came from, opened in the Viewer beside its chat. */
1234
1298
  const KEY = /^(decision|blocked|waited|src|ev|work|board|init|doc|ins|chat|pop):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/;
1235
1299
  load().then(() => {
1236
1300
  const open = P.get('open') || P.get('item'), sid = P.get('session'), mt = P.get('meeting');
@@ -1248,8 +1312,8 @@ load().then(() => {
1248
1312
  }
1249
1313
  else if (sid) { const s = S.D.sessions.find((x) => x.id === sid); if (s) { S.sel = 's:' + s.id; openTarget(sessionTarget(s)); drawList(); } else { openTarget(homeTarget()); toast('That session is not on this machine.'); } }
1250
1314
  else if (/^program:[A-Za-z0-9][A-Za-z0-9._-]{0,100}$/.test(ask)) openTarget(programTarget(ask.slice(8))); // Ask in Home from the program panel
1251
- else if (about && /^init:/.test(about) && iniRowOf(about.slice(5))) goIni(about.slice(5));
1252
- else if (about) openTarget({ ...homeTarget(), key: about, title: (P.get('label') || '').slice(0, 80) || about });
1315
+ else if (about && /^init:/.test(about) && iniRowOf(P.get('vid') || about.slice(5))) { const id = iniRowOf(P.get('vid')) ? P.get('vid') : about.slice(5); goIni(id).then(() => { if (P.get('vk') && S.ini === id && !isPhone()) iniOverview(); }); }
1316
+ else if (about) { openTarget({ ...homeTarget(), key: about, title: (P.get('label') || '').slice(0, 80) || about }); discussed(about, P.get('vid'), P.get('label')); }
1253
1317
  else if (S.ini && P.get('view') === 'metrics') goIni(S.ini).then(() => openMetrics()); // ?view=metrics: the metrics review, as its Open in a new tab names it
1254
1318
  else if (S.ini) goIni(S.ini);
1255
1319
  else if (!isPhone() && !blockOpen && !say && !VW.isOpen()) { const first = H.needsOf(S.D)[0]; if (first) select(first.id); } // a card the PM opened while Home was reading stays
@@ -12,6 +12,7 @@
12
12
  *
13
13
  * The words are Claude Code's own transcript. A conversation is either a chat key (GET /api/briefing-premium/thread?key=, the session it
14
14
  * started, POST /ask and /press) or a session with no chat key (GET /api/sessions/conversation?id=, POST /api/session/say and /keys).
15
+ * A loose session the host can place (host.suggestLink(target, firstText) → { id, title }) shows one chip: Link it (host.linkTo) or × (host.dismissLink).
15
16
  * Every write is the PM's press. mountChat(el, host) returns { open(target), refresh(), focus(), send(text) }.
16
17
  * target: { key?, sid?, title, scope: { text, icon, loose }, role: { name, initial }, intro?: { role, text, at, pills: [{ label, primary, go }] },
17
18
  * ini?, rich, also?: { text, go } }
@@ -49,8 +50,8 @@ export function mountChat(el, host) {
49
50
  const esc = host.esc;
50
51
  const C = { t: null, th: null, conv: null, timer: null, show: 12, open: new Set(), seq: 0, sending: false, files: [], seenAt: null, lastKey: null, picked: {}, auto: { key: null, ctx: new Set(), rep: null, goal: null }, slashAt: 0 };
51
52
  el.innerHTML = `<button type="button" class="hm-reopen" id="hmReopen" aria-label="Open the Viewer" title="Open the Viewer" hidden>${PANE}</button>`
52
- + '<div class="hm-chd" id="hmCh" hidden></div><div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
53
- const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen'), head = el.querySelector('#hmCh');
53
+ + '<div class="hm-chd" id="hmCh" hidden></div><div class="hm-sug" id="hmSug" hidden></div><div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
54
+ const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen'), head = el.querySelector('#hmCh'), sug = el.querySelector('#hmSug');
54
55
  loadSlash(host.pmGet).then(() => { if (el.querySelector('#hmSlash:not([hidden])')) drawSlash(); });
55
56
  // when a hidden log is shown (the phone's chat over the list), a jump still owed is made then
56
57
  // On a phone the chat is the page: the log grows and the page scrolls, so "the end" is the page's end (testing fixes: a chat opened at its oldest message)
@@ -161,8 +162,15 @@ export function mountChat(el, host) {
161
162
  return q.filter((x) => !said.has(String(x.text).trim())).map((x) => `<div class="hm-q"><div class="hm-qb">${userHtml(x.text)}</div><span class="hm-qn">Queued · ${esc(role().name)} reads it after this step<button type="button" data-hm-qdel="${esc(x.at)}">Delete</button></span></div>`).join('');
162
163
  }
163
164
  const sid = () => (C.t && C.t.sid) || (C.th && C.th.session) || null;
165
+ // A loose chat that reads like one initiative gets one quiet chip at its top: "Looks like <initiative> · Link it ×" (XvALinkSuggest).
166
+ function drawSug() {
167
+ const t = C.t, g = t && t.scope && t.scope.loose && t.sid && host.suggestLink ? host.suggestLink(t, firstUser()) : null;
168
+ sug.hidden = !g; C.sug = g;
169
+ put(sug, g ? `<span class="hm-sugc">Looks like <b>${esc(g.title)}</b><button type="button" class="hm-sugl" data-hm-sug="link">Link it</button><button type="button" class="hm-sugx" data-hm-sug="x" aria-label="Not this one" title="Not this one">${SVG(XX, 13)}</button></span>` : '');
170
+ }
164
171
  function draw() {
165
172
  const t = C.t; if (!t) return;
173
+ drawSug();
166
174
  const R = { role: role() };
167
175
  const msgs = (C.conv && C.conv.messages) || [];
168
176
  const items = streamOf(msgs, { seen: C.seenAt, show: C.show });
@@ -364,6 +372,7 @@ export function mountChat(el, host) {
364
372
  return;
365
373
  }
366
374
  const b = e.target.closest('button, [data-file], [data-att], [data-ctx]'); if (!b || !el.contains(b)) return;
375
+ if (b.dataset.hmSug && C.sug) { const g = C.sug; if (b.dataset.hmSug === 'link') host.linkTo(C.t.sid, g.id); else { host.dismissLink(C.t.sid); drawSug(); } return; }
367
376
  const d = b.dataset;
368
377
  const ic = b.closest('.hm-icard'), card = C.t && C.t.intro && C.t.intro.card;
369
378
  if (ic && card && card.press) { if (await card.press(b)) draw(); return; }
@@ -0,0 +1,64 @@
1
+ /* pm/home-day.js — Your day in the Viewer, shell A (initiative viewer-shell-a, V10; canvas XvAPhDay, was TfPhone and the HvAOpen sheet).
2
+ *
3
+ * "Good morning" opens Your day as an item in the Viewer, not as a sheet over the list: on a phone the shell is full screen, on a desktop
4
+ * it sits beside the chat like any other item. The summary card says what is yours and the day's meetings; three sections fold:
5
+ * Your move every row that is the PM's move now (homeList's move), open by default
6
+ * Now a phone only: the moment card (TfPhone: own late tasks with Done, finished drafts, the recap), open by default
7
+ * Next meeting the meeting on now or the next one today
8
+ * This week the Weekly review
9
+ * The calendar is under ⋯. dayModel is pure; dayParts turns it into the shell's summary and sections. Text from records goes through esc(). */
10
+
11
+ import { todayOf, hm } from './home-data.js';
12
+
13
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
15
+ export const DAY_ICON = 'M12 3l1.8 4.6L18 9l-4.2 1.4L12 15l-1.8-4.6L6 9l4.2-1.4z';
16
+ const CLOCK = 'M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16M12 8v4l3 2', CAL = 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', CHEV = 'M10 7l5 5-5 5';
17
+ const svg = (d, w = 15) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
18
+
19
+ const span = (m) => { const a = Date.parse(m.start); const b = m.end ? Date.parse(m.end) : a + (m.minutes || 30) * 60000; return { a, b }; };
20
+ const dur = (mins) => (mins >= 60 ? (Math.round(mins / 30) / 2).toString().replace(/\.0$/, '') + ' h' : mins + ' min');
21
+
22
+ /** Your day's words. M: homeList's model (move); D: Home's data (today's meetings); R: reviewModel. → { signal, text, move, next, week } */
23
+ export function dayModel(M, D, R, now = Date.now()) {
24
+ const move = (M && M.move) || [];
25
+ const t = todayOf(D || {}).filter((m) => m && m.start && !Number.isNaN(Date.parse(m.start))).sort((x, y) => Date.parse(x.start) - Date.parse(y.start));
26
+ const mins = t.reduce((n, m) => { const s = span(m); return n + Math.max(0, Math.round((s.b - s.a) / 60000)); }, 0);
27
+ const next = t.find((m) => m.state === 'now') || t.find((m) => m.state !== 'past' && span(m).b > now) || null;
28
+ const lead = !t.length ? 'No meeting today.' : plural(t.length, 'meeting', 'meetings') + ', ' + dur(mins) + '. '
29
+ + (!next ? 'They are all over.' : next.state === 'now' ? (next.title || 'A meeting') + ' is on now.' : 'The ' + (next === t[0] ? 'first' : 'next') + ' is at ' + hm(next.start) + '.');
30
+ const un = R && R.started && !R.done ? 'Step ' + (R.at + 1) + ' of 4' : '';
31
+ return {
32
+ signal: move.length ? { text: move.length === 1 ? '1 is yours' : move.length + ' are yours', tone: 'you' } : null, // zero is silence
33
+ text: lead,
34
+ move,
35
+ next: next ? { meeting: next, now: next.state === 'now', time: hm(next.start), title: next.title || 'A meeting' } : null,
36
+ week: { sub: un || 'Weekly review' },
37
+ };
38
+ }
39
+
40
+ /* one row of Your move: the mark says what it is (a check box is a task, a dot waits on you, amber when blocked or late) */
41
+ function moveRow(r) {
42
+ const mark = r.check ? `<span class="hv-ck${r.late ? ' late' : ''}" role="img" aria-label="Your task${r.late ? ', late' : ''}"></span>`
43
+ : `<span class="hv-d${r.state === 'blocked' ? ' am' : ''}" role="img" aria-label="${r.state === 'blocked' ? 'Blocked, waits on you' : 'Waits on you'}"></span>`;
44
+ const sub = r.when ? `<em>${svg(CLOCK, 13)} ${esc(r.when)}</em>` : r.sub ? `<em>${esc(r.sub)}</em>` : '';
45
+ return `<div class="hm-r hv-r two" data-id="${esc(r.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"><span class="hv-mk">${mark}</span><span class="hm-rt"><b>${esc(r.name)}</b>${sub}</span></button></div>`;
46
+ }
47
+
48
+ /** The shell's parts for Your day (czSummary and czSections take them). o: { moment: true on a phone with the moment card } → { summary, sections } */
49
+ export function dayParts(Y, o = {}) {
50
+ const sections = [];
51
+ if (Y.move.length) sections.push({ id: 'move', title: 'Your move', count: Y.move.length, open: true, html: `<div class="hv-card hd-move">${Y.move.map(moveRow).join('')}</div>` });
52
+ if (o.moment) sections.push({ id: 'now', title: 'Now', open: true, html: '<div class="hd-now"></div>' }); // kept: the frame has no slot for it; drawDay puts the card in
53
+ if (Y.next) {
54
+ sections.push({ id: 'next', title: Y.next.now ? 'On now' : 'Next meeting', count: Y.next.now ? '' : Y.next.time, html: `<div class="hv-card"><div class="hm-r hv-r two"><button type="button" class="hm-rm" data-hd-meet><span class="hv-mk">${svg(CLOCK, 15)}</span><span class="hm-rt"><b>${esc(Y.next.title)}</b><em>${esc(Y.next.now ? 'On now' : Y.next.time)}</em></span><span class="hv-cv">${svg(CHEV, 16)}</span></button></div></div>` });
55
+ }
56
+ sections.push({ id: 'week', title: 'This week', count: Y.week.sub, html: `<div class="hv-card"><div class="hm-r hv-r two" data-id="review"><button type="button" class="hm-rm" data-hm-review aria-label="Weekly review: ${esc(Y.week.sub)}. Open"><span class="hv-mk">${svg(CAL, 16)}</span><span class="hm-rt"><b>Weekly review</b><em>${esc(Y.week.sub)}</em></span><span class="hv-cv">${svg(CHEV, 16)}</span></button></div></div>` });
57
+ return { summary: { line: Y.signal ? Y.signal.text : '', tone: Y.signal ? Y.signal.tone : '', text: Y.text }, sections };
58
+ }
59
+
60
+ /** Draws Your day into the Viewer's body with the shell's summary and folds; moment(el) puts the phone's moment card in Now. */
61
+ export function drawDay(body, P, VW, moment) {
62
+ body.innerHTML = VW.czSummary(P.summary) + VW.czSections(P.sections, { key: 'day' });
63
+ const now = body.querySelector('.hd-now'); if (now && moment) moment(now);
64
+ }
@@ -92,7 +92,7 @@ export function taskRows(M, L, now = Date.now()) {
92
92
  owner: t.owner || '', av: initials(t.owner), due: due.text, late: due.late, end: t.end || '', group: (lay.of || {})[t.key] || '', src: t.src || '', blocked: !!t.blocked, canCheck: !!(t.pmos && t.uid) };
93
93
  });
94
94
  }
95
- export const BY_LABEL = { stage: 'Stage', mine: 'Your groups', owner: 'Owner', status: 'Status', none: 'No groups' };
95
+ export const BY_LABEL = { stage: 'Stage', epic: 'Epic', mine: 'Your groups', owner: 'Owner', status: 'Status', none: 'No groups' }; // epic: tk-model.js ticketGroups
96
96
  const STATUS = ['To do', 'In progress', 'In review', 'Done'];
97
97
  const order = (rows) => rows.filter((r) => !r.done).concat(rows.filter((r) => r.done));
98
98
  export function taskGroups(rows, L, by, stages) {