create-pmos 0.424.0 → 0.425.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 (63) hide show
  1. package/package.json +13 -13
  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/board-programs-test.js +41 -26
  7. package/workspace/briefing-premium-board-test.js +7 -4
  8. package/workspace/briefing-premium-insights-test.js +31 -15
  9. package/workspace/briefing-premium-products-test.js +46 -43
  10. package/workspace/changelog.json +12 -0
  11. package/workspace/guide/briefing-premium.md +3 -2
  12. package/workspace/guide/home.md +2 -2
  13. package/workspace/guide/index.md +1 -0
  14. package/workspace/guide/notes.md +39 -1
  15. package/workspace/guide/present-in-a-meeting.md +57 -0
  16. package/workspace/guide/programs.md +2 -2
  17. package/workspace/lib/briefing-premium-products.js +18 -4
  18. package/workspace/lib/meeting-focus.js +64 -14
  19. package/workspace/lib/routes-briefing-premium.js +19 -0
  20. package/workspace/lib/routes-meeting-focus.js +28 -6
  21. package/workspace/lib/settings-store.js +2 -1
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/premium-briefing-depth-test.js +1 -1
  25. package/workspace/premium-rec-now-test.js +153 -0
  26. package/workspace/premium-rec-tab-test.js +167 -0
  27. package/workspace/public/pm/cozy-aud.css +9 -0
  28. package/workspace/public/pm/cozy-aud.js +80 -0
  29. package/workspace/public/pm/cozy-live-pill.js +3 -0
  30. package/workspace/public/pm/cozy-pick.css +41 -0
  31. package/workspace/public/pm/cozy-pick.js +134 -0
  32. package/workspace/public/pm/cozy-rec-bridge.js +32 -0
  33. package/workspace/public/pm/cozy-rec-now.css +104 -0
  34. package/workspace/public/pm/cozy-rec-now.js +330 -0
  35. package/workspace/public/pm/cozy-rec-present.css +69 -0
  36. package/workspace/public/pm/cozy-rec-present.js +467 -0
  37. package/workspace/public/pm/cozy-rec-tab.css +90 -0
  38. package/workspace/public/pm/cozy-rec-tab.js +219 -0
  39. package/workspace/public/pm/cozy-settings.js +8 -2
  40. package/workspace/public/pm/home-app.js +37 -22
  41. package/workspace/public/pm/home-list.js +17 -10
  42. package/workspace/public/pm/home-more.js +2 -31
  43. package/workspace/public/pm/home-today.js +4 -4
  44. package/workspace/public/pm/live-model.js +1 -1
  45. package/workspace/public/pm/premium-board.js +56 -25
  46. package/workspace/public/pm/premium-insights.js +42 -24
  47. package/workspace/public/pm/premium-meeting.js +17 -4
  48. package/workspace/public/pm/premium-mtg-present.js +4 -3
  49. package/workspace/public/pm/premium-report-read.js +2 -0
  50. package/workspace/public/pm/premium-vw-mtg.js +15 -7
  51. package/workspace/public/pm/rec-state.js +13 -5
  52. package/workspace/public/pm/rec-tab-core.js +92 -0
  53. package/workspace/public/pm/view-notes.js +9 -0
  54. package/workspace/public/premium-aud.html +22 -0
  55. package/workspace/public/premium-board.html +1 -0
  56. package/workspace/public/premium-insights.html +2 -1
  57. package/workspace/public/premium-rec.html +30 -0
  58. package/workspace/public/premium.html +1 -0
  59. package/workspace/rec-present-test.js +229 -0
  60. package/workspace/server.js +9 -1
  61. package/workspace/test-lists/rec-now.json +6 -0
  62. package/workspace/test-lists/rec-present.json +13 -0
  63. package/workspace/test-lists/recording-tab.json +13 -0
@@ -0,0 +1,90 @@
1
+ /* pm/cozy-rec-tab.css — the recording tab (batch 12 item 1; canvas In development, XrtA1Tab, XrtA7Room, XrtA6States, XrtA5PhoneRec).
2
+ * Every surface is a rounded card with a 12px gutter. The dark stage is only for a shared screen; in the room the page stays light.
3
+ * Token vars from cozy.css only. Motion: the red dot breathes while recording; nothing else moves but the clock. */
4
+ body.rt-page { height: 100vh; overflow: hidden; }
5
+ .rt { box-sizing: border-box; height: 100vh; padding: 12px; display: flex; gap: 12px; }
6
+ .rt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; border-radius: 20px; background: var(--cz-card); box-shadow: var(--cz-vlift); padding: 14px 20px 18px; box-sizing: border-box; }
7
+ .rt-side { width: 400px; flex: none; border-radius: 20px; background: var(--cz-card); box-shadow: var(--cz-vlift); overflow: auto; }
8
+ .rt-side[hidden], .rt-ask[hidden], .rt-line[hidden], .rt-bar[hidden], .rt-msg[hidden], .rt-alert[hidden], .rt-past[hidden] { display: none; }
9
+
10
+ /* the dark stage: only while a screen is shared */
11
+ .rt[data-mode="screen"] .rt-main { background: var(--cz-c-1b1d21); color: var(--cz-c-eceef1); }
12
+
13
+ .rt-hd { display: flex; align-items: center; gap: 10px; min-height: 40px; }
14
+ .rt-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cz-dot-q); flex: none; }
15
+ .rt[data-mode="screen"] .rt-dot, .rt[data-mode="room"] .rt-dot { background: var(--cz-dot-red); animation: rt-breathe 2.4s ease-in-out infinite; }
16
+ .rt-clock { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cz-ink3); }
17
+ .rt[data-mode="screen"] .rt-clock, .rt[data-mode="room"] .rt-clock { color: var(--cz-dot-red); }
18
+ .rt.late .rt-clock, .rt-past { color: var(--cz-dot-risk); }
19
+ .rt-title { margin: 0; font-size: 16px; font-weight: 800; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
20
+ .rt-past { font-size: 13px; font-weight: 700; }
21
+ @keyframes rt-breathe { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }
22
+ @media (prefers-reduced-motion: reduce) { .rt-dot { animation: none !important; } }
23
+
24
+ .rt-alert { margin: 6px 0 0; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 14px; background: var(--cz-riskbg); color: var(--cz-risk); font-weight: 700; font-size: 14px; }
25
+ .rt-alert span { flex: 1; }
26
+
27
+ .rt-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 10px; position: relative; }
28
+ .rt-own { flex: 1; min-height: 0; display: flex; }
29
+ .rt-own:empty { display: none; }
30
+ .rt-scr { flex: 1; min-height: 0; border-radius: 12px; background: var(--cz-c-17191c); display: flex; align-items: center; justify-content: center; overflow: hidden; }
31
+ .rt-scr video { max-width: 100%; max-height: 100%; display: block; }
32
+ .rt-scr.off { flex-direction: column; gap: 12px; background: var(--cz-c-2a2d33); }
33
+ .rt-scr.off p { margin: 0; font-size: 16px; font-weight: 800; color: var(--cz-c-9ea4ad); }
34
+ .rt-wait { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
35
+ .rt-wait h2 { margin: 0; font-size: 20px; font-weight: 800; }
36
+ .rt-wait p { margin: 0 0 8px; font-size: 14px; color: var(--cz-ink3); max-width: 420px; }
37
+
38
+ /* the meeting so far: one mark per highlight, a card with the moment on hover or focus */
39
+ .rt-line { position: relative; height: 28px; margin: 12px 4px 0; }
40
+ .rt-track { position: absolute; left: 0; right: 0; top: 13px; height: 3px; border-radius: 2px; background: var(--cz-hair); }
41
+ .rt-track::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--rt-now, 0%); border-radius: 2px; background: color-mix(in srgb, var(--cz-blue) 70%, transparent); }
42
+ .rt-nowmark { position: absolute; left: var(--rt-now, 0%); top: 4px; width: 2px; height: 20px; border-radius: 1px; background: var(--cz-dot-red); }
43
+ .rt-mk { position: absolute; left: var(--rt-x); top: 0; transform: translateX(-50%); }
44
+ .rt-star { width: 28px; height: 28px; border: 0; padding: 0; border-radius: 50%; background: transparent; color: var(--cz-dot-risk); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
45
+ .rt-star svg { fill: currentColor; stroke: none; }
46
+ .rt-star:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
47
+ .rt-hv { display: none; position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%); width: 240px; padding: 10px; border-radius: 14px; background: var(--cz-card); color: var(--cz-ink); box-shadow: var(--cz-sheet); font-size: 13px; z-index: 3; flex-direction: column; gap: 4px; }
48
+ .rt-hv b { font-size: 12px; color: var(--cz-ink3); }
49
+ .rt-hv img { width: 100%; border-radius: 8px; margin-top: 4px; display: block; }
50
+ .rt-mk:hover .rt-hv, .rt-mk:focus-within .rt-hv { display: flex; }
51
+
52
+ .rt-msg { margin: 8px 0 0; font-size: 13px; font-weight: 700; color: var(--cz-ink3); text-align: center; }
53
+ .rt[data-mode="screen"] .rt-msg { color: var(--cz-c-9ea4ad); }
54
+
55
+ /* the bar: icon only; Stop is the one red press */
56
+ .rt-bar { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
57
+ .rt-slot { display: contents; }
58
+ .rt-b { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
59
+ .rt-b svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
60
+ .rt-b.on { background: var(--cz-ink); color: var(--cz-card); }
61
+ .rt-b.dark { background: var(--cz-ink); color: var(--cz-card); border-color: transparent; }
62
+ .rt-b.dark svg { fill: currentColor; }
63
+ .rt-b.red { width: 64px; border-radius: 26px; background: var(--cz-dot-red); color: var(--cz-onsolid); border-color: transparent; margin-left: 12px; }
64
+ .rt-b.red svg { fill: currentColor; stroke: none; }
65
+ .rt-b.big { width: 64px; height: 64px; border-radius: 50%; margin: 0; }
66
+ .rt-b:focus-visible, .rt-t:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
67
+ .rt-b:disabled { opacity: .5; cursor: default; }
68
+ .rt[data-mode="screen"] .rt-b:not(.red):not(.on) { background: var(--cz-c-33363c); color: var(--cz-c-eceef1); border-color: transparent; }
69
+ .rt-alert .rt-b { width: 36px; height: 36px; background: transparent; border: 0; color: inherit; }
70
+ .rt-scr.off .rt-b { background: var(--cz-c-eceef1); color: var(--cz-c-17191c); }
71
+
72
+ /* Stop asks first; the next meeting asks once */
73
+ .rt-ask { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--cz-c-17191c) 35%, transparent); z-index: 5; }
74
+ .rt-askc { width: min(420px, calc(100vw - 32px)); box-sizing: border-box; padding: 20px; border-radius: 20px; background: var(--cz-card); color: var(--cz-ink); box-shadow: var(--cz-sheet); }
75
+ .rt-askc b { font-size: 16px; }
76
+ .rt-askc p { margin: 8px 0 0; font-size: 14px; color: var(--cz-ink2); }
77
+ .rt-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
78
+ .rt-t { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font: 700 14px var(--cz-sans); cursor: pointer; }
79
+ .rt-t.red { background: var(--cz-dot-red); color: var(--cz-onsolid); border-color: transparent; }
80
+ .rt-t.blue { background: var(--cz-solid); color: var(--cz-onsolid); border-color: transparent; }
81
+
82
+ /* a phone: the recording view in the same tab; the side card goes under the stage */
83
+ @media (max-width: 760px) {
84
+ body.rt-page { height: auto; overflow: auto; }
85
+ .rt { height: auto; min-height: 100vh; flex-direction: column; }
86
+ .rt-main { min-height: 70vh; padding: 12px 14px 14px; }
87
+ .rt-side { width: auto; }
88
+ .rt-bar { gap: 8px; }
89
+ .rt-b { width: 48px; height: 48px; }
90
+ }
@@ -0,0 +1,219 @@
1
+ /* pm/cozy-rec-tab.js — the recording tab, /premium-rec.html?note=<id>&ws=<ws>[&go=1] (batch 12 item 1, slice S1; canvas In development,
2
+ * XrtA1Tab, XrtA7Room, XrtA6States, XrtA5PhoneRec).
3
+ *
4
+ * A meeting records in its own tab, named 'pmos-rec' (rec-tab-core.js). The tab holds the recorder (premium-meeting.js recCore) and
5
+ * never navigates away: its links open in the other PMOS tab, so Home, Board, Insights or a chat never pause the meeting. Only this tab
6
+ * controls the meeting; every other page shows a snippet, and a press on it brings this tab forward.
7
+ *
8
+ * Drawn here:
9
+ * header red dot, the meeting clock, the title; amber "Past 10:30 end" once the calendar end has passed. The tab's title is the clock.
10
+ * stage with a shared screen, a dark stage with the picture live; "Sharing stopped" with Share again when it ends. In the room
11
+ * (microphone only) there is no dark stage: the light page, which slice S2 (cozy-rec-now.js) fills. Paused and not yet
12
+ * started each say so, with the one press that goes on.
13
+ * line the meeting so far, with a mark for each highlight; hover or focus a mark for the moment: its time, the line, the shot.
14
+ * bar icon only: Highlight, Pause or Resume, Pause the screenshots (only with a screen), the slots, and the red Stop.
15
+ * alert amber "Not hearing the meeting" with Share again, when the microphone is heard and the meeting is not.
16
+ * ask Stop asks first. Record on the next meeting, pressed on another page, asks here once: "Stop X and record Y?".
17
+ * Stop ends the meeting, and the tab then shows its notes (the Viewer, /premium-viewer.html?open=meeting).
18
+ *
19
+ * Slots: S2 and S3 load here if their files exist (a missing file is ignored):
20
+ * cozy-rec-now.js mountNow({ stage, side, bar }, ctx) ctx = { ws, note(), mode(), on(evt, fn), focus(), event, rec }
21
+ * cozy-rec-present.js mountPresent({ stage, side, bar }, ctx) ctx = { ws, note: { id, title }, event, focus() }
22
+ * bar holds [data-slot="now"] and [data-slot="present"] for their buttons.
23
+ * Reads: GET /api/notes (recCore), /api/notes/one, /api/meeting-focus. Writes only through the recorder's presses. */
24
+ import { pmGet, pmPost } from './http.js';
25
+ import { recCore, STOP_LINE } from './premium-meeting.js';
26
+ import { post, listen, tabUrl, clockOf, modeOf, endOf, marksOf } from './rec-tab-core.js';
27
+
28
+ const q = new URLSearchParams(location.search);
29
+ const ID = q.get('note') || '', WS = q.get('ws') || '';
30
+ const C = recCore({ pmGet, pmPost, ws: () => WS || null });
31
+ const $ = (id) => document.getElementById(id);
32
+ const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
33
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
34
+ const pad = (n) => String(n).padStart(2, '0');
35
+ const wall = (ms) => { const d = new Date(ms); return pad(d.getHours()) + ':' + pad(d.getMinutes()); };
36
+
37
+ const P = { star: '<path d="M12 3.8l2.5 5.2 5.7.8-4.1 4 1 5.7L12 16.8l-5.1 2.7 1-5.7-4.1-4 5.7-.8z"/>', pause: '<path d="M9 6v12M15 6v12"/>', play: '<path d="M8 5v14l11-7z"/>',
38
+ stop: '<rect x="7" y="7" width="10" height="10" rx="2"/>', eyeoff: '<path d="M3 3l18 18M10.6 6.1A9.8 9.8 0 0 1 12 6c5 0 9 6 9 6a15 15 0 0 1-3 3.5M6.6 6.7C4.3 8.2 3 12 3 12s4 6 9 6a8.6 8.6 0 0 0 4.3-1.1M9.9 9.9a3 3 0 0 0 4.2 4.2"/>',
39
+ eye: '<path d="M3 12s4-6 9-6 9 6 9 6-4 6-9 6-9-6-9-6z"/><circle cx="12" cy="12" r="3"/>', share: '<rect x="3" y="4" width="18" height="12" rx="2"/><path d="M12 13V7M9 10l3-3 3 3M8 20h8"/>',
40
+ rec: '<circle cx="12" cy="12" r="6"/>' };
41
+ const svg = (k, w = 18) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24">${P[k]}</svg>`;
42
+ const btn = (a, label, icon, cls = '') => `<button type="button" class="rt-b${cls ? ' ' + cls : ''}" data-a="${a}" aria-label="${esc(label)}" title="${esc(label)}">${svg(icon, a === 'stop' ? 20 : 18)}</button>`;
43
+
44
+ const S = { row: null, one: null, focus: null, readAt: Date.now(), mode: 'idle', ask: null, msg: '', busy: false, video: null, on: { note: new Set(), mode: new Set(), tick: new Set() } };
45
+ const fire = (k, v) => { for (const fn of S.on[k]) { try { fn(v); } catch { /* the slot's own */ } } };
46
+ const note = () => (S.one && S.one.note) || null;
47
+ const title = () => clip((S.row && ((S.row.meeting && S.row.meeting.title) || S.row.title)) || (note() && note().title) || 'Meeting', 120);
48
+ const held = () => { const h = C.holding(); return !!(h && h.id === ID); };
49
+ const elapsed = () => { const r = S.row; if (!r) return 0; const ms = Number(r.meeting_ms) || 0; return r.state === 'recording' ? ms + Math.max(0, Date.now() - S.readAt) : ms; };
50
+ const eventOf = () => { const n = note(); const m = n && n.meeting; return m && m.kind === 'event' ? { id: m.event_id || '', title: m.title || '', series: (n.series && n.series.key) || '', date: m.start ? String(m.start).slice(0, 10) : '' } : null; };
51
+
52
+ /* ── drawing ───────────────────────────────────────────────────────────────────────────────────────────── */
53
+ function drawHead() {
54
+ const t = title(), past = endOf(note());
55
+ $('rtTitle').textContent = t;
56
+ const late = past && S.mode !== 'stopped' && Date.now() > past;
57
+ $('rt').classList.toggle('late', !!late);
58
+ $('rtPast').hidden = !late; if (late) $('rtPast').textContent = 'Past ' + wall(past) + ' end';
59
+ tick();
60
+ }
61
+ function tick() {
62
+ const c = clockOf(elapsed());
63
+ $('rtClock').textContent = c;
64
+ document.title = (S.mode === 'paused' ? 'Paused · ' : '') + c + ' · ' + title();
65
+ fire('tick', elapsed());
66
+ }
67
+ function drawBar() {
68
+ const bar = $('rtBar'), keep = { now: bar.querySelector('[data-slot="now"]'), present: bar.querySelector('[data-slot="present"]') };
69
+ const live = S.mode === 'screen' || S.mode === 'room', scr = C.screen();
70
+ const parts = [];
71
+ if (live) parts.push(btn('hl', 'Highlight the last 30 seconds', 'star'), btn('pause', 'Pause', 'pause'));
72
+ else if (S.mode === 'paused') parts.push(btn('resume', 'Resume', 'play', 'dark'));
73
+ if (S.mode === 'screen') parts.push(scr.paused ? btn('shots', 'Keep screenshots again', 'eye', 'on') : btn('shots', 'Pause the screenshots (the sound goes on)', 'eyeoff'));
74
+ bar.innerHTML = parts.join('');
75
+ for (const k of ['now', 'present']) { const s = keep[k] || Object.assign(document.createElement('span'), { className: 'rt-slot' }); s.dataset.slot = k; bar.appendChild(s); }
76
+ if (live || S.mode === 'paused') bar.insertAdjacentHTML('beforeend', btn('stop', 'Stop the recording', 'stop', 'red'));
77
+ bar.hidden = !(live || S.mode === 'paused');
78
+ }
79
+ function drawStage() {
80
+ const st = $('rtStage');
81
+ const mine = st.querySelector(':scope > .rt-own');
82
+ const own = mine || Object.assign(document.createElement('div'), { className: 'rt-own' });
83
+ if (!mine) st.prepend(own);
84
+ $('rt').dataset.mode = S.mode;
85
+ const scr = C.screen();
86
+ if (S.mode === 'screen') {
87
+ if (scr.track) {
88
+ if (!S.video || S.video.dataset.track !== scr.track.id) {
89
+ own.innerHTML = '<div class="rt-scr"><video muted playsinline autoplay aria-label="The shared screen, live"></video></div>';
90
+ S.video = own.querySelector('video'); S.video.dataset.track = scr.track.id;
91
+ try { S.video.srcObject = new MediaStream([scr.track]); S.video.play().catch(() => {}); } catch { /* no picture */ }
92
+ }
93
+ } else { S.video = null; own.innerHTML = `<div class="rt-scr off"><p>Sharing stopped</p>${btn('share', 'Share again', 'share', 'dark')}</div>`; }
94
+ return;
95
+ }
96
+ S.video = null;
97
+ if (S.mode === 'room') { own.innerHTML = ''; return; }
98
+ if (S.mode === 'paused') {
99
+ const left = S.row && S.row.resume_until ? Math.max(1, Math.ceil((Date.parse(S.row.resume_until) - Date.now()) / 60000)) : null;
100
+ own.innerHTML = `<div class="rt-wait"><h2>Paused</h2><p>Nothing is kept until you resume${left ? '. ' + left + (left === 1 ? ' minute' : ' minutes') + ' left to resume' : ''}.</p></div>`; return;
101
+ }
102
+ if (S.mode === 'idle') { own.innerHTML = `<div class="rt-wait"><h2>${esc(title())}</h2><p>${esc(S.msg || (S.row && S.row.state === 'recording' ? 'Recording in another tab.' : 'Not recording yet.'))}</p>${S.row && S.row.state !== 'recording' ? btn('start', 'Start recording', 'rec', 'red big') : ''}</div>`; return; }
103
+ own.innerHTML = '<div class="rt-wait"><h2>Stopped</h2><p>The notes are being written.</p></div>';
104
+ }
105
+ function drawLine() {
106
+ const line = $('rtLine');
107
+ const len = Math.max(elapsed(), endOf(note()) && note().recorded_from ? endOf(note()) - Date.parse(note().recorded_from) : 0, 1);
108
+ const marks = marksOf(note(), S.one && S.one.screen && S.one.screen.frames, len);
109
+ const now = Math.min(1, elapsed() / len);
110
+ line.hidden = !(S.mode === 'screen' || S.mode === 'room' || S.mode === 'paused');
111
+ line.style.setProperty('--rt-now', (now * 100).toFixed(2) + '%');
112
+ line.innerHTML = '<span class="rt-track" aria-hidden="true"></span><span class="rt-nowmark" aria-hidden="true"></span>' + marks.map((m) => `<span class="rt-mk" style="--rt-x:${(m.x * 100).toFixed(2)}%">`
113
+ + `<button type="button" class="rt-star" aria-label="Highlight at ${esc(clockOf(m.t))}${m.text ? ': ' + esc(m.text) : ''}">${svg('star', 12)}</button>`
114
+ + `<span class="rt-hv" role="tooltip"><b>${esc(clockOf(m.t))}</b>${m.text ? `<span>${esc(m.text)}</span>` : ''}${m.shot != null ? `<img alt="" loading="lazy" src="/api/notes/screen?id=${encodeURIComponent(ID)}&amp;t=${m.shot}">` : ''}</span></span>`).join('');
115
+ }
116
+ function drawAlert() {
117
+ const scr = C.screen(), a = $('rtAlert');
118
+ const silent = (S.mode === 'screen' || S.mode === 'room') && scr.silent;
119
+ a.hidden = !silent;
120
+ if (silent) a.innerHTML = `<span>Not hearing the meeting</span>${btn('share', 'Share the meeting again', 'share')}`;
121
+ }
122
+ function drawAsk() {
123
+ const k = $('rtAsk');
124
+ if (!S.ask) { k.hidden = true; k.innerHTML = ''; return; }
125
+ k.hidden = false;
126
+ k.innerHTML = S.ask.kind === 'stop'
127
+ ? `<div class="rt-askc" role="alertdialog" aria-label="Stop the recording?"><b>Stop the recording?</b><p>${esc(STOP_LINE)}</p><div class="rt-acts"><button type="button" class="rt-t" data-a="askno">Keep recording</button><button type="button" class="rt-t red" data-a="stopgo">Stop</button></div></div>`
128
+ : `<div class="rt-askc" role="alertdialog" aria-label="Switch meetings?"><b>Stop ${esc(title())} and record ${esc(S.ask.title)}?</b><div class="rt-acts"><button type="button" class="rt-t" data-a="askno">Keep recording</button><button type="button" class="rt-t blue" data-a="switchgo">Switch</button></div></div>`;
129
+ const f = k.querySelector('[data-a="askno"]'); if (f) f.focus();
130
+ }
131
+ function draw() {
132
+ const m = modeOf(S.row, held(), C.screen());
133
+ if (m !== S.mode) { S.mode = m; fire('mode', m); }
134
+ if (S.mode === 'stopped' && !S.ask) { location.replace('/premium-viewer.html?open=meeting&note=' + encodeURIComponent(ID) + (WS ? '&ws=' + encodeURIComponent(WS) : '')); return; }
135
+ drawHead(); drawStage(); drawBar(); drawLine(); drawAlert();
136
+ const say = $('rtMsg'); say.textContent = S.msg && S.mode !== 'idle' ? S.msg : ''; say.hidden = !say.textContent;
137
+ beat();
138
+ }
139
+
140
+ /* ── the state other tabs read ─────────────────────────────────────────────────────────────────────────── */
141
+ let lastBeat = '';
142
+ function beat(force) {
143
+ const st = S.mode === 'paused' ? 'paused' : S.mode === 'screen' || S.mode === 'room' ? 'recording' : S.mode === 'stopped' ? 'ended' : 'idle';
144
+ const b = { id: ID, state: st, title: title(), elapsedMs: elapsed(), silent: !!C.screen().silent };
145
+ const key = b.state + '|' + b.title + '|' + b.silent;
146
+ if (force || key !== lastBeat) { lastBeat = key; post(b); }
147
+ }
148
+
149
+ /* ── reading ───────────────────────────────────────────────────────────────────────────────────────────── */
150
+ async function read() {
151
+ const [rows, one] = await Promise.all([C.refresh(), pmGet('/api/notes/one?id=' + encodeURIComponent(ID))]);
152
+ S.readAt = Date.now();
153
+ S.row = (rows || []).find((n) => n.id === ID) || (one && one.ok && one.note ? { ...one.note, id: ID } : null);
154
+ if (one && one.ok) S.one = one;
155
+ fire('note', S.one);
156
+ draw();
157
+ }
158
+ async function readFocus() {
159
+ const e = eventOf(), qs = e && e.id ? 'event=' + encodeURIComponent(e.id) + '&date=' + encodeURIComponent(e.date) : 'note=' + encodeURIComponent(ID);
160
+ const F = await pmGet('/api/meeting-focus?' + qs + (WS ? '&ws=' + encodeURIComponent(WS) : ''));
161
+ S.focus = F && F.ok !== false ? F : S.focus;
162
+ }
163
+
164
+ /* ── the presses ───────────────────────────────────────────────────────────────────────────────────────── */
165
+ async function act(a, t) {
166
+ if (S.busy && a !== 'askno') return;
167
+ const run = async (fn) => { S.busy = true; if (t) t.disabled = true; try { await fn(); } finally { S.busy = false; await read(); } };
168
+ switch (a) {
169
+ case 'hl': { const r = await C.highlight(); S.msg = r.ok ? 'Keeping the last 30 seconds and the next ones as a highlight.' : r.error; return draw(); }
170
+ case 'pause': return run(async () => { const r = await C.pause(); S.msg = r.ok ? '' : r.error; });
171
+ case 'resume': case 'start': return run(async () => { const r = await C.resume(ID); S.msg = r.ok ? '' : r.error; });
172
+ case 'share': return run(async () => { await C.pause(); const r = await C.resume(ID); S.msg = r.ok ? '' : r.error; });
173
+ case 'shots': { C.shots(!C.screen().paused); return draw(); }
174
+ case 'stop': S.ask = { kind: 'stop' }; return drawAsk();
175
+ case 'askno': S.ask = null; drawAsk(); return draw();
176
+ case 'stopgo': S.ask = null; drawAsk(); return run(async () => { const r = await C.stop(ID); S.msg = r.ok ? '' : r.error; });
177
+ case 'switchgo': {
178
+ const to = S.ask && S.ask.body; S.ask = null; drawAsk();
179
+ return run(async () => {
180
+ const r = await C.stop(ID); if (!r.ok) { S.msg = r.error; return; }
181
+ const made = await pmPost('/api/notes/new', to);
182
+ if (made && made.ok) location.replace(tabUrl(made.note.id, { ws: WS, go: true }));
183
+ else S.msg = (made && made.error) || 'The next meeting\'s note was not made.';
184
+ });
185
+ }
186
+ default:
187
+ }
188
+ }
189
+ document.addEventListener('click', (e) => { const t = e.target.closest('[data-a]'); if (t && !t.disabled && t.closest('#rt')) act(t.dataset.a, t); });
190
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.ask) { S.ask = null; drawAsk(); } });
191
+
192
+ /* Record on the next meeting, pressed on another page while this one records: ask here once (rec-tab-core.js asks over the channel) */
193
+ listen((d) => { if (d.id === ID && d.switchTo && d.switchTo.body) { S.ask = { kind: 'switch', title: clip(d.switchTo.title || 'the next meeting', 80), body: d.switchTo.body }; drawAsk(); } });
194
+
195
+ /* ── the slots: S2 (Now panel) and S3 (Present) mount here when their files are on the page ─────────────────── */
196
+ const slots = () => ({ stage: $('rtStage'), side: $('rtSide'), bar: $('rtBar') });
197
+ function mountSlots() {
198
+ drawBar();
199
+ import('./cozy-rec-now.js').then((M) => M.mountNow && M.mountNow(slots(), { ws: WS, note: () => S.one, mode: () => S.mode, on: (k, fn) => { if (S.on[k]) { S.on[k].add(fn); return () => S.on[k].delete(fn); } return () => {}; },
200
+ focus: () => S.focus, event: eventOf(), rec: C })).catch(() => {});
201
+ import('./cozy-rec-present.js').then((M) => M.mountPresent && M.mountPresent(slots(), { ws: WS, note: { id: ID, title: title() }, event: eventOf(), focus: () => S.focus })).catch(() => {});
202
+ }
203
+
204
+ if (!ID) { $('rtTitle').textContent = 'No meeting'; $('rtMsg').textContent = 'This tab names no meeting. Open a meeting and press Record.'; $('rtMsg').hidden = false; }
205
+ else {
206
+ window.addEventListener('premium-rec', () => { if (!S.busy) draw(); });
207
+ addEventListener('pagehide', () => post({ id: ID, state: 'paused', title: title(), elapsedMs: elapsed(), silent: false }));
208
+ read().then(async () => {
209
+ await readFocus(); mountSlots();
210
+ // opened by Record on another page: listen now; the Listen sheet's press here gives the share its permission
211
+ if (q.get('go') === '1') {
212
+ history.replaceState(null, '', tabUrl(ID, { ws: WS }));
213
+ if (S.row && S.row.state !== 'recording' && S.row.state !== 'ended') act('start');
214
+ }
215
+ });
216
+ setInterval(() => { if (!S.busy) { tick(); drawAlert(); drawLine(); beat(); } }, 1000); // beat(): a change (Not hearing the meeting) reaches the snippets within a second
217
+ setInterval(() => { if (!S.busy) read(); beat(true); }, 5000);
218
+ setInterval(readFocus, 15000);
219
+ }
@@ -46,7 +46,7 @@ function general() {
46
46
  const upd = ready() ? `<div class="ev-card ev-upd"><span class="ev-pill y">Update</span><p><b>PMOS ${esc(latest())} is ready.</b> <span class="ev-mut">${esc(firstLine())}</span></p><button type="button" class="ev-btn sm" data-ev-go="whatsnew">What's new</button><button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button></div>` : '';
47
47
  return trow('Theme', 'Auto follows your computer', seg('Theme', 'theme', theme, [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]))
48
48
  + trow('Viewer opens as', 'A column beside the chat, or a popup over it', seg('Viewer opens as', 'viewer', vw, [['column', 'Column'], ['popup', 'Popup']]))
49
- + trow('Product', 'Which products Home, Board and Insights read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="dialog">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
49
+ + trow('Product', 'Which products Home, Board and Insights read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="menu">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
50
50
  + trow('Your day', 'When the end-of-day card shows', `<label class="ev-vh" for="evDay">Your day ends at</label><select id="evDay" class="ev-inp" data-ev-day>${hours.map((h) => `<option value="${h}"${h === end ? ' selected' : ''}>${pad(h)}:00</option>`).join('')}</select>`)
51
51
  + trow('Agents write to Jira', 'Only after you press Commit. Never on their own.', '<span class="ev-pill ok">Fixed</span>')
52
52
  + upd;
@@ -122,7 +122,13 @@ async function press(e) {
122
122
  if (t.dataset.evGo) { T.sec = t.dataset.evGo; draw(); return; }
123
123
  if (t.dataset.evSeg === 'theme') { const M = await import('./cozy-nav.js'); M.setTheme(t.dataset.v); draw(); return; }
124
124
  if (t.dataset.evSeg === 'viewer') { store.set(VIEWER_KEY, t.dataset.v); document.body.classList.toggle('ev-vw-popup', t.dataset.v === 'popup'); draw(); return; }
125
- if ('evProducts' in t.dataset) { closeSettings(); import('./home-more.js').then((M) => M.openProducts()); return; }
125
+ // the one product pick (batch 12 item 5): the same list as the chip on Home, Board and Insights, under this row
126
+ if ('evProducts' in t.dataset) {
127
+ const PP = await import('./cozy-pick.js'), P = await PP.readPick();
128
+ if (!P) { T.msg = 'The products could not be read.'; draw(); return; }
129
+ PP.openPicker(t, { P, label: 'Products', onApply: async (on) => { const r = await PP.savePick(on); if (!r.ok) { T.msg = r.error; draw(); return; } T.prods = r.products; draw(); } });
130
+ return;
131
+ }
126
132
  if (T.busy) return;
127
133
  T.busy = true; T.msg = '';
128
134
  try {
@@ -16,11 +16,13 @@
16
16
  * press (pmPost). Nothing here opens the old dialog or links to the console. */
17
17
  import { mountNav } from './cozy-nav.js';
18
18
  import { mountLivePill } from './cozy-live-pill.js';
19
+ import { ownTab, bring, tabUrl } from './rec-tab-core.js';
19
20
  import * as VW from './cozy-viewer.js';
20
21
  import { pmGet, pmPost, pmHeaders } from './http.js';
21
22
  import * as H from './home-data.js';
22
23
  import { mountChat, avHtml } from './home-chat.js';
23
24
  import * as MORE from './home-more.js';
25
+ import * as PP from './cozy-pick.js'; // the one product picker Home, Board and Insights share (batch 12 item 5)
24
26
  import { headModel, STEPS } from './premium-initiative-head.js';
25
27
  import * as SC from './home-stage-card.js'; // the initiative's stage card D
26
28
  import * as WFM from './ini-wf-model.js'; // D99: the workflow an initiative runs (kind line, usual days)
@@ -93,8 +95,9 @@ const S = {
93
95
  iniWs: {}, // another product's initiative found by a read (loadIni), by id: the workspace it was found in
94
96
  doneOpen: false, stepsMore: false, sheet: false, rec: {}, pin: new Set(JSON.parse(store.get('pmos.home.pin') || '[]')),
95
97
  cardFold: store.get('pmos.home.cardfold') === '1', // the card's checklist folded to one line (AgInitSpec), kept in this browser
96
- // the one list (premium-uncovered-features): the filter, the picked product, which groups and initiatives are open, kept in this browser
97
- filter: 'today', product: store.get('pmos.home.product') || null, kidsOff: new Set(), rest: new Set(), cap: false, day: false, ses: null,
98
+ // the one list (premium-uncovered-features): the filter, which groups and initiatives are open, kept in this browser. The products shown are
99
+ // the one saved pick (S.D.pick, GET /api/briefing-premium/products), never kept here (batch 12 item 5)
100
+ filter: 'today', kidsOff: new Set(), rest: new Set(), cap: false, day: false, ses: null,
98
101
  pg: (() => { try { return JSON.parse(store.get('pmos.home.pg') || '{}') || {}; } catch { return {}; } })(),
99
102
  eodHidden: store.get('pmos.home.eod') === L.dayOf(), phoneChat: false,
100
103
  };
@@ -144,10 +147,10 @@ async function getRetry(path, tries = 20) {
144
147
  return { ok: false, error: 'still reading' };
145
148
  }
146
149
  async function load() {
147
- const [brief, board, ses, desk, today, sch, work, day, rev, progs] = await Promise.all([
150
+ const [brief, board, ses, desk, today, sch, work, day, rev, progs, , pick] = await Promise.all([
148
151
  getRetry('/api/briefing-premium' + wsQ()), getRetry('/api/board-premium' + wsQ() + boardQ(WS ? '&' : '?')), pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ()),
149
152
  pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()), pmGet('/api/my-work-premium' + wsQ()), pmGet('/api/phone-day'), pmGet('/api/home-review' + wsQ()),
150
- pmGet('/api/programs'), MEN.load(menCtx()),
153
+ pmGet('/api/programs'), MEN.load(menCtx()), PP.readPick(),
151
154
  ]);
152
155
  const D = S.D;
153
156
  D.brief = brief && brief.ok && brief.model ? brief.model : null;
@@ -160,6 +163,8 @@ async function load() {
160
163
  D.phoneDay = day && day.ok ? day : null; // what finished today, the recap and tomorrow (the end-of-day card, the Done filter)
161
164
  D.review = rev && rev.ok ? rev : null; // this week's review (GET /api/home-review)
162
165
  D.programs = progs && progs.ok ? progs.programs : []; // programs above initiatives, across products (GET /api/programs)
166
+ D.pick = pick || D.pick || null; // the one product pick (the chip): which products are on Home and read
167
+ if (D.pick && WS) D.pick = { ...D.pick, products: D.pick.products.map((p) => ({ ...p, on: p.ws === WS })) }; // ?ws= is a one-off view of that product
163
168
  D.now = Date.now();
164
169
  D.err = [brief, board].filter((x) => !x || !x.ok).map((x) => (x && x.error) || 'the server did not answer');
165
170
  const rows = H.boardRows(D);
@@ -264,14 +269,14 @@ function todayModel() {
264
269
  return T;
265
270
  }
266
271
  function homeListHtml() {
267
- const M = L.homeList(S.D, { now: NOW(), filter: S.filter, product: S.product && L.productsOf(S.D).some((p) => p.key === S.product) ? S.product : null });
272
+ const M = L.homeList(S.D, { now: NOW(), filter: S.filter });
268
273
  S.M = M;
269
274
  const R = L.reviewModel(S.D, NOW());
270
275
  // a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
271
- const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1 || (!!S.product && !!g.product && S.product === g.product.key));
276
+ const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1);
272
277
  return TD.listHtml(M, todayModel(), {
273
278
  sel: S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null), selHead: S.head, ses: S.ses, pOpen, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
274
- product: S.product, review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
279
+ pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
275
280
  });
276
281
  }
277
282
  /** Your day (XvAPhDay, was the HvAOpen sheet): "Good morning" opens it in the Viewer, shell A. Full screen on a phone, beside the chat on a
@@ -927,19 +932,28 @@ async function checkRow(id) {
927
932
  toast('Done.');
928
933
  await load();
929
934
  }
930
- /* the products picker (HmProducts): All products, each product with its goals, Add a product */
931
- function pickProduct(anchor) {
932
- const M = S.M || L.homeList(S.D, { now: NOW() });
933
- const items = [{ label: 'All products', sub: 'Home only · Board and Insights show one', checked: !S.product, go: () => setProduct(null) }, { sep: true }]
934
- .concat(M.products.map((p) => {
935
- const g = M.groups.find((x) => x.product && x.product.key === p.key);
936
- const n = g ? g.count : ((p.model && p.model.initiatives && p.model.initiatives.list && p.model.initiatives.list.rows) || []).filter(H.OPEN).length;
937
- return { label: p.name, sub: [n + (n === 1 ? ' initiative' : ' initiatives'), p.goals && p.goals.n ? p.goals.ok + ' of ' + p.goals.n + ' goals' : ''].filter(Boolean).join(' · '), tile: p.initials, primary: p.primary, checked: S.product === p.key, go: () => setProduct(p.key) };
938
- }))
939
- .concat([{ sep: true }, { label: 'Add a product', icon: TD.P.plus, go: () => MORE.openProducts() }]);
940
- menu(anchor, items, '');
941
- }
942
- function setProduct(key) { S.product = key; store.set('pmos.home.product', key); if (key) S.pg['p:' + key] = true; drawList(); }
935
+ /* the product picker (batch 12 item 5, canvas XhpA1Desk): the one list Home, Board and Insights share (pm/cozy-pick.js). Every registered
936
+ * product with its tile, name and one quiet line; the ticks apply when the list closes, and are saved for every page */
937
+ function pickTones() {
938
+ const P = S.D.pick; if (!P) return null;
939
+ // the tints Home's groups use: the board's own product first, then the registered order (home-list.js productsOf)
940
+ const own = ((S.D.board && S.D.board.board) || {}).ws || '';
941
+ return PP.tonesOf(P.products.map((p) => ({ ...p, primary: own ? p.ws === own : p.primary })));
942
+ }
943
+ function pickLine(ws) {
944
+ const M = S.M; if (!M) return '';
945
+ const p = M.products.find((x) => x.ws === ws); if (!p) return '';
946
+ const g = M.groups.find((x) => x.product && x.product.key === p.key);
947
+ const n = g ? g.count : ((p.model && p.model.initiatives && p.model.initiatives.list && p.model.initiatives.list.rows) || []).filter(H.OPEN).length;
948
+ // zero is silence: a part that is zero is left out
949
+ return [n ? n + (n === 1 ? ' initiative' : ' initiatives') : '', p.goals && p.goals.n ? p.goals.ok + ' of ' + p.goals.n + ' goals' : ''].filter(Boolean).join(' · ');
950
+ }
951
+ function pickProduct(chip) {
952
+ if (!S.D.pick) return;
953
+ PP.openPicker(chip, { P: S.D.pick, label: 'Products on Home', tones: pickTones(), lines: pickLine, onApply: async (on) => { const r = await PP.savePick(on); if (!r.ok) toast(r.error); } });
954
+ }
955
+ // a saved pick (from this chip or Settings): Home shows and reads the ticked products
956
+ addEventListener('pp:changed', (e) => { if (WS) { location.assign('/premium.html'); return; } S.D.pick = e.detail; drawList(); toast('Saved. Home, Board and Insights show the products you picked.'); load(); });
943
957
 
944
958
  /* ── the Viewer: needs rows, the weekly update, the overview, files, people, routines ── */
945
959
  let lastViewer = null;
@@ -1396,7 +1410,7 @@ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menuEl.
1396
1410
  function moreMenu(anchor) {
1397
1411
  const go = {
1398
1412
  around: () => MORE.openAround(), inbox: () => MORE.openInbox(searchGo), eod: () => MORE.openEndOfDay(), cal: () => openCalendar(),
1399
- rec: () => MORE.openRecorder(), search: () => MORE.openSearch(searchGo), products: () => MORE.openProducts(), sources: () => MORE.openSources(), settings: () => MORE.openSettings(),
1413
+ rec: () => MORE.openRecorder(), search: () => MORE.openSearch(searchGo), sources: () => MORE.openSources(), settings: () => MORE.openSettings(),
1400
1414
  };
1401
1415
  menu(anchor, MORE.moreItems.map(([k, l]) => ({ label: l, go: go[k] })), 'Waiting for design');
1402
1416
  }
@@ -1460,7 +1474,8 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1460
1474
  if ('hmMeet' in d) { const m = H.meetLineOf(S.D.today); if (m) openMeeting(m.meeting); return; }
1461
1475
  if ('hmCal' in d) { openCalendar(); return; }
1462
1476
  if ('hmRec' in d) { MORE.openRecorder().then(() => drawList()); return; }
1463
- if (d.hmRecopen) { openMeeting({ note: d.hmRecopen }); return; }
1477
+ // the pinned row is a snippet: a press brings the recording tab forward (rec-tab-core.js); where it cannot open, the meeting opens here
1478
+ if (d.hmRecopen) { if (!(ownTab() && bring(tabUrl(d.hmRecopen, { ws: WS || '' })))) openMeeting({ note: d.hmRecopen }); return; }
1464
1479
  };
1465
1480
  $('#hmList').addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.id === 'hmCap' && S.cap) { e.stopPropagation(); S.cap = false; drawList(); } else if (e.key === 'Escape' && S.day) { e.stopPropagation(); day(false); } });
1466
1481
  /** Open (id) or close (null) the list behind an initiative's pill (batch 12 item 6). Closing gives the focus back to the pill, unless the
@@ -54,13 +54,20 @@ export function goalsOf(model) {
54
54
  /* A row the brief tags "Across products" names no product: it is not a group of its own, it sits with the rows that name none. */
55
55
  const ACROSS = 'Across products';
56
56
  const prodOf = (x) => (x && x.product && x.product !== ACROSS ? x.product : '');
57
- /** The products the list shows, the board's own product first. Each: { key, ws, name, initials, primary, model, goals, on }. */
57
+ /** The products the list shows, the board's own product first: only the ticked ones (the one product pick, batch 12 item 5: a registered
58
+ * product that is not ticked is not on Home). Each: { key, ws, name, initials, primary, model, goals, tone }. tone: the tile's tint, by the
59
+ * product's place with the board's own first, then the registered order (pm/cozy-pick.js tonesOf), so the chip and the group agree. */
60
+ /** The pick's unticked test: true for a registered product that is not ticked; a product the pick does not list is never hidden. */
61
+ const unticked = (D) => { const P = (D.pick && D.pick.products) || (D.brief && D.brief.products && D.brief.products.available) || []; return (ws) => !!ws && P.some((a) => a.ws === ws && !a.on); };
58
62
  export function productsOf(D) {
59
63
  const out = [];
60
- const add = (p) => { const k = p.ws || 'n:' + String(p.name).toLowerCase(); if (out.some((x) => x.key === k || x.name.toLowerCase() === String(p.name).toLowerCase())) return; out.push({ ...p, key: k, initials: codeOf(p) }); };
61
64
  const b = D.board && D.board.board;
62
65
  const av = (D.brief && D.brief.products && D.brief.products.available) || [];
63
66
  const avOf = (ws) => (ws && av.find((a) => a.ws === ws)) || {}, named = (ws) => avOf(ws).name || '';
67
+ // D.pick is the pick (GET /api/briefing-premium/products; with none saved, the board's own product stays ticked)
68
+ const off = unticked(D);
69
+ const order = [(b && b.ws) || ''].concat(av.map((a) => a.ws).filter((w) => w !== (b && b.ws)));
70
+ const add = (p) => { const k = p.ws || 'n:' + String(p.name).toLowerCase(); if (off(p.ws) || out.some((x) => x.key === k || x.name.toLowerCase() === String(p.name).toLowerCase())) return; const at = p.ws ? order.indexOf(p.ws) : -1; out.push({ ...p, key: k, initials: codeOf(p), tone: (at >= 0 ? at : order.length + out.length) % TONES }); };
64
71
  if (D.board) add({ ws: (b && b.ws) || '', name: (b && b.product) || named(b && b.ws) || productName(D), code: avOf(b && b.ws).initials, primary: true, model: D.board, goals: goalsOf(D.board) });
65
72
  for (const o of D.others || []) if (o && o.model) add({ ws: o.ws, name: o.name || productName({ board: o.model }), code: avOf(o.ws).initials, primary: false, model: o.model, goals: goalsOf(o.model) });
66
73
  for (const a of av) if (a.on) add({ ws: a.ws, name: a.name, code: a.initials, primary: false, model: null, goals: null });
@@ -136,6 +143,7 @@ const isMe = (D, who) => { const me = String((D.today && D.today.me) || '').toLo
136
143
  export function programGroups(D, groups, products, o, now) {
137
144
  const rowsOf = (ws) => { const p = products.find((x) => x.ws === ws); return p ? { name: p.name, rows: (p.model && p.model.initiatives && p.model.initiatives.list && p.model.initiatives.list.rows) || (p.primary ? boardRows(D) : []) } : null; };
138
145
  const pgs = groups.filter((g) => g.kind === 'product');
146
+ const off = unticked(D);
139
147
  const items = pgs.flatMap((g) => g.inis.concat(g.rest).map((r) => ({ id: r.ini, ws: g.product.ws, product: g.name, r, g })));
140
148
  const grouped = groupRows(items, D.programs, { productOf: (x) => x.product, wsOf: (x) => x.ws });
141
149
  const out = [];
@@ -150,16 +158,16 @@ export function programGroups(D, groups, products, o, now) {
150
158
  g.late = g.inis.concat(g.rest).some((i) => i.late);
151
159
  g.closedLine = closedOf(g.count, g.turnN);
152
160
  }
153
- const tasks = (pr.tasks || []).filter((t) => !t.done && (!o.product || !t.ws || products.some((p) => p.key === o.product && p.ws === t.ws))).map((t) => {
161
+ const tasks = (pr.tasks || []).filter((t) => !t.done && !off(t.ws)).map((t) => {
154
162
  const d = t.due ? dayDiff(t.due, now) : null;
155
163
  return { id: 'pt:' + pr.id + ':' + t.key, kind: 'ptask', program: pr.id, key: t.key, ws: t.ws, name: t.title, check: true, state: 'quiet', mine: isMe(D, t.owner), late: d != null && d < 0, due: t.due || '',
156
164
  hint: [t.owner, d == null ? '' : d < 0 ? plural(-d, 'day', 'days') + ' late' : d === 0 ? 'due today' : 'due ' + shortDay(t.due)].filter(Boolean).join(' · ') };
157
165
  });
158
- const subs = ((G && G.products) || []).map((sp) => { const at = products.findIndex((p) => p.name === sp.name); return { name: sp.name, initials: at >= 0 ? products[at].initials : initialsOf(sp.name), tone: Math.max(0, at) % TONES, inis: sp.rows.map((x) => x.r) }; });
166
+ const subs = ((G && G.products) || []).map((sp) => { const at = products.findIndex((p) => p.name === sp.name); return { name: sp.name, initials: at >= 0 ? products[at].initials : initialsOf(sp.name), tone: at >= 0 ? products[at].tone : 0, inis: sp.rows.map((x) => x.r) }; });
159
167
  const inis = subs.flatMap((x) => x.inis);
160
168
  // a program with no open initiative here (just made, or its initiatives all cancelled or archived) still shows, under all products or its
161
- // home product, so the PM finds it and can move initiatives in
162
- const fresh = !o.product || products.some((p) => p.key === o.product && (!pr.home || p.ws === pr.home));
169
+ // home product, so the PM finds it and can move initiatives in; an unticked home product takes it off Home (batch 12 item 5)
170
+ const fresh = !off(pr.home);
163
171
  if (!inis.length && !tasks.length && !fresh) continue;
164
172
  const st = programState(pr, rowsOf, now);
165
173
  const turnN = inis.filter((x) => x.turn).length;
@@ -175,7 +183,7 @@ export function programGroups(D, groups, products, o, now) {
175
183
 
176
184
  /* ── the list ── */
177
185
  const sameName = (a, b) => String(a || '').toLowerCase() === String(b || '').toLowerCase();
178
- /** o: { filter ('today' | 'kept' | 'done'), product (a product key, or null for all), now } */
186
+ /** o: { filter ('today' | 'kept' | 'done'), now }. The products are the ticked ones (productsOf). */
179
187
  export function homeList(D, o = {}) {
180
188
  const now = o.now || D.now || Date.now();
181
189
  const needs = needsOf(D);
@@ -192,7 +200,6 @@ export function homeList(D, o = {}) {
192
200
  ];
193
201
  const groups = [];
194
202
  for (const p of products) {
195
- if (o.product && o.product !== p.key) continue;
196
203
  const rows = (p.model && p.model.initiatives && p.model.initiatives.list && p.model.initiatives.list.rows) || (p.primary ? boardRows(D) : []);
197
204
  const open = rows.filter(OPEN);
198
205
  const ids = new Set(open.map((r) => r.id));
@@ -209,7 +216,7 @@ export function homeList(D, o = {}) {
209
216
  const flat = mineNeeds.filter((x) => !x.ini || !ids.has(x.ini)).filter((x) => !x.needSession).map((x) => ({ ...x, flat: true, hint: bareHint(x) }));
210
217
  const turnN = inis.filter((x) => x.turn).length + flat.length;
211
218
  const shown = inis.filter((x) => x.turn || x.busy);
212
- groups.push({ key: 'p:' + p.key, kind: 'product', product: p, name: p.name, initials: p.initials, tone: products.indexOf(p) % TONES, primary: !!p.primary, goals: p.goals, flat, inis: shown, rest: inis.filter((x) => !shown.includes(x)),
219
+ groups.push({ key: 'p:' + p.key, kind: 'product', product: p, name: p.name, initials: p.initials, tone: p.tone, primary: !!p.primary, goals: p.goals, flat, inis: shown, rest: inis.filter((x) => !shown.includes(x)),
213
220
  count: inis.length, turnN, yours: inis.reduce((n, x) => n + x.yours, 0) + flat.length, late: inis.some((x) => x.late), closedLine: [inis.length ? plural(inis.length, 'initiative', 'initiatives') : '', turnN ? turnN + ' your turn' : ''].filter(Boolean).join(' · ') || 'Nothing open' });
214
221
  }
215
222
  // programs first (program-hierarchy P3): each program takes its initiatives out of their product groups, so an initiative shows once
@@ -223,7 +230,7 @@ export function homeList(D, o = {}) {
223
230
  for (const s of (D.sessions || []).filter((s) => listed(s) && !iniOfSession(s) && s.shown !== 'needs' && s.shown !== 'blocked')) loose.push({ ...sessionRow(s, D.desk && D.desk.roles), loose: true });
224
231
  // the folded line's signals (HvAC .lh): a blue dot when a row waits on the PM, an amber square when one of the PM's own is late
225
232
  const lsig = { needs: loose.filter((r) => r.state === 'needs' || r.state === 'blocked').length, sessions: loose.filter((r) => r.kind === 'session' || r.needSession).length, tasks: loose.filter((r) => r.check).length, late: loose.filter((r) => r.check && r.late).length };
226
- if (!o.product || o.product === 'loose') groups.push({ key: 'loose', kind: 'loose', name: 'Not in an initiative', rows: loose, n: loose.length, sig: lsig });
233
+ groups.push({ key: 'loose', kind: 'loose', name: 'Not in an initiative', rows: loose, n: loose.length, sig: lsig });
227
234
  const stale = staleInis(D, now);
228
235
  const untouched = { n: stale.length + ((W && W.review && W.review.n) || 0), inis: stale.length, items: (W && W.review && W.review.n) || 0, day: new Date(now).getDay() === REVIEW_DAY ? 'today' : 'Fri' };
229
236
  // a filter other than Today shows one plain list from the PM's own list (the items carry no initiative)