create-pmos 0.269.0 → 0.270.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 +1 -1
- 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/briefing-premium-calendar-2-test.js +2 -2
- package/workspace/briefing-premium-calendar-3-test.js +360 -0
- package/workspace/briefing-premium-calendar-test.js +2 -2
- package/workspace/guide/briefing-premium.md +11 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/premium-meeting.js +375 -16
- package/workspace/public/pm/premium-shell.js +36 -0
- package/workspace/public/pm/premium.css +35 -0
- package/workspace/public/pm/premium.js +1 -0
- package/workspace/test-files.json +2 -0
- package/workspace/test-lists/briefing-premium.json +2 -0
|
@@ -56,7 +56,7 @@ export function meetingView(row, replay, material) {
|
|
|
56
56
|
notes, notesState: replay ? replay.state : 'none',
|
|
57
57
|
notesLine: !replay ? 'Reading the notes.' : replay.state === 'error' ? 'The notes could not be read: ' + clip(replay.error, 120) : replay.state === 'none' ? 'No notes for this meeting.' : '',
|
|
58
58
|
replay: rep && (rep.audio || heard) ? { minutes: heard, keyPoints: keys.length, lines: Array.isArray(rep.lines) ? rep.lines.length : 0 } : null,
|
|
59
|
-
material: material && material.state === 'ok' ? (material.items || []).map((i, n) => ({ n, title: clip(i.title || i.ref || i.url, 120), kind: i.kind || '', scope: i.scope === 'series' ? 'every meeting of this series' : 'this meeting', removable: i.from === 'you' && (i.scope === 'series' || i.scope === 'meeting'), line: removeLine(i) })) : null,
|
|
59
|
+
material: material && material.state === 'ok' ? (material.items || []).map((i, n) => ({ n, title: clip(i.title || i.ref || i.url, 120), kind: i.kind || '', topic: clip(i.topic, 80), scope: i.scope === 'series' ? 'every meeting of this series' : 'this meeting', removable: i.from === 'you' && (i.scope === 'series' || i.scope === 'meeting'), line: removeLine(i) })) : null,
|
|
60
60
|
materialLine: !material ? 'Reading the material.' : material.state === 'error' ? 'The material could not be read: ' + clip(material.error, 120) : (material.items || []).length ? '' : 'No material is linked to this meeting.',
|
|
61
61
|
row,
|
|
62
62
|
};
|
|
@@ -95,10 +95,10 @@ export function suggestQuery(row, { q, ws } = {}) {
|
|
|
95
95
|
return p.toString();
|
|
96
96
|
}
|
|
97
97
|
/** The body of POST /api/meeting-material for a pick made in the sheet. */
|
|
98
|
-
export function addBody(row, pick, scope) {
|
|
98
|
+
export function addBody(row, pick, scope, topic) {
|
|
99
99
|
if (!pick || !(pick.url || pick.ref)) return null;
|
|
100
100
|
const item = isPmos(pick.kind) ? { kind: pick.kind, ref: pick.ref, title: pick.title, ...(pick.ws ? { ws: pick.ws } : {}) } : { url: pick.url, title: pick.title };
|
|
101
|
-
return { op: 'add', event: eventOf(row), scope: scope === 'series' ? 'series' : 'meeting', item };
|
|
101
|
+
return { op: 'add', event: eventOf(row), scope: scope === 'series' ? 'series' : 'meeting', item, ...(topic ? { topic: clip(topic, 120) } : {}) };
|
|
102
102
|
}
|
|
103
103
|
/** The body of POST /api/meeting-material for a row of the list (a row the route returned). */
|
|
104
104
|
export function removeBody(row, item) {
|
|
@@ -106,7 +106,7 @@ export function removeBody(row, item) {
|
|
|
106
106
|
return { op: 'remove', event: eventOf(row), scope: item.scope, item: isPmos(item.kind) ? { kind: item.kind, ref: item.ref, ...(item.ws ? { ws: item.ws } : {}) } : { url: item.url } };
|
|
107
107
|
}
|
|
108
108
|
/** What a press records, said before the press (and after it, as the toast). */
|
|
109
|
-
export const addLine = (pick, scope) => `Adds “${clip(pick && pick.title, 80)}” to ${scopeText(scope)}. The calendar is not written.`;
|
|
109
|
+
export const addLine = (pick, scope, topic) => `Adds “${clip(pick && pick.title, 80)}” to ${scopeText(scope)}${topic ? ', under the topic “' + clip(topic, 80) + '”' : ''}. The calendar is not written.`;
|
|
110
110
|
export const removeLine = (item) => `Removes “${clip(item && item.title, 80)}” from ${scopeText(item && item.scope)}. The document itself is not changed.`;
|
|
111
111
|
|
|
112
112
|
/** Make task for a next step of the meeting's note: the planned event of the note's initiative, or the reason there is none. `stage` is the first stage of its breakdown. */
|
|
@@ -119,6 +119,113 @@ export function taskEvent(note, step, stage) {
|
|
|
119
119
|
return { ok: true, ws: note.initiative.ws, event: ev };
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
/* ── slice 3, the pure half: recording, the chip, Focus and Replay ──────────────────────────────────────────────────
|
|
123
|
+
* Each function takes a route's answer (GET /api/notes, GET /api/meeting-focus, GET /api/meeting-replay) and returns what the page draws or sends. */
|
|
124
|
+
const EVENT_ID = /^[A-Za-z0-9_-]{1,40}$/;
|
|
125
|
+
const normT = (t) => String(t == null ? '' : t).toLowerCase().replace(/\s+/g, ' ').trim();
|
|
126
|
+
const minuteOf = (s) => { const t = Date.parse(s); return Number.isFinite(t) ? Math.floor(t / 60000) : null; };
|
|
127
|
+
const dayOf = (ms) => { const t = new Date(ms); return `${t.getFullYear()}-${pad(t.getMonth() + 1)}-${pad(t.getDate())}`; };
|
|
128
|
+
export const RECORD_GRACE_MS = 10 * 60000;
|
|
129
|
+
export const mmss = (ms) => { const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)); return Math.floor(s / 60) + ':' + pad(s % 60); };
|
|
130
|
+
|
|
131
|
+
/** Can this meeting still be recorded now? A meeting of today that has not ended more than 10 minutes ago, as the console's Record menu lists it. */
|
|
132
|
+
export function recordable(row, now = Date.now()) {
|
|
133
|
+
if (!row || !hasTime(row.at) || row.day !== dayOf(now)) return false;
|
|
134
|
+
const s = Date.parse(row.at); let e = Date.parse(row.end);
|
|
135
|
+
if (!Number.isFinite(e)) e = s + 30 * 60000;
|
|
136
|
+
return e + RECORD_GRACE_MS > now;
|
|
137
|
+
}
|
|
138
|
+
/** The body of POST /api/notes/new for a meeting row: a note linked to the calendar event (the route gives back the note it already has, if any). */
|
|
139
|
+
export function noteBody(row) {
|
|
140
|
+
return { meeting: { kind: 'event', event_id: EVENT_ID.test(String(row.id || '')) ? String(row.id) : null, src: 'memory', start: row.at, end: hasTime(row.end) ? row.end : null, title: row.title } };
|
|
141
|
+
}
|
|
142
|
+
/** Is this note row (GET /api/notes) the note of that meeting row? The same event id, or the same start minute and title. */
|
|
143
|
+
export function sameMeeting(m, row) {
|
|
144
|
+
if (!m || m.kind !== 'event' || !row) return false;
|
|
145
|
+
if (m.event_id && row.id && m.event_id === row.id) return true;
|
|
146
|
+
const a = minuteOf(m.start), b = minuteOf(row.at);
|
|
147
|
+
return a !== null && a === b && normT(m.title) === normT(row.title);
|
|
148
|
+
}
|
|
149
|
+
const RANK = { recording: 3, paused: 2, idle: 1, ended: 0 };
|
|
150
|
+
/** The note a meeting row has, from the note rows: a live one first, then the newest. null when there is none. */
|
|
151
|
+
export function noteOfRow(rows, row) {
|
|
152
|
+
const hit = (Array.isArray(rows) ? rows : []).filter((n) => n && sameMeeting(n.meeting, row));
|
|
153
|
+
hit.sort((a, b) => (RANK[b.state] || 0) - (RANK[a.state] || 0) || String(b.updated_at || '').localeCompare(String(a.updated_at || '')));
|
|
154
|
+
return hit[0] || null;
|
|
155
|
+
}
|
|
156
|
+
export const liveRows = (rows) => (Array.isArray(rows) ? rows : []).filter((n) => n && (n.state === 'recording' || n.state === 'paused'));
|
|
157
|
+
/** What the dialog shows for a meeting: mode is 'none' (no note), 'idle' (a note that never listened), 'recording' (this page holds the recorder), 'stale' (the server says
|
|
158
|
+
* recording but this page holds nothing), 'paused' or 'ended'. `holdingId` is the note this page's recorder is listening to. */
|
|
159
|
+
export function recState(rows, row, holdingId) {
|
|
160
|
+
const note = noteOfRow(rows, row);
|
|
161
|
+
if (!note) return { mode: 'none', note: null };
|
|
162
|
+
const mode = note.state === 'recording' ? (holdingId && holdingId === note.id ? 'recording' : 'stale') : note.state === 'paused' ? 'paused' : note.state === 'ended' ? 'ended' : 'idle';
|
|
163
|
+
return { mode, note };
|
|
164
|
+
}
|
|
165
|
+
/** The chip every premium page shows while a note records or is paused (the mockup's #recChip). null when none does. `here` is the page ('brief' holds the recorder). */
|
|
166
|
+
export function recChipView(rows, { holdingId = null, here = '' } = {}) {
|
|
167
|
+
const live = liveRows(rows);
|
|
168
|
+
if (!live.length) return null;
|
|
169
|
+
live.sort((a, b) => (b.id === holdingId) - (a.id === holdingId) || (RANK[b.state] || 0) - (RANK[a.state] || 0) || String(b.updated_at || '').localeCompare(String(a.updated_at || '')));
|
|
170
|
+
const n = live[0], title = clip(n.title || 'Untitled note', 60), held = !!holdingId && n.id === holdingId;
|
|
171
|
+
if (n.state === 'paused') return { id: n.id, mode: 'paused', held: false, title, text: 'Paused ' + title, canPause: false, canResume: here === 'brief' };
|
|
172
|
+
if (held) return { id: n.id, mode: 'recording', held: true, title, text: 'Recording ' + title, canPause: true, canResume: false };
|
|
173
|
+
return { id: n.id, mode: 'stale', held: false, title, text: title + ' is marked recording, but this page is not capturing audio', canPause: false, canResume: here === 'brief' };
|
|
174
|
+
}
|
|
175
|
+
/** What each recording press records, said before the press. */
|
|
176
|
+
export const RECORD_LINE = 'Makes a note for this meeting, or uses the one it has, and starts listening to your microphone and the meeting’s sound. The audio and the notes stay on this machine.';
|
|
177
|
+
export const RESUME_LINE = 'Starts listening again on this meeting’s note. The meeting stays open for one hour after a pause.';
|
|
178
|
+
export const STOP_LINE = 'A stopped meeting cannot be resumed. The final notes are written now.';
|
|
179
|
+
export const CONSENT_LINE = 'Tell everyone first. Recording writes down each speaker’s name and words. Everyone on the call should know before it starts.';
|
|
180
|
+
export const FOCUS_LINE = 'Focus reads this meeting every 3 seconds. While the note records, PMOS’s companion, a read-only Claude run that sends nothing, may read the last minutes of the talk at most every 40 seconds and writes its own notes.';
|
|
181
|
+
/** The mark a meeting row carries when its note records or is paused. */
|
|
182
|
+
export const rowMark = (rows, row) => { const n = noteOfRow(rows, row); return n && n.state === 'recording' ? 'Recording' : n && n.state === 'paused' ? 'Paused' : ''; };
|
|
183
|
+
|
|
184
|
+
/** The Focus view from GET /api/meeting-focus (or its error). Nothing here is invented: a part the answer does not hold is empty. */
|
|
185
|
+
export function focusView(r) {
|
|
186
|
+
if (!r || r.ok !== true) return { state: 'error', reason: clip((r && r.error) || 'The meeting could not be read.', 160) };
|
|
187
|
+
const ev = r.event || {}, note = r.note || null, now = Number(r.now_ms) || 0, at = Date.parse(ev.at), end = Date.parse(ev.end);
|
|
188
|
+
const rec = !!note && note.state === 'recording', paused = !!note && note.state === 'paused';
|
|
189
|
+
const phase = rec || paused ? 'live' : note && note.state === 'ended' ? 'done' : Number.isFinite(at) && now && now < at ? 'before' : Number.isFinite(end) && now && now > end ? 'done' : 'live';
|
|
190
|
+
const mins = Number.isFinite(at) && now ? Math.max(1, Math.round((at - now) / 60000)) : 0;
|
|
191
|
+
const status = rec ? 'Recording' : paused ? 'Paused' : phase === 'before' && mins ? 'Starts in ' + (mins < 60 ? mins + ' min' : Math.floor(mins / 60) + ' h' + (mins % 60 ? ' ' + (mins % 60) + ' min' : '')) : phase === 'done' ? 'Ended' : 'Not recording';
|
|
192
|
+
const topics = (Array.isArray(r.topics) ? r.topics : []).map((t, i) => ({ n: i + 1, id: t.id, text: clip(t.text, 120), state: t.state === 'now' ? 'now' : t.state === 'discussed' ? 'done' : t.state === 'parked' ? 'parked' : 'plan', minutes: Number(t.minutes) || 0 }));
|
|
193
|
+
const cur = topics.find((t) => t.state === 'now') || null;
|
|
194
|
+
const nowMin = Number.isFinite(at) && now ? (now - at) / 60000 : 0;
|
|
195
|
+
const stretches = (Array.isArray(r.runs) ? r.runs : []).map((x) => { const t = topics.find((y) => y.id === x.topic); const to = x.to_min == null ? Math.max(x.from_min, nowMin) : x.to_min; return t ? { n: t.n, text: t.text, flex: Math.max(0.2, to - x.from_min), on: x.to_min == null } : null; }).filter(Boolean);
|
|
196
|
+
const cap = r.captured || {}, c = (a) => (Array.isArray(a) ? a.length : 0);
|
|
197
|
+
const co = r.companion || {};
|
|
198
|
+
const companion = co.on === false ? 'The companion is off, so Focus shows the talk only.' : co.error ? 'The companion did not answer: ' + clip(co.error, 120) : co.running ? 'The companion is reading the talk.' : !rec ? 'The companion reads the talk while the note records.' : '';
|
|
199
|
+
return { state: 'ok', phase, status, rec, paused, title: clip(ev.title, 120), topics, current: cur, stretches, gist: clip(r.gist, 400),
|
|
200
|
+
chips: (Array.isArray(r.chips) ? r.chips : []).slice(0, 4).map((x) => ({ label: clip(x.label, 60), sub: clip(x.sub, 120) })).filter((x) => x.label),
|
|
201
|
+
tail: (Array.isArray(r.tail) ? r.tail : []).slice(-3).map((l) => ({ who: clip(l.who, 40), text: clip(l.text, 300) })),
|
|
202
|
+
captured: { decisions: c(cap.decisions), actions: c(cap.actions), questions: c(cap.questions) }, hasNote: !!note, noteId: note ? note.id : '',
|
|
203
|
+
material: (Array.isArray(r.material) ? r.material : []).map((m) => ({ title: clip(m.title || m.ref || m.url, 100), kind: m.kind || '', topic: clip(m.topic, 60) })), companion };
|
|
204
|
+
}
|
|
205
|
+
/** The body of POST /api/meeting-focus/topic for a topic chosen with Change. */
|
|
206
|
+
export const topicBody = (row, text) => (row && row.id && clip(text, 120) ? { event: row.id, date: row.day, action: 'set', topic: clip(text, 120) } : null);
|
|
207
|
+
|
|
208
|
+
/** The Replay player's model from GET /api/meeting-replay: the lines, the key points, the stretches by topic and the shots, all in meeting time (ms). */
|
|
209
|
+
export function replayModel(rep) {
|
|
210
|
+
if (!rep || rep.ok !== true) return null;
|
|
211
|
+
const lines = (Array.isArray(rep.lines) ? rep.lines : []).filter((l) => l && Number.isFinite(l.t) && String(l.text || '').trim()).map((l, i) => ({ i, t: l.t, who: clip(l.who, 40), text: clip(l.text, 400) })).sort((a, b) => a.t - b.t);
|
|
212
|
+
const topics = (Array.isArray(rep.topics) ? rep.topics : []).map((t, i) => ({ id: t.id, text: clip(t.text, 120), n: t.n || i + 1 }));
|
|
213
|
+
let len = Number(rep.length_ms) || (rep.audio && Number(rep.audio.ms)) || 0;
|
|
214
|
+
if (!len && lines.length) len = lines[lines.length - 1].t;
|
|
215
|
+
if (!(len > 0)) return null;
|
|
216
|
+
const stretches = (Array.isArray(rep.runs) ? rep.runs : []).filter((x) => Number.isFinite(x.from_ms) && Number.isFinite(x.to_ms) && x.to_ms > x.from_ms).map((x) => { const t = topics.find((y) => y.id === x.topic); return { n: x.n || (t && t.n) || 0, text: t ? t.text : '', from: Math.max(0, x.from_ms), to: Math.min(len, x.to_ms) }; }).filter((x) => x.to > x.from);
|
|
217
|
+
const keys = (Array.isArray(rep.keys) ? rep.keys : []).filter((k) => k && ['decision', 'action', 'question'].includes(k.k)).map((k) => ({ k: k.k, text: clip(k.text, 240), t: Number.isFinite(k.t) ? k.t : null, owner: k.owner || '', due: k.due || '' }));
|
|
218
|
+
const shots = (Array.isArray(rep.shots) ? rep.shots : []).filter((x) => Number.isFinite(x.t)).map((x) => ({ t: x.t, why: clip(x.why, 120) })).sort((a, b) => a.t - b.t);
|
|
219
|
+
return { len, audio: rep.audio && rep.audio.url ? { url: String(rep.audio.url) } : null, lines, keys, stretches, topics, shots, noteId: rep.note && rep.note.id ? rep.note.id : '', title: clip((rep.meeting && rep.meeting.title) || (rep.note && rep.note.title) || '', 120) };
|
|
220
|
+
}
|
|
221
|
+
/** Where the playhead is: the current line, the stretch (topic) and the key points within 30 s. */
|
|
222
|
+
export function replayAt(m, pos) {
|
|
223
|
+
let line = -1; for (const l of m.lines) { if (l.t <= pos) line = l.i; else break; }
|
|
224
|
+
const st = m.stretches.find((x) => pos >= x.from && pos < x.to) || null;
|
|
225
|
+
let shot = -1; m.shots.forEach((x, i) => { if (x.t <= pos) shot = i; });
|
|
226
|
+
return { line, stretch: st, near: m.keys.filter((k) => k.t != null && Math.abs(k.t - pos) <= 30000).length, shot };
|
|
227
|
+
}
|
|
228
|
+
|
|
122
229
|
/* ── the page half ─────────────────────────────────────────────────────────────────────────────────────── */
|
|
123
230
|
|
|
124
231
|
/** deps: { $, $$, esc, openDlg, toast, pmGet, pmPost, turnA, ptx, kv, H, wsq(), ws() }. Returns { mode, draw, openToday }. */
|
|
@@ -147,6 +254,7 @@ export function mountMeeting(d) {
|
|
|
147
254
|
if (W.state === 'error') { $('#tl').innerHTML = `<div class="empty" role="status">Calendar not read. ${esc(W.reason)}</div>`; return true; }
|
|
148
255
|
$('#tl').innerHTML = W.days.map((x) => `<div class="wkd${x.today ? ' now' : ''}">${esc(x.label)}${x.today ? ' · today' : ''}<em>${x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : ''}</em></div>${x.rows.length ? x.rows.map((r, i) => rowHtml(r, x.key + '|' + i)).join('') : '<div class="empty">No meetings.</div>'}`).join('');
|
|
149
256
|
$$('#tl .ev').forEach((e, i) => { e.tabIndex = i ? -1 : 0; });
|
|
257
|
+
mark();
|
|
150
258
|
return true;
|
|
151
259
|
}
|
|
152
260
|
const rowOf = (k) => { const [day, i] = k.split('|'); const x = W && W.days.find((y) => y.key === day); return x ? x.rows[+i] : null; };
|
|
@@ -157,6 +265,105 @@ export function mountMeeting(d) {
|
|
|
157
265
|
redraw();
|
|
158
266
|
}
|
|
159
267
|
|
|
268
|
+
/* ── recording: the notes the server holds, the recorder this page holds, and the presses on both ───────────────────────── */
|
|
269
|
+
let NR = [], HOLD = null, R = null, evOf = null, cur = null;
|
|
270
|
+
const bump = () => { try { window.dispatchEvent(new CustomEvent('premium-rec')); } catch { /* no window */ } };
|
|
271
|
+
async function readNotes() {
|
|
272
|
+
const r = await d.pmGet('/api/notes');
|
|
273
|
+
if (r && r.ok === true && Array.isArray(r.notes)) { const was = JSON.stringify(NR); NR = r.notes; if (was !== JSON.stringify(NR)) bump(); mark(); }
|
|
274
|
+
return NR;
|
|
275
|
+
}
|
|
276
|
+
/** The recorder is the console's own (view-notes.js): microphone, the meeting's sound, POST /api/notes/record and /audio. Loaded the first time it is pressed. */
|
|
277
|
+
async function recorder() {
|
|
278
|
+
if (typeof window !== 'undefined' && window.__premiumRecorder) return window.__premiumRecorder;
|
|
279
|
+
if (R) return R;
|
|
280
|
+
const [V, ST] = await Promise.all([import('./view-notes.js'), import('./state.js')]);
|
|
281
|
+
const ctx = { state: { wsId: d.ws() }, setState: bump, FIXTURE: ST.FIXTURE };
|
|
282
|
+
R = {
|
|
283
|
+
listen: (id) => V.listenNow(ctx, id), pause: () => V.pauseListening(ctx), listening: () => V.listeningId(), started: () => V.liveStarted(), banner: () => V.takeBanner(),
|
|
284
|
+
async stop(id) {
|
|
285
|
+
const one = await d.pmGet('/api/notes/one?id=' + encodeURIComponent(id)), note = one && one.ok ? one.note : null;
|
|
286
|
+
const { discardable } = await import('./note-dock.js');
|
|
287
|
+
if (note && discardable(note)) return { discarded: await V.discardRecording(ctx, id) };
|
|
288
|
+
await V.stopMeeting(ctx, id); return { discarded: false };
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
return R;
|
|
292
|
+
}
|
|
293
|
+
const setHold = (id) => { HOLD = id ? { id } : null; window.__premiumHolding = HOLD; bump(); };
|
|
294
|
+
const ctl = {
|
|
295
|
+
async record(row) {
|
|
296
|
+
const blocking = liveRows(NR).find((n) => n.state === 'recording' && !sameMeeting(n.meeting, row));
|
|
297
|
+
if (blocking || HOLD) return { ok: false, error: (blocking ? clip(blocking.title, 60) : 'A meeting') + ' is recording. Pause or stop it first.' };
|
|
298
|
+
const made = await d.pmPost('/api/notes/new', noteBody(row));
|
|
299
|
+
if (!made || made.ok !== true) return { ok: false, error: (made && made.error) || 'The note was not made.' };
|
|
300
|
+
return ctl.resume(made.note.id);
|
|
301
|
+
},
|
|
302
|
+
async resume(id) {
|
|
303
|
+
const rec = await recorder(); const ok = await rec.listen(id);
|
|
304
|
+
await readNotes();
|
|
305
|
+
if (!ok) return { ok: false, error: (await rec.banner()) || 'The meeting could not be heard.' };
|
|
306
|
+
setHold(id); return { ok: true };
|
|
307
|
+
},
|
|
308
|
+
async pause() {
|
|
309
|
+
if (!HOLD) return { ok: false, error: 'This page is not recording.' };
|
|
310
|
+
const rec = await recorder(); await rec.pause(); setHold(null); await readNotes(); return { ok: true };
|
|
311
|
+
},
|
|
312
|
+
async stop(id) {
|
|
313
|
+
if (HOLD && HOLD.id === id) { const rec = await recorder(); const out = await rec.stop(id); setHold(null); await readNotes(); return { ok: true, discarded: !!(out && out.discarded) }; }
|
|
314
|
+
const res = await d.pmPost('/api/notes/stop', { id }); await readNotes(); bump();
|
|
315
|
+
return res && res.ok === true ? { ok: true } : { ok: false, error: (res && res.error) || 'The meeting was not stopped.' };
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
window.__premiumRec = { pause: ctl.pause, resume: ctl.resume, stop: ctl.stop, note: (id) => NR.find((n) => n.id === id) || null, refresh: readNotes, open: (id) => openNote(id) };
|
|
319
|
+
/* Leaving the Briefing while it holds the recorder: the browser asks first, and if the PM leaves, the meeting is paused (it stays open for an hour) so the record never says "recording" for audio nobody is capturing. */
|
|
320
|
+
addEventListener('beforeunload', (e) => { if (HOLD) { e.preventDefault(); e.returnValue = ''; } });
|
|
321
|
+
addEventListener('pagehide', () => { if (HOLD) d.pmPost('/api/notes/pause', { id: HOLD.id }, { keepalive: true }); });
|
|
322
|
+
setInterval(() => { readNotes(); }, 20000);
|
|
323
|
+
addEventListener('premium-rec', () => { if (cur && cur.alive()) cur.repaint(); mark(); });
|
|
324
|
+
|
|
325
|
+
/** The mark on a meeting row whose note records or is paused. `evOf(i)` gives the Today event of a Today row. */
|
|
326
|
+
function mark(f) {
|
|
327
|
+
if (f) evOf = f;
|
|
328
|
+
$$('#tl .ev.src-meeting').forEach((b) => {
|
|
329
|
+
let row = null;
|
|
330
|
+
if (b.dataset.w) row = rowOf(b.dataset.w);
|
|
331
|
+
else if (evOf && b.dataset.i !== undefined) { const e = evOf(+b.dataset.i); if (e && Number.isFinite(e.at)) row = { id: null, at: new Date(e.at).toISOString(), title: clip(e.title, 120) }; }
|
|
332
|
+
const old = b.querySelector('.m3-mark'); if (old) old.remove();
|
|
333
|
+
const t = row ? rowMark(NR, row) : '';
|
|
334
|
+
if (t) b.querySelector('b').insertAdjacentHTML('afterend', `<em class="m3-mark${t === 'Paused' ? ' m3-paused' : ''}">${t}</em>`);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
async function openNote(id) {
|
|
338
|
+
await readNotes(); const n = NR.find((x) => x.id === id);
|
|
339
|
+
if (!n) return d.toast('That note could not be found.');
|
|
340
|
+
if (!W || W.state !== 'ok') await readWeek();
|
|
341
|
+
const hit = W && W.state === 'ok' ? W.days.flatMap((x) => x.rows).find((r) => sameMeeting(n.meeting, r)) : null;
|
|
342
|
+
if (!hit) return d.toast('That meeting is not in this week’s calendar.');
|
|
343
|
+
return openRow(hit, 'week');
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const consented = new Set();
|
|
347
|
+
const keyOf = (row) => (row.id || row.title) + '|' + row.at;
|
|
348
|
+
const recMode = (row) => recState(NR, row, HOLD && HOLD.id);
|
|
349
|
+
const clockText = () => { const t = window.__premiumRecorder ? window.__premiumRecorder.started() : (R ? R.started() : null); return Number.isFinite(t) ? mmss(Date.now() - t) : ''; };
|
|
350
|
+
/** The Record row of the dialog: what the meeting's note is doing now, from the note rows and the recorder, and the presses that fit. */
|
|
351
|
+
function recBarHtml(row, ui) {
|
|
352
|
+
const st = recMode(row), n = st.note, name = esc(clip((n && n.title) || row.title, 60));
|
|
353
|
+
const b = (act, label, cls) => `<button class="mtg-b${cls ? ' ' + cls : ''}" data-m3="${act}">${label}</button>`;
|
|
354
|
+
const msg = ui.recMsg ? `<p class="note m3-msg" role="status">${esc(ui.recMsg)}</p>` : '';
|
|
355
|
+
if (ui.ask === 'consent') return `<div class="m3-cons" role="alert"><p><b>Tell everyone first.</b> ${esc(CONSENT_LINE.replace('Tell everyone first. ', ''))}</p><p class="note">${esc(RECORD_LINE)}</p><div>${b('go', 'I told them, start', 'cta')}${b('no', 'Not yet')}</div></div>`;
|
|
356
|
+
if (ui.ask === 'stop') return `<div class="m3-cons" role="alert"><p><b>Stop “${name}” for good?</b> ${esc(STOP_LINE)}</p><div>${b('stopno', 'Cancel')}${st.mode === 'recording' ? b('stoppause', 'Pause instead') : ''}${b('stopgo', 'Stop for good', 'cta')}</div></div>`;
|
|
357
|
+
let h = '';
|
|
358
|
+
if (st.mode === 'recording') h = `<div class="m3-row"><span class="m3-dot" aria-hidden="true"></span><b>Recording</b><span class="note" id="m3Clk">${esc(clockText())}</span>${b('pause', 'Pause')}${b('stop', 'Stop')}</div>`;
|
|
359
|
+
else if (st.mode === 'stale') h = `<div class="m3-row"><b>Marked recording</b>${b('resume', 'Resume')}${b('stop', 'Stop')}</div><p class="note">The server holds this meeting as recording, but this page is not capturing audio. Resume starts listening again.</p>`;
|
|
360
|
+
else if (st.mode === 'paused') h = `<div class="m3-row"><b>Paused</b>${n && n.resume_until ? `<span class="note">Open until ${esc(hhmm(n.resume_until))}</span>` : ''}${b('resume', 'Resume')}${b('stop', 'Stop')}</div><p class="note">${esc(RESUME_LINE)}</p>`;
|
|
361
|
+
else if (st.mode === 'ended') h = '<p class="note">The recording of this meeting has ended. A stopped meeting cannot be recorded again.</p>';
|
|
362
|
+
else if (recordable(row)) h = `<div class="m3-row">${b('rec', 'Record', 'cta')}</div><p class="note">${esc(RECORD_LINE)}</p>`;
|
|
363
|
+
return h + msg;
|
|
364
|
+
}
|
|
365
|
+
const actsHtml = (row, ui) => `<div class="m3-acts"><div id="m3Rec">${recBarHtml(row, ui)}</div><div class="m3-row"><button class="mtg-b" data-m3="focus">Focus</button></div><p class="note">${esc(FOCUS_LINE)}</p></div>`;
|
|
366
|
+
|
|
160
367
|
/* the dialog */
|
|
161
368
|
const sec = (label, body) => `<div class="mtg-sec"><span class="label">${esc(label)}</span>${body}</div>`;
|
|
162
369
|
const items = (L, task) => `<ul class="mtg-l">${L.map((x, i) => `<li>${esc(x.text)}${x.owner || x.due ? `<em>${esc([x.owner, x.due].filter(Boolean).join(' · '))}</em>` : ''}${task ? `<button class="mtg-b mtg-task" data-task="${i}"${task.done.has(i) ? ' disabled' : ''}>${task.done.has(i) ? 'Task made' : 'Make task'}</button>` : ''}</li>`).join('')}</ul>`;
|
|
@@ -174,11 +381,11 @@ export function mountMeeting(d) {
|
|
|
174
381
|
const notes = v.notesLine ? `<p class="note">${esc(v.notesLine)}</p>` : [n.title ? `<p><b>${esc(n.title)}</b></p>` : '',
|
|
175
382
|
n.decisions.length ? `<h4 class="mtg-h">Decisions ${n.decisions.length}</h4>${items(n.decisions)}` : '', n.actions.length ? `<h4 class="mtg-h">Next steps ${n.actions.length}</h4>${items(n.actions, task)}` : '',
|
|
176
383
|
n.questions.length ? `<h4 class="mtg-h">Open questions ${n.questions.length}</h4>${items(n.questions)}` : '', (n.decisions.length + n.actions.length + n.questions.length) ? '' : '<p class="note">The note holds no decisions, next steps or questions yet.</p>'].join('');
|
|
177
|
-
const mat = (v.materialLine ? `<p class="note">${esc(v.materialLine)}</p>` : `<ul class="mtg-l">${v.material.map((m) => `<li>${esc(m.title)}<em>${esc([m.kind, 'for ' + m.scope].filter(Boolean).join(' · '))}</em>${m.removable ? `<button class="mtg-b mtg-rm" data-rm="${m.n}" aria-label="Remove ${esc(m.title)}" title="${esc(m.line)}">Remove</button>` : ''}</li>`).join('')}</ul>`)
|
|
384
|
+
const mat = (v.materialLine ? `<p class="note">${esc(v.materialLine)}</p>` : `<ul class="mtg-l">${v.material.map((m) => `<li>${esc(m.title)}<em>${esc([m.kind, 'for ' + m.scope, m.topic ? 'on ' + m.topic : ''].filter(Boolean).join(' · '))}</em>${m.removable ? `<button class="mtg-b mtg-rm" data-rm="${m.n}" aria-label="Remove ${esc(m.title)}" title="${esc(m.line)}">Remove</button>` : ''}</li>`).join('')}</ul>`)
|
|
178
385
|
+ `<div class="mtg-foot"><button class="mtg-b" id="mmAdd">Add material</button><span class="note">Your calendar invite is not changed.</span></div>`;
|
|
179
|
-
const rep = v.replay ? `<p>A recording is kept: ${v.replay.minutes ? v.replay.minutes + ' min, ' : ''}${v.replay.keyPoints} key ${v.replay.keyPoints === 1 ? 'point' : 'points'}.</p><
|
|
386
|
+
const rep = v.replay ? `<p>A recording is kept: ${v.replay.minutes ? v.replay.minutes + ' min, ' : ''}${v.replay.keyPoints} key ${v.replay.keyPoints === 1 ? 'point' : 'points'}.</p><div class="mtg-foot"><button class="cta" data-m3="replay">Replay</button><span class="note">Plays the note’s audio kept on this machine, with the transcript and the key points.</span></div>` : '';
|
|
180
387
|
const status = ui.status ? `<p class="note mtg-status" id="mtgStatus" role="status">${esc(ui.status.text)}${ui.status.undo ? ' <button class="mtg-b" id="mtgUndo">Undo</button>' : ''}</p>` : '<p class="note mtg-status" id="mtgStatus" role="status" hidden></p>';
|
|
181
|
-
return `<article class="paper doc mtg">${status}${d.kv([['When', r.day + ' · ' + r.time + (r.len ? ' · ' + r.len : '')], ['People', v.people.join(', ') || 'The calendar lists no other people.']])}${sec('What it is about', about)}${sec('Notes', notes)}${sec('Material', mat)}${rep ? sec('Replay', rep) : ''}</article>`;
|
|
388
|
+
return `<article class="paper doc mtg">${status}${d.kv([['When', r.day + ' · ' + r.time + (r.len ? ' · ' + r.len : '')], ['People', v.people.join(', ') || 'The calendar lists no other people.']])}${actsHtml(r, ui)}${sec('What it is about', about)}${sec('Notes', notes)}${sec('Material', mat)}${rep ? sec('Replay', rep) : ''}</article>`;
|
|
182
389
|
}
|
|
183
390
|
function sheetHtml(row) {
|
|
184
391
|
return `<article class="paper doc mtg mtg-sheet"><button class="mtg-b" id="mmBack">Back to the meeting</button>
|
|
@@ -189,11 +396,156 @@ export function mountMeeting(d) {
|
|
|
189
396
|
|
|
190
397
|
async function openRow(row, via) {
|
|
191
398
|
let replay = null, material = null, boards = W ? W.boards : [], inis = W ? W.initiatives : [], saved = '';
|
|
192
|
-
const ui = { view: 'detail', status: null, tasked: new Set() }, SH = { sug: null, found: [], pick: null, scope: 'meeting', q: '', link: '', token: 0 };
|
|
399
|
+
const ui = { view: 'detail', status: null, tasked: new Set() }, SH = { sug: null, found: [], pick: null, scope: 'meeting', q: '', link: '', token: 0, topics: [], topic: null };
|
|
193
400
|
let stT = null, findT = null, undoFn = null;
|
|
194
401
|
const view = () => meetingView(row, replay, material);
|
|
195
402
|
const say = (text, undo) => { clearTimeout(stT); undoFn = undo || null; ui.status = { text, undo: undo || null }; if (ui.view === 'detail') { paint(); stT = setTimeout(() => { ui.status = null; if (ui.view === 'detail') paint(); }, 9000); } else d.toast(text); };
|
|
196
|
-
const paint = () => {
|
|
403
|
+
const paint = () => {
|
|
404
|
+
const pane = $('#dOut'), top = pane ? pane.scrollTop : 0, same = ui.last === ui.view; ui.last = ui.view;
|
|
405
|
+
$('#oMain').innerHTML = ({ add: () => sheetHtml(row), focus: focusHtml, replay: replayHtml }[ui.view] || (() => detailHtml(view(), boards, inis, saved, ui)))();
|
|
406
|
+
if (ui.view === 'add') paintSheet();
|
|
407
|
+
if (pane && same) pane.scrollTop = top;
|
|
408
|
+
};
|
|
409
|
+
const alive = (v) => ui.view === v && $('#dlg').classList.contains('on') && $('#dTitle').textContent === row.title;
|
|
410
|
+
const paintRec = () => { const e = $('#m3Rec'); if (e) e.innerHTML = recBarHtml(row, ui); };
|
|
411
|
+
cur = { row, repaint: paintRec, alive: () => $('#dlg').classList.contains('on') && $('#dTitle').textContent === row.title };
|
|
412
|
+
let fT = null, F = null, clkT = null, RP = null, repM = null;
|
|
413
|
+
const tickClock = () => { clearInterval(clkT); clkT = setInterval(() => { if (!cur || cur.row !== row || !cur.alive() || !HOLD) { clearInterval(clkT); return; } const c = $('#m3Clk'); if (c) c.textContent = clockText(); }, 1000); };
|
|
414
|
+
|
|
415
|
+
/* Focus: the meeting as it is now, read every 3 seconds while the view is open (GET /api/meeting-focus) */
|
|
416
|
+
function focusHtml() {
|
|
417
|
+
const head = `<div class="m3-fh"><button class="mtg-b" data-m3="unfocus">Leave focus</button><div class="m3-fti"><b>${esc(row.title)}</b><span class="note">${esc(F && F.state === 'ok' ? F.status : 'Reading the meeting')}</span></div></div><div id="m3Rec">${recBarHtml(row, ui)}</div>`;
|
|
418
|
+
if (!F) return `<article class="paper doc mtg">${head}<p class="note">Reading the meeting.</p></article>`;
|
|
419
|
+
if (F.state === 'error') return `<article class="paper doc mtg">${head}<p class="note" role="status">Focus could not read this meeting: ${esc(F.reason)}</p></article>`;
|
|
420
|
+
const first = F.phase === 'before';
|
|
421
|
+
const nowTopic = first ? F.topics[0] : F.current;
|
|
422
|
+
let h = head;
|
|
423
|
+
if (F.stretches.length) h += `<div class="m3-trk" role="img" aria-label="What the room talked about, in order. Numbers match the topic list.">${F.stretches.map((x) => `<span class="m3-stc${x.on ? ' on' : ''}" style="flex:${x.flex}">${x.n}</span>`).join('')}</div>`;
|
|
424
|
+
h += `<div class="m3-now"><span class="label">${first ? 'First up' : 'Now'}</span><b>${esc(nowTopic ? nowTopic.text : 'No topic is current yet')}</b>${F.topics.length ? `<button class="mtg-b" data-m3="chg" aria-expanded="${!!ui.change}">Change</button>` : ''}</div>`;
|
|
425
|
+
if (ui.change && F.topics.length) h += `<div class="m3-chg" role="group" aria-label="Topics"><p class="note">Sets the topic Focus follows. It records one correction on this meeting; PMOS’s companion may move it on later.</p>${F.topics.map((t) => `<button class="mtg-b" data-m3="topic" data-n="${t.n}" aria-pressed="${t.state === 'now'}">${t.n}. ${esc(t.text)}</button>`).join('')}</div>`;
|
|
426
|
+
if (F.gist) h += `<p class="m3-say">${esc(F.gist)}</p>`;
|
|
427
|
+
if (F.chips.length) h += `<div class="m3-chips">${F.chips.map((c) => `<span class="m3-chp" title="${esc(c.sub)}">${esc(c.label)}${c.sub ? `<small>${esc(c.sub)}</small>` : ''}</span>`).join('')}</div>`;
|
|
428
|
+
h += `<span class="label">${F.rec ? 'Live transcript' : 'Transcript'}</span>`;
|
|
429
|
+
h += F.tail.length ? `<div class="m3-ftr">${F.tail.map((l, i) => `<p${i === F.tail.length - 1 ? ' class="cur"' : ''}><b>${esc(l.who)}</b> ${esc(l.text)}</p>`).join('')}</div>` : `<p class="note">${F.rec ? 'Nothing has been said yet.' : 'The transcript starts when you record.'}</p>`;
|
|
430
|
+
h += '<span class="label">Topics</span>' + (F.topics.length ? `<div class="m3-tops">${F.topics.map((t) => `<div class="m3-tp ${t.state}"><i>${t.n}</i><span>${esc(t.text)}</span><small>${t.state === 'now' ? 'now' : t.state === 'done' ? (t.minutes ? t.minutes + ' min' : 'done') : t.state === 'parked' ? 'parked' : 'planned'}</small></div>`).join('')}</div>` : '<p class="note">The meeting has no topics yet.</p>');
|
|
431
|
+
h += '<span class="label">Material</span>' + (F.material.length ? `<ul class="mtg-l">${F.material.map((m) => `<li>${esc(m.title)}<em>${esc([m.kind, m.topic ? 'on ' + m.topic : ''].filter(Boolean).join(' · '))}</em></li>`).join('')}</ul>` : '<p class="note">No material linked. Add some from the meeting.</p>');
|
|
432
|
+
if (F.rec || F.paused || F.phase === 'done') h += `<span class="label">Captured so far</span><div class="m3-cap"><div><b>${F.captured.decisions}</b><span>Decisions</span></div><div><b>${F.captured.actions}</b><span>Next steps</span></div><div><b>${F.captured.questions}</b><span>Questions</span></div></div>`;
|
|
433
|
+
if (F.companion) h += `<p class="note">${esc(F.companion)}</p>`;
|
|
434
|
+
return `<article class="paper doc mtg">${h}</article>`;
|
|
435
|
+
}
|
|
436
|
+
async function readFocus() {
|
|
437
|
+
const r = await d.pmGet('/api/meeting-focus?event=' + encodeURIComponent(row.id) + '&date=' + row.day);
|
|
438
|
+
F = focusView(r);
|
|
439
|
+
}
|
|
440
|
+
async function focusLoop() {
|
|
441
|
+
clearTimeout(fT);
|
|
442
|
+
if (!alive('focus')) return;
|
|
443
|
+
await readFocus();
|
|
444
|
+
if (!alive('focus')) return;
|
|
445
|
+
paint(); fT = setTimeout(focusLoop, 3000);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/* Replay: the note's audio, the transcript and the key points on one track (GET /api/meeting-replay, GET /api/notes/recording) */
|
|
449
|
+
function replayHtml() {
|
|
450
|
+
const head = `<div class="m3-fh"><button class="mtg-b" data-m3="unreplay">Back to the meeting</button><div class="m3-fti"><b>${esc(row.title)}</b><span class="note">Replay · ${esc(row.time)}</span></div></div>`;
|
|
451
|
+
if (repM === undefined) return `<article class="paper doc mtg">${head}<p class="note" role="status">${esc(RP && RP.error ? 'Replay could not be read: ' + RP.error : 'Reading the recording.')}</p></article>`;
|
|
452
|
+
if (!repM) return `<article class="paper doc mtg">${head}<p class="note">Reading the recording.</p></article>`;
|
|
453
|
+
const m = repM, pct = (t) => Math.min(100, Math.max(0, t / m.len * 100)).toFixed(2);
|
|
454
|
+
const track = m.stretches.length ? m.stretches.map((x) => `<button class="m3-stc" style="flex:${x.to - x.from}" data-m3="seek" data-t="${x.from}" data-from="${x.from}" data-to="${x.to}" aria-label="${esc(x.text || 'Topic ' + x.n)}">${x.n}</button>`).join('') : '';
|
|
455
|
+
const marks = m.keys.filter((k) => k.t != null).map((k) => `<i class="m3-mk ${k.k}" style="left:${pct(k.t)}%" title="${k.k === 'action' ? 'Next step' : k.k === 'decision' ? 'Decision' : 'Question'}"></i>`).join('');
|
|
456
|
+
let h = head + `<div class="m3-rctl"><button class="mtg-b" data-m3="back10" aria-label="Back 10 seconds">Back 10 s</button><button class="mtg-b cta" data-m3="play" id="rpPlay">Play</button><div class="seg2" role="group" aria-label="Speed">${[1, 1.5, 2].map((v) => `<button class="mtg-b" data-m3="spd" data-v="${v}" aria-pressed="${RP.spd === v}">${v}x</button>`).join('')}</div><span class="note m3-pos" id="rpPos"></span></div>`;
|
|
457
|
+
h += `<div class="m3-trk" role="group" aria-label="The meeting by topic">${track}${marks}<b class="m3-ph" id="rpPh"></b></div>`;
|
|
458
|
+
h += '<div class="m3-lgd"><span><i class="decision"></i>Decision</span><span><i class="action"></i>Next step</span><span><i class="question"></i>Question</span></div>';
|
|
459
|
+
h += `<div class="m3-now"><span class="label">Topic</span><b id="rpTopic"></b><span class="note" id="rpNear"></span></div><div id="rpShot"></div>`;
|
|
460
|
+
h += '<span class="label">Key points</span>' + (m.keys.length ? `<div class="m3-kps">${m.keys.map((k) => k.t != null ? `<button data-m3="seek" data-t="${k.t}"><span class="kd">${k.k === 'action' ? 'Next step' : k.k === 'decision' ? 'Decision' : 'Question'}</span><span>${esc(k.text)}</span><time>${mmss(k.t)}</time></button>` : `<div class="m3-kp0"><span class="kd">${k.k === 'action' ? 'Next step' : k.k === 'decision' ? 'Decision' : 'Question'}</span><span>${esc(k.text)}</span><em>No time</em></div>`).join('')}</div>` : '<p class="note">The note holds no decisions, next steps or questions.</p>');
|
|
461
|
+
h += '<span class="label">Conversation</span>' + (m.lines.length ? `<div class="m3-ftr all" id="rpLines">${m.lines.map((l) => `<button class="m3-ln" id="rl${l.i}" data-m3="seek" data-t="${l.t}"><time>${mmss(l.t)}</time><b>${esc(l.who)}</b><span>${esc(l.text)}</span></button>`).join('')}</div>` : '<p class="note">The recording holds no transcript.</p>');
|
|
462
|
+
h += `<p class="note">${m.audio && !RP.noAudio ? 'Plays the note’s audio, kept on this machine.' : 'No audio is kept for this meeting, so the playhead keeps its own clock.'}</p>`;
|
|
463
|
+
return `<article class="paper doc mtg">${h}</article>`;
|
|
464
|
+
}
|
|
465
|
+
function replayPaint() {
|
|
466
|
+
const m = repM; if (!m || !alive('replay')) return;
|
|
467
|
+
const pos = RP.pos, at = replayAt(m, pos), $q = (id) => document.getElementById(id);
|
|
468
|
+
if ($q('rpPos')) $q('rpPos').textContent = mmss(pos) + ' / ' + mmss(m.len);
|
|
469
|
+
if ($q('rpPh')) $q('rpPh').style.left = Math.min(100, pos / m.len * 100).toFixed(2) + '%';
|
|
470
|
+
if ($q('rpTopic')) $q('rpTopic').textContent = at.stretch ? (at.stretch.text || 'Topic ' + at.stretch.n) : m.stretches.length ? 'Between topics' : 'No topics were kept';
|
|
471
|
+
if ($q('rpNear')) $q('rpNear').textContent = at.near ? at.near + (at.near === 1 ? ' key point near' : ' key points near') : '';
|
|
472
|
+
if ($q('rpPlay')) $q('rpPlay').textContent = RP.play ? 'Pause' : 'Play';
|
|
473
|
+
$$('#oMain .m3-stc[data-from]').forEach((b) => b.classList.toggle('on', pos >= +b.dataset.from && pos < +b.dataset.to));
|
|
474
|
+
const prev = RP.line; RP.line = at.line;
|
|
475
|
+
if (prev !== at.line) { if (prev >= 0 && $q('rl' + prev)) $q('rl' + prev).classList.remove('cur'); const c = at.line >= 0 ? $q('rl' + at.line) : null; if (c) { c.classList.add('cur'); if (RP.play) c.scrollIntoView({ block: 'nearest' }); } }
|
|
476
|
+
const sh = $q('rpShot'); if (sh) { const want = at.shot >= 0 ? m.shots[at.shot] : null, have = sh.dataset.t || ''; if ((want ? String(want.t) : '') !== have) { sh.dataset.t = want ? want.t : ''; sh.innerHTML = want && m.noteId ? `<figure class="m3-shot"><img src="/api/notes/screen?id=${encodeURIComponent(m.noteId)}&t=${want.t}" alt="${esc(want.why || 'The shared screen at ' + mmss(want.t))}" loading="lazy"><figcaption class="note">${esc(want.why || 'The shared screen at ' + mmss(want.t))}</figcaption></figure>` : ''; } }
|
|
477
|
+
}
|
|
478
|
+
function replayStop() { clearInterval(RP && RP.tm); if (RP && RP.aud) { try { RP.aud.pause(); } catch { /* gone */ } } if (RP) RP.play = false; }
|
|
479
|
+
function replaySeek(ms, play) {
|
|
480
|
+
RP.pos = Math.max(0, Math.min(repM.len, ms));
|
|
481
|
+
if (RP.aud) { try { RP.aud.currentTime = RP.pos / 1000; } catch { /* not loaded */ } }
|
|
482
|
+
if (play && !RP.play) replayToggle(); else replayPaint();
|
|
483
|
+
}
|
|
484
|
+
function replayToggle() {
|
|
485
|
+
if (RP.play) { RP.play = false; if (RP.aud) RP.aud.pause(); replayPaint(); return; }
|
|
486
|
+
if (RP.pos >= repM.len - 200) replaySeek(0, false);
|
|
487
|
+
RP.play = true; RP.last = performance.now();
|
|
488
|
+
if (RP.aud) { RP.aud.playbackRate = RP.spd; const pr = RP.aud.play(); if (pr && pr.catch) pr.catch(() => { RP.aud = null; RP.noAudio = true; RP.last = performance.now(); say('The audio could not be played, so the playhead keeps its own clock.'); }); }
|
|
489
|
+
clearInterval(RP.tm);
|
|
490
|
+
RP.tm = setInterval(() => {
|
|
491
|
+
if (!alive('replay')) { replayStop(); return; }
|
|
492
|
+
const now = performance.now();
|
|
493
|
+
if (RP.aud && !RP.aud.paused) RP.pos = RP.aud.currentTime * 1000; else if (RP.play) RP.pos += (now - RP.last) * RP.spd; RP.last = now;
|
|
494
|
+
if (RP.pos >= repM.len) { RP.pos = repM.len; RP.play = false; if (RP.aud) RP.aud.pause(); clearInterval(RP.tm); }
|
|
495
|
+
replayPaint();
|
|
496
|
+
}, 500);
|
|
497
|
+
replayPaint();
|
|
498
|
+
}
|
|
499
|
+
async function openReplay() {
|
|
500
|
+
ui.view = 'replay'; repM = null; RP = { pos: 0, play: false, spd: 1, aud: null, tm: null, line: -2, noAudio: false }; paint();
|
|
501
|
+
const r = await d.pmGet('/api/meeting-replay?event=' + encodeURIComponent(row.id) + '&date=' + row.day);
|
|
502
|
+
if (!alive('replay')) return;
|
|
503
|
+
repM = replayModel(r);
|
|
504
|
+
if (!repM) { repM = undefined; RP.error = r && r.ok === true ? 'the recording holds no length and no lines' : (r && r.error) || 'no answer'; paint(); return; }
|
|
505
|
+
if (repM.audio) { RP.aud = new Audio(repM.audio.url); RP.aud.preload = 'metadata'; RP.aud.addEventListener('error', () => { RP.aud = null; RP.noAudio = true; }); }
|
|
506
|
+
paint(); $('#rpPlay') && $('#rpPlay').focus(); replayPaint();
|
|
507
|
+
}
|
|
508
|
+
const leave = (to) => { clearTimeout(fT); if (ui.view === 'replay') replayStop(); ui.view = to; ui.change = false; paint(); const b = $('#oMain [data-m3="' + (to === 'detail' ? (RP && repM ? 'replay' : 'focus') : '') + '"]'); if (b) b.focus(); };
|
|
509
|
+
|
|
510
|
+
/* the presses of the Record row, Focus and Replay */
|
|
511
|
+
async function m3Press(act, t) {
|
|
512
|
+
const st = recMode(row), k = keyOf(row);
|
|
513
|
+
const started = async (kind) => {
|
|
514
|
+
ui.ask = null; ui.recMsg = ''; if (t) t.disabled = true;
|
|
515
|
+
const res = kind === 'resume' ? await ctl.resume(st.note.id) : await ctl.record(row);
|
|
516
|
+
ui.recMsg = res.ok ? (kind === 'resume' ? 'Resumed. Let people know.' : 'Recording. Notes are being taken on this machine. Let people know.') : res.error;
|
|
517
|
+
if (res.ok) tickClock(); paintRec();
|
|
518
|
+
if (res.ok && ui.view === 'detail') d.toast('Recording started.');
|
|
519
|
+
};
|
|
520
|
+
switch (act) {
|
|
521
|
+
case 'rec': if (!consented.has(k)) { ui.ask = 'consent'; paintRec(); const g = $('#m3Rec [data-m3="go"]'); if (g) g.focus(); return; } return started('rec');
|
|
522
|
+
case 'go': consented.add(k); return started('rec');
|
|
523
|
+
case 'no': ui.ask = null; paintRec(); { const b = $('#m3Rec [data-m3="rec"]'); if (b) b.focus(); } return;
|
|
524
|
+
case 'resume': return started('resume');
|
|
525
|
+
case 'pause': { t.disabled = true; const res = await ctl.pause(); ui.recMsg = res.ok ? 'Paused. You can resume within 1 hour.' : res.error; paintRec(); return; }
|
|
526
|
+
case 'stop': ui.ask = 'stop'; paintRec(); { const b = $('#m3Rec [data-m3="stopno"]'); if (b) b.focus(); } return;
|
|
527
|
+
case 'stopno': ui.ask = null; paintRec(); return;
|
|
528
|
+
case 'stoppause': { ui.ask = null; const res = await ctl.pause(); ui.recMsg = res.ok ? 'Paused. You can resume within 1 hour.' : res.error; paintRec(); return; }
|
|
529
|
+
case 'stopgo': { ui.ask = null; const res = await ctl.stop(st.note.id); ui.recMsg = res.ok ? (res.discarded ? 'Nothing was recorded, so the note was deleted.' : 'Stopped for good. The final notes are written now.') : res.error; paintRec(); return; }
|
|
530
|
+
case 'focus': ui.view = 'focus'; F = null; ui.change = false; paint(); { const b = $('#oMain [data-m3="unfocus"]'); if (b) b.focus(); } focusLoop(); return;
|
|
531
|
+
case 'unfocus': return leave('detail');
|
|
532
|
+
case 'chg': ui.change = !ui.change; paint(); return;
|
|
533
|
+
case 'topic': {
|
|
534
|
+
const tp = F && F.state === 'ok' ? F.topics[+t.dataset.n - 1] : null, body = tp ? topicBody(row, tp.text) : null; if (!body) return;
|
|
535
|
+
const res = await d.pmPost('/api/meeting-focus/topic', body);
|
|
536
|
+
ui.recMsg = res && res.ok === true ? '' : 'The topic was not set: ' + ((res && res.error) || 'no answer'); ui.change = false;
|
|
537
|
+
if (res && res.ok === true) await readFocus(); paint(); if (ui.recMsg) d.toast(ui.recMsg); return;
|
|
538
|
+
}
|
|
539
|
+
case 'replay': return openReplay();
|
|
540
|
+
case 'unreplay': replayStop(); ui.view = 'detail'; paint(); { const b = $('#oMain [data-m3="replay"]'); if (b) b.focus(); } return;
|
|
541
|
+
case 'play': if (repM && RP) replayToggle(); return;
|
|
542
|
+
case 'back10': if (repM && RP) replaySeek(RP.pos - 10000, false); return;
|
|
543
|
+
case 'spd': if (RP) { RP.spd = +t.dataset.v; if (RP.aud) RP.aud.playbackRate = RP.spd; $$('#oMain [data-m3="spd"]').forEach((b) => b.setAttribute('aria-pressed', +b.dataset.v === RP.spd)); } return;
|
|
544
|
+
case 'seek': if (repM && RP) replaySeek(+t.dataset.t, true); return;
|
|
545
|
+
default:
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
197
549
|
function paintSheet() {
|
|
198
550
|
const list = (L, k) => (L.length ? `<ul class="mtg-l">${L.map((it, i) => pickLi(it, k + ':' + i, SH.pick && (SH.pick.ref || SH.pick.url) === (it.ref || it.url) && SH.pick.kind === it.kind)).join('')}</ul>` : '');
|
|
199
551
|
const q = $('#mmSug'); if (!q) return;
|
|
@@ -203,7 +555,7 @@ export function mountMeeting(d) {
|
|
|
203
555
|
$('#mmPaste').innerHTML = pst ? list([pst], 'paste') : `<p class="note">${SH.link ? 'Paste an https address.' : 'A web page opens in a new tab and PMOS does not read it.'}</p>`;
|
|
204
556
|
const k = SH.pick;
|
|
205
557
|
$('#mmOpts').innerHTML = k ? `<div class="mtg-sec"><span class="label">For</span><div class="seg2" role="group" aria-label="For"><button class="mtg-b" data-scope="meeting" aria-pressed="${SH.scope === 'meeting'}">This meeting</button><button class="mtg-b" data-scope="series" aria-pressed="${SH.scope === 'series'}">${row.series ? 'Every meeting in the series' : 'Every meeting with this title'}</button></div>
|
|
206
|
-
<p class="note" id="mmLine">${esc(addLine(k, SH.scope))}</p><div class="mtg-foot"><button class="cta" id="mmDo">Add to the meeting</button><button class="mtg-b" id="mmCancel">Cancel</button></div></div>` : '';
|
|
558
|
+
${SH.topics.length ? `<div class="mtg-sec"><span class="label">Topic</span><div class="seg2" role="group" aria-label="Topic"><button class="mtg-b" data-topic="" aria-pressed="${!SH.topic}">Whole meeting</button>${SH.topics.map((t, i) => `<button class="mtg-b" data-topic="${i + 1}" aria-pressed="${SH.topic === t.text}">${i + 1}. ${esc(clip(t.text, 60))}</button>`).join('')}</div></div>` : ''}<p class="note" id="mmLine">${esc(addLine(k, SH.scope, SH.topic))}</p><div class="mtg-foot"><button class="cta" id="mmDo">Add to the meeting</button><button class="mtg-b" id="mmCancel">Cancel</button></div></div>` : '';
|
|
207
559
|
}
|
|
208
560
|
async function reload() {
|
|
209
561
|
const mt = await d.pmGet(matPath());
|
|
@@ -217,7 +569,9 @@ export function mountMeeting(d) {
|
|
|
217
569
|
if ($('#dTitle').textContent !== row.title) return;
|
|
218
570
|
replay = rp && rp.ok === true ? { state: 'ok', body: rp } : rp && rp.status === 404 ? { state: 'none' } : { state: 'error', error: (rp && rp.error) || 'no answer' };
|
|
219
571
|
material = mt && mt.ok === true ? { state: 'ok', items: mt.items || [] } : { state: 'error', error: (mt && mt.error) || 'no answer' };
|
|
220
|
-
|
|
572
|
+
await readNotes();
|
|
573
|
+
if ($('#dTitle').textContent !== row.title) return;
|
|
574
|
+
paint(); if (HOLD) tickClock(); mark();
|
|
221
575
|
|
|
222
576
|
const write = async (body) => { const res = await d.pmPost('/api/meeting-material', body); return res && res.ok === true ? res : { ok: false, error: (res && res.error) || 'The material was not saved.' }; };
|
|
223
577
|
async function removeItem(item) {
|
|
@@ -243,9 +597,10 @@ export function mountMeeting(d) {
|
|
|
243
597
|
} : null);
|
|
244
598
|
}
|
|
245
599
|
async function openSheet() {
|
|
246
|
-
ui.view = 'add'; SH.sug = null; SH.found = []; SH.pick = null; SH.q = ''; SH.link = ''; paint();
|
|
600
|
+
ui.view = 'add'; SH.sug = null; SH.found = []; SH.pick = null; SH.q = ''; SH.link = ''; SH.topics = []; SH.topic = null; paint();
|
|
247
601
|
$('#mmBack').focus();
|
|
248
|
-
const r = await d.pmGet('/api/meeting-material/suggest?' + suggestQuery(row, { ws: d.ws() }));
|
|
602
|
+
const [r, tp] = await Promise.all([d.pmGet('/api/meeting-material/suggest?' + suggestQuery(row, { ws: d.ws() })), d.pmGet(matPath() + '&topics=1')]);
|
|
603
|
+
SH.topics = tp && tp.ok && Array.isArray(tp.topics) ? tp.topics.filter((t) => t && t.text).slice(0, 8) : [];
|
|
249
604
|
SH.sug = r && r.ok && Array.isArray(r.suggested) ? r.suggested : []; if (ui.view === 'add') paintSheet();
|
|
250
605
|
}
|
|
251
606
|
const closeSheet = (focusAdd) => { ui.view = 'detail'; paint(); if (focusAdd && $('#mmAdd')) $('#mmAdd').focus(); };
|
|
@@ -263,17 +618,19 @@ export function mountMeeting(d) {
|
|
|
263
618
|
$('#oMain').onchange = (e) => { if (e.target.id === 'mtgSel') $('#mtgLink').disabled = !e.target.value; };
|
|
264
619
|
$('#oMain').onclick = async (e) => {
|
|
265
620
|
const t = e.target.closest('button'); if (!t) return;
|
|
621
|
+
if (t.dataset.m3) return m3Press(t.dataset.m3, t);
|
|
266
622
|
if (t.id === 'mmAdd') return openSheet();
|
|
267
623
|
if (t.id === 'mmBack' || t.id === 'mmCancel') return closeSheet(true);
|
|
268
624
|
if (t.dataset.pick) { SH.pick = pickOf(t.dataset.pick); paintSheet(); return; }
|
|
269
625
|
if (t.dataset.scope) { SH.scope = t.dataset.scope; paintSheet(); return; }
|
|
626
|
+
if (t.dataset.topic !== undefined) { const tp = SH.topics[+t.dataset.topic - 1]; SH.topic = t.dataset.topic && tp ? tp.text : null; paintSheet(); return; }
|
|
270
627
|
if (t.id === 'mmDo') {
|
|
271
|
-
const body = addBody(row, SH.pick, SH.scope); if (!body) return;
|
|
628
|
+
const body = addBody(row, SH.pick, SH.scope, SH.topic); if (!body) return;
|
|
272
629
|
t.disabled = true;
|
|
273
630
|
const res = await write(body);
|
|
274
631
|
if (!res.ok) { t.disabled = false; $('#mmLine').textContent = 'The material was not saved: ' + res.error; return; }
|
|
275
632
|
await reload(); ui.view = 'detail';
|
|
276
|
-
say('Added “' + clip(SH.pick.title, 80) + '” to ' + scopeText(SH.scope) + '.');
|
|
633
|
+
say('Added “' + clip(SH.pick.title, 80) + '” to ' + scopeText(SH.scope) + (SH.topic ? ', under “' + clip(SH.topic, 60) + '”' : '') + '.');
|
|
277
634
|
if ($('#mmAdd')) $('#mmAdd').focus();
|
|
278
635
|
return;
|
|
279
636
|
}
|
|
@@ -303,5 +660,7 @@ export function mountMeeting(d) {
|
|
|
303
660
|
|
|
304
661
|
$('#rng').addEventListener('click', (e) => { const b = e.target.closest('button'); if (b && b.dataset.r !== mode && d.redraw) setMode(b.dataset.r, d.redraw); });
|
|
305
662
|
$('#tl').addEventListener('click', (e) => { const b = e.target.closest('.ev[data-w]'); if (!b) return; e.stopImmediatePropagation(); const r = rowOf(b.dataset.w); if (r) openRow(r, 'week'); }, true);
|
|
306
|
-
|
|
663
|
+
readNotes().then(() => mark());
|
|
664
|
+
{ const want = new URLSearchParams(location.search).get('meeting'); if (want) { history.replaceState(null, '', location.pathname + location.search.replace(/[?&]meeting=[^&]*/, '').replace(/^&/, '?')); setTimeout(() => openNote(want), 600); } }
|
|
665
|
+
return { mode: () => mode, draw, openToday, busy: () => busy, mark, openNote };
|
|
307
666
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* pm/premium-shell.js — what the premium Briefing and My work pages share: the theme, the toast, the standard dialog and the read-only agent's conversation (initiatives briefing-premium and my-work-premium). */
|
|
2
2
|
import { pmGet, pmPost } from './http.js';
|
|
3
|
+
import { recChipView, STOP_LINE } from './premium-meeting.js';
|
|
3
4
|
export const $ = (s, r = document) => r.querySelector(s);
|
|
4
5
|
export const $$ = (s, r = document) => [...r.querySelectorAll(s)];
|
|
5
6
|
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
|
@@ -144,7 +145,42 @@ addEventListener('scroll', onScroll, { passive: true }); addEventListener('resiz
|
|
|
144
145
|
|
|
145
146
|
/* ── the rail: Briefing, My work, Board and Insights are premium pages ── */
|
|
146
147
|
const GO = { brief: '/premium.html', work: '/premium-work.html', init: '/premium-board.html', rep: '/premium-insights.html' };
|
|
148
|
+
/* ── the recording chip: while a note records or is paused, every premium page says so and can stop it (initiative briefing-premium-calendar, slice 3) ───────────────
|
|
149
|
+
* It reads GET /api/notes. Only the Briefing holds a recorder; the other pages show what the server holds, and Stop there ends the meeting through POST /api/notes/stop. */
|
|
150
|
+
function mountRecChip(here) {
|
|
151
|
+
const c = document.createElement('div'); c.className = 'recchip glass'; c.id = 'recChip'; c.hidden = true; c.setAttribute('role', 'status'); document.body.appendChild(c);
|
|
152
|
+
let rows = [], ask = false, msg = '';
|
|
153
|
+
const holding = () => (window.__premiumHolding && window.__premiumHolding.id) || null;
|
|
154
|
+
const draw = () => {
|
|
155
|
+
const v = recChipView(rows, { holdingId: holding(), here });
|
|
156
|
+
if (!v) { c.hidden = true; c.innerHTML = ''; ask = false; return; }
|
|
157
|
+
c.hidden = false; c.dataset.mode = v.mode;
|
|
158
|
+
if (ask) { c.innerHTML = `<span>Stop “${esc(v.title)}” for good? ${esc(STOP_LINE)}</span><button data-r="no">Cancel</button>${v.held ? '<button data-r="pause">Pause instead</button>' : ''}<button data-r="stopgo">Stop for good</button>`; return; }
|
|
159
|
+
c.innerHTML = `<i${v.mode === 'paused' ? ' class="paused"' : ''}></i><span>${esc(msg || v.text)}</span><button data-r="open">Open</button>${v.canPause ? '<button data-r="pause">Pause</button>' : ''}${v.canResume ? '<button data-r="resume">Resume</button>' : ''}<button data-r="stop">Stop</button>`;
|
|
160
|
+
};
|
|
161
|
+
const read = async () => { const r = await pmGet('/api/notes'); if (r && r.ok === true && Array.isArray(r.notes)) rows = r.notes; draw(); };
|
|
162
|
+
c.addEventListener('click', async (e) => {
|
|
163
|
+
const b = e.target.closest('button'); if (!b) return;
|
|
164
|
+
const v = recChipView(rows, { holdingId: holding(), here }); if (!v) return;
|
|
165
|
+
const act = b.dataset.r; msg = '';
|
|
166
|
+
if (act === 'open') { if (here === 'brief' && window.__premiumRec) window.__premiumRec.open(v.id); else location.assign('/premium.html?meeting=' + encodeURIComponent(v.id)); return; }
|
|
167
|
+
if (act === 'stop') { ask = true; draw(); const g = c.querySelector('[data-r="no"]'); if (g) g.focus(); return; }
|
|
168
|
+
if (act === 'no') { ask = false; draw(); return; }
|
|
169
|
+
b.disabled = true;
|
|
170
|
+
if (act === 'pause') { ask = false; const r = window.__premiumRec ? await window.__premiumRec.pause() : { ok: false }; msg = r.ok ? '' : (r.error || 'It was not paused.'); }
|
|
171
|
+
else if (act === 'resume') { const r = window.__premiumRec ? await window.__premiumRec.resume(v.id) : { ok: false }; msg = r.ok ? '' : (r.error || 'It was not resumed.'); }
|
|
172
|
+
else if (act === 'stopgo') {
|
|
173
|
+
ask = false;
|
|
174
|
+
const r = window.__premiumRec ? await window.__premiumRec.stop(v.id) : await pmPost('/api/notes/stop', { id: v.id });
|
|
175
|
+
if (r && r.ok === true) toast('Stopped for good. The final notes are written now.'); else msg = (r && r.error) || 'The meeting was not stopped.';
|
|
176
|
+
}
|
|
177
|
+
await read();
|
|
178
|
+
});
|
|
179
|
+
addEventListener('premium-rec', read);
|
|
180
|
+
read(); setInterval(read, 20000);
|
|
181
|
+
}
|
|
147
182
|
export function wireRail(here) {
|
|
183
|
+
mountRecChip(here);
|
|
148
184
|
const rail = $('.rail');
|
|
149
185
|
rail.style.setProperty('--pi', String(['brief', 'work', 'init', 'rep'].indexOf(here)));
|
|
150
186
|
$$('.rail [data-go]').forEach((b) => { b.onclick = () => { if (b.dataset.go !== here) location.assign(GO[b.dataset.go]); }; });
|