create-pmos 0.587.0 → 0.589.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 (41) hide show
  1. package/package.json +27 -27
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +26 -0
  7. package/workspace/guide/home.md +13 -2
  8. package/workspace/guide/notes.md +14 -0
  9. package/workspace/lib/jira-status.js +10 -3
  10. package/workspace/lib/meeting-guest-page.js +53 -0
  11. package/workspace/lib/outbox-store.js +9 -2
  12. package/workspace/lib/route-modules.js +1 -0
  13. package/workspace/lib/routes-outbox.js +17 -2
  14. package/workspace/lib/routes-waiting.js +24 -0
  15. package/workspace/lib/share-store.js +3 -2
  16. package/workspace/lib/waiting-on.js +252 -0
  17. package/workspace/milestone-suggest-test.js +5 -4
  18. package/workspace/package-lock.json +2 -2
  19. package/workspace/package.json +1 -1
  20. package/workspace/panels-test.js +1 -1
  21. package/workspace/program-order-test.js +3 -1
  22. package/workspace/public/pm/cozy-today.css +28 -0
  23. package/workspace/public/pm/good-morning.js +6 -2
  24. package/workspace/public/pm/home-app.js +60 -5
  25. package/workspace/public/pm/home-day.js +4 -1
  26. package/workspace/public/pm/home-list.js +3 -1
  27. package/workspace/public/pm/home-today.js +6 -3
  28. package/workspace/public/pm/home-top.js +102 -0
  29. package/workspace/public/pm/ini-tasks.js +6 -2
  30. package/workspace/public/pm/meeting-share.js +192 -0
  31. package/workspace/public/pm/move-rank.js +12 -3
  32. package/workspace/public/pm/outbox-view.js +54 -1
  33. package/workspace/public/pm/premium-vw-doc.css +28 -0
  34. package/workspace/public/pm/premium-vw-mtg.js +13 -8
  35. package/workspace/public/pm/premium-vw-share.js +70 -9
  36. package/workspace/server.js +41 -1
  37. package/workspace/share-server.js +14 -2
  38. package/workspace/sort-order-test.js +3 -1
  39. package/workspace/stage-card-tasks-test.js +2 -0
  40. package/workspace/test-lists/home-your-move-waiting.json +11 -0
  41. package/workspace/test-lists/meeting-share.json +9 -0
@@ -182,7 +182,9 @@ function productHtml(g, o) {
182
182
  * them (the list); the folded rail's card shows the same rows without it. */
183
183
  function productBody(g, o, po) {
184
184
  const pinned = (x) => (o.pin.has(x.key) ? 0 : 1);
185
- const flat = g.flat.slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
185
+ // say it once (home-your-move-waiting): the weekly update leaves the list while Your move at the top of Home holds it
186
+ const held = o.held && o.held.update ? (r) => r.kind === 'update' : () => false;
187
+ const flat = g.flat.filter((r) => !held(r)).slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
186
188
  const QUIET = 3;
187
189
  const restAll = o.restOpen(g.key);
188
190
  // the open initiative always shows, wherever the PM's order puts it (batch 14 item 8)
@@ -225,7 +227,8 @@ function programBody(g, o, po) {
225
227
  const many = g.subs.length > 1;
226
228
  const body = g.subs.map((x) => { const inis = x.inis.map((r) => iniHtml(r, { ...o, gk: g.key }, po)).join(''); return `${many ? `<div class="hv-psub" role="heading" aria-level="3"><span class="hv-st2 t${x.tone}" aria-hidden="true">${esc(x.initials)}</span>${esc(x.name)}</div>` : ''}${po ? `<div class="po-list" data-po-list="${esc(g.program.id)}">${inis}</div>` : inis}`; }).join('');
227
229
  // the program's milestone changes that wait on the PM lead its card (batch 14 item 4: they were only in Your day, which a desktop no longer has)
228
- const msr = g.msRow ? `<div class="hm-r hv-r${o.sel === g.msRow.id ? ' sel' : ''}" data-id="${esc(g.msRow.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(g.msRow.id)}" aria-label="${esc(g.msRow.hint)}. Waits on you. Open the program"><span class="hv-mk"><span class="hv-d" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(g.msRow.hint)}</b></span></button></div>` : '';
230
+ // say it once (home-your-move-waiting): the milestone changes leave the card while Your move at the top of Home holds them
231
+ const msr = g.msRow && !(o.held && o.held.programs && o.held.programs.has(g.program.id)) ? `<div class="hm-r hv-r${o.sel === g.msRow.id ? ' sel' : ''}" data-id="${esc(g.msRow.id)}"><button type="button" class="hm-rm" data-hm-sel="${esc(g.msRow.id)}" aria-label="${esc(g.msRow.hint)}. Waits on you. Open the program"><span class="hv-mk"><span class="hv-d" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(g.msRow.hint)}</b></span></button></div>` : '';
229
232
  return msr + (body || `<p class="hm-none">${(g.program.members || []).length ? 'No open initiatives' : 'No initiatives yet'}. Open the program to move some in.</p>`);
230
233
  }
231
234
  /** Which group holds what is open (o.sel: a row id, or 'i:<initiative>'): the folded rail marks that group's tile (batch 18 item 14, FlA4After).
@@ -331,7 +334,7 @@ export function listHtml(M, T, o) {
331
334
  const head = `<div class="hm-hd hv-bar">${own ? o.imFace : ''}<button type="button" class="hv-hi" ${o.ready ? 'data-hm-day' : 'aria-disabled="true"'} aria-expanded="${!!o.day}" aria-label="${esc(M.word || 'Today')}${nw}. Open your day">${face}<b>${esc(M.word || 'Today')}</b>${o.ready ? '' : LS.ringHtml()}${svg(P.chevD, 18)}</button><span class="hv-acts">`
332
335
  // the product chip, always (it is also the way to add one): the ticked products' tiles, or All (canvas XhpA2States)
333
336
  + (o.pick ? chipHtml(o.pick, { id: 'hmPick', attrs: 'data-hm-pick', label: 'Products on Home', tones: o.tones }) : '')
334
- + (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Kept or Done">${svg(P.filter, 18)}</button>`)
337
+ + (o.phone ? '' : `<button type="button" class="ut-ib hv-ib${flt ? ' on' : ''}" data-hm-flt aria-haspopup="menu" aria-label="Show: Today, Mine, Kept or Done${flt ? '. Now ' + esc(flt.label) : ''}" title="Show: Today, Mine, Kept or Done">${svg(P.filter, 18)}</button>`)
335
338
  + SO.btnHtml('ut-ib hv-ib' + (SO.layout().sort !== 'mine' ? ' on' : ''))
336
339
  + `<button type="button" class="ut-ib hv-ib" data-hm-new aria-haspopup="menu" aria-label="New" title="New">${svg(P.plus, 20)}</button>`
337
340
  // fold the list to the rail (batch 18 item 15, TbT1Split): the rail's list button brings it back; a phone has no rail
@@ -0,0 +1,102 @@
1
+ /* pm/home-top.js — the top of Home: Your move and Waiting on others, above today's list (initiative home-your-move-waiting, batch 30; design
2
+ * A′, board HmA2 on the main canvas, agreed by Wawan 17 Nov 2026). Pure: Node imports it (home-top.test.js).
3
+ *
4
+ * topModel(o) → T what the top says. o: { rank (rankMove's answer, the same one Good morning reads), waiting (GET /api/waiting),
5
+ * products: [{ name, rows }] (the Board rows Home reads, for the last line), all (the fold is open), now }
6
+ * topHtml(T) → markup the .hy section, or '' when there is nothing to say (zero is silence)
7
+ * heldOf(T) → { update, programs: Set } what Your move holds, so the list below leaves those rows out (say it once)
8
+ *
9
+ * YOUR MOVE. callsIn(rank) (pm/good-morning.js): the calls of the six always-yours kinds, in rankMove's order. Each row's meta line starts with
10
+ * its kind word (Message, Move the team reads, Your call, Blocked, Verdict, New request, Merge, Delete or spend). At most CAP (5) show; the fold
11
+ * line names what it hides and whose call it is ("1 more · your call: Commerce workaround needs an owner"), never a bare count.
12
+ * WAITING ON OTHERS. GET /api/waiting rows: each has a real who. A drafted nudge is one line, "Nudge drafted · goes as a Jira comment only when
13
+ * you send it from the Viewer", and one ↗; no ✓ or ✕ here, because a message to people always waits for the PM (D106 class C, D107).
14
+ * THE TWO QUIET LINES. What PMOS did since yesterday, with Undo, and the rows that left Waiting on others ("Faye replied on MSD-4388"); then one
15
+ * plain line on the rest: "Everything else is on track · 8 initiatives in 3 products" only when it is true, else what the statuses say. */
16
+ import { callsIn, MOVE_CAP } from './good-morning.js';
17
+
18
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
19
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
20
+ const clip = (s, n) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
21
+ const svg = (d, w = 14, 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>`;
22
+ const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z', OPEN = 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', CHECK = 'M5 12.5l4.5 4.5L19 7.5';
23
+ const PERSON = 'M12 12a4 4 0 1 0 0-8a4 4 0 1 0 0 8zM4 20a8 8 0 0 1 16 0', CHEV = 'M10 7l5 5-5 5', CHEVD = 'M7 10l5 5 5-5';
24
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
25
+ const dm = (iso) => { const t = Date.parse(iso || ''); if (!Number.isFinite(t)) return ''; const d = new Date(t); return d.getDate() + ' ' + MON[d.getMonth()]; };
26
+ const DAY = 864e5;
27
+ const SOURCE_WORD = { jira: 'Jira assignee', note: 'owns it from', message: 'no reply to your message' };
28
+ const OPEN_STATUS = new Set(['on track', 'at risk', 'late', 'no signal']);
29
+
30
+ /** A call's why, said as Good morning says it: PMOS's pick, when it goes out, else its own sub. */
31
+ const callWhy = (c) => (c.pick ? 'I’d ' + c.pick.charAt(0).toLowerCase() + c.pick.slice(1).replace(/\.?$/, '.') + ' It’s your call.' : c.when ? 'Goes out ' + c.when + '.' : c.sub || c.hint || '');
32
+ const lowerKind = (k) => (k === 'Your call' ? 'your call' : k.charAt(0).toLowerCase() + k.slice(1));
33
+
34
+ /** The last line: on track only when every open initiative reads on track; else what the statuses say (honest state). '' with nothing open. */
35
+ export function restLine(products) {
36
+ const P = (products || []).filter((p) => p && (p.rows || []).some((r) => r && OPEN_STATUS.has(r.status)));
37
+ const rows = P.flatMap((p) => p.rows.filter((r) => r && OPEN_STATUS.has(r.status)));
38
+ if (!rows.length) return '';
39
+ const where = plural(rows.length, 'initiative', 'initiatives') + ' in ' + plural(P.length, 'product', 'products');
40
+ const n = (s) => rows.filter((r) => r.status === s).length;
41
+ if (n('on track') === rows.length) return 'Everything else is on track · ' + where;
42
+ const parts = [['late', 'late'], ['at risk', 'at risk'], ['no signal', 'no signal yet'], ['on track', 'on track']].filter(([s]) => n(s)).map(([s, w]) => n(s) + ' ' + w);
43
+ return where + ' · ' + parts.join(', ');
44
+ }
45
+
46
+ export function topModel(o = {}) {
47
+ const now = o.now || Date.now();
48
+ const R = o.rank || null, W = o.waiting && o.waiting.ok ? o.waiting : null;
49
+ const mine = callsIn(R).map((r) => ({ ...r, sub: r.kind === 'call' && r.call ? callWhy(r.call) : r.sub }));
50
+ const cap = o.all ? mine.length : MOVE_CAP;
51
+ const move = mine.slice(0, cap), hidden = mine.slice(cap);
52
+ const fold = hidden.length ? { n: hidden.length, text: hidden.length + ' more · ' + lowerKind(hidden[0].callKind) + ': ' + clip(hidden[0].title, 80) + (hidden.length > 1 ? ' and ' + plural(hidden.length - 1, 'other', 'others') : '') }
53
+ : o.all && mine.length > MOVE_CAP ? { n: 0, text: 'Show fewer', less: true } : null;
54
+ const waiting = W ? (W.rows || []).filter((r) => r && r.who).map((r) => {
55
+ const src = r.source === 'jira' ? 'Jira assignee · no update since ' + dm(r.since) : r.source === 'note' ? 'owns it from ' + (r.where || 'a meeting note') + ' · since ' + dm(r.since) : 'no reply since ' + dm(r.since);
56
+ const N = r.nudge;
57
+ const nudge = N && !N.sent && !N.snoozed ? 'Nudge drafted · goes as a ' + N.word + ' only when you send it from the Viewer' : N && N.sent ? 'Nudge sent · no reply seen yet' : '';
58
+ return { key: r.key, title: r.title, who: r.who, meta: [src, r.age].filter(Boolean).join(' · '), nudge, nudgeId: N && !N.sent ? N.id : '', link: r.link || '', note: r.note || '', ws: r.ws || '', ini: r.ini || '' };
59
+ }) : [];
60
+ // what PMOS did since yesterday (class A and B, each with Undo, lib/done-feed.js / GET /api/autonomy), said as one line with the newest Undo
61
+ const did = ((R && R.done) || []).filter((d) => { const t = Date.parse(d.at || ''); return Number.isFinite(t) && now - t <= DAY; });
62
+ const d0 = did[0] || null;
63
+ const done = d0 ? { text: 'PMOS did ' + (did.length === 1 ? 'this' : did.length + ' things') + ' since yesterday: ' + (d0.name ? d0.name + ': ' : '') + (d0.said || 'done') + (did.length > 1 ? ', and more on Good morning.' : '.'), d: d0 } : null;
64
+ const closed = W ? (W.closed || []).slice(0, 3).map((c) => c.why).filter(Boolean) : [];
65
+ return { move, fold, n: mine.length, waiting, done, closed, rest: restLine(o.products), held: heldOf({ mine }) };
66
+ }
67
+
68
+ /** What Your move holds that the list below also draws: the weekly update and a program's milestone changes (say it once). */
69
+ export function heldOf(T) {
70
+ const L = (T && (T.mine || T.move)) || [];
71
+ return { update: L.some((r) => r.kind === 'call' && r.call && r.call.kind === 'update'), programs: new Set(L.filter((r) => r.kind === 'meeting' && r.ms && r.program).map((r) => r.program)) };
72
+ }
73
+
74
+ const icon = (yd, key, label, d, cls = '') => `<button type="button"${cls ? ` class="${cls}"` : ''} data-yd="${yd}" data-key="${esc(key)}" aria-label="${esc(label)}" title="${esc(label)}">${svg(d, 14, cls === 'ok' ? 2.2 : 1.8)}</button>`;
75
+ function moveRowHtml(r) {
76
+ const yes = r.yes ? icon('mv-yes', r.key, r.yes + ': ' + r.title, CHECK, 'ok') : '';
77
+ const meta = [r.sub, r.age].filter(Boolean).map(esc).join(' · ');
78
+ return `<div class="hy-r" data-key="${esc(r.key)}"><span class="st">${svg(SPARK, 15)}</span><div class="tx"><b>${esc(r.title)}</b><small><i class="k">${esc(r.callKind)}</i>${meta ? ' · ' + meta : ''}</small></div>`
79
+ + `<div class="ac">${icon('mv-open', r.key, (r.alt || 'Open it') + ': ' + r.title, OPEN)}${yes}</div></div>`;
80
+ }
81
+ function waitRowHtml(w) {
82
+ const go = w.nudgeId ? `data-hm-nudge="${esc(w.nudgeId)}"` : `data-hm-wait="${esc(w.key)}"`;
83
+ const label = w.nudgeId ? 'Look at the nudge: ' + w.title : 'Open: ' + w.title;
84
+ return `<div class="hy-r" data-key="${esc(w.key)}"><span class="st w">${svg(PERSON, 13)}</span><div class="tx"><b>${esc(w.title)}</b><small><i class="k">${esc(w.who)}</i> · ${esc(w.meta)}</small>`
85
+ + (w.nudge ? `<small><i>${svg(SPARK, 13)}</i> ${esc(w.nudge)}</small>` : '') + `</div><div class="ac"><button type="button" ${go} aria-label="${esc(label)}" title="${esc(label)}">${svg(OPEN, 14)}</button></div></div>`;
86
+ }
87
+ export function topHtml(T) {
88
+ if (!T) return '';
89
+ let h = '';
90
+ if (T.move.length) {
91
+ h += `<div class="hy-h"><span>Your move</span><span class="sp"></span><span class="n">${T.n}</span></div>${T.move.map(moveRowHtml).join('')}`;
92
+ if (T.fold) h += `<button type="button" class="hy-q" data-hm-topall aria-expanded="${!!T.fold.less}"><span>${esc(T.fold.text)}</span><span class="sp"></span>${svg(T.fold.less ? CHEVD : CHEV, 14)}</button>`;
93
+ }
94
+ if (T.waiting.length) h += `<div class="hy-h"><span>Waiting on others</span><span class="sp"></span><span class="n">${T.waiting.length}</span></div>${T.waiting.map(waitRowHtml).join('')}`;
95
+ if (T.done) {
96
+ const d = T.done.d;
97
+ h += `<div class="hy-dn"><span>${esc(T.done.text)}</span><span class="sp"></span><button type="button" class="hy-lk" data-yd="done-undo" data-ref="${esc(d.ref)}" data-via="${esc(d.via || 'proposals')}" data-ws="${esc(d.ws || '')}" data-board="${esc(d.board || '')}">Undo</button></div>`;
98
+ }
99
+ for (const c of T.closed) h += `<div class="hy-dn"><span>${esc(c)}</span></div>`;
100
+ if (h && T.rest) h += `<div class="hy-dn"><span>${esc(T.rest)}</span></div>`;
101
+ return h ? `<section class="hy" aria-label="Your move and waiting on others">${h}</section>` : '';
102
+ }
@@ -568,6 +568,8 @@ export function kanbanHtml(v, o, isOpen) {
568
568
 
569
569
  /* ── the popovers: the task card's own status segment and date picker, opened right under the press ── */
570
570
  let POP = null;
571
+ /** The press the picker hangs from moved (or left the page) since it opened. */
572
+ const moved = (P) => { if (!P.anchor || !P.anchor.isConnected || !P.at) return true; const r = P.anchor.getBoundingClientRect(); return Math.abs(r.left - P.at[0]) > 1 || Math.abs(r.top - P.at[1]) > 1; };
571
573
  export function closePop() { if (!POP) return; const { el, anchor, scrim } = POP; POP = null; el.remove(); if (scrim) scrim.remove(); if (anchor && anchor.isConnected) anchor.setAttribute('aria-expanded', 'false'); }
572
574
  /** o.sheet: a bottom sheet over a scrim (a phone); o.right: the popover's right edge under the press's right edge. */
573
575
  export function openPop(anchor, html, onPress, o = {}) {
@@ -583,7 +585,8 @@ export function openPop(anchor, html, onPress, o = {}) {
583
585
  el.style.setProperty('--tl-x', left + 'px'); el.style.setProperty('--tl-y', (below ? r.bottom + 6 : Math.max(8, r.top - 6 - h)) + 'px');
584
586
  }
585
587
  anchor.setAttribute('aria-expanded', 'true');
586
- POP = { el, anchor, onPress, scrim };
588
+ const ar = anchor.getBoundingClientRect();
589
+ POP = { el, anchor, onPress, scrim, at: [ar.left, ar.top] };
587
590
  const f = el.querySelector('[aria-checked="true"], [aria-pressed="true"], button'); if (f) f.focus({ preventScroll: true });
588
591
  return el;
589
592
  }
@@ -600,7 +603,8 @@ if (typeof document !== 'undefined' && document.head) {
600
603
  document.addEventListener('keydown', (e) => { if (POP && e.key === 'Escape') { e.stopPropagation(); const a = POP.anchor; closePop(); if (a && a.isConnected) a.focus(); } }, true);
601
604
  addEventListener('resize', () => { if (POP && !POP.scrim) closePop(); });
602
605
  // the view sheet stays through a scroll: its own presses redraw Tasks, and a Timeline settles its scroll as it draws
603
- document.addEventListener('scroll', (e) => { if (POP && !POP.el.contains(e.target) && !POP.el.querySelector('.ivs')) closePop(); }, true);
606
+ // a scroll closes the picker only when it moves the press it hangs from (a scroll of the page behind the Viewer does not)
607
+ document.addEventListener('scroll', (e) => { if (POP && !POP.el.contains(e.target) && !POP.el.querySelector('.ivs') && moved(POP)) closePop(); }, true);
604
608
  }
605
609
  /** The five icons (To do, In progress, Done, Won't do | Archive), only the current one named: the task card's segment. */
606
610
  /** ms: the task's ◇ flag, or null where the flag cannot change here: after a second divider, the ◇ toggle (batch 11 item 3).
@@ -0,0 +1,192 @@
1
+ /* pm/meeting-share.js — a meeting note shared with people who have no PMOS (initiative shareable-meeting-notes, batch 31 item 1, design A plus the
2
+ * follow-up draft on Exploring 2 "Shareable meeting notes"). Pure: the page's share popover and the workspace server's POST /api/shares both use it,
3
+ * so the cut the PM approves in the popover is the cut the server writes.
4
+ *
5
+ * THE CUT. PMOS proposes it and the PM only approves:
6
+ * sections Summary, Decisions, Next steps and Questions go out; Facts mentioned and Since the last one stay in. Each is a chip.
7
+ * never the transcript, the recording and the screen shots. They are not in the list, there is no switch, and nothing here reads them.
8
+ * inside lines PMOS keeps inside: the PM's own to-dos and rules ("goes to you before release"), and lines about a team or a person who was
9
+ * not in the meeting ("Tell Communicator about the release"). PMOS's read of each line, listed with its reason; an eye puts it back.
10
+ * out details taken out of the lines that go: the link to the initiative, ticket keys, who said what, calendar and call links, email
11
+ * addresses. Listed only when the note holds one; a press puts that kind back.
12
+ * cut = { on: ['summary', …], back: ['in:<line id>', 'out:<kind>', …] } line ids: d<i> decisions, s<i> next steps, q<i> questions,
13
+ * f<i> facts, n<i> since the last one, o the summary.
14
+ *
15
+ * factsOf(note) → the facts mentioned (premium-vw-mtg.js shows the same list)
16
+ * proposeCut({ sheet, facts, pm, people }) → { sections, inside, out } sheet: premium-vw-meet.js noteSheet
17
+ * applyCut(proposal, cut, { sheet, facts, people, pm }) → the guest's copy: { title, when, people, summary, decisions, steps, questions, facts, since }
18
+ * (the guest page itself is lib/meeting-guest-page.js: a standalone page with its own colours, made on the server only)
19
+ * guestMarkdown(copy, { by, ends }) → the same copy as Markdown, the guest's Download
20
+ * followUp(copy, { url, by }) → { subject, body, mailto }: a draft for the PM's own mail app. PMOS sends nothing. */
21
+
22
+ export const SECTIONS = [
23
+ { k: 'summary', label: 'Summary', on: true },
24
+ { k: 'decisions', label: 'Decisions', on: true },
25
+ { k: 'steps', label: 'Next steps', on: true },
26
+ { k: 'questions', label: 'Questions', on: true },
27
+ { k: 'facts', label: 'Facts mentioned', on: false },
28
+ { k: 'since', label: 'Since the last one', on: false },
29
+ ];
30
+ export const NEVER_LINE = 'Transcript, recording and screens stay inside.';
31
+ export const OUT_LABEL = { ini: 'Link to the initiative', ticket: 'Ticket keys', who: 'Who said what', call: 'Calendar and call links', mail: 'Email addresses' };
32
+
33
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
34
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
35
+ const low = (s) => String(s || '').toLowerCase();
36
+ /** "Ana Putri" → "Ana"; an email address → its name part, capitalised; '' for nothing. */
37
+ export function firstName(s) {
38
+ let t = String(s || '').trim();
39
+ if (!t) return '';
40
+ if (/@/.test(t)) t = t.split('@')[0].split(/[._+-]/)[0];
41
+ t = t.split(/\s+/)[0].replace(/[^\p{L}\p{N}'-]/gu, '');
42
+ return t ? t[0].toUpperCase() + t.slice(1) : '';
43
+ }
44
+ const isPm = (name, pm) => { const f = low(firstName(name)); return !!f && (f === 'you' || f === 'me' || (!!pm && f === low(firstName(pm)))); };
45
+
46
+ /** The facts mentioned: statements with a number, or checked against a document. */
47
+ export function factsOf(n) {
48
+ if (!n || n.private) return [];
49
+ return (n.transcript || []).filter((x) => x && x.text && !x.dropped && x.cat === 'statement' && (/\d|\b(?:percent|half|double|twice)\b/i.test(x.text) || (x.check && x.check.doc)))
50
+ .map((x) => { const v = x.check && x.check.verdict; return { text: clip(x.text, 240), src: (x.check && x.check.doc) || '', tag: v === 'agrees' ? 'Matches' : v === 'differs' ? 'Differs' : 'Not checked', k: v === 'agrees' ? 'ok' : v === 'differs' ? 'warn' : '' }; });
51
+ }
52
+
53
+ /* ── the details taken out of the lines that go ── */
54
+ const TICKET_RX = /\s*(?:→\s*)?\(?\b[A-Z][A-Z0-9]{1,9}-\d{1,6}\b\)?/g;
55
+ const CALL_RX = /\s*\(?\bhttps?:\/\/(?:[a-z0-9-]+\.)*(?:meet\.google\.com|zoom\.us|teams\.microsoft\.com|teams\.live\.com|webex\.com|calendar\.google\.com|outlook\.office\.com|outlook\.live\.com|whereby\.com|around\.co)\S*\)?/gi;
56
+ const MAIL_RX = /\s*\(?\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b\)?/g;
57
+ const SAID = '(?:said|says|asked|asks|mentioned|suggested|proposed|noted|argued|thinks|thought|wants|wanted|pushed back|agreed|raised)';
58
+ const whoRx = (names) => (names.length ? new RegExp('\\b(?:' + names.map((x) => x.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|') + ')\\s+' + SAID + '\\b', 'g') : null);
59
+ const has = (rx, t) => { rx.lastIndex = 0; const y = rx.test(t); rx.lastIndex = 0; return y; };
60
+ const tidy = (t) => String(t).replace(/\b(?:call|join|meeting link|link)\s*:\s*$/gim, '').replace(/\s{2,}/g, ' ').replace(/\s+([,.;:!?])/g, '$1').replace(/\(\s*\)/g, '').trim();
61
+
62
+ /** Who was in the meeting, by first name, without the PM. */
63
+ const namesOf = (people, pm) => [...new Set((people || []).map(firstName).filter(Boolean))].filter((x) => !isPm(x, pm));
64
+
65
+ /* ── the lines PMOS keeps inside ── */
66
+ const AT_PM = /\b(?:to|by|with|from|for|ask|asks|tell|tells|ping|pings)\s+you\b|\byour\s+(?:own\s+)?(?:approval|call|sign-?off|review|ok|okay|decision)\b|\bgoes?\s+to\s+you\b|\byou\s+(?:approve|decide|sign\s+off|review)\b/i;
67
+ const either = (w) => '[' + w[0].toUpperCase() + w[0] + ']' + w.slice(1);
68
+ const TELL = new RegExp('\\b(?:' + ['tell', 'inform', 'update', 'ping', 'loop in', 'let', 'ask', 'email', 'message', 'brief', 'warn', 'notify', 'escalate to'].map(either).join('|')
69
+ + ')\\s+(?:the\\s+)?([A-Z][\\p{L}0-9&-]*(?:\\s+[A-Z][\\p{L}0-9&-]*)?)', 'u');
70
+ const TEAM = /\b(?:the\s+)?([A-Z][\p{L}0-9&-]*)\s+(?:team|squad|group|department|dept)\b/u;
71
+ /** PMOS's read of one line: why it stays inside, or '' when it can go. */
72
+ function insideWhy(line, { pm, names }) {
73
+ const why = [];
74
+ if (line.owner && isPm(line.owner, pm)) why.push('Your own to-do');
75
+ else if (AT_PM.test(line.text) || (pm && new RegExp('\\b(?:to|by|with|for)\\s+' + firstName(pm) + '\\b', 'i').test(line.text))) why.push('Your own approval rule');
76
+ const known = new Set(names.map(low));
77
+ const t = TELL.exec(line.text) || TEAM.exec(line.text);
78
+ if (t) {
79
+ const who = t[1].split(/\s+/)[0];
80
+ if (!known.has(low(who)) && !isPm(who, pm) && !/^(?:Them|The|Everyone|All|Us)$/i.test(who)) why.push(why.length ? 'about another team' : 'About another team');
81
+ }
82
+ return why.join(', ');
83
+ }
84
+
85
+ /** Every line that could go, with its id, its section and its owner. */
86
+ function linesOf(sheet, facts) {
87
+ const S = sheet || {};
88
+ const out = [];
89
+ (S.decisions || []).forEach((d, i) => out.push({ id: 'd' + i, sec: 'decisions', text: d.text, why: d.why || '' }));
90
+ (S.actions || []).forEach((a, i) => out.push({ id: 's' + i, sec: 'steps', text: a.text, owner: a.owner || '', due: a.due || '' }));
91
+ (S.questions || []).forEach((q, i) => out.push({ id: 'q' + i, sec: 'questions', text: q.text }));
92
+ (facts || []).forEach((f, i) => out.push({ id: 'f' + i, sec: 'facts', text: f.text }));
93
+ const since = S.since ? [...(S.since.items || []).map((x) => ({ ...x, tag: x.state === 'done' ? 'Done' : x.state === 'again' || x.state === 'raised' ? 'Raised again' : 'Not mentioned' })), ...(S.since.fresh || []).map((x) => ({ ...x, tag: 'New' }))] : [];
94
+ since.forEach((x, i) => out.push({ id: 'n' + i, sec: 'since', text: x.text, owner: x.owner || '', tag: x.tag }));
95
+ return out;
96
+ }
97
+
98
+ /** What PMOS proposes for a note. Pure. */
99
+ export function proposeCut({ sheet, facts = [], pm = '', people = [] } = {}) {
100
+ const S = sheet || {};
101
+ const names = namesOf(people, pm);
102
+ const lines = linesOf(S, facts);
103
+ const count = { summary: S.overview ? 1 : 0 };
104
+ for (const l of lines) count[l.sec] = (count[l.sec] || 0) + 1;
105
+ const sections = SECTIONS.map((s) => ({ k: s.k, label: s.label, n: s.k === 'summary' ? 0 : count[s.k] || 0, on: s.on, has: s.k === 'summary' ? !!S.overview : (count[s.k] || 0) > 0 })).filter((s) => s.has);
106
+ const inside = lines.map((l) => ({ id: l.id, sec: l.sec, text: l.text, why: insideWhy(l, { pm, names }) })).filter((l) => l.why);
107
+ // the details, over everything that could go
108
+ const all = [S.overview || '', ...lines.map((l) => l.text + ' ' + (l.why || ''))].join('\n');
109
+ const out = [];
110
+ if (S.initiative || S.about) out.push({ k: 'ini', label: S.initiative && S.initiative.name ? 'Link to the ' + clip(S.initiative.name, 40) + ' initiative' : OUT_LABEL.ini });
111
+ const tk = all.match(TICKET_RX);
112
+ if (tk) out.push({ k: 'ticket', label: 'Ticket keys, like ' + tk[0].replace(/[\s→()]/g, '') });
113
+ const wr = whoRx([...names, ...(pm ? [firstName(pm)] : [])]);
114
+ if (wr && has(wr, all)) out.push({ k: 'who', label: OUT_LABEL.who });
115
+ if (has(CALL_RX, all)) out.push({ k: 'call', label: OUT_LABEL.call });
116
+ if (has(MAIL_RX, all)) out.push({ k: 'mail', label: OUT_LABEL.mail });
117
+ return { sections, inside, out };
118
+ }
119
+
120
+ /** The proposal's cut as the popover starts it: the default sections, nothing put back. */
121
+ export const defaultCut = (prop) => ({ on: (prop && prop.sections ? prop.sections : []).filter((s) => s.on).map((s) => s.k), back: [] });
122
+
123
+ /** The guest's copy: only the sections that are on, without the lines kept inside (unless put back), with the details taken out. Pure. */
124
+ export function applyCut(prop, cut, { sheet, facts = [], people = [], pm = '' } = {}) {
125
+ const S = sheet || {};
126
+ const on = new Set(((cut && cut.on) || []).filter((k) => SECTIONS.some((s) => s.k === k)));
127
+ const back = new Set((cut && cut.back) || []);
128
+ const kept = new Set((prop.inside || []).filter((l) => !back.has('in:' + l.id)).map((l) => l.id));
129
+ const outK = new Set((prop.out || []).map((o) => o.k).filter((k) => !back.has('out:' + k)));
130
+ const names = namesOf(people, pm);
131
+ const wr = outK.has('who') ? whoRx([...names, ...(pm ? [firstName(pm)] : [])]) : null;
132
+ const clean = (t) => {
133
+ let s = String(t || '');
134
+ if (outK.has('ticket')) s = s.replace(TICKET_RX, '');
135
+ if (outK.has('call')) s = s.replace(CALL_RX, '');
136
+ if (outK.has('mail')) s = s.replace(MAIL_RX, '');
137
+ if (wr) s = s.replace(wr, (m) => 'Someone ' + m.replace(/^\S+\s+/, ''));
138
+ return tidy(s);
139
+ };
140
+ const lines = linesOf(S, facts).filter((l) => on.has(l.sec) && !kept.has(l.id));
141
+ const pick = (sec) => lines.filter((l) => l.sec === sec);
142
+ const who = [...new Set((people || []).map(firstName).filter(Boolean))];
143
+ return {
144
+ title: clean(S.event && S.event.title ? S.event.title : S.title || 'Meeting notes'),
145
+ when: [S.event && S.event.when ? S.event.when : S.day || '', S.minutes ? S.minutes + ' min' : ''].filter(Boolean).join(' · '),
146
+ people: who,
147
+ about: outK.has('ini') ? '' : S.about || '',
148
+ summary: on.has('summary') && !kept.has('o') ? clean(S.overview || '') : '',
149
+ decisions: pick('decisions').map((l) => ({ text: clean(l.text), why: clean(l.why) })).filter((x) => x.text),
150
+ steps: pick('steps').map((l) => ({ text: clean(l.text), owner: firstName(l.owner), due: l.due || '' })).filter((x) => x.text),
151
+ questions: pick('questions').map((l) => ({ text: clean(l.text) })).filter((x) => x.text),
152
+ facts: pick('facts').map((l) => ({ text: clean(l.text) })).filter((x) => x.text),
153
+ since: pick('since').map((l) => ({ text: clean(l.text), tag: l.tag, owner: firstName(l.owner) })).filter((x) => x.text),
154
+ };
155
+ }
156
+
157
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
158
+ const dayOf = (iso) => { const t = new Date(iso); return Number.isFinite(t.getTime()) ? t.getDate() + ' ' + MON[t.getMonth()] : ''; };
159
+ const andList = (xs) => (xs.length <= 1 ? xs.join('') : xs.slice(0, -1).join(', ') + ' and ' + xs[xs.length - 1]);
160
+ const stepMeta = (s) => [s.owner, s.due && /^\d{4}-\d{2}-\d{2}$/.test(s.due) ? dayOf(s.due + 'T12:00:00') : s.due].filter(Boolean).join(' · ');
161
+
162
+ /** The same copy as Markdown: what the guest's Download saves. Pure. */
163
+ export function guestMarkdown(c, { by = '', ends = '' } = {}) {
164
+ const out = ['# ' + c.title, ''];
165
+ const meta = [c.when, c.people.length ? andList(c.people) : ''].filter(Boolean).join(' · ');
166
+ if (meta) out.push('_' + meta + '_', '');
167
+ if (c.summary) out.push(c.summary, '');
168
+ const sec = (h, xs, f) => { if (xs.length) out.push('## ' + h, '', ...xs.map(f), ''); };
169
+ sec('Decided', c.decisions, (x) => '- ' + x.text + (x.why ? ' (' + x.why + ')' : ''));
170
+ sec('Next steps', c.steps, (x) => '- [ ] ' + x.text + (stepMeta(x) ? ' (' + stepMeta(x) + ')' : ''));
171
+ sec('Still open', c.questions, (x) => '- ' + x.text);
172
+ sec('Facts mentioned', c.facts, (x) => '- ' + x.text);
173
+ sec('Since the last one', c.since, (x) => '- ' + x.text + (x.tag ? ' (' + x.tag + ')' : ''));
174
+ out.push('---', '', [by ? 'A read-only copy shared by ' + by + '.' : 'A read-only copy.', ends ? 'The link ends ' + dayOf(ends) + '.' : ''].filter(Boolean).join(' ') + ' Made with PMOS.');
175
+ return out.join('\n').replace(/\n{3,}/g, '\n\n') + '\n';
176
+ }
177
+
178
+ /** The follow-up draft: a subject, the shared parts and the link, for the PM's own mail app (mailto) or the clipboard. PMOS sends nothing. Pure. */
179
+ export function followUp(c, { url = '', by = '', to = [] } = {}) {
180
+ const hi = c.people.filter((x) => !isPm(x, by));
181
+ const lines = [hi.length ? 'Hi ' + andList(hi) + ',' : 'Hi,', ''];
182
+ if (c.summary) lines.push(c.summary, '');
183
+ if (c.decisions.length) lines.push('Decided:', ...c.decisions.map((x) => '- ' + x.text), '');
184
+ if (c.steps.length) lines.push('Next steps:', ...c.steps.map((x) => '- ' + x.text + (x.owner ? ' (' + x.owner + ')' : '')), '');
185
+ if (c.questions.length) lines.push('Still open:', ...c.questions.map((x) => '- ' + x.text), '');
186
+ if (url) lines.push('The notes: ' + url, 'The password comes in a second message.', '');
187
+ if (by) lines.push(by);
188
+ const subject = c.title + ': what we settled';
189
+ const body = lines.join('\n').replace(/\n{3,}/g, '\n\n').trim();
190
+ const addr = (to || []).filter((x) => /^[^\s@,;?&]+@[^\s@,;?&]+\.[a-z]{2,}$/i.test(x)).join(',');
191
+ return { subject, body, mailto: 'mailto:' + encodeURIComponent(addr).replace(/%40/g, '@').replace(/%2C/g, ',') + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body) };
192
+ }
@@ -20,6 +20,7 @@
20
20
  * 2.5 mention a conversation that waits on the PM's reply (GET /api/mentions waiting; Home's Mentions card is gone): one row each,
21
21
  * Claude's gist or the real latest message, the source, "reply drafted" when there is a draft; the press opens it
22
22
  * 4.5 outbox a draft Claude put in the outbox (GET /api/outbox, queued or blocked): it waits for the PM to send it
23
+ * 5.5 owner an action a meeting agreed that nobody owns (o.gaps, GET /api/waiting gaps): the PM's call, "… needs an owner"
23
24
  * 5.6 extra what a page hands in (o.extra): Your impact's weekly check, Claude's clean-up of "Not in an initiative"
24
25
  * Lab results are ✦ on their initiative (lib/idle-lab.js files them as proposals), so they ride in that initiative's row (rank 6).
25
26
  * AT MOST 5 SHOW (CAP). The rest are "Can wait", in the same order (Claude's rank), never gone. A rank 6 row is one press for the whole
@@ -33,7 +34,7 @@
33
34
  *
34
35
  * o: { products: [{ ws, name, board, rows }] (Board rows: r.props from lib/proposals.js viewOf, r.track, r.status),
35
36
  * programs: GET /api/programs' programs, move: GET /api/your-move answers by ws ({ [ws]: { verdicts, kr, expired } }), calls: homeList's call
36
- * rows, mentions: GET /api/mentions waiting, outbox: GET /api/outbox entries, now }
37
+ * rows, mentions: GET /api/mentions waiting, outbox: GET /api/outbox entries, gaps: GET /api/waiting gaps, now }
37
38
  * → { rows (at most CAP), wait (Can wait, ranked), older: [] (kept for old callers), expired: [{ ini, title, why, at, name }],
38
39
  * done: [{ ref, via: 'autonomy' | 'proposals', ini, board, ws, at, said, name }] (C2: what Claude finished by itself, with Undo),
39
40
  * notices: [{ job, product, until, text?, ws }] (a job demoted to propose, said once), failed: [{ run, ini, at, why, ws, name }] (agent-run
@@ -186,9 +187,10 @@ export function rankMove(o = {}) {
186
187
  title: name + ': ' + clip(said, 100), sub: [src + (m.where ? ' · ' + m.where : ''), m.reply || m.draft ? 'reply drafted' : ''].filter(Boolean).join(' · '),
187
188
  alt: 'Open the conversation' });
188
189
  }
189
- // 4.5 the drafts Claude put in the outbox: they leave PMOS only when the PM sends them (C6)
190
+ // 4.5 the drafts Claude put in the outbox: they leave PMOS only when the PM sends them (C6). A nudge (e.about: a Waiting on others row,
191
+ // home-your-move-waiting) counts only under Waiting on others, never as a Message here
190
192
  for (const e of o.outbox || []) {
191
- if (!e || !e.id || (e.state !== 'queued' && e.state !== 'blocked')) continue;
193
+ if (!e || !e.id || e.about || (e.state !== 'queued' && e.state !== 'blocked')) continue;
192
194
  const ch = String(e.channel || 'message'), to = e.recipient ? ' to ' + e.recipient : '';
193
195
  add({ key: 'ob:' + e.id, rank: 4.5, kind: 'outbox', outbox: e, tag: 'Outbox', at: tsOf(e.created_at || e.at),
194
196
  title: clip(e.subject || String(e.body || '').split('\n')[0] || 'A draft', 100), sub: 'Drafted' + (ch ? ' for ' + ch.charAt(0).toUpperCase() + ch.slice(1) : '') + to + (e.state === 'blocked' ? ' · a claim needs a look' : ' · waits for you to send'),
@@ -197,6 +199,13 @@ export function rankMove(o = {}) {
197
199
  // 5.6 the other asks a page hands in (o.extra): Your impact's weekly check, Claude's clean-up of "Not in an initiative". Their cards and
198
200
  // chips on Home are gone (the UI grill's delete list); this is where they land. { key, title, sub, go, alt }
199
201
  for (const x of o.extra || []) if (x && x.key && x.title) add({ rank: 5.6, kind: 'extra', tag: '', at: null, age: '', alt: 'Open', ...x, key: 'ex:' + x.key });
202
+ // 5.5 an action agreed in a meeting that nobody owns (GET /api/waiting gaps, home-your-move-waiting): it waits on no one, so it is the
203
+ // PM's call, "… needs an owner"; the press opens the note
204
+ for (const g of o.gaps || []) {
205
+ if (!g || !g.key || !g.title) continue;
206
+ add({ key: 'gp:' + g.key, rank: 5.5, kind: 'owner', gap: g, tag: '', at: tsOf(g.since), title: clip(g.title, 100) + ' needs an owner',
207
+ sub: 'Agreed in ' + (g.where || 'a meeting') + (g.since ? ' on ' + dm(g.since, now) : '') + ', nobody owns it', alt: 'Open the note' });
208
+ }
200
209
  // the calls only the PM can make that are not ✦ (Claude's milestone changes are rank 3 now: said once)
201
210
  for (const c of (o.calls || []).filter((x) => x && x.kind !== 'msreview')) add({ key: 'call:' + c.id, rank: 5.5, kind: 'call', call: c, title: c.name, sub: '', at: null, age: '' });
202
211
  rows.sort((a, b) => a.rank - b.rank || (a.at == null) - (b.at == null) || (a.at || 0) - (b.at || 0) || a.key.localeCompare(b.key));
@@ -4,11 +4,17 @@
4
4
  * openDraft(entry, H) the Viewer: who it is for, where it goes, the words. Copy puts the words on the clipboard so the PM sends them from
5
5
  * their own tool (no channel is connected: POST /api/outbox/confirm sends nothing yet), ✕ discards the draft with
6
6
  * Undo (POST /api/outbox/discard { id } and { id, undo: true }). A draft whose claim failed the trust rules says so.
7
+ * A NUDGE (e.about: a Waiting on others row, home-your-move-waiting) has Send, Edit and Not now instead. Its channel is named ("Goes as a
8
+ * Jira comment to MSD-4388"). Send is POST /api/outbox/confirm: with no sender registered nothing leaves and the Viewer says "No channel
9
+ * connected: copy it", with Copy. Edit saves new words (POST /api/outbox/edit, a new hash). Not now is POST /api/outbox/snooze: recorded,
10
+ * and Home hides the nudge line until 09:00 the next morning. Nothing is ever sent from Home's list.
7
11
  * H: { pmPost, toast, toastUndo, reload } */
8
12
 
9
13
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
10
14
  const SVG = (d, w = 16, sw = 2) => `<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>`;
11
- const I = { mail: 'M3 5h18v14H3zM3 7l9 6 9-6', copy: 'M8 8h11v13H8zM5 16V3h11', x: 'M6 6l12 12M18 6L6 18' };
15
+ const I = { mail: 'M3 5h18v14H3zM3 7l9 6 9-6', copy: 'M8 8h11v13H8zM5 16V3h11', x: 'M6 6l12 12M18 6L6 18', send: 'M4 12l16-8-6 16-3-7z',
16
+ pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4', later: 'M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16M12 8v4l3 2' };
17
+ const CHANNEL = { 'jira-write': 'Jira comment', 'team-note': 'team note', 'customer-note': 'customer note', 'calendar-hold': 'calendar hold' };
12
18
  const cap = (s) => (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : '');
13
19
 
14
20
  export function draftHtml(e) {
@@ -17,8 +23,55 @@ export function draftHtml(e) {
17
23
  return `<div class="ob-d"><p class="yd-exp">${esc(where ? 'Drafted for ' + where + '. ' : '')}It waits here until you send it.</p>${refused}`
18
24
  + (e.subject ? `<h3>${esc(e.subject)}</h3>` : '') + `<pre class="ob-body">${esc(e.body || '')}</pre></div>`;
19
25
  }
26
+ /** A nudge in the Viewer: where it goes, the words (or the edit box), and what happened on the last Send. st: { edit, noChannel } */
27
+ export function nudgeHtml(e, st = {}) {
28
+ const where = 'Goes as a ' + (CHANNEL[e.channel] || 'message') + (e.recipient ? ' to ' + e.recipient : '') + ', only when you send it.';
29
+ const nc = st.noChannel ? `<p class="yd-exp ob-nc">No channel connected: copy it. <button type="button" class="ut-btn sm soft" data-ob="copy">${SVG(I.copy, 14)} Copy</button></p>` : '';
30
+ const refused = e.claims && e.claims.ok === false && (e.claims.refused || []).length ? `<p class="yd-exp">A claim in it needs a look: ${esc((e.claims.refused || []).join('; '))}</p>` : '';
31
+ const words = st.edit ? `<label class="vh" for="obEdit">The nudge's words</label><textarea id="obEdit" class="ob-edit" rows="5">${esc(e.body || '')}</textarea><p class="ut-acts"><button type="button" class="ut-btn sm pri" data-ob="save">Save</button><button type="button" class="ut-btn sm ghost" data-ob="cancel">Cancel</button></p>`
32
+ : `<pre class="ob-body">${esc(e.body || '')}</pre>`;
33
+ return `<div class="ob-d"><p class="yd-exp">PMOS drafted this nudge. ${esc(where)}</p>${nc}${refused}${words}</div>`;
34
+ }
35
+ function openNudge(e, H, VW) {
36
+ const st = { edit: false, noChannel: false };
37
+ let body = null;
38
+ const draw = () => { if (body) body.innerHTML = nudgeHtml(e, st); if (st.edit && body) { const t = body.querySelector('#obEdit'); if (t) t.focus(); } };
39
+ const copy = async () => { try { await navigator.clipboard.writeText(e.body || ''); H.toast('Copied. Paste it where you send it.'); } catch { H.toast('It could not be copied. Select the words and copy them.'); } };
40
+ VW.open({ id: 'ob:' + e.id, kind: 'Nudge', title: e.subject || 'A nudge to send', icon: I.mail,
41
+ presses: [{ act: 'later', label: 'Not now', icon: I.later }, { act: 'edit', label: 'Edit', icon: I.pen }, { act: 'send', label: 'Send', icon: I.send, solid: true }],
42
+ onPress: async (act) => {
43
+ if (act === 'edit') { st.edit = true; draw(); return; }
44
+ if (act === 'later') {
45
+ const r = await H.pmPost('/api/outbox/snooze', { id: e.id }).catch(() => null);
46
+ if (!r || r.ok === false) { H.toast((r && r.error) || 'It could not be put off. Nothing changed.'); return; }
47
+ VW.back(); H.toast('Not now. The nudge comes back tomorrow at 09:00.'); if (H.reload) H.reload(); return;
48
+ }
49
+ if (act === 'send') {
50
+ const r = await H.pmPost('/api/outbox/confirm', { id: e.id, hash: e.hash }).catch(() => null);
51
+ if (r && r.ok) { VW.back(); H.toast('Sent.'); if (H.reload) H.reload(); return; }
52
+ if (r && r.reason === 'no channel connected') { st.noChannel = true; draw(); return; }
53
+ H.toast((r && (r.reason || r.error)) || 'It could not be sent. Nothing left PMOS.');
54
+ }
55
+ },
56
+ render: (b) => {
57
+ body = b; draw();
58
+ b.onclick = async (ev) => {
59
+ const x = ev.target.closest('[data-ob]'); if (!x) return;
60
+ if (x.dataset.ob === 'copy') { copy(); return; }
61
+ if (x.dataset.ob === 'cancel') { st.edit = false; draw(); return; }
62
+ if (x.dataset.ob === 'save') {
63
+ const t = b.querySelector('#obEdit'), words = t ? t.value : '';
64
+ if (!words.trim()) { H.toast('The nudge needs some words.'); return; }
65
+ const r = await H.pmPost('/api/outbox/edit', { id: e.id, body: words }).catch(() => null);
66
+ if (!r || r.ok === false) { H.toast((r && r.error) || 'It could not be saved. Nothing changed.'); return; }
67
+ Object.assign(e, r.entry || { body: words }); st.edit = false; st.noChannel = false; draw(); H.toast('Saved.'); if (H.reload) H.reload();
68
+ }
69
+ };
70
+ } });
71
+ }
20
72
  export function openDraft(e, H) {
21
73
  const VW = window.czViewer; if (!VW || !e || !e.id) return;
74
+ if (e.about) { openNudge(e, H, VW); return; }
22
75
  VW.open({ id: 'ob:' + e.id, kind: 'Outbox', title: e.subject || 'A draft to send', icon: I.mail,
23
76
  presses: [{ act: 'discard', label: 'Discard the draft', icon: I.x }, { act: 'copy', label: 'Copy to send it yourself', icon: I.copy, solid: true }],
24
77
  onPress: async (act) => {
@@ -229,6 +229,34 @@ iframe.vwprint{position:fixed;right:0;bottom:0;width:1px;height:1px;border:0;opa
229
229
  .vwsm,.vwsrow2,.vwsoff,.vwshp .vwseg,.vwsgo{min-height:44px}.vwsw{width:48px;height:30px}.vwsw::after{width:22px;height:22px}.vwsw[aria-checked="true"]::after{left:23px}
230
230
  }
231
231
  @media (prefers-reduced-motion:reduce){.vwsw::after{transition:none}}
232
+ /* a meeting's share popover (shareable-meeting-notes, design A plus the follow-up draft, Exploring 2): under the share icon beside ⋯ */
233
+ .cz-vw-hd:has(> .vwshp){position:relative}.cz-vw-hd > .vwshp{top:calc(100% + 2px);right:8px}
234
+ /* on a cozy page that does not load premium.css or cozy-viewer.css (premium-viewer.html), the popover names the cozy tokens itself */
235
+ .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);
236
+ --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}
237
+ .vwshp:has(.vwmc){width:380px;max-width:min(380px,calc(100vw - 32px))}
238
+ .vwmc{display:flex;flex-wrap:wrap;gap:6px;padding:4px 8px}
239
+ .vwmchip,.vwmout{display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 12px;border-radius:999px;border:1px solid var(--hair);background:var(--card-solid);color:var(--ink);font:var(--fw-regular) var(--fs-body)/1.2 var(--sans);cursor:pointer}
240
+ .vwmchip small{color:var(--ink-3);font-size:var(--fs-meta)}
241
+ .vwmchip[aria-pressed="true"]{background:var(--cz-bluebg);border-color:var(--cz-blueink);color:var(--cz-blueink)}
242
+ .vwmchip[aria-pressed="true"] small{color:inherit;opacity:.8}
243
+ .vwmout{min-height:30px;padding:0 10px;font-size:var(--fs-meta);background:var(--well);border-color:transparent;color:var(--ink-2)}
244
+ .vwmout .st{text-decoration:line-through;text-decoration-color:var(--ink-3)}.vwmout[aria-pressed="true"]{background:var(--card-solid);border-color:var(--hair);color:var(--ink)}
245
+ .vwmnv{display:flex;align-items:flex-start;gap:8px;margin:2px 8px 4px;color:var(--ink-3);font-size:var(--fs-meta);line-height:1.45}.vwmnv .i{width:14px;height:14px;margin-top:2px}
246
+ .vwmprop{display:flex;align-items:center;gap:10px;min-height:40px;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:var(--ink);font:inherit;text-align:left;cursor:pointer}
247
+ .vwmprop span{flex:1}.vwmprop .sp{color:var(--cz-blueink);fill:currentColor}.vwmprop[aria-expanded="true"] .i:last-child{transform:rotate(90deg)}
248
+ .vwmin{display:flex;align-items:flex-start;gap:10px;padding:6px 8px;border-radius:8px}.vwmin>span{flex:1;min-width:0}.vwmin>.i{margin-top:3px}
249
+ .vwmin b{display:block;font-weight:var(--fw-regular)}.vwmin em{display:block;font-style:normal;color:var(--ink-3);font-size:var(--fs-meta)}.vwmin.back b{color:var(--ink)}
250
+ .vwmeye{width:36px;height:36px;flex:none;display:grid;place-items:center;border:0;border-radius:8px;background:transparent;color:var(--ink-2);cursor:pointer}
251
+ .vwmgo,.vwmfa{display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:4px 8px 6px}.vwmfa .vwsok{flex:1}
252
+ .vwmmk,.vwmmail{width:48px;height:48px;flex:none;display:grid;place-items:center;border:0;border-radius:50%;background:var(--cz-blueink);color:var(--card-solid);cursor:pointer;text-decoration:none}
253
+ .vwmmk .i,.vwmmail .i{color:var(--card-solid);width:20px;height:20px}.vwmmk:disabled{opacity:.45;cursor:default}
254
+ .vwmdr{margin:2px 8px 4px;padding:12px;border-radius:12px;background:var(--well);display:grid;gap:6px}
255
+ .vwmdr b{font-weight:var(--fw-strong)}.vwmdr p{margin:0;color:var(--ink-2);display:-webkit-box;-webkit-line-clamp:5;-webkit-box-orient:vertical;overflow:hidden}
256
+ .vwmdr code{display:flex;align-items:center;gap:6px;font:var(--fw-regular) var(--fs-meta)/var(--lh-meta) var(--mono);color:var(--ink-3);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.vwmdr code .i{width:14px;height:14px}
257
+ @media (hover:hover){.vwmprop:hover,.vwmeye:hover{background:var(--well)}.vwmchip:hover{border-color:var(--ink-3)}}
258
+ @media (max-width:640px){.vwmchip,.vwmout,.vwmprop,.vwmeye{min-height:44px}.vwmeye{width:44px}
259
+ .cz-vw-hd > .vwshp,.vwshp:has(.vwmc){position:fixed;left:8px;right:8px;top:auto;bottom:calc(8px + env(safe-area-inset-bottom,0px));width:auto;max-width:none;max-height:80dvh;overflow:auto;z-index:60}}
232
260
  /* The Edit log and Proposals under the page: a plain minimal section until the Agreed design draws them (initiative premium-agreed-design) */
233
261
  .vwside{display:grid;gap:8px;margin:18px 0 0;padding:14px 0 0;border-top:1px solid var(--hair)}
234
262
  .vwside .vwmp{display:grid;gap:8px}
@@ -44,6 +44,8 @@ import { APPS, recall, remember } from './listen-sources.js';
44
44
  import { replayView, phoneHtml, editHtml, mentions, phraseOf as phraseOfPage, deskHtml, leftHtml, wx, placesBy, wordPopHtml, posOf, lineAtPos, captionHtml } from './premium-mtg-replay.js';
45
45
  import { announce } from './rec-state.js';
46
46
  import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, Present goes to the recording tab (batch 12 item 1, rule 10)
47
+ import { factsOf } from './meeting-share.js'; // the facts mentioned: one list for the note and a shared copy (shareable-meeting-notes)
48
+ export { factsOf };
47
49
 
48
50
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
49
51
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
@@ -98,12 +100,6 @@ export function linesOf(n) {
98
100
  return byTime((n.transcript || []).filter((x) => x && x.text && !x.dropped)).map((x) => ({ t: x.t, text: String(x.text), who: sp[x.source] || DEF[x.source] || 'You', key: '', source: x.source || 'mic' }));
99
101
  }
100
102
  /** The facts said in the meeting, as view-notes.js caught() reads them: a statement with a number, or one checked against a repository file. */
101
- export function factsOf(n) {
102
- if (!n || n.private) return [];
103
- return (n.transcript || []).filter((x) => x && x.text && !x.dropped && x.cat === 'statement' && (/\d|\b(?:percent|half|double|twice)\b/i.test(x.text) || (x.check && x.check.doc)))
104
- .map((x) => { const v = x.check && x.check.verdict; return { text: clip(x.text, 240), src: (x.check && x.check.doc) || '', tag: v === 'agrees' ? 'Matches' : v === 'differs' ? 'Differs' : 'Not checked', k: v === 'agrees' ? 'ok' : v === 'differs' ? 'warn' : '' }; });
105
- }
106
-
107
103
  export const NO_NOTES = 'No notes for this meeting. It was not recorded, and nobody wrote any.';
108
104
  export const PAUSED_LINE = 'nothing is kept while paused';
109
105
  const peopleText = (ps) => (ps.length ? ps.slice(0, 3).join(', ') + (ps.length > 3 ? ' and ' + (ps.length - 3) + ' more' : '') : '');
@@ -680,11 +676,13 @@ function draw(me) {
680
676
  const body = vCur() && vCur().id === me.vid ? document.querySelector('#czViewer .cz-vw-body') : null;
681
677
  const m = me.model = meetModel({ ...me.D, elapsed: elapsedOf(me) });
682
678
  const busy = body && body.contains(document.activeElement) && /^(TEXTAREA|INPUT|SELECT)$/.test(document.activeElement.tagName);
683
- const sig = m.more.map((x) => x.k || '-').join(',');
679
+ const canShare = m.mk === 'notes' && !!m.noteId && !m.private; // shareable-meeting-notes: the share icon beside ⋯ once there are notes
680
+ const sig = m.more.map((x) => x.k || '-').join(',') + (canShare ? ',share' : '');
684
681
  if (!body || me.kind !== m.kind || me.head !== m.head || me.sig !== sig) { // the header names the state and ⋯ holds its presses: open again when they changed
685
682
  if (me.previewing) return; // the PM is looking at material: the meeting is drawn again when ← comes back to it
686
683
  me.kind = m.kind; me.head = m.head; me.sig = sig; me.reopen = true;
687
- vOpen({ id: me.vid, kind: m.kind, title: m.head, icon: 'meet', url: meetingUrl({ ...refNow(me), ws: me.ws }), render: (b) => paint(me, b), onClose: () => closed(me), more: moreOf(me, m) });
684
+ vOpen({ id: me.vid, kind: m.kind, title: m.head, icon: 'meet', url: meetingUrl({ ...refNow(me), ws: me.ws }), render: (b) => paint(me, b), onClose: () => closed(me), more: moreOf(me, m),
685
+ presses: canShare ? [{ act: 'share', label: 'Share…', icon: SHARE_ICON }] : [], onPress: (a, b) => { if (a === 'share') shareNote(me, b); } });
688
686
  widen('mtg');
689
687
  me.reopen = false;
690
688
  wideOnce(me, m);
@@ -702,6 +700,13 @@ function wideOnce(me, m) {
702
700
  }
703
701
  const refNow = (me) => (me.n ? { note: me.n.id } : me.row ? { event: me.row.id, date: me.row.day } : me.R);
704
702
  /** ⋯ of the meeting: the model's list, each with its press. */
703
+ /** The share icon (shareable-meeting-notes, design A): the D97 share popover with the cut PMOS proposes for this note. */
704
+ const SHARE_ICON = 'M12 15V4M8 8l4-4 4 4M6 12v7h12v-7';
705
+ function shareNote(me, btn) {
706
+ const m = me.model; if (!m || !me.n || !me.D || !me.D.S) return;
707
+ btn.setAttribute('aria-haspopup', 'dialog');
708
+ import('./premium-vw-share.js').then((M) => M.shareMenu(btn, { name: m.title, note: { id: me.n.id, sheet: me.D.S, facts: factsOf(me.n), people: m.people } }));
709
+ }
705
710
  function moreOf(me, m) {
706
711
  const on = (k) => () => act(me, k);
707
712
  return m.more.map((x) => (x.sep ? { sep: true } : { label: x.label, danger: !!x.danger, on: on(x.k) }));