create-pmos 0.397.0 → 0.398.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 (145) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +101 -52
  8. package/workspace/briefing-premium-board-test.js +252 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +86 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  13. package/workspace/briefing-premium-initiative-test.js +159 -296
  14. package/workspace/briefing-premium-insights-test.js +337 -219
  15. package/workspace/briefing-premium-metrics-test.js +53 -97
  16. package/workspace/briefing-premium-products-test.js +40 -27
  17. package/workspace/briefing-premium-sources-test.js +66 -48
  18. package/workspace/briefing-premium-test.js +150 -647
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +12 -0
  21. package/workspace/fixtures/board-premium-trail.js +32 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  23. package/workspace/guide/briefing-premium.md +3 -1
  24. package/workspace/guide/home.md +47 -0
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/lib/agent-roles.js +71 -0
  27. package/workspace/lib/board-premium.js +85 -19
  28. package/workspace/lib/board-trail.js +223 -0
  29. package/workspace/lib/home-work-item.js +58 -0
  30. package/workspace/lib/insights-goals.js +196 -0
  31. package/workspace/lib/insights-premium.js +62 -14
  32. package/workspace/lib/insights-records.js +101 -0
  33. package/workspace/lib/jira-tickets.js +1 -1
  34. package/workspace/lib/route-modules.js +4 -0
  35. package/workspace/lib/routes-board-trail.js +33 -0
  36. package/workspace/lib/routes-home-desk.js +176 -0
  37. package/workspace/lib/routes-insights-premium.js +12 -3
  38. package/workspace/lib/routes-insights-records.js +129 -0
  39. package/workspace/lib/routes-notes.js +1 -0
  40. package/workspace/lib/routes-viewer.js +108 -0
  41. package/workspace/lib/transcript-steps.js +123 -0
  42. package/workspace/lib/viewer-meeting.js +205 -0
  43. package/workspace/lib/viewer-report.js +89 -0
  44. package/workspace/package-lock.json +2 -2
  45. package/workspace/package.json +1 -1
  46. package/workspace/premium-board-actions-test.js +85 -75
  47. package/workspace/premium-briefing-depth-test.js +66 -53
  48. package/workspace/premium-chat-attach-test.js +54 -63
  49. package/workspace/premium-chat-chart-tab-test.js +35 -37
  50. package/workspace/premium-chat-context-test.js +19 -18
  51. package/workspace/premium-chat-goal-view-test.js +23 -23
  52. package/workspace/premium-chat-notes-test.js +26 -31
  53. package/workspace/premium-chat-report-tab-test.js +32 -28
  54. package/workspace/premium-chat-term-test.js +16 -16
  55. package/workspace/premium-chat-viewer-test.js +60 -59
  56. package/workspace/premium-core-doc-issue-test.js +50 -43
  57. package/workspace/premium-html-viewer-test.js +14 -17
  58. package/workspace/premium-phone-card-test.js +7 -2
  59. package/workspace/premium-phone-room-test.js +41 -35
  60. package/workspace/premium-report-read-test.js +115 -197
  61. package/workspace/premium-viewer-download-test.js +19 -22
  62. package/workspace/premium-viewer-flicker-test.js +11 -16
  63. package/workspace/premium-viewer-share-test.js +6 -9
  64. package/workspace/premium-viewer-test.js +41 -60
  65. package/workspace/premium-vw-backlog-test.js +53 -33
  66. package/workspace/premium-vw-cal-test.js +82 -128
  67. package/workspace/premium-vw-copy-test.js +17 -33
  68. package/workspace/premium-vw-doc-test.js +11 -10
  69. package/workspace/premium-vw-item-test.js +50 -49
  70. package/workspace/premium-vw-jira-test.js +53 -27
  71. package/workspace/premium-vw-meet-test.js +118 -187
  72. package/workspace/premium-vw-notes-test.js +85 -108
  73. package/workspace/premium-vw-rec-test.js +72 -194
  74. package/workspace/premium-vw-slides-test.js +46 -50
  75. package/workspace/premium-welcome-test.js +3 -2
  76. package/workspace/premium-work-depth-test.js +61 -53
  77. package/workspace/public/pm/bd-acts.js +305 -0
  78. package/workspace/public/pm/bd-span.js +186 -82
  79. package/workspace/public/pm/bd-stages.js +25 -11
  80. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  81. package/workspace/public/pm/c3-md.js +3 -395
  82. package/workspace/public/pm/c3-phone-detail.js +1 -1
  83. package/workspace/public/pm/c3-phone-model.js +3 -68
  84. package/workspace/public/pm/chat-term.js +3 -3
  85. package/workspace/public/pm/cozy-board.css +497 -230
  86. package/workspace/public/pm/cozy-home.css +570 -142
  87. package/workspace/public/pm/cozy-home.js +5 -3
  88. package/workspace/public/pm/cozy-insights.css +296 -167
  89. package/workspace/public/pm/cozy-md.js +396 -0
  90. package/workspace/public/pm/cozy-nav.js +17 -6
  91. package/workspace/public/pm/cozy-placeholder.js +26 -0
  92. package/workspace/public/pm/cozy-viewer.css +3 -3
  93. package/workspace/public/pm/cozy-viewer.js +144 -0
  94. package/workspace/public/pm/cozy-vw.css +485 -0
  95. package/workspace/public/pm/cozy.css +83 -1
  96. package/workspace/public/pm/home-adddoc.js +48 -0
  97. package/workspace/public/pm/home-app.js +905 -0
  98. package/workspace/public/pm/home-around.js +515 -0
  99. package/workspace/public/pm/home-chat.js +459 -0
  100. package/workspace/public/pm/home-data.js +312 -0
  101. package/workspace/public/pm/home-draft.js +68 -0
  102. package/workspace/public/pm/home-more.js +249 -0
  103. package/workspace/public/pm/home-phone-card.js +109 -0
  104. package/workspace/public/pm/home-work.js +519 -0
  105. package/workspace/public/pm/phone-moment.js +69 -0
  106. package/workspace/public/pm/pm-work-view.js +1 -1
  107. package/workspace/public/pm/premium-attach.js +4 -0
  108. package/workspace/public/pm/premium-board.js +423 -394
  109. package/workspace/public/pm/premium-chart-tab.js +110 -62
  110. package/workspace/public/pm/premium-deck.js +3 -3
  111. package/workspace/public/pm/premium-first.js +25 -21
  112. package/workspace/public/pm/premium-insights.js +792 -568
  113. package/workspace/public/pm/premium-meeting.js +61 -549
  114. package/workspace/public/pm/premium-notes.js +1 -1
  115. package/workspace/public/pm/premium-report-frame.css +20 -0
  116. package/workspace/public/pm/premium-report-read.js +509 -480
  117. package/workspace/public/pm/premium-report-tab.js +87 -63
  118. package/workspace/public/pm/premium-shell.js +72 -119
  119. package/workspace/public/pm/premium-viewer.js +22 -1
  120. package/workspace/public/pm/premium-vw-cal.js +187 -48
  121. package/workspace/public/pm/premium-vw-doc.css +6 -0
  122. package/workspace/public/pm/premium-vw-doc.js +40 -2
  123. package/workspace/public/pm/premium-vw-file.js +2 -2
  124. package/workspace/public/pm/premium-vw-meet.js +6 -83
  125. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  126. package/workspace/public/pm/premium-vw-notes.js +56 -69
  127. package/workspace/public/pm/premium-vw-open.js +35 -0
  128. package/workspace/public/pm/premium-vw-page.js +16 -0
  129. package/workspace/public/pm/premium-vw-rec.js +11 -218
  130. package/workspace/public/pm/premium-vw-slides.css +5 -0
  131. package/workspace/public/pm/premium-vw-slides.js +44 -8
  132. package/workspace/public/pm/term-view.js +22 -0
  133. package/workspace/public/premium-board.html +28 -70
  134. package/workspace/public/premium-initiative.html +8 -48
  135. package/workspace/public/premium-insights.html +22 -60
  136. package/workspace/public/premium-viewer.html +20 -0
  137. package/workspace/public/premium.html +16 -107
  138. package/workspace/server.js +18 -3
  139. package/workspace/test-files.json +1 -0
  140. package/workspace/test-lists/home-libs.json +9 -0
  141. package/workspace/test-lists/premium-report-read.json +1 -1
  142. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  143. package/workspace/test-lists/premium-vw-notes.json +1 -1
  144. package/workspace/public/pm/premium-work.js +0 -729
  145. package/workspace/public/pm/premium.js +0 -1146
@@ -0,0 +1,249 @@
1
+ /* pm/home-more.js — the features the Agreed design does not draw yet, as plain minimal versions in the Viewer
2
+ * (initiative premium-agreed-design, Home: "keep every uncovered feature usable, in the cozy style, with a small Waiting for design marker").
3
+ *
4
+ * Each opens in the Viewer card (cozy-viewer.js), never the old dialog, and reads and writes through the routes the old pages used:
5
+ * openSettings() Updates (GET /api/kit/status, POST /api/kit/check|update|upgrade-app), Workspaces (GET|POST /api/workspaces, /forget),
6
+ * Connectors (GET|POST /api/proactive/settings)
7
+ * openSources() GET /api/sources, POST /api/sources/refresh and /refresh-all
8
+ * openMyWork(tab) home-work.js: Your list, Waiting on others, Weekly review, Untouched; an item's fields and agent; Focus and jobs;
9
+ * keys and swipe on the rows (GET /api/my-work-premium; the /api/pm-items, /api/pm-jobs and /api/my-work presses)
10
+ * openAround(key?) home-around.js: the agents' proposals, mentions, portfolio pulse, horizon scan, report found, data freshness, the prep
11
+ * line and today's digests (the old Briefing card's reads and presses)
12
+ * openEndOfDay() GET /api/phone-day: what finished today, the recap and tomorrow's meetings
13
+ * openProducts() which products Home reads (GET /api/briefing-premium products, POST /api/settings ws.briefing.include)
14
+ * openSearch() initiatives, core documents and sessions by name (GET /api/board-premium, /api/core-docs, /api/sessions)
15
+ * openInbox() the agents' results that wait on you (GET /api/inbox, POST /api/inbox/seen)
16
+ * openRecorder() a note recorded now with no calendar event (the Viewer's newNote, else POST /api/notes/new)
17
+ * moreItems the ⋯ menu's rows, [key, label, icon]
18
+ * Every write is the PM's press (pmPost carries the launch nonce). Nothing here sends anything outside PMOS. */
19
+ import { pmGet, pmPost } from './http.js';
20
+ import { open as vwOpen } from './cozy-viewer.js';
21
+
22
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
23
+ const wsQ = (pre = '?') => { const w = new URLSearchParams(location.search).get('ws'); return w ? pre + 'ws=' + encodeURIComponent(w) : ''; };
24
+ export const WAIT = '<p class="hx-wait"><i aria-hidden="true"></i>Waiting for design</p>';
25
+ const toast = (t) => { const el = document.getElementById('toast'); if (!el) return; el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
26
+ const when = (iso) => { const d = new Date(iso); if (Number.isNaN(d.getTime())) return ''; const p = (n) => String(n).padStart(2, '0'); return (d.toDateString() === new Date().toDateString() ? '' : d.getDate() + ' ' + d.toLocaleString('en-GB', { month: 'short' }) + ' ') + p(d.getHours()) + ':' + p(d.getMinutes()); };
27
+ const row = (title, sub, right = '') => `<div class="hx-row"><span class="hx-t"><b>${esc(title)}</b>${sub ? `<em>${esc(sub)}</em>` : ''}</span>${right}</div>`;
28
+ const btn = (label, attrs, pri) => `<button type="button" class="hx-b${pri ? ' pri' : ''}" ${attrs}>${esc(label)}</button>`;
29
+ const sec = (h, inner) => `<section class="hx-sec"><h4>${esc(h)}</h4>${inner}</section>`;
30
+ /** Open one feature in the Viewer: draw(body) is called again after each press. */
31
+ function card(o, draw) {
32
+ return vwOpen({ id: 'more:' + o.id, kind: o.kind, title: o.title, icon: o.icon, render: (body) => { body.classList.add('hx'); draw(body); } });
33
+ }
34
+
35
+ export const moreItems = [
36
+ ['work', 'My work', 'list'], ['around', 'Around you', 'info'], ['inbox', 'Agent results', 'list'], ['eod', 'End of the day', 'cal'],
37
+ ['cal', 'Calendar', 'cal'], ['rec', 'Record a note', 'mic'], ['search', 'Search', 'doc'], ['products', 'Products', 'chart'],
38
+ ['sources', 'Sources', 'source'], ['settings', 'Settings', 'gear'],
39
+ ];
40
+
41
+ /** The ⋯ list itself in the Viewer, for a page with no menu of its own: items are [label, open]. */
42
+ export function listCard(items) {
43
+ return card({ id: 'more', kind: 'More', title: 'Waiting for design', icon: 'list' }, (b) => {
44
+ b.innerHTML = WAIT + items.map(([l], i) => `<button type="button" class="hx-hit" data-i="${i}"><b>${esc(l)}</b></button>`).join('');
45
+ b.onclick = (e) => { const t = e.target.closest('[data-i]'); if (t && items[+t.dataset.i][1]) items[+t.dataset.i][1](); };
46
+ });
47
+ }
48
+
49
+ /* ── Settings ── */
50
+ const SRC = { calendar: 'Calendar', wispr: 'Wispr Flow', mail: 'Mail', slack: 'Slack', jira: 'Jira', confluence: 'Confluence', github: 'GitHub', drive: 'Google Drive', figma: 'Figma', website: 'Your websites' };
51
+ export function openSettings() {
52
+ const M = { ws: null, st: {}, src: null, con: {}, conn: [], msg: '', busy: false };
53
+ const draw = (b) => {
54
+ const home = M.ws && M.ws[0] ? M.st[M.ws[0].id] : null;
55
+ const latest = home && (home.latest || (home.lastCheck && home.lastCheck.latest));
56
+ const behind = M.ws ? M.ws.filter((w) => M.st[w.id] && M.st[w.id].kitBehind) : [];
57
+ const appBehind = !!(home && home.appBehind && !(home.app && home.app.fromCheckout));
58
+ const upd = !home ? '<p class="hx-n">Reading the versions.</p>'
59
+ : row('PMOS ' + ((home.app && home.app.version) || '?'), latest ? (appBehind || behind.length ? latest + ' is ready' : 'Up to date · the newest kit is ' + latest) : 'Press Check now to ask for the latest version',
60
+ btn('Check now', 'data-x="check"') + (appBehind || behind.length ? btn('Update', 'data-x="update"', true) : ''));
61
+ const ws = M.ws === null ? '<p class="hx-n">Reading the repositories.</p>' : M.ws.map((x) => row(x.label || x.name || x.id, (x.root || '') + (x.home ? ' · home' : ''), x.home ? '' : btn('Remove', `data-rm="${esc(x.id)}"`))).join('')
62
+ + '<div class="hx-add"><input id="hxRoot" placeholder="Folder path of a repository" aria-label="Folder path of a repository"><button type="button" class="hx-b pri" data-x="add">Add</button></div>';
63
+ const con = M.src === null ? '<p class="hx-n">Reading the connectors.</p>' : Object.keys(SRC).filter((k) => k in M.src).map((k) => row(SRC[k], M.src[k] ? 'Home reads it' : 'Home does not read it', `<button type="button" class="hx-sw" role="switch" aria-checked="${!!M.src[k]}" data-src="${k}">${M.src[k] ? 'On' : 'Off'}</button>`)).join('')
64
+ + M.conn.filter((c) => !c.source).map((c) => row(c.label, M.con[c.name] ? 'On' : 'Your sessions can use it', `<button type="button" class="hx-sw" role="switch" aria-checked="${!!M.con[c.name]}" data-conn="${esc(c.name)}">${M.con[c.name] ? 'On' : 'Off'}</button>`)).join('');
65
+ b.innerHTML = WAIT + sec('Updates', upd) + sec('Workspaces', ws) + sec('Connectors', con) + `<p class="hx-n" role="status">${esc(M.msg)}</p>`;
66
+ };
67
+ const body = card({ id: 'settings', kind: 'Settings', title: 'Settings', icon: 'gear' }, draw);
68
+ const load = async () => {
69
+ const [w, p] = await Promise.all([pmGet('/api/workspaces'), pmGet('/api/proactive/settings')]);
70
+ M.ws = w && Array.isArray(w.workspaces) ? w.workspaces : [];
71
+ await Promise.all(M.ws.map(async (x) => { const r = await pmGet('/api/kit/status?ws=' + encodeURIComponent(x.id)); if (r && r.ok) M.st[x.id] = r; }));
72
+ M.src = p && p.ok && p.settings ? { ...p.settings.briefSources } : {}; M.con = p && p.ok && p.settings ? { ...p.settings.connectors } : {};
73
+ M.conn = p && p.connectors && Array.isArray(p.connectors.list) ? p.connectors.list : [];
74
+ if (body.isConnected) draw(body);
75
+ };
76
+ body.onclick = async (e) => {
77
+ const t = e.target.closest('button'); if (!t || M.busy) return;
78
+ M.busy = true; M.msg = '';
79
+ try {
80
+ if (t.dataset.x === 'check') { for (const w of M.ws) { const r = await pmPost('/api/kit/check', { ws: w.id }); if (r && r.ok) M.st[w.id] = { ...M.st[w.id], ...r }; else M.msg = (r && r.error) || 'The check failed.'; } }
81
+ else if (t.dataset.x === 'update') {
82
+ const home = M.st[M.ws[0].id], v = home.latest || (home.lastCheck && home.lastCheck.latest);
83
+ for (const w of M.ws.filter((x) => M.st[x.id] && M.st[x.id].kitBehind)) { const r = await pmPost('/api/kit/update', { ws: w.id, version: v }); if (!(r && r.ok)) { M.msg = (r && r.error) || 'The kit was not updated.'; break; } M.st[w.id].kitBehind = false; }
84
+ if (!M.msg && home.appBehind) { const r = await pmPost('/api/kit/upgrade-app', { ws: M.ws[0].id, version: v }); M.msg = r && r.ok !== false ? 'Installing PMOS ' + v + '. Reload this page when it starts again.' : (r && r.error) || 'The update did not start.'; }
85
+ else if (!M.msg) M.msg = 'Updated the kits to ' + v + '.';
86
+ } else if (t.dataset.x === 'add') {
87
+ const root = (body.querySelector('#hxRoot').value || '').trim();
88
+ if (!root) M.msg = 'Paste the folder path of a repository.';
89
+ else { const r = await pmPost('/api/workspaces', { root, focus: false }); if (r && r.ok) M.ws = [...M.ws.filter((y) => y.id !== r.workspace.id), r.workspace]; else M.msg = (r && r.error) || 'Not added.'; }
90
+ } else if (t.dataset.rm) { const r = await pmPost('/api/workspaces/forget', { id: t.dataset.rm }); if (r && r.ok) { M.ws = M.ws.filter((y) => y.id !== t.dataset.rm); toast('Removed. The folder is untouched.'); } else M.msg = (r && (r.error || r.reason)) || 'Not removed.'; }
91
+ else if (t.dataset.src) { const k = t.dataset.src, on = !M.src[k]; const r = await pmPost('/api/proactive/settings', { briefSources: { [k]: on } }); if (r && r.ok) M.src[k] = on; else M.msg = (r && r.error) || 'Not saved.'; }
92
+ else if (t.dataset.conn) { const k = t.dataset.conn, on = !M.con[k]; const r = await pmPost('/api/proactive/settings', { connectors: { [k]: on } }); if (r && r.ok) M.con[k] = on; else M.msg = (r && r.error) || 'Not saved.'; }
93
+ } finally { M.busy = false; }
94
+ draw(body);
95
+ };
96
+ load();
97
+ return body;
98
+ }
99
+
100
+ /* ── Sources ── */
101
+ /** A read line: "<source> read HH:MM" for each id, from one GET /api/sources answer. ids name freshness rows ('initiatives', 'calendar', …)
102
+ * or derived content ('d:brief'). A source never read or failed says so. */
103
+ export function readLine(s, ids) {
104
+ if (!s || !s.ok) return '';
105
+ return ids.map((id) => {
106
+ const der = id.startsWith('d:'), x = der ? (s.derived || []).find((d) => d.id === id.slice(2)) : (s.sources || []).find((r) => r.id === id);
107
+ if (!x) return null;
108
+ const at = der ? x.at : x.as_of;
109
+ const w = x.state === 'failed' ? 'failed' : at ? (der ? 'built ' : 'read ') + when(at) : x.state === 'off' ? 'off' : der ? 'not built yet' : 'not read yet';
110
+ return (der ? ({ brief: 'Brief' })[x.id] || x.label : x.label) + ' ' + w;
111
+ }).filter(Boolean).join(' · ');
112
+ }
113
+ const SST = { fresh: 'Recent', stale: 'Old', never: 'Never read', building: 'Reading now', failed: 'Failed', off: 'Off' };
114
+ export function openSources() {
115
+ const M = { r: null, msg: '', busy: false };
116
+ const draw = (b) => {
117
+ const s = M.r;
118
+ const rows = !s ? '<p class="hx-n">Reading the sources.</p>' : !s.ok ? '<p class="hx-n">The sources could not be read.</p>'
119
+ : s.sources.map((x) => row(x.label, (SST[x.state] || x.state) + (x.as_of ? ' · read ' + when(x.as_of) : ''), x.id === 'repository' ? '' : btn('Refresh', `data-sref="${esc(x.id)}"${x.state === 'off' || x.state === 'building' || M.busy ? ' disabled' : ''}`))).join('');
120
+ const h = s && s.ok && s.health ? s.health : null, lv = h ? (h.level === 'bad' ? 'bad' : h.level === 'warn' ? 'warn' : 'ok') : '';
121
+ const health = h ? `<div id="srcHealth" class="hx-h ${esc(h.level)}" role="status"><p class="hx-n"><i class="sdot ${lv}" aria-hidden="true"></i>${esc(h.line)}</p>${(h.issues || []).slice(1, 4).map((i) => `<p class="hx-n">${esc(i.text)}</p>`).join('')}</div>` : '';
122
+ // which reads each part of Home shows, and when they were read (briefing-source-flow slice 5), from this same read
123
+ const shows = s && s.ok ? [['Today', readLine(s, ['calendar'])], ['Needs you', readLine(s, ['initiatives', 'my-work', 'd:brief'])]].filter((x) => x[1]) : [];
124
+ b.innerHTML = WAIT + health + (shows.length ? sec('What Home shows', shows.map(([k, v]) => `<p class="hx-n hx-reads" data-reads="${esc(k)}"><b>${esc(k)}:</b> ${esc(v)}</p>`).join('')) : '') + `<div class="hx-top"><p class="hx-n">Each source is read on its own schedule, not live. Refresh all reads every source, then writes Home's list from those reads.</p>${btn(s && s.all && !s.all.done ? 'Refreshing' : 'Refresh all', 'data-x="all"' + (M.busy ? ' disabled' : ''), true)}</div>`
125
+ + sec('Sources', rows) + `<p class="hx-n" role="status">${esc(M.msg)}</p>`;
126
+ };
127
+ const body = card({ id: 'sources', kind: 'Sources', title: 'Sources', icon: 'source' }, draw);
128
+ const read = async () => { M.r = await pmGet('/api/sources' + wsQ()); if (body.isConnected) draw(body); };
129
+ body.onclick = async (e) => {
130
+ const t = e.target.closest('button'); if (!t || M.busy || !M.r || !M.r.ok) return;
131
+ M.busy = true; draw(body);
132
+ const r = t.dataset.x === 'all' ? await pmPost('/api/sources/refresh-all', { ws: M.r.ws || '' }) : t.dataset.sref ? await pmPost('/api/sources/refresh', { ws: M.r.ws || '', source: t.dataset.sref }) : null;
133
+ M.busy = false; M.msg = r && r.ok ? 'Reading again.' : (r && r.error) || 'It did not start.';
134
+ await read(); setTimeout(read, 4000);
135
+ };
136
+ read();
137
+ return body;
138
+ }
139
+
140
+ /* ── My work ── */
141
+ /* ── My work ── the four tabs, the item with its fields and its agent, Focus and jobs, and the keys and swipe on the rows, in home-work.js */
142
+ export function openMyWork(tab = 'yours') { return import('./home-work.js').then((M) => M.openMyWork(tab)); }
143
+
144
+ /* ── Around you ── the six rows of the old Briefing card (agent proposals, mentions, portfolio pulse, horizon scan, report found, data freshness),
145
+ * the prep line and today's digests, in home-around.js. key opens one row's view at once. */
146
+ export function openAround(key) { return import('./home-around.js').then((M) => M.openAround(key)); }
147
+
148
+ /* ── End of the day ── */
149
+ export function openEndOfDay() {
150
+ const M = { r: null };
151
+ const draw = (b) => {
152
+ const r = M.r;
153
+ if (!r) { b.innerHTML = WAIT + '<p class="hx-n">Reading the day.</p>'; return; }
154
+ if (!r.ok) { b.innerHTML = WAIT + `<p class="hx-n">The day could not be read${r.error ? ': ' + esc(r.error) : ''}.</p>`; return; }
155
+ const fin = (r.finished || []).map((f) => row(f.title, f.status === 'review' ? 'Waits for your review' : f.status)).join('') || '<p class="hx-n">Nothing finished for you today.</p>';
156
+ const rec = r.recap ? (r.recap.moved || []).map((m) => row(m.text, m.sub)).join('') || '<p class="hx-n">No decision, done item or draft today.</p>' : '';
157
+ const tom = r.tomorrow ? (r.tomorrow.meetings || []).map((m) => row(m.title, new Date(m.start).toTimeString().slice(0, 5))).join('') || '<p class="hx-n">No meeting.</p>' : '';
158
+ b.innerHTML = WAIT + sec('Finished for you', fin) + sec('How the day went', rec) + sec(r.tomorrow ? 'Tomorrow · ' + r.tomorrow.label : 'Tomorrow', tom);
159
+ };
160
+ const body = card({ id: 'eod', kind: 'End of the day', title: 'Today and tomorrow', icon: 'cal' }, draw);
161
+ pmGet('/api/phone-day').then((r) => { M.r = r || { ok: false }; if (body.isConnected) draw(body); });
162
+ return body;
163
+ }
164
+
165
+ /* ── Products ── */
166
+ export function openProducts() {
167
+ const M = { P: null, head: '', msg: '' };
168
+ const one = new URLSearchParams(location.search).get('ws'); // Home narrowed to one workspace (?ws=): a way back to the picked products
169
+ const draw = (b) => {
170
+ const P = M.P, on = P ? P.available.filter((x) => x.on).length : 0;
171
+ b.innerHTML = WAIT + (M.head ? `<p class="hx-n" id="hxSnap">${esc(M.head)}</p>` : '')
172
+ + (one ? '<p class="hx-n">Home shows one workspace now. <a id="pickAll" href="/premium.html">All picked products</a></p>' : '')
173
+ + (!P ? '<p class="hx-n">Reading the products.</p>' : !P.available.length ? '<p class="hx-n">No product workspace is registered.</p>'
174
+ : sec('Home reads', `<p class="hx-n" id="hxCount">Products ${on} of ${P.available.length}</p>` + P.available.map((x) => row(x.name, x.home ? 'home' : '', `<button type="button" class="hx-sw" role="switch" aria-checked="${!!x.on}" aria-label="${esc(x.name)}${x.home ? ' (home)' : ''}" data-ws="${esc(x.ws)}">${x.on ? 'On' : 'Off'}</button>`)).join('') + btn('Back to the default', 'data-reset="1"')))
175
+ + `<p class="hx-n" role="status">${esc(M.msg)}</p>`;
176
+ };
177
+ const body = card({ id: 'products', kind: 'Products', title: 'Which products Home reads', icon: 'chart' }, draw);
178
+ const read = async () => {
179
+ const r = await pmGet('/api/briefing-premium');
180
+ M.P = r && r.ok && r.model ? r.model.products || { available: [] } : { available: [] };
181
+ M.head = r && r.ok && r.model && r.model.header ? r.model.header.text : ''; // what is read and what is not, from the records
182
+ if (body.isConnected) draw(body);
183
+ };
184
+ body.onclick = async (e) => {
185
+ const t = e.target.closest('button'); if (!t || !M.P) return;
186
+ const on = M.P.available.filter((x) => x.on).map((x) => x.ws);
187
+ const r = await pmPost('/api/settings', t.dataset.reset ? { key: 'ws.briefing.include', reset: true } : { key: 'ws.briefing.include', value: on.includes(t.dataset.ws) ? on.filter((x) => x !== t.dataset.ws) : on.concat(t.dataset.ws) });
188
+ M.msg = r && r.ok ? 'Saved. Home reads the products you picked.' : (r && r.error) || 'Not saved.';
189
+ read(); window.dispatchEvent(new CustomEvent('hm:reload'));
190
+ };
191
+ read();
192
+ return body;
193
+ }
194
+
195
+ /* ── Search ── */
196
+ export function openSearch(go) {
197
+ const M = { q: '', inis: [], docs: [], ses: [] };
198
+ const hit = (s) => String(s || '').toLowerCase().includes(M.q.toLowerCase());
199
+ const drawList = (b) => {
200
+ const L = b.querySelector('#hxRes'); if (!L) return;
201
+ if (M.q.length < 2) { L.innerHTML = '<p class="hx-n">Type two letters or more.</p>'; return; }
202
+ const a = M.inis.filter((r) => hit(r.title) || hit(r.id)).slice(0, 8).map((r) => `<button type="button" class="hx-hit" data-ini="${esc(r.id)}"><b>${esc(r.title)}</b><em>Initiative · ${esc(r.stage || '')}</em></button>`);
203
+ const d = M.docs.filter((x) => hit(x.title) || hit(x.path)).slice(0, 8).map((x) => `<button type="button" class="hx-hit" data-doc="${esc(x.path)}"><b>${esc(x.title)}</b><em>Document · ${esc(x.path)}</em></button>`);
204
+ const s = M.ses.filter((x) => hit(x.name) || hit(x.hx && x.hx.title)).slice(0, 8).map((x) => `<button type="button" class="hx-hit" data-ses="${esc(x.id)}"><b>${esc((x.hx && x.hx.title) || x.name)}</b><em>Session · ${esc(x.label || '')}</em></button>`);
205
+ L.innerHTML = [...a, ...d, ...s].join('') || '<p class="hx-n">Nothing matches.</p>';
206
+ };
207
+ const draw = (b) => { b.innerHTML = WAIT + '<label class="hx-q"><input type="search" id="hxQ" placeholder="Search initiatives, documents and sessions" aria-label="Search" autocomplete="off"></label><div id="hxRes"></div>'; drawList(b); const q = b.querySelector('#hxQ'); q.value = M.q; setTimeout(() => q.focus(), 0); };
208
+ const body = card({ id: 'search', kind: 'Search', title: 'Find anything', icon: 'doc' }, draw);
209
+ body.oninput = (e) => { if (e.target.id === 'hxQ') { M.q = e.target.value.trim(); drawList(body); } };
210
+ body.onclick = (e) => { const t = e.target.closest('.hx-hit'); if (!t || !go) return; go(t.dataset); };
211
+ Promise.all([pmGet('/api/board-premium' + wsQ()), pmGet('/api/core-docs?level=product' + wsQ('&')), pmGet('/api/sessions')]).then(([b, d, s]) => {
212
+ M.inis = b && b.ok && b.model ? ((b.model.initiatives && b.model.initiatives.list && b.model.initiatives.list.rows) || []) : [];
213
+ M.docs = d && d.ok ? (d.rows || d.docs || []).filter((x) => x.path) : [];
214
+ M.ses = s && Array.isArray(s.sessions) ? s.sessions.filter((x) => x.shown !== 'exited') : [];
215
+ if (body.isConnected) drawList(body);
216
+ });
217
+ return body;
218
+ }
219
+
220
+ /* ── the agents' results (the bell) ── */
221
+ export function openInbox(go) {
222
+ const M = { r: null };
223
+ const draw = (b) => {
224
+ const r = M.r;
225
+ b.innerHTML = WAIT + (!r ? '<p class="hx-n">Reading the agents\' results.</p>' : !r.ok ? '<p class="hx-n">The results could not be read.</p>'
226
+ : (r.items || []).length ? sec(r.count + ' wait on you', r.items.map((x) => row(x.title || x.text, [x.who, x.where, x.at ? when(x.at) : ''].filter(Boolean).join(' · '), (x.link ? btn('Open', `data-open="${esc(x.link)}"`) : '') + btn('Seen', `data-seen="${esc(x.id)}"`))).join('')) + btn('Mark all seen', 'data-all="1"')
227
+ : '<p class="hx-n">Nothing from the agents waits on you.</p>');
228
+ };
229
+ const body = card({ id: 'inbox', kind: 'Agent results', title: 'What the agents finished', icon: 'list' }, draw);
230
+ const read = async () => { M.r = await pmGet('/api/inbox'); if (body.isConnected) draw(body); };
231
+ body.onclick = async (e) => {
232
+ const t = e.target.closest('button'); if (!t) return;
233
+ if (t.dataset.open) { if (go) go({ link: t.dataset.open }); return; }
234
+ if (t.dataset.seen) await pmPost('/api/inbox/seen', { ids: [t.dataset.seen] });
235
+ if (t.dataset.all) await pmPost('/api/inbox/seen', { all: true });
236
+ read();
237
+ };
238
+ read();
239
+ return body;
240
+ }
241
+
242
+ /* ── record a note now ── */
243
+ export async function openRecorder() {
244
+ // the Viewer's registry (premium-vw-open.js): newNote starts an untitled note now, the recorder starts and the meeting card opens on it
245
+ await import('./premium-vw-open.js');
246
+ const ws = new URLSearchParams(location.search).get('ws') || '';
247
+ try { const r = await window.czViews.newNote({ ws }); if (r && r.ok === false && r.error) toast(r.error); return r; }
248
+ catch { toast('The note was not started.'); return null; }
249
+ }
@@ -0,0 +1,109 @@
1
+ /* pm/home-phone-card.js — the phone moment card, moved onto Home (initiative premium-agreed-design; the card itself is premium-phone-card,
2
+ * planning/prd/premium-phone-card-prd.md R1 to R5). The Agreed design has no place for it, so it stays usable at the top of the phone's
3
+ * "N need you" sheet with a "Waiting for design" marker. At 640 px and narrower only; a desktop never reads /api/phone-day.
4
+ * The moment comes from momentOf (c3-phone-model.js) over the /api/brief-page day and the clock; every line comes from /api/brief-page or
5
+ * /api/phone-day. Done and Undo press /api/pm-items/done and /reopen on the PM's own item; nothing is written on load.
6
+ * mountPhoneCard({ pmGet, pmPost, toast, ws, openMeeting, wait }) → { el, read } */
7
+ import { momentOf, inText } from './phone-moment.js';
8
+
9
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
10
+ const two = (n) => String(n).padStart(2, '0');
11
+ const hm = (iso) => { const d = new Date(iso); return two(d.getHours()) + ':' + two(d.getMinutes()); };
12
+ const first = (n) => String(n || '').trim().split(/\s+/)[0];
13
+ const who = (m) => (m.people && m.people.length ? m.people.map(first).join(', ') : '');
14
+ const num = (n, one, many) => (n === 1 ? '1 ' + one : (n || 0) + ' ' + many);
15
+ const CHECK = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12l5 5 9-10"/></svg>';
16
+ const PHONE = '(max-width:640px)';
17
+
18
+ export function mountPhoneCard(o) {
19
+ const P = { page: null, day: null, dayAt: 0, dec: new Map(), err: {}, busy: '' };
20
+ const on = () => matchMedia(PHONE).matches;
21
+ const el = document.createElement('section');
22
+ el.className = 'hm-phc'; el.id = 'phoneCard'; el.hidden = true; el.setAttribute('aria-label', 'Now');
23
+
24
+ const own = () => ((P.page && P.page.ok && P.page.needs) || []).filter((n) => n && n.id && (n.kind === 'overdue' || n.kind === 'due-today'))
25
+ .map((n) => ({ id: n.id, headline: n.headline, label: n.kind === 'overdue' ? (n.days_late === 1 ? '1 day late' : n.days_late + ' days late') : 'Due today', kind: n.kind, looks: !!(n.evidence && n.evidence.text) }));
26
+ const btn = (label, act, id, alt) => `<button type="button" class="cta${alt ? ' alt' : ''}" data-pha="${act}"${id != null ? ` data-id="${esc(id)}"` : ''}>${esc(label)}</button>`;
27
+ const item = (n) => {
28
+ const act = P.dec.has(n.id) ? `<p class="phok" role="status">${CHECK}<span>Done.</span></p><div class="phacts">${btn('Undo', 'phundo', n.id, true)}</div>` : `<div class="phacts">${btn(n.looks ? 'Confirm done' : 'Done', 'phdone', n.id)}</div>`;
29
+ return `<div class="phfit" data-id="${esc(n.id)}"><span class="label">${esc(n.label)}</span><b class="phtt">${esc(n.headline)}</b>${act}${P.err[n.id] ? `<p class="pherr" role="alert">${esc(P.err[n.id])}</p>` : ''}</div>`;
30
+ };
31
+ const items = (list) => list.concat([...P.dec.values()].filter((x) => !list.some((y) => y.id === x.id))).map(item).join('');
32
+ const open = (m) => btn('Open the meeting', 'phopen', m.id, true);
33
+ const big = (t) => `<b class="phbig">${esc(t)}</b>`;
34
+ const L = (t) => `<p class="phl">${esc(t)}</p>`, S = (t) => `<p class="phs">${esc(t)}</p>`;
35
+ const dayErr = () => (P.day && P.day.ok === false ? S('Today could not be read: ' + P.day.error + '.') : !P.day ? S('Reading your day.') : '');
36
+
37
+ function moment(mo) {
38
+ const m = mo.meeting, mine = own(), day = P.day && P.day.ok !== false ? P.day : null, fin = day ? day.finished || [] : [];
39
+ const waits = mine.length ? num(mine.length, 'item of yours waits', 'items of yours wait') + '.' : 'Nothing of yours is due.';
40
+ const finRows = (n) => fin.slice(0, n).map((t) => `<div class="phfit"><span class="label">${t.status === 'review' ? 'Waits for you' : t.status === 'sent' ? 'Sent' : 'Finished'}</span><b class="phtt">${esc(t.title)}</b><p class="phs">${esc(t.summary)}</p></div>`).join('');
41
+ const fits = (list) => items(list.map((n) => mine.find((x) => x.id === n.id)).filter(Boolean));
42
+ if (mo.kind === 'meeting') return `<span class="label">Under way · ends ${esc(inText(mo.minutes))}</span>${big(m.title)}${who(m) ? L(who(m)) : ''}<div class="phacts">${open(m)}</div>`;
43
+ if (mo.kind === 'before') {
44
+ const prep = (m.prepared || []).slice(0, 3).map((x) => S(x.text)).join('') || S('Nothing is prepared for it.');
45
+ const bf = (m.before || []).filter((x) => x && x.id && !x.done).map((x) => ({ id: x.id, headline: x.title, label: 'Before you go', kind: 'before' }));
46
+ const line = [who(m), m.initiative].filter(Boolean).join(' · ');
47
+ return `<span class="label">Starts ${esc(inText(mo.minutes))} · ${hm(m.start)}</span>${big(m.title)}${line ? L(line) : ''}${prep}${items(bf)}<div class="phacts">${open(m)}</div>`;
48
+ }
49
+ if (mo.kind === 'after') return `<span class="label">Just ended · ${hm(m.end || m.start)}</span>${big(m.title)}${S('The notes of this meeting, if there are any, are in the meeting.')}<div class="phacts">${open(m)}</div>`;
50
+ if (mo.kind === 'gap') return `<span class="label">Until ${esc(mo.next.title)} at ${hm(mo.next.start)}</span>${big(mo.minutes + ' free minutes')}${mo.fits.length ? fits(mo.fits) : L('Nothing of yours is due. A good moment to prepare the next meeting.')}`;
51
+ if (mo.kind === 'morning') {
52
+ const top = mine.slice(0, 3);
53
+ const nx = mo.next ? `<div class="phfit"><b class="phtt">First up: ${esc(mo.next.title)} at ${hm(mo.next.start)}</b><p class="phs">${esc(inText((Date.parse(mo.next.start) - Date.now()) / 60000).replace(/^in/, 'In'))}${who(mo.next) ? ' · ' + esc(who(mo.next)) : ''}</p><div class="phacts">${open(mo.next)}</div></div>` : S('No meetings today.');
54
+ return `<span class="label">Your morning</span>${big(top.length ? ['', 'One thing', 'Two things', 'Three things'][top.length] + ' this morning' : 'Nothing pressing this morning')}${items(top)}${S(waits)}${nx}`;
55
+ }
56
+ if (mo.kind === 'work') return `<span class="label">${mo.next ? 'Next: ' + esc(mo.next.title) + ' at ' + hm(mo.next.start) : 'No more meetings today'}</span>${big(fin.length ? 'Finished for you' : 'Nothing new from the agent')}${fin.length ? finRows(2) + S('Approving a draft waits for your computer.') : dayErr() || S('When the agent finishes a draft today, it shows here.')}${mo.fits.length ? fits(mo.fits) : ''}${mo.next ? `<div class="phacts">${open(mo.next)}</div>` : ''}`;
57
+ if (mo.kind === 'recap') {
58
+ const r = day && day.recap, one = mine[0];
59
+ const stats = r ? `<div class="phstats"><div><b>${r.meetings || 0}</b><span>meetings</span></div><div><b>${r.decided || 0}</b><span>decided in meetings</span></div><div><b>${r.done || 0}</b><span>done by you</span></div></div>${(r.moved || []).length ? `<div class="phfit"><b class="phtt">What moved</b>${r.moved.map((x) => `<p class="phs">${esc(x.text)}${x.sub ? ' · ' + esc(x.sub) : ''}</p>`).join('')}</div>` : ''}` : dayErr();
60
+ return `<span class="label">Evening recap</span>${big('How today went')}${stats}<div class="phfit"><b class="phtt">Still open · ${mine.length}</b>${mine.slice(0, 3).map((x) => S(x.headline)).join('')}${S(mine.length ? 'They come first on Home tomorrow.' : 'Nothing of yours is still open.')}</div>${one ? `<div class="phfit"><span class="label">One thing tonight, if you have a minute</span>${items([one])}</div>` : ''}`;
61
+ }
62
+ const r = day && day.recap, tm = day && day.tomorrow;
63
+ return `<span class="label">End of day</span>${big(tm ? 'Tomorrow, ' + tm.label : 'Tomorrow, at a glance')}${r ? L('Today: ' + [num(r.meetings, 'meeting', 'meetings'), num(r.decided, 'decision', 'decisions'), num(r.done, 'item done', 'items done')].join(', ') + '.') : ''}${tm ? `<div class="phfit"><b class="phtt">${tm.meetings.length ? num(tm.meetings.length, 'meeting', 'meetings') : 'No meetings'}</b>${tm.meetings.slice(0, 5).map((x) => `<p class="phs">${hm(x.start)} · ${esc(x.title)}${who(x) ? ' · ' + esc(who(x)) : ''}</p>`).join('')}</div>` : dayErr()}${S(mine.length ? num(mine.length, 'item carries', 'items carry') + ' over. They open first on Home tomorrow.' : 'Nothing carries over.')}`;
64
+ }
65
+ const momentNow = () => momentOf({ today: P.page.today || [], needs: own(), now: new Date() });
66
+ function draw(focus) {
67
+ el.hidden = !on(); if (el.hidden) return;
68
+ let h;
69
+ if (!P.page) h = '<span class="label">Now</span><p class="phl">Reading your day.</p>';
70
+ else if (!P.page.ok) h = `<span class="label">Now</span><p class="pherr" role="alert">Your day could not be read: ${esc(P.page.error || 'the workspace server did not answer')}.</p>`;
71
+ else { const mo = momentNow(); el.dataset.moment = mo.kind; h = moment(mo); }
72
+ el.innerHTML = (o.wait || '') + h;
73
+ if (focus) { const f = el.querySelector(focus); if (f) f.focus(); }
74
+ }
75
+ async function read(force) {
76
+ if (!on()) { draw(); return; }
77
+ const ws = o.ws && o.ws();
78
+ P.page = (await o.pmGet('/api/brief-page' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)) || { ok: false, error: 'the workspace server did not answer' };
79
+ const mo = P.page.ok ? momentNow() : null;
80
+ if (mo && ['work', 'recap', 'night'].includes(mo.kind) && (force || !P.day || Date.now() - P.dayAt > 300000)) { P.day = (await o.pmGet('/api/phone-day').catch(() => null)) || { ok: false, error: 'the workspace server did not answer' }; P.dayAt = Date.now(); }
81
+ draw();
82
+ }
83
+ el.onclick = async (e) => { // delegated: every press is a <button data-pha>
84
+ const b = e.target.closest('[data-pha]'); if (!b || P.busy) return;
85
+ const act = b.dataset.pha, id = b.dataset.id;
86
+ if (act === 'phopen') {
87
+ const m = ((P.page && P.page.today) || []).find((x) => x.id === id);
88
+ if (!m) { o.toast('PMOS does not hold that meeting any more, so it could not be opened.'); return; }
89
+ try { await o.openMeeting(m); } catch { o.toast('The meeting could not be opened.'); }
90
+ return;
91
+ }
92
+ const n = own().find((x) => x.id === id) || P.dec.get(id) || ((P.page && P.page.today) || []).flatMap((x) => x.before || []).map((x) => ({ id: x.id, headline: x.title, label: 'Before you go', kind: 'before' })).find((x) => x.id === id);
93
+ if (!n) return;
94
+ P.busy = id; b.disabled = true; delete P.err[id];
95
+ const r = await o.pmPost(act === 'phdone' ? '/api/pm-items/done' : '/api/pm-items/reopen', { id }).catch(() => null);
96
+ P.busy = '';
97
+ const sel = `.phfit[data-id="${CSS.escape(id)}"] button`;
98
+ if (!r || r.ok === false) { P.err[id] = 'That did not go through' + (r && r.error ? ': ' + r.error : '.'); draw(sel); return; }
99
+ if (act === 'phdone') { P.dec.set(id, n); o.toast('Done: ' + n.headline); } else { P.dec.delete(id); o.toast('Reopened: ' + n.headline); }
100
+ draw(sel);
101
+ await read(true); draw(sel);
102
+ };
103
+ const mq = matchMedia(PHONE), again = () => { if (!document.hidden) read(); };
104
+ if (mq.addEventListener) mq.addEventListener('change', again); else mq.addListener(again);
105
+ document.addEventListener('visibilitychange', again);
106
+ setInterval(() => { if (!document.hidden && on()) read(true); }, 60000);
107
+ read();
108
+ return { el, read };
109
+ }