create-pmos 0.400.0 → 0.402.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 (57) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +226 -0
  8. package/workspace/board-shot.js +54 -0
  9. package/workspace/briefing-premium-board-test.js +23 -16
  10. package/workspace/briefing-premium-calendar-test.js +6 -3
  11. package/workspace/briefing-premium-sources-test.js +17 -10
  12. package/workspace/briefing-premium-test.js +41 -16
  13. package/workspace/changelog.json +24 -0
  14. package/workspace/fixtures/board-premium-facts.js +20 -3
  15. package/workspace/fixtures/briefing-premium-facts.js +18 -2
  16. package/workspace/fixtures/program-ascent.js +101 -0
  17. package/workspace/guide/home.md +15 -8
  18. package/workspace/guide/index.md +1 -0
  19. package/workspace/guide/programs.md +37 -0
  20. package/workspace/lib/briefing-premium-products.js +4 -4
  21. package/workspace/lib/briefing-premium.js +2 -2
  22. package/workspace/lib/core-docs.js +2 -2
  23. package/workspace/lib/programs.js +129 -0
  24. package/workspace/lib/route-modules.js +1 -0
  25. package/workspace/lib/routes-briefing-premium.js +1 -1
  26. package/workspace/lib/routes-programs.js +122 -0
  27. package/workspace/package-lock.json +2 -2
  28. package/workspace/package.json +1 -1
  29. package/workspace/premium-board-actions-test.js +1 -1
  30. package/workspace/premium-phone-card-test.js +6 -1
  31. package/workspace/premium-vw-cal-test.js +10 -4
  32. package/workspace/program-panel-test.js +143 -0
  33. package/workspace/public/pm/bd-acts.js +23 -14
  34. package/workspace/public/pm/bd-asks.js +89 -23
  35. package/workspace/public/pm/bd-prog-panel.js +451 -0
  36. package/workspace/public/pm/bd-prog.js +191 -0
  37. package/workspace/public/pm/bd-span.js +98 -15
  38. package/workspace/public/pm/bd-views.js +93 -29
  39. package/workspace/public/pm/cozy-board.css +226 -9
  40. package/workspace/public/pm/cozy-home.css +27 -1
  41. package/workspace/public/pm/cozy-panel.css +178 -0
  42. package/workspace/public/pm/cozy-today.css +190 -3
  43. package/workspace/public/pm/home-app.js +93 -26
  44. package/workspace/public/pm/home-chat.js +35 -32
  45. package/workspace/public/pm/home-data.js +8 -2
  46. package/workspace/public/pm/home-ini.js +1 -1
  47. package/workspace/public/pm/home-list.js +100 -24
  48. package/workspace/public/pm/home-today.js +138 -61
  49. package/workspace/public/pm/home-work.js +1 -3
  50. package/workspace/public/pm/premium-board.js +225 -57
  51. package/workspace/public/pm/premium-vw-item.css +6 -0
  52. package/workspace/public/pm/program-model.js +192 -0
  53. package/workspace/public/premium-board.html +4 -1
  54. package/workspace/test-files.json +1 -0
  55. package/workspace/test-lists/board-programs.json +9 -0
  56. package/workspace/test-lists/program-hierarchy.json +11 -0
  57. package/workspace/test-lists/program-panel.json +9 -0
@@ -0,0 +1,129 @@
1
+ 'use strict';
2
+ /* lib/programs.js — programs: the level above initiatives, across products (initiative program-hierarchy, P1).
3
+ *
4
+ * fold(lines) → { [id]: program } PURE. The program records of ONE workspace's ledger
5
+ * merge(perWs) → [program] PURE. perWs: [{ ws, lines }]; the same program id in two workspaces is one program
6
+ * program: { id, title, owner, goal, why, start, target, jira, from, milestones, members, tasks, home }
7
+ * validProgram(b) · validMilestone(m) what a write accepts, or { error }
8
+ *
9
+ * WHERE A PROGRAM LIVES. A program spans products, and a product is a workspace with its own state folder. So there is no one folder a
10
+ * program "belongs" to: each workspace's <state>/programs.jsonl holds the program lines written FROM that workspace — the charter where the
11
+ * program was made, and a `member` line beside each initiative that joins it, in that initiative's own workspace. Reading merges every
12
+ * registered workspace's ledger by program id. The program is a PMOS record (PM, 2026-10-23): most teams' Jira has no Program level, so
13
+ * `jira` is an optional key that is only read, never written to Jira.
14
+ *
15
+ * A LINE is one of:
16
+ * { kind: 'program', id, title, owner?, goal?, start?, target?, jira?, from?, milestones?: [{ id, name, date?, waits: [initiative id], done? }] } the last wins
17
+ * `from`: the initiative a turned program came from ("Turn into a program"), in the charter's workspace
18
+ * { kind: 'check', program, milestone, done: true|false } the PM marks a program check done (canvas PgMilestones); the last line wins
19
+ * { kind: 'member', program, initiative } the initiative (of the workspace whose ledger holds the line) joins the program
20
+ * { kind: 'leave', program, initiative }
21
+ * { kind: 'task', program, key, title, owner?, due? } a task on the program itself; the last line for a key wins
22
+ * { kind: 'task-done', program, key, done: true|false }
23
+ * { kind: 'archive', program }
24
+ * A PROGRAM'S SPAN is `start` to `target` (canvas PgProgram, "Sep 2026 to Jun 2028"): a program can run for years, longer than any one
25
+ * initiative. A MILESTONE waits on initiatives (it is ready when they pass ◆ Deliver, derived on the page), or on none: then it is "a program
26
+ * check" (canvas PgMilestones) and its `done` is the PM's own mark, a `check` line. A milestone that waits on initiatives carries no `done`.
27
+ * Nothing about a program is typed that its initiatives already say: its products, its state and its stage spread are derived on the page
28
+ * (public/pm/program-model.js), from the initiatives' own rows. */
29
+
30
+ const ID_RE = /^[a-z0-9][a-z0-9-]{0,60}$/;
31
+ const INI_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/;
32
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
33
+ const str = (v, n) => String(v == null ? '' : v).replace(/[\u0000-\u001f]+/g, ' ').trim().slice(0, n);
34
+
35
+ /** A program id from a title: "Project Ascent" → "project-ascent". */
36
+ const slug = (t) => String(t || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60);
37
+
38
+ function validMilestone(m, i) {
39
+ if (!m || typeof m !== 'object') return { error: 'a milestone is { name, date?, waits }' };
40
+ const name = str(m.name, 80);
41
+ if (!name) return { error: 'name the milestone' };
42
+ if (m.date && !DAY_RE.test(String(m.date))) return { error: 'a milestone date is YYYY-MM-DD' };
43
+ const waits = (Array.isArray(m.waits) ? m.waits : []).map(String).filter((x) => INI_RE.test(x)).slice(0, 20);
44
+ const out = { id: ID_RE.test(String(m.id || '')) ? String(m.id) : 'm' + (i + 1), name, date: m.date || '', waits };
45
+ if (!waits.length) out.done = m.done === true; // a program check: the PM marks it done; a milestone with initiatives is done when they are
46
+ return out;
47
+ }
48
+
49
+ function validProgram(b) {
50
+ const title = str(b && b.title, 120);
51
+ if (!title) return { error: 'name the program' };
52
+ const id = ID_RE.test(String((b && b.id) || '')) ? String(b.id) : slug(title);
53
+ if (!ID_RE.test(id)) return { error: 'the program needs a name made of letters or numbers' };
54
+ if (b.target && !DAY_RE.test(String(b.target))) return { error: 'the target date is YYYY-MM-DD' };
55
+ if (b.start && !DAY_RE.test(String(b.start))) return { error: 'the start date is YYYY-MM-DD' };
56
+ if (b.start && b.target && String(b.start) > String(b.target)) return { error: 'the start date is after the target date' };
57
+ const milestones = [];
58
+ for (const [i, m] of (Array.isArray(b.milestones) ? b.milestones : []).slice(0, 12).entries()) {
59
+ const v = validMilestone(m, i);
60
+ if (v.error) return v;
61
+ if (milestones.some((x) => x.id === v.id)) return { error: 'two milestones have the id ' + v.id };
62
+ milestones.push(v);
63
+ }
64
+ return { kind: 'program', id, title, owner: str(b.owner, 80), goal: str(b.goal, 160), why: str(b.why, 600), start: b.start || '', target: b.target || '', jira: str(b.jira, 40), milestones };
65
+ }
66
+
67
+ const blank = (id) => ({ id, title: id, owner: '', goal: '', why: '', start: '', target: '', jira: '', from: '', milestones: [], members: [], tasks: [], archived: false, at: '' });
68
+
69
+ /** A program check's done mark from the `check` lines (the last line for a milestone wins) over the charter's own `done`. */
70
+ const withChecks = (milestones, checks) => (milestones || []).map((m) => {
71
+ const waits = Array.isArray(m.waits) ? m.waits : [];
72
+ if (waits.length) { const out = { ...m }; delete out.done; return out; }
73
+ return { ...m, waits, done: checks && Object.prototype.hasOwnProperty.call(checks, m.id) ? !!checks[m.id] : m.done === true };
74
+ });
75
+
76
+ /** The programs one workspace's ledger says, members carrying no workspace yet (merge adds it). `checks` holds the check lines, by milestone id. */
77
+ function fold(lines) {
78
+ const out = {};
79
+ const get = (id) => out[id] || (out[id] = { ...blank(id), charter: false, checks: {} });
80
+ for (const l of lines || []) {
81
+ if (!l || typeof l !== 'object') continue;
82
+ if (l.kind === 'program' && ID_RE.test(String(l.id || ''))) {
83
+ const p = get(l.id);
84
+ Object.assign(p, { title: l.title || p.title, owner: l.owner || '', goal: l.goal || '', why: l.why || '', start: l.start || '', target: l.target || '', jira: l.jira || '',
85
+ from: INI_RE.test(String(l.from || '')) ? String(l.from) : p.from || '', milestones: Array.isArray(l.milestones) ? l.milestones : [], charter: true, at: p.at || l.at || '' });
86
+ continue;
87
+ }
88
+ const pid = String(l.program || '');
89
+ if (!ID_RE.test(pid)) continue;
90
+ const p = get(pid);
91
+ if (l.kind === 'member' || l.kind === 'leave') {
92
+ if (!INI_RE.test(String(l.initiative || ''))) continue;
93
+ p.members = p.members.filter((x) => x !== l.initiative);
94
+ if (l.kind === 'member') p.members.push(String(l.initiative));
95
+ } else if (l.kind === 'task' && l.key && l.title) {
96
+ const t = { key: String(l.key), title: String(l.title), owner: l.owner || '', due: l.due || '', done: false };
97
+ const i = p.tasks.findIndex((x) => x.key === t.key);
98
+ if (i >= 0) p.tasks[i] = { ...t, done: p.tasks[i].done }; else p.tasks.push(t);
99
+ } else if (l.kind === 'task-done') {
100
+ const t = p.tasks.find((x) => x.key === String(l.key));
101
+ if (t) t.done = !!l.done;
102
+ } else if (l.kind === 'check' && ID_RE.test(String(l.milestone || ''))) p.checks[String(l.milestone)] = !!l.done;
103
+ else if (l.kind === 'archive') p.archived = true;
104
+ }
105
+ for (const p of Object.values(out)) p.milestones = withChecks(p.milestones, p.checks);
106
+ return out;
107
+ }
108
+
109
+ /** perWs: [{ ws, lines }] → the programs, each with members [{ ws, initiative }] and the workspace its charter is in (home). */
110
+ function merge(perWs) {
111
+ const all = {};
112
+ for (const { ws, lines } of perWs || []) {
113
+ const one = fold(lines);
114
+ for (const p of Object.values(one)) {
115
+ const m = all[p.id] || (all[p.id] = { ...blank(p.id), home: '', checks: {} });
116
+ if (p.charter) Object.assign(m, { title: p.title, owner: p.owner, goal: p.goal, why: p.why, start: p.start, target: p.target, jira: p.jira, from: p.from, milestones: p.milestones, home: ws, at: p.at });
117
+ Object.assign(m.checks, p.checks);
118
+ for (const ini of p.members) if (!m.members.some((x) => x.ws === ws && x.initiative === ini)) m.members.push({ ws, initiative: ini });
119
+ for (const t of p.tasks) m.tasks.push({ ...t, ws });
120
+ if (p.archived) m.archived = true;
121
+ }
122
+ }
123
+ // the check lines of every workspace apply to the charter's milestones (the route writes them to the charter's workspace)
124
+ for (const m of Object.values(all)) { m.milestones = withChecks(m.milestones, m.checks); delete m.checks; }
125
+ // a program with no charter anywhere is a member line whose program was never made: it is not shown
126
+ return Object.values(all).filter((p) => p.home && !p.archived).sort((a, b) => String(a.title).localeCompare(String(b.title)));
127
+ }
128
+
129
+ module.exports = { fold, merge, validProgram, validMilestone, slug, ID_RE, INI_RE };
@@ -56,6 +56,7 @@ const MODULES = Object.freeze([
56
56
  'routes-home-review', // premium-uncovered-features (Home): the weekly review's four steps and the untouched work looked at (page press; file mode)
57
57
  'routes-initiative-premium', // briefing-premium-initiative: the premium initiative page's model from the Initiatives sheet's own routes (read-only)
58
58
  'routes-initiative-layout', // premium-uncovered-features (Initiative): Moves on by itself, held stages, task groups and saved group sets (page press; file mode)
59
+ 'routes-programs', // program-hierarchy: programs above initiatives across products, their members, tasks and milestones (page press; file mode)
59
60
  'routes-brief-page', // console3 Briefing as the brief: Today agenda, Needs you and Mentions (read-only; writes go through routes-pm-items)
60
61
  'routes-mentions', // console3 Briefing Mentions: the PM's read marks (page press only)
61
62
  'routes-inbox', // premium-agent-inbox: the bell's agent results and the PM's seen marks (page press only)
@@ -34,7 +34,7 @@ const settings = require('./settings-store.js');
34
34
  /** The workspaces the Briefing may read right now (initiative briefing-premium-products): choose()'s list, from the server's workspace list and the PM's setting. */
35
35
  function products(ctx, only) {
36
36
  const home = ctx.homeRoot || ctx.selfRoot || null;
37
- const list = (typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : []).map((w) => ({ id: w.id, name: w.label || w.name, root: w.root, home: !!home && path.resolve(w.root) === path.resolve(home) }));
37
+ const list = (typeof ctx.workspaceList === 'function' ? ctx.workspaceList() : []).map((w) => ({ id: w.id, name: w.label || w.name, root: w.root, initials: w.initials, home: !!home && path.resolve(w.root) === path.resolve(home) }));
38
38
  return Prod.choose({ workspaces: list, include: settings.get(ctx.runtimeDir, 'ws.briefing.include', null), only });
39
39
  }
40
40
  /** The included product a merged row (or a returned run) belongs to: { root, ws } | { error }. null when the key is the one-workspace page's. */
@@ -0,0 +1,122 @@
1
+ 'use strict';
2
+ /* routes-programs.js — programs, the level above initiatives across products (initiative program-hierarchy, P1 and P7).
3
+ *
4
+ * GET /api/programs → { ok, programs: [program] } merged from every registered workspace (lib/programs.js merge)
5
+ * POST /api/programs/save { ws, program } the charter: title, owner, goal, why, start, target, jira, milestones (the last save wins)
6
+ * POST /api/programs/member { ws, program, initiative, leave? } an initiative of workspace `ws` joins (or leaves) the program
7
+ * POST /api/programs/turn { ws, initiative, title? } "Turn into a program": a charter named after the initiative, which joins it; the
8
+ * charter keeps `from` (the initiative), so the panel can count its tasks with no level
9
+ * POST /api/programs/task { ws, program, title, owner?, due?, key? } a task on the program itself
10
+ * POST /api/programs/task-done { ws, program, key, done }
11
+ * POST /api/programs/check { program, milestone, done } the PM marks a program check (a milestone that waits on no initiative) done or
12
+ * not; the line goes to the workspace the charter is in, whatever `ws` says
13
+ * POST /api/programs/archive { ws, program }
14
+ *
15
+ * FILE MODE ONLY (D64/D66): <state>/programs.jsonl of the workspace named by `ws`, append-only. Every POST is a page press (pm-guard
16
+ * requirePagePress): an agent session cannot make, join or archive a program. Nothing here writes to Jira. */
17
+ const path = require('path');
18
+ const guard = require('./pm-guard.js');
19
+ const pmItems = require('./pm-items.js');
20
+ const P = require('./programs.js');
21
+
22
+ const str = (v, n) => String(v == null ? '' : v).replace(/[\u0000-\u001f]+/g, ' ').trim().slice(0, n);
23
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
24
+
25
+ function stateDir(ctx, w) {
26
+ let d = null;
27
+ try { d = ctx.stateDirFor ? ctx.stateDirFor(w, { create: true }) : null; } catch { d = null; }
28
+ return d || (w && w.root ? path.join(w.root, 'pmos', 'state') : null);
29
+ }
30
+ const fileOf = (ctx, w) => { const d = stateDir(ctx, w); return d ? path.join(d, 'programs.jsonl') : null; };
31
+ const read = (f) => { try { return f ? pmItems.readLines(f).filter(Boolean) : []; } catch { return []; } };
32
+
33
+ /** Every registered workspace's ledger, merged. */
34
+ function all(ctx) {
35
+ const list = (ctx.workspaceList ? ctx.workspaceList() : []) || [];
36
+ return P.merge(list.map((w) => ({ ws: w.id, lines: read(fileOf(ctx, w)) })));
37
+ }
38
+
39
+ module.exports = {
40
+ prefixes: ['/api/programs'],
41
+ all,
42
+ handle: async (req, res, url, ctx) => {
43
+ const p = url.pathname;
44
+ const bad = (error, code) => { ctx.json(res, { ok: false, error }, code || 400); return true; };
45
+ if (p === '/api/programs') {
46
+ if (req.method !== 'GET') return bad('GET only', 405);
47
+ ctx.json(res, { ok: true, programs: all(ctx) });
48
+ return true;
49
+ }
50
+ if (req.method !== 'POST') return bad('POST only', 405);
51
+ const got = await ctx.readJson(req);
52
+ if (!got.ok) return bad('invalid JSON body');
53
+ const b = got.body || {};
54
+ const g = guard.requirePagePress(req, b);
55
+ if (!g.ok) return bad(g.error, g.status);
56
+ // a check line belongs with the charter, so every workspace's reader applies it to the same milestones
57
+ const home = p === '/api/programs/check' && P.ID_RE.test(String(b.program || '')) ? (all(ctx).find((x) => x.id === b.program) || {}).home : null;
58
+ const w = ctx.getWs ? ctx.getWs(home || b.ws || null) : null;
59
+ if (!w) return bad('that workspace is not registered', 404);
60
+ const file = fileOf(ctx, w);
61
+ if (!file) return bad('this workspace has no state folder', 409);
62
+ const now = new Date();
63
+ const add = (line) => pmItems.appendEvent(file, line, now);
64
+ const known = (id) => all(ctx).find((x) => x.id === id) || null;
65
+
66
+ if (p === '/api/programs/save' || p === '/api/programs/turn') {
67
+ let input = b.program || {};
68
+ if (p === '/api/programs/turn') {
69
+ if (!P.INI_RE.test(String(b.initiative || ''))) return bad('initiative must name an initiative');
70
+ input = { title: str(b.title, 120) || str(b.initiative, 120) };
71
+ }
72
+ const v = P.validProgram(input);
73
+ if (v.error) return bad(v.error);
74
+ if (p === '/api/programs/turn' && known(v.id)) return bad('a program with this name exists already', 409);
75
+ // a turned program names the initiative it came from: its tasks from before the split wait for a level (canvas PgProgram, the sort card)
76
+ add(p === '/api/programs/turn' ? { ...v, from: String(b.initiative) } : v);
77
+ if (p === '/api/programs/turn') add({ kind: 'member', program: v.id, initiative: String(b.initiative) });
78
+ ctx.json(res, { ok: true, program: known(v.id) });
79
+ return true;
80
+ }
81
+ const pid = String(b.program || '');
82
+ if (!P.ID_RE.test(pid)) return bad('program must name a program');
83
+ if (!known(pid)) return bad('no such program', 404);
84
+ if (p === '/api/programs/member') {
85
+ if (!P.INI_RE.test(String(b.initiative || ''))) return bad('initiative must name an initiative');
86
+ // an initiative is in one program at most: joining one leaves any other it is in, in this workspace
87
+ if (!b.leave) for (const o of all(ctx)) if (o.id !== pid && o.members.some((m) => m.ws === w.id && m.initiative === b.initiative)) add({ kind: 'leave', program: o.id, initiative: String(b.initiative) });
88
+ add({ kind: b.leave ? 'leave' : 'member', program: pid, initiative: String(b.initiative) });
89
+ ctx.json(res, { ok: true, program: known(pid) });
90
+ return true;
91
+ }
92
+ if (p === '/api/programs/task') {
93
+ const title = str(b.title, 200);
94
+ if (!title) return bad('the task has no text');
95
+ if (b.due && !DAY_RE.test(String(b.due))) return bad('due is YYYY-MM-DD');
96
+ const key = /^[A-Za-z0-9._-]{1,40}$/.test(String(b.key || '')) ? String(b.key) : 'pt' + now.getTime().toString(36);
97
+ add({ kind: 'task', program: pid, key, title, owner: str(b.owner, 80), due: b.due || '' });
98
+ ctx.json(res, { ok: true, key });
99
+ return true;
100
+ }
101
+ if (p === '/api/programs/task-done') {
102
+ if (!b.key) return bad('key names the task');
103
+ add({ kind: 'task-done', program: pid, key: String(b.key), done: !!b.done });
104
+ ctx.json(res, { ok: true });
105
+ return true;
106
+ }
107
+ if (p === '/api/programs/check') {
108
+ const m = (known(pid).milestones || []).find((x) => x.id === String(b.milestone || ''));
109
+ if (!m) return bad('no such milestone', 404);
110
+ if ((m.waits || []).length) return bad('this milestone waits on initiatives: it is done when they pass Deliver', 409);
111
+ add({ kind: 'check', program: pid, milestone: m.id, done: !!b.done });
112
+ ctx.json(res, { ok: true, program: known(pid) });
113
+ return true;
114
+ }
115
+ if (p === '/api/programs/archive') {
116
+ add({ kind: 'archive', program: pid });
117
+ ctx.json(res, { ok: true });
118
+ return true;
119
+ }
120
+ return bad('no such route', 404);
121
+ },
122
+ };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.400.0",
3
+ "version": "0.402.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.400.0",
9
+ "version": "0.402.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.400.0",
3
+ "version": "0.402.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -122,7 +122,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
122
122
 
123
123
  /* N New initiative */
124
124
  ok('N1 New initiative is offered on a team board', await p.evaluate(() => !document.querySelector('#newIni').hidden));
125
- await p.click('#newIni'); await peekOn('New initiative');
125
+ await p.click('#newIni'); await p.click('#bdPop [data-newmenu="ini"]'); await peekOn('New initiative');
126
126
  await until(() => p.evaluate(() => { const s = document.querySelector('#peek select[name="anchor"]'); return s && !s.disabled; }));
127
127
  await p.fill('#peek input[name="title"]', 'Partner usage per key'); await p.click('#peek form[data-form="new2"] [type="submit"]');
128
128
  ok('N2 an unanchored create is refused on the page', await p.evaluate(() => /Choose what it counts toward/.test(document.querySelector('#formM').textContent)));
@@ -64,7 +64,12 @@ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'applicati
64
64
  return json(r, { ok: true, view: u.searchParams.get('view') || 'quarter', cells: [], gantt: [], no_plan: 0, strategy: [], today: DATE });
65
65
  });
66
66
  await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
67
- if (width < 641) await until(() => p.evaluate(() => !!document.querySelector('#hmList'))); // the card is the Today card at the top of the phone's list (canvas HmPhone)
67
+ if (width < 641) {
68
+ await until(() => p.evaluate(() => !!document.querySelector('#hmList')));
69
+ // testing fixes: the card is no longer in the phone's list. It is the greeting's detail, in the Viewer: the greeting opens it,
70
+ // and in a mode with no greeting (a meeting near or live) the hm:day event does
71
+ await p.evaluate(() => { const g = document.querySelector('#hmList [data-hm-tc="cal"]'); if (g) g.click(); else dispatchEvent(new Event('hm:day')); });
72
+ }
68
73
  p.__posts = posts; p.__gets = gets; p.__errs = errs; p.__ctx = ctx;
69
74
  if (shotDir && name) p.__shot = async (suffix) => { await sleep(700); fs.mkdirSync(shotDir, { recursive: true }); await p.screenshot({ path: path.join(shotDir, `${name}-${suffix}.png`) }); };
70
75
  return p;
@@ -57,17 +57,20 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
57
57
  ok('C2 each block is placed by custom properties set after the markup', wk.styled > 0);
58
58
  ok('C2 the legend: Linked, Not linked, and what a press does', /Linked\s*Not linked\s*Press a meeting to open its prep or notes here/.test(await p.evaluate(() => document.querySelector('#czViewer .vzc-leg').innerText.replace(/\n/g, ' '))));
59
59
 
60
- /* C3 the day */
60
+ /* C3 the day (on a Saturday or Sunday no day of the Mon–Fri strip is today, so none is pressed) */
61
+ const WEEKDAY = [1, 2, 3, 4, 5].includes(new Date().getDay());
61
62
  await tap(p, '[data-c="view"][data-k="day"]');
62
63
  await until(() => p.evaluate(() => document.querySelectorAll('#czViewer .vzc-dy').length === 5 && document.querySelectorAll('#czViewer .vzc-de').length > 0), 10000);
63
64
  const strip = await p.evaluate(() => [...document.querySelectorAll('#czViewer .vzc-dy')].map((d) => ({ dow: d.querySelector('span').textContent, on: d.getAttribute('aria-pressed') })));
64
- ok('C3 Day: Monday to Friday, today pressed, the range says "· today"', strip.map((d) => d.dow).join() === 'Mon,Tue,Wed,Thu,Fri' && strip.filter((d) => d.on === 'true').length === 1 && /· today$/.test(await p.evaluate(() => document.querySelector('#czViewer .vzc-head h2').textContent)), JSON.stringify(strip));
65
+ ok('C3 Day: Monday to Friday, today pressed, the range says "· today"', strip.map((d) => d.dow).join() === 'Mon,Tue,Wed,Thu,Fri' && (WEEKDAY ? strip.filter((d) => d.on === 'true').length === 1 && /· today$/.test(await p.evaluate(() => document.querySelector('#czViewer .vzc-head h2').textContent)) : strip.every((d) => d.on !== 'true')), JSON.stringify(strip));
65
66
  const day = await text(p);
66
67
  ok('C3 the day: its count, each entry at its time with a chip', /\d (meetings?|entries) · /.test(day) && /Viewer sync/.test(day) && await p.evaluate(() => [...document.querySelectorAll('#czViewer .vzc-de')].every((r) => r.querySelector('.vz-cc'))), day.slice(0, 400));
67
68
  ok('C3 a note recorded without an event shows Link it; a done meeting Done', /Compare meeting note apps/.test(day) && /Link it/.test(day) && /Done/.test(day));
68
69
  const other = await p.evaluate(() => { const b = [...document.querySelectorAll('#czViewer .vzc-dy')].find((d) => d.getAttribute('aria-pressed') === 'false'); b.click(); return b.dataset.k; });
69
70
  ok('C3 another day lists its own meetings', await until(async () => /1:1 with Dita/.test(await text(p))), other);
70
- await p.evaluate(() => [...document.querySelectorAll('#czViewer .vzc-dy')][[...document.querySelectorAll('#czViewer .vzc-dy')].findIndex((d) => /today/.test(d.getAttribute('aria-label')))].click());
71
+ // back to the day the view opened on: today on a weekday; on a Saturday or Sunday the page opened again, since the strip has no button for today
72
+ if (WEEKDAY) await p.evaluate(() => [...document.querySelectorAll('#czViewer .vzc-dy')][[...document.querySelectorAll('#czViewer .vzc-dy')].findIndex((d) => /today/.test(d.getAttribute('aria-label')))].click());
73
+ else { await p.reload(); await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-c="view"][data-k="day"]')), 15000); await tap(p, '[data-c="view"][data-k="day"]'); }
71
74
 
72
75
  /* C4 a meeting opens its card */
73
76
  await until(async () => /Viewer sync/.test(await text(p)));
@@ -92,8 +95,11 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
92
95
  await tap(r, '[data-c="view"][data-k="month"]');
93
96
  ok('C6 Month reads the month and draws its grid', await until(() => C.S.gets.some((g) => /view=month/.test(g))) && await until(() => r.evaluate(() => !!document.querySelector('#czViewer .vzc-mg') && /^\w+ \d{4}$/.test(document.querySelector('#czViewer .vzc-head h2').textContent))));
94
97
  const n1 = C.S.gets.filter((g) => g.startsWith('/api/calendar-views')).length;
98
+ const head = () => r.evaluate(() => document.querySelector('#czViewer .vzc-head h2').textContent);
99
+ const m0 = await head();
95
100
  await tap(r, '[data-c="nav"][data-k="1"]');
96
- await until(() => C.S.gets.filter((g) => g.startsWith('/api/calendar-views')).length > n1);
101
+ // Today is pressed once the next month is drawn: a press while the read is in flight can land on the card being replaced
102
+ await until(async () => C.S.gets.filter((g) => g.startsWith('/api/calendar-views')).length > n1 && (await head()) !== m0);
97
103
  await tap(r, '[data-c="nav"][data-k="0"]');
98
104
  ok('C6 next and Today read again', await until(() => C.S.gets.filter((g) => g.startsWith('/api/calendar-views')).length >= n0 + 3));
99
105
  await tap(r, '[data-c="view"][data-k="week"]');
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* program-panel-test.js — the program panel and the side panel's width on the Board (initiative program-hierarchy P5, P9, B1; canvas PgProgram,
4
+ * PgMilestones, XnAgBoardPanel). Serves the real page from the real server; GET /api/board-premium answers each product of Project Ascent
5
+ * (fixtures/program-ascent.js through fixtures/board-premium-facts.js programFacts), GET /api/programs its programs, and the program writes are
6
+ * captured, not written.
7
+ * P open on ?program=, the head, no chat box · G goals per half, each KR's name and whether it is met · M the track and the Milestones tab ·
8
+ * W waits on you, in Home · T the tree, another product read from its board · K every task by level, and the sort card after Turn into a
9
+ * program · F folds kept · O the Board's program row opens it, an initiative from the tree opens the Board's panel · X task done and a
10
+ * program check · B1 60 % wide, the grip · S the phone sheet. Per product the KRs (GET /api/boards/anchors), the Insights goals (GET
11
+ * /api/insights-premium) and the PMOS tasks (GET /api/boards/items) answer from fixtures/program-ascent.js. */
12
+ const path = require('path');
13
+ const { spawn } = require('child_process');
14
+ const { findBrowser } = require('./lib/find-browser');
15
+ const T = require('./test-run').configure({ name: 'program-panel' });
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 sleep = (ms) => new Promise((r) => setTimeout(r, ms));
22
+ 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); } };
23
+ const results = [];
24
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
25
+ let srv = null; let browser = null;
26
+ const finish = async (code) => {
27
+ if (browser) await browser.close().catch(() => {});
28
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
29
+ T.killTmux();
30
+ const bad = results.filter((x) => !x.cond).length;
31
+ console.log(`\n${results.length - bad}/${results.length} program-panel assertions passed`);
32
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
33
+ };
34
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
35
+
36
+ (async () => {
37
+ const exe = process.env.PMOS_CHROME || findBrowser();
38
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
39
+ let chromium;
40
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
41
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
42
+ await T.waitForServer(BASE);
43
+ browser = await chromium.launch({ executablePath: exe });
44
+
45
+ const open = async ({ w = 1440, h = 900, qs = '?ws=idpf&program=project-ascent', ctx = null, programs = F.programs() } = {}) => {
46
+ const c = ctx || await browser.newContext({ viewport: { width: w, height: h } });
47
+ const page = await c.newPage();
48
+ const errors = [], posts = [];
49
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
50
+ 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() }) }); });
51
+ await page.route('**/api/programs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, programs }) }));
52
+ const wsOf = (r) => new URL(r.request().url()).searchParams.get('ws') || 'idpf', json = (r, b) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(b) });
53
+ await page.route('**/api/boards/anchors*', (r) => json(r, { ok: true, anchors: A.ANCHORS[wsOf(r)] || [] }));
54
+ await page.route('**/api/insights-premium*', (r) => json(r, { ok: true, model: { goals: A.GOALS[wsOf(r)] || [] } }));
55
+ await page.route('**/api/boards/items*', (r) => json(r, { ok: true, items: A.ITEMS[wsOf(r)] || [] }));
56
+ 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}' }); });
57
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: '{"ok":false,"error":"not in this check"}' }));
58
+ await page.addInitScript(() => { window.__bdp = 0; document.addEventListener('bd:program', () => { window.__bdp += 1; }); });
59
+ await page.goto(BASE + '/premium-board.html' + qs);
60
+ return { page, ctx: c, errors, posts };
61
+ };
62
+ const shown = (p) => until(() => p.evaluate(() => { const k = document.querySelector('#ppPeek'); return k && !k.hidden && !!k.querySelector('#ppTitle'); }));
63
+
64
+ /* ── desktop ── */
65
+ const D = await open();
66
+ const p = D.page;
67
+ ok('P ?program=<id> opens the program panel once the board and the programs are read', await shown(p));
68
+ await sleep(1500); // the other product's board and the program reads land after the panel opened: none of them opens it again
69
+ ok('P ?program=<id> sends bd:program once: one path opens the panel', await p.evaluate(() => window.__bdp) === 1, String(await p.evaluate(() => window.__bdp)));
70
+ const hd = await p.evaluate(() => { const k = document.querySelector('#ppPeek'); const r = k.getBoundingClientRect(); return { t: k.querySelector('#ppTitle').textContent, ch: k.querySelector('.pp-ch').textContent, tools: [...k.querySelectorAll('.pk-tools [aria-label]')].map((b) => b.getAttribute('aria-label')), input: k.querySelectorAll('input, textarea').length, w: Math.round(r.width), vw: innerWidth, sel: !!document.querySelector('#ibBody [data-prow="project-ascent"].sel') }; });
71
+ ok('P the head is the program icon, "title · goal", the owner and the span, and four icon buttons; there is no chat box', hd.t === 'Project Ascent · CIAM migration' && hd.ch === 'Wawan · Sep 2026 to Jun 2028' && hd.tools.join('|') === 'Ask about Project Ascent in Home|Open the charter|More: add initiative, move initiative in, archive|Close' && hd.input === 0, JSON.stringify(hd));
72
+ ok('B1 the program panel is 60 % of the width on desktop, and its band row on the Board is selected', Math.abs(hd.w - Math.round(hd.vw * 0.6)) <= 1 && hd.sel, JSON.stringify(hd));
73
+ const g = await p.evaluate(() => ({ per: document.querySelector('#ppPeek .pp-per').textContent.trim(), krs: [...document.querySelectorAll('#ppPeek .pp-goal .pp-kr:not(.ghost) b')].map((b) => b.textContent) }));
74
+ ok('G the goals are the KRs its initiatives anchor to, once each, for the current half', g.per === 'H2 2026' && g.krs.slice().sort().join() === 'KR 1.2,KR 2.1,KR 2.3', JSON.stringify(g));
75
+ const gn = await until(() => p.evaluate(() => { const c = [...document.querySelectorAll('#ppPeek .pp-goal .pp-kr:not(.ghost)')].map((k) => ({ kr: k.querySelector('b').textContent, text: k.textContent, dot: k.querySelector('.pp-gd') ? (k.querySelector('.pp-gd.off') ? 'off' : 'ok') : '', label: k.getAttribute('aria-label') || '' })); return c.length && c.every((x) => x.dot) ? c : null; }));
76
+ const kr = (id) => (gn || []).find((x) => x.kr === id) || {};
77
+ ok('G each KR shows its name from the OKR files and whether Insights reads it as met: 1.2 met, 2.1 on course, 2.3 behind', !!gn
78
+ && /KR 2\.1Sign-in success 99\.5%$/.test(kr('KR 2.1').text) && /Retire legacy IdP$/.test(kr('KR 2.3').text) && /Microsite conversion \+8%$/.test(kr('KR 1.2').text)
79
+ && kr('KR 1.2').dot === 'ok' && /, met$/.test(kr('KR 1.2').label) && kr('KR 2.1').dot === 'ok' && /on course$/.test(kr('KR 2.1').label) && kr('KR 2.3').dot === 'off' && /behind$/.test(kr('KR 2.3').label), JSON.stringify(gn));
80
+ const mt = await p.evaluate(() => { const t = document.querySelector('#ppPeek .pp-mt'); return { caps: [...t.querySelectorAll('.pp-cap')].map((c) => c.textContent.trim()), ms: [...t.querySelectorAll('.pp-m b')].map((b) => b.textContent), next: (t.querySelector('.pp-dm.n') || {}).parentElement && t.querySelector('.pp-dm.n').parentElement.querySelector('b').textContent, rd: (t.querySelector('.pp-rd') || {}).getAttribute && t.querySelector('.pp-rd').getAttribute('aria-label') }; });
81
+ ok('M the track shows 3 milestones between a done cluster and an "N more" cluster; the next one is marked and counts its initiatives', mt.caps.join('|') === '1 done|4 more' && mt.ms.join('|') === 'Charter approved|Pilot live|Pilot users invited' && mt.next === 'Pilot live' && mt.rd === '0 of 2 initiatives ready', JSON.stringify(mt));
82
+ await p.click('#ppPeek .pp-cap:not(.dn)');
83
+ const ml = await until(() => p.evaluate(() => { const l = document.querySelector('#ppPeek .pp-ml'); return l ? { tab: document.querySelector('#ppPeek .pp-tab[aria-selected="true"]').textContent.trim(), groups: [...l.querySelectorAll('.pp-mg')].map((x) => x.textContent.trim()), check: [...l.querySelectorAll('.pp-mr')].filter((x) => /A program check/.test(x.textContent)).map((x) => x.querySelector('b').textContent) } : null; }));
84
+ ok('M "N more" opens the Milestones tab: Done, Next and Later, and a milestone with no initiative is a program check', !!ml && ml.tab === 'Milestones 8' && ml.groups.join('|') === 'Done · 2|Next · 1|Later · 5' && ml.check.join() === 'Support ready,Program review', JSON.stringify(ml));
85
+ await p.click('#ppPeek .pp-mr button.pp-dm[data-ms="support-ready"]');
86
+ const ck = await until(() => D.posts.find((x) => x.path === '/api/programs/check'));
87
+ ok('X a program check\'s diamond marks it done (POST /api/programs/check)', !!ck && ck.body.program === 'project-ascent' && ck.body.milestone === 'support-ready' && ck.body.done === true, JSON.stringify(ck));
88
+ const nr = await p.evaluate(() => [...document.querySelectorAll('#ppPeek .pp-needs .pp-nr')].map((a) => ({ t: a.querySelector('b').textContent, href: a.getAttribute('href'), box: !!a.querySelector('.pp-ck'), sub: a.querySelector('.t span').textContent })));
89
+ ok('W waits on you lists your program task as a check box, and it opens in Home at that item; Dara\'s task is not yours', nr.length === 1 && nr[0].t === 'Sign the CIAM vendor order form' && nr[0].box && /^\/premium\.html\?/.test(nr[0].href) && /item=pt%3Aproject-ascent%3Apt-vendor-form/.test(nr[0].href) && /^On the program · /.test(nr[0].sub), JSON.stringify(nr));
90
+ await p.click('#ppPeek .pp-tab[data-tab="tree"]');
91
+ const tr = await until(() => p.evaluate(() => { const t = document.querySelector('#ppPeek .pp-tree[role="tree"]'); if (!t || /reading its board|not read/.test(t.textContent)) return null; return { rows: [...t.querySelectorAll('.pp-nd.ini .x, .pp-nd.prd2')].map((x) => (x.classList.contains('prd2') ? x.lastChild.textContent : x.textContent).trim()), here: [...t.querySelectorAll('button.pp-open')].map((b) => b.textContent), away: [...t.querySelectorAll('a.pp-open')].map((a) => a.getAttribute('href')) }; }));
92
+ ok('T the tree is the program\'s tasks, then each product with its initiatives; the other product\'s initiative is read from its own board and links there', !!tr && tr.rows[0] === 'On the program' && tr.rows.indexOf('IDPF') > 0 && tr.rows.indexOf('Microsites') > tr.rows.indexOf('IDPF') && tr.rows.includes('Microsite sign-in on CIAM') && tr.here.length === 2 && tr.away.length === 1 && /ws=microsites&focus=microsite-signin/.test(tr.away[0]), JSON.stringify(tr));
93
+ await p.click('#ppPeek .pp-tab[data-tab="tasks"]');
94
+ const tk = await until(() => p.evaluate(() => { const t = document.querySelector('#ppPeek .pp-tree[role="tree"]'); const n = document.querySelector('#ppPeek .pp-tab[data-tab="tasks"] .n'); if (!t || !n || n.textContent !== '7') return null; return { n: n.textContent, heads: [...t.querySelectorAll('.pp-nd.ini .x')].map((x) => x.textContent), rows: [...t.querySelectorAll('a.pp-tk')].map((a) => ({ t: a.querySelector('.x').textContent, href: a.getAttribute('href') })), sort: !!document.querySelector('#ppPeek .pp-sort') }; }));
95
+ ok('K the Tasks tab counts every open task of the program and its initiatives, by level; an initiative\'s task opens in Home; no sort card without Turn into a program', !!tk && tk.heads.join('|') === 'On the program|On its initiatives|On their epics'
96
+ && tk.rows.length === 5 && tk.rows.some((x) => x.t === 'Pick the sign-in widget') && !tk.rows.some((x) => /Not in the program|Read the Descope docs/.test(x.t)) && /^\/premium\.html\?ws=idpf&ini=legacy-idp-sunset$/.test(tk.rows.find((x) => x.t === 'Draft the cutover plan').href) && !tk.sort, JSON.stringify(tk));
97
+ await p.click('#ppPeek .pp-tab[data-tab="tree"]');
98
+ await p.click('#ppPeek .pp-nd.ini.pg .tw');
99
+ ok('F a group folds', await until(() => p.evaluate(() => document.querySelector('#ppPeek .pp-nd.ini.pg').getAttribute('aria-expanded') === 'false' && !document.querySelector('#ppPeek [data-pp="done"]'))));
100
+ await p.click('#ppPeek [data-pp="close"]');
101
+ ok('P Close closes the panel', await until(() => p.evaluate(() => document.querySelector('#ppPeek').hidden && !document.body.classList.contains('pk-on'))));
102
+ await p.reload();
103
+ await shown(p);
104
+ ok('F the fold and the tab are kept after a reload', await until(() => p.evaluate(() => { const g2 = document.querySelector('#ppPeek .pp-nd.ini.pg'); return !!g2 && g2.getAttribute('aria-expanded') === 'false' && document.querySelector('#ppPeek .pp-tab[aria-selected="true"]').dataset.tab === 'tree'; })));
105
+ await p.click('#ppPeek .pp-nd.ini.pg .tw');
106
+ await until(() => p.evaluate(() => !!document.querySelector('#ppPeek [data-pp="done"]')));
107
+ await p.click('#ppPeek [data-pp="done"][data-key="pt-vendor-form"]');
108
+ const dn = await until(() => D.posts.find((x) => x.path === '/api/programs/task-done'));
109
+ ok('X a program task\'s check box marks it done (POST /api/programs/task-done)', !!dn && dn.body.key === 'pt-vendor-form' && dn.body.done === true && dn.body.program === 'project-ascent', JSON.stringify(dn));
110
+ await p.click('#ppPeek button.pp-open[data-ini="descope-parity"]');
111
+ const ip = await until(() => p.evaluate(() => { const k = document.querySelector('#peek'); if (!k || k.hidden) return null; const r = k.getBoundingClientRect(); return { t: document.querySelector('#pkTitle').textContent, prog: document.querySelector('#ppPeek').hidden, w: Math.round(r.width), vw: innerWidth, lad: [...k.querySelectorAll('.pk-lad span')].map((s) => s.textContent).join() }; }));
112
+ ok('O an initiative in the tree opens the Board\'s initiative panel in the same place, and the program panel closes', !!ip && ip.t === 'Descope feature parity' && ip.prog, JSON.stringify(ip));
113
+ ok('B1 the initiative panel is 60 % of the width on desktop and names the steps in full (XnAgBoardPanel)', !!ip && Math.abs(ip.w - Math.round(ip.vw * 0.6)) <= 1 && ip.lad === 'Triage,Discover,Plan,Prioritize,Build,Deliver,Monitor,Evaluate', JSON.stringify(ip));
114
+ await p.keyboard.press('Escape');
115
+ await until(() => p.evaluate(() => document.querySelector('#peek').hidden));
116
+ await p.click('#ibBody [data-prog="project-ascent"]');
117
+ ok('O the Board\'s program row opens the program panel (bd:program)', await shown(p));
118
+ await p.focus('.pk-grip');
119
+ await p.keyboard.press('ArrowLeft');
120
+ const gw = await p.evaluate(() => { const r = document.querySelector('#ppPeek').getBoundingClientRect(); let kept = null; try { kept = localStorage.getItem('pmos.board.pkw'); } catch { /* none */ } return { w: Math.round(r.width), vw: innerWidth, kept, now: document.querySelector('.pk-grip').getAttribute('aria-valuenow') }; });
121
+ ok('B1 the grip on the panel\'s edge widens it within 50 to 70 %, and the width is kept', Math.abs(gw.w - Math.round(gw.vw * 0.62)) <= 1 && gw.kept === '62' && gw.now === '62', JSON.stringify(gw));
122
+ await p.keyboard.press('Escape');
123
+ ok('P Escape closes the panel and gives the focus back to the program row', await until(() => p.evaluate(() => document.querySelector('#ppPeek').hidden && document.activeElement && document.activeElement.matches('[data-prog="project-ascent"]'))));
124
+ ok('0 no page error on desktop', D.errors.length === 0, D.errors.join(' | '));
125
+ await D.ctx.close();
126
+
127
+ /* ── Turn into a program: the sort card counts the tasks of the initiative it came from that have no level, and sorting starts in Home ── */
128
+ const U = await open({ programs: F.programs().map((x) => ({ ...x, from: 'legacy-idp-sunset' })) });
129
+ await shown(U.page);
130
+ const so = await until(() => U.page.evaluate(() => { const c = document.querySelector('#ppPeek .pp-sort'); return c ? { t: c.querySelector('b').textContent, href: c.querySelector('a.pp-cta').getAttribute('href') } : null; }));
131
+ ok('K after Turn into a program the sort card counts the tasks from before the split (not the one already on an epic) and opens the sorting in Home', !!so && so.t === '2 tasks from before the split have no level yet' && /^\/premium\.html\?ws=idpf&ask=program%3Aproject-ascent&q=/.test(so.href), JSON.stringify(so));
132
+ ok('0 no page error after Turn into a program', U.errors.length === 0, U.errors.join(' | '));
133
+ await U.ctx.close();
134
+
135
+ /* ── phone ── */
136
+ const S = await open({ w: 390, h: 844 });
137
+ ok('S on a phone the program panel opens', await shown(S.page));
138
+ const sh = await S.page.evaluate(() => { const r = document.querySelector('#ppPeek').getBoundingClientRect(); return { l: Math.round(r.left), w: Math.round(r.width), b: Math.round(innerHeight - r.bottom), vw: innerWidth, grip: getComputedStyle(document.querySelector('.pk-grip')).display, wide: document.documentElement.scrollWidth <= innerWidth + 1 }; });
139
+ ok('S it is the Board\'s bottom sheet across the width, with no grip and no sideways scroll', sh.l === 0 && sh.w === sh.vw && sh.b === 0 && sh.grip === 'none' && sh.wide, JSON.stringify(sh));
140
+ ok('0 no page error on a phone', S.errors.length === 0, S.errors.join(' | '));
141
+ await S.ctx.close();
142
+ finish();
143
+ })();