create-pmos 0.328.0 → 0.330.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 (34) hide show
  1. package/package.json +227 -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-insights-test.js +56 -25
  7. package/workspace/briefing-premium-test.js +3 -1
  8. package/workspace/changelog.json +672 -0
  9. package/workspace/guide/briefing-premium.md +10 -8
  10. package/workspace/lib/insights-premium.js +111 -26
  11. package/workspace/lib/kit-update.js +57 -8
  12. package/workspace/lib/premium-dashboards.js +25 -5
  13. package/workspace/lib/routes-insights-premium.js +19 -4
  14. package/workspace/lib/routes-premium-dashboards.js +12 -1
  15. package/workspace/lib/settings-store.js +3 -1
  16. package/workspace/package-lock.json +2 -2
  17. package/workspace/package.json +1 -1
  18. package/workspace/premium-report-read-test.js +4 -2
  19. package/workspace/premium-studio-chart-test.js +3 -3
  20. package/workspace/premium-studio-report-test.js +1 -1
  21. package/workspace/premium-studio-test.js +4 -4
  22. package/workspace/premium-vw-cal-test.js +3 -1
  23. package/workspace/premium-vw-slides-test.js +8 -4
  24. package/workspace/public/pm/c3-settings.js +1 -1
  25. package/workspace/public/pm/premium-insights.css +52 -0
  26. package/workspace/public/pm/premium-insights.js +129 -50
  27. package/workspace/public/pm/premium-shell.js +137 -3
  28. package/workspace/public/pm/premium-vw-cal.css +66 -42
  29. package/workspace/public/pm/premium-vw-cal.js +38 -17
  30. package/workspace/public/pm/premium.css +22 -0
  31. package/workspace/public/pm/premium.js +1 -1
  32. package/workspace/public/premium-insights.html +29 -19
  33. package/workspace/server.js +7 -2
  34. package/workspace/test-run.js +2 -0
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.328.0",
3
+ "version": "0.330.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.328.0",
9
+ "version": "0.330.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.328.0",
3
+ "version": "0.330.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -96,8 +96,10 @@ fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
96
96
  const bigTitle = () => p.evaluate(() => { const h = document.querySelector('#rdSlide h3'); return h ? h.textContent : (document.querySelector('#rdSlide iframe') ? 'frame' : ''); });
97
97
  const say = async (t) => { await p.fill('#rdIn', t); await p.press('#rdIn', 'Enter'); };
98
98
  await p.goto(BASE + '/premium-insights.html');
99
- await until(() => p.evaluate(() => document.querySelectorAll('#repDocs [data-rep]').length === 2));
100
- const rowSel = (slot) => `#repDocs [data-rep="rep:${CAD}:${slot}"]`;
99
+ await until(() => p.evaluate(() => !!document.querySelector('#listSeg [data-f="rep"]')));
100
+ await p.click('#listSeg [data-f="rep"]'); // the one list (insights-one-list L5): the Reports filter holds the report files
101
+ await until(() => p.evaluate(() => document.querySelectorAll('#listRows [data-rep]').length === 2));
102
+ const rowSel = (slot) => `#listRows [data-rep="rep:${CAD}:${slot}"]`;
101
103
 
102
104
  /* O: a document row opens the reader on the page */
103
105
  await tap(rowSel('2026-10-12'));
@@ -64,7 +64,7 @@ const model = async () => (await (await fetch(BASE + '/api/insights-premium')).j
64
64
  const pv = () => p.evaluate(() => { const t = document.querySelector('#stPv .mt1'); return t ? { cls: t.className, title: t.querySelector('.mlab').firstChild.textContent, val: (t.querySelector('.mval') || {}).textContent, bars: [...t.querySelectorAll('.bw i')].map((i) => parseFloat(i.style.height)), foot: (t.querySelector('.mfoot') || {}).textContent || '' } : null; });
65
65
  const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
66
66
  const tap = (sel) => p.$eval(sel, (b) => b.click());
67
- 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); };
67
+ const open = async (sel) => { if (sel === '#pdNew' || sel === '#repNew') await p.click('#listNew'); await p.click(sel); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu'))); await sleep(300); };
68
68
  const mode = () => p.evaluate(() => (document.querySelector('#oMain .stmd [aria-pressed="true"]') || {}).textContent || '');
69
69
 
70
70
  /* O: New chart opens the Studio in Chart mode */
@@ -136,8 +136,8 @@ const model = async () => (await (await fetch(BASE + '/api/insights-premium')).j
136
136
  await tap('#oMain [data-st="save"]');
137
137
  await until(async () => (await model()).dashboards.some((d) => d.saved && d.name === 'Weekly'));
138
138
  // the Studio has closed and the page has drawn the new dashboard; Your charts is under All measures
139
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dashTabs [data-d="all"]')));
140
- await p.$eval('#dashTabs [data-d="all"]', (b) => b.click());
139
+ await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && document.querySelector('#hDash').textContent === 'Weekly' && !!document.querySelector('#repBody [data-d="all"]')));
140
+ await p.$eval('#repBody [data-d="all"]', (b) => b.click());
141
141
  await until(() => p.evaluate((id) => !!document.querySelector(`#dashBody [data-ced="${id}"]`), cid));
142
142
  await p.$eval(`#dashBody [data-ced="${cid}"]`, (b) => b.click());
143
143
  await until(async () => await mode() === 'Chart');
@@ -100,7 +100,7 @@ const model = async () => (await (await fetch(BASE + '/api/insights-premium')).j
100
100
  const cta = () => p.evaluate(() => { const b = document.querySelector('#stFt [data-st="save"]'); return b ? b.textContent + (b.disabled ? ':off' : ':on') : ''; });
101
101
 
102
102
  /* O: New report opens the Studio in Report mode */
103
- await p.click('#repNew');
103
+ await p.click('#listNew'); await p.click('#repNew');
104
104
  await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu')));
105
105
  ok('O1 New report opens the Studio in Report mode, with the brief of the mockup', await mode() === 'Report' && await chipv('title') === bname + ' weekly report' && await chipv('purpose') === 'Not set'
106
106
  && await chipv('aud') === 'The team' && await chipv('out') === 'Google Doc' && await chipv('sched') === 'Weekly, Mondays at 09:00' && await chipv('from') === 'Your work' && await chipv('secs') === '7', [await mode(), await chipv('title'), await chipv('sched')].join());
@@ -60,7 +60,7 @@ const saved = async () => { const j = await (await fetch(BASE + '/api/insights-p
60
60
  const tiles = () => p.evaluate(() => [...document.querySelectorAll('#stPv .mch .mlab')].map((e) => e.firstChild.textContent));
61
61
  const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
62
62
  const tap = (sel) => p.$eval(sel, (b) => b.click());
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); };
63
+ const open = async (sel) => { if (sel === '#pdNew' || sel === '#repNew') await p.click('#listNew'); 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
66
  /* O0: the bar's Chat button opens the Studio on the dashboard shown (premium-topbar: the Studio is this page's chat) */
@@ -135,7 +135,7 @@ const saved = async () => { const j = await (await fetch(BASE + '/api/insights-p
135
135
 
136
136
  /* S: save, read back, edit, remove */
137
137
  await tap('#oMain [data-st="save"]');
138
- ok('S1 Save closes the Studio and the page draws the saved dashboard as the main one', await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && [...document.querySelectorAll('#dashTabs button')].some((b) => b.textContent === 'Partner review · Main' && b.getAttribute('aria-pressed') === 'true'))));
138
+ ok('S1 Save closes the Studio and the page draws the saved dashboard as the main one', await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && document.querySelector('#hDash').textContent === 'Partner review' && document.querySelector('#dashTag').textContent === 'Pinned')));
139
139
  let S = await saved();
140
140
  ok('S2 the ledger holds the name, purpose, order and Main', S.length === 1 && S[0].name === 'Partner review' && S[0].purpose === 'the Monday partner review' && S[0].charts.join() === 'krm-a,krm-t' && S[0].main, JSON.stringify(S));
141
141
  await open('#pdEdit');
@@ -166,10 +166,10 @@ const saved = async () => { const j = await (await fetch(BASE + '/api/insights-p
166
166
  for (const theme of ['light', 'dark']) {
167
167
  const c2 = await browser.newContext({ viewport: { width: 390, height: 844 }, colorScheme: theme }), q = await c2.newPage();
168
168
  await q.goto(BASE + '/premium-insights.html');
169
- await until(() => q.evaluate(() => !!document.querySelector('#pdNew')));
169
+ await until(() => q.evaluate(() => !!document.querySelector('#crAsk') && !!document.querySelector('#listRows .dmr')));
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
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
- await q.click('#pdNew'); await until(() => q.evaluate(() => !!document.querySelector('#oMain .stu'))); await sleep(400);
172
+ await q.click('#listNew'); 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(() => {
175
175
  const sm = [...document.querySelectorAll('#oMain .stu button')].filter((b) => b.offsetParent).filter((b) => { const r = b.getBoundingClientRect(); return r.height < 44 || r.width < 44; }).map((b) => (b.dataset.st || b.textContent) + ':' + Math.round(b.getBoundingClientRect().width) + 'x' + Math.round(b.getBoundingClientRect().height));
@@ -85,7 +85,9 @@ const answer = (url, mode) => {
85
85
  ok('R8 the week draws today\'s three meetings as blocks', (await vis(page, '#vcMain .vc-ev')) === 3, String(await vis(page, '#vcMain .vc-ev')));
86
86
  const lanes = await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-ev')].filter((b) => /sync|meter/.test(b.textContent)).map((b) => b.getBoundingClientRect()));
87
87
  ok('R8 two meetings that overlap sit side by side', lanes.length === 2 && Math.abs(lanes[0].left - lanes[1].left) > 20 && lanes[0].width < 200, JSON.stringify(lanes.map((r) => [r.left, r.width])));
88
- ok('R8 the all-day row carries the dated layer as a mark', await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-adc .vc-ad')].some((x) => /promised/.test(x.textContent) && x.tagName === 'SPAN')));
88
+ ok('R8 the dates row carries the dated layer as a mark', await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-sc .vc-ad')].some((x) => /promised/.test(x.textContent) && x.tagName === 'SPAN')));
89
+ ok('R8 a meeting block is filled, not see-through (the console draws a solid block)', await page.evaluate(() => { const b = document.querySelector('#vcMain .vc-ev'); const c = b && getComputedStyle(b).backgroundColor; return !!c && c !== 'transparent' && !/rgba\(.*,\s*0\)$/.test(c); }));
90
+ ok('R8 the first hour of the grid is labelled', await page.evaluate(() => { const i = document.querySelector('#vcMain .vc-gut i'); return !!i && /^\d{2}:00$/.test(i.textContent) && getComputedStyle(i).visibility !== 'hidden' && i.getClientRects().length > 0; }));
89
91
  ok('R8 the now line is drawn on today', (await vis(page, '#vcMain .vc-now')) <= 1);
90
92
  const wk = await title(page);
91
93
  await page.click('#vcMain [data-cn="1"]');
@@ -74,8 +74,10 @@ const disk = () => fs.readFileSync(path.join(dir, pNew), 'utf8');
74
74
  const st = () => p.evaluate((pth) => { const S = window.__premiumSlides && window.__premiumSlides.state(pth); return S ? { i: S.i, n: S.deck.slides.length, theme: S.deck.theme, dirty: S.dirty, ro: S.ro, sel: S.sel, msg: S.msg, slides: JSON.parse(JSON.stringify(S.deck.slides)) } : null; }, pNew);
75
75
  const openReader = async (slot) => {
76
76
  await p.goto(BASE + '/premium-insights.html');
77
- await until(() => p.evaluate(() => document.querySelectorAll('#repDocs [data-rep]').length === 2));
78
- await tap(`#repDocs [data-rep="rep:${CAD}:${slot}"]`);
77
+ await until(() => p.evaluate(() => !!document.querySelector('#listSeg [data-f="rep"]')));
78
+ await tap('#listSeg [data-f="rep"]'); // the one list (insights-one-list L5): the Reports filter holds the report files
79
+ await until(() => p.evaluate(() => document.querySelectorAll('#listRows [data-rep]').length === 2));
80
+ await tap(`#listRows [data-rep="rep:${CAD}:${slot}"]`);
79
81
  return until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
80
82
  };
81
83
  const openEditor = async () => {
@@ -238,8 +240,10 @@ const disk = () => fs.readFileSync(path.join(dir, pNew), 'utf8');
238
240
  const c2 = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true, colorScheme: 'dark' }), q = await c2.newPage(), e2 = [];
239
241
  q.on('pageerror', (e) => e2.push(String(e)));
240
242
  await q.goto(BASE + '/premium-insights.html?theme=dark');
241
- await until(() => q.evaluate(() => document.querySelectorAll('#repDocs [data-rep]').length === 2));
242
- await q.$eval(`#repDocs [data-rep="rep:${CAD}:2026-10-12"]`, (x) => x.click());
243
+ await until(() => q.evaluate(() => !!document.querySelector('#listSeg [data-f="rep"]')));
244
+ await q.$eval('#listSeg [data-f="rep"]', (x) => x.click());
245
+ await until(() => q.evaluate(() => document.querySelectorAll('#listRows [data-rep]').length === 2));
246
+ await q.$eval(`#listRows [data-rep="rep:${CAD}:2026-10-12"]`, (x) => x.click());
243
247
  await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
244
248
  await q.$eval('#oMain [data-rr="rm"]', (x) => x.click()); await q.$eval('#oMain [data-rr="slides"]', (x) => x.click());
245
249
  await until(() => q.evaluate(() => !!document.querySelector('#dOut .obody.vw:not([hidden]) .sl .sl-stage .sl-cv')));
@@ -81,7 +81,7 @@ export const LABELS = Object.freeze({
81
81
  'sess.idle': ['Housekeeping', 'Close a background session idle for', '', { 15: '15 min', 30: '30 min', 60: '1 hour', never: 'Never' }],
82
82
  'sess.share': ['Housekeeping', 'Background jobs', 'Card refresh, imports and final notes can share one session per workspace. It starts faster and costs less.', { ws: 'One session per workspace', job: 'A new session per job' }],
83
83
  'look.start': ['Look', 'Start page', 'The page /c3.html opens on.', { brief: 'Briefing', cal: 'Calendar', work: 'Work', init: 'Initiatives', rep: 'Reports' }],
84
- 'upd.check': ['When', 'Check for updates', 'A check asks the npm registry for the latest version. It is the only request PMOS makes by itself.', { press: 'When I press Check', daily: 'Once a day' }],
84
+ 'upd.check': ['When', 'Check for updates', 'A check asks the npm registry for the latest version and what each newer kit changed. Once a day, an open PMOS page asks by itself. It is the only request PMOS makes by itself.', { press: 'When I press Check', daily: 'Once a day' }],
85
85
  'upd.apply': ['When', 'Install updates', 'An app update restarts PMOS. When idle waits until no recording or session runs.', { ask: 'Ask me', idle: 'When PMOS is idle' }],
86
86
  'upd.kits': ['When', 'Workspace kits', 'Each workspace carries its own copy of the kit.', { all: 'Update all together', each: 'One at a time' }],
87
87
  'upd.channel': ['When', 'Release channel', '', { stable: 'Stable', early: 'Early' }],
@@ -165,3 +165,55 @@ button.nfr:hover,button.nfr:focus-visible{background:color-mix(in oklab,var(--in
165
165
  .pdev{margin:0 0 12px;padding-left:18px;display:grid;gap:4px}
166
166
  .pdev small{color:var(--ink-3)}
167
167
  .dplist button[role="switch"]{min-height:44px;width:100%}
168
+ /* insights-one-list: the insight first, the pinned dashboard on top, one paged list of dashboards and reports */
169
+ .ins-hero{margin-top:28px;display:grid;gap:10px;max-width:72ch}
170
+ .ins-hero .brief.ihead{margin:0;max-width:none}
171
+ .ieye{display:flex;align-items:center;gap:6px;margin:0;font:600 var(--fs-1) var(--mono);letter-spacing:.08em;text-transform:uppercase;color:var(--ember-ink)}
172
+ .ieye svg.i{width:14px;height:14px}
173
+ .ins-hero.calm .ieye{color:var(--ink-3)}
174
+ .ins-hero .ihead{margin:0;font-size:var(--fs-6);line-height:1.15;font-weight:600;letter-spacing:-.03em;color:var(--ink);text-wrap:balance}
175
+ .iwhy{margin:0;font-size:var(--fs-4);line-height:1.5;color:var(--ink-2)}
176
+ .iwhy:empty,.imore:empty,.iact:empty,.inote:empty{display:none}
177
+ .imore{list-style:none;margin:0;padding:0;display:grid;gap:2px}
178
+ .imr{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;min-height:44px;padding:8px 10px;margin:0 -10px;border-radius:14px;text-align:left;font-size:var(--fs-3);color:var(--ink-2)}
179
+ .imr:hover,.imr:focus-visible{background:color-mix(in oklab,var(--ink) 6%,transparent);color:var(--ink)}
180
+ .imr svg.i{width:16px;height:16px;flex:none}
181
+ .iact{display:flex;gap:10px;flex-wrap:wrap;margin-top:4px}
182
+ .iact .dmcta{min-height:44px}
183
+ .inote{margin:0}
184
+ @media (max-width:700px){.ihead{font-size:var(--fs-5)}}
185
+ .ptag{font:600 var(--fs-1) var(--mono);font-style:normal;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-3);border:1px solid var(--hair);border-radius:6px;padding:2px 7px}
186
+ .ptag.on{color:var(--on-solid);background:var(--solid);border-color:transparent}
187
+ .ptag:empty{display:none}
188
+ .pdcard .ch small{margin-left:auto}
189
+ .pdbar .dmcta svg.i{width:16px;height:16px;margin-right:4px}
190
+ .nfd .nft b{font-weight:600}
191
+ .nfd li.stall .nfdot,.nfd li.miss .nfdot{background:var(--ember)}
192
+ .nfd li.course .nfdot{background:var(--ok)}
193
+ .lbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:12px 0 0}
194
+ .lbar .nask{flex:1 1 260px;margin:0}
195
+ .lbar .dmcta{min-height:44px}
196
+ .newm{position:relative}
197
+ .lmenu{position:absolute;top:50px;left:0;z-index:5;display:grid;min-width:180px;padding:6px;border-radius:16px;background:var(--card-solid,var(--card));border:1px solid var(--hair);box-shadow:var(--card-shadow)}
198
+ .lmenu button{min-height:44px;padding:0 12px;border-radius:10px;text-align:left;font-weight:600}
199
+ .lmenu button:hover,.lmenu button:focus-visible{background:var(--well)}
200
+ #cRep .mhint{margin:10px 0 0 4px}
201
+ #listRows{margin-top:10px}
202
+ .dmi.c-Dash{background:color-mix(in oklab,var(--ember) 16%,transparent);color:var(--ember-ink)}
203
+ .nil{display:flex;gap:6px;align-items:flex-start;font-size:var(--fs-3);line-height:1.45;color:var(--ink)}
204
+ .nil svg.i{width:14px;height:14px;margin-top:3px;flex:none;color:var(--ember-ink)}
205
+ .nil.q span{color:var(--ink-2)}
206
+ .dmm .t{text-transform:uppercase;letter-spacing:.06em;font-size:var(--fs-1)}
207
+ .npin{width:44px;height:44px;margin-right:6px;border-radius:12px;display:grid;place-items:center;color:var(--ink-3);border:1px solid transparent}
208
+ .npin:hover{border-color:var(--hair);color:var(--ink)}
209
+ .npin[aria-pressed="true"]{background:var(--solid);color:var(--on-solid)}
210
+ .npin[aria-pressed="true"] svg{fill:currentColor}
211
+ .npin svg.i{width:18px;height:18px}
212
+ .lpager{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-top:12px}
213
+ .lpager .note{margin:0}
214
+ .lpager .pg{display:flex;gap:6px;flex-wrap:wrap}
215
+ .lpager .pg button{min-width:44px;height:44px;display:grid;place-items:center;border-radius:12px;border:1px solid var(--hair);font:500 var(--fs-2) var(--mono)}
216
+ .lpager .pg button[aria-current="page"]{background:var(--solid);color:var(--on-solid);border-color:transparent}
217
+ .lpager .pg button:disabled{opacity:.35;cursor:default}
218
+ .lmenu[hidden]{display:none}
219
+ #listRows .dmr{grid-template-columns:minmax(0,1fr) auto}
@@ -5,7 +5,8 @@
5
5
  * PRD D2 to D6) and the report presses of the console's Reports workspace (POST /api/report-setups/ask | change | cancel | setup | dismiss | pause | resume |
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
- * revert | accept (PRD R5 to R8). Nothing else posts, and nothing is sent outward. */
8
+ * revert | accept (PRD R5 to R8). insights-one-list puts the insight first, the pinned dashboard on top and one paged list of dashboards and reports below
9
+ * (PRD L1 to L6); its one new press is Pin, POST /api/premium-dashboards/pin. Nothing else posts, and nothing is sent outward. */
9
10
  import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb, kv, setPageGaps } from './premium-shell.js';
10
11
  import { pmPost, pmGet } from './http.js';
11
12
  import { openStudio } from './premium-studio.js';
@@ -13,11 +14,15 @@ import { openReport } from './premium-report-read.js';
13
14
  import * as MT from './premium-metric-tiles.js';
14
15
 
15
16
  let M = null; // the model
16
- let dash = 'all'; // the dashboard on screen
17
+ let dash = null; // the dashboard in the top card: the pinned one until a list row opens another
18
+ let listF = 'all', listP = 1; // the list's filter and page
19
+ const PER = 6; // rows to a page (insights-one-list L5)
17
20
  wireRail('rep');
18
21
  const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
19
22
  const DOCI = '<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/>';
20
23
  const CHV2 = '<svg class="i" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></svg>';
24
+ const PINI = '<path d="M9 3h6l-1 6 4 3v2H6v-2l4-3z"/><path d="M12 14v7"/>';
25
+ const DASHI = '<path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/>';
21
26
  const AIC = '<path d="M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z"/>';
22
27
  const byKey = (k) => (M && (M.charts || []).concat(M.mine || []) || []).find((c) => c.key === k) || null;
23
28
  const savedDash = () => (M.dashboards || []).filter((d) => d.saved);
@@ -34,9 +39,28 @@ function drawHead() {
34
39
  $('#snap').textContent = M.header.text;
35
40
  setPageGaps(((M.header && M.header.missing) || []).length);
36
41
  $('#snap').title = 'Every figure on this page comes from a KR metric record. A measure with fewer than two readings is listed, not drawn.';
37
- $('#brief').textContent = M.empty || '';
42
+ drawHero();
38
43
  }
39
44
 
45
+ /* ── the insight (insights-one-list L1, L2): the strongest finding across the board's measures, its reason, two more, and a press to the measure ── */
46
+ function drawHero() {
47
+ const I = M.insight;
48
+ $('#insEye').innerHTML = ICO(AIC) + esc(I.none ? 'Insight' : 'Insight · ' + I.off + ' of ' + I.total + ' behind their line · readings to ' + I.asOf);
49
+ $('#brief').textContent = I.text;
50
+ $('#insWhy').textContent = I.why || '';
51
+ $('#insMore').innerHTML = (I.more || []).map((x) => `<li><button class="imr" data-open="${esc(x.chart)}" aria-haspopup="dialog">${esc(x.text)}${CHV2}</button></li>`).join('');
52
+ $('#insAct').innerHTML = I.chart ? `<button class="dmcta" data-askwhy="${esc(I.chart)}" aria-haspopup="dialog">Ask PMOS why</button><button class="dmcta alt" data-open="${esc(I.chart)}" aria-haspopup="dialog">See the chart</button>` : '';
53
+ $('#insNote').textContent = I.proj || (I.more || []).length ? 'A sentence that says where a measure lands by its target date is a straight line through its last four readings, carried to that date. It is not drawn on a chart.' : '';
54
+ $('#insHero').classList.toggle('calm', !!(I.none || I.calm));
55
+ }
56
+ $('#insHero').addEventListener('click', (e) => {
57
+ const o = e.target.closest('[data-open]'); if (o) { openChart(byKey(o.dataset.open)); return; }
58
+ const a = e.target.closest('[data-askwhy]'); if (!a) return;
59
+ openChart(byKey(a.dataset.askwhy));
60
+ const t = $('#dTabs [data-t="chat"]'); if (t) t.click();
61
+ const inp = $('#askIn'); if (inp) { inp.value = 'Why is this happening, and what would change it?'; inp.focus(); }
62
+ });
63
+
40
64
  /* ── charts ───────────────────────────────────────────────────────────────────────────────────────────────────── */
41
65
  const W = 220, H = 60, P = 5;
42
66
  const X = (fx) => P + fx * (W - 2 * P), Y = (fy) => P + (1 - fy) * (H - 2 * P);
@@ -107,21 +131,25 @@ function chartAt(t, j) {
107
131
  t.setAttribute('aria-label', c.title + ', ' + (last ? 'now ' : '') + val + ', ' + cap + '. Use the arrow keys to read each reading.');
108
132
  }
109
133
 
110
- /* ── the dashboards card ──────────────────────────────────────────────────────────────────────────────────────── */
134
+ /* ── the top card: the pinned dashboard (insights-one-list L4) ─────────────────────────────────────────────────── */
111
135
  const curDash = () => M.dashboards.find((d) => d.id === dash) || M.dashboards[0];
112
- function findingsHtml() {
113
- const F = M.findings.filter((f) => f.text);
114
- if (!F.length) return '';
115
- return `<div class="nfd" role="region" aria-label="What stands out"><p class="label">What stands out</p><ul>${F.map((f) => `<li class="${esc(f.kind)}">${f.chart
116
- ? `<button class="nfr" data-open="${esc(f.chart)}" aria-haspopup="dialog"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(f.text)}</span>${CHV2}</button>`
117
- : `<div class="nfr"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(f.text)}</span></div>`}</li>`).join('')}</ul></div>`;
136
+ const pinnable = (D) => !!M.board.id && (D.id === 'all' || D.saved);
137
+ /* The dashboard's insight band. The finding the page already leads with is skipped, so the band says what else is on this dashboard. */
138
+ function findingsHtml(D) {
139
+ const I = D.insight; if (!I || I.none) return '';
140
+ const all = I.finds, F = all.filter((f) => f.chart !== M.insight.chart), also = F.length < all.length;
141
+ const label = also ? 'Also on this dashboard' : 'Insight';
142
+ const rows = F.length ? F.map((f) => `<li class="${esc(f.kind)}"><button class="nfr" data-open="${esc(f.chart)}" aria-haspopup="dialog"><i class="nfdot" aria-hidden="true"></i><span class="nft"><b>${esc(f.text)}</b> ${esc(f.why)}</span>${CHV2}</button></li>`).join('')
143
+ : `<li class="calm"><div class="nfr"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(also ? 'Nothing else stands out here.' : I.calmText)}</span></div></li>`;
144
+ return `<div class="nfd" role="region" aria-label="${esc(label)}"><p class="label">${esc(label)}</p><ul>${rows}</ul></div>`;
118
145
  }
119
146
  function drawDash() {
120
- const D = curDash(), L = D.keys.map(byKey).filter(Boolean);
121
- $('#dashCap').textContent = M.counts.total ? M.counts.charts + ' drawn · ' + M.counts.noSeries + ' without a series' : '';
122
- const tabs = $('#dashTabs'); tabs.hidden = M.dashboards.length < 2;
123
- if (!tabs.hidden) { tabs.innerHTML = '<i class="pill"></i>' + M.dashboards.map((d) => `<button data-d="${esc(d.id)}" aria-pressed="${d.id === D.id}"${d.main ? ' title="The main dashboard"' : ''}>${esc(d.name)}${d.main ? ' · Main' : ''}</button>`).join(''); pillOf(tabs); }
124
- drawDashBar(D);
147
+ const D = curDash(), L = D.keys.map(byKey).filter(Boolean), isPin = M.pinned === D.id;
148
+ $('#hDash').textContent = D.name;
149
+ $('#dashTag').textContent = isPin ? 'Pinned' : 'Not pinned';
150
+ $('#dashTag').className = 'ptag' + (isPin ? ' on' : '');
151
+ $('#dashCap').textContent = L.length ? (L.length - D.off) + ' of ' + L.length + ' on their line' : '';
152
+ drawDashBar(D, isPin);
125
153
  if (D.saved) { drawSaved(D, L); return; }
126
154
  if (!M.charts.length) {
127
155
  $('#dashBody').innerHTML = `<div class="nempty" style="margin-top:14px"><p><b>${esc(M.counts.total ? 'No KR metric holds two readings yet.' : 'No KR metric is recorded for this workspace.')}</b> ${esc(M.counts.total ? 'A chart needs a series, so nothing is drawn.' : 'There is nothing to chart. Add one where the KR metrics are kept.')}</p></div>` + noSeriesHtml();
@@ -129,22 +157,27 @@ function drawDash() {
129
157
  }
130
158
  const off = D.off, tot = L.length;
131
159
  $('#dashBody').innerHTML = `<div class="mprog" role="progressbar" aria-label="Measures on their line" aria-valuemin="0" aria-valuemax="${tot}" aria-valuenow="${tot - off}"><b style="width:${(tot - off) / tot * 100}%"></b></div>`
132
- + findingsHtml()
160
+ + findingsHtml(D)
133
161
  + `<p class="mhint" style="margin-top:6px"><b>${tot - off} of ${tot}</b> on their line${off ? `. <b class="mflag">${off} ${off === 1 ? 'is' : 'are'} behind it.</b>` : '.'} Each chart is one KR metric, drawn at the dates of its readings. A gap between readings is left as a gap. The dashed line is the target.</p>`
134
- + `<div class="ngrid">${L.map((c) => tileWrap(c)).join('')}</div>` + mineHtml() + noSeriesHtml();
162
+ + `<div class="ngrid">${L.map((c) => tileWrap(c)).join('')}</div>` + (D.id === 'all' ? mineHtml() + noSeriesHtml() : '');
135
163
  }
136
- /* The bar under the switch: a saved dashboard's purpose and Edit, and New dashboard (PRD D3/D4). Hidden when the page has no board to save on. */
137
- function drawDashBar(D) {
164
+ /* The bar under the heading: Pin or Unpin, Back to the pinned one, a saved dashboard's purpose and Edit, and New chart. Hidden with no board to save on. */
165
+ function drawDashBar(D, isPin) {
138
166
  const bar = $('#dashBar'); bar.hidden = !M.board.id;
139
167
  if (bar.hidden) return;
140
- bar.innerHTML = (D.saved ? `<p class="note pdp">${D.main ? '<b>Main dashboard.</b> ' : ''}${esc(D.purpose)}</p><button class="dmcta alt" id="pdEdit" aria-haspopup="dialog">Edit</button>` : '')
141
- + '<button class="dmcta alt" id="pdNew" aria-haspopup="dialog">New dashboard</button>' + (M.charts.length ? '<button class="dmcta alt" id="pcNew" aria-haspopup="dialog">New chart</button>' : '');
168
+ const P = M.pinned ? M.dashboards.find((d) => d.id === M.pinned) : null;
169
+ bar.innerHTML = (D.saved ? `<p class="note pdp">${esc(D.purpose)}</p>` : `<p class="note pdp">${esc(D.id === 'all' ? 'Every KR metric of this board. PMOS makes it, so it cannot be deleted.' : 'The measures of the ' + D.name + ' pillar.')}</p>`)
170
+ + (pinnable(D) ? `<button class="dmcta${isPin ? ' alt' : ''}" id="pdPin" data-pin="${esc(isPin ? '' : D.id)}" aria-pressed="${isPin}">${ICO(PINI)}${isPin ? 'Unpin' : 'Pin'}</button>` : '')
171
+ + (P && !isPin ? `<button class="dmcta alt" id="pdBack">Back to ${esc(P.name)}</button>` : '')
172
+ + (D.saved ? '<button class="dmcta alt" id="pdEdit" aria-haspopup="dialog">Edit</button>' : '')
173
+ + (M.charts.length ? '<button class="dmcta alt" id="pcNew" aria-haspopup="dialog">New chart</button>' : '');
142
174
  }
143
175
  function drawSaved(D, L) {
144
176
  const off = D.off, tot = L.length;
145
177
  const gone = D.gone.length ? `<p class="label ngl">Not drawn · ${D.gone.length}</p><div class="dplist" role="list">${D.gone.map((g) => `<div class="nempty" role="listitem" style="margin-bottom:6px"><p><b>${esc(g.title)}</b><br>${esc(g.why)}</p></div>`).join('')}</div>` : '';
146
178
  const checks = D.checks.length ? `<p class="note pdck">${D.checks.map(esc).join(' ')}</p>` : '';
147
179
  $('#dashBody').innerHTML = (tot ? `<div class="mprog" role="progressbar" aria-label="Measures on their line" aria-valuemin="0" aria-valuemax="${tot}" aria-valuenow="${tot - off}"><b style="width:${(tot - off) / tot * 100}%"></b></div>`
180
+ + findingsHtml(D)
148
181
  + `<p class="mhint" style="margin-top:6px"><b>${tot - off} of ${tot}</b> on their line${off ? `. <b class="mflag">${off} ${off === 1 ? 'is' : 'are'} behind it.</b>` : '.'} The charts are drawn in the order you saved. The dashed line is the target.</p>`
149
182
  + `<div class="ngrid">${L.map((c) => tileWrap(c)).join('')}</div>`
150
183
  : `<div class="nempty" style="margin-top:14px"><p><b>This dashboard draws no chart yet.</b> Press Edit to add a measure with a series.</p></div>`) + checks + gone;
@@ -162,8 +195,21 @@ function noSeriesHtml() {
162
195
  const N = M.noSeries; if (!N.length) return '';
163
196
  return `<p class="label ngl">No series recorded · ${N.length}</p><div class="dplist" role="list">${N.map((n) => `<div class="nempty" role="listitem" style="margin-bottom:6px"><p><b>${esc(n.title)}</b>${n.pillar ? ' · ' + esc(n.pillar) : ''}<br>${esc(n.why)} It is not drawn.</p></div>`).join('')}</div>`;
164
197
  }
165
- $('#dashTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-d]'); if (!b) return; dash = b.dataset.d; drawDash(); });
166
- $('#dashBar').addEventListener('click', (e) => { if (e.target.closest('#pdEdit')) openDashEdit(curDash()); else if (e.target.closest('#pdNew')) openDashEdit(null); else if (e.target.closest('#pcNew')) openChartEdit(null); });
198
+ /* Pin or unpin (PRD L4): one `pin` line in the dashboards ledger. The pinned dashboard shows in the top card of this page, and nowhere else. */
199
+ async function pinDash(id, from) {
200
+ const res = await pmPost('/api/premium-dashboards/pin', { ws: M.board.ws, board: M.board.id, id: id || null });
201
+ if (!res || res.ok !== true) { toast((res && res.error) || 'The pin could not be saved. Nothing changed.'); return; }
202
+ const D = M.dashboards.find((d) => d.id === id);
203
+ dash = res.pinned || 'all';
204
+ toast(res.pinned ? 'Pinned ' + (D ? D.name : 'the dashboard') + '. It shows at the top of Insights.' : 'Unpinned. All measures shows at the top.');
205
+ await load();
206
+ if (from === 'list') { try { $('#cDash').scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch { /* no scroll */ } }
207
+ }
208
+ $('#dashBar').addEventListener('click', (e) => {
209
+ const pin = e.target.closest('#pdPin'); if (pin) { pin.disabled = true; pinDash(pin.dataset.pin || null, 'card'); return; }
210
+ if (e.target.closest('#pdBack')) { dash = M.pinned; drawDash(); drawList(); return; }
211
+ if (e.target.closest('#pdEdit')) openDashEdit(curDash()); else if (e.target.closest('#pcNew')) openChartEdit(null);
212
+ });
167
213
 
168
214
  /* ── a dashboard is made and edited in the Insight Studio (initiative premium-studio-dashboard). Its one press posts POST /api/premium-dashboards/save. ── */
169
215
  async function saveDash(body) { return pmPost('/api/premium-dashboards/save', Object.assign({ ws: M.board.ws, board: M.board.id }, body)); }
@@ -177,8 +223,8 @@ const design = {
177
223
  post: (sub, id, body) => pmPost('/api/report-design/' + sub, Object.assign({ ws: M.board.ws, id }, body)),
178
224
  };
179
225
  const studioOf = (o) => openStudio(Object.assign({ M, tile: tileHtml, derive: deriveChart, save: saveDash, saveChart, setup: (sub, body) => repPost(sub, body), structure, design, reportsChanged: () => load(),
180
- done: async (id) => { dash = id || dash; if (!M.dashboards.some((d) => d.id === dash)) dash = 'all'; await load(); } }, o));
181
- function openDashEdit(D) { studioOf({ mode: 'dash', D, done: async (id) => { dash = id || 'all'; await load(); } }); }
226
+ done: async (id) => { dash = id || dash; await load(); } }, o));
227
+ function openDashEdit(D) { studioOf({ mode: 'dash', D, done: async (id) => { dash = id || null; await load(); } }); }
182
228
  /* A chart is made and edited in the Studio's Chart mode (initiative premium-studio-chart). Save posts POST /api/premium-charts/save. */
183
229
  function openChartEdit(id) { studioOf({ mode: 'chart', C: id ? (M.mineSaved || []).find((x) => x.id === id) || null : null }); }
184
230
  /* A report is set up and shaped in the Studio's Report mode (initiative premium-studio-report). */
@@ -196,45 +242,77 @@ $('#dashBody').addEventListener('pointermove', (e) => {
196
242
  });
197
243
  $('#dashBody').addEventListener('pointerleave', () => $$('#dashBody .mch.hv').forEach((x) => chartAt(x)));
198
244
 
199
- /* ── reports ──────────────────────────────────────────────────────────────────────────────────────────────────── */
245
+ /* ── the list: dashboards, then reports, filtered and paged (insights-one-list L5, L6) ──────────────────────────── */
200
246
  let askTimer = 0;
201
247
  const dismissing = new Map(); // finding id → timer: "Not a report" waits 5 s for an Undo before it is sent
202
248
  const ASKST = { running: ['Working', 'draft'], ready: ['Ready to review', 'issued'], failed: ['Failed', 'none'] };
249
+ const insLine = (t, q) => `<span class="nil${q ? ' q' : ''}">${ICO(AIC)}<span>${esc(t)}</span></span>`;
250
+ function dashRow(D) {
251
+ const I = D.insight || {}, f = I.finds && I.finds[0], on = M.pinned === D.id, shown = curDash().id === D.id;
252
+ const line = I.none ? '' : insLine(f ? f.text : I.calmText);
253
+ const meta = `<span class="t">Dashboard</span>${on ? '<span class="s issued">Pinned</span>' : ''}${shown ? '<span>Shown above</span>' : ''}<span>${D.total} ${D.total === 1 ? 'chart' : 'charts'}</span>${D.off ? `<span class="s none">${D.off} behind</span>` : D.total ? '<span>All on their line</span>' : ''}`;
254
+ return `<div class="dmr" role="listitem"><button class="dmo" data-d="${esc(D.id)}"><span class="dmi c-Dash">${ICO(DASHI)}</span><span class="dmn"><b>${esc(D.name)}</b>${line || `<small>${esc(I.none ? 'No chart is drawn on it yet.' : '')}</small>`}<span class="dmm">${meta}</span></span></button>`
255
+ + (pinnable(D) ? `<button class="npin" data-pin="${esc(D.id)}" aria-pressed="${on}" aria-label="${on ? 'Unpin' : 'Pin'} ${esc(D.name)}" title="${on ? 'Unpin' : 'Pin to the top of Insights'}">${ICO(PINI)}</button>` : '') + '</div>';
256
+ }
257
+ /* A report row's insight is the opening sentence of its latest file, marked as quoted from it. With no file it says no draft is written yet. */
258
+ function setupRow(s) {
259
+ const L = s.latest, line = L && L.lead ? insLine('“' + L.lead + '”', true) : '';
260
+ const from = L ? (L.lead ? 'From the ' + L.date + ' file' : 'The ' + L.date + ' file has no sentence to quote') : 'No draft is written yet';
261
+ return `<div class="dmr" role="listitem"><button class="dmo" data-setup="${esc(s.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(s.name)}</b>${line}<small>${esc([from, s.label, s.audience ? 'for ' + s.audience : ''].filter(Boolean).join(' · '))}</small><span class="dmm"><span class="t">Report</span><span class="s ${s.paused ? 'none' : 'issued'}">${s.paused ? 'Paused' : s.drafting ? 'Drafting' : 'Set up'}</span>${s.next && !s.paused ? `<span>Next draft ${esc(s.next)}</span>` : ''}</span></span></button></div>`;
262
+ }
203
263
  function repRow(r) {
204
- return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="${esc(r.key)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b><small>${esc(r.path)}</small><span class="dmm"><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span><span>Deck, present, download, print</span></span></span></button></div>`;
264
+ return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="${esc(r.key)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b>${r.lead ? insLine('“' + r.lead + '”', true) : ''}<small>${esc(r.path)}</small><span class="dmm"><span class="t">Report</span><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span><span>Deck, present, download, print</span></span></span></button></div>`;
205
265
  }
206
266
  const foundRow = (f) => `<div class="dmr" role="listitem"><button class="dmo" data-found="${esc(f.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(f.name)}</b><small>${esc(f.why)}</small><span class="dmm">${f.confidence ? `<span>${esc(f.confidence)}</span>` : ''}<span>${f.evidence.length} ${f.evidence.length === 1 ? 'sign' : 'signs'} in your work</span></span></span></button></div>`;
207
267
  const askRow = (a) => `<div class="dmr" role="listitem"><button class="dmo" data-ask="${esc(a.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(AIC)}</span><span class="dmn"><b>${esc(a.proposal && a.proposal.name ? a.proposal.name : a.text)}</b><small>You asked: ${esc(a.text)}</small><span class="dmm"><span class="s ${ASKST[a.state][1]}">${ASKST[a.state][0]}</span>${a.changed ? '<span>Changed once</span>' : ''}</span></span></button></div>`;
208
- const setupRow = (s) => `<div class="dmr" role="listitem"><button class="dmo" data-setup="${esc(s.id)}" aria-haspopup="dialog"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(s.name)}</b><small>${esc([s.label, s.audience ? 'for ' + s.audience : ''].filter(Boolean).join(' · '))}</small><span class="dmm"><span class="s ${s.paused ? 'none' : 'issued'}">${s.paused ? 'Paused' : s.drafting ? 'Drafting' : 'Set up'}</span>${s.next && !s.paused ? `<span>Next draft ${esc(s.next)}</span>` : ''}</span></span></button></div>`;
209
- function drawReps() {
210
- const R = M.reports, found = (R.found || []).filter((f) => !dismissing.has(f.id)), asks = R.asks || [], setups = R.setups || [];
211
- $('#repCap').textContent = R.rows.length ? String(R.rows.length) : '';
212
- const group = (id, label, L, row) => L.length ? `<div class="dmg ngrp" id="${id}" role="list"><p class="label">${esc(label)} · ${L.length}</p>${L.map(row).join('')}</div>` : '';
213
- $('#repBody').innerHTML = `<p class="mhint">A report is a file in the repository. PMOS drafts it, you read it. <b>Nothing is sent from here.</b></p>`
214
- + '<div class="nact"><button class="dmcta" id="repNew" aria-haspopup="dialog">New report</button></div>'
215
- + `<form class="nask" id="repAsk"><input id="repAskIn" maxlength="500" autocomplete="off" placeholder="Ask PMOS to set up a report" aria-label="Ask PMOS to set up a report"><button class="dmcta" id="repAskGo" type="submit">Ask</button></form>`
216
- + '<p class="note nask-n">This starts a background run that only proposes a report. Nothing is set up until you press Set it up.</p>'
217
- + (R.setupsOk === false ? '<div class="nempty"><p><b>The report setups could not be read</b>, so what PMOS found and what you set up are not listed.</p></div>'
218
- : group('repAsks', 'Your requests', asks, askRow) + group('repFound', 'Found in your work', found, foundRow) + group('repSetups', 'Set up', setups, setupRow))
219
- + (R.missing ? '<div class="nempty"><p><b>The report files could not be read</b>, so none is listed.</p></div>'
220
- : R.rows.length ? `<div class="dmg ngrp" id="repDocs" role="list"><p class="label">Documents · <b>${R.counts.draft}</b> ${R.counts.draft === 1 ? 'draft' : 'drafts'} · <b>${R.counts.issued}</b> issued</p>${R.rows.map(repRow).join('')}</div>`
221
- : '<div class="nempty"><p><b>No report file is on record.</b> Set one up above, or ask PMOS for one.</p></div>')
222
- + `<p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to edit or issue a document.</p>`;
268
+ function listItems() {
269
+ const R = M.reports, d = M.dashboards.map((x) => ({ kind: 'dash', x }));
270
+ const r = (R.setupsOk === false ? [] : (R.setups || []).map((x) => ({ kind: 'setup', x }))).concat(R.missing ? [] : R.rows.map((x) => ({ kind: 'file', x })));
271
+ return { d, r, all: d.concat(r) };
272
+ }
273
+ function drawList() {
274
+ const R = M.reports, found = (R.found || []).filter((f) => !dismissing.has(f.id)), asks = R.asks || [];
275
+ const I = listItems(), L = listF === 'dash' ? I.d : listF === 'rep' ? I.r : I.all, pages = Math.max(1, Math.ceil(L.length / PER));
276
+ listP = Math.min(Math.max(1, listP), pages);
277
+ $('#repCap').textContent = String(I.all.length);
278
+ const seg = $('#listSeg');
279
+ seg.innerHTML = '<i class="pill"></i>' + [['all', 'All', I.all.length], ['dash', 'Dashboards', I.d.length], ['rep', 'Reports', I.r.length]].map(([k, t, n]) => `<button data-f="${k}" aria-pressed="${listF === k}">${t}<em>${n}</em></button>`).join('');
280
+ pillOf(seg);
281
+ const group = (id, label, G, row) => G.length ? `<div class="dmg ngrp" id="${id}" role="list"><p class="label">${esc(label)} · ${G.length}</p>${G.map(row).join('')}</div>` : '';
282
+ const row = (it) => it.kind === 'dash' ? dashRow(it.x) : it.kind === 'setup' ? setupRow(it.x) : repRow(it.x);
283
+ const empty = listF !== 'dash' && R.missing ? '<div class="nempty"><p><b>The report files could not be read</b>, so none is listed.</p></div>'
284
+ : listF !== 'dash' && R.setupsOk === false ? '<div class="nempty"><p><b>The report setups could not be read</b>, so what PMOS found and what you set up are not listed.</p></div>' : '';
285
+ const none = listF === 'rep' && !L.length && !R.missing ? '<div class="nempty"><p><b>No report is set up and no report file is on record.</b> Press New, then Report, or ask PMOS for one.</p></div>' : '';
286
+ $('#repBody').innerHTML = (listF === 'dash' ? '' : group('repAsks', 'Your requests', asks, askRow) + group('repFound', 'Found in your work', found, foundRow))
287
+ + empty + none
288
+ + `<div class="dmg" id="listRows" role="list" aria-label="Dashboards and reports">${L.slice((listP - 1) * PER, listP * PER).map(row).join('')}</div>`;
289
+ const from = (listP - 1) * PER + 1, to = Math.min(listP * PER, L.length);
290
+ $('#listPager').innerHTML = pages < 2 ? `<span class="note">${L.length} shown</span>`
291
+ : `<span class="note">${from}–${to} of ${L.length}</span><span class="pg" role="group" aria-label="Pages"><button data-pg="${listP - 1}" ${listP === 1 ? 'disabled' : ''} aria-label="Previous page">‹</button>${Array.from({ length: pages }, (_, i) => `<button data-pg="${i + 1}"${i + 1 === listP ? ' aria-current="page"' : ''} aria-label="Page ${i + 1}">${i + 1}</button>`).join('')}<button data-pg="${listP + 1}" ${listP === pages ? 'disabled' : ''} aria-label="Next page">›</button></span>`;
223
292
  clearTimeout(askTimer);
224
293
  if (asks.some((a) => a.state === 'running')) askTimer = setTimeout(load, 5000);
225
294
  }
295
+ $('#listSeg').addEventListener('click', (e) => { const b = e.target.closest('[data-f]'); if (!b || b.dataset.f === listF) return; listF = b.dataset.f; listP = 1; drawList(); });
296
+ $('#listPager').addEventListener('click', (e) => { const b = e.target.closest('[data-pg]'); if (!b || b.disabled) return; listP = +b.dataset.pg; drawList(); $('#cRep').scrollIntoView({ block: 'nearest' }); });
297
+ const menu = (open) => { $('#listMenu').hidden = !open; $('#listNew').setAttribute('aria-expanded', String(open)); };
298
+ $('#listNew').addEventListener('click', () => { const open = $('#listMenu').hidden; menu(open); if (open) $('#listMenu button').focus(); });
299
+ $('#listMenu').addEventListener('click', (e) => { const b = e.target.closest('button'); if (!b) return; menu(false); if (b.id === 'pdNew') openDashEdit(null); else if (b.id === 'repNew') openReportEdit(null); });
300
+ document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !$('#listMenu').hidden) { menu(false); $('#listNew').focus(); } });
301
+ document.addEventListener('click', (e) => { if (!$('#listMenu').hidden && !e.target.closest('.newm')) menu(false); });
226
302
  $('#repBody').addEventListener('click', (e) => {
303
+ const pin = e.target.closest('[data-pin]');
304
+ if (pin) { pin.disabled = true; pinDash(M.pinned === pin.dataset.pin ? null : pin.dataset.pin, 'list'); return; }
305
+ const d = e.target.closest('[data-d]');
306
+ if (d) { dash = d.dataset.d; drawDash(); drawList(); try { $('#cDash').scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch { /* no scroll */ } return; }
227
307
  const rp = e.target.closest('[data-rep]');
228
308
  if (rp) { const row = M.reports.rows.find((x) => x.key === rp.dataset.rep), su = row && (M.reports.setups || []).find((x) => x.id === row.cadence); openReport(row, { ws: M.board.ws, name: su ? su.name : null }); return; }
229
- if (e.target.closest('#repOpen')) { location.assign('/console.html?tab=rep'); return; }
230
- if (e.target.closest('#repNew')) { openReportEdit(null); return; }
231
309
  const f = e.target.closest('[data-found]'), a = e.target.closest('[data-ask]'), s = e.target.closest('[data-setup]');
232
310
  if (f) openFound((M.reports.found || []).find((x) => x.id === f.dataset.found));
233
311
  else if (a) openAsk((M.reports.asks || []).find((x) => x.id === a.dataset.ask));
234
312
  else if (s) openSetup((M.reports.setups || []).find((x) => x.id === s.dataset.setup));
235
313
  });
236
- $('#repBody').addEventListener('submit', async (e) => {
237
- if (e.target.id !== 'repAsk') return;
314
+ $('#repOpen').addEventListener('click', () => location.assign('/console.html?tab=rep'));
315
+ $('#repAsk').addEventListener('submit', async (e) => {
238
316
  e.preventDefault();
239
317
  const inp = $('#repAskIn'), text = inp.value.trim(), go = $('#repAskGo');
240
318
  if (!text) { toast('Say what the report is for, then press Ask.'); inp.focus(); return; }
@@ -286,9 +364,9 @@ function openFound(f) {
286
364
  set: press('setup', { finding: f.id, name: f.name }, setupSaid),
287
365
  no: (m) => {
288
366
  const t = setTimeout(async () => { dismissing.delete(f.id); const res = await repPost('dismiss', { finding: f.id, name: f.name }); if (!res || res.ok !== true) toast(pressFailed(res, 'Not a report did not go through.')); await load(); }, 5000);
289
- dismissing.set(f.id, t); drawReps();
367
+ dismissing.set(f.id, t); drawList();
290
368
  m.innerHTML = 'Hidden. It is recorded as not a report in 5 seconds. <button class="lk" id="rxUndo">Undo</button>';
291
- $('#rxUndo').onclick = () => { clearTimeout(dismissing.get(f.id)); dismissing.delete(f.id); drawReps(); m.textContent = 'Undone. Nothing was recorded.'; $$('#oMain [data-rx]').forEach((x) => { x.disabled = false; }); };
369
+ $('#rxUndo').onclick = () => { clearTimeout(dismissing.get(f.id)); dismissing.delete(f.id); drawList(); m.textContent = 'Undone. Nothing was recorded.'; $$('#oMain [data-rx]').forEach((x) => { x.disabled = false; }); };
292
370
  return 'keep-off';
293
371
  },
294
372
  } });
@@ -335,7 +413,7 @@ function drawDock() { $('#dN').textContent = M.dock.needs; $('#dLab').textConten
335
413
  function cardHtml(c) { return `<div class="acard" id="card"><p class="ct">What this page can do</p><p class="nodef" id="holdWhy">${esc(c.dialog.hold)} The switches under On your dashboards save a dashboard and change no record.</p></div>`; }
336
414
  function paneHtml(c) {
337
415
  const p = c.dialog.pane;
338
- return `<article class="paper doc"><p class="dpath">${esc(p.file)}</p><h3 class="d1">${esc(c.title)}</h3><p>${esc(c.dialog.say)}</p><div class="ntw pdchart">${tileHtml(c)}</div><div class="kv2">${c.dialog.facts.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><h3 class="h2">All ${c.pts.length} readings</h3><div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>${onDashHtml(c)}<p class="xn">Read from the KR metric record. The line status is the record's own: the straight line from its baseline to its target. Nothing here is a forecast.</p></article>`;
416
+ return `<article class="paper doc"><p class="dpath">${esc(p.file)}</p><h3 class="d1">${esc(c.title)}</h3><p>${esc(c.dialog.say)}</p><div class="ntw pdchart">${tileHtml(c)}</div><div class="kv2">${c.dialog.facts.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><h3 class="h2">All ${c.pts.length} readings</h3><div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>${onDashHtml(c)}<p class="xn">Read from the KR metric record. The line status is the record's own: the straight line from its baseline to its target. Where this page says where a measure lands by its target date, that is a straight line through its last four readings, carried to that date. It is not drawn.</p></article>`;
339
417
  }
340
418
  /* Add to a dashboard (PRD D6): one switch per saved dashboard of the board. A press saves that dashboard with the chart added or taken off. */
341
419
  function onDashHtml(c) {
@@ -417,13 +495,14 @@ MT.wireTiles($('#bmBody'), () => (BM ? BM.tiles : []), bmOpen);
417
495
  $('#bmRange').addEventListener('click', (e) => { const b = e.target.closest('[data-w]'); if (!b || +b.dataset.w === bmWeeks) return; bmWeeks = +b.dataset.w; try { localStorage.setItem(BM_KEY, String(bmWeeks)); } catch { /* not kept */ } bmDraw(); bmLoad(); });
418
496
 
419
497
  /* ── load ─────────────────────────────────────────────────────────────────────────────────────────────────────── */
420
- function draw() { drawHead(); if (!M.dashboards.some((d) => d.id === dash)) dash = 'all'; drawDash(); drawReps(); drawDock(); onScroll(); }
498
+ function draw() { drawHead(); if (!dash || !M.dashboards.some((d) => d.id === dash)) dash = M.pinned || 'all'; drawDash(); drawList(); drawDock(); onScroll(); }
421
499
  async function load() {
422
500
  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('&');
423
501
  let r = null, status = 0;
424
502
  try { const res = await fetch('/api/insights-premium' + (q ? '?' + q : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
425
503
  if (!r || !r.ok) {
426
504
  $('#snap').textContent = 'The records could not be read';
505
+ $('#insEye').textContent = 'Insight'; $('#insWhy').textContent = '';
427
506
  $('#brief').textContent = 'The KR metric records could not be read, so this page shows nothing rather than guess.' + (r && r.error ? ' The reason: ' + r.error : status ? ' (the server answered ' + status + ')' : ' The server did not answer.');
428
507
  setTimeout(load, 15000);
429
508
  return;