create-pmos 0.395.0 → 0.397.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 (100) hide show
  1. package/package.json +25 -30
  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/scripts/nine-stages.js +49 -20
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +20 -40
  8. package/workspace/briefing-premium-board-test.js +145 -107
  9. package/workspace/briefing-premium-calendar-2-test.js +5 -2
  10. package/workspace/briefing-premium-calendar-3-test.js +13 -8
  11. package/workspace/briefing-premium-calendar-test.js +16 -5
  12. package/workspace/briefing-premium-initiative-test.js +50 -41
  13. package/workspace/briefing-premium-insights-test.js +104 -85
  14. package/workspace/briefing-premium-metrics-test.js +11 -32
  15. package/workspace/briefing-premium-sources-test.js +42 -21
  16. package/workspace/briefing-premium-test.js +112 -98
  17. package/workspace/briefing-premium-work-test.js +78 -64
  18. package/workspace/changelog.json +24 -0
  19. package/workspace/fixtures/board-premium-facts.js +2 -1
  20. package/workspace/fixtures/board-premium-jira.js +28 -0
  21. package/workspace/fixtures/initiative-premium-facts.js +2 -1
  22. package/workspace/fixtures/initiatives-api/list.json +30 -42
  23. package/workspace/fixtures/initiatives-api/roadmap.json +40 -56
  24. package/workspace/fixtures/initiatives-api/sheet.json +10 -14
  25. package/workspace/fixtures/insights-premium-facts.js +11 -2
  26. package/workspace/guide/briefing-premium.md +3 -1
  27. package/workspace/guide/index.md +1 -0
  28. package/workspace/guide/lifecycle.md +51 -0
  29. package/workspace/home-shot.js +38 -0
  30. package/workspace/lib/board-premium.js +92 -1
  31. package/workspace/lib/engine/boards.js +15 -14
  32. package/workspace/lib/engine/nine-stages.js +49 -20
  33. package/workspace/lib/engine/signals/detectors.js +13 -11
  34. package/workspace/lib/insights-premium.js +78 -1
  35. package/workspace/lib/routes-board-premium.js +3 -2
  36. package/workspace/lib/routes-initiatives.js +1 -1
  37. package/workspace/lib/routes-insights-premium.js +8 -1
  38. package/workspace/lib/vendor/scripts/nine-stages.js +49 -20
  39. package/workspace/package-lock.json +2 -2
  40. package/workspace/package.json +1 -1
  41. package/workspace/premium-agreed-viewer-shots.js +76 -0
  42. package/workspace/premium-board-actions-test.js +2 -0
  43. package/workspace/premium-chat-chart-tab-test.js +6 -5
  44. package/workspace/premium-chat-context-test.js +8 -6
  45. package/workspace/premium-chat-goal-view-test.js +9 -7
  46. package/workspace/premium-chat-notes-test.js +3 -2
  47. package/workspace/premium-chat-report-tab-test.js +8 -2
  48. package/workspace/premium-chat-term-test.js +3 -1
  49. package/workspace/premium-chat-viewer-test.js +23 -17
  50. package/workspace/premium-core-doc-issue-test.js +2 -0
  51. package/workspace/premium-html-viewer-test.js +4 -2
  52. package/workspace/premium-phone-card-test.js +1 -0
  53. package/workspace/premium-phone-room-test.js +16 -11
  54. package/workspace/premium-report-read-test.js +1 -1
  55. package/workspace/premium-vw-backlog-test.js +2 -0
  56. package/workspace/premium-vw-cal-test.js +9 -4
  57. package/workspace/premium-vw-doc-test.js +1 -1
  58. package/workspace/premium-vw-item-test.js +1 -0
  59. package/workspace/premium-vw-jira-test.js +4 -1
  60. package/workspace/premium-vw-notes-test.js +2 -1
  61. package/workspace/premium-vw-rec-test.js +3 -2
  62. package/workspace/premium-vw-slides-test.js +2 -2
  63. package/workspace/premium-work-depth-test.js +7 -3
  64. package/workspace/public/pm/bd-span.js +120 -0
  65. package/workspace/public/pm/bd-stages.js +33 -0
  66. package/workspace/public/pm/cozy-board.css +373 -0
  67. package/workspace/public/pm/cozy-home.css +152 -0
  68. package/workspace/public/pm/cozy-home.js +170 -0
  69. package/workspace/public/pm/cozy-initiative.css +138 -0
  70. package/workspace/public/pm/cozy-insights.css +292 -0
  71. package/workspace/public/pm/cozy-nav.js +54 -0
  72. package/workspace/public/pm/cozy-viewer.css +143 -0
  73. package/workspace/public/pm/cozy.css +172 -0
  74. package/workspace/public/pm/lifecycle-lens-model.js +45 -27
  75. package/workspace/public/pm/lifecycle-lens.js +22 -11
  76. package/workspace/public/pm/premium-board.js +329 -67
  77. package/workspace/public/pm/premium-brief.js +1 -1
  78. package/workspace/public/pm/premium-chat.js +17 -10
  79. package/workspace/public/pm/premium-initiative-head.js +138 -0
  80. package/workspace/public/pm/premium-initiative.js +28 -4
  81. package/workspace/public/pm/premium-insights.js +530 -244
  82. package/workspace/public/pm/premium-shell.js +40 -10
  83. package/workspace/public/pm/premium-viewer.js +5 -0
  84. package/workspace/public/pm/premium-vw-jira-model.js +22 -5
  85. package/workspace/public/pm/premium-vw-jira.css +11 -0
  86. package/workspace/public/pm/premium-vw-jira.js +11 -4
  87. package/workspace/public/pm/premium-vw-rec.js +5 -2
  88. package/workspace/public/pm/premium-wide.css +30 -0
  89. package/workspace/public/pm/premium-work.js +18 -8
  90. package/workspace/public/pm/premium.js +19 -6
  91. package/workspace/public/premium-board.html +83 -47
  92. package/workspace/public/premium-chat.html +7 -32
  93. package/workspace/public/premium-initiative.html +16 -8
  94. package/workspace/public/premium-insights.html +83 -43
  95. package/workspace/public/premium-work.html +6 -71
  96. package/workspace/public/premium.html +62 -15
  97. package/workspace/public/vendor/nunito-var.woff2 +0 -0
  98. package/workspace/server.js +7 -0
  99. package/workspace/test-lists/premium-agreed-viewer.json +9 -0
  100. package/workspace/third-party/README.md +1 -0
@@ -20,8 +20,6 @@ const fs = require('fs');
20
20
  const path = require('path');
21
21
  const { spawn } = require('child_process');
22
22
  const { findBrowser } = require('./lib/find-browser');
23
- const CT = require('./lib/premium-console-type'); // the mockup is read with the console's type (PM, 2026-10-19), as premium.css is
24
- const CT_VENDOR = 'file://' + path.join(__dirname, 'public', 'vendor') + '/';
25
23
  const T = require('./test-run').configure({ name: 'briefing-premium' });
26
24
  const B = require('./lib/briefing-premium.js');
27
25
  const F = require('./fixtures/briefing-premium-facts.js');
@@ -42,8 +40,11 @@ const finish = async (code) => {
42
40
  };
43
41
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
44
42
 
43
+ /* premium-agreed-design H2: on a desktop Home the chat is docked and always open (#dlg.on), and closing a row's conversation goes back to
44
+ * the PM's own chat (title "Chat"). So "a row's dialog is open" is __rowOn(): the dialog is on and shows something other than that own chat.
45
+ * On a phone, and on every other page, it is the dialog being on, as before. */
46
+ const ROW_ON = () => { window.__rowOn = () => { const g = document.querySelector('#dlg'); return !!g && g.classList.contains('on') && !(document.body.classList.contains('cz-dock') && document.querySelector('#dTitle').textContent === 'Chat'); }; };
45
47
  const MODEL = B.build(F.facts());
46
- const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html');
47
48
 
48
49
  (async () => {
49
50
  const exe = findBrowser();
@@ -58,7 +59,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
58
59
  browser = await chromium.launch({ executablePath: exe });
59
60
  { /* every context starts with the console's Needs you read off (see open below); a page route set by `console` wins over it */
60
61
  const nc = browser.newContext.bind(browser);
61
- browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
62
+ browser.newContext = async (...args) => { const c = await nc(...args); await c.addInitScript(ROW_ON); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
62
63
  }
63
64
 
64
65
  /* The console's Needs you reads (premium-brief.js): off by default, so the page keeps the model's records-only hero and rows, which most of
@@ -172,12 +173,11 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
172
173
  await xp.route('**/api/session/say', (r) => { said.push({ ...JSON.parse(r.request().postData()), hasNonce: !!r.request().headers()['x-pmos-nonce'] }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
173
174
  await xp.route('**/api/session/remove', (r) => { removes++; const id = JSON.parse(r.request().postData()).id; if (id === 'sess-4' && slowOnce) { slowOnce = false; return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: false, note: 'asked it to end' }) }); } const i = fake.findIndex((x) => x.id === id); if (i >= 0) fake.splice(i, 1); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: true }) }); });
174
175
  await xp.goto(BASE + '/premium.html?theme=light'); await until(() => xp.evaluate(() => document.querySelectorAll('#rank .rr').length > 0), 20000);
175
- const bt = await xp.evaluate(() => { const b = document.querySelector('.rail [data-go="chat"] .orb'); if (!b) return null; const r = b.getBoundingClientRect(); return { w: Math.round(r.width), h: Math.round(r.height) }; });
176
- ok('X1 the rail\'s Chat is a round button of at least 44 px', bt && bt.w >= 44 && bt.h >= 44, JSON.stringify(bt));
177
- await xp.click('.rail [data-go="chat"]'); await until(() => xp.evaluate(() => /premium-chat\.html/.test(location.pathname) && document.querySelector('#dlg').classList.contains('on')), 10000);
178
- ok('X1b Chat goes to the Chat page and carries the Briefing as the conversation it opens', /about=src%3Athis-page/.test(xp.url()) && /label=the(\+|%20)Briefing/.test(xp.url()), xp.url());
179
- const draw = await xp.evaluate(() => { const i = document.querySelector('.rail .ind'), r = document.querySelector('.rail'), d = document.querySelector('#dlg'); return { ind: getComputedStyle(i).display, rail: +getComputedStyle(r).zIndex, dlg: +getComputedStyle(d).zIndex }; });
180
- ok('X1c on the Chat page no grey indicator sits under the Chat button, and the rail is above the dialog so its shadow does not grey the button', draw.ind === 'none' && draw.rail > draw.dlg, JSON.stringify(draw));
176
+ // premium-agreed-design H2/H3: Home docks the chat beside the list (no rail, no veil), and the Chat page's address opens Home with its query
177
+ const dock = await until(() => xp.evaluate(() => { const d = document.querySelector('#dlg'), r = document.querySelector('#hSessions #sRail'); return d.classList.contains('on') && r ? { veil: getComputedStyle(document.querySelector('#veil')).display, inert: document.querySelector('main.stage').inert, list: !!r } : null; }), 10000);
178
+ ok('X1 on a desktop Home docks the chat: it is open with no veil, the list stays live and holds the session list', dock && dock.veil === 'none' && dock.inert === false && dock.list, JSON.stringify(dock));
179
+ await xp.goto(BASE + '/premium-chat.html?theme=light&about=src%3Athis-page&label=the%20Briefing'); await until(() => xp.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /Briefing/.test(document.querySelector('#dTitle').textContent)), 10000);
180
+ ok('X1b /premium-chat.html opens Home with its query, on the conversation it names', /\/premium\.html\?/.test(xp.url()) && /about=src%3Athis-page/.test(xp.url()), xp.url());
181
181
  const lay = await until(() => xp.evaluate(() => { const d = document.querySelector('#dlg'), r = document.querySelector('#sRail'); if (!d.classList.contains('full') || !r || !r.offsetWidth || !document.querySelector('#srlList .srl-r')) return null; const o = { rail: Math.round(r.getBoundingClientRect().width), work: Math.round(document.querySelector('#dBody').getBoundingClientRect().width), out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width) }; return o.out > 300 ? o : null; }), 8000) || (await xp.evaluate(() => ({ rail: document.querySelector('#sRail').getBoundingClientRect().width, work: document.querySelector('#dBody').getBoundingClientRect().width, out: document.querySelector('#dOut').getBoundingClientRect().width, cls: document.querySelector('#dlg').className, mode: document.querySelector('#dlg').dataset.mode, w: document.querySelector('#dlg').getBoundingClientRect().width })));
182
182
  ok('X2 the Chat page opens the Briefing\'s conversation with the list and the conversation; the viewer is closed until something opens in it (premium-chat-viewer V1)', /Ask about the Briefing/.test(await xp.evaluate(() => document.querySelector('#dTitle').textContent)) && lay && lay.out === 0 && lay.rail > 150 && lay.work > 600 && /vw-shut/.test(lay.cls), JSON.stringify(lay));
183
183
  const grpOf = () => xp.evaluate(() => [...document.querySelectorAll('#srlList .srl-g')].map((g) => g.querySelector('.srl-gh span').textContent + ':' + g.querySelectorAll('.srl-r').length + (g.querySelector('.srl-more') ? '+' + g.querySelector('.srl-more').textContent : '')));
@@ -205,9 +205,10 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
205
205
  ok('X10 a session that has not exited says so and offers Stop again, never "Ended"', /has not exited yet/.test(slow), slow);
206
206
  await xp.click('#oMain [data-yes]');
207
207
  ok('X11 the second press ends it, the toast confirms, and the list drops it', !!(await until(() => xp.evaluate(() => /Ended “Driver · drafts search”/.test(document.querySelector('#toast').textContent) && !document.querySelector('#srlList [data-sid="sess-4"]')), 8000)));
208
- await xp.click('#srlFold');
209
- const folded = await until(() => xp.evaluate(() => { const w = document.querySelector('#sRail').getBoundingClientRect().width; return w > 0 && w < 70 ? Math.round(w) : 0; }), 4000);
210
- ok('X12 the list folds to a strip of dots', folded > 0, String(folded));
208
+ await xp.click('#sessGrp .cz-fold'); // premium-agreed-design H1: on Home the session list is a group of the list, and folds with the group's own fold
209
+ const folded = await until(() => xp.evaluate(() => document.querySelector('#sRail').getBoundingClientRect().width === 0 && document.querySelector('#sessGrp .cz-fold').getAttribute('aria-expanded') === 'false'), 4000);
210
+ ok('X12 the Sessions group folds away and says so', !!folded, String(folded));
211
+ await xp.click('#sessGrp .cz-fold');
211
212
  await xp.click('#vFold'); // premium-chat-viewer V3: on the Chat page the viewer's button closes it, and the head's Viewer chip opens it again
212
213
  const vf = await until(() => xp.evaluate(() => document.querySelector('#dOut').getBoundingClientRect().width === 0 && document.querySelector('#dlg').classList.contains('vw-shut')), 4000);
213
214
  ok('X13 the viewer closes and the conversation takes the width', !!vf && (await xp.evaluate(() => document.querySelector('#dBody').getBoundingClientRect().width)) > 800, String(vf));
@@ -217,7 +218,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
217
218
  const shell = await xp.evaluate(() => ({ close: !!document.querySelector('#dClose').offsetParent, expand: !!document.querySelector('#dExpand').offsetParent, rail: !document.querySelector('.rail').inert }));
218
219
  await xp.keyboard.press('Escape');
219
220
  ok('X13c the Chat page has no close and no full-screen button, its rail stays live, and Escape keeps it open', !shell.close && !shell.expand && shell.rail && await xp.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#dlg').classList.contains('full')), JSON.stringify(shell));
220
- await xp.click('#srlFold'); // the viewer stays closed: on the Chat page nothing remembers it
221
+ // the Sessions group was unfolded again above (X12), so the list is back for X14 and X15
221
222
  /* the soft warning: silent at 6 working agents, speaks at 7, at the top of the list */
222
223
  const before = fake.slice();
223
224
  const mk = (n) => Array.from({ length: n }, (_, i) => ({ id: 'w-' + i, name: 'Agent ' + i, agent: 'claude', note: '', cwd: '.', created: new Date().toISOString(), shown: 'working', label: 'working', automatic: false }));
@@ -286,7 +287,9 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
286
287
  ok('R7 Today has Ahead, a now marker and Earlier today', tl.groups.join() === 'Ahead,Earlier today' && /^18:05 · snapshot$/.test(tl.now), JSON.stringify(tl));
287
288
  ok('R7 the caption counts earlier and ahead', tl.cap === `${MODEL.today.earlier.length} earlier · ${MODEL.today.ahead.length} ahead`, tl.cap);
288
289
  ok('R7 one chip per source with its count', tl.chips.join() === 'Calendar2,Merges3,Agent runs0', tl.chips.join());
289
- ok('R7 the Calendar header shows only ⋯ and the fold; Notes, the source filter and the full calendar wait in the shut ⋯ (premium-calmer-first-screen)', await p.evaluate(() => { const h = document.querySelector('#todayCard .ch'), seen = [...h.querySelectorAll('button')].filter((b) => b.getClientRects().length).map((b) => b.id || b.className); const m = document.querySelector('#calMenu'); return seen.join() === 'calMore,foldb' && m.hidden && !!m.querySelector('.fbtn') && !!m.querySelector('#vnOpen') && !!m.querySelector('.vc-open'); }));
290
+ { const cal = await p.evaluate(() => { const h = document.querySelector('#todayCard .ch'), seen = [...h.querySelectorAll('button')].filter((b) => b.getClientRects().length).map((b) => b.id || b.className); const m = document.querySelector('#calMenu'); return { seen: seen.join(), shut: m.hidden, menu: !!m.querySelector('.fbtn') && !!m.querySelector('#vnOpen') && !!m.querySelector('.vc-open') }; });
291
+ // premium-agreed-design H1: on Home the Calendar is a group of the list, so its header also carries the group's own fold (cz-fold) first
292
+ ok('R7 the Calendar header shows only the group fold, ⋯ and the calendar fold; Notes, the source filter and the full calendar wait in the shut ⋯ (premium-calmer-first-screen)', cal.seen === 'cz-fold,calMore,foldb' && cal.shut && cal.menu, JSON.stringify(cal)); }
290
293
  await p.click('#calMore');
291
294
  ok('R7 ⋯ opens the menu with Notes, Filter sources and Full calendar', await p.evaluate(() => { const m = document.querySelector('#calMenu'); return !m.hidden && document.querySelector('#calMore').getAttribute('aria-expanded') === 'true' && /Notes.*Filter sources.*Full calendar/.test(m.textContent); }));
292
295
  await p.click('.fbtn');
@@ -300,22 +303,26 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
300
303
  const row0 = p.locator('#rank .rhd').first();
301
304
  await row0.focus();
302
305
  await row0.press('Enter');
303
- const dlg = await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')), 4000);
306
+ const dlg = await until(() => p.evaluate(() => __rowOn()), 4000);
304
307
  ok('R4 Enter on a row opens the standard dialog', dlg);
305
- const d = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, inert: ['.rail', 'main.stage', '#dock'].every((s) => document.querySelector(s).inert), pane: document.querySelector('#oMain').textContent, card: document.querySelector('#card') ? document.querySelector('#card').textContent : '', log: document.querySelector('#logT') ? document.querySelector('#logT').textContent : '', label: document.querySelector('#oLab').textContent, input: document.querySelector('#askIn').disabled, role: document.querySelector('#dlg').getAttribute('aria-modal') }));
306
- ok('R11 the page behind the dialog is inert and the dialog is modal', d.inert && d.role === 'true');
308
+ const d = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, live: ['.rail', 'main.stage'].every((s) => !document.querySelector(s).inert), veil: getComputedStyle(document.querySelector('#veil')).display, pane: document.querySelector('#oMain').textContent, card: document.querySelector('#card') ? document.querySelector('#card').textContent : '', log: document.querySelector('#logT') ? document.querySelector('#logT').textContent : '', label: document.querySelector('#oLab').textContent, input: document.querySelector('#askIn').disabled, role: document.querySelector('#dlg').getAttribute('aria-modal') }));
309
+ // premium-agreed-design H2: on a desktop Home the row's chat docks beside the list, so the list stays live and the dialog is not modal
310
+ // (a phone still opens it as a modal popup over an inert page: checked at 390 px below)
311
+ ok('R11 on a desktop Home the row\'s chat docks beside the list: the list and the rail stay live, nothing is veiled and the dialog is not modal', d.live && d.role === 'false' && d.veil === 'none', JSON.stringify({ live: d.live, role: d.role, veil: d.veil }));
307
312
  ok('R4 the dialog offers Pin to the top for a list row (premium-calmer-first-screen)', await p.evaluate(() => { const b = document.querySelector('#card .dpin'); return !!b && /Pin to the top/.test(b.textContent) && b.getAttribute('aria-pressed') === 'false'; }));
308
313
  ok('R4 the dialog names the row, with an activity log of what was read', d.title === MODEL.list.rows[0].title && /Readfromtherepository3steps/.test(d.log.replace(/\s+/g, '')), d.log);
309
314
  ok('R4 the detail pane opens with the record\'s path and does not repeat the title the dialog head shows (popup context slice 2)', await p.evaluate(() => { const o = document.querySelector('#oMain'), t = document.querySelector('#dTitle').textContent.trim(); return !!o.querySelector('.dpath') && ![...o.querySelectorAll('.d1, h1, h2, h3')].some((h) => h.textContent.trim() === t); }));
310
315
  ok('R4 the card holds the evidence and the next step, and the right pane the record', /The way through/.test(d.card) && /Blocked at/.test(d.card) && /Initiative record/.test(d.label) && /planning\/initiatives|console-3-boards/.test(d.pane), d.card.slice(0, 120));
311
- await until(() => p.evaluate(() => getComputedStyle(document.querySelector('#dlg')).transform === 'none' || /matrix\(1, 0, 0, 1, 0, 0\)/.test(getComputedStyle(document.querySelector('#dlg')).transform)), 3000);
312
- const pane0 = await p.evaluate(() => { const b = document.querySelector('#dPane'); const r = b.getBoundingClientRect(); return { on: b.getAttribute('aria-pressed'), t: b.title, w: r.width, h: r.height, convo: getComputedStyle(document.querySelector('#dBody')).display }; });
313
- ok('R4 the dialog has a button that hides the conversation, 44 px, shown pressed while it is visible', pane0.on === 'true' && /Hide the conversation/.test(pane0.t) && pane0.w >= 44 && pane0.h >= 44 && pane0.convo !== 'none', JSON.stringify(pane0));
314
- await p.click('#dPane');
315
- const pane1 = await p.evaluate(() => ({ mode: document.querySelector('#dlg').dataset.mode, convo: getComputedStyle(document.querySelector('#dBody')).display, detail: getComputedStyle(document.querySelector('#dOut')).display, t: document.querySelector('#dPane').title }));
316
- ok('R4 pressing it hides the conversation and leaves the detail, and the button says how to bring it back', pane1.mode === 'detail' && pane1.convo === 'none' && pane1.detail !== 'none' && /Show the conversation/.test(pane1.t), JSON.stringify(pane1));
317
- await p.click('#dPane');
318
- ok('R4 pressing it again shows the conversation', await p.evaluate(() => document.querySelector('#dlg').dataset.mode === 'split' && getComputedStyle(document.querySelector('#dBody')).display !== 'none'));
316
+ // premium-agreed-design H2: the docked chat has no hide-the-conversation, close or full-screen button; the record sits in the Viewer on the
317
+ // right, which folds from its own button and opens again from the head's Viewer chip, and the conversation stays in view throughout
318
+ const pane0 = await until(() => p.evaluate(() => { const hid = (s) => { const e = document.querySelector(s); return !e || !e.getClientRects().length; }, o = document.querySelector('#dOut').getBoundingClientRect(); return o.width > 300 ? { pane: hid('#dPane'), close: hid('#dClose'), expand: hid('#dExpand'), fold: !hid('#vFold'), out: Math.round(o.width), convo: getComputedStyle(document.querySelector('#dBody')).display } : null; }), 4000);
319
+ ok('R4 the docked chat shows the record in the Viewer beside the conversation, with a fold for the Viewer and no hide-the-conversation, close or full-screen button', pane0 && pane0.pane && pane0.close && pane0.expand && pane0.fold && pane0.convo !== 'none', JSON.stringify(pane0));
320
+ const w0 = await p.evaluate(() => Math.round(document.querySelector('#dBody').getBoundingClientRect().width));
321
+ await p.click('#vFold');
322
+ const pane1 = await until(() => p.evaluate(() => { const g = document.querySelector('#dlg'), pill = document.querySelector('#vwPill'); return g.classList.contains('vw-shut') ? { out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width), convo: Math.round(document.querySelector('#dBody').getBoundingClientRect().width), pill: !!pill && !pill.hidden } : null; }), 4000);
323
+ ok('R4 folding the Viewer leaves the conversation, wider, and the head\'s Viewer chip says how to bring it back', pane1 && pane1.out === 0 && pane1.convo > w0 && pane1.pill, JSON.stringify({ w0, pane1 }));
324
+ await p.click('#vwPill');
325
+ ok('R4 the Viewer chip opens the record again', !!(await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('vw-shut') && document.querySelector('#dOut').getBoundingClientRect().width > 300 && /planning\/initiatives|console-3-boards/.test(document.querySelector('#oMain').textContent)), 4000)));
319
326
  ok('D12 the reply box talks to a Claude Code session, and says what it can do', !d.input && await p.evaluate(() => !document.querySelector('#askIn').disabled && /Claude Code session/.test(document.querySelector('#askNote').textContent)));
320
327
  { const nq = await p.evaluate(() => { const n = document.querySelector('#askNote'); document.activeElement && document.activeElement.blur(); const off = getComputedStyle(n).display; document.querySelector('#askIn').focus(); return { quiet: n.classList.contains('quiet'), off, on: getComputedStyle(n).display }; });
321
328
  ok('D12 the standing note under the message box shows while you write there (premium-calmer-first-screen)', nq.quiet && nq.off === 'none' && nq.on !== 'none', JSON.stringify(nq)); }
@@ -327,15 +334,15 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
327
334
  await p.click('[data-start="no"]');
328
335
  ok('W8 Not now goes back to the Start button', await p.evaluate(() => !!document.querySelector('#startBtn') && !document.querySelector('#startGo')) && startBody === null);
329
336
  await p.click('#startBtn'); await p.click('#startGo');
330
- ok('W8 confirming starts a draft session for that initiative and closes the dialog', await until(() => startBody && p.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))) && startBody.task === 'draft' && !!startBody.initiative && !!startBody.what, JSON.stringify(startBody));
337
+ ok('W8 confirming starts a draft session for that initiative and closes the dialog', await until(() => startBody && p.evaluate(() => !__rowOn())) && startBody.task === 'draft' && !!startBody.initiative && !!startBody.what, JSON.stringify(startBody));
331
338
  await p.unroute('**/api/agent/start');
332
339
  await row0.focus(); await row0.press('Enter');
333
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
340
+ await until(() => p.evaluate(() => __rowOn()));
334
341
  await p.keyboard.press('Escape');
335
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
342
+ await until(() => p.evaluate(() => !__rowOn()));
336
343
  // a decision row: no option is chosen for the PM, choosing one drafts the record, and "Not yet" is off
337
344
  await p.locator('#rank .rhd').nth(3).click();
338
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
345
+ await until(() => p.evaluate(() => __rowOn()));
339
346
  const dc = await p.evaluate(() => ({ ops: document.querySelectorAll('#card .op').length, pressed: document.querySelectorAll('#card .op[aria-pressed="true"]').length, rec: !!document.querySelector('#card .op em'), cta: document.querySelector('#card .cta').textContent, pane: document.querySelector('#oMain').textContent, label: document.querySelector('#oLab').textContent, snooze: [...document.querySelectorAll('#card .seg2 button')].every((b) => !b.disabled && b.hasAttribute('data-until')) }));
340
347
  ok('R6 a decision opens with three options and none chosen, and none marked Recommended', dc.ops === 3 && dc.pressed === 0 && !dc.rec && /Your call: choose one/.test(dc.cta), JSON.stringify(dc));
341
348
  ok('R6 the right pane is a draft decision record that says nothing is written until Record', /Decision record/.test(dc.label) && /pm-decisions.md · draft entry/.test(dc.pane) && /Nothing is written to the journal until you press Record/.test(dc.pane) && /Choose an option to draft the entry/.test(dc.pane));
@@ -344,28 +351,28 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
344
351
  ok('R6 choosing an option updates the button and the draft, and the button stays off', /Extend the date/.test(dc2.pressed) && /Record: extend/i.test(dc2.cta) && dc2.dis && /Extend the date/.test(dc2.pane) && /extend the date/.test(dc2.pane), JSON.stringify(dc2).slice(0, 200));
345
352
  ok('W3 "Not yet" has three live choices', dc.snooze);
346
353
  await p.keyboard.press('Escape');
347
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
354
+ await until(() => p.evaluate(() => !__rowOn()));
348
355
  // the failed-reviews row lists every review with its score
349
356
  await p.locator('#rank .rhd').nth(4).click();
350
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
357
+ await until(() => p.evaluate(() => __rowOn()));
351
358
  ok('R4 the reviews row lists each review with its age and score, and proposes nothing', await p.evaluate(() => document.querySelectorAll('#card .tri').length === 5 && /Scored|No score recorded/.test(document.querySelector('#card').textContent) && !document.querySelector('#card .cta') && /No proposal is on record/.test(document.querySelector('#dBody').textContent)));
352
359
  await row0.focus();
353
360
  await p.keyboard.press('Escape');
354
- ok('R11 Escape closes the dialog and focus returns to the row', await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && document.activeElement.classList.contains('rhd'))));
361
+ ok('R11 Escape closes the dialog and focus returns to the row', await until(() => p.evaluate(() => !__rowOn() && document.activeElement.classList.contains('rhd'))));
355
362
  ok('R11 the page is live again after the dialog', await p.evaluate(() => !document.querySelector('main.stage').inert));
356
363
 
357
364
  /* the Today dialogs: a merge shows its files and message, a meeting its time and people */
358
365
  await p.locator('#tl .ev.src-meeting').first().click();
359
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
366
+ await until(() => p.evaluate(() => __rowOn()));
360
367
  const ev = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, card: document.querySelector('#card').textContent, pane: document.querySelector('#oMain').textContent, label: document.querySelector('#oLab').textContent }));
361
368
  ok('R7 a meeting opens a dialog with its time, length and people, from the calendar', /Design review/.test(ev.title) && /Time/.test(ev.card) && /18:30 to 19:15/.test(ev.card) && /Lee, Priya/.test(ev.card) && ev.label === 'Meeting', JSON.stringify(ev).slice(0, 200));
362
369
  await p.keyboard.press('Escape');
363
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
370
+ await until(() => p.evaluate(() => !__rowOn()));
364
371
  await p.locator('#tl .ev.src-merge').first().click();
365
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
372
+ await until(() => p.evaluate(() => __rowOn()));
366
373
  ok('R7 a merge opens a dialog that says it reached main, with a disabled "Return this run to the agent"', await p.evaluate(() => /merged to main/.test(document.querySelector('#oMain').textContent) && /reached main today/.test(document.querySelector('#dBody').textContent) && document.querySelector('#card .cta').disabled && /Return this run to the agent/.test(document.querySelector('#card .cta').textContent) && /no run of its own/.test(document.querySelector('#holdWhy').textContent)));
367
374
  await p.keyboard.press('Escape');
368
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
375
+ await until(() => p.evaluate(() => !__rowOn()));
369
376
 
370
377
  /* R10 */
371
378
  ok('R10 a page where nothing was pressed to record sent only GET requests (the one confirmed Start, closing the bell and recording an opened popup aside)', A.reqs.every((r) => r.startsWith('GET ') || r === 'POST /api/agent/start' || r === 'POST /api/inbox/seen' || r === 'POST /api/briefing-premium/seen'), A.reqs.filter((r) => !r.startsWith('GET ')).join());
@@ -383,8 +390,8 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
383
390
  await pg.route('**/api/briefing-premium/*', (r) => { const rq = r.request(); if (rq.method() === 'GET') return r.fulfill({ contentType: 'application/json', body: JSON.stringify(thread) }); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}'), headers: rq.headers() }); r.fulfill({ status: answer.status, contentType: 'application/json', body: JSON.stringify(answer.body) }); });
384
391
  await pg.goto(BASE + '/premium.html');
385
392
  await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
386
- const openIdx = async (i) => { await pg.locator('#rank .rhd').nth(i).click(); await until(() => pg.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(700); };
387
- const shut = async () => { await pg.keyboard.press('Escape'); await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))); };
393
+ const openIdx = async (i) => { await pg.locator('#rank .rhd').nth(i).click(); await until(() => pg.evaluate(() => __rowOn())); await sleep(700); };
394
+ const shut = async () => { await pg.keyboard.press('Escape'); await until(() => pg.evaluate(() => !__rowOn())); };
388
395
  // a decision: the button waits for a choice and a reason
389
396
  await openIdx(3);
390
397
  const btn = () => pg.evaluate(() => { const b = document.querySelector('#recBtn'); return { dis: b.disabled, t: b.textContent.trim(), h: b.getBoundingClientRect().height }; });
@@ -399,19 +406,19 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
399
406
  // a refusal: the reason is shown and what was typed is kept
400
407
  answer = { status: 409, body: { ok: false, error: 'a decision that names KC5 is already on record' } };
401
408
  await pg.click('#recBtn');
402
- ok('W6 a refused press shows the server reason, keeps the dialog open and keeps the typed reason', await until(() => pg.evaluate(() => !document.querySelector('#cardErr').hidden && /already on record/.test(document.querySelector('#cardErr').textContent) && document.querySelector('#why').value === 'Give it a quarter' && document.querySelector('#dlg').classList.contains('on') && !document.querySelector('#recBtn').disabled)));
409
+ ok('W6 a refused press shows the server reason, keeps the dialog open and keeps the typed reason', await until(() => pg.evaluate(() => !document.querySelector('#cardErr').hidden && /already on record/.test(document.querySelector('#cardErr').textContent) && document.querySelector('#why').value === 'Give it a quarter' && __rowOn() && !document.querySelector('#recBtn').disabled)));
403
410
  ok('W6 the refused press was sent once with the key, the choice and the reason, and no writer field', posts.length === 1 && posts[0].path === '/api/briefing-premium/decide' && posts[0].body.key === 'decision:KC5' && posts[0].body.choice === 'extend' && posts[0].body.why === 'Give it a quarter' && !['by', 'via', 'at', 'actor', 'pm'].some((k) => k in posts[0].body), JSON.stringify(posts[0]));
404
411
  // success: the dialog closes and the page reads again
405
412
  answer = { status: 200, body: { ok: true } }; const g0 = gets;
406
413
  await pg.click('#recBtn');
407
- ok('W7 a recorded press closes the dialog and reads the model again', await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))) && await until(() => gets > g0, 4000));
414
+ ok('W7 a recorded press closes the dialog and reads the model again', await until(() => pg.evaluate(() => !__rowOn())) && await until(() => gets > g0, 4000));
408
415
  ok('W7 the page says where it was recorded', await pg.evaluate(() => /pm-decisions\.md/.test(document.querySelector('#toast').textContent)));
409
416
  // not yet
410
417
  await openIdx(3);
411
418
  ok('W3 "Later" is one quiet button in the bottom bar, and its menu stays shut until pressed', await pg.evaluate(() => { const b = document.querySelector('#card .dbar #laterBtn'), m = document.querySelector('#laterMenu'); return !!b && b.getAttribute('aria-expanded') === 'false' && m.hidden && !!document.querySelector('#card .dbar #recBtn') && !document.querySelector('#card .mv2'); }));
412
419
  await pg.click('#laterBtn');
413
420
  await pg.locator('#card .seg2 button[data-until="tomorrow"]').click();
414
- ok('W3 "Tomorrow" posts the key and the time, and closes the dialog', await until(() => posts.some((x) => x.path === '/api/briefing-premium/put-off' && x.body.key === 'decision:KC5' && x.body.until === 'tomorrow')) && await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))));
421
+ ok('W3 "Tomorrow" posts the key and the time, and closes the dialog', await until(() => posts.some((x) => x.path === '/api/briefing-premium/put-off' && x.body.key === 'decision:KC5' && x.body.until === 'tomorrow')) && await until(() => pg.evaluate(() => !__rowOn())));
415
422
  // slice 3: the read-only agent behind the reply box
416
423
  await shut(); await openIdx(3);
417
424
  ok('A1 the reply box has one Send to Claude button, 44 px, and no note button', await pg.evaluate(() => { const a = document.querySelector('#askGo'); const h = (e) => e.getBoundingClientRect().height; return !!a && h(a) >= 44 && /Send to Claude/.test(a.title) && !document.querySelector('#noteGo') && ![...document.querySelector('#askF').childNodes].filter((n) => n.id !== 'plusM').some((n) => /note/i.test(n.textContent)); })); // the + menu's Notes item opens the notepad, not a note button
@@ -451,20 +458,20 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
451
458
  await shut();
452
459
  // return a run
453
460
  await pg.locator('#tl .ev.src-run').first().click();
454
- await until(() => pg.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(700);
461
+ await until(() => pg.evaluate(() => __rowOn())); await sleep(700);
455
462
  ok('W2 a run dialog offers the four reasons and the return button waits for one', await pg.evaluate(() => [...document.querySelectorAll('#retWhy button')].map((b) => b.textContent).join() === 'wrong facts,wrong scope,not now,too long' && document.querySelector('#recBtn').disabled));
456
463
  await pg.locator('#retWhy button').nth(1).click();
457
464
  ok('W2 choosing a reason turns it on', await pg.evaluate(() => !document.querySelector('#recBtn').disabled && document.querySelector('#retWhy button[aria-pressed="true"]').textContent === 'wrong scope'));
458
465
  await pg.click('#recBtn');
459
466
  ok('W2 the press posts the run and the reason', await until(() => posts.some((x) => x.path === '/api/briefing-premium/return' && x.body.run === 'run-x1' && x.body.reason === 'wrong scope' && Object.keys(x.body).sort().join() === 'reason,run')));
460
- await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
467
+ await until(() => pg.evaluate(() => !__rowOn()));
461
468
  // W10 floors on a phone, both themes: the new controls are 44 px and nothing scrolls sideways
462
469
  for (const theme of ['light', 'dark']) {
463
470
  const c = await browser.newContext({ viewport: { width: 390, height: 800 } }), q = await c.newPage();
464
471
  await q.route('**/api/briefing-premium', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: model2, as_of: Date.now() }) }));
465
472
  await q.goto(BASE + '/premium.html?theme=' + theme);
466
473
  await until(() => q.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
467
- await q.locator('#rank .rhd').nth(3).click(); await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(800);
474
+ await q.locator('#rank .rhd').nth(3).click(); await until(() => q.evaluate(() => __rowOn())); await sleep(800);
468
475
  await q.click('#dTabs [data-t="chat"]'); await sleep(300);
469
476
  await q.locator('#card .op').nth(0).click(); await q.fill('#why', 'A reason'); await q.click('#laterBtn');
470
477
  const m = await q.evaluate(() => { const hs = (sel) => [...document.querySelectorAll(sel)].map((b) => Math.round(b.getBoundingClientRect().height)); return { over: document.documentElement.scrollWidth > innerWidth + 1 || document.querySelector('#dlg').scrollWidth > document.querySelector('#dlg').clientWidth + 1, small: [].concat(hs('#card .seg2 button'), hs('#recBtn'), hs('#askIn'), hs('#askGo'), hs('#card .op')).filter((h) => h < 44) }; });
@@ -528,14 +535,15 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
528
535
  const part = B.build({ ...F.facts(), initiatives: [], pending: true });
529
536
  const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
530
537
  pg.on('pageerror', (e) => errs.push(String(e)));
531
- let calls = 0;
532
- await pg.route('**/api/briefing-premium*', (r) => { calls++; const body = calls < 2 ? { ok: true, state: 'ready', model: part, as_of: Date.now(), pending: true } : { ok: true, state: 'ready', model: MODEL, as_of: Date.now() }; return r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) }); });
538
+ let release = false; // the full answer waits until the partial one has been read: on Home the page's load event can come after the 3 s re-ask
539
+ await pg.route('**/api/briefing-premium*', (r) => { const body = !release ? { ok: true, state: 'ready', model: part, as_of: Date.now(), pending: true } : { ok: true, state: 'ready', model: MODEL, as_of: Date.now() }; return r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) }); });
533
540
  await pg.goto(BASE + '/premium.html');
534
541
  await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
535
542
  const pv = await pg.evaluate(() => ({ snap: document.querySelector('#snap').textContent, cap: document.querySelector('#movesCap').textContent, calm: document.querySelector('#calm').hidden, note: document.querySelector('#order').textContent, dock: document.querySelector('#dN').textContent + ' ' + document.querySelector('#dLab').textContent, rows: [...document.querySelectorAll('#rank .rt')].map((x) => x.childNodes[0].textContent), bar: document.querySelector('#mprog').hidden }));
536
543
  ok('R13 a partial answer says it is still reading the initiative state, in the header, the list and the dock', /reading initiative state/.test(pv.snap) && /so far · still reading/.test(pv.cap) && /appear when the initiative state has been read/.test(pv.note) && /still reading/.test(pv.dock), JSON.stringify(pv));
537
544
  ok('R13 it never says nothing needs you or all clear while the state is unread', pv.calm === true && !/All clear/.test(pv.cap) && pv.bar === true);
538
545
  ok('R13 it shows only what the quick sources hold (the kill-condition decision), not blocked work', pv.rows.length === 1 && /missed KC5 date/.test(pv.rows[0]), JSON.stringify(pv.rows));
546
+ release = true;
539
547
  ok('R13 it asks again and replaces the partial answer with the full one', await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length === 5 && !/reading initiative state/.test(document.querySelector('#snap').textContent)), 9000));
540
548
  ok('0 no page error on a partial answer', errs.length === 0, errs.join(' | '));
541
549
  await ctx.close();
@@ -551,11 +559,11 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
551
559
  await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
552
560
  ok('R9 a failed read says why in the header, and the page does not keep saying it is reading', await pg.evaluate(() => /the latest read failed: boom in build/.test(document.querySelector('#snap').textContent) && !/reading initiative state/.test(document.querySelector('#snap').textContent)));
553
561
  await pg.locator('#rank .rhd').first().click();
554
- ok('R4 a row with no dialog still opens one from what the row says', await until(() => pg.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /What is known/.test(document.querySelector('#card').textContent) && /If you skip/.test(document.querySelector('#card').textContent)), 4000));
562
+ ok('R4 a row with no dialog still opens one from what the row says', await until(() => pg.evaluate(() => __rowOn() && /What is known/.test(document.querySelector('#card').textContent) && /If you skip/.test(document.querySelector('#card').textContent)), 4000));
555
563
  await pg.keyboard.press('Escape');
556
- await until(() => pg.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
564
+ await until(() => pg.evaluate(() => !__rowOn()));
557
565
  await pg.locator('#tl .ev').first().click();
558
- ok('R7 a Today item with no dialog still opens one', await until(() => pg.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#card')), 4000));
566
+ ok('R7 a Today item with no dialog still opens one', await until(() => pg.evaluate(() => __rowOn() && !!document.querySelector('#card')), 4000));
559
567
  ok('0 no page error when a dialog is missing', errs.length === 0, errs.join(' | '));
560
568
  await ctx.close();
561
569
  }
@@ -595,30 +603,31 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
595
603
  ok('C4 the header and the dock count the same two rows, and the bell counts the agent\'s new result', /2 rows left/.test(got.cap) && got.dn === '2' && got.bell === '1', JSON.stringify(got));
596
604
  const dec = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Pick the launch market/.test(r.textContent)));
597
605
  await cp.locator('#rank .rr .rhd').nth(dec).click();
598
- await until(() => cp.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
606
+ await until(() => cp.evaluate(() => __rowOn()));
599
607
  const dd = await cp.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, body: document.querySelector('#dBody').textContent, ask: document.querySelector('#askF').hidden, link: (document.querySelector('#srcLink') || {}).href || '' }));
600
608
  ok('C5 a decision opens the dialog with what its record says, its source link and its own conversation (premium-popup-context P1)', dd.title === 'Pick the launch market' && /Read from the console Briefing/.test(dd.body) && !dd.ask && /J-7/.test(dd.link), JSON.stringify(dd));
601
609
  await cp.keyboard.press('Escape');
602
- await cp.route('**/premium-work.html*', (r) => r.fulfill({ contentType: 'text/html', body: '<p>work</p>' }));
610
+ // premium-agreed-design H2: Home holds My work, so your own item opens on Home itself (premium.js hands its id to premium-work.js)
611
+ await cp.evaluate(() => { window.__items = []; document.addEventListener('pmos:item', (e) => window.__items.push(e.detail.id)); });
603
612
  const own = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Send Priya the date/.test(r.textContent)));
604
613
  await cp.locator('#rank .rr .rhd').nth(own).click();
605
- await until(() => cp.evaluate(() => /premium-work\.html/.test(location.pathname)));
606
- ok('C6 your own item opens on My work, on that item', await cp.evaluate(() => location.pathname === '/premium-work.html' && new URLSearchParams(location.search).get('item') === 'w1'), await cp.evaluate(() => location.href));
607
- await cp.goBack(); await until(() => cp.evaluate(() => location.pathname === '/premium.html' && document.querySelectorAll('#rank .rr').length === 2), 20000);
614
+ const ownGo = await until(() => cp.evaluate(() => (window.__items.length ? { path: location.pathname, items: window.__items } : null)), 6000);
615
+ ok('C6 your own item opens on Home, on that item, without leaving the page', ownGo && ownGo.path === '/premium.html' && ownGo.items.join() === 'w1', JSON.stringify(ownGo));
616
+ await cp.keyboard.press('Escape');
608
617
  await cp.click('#pvBell');
609
618
  await until(() => cp.evaluate(() => !!document.querySelector('#pvList .ib-bun')), 6000);
610
619
  await cp.locator('#pvList .ib-bun').first().click();
611
- await until(() => cp.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelectorAll('#oMain .bd-it').length > 0));
620
+ await until(() => cp.evaluate(() => __rowOn() && document.querySelectorAll('#oMain .bd-it').length > 0));
612
621
  const pd = await cp.evaluate(() => ({ path: location.pathname, title: document.querySelector('#dTitle').textContent, ids: [...document.querySelectorAll('#oMain .bd-it')].map((x) => x.dataset.id), keep: !!document.querySelector('#oMain [data-bda="pkeep"]'), all: !!document.querySelector('#oMain [data-bda="pall"]') }));
613
622
  ok('C8 a piece of work in the bell opens Agent proposals on the Briefing with that initiative\'s drafts only', pd.path === '/premium.html' && pd.title === '2 wait for you' && pd.ids.join() === 'p1,p2' && pd.keep && pd.all, JSON.stringify(pd));
614
623
  await cp.locator('#oMain [data-bda="pall"]').click();
615
624
  ok('C9 Show all proposals lists every proposal', await until(() => cp.evaluate(() => [...document.querySelectorAll('#oMain .bd-it')].map((x) => x.dataset.id).sort().join() === 'p1,p2,p3')));
616
625
  await cp.keyboard.press('Escape');
617
- await until(() => cp.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
626
+ await until(() => cp.evaluate(() => !__rowOn()));
618
627
  await cp.click('#pvBell');
619
628
  await until(() => cp.evaluate(() => !!document.querySelector('#pvList .ib-it [data-ibo="prop:p1"]')), 6000);
620
629
  await cp.locator('#pvList .ib-it [data-ibo="prop:p1"]').click();
621
- const one = await until(() => cp.evaluate(() => { const ids = [...document.querySelectorAll('#oMain .bd-it')].map((x) => x.dataset.id); return document.querySelector('#dlg').classList.contains('on') && ids.length ? { ids, back: !!document.querySelector('#oMain [data-bda="pbell"]'), path: location.pathname } : null; }), 6000);
630
+ const one = await until(() => cp.evaluate(() => { const ids = [...document.querySelectorAll('#oMain .bd-it')].map((x) => x.dataset.id); return __rowOn() && ids.length ? { ids, back: !!document.querySelector('#oMain [data-bda="pbell"]'), path: location.pathname } : null; }), 6000);
622
631
  ok('C10 a new proposal in the bell opens that one proposal, with a way back to the bell', one && one.ids.join() === 'p1' && one.back && one.path === '/premium.html', JSON.stringify(one));
623
632
  await cp.keyboard.press('Escape');
624
633
  ok('C7 no page error on the console path', C.errors.length === 0, C.errors.join(' | '));
@@ -634,23 +643,21 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
634
643
  const pp = PF.page;
635
644
  await until(() => pp.evaluate(() => [...document.querySelectorAll('#rank .rr')].some((r) => /portfolio draft/.test(r.textContent))));
636
645
  await pp.locator('#rank .rr .rhd').first().click();
637
- await until(() => pp.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('[data-issue-bar="draft"]')));
646
+ await until(() => pp.evaluate(() => __rowOn() && !!document.querySelector('[data-issue-bar="draft"]')));
638
647
  const pf = await pp.evaluate(() => ({ path: location.pathname, title: document.querySelector('#dTitle').textContent, issue: !!document.querySelector('[data-issue-bar="draft"] [data-ds="issue"]') }));
639
648
  ok('C10 a portfolio documents row opens its draft in the document sheet with Issue it, on the Briefing', pf.path === '/premium.html' && pf.title === 'Product strategy' && pf.issue, JSON.stringify(pf));
640
649
  await PF.ctx.close();
641
650
  }
642
651
 
643
- /* R8, R11 the dock folds in on scroll, and is not reachable before it shows */
644
- await p.evaluate(() => window.scrollTo(0, 0));
645
- await until(() => p.evaluate(() => !document.body.classList.contains('docked')));
646
- ok('R11 the dock is inert while it is out of sight', await p.evaluate(() => document.querySelector('#dock').inert === true && !document.body.classList.contains('docked')));
647
- await p.evaluate(() => window.scrollTo(0, 900));
648
- ok('R8 scrolling past the hero shows the dock and makes it reachable', await until(() => p.evaluate(() => document.body.classList.contains('docked') && document.querySelector('#dock').inert === false)));
649
- ok('R4 hovering the decision lights the meeting that needs it', await (async () => { await p.evaluate(() => window.scrollTo(0, 0)); await p.locator('#rank .rr[data-link]').first().hover(); return p.evaluate(() => document.querySelector('#tl .ev[data-link]').classList.contains('hl-k')); })());
650
- await p.evaluate(() => window.scrollTo(0, 900));
652
+ /* R8, R11 premium-agreed-design H1/N2: Home has no scroll dock. On a desktop the list is its own panel that scrolls, the page does not, and the
653
+ * summary line that heads the list does the dock's job; the old dock stays hidden and out of reach at every scroll position */
654
+ const dockOff = () => p.evaluate(() => { const d = document.querySelector('#dock'); return getComputedStyle(d).display === 'none' && d.inert === true; });
655
+ await p.evaluate(() => { window.scrollTo(0, 0); document.querySelector('main.stage').scrollTop = 0; });
656
+ ok('R11 the old dock is hidden and inert on Home', await dockOff());
657
+ const scr = await p.evaluate(() => { const st = document.querySelector('main.stage'); st.scrollTop = 900; window.scrollTo(0, 900); return { list: st.scrollTop, page: Math.round(scrollY), sum: document.querySelector('#hSum').textContent.trim() }; });
658
+ ok('R8 the list scrolls in its own panel, the page does not, the summary line heads the list and the dock stays hidden and unreachable', scr.list > 0 && scr.page === 0 && /need you|Nothing needs you/.test(scr.sum) && await dockOff(), JSON.stringify(scr));
659
+ ok('R4 hovering the decision lights the meeting that needs it', await (async () => { await p.evaluate(() => { document.querySelector('main.stage').scrollTop = 0; }); await p.locator('#rank .rr[data-link]').first().hover(); return p.evaluate(() => document.querySelector('#tl .ev[data-link]').classList.contains('hl-k')); })());
651
660
  await sleep(400);
652
- // the dock scales in over 0.7 s: measure its button once the transition is done, not half-way through it
653
- await until(() => p.evaluate(() => document.body.classList.contains('docked') && !document.querySelector('#dock').getAnimations().some((a) => a.playState === 'running')));
654
661
  /* R11 floors */
655
662
  {
656
663
  const t = await p.evaluate(() => {
@@ -675,7 +682,8 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
675
682
  const ov = await R.page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
676
683
  ok(`R11 no sideways scroll at 390 px (${th})`, ov <= 0, String(ov));
677
684
  await R.page.click('#rank .rhd');
678
- const ph = await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('on')), 3000) && await R.page.evaluate(() => ({ tab: document.querySelector('#dGrid').dataset.tab, pressed: document.querySelector('#dTabs [data-t="out"]').getAttribute('aria-pressed'), tabsShown: getComputedStyle(document.querySelector('#dTabs')).display !== 'none', paneBtn: getComputedStyle(document.querySelector('#dPane')).display, w: Math.round(document.querySelector('#dlg').getBoundingClientRect().width), l: Math.round(document.querySelector('#dlg').getBoundingClientRect().left), vw: innerWidth, btn: document.querySelector('#dPane').getAttribute('aria-pressed'), ov: document.documentElement.scrollWidth - innerWidth }));
685
+ const ph = await until(() => R.page.evaluate(() => __rowOn()), 3000) && await R.page.evaluate(() => ({ inert: ['.rail', 'main.stage', '#dock'].every((s) => document.querySelector(s).inert), modal: document.querySelector('#dlg').getAttribute('aria-modal'), tab: document.querySelector('#dGrid').dataset.tab, pressed: document.querySelector('#dTabs [data-t="out"]').getAttribute('aria-pressed'), tabsShown: getComputedStyle(document.querySelector('#dTabs')).display !== 'none', paneBtn: getComputedStyle(document.querySelector('#dPane')).display, w: Math.round(document.querySelector('#dlg').getBoundingClientRect().width), l: Math.round(document.querySelector('#dlg').getBoundingClientRect().left), vw: innerWidth, btn: document.querySelector('#dPane').getAttribute('aria-pressed'), ov: document.documentElement.scrollWidth - innerWidth }));
686
+ ok(`R11 on a phone the row's dialog is a modal popup and the page behind it is inert (${th})`, ph && ph.inert && ph.modal === 'true', JSON.stringify(ph));
679
687
  ok(`R4 the row's dialog says what skipping costs (${th})`, await R.page.evaluate(() => /If you skip/.test(document.querySelector('#card').textContent)), await R.page.evaluate(() => document.querySelector('#card').textContent.slice(0, 300)));
680
688
  ok(`R4 on a phone the dialog opens on Detail, with the mockup's Detail / Conversation switch and no panel button (${th})`, ph && ph.tab === 'out' && ph.pressed === 'true' && ph.tabsShown && ph.paneBtn === 'none' && ph.l === 0 && ph.w === ph.vw && ph.ov <= 0, JSON.stringify(ph));
681
689
  ok(`0 no page error at 390 px (${th})`, R.errors.length === 0, R.errors.join(' | '));
@@ -684,39 +692,45 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
684
692
  { // a touch phone: iOS zooms the page in when a text field under 16 px gets focus, and the reply box then runs off the right edge
685
693
  const R = await open({ w: 390, h: 844, ctxOpts: { isMobile: true, hasTouch: true } });
686
694
  await R.page.click('#rank .rhd');
687
- await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#askIn')), 3000);
695
+ await until(() => R.page.evaluate(() => __rowOn() && document.querySelector('#askIn')), 3000);
688
696
  const fs16 = await R.page.evaluate(() => [...document.querySelectorAll('input,textarea,select')].filter((e) => !/checkbox|radio|range|button|submit|reset|file|color|image|hidden/.test(e.type)).map((e) => (e.id || e.className || e.tagName) + ':' + getComputedStyle(e).fontSize).filter((s) => parseFloat(s.split(':').pop()) < 16));
689
697
  ok('R11 on a touch phone every text field is at least 16 px, so focus does not zoom the page (the reply box included)', fs16.length === 0 && await R.page.evaluate(() => !!document.querySelector('#askIn')), fs16.join(', '));
690
698
  await R.ctx.close();
691
699
  }
692
700
 
693
- /* R12 fidelity: computed styles and geometry against the mockup */
694
- if (!fs.existsSync(MOCKUP)) ok('R12 the mockup is in the repository', false, MOCKUP);
695
- else {
696
- const PAIRS = [['rail', '.rail'], ['name', '.top .name'], ['date', '.hero .date'], ['brief', '.brief'], ['card', '.cols2>div:first-child .card'], ['today', '#todayCard'], ['heading', '#hMoves'], ['row', '.rr'], ['number', '.rr .rn'], ['title', '.rr .rt'], ['subject', '.rr .rs'], ['tag', '.tgf'], ['group', '#tl .grp'], ['event', '#tl .ev'], ['now', '.nowl'], ['dock', '.dock']];
697
- const SKIP_GEOM = { 1280: [], 390: ['heading'] }; // D5: on a phone the card heading wraps its caption under the title (the mockup wrapped the title over four lines)
698
- const PROPS = ['fontSize', 'fontWeight', 'fontFamily', 'color', 'backgroundColor', 'borderRadius', 'paddingTop', 'paddingLeft', 'letterSpacing', 'lineHeight', 'boxShadow', 'backdropFilter', 'borderTopColor'];
699
- const grab = (pg) => pg.evaluate(([pairs, props]) => { const o = {}; for (const [n, s] of pairs) { const e = document.querySelector(s); if (!e) { o[n] = null; continue; } const cs = getComputedStyle(e), r = e.getBoundingClientRect(), v = { left: Math.round(r.left), width: Math.round(r.width) }; props.forEach((k) => { v[k] = cs[k]; }); o[n] = v; } return o; }, [PAIRS, PROPS]);
700
- for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
701
- const m = await (await browser.newContext({ viewport: { width: w, height: h } })).newPage();
702
- await m.goto('file://' + MOCKUP); await CT.applyToPage(m, CT_VENDOR);
703
- await until(() => m.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 && document.querySelectorAll('#tl .ev').length > 0));
704
- await m.evaluate((t) => { document.documentElement.dataset.theme = t; }, th);
705
- const R = await open({ w, h, theme: th });
706
- if (w === 390) { await R.page.click('#todayCard .folds').catch(() => {}); await R.page.evaluate(() => scrollTo(0, 0)); } // the Calendar card starts hidden on a phone (premium-calendar-card); measure it open
707
- await sleep(500);
708
- const a = await grab(m, PAIRS), c = await grab(R.page, PAIRS), diffs = [];
709
- for (const [n] of PAIRS) {
710
- if (!a[n] || !c[n]) { diffs.push(n + ' missing'); continue; }
711
- for (const k of Object.keys(a[n])) {
712
- if ((k === 'left' || k === 'width') && (SKIP_GEOM[w].includes(n) || ['tag', 'brief', 'now', 'event'].includes(n) && k === 'left')) continue;
713
- if (k === 'width' && ['tag', 'brief', 'title', 'subject'].includes(n)) continue; // D8: the row text leaves room for the pin, so its lines are narrower
714
- if ((k === 'left' || k === 'width') ? Math.abs(a[n][k] - c[n][k]) > 2 : a[n][k] !== c[n][k]) diffs.push(`${n}.${k} ${a[n][k]} | ${c[n][k]}`);
715
- }
716
- }
717
- ok(`R12 styles and geometry match the mockup at ${w} px, ${th}`, diffs.length === 0, diffs.join(' ; '));
718
- await m.context().close(); await R.ctx.close();
719
- }
701
+ /* R12 fidelity, re-pointed to the Agreed design (premium-agreed-design; D60: the new surface's design is the reference the build works from).
702
+ * The Agreed design lives on the PM's canvas, not as a page in the repository, so the page is checked against what it fixes: the cozy layer's
703
+ * tokens (pm/cozy.css: Nunito, the blue palette, cards and wells, light and dark), the floating place menu (N1: 56 px, bottom left at 36 px on a
704
+ * desktop, bottom right on a phone), no rail and no page header on a desktop (N2), and the desktop desk: the list panel, then the docked chat. */
705
+ for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
706
+ const R = await open({ w, h, theme: th });
707
+ await until(() => R.page.evaluate(() => !!document.querySelector('#czFab')), 6000);
708
+ await sleep(500);
709
+ const g = await R.page.evaluate(() => {
710
+ const tok = (v, prop = 'color') => { const e = document.createElement('i'); e.style[prop] = `var(${v})`; document.body.appendChild(e); const c = getComputedStyle(e)[prop]; e.remove(); return c; };
711
+ const cs = (s) => { const e = document.querySelector(s); return e ? getComputedStyle(e) : null; }, rect = (s) => { const e = document.querySelector(s); const r = e && e.getClientRects().length ? e.getBoundingClientRect() : null; return r && { l: Math.round(r.left), r: Math.round(innerWidth - r.right), t: Math.round(r.top), b: Math.round(innerHeight - r.bottom), w: Math.round(r.width), h: Math.round(r.height) }; };
712
+ const T = { ink: tok('--cz-ink'), ink2: tok('--cz-ink2'), card: tok('--cz-card', 'backgroundColor'), bluebg: tok('--cz-bluebg', 'backgroundColor'), blue: tok('--cz-blue', 'backgroundColor') };
713
+ return { T, dark: document.documentElement.dataset.theme === 'dark', font: cs('body').fontFamily, bodyInk: cs('body').color, rowFont: cs('#rank .rr .rt') && cs('#rank .rr .rt').fontFamily, rowInk: cs('#rank .rr .rt') && cs('#rank .rr .rt').color,
714
+ dot: cs('#rank .rr .rn') && cs('#rank .rr .rn').backgroundColor, sumBg: cs('.cz-sum').backgroundColor, sumInk: cs('#hSum').color, head: cs('#hInit') && cs('#hInit').color,
715
+ fab: rect('#czFab'), fabBg: cs('#czFab').backgroundColor, fabLabel: document.querySelector('#czFab').getAttribute('aria-label'), rail: rect('.rail'), stage: rect('main.stage'), dlg: rect('#dlg'), wide: document.documentElement.scrollWidth > innerWidth + 1 };
716
+ });
717
+ const diffs = [], want = (n, a, b) => { if (a !== b) diffs.push(`${n} ${a} | ${b}`); };
718
+ want('theme', g.dark, th === 'dark');
719
+ if (!/^Nunito\b/.test(g.font)) diffs.push('font ' + g.font);
720
+ if (!/^Nunito\b/.test(g.rowFont || '')) diffs.push('row font ' + g.rowFont);
721
+ want('body ink', g.bodyInk, g.T.ink); want('row ink', g.rowInk, g.T.ink); want('row dot', g.dot, g.T.blue); want('summary ground', g.sumBg, g.T.bluebg); want('summary ink', g.sumInk, g.T.ink); want('group heading', g.head, g.T.ink2);
722
+ want('menu button background', g.fabBg, g.T.card);
723
+ if (!g.fab || g.fab.w !== 56 || g.fab.h !== 56) diffs.push('menu button size ' + JSON.stringify(g.fab));
724
+ else if (w >= 1000 ? g.fab.l !== 36 || g.fab.b !== 36 : g.fab.r !== 18 || g.fab.b !== 24) diffs.push('menu button place ' + JSON.stringify(g.fab));
725
+ if (!/Home/.test(g.fabLabel || '')) diffs.push('menu label ' + g.fabLabel);
726
+ if (g.rail) diffs.push('rail shown ' + JSON.stringify(g.rail));
727
+ if (w >= 1000) { // cozy-home.css: the list panel at 44 px from the left, 316 px wide, from 40 px down; the docked chat from 382 px
728
+ if (!g.stage || g.stage.l !== 44 || g.stage.w !== 316 || g.stage.t !== 40) diffs.push('list panel ' + JSON.stringify(g.stage));
729
+ if (!g.dlg || g.dlg.l !== 382 || g.dlg.t !== 40) diffs.push('docked chat ' + JSON.stringify(g.dlg));
730
+ } else if (!g.stage || g.stage.w < w - 40) diffs.push('phone list ' + JSON.stringify(g.stage));
731
+ if (g.wide) diffs.push('sideways scroll');
732
+ ok(`R12 Home follows the Agreed design at ${w} px, ${th}: cozy tokens, Nunito, the floating place menu, no rail${w >= 1000 ? ', the list panel and the docked chat' : ''}`, diffs.length === 0, diffs.join(' ; '));
733
+ await R.ctx.close();
720
734
  }
721
735
  return finish();
722
736
  })().catch((e) => { console.error(e); finish(1); });