create-pmos 0.389.0 → 0.391.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 +30 -35
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/briefing-premium-insights-test.js +6 -6
- package/workspace/changelog.json +29 -0
- package/workspace/guide/briefing-premium.md +19 -10
- package/workspace/guide/phone-companion.md +10 -1
- package/workspace/lib/insights-premium.js +10 -8
- package/workspace/lib/routes-insights-premium.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-report-read-test.js +101 -59
- package/workspace/premium-vw-slides-test.js +17 -19
- package/workspace/public/pm/audio-capture.js +7 -5
- package/workspace/public/pm/notes-capture-worklet.js +3 -2
- package/workspace/public/pm/notes-lock.js +66 -0
- package/workspace/public/pm/premium-insights.js +25 -6
- package/workspace/public/pm/premium-meeting.js +2 -1
- package/workspace/public/pm/premium-report-brief.js +132 -0
- package/workspace/public/pm/premium-report-read.js +276 -103
- package/workspace/public/pm/premium-report-tab.js +3 -1
- package/workspace/public/pm/premium-vw-doc.js +9 -1
- package/workspace/public/pm/premium-vw-report.css +1 -1
- package/workspace/public/pm/premium-vw-slides.js +14 -5
- package/workspace/public/pm/premium.css +70 -2
- package/workspace/public/pm/view-notes.js +92 -5
- package/workspace/test-lists/meeting-notes.json +8 -4
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/* pm/premium-vw-doc.js — a markdown document as a page in the premium viewer (initiative premium-viewer, S2; planning/prd/premium-viewer-prd.md R2).
|
|
2
2
|
* One document, one page: read it, edit it in place (or as Markdown), and see an agent's proposed change applied and highlighted, with one Keep and one
|
|
3
3
|
* Undo all. Built on the viewer frame (premium-viewer.js) and the existing /api/doc-sheet routes: log and at to read, edit to save, proposals, accept and
|
|
4
|
-
* reject for an agent's edit, ask to request one. Nothing here is stored anywhere else. The pure half is premium-vw-doc-model.js.
|
|
4
|
+
* reject for an agent's edit, ask to request one. Nothing here is stored anywhere else. The pure half is premium-vw-doc-model.js.
|
|
5
|
+
* ctx.host (an element) draws the page editor inside it instead of a viewer tab (the report dialog's Edit, PM 2026-10-22: one place to edit a
|
|
6
|
+
* report). It opens in Edit, offers only Edit and Markdown, and Cancel or a save calls ctx.onClose. No Health, Links, Copies, extras or Ask. */
|
|
5
7
|
import { pmPost } from './http.js';
|
|
6
8
|
import { vwOpen, vwStyle, vwConfirm } from './premium-viewer.js';
|
|
7
9
|
import { $, $$, esc, toast, AI, CHECK } from './premium-shell.js';
|
|
@@ -79,6 +81,7 @@ const tb = (c, label, icon) => `<button type="button" class="vwtb" data-c="${c}"
|
|
|
79
81
|
export function openDocPage(d, ctx = {}) {
|
|
80
82
|
if (!d || !d.path) return null;
|
|
81
83
|
vwStyle('doc');
|
|
84
|
+
if (ctx.host) return makePage(d, ctx);
|
|
82
85
|
const id = 'doc:' + d.path, prior = OPEN.get(id);
|
|
83
86
|
if (prior) return prior.show(ctx); // the same document opened again: show its tab and read it again; what is typed and not saved stays
|
|
84
87
|
return makePage(d, ctx);
|
|
@@ -104,6 +107,7 @@ function makePage(d, ctx) {
|
|
|
104
107
|
const at = revs.length ? await getJson('/api/doc-sheet/at?path=' + p + '&rev=' + revs[revs.length - 1].rev + wsq()) : null;
|
|
105
108
|
if (at && at.ok) P.text = at.text; else { P.text = null; P.err = (at && at.error) || (lg && lg.error) || 'The file could not be read.'; }
|
|
106
109
|
P.kept = null; draw();
|
|
110
|
+
if (ctx.host) return;
|
|
107
111
|
loadHealth(); loadCopies(); if (P.more === 'links') loadLib();
|
|
108
112
|
}
|
|
109
113
|
/* ── Health, Links and Copies: the sheet's own reads (POST /api/doc-health/check, GET /api/docs/library, GET /api/docs), drawn under the bar ── */
|
|
@@ -196,6 +200,7 @@ function makePage(d, ctx) {
|
|
|
196
200
|
function toolsHtml(p) {
|
|
197
201
|
const lock = p ? ' disabled title="Keep or undo the agent\'s edit first"' : '';
|
|
198
202
|
const seg = (m, label, icon) => `<button type="button" class="vwseg" data-vd="mode:${m}" aria-pressed="${P.mode === m}"${m !== 'read' ? lock : ''}>${IC[icon]}${label}</button>`;
|
|
203
|
+
if (ctx.host) return `<div class="vwdt" role="toolbar" aria-label="Document"><span class="vwsg">${seg('edit', 'Edit', 'pen')}${seg('md', 'Markdown', 'md')}</span></div>`;
|
|
199
204
|
return `<div class="vwdt" role="toolbar" aria-label="Document"><span class="vwsg">${seg('read', 'Page', 'doc')}${seg('edit', 'Edit', 'pen')}${seg('md', 'Markdown', 'md')}</span><span class="gap"></span>`
|
|
200
205
|
+ (P.mode === 'read' ? extrasHtml() : '')
|
|
201
206
|
+ (P.mode === 'read' && !p ? `<button type="button" class="vwbtn" data-vd="askt" aria-expanded="${P.askOpen}">${AI}Ask the agent</button>` : '') + '</div>'
|
|
@@ -354,6 +359,7 @@ function makePage(d, ctx) {
|
|
|
354
359
|
if (k === 'back') cur.delete(arg); else cur.add(arg);
|
|
355
360
|
P.kept = o.live.filter((n) => cur.has(n)); draw(); return;
|
|
356
361
|
}
|
|
362
|
+
if (k === 'cancel' && ctx.host) { if (ctx.onClose) ctx.onClose(); return; }
|
|
357
363
|
if (k === 'cancel') { P.mode = 'read'; P.work = null; P.base = null; P.why = ''; P.msg = ''; draw(); return; }
|
|
358
364
|
if (k === 'save') {
|
|
359
365
|
const why = ($('#vwWhy', el) || {}).value || '';
|
|
@@ -365,6 +371,7 @@ function makePage(d, ctx) {
|
|
|
365
371
|
if (!res || res.ok !== true) return fail((res && res.error) || 'The document could not be saved.');
|
|
366
372
|
toast(`Saved as v${v() + 1}. The reason is in the Edit log.`);
|
|
367
373
|
P.busy = false; P.mode = 'read'; P.base = null; P.work = null; P.why = '';
|
|
374
|
+
if (ctx.host) { if (ctx.onWrite) await ctx.onWrite(); if (ctx.onClose) ctx.onClose(); return; }
|
|
368
375
|
await load(); if (ctx.onWrite) ctx.onWrite(); return;
|
|
369
376
|
}
|
|
370
377
|
if (k === 'ask') {
|
|
@@ -468,6 +475,7 @@ function makePage(d, ctx) {
|
|
|
468
475
|
pane.addEventListener('mouseup', () => { if (P.mode === 'edit') setTimeout(syncBar, 0); });
|
|
469
476
|
}
|
|
470
477
|
|
|
478
|
+
if (ctx.host) { P.mode = 'edit'; el = ctx.host; el.innerHTML = '<p class="vwempty">Reading the file.</p>'; if (!WIRED.has(el)) { WIRED.add(el); wire(el); } load(); return el; }
|
|
471
479
|
const spec = { id, title: d.title || String(d.path).split('/').pop(), icon: 'doc', render(e) { el = e; draw(); }, wire(e) { if (WIRED.has(e)) return; WIRED.add(e); wire(e); } };
|
|
472
480
|
const api = { show(c2) { if (!el || !el.isConnected) { OPEN.delete(id); return makePage(d, c2 || ctx); } if (c2) ctx = c2; el = vwOpen(spec) || el; if (P.mode === 'read') load(); return el; } };
|
|
473
481
|
OPEN.set(id, api);
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
.rt-secs span{font-size:var(--fs-2);color:var(--ink-3)}
|
|
44
44
|
.rt-frame{width:100%;aspect-ratio:16/10;border:1px solid var(--hair);border-radius:8px;background:var(--card-solid,var(--card))}
|
|
45
45
|
.rt-cyc{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:6px}
|
|
46
|
-
.rt-cyc li{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-height:44px;padding:4px 4px 4px 10px;border:1px solid var(--hair);border-radius:8px}
|
|
46
|
+
.rt-cyc li{position:relative;display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-height:44px;padding:4px 4px 4px 10px;border:1px solid var(--hair);border-radius:8px}
|
|
47
47
|
.rt-slot{flex:1;min-width:0;font-size:var(--fs-3);color:var(--ink)}
|
|
48
48
|
.rt-tag{padding:2px 8px;border-radius:6px;font:500 var(--fs-1) var(--mono);text-transform:uppercase}
|
|
49
49
|
.rt-tag.draft{background:var(--well);color:var(--ink-2)}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* (pm/premium-deck.js has the format): the editor reads it through GET /api/doc and saves it through POST /api/doc-sheet/edit, which keeps a
|
|
4
4
|
* revision with the PM's why. Nothing else is stored.
|
|
5
5
|
*
|
|
6
|
-
* openSlides({ ws, path, title, readOnly, onSaved }) opens the file as a Slides tab beside the dialog's own detail
|
|
6
|
+
* openSlides({ ws, path, title, readOnly, onSaved, host, onClose }) opens the file as a Slides tab beside the dialog's own detail. With host
|
|
7
|
+
* (an element), the editor is drawn inside it instead (the report dialog's Edit, PM 2026-10-22: one place to edit a report), with a Cancel
|
|
8
|
+
* that calls onClose, and a save that calls onSaved then onClose. Present stays: it is the presenter view, with the notes.
|
|
7
9
|
*
|
|
8
10
|
* On the slide: click to select, drag to move (centre guides), the corner handles to resize, double-click to type. The rail reorders by drag
|
|
9
11
|
* (or Move up and Move down), adds a slide from a layout, duplicates and deletes. Undo and redo cover every change. Present opens the presenter
|
|
@@ -145,12 +147,13 @@ export function present(deck, ws, start, opt = {}) {
|
|
|
145
147
|
/* ── the editor ── */
|
|
146
148
|
const OPEN = new Map(); // path -> editor state, so the test hook can read it
|
|
147
149
|
|
|
148
|
-
export async function openSlides({ ws, path, title, readOnly, onSaved } = {}) {
|
|
150
|
+
export async function openSlides({ ws, path, title, readOnly, onSaved, host, onClose } = {}) {
|
|
149
151
|
if (!path) return null;
|
|
150
152
|
vwStyle('slides');
|
|
151
|
-
const S = { ws: ws || '', path, title: title || String(path).split('/').pop(), ro: !!readOnly, onSaved, text: null, deck: null, i: 0, sel: null, editing: null, drag: null, hist: [], fut: [], dirty: false, msg: '', busy: false, pop: null, root: null };
|
|
153
|
+
const S = { ws: ws || '', path, title: title || String(path).split('/').pop(), ro: !!readOnly, onSaved, onClose: host ? onClose : null, text: null, deck: null, i: 0, sel: null, editing: null, drag: null, hist: [], fut: [], dirty: false, msg: '', busy: false, pop: null, root: null };
|
|
152
154
|
OPEN.set(path, S);
|
|
153
|
-
const el = vwOpen({ id: 'slides:' + path, title: S.title + ' slides', icon: 'doc', html: '<p class="note">Reading the slides.</p>' });
|
|
155
|
+
const el = host || vwOpen({ id: 'slides:' + path, title: S.title + ' slides', icon: 'doc', html: '<p class="note">Reading the slides.</p>' });
|
|
156
|
+
if (host) host.innerHTML = '<p class="note">Reading the slides.</p>';
|
|
154
157
|
S.root = el;
|
|
155
158
|
try {
|
|
156
159
|
const r = await fetch('/api/doc?' + new URLSearchParams({ ...(S.ws ? { ws: S.ws } : {}), path }).toString(), { credentials: 'same-origin' });
|
|
@@ -175,7 +178,7 @@ function build(S) {
|
|
|
175
178
|
el.innerHTML = `<div class="sl${ro ? ' ro' : ''}" data-sl>`
|
|
176
179
|
+ `<div class="sl-tb" role="toolbar" aria-label="Slides">`
|
|
177
180
|
+ (ro ? '' : `${tb('undo', 'Undo', 'undo', ' disabled')}${tb('redo', 'Redo', 'redo', ' disabled')}<span class="sl-sep"></span>${tbl('text', 'Text', 'txt')}${tbl('img', 'Image', 'img')}${tbl('chart', 'Chart', 'chart')}${tbl('table', 'Table', 'tbl')}${tbl('shape', 'Shape', 'shape')}<span class="sl-sep"></span>${tbl('layout', 'Layout', 'lay', ' aria-haspopup="menu"')}${tbl('theme', 'Theme', 'pal', ' aria-haspopup="menu"')}`)
|
|
178
|
-
+ `<span class="sl-gap"></span>${tbl('present', 'Present', 'play')}${ro ? '' : `<button type="button" class="sl-b sl-pri" data-c="save">${I('save')}<span>Save</span></button>`}</div>`
|
|
181
|
+
+ `<span class="sl-gap"></span>${tbl('present', 'Present', 'play')}${S.onClose ? `<button type="button" class="sl-b sl-bl" data-c="close"><span>Cancel</span></button>` : ''}${ro ? '' : `<button type="button" class="sl-b sl-pri" data-c="save">${I('save')}<span>Save</span></button>`}</div>`
|
|
179
182
|
+ (ro ? '' : '<div class="sl-ctx" role="toolbar" aria-label="Change the selected item"></div>')
|
|
180
183
|
+ `<p class="sl-msg" role="status"></p>`
|
|
181
184
|
+ `<div class="sl-body"><nav class="sl-rail" aria-label="Slides"></nav><div class="sl-main"><div class="sl-stage" tabindex="0" aria-label="Slide"></div>`
|
|
@@ -338,6 +341,11 @@ function onTop(S, c, b) {
|
|
|
338
341
|
S.pres = present(S.deck, S.ws, S.i, { ro: S.ro, onNotes: (i, v, first) => { if (first) snap(S); S.deck.slides[i].notes = v; S.dirty = true; drawBar(S); }, onEnd: (i) => { S.pres = null; go(S, i); } });
|
|
339
342
|
return;
|
|
340
343
|
}
|
|
344
|
+
if (c === 'close') {
|
|
345
|
+
commitEdit(S);
|
|
346
|
+
if (S.dirty && !S.closing) { S.closing = true; b.innerHTML = '<span>Sure? Leave without saving</span>'; return; }
|
|
347
|
+
OPEN.delete(S.path); if (S.onClose) S.onClose(); return;
|
|
348
|
+
}
|
|
341
349
|
if (S.ro) return;
|
|
342
350
|
if (c === 'undo') return undo(S);
|
|
343
351
|
if (c === 'redo') return redo(S);
|
|
@@ -451,6 +459,7 @@ function askSave(S, b) {
|
|
|
451
459
|
const r = await save(S, why);
|
|
452
460
|
if (!r.ok) { err.hidden = false; err.textContent = r.error; return; }
|
|
453
461
|
closePop(S);
|
|
462
|
+
if (S.onClose) { OPEN.delete(S.path); S.onClose(); }
|
|
454
463
|
};
|
|
455
464
|
}
|
|
456
465
|
async function save(S, why) {
|
|
@@ -1912,8 +1912,76 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
|
|
|
1912
1912
|
@media (max-width:700px){#dsOlItems{display:flex;flex-wrap:wrap;gap:6px}.dso button{display:inline-flex;width:auto}.dso .l2,.dso .l3{padding-left:10px}.dso{max-height:none}}
|
|
1913
1913
|
.dsbody .dsat{display:flex;align-items:center;gap:6px;margin:-2px 0 8px;font-size:var(--fs-2);color:var(--ink-3)}
|
|
1914
1914
|
.dsbody .dsat i{width:18px;height:18px;border-radius:50%;background:var(--well);display:grid;place-items:center;font:600 var(--fs-1) var(--mono);font-style:normal;color:var(--ink-2)}
|
|
1915
|
-
|
|
1916
|
-
.rdbar
|
|
1915
|
+
/* one bar for a report, one row, icons only (PM 2026-10-22): Slides | Page, Brief, state, schedule, then Edit, Present, Share, Issue and ⋯ */
|
|
1916
|
+
.rdbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:0 0 12px}
|
|
1917
|
+
.rdbar .rdsp{flex:1 1 0;min-width:0;margin:0}
|
|
1918
|
+
.rdib{display:grid;place-items:center;flex:none;width:44px;height:44px;border-radius:10px;background:var(--well);color:var(--ink)}
|
|
1919
|
+
.rdib svg{width:18px;height:18px}
|
|
1920
|
+
.rdib:disabled{opacity:.5;cursor:not-allowed}
|
|
1921
|
+
.rdib.pri{background:var(--ink);color:var(--card-solid)}
|
|
1922
|
+
.rdib[data-rr="mo"] svg{fill:currentColor;stroke:none}
|
|
1923
|
+
@media (hover:hover){.rdib:hover{background:color-mix(in oklab,var(--ink) 9%,transparent)}.rdib.pri:hover{background:var(--ink);opacity:.9}}
|
|
1924
|
+
.rdvw{display:inline-flex;gap:2px;padding:2px;border-radius:12px;background:var(--well)}
|
|
1925
|
+
.rdvw .rdib{background:none;color:var(--ink-3)}
|
|
1926
|
+
.rdvw .rdib[aria-pressed="true"]{background:var(--card-solid);color:var(--ink);box-shadow:0 0 0 1px var(--hair)}
|
|
1927
|
+
.rdst{padding:4px 10px;font-size:var(--fs-2);gap:6px;font-weight:600}
|
|
1928
|
+
.rdbar .chp.rdsch{min-height:44px;padding:0 12px;border:0;cursor:pointer;font:600 var(--fs-2) var(--mono);gap:6px;background:var(--well);color:var(--ink-2)}
|
|
1929
|
+
.rdsch svg{width:15px;height:15px}
|
|
1930
|
+
.rdsch b{font-weight:600;color:var(--ink)}
|
|
1931
|
+
.rdbar .dsmn{top:50px}
|
|
1932
|
+
.rdbar .dsvw:last-child .dsmn{left:auto;right:0}
|
|
1933
|
+
.dsmn.rdmo,.dsmn.rdsm,.dsmn.rdcm{min-width:min(300px,86vw);max-height:min(70vh,560px);overflow:auto}
|
|
1934
|
+
.dsmn.rdmo button,.dsmn.rdmo a,.dsmn.rdsm button,.dsmn.rdsm a,.dsmn.rdcm button{height:auto;min-height:44px;align-items:flex-start;padding:9px 12px}
|
|
1935
|
+
.dsmn.rdmo hr,.dsmn.rdsm hr{border:0;border-top:1px solid var(--hair);margin:4px 6px;width:auto}
|
|
1936
|
+
.dsmn .rdbad,.dsmn .rdbad svg{color:var(--bad)}
|
|
1937
|
+
.rdfile{margin:6px 12px 2px;font:500 var(--fs-2) var(--mono);color:var(--ink-3);overflow-wrap:anywhere}
|
|
1938
|
+
.rdsd{display:flex;gap:4px;flex-wrap:wrap;padding:6px 8px}
|
|
1939
|
+
.dsmn .rdsd button{min-height:44px;height:auto;padding:6px 12px;border-radius:999px;background:var(--well)}
|
|
1940
|
+
.dsmn .rdsd button[aria-pressed="true"]{background:var(--ink);color:var(--card-solid)}
|
|
1941
|
+
.dsmn.rdsm a span{flex:1}
|
|
1942
|
+
.rdedn{margin:0;align-self:center}
|
|
1943
|
+
.rded{min-height:420px}
|
|
1944
|
+
.rdlook{margin:0 0 12px}
|
|
1945
|
+
/* the report's cycles, under its name */
|
|
1946
|
+
#dSub .rdcw{display:inline-flex;z-index:60}
|
|
1947
|
+
#dSub .chp.rdcyc{min-height:32px;padding:2px 10px;border:0;border-radius:999px;background:var(--well);font:600 var(--fs-2) var(--mono);color:var(--ink-2);gap:4px;cursor:pointer}
|
|
1948
|
+
#dSub .rdcyc svg{width:15px;height:15px}
|
|
1949
|
+
.dsmn.rdcm{top:38px}
|
|
1950
|
+
.dsmn.rdcm .label{margin:8px 12px 2px}
|
|
1951
|
+
.dsmn.rdcm button{flex-wrap:wrap}
|
|
1952
|
+
.dsmn.rdcm small{display:block;width:100%;font:400 var(--fs-2) var(--mono);color:var(--ink-3)}
|
|
1953
|
+
.dsmn.rdcm button svg{margin-left:auto}
|
|
1954
|
+
/* the samples above the chat box, and its clip */
|
|
1955
|
+
.rdsmp{display:flex;flex-wrap:wrap;align-items:center;gap:2px 0;margin-top:10px}
|
|
1956
|
+
.rdsmp .label{margin:0 8px 0 0}
|
|
1957
|
+
#rdF .rdclip{background:var(--well);color:var(--ink-2)}
|
|
1958
|
+
@media (pointer:coarse){#dSub .chp.rdcyc{min-height:44px}}
|
|
1959
|
+
/* the Brief, in its own viewer tab: how the report is made, not part of it */
|
|
1960
|
+
.rbrief{padding:4px 4px 24px;display:grid;gap:14px}
|
|
1961
|
+
.rbhd{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
1962
|
+
.rbhd>span:first-child{flex:1;min-width:0;display:grid;gap:2px}
|
|
1963
|
+
.rbhd small{font-size:var(--fs-2);color:var(--ink-3)}
|
|
1964
|
+
.rbto{padding:4px 10px;border-radius:999px;background:var(--warn-bg,var(--well));color:var(--warn,var(--ink));font:600 var(--fs-2) var(--mono)}
|
|
1965
|
+
.rbhd .dmcta{min-height:44px}
|
|
1966
|
+
.rbtoc{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px}
|
|
1967
|
+
.rbtoc button{flex:none;min-height:44px;padding:0 12px;border-radius:999px;background:var(--well);font:600 var(--fs-2) var(--mono);color:var(--ink-2)}
|
|
1968
|
+
.rbs{padding:14px 16px;border-radius:14px;background:var(--well);scroll-margin-top:12px}
|
|
1969
|
+
.rbs h4{display:flex;align-items:center;gap:8px;margin:0 0 8px;font-size:var(--fs-4)}
|
|
1970
|
+
.rbs p,.rbs li{font-size:var(--fs-3);line-height:1.5;color:var(--ink-2)}
|
|
1971
|
+
.rbs ul,.rbs ol{margin:0;padding-left:20px;display:grid;gap:4px}
|
|
1972
|
+
.rbs p{margin:0 0 6px}
|
|
1973
|
+
.rbfix{margin-left:auto;min-height:44px;padding:0 12px;border-radius:10px;background:var(--card-solid);box-shadow:inset 0 0 0 1px var(--hair);font:600 var(--fs-2) var(--mono);color:var(--ink-2)}
|
|
1974
|
+
.rbs li .rbfix{margin-left:6px;vertical-align:middle}
|
|
1975
|
+
.rbkv{display:grid;grid-template-columns:max-content 1fr;gap:6px 14px;margin:0;font-size:var(--fs-3)}
|
|
1976
|
+
.rbkv dt{color:var(--ink-3)}
|
|
1977
|
+
.rbkv dd{margin:0;color:var(--ink)}
|
|
1978
|
+
.rbcalc{padding:10px 12px;border-radius:10px;background:var(--card-solid);margin:0 0 8px}
|
|
1979
|
+
.rbcalc p{margin:2px 0 0}
|
|
1980
|
+
.rbsub{color:var(--ink-3)}
|
|
1981
|
+
.rbrief .tag{display:inline-block;padding:1px 8px;border-radius:999px;font:600 var(--fs-1) var(--mono);background:var(--card-solid);color:var(--ink-3);box-shadow:inset 0 0 0 1px var(--hair)}
|
|
1982
|
+
.rbrief .tag.ok{color:var(--ok)}
|
|
1983
|
+
.rbrief .tag.no,.rbrief .tag.as{color:var(--warn,var(--bad))}
|
|
1984
|
+
@media (max-width:520px){.rbkv{grid-template-columns:1fr}.rbkv dd{margin-bottom:6px}.rdbar{gap:4px}}
|
|
1917
1985
|
.dsrel{display:grid;gap:6px}
|
|
1918
1986
|
.dsrr{display:flex;align-items:center;gap:10px;justify-content:space-between;padding:6px 10px;border-radius:10px;background:var(--well)}
|
|
1919
1987
|
.dsrr button,.dsrr>span:first-child{display:grid;gap:2px;text-align:left;min-height:44px;align-content:center;color:var(--ink)}
|
|
@@ -51,6 +51,7 @@ import { startScreen } from './notes-screen-capture.js';
|
|
|
51
51
|
import { screenStrip } from './notes-screen-view.js';
|
|
52
52
|
import { planListen, surfaceOf } from './listen-sources.js';
|
|
53
53
|
import { agendaHeard, peopleOf as contextPeople } from './notes-context.js';
|
|
54
|
+
import { makeGapClock, makeWakeLock } from './notes-lock.js';
|
|
54
55
|
|
|
55
56
|
const SAVE_MS = 700; // a pause this long in typing saves the note
|
|
56
57
|
const POLL_MS = 1500; // while listening, and until the last line is labelled, the note is read this often
|
|
@@ -63,6 +64,7 @@ const SILENCE_PEAK = 1e-4; // the loudest sample of a source below this count
|
|
|
63
64
|
const HEARD_PEAK = 0.005; // the microphone has been heard once it reaches this
|
|
64
65
|
const SEND_TRIES = 3; // a chunk that the server did not take is sent again this many times in all …
|
|
65
66
|
const SEND_BACKOFF_MS = 400; // … after 400 ms, then 1200 ms
|
|
67
|
+
const REVIVE_MS = 5000; // a microphone that ends this soon after the page is shown again was taken away by the lock (notes-lock.js)
|
|
66
68
|
const SECTIONS = [['decision', 'Decisions'], ['action', 'Next steps'], ['question', 'Open questions']];
|
|
67
69
|
|
|
68
70
|
/* ── module state: survives the redraw every setState causes ─────────────────────────────── */
|
|
@@ -75,6 +77,7 @@ let banner = null; // { tone, text }
|
|
|
75
77
|
let speech = null; // the browser recogniser: { mode: 'dictate'|'record', id, state, rec, interim, lang, msg, last }
|
|
76
78
|
let audio = null; // local Whisper capture: { id, state, sources, ctx, streams, started, clock, msg }
|
|
77
79
|
let engine = null; // { ws, whisper, jev, at }
|
|
80
|
+
const wake = makeWakeLock(); // the screen stays on while a meeting is recorded, so the phone does not lock by itself (notes-lock.js)
|
|
78
81
|
/** Capture the shared screen (notes-screen-capture): on unless the PM switched it off on this machine. */
|
|
79
82
|
const screenOn = () => !(engine && engine.whisper && engine.whisper.screen === false);
|
|
80
83
|
let showList = false;
|
|
@@ -697,7 +700,7 @@ function checkSilence(ctx, a) {
|
|
|
697
700
|
ctx.setState({});
|
|
698
701
|
}
|
|
699
702
|
async function startAudio(ctx, n, want, plan = null) {
|
|
700
|
-
const a = { id: n.id, state: 'starting', sources: [], streams: [], ctx: null, started: Date.now(), clock: null, msg: null, queue: {}, buf: {}, rs: {}, rs24: {}, buf24: {}, peak: {}, began: Date.now(), lost: 0, ended: 0, cap: null, seq: {}, off: {} };
|
|
703
|
+
const a = { id: n.id, state: 'starting', sources: [], streams: [], ctx: null, started: Date.now(), clock: null, msg: null, queue: {}, buf: {}, rs: {}, rs24: {}, buf24: {}, peak: {}, began: Date.now(), lost: 0, ended: 0, cap: null, seq: {}, off: {}, gaps: {}, nodes: {}, hiddenAt: 0, shownAt: 0, lastGapAt: 0, missed: 0 };
|
|
701
704
|
const opened = [];
|
|
702
705
|
// the meeting first, straight from the press: the browser lets a page share a screen only right after a click
|
|
703
706
|
for (const kind of want.slice().sort((x, y) => (x === 'meeting' ? -1 : y === 'meeting' ? 1 : 0))) {
|
|
@@ -725,9 +728,12 @@ async function startAudio(ctx, n, want, plan = null) {
|
|
|
725
728
|
const rs = a.rs[kind] = makeResampler(ac.sampleRate);
|
|
726
729
|
// a device slower than 24 kHz has nothing above 12 kHz to keep, so it sends 16 kHz audio only and the replay stays 16 kHz
|
|
727
730
|
const rs24 = ac.sampleRate >= HI_RATE ? (a.rs24[kind] = makeResampler(ac.sampleRate, HI_RATE)) : null;
|
|
728
|
-
a.buf24[kind] = []; a.peak[kind] = 0;
|
|
729
|
-
await openCapture(ac, src, sink, (block) => {
|
|
731
|
+
a.buf24[kind] = []; a.peak[kind] = 0; a.gaps[kind] = makeGapClock();
|
|
732
|
+
const cap = await openCapture(ac, src, sink, (block, stamp) => {
|
|
730
733
|
if (audio !== a) return;
|
|
734
|
+
// the phone locked, or the page was in the background, and this source sent no sound for a while: jump over that time
|
|
735
|
+
const missed = a.gaps[kind].block(block.length, ac.sampleRate, { nowMs: Date.now(), ctxSec: ac.currentTime, stamp });
|
|
736
|
+
if (missed) skipGap(ctx, a, kind, missed);
|
|
731
737
|
let pk = a.peak[kind]; for (let i = 0; i < block.length; i++) { const v = block[i] < 0 ? -block[i] : block[i]; if (v > pk) pk = v; }
|
|
732
738
|
a.peak[kind] = pk;
|
|
733
739
|
const s = rs.push(block);
|
|
@@ -735,7 +741,8 @@ async function startAudio(ctx, n, want, plan = null) {
|
|
|
735
741
|
if (rs24) { const h = rs24.push(block); const b24 = a.buf24[kind]; for (let i = 0; i < h.length; i++) b24.push(h[i]); }
|
|
736
742
|
if (b.length >= CHUNK_SAMPLES) sendChunk(ctx, a, kind, false);
|
|
737
743
|
});
|
|
738
|
-
|
|
744
|
+
a.nodes[kind] = cap.node;
|
|
745
|
+
watchEnded(ctx, a, stream, kind);
|
|
739
746
|
}
|
|
740
747
|
// screenshots of the shared screen, on the meeting clock, while this capture lasts (notes-screen-capture)
|
|
741
748
|
const shared = opened.find(([kind, s]) => kind === 'meeting' && s.screenTrack);
|
|
@@ -747,10 +754,80 @@ async function startAudio(ctx, n, want, plan = null) {
|
|
|
747
754
|
} else if (shared) shared[1].screenTrack.stop();
|
|
748
755
|
a.state = 'on';
|
|
749
756
|
a.clock = setInterval(() => { tickClocks(a.started); checkSilence(ctx, a); }, 1000);
|
|
757
|
+
a.onVis = () => onVisibility(ctx, a);
|
|
758
|
+
if (typeof document !== 'undefined') document.addEventListener('visibilitychange', a.onVis);
|
|
759
|
+
wake.hold();
|
|
750
760
|
ctx.setState({});
|
|
751
761
|
poll(ctx, n.id);
|
|
752
762
|
import('./notes-links.js').then((m) => m.refreshNotes()).catch(() => {});
|
|
753
763
|
}
|
|
764
|
+
/* ── the phone locks (notes-lock.js) ─────────────────────────────────────────────────────────────────────── */
|
|
765
|
+
/** The page was locked or in the background while this capture ran: the microphone may be gone and the context interrupted. */
|
|
766
|
+
const interrupted = (a) => (typeof document !== 'undefined' && document.visibilityState === 'hidden')
|
|
767
|
+
|| (a.hiddenAt > 0 && (!(a.shownAt >= a.hiddenAt) || Date.now() - a.shownAt < REVIVE_MS));
|
|
768
|
+
function watchEnded(ctx, a, stream, kind) {
|
|
769
|
+
for (const t of stream.getTracks()) t.addEventListener('ended', () => {
|
|
770
|
+
if (audio !== a) return;
|
|
771
|
+
// a microphone the phone took away while it was locked is opened again when the page is shown; any other end is the end
|
|
772
|
+
if (kind === 'mic' && interrupted(a)) { if (document.visibilityState === 'visible') revive(ctx, a); return; }
|
|
773
|
+
a.ended++; if (a.ended >= a.streams.length) stopAudio(ctx);
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function onVisibility(ctx, a) {
|
|
777
|
+
if (audio !== a) return;
|
|
778
|
+
if (document.visibilityState === 'hidden') {
|
|
779
|
+
// what was heard up to now is sent at once: a page that is frozen next sends nothing more
|
|
780
|
+
a.hiddenAt = Date.now();
|
|
781
|
+
for (const k of a.sources) if ((a.buf[k] || []).length) sendChunk(ctx, a, k, false);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
a.shownAt = Date.now();
|
|
785
|
+
wake.again();
|
|
786
|
+
revive(ctx, a);
|
|
787
|
+
}
|
|
788
|
+
const micLive = (s) => s.getAudioTracks().some((t) => t.readyState === 'live');
|
|
789
|
+
/** Shown again: resume the context and open an ended microphone again. When the browser wants a tap first, the next tap does it. */
|
|
790
|
+
async function revive(ctx, a) {
|
|
791
|
+
if (audio !== a || a.reviving) return;
|
|
792
|
+
a.reviving = true;
|
|
793
|
+
try {
|
|
794
|
+
// called straight from the tap, so resume() is still inside the gesture that iOS asks for
|
|
795
|
+
if (a.ctx && a.ctx.state !== 'running' && a.ctx.state !== 'closed') { try { await a.ctx.resume(); } catch { /* it wants a tap */ } }
|
|
796
|
+
for (let i = 0; i < a.sources.length; i++) {
|
|
797
|
+
if (a.sources[i] !== 'mic' || micLive(a.streams[i]) || !a.nodes.mic) continue;
|
|
798
|
+
let fresh = null;
|
|
799
|
+
try { fresh = await openSource('mic'); } catch { continue; }
|
|
800
|
+
if (audio !== a) { for (const t of fresh.getTracks()) t.stop(); return; }
|
|
801
|
+
a.ctx.createMediaStreamSource(fresh).connect(a.nodes.mic);
|
|
802
|
+
a.streams[i] = fresh;
|
|
803
|
+
watchEnded(ctx, a, fresh, 'mic');
|
|
804
|
+
}
|
|
805
|
+
if (audio !== a) return;
|
|
806
|
+
const stuck = (a.ctx && a.ctx.state !== 'running') || a.sources.some((k, i) => k === 'mic' && !micLive(a.streams[i]));
|
|
807
|
+
if (stuck) {
|
|
808
|
+
banner = { tone: 'bad', audioMsg: true, tap: true, text: 'Recording is paused because the phone locked. Tap anywhere on the page to go on recording.' };
|
|
809
|
+
if (!a.tapArmed) {
|
|
810
|
+
a.tapArmed = true;
|
|
811
|
+
toast({ text: banner.text, tone: 'destructive', timeout: 15000 });
|
|
812
|
+
document.addEventListener('pointerdown', () => { a.tapArmed = false; revive(ctx, a); }, { once: true, capture: true });
|
|
813
|
+
}
|
|
814
|
+
ctx.setState({});
|
|
815
|
+
} else if (banner && banner.tap) { banner = null; ctx.setState({}); }
|
|
816
|
+
} finally { a.reviving = false; }
|
|
817
|
+
}
|
|
818
|
+
const spoken = (ms) => (ms >= 90000 ? Math.round(ms / 60000) + ' minutes' : Math.max(1, Math.round(ms / 1000)) + ' seconds');
|
|
819
|
+
/** `ms` of this source never arrived: what came before is sent, and the offset jumps, so the audio after it keeps its place on the
|
|
820
|
+
* meeting clock and the replay has silence there. The PM is told once for each gap, however many sources it touched. */
|
|
821
|
+
function skipGap(ctx, a, kind, ms) {
|
|
822
|
+
if ((a.buf[kind] || []).length) sendChunk(ctx, a, kind, false);
|
|
823
|
+
a.off[kind] = (a.off[kind] || 0) + Math.round(ms * RATE / 1000);
|
|
824
|
+
if (Date.now() - a.lastGapAt < REVIVE_MS) return;
|
|
825
|
+
a.lastGapAt = Date.now(); a.missed += ms;
|
|
826
|
+
banner = { tone: 'bad', audioMsg: true, text: 'About ' + spoken(ms) + ' of the meeting were not recorded, because the phone was locked or PMOS was in the background. '
|
|
827
|
+
+ 'Recording goes on. A web page cannot record while the phone is locked, so keep this screen on during a meeting.' };
|
|
828
|
+
toast({ text: banner.text, tone: 'destructive', timeout: 12000 });
|
|
829
|
+
ctx.setState({});
|
|
830
|
+
}
|
|
754
831
|
function sendChunk(ctx, a, kind, final) {
|
|
755
832
|
const b = a.buf[kind] || []; a.buf[kind] = [];
|
|
756
833
|
const pcm = b64(Int16Array.from(b));
|
|
@@ -783,8 +860,10 @@ async function stopAudio(ctx, { discard = false, resumable = true } = {}) {
|
|
|
783
860
|
const a = audio;
|
|
784
861
|
if (!a) return;
|
|
785
862
|
audio = null;
|
|
786
|
-
if (banner && banner.silent) banner = null;
|
|
863
|
+
if (banner && (banner.silent || banner.tap)) banner = null;
|
|
787
864
|
clearInterval(a.clock);
|
|
865
|
+
if (a.onVis && typeof document !== 'undefined') document.removeEventListener('visibilitychange', a.onVis);
|
|
866
|
+
wake.release();
|
|
788
867
|
if (a.screen) a.screen.stop();
|
|
789
868
|
for (const s of a.streams) for (const t of s.getTracks()) { try { t.stop(); } catch { /* stopped */ } }
|
|
790
869
|
try { if (a.ctx) await a.ctx.close(); } catch { /* closed */ }
|
|
@@ -818,6 +897,8 @@ function stopSpeech() {
|
|
|
818
897
|
if (!speech) return;
|
|
819
898
|
const s = speech; speech = null;
|
|
820
899
|
clearInterval(s.clock);
|
|
900
|
+
if (s.mode === 'record') wake.release();
|
|
901
|
+
if (s.onVis && typeof document !== 'undefined') document.removeEventListener('visibilitychange', s.onVis);
|
|
821
902
|
if (s.rec) { s.rec.onend = null; try { s.rec.stop(); } catch { /* already stopped */ } }
|
|
822
903
|
}
|
|
823
904
|
async function onFinal(ctx, s, text) {
|
|
@@ -891,6 +972,12 @@ async function startSpeech(ctx, n, mode, install = false) {
|
|
|
891
972
|
rec.onend = () => { if (speech === s && s.state === 'on') { try { rec.start(); } catch { /* it is starting */ } } };
|
|
892
973
|
s.rec = rec;
|
|
893
974
|
try { rec.start(); s.state = 'on'; } catch (e) { s.state = 'error'; s.msg = 'Listening did not start: ' + ((e && e.message) || e); }
|
|
975
|
+
if (mode === 'record' && s.state === 'on') {
|
|
976
|
+
wake.hold();
|
|
977
|
+
// a recognition the lock ended does not start again while the page is hidden: start it when the page is shown
|
|
978
|
+
s.onVis = () => { if (speech === s && s.state === 'on' && document.visibilityState === 'visible') { wake.again(); try { rec.start(); } catch { /* it is running */ } } };
|
|
979
|
+
document.addEventListener('visibilitychange', s.onVis);
|
|
980
|
+
}
|
|
894
981
|
if (mode === 'record') { s.clock = setInterval(() => tickClocks(s.started), 1000); poll(ctx, n.id); import('./notes-links.js').then((m) => m.refreshNotes()).catch(() => {}); }
|
|
895
982
|
ctx.setState({});
|
|
896
983
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_comment": "meeting-notes Runs 1 to 10: the Notes engine and routes (notes.test.js), local Whisper, line labels and repository checks (notes-listen.test.js), the final pass after Stop and the Wispr Flow fetch (notes-final.test.js), Qwen3-ASR kept loaded (notes-qwen.test.js), and the Notes view in a browser (pm-notes-test.js), the echo canceller for the replay (notes-echo.test.js, notes-audio-quality Run 2) and the optional cleaned copy of the replay (notes-polish.test.js, Run 3) and the 24 kHz replay (notes-hires.test.js, Run 4), plus the note pop-up patched in place while it listens (pm-note-dock-test.js). notes-recording-reliability adds the duplication fixture (notes-duplication.test.js): duplicated audio and transcript across retry, restart, two tabs and a late chunk, and the live guards. notes-screen-capture adds the screenshots a note keeps of the shared screen (notes-screen.test.js): who may leave a shot, which pictures, listing and serving, deleting, and the optional on-screen text. notes-live-settle adds the replay of a kept meeting and its report (notes-replay.test.js): lines said twice, the live lines' lag, and the settle tier's busy share. notes-screen-capture also adds the screenshots of the shared screen in a browser (pm-notes-screen-test.js).",
|
|
2
|
+
"_comment": "meeting-notes Runs 1 to 10: the Notes engine and routes (notes.test.js), local Whisper, line labels and repository checks (notes-listen.test.js), the final pass after Stop and the Wispr Flow fetch (notes-final.test.js), Qwen3-ASR kept loaded (notes-qwen.test.js), and the Notes view in a browser (pm-notes-test.js), the echo canceller for the replay (notes-echo.test.js, notes-audio-quality Run 2) and the optional cleaned copy of the replay (notes-polish.test.js, Run 3) and the 24 kHz replay (notes-hires.test.js, Run 4), plus the note pop-up patched in place while it listens (pm-note-dock-test.js). notes-recording-reliability adds the duplication fixture (notes-duplication.test.js): duplicated audio and transcript across retry, restart, two tabs and a late chunk, and the live guards. notes-screen-capture adds the screenshots a note keeps of the shared screen (notes-screen.test.js): who may leave a shot, which pictures, listing and serving, deleting, and the optional on-screen text. notes-live-settle adds the replay of a kept meeting and its report (notes-replay.test.js): lines said twice, the live lines' lag, and the settle tier's busy share. notes-screen-capture also adds the screenshots of the shared screen in a browser (pm-notes-screen-test.js). notes-lock-recovery adds the phone lock: the gap clock and the wake lock (notes-lock.test.js), and a lock and unlock in a browser (pm-notes-lock-test.js).",
|
|
3
3
|
"modules": [
|
|
4
4
|
"notes.test.js",
|
|
5
5
|
"notes-listen.test.js",
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
"notes-hires.test.js",
|
|
11
11
|
"notes-duplication.test.js",
|
|
12
12
|
"notes-screen.test.js",
|
|
13
|
-
"notes-replay.test.js"
|
|
13
|
+
"notes-replay.test.js",
|
|
14
|
+
"notes-lock.test.js"
|
|
14
15
|
],
|
|
15
16
|
"panels": [
|
|
16
17
|
"pm-notes-test.js",
|
|
17
18
|
"pm-note-dock-test.js",
|
|
18
|
-
"pm-notes-screen-test.js"
|
|
19
|
+
"pm-notes-screen-test.js",
|
|
20
|
+
"pm-notes-lock-test.js"
|
|
19
21
|
],
|
|
20
22
|
"seconds": {
|
|
21
23
|
"notes.test.js": 12,
|
|
@@ -30,6 +32,8 @@
|
|
|
30
32
|
"notes-duplication.test.js": 25,
|
|
31
33
|
"pm-notes-screen-test.js": 60,
|
|
32
34
|
"notes-screen.test.js": 6,
|
|
33
|
-
"notes-replay.test.js": 20
|
|
35
|
+
"notes-replay.test.js": 20,
|
|
36
|
+
"notes-lock.test.js": 1,
|
|
37
|
+
"pm-notes-lock-test.js": 30
|
|
34
38
|
}
|
|
35
39
|
}
|