create-pmos 0.343.0 → 0.345.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 +25 -35
- 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-3-test.js +36 -0
- package/workspace/briefing-premium-test.js +30 -16
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +18 -6
- package/workspace/lib/agent-inbox.js +135 -0
- package/workspace/lib/briefing-premium-agent.js +1 -1
- package/workspace/lib/briefing-premium-products.js +2 -2
- package/workspace/lib/briefing-premium.js +5 -2
- package/workspace/lib/goal-chat.js +6 -4
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-briefing-premium.js +5 -3
- package/workspace/lib/routes-inbox.js +44 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/premium-meeting.js +106 -21
- package/workspace/public/pm/premium-shell.js +72 -14
- package/workspace/public/pm/premium.css +59 -0
- package/workspace/public/pm/premium.js +56 -10
- package/workspace/test-files.json +2 -0
|
@@ -142,7 +142,9 @@ function resume({ runtimeDir, key, now = new Date() }) {
|
|
|
142
142
|
* A row goes when the PM writes in the conversation, starts a new /goal there, or after ROW_DAYS. */
|
|
143
143
|
const ROW_DAYS = 7;
|
|
144
144
|
const ROW_TITLE = { done: 'Check the goal Claude finished', waiting: 'Claude needs you on a goal', stopped: 'A goal stopped before it was done' };
|
|
145
|
-
function briefingRows(runtimeDir, now = Date.now()) {
|
|
145
|
+
function briefingRows(runtimeDir, now = Date.now()) { return goalRowsAt(runtimeDir, now).map(({ at, goalState, ...r }) => r); }
|
|
146
|
+
/** briefingRows with each row's `at` (ms of the goal's last event) and `goalState` (done, stopped, waiting) kept: the bell's inbox orders and marks new by it (premium-agent-inbox). */
|
|
147
|
+
function goalRowsAt(runtimeDir, now = Date.now()) {
|
|
146
148
|
let t; try { t = fs.readFileSync(path.join(runtimeDir, RUNS), 'utf8'); } catch { return []; }
|
|
147
149
|
const keys = new Set();
|
|
148
150
|
for (const l of t.split('\n')) { if (!l.trim()) continue; try { const e = JSON.parse(l); if (e && typeof e.key === 'string') keys.add(e.key); } catch { /* skip */ } }
|
|
@@ -155,7 +157,7 @@ function briefingRows(runtimeDir, now = Date.now()) {
|
|
|
155
157
|
const all = g.draft.done || [], met = (g.met || []).length;
|
|
156
158
|
const why = g.state === 'stopped' ? (REASON[g.reason] || 'It stopped.') : g.state === 'waiting' ? 'Claude asked you something in the conversation.' : 'Claude reports every done point met. It checked its own work.';
|
|
157
159
|
out.push({
|
|
158
|
-
kind: 'goal', key: 'goal:' + key, chatKey: key, title: ROW_TITLE[g.state], subject: clip(g.draft.goal, 90),
|
|
160
|
+
kind: 'goal', key: 'goal:' + key, chatKey: key, goalState: g.state, title: ROW_TITLE[g.state], subject: clip(g.draft.goal, 90),
|
|
159
161
|
prepared: met + ' of ' + all.length + ' done points met, as Claude reports it. ' + why,
|
|
160
162
|
skip: g.state === 'waiting' ? 'If you skip: the goal waits and nothing more is done on it.' : 'If you skip: nobody checks the work before it is relied on.',
|
|
161
163
|
at,
|
|
@@ -169,7 +171,7 @@ function briefingRows(runtimeDir, now = Date.now()) {
|
|
|
169
171
|
});
|
|
170
172
|
}
|
|
171
173
|
// the newest first, those that wait on the PM before the rest
|
|
172
|
-
return out.sort((a, b) => ((a.title === ROW_TITLE.waiting ? 0 : 1) - (b.title === ROW_TITLE.waiting ? 0 : 1)) || (b.at - a.at))
|
|
174
|
+
return out.sort((a, b) => ((a.title === ROW_TITLE.waiting ? 0 : 1) - (b.title === ROW_TITLE.waiting ? 0 : 1)) || (b.at - a.at));
|
|
173
175
|
}
|
|
174
176
|
/** The Briefing model with the goal rows first (U7). The rows already on the list follow; the count and the dock count them too. */
|
|
175
177
|
function withGoalRows(model, rows) {
|
|
@@ -218,4 +220,4 @@ function decide({ runtimeDir, key, id, act, draft, session, sessions, now = new
|
|
|
218
220
|
return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
|
|
219
221
|
}
|
|
220
222
|
|
|
221
|
-
module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, begin, decide, onStop, resume, briefingRows, withGoalRows, blockOf, keyOfSession, hookSettings, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
|
|
223
|
+
module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
|
|
@@ -56,6 +56,7 @@ const MODULES = Object.freeze([
|
|
|
56
56
|
'routes-initiative-premium', // briefing-premium-initiative: the premium initiative page's model from the Initiatives sheet's own routes (read-only)
|
|
57
57
|
'routes-brief-page', // console3 Briefing as the brief: Today agenda, Needs you and Mentions (read-only; writes go through routes-pm-items)
|
|
58
58
|
'routes-mentions', // console3 Briefing Mentions: the PM's read marks (page press only)
|
|
59
|
+
'routes-inbox', // premium-agent-inbox: the bell's agent results and the PM's seen marks (page press only)
|
|
59
60
|
'routes-phone-day', // phone companion: the agent's finished drafts, the evening recap and tomorrow at a glance (read-only)
|
|
60
61
|
'routes-report-facts', // console3 D: GET /api/report-families/facts (read-only, real data only)
|
|
61
62
|
'routes-records', // console3 E1a: ideas, hypotheses, decisions, KR metrics, bets (GET list; page-press add/edit/reading)
|
|
@@ -14,6 +14,7 @@ const guard = require('./pm-guard.js');
|
|
|
14
14
|
const Wr = require('./briefing-premium-writes.js');
|
|
15
15
|
const Ag = require('./briefing-premium-agent.js');
|
|
16
16
|
const Goal = require('./goal-chat.js');
|
|
17
|
+
const Inbox = require('./agent-inbox.js');
|
|
17
18
|
const actor = require('./actor.js');
|
|
18
19
|
const WP = require('./my-work-premium.js');
|
|
19
20
|
const BoardP = require('./board-premium.js');
|
|
@@ -106,6 +107,7 @@ async function post(req, res, url, ctx) {
|
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
module.exports = {
|
|
110
|
+
products,
|
|
109
111
|
prefixes: ['/api/briefing-premium'],
|
|
110
112
|
handle: async (req, res, url, ctx) => {
|
|
111
113
|
if (url.pathname === '/api/briefing-premium/goal-stop') {
|
|
@@ -139,8 +141,8 @@ module.exports = {
|
|
|
139
141
|
const sel = products(ctx);
|
|
140
142
|
const sources = await Src.readSources(ctx, Date.now()).catch(() => null);
|
|
141
143
|
const agent = Drafts.readDrafts(sel.available);
|
|
142
|
-
const r = await Prod.modelOfMany({ available: sel.available, engine: enginePath(), runtimeDir: ctx.runtimeDir, sources, agent });
|
|
143
|
-
if (r.model
|
|
144
|
+
const r = await Prod.modelOfMany({ available: sel.available, engine: enginePath(), runtimeDir: ctx.runtimeDir, sources, agent, agentAside: true });
|
|
145
|
+
if (r.model) r.model = Inbox.split(r.model, ctx.runtimeDir ? Goal.goalRowsAt(ctx.runtimeDir) : []); // premium-chat-session U7: goals read live, not cached; premium-agent-inbox: they and the drafts go to the bell
|
|
144
146
|
ctx.json(res, r.state === 'error' ? { ok: false, ...r } : { ok: true, ...r }, r.state === 'ready' ? 200 : r.state === 'reading' ? 202 : 500);
|
|
145
147
|
return true;
|
|
146
148
|
}
|
|
@@ -148,7 +150,7 @@ module.exports = {
|
|
|
148
150
|
try { const w = ctx.getWs && ctx.getWs(url.searchParams.get('ws') || null); root = w && w.root; } catch { root = null; }
|
|
149
151
|
root = root || path.resolve(__dirname, '..', '..');
|
|
150
152
|
const r = await BP.modelOf({ root, engine: enginePath(), runtimeDir: ctx.runtimeDir });
|
|
151
|
-
if (r.model
|
|
153
|
+
if (r.model) r.model = Inbox.split(r.model, ctx.runtimeDir ? Goal.goalRowsAt(ctx.runtimeDir) : []);
|
|
152
154
|
// 200 with the model, 202 while the first read goes on, 500 with the reason when a read failed
|
|
153
155
|
ctx.json(res, r.state === 'error' ? { ok: false, ...r } : { ok: true, ...r }, r.state === 'ready' ? 200 : r.state === 'reading' ? 202 : 500);
|
|
154
156
|
return true;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-inbox.js — the bell's inbox of agent results that wait on the PM (initiative premium-agent-inbox).
|
|
3
|
+
*
|
|
4
|
+
* GET /api/inbox → { ok, count, newCount, items, more, bundles, oldest, seenAt } lib/agent-inbox.js build()
|
|
5
|
+
* POST /api/inbox/seen { ids } | { all } → { ok } one line in <runtime>/inbox-seen.jsonl, a page press only (pm-guard requirePagePress)
|
|
6
|
+
*
|
|
7
|
+
* The read takes the products the premium Briefing reads (routes-briefing-premium products), their Driver ledgers and the goal rows.
|
|
8
|
+
* Seen is not done: an item goes only when its record changes. Nothing here decides a proposal or sends anything. */
|
|
9
|
+
const guard = require('./pm-guard.js');
|
|
10
|
+
const Inbox = require('./agent-inbox.js');
|
|
11
|
+
const Goal = require('./goal-chat.js');
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
prefixes: ['/api/inbox'],
|
|
15
|
+
handle: async (req, res, url, ctx) => {
|
|
16
|
+
if (url.pathname === '/api/inbox/seen') {
|
|
17
|
+
if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
|
|
18
|
+
const got = await ctx.readJson(req);
|
|
19
|
+
if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
|
|
20
|
+
const b = got.body || {};
|
|
21
|
+
const g = guard.requirePagePress(req, b);
|
|
22
|
+
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
|
|
23
|
+
const err = Inbox.badSeen(b);
|
|
24
|
+
if (err) { ctx.json(res, { ok: false, error: err }, 400); return true; }
|
|
25
|
+
if (!ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'no runtime folder' }, 500); return true; }
|
|
26
|
+
Inbox.appendSeen(ctx.runtimeDir, b);
|
|
27
|
+
ctx.json(res, { ok: true });
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (url.pathname !== '/api/inbox') return false;
|
|
31
|
+
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
32
|
+
const { products } = require('./routes-briefing-premium.js');
|
|
33
|
+
let available = [];
|
|
34
|
+
try { available = products(ctx).available; } catch { available = []; }
|
|
35
|
+
const out = Inbox.build({
|
|
36
|
+
proposals: Inbox.readProposals(available),
|
|
37
|
+
goals: ctx.runtimeDir ? Goal.goalRowsAt(ctx.runtimeDir) : [],
|
|
38
|
+
seen: ctx.runtimeDir ? Inbox.readSeen(ctx.runtimeDir) : undefined,
|
|
39
|
+
now: Date.now(),
|
|
40
|
+
});
|
|
41
|
+
ctx.json(res, { ok: true, ...out });
|
|
42
|
+
return true;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.345.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.345.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -313,10 +313,22 @@ export function replayModel(rep) {
|
|
|
313
313
|
if (!len && lines.length) len = lines[lines.length - 1].t;
|
|
314
314
|
if (!(len > 0)) return null;
|
|
315
315
|
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);
|
|
316
|
-
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 || '',
|
|
316
|
+
const keys = (Array.isArray(rep.keys) ? rep.keys : []).filter((k) => k && ['decision', 'action', 'question'].includes(k.k)).map((k, i) => ({ id: k.id || 'k' + i, k: k.k, text: clip(k.text, 240), t: Number.isFinite(k.t) ? k.t : null, owner: clip(k.owner, 60), due: k.due || '', by: clip(k.by, 60), state: k.state || '',
|
|
317
|
+
need: !!k.warn || k.state === 'owner' || k.state === 'open' }));
|
|
317
318
|
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);
|
|
318
|
-
|
|
319
|
+
/* PMOS's notes (the meeting companion's, from the Focus file), the gaps where the recording was off, and the line each key point was caught from */
|
|
320
|
+
const pmos = (Array.isArray(rep.notes) ? rep.notes : []).filter((x) => x && Number.isFinite(x.t) && String(x.body || '').trim()).map((x) => ({ t: Math.max(0, Math.min(len, x.t)), cat: clip(x.cat, 30), body: clip(x.body, 400) })).sort((a, b) => a.t - b.t);
|
|
321
|
+
const gaps = (Array.isArray(rep.gaps) ? rep.gaps : []).filter((g) => Number.isFinite(g.from_ms) && Number.isFinite(g.to_ms) && g.to_ms > g.from_ms).map((g) => ({ from: g.from_ms, to: Math.min(len, g.to_ms) }));
|
|
322
|
+
const keyOfLine = new Map((Array.isArray(rep.lines) ? rep.lines : []).filter((l) => l && l.key && l.key.k).map((l) => [l.t, l.key.k]));
|
|
323
|
+
lines.forEach((l) => { l.key = keyOfLine.get(l.t) || ''; });
|
|
324
|
+
const n = rep.note || {}, ini = n.initiative && n.initiative.id ? n.initiative : null, mt = rep.meeting || {};
|
|
325
|
+
return { len, audio: rep.audio && rep.audio.url ? { url: String(rep.audio.url) } : null, lines, keys, stretches, topics, shots, pmos, gaps,
|
|
326
|
+
start: Number.isFinite(rep.start_ms) ? rep.start_ms : null, at: mt.at || null, people: Array.isArray(mt.attendees) ? mt.attendees.length : 0, aside: Number(rep.aside_count) || 0,
|
|
327
|
+
noteId: n.id || '', title: clip(mt.title || n.title || '', 120),
|
|
328
|
+
note: n.id ? { id: n.id, title: clip(n.title, 120), initiative: ini ? { id: ini.id, ws: ini.ws || n.ws || '', name: clip(ini.name || ini.title || ini.id, 80) } : null } : null };
|
|
319
329
|
}
|
|
330
|
+
/** The time of day at meeting time `ms` (10:05), or m:ss from the start when the recording's start is not known. */
|
|
331
|
+
export const wallOf = (m, ms) => { if (!m || m.start == null) return mmss(ms); const t = new Date(m.start + ms); return pad(t.getHours()) + ':' + pad(t.getMinutes()); };
|
|
320
332
|
/** Where the playhead is: the current line, the stretch (topic) and the key points within 30 s. */
|
|
321
333
|
export function replayAt(m, pos) {
|
|
322
334
|
let line = -1; for (const l of m.lines) { if (l.t <= pos) line = l.i; else break; }
|
|
@@ -495,7 +507,10 @@ export function mountMeeting(d) {
|
|
|
495
507
|
|
|
496
508
|
/* the dialog */
|
|
497
509
|
const sec = (label, body) => `<div class="mtg-sec"><span class="label">${esc(label)}</span>${body}</div>`;
|
|
498
|
-
const IC = { spark: '<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>', clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>', scale: '<path d="M12 4v16M6 20h12M5 8h14M5 8l-2 6a3 3 0 0 0 4 0zM19 8l-2 6a3 3 0 0 0 4 0z"/>', doc: '<path d="M7 3h7l4 4v14H7zM14 3v4h4"/>', user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c1-4 4-6 8-6s7 2 8 6"/>', link: '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>', mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>',
|
|
510
|
+
const IC = { spark: '<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>', clock: '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>', scale: '<path d="M12 4v16M6 20h12M5 8h14M5 8l-2 6a3 3 0 0 0 4 0zM19 8l-2 6a3 3 0 0 0 4 0z"/>', doc: '<path d="M7 3h7l4 4v14H7zM14 3v4h4"/>', user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c1-4 4-6 8-6s7 2 8 6"/>', link: '<path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/>', mic: '<rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/>',
|
|
511
|
+
dec: '<path d="M6 4v8a4 4 0 0 0 4 4h9"/><path d="M15 12l4 4-4 4"/>', task: '<rect x="3" y="4" width="7" height="7" rx="1.5"/><path d="M4.8 7.6l1.4 1.3 2.3-2.6M14 7.5h7M14 17.5h7"/><rect x="3" y="14" width="7" height="7" rx="1.5"/>',
|
|
512
|
+
undo: '<path d="M9 14L4 9l5-5"/><path d="M4 9h11a5 5 0 0 1 0 10h-3"/>', play: '<path d="M7 5l12 7-12 7z"/>', pause: '<path d="M9 5v14M15 5v14"/>', lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/>',
|
|
513
|
+
xp: '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 10l3 3 3-3"/>', search: '<circle cx="11" cy="11" r="6.5"/><path d="M16 16l4 4"/>', back: '<path d="M15 6l-6 6 6 6"/>', plus: '<path d="M12 5v14M5 12h14"/>', x: '<path d="M6 6l12 12M18 6 6 18"/>', check: '<path d="M5 12.5l4.5 4.5L19 7.5"/>' };
|
|
499
514
|
const ic = (n) => `<svg class="i" viewBox="0 0 24 24">${IC[n]}</svg>`;
|
|
500
515
|
const secH = (t, tag, extra) => `<h4 class="sh">${esc(t)}${tag ? ` <small>${esc(tag)}</small>` : ''}${extra || ''}</h4>`;
|
|
501
516
|
const pickLi = (it, key, on) => `<li class="mtg-pick"><span>${esc(clip(it.title, 120))}<em>${esc([it.kind, it.meta].filter(Boolean).join(' · '))}</em></span>${on ? '<span class="mtg-on">Picked</span>' : `<button class="mtg-b" data-pick="${esc(key)}">Pick</button>`}</li>`;
|
|
@@ -556,6 +571,7 @@ export function mountMeeting(d) {
|
|
|
556
571
|
|
|
557
572
|
async function openRow(row, via) {
|
|
558
573
|
delete $('#oMain').dataset.ready;
|
|
574
|
+
{ const g = document.getElementById('dlg'); if (g) g.classList.remove('rpw'); } // a Replay left open when the dialog closed
|
|
559
575
|
let replay = null, material = null, extra = { prev: [], topics: [] }, boards = W ? W.boards : [], inis = W ? W.initiatives : [], saved = '';
|
|
560
576
|
const ui = { view: 'detail', status: null, tasked: new Set(), phase: 'before', picked: false }, SH = { sug: null, found: [], pick: null, scope: 'meeting', q: '', link: '', token: 0, topics: [], topic: null };
|
|
561
577
|
let stT = null, findT = null, undoFn = null;
|
|
@@ -608,34 +624,86 @@ export function mountMeeting(d) {
|
|
|
608
624
|
}
|
|
609
625
|
|
|
610
626
|
/* Replay: the note's audio, the transcript and the key points on one track (GET /api/meeting-replay, GET /api/notes/recording) */
|
|
627
|
+
/* Replay, laid out as the prototype's replay (prototype/premium-conversation-shell, PR 901) and the console's (c3-replay.js), from GET /api/meeting-replay:
|
|
628
|
+
* the head with the player and the time of day, the topic track with a mark for each key point (ringed when it needs you) and each PMOS note,
|
|
629
|
+
* what was on screen beside the conversation (All, Key points, PMOS, search), and the key points in three columns with Confirm all. */
|
|
630
|
+
const RPK = { decision: ['dec', 'Decision', 'Decisions'], action: ['task', 'Next step', 'Next steps'], question: ['undo', 'Question', 'Questions'] };
|
|
611
631
|
function replayHtml() {
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
if (
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
h
|
|
622
|
-
|
|
623
|
-
h +=
|
|
632
|
+
const back = `<button class="mtg-b" data-m3="unreplay">${ic('back')}Back to the meeting</button>`;
|
|
633
|
+
const head0 = `<div class="m3-fh">${back}<div class="m3-fti"><b>${esc(row.title)}</b><span class="note">Replay · ${esc(row.time)}</span></div></div>`;
|
|
634
|
+
if (repM === undefined) return `<article class="paper doc mtg">${head0}<p class="note" role="status">${esc(RP && RP.error ? 'Replay could not be read: ' + RP.error : 'Reading the recording.')}</p></article>`;
|
|
635
|
+
if (!repM) return `<article class="paper doc mtg">${head0}<p class="note">Reading the recording.</p></article>`;
|
|
636
|
+
const m = repM, pct = (t) => Math.min(100, Math.max(0, t / m.len * 100)).toFixed(2), w = (t) => wallOf(m, t);
|
|
637
|
+
const day = m.at && Number.isFinite(Date.parse(m.at)) ? new Date(m.at).toLocaleDateString(undefined, { weekday: 'short', day: 'numeric', month: 'short' }) : row.day;
|
|
638
|
+
const chips = [day, m.start != null ? w(0) + ' to ' + w(m.len) : '', Math.max(1, Math.round(m.len / 60000)) + ' min', m.people ? m.people + (m.people === 1 ? ' person' : ' people') : ''].filter(Boolean).join(' · ');
|
|
639
|
+
const kept = (m.audio ? 'audio' : 'no audio') + (m.shots.length ? ' and ' + m.shots.length + (m.shots.length === 1 ? ' screen shot' : ' screen shots') : '');
|
|
640
|
+
const need = m.keys.filter((k) => k.need).length;
|
|
641
|
+
let h = `<section class="rp-hd"><div class="m3-fh">${back}<div class="m3-fti"><b>${esc(m.title || row.title)}</b><span class="note">${esc(chips)} · ${ic('lock')}${esc(kept)}</span></div>
|
|
642
|
+
<div class="rp-clk"><b id="rpPos">${mmss(0)} / ${mmss(m.len)}</b><small id="rpClk">${esc(w(0))}</small></div></div>`;
|
|
643
|
+
h += `<div class="m3-rctl"><button class="mtg-b" data-m3="back10" aria-label="Back 10 seconds">${ic('undo')}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></div>`;
|
|
644
|
+
const marks = m.keys.filter((k) => k.t != null).map((k) => `<button class="rp-mk ${k.k}${k.need ? ' need' : ''}" style="left:${pct(k.t)}%" data-rp="seek" data-t="${k.t}" aria-label="${RPK[k.k][1]} at ${esc(w(k.t))}: ${esc(k.text)}" title="${esc(RPK[k.k][1] + ' · ' + k.text)}"><span>${ic(RPK[k.k][0])}</span></button>`)
|
|
645
|
+
.concat(m.pmos.map((x) => `<button class="rp-mk pm" style="left:${pct(x.t)}%" data-rp="seek" data-t="${x.t}" aria-label="PMOS note at ${esc(w(x.t))}: ${esc(x.body)}" title="${esc('PMOS · ' + x.body)}"><span>${ic('spark')}</span></button>`)).join('');
|
|
646
|
+
const track = 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) + ' from ' + w(x.from))}">${x.n}</button>`).join('');
|
|
647
|
+
const dots = m.keys.filter((k) => k.t != null).map((k) => `<i class="m3-mk ${k.k}" style="left:${pct(k.t)}%"></i>`).join('');
|
|
648
|
+
const gaps = m.gaps.map((g) => `<i class="rp-gap" style="left:${pct(g.from)}%;width:${(Math.max(0.6, (g.to - g.from) / m.len * 100)).toFixed(2)}%" title="Not recorded ${esc(w(g.from))} to ${esc(w(g.to))}"></i>`).join('');
|
|
649
|
+
const ticks = [0, 0.25, 0.5, 0.75, 1].map((f) => `<span>${esc(w(m.len * f))}</span>`).join('');
|
|
650
|
+
h += `<div class="rp-tl"><div class="rp-mks">${marks}</div><div class="m3-trk${track ? '' : ' none'}" role="group" aria-label="The meeting by topic">${track || `<button class="m3-stc" style="flex:1" data-m3="seek" data-t="0" aria-label="From the start">${m.topics.length ? '' : 'No topics were kept'}</button>`}${dots}${gaps}<b class="m3-ph" id="rpPh"></b></div><div class="rp-sc">${ticks}</div></div>`;
|
|
651
|
+
h += `<div class="m3-lgd"><span>${ic('dec')}Decisions</span><span>${ic('undo')}Questions</span><span>${ic('task')}Next steps</span><span>${ic('spark')}PMOS notes</span><span><i class="ring"></i>needs you</span></div></section>`;
|
|
652
|
+
h += `<div class="m3-now"><span class="label">Topic</span><b id="rpTopic"></b><span class="note" id="rpNear"></span>${m.shots.length ? `<span class="chp sm" id="rpShK">${ic('xp')}<span></span></span>` : ''}${m.keys.length ? `<button class="mtg-b" data-rp="keys">${ic('check')}${m.keys.length} key ${m.keys.length === 1 ? 'point' : 'points'}${need ? ' · ' + need + ' need you' : ''}</button>` : ''}</div>`;
|
|
653
|
+
const strip = m.shots.map((x) => `<button class="mtg-b" data-m3="seek" data-t="${x.t}" data-shot="${x.t}" title="${esc(x.why || 'The shared screen at ' + w(x.t))}">${esc(w(x.t))}</button>`).join('');
|
|
654
|
+
h += `<div class="rp-g"><section class="rp-box rp-st"><div class="rp-cap">${ic('xp')}<b>On screen</b><span class="note">Kept when the screen changed${m.aside ? ' · ' + m.aside + ' set aside' : ''}</span></div><div id="rpShot"></div>${strip ? `<div class="rp-ts" role="group" aria-label="Screen shots kept, by time">${strip}</div>` : ''}</section>
|
|
655
|
+
<section class="rp-box rp-cv"><div class="rp-cvh"><b>Conversation</b><div class="seg2" role="group" aria-label="Show">${[['a', 'All'], ['k', 'Key points'], ['p', 'PMOS']].map(([k, l]) => `<button class="mtg-b" data-rp="tab" data-v="${k}" aria-pressed="${RP.tab === k}">${l}</button>`).join('')}</div></div>
|
|
656
|
+
<div class="m3-ftr all" id="rpLines">${convHtml()}</div><label class="rp-q">${ic('search')}<input id="rpQ" type="search" placeholder="Search what was said" aria-label="Search what was said" value="${esc(RP.q)}" autocomplete="off"></label></section></div>`;
|
|
657
|
+
h += `<section class="rp-box" id="rpKeys"><div class="rp-cvh"><div class="rp-cap">${ic('check')}<b>Key points</b></div>${m.keys.some((k) => k.k === 'action') ? `<button class="mtg-b cta" data-rp="confirm" title="Make a task of each next step on the note’s initiative">${ic('check')}Confirm all</button>` : ''}</div>`
|
|
658
|
+
+ (m.keys.length ? `<div class="m3-kps rp-kc">${['decision', 'action', 'question'].map((k) => { const l = m.keys.filter((x) => x.k === k); return `<div class="rp-col"><h4>${ic(RPK[k][0])}${RPK[k][2]}<small>${l.length}</small></h4>${l.length ? l.map(keyHtml).join('') : '<p class="note">None caught.</p>'}</div>`; }).join('')}</div><p class="note">Each one plays from the moment it was said. Confirm all makes a task of each next step on the note’s initiative.</p>` : '<p class="note">The note holds no decisions, next steps or questions.</p>') + '</section>';
|
|
624
659
|
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>`;
|
|
625
|
-
return `<article class="paper doc mtg">${h}</article>`;
|
|
660
|
+
return `<article class="paper doc mtg rpv">${h}</article>`;
|
|
661
|
+
}
|
|
662
|
+
function keyHtml(k) {
|
|
663
|
+
const meta = k.k === 'decision' ? (k.by || 'the group') : k.k === 'action' ? (k.owner ? [k.owner, k.due && 'due ' + k.due].filter(Boolean).join(' · ') : 'no owner') : k.state === 'answered' ? 'answered' : 'still open';
|
|
664
|
+
const tags = `<span class="rp-tg"><span class="${k.need ? 'warn' : ''}">${esc(meta)}</span>${k.k === 'question' ? '' : `<span>${RP.done.has(k.id) ? 'task made' : 'draft'}</span>`}</span>`;
|
|
665
|
+
const kind = `<span class="kd">${esc(RPK[k.k][1])}</span>`;
|
|
666
|
+
return k.t != null ? `<button data-m3="seek" data-t="${k.t}" class="${k.need ? 'need' : ''}">${kind}<span>${esc(k.text)}${tags}</span><time>${esc(wallOf(repM, k.t))}</time></button>`
|
|
667
|
+
: `<div class="m3-kp0${k.need ? ' need' : ''}">${kind}<span>${esc(k.text)}${tags}</span><em>No time</em></div>`;
|
|
668
|
+
}
|
|
669
|
+
function convHtml() {
|
|
670
|
+
const m = repM, q = RP.q.trim().toLowerCase();
|
|
671
|
+
const all = [...m.lines.map((l) => ({ t: l.t, l })), ...m.pmos.map((p) => ({ t: p.t, p }))].sort((a, b) => a.t - b.t || (a.p ? 1 : 0) - (b.p ? 1 : 0))
|
|
672
|
+
.filter((x) => RP.tab === 'a' || (RP.tab === 'k' ? x.l && x.l.key : x.p)).filter((x) => !q || (x.l ? x.l.who + ' ' + x.l.text : x.p.body).toLowerCase().includes(q));
|
|
673
|
+
if (!all.length) return `<p class="note">${q ? 'Nothing said matches “' + esc(RP.q) + '”.' : RP.tab === 'p' ? 'PMOS made no notes during this meeting.' : RP.tab === 'k' ? 'No line was caught as a key point.' : 'The recording holds no transcript.'}</p>`;
|
|
674
|
+
return all.map((x) => x.p ? `<button class="m3-ln pm" data-m3="seek" data-t="${x.t}"><time>${esc(wallOf(m, x.t))}</time><b>PMOS</b><span>${esc(x.p.body)}</span></button>`
|
|
675
|
+
: `<button class="m3-ln" id="rl${x.l.i}" data-m3="seek" data-t="${x.l.t}"><time>${esc(wallOf(m, x.l.t))}</time><b>${esc(x.l.who || 'You')}</b><span>${x.l.key && RPK[x.l.key] ? `<em class="rp-kt">${esc(RPK[x.l.key][1])}</em>` : ''}${esc(x.l.text)}</span></button>`).join('');
|
|
626
676
|
}
|
|
627
677
|
function replayPaint() {
|
|
628
678
|
const m = repM; if (!m || !alive('replay')) return;
|
|
629
679
|
const pos = RP.pos, at = replayAt(m, pos), $q = (id) => document.getElementById(id);
|
|
630
680
|
if ($q('rpPos')) $q('rpPos').textContent = mmss(pos) + ' / ' + mmss(m.len);
|
|
681
|
+
if ($q('rpClk')) $q('rpClk').textContent = wallOf(m, pos);
|
|
631
682
|
if ($q('rpPh')) $q('rpPh').style.left = Math.min(100, pos / m.len * 100).toFixed(2) + '%';
|
|
632
683
|
if ($q('rpTopic')) $q('rpTopic').textContent = at.stretch ? (at.stretch.text || 'Topic ' + at.stretch.n) : m.stretches.length ? 'Between topics' : 'No topics were kept';
|
|
633
684
|
if ($q('rpNear')) $q('rpNear').textContent = at.near ? at.near + (at.near === 1 ? ' key point near' : ' key points near') : '';
|
|
634
685
|
if ($q('rpPlay')) $q('rpPlay').textContent = RP.play ? 'Pause' : 'Play';
|
|
635
686
|
$$('#oMain .m3-stc[data-from]').forEach((b) => b.classList.toggle('on', pos >= +b.dataset.from && pos < +b.dataset.to));
|
|
636
687
|
const prev = RP.line; RP.line = at.line;
|
|
637
|
-
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)
|
|
638
|
-
|
|
688
|
+
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) { const L = $q('rpLines'); if (L) L.scrollTop = Math.max(0, c.offsetTop - L.offsetTop - L.clientHeight / 3); } } }
|
|
689
|
+
$$('#oMain .m3-ln.pm').forEach((b) => b.classList.toggle('fut', +b.dataset.t > pos));
|
|
690
|
+
const want = at.shot >= 0 ? m.shots[at.shot] : null;
|
|
691
|
+
if ($q('rpShK')) $q('rpShK').lastChild.textContent = want ? 'Screen shot from ' + wallOf(m, want.t) : 'Nothing shared yet';
|
|
692
|
+
$$('#oMain [data-shot]').forEach((b) => b.setAttribute('aria-pressed', String(!!want && +b.dataset.shot === want.t)));
|
|
693
|
+
const sh = $q('rpShot'); if (sh) { const have = sh.dataset.t, key = want ? String(want.t) : 'none'; if (key !== have) { sh.dataset.t = key; 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))} · ${esc(wallOf(m, want.t))}</figcaption></figure>` : `<p class="note rp-none">${m.shots.length ? 'Nothing was shared yet. The first screen shot is at ' + esc(wallOf(m, m.shots[0].t)) + '.' : 'No screen shots were kept for this meeting.'}</p>`; } }
|
|
694
|
+
}
|
|
695
|
+
/* Confirm all: each next step not yet made becomes a task of the note's initiative, as Make task does (POST /api/plan-items) */
|
|
696
|
+
async function confirmAll(btn) {
|
|
697
|
+
const m = repM, todo = m.keys.filter((k) => k.k === 'action' && !RP.done.has(k.id));
|
|
698
|
+
if (!todo.length) return say('Every next step is already a task.');
|
|
699
|
+
if (!m.note || !m.note.initiative) return say('Link the note to an initiative first. Confirm all adds each next step to its breakdown.');
|
|
700
|
+
if (btn) btn.disabled = true;
|
|
701
|
+
let made = 0, last = '';
|
|
702
|
+
for (const k of todo) { const res = await planTask(m.note, { text: k.text, owner: k.owner, due: k.due }); if (!res.ok) { last = res.text; break; } RP.done.add(k.id); made++; }
|
|
703
|
+
if (!alive('replay')) return;
|
|
704
|
+
const L = $('#rpKeys'); if (L) { const fresh = document.createElement('div'); fresh.innerHTML = replayHtml(); const k2 = fresh.querySelector('#rpKeys'); if (k2) L.replaceWith(k2); }
|
|
705
|
+
say(made ? `${made} next ${made === 1 ? 'step is' : 'steps are'} now ${made === 1 ? 'a task' : 'tasks'} in ${m.note.initiative.name}.${last ? ' ' + last : ''}` : last);
|
|
706
|
+
replayPaint();
|
|
639
707
|
}
|
|
640
708
|
function replayStop() { clearInterval(RP && RP.tm); if (RP && RP.aud) { try { RP.aud.pause(); } catch { /* gone */ } } if (RP) RP.play = false; }
|
|
641
709
|
function replaySeek(ms, play) {
|
|
@@ -659,7 +727,8 @@ export function mountMeeting(d) {
|
|
|
659
727
|
replayPaint();
|
|
660
728
|
}
|
|
661
729
|
async function openReplay() {
|
|
662
|
-
ui.view = 'replay'; repM = null; RP = { pos: 0, play: false, spd: 1, aud: null, tm: null, line: -2, noAudio: false
|
|
730
|
+
ui.view = 'replay'; repM = null; RP = { pos: 0, play: false, spd: 1, aud: null, tm: null, line: -2, noAudio: false, tab: 'a', q: '', done: new Set() };
|
|
731
|
+
wide(true); paint();
|
|
663
732
|
const r = await d.pmGet('/api/meeting-replay?event=' + encodeURIComponent(row.id) + '&date=' + row.day);
|
|
664
733
|
if (!alive('replay')) return;
|
|
665
734
|
repM = replayModel(r);
|
|
@@ -667,7 +736,14 @@ export function mountMeeting(d) {
|
|
|
667
736
|
if (repM.audio) { RP.aud = new Audio(repM.audio.url); RP.aud.preload = 'metadata'; RP.aud.addEventListener('error', () => { RP.aud = null; RP.noAudio = true; }); }
|
|
668
737
|
paint(); $('#rpPlay') && $('#rpPlay').focus(); replayPaint();
|
|
669
738
|
}
|
|
670
|
-
|
|
739
|
+
/* Replay takes the whole window with the conversation hidden, as the prototype's replay does; leaving it puts the dialog back as it was */
|
|
740
|
+
let wasDlg = null;
|
|
741
|
+
function wide(on) {
|
|
742
|
+
const g = document.getElementById('dlg'); if (!g || !d.setFull || !d.setMode) return;
|
|
743
|
+
if (on) { if (!wasDlg) wasDlg = { full: g.classList.contains('full'), mode: g.dataset.mode || 'split' }; d.setFull(true); d.setMode('detail'); g.classList.add('rpw'); return; }
|
|
744
|
+
g.classList.remove('rpw'); if (wasDlg) { d.setFull(wasDlg.full); d.setMode(wasDlg.mode); wasDlg = null; }
|
|
745
|
+
}
|
|
746
|
+
const leave = (to) => { clearTimeout(fT); if (ui.view === 'replay') { replayStop(); wide(false); } ui.view = to; ui.change = false; paint(); const b = $('#oMain [data-m3="' + (to === 'detail' ? (RP && repM ? 'replay' : 'focus') : '') + '"]'); if (b) b.focus(); };
|
|
671
747
|
|
|
672
748
|
/* the presses of the Record row, Focus and Replay */
|
|
673
749
|
async function m3Press(act, t) {
|
|
@@ -700,7 +776,7 @@ export function mountMeeting(d) {
|
|
|
700
776
|
if (res && res.ok === true) await readFocus(); paint(); if (ui.recMsg) d.toast(ui.recMsg); return;
|
|
701
777
|
}
|
|
702
778
|
case 'replay': return openReplay();
|
|
703
|
-
case 'unreplay': replayStop(); ui.view = 'detail'; paint(); { const b = $('#oMain [data-m3="replay"]'); if (b) b.focus(); } return;
|
|
779
|
+
case 'unreplay': replayStop(); wide(false); ui.view = 'detail'; paint(); { const b = $('#oMain [data-m3="replay"]'); if (b) b.focus(); } return;
|
|
704
780
|
case 'play': if (repM && RP) replayToggle(); return;
|
|
705
781
|
case 'back10': if (repM && RP) replaySeek(RP.pos - 10000, false); return;
|
|
706
782
|
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;
|
|
@@ -793,6 +869,7 @@ export function mountMeeting(d) {
|
|
|
793
869
|
const pickOf = (key) => { const [k, i] = key.split(':'); return (k === 'sug' ? SH.sug : k === 'found' ? SH.found : [pasteOf(SH.link)])[+i] || null; };
|
|
794
870
|
|
|
795
871
|
$('#oMain').oninput = (e) => {
|
|
872
|
+
if (e.target.id === 'rpQ' && repM && RP) { RP.q = e.target.value; $('#rpLines').innerHTML = convHtml(); RP.line = -2; replayPaint(); return; }
|
|
796
873
|
if (e.target.id === 'mmLinkIn') { SH.link = e.target.value.trim(); const p = pasteOf(SH.link); if (p) SH.pick = p; else if (SH.pick && !SH.pick.ref) SH.pick = null; paintSheet(); }
|
|
797
874
|
if (e.target.id === 'mmFind') {
|
|
798
875
|
SH.q = e.target.value.trim(); SH.found = []; SH.foundBusy = SH.q.length >= 2; paintSheet(); clearTimeout(findT);
|
|
@@ -806,6 +883,14 @@ export function mountMeeting(d) {
|
|
|
806
883
|
$('#oMain').onclick = async (e) => {
|
|
807
884
|
const t = e.target.closest('button'); if (!t) return;
|
|
808
885
|
if (t.dataset.m3) return m3Press(t.dataset.m3, t);
|
|
886
|
+
if (t.dataset.rp && repM && RP) { // the Replay's own presses: a mark on the track, the conversation tabs, the key points link and Confirm all
|
|
887
|
+
const k = t.dataset.rp;
|
|
888
|
+
if (k === 'seek') return replaySeek(+t.dataset.t, true);
|
|
889
|
+
if (k === 'tab') { RP.tab = t.dataset.v; $$('#oMain [data-rp="tab"]').forEach((b) => b.setAttribute('aria-pressed', String(b === t))); $('#rpLines').innerHTML = convHtml(); RP.line = -2; replayPaint(); return; }
|
|
890
|
+
if (k === 'keys') { const n = $('#rpKeys'); if (n) n.scrollIntoView({ behavior: 'smooth', block: 'start' }); return; }
|
|
891
|
+
if (k === 'confirm') return confirmAll(t);
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
809
894
|
if (t.dataset.ph) {
|
|
810
895
|
ui.phase = t.dataset.ph; ui.picked = true;
|
|
811
896
|
$$('#oMain .vm-ph [data-ph]').forEach((b) => b.setAttribute('aria-pressed', String(b === t)));
|
|
@@ -163,7 +163,14 @@ tbMount(); // the top bar first: the menu holds the Settings, Agent sessions,
|
|
|
163
163
|
|
|
164
164
|
/* ── toast ──────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
165
165
|
let tt = null;
|
|
166
|
-
export function toast(msg
|
|
166
|
+
export function toast(msg, act) {
|
|
167
|
+
const t = $('#toast'); t.textContent = msg; t.classList.add('on'); clearTimeout(tt);
|
|
168
|
+
if (act) { // premium-agent-inbox: one action on the toast (the bell's "Review"), kept a little longer so it can be pressed
|
|
169
|
+
const b = document.createElement('button'); b.type = 'button'; b.className = 'cta'; b.textContent = act.label;
|
|
170
|
+
b.onclick = () => { t.classList.remove('on'); act.fn(); }; t.appendChild(b);
|
|
171
|
+
}
|
|
172
|
+
tt = setTimeout(() => t.classList.remove('on'), act ? 9000 : 4200);
|
|
173
|
+
}
|
|
167
174
|
|
|
168
175
|
/* ── the standard dialog: detail first, the conversation beside it (Detail tab first on a phone) ─────────── */
|
|
169
176
|
export const kv = (rows) => `<div class="kv2">${rows.filter((r) => r && r[1]).map(([k, v]) => `<span>${esc(k)}</span><span>${esc(v)}</span>`).join('')}</div>`;
|
|
@@ -499,19 +506,26 @@ const PV_WS = new URLSearchParams(location.search).get('ws');
|
|
|
499
506
|
const pvQ = (sep) => (PV_WS ? sep + 'ws=' + encodeURIComponent(PV_WS) : '');
|
|
500
507
|
async function pvGet(u) { try { const r = await fetch(u, { credentials: 'same-origin' }); return { status: r.status, j: await r.json() }; } catch { return { status: 0, j: null }; } }
|
|
501
508
|
const pvOv = { kind: null, back: null, at: 0, list: [], pal: null, need: null };
|
|
509
|
+
/* the bell's inbox (initiative premium-agent-inbox): r is the last GET /api/inbox answer, ids the item ids it held (null before the first read, so the
|
|
510
|
+
* first read never toasts), shown the new ids the open panel shows (closing the panel marks them seen), toastAt the last toast (at most one per 15 min). */
|
|
511
|
+
const IB = { r: null, ids: null, shown: [], toastAt: 0 };
|
|
502
512
|
function pvMount() {
|
|
503
513
|
const a = $('#tbMore'); if (!a || $('#pvBell')) return;
|
|
504
514
|
a.insertAdjacentHTML('beforebegin', `<button class="glass round pv-hp" id="pvBell" aria-haspopup="dialog" aria-label="Needs you" title="Needs you">${BELL}<span class="pv-bdg" id="pvBdg" hidden></span></button>`);
|
|
505
515
|
document.body.insertAdjacentHTML('beforeend', '<div class="pv-scrim" id="pvScrim"></div><div class="pv-ov" id="pvOv" role="dialog" aria-modal="true" hidden inert></div>');
|
|
506
516
|
$('#pvSearch').onclick = () => pvOpen('pal'); $('#pvBell').onclick = () => pvOpen('bell'); $('#pvScrim').onclick = pvClose;
|
|
507
|
-
pvNeeds();
|
|
517
|
+
pvNeeds(); ibRead();
|
|
518
|
+
setInterval(() => { if (!document.hidden) ibRead(); }, 60000);
|
|
519
|
+
document.addEventListener('visibilitychange', () => { if (!document.hidden) ibRead(); });
|
|
508
520
|
}
|
|
509
521
|
export function pvClose() {
|
|
510
522
|
if (!pvOv.kind) return;
|
|
523
|
+
if (pvOv.kind === 'bell' && IB.shown.length) { const ids = IB.shown.slice(0, 100); IB.shown = []; pmPost('/api/inbox/seen', { ids }).then(ibRead); } // seen is not done: they move to Still waiting
|
|
511
524
|
pvOv.kind = null; $('#pvOv').hidden = true; $('#pvOv').inert = true; $('#pvScrim').classList.remove('on');
|
|
512
525
|
$$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; }); $('#dock').inert = !document.body.classList.contains('docked'); document.documentElement.style.overflow = '';
|
|
513
526
|
if (pvOv.back) { try { pvOv.back.focus(); } catch { /* gone */ } }
|
|
514
527
|
}
|
|
528
|
+
export const pvOpenBell = () => pvOpen('bell');
|
|
515
529
|
function pvOpen(kind) {
|
|
516
530
|
if (pvOv.kind === kind) { pvClose(); return; }
|
|
517
531
|
if (pvOv.kind) pvClose();
|
|
@@ -520,7 +534,7 @@ function pvOpen(kind) {
|
|
|
520
534
|
$$('.rail,main.stage,#dock').forEach((x) => { x.inert = true; }); document.documentElement.style.overflow = 'hidden';
|
|
521
535
|
const o = $('#pvOv'); o.className = 'pv-ov ' + kind; o.setAttribute('aria-label', kind === 'pal' ? 'Search' : 'Needs you'); o.hidden = false; o.inert = false; $('#pvScrim').classList.add('on');
|
|
522
536
|
if (kind === 'pal') { o.innerHTML = '<div class="pv-pin">' + SRCH + '<input id="pvQ" type="text" placeholder="Search places, initiatives, documents and sessions" aria-label="Search" autocomplete="off" role="combobox" aria-expanded="true" aria-controls="pvList"><kbd>Esc</kbd></div><div id="pvList" role="listbox" aria-label="Results"></div><p class="pv-note">Ctrl K or / opens this from any page. Arrow keys move, Enter opens.</p>'; $('#pvQ').focus(); pvPal(); }
|
|
523
|
-
else { o.innerHTML = '<div class="pv-hd"><h2>Needs you</h2><small id="pvN"></small
|
|
537
|
+
else { o.innerHTML = '<div class="pv-hd"><h2>Needs you</h2><small id="pvN"></small><button type="button" class="ib-all" id="ibAll" hidden>Mark all seen</button></div><div id="pvList" class="pv-lst"></div>'; pvBellDraw(); pvNeeds(); ibRead(); }
|
|
524
538
|
}
|
|
525
539
|
const pvGo = (it) => { pvClose(); if (it.go) location.assign(it.go); };
|
|
526
540
|
const pvRow = (it, i, sel) => `<button type="button" class="pv-row" role="option" id="pvo${i}" data-i="${i}" aria-selected="${sel}"><span class="gl">${GL[it.gl]}</span><span><b>${esc(it.t)}</b>${it.s ? `<small>${esc(it.s)}</small>` : ''}</span></button>`;
|
|
@@ -551,13 +565,54 @@ function pvPalDraw() {
|
|
|
551
565
|
export function pvFeed(r) {
|
|
552
566
|
const M = r && r.ok && r.model, L = M && M.list;
|
|
553
567
|
pvOv.need = r && r.state === 'reading' ? { state: 'reading' } : L ? { state: 'ready', count: L.count, rows: L.rows || [] } : { state: 'error' };
|
|
554
|
-
const n = pvOv.need, b = $('#pvBdg'), btn = $('#pvBell'); if (!b) return;
|
|
555
|
-
const on = n.state === 'ready' && n.count > 0;
|
|
556
|
-
b.hidden = !on; b.textContent = on ? (n.count > 99 ? '99+' : String(n.count)) : '';
|
|
557
|
-
btn.setAttribute('aria-label', n.state === 'ready' ? 'Needs you: ' + n.count : 'Needs you');
|
|
558
568
|
if (pvOv.kind === 'bell') pvBellDraw();
|
|
559
569
|
}
|
|
560
|
-
|
|
570
|
+
/* ── the bell's inbox (initiative premium-agent-inbox): one item per agent result that waits on the PM, a press opens that exact proposal or goal ── */
|
|
571
|
+
const IB_KIND = { proposal: 'Proposal', draft: 'Draft', 'goal-waiting': 'Goal needs you', 'goal-done': 'Goal finished', 'goal-stopped': 'Goal stopped' };
|
|
572
|
+
const IB_ACT = { proposal: 'Review', draft: 'Read', 'goal-waiting': 'Answer', 'goal-done': 'See result', 'goal-stopped': 'See why' };
|
|
573
|
+
const IB_GL = { proposal: IC('M4 20h4L19 9l-4-4L4 16zM14 6l4 4'), draft: GL.doc, 'goal-waiting': IC('M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8'), 'goal-done': IC('M5 12l5 5L20 7'), 'goal-stopped': IC('M6 6h12v12H6z') };
|
|
574
|
+
const ibAgo = (ms) => { if (ms == null) return ''; const m = Math.round((Date.now() - ms) / 60000); return m < 1 ? 'just now' : m < 60 ? m + ' min ago' : m < 1440 ? Math.round(m / 60) + ' h ago' : Math.round(m / 1440) + (Math.round(m / 1440) === 1 ? ' day ago' : ' days ago'); };
|
|
575
|
+
const ibOld = (ms) => { if (ms == null) return ''; const d = Math.floor((Date.now() - ms) / 86400000); return d < 1 ? 'oldest is from today' : 'oldest is ' + d + (d === 1 ? ' day old' : ' days old'); };
|
|
576
|
+
/** The deep link of an inbox item or bundle: the Briefing opens it (premium.js openParam). */
|
|
577
|
+
export const ibHref = (open, pws) => '/premium.html?' + ['open=' + encodeURIComponent(open), pws ? 'pws=' + encodeURIComponent(pws) : '', PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&');
|
|
578
|
+
/** The last inbox answer, for the Briefing's count line: { count, newCount, oldest } or null. */
|
|
579
|
+
export const ibState = () => IB.r;
|
|
580
|
+
async function ibRead() {
|
|
581
|
+
const { j } = await pvGet('/api/inbox');
|
|
582
|
+
if (!j || !j.ok) return;
|
|
583
|
+
const before = IB.ids; IB.r = j; IB.ids = new Set(j.items.map((i) => i.id));
|
|
584
|
+
const fresh = before ? j.items.filter((i) => !before.has(i.id)) : [];
|
|
585
|
+
const b = $('#pvBdg'), btn = $('#pvBell');
|
|
586
|
+
if (b) { b.hidden = !j.newCount; b.textContent = j.newCount > 99 ? '99+' : String(j.newCount || ''); btn.setAttribute('aria-label', j.newCount ? 'Needs you: ' + j.newCount + ' new from the agent' : 'Needs you'); }
|
|
587
|
+
if (fresh.length && pvOv.kind !== 'bell' && Date.now() - IB.toastAt >= 15 * 60000) { // at most one toast every 15 minutes, bundled; never on a page's first read
|
|
588
|
+
IB.toastAt = Date.now();
|
|
589
|
+
if (fresh.length === 1) toast('New from the agent: ' + fresh[0].title, { label: IB_ACT[fresh[0].kind] || 'Open', fn: () => ibGo(fresh[0].open, fresh[0].pws, fresh[0].id) });
|
|
590
|
+
else toast(fresh.length + ' new agent results', { label: 'Open', fn: () => pvOpen('bell') });
|
|
591
|
+
}
|
|
592
|
+
if (pvOv.kind === 'bell') pvBellDraw();
|
|
593
|
+
document.dispatchEvent(new CustomEvent('pmos:inbox', { detail: j }));
|
|
594
|
+
}
|
|
595
|
+
/** Open an inbox item: on the Briefing in place (premium.js listens), elsewhere by the deep link. The item opened is seen. */
|
|
596
|
+
function ibGo(open, pws, id) {
|
|
597
|
+
if (id) { IB.shown = IB.shown.filter((x) => x !== id); pmPost('/api/inbox/seen', { ids: [id] }); }
|
|
598
|
+
pvClose();
|
|
599
|
+
if (!pvOnBriefing()) { location.assign(ibHref(open, pws)); return; }
|
|
600
|
+
document.dispatchEvent(new CustomEvent('pmos:open', { detail: { open, pws } }));
|
|
601
|
+
}
|
|
602
|
+
function ibHtml() {
|
|
603
|
+
const j = IB.r; if (!j) return '';
|
|
604
|
+
const item = (it) => `<div class="ib-it"><span class="gl">${IB_GL[it.kind] || GL.need}</span><span class="ib-b"><b><span class="ib-k">${esc(IB_KIND[it.kind] || 'Agent')}</span>${esc(it.title)}</b><small>${esc([it.product, it.target ? it.target.title : '', ibAgo(it.at)].filter(Boolean).join(' · '))}</small><span class="ib-acts"><button type="button" class="cta" data-ibo="${esc(it.open)}" data-ibw="${esc(it.pws || '')}" data-ibi="${esc(it.id)}">${esc(IB_ACT[it.kind] || 'Open')}</button>${/^row:/.test(it.open) ? '' : `<button type="button" class="cta alt" data-ibo="row:${esc(it.session)}" data-ibi="${esc(it.id)}">Session</button>`}</span></span></div>`;
|
|
605
|
+
const bun = (x) => `<button type="button" class="pv-row ib-bun" data-ibo="${esc(x.open)}" data-ibw="${esc(x.pws || '')}"><span class="gl">${GL.ini}</span><span><b>${esc(x.title)}</b><small>${esc([x.product, x.sub, ibOld(x.oldest)].filter(Boolean).join(' · '))}</small></span></button>`;
|
|
606
|
+
IB.shown = j.items.map((i) => i.id);
|
|
607
|
+
return (j.items.length ? `<div class="pv-grp">New from the agent · ${j.newCount}</div>` + j.items.map(item).join('') + (j.more ? `<p class="pv-note">${j.more} more new. Mark all seen to fold them by piece of work.</p>` : '') : '')
|
|
608
|
+
+ (j.bundles.length ? '<div class="pv-grp">Still waiting · one line per piece of work</div>' + j.bundles.map(bun).join('') : '');
|
|
609
|
+
}
|
|
610
|
+
document.addEventListener('click', (e) => {
|
|
611
|
+
const o = e.target.closest('#pvOv [data-ibo]');
|
|
612
|
+
if (o) { ibGo(o.dataset.ibo, o.dataset.ibw || '', o.dataset.ibi || ''); return; }
|
|
613
|
+
if (e.target.closest('#ibAll')) { IB.shown = []; pmPost('/api/inbox/seen', { all: true }).then((r) => { if (!r || !r.ok) toast('It was not marked seen: ' + ((r && r.error) || 'the server did not answer') + '.'); ibRead(); }); }
|
|
614
|
+
});
|
|
615
|
+
const pvOnBriefing = () => /^\/(?:premium(?:\.html)?|index\.html)?$/.test(location.pathname); // '/' and '/index.html' serve the Briefing too
|
|
561
616
|
async function pvNeeds() {
|
|
562
617
|
if (pvOnBriefing()) return;
|
|
563
618
|
const r = await pvGet('/api/briefing-premium' + pvQ('?'));
|
|
@@ -565,12 +620,15 @@ async function pvNeeds() {
|
|
|
565
620
|
}
|
|
566
621
|
function pvBellDraw() {
|
|
567
622
|
const n = pvOv.need, box = $('#pvList'); if (!box) return;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
623
|
+
const j = IB.r;
|
|
624
|
+
$('#pvN').textContent = j ? String(j.count) : '';
|
|
625
|
+
$('#ibAll').hidden = !(j && j.newCount);
|
|
626
|
+
// the PM's own work stays on the Briefing: one line here says how much, and a press goes there
|
|
627
|
+
const own = !n || n.state === 'reading' ? 'Your own work is still being read.' : n.state === 'error' ? 'Your own work could not be read.' : n.count ? 'Your own work: ' + n.count + (n.count === 1 ? ' item' : ' items') + ' on the Briefing.' : 'Your own work: nothing waits on the Briefing.';
|
|
628
|
+
pvOv.list = [{ gl: 'need', t: own, s: 'What you need to do', go: '/premium.html' + pvQ('?') }];
|
|
629
|
+
box.innerHTML = (!j ? '<p class="pv-note" role="status">Reading what the agent has for you.</p>' : j.count ? ibHtml() : '<p class="pv-note" role="status">No agent result waits on you.</p>')
|
|
630
|
+
+ '<div class="pv-grp">Yours</div>' + pvRow(pvOv.list[0], 0, false).replace('role="option"', 'role="listitem"').replace(' aria-selected="false"', '')
|
|
631
|
+
+ '<p class="pv-note">An item leaves when you decide it, wherever you decide it. Closing this marks the new ones seen.</p>';
|
|
574
632
|
}
|
|
575
633
|
document.addEventListener('click', (e) => { const b = e.target.closest('#pvList .pv-row'); if (b && pvOv.list[+b.dataset.i]) pvGo(pvOv.list[+b.dataset.i]); });
|
|
576
634
|
document.addEventListener('input', (e) => { if (e.target.id === 'pvQ') { pvOv.at = 0; pvPalDraw(); } });
|