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
@@ -0,0 +1,187 @@
1
+ /* pm/home-mentions.js — @Mentions on Home: a permanent row at the top of the list and the Mentions Viewer (Viewer kit; canvas XvANew,
2
+ * XvAMention, XvAMentionJira, XvAMentionDoc, XvAMentionMail).
3
+ *
4
+ * rowHtml(D, { sel }) → the row's markup: "@ Mentions" and "N new" while some are unread. With none new the row stays, with no count
5
+ * (zero is silence). The press is data-hr-mentions; home-app.js opens the Viewer.
6
+ * openMentions(ctx) → the Mentions Viewer: the summary card (how many are new, who asked what, ONE primary: Reply to <first>), then
7
+ * "New" (open) and "Earlier" (folded, the ones already read). A mention opens with back: true, so ← returns here.
8
+ * openOne(m, ctx, { back }) → one mention: how long it waits on the PM, what it is about, where it is, ONE primary (Draft a reply), the
9
+ * source excerpt with the mention outlined, What I checked (only the brief's own checks), Open in <source> and its
10
+ * initiative with its stage. ⋯ holds Make it a task and Mark read (or Mark unread).
11
+ * ctx: { D() → Home's data, pmPost, toast, reload(), iniTitle(id), stageOf(id), goIni(id), draft(m) }
12
+ *
13
+ * The mentions are today's (GET /api/brief-page mentions, Home's D.today). New = not marked read. Mark read is POST /api/mentions/read;
14
+ * Make it a task is POST /api/pm-items/add. Nothing here replies or posts: Draft a reply opens Home's chat to write it, and the PM sends
15
+ * it where the mention is. A mention shows only here: it is no longer a row under its initiative (say it once). */
16
+ import * as VW from './cozy-viewer.js';
17
+
18
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
19
+ const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail', gmail: 'Gmail', figma: 'Figma', doc: 'the document' };
20
+ const ICON = { jira: 'jira', confluence: 'doc', doc: 'doc', mail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7', gmail: 'M3.5 5.5h17v13h-17zM3.5 6l8.5 7 8.5-7' };
21
+ const TICK = 'M5 12.5l4.5 4.5L19 7.5';
22
+ 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>`;
23
+ const srcName = (s) => SRC[s] || (s ? String(s).charAt(0).toUpperCase() + String(s).slice(1) : 'its source');
24
+ const first = (who) => String(who || 'someone').trim().split(/\s+/)[0];
25
+ const clip = (s, n) => { s = String(s || '').replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
26
+ const https = (u) => (/^https:\/\/\S+$/i.test(String(u || '')) ? u : '');
27
+ const isMail = (s) => s === 'mail' || s === 'gmail';
28
+ const isDoc = (s) => s === 'confluence' || s === 'doc';
29
+
30
+ /* ── the data ── */
31
+ /** Today's mentions: { all, fresh (not read yet), earlier (read) }, newest first as the server sends them. */
32
+ export function mentionsOf(D) {
33
+ const all = (D && D.today && Array.isArray(D.today.mentions) ? D.today.mentions : []).filter((m) => m && m.id && !m.done);
34
+ return { all, fresh: all.filter((m) => !m.read), earlier: all.filter((m) => m.read) };
35
+ }
36
+ /** "40 min", "2 h", "1 day", "3 days"; '' with no time. */
37
+ export function age(at, now = Date.now()) {
38
+ const t = Date.parse(at || ''); if (!Number.isFinite(t)) return '';
39
+ const m = Math.max(0, Math.round((now - t) / 60000));
40
+ if (m < 60) return Math.max(1, m) + ' min';
41
+ const h = Math.round(m / 60); if (h < 24) return h + ' h';
42
+ const d = Math.round(h / 24); return d === 1 ? '1 day' : d + ' days';
43
+ }
44
+ /** Where the mention is, the way the frames say it: "Slack #product", "SLV-144 comment", "comment on PRD v3", "email". */
45
+ export function placeOf(m) {
46
+ const w = String(m.where || '').trim();
47
+ if (m.source === 'slack') return 'Slack' + (w ? ' ' + w : '');
48
+ if (m.source === 'jira') return (w || 'Jira') + ' comment';
49
+ if (isDoc(m.source)) return 'comment on ' + (w || srcName(m.source));
50
+ if (isMail(m.source)) return 'email';
51
+ return [srcName(m.source), w].filter(Boolean).join(' ');
52
+ }
53
+ const whoOf = (m) => m.who || srcName(m.source);
54
+ const askWord = (m) => (m.reply ? 'asks' : 'wrote');
55
+
56
+ /* ── the row on Home (XvANew .row) ── */
57
+ export function rowHtml(D, o = {}) {
58
+ const n = mentionsOf(D).fresh.length;
59
+ const sel = o.sel === 'mentions';
60
+ return `<div class="hv-card hr-card hr-men-card"><div class="hm-r hv-r hr-men${sel ? ' sel' : ''}${n ? ' new' : ''}" data-id="mentions">`
61
+ + `<button type="button" class="hm-rm" data-hr-mentions${sel ? ' aria-current="true"' : ''} aria-label="Mentions${n ? ', ' + n + ' new' : ''}">`
62
+ + '<span class="hv-mk hr-at" aria-hidden="true">@</span><span class="hm-rt"><b>Mentions</b></span>'
63
+ + (n ? `<span class="hv-st hr-new">${n} new</span>` : '') + '<span class="hv-xc" aria-hidden="true"></span></button></div></div>';
64
+ }
65
+
66
+ /* ── the Mentions Viewer (XvANew .vw) ── */
67
+ function itemHtml(m, now) {
68
+ const head = [whoOf(m), placeOf(m), m.at ? age(m.at, now) + ' ago' : ''].filter(Boolean).join(' · ');
69
+ const sub = [m.text ? '“' + clip(m.text, 120) + '”' : '', m.checks && m.checks[0] ? 'I checked: ' + clip(m.checks[0], 80) : ''].filter(Boolean).join(' · ');
70
+ return `<button type="button" class="hr-mi" data-hr-mi="${esc(m.id)}" aria-label="${esc(whoOf(m) + ', ' + placeOf(m) + '. Open')}">`
71
+ + `<span class="hr-mdot${m.read ? ' read' : ''}" aria-hidden="true"></span><span class="hr-mw"><b>${esc(head)}</b>${sub ? `<span>${esc(sub)}</span>` : ''}</span>`
72
+ + `<span class="hr-mcv">${svg('M10 7l5 5-5 5', 15)}</span></button>`;
73
+ }
74
+ function listHtml(ctx) {
75
+ const now = Date.now();
76
+ const { fresh, earlier } = mentionsOf(ctx.D());
77
+ const n = fresh.length;
78
+ const end = (t) => (/[.?!…]”?$/.test(t) ? t : t + '.');
79
+ const said = fresh.slice(0, 2).map((m) => end(first(whoOf(m)) + ' ' + askWord(m) + (m.text ? ' “' + clip(m.text, 70) + '”' : ' something'))).join(' ');
80
+ const sum = n
81
+ ? VW.czSummary({ line: n + ' new since this morning', tone: 'you', text: said + (n > 2 ? ' And ' + (n - 2) + ' more.' : ''), primary: { label: 'Reply to ' + first(whoOf(fresh[0])), act: 'reply' } })
82
+ : VW.czSummary({ text: earlier.length ? 'Nothing new. What you already read today is under Earlier.' : 'Nobody has mentioned you today.' });
83
+ const secs = VW.czSections([
84
+ n ? { id: 'new', title: 'New', count: n, open: true, html: '<div class="hr-ml">' + fresh.map((m) => itemHtml(m, now)).join('') + '</div>' } : null,
85
+ earlier.length ? { id: 'earlier', title: 'Earlier', count: earlier.length, open: false, html: '<div class="hr-ml">' + earlier.map((m) => itemHtml(m, now)).join('') + '</div>' } : null,
86
+ ], { key: 'mentions' });
87
+ return '<div class="hr-vb">' + sum + secs + '</div>';
88
+ }
89
+ export function openMentions(ctx) {
90
+ sheet();
91
+ const draw = (b) => {
92
+ b.innerHTML = listHtml(ctx);
93
+ b.onclick = (e) => {
94
+ const t = e.target.closest('[data-hr-mi],[data-czs-act]'); if (!t || !b.contains(t)) return;
95
+ const { all, fresh } = mentionsOf(ctx.D());
96
+ if (t.dataset.hrMi) { const m = all.find((x) => x.id === t.dataset.hrMi); if (m) openOne(m, ctx, { back: true }); return; }
97
+ if (t.dataset.czsAct === 'reply' && fresh[0]) ctx.draft(fresh[0]);
98
+ };
99
+ };
100
+ const { fresh } = mentionsOf(ctx.D());
101
+ return VW.open({ id: 'mentions', kind: 'Mentions', title: 'Mentions', icon: 'spark', render: draw,
102
+ more: fresh.length ? [{ label: 'Mark all read', on: () => markAll(ctx) }] : [] });
103
+ }
104
+ async function markAll(ctx) {
105
+ const { fresh } = mentionsOf(ctx.D());
106
+ let ok = 0;
107
+ for (const m of fresh) { const r = await ctx.pmPost('/api/mentions/read', { id: m.id, read: true }); if (r && r.ok) { m.read = true; ok++; } }
108
+ ctx.toast(ok === fresh.length ? 'Marked read.' : 'Marked ' + ok + ' of ' + fresh.length + ' read. The server did not take the rest.');
109
+ if (VW.current() && VW.current().id === 'mentions') openMentions(ctx);
110
+ ctx.reload();
111
+ }
112
+
113
+ /* ── one mention (XvAMention, XvAMentionJira, XvAMentionDoc, XvAMentionMail) ── */
114
+ const hm = (at) => { const t = Date.parse(at || ''); if (!Number.isFinite(t)) return ''; const d = new Date(t); return String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
115
+ const ini2 = (who) => esc(String(who || '?').replace(/[^A-Za-z]/g, '').slice(0, 2) || '?');
116
+ const msgHtml = (x, me) => `<div class="hr-msg${me ? ' me' : ''}"><span class="hr-av" aria-hidden="true">${ini2(x.who)}</span><span class="hr-w"><small><b>${esc(x.who || 'Someone')}</b>${hm(x.at) ? ' · ' + hm(x.at) : ''}</small><span>${esc(x.text)}</span></span></div>`;
117
+ /** The source excerpt, with the mention outlined. Only what the record holds: the thread when the brief kept it, else the mention's words. */
118
+ export function excerptHtml(m) {
119
+ const own = { who: whoOf(m), at: m.at, text: m.text || '' };
120
+ const thread = Array.isArray(m.thread) && m.thread.length ? m.thread : null;
121
+ // the mention in the thread: the last message of its author (the server keeps the author's last time as m.at)
122
+ let at = -1;
123
+ if (thread) for (let i = thread.length - 1; i >= 0; i--) if (!m.who || thread[i].who === m.who) { at = i; break; }
124
+ const msgs = thread ? thread.map((x, i) => msgHtml(i === at && !x.text ? { ...x, text: m.text } : x, i === at)).join('') + (at < 0 && m.text ? msgHtml(own, true) : '') : msgHtml(own, true);
125
+ if (m.source === 'jira') return `<div class="hr-tkt">${m.where ? `<div class="hr-kv"><span>${esc(m.where)}</span></div>` : ''}${msgs}</div>`;
126
+ if (isMail(m.source)) return `<div class="hr-mail">${m.where ? `<b>${esc(m.where)}</b>` : ''}<span>${esc([whoOf(m), hm(m.at), thread && thread.length > 1 ? thread.length + ' messages' : ''].filter(Boolean).join(' · '))}</span></div>`
127
+ + (m.text ? `<div class="hr-quote">${esc(m.text)}</div>` : '');
128
+ if (isDoc(m.source)) return msgs;
129
+ return `<div class="hr-thr">${msgs}</div>`;
130
+ }
131
+ const checksHtml = (m) => (Array.isArray(m.checks) && m.checks.length
132
+ ? `<div class="hr-chk"><b>What I checked</b>${m.checks.map((c) => `<div class="hr-cl"><span class="hr-ok">${svg(TICK, 15, 2.2)}</span><span>${esc(c)}</span></div>`).join('')}</div>` : '');
133
+ function oneHtml(m, ctx) {
134
+ const a = age(m.at);
135
+ const line = m.reply ? 'Waiting on you' + (a ? ' · ' + a : '') : 'Mentioned you' + (a ? ' · ' + a + ' ago' : '');
136
+ const text = whoOf(m) + (m.reply ? ' asks you something in ' : ' named you in ') + placeOf(m) + '.';
137
+ const meta = [m.initiative ? ctx.iniTitle(m.initiative) : '', m.where && !isMail(m.source) ? m.where : ''].filter(Boolean).join(' · ');
138
+ const sum = VW.czSummary({ line: m.read ? line + ' · read' : line, tone: m.reply && !m.read ? 'warn' : '', text, meta, primary: { label: 'Draft a reply', act: 'draft' } });
139
+ const link = https(m.link);
140
+ const secs = VW.czSections([
141
+ link ? { id: 'src', title: 'Open in ' + srcName(m.source), on: 'src' } : null,
142
+ m.initiative ? { id: 'ini', title: ctx.iniTitle(m.initiative), count: ctx.stageOf(m.initiative) || '', on: 'ini' } : null,
143
+ ], { key: 'mention' });
144
+ return '<div class="hr-vb">' + sum + excerptHtml(m) + checksHtml(m) + secs + '</div>';
145
+ }
146
+ const taskLine = (m) => (m.reply ? 'Reply to ' + first(whoOf(m)) + ' (' + srcName(m.source) + ') by today' : 'Read ' + first(whoOf(m)) + '\'s note (' + srcName(m.source) + ')');
147
+ export function openOne(m, ctx, o = {}) {
148
+ sheet();
149
+ const more = () => [
150
+ { label: 'Make it a task', on: async () => {
151
+ const r = await ctx.pmPost('/api/pm-items/add', { line: taskLine(m) });
152
+ ctx.toast(r && r.ok !== false ? 'Added to your tasks: ' + taskLine(m).replace(/ by today$/, '') : 'That did not go through' + (r && r.error ? ': ' + r.error : '.'));
153
+ if (r && r.ok !== false) ctx.reload();
154
+ } },
155
+ { label: m.read ? 'Mark unread' : 'Mark read', on: async () => {
156
+ const to = !m.read;
157
+ const r = await ctx.pmPost('/api/mentions/read', { id: m.id, read: to });
158
+ if (!r || !r.ok) { ctx.toast('That did not go through' + (r && r.error ? ': ' + r.error : '.')); return; }
159
+ m.read = to; ctx.toast(to ? 'Marked read.' : 'Marked unread.');
160
+ const c = VW.current(); if (c && c.id === 'mention:' + m.id) openOne(m, ctx, { _again: true });
161
+ ctx.reload();
162
+ } },
163
+ ];
164
+ const draw = (b) => {
165
+ b.innerHTML = oneHtml(m, ctx);
166
+ b.onclick = (e) => {
167
+ const t = e.target.closest('[data-czs-act]'); if (!t || !b.contains(t)) return;
168
+ const k = t.dataset.czsAct;
169
+ if (k === 'draft') ctx.draft(m);
170
+ else if (k === 'src') { const l = https(m.link); if (l) window.open(l, '_blank', 'noopener'); }
171
+ else if (k === 'ini') ctx.goIni(m.initiative);
172
+ };
173
+ };
174
+ const args = { id: 'mention:' + m.id, kind: 'Mention', title: whoOf(m) + ' · ' + placeOf(m), icon: ICON[m.source] || 'at', render: draw, more: more() };
175
+ // Mark read redraws in place: the item is replaced by itself, so ← still goes back to the list behind it
176
+ if (o._again) return VW.open({ ...args, back: false, _back: true });
177
+ return VW.open({ ...args, back: !!o.back });
178
+ }
179
+
180
+ /* ── the look: cozy-home-rows.css, loaded once ── */
181
+ export function sheet() {
182
+ if (typeof document === 'undefined' || document.getElementById('czHomeRowsCss')) return;
183
+ const l = document.createElement('link'); l.id = 'czHomeRowsCss'; l.rel = 'stylesheet';
184
+ try { l.href = new URL('./cozy-home-rows.css', import.meta.url).href; } catch { l.href = '/pm/cozy-home-rows.css'; }
185
+ document.head.appendChild(l);
186
+ }
187
+ sheet();
@@ -0,0 +1,67 @@
1
+ /* pm/home-rec-row.js — the pinned recording row at the very top of Home (Viewer kit; canvas XvARecHome).
2
+ *
3
+ * While a meeting records, a row sits above @Mentions: a red outline, a red dot, the meeting's title and "Recording · 12:40", and the
4
+ * clock ticks. It stays while the PM opens other items. A press opens the live meeting (data-hm-recopen, which home-app.js already opens
5
+ * in place). Paused: "Paused · 12:40", quieter, and the clock stands still. With no recording there is no row.
6
+ *
7
+ * mountRecRow({ notes, refresh, redraw }) → { html() }
8
+ * notes() the notes Home already reads (premium-meeting.js recCore().notes()), the fallback while rec-state.js is not on the page
9
+ * refresh() reads the notes again (every 10 s while rec-state.js is not on the page)
10
+ * redraw() Home draws its list again: called when the recording starts, pauses, resumes, stops or changes its title
11
+ *
12
+ * The state comes from rec-state.js (onRecording, the meetings workstream) when the page has it, else from the notes, read by the same rule
13
+ * (a note recording or paused; meeting_ms is the meeting time heard). Nothing is written here. */
14
+ import { sheet } from './home-mentions.js';
15
+
16
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
+ const OFF = { on: false, paused: false, id: '', title: '', elapsedMs: 0, readAt: 0 };
18
+
19
+ /** The recording now, from a list of notes (pure; the rule of rec-state.js stateOf). */
20
+ export function stateOfNotes(rows, now = Date.now()) {
21
+ const live = (Array.isArray(rows) ? rows : []).filter((n) => n && (n.state === 'recording' || n.state === 'paused'));
22
+ if (!live.length) return { ...OFF, readAt: now };
23
+ const n = live.find((x) => x.state === 'recording') || live[0];
24
+ return { on: true, paused: n.state === 'paused', id: String(n.id), title: String((n.meeting && n.meeting.title) || n.title || 'Meeting'), elapsedMs: Math.max(0, Number(n.meeting_ms) || 0), readAt: now };
25
+ }
26
+ /** "12:40", or "1:02:40" past the hour. */
27
+ export function clockOf(ms) {
28
+ const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)), h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60), x = String(s % 60).padStart(2, '0');
29
+ return h ? h + ':' + String(m).padStart(2, '0') + ':' + x : m + ':' + x;
30
+ }
31
+ const elapsed = (st, now = Date.now()) => st.elapsedMs + (st.paused ? 0 : Math.max(0, now - (st.readAt || now)));
32
+ /** The row's markup for a state; '' when nothing records. Pure. */
33
+ export function recRowHtml(st, now = Date.now()) {
34
+ if (!st || !st.on) return '';
35
+ const word = st.paused ? 'Paused' : 'Recording';
36
+ return `<div class="hv-card hr-card hr-rec-card${st.paused ? ' paused' : ''}"><div class="hm-r hv-r hr-rec" data-id="rec:${esc(st.id)}">`
37
+ + `<button type="button" class="hm-rm" data-hm-recopen="${esc(st.id)}" aria-label="${esc(st.title)}. ${word}. Open the meeting">`
38
+ + `<span class="hv-mk"><span class="hr-rdot" aria-hidden="true"></span></span><span class="hm-rt"><b>${esc(st.title)}</b></span>`
39
+ + `<span class="hv-st hr-rst">${word} · <span data-hr-clock>${clockOf(elapsed(st, now))}</span></span><span class="hv-xc" aria-hidden="true"></span></button></div></div>`;
40
+ }
41
+
42
+ export function mountRecRow({ notes, refresh, redraw } = {}) {
43
+ sheet();
44
+ let live = null; // the state rec-state.js gave, once it answers; null: read the notes
45
+ let seen = '';
46
+ const fromNotes = () => {
47
+ const st = stateOfNotes(typeof notes === 'function' ? notes() : []);
48
+ // the notes carry no read time of their own: the clock runs from the first time this page saw this stretch of the recording
49
+ if (st.on && !st.paused) { const k = st.id + ':' + st.elapsedMs; if (fromNotes.k !== k) { fromNotes.k = k; fromNotes.at = Date.now(); } st.readAt = fromNotes.at; }
50
+ return st;
51
+ };
52
+ const state = () => live || fromNotes();
53
+ const changed = (st) => { const k = st.on ? [st.id, st.paused, st.title].join('|') : ''; if (k === seen) return false; seen = k; return true; };
54
+ import('./rec-state.js').then((M) => {
55
+ M.onRecording((st) => { live = st && typeof st === 'object' ? st : null; if (changed(state()) && redraw) redraw(); });
56
+ }).catch(() => { // not on this page yet: the notes answer, read again every 10 s
57
+ if (typeof refresh === 'function') setInterval(() => { if (!document.hidden) Promise.resolve(refresh()).then(() => { if (changed(state()) && redraw) redraw(); }).catch(() => {}); }, 10000);
58
+ });
59
+ setInterval(() => { // the clock ticks in place; the list is not drawn again for it
60
+ const st = state();
61
+ if (changed(st) && redraw) { redraw(); return; }
62
+ if (!st.on || st.paused) return;
63
+ const t = clockOf(elapsed(st));
64
+ document.querySelectorAll('[data-hr-clock]').forEach((el) => { if (el.textContent !== t) el.textContent = t; });
65
+ }, 1000);
66
+ return { html: () => { const st = state(); changed(st); return recRowHtml(st); }, state };
67
+ }
@@ -53,26 +53,36 @@ export function openReview(h) {
53
53
  if (key === 'untouched') { const R = reviewModel(h.D(), h.now()); return plural(Object.keys(R.kept || {}).length, 'looked at', 'looked at'); }
54
54
  return st.picked.size ? st.picked.size + ' picked' : 'None picked';
55
55
  }
56
+ // shell A (canvas XvAReview): the summary card names the step on now, says what it asks, and holds the one primary (Continue);
57
+ // each step is a folding row: a done step shows its note, the step on now is open with its rows, a later step waits.
58
+ const ASK = {
59
+ sort: (R) => { const n = tab('inbox').concat(tab('tray')).length; return n ? plural(n, 'thing came in that is', 'things came in that are') + ' not placed. Put each in Today, or keep it.' : 'Nothing came in that is not placed.'; },
60
+ wait: () => { const n = (work() && work().waiting ? work().waiting.rows : []).length; return n ? plural(n, 'thing is', 'things are') + ' owed to you. Mark what came in.' : 'Nobody owes you anything.'; },
61
+ untouched: () => { const n = staleInis(h.D(), h.now()).length; return n ? plural(n, 'initiative has', 'initiatives have') + ' not moved for two weeks. Keep them going, or ask in chat.' : 'Nothing has sat untouched for 14 days.'; },
62
+ pick: () => "Pick next week's three. Each one becomes P1 on your list.",
63
+ };
56
64
  const draw = (b) => {
57
65
  const R = reviewModel(h.D(), h.now());
58
- const steps = R.steps.map((s) => {
59
- if (s.done) return `<div class="ut-step"><span class="ut-chk on">${svg(P.check, 12)}</span><b>${esc(s.label)}</b><span class="ut-small ut-mut">${esc(s.note)}</span></div>`;
60
- if (s.now) return `<div class="ut-step now" role="group" aria-label="${esc(s.label)}, now"><div class="h"><span class="ut-chk"></span><b>${esc(s.label)}</b><span class="ut-small ut-bl"><b>Now</b></span></div>`
61
- + `<div>${stepBody(s, R)}</div><div class="ut-acts"><button type="button" class="ut-btn sm pri" data-rv-step="${s.key}"${st.busy ? ' disabled' : ''}>Done with this step</button></div></div>`;
62
- return `<div class="ut-step later"><span class="ut-chk"></span><b>${esc(s.label)}</b></div>`;
63
- }).join('');
66
+ const at = R.steps.findIndex((s) => s.now), left = R.steps.filter((s) => !s.done).length;
67
+ const now = at >= 0 ? R.steps[at] : null;
64
68
  const last = R.last ? 'Last review: ' + dayLabel(R.last.week) + (R.last.minutes ? ' · ' + plural(R.last.minutes, 'minute', 'minutes') : '') : 'This is your first weekly review here.';
65
- b.innerHTML = `<div class="ut-vc">${tabsHtml('review')}<div><h2 class="ut-h2">Weekly review · ${esc(R.label)}</h2><p class="ut-sub">${R.done ? 'Done for this week. Each step kept what you decided.' : 'Four short steps. Each one keeps what you decided.'}</p></div>`
66
- + `<div class="cz-ladder" role="img" aria-label="${R.steps.filter((x) => x.done).length} of 4 steps done">${R.steps.map((s) => `<i class="${s.done ? 'done' : s.now ? 'now' : ''}"></i>`).join('')}</div>`
67
- + `<div class="ut-steps">${steps}</div><p class="ut-small ut-mut" role="status" id="rvMsg">${esc(st.msg)}</p><p class="ut-small ut-mut ut-foot">${esc(last)}</p></div>`;
69
+ const sum = h.VW.czSummary({ line: R.done ? 'Done for this week' : now ? 'Step ' + (at + 1) + ' of ' + R.steps.length : '', tone: R.done ? 'ok' : 'you',
70
+ text: R.done ? 'Each step kept what you decided.' : now ? (ASK[now.key] || ASK.pick)(R) : 'Four short steps. Each one keeps what you decided.',
71
+ meta: R.done ? last : 'About ' + plural(left * 3, 'minute', 'minutes') + ' left · ' + last,
72
+ primary: now ? { label: 'Continue', act: 'step:' + now.key, disabled: st.busy } : null });
73
+ const secs = h.VW.czSections(R.steps.map((s) => ({ id: s.key, title: s.label, count: s.done ? s.note || 'done' : '', open: !!s.now,
74
+ html: s.now ? `<div class="ut-steps1">${stepBody(s, R)}</div>` : '' })), { key: 'review:' + R.label });
75
+ b.innerHTML = sum + `<div class="cz-ladder" role="img" aria-label="${R.steps.filter((x) => x.done).length} of 4 steps done">${R.steps.map((s) => `<i class="${s.done ? 'done' : s.now ? 'now' : ''}"></i>`).join('')}</div>`
76
+ + secs + `<p class="ut-small ut-mut" role="status" id="rvMsg">${esc(st.msg)}</p>`;
68
77
  };
69
- const body = h.VW.open({ id: 'review', kind: 'Weekly review', title: 'Weekly review', icon: 'list', render: draw });
78
+ const body = h.VW.open({ id: 'review', kind: 'Weekly review', title: 'Weekly review · ' + reviewModel(h.D(), h.now()).label, icon: 'list', render: draw });
70
79
  const say = (m) => { st.msg = m; const el = body.querySelector('#rvMsg'); if (el) el.textContent = m; };
71
80
  const post = async (path, b) => { const r = await h.pmPost(path, b).catch(() => null); if (!r || r.ok !== true) { say((r && r.error) || 'Nothing was changed.'); return null; } return r; };
72
81
  const redraw = async () => { await h.reload(); if (body.isConnected) draw(body); };
73
82
  body.onclick = async (e) => {
74
83
  const b = e.target.closest('button'); if (!b || b.disabled) return;
75
84
  const d = b.dataset;
85
+ if (/^step:/.test(d.czsAct || '')) d.rvStep = d.czsAct.slice(5); // the summary's Continue is the step's own Done
76
86
  if (d.rvToday) { if (await post('/api/pm-items/flag', { id: d.rvToday, flagged: true })) { st.done[d.k] = 'today'; draw(body); } return; }
77
87
  if (d.rvKeep) { if (await post('/api/pm-items/keep', { id: d.rvKeep })) { st.done[d.k] = 'kept'; draw(body); } return; }
78
88
  if (d.rvDone) { if (await post('/api/pm-items/done', { id: d.rvDone })) { st.done[d.k] = 'done'; draw(body); } return; }
@@ -20,7 +20,10 @@ export function dueText(iso, now = Date.now()) {
20
20
  const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso); return 'Due ' + +m[3] + ' ' + MON[+m[2] - 1];
21
21
  }
22
22
 
23
- /** h: { VW, pmPost, toast, now, ws, board, iniTitle(id), docs(id) → [{ title, path }], openIni(id), openDoc(doc), askInChat(task), openRecord(task), onChange() } */
23
+ /** h: { VW, pmPost, toast, now, ws, board, iniTitle(id), docs(id) → [{ title, path }], openIni(id), openDoc(doc), askInChat(task), openRecord(task), onChange() }
24
+ * Shell A (canvas XvATask): the summary card says when it is due, quotes the task's words, says where it sits, and holds the one primary
25
+ * (Talk it through in chat) with Done as a quiet check beside it. "Needs" folds below: the initiative, its documents and the Jira item.
26
+ * The status moves and the task's record are under ⋯ (the xvMore note: change it, then look back). */
24
27
  export function openTask(task, h) {
25
28
  const st = { msg: '', busy: false };
26
29
  const t = task;
@@ -28,21 +31,21 @@ export function openTask(task, h) {
28
31
  const now = h.now ? h.now() : Date.now();
29
32
  const done = t.status === 'Done';
30
33
  const due = dueText(t.end, now);
31
- const where = [h.iniTitle(t.ini), 'task', due === 'No date' ? '' : due.replace(/^Due /, '').toLowerCase(), t.owner && !/^(pm|you)(:|$)/i.test(t.owner) ? 'with ' + t.owner : ''].filter(Boolean).join(' · ');
34
+ const late = /late/.test(due), today = due === 'Due today';
35
+ const where = [h.iniTitle(t.ini), t.status && t.status !== 'To do' ? t.status.toLowerCase() : '', t.owner && !/^(pm|you)(:|$)/i.test(t.owner) ? 'with ' + t.owner : ''].filter(Boolean).join(' · ');
32
36
  const docs = (h.docs ? h.docs(t.ini) : []) || [];
33
- const need = [`<div class="ut-trow">${svg(P.flag, 16)}<span>${esc(h.iniTitle(t.ini))} <span class="ut-mut">· the initiative</span></span><button type="button" class="ut-btn sm soft" data-tk="ini">Open</button></div>`]
34
- .concat(docs.slice(0, 4).map((d, i) => `<div class="ut-trow">${svg(P.doc, 16)}<span>${esc(d.title)}</span><button type="button" class="ut-btn sm soft" data-tk-doc="${i}">Open</button></div>`))
35
- .concat(t.ref && t.src !== 'pmos' ? [`<div class="ut-trow">${svg(P.ticket, 16)}<span>${esc(t.ref)}</span></div>`] : []);
36
- b.innerHTML = `<div class="ut-vc">`
37
- + `<div class="ut-vh"><button type="button" class="hm-ck" data-tk="done" aria-label="${done ? 'Done' : 'Mark ' + esc(t.title) + ' done'}"${done ? ' disabled' : ''}><span class="ut-chk${done ? ' on' : ''}">${done ? svg(P.check, 12) : ''}</span></button>`
38
- + `<div><h2 class="ut-h2">${esc(t.title)}</h2><p class="ut-sub">${esc(where)}</p></div>`
39
- + `<button type="button" class="ut-ib" data-tk="record" aria-label="Open the task's record" title="The task's record">${svg(P.dots, 16, 'dots')}</button></div>`
40
- + `<div class="ut-chips"><span class="cz-chip${/late/.test(due) ? ' on' : ''}">${esc(due)}</span>${STATES.filter((x) => x !== 'Done').map((x) => `<button type="button" class="cz-chip${t.status === x ? ' on' : ' gh'}" data-tk-state="${esc(x)}" aria-pressed="${t.status === x}">${esc(x)}</button>`).join('')}</div>`
41
- + `<p class="ut-lbl">What you need for it</p><div>${need.join('')}</div>`
42
- + `<div class="ut-foot"><button type="button" class="ut-btn pri" data-tk="chat">Talk it through in chat</button><button type="button" class="ut-btn" data-tk="done"${done ? ' disabled' : ''}>Done</button></div>`
43
- + `<p class="ut-small ut-mut" role="status" id="tkMsg">${esc(st.msg)}</p></div>`;
37
+ const row = (icon, title, sub, attr) => `<button type="button" class="czs-it" ${attr}><span class="ut-tki" aria-hidden="true">${icon}</span><span class="w">${esc(title)}${sub ? `<span>${esc(sub)}</span>` : ''}</span></button>`;
38
+ const need = [row(svg(P.flag, 15), h.iniTitle(t.ini), 'the initiative', 'data-tk="ini"')]
39
+ .concat(docs.slice(0, 4).map((d, i) => row(svg(P.doc, 15), d.title, '', `data-tk-doc="${i}"`)))
40
+ .concat(t.ref && t.src !== 'pmos' ? [`<div class="czs-it"><span class="ut-tki j" aria-hidden="true">J</span><span class="w">${esc(t.ref)}</span></div>`] : []);
41
+ b.innerHTML = h.VW.czSummary({ line: done ? 'Done' : due === 'No date' ? '' : due, tone: done ? 'ok' : late || today ? 'warn' : '', text: t.note || t.text || '', meta: where,
42
+ primary: { label: 'Talk it through in chat', act: 'chat' }, also: [{ act: 'done', label: done ? 'Done' : 'Mark ' + t.title + ' done', icon: 'M5 12l4.5 4.5L19 7', disabled: done }] })
43
+ + h.VW.czSections([{ id: 'need', title: 'Needs', count: need.length, open: true, html: need.join('') }], { key: 'task' })
44
+ + `<p class="ut-small ut-mut" role="status" id="tkMsg">${esc(st.msg)}</p>`;
44
45
  };
45
- const body = h.VW.open({ id: 'task:' + t.uid, kind: 'Task', title: t.title, icon: 'M5 12l5 5 9-10', render: draw });
46
+ const more = () => STATES.filter((x) => x !== 'Done' && x !== t.status).map((x) => ({ label: 'Mark ' + x.toLowerCase(), on: () => setState(x) }))
47
+ .concat(h.openRecord ? [{ sep: true }, { label: "Open the task's record", on: () => h.openRecord(t) }] : []);
48
+ const body = h.VW.open({ id: 'task:' + t.uid, kind: 'Task', title: t.title, icon: 'task', more: more(), render: draw });
46
49
  const setState = async (state) => {
47
50
  if (st.busy) return; st.busy = true;
48
51
  const r = await h.pmPost('/api/boards/tasks/state', { ws: h.ws, board: t.board || h.board, task: t.uid, state }).catch(() => null);
@@ -50,18 +53,16 @@ export function openTask(task, h) {
50
53
  if (!r || r.ok !== true) { st.msg = (r && r.error) || 'The status did not change.'; draw(body); return; }
51
54
  t.status = state; st.msg = '';
52
55
  h.toast(state === 'Done' ? 'Done. It leaves your list.' : 'Now ' + state.toLowerCase() + '.');
53
- if (state === 'Done') h.VW.close(); else draw(body);
56
+ if (state === 'Done') h.VW.close(); else openTask(t, h);
54
57
  if (h.onChange) h.onChange();
55
58
  };
56
59
  body.onclick = (e) => {
57
60
  const b = e.target.closest('button'); if (!b || b.disabled) return;
58
- const k = b.dataset.tk;
59
- if (b.dataset.tkState) { if (b.dataset.tkState !== t.status) setState(b.dataset.tkState); return; }
61
+ const k = b.dataset.tk || b.dataset.czsAct;
60
62
  if (b.dataset.tkDoc != null && b.dataset.tkDoc !== '') { const d = (h.docs ? h.docs(t.ini) : [])[+b.dataset.tkDoc]; if (d && h.openDoc) h.openDoc(d); return; }
61
63
  if (k === 'done') setState('Done');
62
64
  else if (k === 'ini') h.openIni(t.ini);
63
65
  else if (k === 'chat') h.askInChat(t);
64
- else if (k === 'record' && h.openRecord) h.openRecord(t);
65
66
  };
66
67
  return body;
67
68
  }
@@ -94,7 +94,7 @@ function productHtml(g, o) {
94
94
  // open: the goal dots; folded: the tile's dot says something in it is yours (blue) or late (amber). No counts in words (HvAC)
95
95
  const say = [g.name, open ? (g.goals && g.goals.n ? g.goals.text : '') : [plural(g.count, 'initiative', 'initiatives'), yoursWords(g)].filter(Boolean).join(', ')].filter(Boolean).join(', ');
96
96
  const head = `<button type="button" class="hv-gh${open ? '' : ' closed'}" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(say)}. ${open ? 'Close' : 'Open'} the group">`
97
- + `<span class="hv-tl t${g.tone}" aria-hidden="true">${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b>${open ? dots(g) : ''}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button>`;
97
+ + `<span class="hv-tl t${g.tone}" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${esc(g.initials)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b>${open ? dots(g) : ''}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button>`;
98
98
  if (!open) return `<section class="hm-pg hv-g" aria-label="${esc(g.name)}">${head}</section>`;
99
99
  const pinned = (x) => (o.pin.has(x.key) ? 0 : 1);
100
100
  const flat = g.flat.slice().sort((a, b) => pinned(a) - pinned(b)).map((r) => rowHtml(r, o)).join('');
@@ -117,7 +117,7 @@ function programHtml(g, o) {
117
117
  const ms = nx ? `<span class="hv-msd${nx.late ? ' late' : ''}"><span class="hv-dm"></span>${esc(nx.day || nx.name)}${nx.n ? `<span class="hv-rd">${Array.from({ length: nx.n }, (_, i) => `<i${i < nx.ready ? ' class="on"' : ''}></i>`).join('')}</span>` : ''}</span>` : '';
118
118
  const line = nx ? 'Next milestone ' + nx.name + (nx.day ? ', ' + nx.day : '') + (nx.late ? ', late' : '') + (nx.n ? ', ' + nx.ready + ' of ' + nx.n + (nx.n === 1 ? ' initiative' : ' initiatives') + ' ready' : '') : 'No open milestone';
119
119
  const head = `<div class="hv-gh hv-prg${open ? '' : ' closed'}"><button type="button" class="hv-pt" data-hm-prog="${esc(g.program.id)}" aria-label="Open ${esc(g.name)}, a program">`
120
- + `<span class="hv-tl tp" aria-hidden="true">${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
120
+ + `<span class="hv-tl tp" aria-hidden="true" data-cz-rail-tile="${esc(g.key)}" data-cz-rail-name="${esc(g.name)}">${svg(P.layers, 16)}${open ? '' : nd(g)}</span><b>${esc(g.name)}</b></button>`
121
121
  + `<button type="button" class="hv-pf" data-hm-pg="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}. ${esc(line)}${g.yours ? '. ' + yoursWords(g) : ''}. ${open ? 'Close' : 'Open'} the group">${ms}<span class="hv-cv">${svg(open ? P.chevD : P.chevR, 16)}</span></button></div>`;
122
122
  if (!open) return `<section class="hm-pg hv-g prg" aria-label="${esc(g.name)}">${head}</section>`;
123
123
  const body = g.tasks.map((t) => rowHtml(t, o)).join('')
@@ -199,7 +199,7 @@ export function listHtml(M, T, o) {
199
199
  if (o.cap) body += `<form class="hm-cap" id="hmCapF"><label class="vh" for="hmCap">Add a task to your own list</label><input id="hmCap" autocomplete="off" maxlength="250" placeholder="A task for your own list. Esc to cancel">`
200
200
  + (o.mic ? `<button type="button" class="ut-ib" data-hm-capmic aria-label="Say it instead" title="Say it instead">${svg(P.mic, 16)}</button>` : '') + '</form>';
201
201
  }
202
- return head + card + `<div class="hv-body">${body}</div>`;
202
+ return head + card + `<div class="hv-body">${o.top || ''}${body}</div>`; // o.top: the pinned recording row and Mentions (home-rec-row.js, home-mentions.js)
203
203
  }
204
204
  /** Your day (HvAOpen): a sheet over the list from "Good morning". The date, the day's meetings and their load (a press opens the calendar,
205
205
  * or the day's moment card on a phone), Your move with its count, This week with the Weekly review (and the untouched work it looks at).