create-pmos 0.397.0 → 0.398.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 (145) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +101 -52
  8. package/workspace/briefing-premium-board-test.js +252 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +86 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  13. package/workspace/briefing-premium-initiative-test.js +159 -296
  14. package/workspace/briefing-premium-insights-test.js +337 -219
  15. package/workspace/briefing-premium-metrics-test.js +53 -97
  16. package/workspace/briefing-premium-products-test.js +40 -27
  17. package/workspace/briefing-premium-sources-test.js +66 -48
  18. package/workspace/briefing-premium-test.js +150 -647
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +12 -0
  21. package/workspace/fixtures/board-premium-trail.js +32 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  23. package/workspace/guide/briefing-premium.md +3 -1
  24. package/workspace/guide/home.md +47 -0
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/lib/agent-roles.js +71 -0
  27. package/workspace/lib/board-premium.js +85 -19
  28. package/workspace/lib/board-trail.js +223 -0
  29. package/workspace/lib/home-work-item.js +58 -0
  30. package/workspace/lib/insights-goals.js +196 -0
  31. package/workspace/lib/insights-premium.js +62 -14
  32. package/workspace/lib/insights-records.js +101 -0
  33. package/workspace/lib/jira-tickets.js +1 -1
  34. package/workspace/lib/route-modules.js +4 -0
  35. package/workspace/lib/routes-board-trail.js +33 -0
  36. package/workspace/lib/routes-home-desk.js +176 -0
  37. package/workspace/lib/routes-insights-premium.js +12 -3
  38. package/workspace/lib/routes-insights-records.js +129 -0
  39. package/workspace/lib/routes-notes.js +1 -0
  40. package/workspace/lib/routes-viewer.js +108 -0
  41. package/workspace/lib/transcript-steps.js +123 -0
  42. package/workspace/lib/viewer-meeting.js +205 -0
  43. package/workspace/lib/viewer-report.js +89 -0
  44. package/workspace/package-lock.json +2 -2
  45. package/workspace/package.json +1 -1
  46. package/workspace/premium-board-actions-test.js +85 -75
  47. package/workspace/premium-briefing-depth-test.js +66 -53
  48. package/workspace/premium-chat-attach-test.js +54 -63
  49. package/workspace/premium-chat-chart-tab-test.js +35 -37
  50. package/workspace/premium-chat-context-test.js +19 -18
  51. package/workspace/premium-chat-goal-view-test.js +23 -23
  52. package/workspace/premium-chat-notes-test.js +26 -31
  53. package/workspace/premium-chat-report-tab-test.js +32 -28
  54. package/workspace/premium-chat-term-test.js +16 -16
  55. package/workspace/premium-chat-viewer-test.js +60 -59
  56. package/workspace/premium-core-doc-issue-test.js +50 -43
  57. package/workspace/premium-html-viewer-test.js +14 -17
  58. package/workspace/premium-phone-card-test.js +7 -2
  59. package/workspace/premium-phone-room-test.js +41 -35
  60. package/workspace/premium-report-read-test.js +115 -197
  61. package/workspace/premium-viewer-download-test.js +19 -22
  62. package/workspace/premium-viewer-flicker-test.js +11 -16
  63. package/workspace/premium-viewer-share-test.js +6 -9
  64. package/workspace/premium-viewer-test.js +41 -60
  65. package/workspace/premium-vw-backlog-test.js +53 -33
  66. package/workspace/premium-vw-cal-test.js +82 -128
  67. package/workspace/premium-vw-copy-test.js +17 -33
  68. package/workspace/premium-vw-doc-test.js +11 -10
  69. package/workspace/premium-vw-item-test.js +50 -49
  70. package/workspace/premium-vw-jira-test.js +53 -27
  71. package/workspace/premium-vw-meet-test.js +118 -187
  72. package/workspace/premium-vw-notes-test.js +85 -108
  73. package/workspace/premium-vw-rec-test.js +72 -194
  74. package/workspace/premium-vw-slides-test.js +46 -50
  75. package/workspace/premium-welcome-test.js +3 -2
  76. package/workspace/premium-work-depth-test.js +61 -53
  77. package/workspace/public/pm/bd-acts.js +305 -0
  78. package/workspace/public/pm/bd-span.js +186 -82
  79. package/workspace/public/pm/bd-stages.js +25 -11
  80. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  81. package/workspace/public/pm/c3-md.js +3 -395
  82. package/workspace/public/pm/c3-phone-detail.js +1 -1
  83. package/workspace/public/pm/c3-phone-model.js +3 -68
  84. package/workspace/public/pm/chat-term.js +3 -3
  85. package/workspace/public/pm/cozy-board.css +497 -230
  86. package/workspace/public/pm/cozy-home.css +570 -142
  87. package/workspace/public/pm/cozy-home.js +5 -3
  88. package/workspace/public/pm/cozy-insights.css +296 -167
  89. package/workspace/public/pm/cozy-md.js +396 -0
  90. package/workspace/public/pm/cozy-nav.js +17 -6
  91. package/workspace/public/pm/cozy-placeholder.js +26 -0
  92. package/workspace/public/pm/cozy-viewer.css +3 -3
  93. package/workspace/public/pm/cozy-viewer.js +144 -0
  94. package/workspace/public/pm/cozy-vw.css +485 -0
  95. package/workspace/public/pm/cozy.css +83 -1
  96. package/workspace/public/pm/home-adddoc.js +48 -0
  97. package/workspace/public/pm/home-app.js +905 -0
  98. package/workspace/public/pm/home-around.js +515 -0
  99. package/workspace/public/pm/home-chat.js +459 -0
  100. package/workspace/public/pm/home-data.js +312 -0
  101. package/workspace/public/pm/home-draft.js +68 -0
  102. package/workspace/public/pm/home-more.js +249 -0
  103. package/workspace/public/pm/home-phone-card.js +109 -0
  104. package/workspace/public/pm/home-work.js +519 -0
  105. package/workspace/public/pm/phone-moment.js +69 -0
  106. package/workspace/public/pm/pm-work-view.js +1 -1
  107. package/workspace/public/pm/premium-attach.js +4 -0
  108. package/workspace/public/pm/premium-board.js +423 -394
  109. package/workspace/public/pm/premium-chart-tab.js +110 -62
  110. package/workspace/public/pm/premium-deck.js +3 -3
  111. package/workspace/public/pm/premium-first.js +25 -21
  112. package/workspace/public/pm/premium-insights.js +792 -568
  113. package/workspace/public/pm/premium-meeting.js +61 -549
  114. package/workspace/public/pm/premium-notes.js +1 -1
  115. package/workspace/public/pm/premium-report-frame.css +20 -0
  116. package/workspace/public/pm/premium-report-read.js +509 -480
  117. package/workspace/public/pm/premium-report-tab.js +87 -63
  118. package/workspace/public/pm/premium-shell.js +72 -119
  119. package/workspace/public/pm/premium-viewer.js +22 -1
  120. package/workspace/public/pm/premium-vw-cal.js +187 -48
  121. package/workspace/public/pm/premium-vw-doc.css +6 -0
  122. package/workspace/public/pm/premium-vw-doc.js +40 -2
  123. package/workspace/public/pm/premium-vw-file.js +2 -2
  124. package/workspace/public/pm/premium-vw-meet.js +6 -83
  125. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  126. package/workspace/public/pm/premium-vw-notes.js +56 -69
  127. package/workspace/public/pm/premium-vw-open.js +35 -0
  128. package/workspace/public/pm/premium-vw-page.js +16 -0
  129. package/workspace/public/pm/premium-vw-rec.js +11 -218
  130. package/workspace/public/pm/premium-vw-slides.css +5 -0
  131. package/workspace/public/pm/premium-vw-slides.js +44 -8
  132. package/workspace/public/pm/term-view.js +22 -0
  133. package/workspace/public/premium-board.html +28 -70
  134. package/workspace/public/premium-initiative.html +8 -48
  135. package/workspace/public/premium-insights.html +22 -60
  136. package/workspace/public/premium-viewer.html +20 -0
  137. package/workspace/public/premium.html +16 -107
  138. package/workspace/server.js +18 -3
  139. package/workspace/test-files.json +1 -0
  140. package/workspace/test-lists/home-libs.json +9 -0
  141. package/workspace/test-lists/premium-report-read.json +1 -1
  142. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  143. package/workspace/test-lists/premium-vw-notes.json +1 -1
  144. package/workspace/public/pm/premium-work.js +0 -729
  145. package/workspace/public/pm/premium.js +0 -1146
@@ -37,12 +37,17 @@ const PROP = { kind: 'report', proposal: { name: 'Social login weekly', purpose:
37
37
  const ASK = { role: 'user', text: '[PMOS report] rule\n\nThe PM says: make this a report for the growth leads' };
38
38
  const ANSWER = { role: 'assistant', text: 'Signups from the lightbox rose to 1,240. I drafted a report from this chat.\n\n' + block(PROP) };
39
39
 
40
+ /* premium-agreed-design: Home's chat is #hmLog; a report opens in the Viewer card (#czViewer), which covers the chat page on a phone. A new
41
+ * report is the design's slide deck (Main.dc.html viewer "deck"): one slide, Slide n of N, the thumbnails (the title slide, then the seven sections);
42
+ * its setup and a set-up template are the cozy parts marked Waiting for design. A confirm asks in the card ([data-rt="askyes"]). */
40
43
  const look = () => {
41
- const g = document.querySelector('#dlg'), pane = [...document.querySelectorAll('#dOut .obody.vw[data-vw^="report:"]')].find((x) => !x.hidden) || null;
42
- return { shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), chip: (document.querySelector('#dBody [data-report-open]') || {}).textContent || null,
43
- json: /pmos-report|"kind"/.test((document.querySelector('#dBody .stream') || {}).textContent || ''), user: [...document.querySelectorAll('#dBody .turn.u')].map((u) => u.textContent.trim()),
44
- tabs: [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.textContent.trim()), pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null,
45
- secs: pane ? pane.querySelectorAll('.rt-secs li').length : 0, sched: pane && pane.querySelector('.rt-chip b') ? pane.querySelector('.rt-chip b').textContent : null,
44
+ const vw = document.querySelector('#czViewer:not([hidden])'), pane = vw ? vw.querySelector('.vz[data-vw^="report:"]') : null;
45
+ return { shut: !pane, layer: false, chip: (document.querySelector('#hmLog [data-report-open]') || {}).textContent || null,
46
+ json: /pmos-report|"kind"/.test((document.querySelector('#hmLog') || {}).textContent || ''), user: [...document.querySelectorAll('#hmLog .hm-u .hm-bub')].map((u) => u.textContent.trim()),
47
+ tabs: pane ? [(vw.querySelector('.cz-vw-kind') || {}).textContent || ''] : [], pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null,
48
+ secs: pane ? (pane.querySelector('.vz-dkt') ? pane.querySelectorAll('.vz-dkt button').length - 1 : pane.querySelectorAll('.vz-secs li').length) : 0,
49
+ slide: pane && pane.querySelector('.vz-dkn > span') ? pane.querySelector('.vz-dkn > span').textContent : null,
50
+ sched: pane && pane.querySelector('[data-rt="sched"] b') ? pane.querySelector('[data-rt="sched"] b').textContent : null,
46
51
  wide: document.documentElement.scrollWidth > innerWidth + 1 };
47
52
  };
48
53
 
@@ -62,10 +67,8 @@ const look = () => {
62
67
  const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
63
68
  await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-rep', goal: null } }));
64
69
  await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'pm', messages: st.messages } }));
65
- await p.goto(chat);
66
- // re-pointed for premium-agreed-design: on a phone /premium-chat.html opens Home with the chat closed; the head's chat button opens it
67
- if (width < 1000) { await until(() => p.evaluate(() => !!document.querySelector('#hChat'))); if (!(await p.evaluate(() => document.querySelector('#dlg').classList.contains('on')))) await p.click('#hChat'); }
68
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream #thr')));
70
+ await p.goto(chat + '&about=work:report-test'); // premium-agreed-design: /premium-chat.html opens Home with the chat ?about names; on a phone the chat is the page
71
+ await until(() => p.evaluate(() => !!document.querySelector('#hmLog [data-report-open]')));
69
72
  await sleep(500);
70
73
  return { p, ctx, errs, st };
71
74
  };
@@ -74,32 +77,34 @@ const look = () => {
74
77
  const s0 = await p.evaluate(look);
75
78
  ok('R1 the block is a chip under Claude\'s words, never JSON; the PM\'s turn shows as typed', /Social login weekly/.test(s0.chip || '') && /New report/.test(s0.chip || '') && !s0.json && s0.user.includes('make this a report for the growth leads'), JSON.stringify(s0));
76
79
  ok('R1 opening the chat opens no tab by itself', s0.tabs.length === 0, JSON.stringify(s0));
77
- await p.click('#dBody [data-report-open]');
80
+ await p.click('#hmLog [data-report-open]');
78
81
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane ? v : null; }) || await p.evaluate(look);
79
- ok('R3 the Report tab shows the new report: name, audience, format, seven sections, Schedule Off', /Report/.test(s1.tabs.join(' ')) && /Social login weekly/.test(s1.pane || '') && /For Growth leads · Google Slides/.test(s1.pane || '')
80
- && s1.secs === 7 && s1.sched === 'Off · runs once' && /Set it up/.test(s1.pane || ''), JSON.stringify(s1));
82
+ ok('R3 the new report is the design\'s slide deck: name, audience, format, a title slide and seven section slides, Schedule Off', /Slide deck/.test(s1.tabs.join(' ')) && /Social login weekly/.test(s1.pane || '') && /For Growth leads · Google Slides/.test(s1.pane || '')
83
+ && s1.secs === 7 && s1.slide === 'Slide 1 of 8' && s1.sched === 'Off · runs once' && /Set it up/.test(s1.pane || '') && !(await p.$('#czViewer .rt, #czViewer .obody, #dlg:not([hidden])')), JSON.stringify(s1));
84
+ await p.click('#czViewer [data-rt="sl|1"]');
85
+ ok('R3 next shows the second slide, a section of the report', /Slide 2 of 8/.test((await p.evaluate(look)).slide || '') && /Headline/.test(await p.textContent('#czViewer .vz-dks')));
81
86
  if (shots) await p.screenshot({ path: `${shots}/new-1280-light.png` });
82
- await p.click('#dOut .rt-chip');
83
- await p.click('#dOut .rt-menu [data-rt="pick|2"]');
87
+ await p.click('#czViewer [data-rt="sched"]');
88
+ await p.click('#czViewer [data-rt="pick|2"]');
84
89
  const s2 = await until(async () => { const v = await p.evaluate(look); return v.sched && /Weekly/.test(v.sched) ? v : null; }) || await p.evaluate(look);
85
90
  ok('R3 a pick changes the chip only: nothing is written', /Weekly, Mondays at 09:00/.test(s2.sched || '') && !ledger().some((l) => l.ev === 'setup'), JSON.stringify(s2));
86
- await p.click('#dOut .rt-chip'); await p.click('#dOut .rt-menu [data-rt="pick|0"]');
87
- await p.click('#dOut [data-rt="setup"]');
88
- const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Report template/.test(v.pane) ? v : null; }, 15000) || await p.evaluate(look);
91
+ await p.click('#czViewer [data-rt="sched"]'); await p.click('#czViewer [data-rt="pick|0"]');
92
+ await p.click('#czViewer [data-rt="setup"]');
93
+ const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Report template/.test(v.tabs.join()) && /Draft/.test(v.pane) ? v : null; }, 15000) || await p.evaluate(look);
89
94
  const L = ledger(), setup = L.find((l) => l.ev === 'setup');
90
- ok('R4 Set it up records the report and pauses it (Schedule Off: it runs once); the tab shows the template', !!setup && L.some((l) => l.ev === 'pause' && l.id === setup.id) && s3.sched === 'Off · runs once' && /Report template/.test(s3.pane || ''), JSON.stringify([s3, L.map((l) => l.ev)]));
95
+ ok('R4 Set it up records the report and pauses it (Schedule Off: it runs once); the tab shows the template', !!setup && L.some((l) => l.ev === 'pause' && l.id === setup.id) && s3.sched === 'Off · runs once' && /Report template/.test(s3.tabs.join()), JSON.stringify([s3, L.map((l) => l.ev)]));
91
96
  ok('R4 its first draft is written and listed as a draft with Discard', /Draft/.test(s3.pane || '') && /Discard/.test(s3.pane || ''), JSON.stringify(s3));
92
97
  if (shots) await p.screenshot({ path: `${shots}/template-1280-light.png` });
93
- await p.click('#dOut .rt-chip'); await p.click('#dOut .rt-menu [data-rt="pick|3"]');
98
+ await p.click('#czViewer [data-rt="sched"]'); await p.click('#czViewer [data-rt="pick|3"]');
94
99
  const s4 = await until(async () => { const v = await p.evaluate(look); return v.sched && /Every two weeks/.test(v.sched) ? v : null; }) || await p.evaluate(look);
95
100
  const changed = RS.fold(ledger()).setups.get(setup && setup.id);
96
101
  ok('R5 the Schedule chip changes a template through the route and resumes it', !!changed && changed.status === 'active' && changed.schedule.cadence === 'bi-weekly' && /Every two weeks/.test(s4.sched || ''), JSON.stringify([s4.sched, changed]));
97
- await p.click('#dOut [data-rt^="discard|"]');
98
- await p.click('#dOut .vcf [data-a="1"]');
102
+ await p.click('#czViewer [data-rt^="discard|"]');
103
+ await p.click('#czViewer [data-rt="askyes"]');
99
104
  const s5 = await until(async () => { const v = await p.evaluate(look); return v.pane && /The draft is discarded/.test(v.pane) ? v : null; }) || await p.evaluate(look);
100
105
  ok('R6 Discard asks once, then the draft is deleted and logged', /The draft is discarded/.test(s5.pane || '') && ledger().some((l) => l.ev === 'doc-discard'), (s5.pane || '').slice(-300));
101
- await p.click('#dOut [data-rt="remove"]');
102
- await p.click('#dOut .vcf [data-a="1"]');
106
+ await p.click('#czViewer [data-rt="remove"]');
107
+ await p.click('#czViewer [data-rt="askyes"]');
103
108
  const s6 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Template deleted/.test(v.pane) ? v : null; }) || await p.evaluate(look);
104
109
  ok('R6 Delete template asks once, then the template is gone and the tab says its reports stay', /Template deleted/.test(s6.pane || '') && ledger().some((l) => l.ev === 'remove'), JSON.stringify(s6));
105
110
  st.messages = [ASK, ANSWER, { role: 'user', text: '[PMOS report] rule\n\nThe PM says: one for the board too' }, { role: 'assistant', text: 'Here.\n\n' + block({ kind: 'report', proposal: { ...PROP.proposal, name: 'Board summary' } }) }];
@@ -111,10 +116,9 @@ const look = () => {
111
116
  for (const scheme of ['light', 'dark']) {
112
117
  const { p, ctx, errs } = await open(390, scheme, [ASK, ANSWER]);
113
118
  if (shots) await p.screenshot({ path: `${shots}/chip-390-${scheme}.png` });
114
- await p.click('#dBody [data-report-open]');
115
- // re-pointed for premium-agreed-design: on a phone the chat is Home's popup with the Detail / Conversation switch (no vw-layer), so the chip
116
- // must bring the Detail side forward, covering the conversation, with the Report tab in it
117
- const shown = () => p.evaluate(() => getComputedStyle(document.querySelector('#dOut')).display !== 'none' && document.querySelector('#dGrid').dataset.tab !== 'chat');
119
+ await p.click('#hmLog [data-report-open]');
120
+ // premium-agreed-design: on a phone the chat is the page, and the Viewer card covers the whole screen with the Report in it
121
+ const shown = () => p.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); return !!v && v.getBoundingClientRect().width >= innerWidth - 1; });
118
122
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && await shown() ? v : null; }) || await p.evaluate(look);
119
123
  s1.detail = await shown();
120
124
  ok(`R7 (${scheme}) at 390 the chip covers the page with the Report tab`, s1.detail && /Social login weekly/.test(s1.pane || '') && s1.secs === 7, JSON.stringify(s1));
@@ -124,7 +128,7 @@ const look = () => {
124
128
  }
125
129
  if (shots) {
126
130
  const { p, ctx } = await open(1280, 'dark', [ASK, ANSWER]);
127
- await p.click('#dBody [data-report-open]'); await sleep(500);
131
+ await p.click('#hmLog [data-report-open]'); await sleep(500);
128
132
  await p.screenshot({ path: `${shots}/new-1280-dark.png` });
129
133
  await ctx.close();
130
134
  }
@@ -2,7 +2,8 @@
2
2
  'use strict';
3
3
  /* premium-chat-term-test.js — the chat header's Open in terminal icon (chat-open-in-terminal, Wawan 2026-10-22).
4
4
  * A real server on a scratch repository (c3-scan-fixture.js); the thread and the session list are routed.
5
- * O1 a running session: the icon shows and opens the console terminal of that same session in a new tab
5
+ * O1 a running session: the icon shows and opens that session's terminal, read only, in the Viewer (premium-agreed-design: Home's chat has no
6
+ * header, so the icon sits in the box's toolbar; nothing links to the console)
6
7
  * O2 an ended chat: the icon copies the line that resumes it
7
8
  * O3 no session: no icon
8
9
  * O4 /console.html?term=<id> opens that session's sheet on the terminal, also at phone width
@@ -26,7 +27,9 @@ const finish = async (code) => {
26
27
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
27
28
 
28
29
  const CMD = "cd '/Users/pm/pmos' && claude --resume 685a486b-d916-4002-9629-5e0fa33eaa9b";
29
- const icon = () => { const b = document.querySelector('#dTerm'); return b ? { shown: !b.hidden && getComputedStyle(b).display !== 'none', label: b.getAttribute('aria-label'), before: b.nextElementSibling && b.nextElementSibling.id } : null; };
30
+ // the terminal is an item of the box's + menu (Agreed design: the toolbar is "+ / @ chip"; marked Waiting for design): it is there when the menu lists it
31
+ const icon = () => { const b = document.querySelector('#hmTerm'); return { shown: !!b && !!b.closest('.hm-addm'), label: b ? b.getAttribute('aria-label') : null, inBox: !!(b && b.closest('#hmFoot')) }; };
32
+ const pressTerm = async (p) => { await p.click('#hmAdd'); await p.click('#hmTerm'); };
30
33
 
31
34
  (async () => {
32
35
  const exe = findBrowser();
@@ -43,31 +46,28 @@ const icon = () => { const b = document.querySelector('#dTerm'); return b ? { sh
43
46
  const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
44
47
  await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], working: false, history: null, goal: null, ...thread } }));
45
48
  await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', messages: [{ role: 'assistant', text: 'Working on the sheet.', at: null }], turn: null } }));
46
- await p.goto(chat); // premium-agreed-design H3: /premium-chat.html opens Home; a desktop docks the chat, a phone opens it from the head's chat button
47
- if (width < 1000) { await until(() => p.evaluate(() => !!document.querySelector('#hChat'))); await p.click('#hChat'); }
48
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream')));
49
- // the Chat page draws a conversation once it has a key: give it one, as a press on a list row does
50
- await p.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.S.key = 'work:term-test'; await m.loadThread('work:term-test'); });
49
+ await p.goto(chat + '&about=work:term-test'); // premium-agreed-design: /premium-chat.html opens Home; ?about names the conversation, as a list row does
50
+ await until(() => p.evaluate(() => !!document.querySelector('#hmFoot textarea')));
51
51
  return { p, ctx, errs };
52
52
  };
53
53
 
54
54
  { const { p, ctx, errs } = await open({ session: 'sess-7' });
55
55
  const i = await until(async () => { const v = await p.evaluate(icon); return v && v.shown ? v : null; }) || await p.evaluate(icon);
56
- ok('O1 a running session shows the terminal icon, before the conversation toggle', i && i.shown && i.label === 'Open in terminal' && i.before === 'dPane', JSON.stringify(i));
57
- const [pop] = await Promise.all([ctx.waitForEvent('page', { timeout: 8000 }).catch(() => null), p.click('#dTerm')]);
58
- // the new tab opens on about:blank and then loads the address, so wait for it (on a busy CI runner the event comes first)
59
- if (pop) await pop.waitForURL(/\/console\.html\?term=/, { timeout: 8000 }).catch(() => {});
60
- const href = pop ? pop.url() : '';
61
- ok('O1 pressing it opens the console terminal of that same session in a new tab', /\/console\.html\?term=sess-7&ws=/.test(href), href);
62
- if (pop) await pop.close();
56
+ ok('O1 a running session shows the terminal in the box\'s + menu', i && i.shown && i.label === 'Watch its terminal' && i.inBox, JSON.stringify(i));
57
+ let read = null; await p.route('**/api/sessions/transcript?**', (r) => { read = new URL(r.request().url()).searchParams.get('id'); r.fulfill({ json: { ok: true, id: 'sess-7', text: 'claude> working on the sheet' } }); });
58
+ let pops = 0; ctx.on('page', () => { pops++; });
59
+ await pressTerm(p);
60
+ const v = await until(() => p.evaluate(() => { const w = document.querySelector('#czViewer:not([hidden])'); return w && /working on the sheet/.test(w.textContent) ? (w.querySelector('.cz-vw-kind') || {}).textContent : null; }));
61
+ ok('O1 pressing it shows that same session\'s terminal, read only, in the Viewer; no tab opens and nothing links to the console', v === 'Terminal · read only' && read === 'sess-7' && pops === 0
62
+ && !(await p.evaluate(() => [...document.querySelectorAll('a[href]')].some((a) => /console/.test(a.getAttribute('href'))))), JSON.stringify([v, read, pops]));
63
63
  if (shots) await p.screenshot({ path: `${shots}/term-1280-light.png` });
64
64
  ok('O1 no error on the page', !errs.length, errs.join(' | '));
65
65
  await ctx.close();
66
66
  }
67
67
  { const { p, ctx } = await open({ session: null, resume: CMD }, 390, 'dark');
68
68
  const i = await until(async () => { const v = await p.evaluate(icon); return v && v.shown ? v : null; }) || await p.evaluate(icon);
69
- ok('O2 an ended chat shows the icon to copy its terminal line', i && i.shown && i.label === 'Copy the terminal command', JSON.stringify(i));
70
- await p.click('#dTerm');
69
+ ok('O2 an ended chat lists the item to copy its terminal line in the + menu', i && i.shown && i.label === 'Copy the terminal command', JSON.stringify(i));
70
+ await pressTerm(p);
71
71
  const clip = await until(() => p.evaluate(() => navigator.clipboard.readText()));
72
72
  const t = await p.evaluate(() => document.querySelector('#toast').textContent);
73
73
  ok('O2 pressing it copies cd to the folder and claude --resume, and says so', clip === CMD && /Copied/.test(t), clip + ' | ' + t);
@@ -1,15 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
  /* premium-chat-viewer-test.js — the Chat page's viewer opens when something opens in it (initiative premium-chat-viewer, slice 1).
4
- * A real server on a scratch repository (c3-scan-fixture.js); the file reads are routed and the conversation is filled in the page.
5
- * Since premium-agreed-design (H2, H3) /premium-chat.html opens Home: on a desktop the chat is docked beside Home's list, on a phone it opens
6
- * over the list as a popup from the head's chat button.
7
- * V1 at 1280 the docked chat opens with no viewer column; a file press opens it beside a conversation of at least 360 px (the dock's
8
- * minimum, cozy-home.css) while Home's list stays in view; closing its last tab closes it again
9
- * V3 a closed viewer with tabs shows the head's Viewer pill with the count, and the pill opens it
4
+ * A real server on a scratch repository (c3-scan-fixture.js); the file reads and the conversation are routed.
5
+ * Since premium-agreed-design /premium-chat.html opens Home: the list, the chat, and the Viewer — one cozy card (#czViewer) that shows one
6
+ * item at a time, so the old tab strip, its "+N" fold and the head's Viewer pill are gone; the chat's "Open the Viewer" button (#hmReopen)
7
+ * brings back what was closed. On a phone the chat is the page and the Viewer covers it.
8
+ * V1 at 1280 Home opens with no Viewer and a wide chat; a file press opens the Viewer beside a chat of at least 360 px (cozy-home.css)
9
+ * while the list stays in view; closing it gives the chat its width again
10
+ * V2 the Viewer shows the file only, with its name as the title
11
+ * V3 a closed Viewer leaves the chat's "Open the Viewer" button, which opens the last item again
10
12
  * V4 in a full-screen dialog on another page, a folded viewer unfolds when something opens in it
11
- * V5 at 390 the chat is a popup on its Conversation tab; a file press shows the file on the Detail tab, the switch returns, Escape closes
12
- * V6 tabs that do not fit fold into "+N", whose menu opens each
13
+ * V5 at 390 a file press covers the chat with the Viewer at full width; closing it returns to the conversation; Escape closes it too
14
+ * V6 a new item replaces the one shown: one card, no tab strip
13
15
  * Set CHAT_VIEWER_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
14
16
  const { findBrowser } = require('./lib/find-browser');
15
17
  require('./test-run').configure({ name: 'premium-chat-viewer' });
@@ -30,19 +32,16 @@ const finish = async (code) => {
30
32
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
31
33
 
32
34
  const MD = '# Sign-up drop\n\nThe **sign-up** rate fell from 41% to 38%.\n';
33
- const fill = () => {
34
- const s = document.querySelector('#dBody .stream');
35
- s.insertAdjacentHTML('beforeend', '<div class="turn a"><div class="tc"><div class="md"><p>I wrote it up in <button type="button" class="fpath" data-file="planning/research/signup-drop.md">planning/research/signup-drop.md</button> and read <button type="button" class="fpath" data-file="planning/prd/signup-fix.md">planning/prd/signup-fix.md</button>.</p></div></div></div>');
36
- };
35
+ const ANSWER = [{ role: 'user', text: 'Why did sign-ups drop?', at: '2026-10-21T08:00:00Z' },
36
+ { role: 'assistant', text: 'I wrote it up in `planning/research/signup-drop.md` and read `planning/prd/signup-fix.md`.', at: '2026-10-21T08:00:20Z' }];
37
37
  /* the page's own state */
38
38
  const look = () => {
39
- const g = document.querySelector('#dlg'), w = (s) => { const e = document.querySelector(s); return e ? Math.round(e.getBoundingClientRect().width) : 0; }, pill = document.querySelector('#vwPill');
40
- const out = document.querySelector('#dOut').getBoundingClientRect();
41
- const st = document.querySelector('main.stage'), sr = st.getBoundingClientRect();
42
- return { list: sr.width > 200 && sr.right <= g.getBoundingClientRect().left + 1 && !st.inert, tab: document.querySelector('#dGrid').dataset.tab, outShown: getComputedStyle(document.querySelector('#dOut')).display !== 'none', on: g.classList.contains('on'), shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), srlMin: g.classList.contains('srl-min'), conv: w('#dBody'), out: Math.round(out.width), outH: Math.round(out.height), vh: innerHeight,
43
- sw: getComputedStyle(document.querySelector('#dTabs')).display, pill: pill && !pill.hidden ? pill.textContent.trim() : null, back: !!document.querySelector('#vBack') && getComputedStyle(document.querySelector('#vBack')).display !== 'none',
44
- tabs: [...document.querySelectorAll('#vTabs .vtab')].map((t) => (t.hidden ? '~' : '') + t.textContent.trim()), more: (document.querySelector('#vTabs .vmore') || {}).textContent || null,
45
- railOff: getComputedStyle(document.querySelector('.rail')).opacity === '0', wide: document.documentElement.scrollWidth > innerWidth + 1 };
39
+ const w = (s) => { const e = document.querySelector(s); return e ? Math.round(e.getBoundingClientRect().width) : 0; };
40
+ const vw = document.querySelector('#czViewer:not([hidden])'), list = document.querySelector('#hmList'), lr = list ? list.getBoundingClientRect() : null;
41
+ const reopen = document.querySelector('#hmReopen');
42
+ return { list: !!lr && lr.width > 200 && getComputedStyle(list).display !== 'none', shut: !vw, conv: w('#hmChat'), out: vw ? Math.round(vw.getBoundingClientRect().width) : 0,
43
+ title: vw ? ((vw.querySelector('#czVwTitle') || {}).textContent || '').trim() : null, strip: !!document.querySelector('#vTabs .vtab, #vwPill'),
44
+ reopen: !!reopen && !reopen.hidden, railOff: !document.querySelector('nav.rail'), wide: document.documentElement.scrollWidth > innerWidth + 1 };
46
45
  };
47
46
 
48
47
  (async () => {
@@ -59,72 +58,74 @@ const look = () => {
59
58
  const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
60
59
  await p.route('**/api/doc/locate**', (r) => { const rel = r.request().url().includes('prd') ? 'planning/prd/signup-fix.md' : 'planning/research/signup-drop.md'; r.fulfill({ json: { ok: true, ws: F.ws, rel, name: rel.split('/').pop(), abs: '/x/' + rel, mtime: 1, size: MD.length } }); });
61
60
  await p.route('**/api/doc?**', (r) => r.fulfill({ contentType: 'text/plain', headers: { 'X-Doc-Kind': 'markdown' }, body: MD }));
62
- await p.goto(chat); await until(() => p.evaluate(() => /\/premium\.html$/.test(location.pathname) && !!document.querySelector('#hChat')));
63
- if (width < 1000) await p.click('#hChat'); // a phone: the list is the page, and the head's chat button opens your chat
64
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream')));
65
- await p.evaluate(fill); await sleep(300);
61
+ await p.route('**/api/briefing-premium/thread**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-vw' } }));
62
+ await p.route('**/api/sessions/conversation**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'user', messages: ANSWER } }));
63
+ await p.goto(chat + '&about=work:viewer-test');
64
+ await until(() => p.evaluate(() => /\/premium\.html$/.test(location.pathname) && document.querySelectorAll('#hmLog .fpath').length >= 2), 12000);
65
+ await sleep(300);
66
66
  return { p, ctx, errs };
67
67
  };
68
68
  const many = (p) => p.evaluate(async () => { const v = await import('/pm/premium-viewer.js'); for (const n of ['funnel-export.csv', 'support-tickets.md', 'pricing-notes.md', 'a-longer-quarterly-plan.md']) v.vwOpen({ id: 'x:' + n, title: n, html: '<article class="paper doc"><p>' + n + '</p></article>' }); });
69
+ const closeVw = (p) => p.click('#czViewer [data-cz-vw="close"]');
69
70
 
70
71
  { const { p, ctx, errs } = await open(1280);
71
72
  const s0 = await p.evaluate(look);
72
- ok('V1 at 1280 /premium-chat.html opens Home with the chat docked beside the list, no viewer column and the conversation wide', s0.list && s0.shut && s0.out === 0 && s0.conv > 700 && !s0.pill && s0.tabs.length === 0, JSON.stringify(s0));
73
- await p.click('.fpath >> nth=0');
74
- const s1 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.out > 400 ? v : null; }) || await p.evaluate(look);
75
- ok('V1 a file press opens the viewer beside a conversation of at least 360 px, and Home\'s list stays in view beside them', !s1.shut && s1.out > 400 && s1.conv >= 360 && s1.list, JSON.stringify(s1));
76
- ok('V2 the placeholder is not a tab: the strip shows only the file', s1.tabs.length === 1 && /signup-drop\.md/.test(s1.tabs[0]), JSON.stringify(s1.tabs));
77
- await p.click('#vTabs [data-vx]');
73
+ ok('V1 at 1280 /premium-chat.html opens Home with the list, no Viewer and the conversation wide', s0.list && s0.shut && s0.out === 0 && s0.conv > 700 && s0.railOff, JSON.stringify(s0));
74
+ await p.click('#hmLog .fpath >> nth=0');
75
+ const s1 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.title ? v : null; }) || await p.evaluate(look);
76
+ ok('V1 a file press opens the Viewer beside a conversation of at least 360 px, and Home\'s list stays in view beside them', !s1.shut && s1.out > 300 && s1.conv >= 360 && s1.list, JSON.stringify(s1));
77
+ ok('V2 the Viewer shows only the file, with its name as the title, and no tab strip', /signup-drop\.md/.test(s1.title) && !s1.strip, JSON.stringify(s1));
78
+ await closeVw(p);
78
79
  const s2 = await until(async () => { const v = await p.evaluate(look); return v.shut ? v : null; }) || await p.evaluate(look);
79
- ok('V1 closing the last tab closes the viewer, the conversation takes its width and the list stays', s2.shut && s2.out === 0 && s2.conv > 700 && s2.list, JSON.stringify(s2));
80
- await p.click('.fpath >> nth=0'); await p.click('.fpath >> nth=1'); await sleep(300);
81
- await p.click('#vFold');
82
- const s3 = await until(async () => { const v = await p.evaluate(look); return v.shut && v.pill ? v : null; }) || await p.evaluate(look);
83
- ok('V3 the close button closes the viewer and the head shows "Viewer 2"', s3.shut && /Viewer\s*2/.test(s3.pill || ''), JSON.stringify(s3));
84
- await p.click('#vwPill');
80
+ ok('V1 closing the Viewer gives the conversation its width and the list stays', s2.shut && s2.out === 0 && s2.conv > 700 && s2.list, JSON.stringify(s2));
81
+ await p.click('#hmLog .fpath >> nth=0'); await p.click('#hmLog .fpath >> nth=1'); await sleep(300);
82
+ const sb = await until(async () => { const v = await p.evaluate(look); return /signup-fix\.md/.test(v.title || '') ? v : null; }) || await p.evaluate(look);
83
+ ok('V6 a second file replaces the first in the one Viewer card', /signup-fix\.md/.test(sb.title || '') && !sb.strip && await p.evaluate(() => document.querySelectorAll('#czViewer').length === 1), JSON.stringify(sb));
84
+ await closeVw(p);
85
+ const s3 = await until(async () => { const v = await p.evaluate(look); return v.shut && v.reopen ? v : null; }) || await p.evaluate(look);
86
+ ok('V3 the close leaves the chat\'s "Open the Viewer" button', s3.shut && s3.reopen, JSON.stringify(s3));
87
+ await p.click('#hmReopen');
85
88
  const s4 = await until(async () => { const v = await p.evaluate(look); return !v.shut ? v : null; }) || await p.evaluate(look);
86
- ok('V3 the pill opens it again on the last tab', !s4.shut && !s4.pill && /signup-fix\.md/.test(s4.tabs.find((t) => !t.startsWith('~')) && s4.tabs[s4.tabs.length - 1]), JSON.stringify(s4));
89
+ ok('V3 the button opens the last item again', !s4.shut && /signup-fix\.md/.test(s4.title || '') && !s4.reopen, JSON.stringify(s4));
87
90
  if (shots) await p.screenshot({ path: `${shots}/chat-viewer-1280-light.png` });
88
91
  await many(p); await sleep(400);
89
92
  const s5 = await p.evaluate(look);
90
- ok('V6 tabs that do not fit fold into +N and the current tab shows', /^\+\d$/.test(s5.more || '') && s5.tabs.some((t) => t.startsWith('~')) && !s5.tabs[s5.tabs.length - 1].startsWith('~'), JSON.stringify(s5));
91
- await p.click('#vTabs .vmore'); await sleep(200);
92
- const items = await p.evaluate(() => [...document.querySelectorAll('#vMore [data-vw]')].map((b) => b.dataset.vw));
93
- await p.click('#vMore [data-vw] >> nth=0'); await sleep(200);
94
- const on = await p.evaluate(() => (document.querySelector('#vTabs .vtab[aria-selected="true"]') || {}).dataset.vw);
95
- ok('V6 the +N menu lists the hidden tabs and opens one', items.length >= 1 && on === items[0], JSON.stringify({ items, on }));
93
+ ok('V6 many opens leave one card on the newest item and nothing to fold', s5.title === 'a-longer-quarterly-plan.md' && !s5.strip, JSON.stringify(s5));
96
94
  ok('F1 no page error and no sideways scroll', !errs.length && !s5.wide, errs.join(' | '));
97
95
  await ctx.close(); }
98
96
 
99
97
  for (const scheme of ['light', 'dark']) {
100
98
  const { p, ctx, errs } = await open(390, scheme);
101
99
  const s0 = await p.evaluate(look);
102
- ok(`V5 (${scheme}) at 390 the chat opens over Home's list as a popup on its Conversation tab, with the Detail / Conversation switch and no file yet`, s0.on && s0.tab === 'chat' && s0.sw !== 'none' && !s0.layer && s0.conv > 300 && s0.tabs.length === 0, JSON.stringify(s0));
103
- await p.click('.fpath >> nth=0');
104
- const s1 = await until(async () => { const v = await p.evaluate(look); return v.tab === 'out' && v.outShown && v.tabs.some((t) => /signup-drop\.md/.test(t)) ? v : null; }) || await p.evaluate(look);
105
- ok(`V5 (${scheme}) a file press shows the file on the Detail tab, the full width of the popup`, s1.tab === 'out' && s1.outShown && s1.out >= 340 && /signup-drop\.md/.test(s1.tabs.join()), JSON.stringify(s1));
100
+ ok(`V5 (${scheme}) at 390 the chat is the page, with no Viewer yet`, s0.shut && s0.conv > 340 && !s0.list, JSON.stringify(s0));
101
+ await p.click('#hmLog .fpath >> nth=0');
102
+ const s1 = await until(async () => { const v = await p.evaluate(look); return !v.shut && /signup-drop\.md/.test(v.title || '') ? v : null; }) || await p.evaluate(look);
103
+ ok(`V5 (${scheme}) a file press covers the chat with the file at full width`, !s1.shut && s1.out >= 340 && /signup-drop\.md/.test(s1.title || ''), JSON.stringify(s1));
106
104
  if (shots) await p.screenshot({ path: `${shots}/chat-viewer-390-${scheme}.png` });
107
- await p.click('#dTabs [data-t="chat"]');
108
- const s2 = await until(async () => { const v = await p.evaluate(look); return v.tab === 'chat' ? v : null; }) || await p.evaluate(look);
109
- ok(`V5 (${scheme}) the Conversation tab returns to the conversation and the file stays open on Detail`, s2.tab === 'chat' && s2.conv > 300 && /signup-drop\.md/.test(s2.tabs.join()), JSON.stringify(s2));
105
+ await closeVw(p);
106
+ const s2 = await until(async () => { const v = await p.evaluate(look); return v.shut ? v : null; }) || await p.evaluate(look);
107
+ ok(`V5 (${scheme}) closing the Viewer returns to the conversation`, s2.shut && s2.conv > 340 && await p.isVisible('#hmIn'), JSON.stringify(s2));
108
+ await p.click('#hmLog .fpath >> nth=1');
109
+ await until(async () => !(await p.evaluate(look)).shut);
110
110
  await p.keyboard.press('Escape');
111
- const s3 = await until(async () => { const v = await p.evaluate(look); return !v.on ? v : null; }) || await p.evaluate(look);
112
- ok(`V5 (${scheme}) Escape closes the popup and Home's list is live again`, !s3.on && await p.evaluate(() => !document.querySelector('main.stage').inert), JSON.stringify(s3));
111
+ const s3 = await until(async () => { const v = await p.evaluate(look); return v.shut ? v : null; }) || await p.evaluate(look);
112
+ ok(`V5 (${scheme}) Escape closes the Viewer`, s3.shut, JSON.stringify(s3));
113
113
  ok(`F1 (${scheme}) no page error and no sideways scroll at 390`, !errs.length && !s3.wide, errs.join(' | '));
114
114
  await ctx.close();
115
115
  }
116
116
 
117
117
  { const ctx = await browser.newContext({ viewport: { width: 1280, height: 800 } }); const p = await ctx.newPage();
118
118
  await p.addInitScript(() => { try { localStorage.setItem('pmos.srl.view', 'min'); } catch { /* none */ } });
119
- // another page: Home now holds the chat docked (its viewer never folds to vw-min), so this runs on Insights, a page whose dialogs are popups
120
- await p.goto(`${F.BASE}/premium-insights.html?ws=${encodeURIComponent(F.ws)}`); await until(() => p.evaluate(() => !!document.querySelector('#dlg') && !!document.querySelector('.rail')));
121
- await p.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.openDlg({ eye: 'Goal', title: 'Check the funnel', html: '<p>detail</p>', say: 'Hello', noteKey: 'work:x' }); m.setFull(true); });
122
- await sleep(300);
123
- const before = await p.evaluate(() => document.querySelector('#dlg').classList.contains('vw-min'));
124
- await p.evaluate(async () => { const v = await import('/pm/premium-viewer.js'); v.vwOpen({ id: 'x:a', title: 'a.md', html: '<p>a</p>' }); });
119
+ // re-pointed (insights fix): Insights has no old dialog now (Agreed design), so nothing can fold; what opens goes to the Viewer card.
120
+ // The intent stays: on another page, with a folded view remembered, something opened in the Viewer is shown, never left folded
121
+ await p.goto(`${F.BASE}/premium-insights.html?ws=${encodeURIComponent(F.ws)}`); await until(() => p.evaluate(() => !!window.czViewer));
122
+ const vl = () => { const v = document.querySelector('#czViewer'); const r = v && !v.hidden ? v.getBoundingClientRect() : null; return { dlg: !!document.querySelector('#dlg'), shown: !!r, w: r ? Math.round(r.width) : 0, h: r ? Math.round(r.height) : 0, min: !!(v && /vw-min/.test(v.className)), title: v ? (v.querySelector('.cz-vw-title') || {}).textContent : '', body: v ? v.querySelector('.cz-vw-body').textContent : '' }; };
123
+ await p.evaluate(() => window.czViewer.open({ kind: 'Report', title: 'a.md', html: '<p>a</p>', id: 'x:a' }));
124
+ await sleep(200);
125
+ await p.evaluate(() => window.czViewer.open({ kind: 'Report', title: 'b.md', html: '<p>b</p>', id: 'x:b' }));
125
126
  await sleep(200);
126
- const after = await p.evaluate(() => document.querySelector('#dlg').classList.contains('vw-min'));
127
- ok('V4 a folded viewer in a full-screen dialog unfolds when something opens in it', before && !after, JSON.stringify({ before, after }));
127
+ const after = await p.evaluate(vl);
128
+ ok('V4 on another page, something opened in the Viewer is shown whole, never folded (no old dialog to fold)', !after.dlg && after.shown && !after.min && after.w >= 300 && after.h >= 300 && after.title === 'b.md' && after.body === 'b', JSON.stringify(after));
128
129
  await ctx.close(); }
129
130
 
130
131
  return finish();
@@ -3,7 +3,8 @@
3
3
  /* premium-core-doc-issue-test.js — Issue it on a core document draft, on the premium Board and the premium initiative page (initiative premium-core-doc-issue;
4
4
  * planning/prd/premium-core-doc-issue-prd.md I1 to I7). A real server on a scratch `team` repository, never the PMOS checkout. The drafts are written by the
5
5
  * core-docs writer (lib/core-docs.js writeDraft), so the pages read what the agent's run would leave. The real pages press the real route:
6
- * R reading (slot and path) · B the Board reader and Issue it · I the initiative sheet, unsaved edits and a refusal · P the POST allow-list · F floors */
6
+ * R reading (slot and path) · B the Board reader and Issue it · I the initiative (a layout in Home since premium-agreed-design: its Overview, the draft
7
+ * reader in the Viewer), unsaved edits and a refusal · P the POST allow-list · F floors */
7
8
  const fs = require('fs');
8
9
  const path = require('path');
9
10
  const { spawn } = require('child_process');
@@ -34,7 +35,7 @@ const finish = async (code) => {
34
35
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
35
36
 
36
37
  const ledger = () => { const f = CD.ledgerFile(team); return fs.existsSync(f) ? fs.readFileSync(f, 'utf8').split('\n').filter(Boolean).map((x) => JSON.parse(x)) : []; };
37
- const ALLOWED = /^\/api\/(?:core-docs\/issue|briefing-premium\/note|doc-health\/check)$/;
38
+ const ALLOWED = /^\/api\/(?:core-docs\/issue|briefing-premium\/note|briefing-premium\/seen|doc-health\/check)$/; // seen: Home records what it showed, not a press
38
39
  const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers.\n';
39
40
 
40
41
  (async () => {
@@ -81,66 +82,71 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
81
82
  if (theme === 'dark') await page.evaluate(() => { document.documentElement.dataset.theme = 'dark'; });
82
83
  return { ctx, page, errors, posts };
83
84
  };
84
- const dlgOn = async (p) => { const v = await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(800); return v; };
85
+ const dlgOn = async (p) => { const v = await until(() => p.evaluate(() => !!document.querySelector('#dlg.on'))); await sleep(800); return v; };
85
86
  const toastIs = (p, re) => until(() => p.evaluate((s) => { const t = document.querySelector('#toast'); return t.classList.contains('on') && new RegExp(s).test(t.textContent) ? t.textContent : null; }, re.source));
86
87
  const H = await T.pressHeaders(BASE);
87
88
  const nonce = H['x-pmos-nonce'];
88
89
 
89
- /* B the Board reader */
90
+ /* B the Board reader (premium-agreed-design: the Documents tab is a plain list; a document with a file opens a plain reader in the side panel,
91
+ tagged "Waiting for design", with the Issue it bar) */
92
+ const bToast = (p, re) => until(() => p.evaluate((s) => { const t = document.querySelector('#bdToast'); return t && !t.hidden && new RegExp(s).test(t.textContent) ? t.textContent : null; }, re.source));
90
93
  const P = await open('/premium-board.html'), p = P.page;
91
- ok('B1 a board document with a file is a button that opens the reader', await until(() => p.evaluate((k) => !!document.querySelector(`#docBody [data-doc="${k}"]`), bkey)));
92
- ok('B1 a document with no file is not', await p.evaluate((k) => !document.querySelector('#docBody .dmo:not(button)') || [...document.querySelectorAll('#docBody .dmo:not(button)')].every((x) => !x.closest('.dmr').querySelector(`[data-doc="${k}"]`)), bkey));
93
- await p.click('#tabDocs'); // the Agreed design shows the documents on the Documents tab (premium-agreed-design)
94
- await p.click(`#docBody [data-doc="${bkey}"]`); await dlgOn(p);
95
- ok('B2 the reader shows the file\'s text and path, and the bar says nothing is sent', await until(() => p.evaluate((pt) => { const o = document.querySelector('#oMain'); return /Why this board exists/.test(o.textContent) && !!o.querySelector('[data-ds="meta"]') && !!o.querySelector('[data-issue-bar="draft"]') && /Nothing is sent/.test(o.querySelector('[data-issue-bar]').textContent) && !!o.querySelector('[data-ds="issue"]'); }, d1.path)), await p.evaluate(() => document.querySelector('#oMain').textContent));
96
- ok('B2 the path is behind the file chip, not in the way', await p.evaluate((pt) => !document.querySelector('#oMain .dsmeta') && !!document.querySelector('#oMain [data-ds="meta"]'), d1.path) && (await p.click('#oMain [data-ds="meta"]'), await p.evaluate((pt) => document.querySelector('#oMain .dsmeta').textContent.includes(pt), d1.path)));
97
- ok('B2 the reader has the sheet\'s view menu, as the initiative page does', await p.evaluate(() => !!document.querySelector('#oMain #shV')));
94
+ await until(() => p.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 60000);
95
+ await p.click('#tabDocs');
96
+ ok('B1 a board document with a file is a button that opens the reader', await until(() => p.evaluate((k) => !!document.querySelector(`#docBody [data-act="cdoc"][data-key="${k}"]`), bkey), 60000));
97
+ ok('B1 a document with no file is not', await p.evaluate(() => [...document.querySelectorAll('#docBody .bd-lr')].every((r) => !!r.querySelector('[data-act="cdoc"]') === /\//.test(r.querySelector('.pth').textContent))));
98
+ await p.click(`#docBody [data-act="cdoc"][data-key="${bkey}"]`);
99
+ ok('B2 the reader shows the file\'s text and path, tagged, and the bar says nothing is sent', await until(() => p.evaluate((pt) => { const o = document.querySelector('#peek'); return !o.hidden && /Why this board exists/.test(o.textContent) && o.textContent.includes(pt) && !!o.querySelector('.bd-wtag') && !!o.querySelector('[data-issue-bar="draft"]') && /Nothing is sent/.test(o.querySelector('[data-issue-bar]').textContent) && !!o.querySelector('[data-act="issue"]'); }, d1.path)), await p.evaluate(() => document.querySelector('#peek').textContent));
100
+ ok('B2 no old dialog opens', await p.evaluate(() => !!!document.querySelector('#dlg.on')));
98
101
  const n0 = ledger().filter((l) => l.ev === 'issue').length;
99
- await p.click('[data-ds="issue"]');
100
- ok('B3 Issue it says it sent nothing', !!(await toastIs(p, /Issued\. Nothing was sent to anyone/)));
102
+ await p.click('#peek [data-act="issue"]');
103
+ ok('B3 Issue it says it sent nothing', !!(await bToast(p, /Issued\. Nothing was sent to anyone/)));
101
104
  const sent = P.posts.filter((x) => x.path === '/api/core-docs/issue');
102
105
  ok('B4 it posted the workspace, the scope, the key and the slot, and nothing else, with the launch nonce', sent.length === 1 && Object.keys(sent[0].body).sort().join() === 'key,scope,slot,ws' && sent[0].body.scope === bscope && sent[0].body.key === bkey && sent[0].body.slot === d1.slot && sent[0].body.ws === B.ws && sent[0].headers['x-pmos-nonce'] === nonce && !!nonce, JSON.stringify(sent));
103
106
  const il = ledger().filter((l) => l.ev === 'issue');
104
107
  ok('B5 the ledger has one new issue line for that draft, written by the PM', il.length === n0 + 1 && il[il.length - 1].slot === d1.slot && il[il.length - 1].scope === bscope && /pm/.test(String(il[il.length - 1].by)), JSON.stringify(il));
105
108
  ok('B5 the file now says state: issued', /^state: issued$/m.test(fs.readFileSync(path.join(team, d1.path), 'utf8')));
106
- ok('B6 the reader says it is issued, the Issue it press is gone, and the row reads Up to date', await until(() => p.evaluate(() => { const o = document.querySelector('#oMain'); return !!o.querySelector('[data-issue-bar="done"]') && !o.querySelector('[data-ds="issue"]') && /state: issued|issued/.test(o.textContent); })) && await until(() => p.evaluate((k) => { const r = document.querySelector(`#docBody [data-doc="${k}"]`); return r && /Up to date/.test(r.textContent); }, bkey)));
109
+ ok('B6 the reader says it is issued, the Issue it press is gone, and the row reads Up to date', await until(() => p.evaluate(() => { const o = document.querySelector('#peek'); return !o.hidden && !!o.querySelector('[data-issue-bar="done"]') && !o.querySelector('[data-act="issue"]'); }), 30000) && await until(() => p.evaluate((k) => { const r = document.querySelector(`#docBody [data-doc-key="${k}"]`); return r && /Up to date/.test(r.textContent); }, bkey), 30000), await p.evaluate(() => document.querySelector('#peek').textContent + ' // ' + document.querySelector('#docBody').textContent));
107
110
  await p.screenshot({ path: path.join(R.base, 'board-issued.png') });
108
111
  await P.ctx.close();
109
112
 
110
- /* I the initiative sheet */
113
+ /* I the initiative: a layout inside Home (premium-agreed-design). The Board's expand link lands there; the card's Overview lists the core documents,
114
+ and a draft opens a minimal reader in the Viewer (Waiting for design) with the Issue it bar, Read and Edit */
115
+ const ovOpen = async (p) => { await until(() => p.evaluate(() => !!document.querySelector('.hm-card [data-hm-ov]')), 60000); await p.click('.hm-card [data-hm-ov]'); };
111
116
  const I = await open('/premium-initiative.html' + iq), ip = I.page;
112
- await until(() => ip.evaluate((k) => !!document.querySelector(`#dmList [data-doc="${k}"]`), ikey), 60000);
113
- await ip.click(`#dmList [data-doc="${ikey}"]`); await dlgOn(ip);
114
- ok('I1 the Read tab of a draft has the Issue it bar above the text', await until(() => ip.evaluate(() => { const o = document.querySelector('#oMain'); const b = o.querySelector('[data-issue-bar="draft"]'); return !!b && /Nothing is sent/.test(b.textContent) && /Why this board exists/.test(o.textContent) && b.compareDocumentPosition(o.querySelector('.dsbody')) & Node.DOCUMENT_POSITION_FOLLOWING; })));
115
- await ip.click('#shV'); await ip.click('[data-sh="edit"]');
116
- await until(() => ip.evaluate(() => !!document.querySelector('#dsEd')));
117
- await ip.fill('#dsEd', BODY + '\n## Added\n\nUnsaved line.\n');
118
- await ip.click('#shV'); await ip.click('[data-sh="read"]');
119
- await until(() => ip.evaluate(() => !!document.querySelector('[data-ds="issue"]')));
120
- const nI = I.posts.length;
121
- await ip.click('[data-ds="issue"]');
122
- ok('I2 Issue it with unsaved edits posts nothing and says to save or cancel first', await until(() => ip.evaluate(() => /unsaved changes.*Save or cancel/.test((document.querySelector('#dsErr') || {}).textContent || ''))) && I.posts.length === nI);
117
+ await ovOpen(ip);
118
+ await until(() => ip.evaluate((k) => !!document.querySelector(`#czViewer [data-ov-dread="${k}"]`), ikey), 60000);
119
+ await ip.click(`#czViewer [data-ov-dread="${ikey}"]`);
120
+ ok('I1 the reader of a draft has the Issue it bar above the text, tagged Waiting for design', await until(() => ip.evaluate(() => { const o = document.querySelector('#czViewer:not([hidden])'); const b = o && o.querySelector('[data-issue-bar="draft"]'); const t = o && o.querySelector('.dsbody'); return !!b && !!t && /Nothing is sent/.test(b.textContent) && /Why this board exists/.test(t.textContent) && !!o.querySelector('.hx-wait') && !!(b.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING); }), 30000));
121
+ ok('I1 no old dialog opens', await ip.evaluate(() => { const d = document.querySelector('#dlg'); return !d || !d.classList.contains('on'); }));
122
+ await ip.click('#czViewer [data-ds="edit"]');
123
+ await until(() => ip.evaluate(() => !!document.querySelector('#czViewer [data-ds-host] .cfb[contenteditable="true"]')), 30000);
124
+ await ip.click('#czViewer [data-ds-host] .cfb'); await ip.keyboard.press('Control+End'); await ip.keyboard.type(' Unsaved line.');
125
+ const nI = I.posts.filter((x) => x.path === '/api/core-docs/issue').length;
126
+ await ip.click('#czViewer [data-ds="issue"]');
127
+ ok('I2 Issue it with unsaved edits posts nothing and says to save or cancel first', await until(() => ip.evaluate(() => /unsaved changes.*Save or cancel/.test((document.querySelector('#czViewer #dsErr') || {}).textContent || ''))) && I.posts.filter((x) => x.path === '/api/core-docs/issue').length === nI);
123
128
  ok('I2 the ledger has no issue line for that draft yet', !ledger().some((l) => l.ev === 'issue' && l.slot === d2.slot && l.scope === iscope));
124
- await ip.click('#shV'); await ip.click('[data-sh="edit"]'); await until(() => ip.evaluate(() => !!document.querySelector('[data-ds="discard"]')));
125
- await ip.click('[data-ds="discard"]'); await ip.click('#shV'); await ip.click('[data-sh="read"]');
126
- await until(() => ip.evaluate(() => !!document.querySelector('[data-ds="issue"]')));
129
+ await ip.click('#czViewer [data-vd="cancel"]');
130
+ await until(() => ip.evaluate(() => !!document.querySelector('#czViewer [data-ds="issue"]') && !!document.querySelector('#czViewer .dsbody')));
127
131
  /* a refusal: someone else issues the same draft first (the console, a second tab) */
128
132
  const raced = await fetch(BASE + '/api/core-docs/issue', { method: 'POST', headers: H, body: JSON.stringify({ ws: B.ws, scope: iscope, key: ikey, slot: d2.slot }) });
129
133
  ok('I3 setup the draft is issued behind the page\'s back', raced.status === 200);
130
- await ip.click('[data-ds="issue"]');
131
- ok('I3 a refused press shows the server\'s words and the sheet changes nothing else', await until(() => ip.evaluate(() => /already/.test((document.querySelector('#dsErr') || {}).textContent || ''))));
134
+ await ip.click('#czViewer [data-ds="issue"]');
135
+ ok('I3 a refused press shows the server\'s words and the reader changes nothing else', await until(() => ip.evaluate(() => /already/.test((document.querySelector('#czViewer #dsErr') || {}).textContent || '') && !!document.querySelector('#czViewer [data-issue-bar="draft"]'))));
132
136
  ok('I3 the refusal wrote no second issue line', ledger().filter((l) => l.ev === 'issue' && l.slot === d2.slot && l.scope === iscope).length === 1);
133
- await ip.click('#dlg [data-act="close"], #dClose').catch(() => {});
134
137
  await I.ctx.close();
135
138
 
136
139
  /* I4 a fresh page: press Issue it on the third draft */
137
140
  const J = await open('/premium-initiative.html' + iq), jp = J.page;
138
141
  const k3 = d3.path.split('/').slice(-2)[0];
139
- await until(() => jp.evaluate((k) => !!document.querySelector(`#dmList [data-doc="${k}"]`), k3), 60000);
140
- await jp.click(`#dmList [data-doc="${k3}"]`); await dlgOn(jp);
141
- await until(() => jp.evaluate(() => !!document.querySelector('[data-ds="issue"]')));
142
- await jp.click('[data-ds="issue"]');
143
- ok('I4 Issue it works from the sheet: the toast, the issued bar, and the row reads Up to date', !!(await toastIs(jp, /Issued\. Nothing was sent to anyone/)) && await until(() => jp.evaluate(() => !!document.querySelector('#oMain [data-issue-bar="done"]') && !document.querySelector('[data-ds="issue"]'))) && await until(() => jp.evaluate((k) => /Up to date/.test((document.querySelector(`#dmList [data-doc="${k}"]`) || {}).textContent || ''), k3)));
142
+ await ovOpen(jp);
143
+ await until(() => jp.evaluate((k) => !!document.querySelector(`#czViewer [data-ov-dread="${k}"]`), k3), 60000);
144
+ await jp.click(`#czViewer [data-ov-dread="${k3}"]`);
145
+ await until(() => jp.evaluate(() => !!document.querySelector('#czViewer [data-ds="issue"]')));
146
+ await jp.click('#czViewer [data-ds="issue"]');
147
+ const issued = !!(await toastIs(jp, /Issued\. Nothing was sent to anyone/)) && await until(() => jp.evaluate(() => !!document.querySelector('#czViewer [data-issue-bar="done"]') && !document.querySelector('#czViewer [data-ds="issue"]')));
148
+ await sleep(1500); await jp.click('.hm-card [data-hm-ov]');
149
+ ok('I4 Issue it works from the reader: the toast, the issued bar, and the Overview row reads Up to date', issued && await until(() => jp.evaluate((k) => /Up to date/.test((document.querySelector(`#czViewer [data-ov-doc="${k}"]`) || {}).textContent || ''), k3), 30000));
144
150
  ok('I4 the file says state: issued and the ledger has its issue line', /^state: issued$/m.test(fs.readFileSync(path.join(team, d3.path), 'utf8')) && ledger().some((l) => l.ev === 'issue' && l.slot === d3.slot && l.scope === iscope));
145
151
  await jp.screenshot({ path: path.join(R.base, 'ini-issued.png') });
146
152
 
@@ -162,12 +168,13 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
162
168
  const k4 = d4.path.split('/').slice(-2)[0];
163
169
  for (const [w, h, theme] of [[390, 844, 'light'], [390, 844, 'dark'], [1280, 900, 'dark']]) {
164
170
  const S = await open('/premium-board.html', { w, h, theme });
165
- await until(() => S.page.evaluate((k) => !!document.querySelector(`#docBody [data-doc="${k}"]`), k4), 60000);
166
- await S.page.click('#tabDocs'); // the Agreed design shows the documents on the Documents tab (premium-agreed-design)
167
- await S.page.click(`#docBody [data-doc="${k4}"]`); await dlgOn(S.page);
168
- await until(() => S.page.evaluate(() => !!document.querySelector('[data-ds="issue"]')));
169
- const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#oMain [data-ds="issue"], #oMain [data-ds="again"]')].filter((b) => b.getBoundingClientRect().height < 44 || b.getBoundingClientRect().width < 44).map((b) => b.dataset.ds), bg: getComputedStyle(document.querySelector('[data-issue-bar]')).backgroundColor }));
170
- ok(`F1 ${w} px ${theme}: no sideways scroll and the bar's buttons are at least 44 px`, !f.wide && !f.small.length, JSON.stringify(f));
171
+ await until(() => S.page.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 60000);
172
+ await S.page.click(w <= 720 ? '#chDocs' : '#tabDocs');
173
+ await until(() => S.page.evaluate((k) => !!document.querySelector(`#docBody [data-act="cdoc"][data-key="${k}"]`), k4), 60000);
174
+ await S.page.click(`#docBody [data-act="cdoc"][data-key="${k4}"]`);
175
+ await until(() => S.page.evaluate(() => !!document.querySelector('#peek [data-act="issue"]')));
176
+ const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#peek [data-act="issue"]')].filter((b) => b.getBoundingClientRect().height < (innerWidth <= 720 ? 44 : 34)).map((b) => b.textContent) }));
177
+ ok(`F1 ${w} px ${theme}: no sideways scroll and the bar's button is 44 px on a phone`, !f.wide && !f.small.length, JSON.stringify(f));
171
178
  await S.page.screenshot({ path: path.join(R.base, `bar-${w}-${theme}.png`) });
172
179
  await S.ctx.close();
173
180
  }