create-pmos 0.408.0 → 0.409.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 (75) hide show
  1. package/package.json +13 -13
  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/board-programs-test.js +1 -1
  7. package/workspace/board-wf-shot.js +45 -0
  8. package/workspace/board-workflows-test.js +186 -0
  9. package/workspace/briefing-premium-board-test.js +2 -2
  10. package/workspace/briefing-premium-initiative-test.js +1 -1
  11. package/workspace/changelog.json +12 -0
  12. package/workspace/fixtures/board-workflows-facts.js +49 -0
  13. package/workspace/fixtures/workflows-facts.js +53 -0
  14. package/workspace/guide/index.md +1 -0
  15. package/workspace/guide/workflows.md +58 -0
  16. package/workspace/ini-workflow-test.js +177 -0
  17. package/workspace/lib/board-premium.js +30 -5
  18. package/workspace/lib/board-trail.js +24 -7
  19. package/workspace/lib/briefing-premium-agent.js +3 -0
  20. package/workspace/lib/engine/boards.js +30 -2
  21. package/workspace/lib/engine/workflows.js +204 -0
  22. package/workspace/lib/pmos-verbs.js +3 -0
  23. package/workspace/lib/programs.js +22 -7
  24. package/workspace/lib/route-modules.js +1 -0
  25. package/workspace/lib/routes-boards.js +157 -7
  26. package/workspace/lib/routes-programs.js +5 -0
  27. package/workspace/lib/routes-workflows.js +105 -0
  28. package/workspace/lib/workflow-chat.js +26 -0
  29. package/workspace/lib/workflow-cli.js +141 -0
  30. package/workspace/lib/workflows-store.js +108 -0
  31. package/workspace/package-lock.json +2 -2
  32. package/workspace/package.json +1 -1
  33. package/workspace/program-charter-test.js +243 -0
  34. package/workspace/program-panel-test.js +1 -1
  35. package/workspace/public/pm/bd-acts.js +10 -5
  36. package/workspace/public/pm/bd-asks.js +2 -2
  37. package/workspace/public/pm/bd-prog-panel.js +33 -14
  38. package/workspace/public/pm/bd-prog.js +11 -3
  39. package/workspace/public/pm/bd-views.js +128 -45
  40. package/workspace/public/pm/bd-wf.js +99 -0
  41. package/workspace/public/pm/cozy-board.css +67 -6
  42. package/workspace/public/pm/cozy-evmodel.js +1 -1
  43. package/workspace/public/pm/cozy-panel.css +12 -6
  44. package/workspace/public/pm/cozy-settings.js +4 -2
  45. package/workspace/public/pm/cozy-viewer.js +36 -9
  46. package/workspace/public/pm/cozy-vw-shell.css +8 -0
  47. package/workspace/public/pm/goal-chat.js +1 -1
  48. package/workspace/public/pm/home-app.js +14 -9
  49. package/workspace/public/pm/home-ini-model.js +2 -2
  50. package/workspace/public/pm/home-ini.css +30 -0
  51. package/workspace/public/pm/home-ini.js +52 -9
  52. package/workspace/public/pm/home-list.js +5 -3
  53. package/workspace/public/pm/home-today.js +4 -4
  54. package/workspace/public/pm/ini-wf-model.js +91 -0
  55. package/workspace/public/pm/ini-wf.js +160 -0
  56. package/workspace/public/pm/premium-board.js +98 -30
  57. package/workspace/public/pm/premium-initiative-head.js +18 -8
  58. package/workspace/public/pm/program-charter.css +135 -0
  59. package/workspace/public/pm/program-charter.js +333 -0
  60. package/workspace/public/pm/program-model.js +44 -4
  61. package/workspace/public/pm/wf-edit.js +119 -0
  62. package/workspace/public/pm/wf-model.js +48 -0
  63. package/workspace/public/pm/wf-page.css +162 -0
  64. package/workspace/public/pm/wf-page.js +398 -0
  65. package/workspace/public/pm/wf-stage.js +187 -0
  66. package/workspace/public/premium-workflows.html +31 -0
  67. package/workspace/public/premium.html +1 -0
  68. package/workspace/server.js +1 -1
  69. package/workspace/skills/workflow-setup.skill +57 -0
  70. package/workspace/test-lists/ini-workflow.json +6 -0
  71. package/workspace/test-lists/program-charter.json +9 -0
  72. package/workspace/test-lists/workflows-board.json +13 -0
  73. package/workspace/test-lists/workflows-setup.json +13 -0
  74. package/workspace/test-lists/workflows.json +5 -0
  75. package/workspace/workflows-setup-test.js +346 -0
@@ -0,0 +1,243 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* program-charter-test.js — a program's charter, the one editor of its fields and milestones (feedback batch item 4; canvas MsBCharter,
4
+ * MsB0Entry, MsB1First, MsB2Drafts, MsB3Pick, MsB4Rename, MsB5Leave, MsB6Problems, MsB7Done, MsBPhone, MsEmpty). Serves the real Board
5
+ * page from the real server; Project Ascent comes from fixtures/program-ascent.js through fixtures/board-premium-facts.js, and the program
6
+ * writes are captured, not written.
7
+ * W the ways in: the charter icon, the pencil on Milestones, "Add the first milestone" · F the fields and the milestones as the record
8
+ * holds them · S Save only after a change, and it resends every field with stable ids · L leaving with changes asks Save or Discard ·
9
+ * P the picker by product with each ◆ Deliver day; an earlier milestone date warns · X what stops a save · D the drafts · N the name ·
10
+ * O "Open again" on a done check · H on a phone. PMOS_SHOTS=<dir> also saves the screenshots the frames are compared with. */
11
+ const path = require('path');
12
+ const fs = require('fs');
13
+ const { spawn } = require('child_process');
14
+ const { findBrowser } = require('./lib/find-browser');
15
+ const T = require('./test-run').configure({ name: 'program-charter' });
16
+ const BP = require('./lib/board-premium.js');
17
+ const F = require('./fixtures/board-premium-facts.js');
18
+ const A = require('./fixtures/program-ascent.js');
19
+
20
+ const BASE = T.BASE;
21
+ const SHOTS = process.env.PMOS_SHOTS || '';
22
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
23
+ const until = async (fn, ms = 10000, 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); } };
24
+ const results = [];
25
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
26
+ let srv = null; let browser = null;
27
+ const finish = async (code) => {
28
+ if (browser) await browser.close().catch(() => {});
29
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
30
+ T.killTmux();
31
+ const bad = results.filter((x) => !x.cond).length;
32
+ console.log(`\n${results.length - bad}/${results.length} program-charter assertions passed`);
33
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
34
+ };
35
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
36
+
37
+ (async () => {
38
+ const exe = process.env.PMOS_CHROME || findBrowser();
39
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
40
+ let chromium;
41
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
42
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
43
+ await T.waitForServer(BASE);
44
+ browser = await chromium.launch({ executablePath: exe });
45
+ if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
46
+ const shot = async (p, name) => { if (SHOTS) await p.screenshot({ path: path.join(SHOTS, name + '.png') }); };
47
+
48
+ const open = async ({ w = 1440, h = 900, programs = F.programs(), dark = false, home = false } = {}) => {
49
+ const c = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: dark ? 'dark' : 'light' });
50
+ const page = await c.newPage();
51
+ const errors = [], posts = [];
52
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
53
+ await page.route('**/api/board-premium*', (r) => { const ws = new URL(r.request().url()).searchParams.get('ws') || 'idpf'; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.programFacts(ws)), as_of: Date.now() }) }); });
54
+ await page.route('**/api/programs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, programs }) }));
55
+ const wsOf = (r) => new URL(r.request().url()).searchParams.get('ws') || 'idpf', json = (r, b) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(b) });
56
+ await page.route('**/api/boards/anchors*', (r) => json(r, { ok: true, anchors: A.ANCHORS[wsOf(r)] || [] }));
57
+ await page.route('**/api/insights-premium*', (r) => json(r, { ok: true, model: { goals: A.GOALS[wsOf(r)] || [] } }));
58
+ await page.route('**/api/boards/items*', (r) => json(r, { ok: true, items: A.ITEMS[wsOf(r)] || [] }));
59
+ await page.route('**/api/programs/*', (r) => { const rq = r.request(); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }); });
60
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: '{"ok":false,"error":"not in this check"}' }));
61
+ if (home) { await page.goto(BASE + '/premium.html?ws=idpf'); return { page, ctx: c, errors, posts }; }
62
+ await page.goto(BASE + '/premium-board.html?ws=idpf&program=' + programs[0].id);
63
+ await until(() => page.evaluate(() => { const v = document.querySelector('#czViewer'); return !!v && !v.hidden && !!v.querySelector('.pp-vw .czs-sum'); }));
64
+ // the other product's board lands after the panel opens: the charter lists its initiative once it is read
65
+ await until(() => page.evaluate(() => !/reading its board/.test((document.querySelector('#czViewer [data-czs-id="tree"]') || {}).textContent || '')), 6000);
66
+ return { page, ctx: c, errors, posts };
67
+ };
68
+ const charterShown = (p) => until(() => p.evaluate(() => { const v = document.querySelector('#czViewer'); return !!v && !v.hidden && /Charter/.test(v.getAttribute('aria-label') || '') && !!v.querySelector('.pc-vw .pc'); }));
69
+ const head = (p) => p.evaluate(() => { const v = document.querySelector('#czViewer'); return { tools: [...v.querySelectorAll('.cz-vw-hd [data-cz-vw]')].map((b) => b.getAttribute('aria-label')), title: (v.querySelector('.cz-vw-title') || {}).textContent, sub: (v.querySelector('.cz-vw-sub') || {}).textContent || '', save: !!v.querySelector('.cz-vw-hd .cz-vw-pri') }; });
70
+ const setVal = (p, sel, v) => p.evaluate(([s, x]) => { const i = document.querySelector(s); i.value = x; i.dispatchEvent(new Event('input', { bubbles: true })); }, [sel, v]);
71
+ const rowsOf = (p) => p.evaluate(() => [...document.querySelectorAll('#czViewer .pc-ln[data-m]')].map((r) => ({ id: r.dataset.m, name: r.querySelector('[data-f="name"]').value, day: r.querySelector('.pc-fd span').textContent, when: (r.querySelector('.pc-wch span:not(.sq):not(.bx)') || r.querySelector('.pc-via, .pc-mini') || {}).textContent || '', draft: r.classList.contains('sug') })));
72
+
73
+ /* ── desktop: the ways in, the fields, Save ── */
74
+ const D = await open();
75
+ const p = D.page;
76
+ const ph = await head(p);
77
+ ok('W the program\'s header holds the charter icon beside Discuss, and ⋯ no longer repeats it', ph.tools.includes('Open the charter') && ph.tools.indexOf('Open the charter') === ph.tools.indexOf('Discuss in chat') + 1, JSON.stringify(ph.tools));
78
+ await p.click('#czViewer [data-cz-vw="more"]');
79
+ ok('W ⋯ holds no "Open the charter"', !(await p.evaluate(() => [...document.querySelectorAll('.cz-vw-menu button')].some((b) => /charter/i.test(b.textContent)))));
80
+ await p.keyboard.press('Escape');
81
+ await shot(p, 'MsB0Entry-built-track');
82
+ await p.evaluate(() => { const b = document.querySelector('#czViewer [data-czs-fold="ms"]'); if (b && b.getAttribute('aria-expanded') !== 'true') b.click(); });
83
+ ok('W the Milestones row carries a pencil', await p.evaluate(() => !!document.querySelector('#czViewer [data-czs-id="ms"] .czs-tail [data-pp="edit"]')));
84
+ await shot(p, 'MsB0Entry-built');
85
+ await p.click('#czViewer [data-pp="edit"]');
86
+ ok('W the pencil opens the charter as a drill-in (← back to the program)', await charterShown(p));
87
+ const ch = await head(p);
88
+ ok('F the header: ←, the program\'s name with "Charter" under it, no Save before a change, no ⋯', ch.tools[0] === 'Back' && /^Project Ascent · CIAM migration/.test(ch.title) && ch.sub === 'Charter' && !ch.save && !ch.tools.includes('More'), JSON.stringify(ch));
89
+ const fv = await p.evaluate(() => { const v = (f) => (document.querySelector(`#czViewer [data-f="${f}"]:not(.pc-dt)`) || {}).value; return { goal: v('goal'), owner: v('owner'), jira: v('jira'), why: v('why'), start: document.querySelector('#czViewer [data-pc="date"][data-f="start"] span').textContent, target: document.querySelector('#czViewer [data-pc="date"][data-f="target"] span').textContent, lim: document.querySelector('#czViewer .pc-lim').textContent, done: document.querySelector('#czViewer button.pc-ln.dn').textContent }; });
90
+ ok('F every field as the record holds it; the span as days; "8 of 12"; the done ones fold into "2 done · …"', fv.goal === 'CIAM migration' && fv.owner === 'Wawan' && fv.jira === '' && /^Move every product/.test(fv.why) && fv.start === 'Sep 1, 2026' && fv.target === 'Jun 30, 2028' && fv.lim === '8 of 12' && fv.done === '2 done · Vendor picked, Charter approved', JSON.stringify(fv));
91
+ const r0 = await rowsOf(p);
92
+ ok('F the open milestones by date, each with its date and what it waits on, or "I tick it myself"', r0.map((r) => r.name).join('|') === 'Pilot live|Pilot users invited|Support ready|Legacy IdP off|All microsites on CIAM|Program review'
93
+ && r0[0].day === 'Nov 18' && r0[0].when === 'Descope feature parity, Microsite sign-in on CIAM' && r0[2].when === 'I tick it myself', JSON.stringify(r0));
94
+ await shot(p, 'MsBCharter-built');
95
+
96
+ // L: a change, then ← asks once
97
+ await setVal(p, '#czViewer [data-f="goal"]', 'One sign-in for every product on CIAM');
98
+ ok('S Save shows after a change', (await head(p)).save);
99
+ await p.click('#czViewer [data-cz-vw="back"]');
100
+ const ask = await until(() => p.evaluate(() => { const a = document.querySelector('#czViewer .pc-ask'); return a ? { q: a.querySelector('p').textContent, t: a.querySelector('.t').textContent } : null; }));
101
+ ok('L ← with a change asks once: Save or Discard, naming what changed', !!ask && ask.q === 'Save your 1 change?' && ask.t === 'The goal.', JSON.stringify(ask));
102
+ await p.keyboard.press('Escape');
103
+ ok('L Escape closes the question and stays in the charter', await until(() => p.evaluate(() => !document.querySelector('#czViewer .pc-ask') && !!document.querySelector('#czViewer .pc-vw'))));
104
+ await p.evaluate(() => { const b = document.querySelector('#czViewer [data-pc="del"][data-m="support-ready"]'); b.click(); });
105
+ await setVal(p, '#czViewer .pc-dt[data-f="date"][data-m="pilot-live"]', '2026-11-25');
106
+ await p.click('#czViewer [data-cz-vw="back"]');
107
+ await until(() => p.evaluate(() => !!document.querySelector('#czViewer .pc-ask')));
108
+ await shot(p, 'MsB5Leave-built');
109
+ const ask2 = await p.evaluate(() => ({ q: document.querySelector('#czViewer .pc-ask p').textContent, t: document.querySelector('#czViewer .pc-ask .t').textContent }));
110
+ ok('L the question counts and names each change', ask2.q === 'Save your 3 changes?' && ask2.t === 'Pilot live moved to Nov 25, Support ready deleted, and the goal.', JSON.stringify(ask2));
111
+ await p.click('#czViewer [data-pc="discard"]');
112
+ ok('L Discard goes back to the program and writes nothing', await until(() => p.evaluate(() => /^Viewer: Program/.test(document.querySelector('#czViewer').getAttribute('aria-label')))) && !D.posts.some((x) => x.path === '/api/programs/save'));
113
+
114
+ // S: the charter icon in the header; a change saved resends every field and keeps the ids
115
+ await p.click('#czViewer [data-cz-vw-p="charter"]');
116
+ await charterShown(p);
117
+ await setVal(p, '#czViewer .pc-dt[data-f="date"][data-m="pilot-live"]', '2026-11-25');
118
+ await p.click('#czViewer [data-pc="del"][data-m="support-ready"]');
119
+ await p.click('#czViewer [data-pc="add"]');
120
+ await p.keyboard.type('Partners told');
121
+ await p.click('#czViewer .cz-vw-hd .cz-vw-pri');
122
+ const sv = await until(() => D.posts.find((x) => x.path === '/api/programs/save'));
123
+ const b = sv && sv.body.program;
124
+ ok('S Save resends the whole charter: the program id, every field, the milestones by date with their ids; a new one gets an id from its name', !!b && sv.body.ws === 'idpf' && b.id === 'project-ascent' && b.title === 'Project Ascent' && b.owner === 'Wawan' && b.goal === 'CIAM migration' && b.start === '2026-09-01' && b.target === '2028-06-30'
125
+ && b.milestones.length === 8 && !b.milestones.some((m) => m.id === 'support-ready') && b.milestones.find((m) => m.id === 'pilot-live').date === '2026-11-25' && JSON.stringify(b.milestones.find((m) => m.id === 'pilot-live').waits) === '["descope-parity","microsite-signin"]'
126
+ && b.milestones.some((m) => m.id === 'partners-told' && m.name === 'Partners told' && m.done === false) && b.milestones.find((m) => m.id === 'vendor-picked').done === true, JSON.stringify(b));
127
+ ok('S after Save, Save is gone again', await until(() => head(p).then((h) => !h.save)));
128
+
129
+ // P: the picker, and the amber date warning
130
+ await p.click('#czViewer [data-pc="pick"][data-m="pilot-live"]');
131
+ const mn = await until(() => p.evaluate(() => { const m = document.querySelector('#czViewer .pc-menu'); return m ? { hd: [...m.querySelectorAll('.pc-mhd')].map((x) => x.textContent), items: [...m.querySelectorAll('.pc-mi')].map((x) => x.querySelector('.t').textContent + (x.querySelector('.r') ? ' ' + x.querySelector('.r').textContent : '') + (x.getAttribute('aria-checked') === 'true' ? ' ✓' : '')) } : null; }));
132
+ ok('P the picker lists its initiatives per product with their ◆ Deliver days, the chosen ones ticked, then "None: I tick it myself"', !!mn && mn.hd.join('|') === 'Done when these pass ◆ Deliver|IDPF|Microsites'
133
+ && mn.items.includes('Descope feature parity Nov 12 ✓') && mn.items.includes('Microsite sign-in on CIAM Nov 14 ✓') && mn.items.includes('Legacy IdP sunset Feb 20') && mn.items[mn.items.length - 1] === 'None: I tick it myself', JSON.stringify(mn));
134
+ await p.click('#czViewer .pc-menu [data-ini="legacy-idp-sunset"]');
135
+ const wv = await until(() => p.evaluate(() => { const w = document.querySelector('#czViewer .pc-lnw:has([data-m="pilot-live"]) .pc-warn'); return w ? w.textContent : null; }));
136
+ ok('P picking an initiative whose ◆ Deliver is later than the milestone warns in amber, and Save stays', wv === 'Legacy IdP sunset is set to deliver on Feb 20, after this date.' && (await head(p)).save, String(wv));
137
+ await shot(p, 'MsB3Pick-built');
138
+ await p.click('#czViewer .pc-menu [data-ini="legacy-idp-sunset"]');
139
+ await p.keyboard.press('Escape');
140
+ ok('P Escape closes the picker first', await until(() => p.evaluate(() => !document.querySelector('#czViewer .pc-menu') && !!document.querySelector('#czViewer .pc-vw'))));
141
+
142
+ // X: what stops a save
143
+ await setVal(p, '#czViewer .pc-dt[data-f="start"]', '2028-07-01');
144
+ await p.click('#czViewer [data-pc="add"]');
145
+ const px = await p.evaluate(() => ({ span: (document.querySelector('#czViewer .pc-lab .pc-warn') || {}).textContent || '', bad: [...document.querySelectorAll('#czViewer .bad')].map((x) => x.dataset.f), ph: (document.querySelector('#czViewer [data-f="name"].bad') || {}).placeholder }));
146
+ ok('X a start after the target, and a row with no name, are said in place and Save is not drawn', px.span === 'The start is after the target. Change one to save.' && px.bad.includes('start') && px.bad.includes('name') && px.ph === 'Name it or delete it' && !(await head(p)).save, JSON.stringify(px));
147
+ await shot(p, 'MsB6Problems-built');
148
+ await setVal(p, '#czViewer .pc-dt[data-f="start"]', '2026-09-01');
149
+ for (let i = 0; i < 6; i++) await p.click('#czViewer [data-pc="add"]').catch(() => {});
150
+ const full = await p.evaluate(() => ({ lim: document.querySelector('#czViewer .pc-lim').textContent, add: !!document.querySelector('#czViewer [data-pc="add"]'), n: document.querySelectorAll('#czViewer .pc-ln[data-m]').length + 0 }));
151
+ ok('X 12 is the most: the count says so in amber and "Add a milestone" goes', full.lim === '12 of 12 · the most a program holds' && !full.add, JSON.stringify(full));
152
+
153
+ // O: the done ones open from "2 done"; a check opens again, one done by its initiatives says so
154
+ await p.click('#czViewer [data-cz-vw="back"]');
155
+ await until(() => p.evaluate(() => !!document.querySelector('#czViewer .pc-ask')));
156
+ await p.click('#czViewer [data-pc="discard"]');
157
+ await p.click('#czViewer [data-cz-vw-p="charter"]');
158
+ await charterShown(p);
159
+ await p.click('#czViewer button.pc-ln.dn');
160
+ const dn = await p.evaluate(() => [...document.querySelectorAll('#czViewer .pc-ln.dn2')].map((r) => r.querySelector('[data-f="name"]').value + ':' + ((r.querySelector('.pc-mini, .pc-via') || {}).textContent || '')));
161
+ ok('O "2 done" opens the done ones: a check can be opened again', dn.join('|') === 'Vendor picked:Open again|Charter approved:Open again', JSON.stringify(dn));
162
+ await shot(p, 'MsB7Done-built');
163
+ await p.click('#czViewer [data-pc="reopen"][data-m="vendor-picked"]');
164
+ const n0 = D.posts.length;
165
+ await p.click('#czViewer .cz-vw-hd .cz-vw-pri');
166
+ const sv2 = await until(() => D.posts.slice(n0).find((x) => x.path === '/api/programs/save'));
167
+ ok('O Open again is saved with the charter: the check goes back to open', !!sv2 && sv2.body.program.milestones.find((m) => m.id === 'vendor-picked').done === false, JSON.stringify(sv2 && sv2.body.program.milestones));
168
+
169
+ // N: the name is the rename press, saved at once
170
+ await p.click('#czViewer [data-cz-vw-rn]');
171
+ await p.fill('#czViewer #czVwTitle', 'Project Summit');
172
+ const n1 = D.posts.length;
173
+ await p.keyboard.press('Enter');
174
+ const rn = await until(() => D.posts.slice(n1).find((x) => x.path === '/api/programs/save'));
175
+ ok('N tapping the title renames the program at once, the whole charter with its id', !!rn && rn.body.program.title === 'Project Summit' && rn.body.program.id === 'project-ascent' && rn.body.program.milestones.length === 8, JSON.stringify(rn && rn.body));
176
+ ok('0 no page error on a desk', D.errors.length === 0, D.errors.join(' | '));
177
+ await D.ctx.close();
178
+
179
+ /* ── a program with no milestones: the first way in, the drafts ── */
180
+ const bare = F.programs().map((x, i) => (i === 0 ? { ...x, milestones: [], goal: '', why: '', jira: '' } : x));
181
+ const E = await open({ programs: bare });
182
+ const q = E.page;
183
+ const first = await q.evaluate(() => ({ track: !!document.querySelector('#czViewer .pp-mt'), first: (document.querySelector('#czViewer [data-pp="first"]') || {}).textContent || '' }));
184
+ ok('W no milestone yet: "Add the first milestone" stands where the track would be', !first.track && first.first === 'Add the first milestone', JSON.stringify(first));
185
+ await shot(q, 'MsEmpty-built');
186
+ await q.click('#czViewer [data-pp="first"]');
187
+ await charterShown(q);
188
+ const sg = await q.evaluate(() => ({ t: (document.querySelector('#czViewer .pc-sugh span') || {}).textContent || '', ph: document.querySelector('#czViewer [data-f="goal"]').placeholder }));
189
+ ok('D a charter with no milestones offers drafts from the ◆ Deliver dates of its initiatives; empty fields say what goes in', /^No milestones yet\. Draft them from the ◆ Deliver dates of its 3 initiatives\.$/.test(sg.t) && sg.ph === 'What the program achieves, in one line', JSON.stringify(sg));
190
+ await shot(q, 'MsB1First-built');
191
+ await q.click('#czViewer [data-pc="drafts"]');
192
+ const dr = await rowsOf(q);
193
+ ok('D the drafts are dashed rows, one per initiative on its ◆ Deliver day and a review at the target; nothing is written yet', dr.length === 4 && dr.every((r) => r.draft) && dr[0].name === 'Descope feature parity delivered' && dr[0].day === 'Nov 12' && dr[3].name === 'Program review' && dr[3].when === 'I tick it myself' && !E.posts.some((x) => x.path === '/api/programs/save'), JSON.stringify(dr));
194
+ await shot(q, 'MsB2Drafts-built');
195
+ await q.click('#czViewer [data-pc="drop"][data-m="' + dr[3].id + '"]');
196
+ await q.click('#czViewer [data-pc="keepall"]');
197
+ await q.click('#czViewer .cz-vw-hd .cz-vw-pri');
198
+ const sv3 = await until(() => E.posts.find((x) => x.path === '/api/programs/save'));
199
+ ok('D Save writes the kept drafts, each with an id from its name', !!sv3 && sv3.body.program.milestones.map((m) => m.id).join() === 'descope-feature-parity-delivered,microsite-sign-in-on-ciam-delivered,legacy-idp-sunset-delivered', JSON.stringify(sv3 && sv3.body.program.milestones));
200
+ ok('0 no page error with no milestones', E.errors.length === 0, E.errors.join(' | '));
201
+ await E.ctx.close();
202
+
203
+ /* ── an initiative that left the program ── */
204
+ const gone = F.programs().map((x, i) => (i === 0 ? { ...x, milestones: x.milestones.map((m) => (m.id === 'pilot-users' ? { ...m, waits: ['partner-sso'] } : m)) } : x));
205
+ const G = await open({ programs: gone });
206
+ await G.page.click('#czViewer [data-cz-vw-p="charter"]');
207
+ await charterShown(G.page);
208
+ const gw = await G.page.evaluate(() => ({ warn: (document.querySelector('#czViewer .pc-lnw:has([data-m="pilot-users"]) .pc-warn') || {}).textContent || '', amber: !!document.querySelector('#czViewer .pc-wch.gone[data-m="pilot-users"]') }));
209
+ await setVal(G.page, '#czViewer [data-f="goal"]', 'x');
210
+ ok('X a milestone that waits on an initiative that left the program says so in amber, and Save is not drawn', gw.warn === 'partner-sso left the program. Pick another initiative, or tick it yourself.' && gw.amber && !(await head(G.page)).save, JSON.stringify(gw));
211
+ await G.ctx.close();
212
+
213
+ /* ── phone ── */
214
+ const S = await open({ w: 390, h: 844 });
215
+ await S.page.click('#czViewer [data-cz-vw-p="charter"]');
216
+ await charterShown(S.page);
217
+ await setVal(S.page, '#czViewer [data-f="goal"]', 'One sign-in for every product on CIAM');
218
+ await S.page.click('#czViewer [data-pc="pick"][data-m="pilot-live"]');
219
+ const sp = await S.page.evaluate(() => { const s = document.querySelector('#czViewer .cz-vw-pri'); return { save: !!s && s.classList.contains('i') && !s.textContent.trim(), chips: [...document.querySelectorAll('#czViewer .pc-chips .pc-ch')].map((c) => c.textContent.trim() + (c.getAttribute('aria-pressed') === 'true' ? ' ✓' : '')), wide: document.documentElement.scrollWidth <= innerWidth + 1 }; });
220
+ ok('H on a phone Save is a round check, the picker is chips under the row, and nothing scrolls sideways', sp.save && sp.chips.includes('Descope feature parity ✓') && sp.chips.includes('I tick it myself') && sp.wide, JSON.stringify(sp));
221
+ await S.page.evaluate(() => { const r = document.querySelector('#czViewer .pc-ms'); if (r) r.scrollIntoView(); });
222
+ await shot(S.page, 'MsBPhone-built');
223
+ ok('0 no page error on a phone', S.errors.length === 0, S.errors.join(' | '));
224
+ await S.ctx.close();
225
+
226
+ /* ── Home: the program heading's name opens the same panel in Home's Viewer, styled, and its charter ── */
227
+ const M = await open({ home: true });
228
+ const prog = await until(() => M.page.$('#hmList [data-hm-prog]'), 10000);
229
+ if (prog) await prog.click();
230
+ const hp = await until(() => M.page.evaluate(() => { const v = document.querySelector('#czViewer'); if (!v || v.hidden || !v.querySelector('.pp-vw .czs-sum')) return null; return { tile: getComputedStyle(v.querySelector('.cz-vw-tile')).backgroundColor, prog: getComputedStyle(document.body).getPropertyValue('--pp-prog').trim() }; }));
231
+ ok('M on Home the program heading opens the program panel with its own purple (cozy-panel.css is on Home)', !!hp && !!hp.prog && !/rgba\(0, 0, 0, 0\)|transparent/.test(hp.tile), JSON.stringify(hp));
232
+ if (hp) { await M.page.click('#czViewer [data-cz-vw-p="charter"]'); }
233
+ ok('M the charter opens from the panel on Home too', !!hp && !!(await charterShown(M.page)));
234
+ ok('0 no page error on Home', M.errors.length === 0, M.errors.join(' | '));
235
+ await M.ctx.close();
236
+
237
+ if (SHOTS) { // dark, for the look only
238
+ const K = await open({ dark: true });
239
+ await K.page.click('#czViewer [data-cz-vw-p="charter"]'); await charterShown(K.page);
240
+ await shot(K.page, 'MsBCharter-built-dark'); await K.ctx.close();
241
+ }
242
+ finish();
243
+ })();
@@ -71,7 +71,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
71
71
  await sleep(1500); // the other product's board and the program reads land after the program opened: none of them opens it again
72
72
  ok('P ?program=<id> sends bd:program once: one path opens the program', await p.evaluate(() => window.__bdp) === 1, String(await p.evaluate(() => window.__bdp)));
73
73
  const hd = await p.evaluate(() => { const v = document.querySelector('#czViewer'); const r = v.getBoundingClientRect(); return { t: v.querySelector('.cz-vw-title').textContent, kind: (v.querySelector('.cz-vw-kind') || {}).textContent, meta: (v.querySelector('.czs-meta') || {}).textContent, tools: [...v.querySelectorAll('.cz-vw-head [data-cz-vw], [data-cz-vw]')].filter((b) => b.closest('#czViewer') && !b.classList.contains('cz-vw-grip')).map((b) => b.getAttribute('aria-label')), input: v.querySelectorAll('.cz-vw-body input, .cz-vw-body textarea').length, tabs: v.querySelectorAll('.pp-tab, [role="tab"]').length, w: Math.round(r.width), right: Math.round(innerWidth - r.right), sel: !!document.querySelector('#ibBody [data-prow="project-ascent"].sel') }; });
74
- ok('P the shell\'s header names it once ("title · goal"), with Discuss in chat, ⋯, Open wide and Close; the summary says the owner and the span; there is no chat box and no tab', hd.t === 'Project Ascent · CIAM migration' && hd.kind === 'Program' && hd.meta === 'Wawan · Sep 2026 to Jun 2028' && [...new Set(hd.tools)].join('|') === 'Discuss in chat|More|Open wide|Close the viewer' && hd.input === 0 && hd.tabs === 0, JSON.stringify(hd));
74
+ ok('P the shell\'s header names it once ("title · goal"), with Discuss in chat, the charter icon, ⋯, Open wide and Close; the summary says the owner and the span; there is no chat box and no tab', hd.t === 'Project Ascent · CIAM migration' && hd.kind === 'Program' && hd.meta === 'Wawan · Sep 2026 to Jun 2028' && [...new Set(hd.tools)].join('|') === 'Discuss in chat|Open the charter|More|Open wide|Close the viewer' && hd.input === 0 && hd.tabs === 0, JSON.stringify(hd));
75
75
  ok('V the program floats at 560 px over the page\'s right edge, and its band row on the Board is selected', hd.w === 560 && hd.right < 40 && hd.sel, JSON.stringify(hd));
76
76
  const sm = await p.evaluate(() => ({ line: (document.querySelector('#czViewer .czs-line') || {}).textContent, pri: (document.querySelector('#czViewer .czs-pri') || {}).textContent || '' }));
77
77
  ok('P the summary line is the next milestone (Waits on you counts itself in its row, said once); no primary while every task has a level', /^Next: Pilot live/.test(sm.line) && sm.pri === '', JSON.stringify(sm));
@@ -6,7 +6,7 @@
6
6
  * /api/lifecycle { initiative_id, state, reason, back? } · /api/boards/archive { board, id, archived, reason? }.
7
7
  * Each one is done at once, with Undo in the toast, which writes the opposite line through the same route.
8
8
  * Cancelled and archived the side panel: All, On hold, Cancelled, Archived, each with Resume, Reopen or Restore
9
- * Find, Filter (BdFilter) Find: a jump list of the initiatives and the Jira work-items on this Board. Filter: owner, kind, sprint, applied as
9
+ * Find, Filter (BdFilter) Find: a jump list of the initiatives and the Jira work-items on this Board. Filter: owner, workflow, category, sprint, applied as
10
10
  * the PM picks; the "Showing" bar above the view lists what is on (the page's filter state F)
11
11
  * Sprints and releases (BdSprint) the chip's popover: the Jira sprints, the releases, the backlog; a release opens its panel (work-items done, days
12
12
  * left, the initiatives it carries, your sign-off, the backlog preview). Sprint moves are proposals that go to Home.
@@ -21,6 +21,7 @@ import { $, $$, esc } from './premium-shell.js';
21
21
  import * as Pop from './bd-pop.js';
22
22
  import * as V from './bd-views.js';
23
23
  import * as Asks from './bd-asks.js';
24
+ import * as WF from './bd-wf.js';
24
25
 
25
26
  const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
26
27
  const I = {
@@ -184,18 +185,21 @@ function openFind(from) {
184
185
  function pickFind() {
185
186
  const b = $$('#bdQr .bd-mi')[findAt]; if (b) b.click();
186
187
  }
187
- /** The Filter's groups: owner, kind (the lane), sprint (from the Jira reading, and the backlog). */
188
+ /** The Filter's groups: owner, workflow and category (WfAElse: Kind became Workflow), sprint (from the Jira reading, and the backlog).
189
+ * The workflow is one choice, the same one the chip row picks (pm/bd-wf.js); it shows only with more than one workflow on the board. */
188
190
  function filterHtml() {
189
191
  const rows = M().initiatives.list.rows, F = A.F;
190
192
  const owners = [...new Set(rows.map((r) => r.owner || 'No owner'))].sort((a, b) => (a === 'No owner') - (b === 'No owner') || a.localeCompare(b));
191
- const kinds = [...new Set(rows.map((r) => r.lane).filter(Boolean))].sort();
193
+ const W = A.wf ? A.wf() : { list: [], cur: null };
194
+ const cats = WF.CATS.map(([k]) => k).filter((k) => rows.some((r) => !r.ended && WF.catOfRow(r) === k));
192
195
  const sprints = (M().jira && M().jira.sprints) || [];
193
196
  const chip = (k, v, label) => `<button type="button" class="bd-chip${F[k].has(v) ? ' on' : ''}" data-flt="${k}" data-v="${esc(v)}" aria-pressed="${F[k].has(v)}">${label || esc(v)}</button>`;
194
197
  // the grouping (PgBoard, PgBoardProduct): programs first by default, so the toolbar shows nothing; By product shows its chip there
195
198
  const G = A.grouping ? A.grouping() : null;
196
199
  const grp = G && G.on ? `<p class="bd-mlbl">Group</p><div class="bd-fg" role="radiogroup" aria-label="Group">${[['program', 'Programs first'], ['product', 'By product']].map(([k, n]) => `<button type="button" class="bd-chip${(k === 'product') === G.byProduct ? ' on' : ''}" role="radio" aria-checked="${(k === 'product') === G.byProduct}" data-fgrp="${k}">${n}</button>`).join('')}</div>` : '';
197
200
  return grp + `<p class="bd-mlbl">Owner</p><div class="bd-fg">${owners.map((o) => chip('owners', o, (o === 'No owner' ? '' : V.avatar(o, 'xs')) + esc(o))).join('')}</div>`
198
- + `<p class="bd-mlbl">Kind</p><div class="bd-fg">${kinds.map((l) => chip('lanes', l, esc(cap(l)))).join('') || '<span class="bd-amut">No kind is on record</span>'}</div>`
201
+ + (W.list.length > 1 ? `<p class="bd-mlbl">Workflow</p><div class="bd-fg" role="radiogroup" aria-label="Workflow">${W.list.map((w) => { const on = WF.narrowed(W.list) && W.cur.id === w.id; return `<button type="button" class="bd-chip${on ? ' on' : ''}" role="radio" aria-checked="${on}" data-fwf="${esc(w.id)}">${WF.wfIcon(w, 16)}${esc(w.name)}</button>`; }).join('')}</div>` : '')
202
+ + (cats.length ? `<p class="bd-mlbl">Category</p><div class="bd-fg">${cats.map((k) => chip('cats', k, esc(WF.catLabel(k)))).join('')}</div>` : '')
199
203
  + (sprints.length ? `<p class="bd-mlbl">Sprint</p><div class="bd-fg">${sprints.map((s) => chip('sprints', s.name, esc(s.name + (s.now ? ' · now' : '')))).join('')}${chip('sprints', 'Backlog')}</div>` : '')
200
204
  + `<div class="bd-arow bd-ffoot"><button type="button" class="bd-btn sm ghost" data-fclear>Clear</button><span class="bd-amut bd-push">Applies as you pick</span></div>`;
201
205
  }
@@ -355,7 +359,8 @@ document.addEventListener('click', async (e) => {
355
359
  const ft = t.closest('[data-findtk]'); if (ft) { Pop.close(false); A.openTicket(ft.dataset.ini, ft.dataset.findtk); return; }
356
360
  const fl = t.closest('[data-flt]'); if (fl && Pop.isOpen() && Pop.el().contains(fl)) { const S = A.F[fl.dataset.flt], v = fl.dataset.v; if (S.has(v)) S.delete(v); else S.add(v); Pop.redraw(filterHtml()); A.redraw(); return; }
357
361
  const fg = t.closest('[data-fgrp]'); if (fg && Pop.isOpen() && Pop.el().contains(fg)) { A.setGrouping(fg.dataset.fgrp === 'product'); Pop.redraw(filterHtml()); return; }
358
- if (t.closest('[data-fclear]')) { A.F.owners.clear(); A.F.lanes.clear(); A.F.sprints.clear(); Pop.redraw(filterHtml()); A.redraw(); return; }
362
+ const fw = t.closest('[data-fwf]'); if (fw && Pop.isOpen() && Pop.el().contains(fw)) { WF.setPick(fw.getAttribute('aria-checked') === 'true' ? '' : fw.dataset.fwf); Pop.redraw(filterHtml()); A.redraw(); return; }
363
+ if (t.closest('[data-fclear]')) { A.F.owners.clear(); A.F.cats.clear(); A.F.sprints.clear(); WF.setPick(''); Pop.redraw(filterHtml()); A.redraw(); return; }
359
364
  const sp = t.closest('[data-sprint]'); if (sp) { const S = A.F.sprints, v = sp.dataset.sprint; if (S.has(v)) S.delete(v); else { S.clear(); S.add(v); } Pop.close(false); A.say(S.has(v) ? 'Showing the initiatives with work in ' + v + '.' : 'Showing every sprint.'); A.redraw(); return; }
360
365
  const rl = t.closest('[data-rel]'); if (rl) { Pop.close(false); openRelease(+rl.dataset.rel, $('#chSprint')); return; }
361
366
  if (t.closest('[data-backlog]')) { Pop.close(false); openRelease(-1, $('#chSprint'), 'backlog'); return; }
@@ -119,8 +119,8 @@ function materialChips() {
119
119
  + N.files.map((f, i) => `<span class="bd-chip sm">${SV(I.file)}${esc(f.name)}<button type="button" class="bd-x0" data-rmfile="${i}" aria-label="Remove ${esc(f.name)}">${SV(I.x)}</button></span>`).join('');
120
120
  }
121
121
  function kindBox() {
122
- const lean = N.lean ? cap(N.lean) : null;
123
- return `<b>Kind of work · PMOS works it out</b><span>No need to choose now. It starts in ${esc(firstStage())}, and PMOS names the kind (feature, discovery, chore and so on) once the BRD or the first research makes it clear. It tells you in New for you, and you can change it.</span><span class="bd-amut">Now: ${lean ? 'not sure yet · leaning ' + esc(lean) + ', from the words of the name' : 'not sure yet'}</span>`;
122
+ // D99: Kind becomes Workflow. Every workflow starts in Triage, and PMOS names the workflow from the BRD (WfTriage)
123
+ return `<b>Workflow · PMOS works it out</b><span>No need to choose now. It starts in ${esc(firstStage())}, and PMOS names the workflow (Product feature, or one you made) once the BRD makes it clear. It tells you why, and you can change it.</span><span class="bd-amut">Now: Product feature, until the BRD says otherwise</span>`;
124
124
  }
125
125
  function hintsHtml() {
126
126
  const p = N.prior && N.prior[0] && !N.ack ? `<div class="bd-warn"><b>Close to something you declined</b><span>“${esc(N.prior[0].title)}” was set aside in ${esc(N.prior[0].file)}.</span><div class="bd-arow"><button type="button" class="bd-btn sm" data-newact="seewhy">See why</button><button type="button" class="bd-btn sm ghost" data-newact="ack">It is different</button></div></div>` : '';
@@ -10,8 +10,10 @@
10
10
  * that event through pm/bd-prog.js openProgram, the one path that opens it.
11
11
  *
12
12
  * What it shows, each part only when a record holds something for it:
13
- * · the shell's header: the program icon, "title · goal" once, Discuss in chat (the question goes to Home), ⋯ and Close. ⋯ holds, in the
14
- * shell's order: add an initiative, move one in, the charter, copy link, copy as text, and archive (red, last, with a confirmation)
13
+ * · the shell's header: the program icon, "title · goal" once, Discuss in chat (the question goes to Home), the charter, ⋯ and Close. ⋯
14
+ * holds, in the shell's order: add an initiative, move one in, copy link, copy as text, and archive (red, last, with a confirmation)
15
+ * · the charter (pm/program-charter.js, canvas MsB*): the one editor of the program's fields and milestones. Ways in: its icon in the
16
+ * header, the pencil on the Milestones row, and "Add the first milestone" where the track would be
15
17
  * · the summary card: the next milestone, else what waits on you; the owner and the span; one primary, "Review the suggested homes", only
16
18
  * after Turn into a program while tasks of the initiative it came from have no level yet; Claude sorts them in Home
17
19
  * · the goals: the KRs its initiatives anchor to, for one year half with a period picker; the earlier halves fold into one chip
@@ -29,11 +31,12 @@ import * as VW from './cozy-viewer.js';
29
31
  import * as Pop from './bd-pop.js';
30
32
  import { copyText } from './cozy-xv.js';
31
33
  import { programRename } from './rename-press.js';
34
+ import { openCharter as charterForm, renamed as charterRenamed } from './program-charter.js';
32
35
 
33
36
  const SV = (d, w) => `<svg viewBox="0 0 24 24" width="${w || 18}" height="${w || 18}" aria-hidden="true"><path d="${d}"/></svg>`;
34
37
  const I = {
35
38
  prog: 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5M3 17.5l9 5 9-5', ask: 'M4 5h16v11H9l-5 4z', doc: 'M7 3h7l5 5v13H7zM14 3v5h5', more: 'M5 12h.01M12 12h.01M19 12h.01',
36
- x: 'M6 6l12 12M18 6L6 18', chev: 'M7 10l5 5 5-5', chevR: 'M10 7l5 5-5 5', plus: 'M12 5v14M5 12h14', go: 'M5 12h14M13 6l6 6-6 6', out: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
39
+ x: 'M6 6l12 12M18 6L6 18', pen: 'M4 20h4L19 9l-4-4L4 16zM13.5 6.5l4 4', chev: 'M7 10l5 5 5-5', chevR: 'M10 7l5 5-5 5', plus: 'M12 5v14M5 12h14', go: 'M5 12h14M13 6l6 6-6 6', out: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6',
37
40
  };
38
41
  const FOLD_KEY = 'pmos.board.ppfold';
39
42
  const PLAN = STEPS.findIndex((s) => s.key === 'plan');
@@ -157,17 +160,18 @@ function goalsHtml(st) {
157
160
  const menu = O._perOpen ? `<div class="pp-menu pp-pmenu" role="menu" aria-label="Period">${all.slice().sort((a, b) => b.key.localeCompare(a.key)).map((h) => `<button type="button" role="menuitemradio" aria-checked="${h === on}" data-pp="per" data-per="${esc(h.label)}">${esc(h.label)} <span>${h.goals.length}</span></button>`).join('')}</div>` : '';
158
161
  return `<div class="pp-goal" role="group" aria-label="Goals: the KRs its initiatives anchor to">${pick}${on.goals.map(chip).join('')}${early}${menu}</div>`;
159
162
  }
160
- /** The readiness dots of a milestone: one per initiative it waits on, filled when that one is past Deliver. */
163
+ /** The readiness dots of a milestone: one per initiative it waits on, filled when that one is past its own ◆ stage (D99). */
161
164
  const rdHtml = (m) => (m.n ? `<span class="pp-rd" role="img" aria-label="${m.ready} of ${m.n} ${plural(m.n, 'initiative', 'initiatives')} ready">${Array.from({ length: m.n }, (_, j) => `<i${j < m.ready ? ' class="on"' : ''}></i>`).join('')}</span>` : '');
162
165
  const waitsLine = (m) => (m.check ? 'A program check, no initiative to wait on' : 'Waits on ' + m.titles.join(' and '));
163
166
  function trackHtml(st) {
164
- if (!st.milestones.length) return '';
167
+ // no milestone yet: one dashed way into the charter, at Milestones (canvas MsEmpty)
168
+ if (!st.milestones.length) return `<div class="pp-sec"><p class="lbl">Program milestones</p><button type="button" class="pp-first" data-pp="first"><span class="gd" aria-hidden="true"></span>Add the first milestone</button></div>`;
165
169
  const T = milestoneTrack(st, 3), n = Math.max(1, T.shown.length);
166
170
  const lastDone = T.shown.map((m) => m.done).lastIndexOf(true);
167
171
  // the filled line runs to halfway between the last done milestone in view and the next one; with none in view, to the done cluster
168
172
  const f = T.shown.length && lastDone === T.shown.length - 1 ? lastDone + 0.5 : lastDone >= 0 ? lastDone + 1 : T.done.length ? 0 : -1;
169
173
  const cl = (L, done) => (L.length ? `<button type="button" class="pp-cap${done ? ' dn' : ''}" data-pp="ms" aria-label="${L.length} ${done ? 'earlier ' + plural(L.length, 'milestone', 'milestones') + ', done' : 'later ' + plural(L.length, 'milestone', 'milestones')}. Show all milestones"><span class="st3" aria-hidden="true">${L.slice(0, 3).map(() => '<i></i>').join('')}</span>${L.length} ${done ? 'done' : 'more'}</button>` : '<span></span>');
170
- const one = (m) => `<div class="pp-m${m.late ? ' late' : ''}" title="${esc(waitsLine(m))}${m.check ? '' : ' reaching Deliver'}"><span class="pp-dm${m.done ? ' d' : st.next && m.id === st.next.id ? ' n' : ''}" aria-hidden="true"></span><b>${esc(m.name)}</b><span class="pp-md">${esc(m.day)}${m.done ? '' : rdHtml(m)}</span></div>`;
174
+ const one = (m) => `<div class="pp-m${m.late ? ' late' : ''}" title="${esc(waitsLine(m))}${m.check ? '' : ' reaching ' + (m.reach || 'its ◆ stage')}"><span class="pp-dm${m.done ? ' d' : st.next && m.id === st.next.id ? ' n' : ''}" aria-hidden="true"></span><b>${esc(m.name)}</b><span class="pp-md">${esc(m.day)}${m.done ? '' : rdHtml(m)}</span></div>`;
171
175
  return `<div class="pp-sec"><p class="lbl">Program milestones</p><div class="pp-mt" style="--pp-n:${n};--pp-f:${f}"${f < 0 ? ' data-nofill' : ''}>${cl(T.done, true)}${T.shown.map(one).join('')}${cl(T.more, false)}</div></div>`;
172
176
  }
173
177
  /** What waits on you in the program: your open program tasks, then each initiative's next action that is yours. Each opens in Home. */
@@ -269,13 +273,24 @@ function docsHtml(p, st) {
269
273
  + D.map((d) => `<button type="button" class="pp-nd pp-doc" role="listitem" data-doc="${esc(d.path)}" title="${esc(d.path)}">${SV(I.doc, 15)}<span class="x">${esc(d.name)}</span><span class="r">${esc(d.ini)}</span></button>`).join('')
270
274
  + (D.length ? '' : '<div class="pp-nd q"><span class="x">No PRD, rubric or release notes of its initiatives on this board yet</span></div>') + '</div>';
271
275
  }
272
- /** The charter in the Viewer, as a drill-in: ← comes back to the program. Why, goal, owner, span and the Jira key, as the record holds them. */
273
- function openCharter(p) {
276
+ /** An initiative's title from any board the panel has read (this one, then the other products'), for a charter row that names it. */
277
+ function nameOf(id) {
278
+ const all = [rowsOf(board().ws)].concat([...AWAY.values()].filter((a) => a && a !== 'reading'));
279
+ for (const g of all) { const r = g && (g.rows || []).find((x) => x.id === id); if (r) return r.title || id; }
280
+ return '';
281
+ }
282
+ /** The charter (canvas MsBCharter): the one editor of the program's fields and milestones, a drill-in, so ← comes back to the program.
283
+ * at 'milestones': it opens at Milestones (the pencil on the Milestones row, "Add the first milestone", MsB0Entry, MsEmpty). */
284
+ function openCharter(p, at) {
274
285
  const st = programState(p, rowsOf);
275
- VW.open({ kind: 'Charter', title: p.title, icon: 'doc', id: 'charter:' + p.id, back: true, render: (body) => {
276
- const rows = [['Goal', p.goal], ['Why', p.why], ['Owner', p.owner], ['Span', st.span.label], ['Products', st.products.join(', ')], ['Jira', p.jira]].filter(([, v]) => v);
277
- body.innerHTML = rows.length ? `<dl class="pp-cdl">${rows.map(([k, v]) => `<dt>${esc(k)}</dt><dd>${esc(v)}</dd>`).join('')}</dl>` : '<p class="bd-amut">The charter holds only the program\'s name so far.</p>';
286
+ // the name is the agreed rename press (MsB4Rename): it saves at once, as on the program, and the form keeps the new name
287
+ const rename = programRename({ pmPost, program: p, onSaved: async (o) => {
288
+ charterRenamed(p.id, o.title); await O.reload(); VW.retitle('charter:' + p.id, titleOf(progOf(p.id) || { ...p, title: o.title }));
289
+ O.say('Renamed', async () => { const u = await o.undo(); if (!u.ok) { O.say(u.error); return; } charterRenamed(p.id, o.from); await O.reload(); VW.retitle('charter:' + p.id, titleOf(progOf(p.id) || p)); });
278
290
  } });
291
+ rename.save = ((save) => async (title, x) => { const r = await save(title, x); if (!r.ok) return r; p.title = r.title; rename.value = r.title; return { ...r, title: titleOf(p) }; })(rename.save);
292
+ rename.value = p.title;
293
+ charterForm({ VW, pmPost, p, st, rename, title: titleOf(p), nameOf, at, reload: () => O.reload(), say: (m) => O.say(m) });
279
294
  }
280
295
 
281
296
  /* ── the shell: summary first, then the folding rows ── */
@@ -289,7 +304,7 @@ function summaryOf(p, st) {
289
304
  const next = nx ? 'Next: ' + nx.name + (nx.day ? ' · ' + nx.day : '') : '';
290
305
  // The Waits on you row already counts what waits on you (say it once), so the line is the next milestone while there is one.
291
306
  if (!nx && N.length) return { line: N.length + ' ' + plural(N.length, 'waits', 'wait') + ' on you', tone: 'you', text: sortText, meta, primary };
292
- if (nx) return { line: next, tone: nx.late ? 'warn' : '', text: sortText || waitsLine(nx) + (nx.check ? '.' : ' reaching Deliver.'), meta, primary };
307
+ if (nx) return { line: next, tone: nx.late ? 'warn' : '', text: sortText || waitsLine(nx) + (nx.check ? '.' : ' reaching ' + (nx.reach || 'its ◆ stage') + '.'), meta, primary };
293
308
  return { line: '', text: sortText, meta, primary };
294
309
  }
295
310
  function needsList(p, st) {
@@ -306,7 +321,8 @@ function bodyHtml(p) {
306
321
  L.length ? { id: 'itasks', title: 'On its initiatives', count: L.length, render: () => levelHtml(p, L, 'Tasks on its initiatives') } : null,
307
322
  E.length ? { id: 'etasks', title: 'On their epics', count: E.length, render: () => levelHtml(p, E, 'Tasks on their epics') } : null,
308
323
  st.inis.length || st.missing.length ? { id: 'tree', title: 'Initiatives', count: st.inis.length + st.missing.length, open: true, render: () => treeHtml(p, st) } : null,
309
- st.milestones.length ? { id: 'ms', title: 'Milestones', count: st.milestones.length, render: () => msHtml(st) } : null,
324
+ st.milestones.length ? { id: 'ms', title: 'Milestones', count: st.milestones.length, render: () => msHtml(st),
325
+ tail: `<button type="button" class="cz-vw-ib" data-pp="edit" aria-label="Edit the milestones in the charter" title="Edit in the charter">${SV(I.pen, 15)}</button>` } : null,
310
326
  { id: 'docs', title: 'Documents', count: D.length + 1, render: () => docsHtml(p, st) },
311
327
  ];
312
328
  return VW.czSummary(summaryOf(p, st)) + goalsHtml(st) + trackHtml(st) + VW.czSections(rows, { key: 'program' });
@@ -332,7 +348,6 @@ function moreOf(p) {
332
348
  const more = [{ label: 'Add a new initiative', on: () => { VW.close(); const n = document.getElementById('newIni'); if (n) n.click(); } }];
333
349
  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' }) });
334
350
  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(); } });
335
- more.push({ sep: true }, { label: 'Open the charter', on: () => openCharter(p) });
336
351
  more.push({ sep: true }, { label: 'Copy link', on: () => copyText(new URL('/premium-board.html?' + (p.home ? 'ws=' + encodeURIComponent(p.home) + '&' : '') + 'program=' + encodeURIComponent(p.id), location.href).href, 'Link copied.') },
337
352
  { label: 'Copy as text', on: () => copyText(textOf(p), 'Copied as text.') });
338
353
  more.push({ sep: true }, { label: 'Archive the program', danger: true, on: (b) => Pop.open(`<p class="bd-mlbl">Archive ${esc(p.title)}?</p><div class="bd-ppb"><p class="bd-amut">Its initiatives stay where they are.</p><div class="bd-arow"><button type="button" class="bd-btn sm solid" data-pparch="1">Archive</button><button type="button" class="bd-btn sm ghost" data-pparch="0">Not now</button></div></div>`, b, { label: 'Archive the program', width: 280, align: 'right', focus: '[data-pparch="1"]' }) });
@@ -360,7 +375,10 @@ function openPanel(id, from) {
360
375
  rename.value = p.title;
361
376
  VW.open({ kind: 'Program', title: titleOf(p), icon: I.prog, id: 'program:' + id,
362
377
  discuss: true, more: moreOf(p), rename,
378
+ // the charter's icon beside Discuss (canvas MsB0Entry): the one way to its fields, so ⋯ no longer repeats it
379
+ presses: [{ act: 'charter', label: 'Open the charter', icon: 'doc' }], onPress: (a) => { const q = progOf(id); if (a === 'charter' && q) openCharter(q); },
363
380
  render: (body) => {
381
+ { const q = progOf(id); if (q && VW.current() && VW.current().title !== titleOf(q)) VW.retitle('program:' + id, titleOf(q)); } // a rename in the charter, on ←
364
382
  cur = { id, from: from && !(VW.body() && VW.body().contains(from)) ? from : (cur && cur.id === id && cur.from) || null };
365
383
  body.classList.add('pp-vw');
366
384
  const q = progOf(id); if (q) { readAway(q); readMore(q); body.innerHTML = bodyHtml(q); }
@@ -391,6 +409,7 @@ async function press(b) {
391
409
  else if (a === 'ini') { const id = b.dataset.ini, from = document.querySelector(`#ibBody [data-prog="${CSS.escape(p.id)}"]`); if (O.drill) VW.drill(); else VW.close(); O.openIni(id, from); }
392
410
  else if (a === 'add') { adding = true; draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); }
393
411
  else if (a === 'charter') openCharter(p);
412
+ else if (a === 'edit' || a === 'first') openCharter(p, 'milestones');
394
413
  else if (a === 'done') {
395
414
  const r = await pmPost('/api/programs/task-done', { ws: b.dataset.ws || p.home || board().ws || null, program: p.id, key: b.dataset.key, done: b.dataset.done === '1' });
396
415
  if (!r || !r.ok) { O.say((r && r.error) || 'Not marked. The server did not say why.'); return; }
@@ -97,12 +97,19 @@ export function mergeBoards(list) {
97
97
  initiatives: { ...I, open: n('open'), on: n('on'), risk: n('risk'), late: n('late'), hold: n('hold'), total: n('total'), cap: null, note: '', list: { rows: list2, total: list2.length }, gone, stages: [], timeline: I.timeline },
98
98
  sprint: null, release: null, docs: { cap: '', rows: docs, counts: { all: docs.length, none: 0, draft: 0, ok: 0 }, scope: null, missing: list.some((b) => b.model.docs && b.model.docs.missing) },
99
99
  steps: steps.map((st, i) => ({ ...st, count: sum((m) => m.steps && m.steps[i] && m.steps[i].count) })),
100
+ workflows: mergeWorkflows(list.map((b) => b.model.workflows || [])),
100
101
  jira: { ...(home.jira || {}), readAt, sprint: null, release: null, sprints: [], backlog: [] },
101
102
  chips: { late: C('late'), risk: C('risk'), blocked: C('blocked'), idle: C('idle'), asks: asksRead ? asks.length : null },
102
103
  asks: asksRead ? { rows: asks } : null,
103
104
  rows,
104
105
  };
105
106
  }
107
+ /** Every product's workflows as one list (All products, D99): the counts add up, Product feature first, then by count. */
108
+ function mergeWorkflows(lists) {
109
+ const by = new Map();
110
+ for (const L of lists) for (const w of L) { const x = by.get(w.id) || { ...w, count: 0 }; x.count += Number(w.count) || 0; by.set(w.id, x); }
111
+ return [...by.values()].sort((a, b) => (b.id === 'product-feature') - (a.id === 'product-feature') || b.count - a.count || String(a.name).localeCompare(String(b.name)));
112
+ }
106
113
  /** The products a program spans: its members' workspaces, once each. */
107
114
  export const productsOf = (p) => new Set((p.members || []).map((m) => m.ws || '')).size;
108
115
 
@@ -131,14 +138,15 @@ const whole = (st) => !st.missing.length;
131
138
  /** The open milestones in date order: the next merged with the ones close to it (PgKanban "Pilot live +2 · Nov 18–21"). */
132
139
  export const nextCluster = (st) => mergeClose((st.milestones || []).filter((m) => !m.done), 7)[0] || null;
133
140
 
134
- /** The stage track's program row (PgBoard .pg). g: the program group; o: { steps, rows (this board's rows in it) }. */
141
+ /** The stage track's program row (PgBoard .pg). g: the program group; o: { steps, rows (this board's rows in it), plain }. */
135
142
  export function bandHtml(g, st, o) {
136
143
  const p = g.program, steps = o.steps || [], open = !folded(g.key);
137
144
  const n = productsOf(p);
138
- const sp = st.spread, nI = st.inis.length;
145
+ // o.plain: the track draws categories or another workflow's stages, so the spread across the eight steps is not drawn, only the count
146
+ const sp = o.plain ? null : st.spread, nI = st.inis.length;
139
147
  const N = steps.length || 8, pc = (n) => ((n / N) * 100).toFixed(3) + '%'; // a step's share of the cells, so the band follows their width
140
148
  const band = sp ? `<span class="bd-spb" style="left:calc(${pc(sp.lo)} + 4px);width:calc(${pc(sp.hi - sp.lo + 1)} - 8px)"></span>` : '';
141
- const words = sp ? nI + ' ' + plural(nI, 'initiative', 'initiatives') + ', ' + (sp.from === sp.to ? sp.from : sp.from + ' to ' + sp.to) : 'No stage on record';
149
+ const words = sp ? nI + ' ' + plural(nI, 'initiative', 'initiatives') + ', ' + (sp.from === sp.to ? sp.from : sp.from + ' to ' + sp.to) : o.plain && nI ? nI + ' ' + plural(nI, 'initiative', 'initiatives') : 'No stage on record';
142
150
  // the words sit right of the band, else left of it, else inside it when the band spans nearly every step
143
151
  const lab = !sp || sp.hi < N - 3 ? `<span class="bd-spl" style="left:calc(${pc(sp ? sp.hi + 1 : 0)} + 8px)">${esc(words)}</span>`
144
152
  : sp.lo >= 3 ? `<span class="bd-spl" style="right:calc(${pc(N - sp.lo)} + 8px)">${esc(words)}</span>` : `<span class="bd-spl" style="left:calc(${pc(sp.lo)} + 14px)">${esc(words)}</span>`;