create-pmos 0.409.0 → 0.411.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 (83) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +1 -1
  7. package/workspace/briefing-premium-initiative-test.js +9 -15
  8. package/workspace/changelog.json +24 -0
  9. package/workspace/chat-asks-test.js +146 -0
  10. package/workspace/guide/briefing-premium.md +1 -1
  11. package/workspace/guide/home.md +25 -0
  12. package/workspace/guide/programs.md +2 -1
  13. package/workspace/home-rows-test.js +149 -56
  14. package/workspace/ini-workflow-test.js +4 -4
  15. package/workspace/lib/briefing-premium-agent.js +8 -1
  16. package/workspace/lib/engine/boards.js +3 -1
  17. package/workspace/lib/goal-chat.js +94 -30
  18. package/workspace/lib/mention-cli.js +70 -0
  19. package/workspace/lib/mention-store.js +307 -0
  20. package/workspace/lib/pmos-verbs.js +3 -0
  21. package/workspace/lib/routes-boards.js +12 -0
  22. package/workspace/lib/routes-briefing-premium.js +2 -2
  23. package/workspace/lib/routes-mentions.js +62 -9
  24. package/workspace/lib/session-files.js +132 -0
  25. package/workspace/lib/session-name.js +103 -0
  26. package/workspace/lib/source-reads.js +4 -1
  27. package/workspace/package-lock.json +2 -2
  28. package/workspace/package.json +1 -1
  29. package/workspace/premium-board-actions-test.js +10 -8
  30. package/workspace/premium-chat-goal-setup-test.js +203 -0
  31. package/workspace/premium-chat-goal-view-test.js +28 -23
  32. package/workspace/premium-chat-line-test.js +189 -0
  33. package/workspace/premium-vw-backlog-test.js +1 -1
  34. package/workspace/premium-vw-item-test.js +1 -1
  35. package/workspace/premium-vw-jira-test.js +1 -1
  36. package/workspace/public/pm/bd-prog-panel.js +3 -1
  37. package/workspace/public/pm/bd-prog.js +4 -2
  38. package/workspace/public/pm/chat-ask.js +17 -9
  39. package/workspace/public/pm/cozy-home-rows.css +39 -1
  40. package/workspace/public/pm/cozy-home.css +112 -12
  41. package/workspace/public/pm/cozy-search.js +2 -1
  42. package/workspace/public/pm/cozy-steps.css +69 -0
  43. package/workspace/public/pm/cozy-steps.js +90 -0
  44. package/workspace/public/pm/goal-chat.js +141 -23
  45. package/workspace/public/pm/home-app.js +71 -35
  46. package/workspace/public/pm/home-ask.js +121 -0
  47. package/workspace/public/pm/home-chat.js +120 -68
  48. package/workspace/public/pm/home-data.js +10 -2
  49. package/workspace/public/pm/home-goal.js +159 -0
  50. package/workspace/public/pm/home-ini.css +35 -0
  51. package/workspace/public/pm/home-ini.js +50 -19
  52. package/workspace/public/pm/home-line.css +59 -0
  53. package/workspace/public/pm/home-line.js +200 -0
  54. package/workspace/public/pm/home-list.js +7 -4
  55. package/workspace/public/pm/home-mentions.js +303 -111
  56. package/workspace/public/pm/home-ses-name.js +65 -0
  57. package/workspace/public/pm/home-stage-card.js +94 -0
  58. package/workspace/public/pm/home-sweep.js +112 -0
  59. package/workspace/public/pm/home-today.js +8 -3
  60. package/workspace/public/pm/premium-initiative-head.js +8 -4
  61. package/workspace/public/pm/program-model.js +4 -1
  62. package/workspace/public/pm/rename-press.js +24 -0
  63. package/workspace/public/pm/wf-page.css +3 -0
  64. package/workspace/public/pm/wf-page.js +2 -1
  65. package/workspace/public/premium-workflows.html +1 -0
  66. package/workspace/server.js +125 -11
  67. package/workspace/session-names-test.js +144 -0
  68. package/workspace/skills/jira-push.skill +1 -0
  69. package/workspace/skills/morning-brief.skill +2 -1
  70. package/workspace/skills/report-daily.skill +1 -0
  71. package/workspace/skills/report-monthly.skill +1 -0
  72. package/workspace/skills/report-weekly.skill +1 -0
  73. package/workspace/skills/sources-read.skill +3 -2
  74. package/workspace/stage-card-test.js +203 -0
  75. package/workspace/test-lists/chat-asks.json +13 -0
  76. package/workspace/test-lists/chat-progress.json +13 -0
  77. package/workspace/test-lists/mentions-a-plus.json +9 -0
  78. package/workspace/test-lists/premium-chat-goal-setup.json +9 -0
  79. package/workspace/test-lists/session-files.json +5 -0
  80. package/workspace/test-lists/session-names.json +13 -0
  81. package/workspace/test-lists/stage-card.json +6 -0
  82. package/workspace/tk-tasks-test.js +1 -1
  83. package/workspace/workflows-setup-test.js +17 -0
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-chat-goal-setup-test.js — the goal before Start in a Home chat (XcbOptions B, row 1; Ready for development 2026-10-25).
4
+ * A real server on a scratch repository (c3-scan-fixture.js); the thread, the conversation and the presses are routed, so each state is set here.
5
+ * M1 a question names its method in one line with Change, draws one dot per point (no S M A R T letters) and tap answers, one recommended
6
+ * M2 Change opens the other methods; a pick sends the method message, which reads as "Ask with …"
7
+ * P1 the ready plan is a card in the chat with Start (go arrow), Change and Cancel as icons; Start sends the plan
8
+ * E1 Change turns the card into an editor in place: type in a point, + adds one, × removes one, the arrow keys move one; ✓ sends the plan
9
+ * E2 a redraw while editing keeps what was typed; × discards the changes
10
+ * K1 a working goal's Goal view has × on a point that has not started, none on the point Claude is on; × sends the skip; Undo sends it back
11
+ * Q1 /goal while a goal works shows the choice instead of sending; Here, instead stops the goal (replace), then sends the new /goal
12
+ * Q2 In a new chat opens a new chat and sends the goal there; the old goal is not touched
13
+ * F1 no page error and no sideways scroll at 1280 and 390, light and dark
14
+ * Set GOAL_SETUP_SHOTS=<dir> to save the page. */
15
+ const { findBrowser } = require('./lib/find-browser');
16
+ require('./test-run').configure({ name: 'premium-chat-goal-setup' });
17
+ const Fx = require('./c3-scan-fixture.js');
18
+
19
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
20
+ const until = async (fn, ms = 8000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
21
+ const results = [];
22
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
23
+ let F = null, browser = null;
24
+ const finish = async (code) => {
25
+ if (browser) await browser.close().catch(() => {});
26
+ if (F) F.stop();
27
+ const bad = results.filter((x) => !x.cond).length;
28
+ console.log(`\n${results.length - bad}/${results.length} premium-chat-goal-setup assertions passed`);
29
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
30
+ };
31
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
32
+
33
+ const fence = (o) => '\n\n```pmos-goal\n' + JSON.stringify(o) + '\n```';
34
+ const PTS = [{ name: 'What it delivers', agreed: true }, { name: 'The done points' }, { name: 'By when' }, { name: 'What it may do' }];
35
+ const QUESTION = 'I read the PRD folder.' + fence({ step: 'question', method: 'done-criteria', why: 'it ends in a document', points: PTS, question: 'What must be true for the draft to be review-ready?', options: [{ label: 'Parity table, open questions with owners, out-of-scope list', recommended: true }, { label: 'Only the parity table' }], draft: { goal: 'Bring the PRD to a review-ready draft' } });
36
+ const DRAFT = { goal: 'Bring the descope-feature-parity PRD to a review-ready draft', done: ['Parity table: every Descope feature against ours', 'Open questions, each with an owner', 'Out-of-scope list, with SSO on it', "Ready for Dita's review"], by: 'Friday', may: 'edit the PRD, ask Dita', limit: 12, assumed: ['may'] };
37
+ const READY = 'The plan reads like this.' + fence({ step: 'ready', method: 'done-criteria', points: PTS.map((p) => ({ ...p, agreed: true })), draft: DRAFT });
38
+ const grill = [{ role: 'user', text: '[PMOS /goal] The PM set a goal: Bring the descope-feature-parity PRD to a review-ready draft\n' }];
39
+
40
+ const look = () => {
41
+ const log = document.querySelector('#hmLog'), q = (s) => log.querySelector(s), ta = document.querySelector('#hmIn');
42
+ const vw = document.querySelector('#czViewer:not([hidden]) .obody.vw[data-vw="goal"]');
43
+ return {
44
+ meth: (q('.gmeth') || {}).textContent || null, methBtn: !!q('button.gmeth[data-goal-meth]'), menuOpen: !!q('.gmenu:not([hidden])'), menu: [...log.querySelectorAll('.gmenu:not([hidden]) [data-goal-method]')].map((b) => b.dataset.goalMethod),
45
+ dots: log.querySelectorAll('.gq .gdots i').length, dotsOn: log.querySelectorAll('.gq .gdots i.y').length, letters: !!q('.smart b'),
46
+ chips: [...log.querySelectorAll('.gchips [data-chat-say]')].map((b) => b.textContent), rec: (q('.gchip.rec') || {}).textContent || null,
47
+ plan: !!q('.gplan:not(.ed)'), planText: (q('.gplan') || {}).textContent || '', acts: [...log.querySelectorAll('.gplan .acts button')].map((b) => [b.getAttribute('aria-label'), b.textContent.trim()]),
48
+ go: !!q('.gplan [data-goal="start"] path[d="M5 12h14M13 6l6 6-6 6"]'),
49
+ ed: !!q('[data-goal-ed]'), fields: [...log.querySelectorAll('[data-goal-ed] [data-goal-fld="done"]')].map((f) => f.value),
50
+ choice: (q('.gchoice') || {}).textContent || null, goalq: document.querySelector('.hm-chat, #hmChat') ? !!document.querySelector('.hm-goalq') : false,
51
+ ph: ta ? ta.placeholder : null, box: ta ? ta.value : null,
52
+ view: vw ? vw.textContent.replace(/\s+/g, ' ').trim() : null, skips: vw ? [...vw.querySelectorAll('[data-goal-skip]')].map((b) => b.dataset.goalSkip) : [], unskip: vw ? [...vw.querySelectorAll('[data-goal-unskip]')].map((b) => b.dataset.goalUnskip) : [],
53
+ wide: document.documentElement.scrollWidth > innerWidth + 1,
54
+ };
55
+ };
56
+
57
+ (async () => {
58
+ const exe = findBrowser();
59
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
60
+ let chromium;
61
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
62
+ F = await Fx.start({ name: 'premium-chat-goal-setup' });
63
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
64
+ const shots = process.env.GOAL_SETUP_SHOTS;
65
+ const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}`;
66
+ const open = async (width, scheme, first) => {
67
+ const st = { goal: first.goal, messages: first.messages, posts: [], asks: [] };
68
+ const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 800 }, colorScheme: scheme, hasTouch: width < 1000 });
69
+ const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
70
+ await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-goal', goal: st.goal } }));
71
+ await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: st.turn || 'pm', messages: st.messages } }));
72
+ await p.route('**/api/briefing-premium/goal**', (r) => { st.posts.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ json: { ok: true } }); });
73
+ await p.route('**/api/briefing-premium/ask**', (r) => { st.asks.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ json: { ok: true, session: 's-goal' } }); });
74
+ await p.goto(chat + '&about=work:goal-setup');
75
+ await until(() => p.evaluate(() => !!document.querySelector('#hmLog .hm-a, #hmLog .hm-u')));
76
+ await sleep(400);
77
+ return { p, ctx, errs, st };
78
+ };
79
+ const poll = async (p, test, ms) => (await until(async () => { const v = await p.evaluate(look); return test(v) ? v : null; }, ms)) || p.evaluate(look);
80
+
81
+ for (const [width, scheme] of [[1280, 'light'], [390, 'dark']]) {
82
+ const tag = `(${width} ${scheme})`;
83
+ // M1, M2: the question and its method
84
+ { const { p, ctx, errs, st } = await open(width, scheme, { goal: { id: 'g1', state: 'grilling' }, messages: grill.concat({ role: 'assistant', text: QUESTION }) });
85
+ const s0 = await p.evaluate(look);
86
+ ok(`M1 ${tag} the question names its method in one line with Change, and why it fits`, s0.methBtn && /Method: Done criteria/.test(s0.meth || '') && /it ends in a document/.test(s0.meth || ''), JSON.stringify(s0));
87
+ ok(`M1 ${tag} one dot per point the method needs, filled as agreed; no S M A R T letters`, s0.dots === 4 && s0.dotsOn === 1 && !s0.letters, JSON.stringify(s0));
88
+ ok(`M1 ${tag} tap answers, the recommended one marked; the box says so`, s0.chips.length === 2 && /recommended/.test(s0.rec || '') && s0.ph === 'Answer, or pick one above', JSON.stringify(s0));
89
+ if (shots) await p.screenshot({ path: `${shots}/question-${width}-${scheme}.png` });
90
+ await p.click('#hmLog [data-goal-meth]');
91
+ const s1 = await poll(p, (v) => v.menuOpen);
92
+ ok(`M2 ${tag} Change opens the other methods`, s1.menuOpen && s1.menu.length === 4 && s1.menu.includes('pre-mortem') && !s1.menu.includes('done-criteria'), JSON.stringify(s1));
93
+ if (shots) await p.screenshot({ path: `${shots}/method-menu-${width}-${scheme}.png` });
94
+ await p.keyboard.press('Escape');
95
+ const s1b = await poll(p, (v) => !v.menuOpen);
96
+ ok(`M2 ${tag} Esc closes the menu`, !s1b.menuOpen, JSON.stringify(s1b));
97
+ await p.click('#hmLog [data-goal-meth]'); await poll(p, (v) => v.menuOpen);
98
+ await p.click('#hmLog [data-goal-method="pre-mortem"]');
99
+ const asked = await until(() => st.asks.find((a) => /^\[PMOS \/goal method\] Use the Pre-mortem method/.test(a.text || '')));
100
+ ok(`M2 ${tag} a pick sends the method message to Claude`, !!asked && /Its points: What ships; How it could fail/.test(asked.text), JSON.stringify(st.asks));
101
+ ok(`F1 ${tag} question: no page error and no sideways scroll`, !errs.length && !(await p.evaluate(look)).wide, errs.join(' | '));
102
+ await ctx.close(); }
103
+
104
+ // P1, E1, E2: the plan card and its editor
105
+ { const { p, ctx, errs, st } = await open(width, scheme, { goal: { id: 'g1', state: 'grilling' }, messages: grill.concat({ role: 'assistant', text: READY }) });
106
+ const s0 = await p.evaluate(look);
107
+ ok(`P1 ${tag} the ready plan is a card in the chat: done when, by, it may (assumed)`, s0.plan && /Done when/.test(s0.planText) && /By Friday/.test(s0.planText) && /It may edit the PRD, ask Dita assumed/.test(s0.planText), JSON.stringify(s0));
108
+ ok(`P1 ${tag} Start (go arrow), Change and Cancel are icons with no words`, JSON.stringify(s0.acts.map((a) => a[0])) === '["Start","Change the plan","Cancel the goal"]' && s0.acts.every((a) => a[1] === '') && s0.go, JSON.stringify(s0.acts));
109
+ if (shots) await p.screenshot({ path: `${shots}/plan-${width}-${scheme}.png` });
110
+ await p.click('#hmLog .gplan [data-goal="change"]');
111
+ const s1 = await poll(p, (v) => v.ed);
112
+ ok(`E1 ${tag} Change turns the card into the editor in place, one field per point`, s1.ed && s1.fields.length === 4 && s1.fields[2] === DRAFT.done[2] && s1.ph === 'Or tell Claude what to change', JSON.stringify(s1));
113
+ const f3 = '#hmLog [data-goal-ed] .edl li:nth-child(3) textarea';
114
+ await p.fill(f3, 'Out-of-scope list, with SSO and Okta on it');
115
+ await p.click('#hmLog [data-goal-ed] [data-goal-add]');
116
+ await p.keyboard.type('Okta gap in the open questions');
117
+ await p.click('#hmLog [data-goal-ed] .edl li:nth-child(1) [data-goal-rm]');
118
+ await p.focus('#hmLog [data-goal-ed] .edl li:nth-child(4) [data-goal-grip]'); // the new point, last: up two with the arrow keys
119
+ await p.keyboard.press('ArrowUp'); await p.keyboard.press('ArrowUp');
120
+ // then drag the last point above the third by its handle
121
+ const gb = await p.locator('#hmLog [data-goal-ed] .edl li:nth-child(4) [data-goal-grip]').boundingBox(), tb = await p.locator('#hmLog [data-goal-ed] .edl li:nth-child(3)').boundingBox();
122
+ await p.mouse.move(gb.x + gb.width / 2, gb.y + gb.height / 2); await p.mouse.down();
123
+ await p.mouse.move(gb.x + gb.width / 2, tb.y + 4, { steps: 6 }); await p.mouse.up();
124
+ await p.fill('#hmLog [data-goal-ed] [data-goal-fld="by"]', 'Thursday');
125
+ const s2 = await p.evaluate(look);
126
+ ok(`E1 ${tag} a typed point, a new point, a removed point, the arrow keys and a drag show in place`, JSON.stringify(s2.fields) === JSON.stringify(['Open questions, each with an owner', 'Okta gap in the open questions', "Ready for Dita's review", 'Out-of-scope list, with SSO and Okta on it']), JSON.stringify(s2.fields));
127
+ // a redraw (a new poll with a changed conversation) must not lose what was typed
128
+ st.messages = st.messages.concat([]); st.turn = 'pm'; await p.evaluate(() => { const l = document.querySelector('#hmLog'); l.__h = null; });
129
+ await sleep(2600);
130
+ const s3 = await p.evaluate(look);
131
+ ok(`E2 ${tag} a redraw while editing keeps what was typed`, s3.ed && JSON.stringify(s3.fields) === JSON.stringify(s2.fields), JSON.stringify(s3.fields));
132
+ if (shots) await p.screenshot({ path: `${shots}/edit-${width}-${scheme}.png` });
133
+ await p.click('#hmLog [data-goal-ed] [data-goal-save]');
134
+ const saved = await until(() => st.posts.find((x) => x.act === 'plan'));
135
+ ok(`E1 ${tag} ✓ sends the edited plan for this goal`, saved && saved.id === 'g1' && JSON.stringify(saved.draft.done) === JSON.stringify(s2.fields) && saved.draft.by === 'Thursday' && saved.draft.goal === DRAFT.goal && !(saved.draft.assumed || []).includes('by'), JSON.stringify(st.posts));
136
+ const s4 = await poll(p, (v) => !v.ed);
137
+ ok(`E1 ${tag} after the save the card is shown again`, !s4.ed && s4.plan, JSON.stringify(s4));
138
+ await p.click('#hmLog .gplan [data-goal="change"]'); await poll(p, (v) => v.ed);
139
+ await p.fill('#hmLog [data-goal-ed] .edl li:nth-child(1) textarea', 'thrown away');
140
+ await p.click('#hmLog [data-goal-ed] [data-goal-discard]');
141
+ const s5 = await poll(p, (v) => !v.ed);
142
+ ok(`E2 ${tag} × discards the changes and sends nothing`, !s5.ed && !/thrown away/.test(s5.planText) && st.posts.filter((x) => x.act === 'plan').length === 1, JSON.stringify(st.posts));
143
+ await p.click('#hmLog .gplan [data-goal="start"]');
144
+ const go = await until(() => st.posts.find((x) => x.act === 'start'));
145
+ ok(`P1 ${tag} Start sends the plan`, go && go.id === 'g1' && go.draft && go.draft.goal === DRAFT.goal, JSON.stringify(st.posts));
146
+ ok(`F1 ${tag} plan: no page error and no sideways scroll`, !errs.length && !(await p.evaluate(look)).wide, errs.join(' | '));
147
+ await ctx.close(); }
148
+
149
+ // K1, Q1, Q2: a working goal
150
+ const started = (extra = {}) => ({ id: 'g2', state: 'started', draft: DRAFT, met: [DRAFT.done[0]], rounds: 1, roundAt: '2026-10-25T01:00:00Z', ...extra });
151
+ const working = grill.concat([{ role: 'assistant', text: READY }, { role: 'user', text: '[PMOS /goal start] go' }, { role: 'assistant', text: 'On it.' }]);
152
+ { const { p, ctx, errs, st } = await open(width, scheme, { goal: started(), messages: working });
153
+ await p.evaluate(() => import('/pm/premium-viewer.js').then(() => document.querySelector('#hmLog [data-goal-open]') && document.querySelector('#hmLog [data-goal-open]').click()));
154
+ let s0 = await poll(p, (v) => v.view, 3000);
155
+ if (!s0.view) { await p.evaluate(() => { const b = document.querySelector('.hm-pl [data-pl="toggle"], #hmLog [data-goal-open]'); if (b) b.click(); }); s0 = await poll(p, (v) => v.view, 3000); }
156
+ ok(`K1 ${tag} the Goal view has × on a point that has not started, none on the point Claude is on`, s0.skips.includes(DRAFT.done[2]) && s0.skips.includes(DRAFT.done[3]) && !s0.skips.includes(DRAFT.done[1]) && !s0.skips.includes(DRAFT.done[0]), JSON.stringify(s0));
157
+ await p.click(`#czViewer [data-goal-skip="${DRAFT.done[2]}"]`);
158
+ const sk = await until(() => st.posts.find((x) => x.act === 'skip'));
159
+ ok(`K1 ${tag} × sends the skip for that point`, sk && sk.point === DRAFT.done[2] && sk.id === 'g2', JSON.stringify(st.posts));
160
+ st.goal = started({ skipped: [DRAFT.done[2]], skipAt: { [DRAFT.done[2]]: '2026-10-25T02:00:00Z' } });
161
+ const s1 = await poll(p, (v) => v.unskip.length);
162
+ ok(`K1 ${tag} the skipped point is struck through with Undo, and the count leaves it out`, s1.unskip[0] === DRAFT.done[2] && /Skipped by you · Claude drops it after this step/.test(s1.view || '') && /1 of 3 (done )?points met/.test(s1.view || ''), JSON.stringify(s1));
163
+ await p.click(`#czViewer [data-goal-unskip="${DRAFT.done[2]}"]`);
164
+ const un = await until(() => st.posts.find((x) => x.act === 'unskip'));
165
+ ok(`K1 ${tag} Undo sends the point back`, un && un.point === DRAFT.done[2], JSON.stringify(st.posts));
166
+ if (shots) await p.screenshot({ path: `${shots}/skip-${width}-${scheme}.png` });
167
+ // during a run, the Viewer's pencil opens the same editor; ✓ sends the plan, which applies after the current step
168
+ await p.click('#czViewer [data-goal="change"]');
169
+ const e0 = await until(() => p.evaluate(() => document.querySelectorAll('#czViewer [data-goal-ed] [data-goal-fld="done"]').length));
170
+ ok(`K2 ${tag} the Viewer's pencil opens the plan editor for a working goal`, e0 === 4, String(e0));
171
+ await p.fill('#czViewer [data-goal-ed] .edl li:nth-child(4) textarea', "Ready for Dita's review by Thursday");
172
+ await p.click('#czViewer [data-goal-ed] [data-goal-save]');
173
+ const pe = await until(() => st.posts.find((x) => x.act === 'plan'));
174
+ ok(`K2 ${tag} ✓ sends the changed plan for the working goal`, pe && pe.id === 'g2' && pe.draft.done[3] === "Ready for Dita's review by Thursday", JSON.stringify(st.posts));
175
+ await p.evaluate(() => { const c = document.querySelector('#czViewer [data-cz-vw="close"], #czViewer [data-cz-vw="back"]'); if (c) c.click(); });
176
+ await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')), 3000);
177
+ st.goal = started();
178
+ const n0 = st.asks.length;
179
+ await p.fill('#hmIn', '/goal Draft the Q1 OKR review for the leads');
180
+ await p.keyboard.press('Enter');
181
+ const s2 = await poll(p, (v) => v.choice);
182
+ ok(`Q1 ${tag} /goal while a goal works shows the choice, and sends nothing yet`, /One goal runs in a chat at a time/.test(s2.choice || '') && /In a new chat/.test(s2.choice || '') && /recommended · this goal keeps going/.test(s2.choice || '') && /stops “Bring the descope-feature-parity PRD/.test(s2.choice || '') && st.asks.length === n0 && s2.goalq && s2.box === '', JSON.stringify(s2));
183
+ if (shots) await p.screenshot({ path: `${shots}/choice-${width}-${scheme}.png` });
184
+ await p.click('#hmLog [data-goal-where="here"]');
185
+ const rp = await until(() => st.posts.find((x) => x.act === 'replace'));
186
+ const sent = await until(() => st.asks.find((a) => a.text === '/goal Draft the Q1 OKR review for the leads'));
187
+ ok(`Q1 ${tag} Here, instead stops this goal (replace), then sends the new /goal here`, rp && rp.id === 'g2' && sent && sent.key === 'work:goal-setup' && !(await p.evaluate(look)).choice, JSON.stringify({ posts: st.posts, asks: st.asks }));
188
+ await p.fill('#hmIn', '/goal Another one'); await p.keyboard.press('Enter');
189
+ await poll(p, (v) => v.choice);
190
+ await p.keyboard.press('Escape');
191
+ const s3 = await poll(p, (v) => !v.choice);
192
+ ok(`Q1 ${tag} Esc closes the choice`, !s3.choice && !s3.goalq, JSON.stringify(s3));
193
+ await p.fill('#hmIn', '/goal Draft the Q1 OKR review'); await p.keyboard.press('Enter');
194
+ await poll(p, (v) => v.choice);
195
+ const reps = st.posts.filter((x) => x.act === 'replace').length;
196
+ await p.click('#hmLog [data-goal-where="new"]');
197
+ const nw = await until(() => st.asks.find((a) => a.text === '/goal Draft the Q1 OKR review'));
198
+ ok(`Q2 ${tag} In a new chat sends the goal to a new chat and leaves this goal running`, nw && nw.key !== 'work:goal-setup' && /^chat:loose-/.test(nw.key) && st.posts.filter((x) => x.act === 'replace').length === reps, JSON.stringify(st.asks));
199
+ ok(`F1 ${tag} working goal: no page error and no sideways scroll`, !errs.length && !(await p.evaluate(look)).wide, errs.join(' | '));
200
+ await ctx.close(); }
201
+ }
202
+ return finish();
203
+ })();
@@ -2,11 +2,12 @@
2
2
  'use strict';
3
3
  /* premium-chat-goal-view-test.js — the /goal card lives in the viewer, not in the conversation (initiative premium-chat-session, goal in the viewer).
4
4
  * A real server on a scratch repository (c3-scan-fixture.js); the thread and the session's conversation are routed, so the goal's state is set here.
5
- * G1 at 1280 a stopped goal draws no card in the conversation, only a small Goal chip; the chip opens a Goal tab with the card
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
- * G3 a ready goal: the conversation shows only the chip; the plan, SMART and Start / Change / Cancel are in the Goal tab
8
- * G4 Stop the goal is in the Goal tab and reaches the server
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
5
+ * G1 at 1280 a stopped goal draws no card in the conversation, only the amber divider where it stopped; the divider opens a Goal tab with the card
6
+ * G2 a goal at work is the progress line at the top (XcbOptions B): it opens nothing by itself; a tap opens its steps in the Goal tab,
7
+ * and the open tab follows the next change
8
+ * G3 a ready goal: the plan card is in the conversation with Start / Change / Cancel as icons (XcbOptions B); the whole plan still opens in the Goal tab
9
+ * G4 Stop the goal is in the Goal tab and on the line, and reaches the server
10
+ * G5 at 390 the line opens in place, not in the Viewer; a goal that waits on the PM turns the line blue, with no bar over the box
10
11
  * (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)
11
12
  * Set GOAL_VIEW_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
12
13
  const { findBrowser } = require('./lib/find-browser');
@@ -41,11 +42,13 @@ const look = () => {
41
42
  const vw = document.querySelector('#czViewer:not([hidden])'), gp = vw ? vw.querySelector('.obody.vw[data-vw="goal"]') : null;
42
43
  const peek = document.querySelector('#hmPeek');
43
44
  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"]'),
45
+ cardInChat: !!document.querySelector('#hmLog .gcard'), chip: (document.querySelector('#hmLog .ctxchip[data-goal-open]') || {}).textContent || null,
46
+ smart: !!document.querySelector('#hmLog .smart'), start: !!document.querySelector('#hmLog [data-goal="start"]'), planInChat: !!document.querySelector('#hmLog .gplan'),
46
47
  tabs: gp ? ['Goal'] : [], on: vw ? (vw.querySelector('.cz-vw-kind') || vw.querySelector('.cz-vw-title') || {}).textContent || null : null, // a kind that repeats the title is not drawn
47
48
  pane: gp ? gp.textContent.replace(/\s+/g, ' ').trim() : null, stop: !!document.querySelector('#czViewer [data-goal="stop"]'),
48
49
  peek: peek && !peek.hidden ? peek.textContent.trim() : null,
50
+ line: (document.querySelector('#hmPl:not([hidden]) .hm-pl') || {}).textContent || null, lineCls: (document.querySelector('#hmPl .hm-pl') || {}).className || '',
51
+ divider: (document.querySelector('#hmLog .pl-dv') || {}).textContent || null,
49
52
  railOff: !document.querySelector('nav.rail'), wide: document.documentElement.scrollWidth > innerWidth + 1 };
50
53
  };
51
54
 
@@ -74,33 +77,36 @@ const look = () => {
74
77
 
75
78
  { const { p, ctx, errs, st } = await open(1280, 'light', { goal: goalOf('stopped', { reason: 'pm' }), messages: working });
76
79
  const s0 = await p.evaluate(look);
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));
80
+ ok('G1 at 1280 a stopped goal draws no card and no line, only the amber divider that says why', !s0.cardInChat && !s0.chip && !s0.line && /Goal stopped: you stopped it/.test(s0.divider || ''), JSON.stringify(s0));
78
81
  ok('G1 opening the chat with a goal opens nothing by itself', s0.shut, JSON.stringify(s0));
79
82
  if (shots) await p.screenshot({ path: `${shots}/chip-1280-light.png` });
80
- await p.click('#hmLog [data-goal-open]');
83
+ await p.click('#hmLog .pl-dv [data-goal-open]');
81
84
  const s1 = await until(async () => { const v = await p.evaluate(look); return !v.shut && v.pane ? v : null; }) || await p.evaluate(look);
82
85
  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));
83
86
  await p.click('#czViewer [data-cz-vw="close"]'); await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')));
84
87
  st.goal = goalOf('started', { met: [DRAFT.done[0]] });
88
+ const s1b = await until(async () => { const v = await p.evaluate(look); return v.line ? v : null; }) || await p.evaluate(look);
89
+ ok('G2 a goal at work is the line at the top, and opens nothing by itself', /Each drop has a reason label/.test(s1b.line || '') && /1 of 3 done/.test(s1b.line || '') && s1b.shut && !s1b.chip, JSON.stringify(s1b));
90
+ await p.click('#hmPl [data-pl="toggle"]');
85
91
  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);
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));
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));
92
+ ok('G2 a tap on the line opens the goal\'s steps in the Goal tab, and the line is tinted while it shows', !s2.shut && /Goal/.test(s2.on || '') && /1 of 3 points met · round 3 of 12/.test(s2.pane || '') && /\bon\b/.test(s2.lineCls), JSON.stringify(s2));
93
+ ok('G4 Stop is in the Goal tab and on the line, not in the conversation', await p.evaluate(() => !!document.querySelector('#czViewer [data-pl="stop"]') && !!document.querySelector('#hmPl [data-pl="stop"]') && !document.querySelector('#hmLog [data-goal="stop"]')), JSON.stringify(s2));
88
94
  if (shots) await p.screenshot({ path: `${shots}/goal-1280-light.png` });
89
- await p.click('#czViewer [data-goal="stop"]');
95
+ await p.click('#czViewer [data-pl="stop"]');
90
96
  const posted = await until(() => st.posts.find((x) => x.act === 'stop'));
91
97
  ok('G4 Stop reaches the server for this goal', posted && posted.id === 'g1', JSON.stringify(st.posts));
92
98
  st.goal = goalOf('done', { met: DRAFT.done });
93
99
  const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Done, as Claude reports it/.test(v.pane) ? v : null; }) || await p.evaluate(look);
94
- ok('G2 the open Goal tab follows the next change', /3 of 3 done points met/.test(s3.pane || '') && !s3.stop, JSON.stringify(s3));
100
+ ok('G2 the open Goal tab follows the next change; the line goes and "Goal done" stays where it finished', /3 of 3 done points met/.test(s3.pane || '') && !s3.stop && !s3.line && /Goal done/.test(s3.divider || ''), JSON.stringify(s3));
95
101
  ok('F1 no page error and no sideways scroll', !errs.length && !s3.wide, errs.join(' | '));
96
102
  await ctx.close(); }
97
103
 
98
104
  { 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 }] });
99
105
  const s0 = await p.evaluate(look);
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));
101
- await p.click('#hmLog [data-goal-open]');
106
+ ok('G3 a ready goal is the plan card in the conversation, with Start, Change and Cancel as icons (XcbOptions B)', !s0.smart && s0.start && s0.planInChat && !s0.cardInChat, JSON.stringify(s0));
107
+ await p.click('#hmLog .gplan [data-goal-open]');
102
108
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane ? v : null; }) || await p.evaluate(look);
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));
109
+ ok('G3 the whole plan still opens in the Viewer: 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));
104
110
  await p.click('#czViewer [data-goal="start"]');
105
111
  const sent = await until(() => st.posts.find((x) => x.act === 'start'));
106
112
  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));
@@ -111,16 +117,15 @@ const look = () => {
111
117
  for (const scheme of ['light', 'dark']) {
112
118
  const { p, ctx, errs, st } = await open(390, scheme, { goal: goalOf('started', { met: [DRAFT.done[0]] }), messages: working });
113
119
  const s0 = await p.evaluate(look);
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));
120
+ ok(`G5 (${scheme}) at 390 the conversation shows the line, not the card or a chip`, !s0.cardInChat && !s0.chip && /1 of 3 done/.test(s0.line || '') && !s0.layer && s0.tab === 'chat', JSON.stringify(s0));
115
121
  if (shots) await p.screenshot({ path: `${shots}/chip-390-${scheme}.png` });
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));
122
+ await p.click('#hmPl [data-pl="toggle"]');
123
+ const s1 = await until(async () => { const v = await p.evaluate(look); return /points met/.test(v.line || '') ? v : null; }) || await p.evaluate(look);
124
+ ok(`G5 (${scheme}) a tap opens the line in place with the goal's points, not the Viewer`, s1.tab === 'chat' && /1 of 3 points met/.test(s1.line || '') && /Totals match GA4/.test(s1.line || ''), JSON.stringify(s1));
119
125
  if (shots) await p.screenshot({ path: `${shots}/goal-390-${scheme}.png` });
120
- await p.click('#czViewer [data-cz-vw="back"]'); await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])'))); // the popup is phone-wide here: shell A shows ← there, no ×
121
126
  st.goal = goalOf('waiting', { met: [DRAFT.done[0]] });
122
- const s2 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }) || await p.evaluate(look);
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));
127
+ const s2 = await until(async () => { const v = await p.evaluate(look); return /asks before it goes on/.test(v.line || '') ? v : null; }) || await p.evaluate(look);
128
+ ok(`G5 (${scheme}) a goal that waits turns the line blue, with no bar over the box`, /\byou\b/.test(s2.lineCls) && !s2.peek && !s2.layer && s2.tab === 'chat', JSON.stringify(s2));
124
129
  ok(`F1 (${scheme}) no page error and no sideways scroll at 390`, !errs.length && !s2.wide, errs.join(' | '));
125
130
  await ctx.close();
126
131
  }
@@ -0,0 +1,189 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-chat-line-test.js — the chat progress line in the real page (initiative premium-agreed-design; canvas XcbOptions B, cases 1–9).
4
+ * A real server on a scratch repository (c3-scan-fixture.js); the thread, the conversation, the sessions, the queue and the notes are routed.
5
+ * P1 (390) a goal at work: one line at the top with the point it is on, "1 of 4 done" and Stop; no run strip, no live card, no goal chip,
6
+ * no @ and no / button, no floating menu; a message sent while it works waits as "Claude reads it after this tool call, in seconds" with ×
7
+ * P2 (390) a tap opens the line in place: the head line, every point, the Now row and Watch its terminal; Stop reaches the server;
8
+ * the line stays at the top while the page scrolls
9
+ * P3 (390) a session with no step list: "Working · m:ss", no count; a session with its own steps: its step and "1 of 3 done"
10
+ * P4 (390) Claude asks: the line is blue, "Claude asks before it goes on"; a tap scrolls to the ask, not to the Viewer
11
+ * P5/P6 a finished goal: no line; "Goal done" over Claude's result, or the amber "Goal stopped: …" and the box says how to go on
12
+ * P7 (390) a meeting records: the pill is in the chat's top bar, which shows ← and the title only
13
+ * P8 (390) Home: a running row's ring fills as its steps are met, no number; a running row with no steps has the plain ring
14
+ * P9 (1280) the line sits over the chat column; a tap opens the steps in the Viewer and the line is tinted while it shows them
15
+ * Set CHAT_LINE_SHOTS=<dir> to save the pages. */
16
+ const { findBrowser } = require('./lib/find-browser');
17
+ require('./test-run').configure({ name: 'premium-chat-line' });
18
+ const Fx = require('./c3-scan-fixture.js');
19
+
20
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
21
+ const until = async (fn, ms = 8000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
22
+ const results = [];
23
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 700) : ''}`); };
24
+ let F = null, browser = null;
25
+ const finish = async (code) => {
26
+ if (browser) await browser.close().catch(() => {});
27
+ if (F) F.stop();
28
+ const bad = results.filter((x) => !x.cond).length;
29
+ console.log(`\n${results.length - bad}/${results.length} premium-chat-line assertions passed`);
30
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
31
+ };
32
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
33
+
34
+ const DRAFT = { goal: 'Bring the descope-feature-parity PRD to a review-ready draft', done: ['Parity table: every Descope feature against ours', 'Open questions, each with an owner', 'Out-of-scope list, with SSO on it', "Ready for Dita's review"], by: 'Fri', limit: 12 };
35
+ const ago = (m) => new Date(Date.now() - m * 60000).toISOString();
36
+ const BASE = [{ role: 'user', text: '[PMOS /goal start] Start', at: ago(4) }, { role: 'assistant', text: 'SSO goes on the out-of-scope list; the date stays.', at: ago(3) }, { role: 'tool', tools: { Edit: 1 }, calls: [{ tool: 'Edit', target: 'planning/prd/descope-parity.md' }], at: ago(2) }];
37
+ const LONG = Array.from({ length: 14 }, (_, i) => ({ role: i % 2 ? 'assistant' : 'user', text: 'Message ' + i + ' with enough words to take a line or two of room in the chat.', at: ago(30 - i) }));
38
+ const goal = (state, extra = {}) => ({ id: 'g1', state, draft: DRAFT, met: [DRAFT.done[0]], rounds: 1, at: ago(1), ...extra });
39
+
40
+ const look = () => {
41
+ const line = document.querySelector('#hmPl:not([hidden]) .hm-pl'), vw = document.querySelector('#czViewer:not([hidden])');
42
+ const fab = document.querySelector('.cz-fabw'), rec = document.querySelector('#hmRecTop:not([hidden])'), sub = document.querySelector('#hmTopSub');
43
+ const r = line ? line.getBoundingClientRect() : null;
44
+ return {
45
+ line: line ? line.textContent.replace(/\s+/g, ' ').trim() : null, cls: line ? line.className : '', top: r ? Math.round(r.top) : null,
46
+ open: !!(line && line.querySelector('.pl-body')), stop: !!(line && line.querySelector('[data-pl="stop"]')), term: !!(line && line.querySelector('[data-pl="term"]')),
47
+ strip: !!document.querySelector('.hm-run'), live: !!document.querySelector('.hm-live'), chip: !!document.querySelector('#hmLog .ctxchip[data-goal-open]'),
48
+ at: !!document.querySelector('[data-hm-at]'), slash: !!document.querySelector('[data-hm-slash]'), peek: !!document.querySelector('#hmPeek:not([hidden])'),
49
+ fab: !!(fab && fab.offsetParent !== null && getComputedStyle(fab).display !== 'none'),
50
+ queued: (document.querySelector('.hm-qn') || {}).textContent || null, qx: !!document.querySelector('.hm-qn [data-hm-qdel]'),
51
+ divider: [...document.querySelectorAll('#hmLog .pl-dv')].map((d) => d.textContent.trim()).join(' | ') || null,
52
+ dividerNext: (() => { const d = document.querySelector('#hmLog .pl-dv'); const n = d && d.nextElementSibling; return n ? n.textContent.replace(/\s+/g, ' ').trim().slice(0, 80) : null; })(),
53
+ ph: (document.querySelector('#hmIn') || {}).placeholder || null,
54
+ vw: vw ? vw.textContent.replace(/\s+/g, ' ').trim() : null,
55
+ rec: rec ? rec.textContent.trim() : null, sub: sub ? getComputedStyle(sub).display : null,
56
+ wide: document.documentElement.scrollWidth > innerWidth + 1,
57
+ };
58
+ };
59
+
60
+ (async () => {
61
+ const exe = findBrowser();
62
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
63
+ let chromium;
64
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
65
+ F = await Fx.start({ name: 'premium-chat-line' });
66
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
67
+ const shots = process.env.CHAT_LINE_SHOTS;
68
+ const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}&about=work:line-test`;
69
+ const open = async (width, st, url = chat) => {
70
+ st.posts = [];
71
+ const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 800 }, hasTouch: width < 1000 });
72
+ const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
73
+ await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-line', goal: st.goal || null } }));
74
+ await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', ...st.conv } }));
75
+ await p.route('**/api/briefing-premium/goal**', (r) => { st.posts.push({ goal: JSON.parse(r.request().postData() || '{}') }); r.fulfill({ json: { ok: true } }); });
76
+ await p.route('**/api/session/keys', (r) => { st.posts.push({ keys: JSON.parse(r.request().postData() || '{}') }); r.fulfill({ json: { ok: true } }); });
77
+ await p.route('**/api/briefing-premium/press**', (r) => { st.posts.push({ keys: JSON.parse(r.request().postData() || '{}') }); r.fulfill({ json: { ok: true } }); });
78
+ if (st.queued) await p.route(/\/api\/home-desk(\?|$)/, async (r) => { const res = await r.fetch(); const j = await res.json().catch(() => ({})); j.ok = true; j.queued = { 's-line': st.queued }; r.fulfill({ json: j }); });
79
+ if (st.sessions) await p.route(/\/api\/sessions(\?|$)/, async (r) => { const res = await r.fetch(); const j = await res.json().catch(() => ({})); j.sessions = (j.sessions || []).concat(st.sessions); r.fulfill({ json: j }); });
80
+ if (st.notes) await p.route('**/api/notes', (r) => r.fulfill({ json: { ok: true, notes: st.notes } }));
81
+ await p.goto(url);
82
+ await until(() => p.evaluate(() => !!document.querySelector('#hmLog .hm-a, #hmLog .hm-u, #hmList .hm-r')));
83
+ await sleep(600);
84
+ return { p, ctx, errs };
85
+ };
86
+
87
+ /* P1, P2, P7: a goal at work on a phone, with a queued message and a recording */
88
+ { const st = { goal: goal('started'), conv: { turn: 'tool', messages: LONG.concat(BASE) }, queued: [{ text: 'Also add the Okta gap to the open questions.', at: ago(0.2) }],
89
+ notes: [{ id: 'n1', state: 'recording', title: 'CIAM weekly sync', meeting_ms: 724000 }] };
90
+ const { p, ctx, errs } = await open(390, st);
91
+ const s0 = await until(async () => { const v = await p.evaluate(look); return v.line && v.queued ? v : null; }) || await p.evaluate(look);
92
+ ok('P1 a goal at work: one line with the point it is on, "1 of 4 done" and Stop', /Open questions, each with an owner/.test(s0.line || '') && /1 of 4 done/.test(s0.line || '') && s0.stop && !s0.open, JSON.stringify(s0));
93
+ ok('P1 the line replaces the run strip, the live card, the goal chip and the goal bar', !s0.strip && !s0.live && !s0.chip && !s0.peek, JSON.stringify(s0));
94
+ ok('P1 the box has no @ and no / button, and a phone chat has no floating menu', !s0.at && !s0.slash && !s0.fab, JSON.stringify(s0));
95
+ ok('P1 a message sent while it works says Claude reads it after this tool call, with × to take it back', /reads it after this tool call, in seconds/.test(s0.queued || '') && s0.qx, JSON.stringify(s0));
96
+ const s7 = await until(async () => { const v = await p.evaluate(look); return v.rec ? v : null; }) || await p.evaluate(look);
97
+ ok('P7 a meeting records: the pill with its clock is in the chat\'s top bar, which shows the title only', /^\d+:\d\d/.test(s7.rec || '') && s7.sub === 'none', JSON.stringify(s7));
98
+ if (shots) await p.screenshot({ path: `${shots}/line-390.png` });
99
+ await p.click('#hmPl [data-pl="toggle"]');
100
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.open ? v : null; }) || await p.evaluate(look);
101
+ ok('P2 a tap opens it in place: the goal, "1 of 4 points met · round 2 of 12", every point, Now and the terminal',
102
+ /Bring the descope-feature-parity PRD/.test(s1.line || '') && /1 of 4 points met · round 2 of 12/.test(s1.line || '') && /Ready for Dita's review/.test(s1.line || '') && /Now\s*Edit · planning\/prd\/descope-parity.md/.test(s1.line || '') && s1.term && !s1.vw, JSON.stringify(s1));
103
+ if (shots) await p.screenshot({ path: `${shots}/line-390-open.png` });
104
+ await p.click('#hmPl [data-pl="toggle"]');
105
+ await p.evaluate(() => { const se = document.scrollingElement; se.scrollTop = 0; });
106
+ await sleep(200);
107
+ const s2 = await p.evaluate(look);
108
+ ok('P2 the line stays at the top while the page scrolls', s2.top != null && s2.top >= 40 && s2.top < 140, JSON.stringify(s2));
109
+ await p.click('#hmPl [data-pl="stop"]');
110
+ const posted = await until(() => st.posts.find((x) => x.goal && x.goal.act === 'stop'));
111
+ ok('P2 Stop on the line stops the goal', posted && posted.goal.id === 'g1', JSON.stringify(st.posts));
112
+ ok('F1 (390) no page error and no sideways scroll', !errs.length && !s2.wide, errs.join(' | '));
113
+ await ctx.close(); }
114
+
115
+ /* P3: sessions with and without a step list */
116
+ { const st = { conv: { turn: 'agent', messages: BASE } };
117
+ const { p, ctx, errs } = await open(390, st);
118
+ const s0 = await until(async () => { const v = await p.evaluate(look); return v.line ? v : null; }) || await p.evaluate(look);
119
+ ok('P3 a session with no step list: "Working · m:ss", never an invented count', /Working · \d+:\d\d/.test(s0.line || '') && !/ of \d+ done/.test(s0.line || ''), JSON.stringify(s0));
120
+ st.conv = { turn: 'agent', messages: BASE, steps: [{ text: 'Read the funnel export', state: 'done' }, { text: 'Find the step that moved', state: 'now', call: 'Read · funnel.csv' }, { text: 'Write it up', state: 'next' }] };
121
+ const s1 = await until(async () => { const v = await p.evaluate(look); return /Find the step/.test(v.line || '') ? v : null; }) || await p.evaluate(look);
122
+ ok('P3 a session with its own steps: its step and "1 of 3 done"', /Find the step that moved/.test(s1.line || '') && /1 of 3 done/.test(s1.line || ''), JSON.stringify(s1));
123
+ await p.click('#hmPl [data-pl="stop"]');
124
+ const esc = await until(() => st.posts.find((x) => x.keys && x.keys.press === 'esc'));
125
+ ok('P3 Stop on a session line presses Esc in it', !!esc, JSON.stringify(st.posts));
126
+ st.conv = { turn: 'pm', messages: BASE.concat([{ role: 'assistant', text: 'The checkout step moved.', at: ago(0) }]) };
127
+ const s2 = await until(async () => { const v = await p.evaluate(look); return !v.line ? v : null; }) || await p.evaluate(look);
128
+ ok('P3 when the run ends the line goes away (zero is silence)', !s2.line, JSON.stringify(s2));
129
+ ok('F1 (sessions) no page error', !errs.length, errs.join(' | '));
130
+ await ctx.close(); }
131
+
132
+ /* P4: Claude asks */
133
+ { const st = { goal: goal('waiting'), conv: { turn: 'pm', messages: LONG.concat(BASE, [{ role: 'assistant', text: 'Is the draft ready for Dita?', at: ago(0.5) }]) } };
134
+ const { p, ctx, errs } = await open(390, st);
135
+ const s0 = await until(async () => { const v = await p.evaluate(look); return v.line ? v : null; }) || await p.evaluate(look);
136
+ ok('P4 Claude needs the PM: the line is blue and says "Claude asks before it goes on", Stop stays', /\byou\b/.test(s0.cls) && /Claude asks before it goes on/.test(s0.line || '') && s0.stop && !/ of \d+ done/.test(s0.line || ''), JSON.stringify(s0));
137
+ if (shots) await p.screenshot({ path: `${shots}/line-390-ask.png` });
138
+ await p.click('#hmPl [data-pl="toggle"]'); await sleep(500);
139
+ const s1 = await p.evaluate(look);
140
+ ok('P4 a tap goes to the ask in the conversation, not to a panel', !s1.open && !s1.vw, JSON.stringify(s1));
141
+ ok('F1 (ask) no page error', !errs.length, errs.join(' | '));
142
+ await ctx.close(); }
143
+
144
+ /* P5, P6: a goal that finished */
145
+ { const st = { goal: goal('done', { met: DRAFT.done, at: ago(0.2) }), conv: { turn: 'pm', messages: BASE.concat([{ role: 'assistant', text: 'The draft is ready for Dita; 2 open questions have owners.', at: ago(0.5) }]) } };
146
+ const { p, ctx, errs } = await open(1280, st);
147
+ const s0 = await until(async () => { const v = await p.evaluate(look); return v.divider ? v : null; }) || await p.evaluate(look);
148
+ ok('P5 a goal that is done: no line; "Goal done" sits over Claude\'s result', !s0.line && /Goal done/.test(s0.divider || '') && /The draft is ready for Dita/.test(s0.dividerNext || ''), JSON.stringify(s0));
149
+ await p.click('#hmLog .pl-dv [data-goal-open]');
150
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.vw ? v : null; }) || await p.evaluate(look);
151
+ ok('P5 a tap opens the points, with the note that Claude checked them itself', /4 of 4 done points met/.test(s1.vw || '') && /Claude checked its own points/.test(s1.vw || ''), JSON.stringify(s1));
152
+ st.goal = goal('stopped', { reason: 'deadline', at: ago(0.2) });
153
+ const s2 = await until(async () => { const v = await p.evaluate(look); return /Goal stopped/.test(v.divider || '') ? v : null; }) || await p.evaluate(look);
154
+ ok('P6 a goal that stopped: the amber divider says why, and the box says how to go on', /Goal stopped: the deadline passed/.test(s2.divider || '') && s2.ph === 'Reply to go on, or /goal for a new goal' && !s2.line, JSON.stringify(s2));
155
+ if (shots) await p.screenshot({ path: `${shots}/line-1280-stopped.png` });
156
+ ok('F1 (finished) no page error', !errs.length, errs.join(' | '));
157
+ await ctx.close(); }
158
+
159
+ /* P9: a desktop */
160
+ { const st = { goal: goal('started'), conv: { turn: 'tool', messages: BASE } };
161
+ const { p, ctx, errs } = await open(1280, st);
162
+ const s0 = await until(async () => { const v = await p.evaluate(look); return v.line ? v : null; }) || await p.evaluate(look);
163
+ ok('P9 a desktop: the same line over the chat column, opening nothing by itself', /1 of 4 done/.test(s0.line || '') && !s0.vw, JSON.stringify(s0));
164
+ await p.click('#hmPl [data-pl="toggle"]');
165
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.vw && /\bon\b/.test(v.cls) ? v : null; }) || await p.evaluate(look);
166
+ ok('P9 a tap opens the steps in the Viewer (the goal, the round, every point, Now) and the line stays tinted', /round 2 of 12/.test(s1.vw || '') && /Ready for Dita's review/.test(s1.vw || '') && /Now/.test(s1.vw || '') && !s1.open && /\bon\b/.test(s1.cls), JSON.stringify(s1));
167
+ if (shots) await p.screenshot({ path: `${shots}/line-1280-viewer.png` });
168
+ await p.click('#hmPl [data-pl="toggle"]');
169
+ const s2 = await until(async () => { const v = await p.evaluate(look); return !v.vw ? v : null; }) || await p.evaluate(look);
170
+ ok('P9 a second tap closes the Viewer and the tint goes', !s2.vw && !/\bon\b/.test(s2.cls), JSON.stringify(s2));
171
+ ok('F1 (1280) no page error and no sideways scroll', !errs.length && !s2.wide, errs.join(' | '));
172
+ await ctx.close(); }
173
+
174
+ /* P8: Home's rings */
175
+ { const st = { sessions: [
176
+ { id: 'ring-a', name: 'Weekly update draft', agent: 'claude', state: 'running', shown: 'working', created: ago(10), hx: { title: 'Weekly update draft' }, progress: { done: 3, n: 5 } },
177
+ { id: 'ring-b', name: 'Checkout drop-off', agent: 'claude', state: 'running', shown: 'working', created: ago(9), hx: { title: 'Checkout drop-off' }, progress: null },
178
+ ] };
179
+ const { p, ctx, errs } = await open(390, st, `${F.BASE}/premium.html?ws=${encodeURIComponent(F.ws)}`);
180
+ await until(() => p.evaluate(() => !!document.querySelector('#hmList [data-hm-pg="loose"]')));
181
+ await p.evaluate(() => { const g = document.querySelector('#hmList [data-hm-pg="loose"]'); if (g && g.getAttribute('aria-expanded') !== 'true') g.click(); });
182
+ const rows = await until(() => p.evaluate(() => { const a = [...document.querySelectorAll('#hmList .hm-r')].find((r) => /Weekly update draft/.test(r.textContent)), b = [...document.querySelectorAll('#hmList .hm-r')].find((r) => /Checkout drop-off/.test(r.textContent)); return a && b ? { a: a.innerHTML, at: a.textContent, b: b.innerHTML } : null; })) || {};
183
+ ok('P8 a running row with steps has a ring that fills (3 of 5), with no number on the row', /hv-ring/.test(rows.a || '') && /3 of 5 done/.test(rows.a || '') && !/3\/5/.test(rows.at || ''), (rows.a || '').slice(0, 600));
184
+ ok('P8 a running row with no steps has the plain ring', /hv-d run/.test(rows.b || '') && !/hv-ring/.test(rows.b || ''), (rows.b || '').slice(0, 400));
185
+ if (shots) await p.screenshot({ path: `${shots}/home-390-rings.png` });
186
+ ok('F1 (Home) no page error', !errs.length, errs.join(' | '));
187
+ await ctx.close(); }
188
+ return finish();
189
+ })();
@@ -57,7 +57,7 @@ const SPRINTS = { ok: true, source: 'jira', readAt: '2026-10-19T09:00:00Z', velo
57
57
  await page.route('**/api/initiative-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IMODEL, as_of: Date.now() }) }));
58
58
  await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
59
59
  // the Board's expand link lands on Home's initiative layout (premium-agreed-design); its Overview has the Sprint press, and the Viewer shows one item at a time
60
- S.up = await until(() => page.evaluate(() => !!document.querySelector('.hm-card [data-hm-ov]') && !!window.__premiumViewer && !!window.__premiumVwJira), 20000);
60
+ S.up = await until(() => page.evaluate(() => !!document.querySelector('.hm-card .cz-sl') && !!window.__premiumViewer && !!window.__premiumVwJira), 20000);
61
61
  if (S.up) { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .hi-pgh [data-hi-addtask]', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await page.click('#czViewer .hi-pgh [data-hi-addtask]'); /* the initiative's page (canvas HbC): its + drills into Tasks */ S.up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]'))); }
62
62
  S.reads.length = 0;
63
63
  return { page, ctx, S };
@@ -48,7 +48,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
48
48
  await page.route('**/api/initiative-premium*', (r) => { const u = r.request().url(); S.gets.push(u); if (!r.request().headers()['x-pmos-nonce']) S.vgets.push(u); const a = answer ? answer(u, S.gets.filter((x) => x === u).length) : { status: 200, body: { ok: true, state: 'ready', model: MODEL, as_of: Date.now() } }; r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
49
49
  await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
50
50
  await page.goto(BASE + '/premium.html?ini=self-serve-v2&ws=w1&board=w1&theme=' + theme);
51
- S.up = await until(() => page.evaluate(() => !!document.querySelector('.hm-card [data-hm-ov]') && !!window.__premiumWorkItem), 20000);
51
+ S.up = await until(() => page.evaluate(() => !!document.querySelector('.hm-card .cz-sl') && !!window.__premiumWorkItem), 20000);
52
52
  return { page, ctx, S };
53
53
  };
54
54
  const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
@@ -87,7 +87,7 @@ const TICKETS = {
87
87
  await page.route('**/api/initiative-premium*', (r) => json(r, { ok: true, state: 'ready', model: IMODEL, as_of: Date.now() }));
88
88
  await page.route('**/api/briefing-premium/**', (r) => json(r, { ok: true, turns: [], working: false }));
89
89
  await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme); // the Board's expand link: Home with the initiative
90
- await until(() => page.evaluate(() => !!document.querySelector('.hm-card [data-hm-ov]') && !!window.__premiumVwJira), 20000);
90
+ await until(() => page.evaluate(() => !!document.querySelector('.hm-card .cz-sl') && !!window.__premiumVwJira), 20000);
91
91
  await overview(page);
92
92
  await sleep(300); reads.length = 0; posts.length = 0; // Home's own reads; the checks below are about the sprint view's
93
93
  return { ctx, page, errors, posts, reads };
@@ -344,7 +344,9 @@ function draw(keepFocus) {
344
344
  /** ⋯ in the shell's order: change it (add, move in), look back (the charter), copy, then archive in red, last. */
345
345
  function moreOf(p) {
346
346
  const M = O.M(), taken = new Set(((O.programs()) || []).flatMap((x) => (x.members || []).filter((m) => !m.ws || m.ws === board().ws).map((m) => m.initiative)));
347
- const free = ((M && M.rows) || []).filter((r) => r.id && r.track && !taken.has(r.id)).slice(0, 8);
347
+ // only the open initiatives: a cancelled or archived one moved in would not show in the program
348
+ const gone = new Set(Object.values((M && M.initiatives && M.initiatives.gone) || {}).flat().map((r) => r.key));
349
+ const free = ((M && M.rows) || []).filter((r) => r.id && r.track && !gone.has(r.key) && !taken.has(r.id)).slice(0, 8);
348
350
  const more = [{ label: 'Add a new initiative', on: () => { VW.close(); const n = document.getElementById('newIni'); if (n) n.click(); } }];
349
351
  if (free.length) more.push({ label: 'Move an initiative in', on: (b) => Pop.open(`<p class="bd-mlbl">Move an initiative into ${esc(p.title)}</p>${free.map((r) => `<button type="button" class="bd-mi" role="menuitem" data-ppjoin="${esc(r.id)}">${esc(r.title)}</button>`).join('')}`, b, { label: 'Move an initiative in', role: 'menu', width: 280, align: 'right', cls: 'bd-menu', focus: '.bd-mi' }) });
350
352
  more.push({ label: 'Add a task to the program', on: () => { adding = true; try { localStorage.setItem('cz-vw-fold:program:tasks', '1'); } catch { /* a private window */ } draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); } });