create-pmos 0.317.0 → 0.319.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 (33) hide show
  1. package/package.json +1 -1
  2. package/payload/KIT-VERSION +1 -1
  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/workspace/briefing-premium-board-test.js +2 -2
  7. package/workspace/briefing-premium-initiative-test.js +5 -10
  8. package/workspace/briefing-premium-insights-test.js +1 -1
  9. package/workspace/briefing-premium-products-test.js +9 -4
  10. package/workspace/briefing-premium-test.js +12 -10
  11. package/workspace/briefing-premium-work-test.js +2 -10
  12. package/workspace/guide/briefing-premium.md +22 -19
  13. package/workspace/lib/briefing-premium-agent.js +5 -0
  14. package/workspace/lib/insights-premium.js +1 -1
  15. package/workspace/lib/my-work-premium.js +1 -24
  16. package/workspace/lib/routes-briefing-premium.js +1 -1
  17. package/workspace/lib/routes-my-work-premium.js +1 -3
  18. package/workspace/package-lock.json +2 -2
  19. package/workspace/package.json +1 -1
  20. package/workspace/premium-studio-test.js +4 -4
  21. package/workspace/public/pm/premium-board.js +3 -2
  22. package/workspace/public/pm/premium-initiative.js +2 -1
  23. package/workspace/public/pm/premium-insights.js +3 -2
  24. package/workspace/public/pm/premium-meeting.js +3 -3
  25. package/workspace/public/pm/premium-shell.js +147 -7
  26. package/workspace/public/pm/premium-work.js +5 -29
  27. package/workspace/public/pm/premium.css +47 -2
  28. package/workspace/public/pm/premium.js +16 -23
  29. package/workspace/public/premium-board.html +2 -6
  30. package/workspace/public/premium-initiative.html +1 -5
  31. package/workspace/public/premium-insights.html +1 -5
  32. package/workspace/public/premium-work.html +4 -14
  33. package/workspace/public/premium.html +3 -7
@@ -63,10 +63,10 @@ const saved = async () => { const j = await (await fetch(BASE + '/api/insights-p
63
63
  const open = async (sel) => { await p.click(sel); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu'))); await sleep(300); };
64
64
  const shut = async () => { for (let i = 0; i < 2 && await p.evaluate(() => document.querySelector('#dlg').classList.contains('on')); i++) { await p.keyboard.press('Escape'); await sleep(150); } };
65
65
 
66
- /* O0: the crumb's Studio pill, as the mockup has it, opens the Studio on the dashboard shown */
67
- ok('O0 the crumb has a Studio pill with the sparkle', await p.evaluate(() => { const b = document.querySelector('#crAsk'); return !!b && b.textContent.trim() === 'Studio' && !!b.querySelector('svg') && b.getAttribute('aria-label') === 'Open the Insight Studio'; }));
66
+ /* O0: the bar's Chat button opens the Studio on the dashboard shown (premium-topbar: the Studio is this page's chat) */
67
+ ok('O0 the bar has the Chat button, no label, named for the Studio (premium-topbar)', await p.evaluate(() => { const b = document.querySelector('#crAsk'); return !!b && b.textContent.trim() === '' && !!b.querySelector('svg') && b.getAttribute('aria-label') === 'Open the Insight Studio'; }));
68
68
  await open('#crAsk');
69
- ok('O0b the Studio pill opens the Studio', await p.evaluate(() => /^Insight Studio · /.test(document.querySelector('#dEye').textContent)));
69
+ ok('O0b Chat opens the Studio', await p.evaluate(() => /^Insight Studio · /.test(document.querySelector('#dEye').textContent)));
70
70
  await shut();
71
71
  /* O: New dashboard opens the Studio */
72
72
  await open('#pdNew');
@@ -168,7 +168,7 @@ const saved = async () => { const j = await (await fetch(BASE + '/api/insights-p
168
168
  await q.goto(BASE + '/premium-insights.html');
169
169
  await until(() => q.evaluate(() => !!document.querySelector('#pdNew')));
170
170
  const pill = await q.evaluate(() => { const b = document.querySelector('#crAsk'), r = b.getBoundingClientRect(); return { txt: b.textContent.trim(), w: r.width, h: r.height, right: r.right, vw: innerWidth, vis: !!b.offsetParent }; });
171
- ok(`F0 at 390 px (${theme}) the Studio pill shows its label, fits the width and is as tall as the crumb's other buttons`, pill.txt === 'Studio' && pill.vis && pill.right <= pill.vw && Math.round(pill.h) >= 34, JSON.stringify(pill));
171
+ ok(`F0 at 390 px (${theme}) the Chat button shows, fits the width and is 44 px`, pill.vis && pill.right <= pill.vw && Math.round(pill.h) >= 44 && Math.round(pill.w) >= 44, JSON.stringify(pill));
172
172
  await q.click('#pdNew'); await until(() => q.evaluate(() => !!document.querySelector('#oMain .stu'))); await sleep(400);
173
173
  // measured once the dialog has finished opening: its rise animation scales the targets while it runs
174
174
  const measure = () => q.evaluate(() => {
@@ -4,7 +4,7 @@
4
4
  * and the board's own presses of pm/premium-acts.js (initiative premium-board-actions): the New asks card, New initiative, and a row's menu (move,
5
5
  * hold, cancel, archive and their Undo). Issue it on a document draft, read in a dialog, is POST /api/core-docs/issue (initiative premium-core-doc-issue). */
6
6
  import { pmPost } from './http.js';
7
- import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, CHECK, AI, store, crumbHtml, wireCrumb, kv, H, openAddDoc } from './premium-shell.js';
7
+ import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, CHECK, AI, store, crumbHtml, wireCrumb, kv, H, openAddDoc, setPageGaps } from './premium-shell.js';
8
8
  import { issueBody } from './premium-doc-edit.js';
9
9
  import { mountDocSheet } from './premium-doc-sheet.js';
10
10
  import * as MT from './premium-metric-tiles.js';
@@ -30,10 +30,11 @@ function drawHead() {
30
30
  if (!crumbed) {
31
31
  crumbed = true;
32
32
  const boards = M.board.switcher || [];
33
- $('#crumbHost').innerHTML = crumbHtml({ board: M.board.name || 'Board', boards, ask: 'Ask about this board' });
33
+ $('#crumbHost').innerHTML = crumbHtml({ page: 'Board', board: M.board.name || 'Board', boards, ask: 'Ask about this board' });
34
34
  wireCrumb({ boards, board: M.board.id, goBoard: (ws, id) => location.assign('/premium-board.html?ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(id)), ask: () => openRow(rowOf('board:this-board')) });
35
35
  }
36
36
  $('#snap').textContent = M.header.text;
37
+ setPageGaps(((M.header && M.header.missing) || []).length);
37
38
  $('#snap').title = 'Every figure on this page comes from a record of the board. A date, owner or progress shows only when one was set.';
38
39
  $('#brief').textContent = '';
39
40
  }
@@ -6,7 +6,7 @@
6
6
  * premium-board-actions, pm/premium-acts.js): move to the next stage or back, hold, cancel, archive, resume, reopen and restore, each with Undo. Nothing here issues a document. */
7
7
  import { pmPost } from './http.js';
8
8
  import { mountDocSheet } from './premium-doc-sheet.js';
9
- import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, kv, H2, CHECK, CHEV, crumbHtml, wireCrumb, AI, openAddDoc } from './premium-shell.js';
9
+ import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, kv, H2, CHECK, CHEV, crumbHtml, wireCrumb, AI, openAddDoc, setPageGaps } from './premium-shell.js';
10
10
  import { barHtml, onBar, closeMenu } from './premium-acts.js';
11
11
 
12
12
  let M = null; // the model
@@ -257,6 +257,7 @@ function draw() {
257
257
  }
258
258
  $('#iH1').textContent = M.title; document.title = 'PMOS · ' + M.title;
259
259
  $('#snap').textContent = M.header.text;
260
+ setPageGaps(((M.header && M.header.missing) || []).length);
260
261
  $('#snap').title = 'Every figure on this page comes from a record. A date, owner or progress shows only when one was set.';
261
262
  const keepQ = $('#dmQ') && document.activeElement === $('#dmQ');
262
263
  closeMenu();
@@ -6,7 +6,7 @@
6
6
  * draft, PRD R2 to R4). premium-studio-chart adds a saved chart (POST /api/premium-charts/save, PRD C1, C10) and its four forms (C3). premium-studio-report
7
7
  * adds New report and Shape it in the Studio, whose presses are POST /api/report-setups/setup | from-dashboard and POST /api/report-structure/turn | remove |
8
8
  * revert | accept (PRD R5 to R8). Nothing else posts, and nothing is sent outward. */
9
- import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv } from './premium-shell.js';
9
+ import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv, setPageGaps } from './premium-shell.js';
10
10
  import { pmPost, pmGet } from './http.js';
11
11
  import { openStudio } from './premium-studio.js';
12
12
  import { openReport } from './premium-report-read.js';
@@ -28,10 +28,11 @@ function drawHead() {
28
28
  if (!crumbed) {
29
29
  crumbed = true;
30
30
  const boards = M.board.switcher || [];
31
- $('#crumbHost').innerHTML = crumbHtml({ board: M.board.name || 'Insights', boards, ask: 'Open the Insight Studio', label: 'Studio' });
31
+ $('#crumbHost').innerHTML = crumbHtml({ page: 'Insights', board: M.board.name || 'Insights', boards, ask: 'Open the Insight Studio' });
32
32
  wireCrumb({ boards, board: M.board.id, goBoard: (ws, id) => location.assign('/premium-insights.html?ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(id)), ask: () => { const D = curDash(); if (D && D.saved) openDashEdit(D); else if (M.charts.length) openDashEdit(null); else openReportEdit(null); } }); // the mockup's Studio pill: the saved dashboard shown, else a new dashboard, else a report when no measure has a series
33
33
  }
34
34
  $('#snap').textContent = M.header.text;
35
+ setPageGaps(((M.header && M.header.missing) || []).length);
35
36
  $('#snap').title = 'Every figure on this page comes from a KR metric record. A measure with fewer than two readings is listed, not drawn.';
36
37
  $('#brief').textContent = M.empty || '';
37
38
  }
@@ -42,12 +42,12 @@ export function weekView(r, today) {
42
42
  initiatives: (Array.isArray(r.gantt) ? r.gantt : []).filter((g) => g && g.id).slice(0, 60).map((g) => ({ id: g.id, name: clip(g.title || g.id, 70) })) };
43
43
  }
44
44
 
45
- /* ── the Calendar card shared by the Briefing and My work (initiative premium-calendar-card): the day strip, its summary line and the chevron ── */
45
+ /* ── the Briefing's Calendar card (initiative premium-calendar-card; My work has none, A1): the day strip, its summary line and the chevron ── */
46
46
  const weekKeys = (today) => {
47
47
  const [y, m, d] = today.split('-').map(Number), wd = (new Date(Date.UTC(y, m - 1, d)).getUTCDay() + 6) % 7;
48
48
  return [0, 1, 2, 3, 4].map((i) => new Date(Date.UTC(y, m - 1, d - wd + i)).toISOString().slice(0, 10));
49
49
  };
50
- /** Monday to Friday, in the shape lib/my-work-premium.js weekOf draws: meeting minutes from the week answer `W` (weekView), done and due counts from the PM's
50
+ /** Monday to Friday: meeting minutes from the week answer `W` (weekView), done and due counts from the PM's
51
51
  * list `items` (GET /api/pm-items). With no calendar the days still carry the list's counts and `calendar` is false. */
52
52
  export function stripOf(W, items, today) {
53
53
  const ok = !!(W && W.state === 'ok'), its = Array.isArray(items) ? items : [];
@@ -60,7 +60,7 @@ export function stripOf(W, items, today) {
60
60
  });
61
61
  return { days, calendar: ok };
62
62
  }
63
- /** The strip: one button per day, the picked one pressed. Its look is the My work This week card's (meeting bar, done and due blocks). */
63
+ /** The strip: one button per day, the picked one pressed. Meeting bar, done and due blocks, as PR 878 drew them. */
64
64
  export function stripHtml(S, picked, esc) {
65
65
  const top = Math.max(60, ...S.days.map((d) => d.meet_min));
66
66
  const blk = (n, c) => Array.from({ length: Math.min(n, 3) }, () => `<i class="${c}"></i>`).join('');
@@ -1,6 +1,7 @@
1
1
  /* pm/premium-shell.js — what the premium Briefing and My work pages share: the theme, the toast, the standard dialog and the read-only agent's conversation (initiatives briefing-premium and my-work-premium). */
2
2
  import { pmGet, pmPost } from './http.js';
3
3
  import { recChipView, STOP_LINE } from './premium-meeting.js';
4
+ import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
4
5
  export const $ = (s, r = document) => r.querySelector(s);
5
6
  export const $$ = (s, r = document) => [...r.querySelectorAll(s)];
6
7
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
@@ -17,10 +18,142 @@ export function theme(t) {
17
18
  export function flip() {
18
19
  const dark = document.documentElement.dataset.theme ? document.documentElement.dataset.theme === 'dark' : matchMedia('(prefers-color-scheme: dark)').matches;
19
20
  const next = dark ? 'light' : 'dark';
20
- theme(next); store.set(THEME_KEY, next);
21
+ theme(next); store.set(THEME_KEY, next); tbTheme();
21
22
  }
22
23
  { const t = new URLSearchParams(location.search).get('theme') || store.get(THEME_KEY); theme(t); }
23
- $('#theme').onclick = flip; $('#theme2').onclick = flip;
24
+ /* ── the top bar (initiative premium-topbar): where you are and Chat on the left; the Sources chip, the bell and one menu on the right.
25
+ * The menu holds what left the bar: Search, Agent sessions, Console, Theme, Settings, and on Board how an initiative opens. Every item keeps
26
+ * the id the pages and the code below wire, so a press does what it did as a round button. ── */
27
+ export const CHAT = '<svg class="i" viewBox="0 0 24 24"><path d="M4 5h16v11h-9l-5 4v-4H4z"/><path d="M12 7.6l.8 1.9 1.9.8-1.9.8-.8 1.9-.8-1.9-1.9-.8 1.9-.8z"/></svg>';
28
+ const MORE = '<svg class="i" viewBox="0 0 24 24"><circle cx="6" cy="12" r="1.3"/><circle cx="12" cy="12" r="1.3"/><circle cx="18" cy="12" r="1.3"/></svg>';
29
+ const TH = [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']];
30
+ function tbMount() {
31
+ const t = $('.tools-top'); if (!t || $('#tbMore')) return;
32
+ const pc = $('#pgChat'); if (pc) pc.innerHTML = CHAT;
33
+ t.insertAdjacentHTML('beforeend', `<button type="button" class="schip" id="srcChip" aria-haspopup="dialog" title="When each source was last read"><i class="sdot" id="srcDot" aria-hidden="true"></i>Sources</button>`
34
+ + `<span class="mwrap" id="tbMore"><button type="button" class="glass round" id="moreBtn" aria-haspopup="menu" aria-expanded="false" aria-controls="moreMenu" aria-label="More" title="More">${MORE}<i class="mdot" id="moreDot" hidden></i></button>`
35
+ + '<div class="crmenu tbmenu" id="moreMenu" role="menu" aria-label="More" hidden>'
36
+ + '<button role="menuitem" id="pvSearch" aria-haspopup="dialog">Search<em>Ctrl K</em></button>'
37
+ + '<button role="menuitem" id="srcItem" class="tbm-src" aria-haspopup="dialog">Sources</button>'
38
+ + '<button role="menuitem" id="sessBtn" aria-haspopup="dialog" aria-label="Agent sessions">Agent sessions<em id="sessBdg" hidden></em></button>'
39
+ + '<a role="menuitem" id="toConsole" href="/console.html" aria-label="Open the console">Console</a>'
40
+ + '<div class="tbrow" id="modeRow" hidden><span>Open initiatives</span></div>'
41
+ + `<div class="tbrow" role="group" aria-label="Theme"><span>Theme</span><span class="tbseg" id="tbTheme">${TH.map(([k, w]) => `<button role="menuitemradio" data-th="${k}" aria-checked="false">${w}</button>`).join('')}</span></div>`
42
+ + '<button role="menuitem" id="settingsBtn" aria-haspopup="dialog">Settings</button></div></span>');
43
+ const ms = $('#modeSeg'); if (ms) { $('#modeRow').appendChild(ms); $('#modeRow').hidden = false; }
44
+ tbTheme();
45
+ const btn = $('#moreBtn'), menu = $('#moreMenu');
46
+ const items = () => $$('#moreMenu [role^="menuitem"]').filter((x) => x.offsetParent !== null || x.closest('.tbseg'));
47
+ const close = (back) => { if (menu.hidden) return; menu.hidden = true; btn.setAttribute('aria-expanded', 'false'); if (back) btn.focus(); };
48
+ btn.onclick = (e) => {
49
+ e.stopPropagation();
50
+ if (!menu.hidden) { close(); return; }
51
+ menu.hidden = false; btn.setAttribute('aria-expanded', 'true');
52
+ if ($('#modeSeg', menu)) pillOf($('#modeSeg', menu));
53
+ const f = items()[0]; if (f) f.focus();
54
+ };
55
+ // capture: the menu closes and focus goes back to its button before the item's own press runs, so a dialog it opens returns focus there
56
+ menu.addEventListener('click', (e) => {
57
+ const th = e.target.closest('[data-th]');
58
+ if (th) { const v = th.dataset.th; theme(v === 'auto' ? null : v); store.set(THEME_KEY, v === 'auto' ? '' : v); tbTheme(); return; }
59
+ if (e.target.closest('#modeRow')) return;
60
+ if (e.target.closest('[role="menuitem"]')) close(true);
61
+ }, true);
62
+ document.addEventListener('click', (e) => { if (!e.target.closest('#tbMore')) close(); });
63
+ menu.addEventListener('keydown', (e) => {
64
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(true); return; }
65
+ if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
66
+ const L = items(), i = L.indexOf(document.activeElement); if (!L.length) return;
67
+ e.preventDefault(); L[(i + (e.key === 'ArrowDown' ? 1 : L.length - 1) + (i < 0 ? 1 : 0)) % L.length].focus();
68
+ });
69
+ $('#srcChip').onclick = () => openSources(); $('#srcItem').onclick = () => openSources();
70
+ if (pc) pc.onclick = () => { if (PAGE_CHAT) PAGE_CHAT(); };
71
+ tbReadSrc();
72
+ setInterval(() => { if (!document.hidden) tbReadSrc(); }, 300000);
73
+ }
74
+ function tbTheme() {
75
+ const cur = document.documentElement.dataset.theme || 'auto';
76
+ $$('#tbTheme [data-th]').forEach((b) => b.setAttribute('aria-checked', String(b.dataset.th === cur)));
77
+ }
78
+ let PAGE_CHAT = null;
79
+ /** The page's Chat press: fn opens the page's conversation (the Briefing and My work), the board's or the initiative's, or the Studio. */
80
+ export function onPageChat(fn) { PAGE_CHAT = fn; }
81
+
82
+ /* ── Sources: when each source was last read, and a Refresh for each (GET /api/sources, POST /api/sources/refresh, as Data freshness) ──
83
+ * The chip says no time: each source is read on its own schedule, so only the dialog's rows carry times. Its dot is orange when a source is
84
+ * old, failed or never read, or when the page itself could not read something (setPageGaps). A page adds its own part with sourcesHook. */
85
+ const TB = { src: null, gaps: 0, extra: null, msg: '', busy: false };
86
+ const SSTATE = { fresh: 'Recent', stale: 'Old', never: 'Never read', building: 'Reading now', failed: 'Failed', off: 'Off' };
87
+ const wsQ = () => { const w = new URLSearchParams(location.search).get('ws'); return w ? '?ws=' + encodeURIComponent(w) : ''; };
88
+ async function tbReadSrc() {
89
+ const r = await pmGet('/api/sources' + wsQ());
90
+ TB.src = r && r.ok && Array.isArray(r.sources) ? r : { ok: false, sources: [] };
91
+ tbDot();
92
+ return TB.src;
93
+ }
94
+ function tbDot() {
95
+ const d = $('#srcDot'), c = $('#srcChip'); if (!d || !c) return;
96
+ const behind = TB.src && TB.src.ok ? behindOf(lineItems(TB.src.sources)) : [];
97
+ const n = behind.length + TB.gaps, known = TB.src && TB.src.ok;
98
+ d.className = 'sdot ' + (n || (TB.src && !TB.src.ok) ? 'warn' : known ? 'ok' : '');
99
+ c.title = TB.src && !TB.src.ok ? 'The sources could not be read' : n ? [behind.length ? behind.map((b) => b.text).join(', ') : '', TB.gaps ? TB.gaps + (TB.gaps === 1 ? ' source this page could not read' : ' sources this page could not read') : ''].filter(Boolean).join(' · ') : known ? 'Every source was read recently' : 'Reading the sources';
100
+ }
101
+ /** n: how many sources the page itself could not read (its header's missing list). */
102
+ export function setPageGaps(n) { TB.gaps = n || 0; tbDot(); }
103
+ /** h: { html() → the page's own part of Sources, mount() after it is drawn, refresh() → what Refresh all also reads again }. */
104
+ export function sourcesHook(h) { TB.extra = h; }
105
+ function park() { $$('#oMain [data-park]').forEach((x) => { const p = document.getElementById(x.dataset.park); if (p) p.appendChild(x); }); }
106
+ const srcRow = (s) => {
107
+ const cls = s.state === 'fresh' ? 'ok' : s.state === 'stale' || s.state === 'failed' || s.state === 'never' ? 'warn' : '';
108
+ const when = s.id === 'repository' && s.state === 'fresh' ? 'watched for changes' : s.as_of ? 'read ' + whenRead(s.as_of) : 'never read';
109
+ const off = s.state === 'off' || s.state === 'building' || TB.busy;
110
+ return `<div class="sr"><span class="sn"><b><i class="sdot ${cls}" aria-hidden="true"></i>${esc(s.label)}</b><em>${esc(SSTATE[s.state] || s.state)}${s.as_of || s.id === 'repository' && s.state === 'fresh' ? ' · ' + esc(when) : ''}</em></span>${s.id === 'repository' ? '' : `<button type="button" class="cta alt" data-sref="${esc(s.id)}" aria-label="Refresh ${esc(s.label)}"${off ? ' disabled' : ''}>Refresh</button>`}</div>`;
111
+ };
112
+ let SPOLL = null;
113
+ export async function openSources() {
114
+ // the frame is drawn once; a re-read redraws only the rows, the button and the message, so the page's own part (the Briefing's picker) is left alone
115
+ const rowsHtml = () => { const s = TB.src; return !s ? '<p class="note">Reading the sources.</p>' : !s.ok ? '<p class="note err" role="alert">The sources could not be read.</p>' : s.sources.map(srcRow).join(''); };
116
+ const draw = () => {
117
+ if ($('#srcRows')) { $('#srcRows').innerHTML = rowsHtml(); $('#srcAll').disabled = TB.busy; $('#srcM').textContent = TB.msg; return; }
118
+ park();
119
+ $('#oMain').innerHTML = `<article class="paper doc"><div class="addf">
120
+ <div class="srctop"><p class="note" style="margin:0">Each source is read on its own schedule, not live. Each row says when it was last read.</p><button type="button" class="cta" id="srcAll"${TB.busy ? ' disabled' : ''}>Refresh all</button></div>
121
+ <div>${TB.extra ? '<span class="label">Sources</span>' : ''}<div id="srcRows">${rowsHtml()}</div></div>
122
+ ${TB.extra ? TB.extra.html() : ''}
123
+ <p class="note" id="srcM" role="status" style="margin:0;min-height:1.2em">${esc(TB.msg)}</p></div></article>`;
124
+ if (TB.extra && TB.extra.mount) TB.extra.mount();
125
+ };
126
+ const say = 'When each source was last read. Each one is read on its own schedule, so the rows say their own times.';
127
+ TB.msg = '';
128
+ openDlg({ eye: 'Sources', title: 'Sources', say, stream: turnA(ptx(say)), noteKey: null, pane: '<article class="paper doc"></article>', label: 'Sources' });
129
+ $('#askF').hidden = true; setMode('detail');
130
+ const poll = (n) => { clearTimeout(SPOLL); if (!n || !TB.src || !TB.src.ok || !TB.src.sources.some((x) => x.state === 'building')) return; SPOLL = setTimeout(async () => { if ($('#dTitle').textContent !== 'Sources' || !$('#dlg').classList.contains('on')) return; await tbReadSrc(); draw(); poll(n - 1); }, 3000); };
131
+ $('#oMain').onclick = async (e) => {
132
+ const one = e.target.closest('[data-sref]'), all = e.target.closest('#srcAll');
133
+ if ((!one && !all) || TB.busy || !TB.src || !TB.src.ok) return;
134
+ const ids = all ? refreshTargets(TB.src.sources) : [one.dataset.sref];
135
+ TB.busy = true; TB.msg = 'Starting.'; draw();
136
+ const got = await Promise.all(ids.map((id) => pmPost('/api/sources/refresh', { ws: TB.src.ws || '', source: id }).catch(() => null)));
137
+ let extra = null; if (all && TB.extra && TB.extra.refresh) extra = await TB.extra.refresh();
138
+ const bad = got.filter((r) => !r || !r.ok).length;
139
+ TB.busy = false;
140
+ TB.msg = (ids.length ? (bad ? bad + ' of ' + ids.length + ' did not start.' : ids.length === 1 ? 'Reading it again.' : 'Reading ' + ids.length + ' sources again.') : '') + (extra ? ' ' + extra : '');
141
+ await tbReadSrc(); draw(); poll(8);
142
+ };
143
+ draw();
144
+ await tbReadSrc(); draw(); poll(8);
145
+ }
146
+
147
+ /* ── Chat on the Briefing and My work: the standard dialog, read-only, about the page as a whole (key src:this-page or work:this-page) ── */
148
+ export function openPageChat(key, page) {
149
+ const lead = (($('#brief') && $('#brief').textContent) || '').replace(/\s+/g, ' ').trim();
150
+ const say = 'Ask anything about this page. The agent reads the records the page shows and answers in words. It cannot change anything.';
151
+ openDlg({ eye: page, title: 'Ask about ' + page, say, stream: turnA(ptx(say)), noteKey: key, pane: `<article class="paper doc"><h3 class="d2">What the page says</h3><p>${esc(lead || 'The page has not read its records yet.')}</p></article>`, label: page });
152
+ $('#askIn').placeholder = 'Ask the agent about this page';
153
+ loadThread(key);
154
+ }
155
+ tbMount(); // the top bar first: the menu holds the Settings, Agent sessions, Console and Search items the code below wires
156
+ { const t2 = $('#theme2'); if (t2) t2.onclick = flip; }
24
157
  { const b = $('#settingsBtn'); if (b) b.onclick = () => openSettings(); } // hoisted: the function below is declared, not assigned
25
158
 
26
159
  /* ── toast ──────────────────────────────────────────────────────────────────────────────────────────────── */
@@ -32,6 +165,7 @@ export const kv = (rows) => `<div class="kv2">${rows.filter((r) => r && r[1]).ma
32
165
  export const H = (t) => `<h3 class="h2">${esc(t)}</h3>`;
33
166
  export function openDlg(o) {
34
167
  S.key = o.noteKey || null;
168
+ park(); // a page's own control lent to the dialog (the Briefing's product picker) goes home before the pane is replaced
35
169
  const ae = document.activeElement; if (ae && ae !== document.body) lastFocus = ae;
36
170
  $$('.rail,main.stage,#dock').forEach((x) => { x.inert = true; });
37
171
  $('#dlg').inert = false; document.documentElement.style.overflow = 'hidden';
@@ -45,6 +179,7 @@ export function openDlg(o) {
45
179
  }
46
180
  export function closeDlg() {
47
181
  clearTimeout(threadTimer); S.key = null;
182
+ park();
48
183
  $('#veil').classList.remove('on'); $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; });
49
184
  $('#dlg').inert = true; document.documentElement.style.overflow = ''; $('#dlg').classList.remove('on');
50
185
  $('#dock').inert = !document.body.classList.contains('docked');
@@ -188,10 +323,15 @@ export function wireRail(here) {
188
323
  $$('.rail [data-go]').forEach((b) => { b.onclick = () => { if (b.dataset.go !== here) location.assign(GO[b.dataset.go]); }; });
189
324
  }
190
325
 
191
- /* ── the crumb: where you are, a menu to switch board or initiative, and the sparkle that opens the read-only agent ──────────────────── */
326
+ /* ── the crumb: where you are, a menu to switch board or initiative, and Chat, which opens the read-only agent ──────────────────── */
192
327
  export function crumbHtml(o) {
193
328
  const chev = (id, label, show) => `<button id="${id}" class="cri" aria-haspopup="menu" aria-expanded="false" aria-label="${esc(label)}"${show ? '' : ' hidden'}>${CHEV}</button>`;
194
- return `<nav class="crumb" aria-label="Where you are"><button id="crBoard"${o.ini ? '' : ' aria-current="page" disabled'}>${esc(o.board)}</button>${chev('crSw', 'Switch board', o.boards && o.boards.length > 1)}${o.ini ? `<span aria-hidden="true">›</span><span id="crIni" aria-current="page">${esc(o.ini)}</span>${chev('crSw2', 'Switch initiative', o.siblings && o.siblings.length > 1)}` : ''}<button id="crAsk" class="cri crask${o.label ? ' crst' : ''}" aria-label="${esc(o.ask)}">${AI}${o.label ? esc(o.label) : ''}</button><div id="crMenu" class="crmenu" role="menu" hidden></div></nav>`;
329
+ const menu = '<div id="crMenu" class="crmenu" role="menu" hidden></div>';
330
+ // an initiative: a round back button to its board, then one pill with its name and the switcher; a board page: the page, the board and its switcher
331
+ const left = o.ini
332
+ ? `<button id="crBoard" class="glass round crback" aria-label="Back to ${esc(o.board)}" title="Back to ${esc(o.board)}"><svg class="i" viewBox="0 0 24 24"><path d="m14 6-6 6 6 6"/></svg></button><nav class="crumb" aria-label="Where you are"><span id="crIni" aria-current="page">${esc(o.ini)}</span>${chev('crSw2', 'Switch initiative', o.siblings && o.siblings.length > 1)}${menu}</nav>`
333
+ : `<nav class="crumb" aria-label="Where you are">${o.page ? `<span class="crpg">${esc(o.page)}</span>` : ''}<button id="crBoard" aria-current="page" disabled>${esc(o.board)}</button>${chev('crSw', 'Switch board', o.boards && o.boards.length > 1)}${menu}</nav>`;
334
+ return `<div class="where">${left}<button id="crAsk" class="round tbchat" aria-haspopup="dialog" aria-label="${esc(o.ask)}" title="${esc(o.ask)}">${CHAT}</button></div>`;
195
335
  }
196
336
  /** o: { boards: [{ws,id,name}], board: id, siblings: [{id,title}], ini: id, goBoard(ws, id), goIni(id), ask() }. Escape and a click outside close the menu; the arrows move in it. */
197
337
  export function wireCrumb(o) {
@@ -262,8 +402,8 @@ const pvQ = (sep) => (PV_WS ? sep + 'ws=' + encodeURIComponent(PV_WS) : '');
262
402
  async function pvGet(u) { try { const r = await fetch(u, { credentials: 'same-origin' }); return { status: r.status, j: await r.json() }; } catch { return { status: 0, j: null }; } }
263
403
  const pvOv = { kind: null, back: null, at: 0, list: [], pal: null, need: null };
264
404
  function pvMount() {
265
- const a = $('#toConsole'); if (!a || $('#pvSearch')) return;
266
- a.insertAdjacentHTML('beforebegin', `<button class="glass round" id="pvSearch" aria-haspopup="dialog" aria-label="Search (Ctrl K)" title="Search (Ctrl K)">${SRCH}</button><button class="glass round pv-hp" id="pvBell" aria-haspopup="dialog" aria-label="Needs you" title="Needs you">${BELL}<span class="pv-bdg" id="pvBdg" hidden></span></button>`);
405
+ const a = $('#tbMore'); if (!a || $('#pvBell')) return;
406
+ a.insertAdjacentHTML('beforebegin', `<button class="glass round pv-hp" id="pvBell" aria-haspopup="dialog" aria-label="Needs you" title="Needs you">${BELL}<span class="pv-bdg" id="pvBdg" hidden></span></button>`);
267
407
  document.body.insertAdjacentHTML('beforeend', '<div class="pv-scrim" id="pvScrim"></div><div class="pv-ov" id="pvOv" role="dialog" aria-modal="true" hidden inert></div>');
268
408
  $('#pvSearch').onclick = () => pvOpen('pal'); $('#pvBell').onclick = () => pvOpen('bell'); $('#pvScrim').onclick = pvClose;
269
409
  pvNeeds();
@@ -277,7 +417,7 @@ export function pvClose() {
277
417
  function pvOpen(kind) {
278
418
  if (pvOv.kind === kind) { pvClose(); return; }
279
419
  if (pvOv.kind) pvClose();
280
- const ae = document.activeElement; pvOv.back = ae && ae !== document.body ? ae : $(kind === 'pal' ? '#pvSearch' : '#pvBell');
420
+ const ae = document.activeElement; pvOv.back = ae && ae !== document.body ? ae : $(kind === 'pal' ? '#moreBtn' : '#pvBell');
281
421
  pvOv.kind = kind; pvOv.at = 0;
282
422
  $$('.rail,main.stage,#dock').forEach((x) => { x.inert = true; }); document.documentElement.style.overflow = 'hidden';
283
423
  const o = $('#pvOv'); o.className = 'pv-ov ' + kind; o.setAttribute('aria-label', kind === 'pal' ? 'Search' : 'Needs you'); o.hidden = false; o.inert = false; $('#pvScrim').classList.add('on');
@@ -3,10 +3,9 @@
3
3
  * Every press goes to the Work page's own route under /api/pm-items, /api/pm-jobs or /api/my-work; this file adds no writer. A control with nothing honest to write stays off and says why.
4
4
  * My work depth (initiative premium-work-depth): the dialog's tool row (Edit, Who does each step, Not before, Someday), the Focus bar and its jobs, the agent on an item
5
5
  * (draft, stop, edit, post after a confirm, send back, try again), and keys and swipe on the rows. */
6
- import { pmPost, pmGet } from './http.js';
7
- import { weekView, stripHtml, foldLine, mountFold } from './premium-meeting.js';
6
+ import { pmPost } from './http.js';
8
7
  import { mdRender } from './markdown.js';
9
- import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, turnU, ptx, CHECK, RM, S } from './premium-shell.js';
8
+ import { $, $$, esc, openDlg, closeDlg, setMode, toast, loadThread, onScroll, wireRail, logHtml, turnA, turnU, ptx, CHECK, RM, S, setPageGaps, onPageChat, openPageChat } from './premium-shell.js';
10
9
 
11
10
  let M = null; // the model
12
11
  let openR = null; // the row whose dialog is open
@@ -35,6 +34,7 @@ function drawHero() {
35
34
  $('#date').textContent = M.date;
36
35
  $('#brief').innerHTML = M.hero.map((s) => s.parts.map((p) => (p.s ? `<span class="k">${esc(p.t)}</span>` : esc(p.t))).join('')).join(' ');
37
36
  $('#snap').textContent = M.header.text;
37
+ setPageGaps(((M.header && M.header.missing) || []).length);
38
38
  $('#snap').title = 'Every figure on this page comes from an item on your list. A date shows only when one was set.';
39
39
  }
40
40
  function drawDock() { $('#dN').textContent = M.dock.needs; $('#dLab').textContent = M.dock.needs === 0 ? 'to clear' : M.dock.label; $('#dNext').innerHTML = M.dock.next ? `<i></i>Next <b>${esc(M.dock.next)}</b>` : 'Nothing more on your list'; }
@@ -120,31 +120,7 @@ $('#frBody').addEventListener('click', (e) => {
120
120
  const st = M.friday.steps.find((x) => x.key === b.dataset.fr); const r = st && st.first ? rowOf(st.first) : null;
121
121
  if (r) openRow(r); else toast('Nothing to open here.');
122
122
  });
123
- /* the Calendar card (initiative premium-calendar-card): the strip from this page's model, the picked day's meetings from GET /api/calendar-views (read-only here), a chevron */
124
- let wkPick = null, WK = null, wkFold = null;
125
- const wkToday = () => (M && M.today) || new Date().toISOString().slice(0, 10);
126
- async function readWk() {
127
- const w = new URLSearchParams(location.search).get('ws');
128
- WK = weekView(await pmGet('/api/calendar-views?view=week&date=' + wkToday() + (w ? '&ws=' + encodeURIComponent(w) : '')), wkToday());
129
- drawWeek();
130
- }
131
- function drawWeek() {
132
- const W = M.week; if (!W) return;
133
- if (!wkFold) wkFold = mountFold($('#weekCard'), 'work');
134
- const pick = wkPick || wkToday(), S = { days: W.days.map((d) => ({ ...d, meetings: d.meetings || 0 })), calendar: W.calendar };
135
- $('#weekCap').textContent = W.cap;
136
- $('#weekBody').innerHTML = stripHtml(S, pick, esc);
137
- $('#weekNote').textContent = W.note;
138
- wkFold.line(S, foldLine(S, WK), esc);
139
- const x = WK && WK.state === 'ok' ? WK.days.find((y) => y.key === pick) : null;
140
- const due = (M.rows || []).filter((r) => r.edit && r.edit.due === pick && r.list !== 'done');
141
- $('#wkList').innerHTML = !WK ? '<div class="empty">Reading the calendar PMOS holds.</div>' : WK.state === 'error' ? `<div class="empty" role="status">Calendar not read. ${esc(WK.reason)}</div>`
142
- : `<div class="wkd${x && x.today ? ' now' : ''}">${esc(x ? x.label : pick)}${x && x.today ? ' · today' : ''}<em>${x && x.rows.length ? x.rows.length + (x.rows.length === 1 ? ' meeting' : ' meetings') : ''}</em></div>`
143
- + due.map((r) => `<div class="wkdue" role="listitem"><span>Due</span><b>${esc(r.title)}</b></div>`).join('')
144
- + (x && x.rows.length ? x.rows.map((r) => `<div class="ev src-meeting${r.past || (x.today && Date.parse(r.end || r.at) < Date.now()) ? ' wkpast' : ''}" role="listitem"><time>${esc(r.time)}</time><span class="gl-t"><svg class="i" viewBox="0 0 24 24"><rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/></svg></span><span><b>${esc(r.title)}</b><span class="d">${esc([r.sub, r.about].filter(Boolean).join(' · ') || 'No other people listed')}</span></span></div>`).join('') : '<div class="empty">No meetings.</div>');
145
- }
146
- $('#weekBody').addEventListener('click', (e) => { const b = e.target.closest('[data-day]'); if (!b || !M) return; wkPick = b.dataset.day; drawWeek(); });
147
- function draw() { drawHero(); drawWeek(); drawFriday(); drawFocus(); drawQueue(); drawWaiting(); drawReview(); drawDock(); onScroll(); backFocus(); }
123
+ function draw() { drawHero(); drawFriday(); drawFocus(); drawQueue(); drawWaiting(); drawReview(); drawDock(); onScroll(); backFocus(); }
148
124
  const rowOf = (key) => (M && M.rows || []).find((r) => r.key === key) || null;
149
125
 
150
126
  /* ── the dialog: detail first, the presses of the Work page, the tool row, the agent, the read-only agent beside it ─────────────────── */
@@ -653,10 +629,10 @@ async function load() {
653
629
  }
654
630
  M = r.model; draw();
655
631
  openAsked();
656
- if (!WK) readWk();
657
632
  const mine = dlgOpen() && ((dlgKind === 'item' && openR && S.key === openR.key) || (dlgKind === 'fjobs' && S.key === 'focus:today'));
658
633
  if (mine && dlgKind === 'item') refreshOpen(); else if (mine) drawFocusDlg();
659
634
  }
660
635
  setInterval(() => { if (M && M.agents && M.agents.counts.running > 0 && !document.hidden) load(); }, 15000); // an agent's state changes without a press
636
+ onPageChat(() => openPageChat('work:this-page', 'My work')); // Chat in the top bar: the page as a whole (initiative premium-topbar)
661
637
  $('#brief').textContent = 'Reading your list.';
662
638
  load();
@@ -1531,8 +1531,7 @@ button.dsn:hover{box-shadow:inset 0 0 0 1.5px rgb(79,109,245)}
1531
1531
  .rsm .mchip{font-size:1.8cqw;margin:1.2cqw 0 1.6cqw;display:inline-block}
1532
1532
  .nrep .mhint{margin-bottom:10px}
1533
1533
  .rsg .mt1{margin:0;padding:0;background:none;box-shadow:none}
1534
- /* initiative page: the pill and the theme button sit under the crumb as the mockup draws them; long file names in the check evidence wrap */
1535
- .top:has(#iH1) .tools-top{flex-basis:100%;justify-content:flex-start}
1534
+ /* initiative page: long file names in the check evidence wrap */
1536
1535
  #cIniChk .ckr small{overflow-wrap:anywhere}
1537
1536
 
1538
1537
  /* search and the bell in the header (initiative premium-search-bell); the look is the mockup's overlays ov-pal and ov-bell */
@@ -2021,3 +2020,49 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2021
2020
  .wkdue span{font:600 var(--fs-2) var(--mono);letter-spacing:.06em;text-transform:uppercase;color:var(--ember-ink)}.wkdue b{font-weight:500}
2022
2021
  .tl.wkday{min-height:0}.tl.wkday .ev{cursor:default}
2023
2022
  #todayCard.wkm .foldb{margin-left:auto}
2023
+
2024
+ /* one top bar on every premium page (initiative premium-topbar): left = where you are + Chat; right = Sources chip, bell, one ⋯ menu */
2025
+ .top{flex-wrap:nowrap}
2026
+ .where{display:flex;align-items:center;gap:10px;min-width:0}
2027
+ .where .crumb{max-width:none;min-width:0}
2028
+ .tbchat{flex:none;background:var(--solid);color:var(--on-solid);border:0;box-shadow:0 10px 30px -10px rgba(20,22,31,.45)}
2029
+ .tbchat svg{width:19px;height:19px}
2030
+ #crBoard.crback{flex:none;width:44px;height:44px;padding:0;border-radius:50%;display:grid;place-items:center;background:var(--card);border:1px solid var(--hair);color:var(--ink);cursor:pointer}
2031
+ #crBoard.crback:hover{text-decoration:none;background:var(--well)}
2032
+ #crBoard.crback svg{width:20px;height:20px}
2033
+ .crumb .crpg{color:var(--ink);font-weight:600;padding:0 4px 0 12px}
2034
+ .top .tools-top{flex-wrap:nowrap;justify-content:flex-end;flex:none}
2035
+ .schip{height:44px;display:inline-flex;align-items:center;gap:8px;padding:0 14px;border-radius:999px;background:var(--card);border:1px solid var(--hair);font:500 var(--t-micro) var(--mono);color:var(--ink-2);flex:none}
2036
+ .schip:hover{background:var(--well)}
2037
+ .sdot{width:8px;height:8px;border-radius:50%;background:var(--ink-3);flex:none;display:inline-block}
2038
+ .sdot.ok{background:var(--ok)}
2039
+ .sdot.warn{background:var(--ember)}
2040
+ .sr .sn b{display:inline-flex;align-items:center;gap:8px}
2041
+ .srctop{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
2042
+ .mwrap{position:relative;display:inline-flex}
2043
+ .mdot{position:absolute;top:2px;right:2px;width:10px;height:10px;border-radius:50%;background:var(--ember);border:2px solid var(--card-solid)}
2044
+ .mdot[hidden]{display:none}
2045
+ .crmenu.tbmenu{left:auto;right:0;min-width:300px;z-index:45}
2046
+ .crmenu.tbmenu > button,.crmenu.tbmenu > a{height:44px}
2047
+ .crmenu .seg button{width:auto;height:38px;padding:0 12px;font-size:var(--fs-2);font-weight:600}
2048
+ .tbrow > span:first-child{white-space:nowrap}
2049
+ .crmenu a{display:flex;align-items:center;height:42px;padding:0 14px;border-radius:14px;font-weight:500;font-size:var(--fs-3);color:inherit;text-decoration:none}
2050
+ .crmenu a:hover,.crmenu a:focus-visible{background:var(--well)}
2051
+ .tbrow{display:flex;align-items:center;gap:10px;min-height:44px;padding:0 6px 0 14px;font-weight:500;font-size:var(--fs-3);border-top:1px solid var(--hair);margin-top:4px}
2052
+ .tbrow[hidden]{display:none}
2053
+ .tbrow + .tbrow{border-top:0;margin-top:0}
2054
+ .tbrow > .seg,.tbseg{margin-left:auto}
2055
+ .tbseg{display:inline-flex;padding:3px;border-radius:999px;background:var(--well);gap:2px}
2056
+ .crmenu .tbseg button{height:38px;width:auto;padding:0 11px;border-radius:999px;font-size:var(--fs-2);font-weight:600;color:var(--ink-2)}
2057
+ .crmenu .tbseg button[aria-checked="true"]{background:var(--solid);color:var(--on-solid)}
2058
+ .tbrow + #settingsBtn{border-top:1px solid var(--hair);border-radius:0 0 14px 14px;margin-top:4px}
2059
+ .crmenu .tbm-src{display:none}
2060
+ #oMain .pkw .pkmenu{left:0;right:auto}
2061
+ #oMain .pkmenu button{height:44px;min-height:44px;box-sizing:border-box}
2062
+ @media (max-width:700px){
2063
+ #srcChip{display:none}
2064
+ .crmenu .tbm-src{display:flex}
2065
+ .where .crumb:has(.crpg) #crBoard{display:none}
2066
+ .where #crIni{max-width:calc(100vw - 316px)}
2067
+ .top .tools-top{gap:8px}
2068
+ }
@@ -9,7 +9,7 @@ import { mountFirst } from './premium-first.js';
9
9
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
10
10
  import { consoleReads, briefOf, needsListOf } from './premium-brief.js';
11
11
  import { momentOf, inText } from './c3-phone-model.js';
12
- import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail, pvFeed } from './premium-shell.js';
12
+ import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail, pvFeed, setPageGaps, sourcesHook, onPageChat, openPageChat } from './premium-shell.js';
13
13
  const ICON = {
14
14
  meeting: '<rect x="4" y="5" width="16" height="15" rx="3"/><path d="M4 10h16M9 3v4M15 3v4"/>',
15
15
  merge: '<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="9" r="2"/><path d="M6 8v8M18 11c0 4-6 3-12 5"/>',
@@ -60,6 +60,7 @@ function drawHero() {
60
60
  if (shownBrief == null) $('#brief').innerHTML = M.hero.map((s) => s.parts.map((p) => (p.s ? `<span class="k">${esc(p.t)}</span>` : esc(p.t))).join('')).join(' ');
61
61
  drawConsoleBrief();
62
62
  $('#snap').textContent = M.header.text;
63
+ setPageGaps(M.header.sources ? M.header.sources.filter((x) => x.state === 'not-read').length : (M.header.missing || []).length);
63
64
  $('#snap').title = M.header.missing.length ? 'A source that cannot be read adds nothing. It is named here, and the page does not guess.' : 'Every figure on this page comes from a record in the repository.';
64
65
  }
65
66
 
@@ -947,34 +948,26 @@ async function load() {
947
948
  else if (r.pending) setTimeout(load, 3000);
948
949
  else if (r.refreshing) setTimeout(load, 10000);
949
950
  }
950
- /* ── Refresh and Sources, beside the Real data line: read the repositories again now, and see which source was read, which was not, and why ── */
951
- const RDST = { read: ['fresh', 'Read'], 'not-read': ['failed', 'Not read'], 'not-included': ['off', 'Not included'], off: ['off', 'Off'] };
951
+ /* ── the Briefing's part of Sources (initiative premium-topbar): the products it reads, what it could not read and why, and Refresh all
952
+ * also reads the included repositories again. The product picker is the header's own control, lent to the dialog while it is open. ── */
953
+ const RDST = { read: ['ok', 'Read'], 'not-read': ['warn', 'Not read'], 'not-included': ['', 'Not included'], off: ['', 'Off'] };
952
954
  function sourcesHtml() {
953
955
  const L = (M && M.header && M.header.sources) || [];
954
- if (!L.length) return '<p class="note">The Briefing has not read anything yet.</p>';
955
- const bad = L.filter((x) => x.state === 'not-read').length;
956
- return `<div class="bd-top"><p>${bad ? bad + (bad === 1 ? ' source was' : ' sources were') + ' not read. Each reason is below.' : 'Every source was read.'}</p></div>`
957
- + L.map((x) => { const [c, w] = RDST[x.state] || ['off', x.state]; return `<div class="bd-src"><span><b>${esc(x.name)}</b><small><span class="bd-st ${c}">${w}</span></small><small>${esc(x.reason)}</small></span></div>`; }).join('')
958
- + '<p class="note">Refresh reads the included repositories again. Mail, Jira and the calendar are read by skills: refresh them under Around you, Data freshness.</p>';
959
- }
960
- async function pressRefresh(btn) {
961
- if (btn.disabled) return;
962
- btn.disabled = true; btn.textContent = 'Refreshing';
956
+ const rows = !L.length ? '<p class="note">The Briefing has not read anything yet.</p>'
957
+ : L.map((x) => { const [c, w] = RDST[x.state] || ['', x.state]; return `<div class="sr"><span class="sn"><b><i class="sdot ${c}" aria-hidden="true"></i>${esc(x.name)}</b><em>${esc(w)}${x.reason ? ' · ' + esc(x.reason) : ''}</em></span></div>`; }).join('');
958
+ return `<div id="pkSlot"></div><div><span class="label">What the Briefing read</span>${rows}</div>`;
959
+ }
960
+ async function refreshRepos() {
963
961
  const ws = new URLSearchParams(location.search).get('ws');
964
962
  const r = await pmPost('/api/briefing-premium/refresh' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), {});
965
- if (!r || !r.ok) { btn.disabled = false; btn.textContent = 'Refresh'; toast('Refresh did not start: ' + ((r && r.error) || 'the server did not answer') + '.'); return; }
966
- toast(r.started && r.started.length ? 'Reading again: ' + r.started.join(', ') + '.' : r.already && r.already.length ? 'Already reading ' + r.already.join(', ') + '.' : 'No repository is included, so there is nothing to read.');
967
- clearTimeout(RTIMER); RTIMER = setTimeout(async () => { await load(); btn.disabled = false; btn.textContent = 'Refresh'; }, 4000);
963
+ if (!r || !r.ok) return 'The repositories were not read again: ' + ((r && r.error) || 'the server did not answer') + '.';
964
+ clearTimeout(RTIMER); RTIMER = setTimeout(load, 4000);
965
+ return r.started && r.started.length ? 'Reading again: ' + r.started.join(', ') + '.' : r.already && r.already.length ? 'Already reading ' + r.already.join(', ') + '.' : 'No repository is included.';
968
966
  }
969
967
  let RTIMER = null;
970
- (function mountReal() {
971
- const snap = $('#snap'); if (!snap) return;
972
- const w = document.createElement('span'); w.className = 'rdbtns';
973
- w.innerHTML = '<button type="button" class="fchip" id="rdRefresh" title="Read the included repositories again now">Refresh</button><button type="button" class="fchip" id="rdSources" aria-haspopup="dialog" title="Which source was read, which was not, and why">Sources</button>';
974
- snap.insertAdjacentElement('afterend', w);
975
- $('#rdRefresh').addEventListener('click', (e) => pressRefresh(e.currentTarget));
976
- $('#rdSources').addEventListener('click', () => bdDlg('rd', 'Sources · real data', 'What the Briefing read', 'Which source was read, which was not, and why', M ? 'Each source below says whether it was read and, when it was not, the reason.' : 'The Briefing has not read anything yet.', sourcesHtml, () => {}));
977
- })();
968
+ $('#pkw').dataset.park = 'pkPark';
969
+ sourcesHook({ html: sourcesHtml, mount: () => { const slot = $('#pkSlot'), w = $('#pkw'); if (slot && w) slot.appendChild(w); }, refresh: refreshRepos });
970
+ onPageChat(() => openPageChat('src:this-page', 'the Briefing'));
978
971
  $('#brief').textContent = 'Reading the repository.';
979
972
  load();
980
973
  mountFirst(); // the "Your first Briefing" card, only when the page was opened with first=<import id> (initiative premium-welcome)
@@ -33,12 +33,8 @@
33
33
  <main class="stage" id="stage">
34
34
  <header class="top rise" style="--d:0">
35
35
  <h1 class="vh">Board</h1><div id="crumbHost"></div>
36
- <div class="tools tools-top"><span class="snap" id="snap">Reading the board</span>
37
- <span class="seg modeseg" id="modeSeg" role="group" aria-label="How an initiative opens"><i class="pill"></i><button data-m="page" aria-pressed="true">Page</button><button data-m="popup" aria-pressed="false">Popup</button></span>
38
- <a class="glass round" id="toConsole" href="/console.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
39
- <button class="glass round sbtn" id="sessBtn" aria-haspopup="dialog" aria-label="Agent sessions" title="Agent sessions"><svg class="i" viewBox="0 0 24 24"><path d="M4 6h16M4 12h10M4 18h6"/><circle cx="18" cy="16" r="3"/></svg><span class="sbdg" id="sessBdg" aria-hidden="true" hidden></span></button>
40
- <button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
41
- <button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
36
+ <div class="tools tools-top"><span class="vh" id="snap">Reading the board</span>
37
+ <span id="modePark" hidden><span class="seg modeseg" id="modeSeg" role="group" aria-label="How an initiative opens"><i class="pill"></i><button data-m="page" aria-pressed="true">Page</button><button data-m="popup" aria-pressed="false">Popup</button></span></span></div>
42
38
  </header>
43
39
  <section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
44
40
  <section class="card rise" style="--d:4" id="cMet" aria-labelledby="hMet" hidden>
@@ -33,11 +33,7 @@
33
33
  <main class="stage" id="stage">
34
34
  <header class="top rise" style="--d:0">
35
35
  <h1 class="vh" id="iH1">Initiative</h1><div id="crumbHost"></div>
36
- <div class="tools tools-top"><span class="snap" id="snap">Reading the initiative</span>
37
- <a class="glass round" id="toConsole" href="/console.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
38
- <button class="glass round sbtn" id="sessBtn" aria-haspopup="dialog" aria-label="Agent sessions" title="Agent sessions"><svg class="i" viewBox="0 0 24 24"><path d="M4 6h16M4 12h10M4 18h6"/><circle cx="18" cy="16" r="3"/></svg><span class="sbdg" id="sessBdg" aria-hidden="true" hidden></span></button>
39
- <button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
40
- <button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
36
+ <div class="tools tools-top"><span class="vh" id="snap">Reading the initiative</span></div>
41
37
  </header>
42
38
  <section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
43
39
  <div id="iMain"><p class="empty3 plain" id="iRead">The initiative is read from its records. This page shows nothing until it has read, rather than guess.</p></div>
@@ -34,11 +34,7 @@
34
34
  <main class="stage" id="stage">
35
35
  <header class="top rise" style="--d:0">
36
36
  <h1 class="vh">Insights</h1><div id="crumbHost"></div>
37
- <div class="tools tools-top"><span class="snap" id="snap">Reading the records</span>
38
- <a class="glass round" id="toConsole" href="/console.html" aria-label="Open the console" title="Open the console"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="m7 9 3 3-3 3M13 15h4"/></svg></a>
39
- <button class="glass round sbtn" id="sessBtn" aria-haspopup="dialog" aria-label="Agent sessions" title="Agent sessions"><svg class="i" viewBox="0 0 24 24"><path d="M4 6h16M4 12h10M4 18h6"/><circle cx="18" cy="16" r="3"/></svg><span class="sbdg" id="sessBdg" aria-hidden="true" hidden></span></button>
40
- <button class="glass round" id="settingsBtn" aria-label="Settings" title="Settings"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/></svg></button>
41
- <button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
37
+ <div class="tools tools-top"><span class="vh" id="snap">Reading the records</span></div>
42
38
  </header>
43
39
  <section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
44
40
  <section class="card rise" style="--d:4" id="cBm" aria-labelledby="hBm" hidden>