create-pmos 0.396.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 (177) 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/scripts/nine-stages.js +49 -20
  6. package/payload/state/discoveries.md +1 -1
  7. package/payload/state/log.md +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +103 -74
  9. package/workspace/briefing-premium-board-test.js +316 -154
  10. package/workspace/briefing-premium-calendar-2-test.js +135 -195
  11. package/workspace/briefing-premium-calendar-3-test.js +143 -413
  12. package/workspace/briefing-premium-calendar-test.js +86 -185
  13. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  14. package/workspace/briefing-premium-initiative-test.js +166 -294
  15. package/workspace/briefing-premium-insights-test.js +351 -214
  16. package/workspace/briefing-premium-metrics-test.js +53 -118
  17. package/workspace/briefing-premium-products-test.js +40 -27
  18. package/workspace/briefing-premium-sources-test.js +91 -52
  19. package/workspace/briefing-premium-test.js +150 -633
  20. package/workspace/briefing-premium-work-test.js +88 -269
  21. package/workspace/changelog.json +24 -0
  22. package/workspace/fixtures/board-premium-facts.js +2 -1
  23. package/workspace/fixtures/board-premium-jira.js +28 -0
  24. package/workspace/fixtures/board-premium-trail.js +32 -0
  25. package/workspace/fixtures/initiative-premium-facts.js +2 -1
  26. package/workspace/fixtures/initiatives-api/list.json +30 -42
  27. package/workspace/fixtures/initiatives-api/roadmap.json +40 -56
  28. package/workspace/fixtures/initiatives-api/sheet.json +10 -14
  29. package/workspace/fixtures/insights-premium-facts.js +11 -2
  30. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  31. package/workspace/guide/briefing-premium.md +3 -1
  32. package/workspace/guide/home.md +47 -0
  33. package/workspace/guide/index.md +2 -0
  34. package/workspace/guide/lifecycle.md +51 -0
  35. package/workspace/home-shot.js +38 -0
  36. package/workspace/lib/agent-roles.js +71 -0
  37. package/workspace/lib/board-premium.js +160 -3
  38. package/workspace/lib/board-trail.js +223 -0
  39. package/workspace/lib/engine/boards.js +15 -14
  40. package/workspace/lib/engine/nine-stages.js +49 -20
  41. package/workspace/lib/engine/signals/detectors.js +13 -11
  42. package/workspace/lib/home-work-item.js +58 -0
  43. package/workspace/lib/insights-goals.js +196 -0
  44. package/workspace/lib/insights-premium.js +126 -1
  45. package/workspace/lib/insights-records.js +101 -0
  46. package/workspace/lib/jira-tickets.js +1 -1
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-board-premium.js +3 -2
  49. package/workspace/lib/routes-board-trail.js +33 -0
  50. package/workspace/lib/routes-home-desk.js +176 -0
  51. package/workspace/lib/routes-initiatives.js +1 -1
  52. package/workspace/lib/routes-insights-premium.js +19 -3
  53. package/workspace/lib/routes-insights-records.js +129 -0
  54. package/workspace/lib/routes-notes.js +1 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/transcript-steps.js +123 -0
  57. package/workspace/lib/vendor/scripts/nine-stages.js +49 -20
  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-agreed-viewer-shots.js +76 -0
  63. package/workspace/premium-board-actions-test.js +85 -73
  64. package/workspace/premium-briefing-depth-test.js +66 -53
  65. package/workspace/premium-chat-attach-test.js +54 -63
  66. package/workspace/premium-chat-chart-tab-test.js +35 -36
  67. package/workspace/premium-chat-context-test.js +22 -19
  68. package/workspace/premium-chat-goal-view-test.js +28 -26
  69. package/workspace/premium-chat-notes-test.js +29 -33
  70. package/workspace/premium-chat-report-tab-test.js +35 -25
  71. package/workspace/premium-chat-term-test.js +16 -14
  72. package/workspace/premium-chat-viewer-test.js +60 -53
  73. package/workspace/premium-core-doc-issue-test.js +50 -41
  74. package/workspace/premium-html-viewer-test.js +17 -18
  75. package/workspace/premium-phone-card-test.js +8 -2
  76. package/workspace/premium-phone-room-test.js +42 -31
  77. package/workspace/premium-report-read-test.js +115 -197
  78. package/workspace/premium-viewer-download-test.js +19 -22
  79. package/workspace/premium-viewer-flicker-test.js +11 -16
  80. package/workspace/premium-viewer-share-test.js +6 -9
  81. package/workspace/premium-viewer-test.js +41 -60
  82. package/workspace/premium-vw-backlog-test.js +53 -31
  83. package/workspace/premium-vw-cal-test.js +82 -123
  84. package/workspace/premium-vw-copy-test.js +17 -33
  85. package/workspace/premium-vw-doc-test.js +12 -11
  86. package/workspace/premium-vw-item-test.js +50 -48
  87. package/workspace/premium-vw-jira-test.js +55 -26
  88. package/workspace/premium-vw-meet-test.js +118 -187
  89. package/workspace/premium-vw-notes-test.js +85 -107
  90. package/workspace/premium-vw-rec-test.js +72 -193
  91. package/workspace/premium-vw-slides-test.js +46 -50
  92. package/workspace/premium-welcome-test.js +3 -2
  93. package/workspace/premium-work-depth-test.js +63 -51
  94. package/workspace/public/pm/bd-acts.js +305 -0
  95. package/workspace/public/pm/bd-span.js +224 -0
  96. package/workspace/public/pm/bd-stages.js +47 -0
  97. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  98. package/workspace/public/pm/c3-md.js +3 -395
  99. package/workspace/public/pm/c3-phone-detail.js +1 -1
  100. package/workspace/public/pm/c3-phone-model.js +3 -68
  101. package/workspace/public/pm/chat-term.js +3 -3
  102. package/workspace/public/pm/cozy-board.css +640 -0
  103. package/workspace/public/pm/cozy-home.css +580 -0
  104. package/workspace/public/pm/cozy-home.js +172 -0
  105. package/workspace/public/pm/cozy-initiative.css +138 -0
  106. package/workspace/public/pm/cozy-insights.css +421 -0
  107. package/workspace/public/pm/cozy-md.js +396 -0
  108. package/workspace/public/pm/cozy-nav.js +65 -0
  109. package/workspace/public/pm/cozy-placeholder.js +26 -0
  110. package/workspace/public/pm/cozy-viewer.css +143 -0
  111. package/workspace/public/pm/cozy-viewer.js +144 -0
  112. package/workspace/public/pm/cozy-vw.css +485 -0
  113. package/workspace/public/pm/cozy.css +254 -0
  114. package/workspace/public/pm/home-adddoc.js +48 -0
  115. package/workspace/public/pm/home-app.js +905 -0
  116. package/workspace/public/pm/home-around.js +515 -0
  117. package/workspace/public/pm/home-chat.js +459 -0
  118. package/workspace/public/pm/home-data.js +312 -0
  119. package/workspace/public/pm/home-draft.js +68 -0
  120. package/workspace/public/pm/home-more.js +249 -0
  121. package/workspace/public/pm/home-phone-card.js +109 -0
  122. package/workspace/public/pm/home-work.js +519 -0
  123. package/workspace/public/pm/lifecycle-lens-model.js +45 -27
  124. package/workspace/public/pm/lifecycle-lens.js +22 -11
  125. package/workspace/public/pm/phone-moment.js +69 -0
  126. package/workspace/public/pm/pm-work-view.js +1 -1
  127. package/workspace/public/pm/premium-attach.js +4 -0
  128. package/workspace/public/pm/premium-board.js +544 -253
  129. package/workspace/public/pm/premium-brief.js +1 -1
  130. package/workspace/public/pm/premium-chart-tab.js +110 -62
  131. package/workspace/public/pm/premium-chat.js +17 -10
  132. package/workspace/public/pm/premium-deck.js +3 -3
  133. package/workspace/public/pm/premium-first.js +25 -21
  134. package/workspace/public/pm/premium-initiative-head.js +138 -0
  135. package/workspace/public/pm/premium-initiative.js +28 -4
  136. package/workspace/public/pm/premium-insights.js +950 -440
  137. package/workspace/public/pm/premium-meeting.js +61 -549
  138. package/workspace/public/pm/premium-notes.js +1 -1
  139. package/workspace/public/pm/premium-report-frame.css +20 -0
  140. package/workspace/public/pm/premium-report-read.js +509 -480
  141. package/workspace/public/pm/premium-report-tab.js +87 -63
  142. package/workspace/public/pm/premium-shell.js +107 -124
  143. package/workspace/public/pm/premium-viewer.js +27 -1
  144. package/workspace/public/pm/premium-vw-cal.js +187 -48
  145. package/workspace/public/pm/premium-vw-doc.css +6 -0
  146. package/workspace/public/pm/premium-vw-doc.js +40 -2
  147. package/workspace/public/pm/premium-vw-file.js +2 -2
  148. package/workspace/public/pm/premium-vw-jira-model.js +22 -5
  149. package/workspace/public/pm/premium-vw-jira.css +11 -0
  150. package/workspace/public/pm/premium-vw-jira.js +11 -4
  151. package/workspace/public/pm/premium-vw-meet.js +6 -83
  152. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  153. package/workspace/public/pm/premium-vw-notes.js +56 -69
  154. package/workspace/public/pm/premium-vw-open.js +35 -0
  155. package/workspace/public/pm/premium-vw-page.js +16 -0
  156. package/workspace/public/pm/premium-vw-rec.js +11 -215
  157. package/workspace/public/pm/premium-vw-slides.css +5 -0
  158. package/workspace/public/pm/premium-vw-slides.js +44 -8
  159. package/workspace/public/pm/term-view.js +22 -0
  160. package/workspace/public/premium-board.html +57 -64
  161. package/workspace/public/premium-chat.html +7 -33
  162. package/workspace/public/premium-initiative.html +8 -41
  163. package/workspace/public/premium-insights.html +63 -62
  164. package/workspace/public/premium-viewer.html +20 -0
  165. package/workspace/public/premium-work.html +6 -72
  166. package/workspace/public/premium.html +21 -66
  167. package/workspace/public/vendor/nunito-var.woff2 +0 -0
  168. package/workspace/server.js +25 -3
  169. package/workspace/test-files.json +1 -0
  170. package/workspace/test-lists/home-libs.json +9 -0
  171. package/workspace/test-lists/premium-agreed-viewer.json +9 -0
  172. package/workspace/test-lists/premium-report-read.json +1 -1
  173. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  174. package/workspace/test-lists/premium-vw-notes.json +1 -1
  175. package/workspace/third-party/README.md +1 -0
  176. package/workspace/public/pm/premium-work.js +0 -719
  177. package/workspace/public/pm/premium.js +0 -1133
@@ -6,7 +6,8 @@
6
6
  * C1 a chart block is a chip; it opens the Chart tab with the measure drawn from its readings, as proposed (bars)
7
7
  * C2 a form pick redraws the chart and writes nothing; Save chart saves it with the picked form; Delete chart asks once and removes it
8
8
  * C3 a dashboard block draws its charts in order and names a measure with no series; Save dashboard saves it
9
- * I1 Insights has no Studio: Edit on a saved dashboard opens the Chat page with its tab; New chart opens it with a first message in the box
9
+ * I1 Insights has no Studio: Ask why opens Home's chat about Insights with the question in the box, not sent (Insights was rebuilt; its
10
+ * dashboards are edited on Insights itself)
10
11
  * F1 no page error and no sideways scroll at 1280 and 390
11
12
  * Set CHART_TAB_SHOTS=<dir> to save the page at 1280 and 390. */
12
13
  const fs = require('fs');
@@ -53,12 +54,17 @@ const ASK = (t) => ({ role: 'user', text: '[PMOS report] rule\n\nThe PM says: '
53
54
  const CHART = { kind: 'chart', proposal: { measure: 'krm-a', title: 'Partners activating', question: 'Are partners activating?', form: 'bars', range: null, target: 50, better: 'higher', note: '' } };
54
55
  const DASH = { kind: 'dashboard', proposal: { name: 'Partner growth', purpose: 'The Monday partner review', charts: ['krm-a', 'krm-t', 'krm-l'] } };
55
56
 
57
+ /* premium-agreed-design: Home's chat (home-chat.js) draws the chip; a chart or dashboard opens in the Viewer card (cozy-viewer.js), whose kind line names it.
58
+ * A chart is the design's metrics view (Main.dc.html viewer "metrics": stat tiles, then the readings with the newest in ember); its forms, Save and
59
+ * Delete are the cozy part marked Waiting for design, and a confirm asks in the card ([data-ct="askyes"]). */
56
60
  const look = () => {
57
- const pane = [...document.querySelectorAll('#dOut .obody.vw')].find((x) => !x.hidden && /^(chart|dashboard):/.test(x.dataset.vw || '')) || null;
58
- return { chip: (document.querySelector('#dBody [data-report-open]') || {}).textContent || null, tabs: [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.textContent.trim()),
59
- pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null, tiles: pane ? [...pane.querySelectorAll('.mt1')].map((t) => t.className.split(' ').slice(0, 3).join(' ')) : [],
60
- bars: pane ? pane.querySelectorAll('.bw i').length : 0, form: pane ? ((pane.querySelector('.rt-seg [aria-pressed="true"]') || {}).textContent || null) : null,
61
- wide: document.documentElement.scrollWidth > innerWidth + 1, say: (document.querySelector('#askIn') || {}).value || '' };
61
+ const vw = document.querySelector('#czViewer:not([hidden])');
62
+ const pane = vw ? vw.querySelector('.vz[data-vw^="chart:"], .vz[data-vw^="dashboard:"]') : null;
63
+ return { chip: (document.querySelector('#hmLog [data-report-open]') || {}).textContent || null, tabs: vw ? [(vw.querySelector('.cz-vw-kind') || {}).textContent || ''] : [], title: vw ? (vw.querySelector('.cz-vw-title') || {}).textContent || '' : '',
64
+ pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null, tiles: pane ? [...pane.querySelectorAll('.vz-mx-fig, .vz-mx-tile')].map((t) => t.className + ' ' + (t.dataset.form || '')) : [],
65
+ kpis: pane ? pane.querySelectorAll('.vz-kpi').length : 0, ember: pane ? pane.querySelectorAll('.vz-mx-fig .vz-bar.now').length : 0,
66
+ bars: pane ? pane.querySelectorAll('.vz-mx-fig .vz-bar').length : 0, form: pane ? ((pane.querySelector('.vz-sg [aria-pressed="true"]') || {}).textContent || null) : null,
67
+ wide: document.documentElement.scrollWidth > innerWidth + 1, say: (document.querySelector('#hmIn') || {}).value || '' };
62
68
  };
63
69
 
64
70
  (async () => {
@@ -76,8 +82,8 @@ const look = () => {
76
82
  const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
77
83
  await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-ch', goal: null } }));
78
84
  await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'pm', messages } }));
79
- await p.goto(BASE + url);
80
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream')));
85
+ await p.goto(BASE + url); // premium-agreed-design: /premium-chat.html opens Home, whose chat is docked on a desktop and is the page on a phone
86
+ await until(() => p.evaluate(() => !!document.querySelector('#hmLog [data-report-open]')));
81
87
  await sleep(500);
82
88
  return { p, ctx, errs };
83
89
  };
@@ -85,62 +91,55 @@ const look = () => {
85
91
  { const { p, ctx, errs } = await open(1280, [ASK('chart partner activation as bars'), { role: 'assistant', text: 'Partner activation is at 33%.\n\n' + block(CHART) }]);
86
92
  const s0 = await p.evaluate(look);
87
93
  ok('C1 the chart block is a chip under Claude\'s words', /Partners activating/.test(s0.chip || '') && /New chart/.test(s0.chip || ''), JSON.stringify(s0));
88
- await p.click('#dBody [data-report-open]');
94
+ await p.click('#hmLog [data-report-open]');
89
95
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && v.tiles.length ? v : null; }) || await p.evaluate(look);
90
- ok('C1 the Chart tab draws the measure from its five readings as bars, as proposed', s1.tabs.includes('Chart') && /New chart/.test(s1.pane || '') && s1.bars === 5 && s1.form === 'Bars', JSON.stringify(s1));
96
+ ok('C1 the Chart view draws the measure from its five readings as bars, as proposed: three stat tiles, the newest bar in ember', s1.tabs.includes('Chart') && /New chart/.test(s1.pane || '') && s1.bars === 5 && s1.form === 'Bars' && s1.kpis === 3 && s1.ember === 1 && !(await p.$('#czViewer .rt, #czViewer .obody, #czViewer .mt1')), JSON.stringify(s1));
91
97
  if (shots) await p.screenshot({ path: `${shots}/chart-1280.png` });
92
- await p.click('#dOut [data-ct="form|line"]');
98
+ await p.click('#czViewer [data-ct="form|line"]');
93
99
  const s2 = await until(async () => { const v = await p.evaluate(look); return v.form === 'Line' ? v : null; }) || await p.evaluate(look);
94
- ok('C2 a form pick redraws the chart and writes nothing', s2.bars === 0 && /mch/.test(s2.tiles.join()) && PC.list(dir, board).length === 0, JSON.stringify(s2));
95
- await p.click('#dOut [data-ct="save"]');
100
+ ok('C2 a form pick redraws the chart and writes nothing', s2.bars === 0 && /line/.test(s2.tiles.join()) && PC.list(dir, board).length === 0, JSON.stringify(s2));
101
+ await p.click('#czViewer [data-ct="save"]');
96
102
  const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Saved\./.test(v.pane) ? v : null; }) || await p.evaluate(look);
97
103
  const saved = PC.list(dir, board);
98
104
  ok('C2 Save chart saves it with the picked form; the tab shows it saved', saved.length === 1 && saved[0].form === 'line' && saved[0].measure === 'krm-a' && saved[0].title === 'Partners activating' && /Saved chart/.test(s3.pane || ''), JSON.stringify([saved, s3.pane]));
99
- await p.click('#dOut [data-ct="remove"]');
100
- await p.click('#dOut .vcf [data-a="1"]');
105
+ await p.click('#czViewer [data-ct="remove"]');
106
+ await p.click('#czViewer [data-ct="askyes"]');
101
107
  const s4 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Deleted\./.test(v.pane) ? v : null; }) || await p.evaluate(look);
102
108
  ok('C2 Delete chart asks once, then the chart is removed', /Deleted\./.test(s4.pane || '') && PC.list(dir, board).length === 0, JSON.stringify(s4));
103
109
  ok('F1 no page error and no sideways scroll (chart, 1280)', !errs.length && !s4.wide, errs.join(' | '));
104
110
  await ctx.close(); }
105
111
 
106
112
  { const { p, ctx, errs } = await open(1280, [ASK('a dashboard for the partner review'), { role: 'assistant', text: 'Here it is.\n\n' + block(DASH) }]);
107
- await p.click('#dBody [data-report-open]');
113
+ await p.click('#hmLog [data-report-open]');
108
114
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && v.tiles.length ? v : null; }) || await p.evaluate(look);
109
- ok('C3 the Dashboard tab draws two charts in order and names the measure with no series', s1.tabs.includes('Dashboard') && s1.tiles.length === 2 && /Partner growth/.test(s1.pane || '') && /Lonely/.test(s1.pane || '') && /fewer than two readings/.test(s1.pane || ''), JSON.stringify(s1));
115
+ ok('C3 the Dashboard tab draws two charts in order and names the measure with no series', s1.tabs.includes('Dashboard') && s1.tiles.length === 2 && /Partner growth/.test(s1.title) && /Lonely/.test(s1.pane || '') && /fewer than two readings/.test(s1.pane || ''), JSON.stringify(s1));
110
116
  if (shots) await p.screenshot({ path: `${shots}/dashboard-1280.png` });
111
- await p.click('#dOut [data-ct="save"]');
117
+ await p.click('#czViewer [data-ct="save"]');
112
118
  await until(async () => { const v = await p.evaluate(look); return v.pane && /Saved\./.test(v.pane) ? v : null; });
113
119
  const D = PD.list(dir, board);
114
120
  ok('C3 Save dashboard saves it with its charts in order', D.length === 1 && D[0].name === 'Partner growth' && D[0].charts.join() === 'krm-a,krm-t,krm-l', JSON.stringify(D));
115
121
  ok('F1 no page error (dashboard, 1280)', !errs.length, errs.join(' | '));
116
122
  await ctx.close(); }
117
123
 
124
+ /* I1, re-pointed for the rebuilt Insights (premium-agreed-design): Insights has no Studio, and its way into a chat is Ask why, which opens Home's
125
+ * chat about Insights with the question in the box, not sent. Dashboards are edited on Insights itself now (premium-insights.js side panel). */
118
126
  { const ctx = await browser.newContext({ viewport: { width: 1280, height: 860 } }), p = await ctx.newPage(), errs = [];
119
127
  p.on('pageerror', (e) => errs.push(String(e)));
128
+ let asked = 0; await p.route('**/api/briefing-premium/ask**', (r) => { asked++; r.fulfill({ json: { ok: true } }); });
120
129
  await p.goto(BASE + '/premium-insights.html');
121
- await until(() => p.evaluate(() => !!document.querySelector('#dashBody .mch')));
122
- const D = PD.list(dir, board)[0];
123
- await p.evaluate((id) => { const r = document.querySelector(`[data-d="${id}"]`); if (r) r.click(); }, D.id);
124
- await sleep(400);
125
- if (await p.locator('#dashBar').isHidden()) await p.click('#dashMore');
126
- const hasStudio = await p.evaluate(() => !!document.querySelector('#oMain .stu') || [...document.scripts].some((s) => /premium-studio/.test(s.src)));
127
- await Promise.all([p.waitForURL(/premium-chat\.html/), p.click('#pdEdit')]);
130
+ await until(() => p.evaluate(() => /premium\.html\?/.test((document.querySelector('#askWhy') || {}).href || '')));
131
+ const hasStudio = await p.evaluate(() => !!document.querySelector('.stu, #studio') || [...document.scripts].some((s) => /premium-studio/.test(s.src)));
132
+ const href = await p.evaluate(() => document.querySelector('#askWhy').href);
133
+ await Promise.all([p.waitForURL(/\/premium\.html\?/), p.click('#askWhy')]);
128
134
  const u1 = new URL(p.url());
129
- await until(() => p.evaluate(() => [...document.querySelectorAll('#dOut .obody.vw')].some((x) => !x.hidden && /Partner growth/.test(x.textContent))));
130
- const s1 = await p.evaluate(look);
131
- ok('I1 Edit on a saved dashboard opens the Chat page with its Dashboard tab, saved', !hasStudio && u1.searchParams.get('open') === 'dashboard:' + D.id && /Saved dashboard/.test(s1.pane || ''), JSON.stringify([u1.search, s1.pane]));
132
- await p.goto(BASE + '/premium-insights.html');
133
- await until(() => p.evaluate(() => !!document.querySelector('#dashBody .mch')));
134
- await p.evaluate(() => { const r = document.querySelector('[data-d="all"]'); if (r) r.click(); });
135
- if (await p.locator('#dashBar').isHidden()) await p.click('#dashMore');
136
- await Promise.all([p.waitForURL(/premium-chat\.html/), p.click('#pcNew')]);
137
135
  const s2 = await until(async () => { const v = await p.evaluate(look); return v.say ? v : null; }) || await p.evaluate(look);
138
- ok('I1 New chart opens the Chat page with a first message in the box, not sent', s2.say === 'Make a chart of ', JSON.stringify(s2.say));
139
- ok('F1 no page error (Insights to Chat)', !errs.length, errs.join(' | '));
136
+ ok('I1 Insights has no Studio; Ask why opens Home\'s chat about Insights', !hasStudio && u1.pathname === '/premium.html' && u1.searchParams.get('ask') === 'insights' && /ask=insights/.test(href), JSON.stringify([href, u1.search]));
137
+ ok('I1 the question waits in the box, not sent', /^Why/.test(s2.say) && asked === 0, JSON.stringify([s2.say, asked]));
138
+ ok('F1 no page error (Insights to Home)', !errs.length, errs.join(' | '));
140
139
  await ctx.close(); }
141
140
 
142
141
  { const { p, ctx, errs } = await open(390, [ASK('chart partner activation'), { role: 'assistant', text: 'Here.\n\n' + block(CHART) }]);
143
- await p.click('#dBody [data-report-open]');
142
+ await p.click('#hmLog [data-report-open]');
144
143
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && v.tiles.length ? v : null; }) || await p.evaluate(look);
145
144
  ok('C1 at 390 the chip opens the Chart tab over the page', s1.bars === 5, JSON.stringify(s1));
146
145
  if (shots) await p.screenshot({ path: `${shots}/chart-390.png` });
@@ -7,7 +7,9 @@
7
7
  * C2 a new answer opens its main item in the viewer once, when Claude has finished, and not while it still works
8
8
  * C3 a Jira chip opens the ticket from the stored Jira reading, with Open in Jira; a key with no reading says so
9
9
  * C4 a Slack chip opens a tab with Open in Slack
10
- * C5 at 390 a new answer shows a bar over the message box instead of covering the conversation; its press opens the viewer layer
10
+ * C5 at 390 a new answer shows a bar over the message box instead of covering the conversation; its press opens the file on the Detail tab
11
+ * (since premium-agreed-design /premium-chat.html opens Home with the chat ?about names; the Viewer is the cozy card #czViewer, and on a
12
+ * phone the chat is the page and the Viewer covers it in place of the old Detail tab)
11
13
  * C6 every chip is at least 44 px; no sideways scroll; no page error
12
14
  * Set CHAT_CONTEXT_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
13
15
  const { findBrowser } = require('./lib/find-browser');
@@ -58,16 +60,17 @@ const second = (k) => [
58
60
  await p.route('**/api/jira/ticket**', (r) => r.fulfill({ json: { ok: true, ticket: /SGN-42/.test(r.request().url()) ? { key: 'SGN-42', summary: 'Fix the sign-up form', status: 'In Review', category: 'indeterminate', sprint: { name: 'Sprint 14', state: 'active' }, url: 'https://acme.atlassian.net/browse/SGN-42', fetchedAt: '2026-10-21T07:00:00Z' } : null } }));
59
61
  await p.route('**/api/doc/locate**', (r) => { const u = decodeURIComponent(r.request().url()); const rel = (u.match(/path=([^&]+)/) || [])[1] || 'x.md'; r.fulfill({ json: { ok: true, ws: F.ws, rel, name: rel.split('/').pop(), abs: '/x/' + rel, mtime: 1, size: MD.length } }); });
60
62
  await p.route('**/api/doc?**', (r) => r.fulfill({ contentType: 'text/plain', headers: { 'X-Doc-Kind': 'markdown' }, body: MD }));
61
- await p.goto(chat);
62
- await until(() => p.evaluate(() => document.querySelectorAll('#dBody .ctxchip').length > 0), 10000);
63
+ await p.goto(chat + '&about=work:ctx-test'); // premium-agreed-design: Home with this chat; on a phone the chat is the page
64
+ await until(() => p.evaluate(() => document.querySelectorAll('#hmLog .ctxchip').length > 0), 10000);
63
65
  return { p, ctx, errs, conv };
64
66
  };
65
67
  const look = () => {
66
- const g = document.querySelector('#dlg'), peek = document.querySelector('#ctxPeek');
67
- return { shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width),
68
- tabs: [...document.querySelectorAll('#vTabs .vtab')].filter((t) => !t.hidden).map((t) => t.textContent.trim()),
69
- chips: [...document.querySelectorAll('#dBody .ctxc')].map((c) => [...c.querySelectorAll('.ctxchip')].map((b) => b.dataset.ctx + ':' + b.querySelector('b').textContent + (b.classList.contains('lead') ? '*' : ''))),
70
- peek: peek && !peek.hidden ? peek.textContent.trim() : null, minH: Math.min(...[...document.querySelectorAll('#dBody .ctxchip')].map((b) => b.getBoundingClientRect().height)), wide: document.documentElement.scrollWidth > innerWidth + 1 };
68
+ const vw = document.querySelector('#czViewer:not([hidden])'), peek = document.querySelector('#hmPeek');
69
+ const title = vw ? ((vw.querySelector('#czVwTitle') || {}).textContent || '').trim() : '';
70
+ return { tab: vw ? 'out' : 'chat', shut: !vw, layer: false, out: vw ? Math.round(vw.getBoundingClientRect().width) : 0,
71
+ tabs: vw && title ? [title] : [],
72
+ chips: [...document.querySelectorAll('#hmLog .ctxc')].map((c) => [...c.querySelectorAll('.ctxchip')].map((b) => b.dataset.ctx + ':' + b.querySelector('b').textContent + (b.classList.contains('lead') ? '*' : ''))),
73
+ peek: peek && !peek.hidden ? peek.textContent.trim() : null, minH: Math.min(...[...document.querySelectorAll('#hmLog .ctxchip')].map((b) => b.getBoundingClientRect().height)), wide: document.documentElement.scrollWidth > innerWidth + 1 };
71
74
  };
72
75
  const answer = async (p, conv, k, working) => { conv.messages = [...first(), ...second(k)]; conv.turn = working ? 'agent' : 'user'; };
73
76
 
@@ -86,14 +89,14 @@ const second = (k) => [
86
89
  ok('C2 its chips: the file it changed, then the ticket and the Slack channel it worked with; a ticket only read and not named comes after', JSON.stringify(s2.chips[1]) === JSON.stringify(['file:signup-plan1.md*', 'slack:Slack channel', 'jira:SGN-42', 'jira:SGN-7']), JSON.stringify(s2.chips));
87
90
  await sleep(2500);
88
91
  ok('C2 it opens once: later reads open nothing more', JSON.stringify((await p.evaluate(look)).tabs) === JSON.stringify(['signup-plan1.md']));
89
- await p.click('#dBody .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-42"]');
90
- const tk = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw="jira:SGN-42"]'); return e && /Fix the sign-up form/.test(e.textContent) ? { text: e.textContent, href: (e.querySelector('a') || {}).href } : null; }));
92
+ await p.click('#hmLog .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-42"]');
93
+ const tk = await until(() => p.evaluate(() => { const e = document.querySelector('#czViewer .obody.vw[data-vw="jira:SGN-42"]'); return e && /Fix the sign-up form/.test(e.textContent) ? { text: e.textContent, href: (e.querySelector('a') || {}).href } : null; }));
91
94
  ok('C3 a Jira chip opens the ticket from the stored reading: key, summary, status, sprint, and Open in Jira', !!tk && /In Review/.test(tk.text) && /Active sprint: Sprint 14/.test(tk.text) && tk.href === 'https://acme.atlassian.net/browse/SGN-42', JSON.stringify(tk));
92
- await p.click('#dBody .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-7"]');
93
- const none = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw="jira:SGN-7"]'); return e && /no reading/.test(e.textContent) ? e.textContent : null; }));
95
+ await p.click('#hmLog .ctxchip[data-ctx="jira"][data-ctx-ref="SGN-7"]');
96
+ const none = await until(() => p.evaluate(() => { const e = document.querySelector('#czViewer .obody.vw[data-vw="jira:SGN-7"]'); return e && /no reading/.test(e.textContent) ? e.textContent : null; }));
94
97
  ok('C3 a key with no stored reading says so and claims nothing', !!none, String(none));
95
- await p.click('#dBody .ctxchip[data-ctx="slack"]');
96
- const sl = await until(() => p.evaluate(() => { const e = document.querySelector('#dOut .obody.vw[data-vw^="slack:"]'); const a = e && e.querySelector('a'); return a ? a.href : null; }));
98
+ await p.click('#hmLog .ctxchip[data-ctx="slack"]');
99
+ const sl = await until(() => p.evaluate(() => { const e = document.querySelector('#czViewer .obody.vw[data-vw^="slack:"]'); const a = e && e.querySelector('a'); return a ? a.href : null; }));
97
100
  ok('C4 a Slack chip opens a tab with Open in Slack', sl === 'slack://channel?id=C0123ABCD', String(sl));
98
101
  const s3 = await p.evaluate(look);
99
102
  ok('C6 at 1280 every chip is at least 44 px and nothing scrolls sideways', s3.minH >= 44 && !s3.wide, JSON.stringify(s3));
@@ -106,12 +109,12 @@ const second = (k) => [
106
109
  await sleep(2500);
107
110
  await answer(p, conv, 2, false);
108
111
  const s0 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }, 6000) || await p.evaluate(look);
109
- ok(`C5 at 390 (${scheme}) a new answer shows a bar over the message box and leaves the conversation uncovered`, /Claude wrote this · signup-plan2\.md\s*View/.test(s0.peek || '') && !s0.layer, JSON.stringify(s0));
112
+ ok(`C5 at 390 (${scheme}) a new answer shows a bar over the message box and leaves the conversation uncovered`, /Claude wrote this · signup-plan2\.md\s*View/.test(s0.peek || '') && !s0.layer && s0.tab === 'chat', JSON.stringify(s0));
110
113
  if (shots) await p.screenshot({ path: `${shots}/chat-context-390-${scheme}.png` });
111
- await p.click('#ctxPeek');
112
- const s1 = await until(async () => { const v = await p.evaluate(look); return v.layer ? v : null; }) || await p.evaluate(look);
113
- ok(`C5 at 390 (${scheme}) the bar's press opens the file in the viewer layer and the bar goes`, s1.layer && JSON.stringify(s1.tabs) === JSON.stringify(['signup-plan2.md']) && !s1.peek, JSON.stringify(s1));
114
- await p.click('#vBack');
114
+ await p.click('#hmPeek');
115
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.tab === 'out' && v.tabs.length ? v : null; }) || await p.evaluate(look);
116
+ ok(`C5 at 390 (${scheme}) the bar's press opens the file in the Viewer over the chat and the bar goes`, s1.tab === 'out' && s1.out >= 340 && JSON.stringify(s1.tabs) === JSON.stringify(['signup-plan2.md']) && !s1.peek, JSON.stringify(s1));
117
+ await p.click('#czViewer [data-cz-vw="close"]'); // closing the Viewer goes back to the chat
115
118
  const s2 = await p.evaluate(look);
116
119
  ok(`C6 at 390 (${scheme}) every chip is at least 44 px and nothing scrolls sideways`, s2.minH >= 44 && !s2.wide, JSON.stringify(s2));
117
120
  ok(`C6 no page error at 390 (${scheme})`, errs.length === 0, errs.join(' | '));
@@ -6,7 +6,8 @@
6
6
  * G2 a goal that changes state opens the Goal tab by itself on a desktop, and the open tab follows the next change
7
7
  * G3 a ready goal: the conversation shows only the chip; the plan, SMART and Start / Change / Cancel are in the Goal tab
8
8
  * G4 Stop the goal is in the Goal tab and reaches the server
9
- * G5 at 390 the chip covers the page with the Goal tab and Back; a change offers the goal in the bar over the box
9
+ * G5 at 390 the chip shows the Goal tab on the popup's Detail tab; a change offers the goal in the bar over the box
10
+ * (premium-agreed-design: /premium-chat.html opens Home; the Goal tab is the Viewer card, and on a phone the Viewer covers the chat page)
10
11
  * Set GOAL_VIEW_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
11
12
  const { findBrowser } = require('./lib/find-browser');
12
13
  require('./test-run').configure({ name: 'premium-chat-goal-view' });
@@ -34,17 +35,18 @@ const DRAFT = {
34
35
  const READY = 'The goal is clear. Press Start when it reads right.\n\n```pmos-goal\n' + JSON.stringify({ step: 'ready', draft: DRAFT }) + '\n```';
35
36
  const goalOf = (state, extra = {}) => ({ id: 'g1', state, draft: DRAFT, met: [], rounds: 2, ...extra });
36
37
 
37
- /* the page's own state */
38
+ /* the page's own state (premium-agreed-design: Home's chat is #hmLog; the Goal view opens in the Viewer card #czViewer, one item at a time;
39
+ * on a phone the chat is the page and the Viewer covers it, so "the Detail tab" is the Viewer shown and "the chat tab" is the Viewer closed) */
38
40
  const look = () => {
39
- const g = document.querySelector('#dlg'), out = document.querySelector('#dOut').getBoundingClientRect(), gp = document.querySelector('#dOut .obody.vw[data-vw="goal"]');
40
- const peek = document.querySelector('#ctxPeek');
41
- return { shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), out: Math.round(out.width), outH: Math.round(out.height), vh: innerHeight,
42
- cardInChat: !!document.querySelector('#dBody .gcard'), chip: (document.querySelector('#dBody [data-goal-open]') || {}).textContent || null,
43
- smart: !!document.querySelector('#dBody .smart'), start: !!document.querySelector('#dBody [data-goal="start"]'),
44
- tabs: [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.textContent.trim()), on: (document.querySelector('#vTabs .vtab[aria-selected="true"]') || {}).textContent || null,
45
- pane: gp && !gp.hidden ? gp.textContent.replace(/\s+/g, ' ').trim() : null, stop: !!document.querySelector('#dOut [data-goal="stop"]'),
46
- peek: peek && !peek.hidden ? peek.textContent.trim() : null, back: !!document.querySelector('#vBack') && getComputedStyle(document.querySelector('#vBack')).display !== 'none',
47
- railOff: getComputedStyle(document.querySelector('.rail')).opacity === '0', wide: document.documentElement.scrollWidth > innerWidth + 1 };
41
+ const vw = document.querySelector('#czViewer:not([hidden])'), gp = vw ? vw.querySelector('.obody.vw[data-vw="goal"]') : null;
42
+ const peek = document.querySelector('#hmPeek');
43
+ return { tab: vw ? 'out' : 'chat', shut: !gp, layer: false, out: vw ? Math.round(vw.getBoundingClientRect().width) : 0, vh: innerHeight,
44
+ cardInChat: !!document.querySelector('#hmLog .gcard'), chip: (document.querySelector('#hmLog [data-goal-open]') || {}).textContent || null,
45
+ smart: !!document.querySelector('#hmLog .smart'), start: !!document.querySelector('#hmLog [data-goal="start"]'),
46
+ tabs: gp ? ['Goal'] : [], on: vw ? (vw.querySelector('.cz-vw-kind') || {}).textContent || null : null,
47
+ pane: gp ? gp.textContent.replace(/\s+/g, ' ').trim() : null, stop: !!document.querySelector('#czViewer [data-goal="stop"]'),
48
+ peek: peek && !peek.hidden ? peek.textContent.trim() : null,
49
+ railOff: !document.querySelector('nav.rail'), wide: document.documentElement.scrollWidth > innerWidth + 1 };
48
50
  };
49
51
 
50
52
  (async () => {
@@ -63,8 +65,8 @@ const look = () => {
63
65
  await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-goal', goal: st.goal } }));
64
66
  await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'pm', messages: st.messages } }));
65
67
  await p.route('**/api/briefing-premium/goal**', (r) => { st.posts.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ json: { ok: true } }); });
66
- await p.goto(chat);
67
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream #thr')));
68
+ await p.goto(chat + '&about=work:goal-test'); // premium-agreed-design: /premium-chat.html opens Home with the chat named by ?about
69
+ await until(() => p.evaluate(() => !!document.querySelector('#hmLog .hm-a, #hmLog .hm-u')));
68
70
  await sleep(400);
69
71
  return { p, ctx, errs, st };
70
72
  };
@@ -73,18 +75,18 @@ const look = () => {
73
75
  { const { p, ctx, errs, st } = await open(1280, 'light', { goal: goalOf('stopped', { reason: 'pm' }), messages: working });
74
76
  const s0 = await p.evaluate(look);
75
77
  ok('G1 at 1280 a stopped goal draws no card in the conversation, only a small Goal chip', !s0.cardInChat && /Stopped/.test(s0.chip || '') && /0 of 3/.test(s0.chip || ''), JSON.stringify(s0));
76
- ok('G1 opening the chat with a goal opens nothing by itself', s0.shut && s0.tabs.length === 0, JSON.stringify(s0));
78
+ ok('G1 opening the chat with a goal opens nothing by itself', s0.shut, JSON.stringify(s0));
77
79
  if (shots) await p.screenshot({ path: `${shots}/chip-1280-light.png` });
78
- await p.click('#dBody [data-goal-open]');
80
+ await p.click('#hmLog [data-goal-open]');
79
81
  const s1 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.pane ? v : null; }) || await p.evaluate(look);
80
82
  ok('G1 the chip opens a Goal tab with the goal, its done points and why it stopped', /Goal/.test(s1.on || '') && /Stopped/.test(s1.pane || '') && /0 of 3 done points met/.test(s1.pane || '') && /Totals match GA4/.test(s1.pane || '') && /You stopped it/.test(s1.pane || ''), JSON.stringify(s1));
81
- await p.click('#vTabs [data-vx]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('vw-shut')));
83
+ await p.click('#czViewer [data-cz-vw="close"]'); await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')));
82
84
  st.goal = goalOf('started', { met: [DRAFT.done[0]] });
83
85
  const s2 = await until(async () => { const v = await p.evaluate(look); return v.pane && /round 3/.test(v.pane) ? v : null; }) || await p.evaluate(look);
84
86
  ok('G2 a goal that changes state opens the Goal tab by itself', !s2.shut && /Goal/.test(s2.on || '') && /1 of 3 done points met/.test(s2.pane || ''), JSON.stringify(s2));
85
- ok('G4 Stop the goal is in the Goal tab, not in the conversation', s2.stop && !(await p.evaluate(() => !!document.querySelector('#dBody [data-goal="stop"]'))), JSON.stringify(s2));
87
+ ok('G4 Stop the goal is in the Goal tab, not in the conversation', s2.stop && !(await p.evaluate(() => !!document.querySelector('#hmLog [data-goal="stop"]'))), JSON.stringify(s2));
86
88
  if (shots) await p.screenshot({ path: `${shots}/goal-1280-light.png` });
87
- await p.click('#dOut [data-goal="stop"]');
89
+ await p.click('#czViewer [data-goal="stop"]');
88
90
  const posted = await until(() => st.posts.find((x) => x.act === 'stop'));
89
91
  ok('G4 Stop reaches the server for this goal', posted && posted.id === 'g1', JSON.stringify(st.posts));
90
92
  st.goal = goalOf('done', { met: DRAFT.done });
@@ -96,10 +98,10 @@ const look = () => {
96
98
  { const { p, ctx, errs, st } = await open(1280, 'dark', { goal: goalOf('grilling'), messages: [{ role: 'user', text: '[PMOS /goal] The PM set a goal: Enrich the Lightbox reports\n' }, { role: 'assistant', text: READY }] });
97
99
  const s0 = await p.evaluate(look);
98
100
  ok('G3 a ready goal is one chip in the conversation: no card, no SMART row, no buttons', !s0.smart && !s0.start && !s0.cardInChat && /Not started/.test(s0.chip || ''), JSON.stringify(s0));
99
- await p.click('#dBody [data-goal-open]');
101
+ await p.click('#hmLog [data-goal-open]');
100
102
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane ? v : null; }) || await p.evaluate(look);
101
103
  ok('G3 the Goal tab shows the plan: done when, may, serves, by', /Done when/.test(s1.pane || '') && /It may/.test(s1.pane || '') && /Serves/.test(s1.pane || '') && /Not started/.test(s1.pane || ''), JSON.stringify(s1));
102
- await p.click('#dOut [data-goal="start"]');
104
+ await p.click('#czViewer [data-goal="start"]');
103
105
  const sent = await until(() => st.posts.find((x) => x.act === 'start'));
104
106
  ok('G3 Start in the Goal tab sends the ready draft for this goal', sent && sent.id === 'g1' && sent.draft && sent.draft.goal === DRAFT.goal, JSON.stringify(st.posts));
105
107
  if (shots) await p.screenshot({ path: `${shots}/ready-1280-dark.png` });
@@ -109,16 +111,16 @@ const look = () => {
109
111
  for (const scheme of ['light', 'dark']) {
110
112
  const { p, ctx, errs, st } = await open(390, scheme, { goal: goalOf('started', { met: [DRAFT.done[0]] }), messages: working });
111
113
  const s0 = await p.evaluate(look);
112
- ok(`G5 (${scheme}) at 390 the conversation shows the chip, not the card`, !s0.cardInChat && /Working/.test(s0.chip || '') && !s0.layer, JSON.stringify(s0));
114
+ ok(`G5 (${scheme}) at 390 the conversation shows the chip, not the card`, !s0.cardInChat && /Working/.test(s0.chip || '') && !s0.layer && s0.tab === 'chat', JSON.stringify(s0));
113
115
  if (shots) await p.screenshot({ path: `${shots}/chip-390-${scheme}.png` });
114
- await p.click('#dBody [data-goal-open]');
115
- const s1 = await until(async () => { const v = await p.evaluate(look); return v.layer && v.pane && v.outH >= v.vh - 2 && v.railOff ? v : null; }) || await p.evaluate(look);
116
- ok(`G5 (${scheme}) the chip covers the page with the Goal tab and Back`, s1.layer && s1.back && /1 of 3 done points met/.test(s1.pane || '') && s1.outH >= s1.vh - 2, JSON.stringify(s1));
116
+ await p.click('#hmLog [data-goal-open]');
117
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.tab === 'out' && v.pane ? v : null; }) || await p.evaluate(look);
118
+ ok(`G5 (${scheme}) the chip shows the Goal tab on the popup's Detail tab, the popup's full width`, s1.tab === 'out' && s1.out >= 340 && /1 of 3 done points met/.test(s1.pane || ''), JSON.stringify(s1));
117
119
  if (shots) await p.screenshot({ path: `${shots}/goal-390-${scheme}.png` });
118
- await p.click('#vBack'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('vw-layer')));
120
+ await p.click('#czViewer [data-cz-vw="close"]'); await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')));
119
121
  st.goal = goalOf('waiting', { met: [DRAFT.done[0]] });
120
122
  const s2 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }) || await p.evaluate(look);
121
- ok(`G5 (${scheme}) a change offers the goal in the bar over the box, without covering the conversation`, /Needs you/.test(s2.peek || '') && !s2.layer, JSON.stringify(s2));
123
+ ok(`G5 (${scheme}) a change offers the goal in the bar over the box, without covering the conversation`, /Needs you/.test(s2.peek || '') && !s2.layer && s2.tab === 'chat', JSON.stringify(s2));
122
124
  ok(`F1 (${scheme}) no page error and no sideways scroll at 390`, !errs.length && !s2.wide, errs.join(' | '));
123
125
  await ctx.close();
124
126
  }
@@ -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,13 +12,11 @@ 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;
18
18
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
- const until = async (fn, ms = 6000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
19
+ const until = async (fn, ms = 12000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
20
20
  const results = [];
21
21
  const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
22
22
  let srv = null; let browser = null;
@@ -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,30 +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
- ok(`N10 ${scheme}: the icon buttons are 44px targets`, await page.evaluate(() => [...document.querySelectorAll('.ntic')].every((b) => b.getBoundingClientRect().height >= 44)));
134
+ await until(async () => page.evaluate(() => !document.getAnimations().some((a) => a.playState === 'running'))); // the popup's entrance scales it: measure once it has settled
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()); }
140
136
  await page.click('[data-nt="share"]');
141
- 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)));
142
138
  ok(`N10 ${scheme}: no page errors`, errors.length === 0, errors.join(' | '));
143
139
  await ctx.close();
144
140
  }