create-pmos 0.397.0 → 0.399.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 (195) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +105 -52
  8. package/workspace/briefing-premium-board-test.js +284 -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 +85 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +99 -83
  13. package/workspace/briefing-premium-initiative-test.js +175 -290
  14. package/workspace/briefing-premium-insights-test.js +414 -219
  15. package/workspace/briefing-premium-metrics-test.js +55 -97
  16. package/workspace/briefing-premium-products-test.js +44 -28
  17. package/workspace/briefing-premium-sources-test.js +70 -49
  18. package/workspace/briefing-premium-test.js +155 -648
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +24 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/board-premium-trail.js +32 -0
  23. package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
  24. package/workspace/guide/briefing-premium.md +3 -1
  25. package/workspace/guide/home.md +68 -0
  26. package/workspace/guide/index.md +1 -0
  27. package/workspace/lib/agent-roles.js +71 -0
  28. package/workspace/lib/board-grill.js +63 -0
  29. package/workspace/lib/board-premium.js +121 -24
  30. package/workspace/lib/board-trail.js +223 -0
  31. package/workspace/lib/home-work-item.js +58 -0
  32. package/workspace/lib/initiative-layout.js +77 -0
  33. package/workspace/lib/insights-goals.js +196 -0
  34. package/workspace/lib/insights-premium.js +64 -15
  35. package/workspace/lib/insights-records.js +115 -0
  36. package/workspace/lib/jira-tickets.js +1 -1
  37. package/workspace/lib/meeting-points.js +52 -0
  38. package/workspace/lib/news-for-you.js +88 -0
  39. package/workspace/lib/notes-series.js +29 -6
  40. package/workspace/lib/report-confirm.js +48 -0
  41. package/workspace/lib/route-modules.js +12 -0
  42. package/workspace/lib/routes-board-docs.js +46 -0
  43. package/workspace/lib/routes-board-grill.js +90 -0
  44. package/workspace/lib/routes-board-trail.js +33 -0
  45. package/workspace/lib/routes-home-desk.js +176 -0
  46. package/workspace/lib/routes-home-review.js +108 -0
  47. package/workspace/lib/routes-initiative-layout.js +57 -0
  48. package/workspace/lib/routes-insights-premium.js +16 -4
  49. package/workspace/lib/routes-insights-records.js +133 -0
  50. package/workspace/lib/routes-meeting-points.js +37 -0
  51. package/workspace/lib/routes-news.js +57 -0
  52. package/workspace/lib/routes-notes.js +3 -1
  53. package/workspace/lib/routes-report-confirm.js +31 -0
  54. package/workspace/lib/routes-search.js +38 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/search-index.js +176 -0
  57. package/workspace/lib/transcript-steps.js +123 -0
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-board-actions-test.js +128 -82
  63. package/workspace/premium-briefing-depth-test.js +104 -90
  64. package/workspace/premium-chat-attach-test.js +54 -63
  65. package/workspace/premium-chat-chart-tab-test.js +37 -37
  66. package/workspace/premium-chat-context-test.js +19 -18
  67. package/workspace/premium-chat-goal-view-test.js +23 -23
  68. package/workspace/premium-chat-notes-test.js +26 -31
  69. package/workspace/premium-chat-report-tab-test.js +46 -28
  70. package/workspace/premium-chat-term-test.js +16 -16
  71. package/workspace/premium-chat-viewer-test.js +60 -59
  72. package/workspace/premium-core-doc-issue-test.js +52 -43
  73. package/workspace/premium-html-viewer-test.js +14 -17
  74. package/workspace/premium-phone-card-test.js +10 -3
  75. package/workspace/premium-phone-room-test.js +41 -35
  76. package/workspace/premium-report-read-test.js +152 -197
  77. package/workspace/premium-viewer-download-test.js +19 -22
  78. package/workspace/premium-viewer-flicker-test.js +11 -16
  79. package/workspace/premium-viewer-share-test.js +6 -9
  80. package/workspace/premium-viewer-test.js +41 -60
  81. package/workspace/premium-vw-backlog-test.js +53 -33
  82. package/workspace/premium-vw-cal-test.js +97 -128
  83. package/workspace/premium-vw-copy-test.js +17 -33
  84. package/workspace/premium-vw-doc-test.js +17 -10
  85. package/workspace/premium-vw-item-test.js +50 -49
  86. package/workspace/premium-vw-jira-test.js +53 -27
  87. package/workspace/premium-vw-meet-test.js +115 -187
  88. package/workspace/premium-vw-notes-test.js +88 -109
  89. package/workspace/premium-vw-rec-test.js +71 -194
  90. package/workspace/premium-vw-slides-test.js +46 -50
  91. package/workspace/premium-welcome-test.js +3 -2
  92. package/workspace/premium-work-depth-test.js +61 -53
  93. package/workspace/public/pm/bd-acts.js +383 -0
  94. package/workspace/public/pm/bd-asks.js +261 -0
  95. package/workspace/public/pm/bd-pop.js +59 -0
  96. package/workspace/public/pm/bd-span.js +222 -82
  97. package/workspace/public/pm/bd-stages.js +25 -11
  98. package/workspace/public/pm/bd-views.js +169 -0
  99. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  100. package/workspace/public/pm/c3-md.js +3 -395
  101. package/workspace/public/pm/c3-phone-detail.js +1 -1
  102. package/workspace/public/pm/c3-phone-model.js +3 -68
  103. package/workspace/public/pm/chat-term.js +3 -3
  104. package/workspace/public/pm/cozy-board.css +798 -230
  105. package/workspace/public/pm/cozy-ev.css +228 -0
  106. package/workspace/public/pm/cozy-evmodel.js +106 -0
  107. package/workspace/public/pm/cozy-evui.js +47 -0
  108. package/workspace/public/pm/cozy-home.css +570 -142
  109. package/workspace/public/pm/cozy-home.js +5 -3
  110. package/workspace/public/pm/cozy-insights.css +437 -170
  111. package/workspace/public/pm/cozy-md.js +396 -0
  112. package/workspace/public/pm/cozy-nav.js +104 -29
  113. package/workspace/public/pm/cozy-news.js +140 -0
  114. package/workspace/public/pm/cozy-placeholder.js +26 -0
  115. package/workspace/public/pm/cozy-search.js +203 -0
  116. package/workspace/public/pm/cozy-settings.js +198 -0
  117. package/workspace/public/pm/cozy-sources.js +89 -0
  118. package/workspace/public/pm/cozy-today.css +217 -0
  119. package/workspace/public/pm/cozy-viewer.css +3 -3
  120. package/workspace/public/pm/cozy-viewer.js +145 -0
  121. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  122. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  123. package/workspace/public/pm/cozy-vw.css +485 -0
  124. package/workspace/public/pm/cozy.css +83 -1
  125. package/workspace/public/pm/home-adddoc.js +48 -0
  126. package/workspace/public/pm/home-app.js +1179 -0
  127. package/workspace/public/pm/home-around.js +413 -0
  128. package/workspace/public/pm/home-chat.js +512 -0
  129. package/workspace/public/pm/home-data.js +312 -0
  130. package/workspace/public/pm/home-dictate.js +54 -0
  131. package/workspace/public/pm/home-draft.js +68 -0
  132. package/workspace/public/pm/home-ini-model.js +190 -0
  133. package/workspace/public/pm/home-ini.css +171 -0
  134. package/workspace/public/pm/home-ini.js +456 -0
  135. package/workspace/public/pm/home-list.js +276 -0
  136. package/workspace/public/pm/home-more.js +132 -0
  137. package/workspace/public/pm/home-phone-card.js +109 -0
  138. package/workspace/public/pm/home-review.js +104 -0
  139. package/workspace/public/pm/home-task.js +67 -0
  140. package/workspace/public/pm/home-today.js +144 -0
  141. package/workspace/public/pm/home-work.js +547 -0
  142. package/workspace/public/pm/phone-moment.js +69 -0
  143. package/workspace/public/pm/pm-work-view.js +1 -1
  144. package/workspace/public/pm/premium-attach.js +4 -0
  145. package/workspace/public/pm/premium-board.js +548 -395
  146. package/workspace/public/pm/premium-chart-tab.js +109 -62
  147. package/workspace/public/pm/premium-deck.js +3 -3
  148. package/workspace/public/pm/premium-first.js +23 -21
  149. package/workspace/public/pm/premium-insights.js +1102 -581
  150. package/workspace/public/pm/premium-meeting.js +61 -549
  151. package/workspace/public/pm/premium-mtg-present.js +138 -0
  152. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  153. package/workspace/public/pm/premium-notes.js +1 -1
  154. package/workspace/public/pm/premium-report-frame.css +20 -0
  155. package/workspace/public/pm/premium-report-read.js +669 -476
  156. package/workspace/public/pm/premium-report-tab.js +116 -67
  157. package/workspace/public/pm/premium-shell.js +76 -123
  158. package/workspace/public/pm/premium-viewer.js +22 -1
  159. package/workspace/public/pm/premium-vw-cal.js +277 -48
  160. package/workspace/public/pm/premium-vw-doc.css +6 -0
  161. package/workspace/public/pm/premium-vw-doc.js +40 -2
  162. package/workspace/public/pm/premium-vw-file.js +2 -2
  163. package/workspace/public/pm/premium-vw-meet.js +6 -83
  164. package/workspace/public/pm/premium-vw-mtg.js +958 -0
  165. package/workspace/public/pm/premium-vw-notes.js +116 -68
  166. package/workspace/public/pm/premium-vw-open.js +35 -0
  167. package/workspace/public/pm/premium-vw-page.js +16 -0
  168. package/workspace/public/pm/premium-vw-rec.js +11 -218
  169. package/workspace/public/pm/premium-vw-slides.css +5 -0
  170. package/workspace/public/pm/premium-vw-slides.js +44 -8
  171. package/workspace/public/pm/rp-parts.js +269 -0
  172. package/workspace/public/pm/term-view.js +22 -0
  173. package/workspace/public/premium-board.html +29 -70
  174. package/workspace/public/premium-initiative.html +8 -48
  175. package/workspace/public/premium-insights.html +26 -64
  176. package/workspace/public/premium-viewer.html +20 -0
  177. package/workspace/public/premium.html +18 -107
  178. package/workspace/r/m1.png +0 -0
  179. package/workspace/r/m2.png +0 -0
  180. package/workspace/r/m3.png +0 -0
  181. package/workspace/r/nl.png +0 -0
  182. package/workspace/server.js +18 -3
  183. package/workspace/test-files.json +1 -0
  184. package/workspace/test-lists/home-libs.json +9 -0
  185. package/workspace/test-lists/initiative-layout.json +9 -0
  186. package/workspace/test-lists/premium-report-read.json +1 -1
  187. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  188. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  189. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  190. package/workspace/test-lists/premium-vw-notes.json +1 -1
  191. package/workspace/test-lists/uf-everywhere.json +15 -0
  192. package/workspace/test-lists/uf-home.json +9 -0
  193. package/workspace/test-lists/uncovered-board.json +9 -0
  194. package/workspace/public/pm/premium-work.js +0 -729
  195. package/workspace/public/pm/premium.js +0 -1146
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- /* premium-chat-notes-test.js — Notes for a premium chat conversation (initiative premium-chat-attach, N1-N7).
4
- * Serves the real My work page from the real server with a fixture model; notes save through the real /api/chat-file/notes in a scratch state folder.
5
- * N1 + › Notes opens the notepad in the viewer, the old Scratchpad text is the first note · N2 typed Markdown is saved as a .md file
3
+ /* premium-chat-notes-test.js — Notes for a premium chat conversation (initiative premium-chat-attach, N1-N7; re-pointed by premium-agreed-design
4
+ * to Home's chat: /premium-chat.html opens Home with the chat ?about names. Notes is not in the Agreed design, so it stays usable from the
5
+ * composer's + menu (Notes, #hmNotes) and opens in the cozy Viewer with a "Waiting for design" marker; there is no + menu and no tab strip).
6
+ * Serves the real Home from the real server; notes save through the real /api/chat-file/notes in a scratch state folder.
7
+ * N1 the Notes button opens the notepad in the Viewer, the old Scratchpad text is the first note · N2 typed Markdown is saved as a .md file
6
8
  * N3 a checkbox ticks · N4 New note and the list · N5 the buttons are icons with names · N6 Add selection · N7 Share with Claude puts the note on
7
9
  * the message · N8 the bubble's note chip opens Notes · N9 Delete asks first · N10 phone, both themes */
8
10
  const fs = require('fs');
@@ -10,8 +12,6 @@ const path = require('path');
10
12
  const { spawn } = require('child_process');
11
13
  const { findBrowser } = require('./lib/find-browser');
12
14
  const T = require('./test-run').configure({ name: 'premium-chat-notes' });
13
- const WP = require('./lib/my-work-premium.js');
14
- const F = require('./fixtures/my-work-premium-facts.js');
15
15
  const lib = require('./lib/chat-files.js');
16
16
 
17
17
  const BASE = T.BASE;
@@ -42,33 +42,30 @@ const notes = (key = KEY) => lib.listNotes({ runtimeDir: T.STATE_DIR, key }).not
42
42
  srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
43
43
  await T.waitForServer(BASE);
44
44
  browser = await chromium.launch({ executablePath: exe });
45
- const model = WP.build({ v: F.view(), now: F.NOW });
46
45
 
47
46
  const open = async ({ w = 1280, h = 900, scheme = 'light' } = {}) => {
48
- const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: scheme });
47
+ const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: scheme, hasTouch: w < 1000 });
49
48
  const page = await ctx.newPage();
50
- const errors = [], asks = [];
49
+ const errors = [], asks = [], st = { session: null, messages: [] };
51
50
  page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
52
- await page.route('**/api/my-work-premium', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model, as_of: Date.now() }) }));
53
- await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() !== 'GET') asks.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }); });
54
- await page.goto(BASE + '/premium-work.html', { waitUntil: 'domcontentloaded' });
55
- await page.waitForFunction(() => document.querySelector('#dBody') !== null);
56
- return { page, ctx, errors, asks };
51
+ await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() !== 'GET') asks.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false, ...(st.session ? { session: st.session } : {}) }) }); });
52
+ await page.route('**/api/sessions/conversation**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'user', messages: st.messages } }));
53
+ await page.goto(BASE + '/premium-chat.html?about=' + encodeURIComponent(KEY), { waitUntil: 'domcontentloaded' });
54
+ await page.waitForFunction(() => !!document.querySelector('#hmNotes'), null, { timeout: 15000 });
55
+ return { page, ctx, errors, asks, st };
57
56
  };
58
- const dlg = (page, key) => page.evaluate(async (key) => { const m = await import('/pm/premium-shell.js'); m.openDlg({ eye: 'Test', title: 'Notes test', say: 'Hello.', noteKey: key, html: '<p>detail</p>' }); m.setTab('chat'); }, key);
59
- const close = (page) => page.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.closeDlg(); });
60
- const openNotes = async (page) => { await page.click('#askPlus'); await page.click('[data-plus="pad"]'); return until(async () => page.isVisible('#ntEd')); };
57
+ // Notes is an item of the box's + menu (Agreed design: the toolbar is "+ / @ chip"; Notes is marked Waiting for design)
58
+ const openNotes = async (page) => { await page.click('#hmAdd'); await page.click('#hmNotes'); return until(async () => page.isVisible('#ntEd')); };
61
59
  const typeIn = async (page, s) => { await page.click('#ntEd'); await page.keyboard.type(s); };
62
60
 
63
61
  // the old Scratchpad of this conversation, as the pad left it
64
62
  await fetch(BASE + '/api/scratchpad', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ key: KEY, text: 'call Dana\nask about Q4' }) });
65
63
 
66
- let { page, ctx, errors, asks } = await open();
67
- await dlg(page, KEY);
64
+ let { page, ctx, errors, asks, st } = await open();
68
65
  /* N1 */
69
- ok('N1 the + menu names Notes, not Scratchpad', /Notes/.test(await page.textContent('#plusM')) && !/Scratchpad/.test(await page.textContent('#plusM')));
66
+ ok('N1 the composer has a Notes button, not a Scratchpad', /Notes/.test(await page.getAttribute('#hmNotes', 'aria-label')) && !/Scratchpad/.test(await page.textContent('#hmFoot')));
70
67
  ok('N1 the Scratchpad strip and its chip are gone', (await page.$('#sPad')) === null && (await page.$('#sPadT')) === null);
71
- ok('N1 Notes opens in the viewer as a tab', !!(await openNotes(page)) && /Notes/.test(await page.textContent('#vTabs')));
68
+ ok('N1 Notes opens in the Viewer, titled Notes, marked Waiting for design', !!(await openNotes(page)) && (await page.textContent('#czVwTitle')).trim() === 'Notes' && !!(await until(async () => page.isVisible('#czViewer .hx-wait'))));
72
69
  ok('N1 the old Scratchpad text is the first note, line by line', !!(await until(async () => notes().length === 1)) && notes()[0].text === 'call Dana\n\nask about Q4' && /call Dana[\s\S]*ask about Q4/.test(await page.textContent('#ntEd')));
73
70
  ok('N1 the pad is emptied once its text is a note', !!(await until(async () => { const r = await (await fetch(BASE + '/api/scratchpad?key=' + encodeURIComponent(KEY))).json(); return r.text === ''; })));
74
71
  ok('N1 the note title shows in the head', (await page.textContent('#ntSw')).trim() === 'call Dana');
@@ -99,15 +96,15 @@ const notes = (key = KEY) => lib.listNotes({ runtimeDir: T.STATE_DIR, key }).not
99
96
  /* N6 */
100
97
  await page.evaluate(() => { const p = [...document.querySelectorAll('#ntEd p')].find((x) => /ask about/.test(x.textContent)); const r = document.createRange(); r.selectNodeContents(p); getSelection().removeAllRanges(); getSelection().addRange(r); });
101
98
  await page.click('[data-nt="sel"]');
102
- ok('N6 Add selection puts only the selected words in the message box', (await page.inputValue('#askIn')) === 'ask about Q4', JSON.stringify(await page.inputValue('#askIn')));
99
+ ok('N6 Add selection puts only the selected words in the message box', (await page.inputValue('#hmIn')) === 'ask about Q4', JSON.stringify(await page.inputValue('#hmIn')));
103
100
  ok('N6 nothing was sent', asks.length === 0);
104
101
  /* N7 */
105
- await page.fill('#askIn', 'Plan the deck from my note');
102
+ await page.fill('#hmIn', 'Plan the deck from my note');
106
103
  await page.click('#ntSw'); await page.click('#ntM [data-ntgo]:nth-child(1)');
107
104
  await page.click('[data-nt="share"]');
108
- ok('N7 Share with Claude puts the note on the message as a chip', !!(await until(async () => page.evaluate(() => { const c = document.querySelector('#attRow .atc'); return c && /Q4 review prep/.test(c.textContent) && /NOTE/.test(c.textContent); }))));
105
+ ok('N7 Share with Claude puts the note on the message as a chip', !!(await until(async () => page.evaluate(() => { const c = document.querySelector('#hmFiles .hm-att'); return c && /Q4 review prep/.test(c.textContent) && /Note/.test(c.textContent); }))));
109
106
  await shot(page, 'shared-1280-light');
110
- await page.click('#askGo');
107
+ await page.click('#hmForm [type=submit]');
111
108
  const ask = await until(async () => asks.find((a) => a.path.endsWith('/ask')));
112
109
  const q4 = notes().find((x) => x.title === 'Q4 review prep');
113
110
  ok('N7 send names the note as notes/<id>.md', !!ask && ask.body.text === 'Plan the deck from my note' && JSON.stringify(ask.body.files) === JSON.stringify(['notes/' + q4.id + '.md']), JSON.stringify(ask && ask.body));
@@ -115,31 +112,29 @@ const notes = (key = KEY) => lib.listNotes({ runtimeDir: T.STATE_DIR, key }).not
115
112
  ok('N7 the name resolves to the note file Claude reads', paths.ok && paths.paths[0] === q4.path);
116
113
  ok('N7 the note stays after the send', notes().length === 2);
117
114
  /* N8 */
118
- const line = lib.withFiles('Plan the deck from my note', paths.paths).replace(/\n/g, ' ');
119
- await page.evaluate(async (text) => { const m = await import('/pm/premium-shell.js'); document.querySelector('#dBody .stream').innerHTML = m.sessionHtml({ state: 'conv', messages: [{ role: 'user', text }] }); }, line);
115
+ st.messages = [{ role: 'user', text: lib.withFiles('Plan the deck from my note', paths.paths), at: '2026-10-21T08:00:00Z' }]; st.session = 's-notes';
116
+ await until(async () => page.isVisible('#hmLog .hm-u .atc[data-att]'));
120
117
  await page.click('#ntSw'); await page.click('#ntM [data-ntgo]:nth-child(2)');
121
- await page.click('#dBody .turn.u .atc[data-att]');
118
+ await page.click('#hmLog .hm-u .atc[data-att]');
122
119
  ok('N8 the note chip in the PM\'s bubble opens that note', !!(await until(async () => (await page.textContent('#ntSw')).trim() === 'Q4 review prep')));
123
120
  /* N9 */
124
121
  await page.click('#ntSw'); await page.click('#ntM [data-ntdel]');
125
122
  ok('N9 Delete asks first', await page.isVisible('.vcf'));
126
123
  await page.click('.vcf button:has-text("Delete")');
127
124
  ok('N9 Delete removes the note and shows the other', !!(await until(async () => notes().length === 1 && /call Dana/.test(await page.textContent('#ntEd')))));
128
- await close(page);
129
125
  ok('N1-N9 no page errors', errors.length === 0, errors.join(' | '));
130
126
  await ctx.close();
131
127
 
132
128
  /* N10 phone, both themes */
133
129
  for (const scheme of ['light', 'dark']) {
134
130
  ({ page, ctx, errors } = await open({ w: 390, h: 844, scheme }));
135
- await dlg(page, KEY);
136
- ok(`N10 ${scheme}: Notes opens the viewer tab on a phone`, !!(await openNotes(page)));
131
+ ok(`N10 ${scheme}: Notes opens the Viewer over the chat on a phone`, !!(await openNotes(page)));
137
132
  await shot(page, 'notes-390-' + scheme);
138
133
  ok(`N10 ${scheme}: the notepad fits the width`, await page.evaluate(() => { const w = innerWidth; return ['#ntEd', '.ntf', '.nth'].every((s) => { const r = document.querySelector(s).getBoundingClientRect(); return r.width > 0 && r.left >= 0 && r.right <= w + 1; }); }));
139
134
  await until(async () => page.evaluate(() => !document.getAnimations().some((a) => a.playState === 'running'))); // the popup's entrance scales it: measure once it has settled
140
135
  { const ic = await page.evaluate(() => [...document.querySelectorAll('.ntic')].map((b) => (b.dataset.nt || b.id || b.className) + ':' + Math.round(b.getBoundingClientRect().height))); ok(`N10 ${scheme}: the icon buttons are 44px targets`, ic.length > 0 && ic.every((x) => +x.split(':').pop() >= 44), ic.join()); }
141
136
  await page.click('[data-nt="share"]');
142
- ok(`N10 ${scheme}: Share with Claude goes back to the conversation with the chip`, !!(await until(async () => page.isVisible('#attRow .atc'))));
137
+ ok(`N10 ${scheme}: Share with Claude goes back to the conversation with the chip`, !!(await until(async () => (await page.isVisible('#hmFiles .hm-att')) && (await page.$('#czViewer:not([hidden])')) === null)));
143
138
  ok(`N10 ${scheme}: no page errors`, errors.length === 0, errors.join(' | '));
144
139
  await ctx.close();
145
140
  }
@@ -37,12 +37,18 @@ 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 show At a glance as the Brief draws it (premium-uncovered-features, canvas RpBrief). A confirm asks in the
43
+ * card ([data-rt="askyes"]). */
40
44
  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,
45
+ const vw = document.querySelector('#czViewer:not([hidden])'), pane = vw ? vw.querySelector('.vz[data-vw^="report:"]') : null;
46
+ return { shut: !pane, layer: false, chip: (document.querySelector('#hmLog [data-report-open]') || {}).textContent || null,
47
+ json: /pmos-report|"kind"/.test((document.querySelector('#hmLog') || {}).textContent || ''), user: [...document.querySelectorAll('#hmLog .hm-u .hm-bub')].map((u) => u.textContent.trim()),
48
+ tabs: pane ? [(vw.querySelector('.cz-vw-kind') || {}).textContent || ''] : [], pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null,
49
+ secs: pane ? (pane.querySelector('.vz-dkt') ? pane.querySelectorAll('.vz-dkt button').length - 1 : pane.querySelectorAll('.vz-secs li').length) : 0,
50
+ slide: pane && pane.querySelector('.vz-dkn > span') ? pane.querySelector('.vz-dkn > span').textContent : null,
51
+ sched: pane && pane.querySelector('[data-rt="sched"] b') ? pane.querySelector('[data-rt="sched"] b').textContent : null,
46
52
  wide: document.documentElement.scrollWidth > innerWidth + 1 };
47
53
  };
48
54
 
@@ -62,10 +68,8 @@ const look = () => {
62
68
  const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
63
69
  await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-rep', goal: null } }));
64
70
  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')));
71
+ 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
72
+ await until(() => p.evaluate(() => !!document.querySelector('#hmLog [data-report-open]')));
69
73
  await sleep(500);
70
74
  return { p, ctx, errs, st };
71
75
  };
@@ -74,32 +78,47 @@ const look = () => {
74
78
  const s0 = await p.evaluate(look);
75
79
  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
80
  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]');
81
+ await p.click('#hmLog [data-report-open]');
78
82
  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));
83
+ 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 || '') && /Read byGrowth leads/.test(s1.pane || '') && /FormatGoogle Slides/.test(s1.pane || '') && !/Waiting for design/.test(s1.pane || '')
84
+ && 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));
85
+ await p.click('#czViewer [data-rt="sl|1"]');
86
+ 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
87
  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"]');
88
+ await p.click('#czViewer [data-rt="sched"]');
89
+ await p.click('#czViewer [data-rt="pick|2"]');
84
90
  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
91
  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);
92
+ await p.click('#czViewer [data-rt="sched"]'); await p.click('#czViewer [data-rt="pick|0"]');
93
+ await p.click('#czViewer [data-rt="setup"]');
94
+ 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
95
  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)]));
96
+ 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
97
  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
98
  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"]');
99
+ await p.click('#czViewer [data-rt="sched"]'); await p.click('#czViewer [data-rt="pick|3"]');
94
100
  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
101
  const changed = RS.fold(ledger()).setups.get(setup && setup.id);
96
102
  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"]');
103
+ /* R8 the look conversation's card (canvas RpDesign): D1 is the saved look, D2 a new one; Design previews D2 beside the current look */
104
+ const RDS = require('./lib/report-design.js');
105
+ const look1 = '<style>.pmos-slide{background:#fff}</style><section class="pmos-slide" data-title="Headline"><h2>Light, long</h2></section>';
106
+ const look2 = '<style>.pmos-slide{background:#14213D;color:#F3F5F9}</style><section class="pmos-slide" data-title="Headline"><h2>Dark, short</h2></section>';
107
+ const v1 = RDS.writeVersion(F.team, setup.id, look1, { turn: 'Light, long' }), v2 = RDS.writeVersion(F.team, setup.id, look2, { turn: 'Like the Sept leadership deck' });
108
+ RDS.append(F.team, setup.id, { ev: 'accept', n: 1, rules: { same: ['Dark slides'], changes: [], learned: [] } });
109
+ await p.click('#czViewer [data-rt="view|design"]');
110
+ const d1 = await until(() => p.evaluate(() => { const v = document.querySelector('#czViewer .vz[data-vw^="report:"]'); return v && /Previewing new look/.test(v.textContent) ? { t: v.textContent, pair: v.querySelectorAll('.rp-pair .rp-thumb').length, use: !!v.querySelector('[data-rt="d-accept"]'), keep: !!v.querySelector('[data-rt="d-keep"]') } : null; }), 10000);
111
+ ok('R8 Design is the look conversation (RpDesign): Previewing new look, Current beside New look, Use it and Keep current', v1.ok && v2.ok && d1 && d1.pair === 2 && d1.use && d1.keep && /New look/.test(d1.t) && /Current/.test(d1.t), JSON.stringify(d1));
112
+ if (shots) await p.screenshot({ path: `${shots}/design-1280-light.png` });
113
+ await p.click('#czViewer [data-rt="d-accept"]');
114
+ ok('R8 Use it saves the new look; the card says the next cycle follows it', await until(() => p.evaluate(() => /Using the new look \(D2\)/.test((document.querySelector('#czViewer .vz[data-vw^="report:"]') || {}).textContent || '') && /Saved look/.test(document.querySelector('#czViewer .vz[data-vw^="report:"]').textContent)), 10000) && (RDS.fold(RDS.readEvents(F.team, setup.id)).saved || {}).version === 2, await p.evaluate(() => ((document.querySelector('#czViewer .vz[data-vw^="report:"]') || {}).textContent || '').slice(0, 600)));
115
+ await p.click('#czViewer [data-rt="view|structure"]');
116
+ await p.click('#czViewer [data-rt^="discard|"]');
117
+ await p.click('#czViewer [data-rt="askyes"]');
99
118
  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
119
  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"]');
120
+ await p.click('#czViewer [data-rt="remove"]');
121
+ await p.click('#czViewer [data-rt="askyes"]');
103
122
  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
123
  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
124
  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 +130,9 @@ const look = () => {
111
130
  for (const scheme of ['light', 'dark']) {
112
131
  const { p, ctx, errs } = await open(390, scheme, [ASK, ANSWER]);
113
132
  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');
133
+ await p.click('#hmLog [data-report-open]');
134
+ // premium-agreed-design: on a phone the chat is the page, and the Viewer card covers the whole screen with the Report in it
135
+ const shown = () => p.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); return !!v && v.getBoundingClientRect().width >= innerWidth - 1; });
118
136
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && await shown() ? v : null; }) || await p.evaluate(look);
119
137
  s1.detail = await shown();
120
138
  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 +142,7 @@ const look = () => {
124
142
  }
125
143
  if (shots) {
126
144
  const { p, ctx } = await open(1280, 'dark', [ASK, ANSWER]);
127
- await p.click('#dBody [data-report-open]'); await sleep(500);
145
+ await p.click('#hmLog [data-report-open]'); await sleep(500);
128
146
  await p.screenshot({ path: `${shots}/new-1280-dark.png` });
129
147
  await ctx.close();
130
148
  }
@@ -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();