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.
- package/package.json +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/board-programs-test.js +41 -26
- package/workspace/briefing-premium-board-test.js +7 -4
- package/workspace/briefing-premium-insights-test.js +31 -15
- package/workspace/briefing-premium-products-test.js +46 -43
- package/workspace/changelog.json +12 -0
- package/workspace/guide/briefing-premium.md +3 -2
- package/workspace/guide/home.md +2 -2
- package/workspace/guide/index.md +1 -0
- package/workspace/guide/notes.md +39 -1
- package/workspace/guide/present-in-a-meeting.md +57 -0
- package/workspace/guide/programs.md +2 -2
- package/workspace/lib/briefing-premium-products.js +18 -4
- package/workspace/lib/meeting-focus.js +64 -14
- package/workspace/lib/routes-briefing-premium.js +19 -0
- package/workspace/lib/routes-meeting-focus.js +28 -6
- package/workspace/lib/settings-store.js +2 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-briefing-depth-test.js +1 -1
- package/workspace/premium-rec-now-test.js +153 -0
- package/workspace/premium-rec-tab-test.js +167 -0
- package/workspace/public/pm/cozy-aud.css +9 -0
- package/workspace/public/pm/cozy-aud.js +80 -0
- package/workspace/public/pm/cozy-live-pill.js +3 -0
- package/workspace/public/pm/cozy-pick.css +41 -0
- package/workspace/public/pm/cozy-pick.js +134 -0
- package/workspace/public/pm/cozy-rec-bridge.js +32 -0
- package/workspace/public/pm/cozy-rec-now.css +104 -0
- package/workspace/public/pm/cozy-rec-now.js +330 -0
- package/workspace/public/pm/cozy-rec-present.css +69 -0
- package/workspace/public/pm/cozy-rec-present.js +467 -0
- package/workspace/public/pm/cozy-rec-tab.css +90 -0
- package/workspace/public/pm/cozy-rec-tab.js +219 -0
- package/workspace/public/pm/cozy-settings.js +8 -2
- package/workspace/public/pm/home-app.js +37 -22
- package/workspace/public/pm/home-list.js +17 -10
- package/workspace/public/pm/home-more.js +2 -31
- package/workspace/public/pm/home-today.js +4 -4
- package/workspace/public/pm/live-model.js +1 -1
- package/workspace/public/pm/premium-board.js +56 -25
- package/workspace/public/pm/premium-insights.js +42 -24
- package/workspace/public/pm/premium-meeting.js +17 -4
- package/workspace/public/pm/premium-mtg-present.js +4 -3
- package/workspace/public/pm/premium-report-read.js +2 -0
- package/workspace/public/pm/premium-vw-mtg.js +15 -7
- package/workspace/public/pm/rec-state.js +13 -5
- package/workspace/public/pm/rec-tab-core.js +92 -0
- package/workspace/public/pm/view-notes.js +9 -0
- package/workspace/public/premium-aud.html +22 -0
- package/workspace/public/premium-board.html +1 -0
- package/workspace/public/premium-insights.html +2 -1
- package/workspace/public/premium-rec.html +30 -0
- package/workspace/public/premium.html +1 -0
- package/workspace/rec-present-test.js +229 -0
- package/workspace/server.js +9 -1
- package/workspace/test-lists/rec-now.json +6 -0
- package/workspace/test-lists/rec-present.json +13 -0
- package/workspace/test-lists/recording-tab.json +13 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* pm/cozy-pick.js — the one product picker Home, Board and Insights share (batch 12 item 5; canvas XhpA1Desk, XhpA2States, XhpA3Phone,
|
|
2
|
+
* XhpA4Dark, XhpA5Pages and the rules sticky).
|
|
3
|
+
*
|
|
4
|
+
* readPick() → { ok, all, products: [{ ws, name, home, primary, initials, on }] } from GET /api/briefing-premium/products, or null
|
|
5
|
+
* savePick(on) → the same answer after POST /api/briefing-premium/products { on: [ws…] }; { ok:false, error } when refused.
|
|
6
|
+
* A saved pick fires pp:changed on the window (detail: the answer); each page follows it there
|
|
7
|
+
* tonesOf(products) → { [ws]: 0 | 1 | 2 }: a product's tint, by its place with the default workspace first (Home's groups use the same)
|
|
8
|
+
* codeOf(p) → the tile's letters: the workspace's own abbreviation, else two letters of its name
|
|
9
|
+
* chipHtml(P, o) → the chip: the ticked products' tiles, overlapped, +N past 3; the word All when every one is ticked
|
|
10
|
+
* openPicker(chip, o) → the list under the chip (a sheet on a phone). o: { P, label, lines(ws), tones?, onApply(on), onAdd()?, note? };
|
|
11
|
+
* Add a product opens Settings › Workspaces (the add flow) unless the page gives its own onAdd
|
|
12
|
+
*
|
|
13
|
+
* THE PICK. One saved setting (ws.briefing.include), never the address: ticked = on Home and read, on every page. All products ticks every one,
|
|
14
|
+
* a press ticks or unticks and the list stays open, the last tick stays, and the pick applies when the list closes (Escape, a press outside,
|
|
15
|
+
* the chip again, or the sheet's scrim). Arrow keys move in the list. Add a product is the last row. Nothing here writes but savePick. */
|
|
16
|
+
import { pmGet, pmPost } from './http.js';
|
|
17
|
+
|
|
18
|
+
export const TONES = 3;
|
|
19
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
20
|
+
const initialsOf = (name) => { const w = String(name || '').trim().split(/[\s_-]+/).filter(Boolean); return (w.length > 1 ? w[0][0] + w[1][0] : String(name || '?').slice(0, 2)).toUpperCase(); };
|
|
21
|
+
export const codeOf = (p) => { const c = String((p && (p.initials || p.code)) || '').replace(/[^A-Za-z0-9]/g, '').slice(0, 3).toUpperCase(); return c || initialsOf(p && p.name); };
|
|
22
|
+
const isPhone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
|
|
23
|
+
const svg = (d, n, w = 2.4) => `<svg width="${n}" height="${n}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
24
|
+
const CHEV_D = 'M6 9l6 6 6-6', CHEV_U = 'M6 15l6-6 6 6', TICK = 'M5 12.5l4.5 4.5L19 7.5', PART = 'M7 12h10', PLUS = 'M12 5v14M5 12h14';
|
|
25
|
+
|
|
26
|
+
// its sheet: linked by Home, Board and Insights; any other page that opens the list (Settings) gets it here
|
|
27
|
+
try { if (!document.querySelector('link[href$="cozy-pick.css"]')) document.head.insertAdjacentHTML('beforeend', `<link rel="stylesheet" href="${new URL('./cozy-pick.css', import.meta.url).href}">`); } catch { /* no document */ }
|
|
28
|
+
|
|
29
|
+
export async function readPick() { const r = await pmGet('/api/briefing-premium/products'); return r && r.ok && Array.isArray(r.products) ? r : null; }
|
|
30
|
+
/** Save the ticks; a saved pick tells the page (window event pp:changed, detail = the answer), so whatever opened the list, the page follows. */
|
|
31
|
+
export async function savePick(on) {
|
|
32
|
+
const r = await pmPost('/api/briefing-premium/products', { on });
|
|
33
|
+
if (!(r && r.ok)) return { ok: false, error: (r && r.error) || 'The pick was not saved.' };
|
|
34
|
+
try { dispatchEvent(new CustomEvent('pp:changed', { detail: r })); } catch { /* no window */ }
|
|
35
|
+
return r;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Every product's tint: the default workspace first, then the registered order (so Home's group, the chip and the list agree). */
|
|
39
|
+
export function tonesOf(products) {
|
|
40
|
+
const L = (products || []).slice().sort((a, b) => (b.primary ? 1 : 0) - (a.primary ? 1 : 0));
|
|
41
|
+
return Object.fromEntries(L.map((p, i) => [p.ws, i % TONES]));
|
|
42
|
+
}
|
|
43
|
+
const isAll = (P) => !!P && P.products.length > 1 && P.products.every((p) => p.on); // one product registered: its tile, never All
|
|
44
|
+
/** The words of the chip (its tooltip and accessible name): "Products on Home: pmos-idpf, pmos-microsites", or "… all 3". */
|
|
45
|
+
export function chipWords(P, label) {
|
|
46
|
+
if (!P || !P.products.length) return label + ': none registered';
|
|
47
|
+
return label + ': ' + (isAll(P) ? 'all ' + P.products.length : P.products.filter((p) => p.on).map((p) => p.name).join(', '));
|
|
48
|
+
}
|
|
49
|
+
export function chipHtml(P, o = {}) {
|
|
50
|
+
const T = o.tones || tonesOf(P ? P.products : []), on = P ? P.products.filter((p) => p.on) : [];
|
|
51
|
+
const inner = !P ? '' : isAll(P) ? '<span class="ppk-all">All</span>'
|
|
52
|
+
: `<span class="ppk-stk">${on.slice(0, 3).map((p) => `<i class="ppk-t t${T[p.ws] || 0}">${esc(codeOf(p))}</i>`).join('')}${on.length > 3 ? `<i class="ppk-t ppk-n">+${on.length - 3}</i>` : ''}</span>`;
|
|
53
|
+
const words = chipWords(P, o.label || 'Products'), id = o.id || 'ppChip', open = !!cur && cur.id === id; // a page that draws again keeps the open state
|
|
54
|
+
return `<button type="button" class="ppk-chip${open ? ' open' : ''}" id="${esc(id)}"${o.attrs ? ' ' + o.attrs : ''} aria-haspopup="menu" aria-expanded="${open}" aria-label="${esc(words)}" title="${esc(words)}">${inner}${svg(open ? CHEV_U : CHEV_D, 14)}</button>`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* ── the list: one at a time ── */
|
|
58
|
+
let cur = null; // { id (the chip's), chip, o, tick: Set of ws, el, scrim }
|
|
59
|
+
const chipOf = (c) => (c.chip.isConnected ? c.chip : document.getElementById(c.id)) || c.chip;
|
|
60
|
+
function itemsHtml(c) {
|
|
61
|
+
const P = c.o.P, T = c.o.tones || tonesOf(P.products), n = P.products.filter((p) => c.tick.has(p.ws)).length;
|
|
62
|
+
const all = n === P.products.length ? 'true' : 'mixed';
|
|
63
|
+
const box = (st) => `<i class="ppk-tk${st === 'true' ? ' on' : st === 'mixed' ? ' part' : ''}" aria-hidden="true">${st === 'true' ? svg(TICK, 13, 3.4) : st === 'mixed' ? svg(PART, 12, 3.4) : ''}</i>`;
|
|
64
|
+
const rows = P.products.map((p) => {
|
|
65
|
+
const on = c.tick.has(p.ws), line = c.o.lines ? c.o.lines(p.ws) : '';
|
|
66
|
+
return `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${on}" data-pp="${esc(p.ws)}"><span class="ppk-tl t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</span><span class="ppk-nm"><b>${esc(p.name)}</b>${line ? `<em>${esc(line)}</em>` : ''}</span>${box(String(on))}</button>`;
|
|
67
|
+
}).join('');
|
|
68
|
+
return (P.products.length > 1 ? `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${all}" data-pp="*"><span class="ppk-nm"><b>All products</b></span>${box(all)}</button><div class="ppk-sep" role="separator"></div>` : '')
|
|
69
|
+
+ rows + (`${P.products.length ? '<div class="ppk-sep" role="separator"></div>' : ''}<button type="button" class="ppk-mi" role="menuitem" data-pp-add><span class="ppk-pl" aria-hidden="true">${svg(PLUS, 18, 2.2)}</span><span class="ppk-nm"><b>Add a product</b></span></button>`)
|
|
70
|
+
+ (c.o.note ? `<p class="ppk-sr" id="ppNote">${esc(c.o.note)}</p>` : '');
|
|
71
|
+
}
|
|
72
|
+
function place(c) {
|
|
73
|
+
const sheet = isPhone();
|
|
74
|
+
c.el.classList.toggle('sheet', sheet); c.scrim.hidden = !sheet;
|
|
75
|
+
if (sheet) { c.el.style.left = c.el.style.top = ''; return; }
|
|
76
|
+
const r = chipOf(c).getBoundingClientRect(), w = Math.min(348, innerWidth - 24);
|
|
77
|
+
c.el.style.left = Math.max(12, Math.min(r.left, innerWidth - w - 12)) + 'px'; c.el.style.top = Math.round(r.bottom + 8) + 'px';
|
|
78
|
+
}
|
|
79
|
+
export function closePicker(apply = true) {
|
|
80
|
+
const c = cur; if (!c) return;
|
|
81
|
+
cur = null;
|
|
82
|
+
c.el.remove(); c.scrim.remove();
|
|
83
|
+
removeEventListener('keydown', onKey, true); document.removeEventListener('click', onOut, true); removeEventListener('resize', onSize);
|
|
84
|
+
const ch = chipOf(c);
|
|
85
|
+
ch.setAttribute('aria-expanded', 'false'); ch.classList.remove('open');
|
|
86
|
+
const sv = ch.querySelector('svg:last-child path'); if (sv) sv.setAttribute('d', CHEV_D);
|
|
87
|
+
if (ch.isConnected) ch.focus();
|
|
88
|
+
const was = c.o.P.products.filter((p) => p.on).map((p) => p.ws), now = c.o.P.products.filter((p) => c.tick.has(p.ws)).map((p) => p.ws);
|
|
89
|
+
if (apply && now.join(',') !== was.join(',')) c.o.onApply(now);
|
|
90
|
+
}
|
|
91
|
+
function onKey(e) {
|
|
92
|
+
if (!cur) return;
|
|
93
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopImmediatePropagation(); closePicker(); return; }
|
|
94
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
const L = [...cur.el.querySelectorAll('button')], i = L.indexOf(document.activeElement);
|
|
97
|
+
L[(i + (e.key === 'ArrowDown' ? 1 : L.length - 1)) % L.length].focus();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function onOut(e) { if (cur && !cur.el.contains(e.target) && !chipOf(cur).contains(e.target)) closePicker(); }
|
|
101
|
+
function onSize() { if (cur) place(cur); }
|
|
102
|
+
/** Open (or, when it is open, close) the list under chip. */
|
|
103
|
+
export function openPicker(chip, o) {
|
|
104
|
+
if (cur && cur.id === chip.id) { closePicker(); return; }
|
|
105
|
+
closePicker();
|
|
106
|
+
const el = document.createElement('div'), scrim = document.createElement('div');
|
|
107
|
+
el.className = 'ppk-menu'; el.id = 'ppMenu'; el.setAttribute('role', 'menu'); el.setAttribute('aria-label', o.label || 'Products');
|
|
108
|
+
el.setAttribute('data-esc-layer', ''); // Escape closes this list first, not the Viewer under it
|
|
109
|
+
if (o.note) el.setAttribute('aria-describedby', 'ppNote');
|
|
110
|
+
scrim.className = 'ppk-scrim'; scrim.hidden = true;
|
|
111
|
+
document.body.append(scrim, el);
|
|
112
|
+
const c = cur = { id: chip.id, chip, o, tick: new Set(o.P.products.filter((p) => p.on).map((p) => p.ws)), el, scrim };
|
|
113
|
+
el.innerHTML = itemsHtml(c); place(c);
|
|
114
|
+
chip.setAttribute('aria-expanded', 'true'); chip.classList.add('open');
|
|
115
|
+
const sv = chip.querySelector('svg:last-child path'); if (sv) sv.setAttribute('d', CHEV_U);
|
|
116
|
+
el.onclick = (e) => {
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
if (e.target.closest('[data-pp-add]')) { closePicker(); if (o.onAdd) o.onAdd(); else import('./cozy-settings.js').then((M) => M.openSettings('workspaces')); return; }
|
|
119
|
+
const k = e.target.closest('[data-pp]'); if (!k) return;
|
|
120
|
+
// All products ticks every one; a product ticks or unticks; the last one stays ticked; the list stays open
|
|
121
|
+
const ws = k.dataset.pp;
|
|
122
|
+
if (ws === '*') o.P.products.forEach((p) => c.tick.add(p.ws));
|
|
123
|
+
else if (!c.tick.has(ws)) c.tick.add(ws);
|
|
124
|
+
else if (c.tick.size > 1) c.tick.delete(ws);
|
|
125
|
+
el.innerHTML = itemsHtml(c);
|
|
126
|
+
const f = el.querySelector(`[data-pp="${CSS.escape(ws)}"]`); if (f) f.focus();
|
|
127
|
+
};
|
|
128
|
+
scrim.onclick = () => closePicker();
|
|
129
|
+
addEventListener('keydown', onKey, true); // the window, before any page's own Escape
|
|
130
|
+
setTimeout(() => document.addEventListener('click', onOut, true), 0);
|
|
131
|
+
addEventListener('resize', onSize);
|
|
132
|
+
const f = el.querySelector('button'); if (f) f.focus();
|
|
133
|
+
}
|
|
134
|
+
export const pickerOpen = () => !!cur;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* pm/cozy-rec-bridge.js — one way to present while a meeting records (batch 12 item 1, S3; rule 10 of the sticky "A · the rules").
|
|
2
|
+
*
|
|
3
|
+
* The recording tab (cozy-rec-tab.js) says on BroadcastChannel('pmos-rec') that it records: { id, state, title, elapsedMs, … } on each change
|
|
4
|
+
* and every 5 s. While a heard state is 'recording' and under 12 s old, Present on a PMOS deck, document or meeting material on any other
|
|
5
|
+
* page does not open its own presenter: it opens the audience tab in the press (the browser allows a tab only then) and asks the recording
|
|
6
|
+
* tab, on BroadcastChannel('pmos-present'), to present it there ({ t: 'present', mat }). The recording tab's presenter view then shows
|
|
7
|
+
* They see this, Next, Notes, Previous and Next beside Now. With no recording, Present works as before.
|
|
8
|
+
*
|
|
9
|
+
* recordingNow(now) → the last heard state while it says 'recording' and is fresh, else null
|
|
10
|
+
* presentInRecording(mat) → true when the recording tab takes it (call it first in the press, before anything is awaited) */
|
|
11
|
+
import { CHANNEL, openAudienceTab } from './cozy-rec-present.js';
|
|
12
|
+
|
|
13
|
+
export const REC_CHANNEL = 'pmos-rec';
|
|
14
|
+
const FRESH_MS = 12000;
|
|
15
|
+
let heard = null, heardAt = 0;
|
|
16
|
+
const rec = typeof BroadcastChannel === 'function' ? new BroadcastChannel(REC_CHANNEL) : null;
|
|
17
|
+
if (rec) rec.addEventListener('message', (e) => { const d = e.data || {}; if (d && d.id && d.state) { heard = d; heardAt = Date.now(); } });
|
|
18
|
+
|
|
19
|
+
export function recordingNow(now = Date.now()) {
|
|
20
|
+
return heard && heard.state === 'recording' && now - heardAt < FRESH_MS ? heard : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** mat: { kind: 'pmos-deck'|'pmos-doc'|'report'|…, ref?, url?, title, ws? } as a meeting-material row names it. */
|
|
24
|
+
export function presentInRecording(mat) {
|
|
25
|
+
if (!mat || !recordingNow() || typeof BroadcastChannel !== 'function') return false;
|
|
26
|
+
if (typeof window !== 'undefined' && window.name === 'pmos-rec') return false; // the recording tab presents by itself
|
|
27
|
+
openAudienceTab(mat.ws || '');
|
|
28
|
+
const ch = new BroadcastChannel(CHANNEL);
|
|
29
|
+
ch.postMessage({ t: 'present', mat });
|
|
30
|
+
ch.close();
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* cozy-rec-now.css — the recording tab's Now panel and live transcript (batch 12 item 1, slice S2; pm/cozy-rec-now.js).
|
|
2
|
+
* Frames XrtA1Tab (the side panel), XrtA7Room (in the room: the topic now big), XrtA7Transcript (the 420px card), XrtA5PhoneRec.
|
|
3
|
+
* Colours are the cozy tokens only, so the dark theme follows cozy.css. Every class starts with rn-. */
|
|
4
|
+
|
|
5
|
+
.rn { flex: 1; height: 100%; display: flex; flex-direction: column; min-height: 0; color: var(--cz-ink); }
|
|
6
|
+
.rn-side { background: var(--cz-card); border-radius: inherit; overflow: hidden; }
|
|
7
|
+
.rn-nw { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 16px; }
|
|
8
|
+
.rn-sec h5 { margin: 0 0 6px; font-size: 12.5px; font-weight: 800; color: var(--cz-ink3); display: flex; align-items: center; gap: 8px; }
|
|
9
|
+
.rn-sec h5 .r { margin-left: auto; font-weight: 700; color: var(--cz-ink3); font-variant-numeric: tabular-nums; }
|
|
10
|
+
|
|
11
|
+
/* To cover */
|
|
12
|
+
.rn-ag { display: flex; flex-direction: column; }
|
|
13
|
+
.rn-ai { display: flex; align-items: center; gap: 10px; min-height: 38px; font-size: 14px; color: var(--cz-ink); padding: 0 4px; }
|
|
14
|
+
.rn-ai .tx { flex: 1; min-width: 0; }
|
|
15
|
+
.rn-ai .m { width: 18px; height: 18px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
|
|
16
|
+
.rn-ai.dn { color: var(--cz-ink3); }
|
|
17
|
+
.rn-ai.dn .m { color: var(--cz-ok); }
|
|
18
|
+
.rn-ai.now { background: var(--cz-bluebg); border-radius: 12px; font-weight: 700; color: var(--cz-blueink); }
|
|
19
|
+
.rn-ai .m i { width: 9px; height: 9px; border-radius: 50%; background: var(--cz-blue); display: block; }
|
|
20
|
+
.rn-ai .m b { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--cz-ink3); opacity: .55; display: block; box-sizing: border-box; }
|
|
21
|
+
.rn-ai .t4 { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--cz-ink3); font-variant-numeric: tabular-nums; }
|
|
22
|
+
|
|
23
|
+
/* Raise now */
|
|
24
|
+
.rn-rz { display: flex; flex-direction: column; gap: 8px; }
|
|
25
|
+
.rn-rq { display: flex; align-items: flex-start; gap: 6px; padding: 10px 6px 10px 12px; border-radius: 14px; background: var(--cz-riskbg); }
|
|
26
|
+
.rn-rq .w { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; color: var(--cz-ink); padding-top: 2px; }
|
|
27
|
+
.rn-rq .w small { display: block; font-size: 12px; font-weight: 700; color: var(--cz-risk); margin-bottom: 2px; }
|
|
28
|
+
.rn-ib { width: 36px; height: 36px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex: none; padding: 0; border: 0; background: none; color: var(--cz-ink2); cursor: pointer; font: inherit; }
|
|
29
|
+
.rn-ib:hover { background: var(--cz-well); }
|
|
30
|
+
.rn-ib:disabled { opacity: .5; cursor: default; }
|
|
31
|
+
|
|
32
|
+
/* the counts line */
|
|
33
|
+
.rn-cgl { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--cz-ink3); padding: 2px 4px; }
|
|
34
|
+
.rn-cgl .dm2 { width: 8px; height: 8px; transform: rotate(45deg); border-radius: 2px; background: var(--cz-blue); flex: none; }
|
|
35
|
+
|
|
36
|
+
/* a question and Claude's answer */
|
|
37
|
+
.rn-chx { display: flex; flex-direction: column; gap: 8px; }
|
|
38
|
+
.rn-chx .q { align-self: flex-end; max-width: 80%; background: var(--cz-solid); color: var(--cz-onsolid); border-radius: 16px 16px 4px 16px; padding: 8px 12px; font-size: 14px; }
|
|
39
|
+
.rn-chx .ca { align-self: flex-start; max-width: 86%; background: var(--cz-card); border-radius: 16px 16px 16px 4px; padding: 10px 6px 10px 12px; font-size: 14px; line-height: 1.45; box-shadow: 0 0 0 1px var(--cz-hair); display: flex; gap: 8px; align-items: flex-start; }
|
|
40
|
+
.rn-chx .ca .w { flex: 1; min-width: 0; padding-top: 1px; }
|
|
41
|
+
.rn-chx .ca.bad .w { color: var(--cz-late); }
|
|
42
|
+
.rn-chx .ca .sp { color: var(--cz-blueink); background: var(--cz-bluebg); width: 24px; height: 24px; border-radius: 999px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
|
|
43
|
+
.rn-chx .ca .src { display: block; font-size: 12px; font-weight: 700; color: var(--cz-ink3); margin-top: 2px; }
|
|
44
|
+
.rn-chx .ca .rn-ib { width: 32px; height: 32px; }
|
|
45
|
+
.rn-dots { display: inline-flex; gap: 4px; padding: 6px 0; }
|
|
46
|
+
.rn-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--cz-ink3); opacity: .4; animation: rn-dot 1.2s infinite ease-in-out; }
|
|
47
|
+
.rn-dots i:nth-child(2) { animation-delay: .15s; } .rn-dots i:nth-child(3) { animation-delay: .3s; }
|
|
48
|
+
@keyframes rn-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .8; } }
|
|
49
|
+
@media (prefers-reduced-motion: reduce) { .rn-dots i { animation: none; } }
|
|
50
|
+
|
|
51
|
+
/* the note box */
|
|
52
|
+
.rn-err { margin: 0 16px 6px; font-size: 13px; color: var(--cz-late); }
|
|
53
|
+
.rn-err[hidden] { display: none; }
|
|
54
|
+
.rn-mine { margin: 0 12px 12px; border-radius: 18px; background: var(--cz-well); padding: 8px 8px 8px 14px; display: flex; align-items: flex-end; gap: 8px; }
|
|
55
|
+
.rn-mine textarea { flex: 1; min-width: 0; min-height: 36px; max-height: 120px; resize: none; border: 0; outline: 0; background: none; font: inherit; font-size: 14px; line-height: 1.45; color: var(--cz-ink); padding: 8px 0; }
|
|
56
|
+
.rn-mine textarea::placeholder { color: var(--cz-ink3); }
|
|
57
|
+
.rn-send { width: 36px; height: 36px; border-radius: 50%; background: var(--cz-solid); color: var(--cz-onsolid); display: inline-flex; align-items: center; justify-content: center; flex: none; border: 0; padding: 0; cursor: pointer; }
|
|
58
|
+
.rn-send:disabled { opacity: .5; }
|
|
59
|
+
|
|
60
|
+
/* In the room (microphone only): the topic now big, chips for done and Next, two prompts side by side */
|
|
61
|
+
.rn-room { flex: 1; min-width: 0; background: none; }
|
|
62
|
+
.rn-room .rn-nw { width: 100%; max-width: 1000px; margin: 0 auto; box-sizing: border-box; padding: 24px 32px 16px; gap: 24px; justify-content: center; }
|
|
63
|
+
.rn-now small { display: block; font-size: 13px; font-weight: 800; color: var(--cz-blueink); margin-bottom: 6px; }
|
|
64
|
+
.rn-now h1 { margin: 0; font-size: 34px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
|
|
65
|
+
.rn-now p { margin: 8px 0 0; font-size: 14px; font-weight: 700; color: var(--cz-ink3); }
|
|
66
|
+
.rn-stp { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
67
|
+
.rn-stp span { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; background: var(--cz-card); font-size: 14px; font-weight: 700; color: var(--cz-ink2); box-shadow: 0 0 0 1px var(--cz-hair); }
|
|
68
|
+
.rn-stp .dn { color: var(--cz-ink3); }
|
|
69
|
+
.rn-stp .dn svg { color: var(--cz-ok); }
|
|
70
|
+
.rn-stp b { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--cz-ink3); opacity: .55; display: block; box-sizing: border-box; }
|
|
71
|
+
.rn-room .rn-rz { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
|
72
|
+
.rn-room .rn-rq .w { font-size: 15px; }
|
|
73
|
+
.rn-room .rn-cgl { padding: 0; }
|
|
74
|
+
.rn-room .rn-mine { width: calc(100% - 64px); max-width: 936px; margin: 0 auto 16px; box-sizing: border-box; background: var(--cz-card); box-shadow: 0 0 0 1px var(--cz-hair); }
|
|
75
|
+
|
|
76
|
+
/* the live transcript: a 420px rounded card beside Now, closed by default */
|
|
77
|
+
.rn-trp { width: 420px; flex: none; background: var(--cz-card); border-radius: 20px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
|
|
78
|
+
.rn-trp[hidden] { display: none; }
|
|
79
|
+
.rn-trp .th2 { display: flex; align-items: center; height: 60px; padding: 0 8px 0 20px; font-size: 15px; font-weight: 800; flex: none; }
|
|
80
|
+
.rn-trp .th2 span { flex: 1; }
|
|
81
|
+
.rn-trp .tfeed { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 0 20px 20px; }
|
|
82
|
+
.rn-trp .tfeed > :first-child { margin-top: auto; }
|
|
83
|
+
.rn-trp .l { display: flex; gap: 10px; font-size: 14.5px; line-height: 1.5; color: var(--cz-ink3); }
|
|
84
|
+
.rn-trp .l .t { flex: none; width: 34px; font-size: 12px; font-weight: 700; color: var(--cz-ink3); padding-top: 2px; font-variant-numeric: tabular-nums; }
|
|
85
|
+
.rn-trp .l b { flex: none; width: 52px; color: var(--cz-ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
86
|
+
.rn-trp .l.now { color: var(--cz-ink); }
|
|
87
|
+
.rn-trp .l.now b { color: var(--cz-blueink); }
|
|
88
|
+
.rn-trp .mk { display: inline-flex; vertical-align: -1px; margin-left: 6px; }
|
|
89
|
+
.rn-trp .mk.hl { color: var(--cz-risk); }
|
|
90
|
+
.rn-trp .mk .dm { width: 9px; height: 9px; transform: rotate(45deg); border-radius: 2px; background: var(--cz-blue); display: inline-block; }
|
|
91
|
+
|
|
92
|
+
/* Phone: the panel under the stage, full width; the transcript is a sheet over it */
|
|
93
|
+
@media (max-width: 720px) {
|
|
94
|
+
.rn-room .rn-nw { padding: 20px 16px 12px; gap: 18px; justify-content: flex-start; }
|
|
95
|
+
.rn-now h1 { font-size: 26px; }
|
|
96
|
+
.rn-room .rn-rz { grid-template-columns: 1fr; }
|
|
97
|
+
.rn-room .rn-mine { width: calc(100% - 32px); }
|
|
98
|
+
.rn-trp { position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; width: auto; height: 70vh; border-radius: 22px 22px 0 0; box-shadow: var(--cz-sheet); }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* the bar's icons the panel adds (the tab styles them as .rt-b, whose display wins over [hidden]) */
|
|
102
|
+
[data-slot="now"] .rt-b[hidden] { display: none; }
|
|
103
|
+
.rn-mine:focus-within { box-shadow: 0 0 0 2px var(--cz-blue); }
|
|
104
|
+
.rn-mine textarea:focus-visible { outline: none; }
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/* pm/cozy-rec-now.js — the recording tab's Now panel and its live transcript (batch 12 item 1, slice S2; frames XrtA1Tab side, XrtA7Room,
|
|
2
|
+
* XrtA7Transcript, XrtA5PhoneRec on the main canvas).
|
|
3
|
+
*
|
|
4
|
+
* nowModel(F, one, { now? }) → Model pure: what the Now panel shows, from GET /api/meeting-focus (F) and GET /api/notes/one (one)
|
|
5
|
+
* nowHtml(m, { room? }) → string To cover (or, in the room, the topic now big with chips), Raise now, the counts line, the last answer
|
|
6
|
+
* transcriptModel(one, { max? }) → [Line] pure: the live transcript, oldest first, with the highlight and decision marks
|
|
7
|
+
* transcriptHtml(lines) → string the 420px card's feed
|
|
8
|
+
* kindOf(text) → 'ask' | 'note' a line that ends with "?" asks Claude; anything else is kept as a note
|
|
9
|
+
* fromLine(note) → string "From the talk and last time": where an answer came from
|
|
10
|
+
* mountNow(slots, ctx) → { stop, refresh, toggleTranscript } pm/cozy-rec-tab.js mounts it: with a screen the panel fills `side`, in the room
|
|
11
|
+
* it fills the light `stage`; the side-panel toggle and the transcript icon go in the bar's [data-slot="now"]; the transcript card sits beside.
|
|
12
|
+
*
|
|
13
|
+
* The panel has no tabs and no header. Every part is silent at zero: no topics, no prompts, no counts, no answer → no line.
|
|
14
|
+
* Reads: the tab's own reads (ctx.note(): GET /api/notes/one, for the highlights and the transcript; ctx.focus(): GET /api/meeting-focus, every 15 s),
|
|
15
|
+
* redrawn on the tab's 'note', 'mode' and 'tick'. After a press, and every 3 s while Claude answers a question, it reads GET /api/meeting-focus itself. Writes, each on a press: POST /api/meeting-focus/raise (✓ raised, ✗ not now), POST /api/notes/save
|
|
16
|
+
* (a note, or an answer kept with +), POST /api/meeting-focus/ask (a question; the answer comes back on the next read). */
|
|
17
|
+
import { pmGet, pmPost } from './http.js';
|
|
18
|
+
|
|
19
|
+
const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
20
|
+
const P = {
|
|
21
|
+
check: 'M5 12.5l4.5 4.5L19 7.5',
|
|
22
|
+
x: 'M6 6l12 12M18 6L6 18',
|
|
23
|
+
up: 'M12 19V5M6 11l6-6 6 6',
|
|
24
|
+
plus: 'M12 5v14M5 12h14',
|
|
25
|
+
lines: 'M4 6h16M4 11h16M4 16h10',
|
|
26
|
+
star: 'M12 4l2.4 5 5.6.8-4 3.9 1 5.5-5-2.7-5 2.7 1-5.5-4-3.9 5.6-.8z',
|
|
27
|
+
spark: 'M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8',
|
|
28
|
+
};
|
|
29
|
+
const svg = (d, n = 17, w = 1.8, fill = false) => `<svg width="${n}" height="${n}" viewBox="0 0 24 24" fill="${fill ? 'currentColor' : 'none'}" stroke="currentColor" stroke-width="${w}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${d}"/></svg>`;
|
|
30
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
31
|
+
const mmss = (ms) => { const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)); return Math.floor(s / 60) + ':' + String(s % 60).padStart(2, '0'); };
|
|
32
|
+
const FROM_WORDS = { talk: 'the talk', screen: 'the screen', prep: 'the prep', last: 'last time' };
|
|
33
|
+
const RAISE_LABEL = { check: 'Check', 'follow-up': 'Follow-up', 'no-owner': 'No owner yet' };
|
|
34
|
+
export const BOX_HINT = 'Note, or ask Claude…';
|
|
35
|
+
|
|
36
|
+
export const kindOf = (text) => (/\?\s*$/.test(String(text || '').trim()) ? 'ask' : 'note');
|
|
37
|
+
|
|
38
|
+
/** "From the talk and last time" from an answer note's `from` list; its free `src` when it names none. */
|
|
39
|
+
export function fromLine(note) {
|
|
40
|
+
const words = (Array.isArray(note && note.from) ? note.from : []).map((k) => FROM_WORDS[k]).filter(Boolean);
|
|
41
|
+
if (!words.length) return note && note.src ? 'From ' + String(note.src).replace(/^from\s+/i, '') : '';
|
|
42
|
+
return 'From ' + (words.length === 1 ? words[0] : words.slice(0, -1).join(', ') + ' and ' + words[words.length - 1]);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The small line over a Raise now prompt: "Check · from the screen", "Follow-up · from Oct 19", "No owner yet". */
|
|
46
|
+
export function raiseLabel(r) {
|
|
47
|
+
const head = RAISE_LABEL[r && r.kind] || 'Raise';
|
|
48
|
+
return r && r.from && r.kind !== 'no-owner' ? head + ' · from ' + String(r.from).replace(/^from\s+/i, '') : head;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** What the Now panel shows. F = GET /api/meeting-focus's answer; one = GET /api/notes/one's answer. Nothing is invented. */
|
|
52
|
+
export function nowModel(F, one, { now = Date.now() } = {}) {
|
|
53
|
+
const f = F && F.ok ? F : {};
|
|
54
|
+
const n = one && one.ok && one.note ? one.note : null;
|
|
55
|
+
const nowMs = Number.isFinite(f.now_ms) ? f.now_ms : now;
|
|
56
|
+
const ev = f.event || {};
|
|
57
|
+
const startMs = Date.parse(ev.at);
|
|
58
|
+
const endMs = Date.parse(ev.end);
|
|
59
|
+
const nowMin = Number.isFinite(startMs) ? (nowMs - startMs) / 60000 : null;
|
|
60
|
+
const runs = Array.isArray(f.runs) ? f.runs : [];
|
|
61
|
+
const spentMs = (id) => runs.filter((r) => r.topic === id).reduce((s, r) => s + ((r.to_min == null ? (nowMin == null ? r.from_min : nowMin) : r.to_min) - r.from_min) * 60000, 0);
|
|
62
|
+
const topics = (Array.isArray(f.topics) ? f.topics : []).filter((t) => t && t.state !== 'parked').map((t) => ({
|
|
63
|
+
id: t.id, text: t.text, state: t.state === 'now' ? 'now' : t.state === 'discussed' ? 'done' : 'open', spent: Math.max(0, spentMs(t.id)),
|
|
64
|
+
}));
|
|
65
|
+
const current = topics.find((t) => t.state === 'now') || null;
|
|
66
|
+
const left = Number.isFinite(endMs) && endMs > nowMs ? Math.ceil((endMs - nowMs) / 60000) : null;
|
|
67
|
+
const cap = f.captured || {};
|
|
68
|
+
const counts = { decisions: (cap.decisions || []).length, steps: (cap.actions || []).length, highlights: n && !n.private && Array.isArray(n.highlights) ? n.highlights.length : 0 };
|
|
69
|
+
const parts = [];
|
|
70
|
+
if (counts.decisions) parts.push(plural(counts.decisions, 'decision', 'decisions'));
|
|
71
|
+
if (counts.steps) parts.push(plural(counts.steps, 'next step', 'next steps'));
|
|
72
|
+
if (counts.highlights) parts.push(plural(counts.highlights, 'highlight', 'highlights'));
|
|
73
|
+
const raise = (Array.isArray(f.raise) ? f.raise : []).slice(0, 2).map((r) => ({ id: r.id, kind: r.kind, text: r.text, label: raiseLabel(r) }));
|
|
74
|
+
// the last question asked in this meeting and its answer (or that Claude is on it, or why it failed)
|
|
75
|
+
const asks = Array.isArray(f.asks) ? f.asks : [];
|
|
76
|
+
const lastAsk = asks.length ? asks[asks.length - 1] : null;
|
|
77
|
+
let answer = null;
|
|
78
|
+
if (lastAsk) {
|
|
79
|
+
const a = (Array.isArray(f.notes) ? f.notes : []).filter((x) => x.ask === lastAsk.id).pop() || null;
|
|
80
|
+
answer = { id: lastAsk.id, question: lastAsk.question, state: a ? 'answered' : lastAsk.state === 'failed' ? 'failed' : 'working',
|
|
81
|
+
body: a ? a.body : lastAsk.state === 'failed' ? (lastAsk.error || 'Claude could not answer. Ask again.') : '', from: a ? fromLine(a) : '' };
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
noteId: n ? n.id : (f.note && f.note.id) || '',
|
|
85
|
+
topics, current, next: topics.find((t) => t.state === 'open') || null,
|
|
86
|
+
onIt: current ? Math.max(0, Math.round(current.spent / 60000)) : null,
|
|
87
|
+
left, raise, counts: parts.join(' · '), answer,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const mark = (state) => (state === 'done' ? svg(P.check, 16) : state === 'now' ? '<i></i>' : '<b></b>');
|
|
92
|
+
|
|
93
|
+
/** The panel's body (not the note box, which the page keeps so a half-typed line survives a redraw). */
|
|
94
|
+
export function nowHtml(m, { room = false } = {}) {
|
|
95
|
+
let h = '';
|
|
96
|
+
if (room) {
|
|
97
|
+
if (m.current) {
|
|
98
|
+
const sub = [m.onIt != null ? m.onIt + ' min on it' : '', m.left != null ? m.left + ' min left' : ''].filter(Boolean).join(' · ');
|
|
99
|
+
h += `<div class="rn-now"><small>Now</small><h1>${esc(m.current.text)}</h1>${sub ? `<p>${esc(sub)}</p>` : ''}</div>`;
|
|
100
|
+
}
|
|
101
|
+
const chips = m.topics.filter((t) => t.state === 'done').map((t) => `<span class="dn" role="listitem">${svg(P.check, 15)}${esc(t.text)}</span>`);
|
|
102
|
+
if (m.next) chips.push(`<span role="listitem"><b></b>Next: ${esc(m.next.text)}</span>`);
|
|
103
|
+
if (!m.current && !chips.length && m.topics.length) m.topics.forEach((t) => chips.push(`<span role="listitem"><b></b>${esc(t.text)}</span>`));
|
|
104
|
+
if (chips.length) h += `<div class="rn-stp" role="list" aria-label="To cover">${chips.join('')}</div>`;
|
|
105
|
+
} else if (m.topics.length) {
|
|
106
|
+
h += `<section class="rn-sec" aria-label="To cover"><h5>To cover${m.left != null ? `<span class="r">${m.left} min left</span>` : ''}</h5><div class="rn-ag">`
|
|
107
|
+
+ m.topics.map((t) => `<div class="rn-ai ${t.state === 'done' ? 'dn' : t.state === 'now' ? 'now' : ''}"${t.state === 'now' ? ' aria-current="true"' : ''}><span class="m" aria-hidden="true">${mark(t.state)}</span><span class="tx">${esc(t.text)}</span>${t.state === 'done' && t.spent >= 30000 ? `<span class="t4">${mmss(t.spent)}</span>` : ''}</div>`).join('')
|
|
108
|
+
+ '</div></section>';
|
|
109
|
+
}
|
|
110
|
+
if (m.raise.length) {
|
|
111
|
+
h += `<section class="rn-sec" aria-label="Raise now">${room ? '' : '<h5>Raise now</h5>'}<div class="rn-rz">`
|
|
112
|
+
+ m.raise.map((r) => `<div class="rn-rq" data-raise="${esc(r.id)}"><span class="w"><small>${esc(r.label)}</small>${esc(r.text)}</span>`
|
|
113
|
+
+ `<button type="button" class="rn-ib" data-rn="raised" aria-label="Raised" title="Raised">${svg(P.check)}</button>`
|
|
114
|
+
+ `<button type="button" class="rn-ib" data-rn="skip" aria-label="Not now" title="Not now">${svg(P.x)}</button></div>`).join('')
|
|
115
|
+
+ '</div></section>';
|
|
116
|
+
}
|
|
117
|
+
if (m.counts) h += `<div class="rn-cgl" aria-label="Caught so far"><span class="dm2" aria-hidden="true"></span>${esc(m.counts)}</div>`;
|
|
118
|
+
if (m.answer) {
|
|
119
|
+
const a = m.answer;
|
|
120
|
+
h += `<div class="rn-chx" aria-live="polite"><div class="q">${esc(a.question)}</div>`
|
|
121
|
+
+ `<div class="ca${a.state === 'failed' ? ' bad' : ''}" data-answer="${esc(a.id)}"><span class="sp" aria-hidden="true">${svg(P.spark, 14, 2)}</span>`
|
|
122
|
+
+ (a.state === 'working' ? '<span class="w"><span class="rn-dots" role="status" aria-label="Claude is answering"><i></i><i></i><i></i></span></span>'
|
|
123
|
+
: `<span class="w">${esc(a.body)}${a.from ? `<span class="src">${esc(a.from)}</span>` : ''}</span>`)
|
|
124
|
+
+ (a.state === 'answered' ? `<button type="button" class="rn-ib" data-rn="keep" aria-label="Keep as a note" title="Keep as a note">${svg(P.plus)}</button>` : '')
|
|
125
|
+
+ '</div></div>';
|
|
126
|
+
}
|
|
127
|
+
return h;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** The live transcript, oldest first: { t, who, text, hl, dec, now }. A highlight marks the line said at or just before it; a decision line carries ◆. */
|
|
131
|
+
export function transcriptModel(one, { max = 80 } = {}) {
|
|
132
|
+
const n = one && one.ok && one.note ? one.note : null;
|
|
133
|
+
if (!n || n.private) return [];
|
|
134
|
+
const names = n.speakers || {};
|
|
135
|
+
const who = (src) => names[src] || { mic: 'You', meeting: 'Meeting', speech: 'You', typed: 'You (typed)' }[src] || 'You';
|
|
136
|
+
const tr = (Array.isArray(n.transcript) ? n.transcript : []).filter((x) => x && !x.dropped && typeof x.text === 'string' && x.text.trim());
|
|
137
|
+
const rows = tr.slice(-max).map((x) => ({ t: Number.isFinite(x.t) ? x.t : null, who: who(x.source), text: x.text.trim(), hl: false, dec: x.cat === 'decision', now: false }));
|
|
138
|
+
for (const h of Array.isArray(n.highlights) ? n.highlights : []) {
|
|
139
|
+
const ht = Number(h && (h.t != null ? h.t : h.from));
|
|
140
|
+
if (!Number.isFinite(ht)) continue;
|
|
141
|
+
let hit = null; for (const r of rows) if (r.t != null && r.t <= ht + 1000) hit = r;
|
|
142
|
+
if (hit) hit.hl = true;
|
|
143
|
+
}
|
|
144
|
+
if (rows.length) rows[rows.length - 1].now = true;
|
|
145
|
+
return rows;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function transcriptHtml(lines) {
|
|
149
|
+
if (!lines.length) return '';
|
|
150
|
+
return lines.map((l) => `<div class="l${l.now ? ' now' : ''}"><span class="t">${l.t != null ? mmss(l.t) : ''}</span><b>${esc(l.who)}</b><span>${esc(l.text)}`
|
|
151
|
+
+ (l.hl ? `<span class="mk hl" role="img" aria-label="Your highlight">${svg(P.star, 12, 1.8, true)}</span>` : '')
|
|
152
|
+
+ (l.dec ? '<span class="mk" role="img" aria-label="Decision"><i class="dm"></i></span>' : '') + '</span></div>').join('');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* ── the page part ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
156
|
+
|
|
157
|
+
const ASK_POLL_MS = 3000; // while Claude answers, the panel reads the meeting itself instead of waiting for the tab's 15 s read
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Mount the Now panel into the recording tab (pm/cozy-rec-tab.js calls it). slots = { stage, side, bar }; ctx = { ws, note(), mode(), on(evt, fn),
|
|
161
|
+
* focus(), event }. With a screen the panel fills `side` (unhidden here); in the room (microphone only) it fills the light `stage`. The bar's
|
|
162
|
+
* [data-slot="now"] takes the side-panel toggle (only with a screen) and the transcript icon. → { stop, refresh, toggleTranscript }
|
|
163
|
+
*/
|
|
164
|
+
export function mountNow(slots, ctx) {
|
|
165
|
+
const noop = { stop() {}, refresh() {}, toggleTranscript() {} };
|
|
166
|
+
if (!slots || !ctx || (!slots.side && !slots.stage)) return noop;
|
|
167
|
+
const q = (o) => new URLSearchParams(Object.fromEntries(Object.entries(o).filter(([, v]) => v != null && v !== ''))).toString();
|
|
168
|
+
const oneNow = () => { try { return typeof ctx.note === 'function' ? ctx.note() : null; } catch { return null; } };
|
|
169
|
+
const noteId = () => { const o = oneNow(); return o && o.note ? o.note.id : ''; };
|
|
170
|
+
const modeNow = () => { try { return typeof ctx.mode === 'function' ? ctx.mode() : 'screen'; } catch { return 'screen'; } };
|
|
171
|
+
|
|
172
|
+
if (!document.querySelector('link[data-rn-css]')) {
|
|
173
|
+
const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./cozy-rec-now.css', import.meta.url).href; l.setAttribute('data-rn-css', '');
|
|
174
|
+
document.head.appendChild(l);
|
|
175
|
+
}
|
|
176
|
+
const wrap = document.createElement('div');
|
|
177
|
+
wrap.className = 'rn';
|
|
178
|
+
wrap.innerHTML = `<div class="rn-nw" data-rn-body></div><p class="rn-err" role="alert" hidden></p>`
|
|
179
|
+
+ `<form class="rn-mine" data-rn-box><textarea rows="1" aria-label="${BOX_HINT}" placeholder="${BOX_HINT}"></textarea>`
|
|
180
|
+
+ `<button type="submit" class="rn-send" aria-label="Keep the note" title="Keep the note">${svg(P.up, 16)}</button></form>`;
|
|
181
|
+
const body = wrap.querySelector('[data-rn-body]');
|
|
182
|
+
const err = wrap.querySelector('.rn-err');
|
|
183
|
+
const box = wrap.querySelector('[data-rn-box]');
|
|
184
|
+
const ta = box.querySelector('textarea');
|
|
185
|
+
const send = box.querySelector('.rn-send');
|
|
186
|
+
|
|
187
|
+
// the bar's icons: the side panel (with a screen only) and the transcript
|
|
188
|
+
const slot = slots.bar ? slots.bar.querySelector('[data-slot="now"]') || slots.bar : null;
|
|
189
|
+
const iconBtn = (label, d) => { const b = document.createElement('button'); b.type = 'button'; b.className = 'rt-b'; b.setAttribute('aria-label', label); b.title = label; b.innerHTML = svg(d); return b; };
|
|
190
|
+
const sideBtn = slot ? iconBtn('Hide the side panel', 'M3.5 7.5a3 3 0 013-3h11a3 3 0 013 3v9a3 3 0 01-3 3h-11a3 3 0 01-3-3zM14 4.5v15') : null;
|
|
191
|
+
const tBtn = slot ? iconBtn('Live transcript', P.lines) : null;
|
|
192
|
+
if (sideBtn) { sideBtn.classList.add('rn-sbtn'); sideBtn.setAttribute('aria-pressed', 'true'); slot.appendChild(sideBtn); }
|
|
193
|
+
if (tBtn) { tBtn.classList.add('rn-tbtn'); tBtn.setAttribute('aria-pressed', 'false'); slot.appendChild(tBtn); }
|
|
194
|
+
|
|
195
|
+
// the transcript: a 420px card beside the panel, closed by default
|
|
196
|
+
const card = document.createElement('aside');
|
|
197
|
+
card.className = 'rn-trp'; card.hidden = true; card.setAttribute('aria-label', 'Live transcript');
|
|
198
|
+
card.innerHTML = `<div class="th2"><span>Live transcript</span><button type="button" class="rn-ib" data-rn="tclose" aria-label="Close" title="Close">${svg(P.x)}</button></div><div class="tfeed" aria-live="polite"></div>`;
|
|
199
|
+
const feed = card.querySelector('.tfeed');
|
|
200
|
+
|
|
201
|
+
let room = null, sideOpen = true, open = false, last = '', lastT = '', own = null, askTimer = null, stopped = false;
|
|
202
|
+
/** Where the panel lives: the light page in the room, the side card with a screen. Paused or idle keeps the last place. */
|
|
203
|
+
const place = () => {
|
|
204
|
+
const md = modeNow();
|
|
205
|
+
// nothing to follow before the meeting records or after it stopped; paused keeps the last place (the light page at first)
|
|
206
|
+
wrap.hidden = !['room', 'screen', 'paused'].includes(md);
|
|
207
|
+
const want = md === 'room' ? true : md === 'screen' ? false : room == null ? true : room;
|
|
208
|
+
if (want !== room || !wrap.parentElement) {
|
|
209
|
+
room = want || !slots.side;
|
|
210
|
+
const host = room ? slots.stage : slots.side;
|
|
211
|
+
if (!host) return;
|
|
212
|
+
wrap.classList.toggle('rn-room', room); wrap.classList.toggle('rn-side', !room);
|
|
213
|
+
host.appendChild(wrap);
|
|
214
|
+
(slots.side || host).after(card); // the card sits after the side card in both modes: its own rounded card beside everything
|
|
215
|
+
last = '';
|
|
216
|
+
}
|
|
217
|
+
if (slots.side) slots.side.hidden = room || !sideOpen || wrap.hidden;
|
|
218
|
+
if (sideBtn) sideBtn.hidden = room || wrap.hidden;
|
|
219
|
+
if (tBtn) tBtn.hidden = wrap.hidden;
|
|
220
|
+
if (wrap.hidden && open) setOpen(false);
|
|
221
|
+
};
|
|
222
|
+
const focusNow = () => {
|
|
223
|
+
let f = null; try { f = typeof ctx.focus === 'function' ? ctx.focus() : null; } catch { f = null; }
|
|
224
|
+
// the panel's own read (after a press, or while Claude answers) wins until the tab's read is newer
|
|
225
|
+
if (own && (!f || !f.ok || !(f.now_ms > own.now_ms))) return own;
|
|
226
|
+
own = null; return f;
|
|
227
|
+
};
|
|
228
|
+
const say = (msg) => { err.textContent = msg || ''; err.hidden = !msg; };
|
|
229
|
+
const draw = () => {
|
|
230
|
+
if (stopped) return;
|
|
231
|
+
place();
|
|
232
|
+
const one = oneNow();
|
|
233
|
+
const h = nowHtml(nowModel(focusNow(), one), { room });
|
|
234
|
+
if (h !== last) { body.innerHTML = h; last = h; }
|
|
235
|
+
if (open) {
|
|
236
|
+
const t = transcriptHtml(transcriptModel(one));
|
|
237
|
+
if (t !== lastT) {
|
|
238
|
+
const atEnd = feed.scrollHeight - feed.scrollTop - feed.clientHeight < 40;
|
|
239
|
+
feed.innerHTML = t; lastT = t;
|
|
240
|
+
if (atEnd) feed.scrollTop = feed.scrollHeight;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
/** Read the meeting now (after a press; while a question is answered). */
|
|
245
|
+
const read = async () => {
|
|
246
|
+
const id = noteId(); if (!id || stopped) return;
|
|
247
|
+
const f = await pmGet('/api/meeting-focus?' + q({ note: id, ws: ctx.ws }));
|
|
248
|
+
if (stopped || !f || !f.ok) return;
|
|
249
|
+
own = f; draw();
|
|
250
|
+
const working = (f.asks || []).some((a) => a.state === 'working');
|
|
251
|
+
clearTimeout(askTimer); askTimer = working ? setTimeout(read, ASK_POLL_MS) : null;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const setOpen = (v) => {
|
|
255
|
+
open = !!v; card.hidden = !open;
|
|
256
|
+
if (tBtn) { tBtn.setAttribute('aria-pressed', String(open)); tBtn.classList.toggle('on', open); }
|
|
257
|
+
if (open) { lastT = ''; draw(); feed.scrollTop = feed.scrollHeight; }
|
|
258
|
+
};
|
|
259
|
+
if (tBtn) tBtn.addEventListener('click', () => setOpen(!open));
|
|
260
|
+
if (sideBtn) sideBtn.addEventListener('click', () => {
|
|
261
|
+
sideOpen = !sideOpen; if (slots.side && !room) slots.side.hidden = !sideOpen;
|
|
262
|
+
const label = sideOpen ? 'Hide the side panel' : 'Show the side panel';
|
|
263
|
+
sideBtn.setAttribute('aria-label', label); sideBtn.title = label; sideBtn.setAttribute('aria-pressed', String(sideOpen));
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
/** Add a line to the note's own notes (the same body the Viewer's Your notes edits). */
|
|
267
|
+
const keep = async (line) => {
|
|
268
|
+
const n = (oneNow() || {}).note;
|
|
269
|
+
if (!n) { say('The note was not found, so nothing was kept.'); return false; }
|
|
270
|
+
const before = String(n.body || '').replace(/\s+$/, '');
|
|
271
|
+
const next = before + (before ? '\n' : '') + line;
|
|
272
|
+
const r = await pmPost('/api/notes/save', { id: n.id, body: next });
|
|
273
|
+
if (!r || !r.ok) { say('Not kept: ' + ((r && r.error) || 'no answer')); return false; }
|
|
274
|
+
n.body = next; say(''); return true;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
ta.addEventListener('input', () => {
|
|
278
|
+
const ask = kindOf(ta.value) === 'ask';
|
|
279
|
+
send.setAttribute('aria-label', ask ? 'Ask Claude' : 'Keep the note'); send.title = ask ? 'Ask Claude' : 'Keep the note';
|
|
280
|
+
ta.style.height = ''; if (ta.value) ta.style.height = Math.min(ta.scrollHeight, 120) + 'px';
|
|
281
|
+
});
|
|
282
|
+
ta.addEventListener('keydown', (e) => { if (e.key === 'Enter' && !e.shiftKey && !e.isComposing) { e.preventDefault(); box.requestSubmit(); } });
|
|
283
|
+
box.addEventListener('submit', async (e) => {
|
|
284
|
+
e.preventDefault();
|
|
285
|
+
const text = ta.value.trim(); if (!text) return;
|
|
286
|
+
send.disabled = true;
|
|
287
|
+
try {
|
|
288
|
+
if (kindOf(text) === 'ask') {
|
|
289
|
+
const r = await pmPost('/api/meeting-focus/ask', { note: noteId(), question: text, ws: ctx.ws });
|
|
290
|
+
if (!r || !r.ok) { say('Claude could not take the question: ' + ((r && r.error) || 'no answer')); return; }
|
|
291
|
+
// the question shows at once; the answer arrives on a later read
|
|
292
|
+
const f = focusNow() || { ok: true };
|
|
293
|
+
own = { ...f, now_ms: Number(f.now_ms) || 0, asks: [...(f.asks || []), { id: r.id, question: text, state: 'working' }] };
|
|
294
|
+
draw(); clearTimeout(askTimer); askTimer = setTimeout(read, ASK_POLL_MS);
|
|
295
|
+
} else if (!(await keep(text))) return;
|
|
296
|
+
ta.value = ''; ta.dispatchEvent(new Event('input')); say('');
|
|
297
|
+
} finally { send.disabled = false; }
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
body.addEventListener('click', async (e) => {
|
|
301
|
+
const b = e.target.closest('[data-rn]'); if (!b) return;
|
|
302
|
+
const act = b.getAttribute('data-rn');
|
|
303
|
+
if (act === 'raised' || act === 'skip') {
|
|
304
|
+
const row = b.closest('[data-raise]'); const id = row && row.getAttribute('data-raise'); if (!id) return;
|
|
305
|
+
b.disabled = true;
|
|
306
|
+
const r = await pmPost('/api/meeting-focus/raise', { note: noteId(), id, action: act, ws: ctx.ws });
|
|
307
|
+
if (!r || !r.ok) { b.disabled = false; say('Not saved: ' + ((r && r.error) || 'no answer')); return; }
|
|
308
|
+
const f = focusNow();
|
|
309
|
+
if (f) own = { ...f, now_ms: Number(f.now_ms) || 0, raise: (f.raise || []).filter((x) => x.id !== id) };
|
|
310
|
+
say(''); draw(); read();
|
|
311
|
+
} else if (act === 'keep') {
|
|
312
|
+
const m = nowModel(focusNow(), oneNow());
|
|
313
|
+
if (!m.answer || !m.answer.body) return;
|
|
314
|
+
b.disabled = true;
|
|
315
|
+
if (await keep(m.answer.body)) { b.innerHTML = svg(P.check); b.setAttribute('aria-label', 'Kept as a note'); b.title = 'Kept as a note'; }
|
|
316
|
+
else b.disabled = false;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
card.addEventListener('click', (e) => { if (e.target.closest('[data-rn="tclose"]')) { setOpen(false); if (tBtn) tBtn.focus(); } });
|
|
320
|
+
|
|
321
|
+
const offs = [];
|
|
322
|
+
if (typeof ctx.on === 'function') for (const evt of ['note', 'mode', 'tick']) { const off = ctx.on(evt, draw); if (typeof off === 'function') offs.push(off); }
|
|
323
|
+
draw();
|
|
324
|
+
if (!focusNow()) read();
|
|
325
|
+
return {
|
|
326
|
+
stop() { stopped = true; clearTimeout(askTimer); offs.forEach((f) => f()); wrap.remove(); card.remove(); if (sideBtn) sideBtn.remove(); if (tBtn) tBtn.remove(); },
|
|
327
|
+
refresh: read,
|
|
328
|
+
toggleTranscript: (v) => setOpen(v === undefined ? !open : v),
|
|
329
|
+
};
|
|
330
|
+
}
|