create-pmos 0.423.0 → 0.425.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +41 -26
  8. package/workspace/briefing-premium-board-test.js +7 -4
  9. package/workspace/briefing-premium-insights-test.js +31 -15
  10. package/workspace/briefing-premium-products-test.js +62 -46
  11. package/workspace/changelog.json +24 -0
  12. package/workspace/guide/briefing-premium.md +3 -2
  13. package/workspace/guide/claude-proposes.md +37 -0
  14. package/workspace/guide/home.md +2 -2
  15. package/workspace/guide/index.md +2 -0
  16. package/workspace/guide/notes.md +39 -1
  17. package/workspace/guide/present-in-a-meeting.md +57 -0
  18. package/workspace/guide/programs.md +2 -2
  19. package/workspace/home-pill-test.js +138 -0
  20. package/workspace/lib/briefing-premium-products.js +18 -4
  21. package/workspace/lib/headless.js +14 -1
  22. package/workspace/lib/meeting-focus.js +64 -14
  23. package/workspace/lib/pmos-verbs.js +3 -0
  24. package/workspace/lib/proposal-runs.js +148 -0
  25. package/workspace/lib/proposals.js +370 -0
  26. package/workspace/lib/propose-cli.js +96 -0
  27. package/workspace/lib/route-modules.js +1 -0
  28. package/workspace/lib/routes-board-premium.js +11 -0
  29. package/workspace/lib/routes-boards.js +1 -1
  30. package/workspace/lib/routes-briefing-premium.js +19 -0
  31. package/workspace/lib/routes-meeting-focus.js +28 -6
  32. package/workspace/lib/routes-proposals.js +325 -0
  33. package/workspace/lib/routes-task-links.js +35 -28
  34. package/workspace/lib/settings-store.js +2 -1
  35. package/workspace/package-lock.json +2 -2
  36. package/workspace/package.json +1 -1
  37. package/workspace/premium-board-actions-test.js +2 -2
  38. package/workspace/premium-briefing-depth-test.js +1 -1
  39. package/workspace/premium-rec-now-test.js +153 -0
  40. package/workspace/premium-rec-tab-test.js +167 -0
  41. package/workspace/public/pm/bd-asks.js +3 -0
  42. package/workspace/public/pm/cozy-aud.css +9 -0
  43. package/workspace/public/pm/cozy-aud.js +80 -0
  44. package/workspace/public/pm/cozy-live-pill.js +3 -0
  45. package/workspace/public/pm/cozy-pick.css +41 -0
  46. package/workspace/public/pm/cozy-pick.js +134 -0
  47. package/workspace/public/pm/cozy-rec-bridge.js +32 -0
  48. package/workspace/public/pm/cozy-rec-now.css +104 -0
  49. package/workspace/public/pm/cozy-rec-now.js +330 -0
  50. package/workspace/public/pm/cozy-rec-present.css +69 -0
  51. package/workspace/public/pm/cozy-rec-present.js +467 -0
  52. package/workspace/public/pm/cozy-rec-tab.css +90 -0
  53. package/workspace/public/pm/cozy-rec-tab.js +219 -0
  54. package/workspace/public/pm/cozy-settings.js +8 -2
  55. package/workspace/public/pm/cozy-today.css +23 -0
  56. package/workspace/public/pm/cozy-viewer.js +14 -3
  57. package/workspace/public/pm/cozy-vw-shell.css +8 -0
  58. package/workspace/public/pm/home-app.js +56 -27
  59. package/workspace/public/pm/home-list.js +17 -10
  60. package/workspace/public/pm/home-more.js +2 -31
  61. package/workspace/public/pm/home-task.js +2 -1
  62. package/workspace/public/pm/home-today.js +69 -19
  63. package/workspace/public/pm/ini-groups.js +30 -5
  64. package/workspace/public/pm/ini-links.js +6 -48
  65. package/workspace/public/pm/ini-props.js +218 -0
  66. package/workspace/public/pm/ini-view-model.js +6 -1
  67. package/workspace/public/pm/ini-view.css +47 -0
  68. package/workspace/public/pm/ini-view.js +23 -6
  69. package/workspace/public/pm/live-model.js +1 -1
  70. package/workspace/public/pm/premium-board.js +56 -25
  71. package/workspace/public/pm/premium-insights.js +42 -24
  72. package/workspace/public/pm/premium-meeting.js +17 -4
  73. package/workspace/public/pm/premium-mtg-present.js +4 -3
  74. package/workspace/public/pm/premium-report-read.js +2 -0
  75. package/workspace/public/pm/premium-vw-item.js +2 -1
  76. package/workspace/public/pm/premium-vw-mtg.js +15 -7
  77. package/workspace/public/pm/rec-state.js +13 -5
  78. package/workspace/public/pm/rec-tab-core.js +92 -0
  79. package/workspace/public/pm/task-card.css +13 -0
  80. package/workspace/public/pm/task-card.js +37 -2
  81. package/workspace/public/pm/view-notes.js +9 -0
  82. package/workspace/public/premium-aud.html +22 -0
  83. package/workspace/public/premium-board.html +1 -0
  84. package/workspace/public/premium-insights.html +2 -1
  85. package/workspace/public/premium-rec.html +30 -0
  86. package/workspace/public/premium.html +1 -0
  87. package/workspace/rec-present-test.js +229 -0
  88. package/workspace/server.js +46 -3
  89. package/workspace/skills/initiative-propose.skill +45 -0
  90. package/workspace/stage-card-test.js +1 -1
  91. package/workspace/task-links-test.js +26 -14
  92. package/workspace/test-lists/claude-proposes.json +5 -0
  93. package/workspace/test-lists/home-sessions-pill.json +6 -0
  94. package/workspace/test-lists/rec-now.json +6 -0
  95. package/workspace/test-lists/rec-present.json +13 -0
  96. package/workspace/test-lists/recording-tab.json +13 -0
  97. package/workspace/tk-tasks-test.js +13 -0
@@ -16,13 +16,15 @@
16
16
  * POST /api/insights-records/tile. A tile goes amber only after two readings past its target. "Delivery trends" is also a view.
17
17
  * IsLibrary Found in your work as cards (Set it up, Not a report with Undo), the reports as Report · Next · Status, and a report's setup in the
18
18
  * Viewer card (Setup, Issues, Brief); a request from Home with Set it up, Change it and Cancel. New report hands off to Home.
19
- * IsMenus the product picker (each product's goal count, Portfolio rolls the goals of every product up), the Dashboard menu, Find (goals,
19
+ * IsMenus the product chip (the one pick Home and Board share, batch 12 item 5: one ticked = that product; several = Portfolio, their
20
+ * goals rolled up and grouped by product), the Dashboard menu, Find (goals,
20
21
  * reports and dashboards), Filter (status, owner, kind), ⋯ (Sources, Export, About) and the empty trend of a goal with one reading.
21
22
  * IsPhone the goal detail full screen with Readings, Moved by and Dashboards; a report setup as a sheet.
22
23
  * window.czViewer is feature-detected, with this page's side panel as the fallback. A report file opens in the report reader
23
24
  * (pm/premium-report-read.js), the report panel in the Viewer card. The page has no #dlg. */
24
25
  import { $, $$, esc, toast, wireRail, setPageGaps } from './premium-shell.js';
25
26
  import { pmPost } from './http.js';
27
+ import * as PK from './cozy-pick.js'; // the one product picker Home, Board and Insights share (batch 12 item 5)
26
28
  import { openReport } from './premium-report-read.js';
27
29
  import { mountNav } from './cozy-nav.js';
28
30
  import { mountLivePill } from './cozy-live-pill.js';
@@ -34,7 +36,11 @@ let tab = 'goals';
34
36
  let per = null; // the period { key, label, name, from, to }
35
37
  let find = '';
36
38
  let filt = { status: [], owner: [], kind: [] }; // the Filter (IsMenus): each group holds the chips that are on
37
- let PF = null; // Portfolio (IsMenus): { goals, charts, products } rolled up from every product's model, or null
39
+ let PF = null; // Portfolio (IsMenus): { goals, charts, products } rolled up from the ticked products' models, or null
40
+ // the products shown: the one saved pick (GET /api/briefing-premium/products). A link with ?ws= or ?board= is a one-off view of that product.
41
+ const DEEP = new URLSearchParams(location.search).has('ws') || new URLSearchParams(location.search).has('board');
42
+ let PKP = null;
43
+ const pickedWs = () => (PKP && !DEEP ? PKP.products.filter((p) => p.on).sort((a, b) => (b.primary ? 1 : 0) - (a.primary ? 1 : 0)).map((p) => p.ws) : []); // the default workspace first
38
44
  let loadedAt = 0;
39
45
  let selecting = false; let picked = []; // New dashboard: the goals picked in the table, in order
40
46
  wireRail('rep');
@@ -72,7 +78,7 @@ const closeViewer = () => { if (window.czViewer && typeof window.czViewer.close
72
78
  // The Viewer floats over the page (XvAInsight); the page does not move for it.
73
79
 
74
80
  /* ── small menus: one open at a time, Escape and an outside press close it ─────────────────────────────────────────────────────── */
75
- const MENUS = [['#prodPick', '#prodMenu'], ['#viewChip', '#viewMenu'], ['#perChip', '#perMenu'], ['#filtB', '#filtMenu'], ['#newB', '#newMenu'], ['#moreB', '#moreMenu']];
81
+ const MENUS = [['#viewChip', '#viewMenu'], ['#perChip', '#perMenu'], ['#filtB', '#filtMenu'], ['#newB', '#newMenu'], ['#moreB', '#moreMenu']];
76
82
  function menu(btn, box, open) { $(box).hidden = !open; $(btn).setAttribute('aria-expanded', String(open)); }
77
83
  function closeMenus(except) { for (const [b, m] of MENUS) if (m !== except && !$(m).hidden) menu(b, m, false); const cm = $('#chMenu'); if (cm) cm.hidden = true; if (!$('#findRow').hidden) closeFind(false); }
78
84
  for (const [b, m] of MENUS) {
@@ -156,12 +162,7 @@ const curDash = () => M.dashboards.find((d) => d.id === dash) || M.dashboards[0]
156
162
  const dashName = (D) => (D.id === 'all' ? 'All goals' : D.name);
157
163
  const nGoals = (k) => k + (k === 1 ? ' goal' : ' goals');
158
164
  function drawBar() {
159
- $('#prodName').textContent = PF ? 'Portfolio' : M.board.name || 'Insights';
160
- const boards = M.board.switcher || [];
161
- /* the product picker: each product with its goal count, then Portfolio, which rolls every product's goals up */
162
- $('#prodMenu').innerHTML = '<p class="ins-mh">Product</p>' + (boards.length ? boards.map((b) => `<button type="button" role="menuitemradio" aria-checked="${!PF && b.id === M.board.id && b.ws === M.board.ws}" data-ws="${esc(b.ws)}" data-board="${esc(b.id)}">${esc(b.name)}<span class="k">${b.goals != null ? esc(nGoals(b.goals)) : ''}</span></button>`).join('')
163
- : '<p class="note ins-mnote">One product is registered.</p>')
164
- + (boards.length > 1 ? `<div class="ins-hr"></div><button type="button" role="menuitemradio" aria-checked="${!!PF}" data-portfolio>Portfolio · all products</button><p class="note ins-mnote">Portfolio rolls goals up across products.</p>` : '');
165
+ drawPick();
165
166
  $('#nGoals').textContent = String(dash === TRENDS ? 0 : goalsShown().length);
166
167
  $('#nOutcomes').textContent = String(outcomesShown().length);
167
168
  const D = curDash();
@@ -172,12 +173,22 @@ function drawBar() {
172
173
  + `<div class="ins-hr"></div><button type="button" role="menuitem" data-newdash>${SV(I.plus)}New dashboard</button>`;
173
174
  drawPeriod(); drawFilter();
174
175
  }
175
- $('#prodMenu').addEventListener('click', (e) => {
176
- if (e.target.closest('[data-portfolio]')) { closeMenus(); if (!PF) openPortfolio(); return; }
177
- const b = e.target.closest('[data-board]'); if (!b) return;
178
- if (PF && b.dataset.ws === M.board.ws && b.dataset.board === M.board.id) { closeMenus(); PF = null; redraw(); return; }
179
- location.assign('/premium-insights.html?ws=' + encodeURIComponent(b.dataset.ws) + '&board=' + encodeURIComponent(b.dataset.board));
180
- });
176
+ /* the product chip (canvas XhpA5Pages): the same chip and list as Home's. It replaces the one-product menu and "Portfolio · all products" */
177
+ function shownPick() {
178
+ if (!PKP) return null;
179
+ if (!DEEP) return PKP;
180
+ return { ...PKP, products: PKP.products.map((p) => ({ ...p, on: p.ws === M.board.ws })) }; // a one-off link: the product on screen
181
+ }
182
+ function drawPick() {
183
+ const P = shownPick(), host = $('#prodHost');
184
+ host.innerHTML = P ? PK.chipHtml(P, { id: 'prodPick', label: 'Products' }) : `<span class="ins-ttl">${esc(M.board.name || 'Insights')}</span>`;
185
+ const chip = $('#prodPick'); if (!chip) return;
186
+ // a product's line: its goals, from what this page read (zero is silence)
187
+ const lines = (ws) => { const n = PF ? PF.goals.filter((g) => g.ws === ws).length : ws === M.board.ws ? M.goals.length : 0; return n ? nGoals(n) : ''; };
188
+ chip.onclick = (e) => { e.stopPropagation(); closeMenus(); PK.openPicker(chip, { P: shownPick(), label: 'Products', lines, note: 'One pick for Home, Board and Insights: unticking a product here also takes it off Home.', onApply: async (on) => { const r = await PK.savePick(on); if (!r.ok) toast(r.error); } }); };
189
+ }
190
+ // a saved pick (this chip, or Settings): Insights opens on the ticked products, without a one-off link's ws or board
191
+ addEventListener('pp:changed', () => { const q = new URLSearchParams(location.search); ['ws', 'board'].forEach((k) => q.delete(k)); const s = q.toString(); location.assign(location.pathname + (s ? '?' + s : '')); });
181
192
  $('#viewMenu').addEventListener('click', (e) => {
182
193
  if (e.target.closest('[data-newdash]')) { closeMenus(); openNewDash(); return; }
183
194
  const b = e.target.closest('[data-view]'); if (!b) return; closeMenus(); setView(b.dataset.view);
@@ -200,11 +211,12 @@ $('.ins-tabs').addEventListener('keydown', (e) => {
200
211
  });
201
212
  function setView(id) { dash = id; setTab('goals'); redraw(); }
202
213
 
203
- /* Portfolio: the goals of every product, each product's model read once through GET /api/insights-premium, grouped by product. A goal of another
204
- * product keeps its own workspace, so a reading added to it goes there. Budgets, Outcomes and Library stay the open product's. */
205
- async function openPortfolio() {
206
- const seen = new Set([M.board.ws]), others = (M.board.switcher || []).filter((b) => !seen.has(b.ws) && seen.add(b.ws));
207
- toast('Reading every product’s goals.');
214
+ /* Portfolio: the goals of the ticked products (several ticked, batch 12 item 5), each product's model read once through GET /api/insights-premium,
215
+ * grouped by product. A goal of another product keeps its own workspace, so a reading added to it goes there. Budgets, Outcomes and Library stay
216
+ * the first ticked product's, and say so (oneNote). */
217
+ async function openPortfolio(only = pickedWs(), keepTab = false) {
218
+ const seen = new Set([M.board.ws]), others = (M.board.switcher || []).filter((b) => (!only.length || only.includes(b.ws)) && !seen.has(b.ws) && seen.add(b.ws));
219
+ toast('Reading the goals of the products you picked.');
208
220
  const got = await Promise.all(others.map(async (b) => { try { const r = await (await fetch('/api/insights-premium?ws=' + encodeURIComponent(b.ws) + '&board=' + encodeURIComponent(b.id), { credentials: 'same-origin' })).json(); return r && r.ok ? r.model : null; } catch { return null; } }));
209
221
  const goals = M.goals.map((g) => Object.assign({}, g, { prod: M.board.name, ws: M.board.ws, rid: g.id })), charts = {}, products = [M.board.name], unread = [];
210
222
  got.forEach((m, i) => {
@@ -214,9 +226,11 @@ async function openPortfolio() {
214
226
  for (const g of m.goals || []) goals.push(Object.assign({}, g, { id: m.board.ws + '~' + g.id, rid: g.id, key: g.key ? m.board.ws + '~' + g.key : null, prod: m.board.name || others[i].name, ws: m.board.ws, moves: g.moves || [] }));
215
227
  });
216
228
  PF = { goals, charts, products, unread };
217
- dash = 'all'; setTab('goals'); redraw();
229
+ dash = 'all'; if (!keepTab) setTab('goals'); redraw();
218
230
  if (unread.length) toast('Not read: ' + unread.join(', ') + '. Their goals are not in Portfolio.');
219
231
  }
232
+ /** With several products ticked, Outcomes and Library are still read one product at a time: say which (principle 7, honest state). */
233
+ const oneNote = () => (PF ? `<p class="note ins-onenote">Shows ${esc(M.board.name || 'the first product')} only: this tab reads one product at a time.</p>` : '');
220
234
  const allGoals = () => (PF ? PF.goals : M.goals);
221
235
  const goalById = (id) => allGoals().find((x) => x.id === id) || null;
222
236
  const goalWs = (g) => (g && g.ws) || M.board.ws;
@@ -849,7 +863,7 @@ function drawOutcomes() {
849
863
  : (need.length ? `<b>${esc(need[0].title)} needs your verdict${dueOf(need[0]) !== null ? ' by ' + esc(md(dueOf(need[0]))) : ''}.</b> ` : '') + esc('Of ' + P.length + (P.length === 1 ? ' promise ' : ' promises ') + (per.said || 'in these dates') + ', ' + met + (met === 1 ? ' is' : ' are') + ' met, ' + part + (part === 1 ? ' is' : ' are') + ' partly met and ' + win + (win === 1 ? ' is' : ' are') + ' still in their window.');
850
864
  const head = '<div class="ins-tr ins-th ins-ocols" role="row"><div role="columnheader">Shipped initiative</div><div role="columnheader">What it promised · and what happened so far</div><div role="columnheader">Guardrail and overlap</div><div role="columnheader">Window</div><div role="columnheader">Verdict</div></div>';
851
865
  const groups = Object.keys(OUT_G).map((k) => { const G = L.filter((r) => r.group === k); return G.length ? `<div class="ins-grp" role="row"><span role="cell">${k === 'decided' ? 'Decided ' + esc(per.said || 'in these dates') : OUT_G[k]}</span> <span class="q">${G.length}</span></div>` + G.map(outRow).join('') : ''; }).join('');
852
- $('#outTbl').innerHTML = head + (groups || '<div class="ins-empty">Nothing to judge yet.</div>');
866
+ $('#outTbl').innerHTML = oneNote() + head + (groups || '<div class="ins-empty">Nothing to judge yet.</div>');
853
867
  }
854
868
  $('#outTbl').addEventListener('click', (e) => { const b = e.target.closest('[data-verdict]'); if (b) openVerdict((M.outcomes || []).find((r) => r.id === b.dataset.verdict)); });
855
869
 
@@ -1197,7 +1211,7 @@ function drawList() {
1197
1211
  const table = nRep ? `<div class="ins-rtbl" id="repAsks"><div class="ins-rl ins-rlh" role="presentation"><span>Report</span><span>Next</span><span>Status</span></div><div role="list">${reps.map(repRowHtml).join('')}${asks.map(askRowHtml).join('')}</div></div>`
1198
1212
  : !empty ? '<div class="ins-empty"><b>No report is set up and no report file is on record.</b> Reports are made in Home.</div>' : '';
1199
1213
  const dashBlock = `<div class="ins-sec"><h3>Dashboards</h3><span class="q">${dashes.length} · a dashboard is a saved view of Goals</span></div><div class="ins-dgrid" role="list">${dashes.map(dashCard).join('')}</div>`;
1200
- $('#repBody').innerHTML = `<div id="listRows" aria-label="Dashboards and reports">${fbox}${empty}${table}${dashBlock}</div>`;
1214
+ $('#repBody').innerHTML = `${oneNote()}<div id="listRows" aria-label="Dashboards and reports">${fbox}${empty}${table}${dashBlock}</div>`;
1201
1215
  }
1202
1216
  $('#repBody').addEventListener('click', async (e) => {
1203
1217
  const d = e.target.closest('[data-d]'); if (d) { setView(d.dataset.d); return; }
@@ -1343,7 +1357,10 @@ function draw() {
1343
1357
  redraw();
1344
1358
  }
1345
1359
  async function load() {
1346
- const p = new URLSearchParams(location.search), q = [p.get('ws') ? 'ws=' + encodeURIComponent(p.get('ws')) : '', p.get('board') ? 'board=' + encodeURIComponent(p.get('board')) : ''].filter(Boolean).join('&');
1360
+ if (!PKP) PKP = await PK.readPick();
1361
+ // the pick: one ticked = that product; several = the first one read, then Portfolio of them all
1362
+ const p = new URLSearchParams(location.search), on = pickedWs(), pw = DEEP ? p.get('ws') : on[0] || null;
1363
+ const q = [pw ? 'ws=' + encodeURIComponent(pw) : '', DEEP && p.get('board') ? 'board=' + encodeURIComponent(p.get('board')) : ''].filter(Boolean).join('&');
1347
1364
  let r = null, status = 0;
1348
1365
  try { const res = await fetch('/api/insights-premium' + (q ? '?' + q : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
1349
1366
  if (!r || !r.ok) {
@@ -1353,6 +1370,7 @@ async function load() {
1353
1370
  return;
1354
1371
  }
1355
1372
  const first = !M; M = r.model; loadedAt = Date.now(); draw(); if (first || !BM) bmLoad();
1373
+ if (on.length > 1 && first) await openPortfolio(on, true);
1356
1374
  // A shared goal link (?goal=<id>, from "Copy link" in the goal's ⋯) opens that goal once, after the first read.
1357
1375
  if (first) { const gid = new URLSearchParams(location.search).get('goal'); if (gid && allGoals().some((g) => g.id === gid)) openGoalDetail(gid); }
1358
1376
  }
@@ -6,6 +6,8 @@
6
6
  * window.__premiumRec, and mountMeeting(d): the controller Home mounts. It draws nothing: every meeting opens in the Viewer card
7
7
  * (premium-vw-mtg.js openMeeting). */
8
8
 
9
+ import { ownTab, openTab, goTab, dropTab, tabUrl, post } from './rec-tab-core.js';
10
+
9
11
  const pad = (n) => String(n).padStart(2, '0');
10
12
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
11
13
  const DOW = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -359,6 +361,7 @@ export function recCore(d) {
359
361
  R = {
360
362
  listen: (id) => V.listenNow(ctx, id), pause: () => V.pauseListening(ctx), listening: () => V.listeningId(), started: () => V.liveStarted(), banner: () => V.takeBanner(),
361
363
  highlight: (id) => V.highlightNow(ctx, id), highlighting: () => V.highlightBusy(),
364
+ screen: () => V.liveScreen(), shots: (on) => V.pauseShots(on),
362
365
  async stop(id) {
363
366
  const one = await d.pmGet('/api/notes/one?id=' + encodeURIComponent(id)), note = one && one.ok ? one.note : null;
364
367
  const { discardable } = await import('./note-dock.js');
@@ -368,22 +371,28 @@ export function recCore(d) {
368
371
  };
369
372
  return R;
370
373
  }
374
+ /* not the recording tab: the recording tab listens (rec-tab-core.js), and the press there gives the share its permission */
375
+ async function inTab(T, id) { goTab(T, tabUrl(id, { ws: (d.ws ? d.ws() : '') || '', go: true })); await readNotes(); return { ok: true, tab: true }; }
371
376
  const setHold = (id) => { HOLD = id ? { id } : null; window.__premiumHolding = HOLD; bump(); };
372
377
  const started = () => { const r = window.__premiumRecorder || R; return r ? r.started() : null; };
373
378
  const C = {
374
379
  async record(row) {
375
380
  const blocking = liveRows(NR).find((n) => n.state === 'recording' && !sameMeeting(n.meeting, row));
381
+ // the next meeting while one records in its own tab: that tab comes forward and asks once, "Stop X and record Y?"
382
+ if (blocking && !HOLD && ownTab() && openTab(tabUrl(String(blocking.id), { ws: (d.ws ? d.ws() : '') || '' }))) { post({ id: String(blocking.id), switchTo: { title: clip(row && row.title, 120), body: noteBody(row) } }); return { ok: false, tab: true, error: clip(blocking.title, 60) + ' is recording. Its tab asks whether to switch.' }; }
376
383
  if (blocking || HOLD) return { ok: false, error: (blocking ? clip(blocking.title, 60) : 'A meeting') + ' is recording. Pause or stop it first.' };
384
+ const T = ownTab() ? openTab(null) : null; // before the first await, so the browser lets the tab open
377
385
  const made = await d.pmPost('/api/notes/new', noteBody(row));
378
- if (!made || made.ok !== true) return { ok: false, error: (made && made.error) || 'The note was not made.' };
379
- return C.resume(made.note.id);
386
+ if (!made || made.ok !== true) { dropTab(T); return { ok: false, error: (made && made.error) || 'The note was not made.' }; }
387
+ return T ? inTab(T, made.note.id) : C.resume(made.note.id);
380
388
  },
381
389
  /** New meeting: an untitled note with no calendar event, listened to at once (the console's recordNew). */
382
390
  async fresh() {
383
391
  if (HOLD || liveRows(NR).some((n) => n.state === 'recording')) return { ok: false, error: 'A meeting is recording. Pause or stop it first.' };
392
+ const T = ownTab() ? openTab(null) : null;
384
393
  const made = await d.pmPost('/api/notes/new', { title: '' });
385
- if (!made || made.ok !== true) return { ok: false, error: (made && made.error) || 'The note was not made.' };
386
- const res = await C.resume(made.note.id); return res.ok ? { ok: true, id: made.note.id } : { ...res, id: made.note.id };
394
+ if (!made || made.ok !== true) { dropTab(T); return { ok: false, error: (made && made.error) || 'The note was not made.' }; }
395
+ const res = T ? await inTab(T, made.note.id) : await C.resume(made.note.id); return { ...res, id: made.note.id };
387
396
  },
388
397
  /** Highlight: the last 30 seconds and the next ones, made into a highlight from the transcript when the window closes. */
389
398
  async highlight() {
@@ -392,6 +401,7 @@ export function recCore(d) {
392
401
  return ok === false ? { ok: false, error: 'The highlight was not started.' } : { ok: true };
393
402
  },
394
403
  async resume(id) {
404
+ if (ownTab()) { const T = openTab(null); if (T) return inTab(T, id); }
395
405
  const rec = await recorder(); const ok = await rec.listen(id);
396
406
  await readNotes();
397
407
  if (!ok) return { ok: false, error: (await rec.banner()) || 'The meeting could not be heard.' };
@@ -408,6 +418,9 @@ export function recCore(d) {
408
418
  },
409
419
  refresh: readNotes, notes: () => NR, note: (id) => NR.find((n) => n.id === id) || null, started, holding: () => HOLD,
410
420
  highlighting: () => { const r = window.__premiumRecorder || R; return r && r.highlighting ? r.highlighting() : null; },
421
+ /** The recording tab's picture: { track, shared, paused, silent } (view-notes.js liveScreen); shots(on) pauses or keeps the screenshots. */
422
+ screen: () => { const r = window.__premiumRecorder || R; return r && r.screen ? r.screen() : { track: null, shared: false, paused: false, silent: false }; },
423
+ shots: (on) => { const r = window.__premiumRecorder || R; return !!(r && r.shots && r.shots(on)); },
411
424
  };
412
425
  window.__pmRecCore = C;
413
426
  window.__premiumRec = { pause: C.pause, resume: C.resume, stop: C.stop, record: C.record, fresh: C.fresh, highlight: C.highlight, today: async () => [],
@@ -30,7 +30,8 @@
30
30
  * presentModel(S, now) → the view model (pure) presentHtml(V) → the presenter (pure) audienceFoot(V) → text (pure)
31
31
  * openAudience() → the window (call it inside the press, before anything is awaited, so the browser allows it)
32
32
  * presentMaterial({ mats, start, ws, meeting, getMeeting, onKeep, onAddLink, onEnd, app, win }) → { ok, end, go, at, cur, blank }
33
- * previewMaterial(body, item, { ws, at, onAt, onPresent }) → draws the material for the PM only (XvAMaterialPreview) */
33
+ * previewMaterial(body, item, { ws, at, onAt, onPresent }) → draws the material for the PM only (XvAMaterialPreview)
34
+ * place(root), fit(box, slot) a drawn slide's items and its scale (the recording tab's presenter and audience tab draw slides too) */
34
35
  import * as D from './premium-deck.js';
35
36
  import { parseMd, toDom } from './cozy-md.js';
36
37
 
@@ -199,10 +200,10 @@ function copySheets(doc, again) {
199
200
  st.textContent = text.join('\n'); st.dataset.full = got.size === want.length ? '1' : '';
200
201
  if (got.size < want.length && again) for (const l of document.querySelectorAll('link[rel="stylesheet"]')) if (!l.sheet && want.some((x) => l.href.split('?')[0].endsWith(x))) l.addEventListener('load', again, { once: true });
201
202
  }
202
- function place(root) {
203
+ export function place(root) {
203
204
  root.querySelectorAll('.sl-it[data-g]').forEach((n) => { const [x, y, w, h] = n.dataset.g.split(','); n.style.setProperty('--bd-x', x + 'px'); n.style.setProperty('--bd-y', y + 'px'); n.style.setProperty('--bd-w', w + 'px'); n.style.setProperty('--bd-h', h + 'px'); });
204
205
  }
205
- function fit(box, slot) { const k = Math.max(0.03, Math.min(slot.clientWidth / D.W, slot.clientHeight / D.H)); box.style.setProperty('--bd-k', String(k)); }
206
+ export function fit(box, slot) { const k = Math.max(0.03, Math.min(slot.clientWidth / D.W, slot.clientHeight / D.H)); box.style.setProperty('--bd-k', String(k)); }
206
207
 
207
208
  /** Opens the audience window. Call it in the press itself (before an await), so the browser counts it as the PM's own. */
208
209
  export function openAudience() {
@@ -50,6 +50,7 @@
50
50
  import { pmGet, pmPost } from './http.js';
51
51
  import { open as vOpen, current as vCur, czSections } from './cozy-viewer.js';
52
52
  import * as MP from './premium-mtg-present.js'; // the one presenter window for every kind (canvas note xvPresent)
53
+ import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, the recording tab presents it (rule 10)
53
54
  import { placeholderHtml } from './cozy-placeholder.js';
54
55
  import './premium-vw-open.js'; // registers window.czViews
55
56
  import { cycleGroups, cycleName, briefModel, briefGlanceHtml, briefConfirmHtml, briefWhyHtml, briefLooksHtml, paperModel, paperHtml, liveModel, liveHtml, presentHtml, dayMon, reportSummary,
@@ -805,6 +806,7 @@ function printIt() {
805
806
  function presentIt() {
806
807
  const me = R;
807
808
  if (R.cyc || !R.W || R.err) return present(true);
809
+ if (presentInRecording({ kind: R.view === 'deck' ? 'pmos-deck' : 'report', ref: R.row.path, title: R.name, ws: R.ws })) return;
808
810
  if (typeof MP.presentMaterial === 'function') {
809
811
  const win = typeof MP.openAudience === 'function' ? MP.openAudience() : null;
810
812
  const mat = { kind: R.view === 'deck' ? 'pmos-deck' : 'report', ref: R.row.path, title: R.name, ws: R.ws };
@@ -7,7 +7,7 @@
7
7
  * 'reading' while the board derives, and the tab asks again. Inside a tab a task opens its own tab and the initiative link opens the initiative's. */
8
8
  import { vwOpen, vwStyle, vwClose } from './premium-viewer.js';
9
9
  import { esc, iniId, taskId, stateOf, readingHtml, errorHtml, iniHtml, taskHtml, findTask, cardTask } from './premium-vw-item-model.js';
10
- import { mountCard, boardSaver, checkOf, cardStyle, toastUndo, placeOf, deleteEntry } from './task-card.js';
10
+ import { mountCard, boardSaver, checkOf, cardStyle, toastUndo, placeOf, deleteEntry, historyFor } from './task-card.js';
11
11
  import { pmPost } from './http.js';
12
12
  import { setCheck } from './cozy-viewer.js';
13
13
 
@@ -104,6 +104,7 @@ export function openWorkItem(o) {
104
104
  openIni: (id) => openWorkItem({ kind: 'initiative', id, title: id === m.id ? m.title : '', ws: ctx.ws, board: ctx.board }),
105
105
  iniTitleOf: (id) => ((lists.inis || []).find((x) => x.id === id) || {}).title || id,
106
106
  inis: () => lists.inis || [], owners: () => lists.owners || [], groups: () => lists.groups, sections: () => lists.sections,
107
+ history: historyFor({ ws, board, t, post: (p, b) => pmPost(p, b) }), // what Claude changed with your ✓ (batch 12, TpA6)
107
108
  });
108
109
  check();
109
110
  // the pickers' lists: the board's initiatives and owners, the initiative's groups (read once, after the card shows)
@@ -35,11 +35,13 @@
35
35
  * openMeeting(ref, { ws }) → opens the card. ref: a note id, { note }, { event, date }, a calendar week row or a brief-page today row. */
36
36
  import { open as vOpen, current as vCur, back as vBack, czSummary, czSections } from './cozy-viewer.js';
37
37
  import { pmGet, pmPost, pressFetch } from './http.js';
38
+ import { ownTab, bring, tabUrl } from './rec-tab-core.js';
38
39
  import { noteSheet, aboutChoices, aboutBody, aboutNow } from './premium-vw-meet.js';
39
40
  import { weekView, noteOfRow, sameMeeting, recordable, prevOf, taskEvent, linkBody, mmss, focusView, replayModel, RECORD_LINE, FOCUS_LINE, STOP_LINE, CONSENT_LINE, recCore } from './premium-meeting.js';
40
41
  import { APPS, recall, remember } from './listen-sources.js';
41
42
  import { replayView, playerHtml, partHtml, keptHtml, phoneHtml, editHtml, mentions, phraseOf as phraseOfPage } from './premium-mtg-replay.js';
42
43
  import { announce } from './rec-state.js';
44
+ import { presentInRecording } from './cozy-rec-bridge.js'; // while a meeting records, Present goes to the recording tab (batch 12 item 1, rule 10)
43
45
 
44
46
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
45
47
  const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1) + '…' : t; };
@@ -68,6 +70,8 @@ const MENU = {
68
70
  fresh: ['New meeting', 'Start an untitled note now'],
69
71
  why: ['What Record and Focus do', 'Audio and notes stay on this machine'],
70
72
  };
73
+ /** Record and Resume on a page that is not the recording tab: the meeting opens in its own tab, where one press shares it. */
74
+ const TAB_LINE = 'The meeting opens in its own tab. Share it there to start.';
71
75
  export const EMPTY_LIVE = 'Press Record when the meeting starts. PMOS listens to your microphone and the meeting sound, and keeps both on this machine.';
72
76
  export const EMPTY_NOTES = 'The summary, decisions and next steps are written when you stop recording.';
73
77
  export const LIVE_FOOT = 'Transcribed on this machine. Audio and notes stay here.';
@@ -291,7 +295,7 @@ const SV = { link: '<path d="M10 14a4 4 0 0 0 6 0l3-3a4 4 0 0 0-6-6l-1 1M14 10a4
291
295
  prod: '<path d="M5 20V11M12 20V5M19 20v-6"/>', ticket: '<path d="M4 7h16v4a2 2 0 0 0 0 4v4H4v-4a2 2 0 0 0 0-4z"/>', warn: '<path d="M12 4l9 16H3zM12 10v4M12 17v.01"/>',
292
296
  rec: '<circle cx="12" cy="12" r="5"/>', star: '<path d="M12 3.8l2.5 5.2 5.7.8-4.1 4 1 5.7L12 16.8l-5.1 2.7 1-5.7-4.1-4 5.7-.8z"/>',
293
297
  img: '<path d="M4 4.5h16v15H4zM9 10a1.6 1.6 0 1 0 0-.01M20 16l-5-5-8 8"/>', up: '<path d="M12 16V4M7 9l5-5 5 5M5 20h14"/>',
294
- present: '<path d="M3 4h18v12H3zM10 8.5l4 2.5-4 2.5zM8 20h8M12 16v4"/>' };
298
+ tab: '<path d="M14 4h6v6M20 4l-8 8M18 14v6H4V6h6"/>', present: '<path d="M3 4h18v12H3zM10 8.5l4 2.5-4 2.5zM8 20h8M12 16v4"/>' };
295
299
  const svg = (k, w, extra) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24"${extra || ''}>${SV[k]}</svg>`;
296
300
  /* bars split by weight (live topics): an SVG, so each length is an attribute and not an inline style */
297
301
  function weightBar(cls, parts) {
@@ -326,13 +330,15 @@ export function summaryHtml(m, ui = {}) {
326
330
  }
327
331
  if (m.mk === 'live') {
328
332
  const L = m.live, Fo = m.focus;
329
- const line = m.liveK === 'rec' ? 'Recording · ' + mmss(m.liveMs || 0) : m.liveK === 'paused' ? 'Paused at ' + mmss(m.liveMs || 0) : 'Recording, but not on this page';
333
+ // a recording in its own tab (rec-tab-core.js) is live, not stale: this page shows it, and its one press brings that tab forward
334
+ const away = m.liveK === 'stale' && ownTab();
335
+ const line = m.liveK === 'rec' || away ? 'Recording · ' + mmss(m.liveMs || 0) : m.liveK === 'paused' ? 'Paused at ' + mmss(m.liveMs || 0) : 'Recording, but not on this page';
330
336
  const now = Fo.now ? 'Now on: ' + Fo.now + (Fo.topics.length > 1 ? ', topic ' + (Fo.topics.findIndex((t) => t.now) + 1) + ' of ' + Fo.topics.length + '.' : '.')
331
337
  : Fo.error ? 'Focus could not read this meeting: ' + String(Fo.error).replace(/\.$/, '') + '.' : ''; // honest: a refused read says why
332
- const text = m.liveK === 'paused' ? 'Nothing is kept while paused. ' + now : m.liveK === 'stale' ? 'Nothing is kept until you resume here. ' + now : now;
333
- const acts = m.liveK === 'rec' ? roundBtn('stop', 'Stop the recording', 'stop', 'red') + roundBtn('hl', 'Highlight the last 30 seconds', 'star') + roundBtn('pause', 'Pause', 'pause')
338
+ const text = m.liveK === 'paused' ? 'Nothing is kept while paused. ' + now : m.liveK === 'stale' && !away ? 'Nothing is kept until you resume here. ' + now : now;
339
+ const acts = away ? roundBtn('rectab', 'Go to the recording tab', 'tab', 'dark') : m.liveK === 'rec' ? roundBtn('stop', 'Stop the recording', 'stop', 'red') + roundBtn('hl', 'Highlight the last 30 seconds', 'star') + roundBtn('pause', 'Pause', 'pause')
334
340
  : roundBtn('resume', 'Resume', 'play', 'dark') + roundBtn('stop', 'Stop the recording', 'stop', 'red');
335
- return czSummary({ line, tone: m.liveK === 'rec' ? 'live' : 'warn', text: text.trim(), extra: metaLine([L.app + ' · microphone and meeting', m.people.length ? plural(m.people.length, 'person', 'people') : '']) + `<div class="vzm-acts">${acts}</div>` });
341
+ return czSummary({ line, tone: m.liveK === 'rec' || away ? 'live' : 'warn', text: text.trim(), extra: metaLine([L.app + ' · microphone and meeting', m.people.length ? plural(m.people.length, 'person', 'people') : '']) + `<div class="vzm-acts">${acts}</div>` });
336
342
  }
337
343
  const N = m.notes, V = N.replay;
338
344
  const text = N.summary || (m.private ? 'This note is private: only what you typed is kept.' : 'No summary was written for this meeting.');
@@ -715,10 +721,11 @@ async function press(me, e) {
715
721
  case 'recgo': {
716
722
  ui.ask = null; t.disabled = true;
717
723
  const res = me.n && !me.row ? await C.resume(me.n.id) : await C.record(me.row);
718
- say(me, res.ok ? 'Recording. Notes are being taken on this machine. Let people know.' : res.error, res.ok ? '' : 'bad');
724
+ say(me, res.ok ? (res.tab ? TAB_LINE : 'Recording. Notes are being taken on this machine. Let people know.') : res.error, res.ok ? '' : 'bad');
719
725
  announce(); return load(me);
720
726
  }
721
- case 'resume': { t.disabled = true; const res = await C.resume(me.n.id); say(me, res.ok ? 'Listening again.' : res.error, res.ok ? '' : 'bad'); announce(); return load(me); }
727
+ case 'resume': { t.disabled = true; const res = await C.resume(me.n.id); say(me, res.ok ? (res.tab ? TAB_LINE : 'Listening again.') : res.error, res.ok ? '' : 'bad'); announce(); return load(me); }
728
+ case 'rectab': if (me.n) bring(tabUrl(me.n.id, { ws: me.ws || '' })); return;
722
729
  case 'pause': { ui.ask = null; t.disabled = true; const res = await C.pause(); say(me, res.ok ? 'Paused. You can resume within 1 hour.' : res.error, res.ok ? '' : 'bad'); announce(); return load(me); }
723
730
  case 'stop': ui.ask = 'stop'; return repaint(me);
724
731
  case 'stopgo': { ui.ask = null; t.disabled = true; const res = await C.stop(me.n.id); say(me, res.ok ? (res.discarded ? 'Nothing was recorded, so the note was deleted.' : 'Stopped. The final notes are written now.') : res.error, res.ok ? '' : 'bad'); announce(); return load(me); }
@@ -988,6 +995,7 @@ function meetingNow(me) {
988
995
  const matId = (x) => x.id || x.mkind + '|' + (x.ref || x.url || x.title);
989
996
  async function presentIt(me, i, at) {
990
997
  const all = (me.model && me.model.material) || [], x = all[i]; if (!x || !x.present) return;
998
+ if (presentInRecording({ ...x, kind: x.mkind || x.kind, ws: x.ws || me.ws })) return; // while a meeting records, the recording tab presents it (rule 10)
991
999
  const win = audience(); // before anything is awaited
992
1000
  const M = await import('./premium-mtg-present.js');
993
1001
  const list = all.filter((y) => y.present), start = list.indexOf(x);
@@ -12,16 +12,21 @@
12
12
  * paused it is paused (nothing is kept until it resumes)
13
13
  * startedAt ms when this stretch of the meeting clock started, so a page can tick it: elapsed = elapsedMs + (Date.now() - readAt)
14
14
  * elapsedMs the meeting time heard so far, at readAt
15
- * href where the recording is shown: Home with the meeting open (/premium.html?meeting=<note id>)
16
- * here this page holds the recorder (premium-meeting.js sets window.__premiumHolding)
15
+ * href the recording tab (/premium-rec.html?note=<id>, rec-tab-core.js): a press on a snippet brings it forward
16
+ * here this page holds the recorder (premium-meeting.js sets window.__premiumHolding), or is the recording tab
17
+ * silent the recording tab hears the microphone but not the meeting ("Not hearing the meeting")
18
+ * The recording tab also sends its state over a BroadcastChannel (rec-tab-core.js post) on each change and every 5 s: a page reads again
19
+ * at once, so its snippet never runs a stale clock. The channel carries state only.
17
20
  * The answer comes from the notes the server keeps, so a page that did not start the recording still knows of it. Nothing is written. */
18
21
  import { pmGet } from './http.js';
22
+ import { tabUrl, isTab, listen } from './rec-tab-core.js';
19
23
 
20
24
  export const EVENT = 'cz:recording';
21
- const OFF = Object.freeze({ on: false, paused: false, id: '', title: '', startedAt: 0, elapsedMs: 0, readAt: 0, href: '', here: false });
25
+ const OFF = Object.freeze({ on: false, paused: false, id: '', title: '', startedAt: 0, elapsedMs: 0, readAt: 0, href: '', here: false, silent: false });
26
+ let heard = { id: '', silent: false };
22
27
  let last = null, lastAt = 0, inflight = null, timer = null;
23
28
  const subs = new Set();
24
- const same = (a, b) => !!a && !!b && a.on === b.on && a.paused === b.paused && a.id === b.id && a.title === b.title;
29
+ const same = (a, b) => !!a && !!b && a.on === b.on && a.paused === b.paused && a.id === b.id && a.title === b.title && a.silent === b.silent;
25
30
 
26
31
  /** The State of the note list (pure). rows: GET /api/notes .notes */
27
32
  export function stateOf(rows, now = Date.now(), holding = null) {
@@ -30,7 +35,8 @@ export function stateOf(rows, now = Date.now(), holding = null) {
30
35
  const n = live.find((x) => x.state === 'recording') || live[0];
31
36
  const el = Math.max(0, Number(n.meeting_ms) || 0);
32
37
  return { on: true, paused: n.state === 'paused', id: String(n.id), title: String((n.meeting && n.meeting.title) || n.title || 'Meeting'), startedAt: n.state === 'recording' ? now - el : 0,
33
- elapsedMs: el, readAt: now, href: '/premium.html?meeting=' + encodeURIComponent(n.id), here: !!(holding && holding.id === n.id) };
38
+ elapsedMs: el, readAt: now, href: tabUrl(String(n.id), { ws: n.ws || '' }), here: !!(holding && holding.id === n.id) || isTab(),
39
+ silent: heard.id === String(n.id) && heard.silent && n.state === 'recording' };
34
40
  }
35
41
 
36
42
  export async function recState({ fresh = false } = {}) {
@@ -60,4 +66,6 @@ export function onRecording(fn) {
60
66
  /** A recording was started, paused, resumed or stopped on this page: read again now. */
61
67
  export function announce() { return recState({ fresh: true }); }
62
68
 
69
+ if (typeof window !== 'undefined' && !isTab()) listen((d) => { heard = { id: d.id, silent: !!d.silent }; recState({ fresh: true }); });
70
+
63
71
  if (typeof window !== 'undefined') window.czRecording = { state: recState, on: onRecording, EVENT };
@@ -0,0 +1,92 @@
1
+ /* pm/rec-tab-core.js — a recording runs in its own tab (batch 12 item 1; canvas Ready for development, XrtA1Tab … XrtA6States).
2
+ *
3
+ * The recording tab (/premium-rec.html, rec-tab.js) holds the recorder and never navigates away, so opening Home, Board, Insights or a
4
+ * chat in another tab never pauses the meeting. Every other page shows only a snippet (the Live pill's first row, Home's pinned row): a
5
+ * press brings the recording tab forward. Only the recording tab controls the meeting; the channel below carries its state, never a press.
6
+ *
7
+ * TAB, MAIN the window names: the recording tab, and the PMOS tab its links open in
8
+ * tabUrl(id, { ws, go }) the recording tab's address for one note; go: start listening when it opens
9
+ * isTab() this page is the recording tab
10
+ * ownTab() a Record pressed on this page records in the recording tab (not on a phone, not in the recording tab;
11
+ * a browser under automation only when the suite asks with window.__pmRecOwnTab)
12
+ * openTab(url) → T | null the recording tab, opened or brought forward. Call it first in the press, before any await, so the
13
+ * browser lets it open. A tab that is already open keeps its page; url is loaded only into a new one.
14
+ * goTab(T, url) load url into that tab (a note was made after the press)
15
+ * bring(url) → bool a snippet's press: the recording tab forward (opened at url when it was closed)
16
+ * post(state) · listen(fn) the recording tab's state to every other PMOS tab: { id, state, title, elapsedMs, silent, at }
17
+ * clockOf(ms) · modeOf(row, held, screen) · endOf(note) · marksOf(note, frames, len) the recording tab's pure half
18
+ */
19
+ export const TAB = 'pmos-rec';
20
+ export const MAIN = 'pmos-main';
21
+ const CHANNEL = 'pmos-rec';
22
+
23
+ export const tabUrl = (id, { ws = '', go = false } = {}) => '/premium-rec.html?note=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) : '') + (go ? '&go=1' : '');
24
+ export const isTab = () => typeof location !== 'undefined' && /^\/premium-rec(\.html)?$/.test(location.pathname);
25
+ const phone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
26
+ export function ownTab() {
27
+ if (typeof window === 'undefined' || isTab()) return false;
28
+ if (typeof navigator !== 'undefined' && navigator.webdriver === true && window.__pmRecOwnTab !== true) return false;
29
+ return true;
30
+ }
31
+
32
+ /** T = { win, blank, here }: here is true on a phone, where the recording view opens in this same tab. */
33
+ export function openTab(url) {
34
+ if (phone()) { if (url) location.href = url; return { win: window, blank: true, here: true }; }
35
+ let win = null;
36
+ try { win = window.open('', TAB); } catch { win = null; }
37
+ if (!win) return null;
38
+ let blank = false;
39
+ try { blank = !win.location.href || win.location.href === 'about:blank'; } catch { blank = false; }
40
+ if (url && blank) win.location.href = url;
41
+ try { win.focus(); } catch { /* the browser keeps the focus */ }
42
+ return { win, blank, here: false };
43
+ }
44
+ export function goTab(T, url) {
45
+ if (!T || !T.win) return;
46
+ try { T.win.location.href = url; T.win.focus(); } catch { /* the tab was closed */ }
47
+ }
48
+ /** Close a tab opened for a note that was then not made. */
49
+ export function dropTab(T) { if (T && T.blank && !T.here) { try { T.win.close(); } catch { /* gone */ } } }
50
+ export function bring(url) { const T = openTab(url); return !!T; }
51
+
52
+ /* ── the recording tab's pure half (cozy-rec-tab.js draws from these) ─────────────────────────────────────── */
53
+ const pad = (n) => String(n).padStart(2, '0');
54
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
55
+ /** The meeting clock: 12:40, then 1:02:40 past the hour. */
56
+ export const clockOf = (ms) => { const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)), h = Math.floor(s / 3600), m = Math.floor((s % 3600) / 60); return h ? h + ':' + pad(m) + ':' + pad(s % 60) : m + ':' + pad(s % 60); };
57
+ /** What the tab is in now (pure): 'stopped' | 'paused' | 'screen' | 'room' | 'idle'. row: the note's list row; held: this tab listens to it;
58
+ * scr: the recorder's picture ({ shared }). */
59
+ export function modeOf(row, held, scr) {
60
+ if (!row) return 'idle';
61
+ if (row.state === 'ended') return 'stopped';
62
+ if (row.state === 'paused') return 'paused';
63
+ if (row.state === 'recording' && held) return scr && scr.shared ? 'screen' : 'room';
64
+ return 'idle';
65
+ }
66
+ /** The meeting's calendar end in ms, or null (an untitled note has none). */
67
+ export const endOf = (note) => { const e = note && note.meeting && note.meeting.end; const t = e && /T\d{2}:\d{2}/.test(e) ? Date.parse(e) : NaN; return Number.isFinite(t) ? t : null; };
68
+ /** The marks on the meeting-so-far line (pure): one per highlight, at its meeting time. → [{ t, x (0..1), text, shot }] */
69
+ export function marksOf(note, frames, len) {
70
+ if (!note || !(len > 0)) return [];
71
+ const from = Date.parse(note.recorded_from || '') || 0;
72
+ const shots = (Array.isArray(frames) ? frames : []).map((f) => f.t).filter(Number.isFinite).sort((a, b) => a - b);
73
+ const near = (t) => { let best = null; for (const s of shots) { if (s <= t + 15000) best = s; else break; } return best; };
74
+ return (note.highlights || []).map((h) => {
75
+ const t = Number.isFinite(h.t) ? h.t : Number.isFinite(h.timestamp) && from ? h.timestamp - from : null;
76
+ return t == null ? null : { t, x: Math.min(1, Math.max(0, t / len)), text: clip(h.text || h.label || '', 140), shot: near(t) };
77
+ }).filter(Boolean);
78
+ }
79
+
80
+
81
+ let ch = null;
82
+ const channel = () => { if (!ch && typeof BroadcastChannel === 'function') { try { ch = new BroadcastChannel(CHANNEL); } catch { ch = null; } } return ch; };
83
+ export function post(state) { const c = channel(); if (c) { try { c.postMessage({ ...state, at: Date.now() }); } catch { /* closed */ } } }
84
+ export function listen(fn) {
85
+ const c = channel(); if (!c) return () => {};
86
+ const on = (e) => { const d = e && e.data; if (d && typeof d.id === 'string') { try { fn(d); } catch { /* the listener's own */ } } };
87
+ c.addEventListener('message', on);
88
+ return () => c.removeEventListener('message', on);
89
+ }
90
+
91
+ /* every other PMOS page is the tab the recording tab's links open in */
92
+ if (typeof window !== 'undefined' && !isTab() && !window.name) { try { window.name = MAIN; } catch { /* read-only */ } }
@@ -84,3 +84,16 @@
84
84
  /* the ◇ milestone toggle after a divider (feedback batch 11 item 3, canvas XmlA2Flag) */
85
85
  .tkc .seg .vr { width: 1px; height: 20px; background: var(--cz-hair); margin: 0 3px; align-self: center; }
86
86
  .tkc .seg .ivq-ms.on { width: auto; padding: 0 12px 0 9px; gap: 6px; background: var(--cz-bluebg); color: var(--cz-blueink); font-weight: 800; font-size: 13px; box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
87
+ /* History (batch 12 items 2 and 3, canvas TpA6): what Claude changed with the PM's ✓; folded, hidden at zero */
88
+ .tkc .tkc-h { padding-top: 4px; }
89
+ .tkc .tkc-hh { display: flex; align-items: center; gap: 6px; width: 100%; font: inherit; background: none; border: 0; padding: 6px 0; color: var(--cz-ink); cursor: pointer; text-align: left; }
90
+ .tkc .tkc-hh b { font-size: 13px; font-weight: 800; }
91
+ .tkc .tkc-hh .n { font-size: 12px; font-weight: 700; color: var(--cz-ink3); }
92
+ .tkc .tkc-hh svg { margin-left: auto; color: var(--cz-ink3); }
93
+ .tkc .tkc-h ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
94
+ .tkc .tkc-h li { display: flex; align-items: flex-start; gap: 8px; }
95
+ .tkc .tkc-h li .w { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
96
+ .tkc .tkc-h li b { font-size: 13px; font-weight: 700; }
97
+ .tkc .tkc-h li small { font-size: 12px; color: var(--cz-ink3); line-height: 1.4; }
98
+ .tkc .tkc-hu { width: 30px; height: 30px; border-radius: 999px; border: 0; background: none; color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
99
+ .tkc .tkc-hu:hover { background: var(--cz-well); color: var(--cz-ink); }
@@ -8,6 +8,8 @@
8
8
  * Notes the PM's words, edited in place;
9
9
  * where it sits one row: initiative › section › breakdown item. The row opens the initiative; the move icon beside it changes the
10
10
  * section (the workflow stage the task sits in), the PM's group, or the initiative.
11
+ * History N what Claude changed with the PM's ✓ (batch 12 items 2 and 3, canvas TpA6): field, before → after, why and where it read
12
+ * it; Undo on a change of the last 7 days. Folded; hidden at zero. h.history: { load() → [entry], undo(batch) → { ok } }
11
13
  * Every change saves at once and says so in a toast with Undo. A Jira ticket is not drawn here: it opens the ticket Viewer (tk-view.js).
12
14
  * cardHtml(t, o) → markup pure, for a node test: t is a task (taskOf), o the open picker and its lists
13
15
  * taskOf(row, extra) → t a row of /api/boards/items or of the initiative model, in one shape
@@ -181,7 +183,22 @@ export function cardHtml(t, o = {}) {
181
183
  const move = canMove(t, o) ? `<span class="anc"><button type="button" class="ovmv${mOpen ? ' open' : ''}" data-tkc="move" aria-label="Move it: section, group or initiative" title="Move it" aria-expanded="${mOpen}" aria-haspopup="menu">${ico(I.drag, 17)}</button>${mOpen ? movePop(t, o) : ''}</span>` : '';
182
184
  const where = t.ini ? `<div class="ovw tk-ini"><button type="button" class="go" data-tkc="ini" aria-label="Open ${esc(t.iniTitle || t.ini)}"><span class="tl" aria-hidden="true">${ico(I.flag, 15)}</span>`
183
185
  + `<span class="tx"><b>${esc(t.iniTitle || t.ini)}</b>${path.length ? `<small>${path.join('<span class="sep" aria-hidden="true">›</span>')}</small>` : ''}</span><span class="cv">${ico(I.chev, 15)}</span></button>${move}</div>` : '';
184
- return `<div class="tkc s-${sk}">${facts}${notes}${where}<p class="tkc-msg" role="status">${esc(o.msg || '')}</p></div>`;
186
+ return `<div class="tkc s-${sk}">${facts}${notes}${where}${historyHtml(o.hist, o.histOpen, now)}<p class="tkc-msg" role="status">${esc(o.msg || '')}</p></div>`;
187
+ }
188
+
189
+ /** History (canvas TpA6): Claude's approved changes to the task, newest first (lib/proposals.js historyOf). Zero is silence. */
190
+ const FIELD = { due: 'Due', status: 'Status', name: 'Name', notes: 'Notes', add: 'Added' };
191
+ const valOf = (f, v) => (v == null || v === '' ? '—' : typeof v === 'object' ? [short(v.start), short(v.due)].filter(Boolean).join(' – ') || '—' : f === 'notes' ? 'edited' : String(v));
192
+ export function historyHtml(hist, open, now = Date.now()) {
193
+ const L = (hist || []).filter((x) => x && !x.undone);
194
+ if (!L.length) return '';
195
+ const rows = L.map((x) => {
196
+ const recent = now - (Date.parse(x.at) || 0) < 7 * 864e5;
197
+ const what = x.field === 'add' ? 'Added from ' + (x.source || 'your sources') : (FIELD[x.field] || x.field) + ': ' + valOf(x.field, x.from) + ' → ' + valOf(x.field, x.to);
198
+ return `<li><span class="w"><b>${esc(what)}</b><small>${esc(['Claude, kept by you ' + short(String(x.at).slice(0, 10)), x.why, x.field !== 'add' && x.source ? x.source : ''].filter(Boolean).join(' · '))}</small></span>`
199
+ + (recent && x.batch ? `<button type="button" class="tkc-hu" data-tkc-hundo="${esc(x.batch)}" aria-label="Undo this change" title="Undo">${ico('<path d="M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3"/>', 15)}</button>` : '') + '</li>';
200
+ }).join('');
201
+ return `<div class="ovb tkc-h"><button type="button" class="tkc-hh" data-tkc-hist aria-expanded="${!!open}"><b>History</b><span class="n">${L.length}</span>${ico(open ? '<path d="M6 9l6 6 6-6"/>' : I.chev, 14)}</button>${open ? `<ul>${rows}</ul>` : ''}</div>`;
185
202
  }
186
203
 
187
204
  /* ── the page: one card, every change saved at once with Undo ── */
@@ -209,7 +226,7 @@ export function mountCard(el, t, h) {
209
226
  const draw = () => {
210
227
  const keep = document.activeElement && el.contains(document.activeElement) && document.activeElement.matches('[data-tkc-notes]');
211
228
  if (keep) return; // never redraw under the PM's typing
212
- el.innerHTML = cardHtml(t, { ...st, ...lists(), now: h.now ? h.now() : Date.now() });
229
+ el.innerHTML = cardHtml(t, { ...st, ...lists(), hist: st.hist, histOpen: st.histOpen, now: h.now ? h.now() : Date.now() });
213
230
  const f = el.querySelector('.tkc-new input'); if (f && (st.open === 'owner' || st.open === 'group')) f.focus();
214
231
  };
215
232
  const word = (kind) => (WORDS[kind] || (() => 'Saved'))(t, h);
@@ -237,6 +254,12 @@ export function mountCard(el, t, h) {
237
254
  el.onclick = (e) => {
238
255
  const b = e.target.closest('button'); if (!b || b.disabled || !el.contains(b)) return;
239
256
  const d = b.dataset;
257
+ if ('tkcHist' in d) { st.histOpen = !st.histOpen; draw(); return; }
258
+ if (d.tkcHundo && h.history) {
259
+ b.disabled = true;
260
+ Promise.resolve(h.history.undo(d.tkcHundo)).catch(() => null).then((r) => { st.msg = r && r.ok !== false ? '' : (r && r.error) || 'The undo did not land.'; loadHist(); if (h.changed) h.changed(t); });
261
+ return;
262
+ }
240
263
  if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } return; }
241
264
  if ('tkcMs' in d) { st.open = null; change('milestone', { milestone: !t.milestone }); return; }
242
265
  if (d.tkcDay != null && b.closest('.tkc-dp')) { pick(d.tkcDay); return; }
@@ -272,7 +295,9 @@ export function mountCard(el, t, h) {
272
295
  // a press outside an open picker closes it (a popover opens under its control and leaves the same way)
273
296
  const away = (e) => { if (!el.isConnected) { document.removeEventListener('pointerdown', away, true); return; } if (st.open && !e.target.closest('.anc')) { st.open = null; draw(); } };
274
297
  document.addEventListener('pointerdown', away, true);
298
+ const loadHist = () => { if (h.history) Promise.resolve(h.history.load()).catch(() => null).then((L) => { st.hist = Array.isArray(L) ? L : []; draw(); }); };
275
299
  draw();
300
+ loadHist();
276
301
  return { draw, setStatus: (s) => change('status', { status: s }), task: t };
277
302
  }
278
303
 
@@ -305,6 +330,16 @@ export function toastUndo(msg, undo) {
305
330
  clearTimeout(toastUndo.t); toastUndo.t = setTimeout(() => el.classList.remove('on', 'act'), undo ? 8000 : 4200);
306
331
  }
307
332
 
333
+ /** h.history for a board task: GET /api/proposals/history and POST /api/proposals/undo (lib/routes-proposals.js). o: { ws, board, t, post } */
334
+ export function historyFor(o) {
335
+ const { ws, board, t, post } = o;
336
+ if (!t || t.jira || !t.uid || !board) return null;
337
+ return {
338
+ load: () => fetch('/api/proposals/history?board=' + encodeURIComponent(board) + (ws ? '&ws=' + encodeURIComponent(ws) : '') + '&task=' + encodeURIComponent(t.uid), { credentials: 'same-origin' })
339
+ .then((r) => r.json()).then((j) => (j && j.ok ? j.history : [])).catch(() => []),
340
+ undo: (batch) => post('/api/proposals/undo', { ws, board, batch }),
341
+ };
342
+ }
308
343
  /** The board's routes behind h.save. o: { ws, board, t, post(path, body) → Promise<json> } */
309
344
  export function boardSaver(o) {
310
345
  const { ws, board, t, post } = o;