create-pmos 0.398.0 → 0.399.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) 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/briefing-premium-adddoc-test.js +18 -14
  7. package/workspace/briefing-premium-board-test.js +80 -48
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +6 -2
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +46 -42
  18. package/workspace/briefing-premium-work-test.js +9 -9
  19. package/workspace/changelog.json +12 -0
  20. package/workspace/ev-everywhere-test.js +210 -0
  21. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  22. package/workspace/guide/home.md +39 -18
  23. package/workspace/guide/index.md +1 -1
  24. package/workspace/lib/board-grill.js +63 -0
  25. package/workspace/lib/board-premium.js +36 -5
  26. package/workspace/lib/initiative-layout.js +77 -0
  27. package/workspace/lib/insights-premium.js +3 -2
  28. package/workspace/lib/insights-records.js +21 -7
  29. package/workspace/lib/meeting-points.js +52 -0
  30. package/workspace/lib/news-for-you.js +88 -0
  31. package/workspace/lib/notes-series.js +29 -6
  32. package/workspace/lib/report-confirm.js +48 -0
  33. package/workspace/lib/route-modules.js +8 -0
  34. package/workspace/lib/routes-board-docs.js +46 -0
  35. package/workspace/lib/routes-board-grill.js +90 -0
  36. package/workspace/lib/routes-home-review.js +108 -0
  37. package/workspace/lib/routes-initiative-layout.js +57 -0
  38. package/workspace/lib/routes-insights-premium.js +4 -1
  39. package/workspace/lib/routes-insights-records.js +8 -4
  40. package/workspace/lib/routes-meeting-points.js +37 -0
  41. package/workspace/lib/routes-news.js +57 -0
  42. package/workspace/lib/routes-notes.js +2 -1
  43. package/workspace/lib/routes-report-confirm.js +31 -0
  44. package/workspace/lib/routes-search.js +38 -0
  45. package/workspace/lib/search-index.js +176 -0
  46. package/workspace/package-lock.json +2 -2
  47. package/workspace/package.json +1 -1
  48. package/workspace/premium-board-actions-test.js +86 -50
  49. package/workspace/premium-briefing-depth-test.js +55 -54
  50. package/workspace/premium-chat-chart-tab-test.js +4 -2
  51. package/workspace/premium-chat-report-tab-test.js +16 -2
  52. package/workspace/premium-core-doc-issue-test.js +15 -13
  53. package/workspace/premium-phone-card-test.js +5 -3
  54. package/workspace/premium-report-read-test.js +55 -18
  55. package/workspace/premium-vw-backlog-test.js +2 -2
  56. package/workspace/premium-vw-cal-test.js +50 -35
  57. package/workspace/premium-vw-doc-test.js +9 -3
  58. package/workspace/premium-vw-item-test.js +1 -1
  59. package/workspace/premium-vw-jira-test.js +2 -2
  60. package/workspace/premium-vw-meet-test.js +37 -40
  61. package/workspace/premium-vw-notes-test.js +21 -19
  62. package/workspace/premium-vw-rec-test.js +11 -12
  63. package/workspace/premium-welcome-test.js +3 -3
  64. package/workspace/premium-work-depth-test.js +3 -3
  65. package/workspace/public/pm/bd-acts.js +303 -225
  66. package/workspace/public/pm/bd-asks.js +261 -0
  67. package/workspace/public/pm/bd-pop.js +59 -0
  68. package/workspace/public/pm/bd-span.js +49 -13
  69. package/workspace/public/pm/bd-views.js +169 -0
  70. package/workspace/public/pm/cozy-board.css +301 -0
  71. package/workspace/public/pm/cozy-ev.css +228 -0
  72. package/workspace/public/pm/cozy-evmodel.js +106 -0
  73. package/workspace/public/pm/cozy-evui.js +47 -0
  74. package/workspace/public/pm/cozy-insights.css +148 -10
  75. package/workspace/public/pm/cozy-nav.js +103 -39
  76. package/workspace/public/pm/cozy-news.js +140 -0
  77. package/workspace/public/pm/cozy-search.js +203 -0
  78. package/workspace/public/pm/cozy-settings.js +198 -0
  79. package/workspace/public/pm/cozy-sources.js +89 -0
  80. package/workspace/public/pm/cozy-today.css +217 -0
  81. package/workspace/public/pm/cozy-viewer.js +1 -0
  82. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  83. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  84. package/workspace/public/pm/home-adddoc.js +5 -5
  85. package/workspace/public/pm/home-app.js +329 -55
  86. package/workspace/public/pm/home-around.js +24 -126
  87. package/workspace/public/pm/home-chat.js +67 -14
  88. package/workspace/public/pm/home-data.js +6 -6
  89. package/workspace/public/pm/home-dictate.js +54 -0
  90. package/workspace/public/pm/home-draft.js +6 -6
  91. package/workspace/public/pm/home-ini-model.js +190 -0
  92. package/workspace/public/pm/home-ini.css +171 -0
  93. package/workspace/public/pm/home-ini.js +456 -0
  94. package/workspace/public/pm/home-list.js +276 -0
  95. package/workspace/public/pm/home-more.js +17 -134
  96. package/workspace/public/pm/home-phone-card.js +4 -4
  97. package/workspace/public/pm/home-review.js +104 -0
  98. package/workspace/public/pm/home-task.js +67 -0
  99. package/workspace/public/pm/home-today.js +144 -0
  100. package/workspace/public/pm/home-work.js +54 -26
  101. package/workspace/public/pm/premium-board.js +163 -39
  102. package/workspace/public/pm/premium-chart-tab.js +4 -5
  103. package/workspace/public/pm/premium-first.js +5 -7
  104. package/workspace/public/pm/premium-insights.js +499 -202
  105. package/workspace/public/pm/premium-mtg-present.js +138 -0
  106. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  107. package/workspace/public/pm/premium-report-read.js +216 -52
  108. package/workspace/public/pm/premium-report-tab.js +44 -19
  109. package/workspace/public/pm/premium-shell.js +7 -7
  110. package/workspace/public/pm/premium-vw-cal.js +150 -60
  111. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  112. package/workspace/public/pm/premium-vw-notes.js +61 -0
  113. package/workspace/public/pm/rp-parts.js +269 -0
  114. package/workspace/public/premium-board.html +4 -3
  115. package/workspace/public/premium-insights.html +10 -10
  116. package/workspace/public/premium.html +3 -1
  117. package/workspace/r/m1.png +0 -0
  118. package/workspace/r/m2.png +0 -0
  119. package/workspace/r/m3.png +0 -0
  120. package/workspace/r/nl.png +0 -0
  121. package/workspace/test-lists/initiative-layout.json +9 -0
  122. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  123. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  124. package/workspace/test-lists/uf-everywhere.json +15 -0
  125. package/workspace/test-lists/uf-home.json +9 -0
  126. package/workspace/test-lists/uncovered-board.json +9 -0
@@ -0,0 +1,176 @@
1
+ 'use strict';
2
+ /* search-index.js — Search across the repository and every worktree (initiative premium-uncovered-features, E1; canvas EvSearch, EvPhone).
3
+ *
4
+ * worktrees(root) → [{ id, name, path, branch, head, main }] `git worktree list --porcelain`; the first is the main one
5
+ * kindOf(relPath) → 'initiative' | 'document' | 'slides' | 'report' | 'artifact' | 'file' | null PURE
6
+ * titleOf(text, relPath) → the frontmatter title, else the first "# " heading, else the file name PURE
7
+ * search({ root, q, only, notes, now }) → { ok, q, worktrees, counts, results, more } READ-ONLY
8
+ * readFile({ root, wt, path }) → { ok, text, path, wt } | { ok: false, status, error } one file of a listed worktree, read-only
9
+ *
10
+ * What is searched. Every file git knows in the main worktree (tracked, plus untracked files that are not ignored), and in each other worktree
11
+ * only the files that differ from the main worktree's HEAD (changed, committed on its branch, or new). So a file shows once, from main, unless
12
+ * a worktree holds another version of it: then that version shows too, marked with the worktree, so a draft that is not merged can be found.
13
+ * A file matches by its path or name, or by its text (git grep, case-insensitive, fixed string). Meetings are the note titles (lib/notes.js).
14
+ * Nothing here writes. Every git call has a time limit and a size limit; a worktree that cannot be read is listed with its error. */
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+ const { execFileSync } = require('child_process');
18
+
19
+ const KINDS = ['initiative', 'document', 'slides', 'report', 'artifact', 'meeting'];
20
+ const MAX_FILES = 40000;
21
+ const MAX_PER_KIND = 30;
22
+ const SKIP = /(^|\/)(node_modules|\.git|vendor|dist|build|coverage|\.next|\.claude\/worktrees)(\/|$)/;
23
+ const BINARY = /\.(png|jpe?g|gif|webp|ico|woff2?|ttf|otf|mp3|mp4|wav|webm|zip|gz|tgz|lock)$/i;
24
+ const DESIGN = /\.(html?|svg|pdf|fig|sketch)$/i;
25
+ const SLIDES = /\.(pptx|key|odp)$/i;
26
+ const CODE = /\.(m?js|cjs|ts|tsx|jsx|css|py|sh|json|jsonl|ya?ml|go|rb|rs|java|kt|swift|sql)$/i;
27
+
28
+ function git(cwd, args, { timeout = 8000, max = 32 * 1024 * 1024 } = {}) {
29
+ return execFileSync('git', args, { cwd, encoding: 'utf8', timeout, maxBuffer: max, stdio: ['ignore', 'pipe', 'ignore'] });
30
+ }
31
+
32
+ /** The worktrees of the repository at root, the main one first. Each id is stable and safe in a URL: 'main' or the folder name. */
33
+ function worktrees(root) {
34
+ let out = '';
35
+ try { out = git(root, ['worktree', 'list', '--porcelain']); } catch { return [{ id: 'main', name: 'main', path: path.resolve(root), branch: '', head: '', main: true }]; }
36
+ const list = [];
37
+ let cur = null;
38
+ for (const line of out.split('\n')) {
39
+ if (line.startsWith('worktree ')) { cur = { path: line.slice(9).trim(), branch: '', head: '', bare: false }; list.push(cur); }
40
+ else if (!cur) continue;
41
+ else if (line.startsWith('HEAD ')) cur.head = line.slice(5).trim();
42
+ else if (line.startsWith('branch ')) cur.branch = line.slice(7).trim().replace(/^refs\/heads\//, '');
43
+ else if (line === 'bare') cur.bare = true;
44
+ }
45
+ const used = new Set();
46
+ return list.filter((w) => !w.bare).map((w, i) => {
47
+ let id = i === 0 ? 'main' : path.basename(w.path).replace(/[^A-Za-z0-9._-]/g, '-').slice(0, 80) || 'wt' + i;
48
+ while (used.has(id)) id += '-' + i;
49
+ used.add(id);
50
+ return { id, name: i === 0 ? (w.branch || 'main') : (w.branch || path.basename(w.path)), path: w.path, branch: w.branch, head: w.head, main: i === 0 };
51
+ });
52
+ }
53
+
54
+ /** The kind of a file, from its path alone. null: not something Search lists. Pure. */
55
+ function kindOf(rel) {
56
+ const p = String(rel || '').replace(/\\/g, '/');
57
+ if (!p || SKIP.test(p) || BINARY.test(p)) return null;
58
+ const base = p.split('/').pop();
59
+ if (/^planning\/initiatives\/[^/]+\.md$/.test(p)) return 'initiative';
60
+ if (SLIDES.test(p) || /(^|[-_.])(deck|slides)([-_.]|$)/i.test(base)) return 'slides';
61
+ if (/(^|\/)reports\//.test(p) && /\.(md|html?|pdf)$/i.test(p)) return 'report';
62
+ if (/\.(md|mdx|txt|docx?)$/i.test(p)) return 'document';
63
+ if (DESIGN.test(p)) return 'artifact';
64
+ if (CODE.test(p)) return 'file';
65
+ return null;
66
+ }
67
+ /** The group a kind is counted in: a code file is counted with the artifacts (EvSearch "Artifacts and designs"). */
68
+ const groupOf = (kind) => (kind === 'file' ? 'artifact' : kind);
69
+
70
+ /** A document's title: its frontmatter title, else its first "# " heading, else its file name without the extension. Pure. */
71
+ function titleOf(text, rel) {
72
+ const t = String(text || '');
73
+ const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(t);
74
+ if (fm) { const m = /^title:\s*["']?(.+?)["']?\s*$/m.exec(fm[1]); if (m && m[1].trim()) return m[1].trim().slice(0, 160); }
75
+ const h = /^#\s+(.+)$/m.exec(t);
76
+ if (h) return h[1].trim().slice(0, 160);
77
+ const base = String(rel || '').split('/').pop() || '';
78
+ return base.replace(/\.[^.]+$/, '') || base;
79
+ }
80
+ const fmField = (text, key) => { const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(String(text || '')); if (!fm) return ''; const m = new RegExp('^' + key + ':\\s*["\']?(.+?)["\']?\\s*$', 'm').exec(fm[1]); return m ? m[1].trim().slice(0, 80) : ''; };
81
+
82
+ /** The files of one worktree that Search reads. Main: every file git knows. Another: the files that differ from main's HEAD. */
83
+ function filesOf(wt, mainHead) {
84
+ const lines = (s) => s.split('\n').map((x) => x.trim()).filter(Boolean);
85
+ if (wt.main) return lines(git(wt.path, ['ls-files', '-co', '--exclude-standard'])).slice(0, MAX_FILES);
86
+ // since the branch left main (its merge base), so a file main changed later is not shown as this worktree's draft
87
+ let base = '';
88
+ if (mainHead) { try { base = git(wt.path, ['merge-base', 'HEAD', mainHead]).trim(); } catch { base = mainHead; } }
89
+ const changed = base ? lines(git(wt.path, ['diff', '--name-only', '--diff-filter=ACMR', base])) : [];
90
+ const fresh = lines(git(wt.path, ['ls-files', '-o', '--exclude-standard']));
91
+ return [...new Set(changed.concat(fresh))].slice(0, MAX_FILES);
92
+ }
93
+ /** The files whose text holds q (case-insensitive, fixed string), among `among`. */
94
+ function textHits(wt, q, among) {
95
+ if (!among.length) return new Set();
96
+ const args = ['grep', '-I', '-l', '-i', '-F', '--untracked', '-e', q, '--'];
97
+ const out = new Set();
98
+ for (let i = 0; i < among.length; i += 400) { // a long list goes in parts, so the command line stays short
99
+ try { for (const l of git(wt.path, args.concat(among.slice(i, i + 400)), { timeout: 10000 }).split('\n')) if (l.trim()) out.add(l.trim()); }
100
+ catch (e) { if (!(e && e.status === 1)) throw e; } // 1: no match
101
+ }
102
+ return out;
103
+ }
104
+ /** The first line of text that holds q, shortened around it. */
105
+ function lineOf(text, q) {
106
+ const low = q.toLowerCase();
107
+ const l = String(text || '').split('\n').find((x) => x.toLowerCase().includes(low));
108
+ if (!l) return '';
109
+ const s = l.replace(/^[#>*\-\s]+/, '').trim(), at = s.toLowerCase().indexOf(low);
110
+ return (at > 60 ? '…' + s.slice(at - 40) : s).slice(0, 120);
111
+ }
112
+ const readText = (abs, max = 256 * 1024) => { try { const st = fs.statSync(abs); if (!st.isFile() || st.size > max) return { text: '', mtime: st.mtimeMs }; return { text: fs.readFileSync(abs, 'utf8'), mtime: st.mtimeMs }; } catch { return { text: '', mtime: 0 }; } };
113
+
114
+ /** Search one query. only: worktree ids to search ([] or null: all). notes: lib/notes.js list rows, for meetings. */
115
+ function search({ root, q, only = null, notes = [], now = Date.now() } = {}) {
116
+ const query = String(q || '').trim().slice(0, 120);
117
+ const all = worktrees(root);
118
+ const pick = Array.isArray(only) && only.length ? all.filter((w) => w.main || only.includes(w.id)) : all;
119
+ const counts = Object.fromEntries(KINDS.map((k) => [k, 0]));
120
+ const shownWt = all.map((w) => ({ id: w.id, name: w.name, branch: w.branch, main: w.main, on: pick.includes(w) }));
121
+ if (query.length < 2) return { ok: true, q: query, worktrees: shownWt, counts, results: [], more: 0 };
122
+ const mainHead = (all[0] && all[0].head) || '';
123
+ const low = query.toLowerCase();
124
+ const results = [];
125
+ const errors = [];
126
+ const day = new Date(now).toDateString();
127
+ for (const wt of pick) {
128
+ let files;
129
+ try { files = filesOf(wt, mainHead); } catch (e) { errors.push({ wt: wt.id, error: 'could not be read' }); const s = shownWt.find((x) => x.id === wt.id); if (s) s.error = 'could not be read'; continue; }
130
+ const kinds = new Map();
131
+ for (const f of files) { const k = kindOf(f); if (k) kinds.set(f, k); }
132
+ const byName = [...kinds.keys()].filter((f) => f.toLowerCase().includes(low));
133
+ let byText = new Set();
134
+ try { byText = textHits(wt, query, [...kinds.keys()].filter((f) => /\.(md|mdx|txt|html?)$/i.test(f))); } catch { byText = new Set(); }
135
+ for (const f of new Set(byName.concat([...byText]))) {
136
+ const kind = kinds.get(f); if (!kind) continue;
137
+ const abs = path.join(wt.path, f);
138
+ const { text, mtime } = /\.(md|mdx|txt|html?)$/i.test(f) ? readText(abs) : { text: '', mtime: (() => { try { return fs.statSync(abs).mtimeMs; } catch { return 0; } })() };
139
+ const title = /\.(md|mdx|txt)$/i.test(f) ? titleOf(text, f) : f.split('/').pop();
140
+ const named = f.toLowerCase().includes(low) || title.toLowerCase().includes(low);
141
+ const r = { kind, group: groupOf(kind), title, path: f, dir: path.posix.dirname(f), wt: wt.id, branch: wt.branch || '', main: wt.main, why: named ? 'name' : 'text' };
142
+ if (!named) r.line = lineOf(text, query);
143
+ if (kind === 'initiative') { r.id = path.posix.basename(f, '.md'); r.lane = fmField(text, 'lane'); }
144
+ if (!wt.main) r.draft = true;
145
+ if (mtime && new Date(mtime).toDateString() === day) r.today = true;
146
+ results.push(r);
147
+ }
148
+ }
149
+ for (const n of notes || []) {
150
+ const t = String((n && n.title) || '');
151
+ if (!n || !n.id || !t.toLowerCase().includes(low)) continue;
152
+ results.push({ kind: 'meeting', group: 'meeting', title: t, id: n.id, at: (n.meeting && n.meeting.start) || n.created_at || null, summary: !!n.summary, private: !!n.private, why: 'name' });
153
+ }
154
+ // the order: a name match before a text match, main before a worktree, then the shorter path (the nearer file)
155
+ results.sort((a, b) => (a.why === b.why ? 0 : a.why === 'name' ? -1 : 1) || (a.main === b.main ? 0 : a.main === false ? 1 : -1) || String(a.path || '').length - String(b.path || '').length);
156
+ const shown = [];
157
+ let more = 0;
158
+ for (const r of results) { counts[r.group] = (counts[r.group] || 0) + 1; if (shown.filter((x) => x.group === r.group).length < MAX_PER_KIND) shown.push(r); else more++; }
159
+ return { ok: true, q: query, worktrees: shownWt, counts, results: shown, more, errors };
160
+ }
161
+
162
+ /** One file of a listed worktree, for the Viewer. The path must be a relative path inside the worktree; nothing outside it is read. */
163
+ function readFile({ root, wt, path: rel } = {}) {
164
+ const w = worktrees(root).find((x) => x.id === (wt || 'main'));
165
+ if (!w) return { ok: false, status: 404, error: 'no such worktree' };
166
+ const p = String(rel || '').replace(/\\/g, '/');
167
+ if (!p || p.startsWith('/') || p.split('/').includes('..') || SKIP.test(p)) return { ok: false, status: 400, error: 'path must be a relative path inside the worktree' };
168
+ const abs = path.resolve(w.path, p);
169
+ if (!abs.startsWith(path.resolve(w.path) + path.sep)) return { ok: false, status: 400, error: 'path must be a relative path inside the worktree' };
170
+ let st; try { st = fs.statSync(abs); } catch { return { ok: false, status: 404, error: 'The file moved or was renamed after it was found.' }; }
171
+ if (!st.isFile()) return { ok: false, status: 404, error: 'not a file' };
172
+ if (st.size > 1024 * 1024 || BINARY.test(p)) return { ok: false, status: 413, error: 'This file is too large or not text, so it is not shown here.' };
173
+ return { ok: true, wt: w.id, branch: w.branch, main: w.main, path: p, text: fs.readFileSync(abs, 'utf8'), mtime: new Date(st.mtimeMs).toISOString() };
174
+ }
175
+
176
+ module.exports = { KINDS, worktrees, kindOf, groupOf, titleOf, lineOf, search, readFile };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.398.0",
3
+ "version": "0.399.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.398.0",
9
+ "version": "0.399.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.398.0",
3
+ "version": "0.399.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",
@@ -2,7 +2,8 @@
2
2
  'use strict';
3
3
  /* premium-board-actions-test.js — the board presses of the premium Board and initiative pages (initiative premium-board-actions; planning/prd/premium-board-actions-prd.md A1 to A12).
4
4
  * A real server on a scratch `team` repository (planning/initiatives, pmos/state), never the PMOS checkout. The real pages press the real routes.
5
- * Re-pointed for the Agreed Board (premium-agreed-design): the Board's presses are the plain versions of pm/bd-acts.js in the side panel.
5
+ * Re-pointed for the uncovered-features designs (premium-uncovered-features: BdAsks, BdNew, BdGrill, BdActions): popovers and side panels, each
6
+ * press done at once with Undo, and the first questions of a new initiative (lib/routes-board-grill.js).
6
7
  * T triage (accept, decline) · N New initiative · M move and Undo · L hold, resume, cancel, reopen, archive, restore · I the initiative page's bar
7
8
  * S the PMOS-self board (a model answer, since only the embedded checkout is self) · P the POST allow-list and the refusals · F floors */
8
9
  const fs = require('fs');
@@ -45,7 +46,8 @@ const lines = (name) => {
45
46
  };
46
47
  /** A press on a choice chip inside the dialog's pane, as a click event on the element (Playwright's pointer check races the dialog's spring). */
47
48
  const tap = (pg, sel) => pg.$eval(sel, (b) => b.click());
48
- const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive)|lifecycle|briefing-premium\/note)$/;
49
+ // the Board's first questions (board-grill: start, file, answer, later) write only triage-answers.jsonl and the material folder; intake/draft only drafts
50
+ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive)|lifecycle|briefing-premium\/note|board-grill\/(?:start|file|answer|later)|intake\/draft|initiative-layout)$/; // initiative-layout: the card's Moves on by itself switch (premium-uncovered-features)
49
51
 
50
52
  (async () => {
51
53
  const exe = findBrowser();
@@ -75,98 +77,116 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
75
77
  };
76
78
  const P = await open('/premium-board.html');
77
79
  const p = P.page;
78
- // re-pointed for the Agreed Board (premium-agreed-design): the presses live in plain versions in the side panel (pm/bd-acts.js), tagged
79
- // "Waiting for design"; a row's actions open from the panel's ⋯; the toast is #bdToast with its Undo; the old dialog never opens.
80
+ // re-pointed for the uncovered-features designs (premium-uncovered-features): the asks, the row menu, Find and Filter are popovers (#bdPop,
81
+ // BdAsks, BdActions); New initiative and Cancelled and archived are side panels; the toast is #bdToast with its Undo; the old dialog never opens.
80
82
  const listed = (id) => p.evaluate((x) => [...document.querySelectorAll('#ibBody .ini2')].some((b) => b.dataset.key === 'board:' + x), id);
81
83
  const toastIs = (re) => until(() => p.evaluate((s) => { const t = document.querySelector('#bdToast'); return t && !t.hidden && new RegExp(s).test(t.textContent) ? t.textContent : null; }, re.source));
82
- const peekOn = (title) => until(() => p.evaluate((t) => { const k = document.querySelector('#peek'); return k && !k.hidden && (document.querySelector('#pkTitle') || {}).textContent === t && !!k.querySelector('.bd-wtag'); }, title));
84
+ const peekOn = (title) => until(() => p.evaluate((t) => { const k = document.querySelector('#peek'); return k && !k.hidden && (document.querySelector('#pkTitle') || {}).textContent === t && !k.querySelector('.bd-wtag'); }, title));
85
+ const popOn = (re) => until(() => p.evaluate((s) => { const k = document.querySelector('#bdPop'); return k && !k.hidden && new RegExp(s).test(k.textContent) ? k.textContent : null; }, re.source));
83
86
  const noDlg = () => p.evaluate(() => !document.querySelector('#dlg.on'));
84
- const acts = async (id) => { await until(() => listed(id), 30000); await p.click(`#ibBody .ini2[data-key="board:${id}"]`); await until(() => p.evaluate(() => !!document.querySelector('#peek [data-pk="acts"]'))); await p.click('#peek [data-pk="acts"]'); return peekOn('Initiative actions'); };
87
+ const acts = async (id) => { await until(() => listed(id), 30000); await p.click(`#ibBody .ini2[data-key="board:${id}"]`); await until(() => p.evaluate(() => !!document.querySelector('#peek [data-pk="acts"]'))); await p.click('#peek [data-pk="acts"]'); return until(() => p.evaluate(() => { const m = document.querySelector('#bdPop'); return !!m && !m.hidden && m.getAttribute('role') === 'menu'; })); };
88
+ const closeAll = async () => { for (let i = 0; i < 3; i++) { if (await p.evaluate(() => document.querySelector('#peek').hidden && (!document.querySelector('#bdPop') || document.querySelector('#bdPop').hidden))) return; await p.keyboard.press('Escape'); await sleep(100); } };
85
89
  await until(() => p.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 30000);
86
90
  await p.click('#chAsks');
87
- ok('A2 the New asks panel lists both asks with Accept and Decline', await until(() => p.evaluate(() => document.querySelectorAll('#peek .bd-ask').length === 2 && document.querySelectorAll('#peek [data-act="accept"]').length === 2)), await p.evaluate(() => (document.querySelector('#peek') || {}).textContent));
88
- ok('A2 an ask shows its source, not an invented name, and the panel is tagged "Waiting for design"', await p.evaluate(() => /Email from Rina/.test(document.querySelector('#peek').textContent) && !/demo/i.test(document.querySelector('#peek').textContent) && !!document.querySelector('#peek .bd-wtag')));
91
+ ok('A2 the New asks popover lists both asks with Accept and Decline (BdAsks)', await until(() => p.evaluate(() => document.querySelectorAll('#bdPop .bd-acard[data-ask]').length === 2 && document.querySelectorAll('#bdPop [data-askact="accept"]').length === 2 && document.querySelectorAll('#bdPop [data-askact="decline"]').length === 2)), await p.evaluate(() => (document.querySelector('#bdPop') || {}).textContent));
92
+ ok('A2 an ask shows its source and the product with the reason, not an invented name, and no "Waiting for design" tag', await p.evaluate(() => { const t = document.querySelector('#bdPop').textContent; return /Email from Rina/.test(t) && /Why: came in through Email from Rina/.test(t) && !/demo/i.test(t) && !document.querySelector('#bdPop .bd-wtag'); }));
89
93
 
90
94
  /* T triage */
91
- await p.click(`#peek [data-act="accept"][data-id="${a1.body.ask.id}"]`); await peekOn('Accept ask');
95
+ await p.click(`#bdPop [data-askact="accept"][data-id="${a1.body.ask.id}"]`); await peekOn('Accept ask');
92
96
  const anc = await until(() => p.evaluate(() => { const s = document.querySelector('#peek select[name="anchor"]'); return s && !s.disabled ? [...s.options].map((o) => o.value) : null; }));
93
- ok('T1 Accept opens the form with the anchors the board declares', !!anc && anc.includes('health:tech'), JSON.stringify(anc));
94
- await p.fill('#peek input[name="title"]', ''); await p.click('#peek form[data-form="new"] [type="submit"]');
95
- ok('T2 an empty title is refused on the page, before any press', await p.evaluate(() => /Give it a title/.test(document.querySelector('#formM').textContent)) && !P.posts.some((x) => x.path === '/api/boards/asks/accept'));
96
- await p.fill('#peek input[name="title"]', 'Daily CSV of failed payouts'); await p.selectOption('#peek select[name="anchor"]', 'health:tech'); await p.click('#peek form[data-form="new"] [type="submit"]');
97
+ ok('T1 Accept of an ask with no goal opens New initiative with the anchors the board declares, and no lane field', !!anc && anc.includes('health:tech') && await p.evaluate(() => !document.querySelector('#peek [name="lane"]')), JSON.stringify(anc));
98
+ await p.fill('#peek input[name="title"]', ''); await p.click('#peek form[data-form="new2"] [type="submit"]');
99
+ ok('T2 an empty name is refused on the page, before any press', await p.evaluate(() => /Give it a name/.test(document.querySelector('#formM').textContent)) && !P.posts.some((x) => x.path === '/api/boards/asks/accept'));
100
+ await p.fill('#peek input[name="title"]', 'Daily CSV of failed payouts'); await p.selectOption('#peek select[name="anchor"]', 'health:tech');
101
+ await p.click('#peek [data-newact="link"]'); await p.fill('#nwLink input', 'https://slack.example.com/archives/finance'); await p.click('#peek [data-newact="addlink"]');
102
+ ok('T2 a pasted link shows as material', await p.evaluate(() => /slack\.example\.com/.test(document.querySelector('#nwMat').textContent)));
103
+ await p.click('#peek form[data-form="new2"] [type="submit"]');
97
104
  ok('T3 Accept records the accept line and a new initiative, and says so', !!(await toastIs(/accepted in/)) && lines('boards.jsonl').some((l) => l.kind === 'ask-accept' && l.ask === a1.body.ask.id), JSON.stringify(lines('boards.jsonl').map((l) => l.kind)));
105
+ const g0 = await until(() => lines('triage-answers.jsonl').find((l) => l.kind === 'start'));
106
+ ok('T3 the Why and the link start its first questions (BdGrill): one start line, and the questions open in the same panel', !!g0 && /Finance wants a CSV/.test(g0.why) && g0.links.length === 1 && !!(await until(() => p.evaluate(() => !!document.querySelector('#peek .bd-qc.on') && /questions? before the BRD/.test(document.querySelector('#peek').textContent)))), JSON.stringify(g0));
107
+ await p.click('#peek .bd-qc.on [data-qchip]'); await p.click('#peek [data-grill="next"]');
108
+ ok('T3 an answer is kept per question', await until(() => lines('triage-answers.jsonl').some((l) => l.kind === 'answer' && l.answer)));
109
+ await p.click('#peek [data-grill="later"]');
110
+ ok('T3 Later keeps the open questions as the next step', await until(() => lines('triage-answers.jsonl').some((l) => l.kind === 'later')) && !!(await toastIs(/Kept as the next step/)));
98
111
  await until(() => p.evaluate(() => document.querySelector('#chAsks') && /\b1\b/.test(document.querySelector('#chAsks').textContent)), 30000);
99
112
  await p.click('#chAsks');
100
- ok('T4 the accepted ask leaves the panel', await until(() => p.evaluate((id) => !document.querySelector(`#peek [data-act="accept"][data-id="${id}"]`) && document.querySelectorAll('#peek .bd-ask').length === 1, a1.body.ask.id)));
101
- await p.click(`#peek [data-act="decline"][data-id="${a2.body.ask.id}"]`); await peekOn('Decline ask');
102
- await p.click('#peek form[data-form="decline"] [type="submit"]');
103
- ok('T5 Decline waits for a reason', await p.evaluate(() => document.querySelector('#peek textarea[name="why"]').validity.valueMissing) && !P.posts.some((x) => x.path === '/api/boards/asks/decline'));
104
- await p.fill('#peek textarea[name="why"]', 'Not tied to a goal this quarter'); await p.click('#peek form[data-form="decline"] [type="submit"]');
105
- ok('T6 Decline records the reason in the board ledger', !!(await toastIs(/Ask declined/)) && lines('boards.jsonl').some((l) => l.kind === 'ask-decline' && l.why === 'Not tied to a goal this quarter'));
113
+ ok('T4 the accepted ask leaves the popover', await until(() => p.evaluate((id) => !document.querySelector(`#bdPop [data-askact="accept"][data-id="${id}"]`) && document.querySelectorAll('#bdPop .bd-acard[data-ask]').length === 1, a1.body.ask.id)));
114
+ await p.click(`#bdPop [data-askact="decline"][data-id="${a2.body.ask.id}"]`);
115
+ ok('T5 Decline asks why not, with the chips', !!(await popOn(/Why not.*Out of scope.*Already planned.*Not now.*Other/)) && !P.posts.some((x) => x.path === '/api/boards/asks/decline'));
116
+ await p.click('#bdPop [data-whynot="Not now"]'); await p.fill('#bdPop input[name="why"]', 'Not tied to a goal this quarter'); await p.click('#bdPop [data-askact="decline-go"]');
117
+ ok('T6 Decline records the reason in the board ledger', !!(await toastIs(/Ask declined/)) && lines('boards.jsonl').some((l) => l.kind === 'ask-decline' && l.why === 'Not now: Not tied to a goal this quarter'), JSON.stringify(lines('boards.jsonl').filter((l) => l.kind === 'ask-decline')));
106
118
  await until(() => p.evaluate(() => /^No new asks|0 new asks/.test((document.querySelector('#chAsks') || {}).textContent.trim())), 30000);
107
119
  await p.click('#chAsks');
108
- ok('T7 the panel says nothing is left to triage', await until(() => p.evaluate(() => /No new ask waits for triage/.test(document.querySelector('#peek').textContent))));
109
- await p.keyboard.press('Escape');
120
+ ok('T7 the popover says nothing is left to triage', !!(await popOn(/No new ask waits for triage/)));
121
+ await closeAll();
110
122
 
111
123
  /* N New initiative */
112
124
  ok('N1 New initiative is offered on a team board', await p.evaluate(() => !document.querySelector('#newIni').hidden));
113
125
  await p.click('#newIni'); await peekOn('New initiative');
114
126
  await until(() => p.evaluate(() => { const s = document.querySelector('#peek select[name="anchor"]'); return s && !s.disabled; }));
115
- await p.fill('#peek input[name="title"]', 'Partner usage per key'); await p.click('#peek form[data-form="new"] [type="submit"]');
116
- ok('N2 an unanchored create is refused on the page', await p.evaluate(() => /Choose an anchor/.test(document.querySelector('#formM').textContent)));
117
- await p.selectOption('#peek select[name="anchor"]', 'health:tech'); await p.click('#peek form[data-form="new"] [type="submit"]');
127
+ await p.fill('#peek input[name="title"]', 'Partner usage per key'); await p.click('#peek form[data-form="new2"] [type="submit"]');
128
+ ok('N2 an unanchored create is refused on the page', await p.evaluate(() => /Choose what it counts toward/.test(document.querySelector('#formM').textContent)));
129
+ await p.selectOption('#peek select[name="anchor"]', 'health:tech'); await p.click('#peek form[data-form="new2"] [type="submit"]');
118
130
  const made = await toastIs(/created in/);
119
131
  const recs = fs.readdirSync(path.join(team, 'planning', 'initiatives'));
120
132
  ok('N3 Create writes an ask, its accept and a new initiative record, as the console does', !!made && recs.some((f) => /partner-usage/.test(f)) && lines('boards.jsonl').some((l) => l.kind === 'ask' && l.line === 'Partner usage per key'), made + ' / ' + recs.join());
133
+ await until(() => p.evaluate(() => !!document.querySelector('#peek .bd-qc')));
134
+ await closeAll();
121
135
 
122
- /* M move and Undo, from the panel's ⋯ */
123
- ok('M1 the initiative actions offer the next stage, hold, cancel and archive', await acts('pa-one') && await p.evaluate(() => { const L = [...document.querySelectorAll('#peek .bd-ai b')].map((b) => b.textContent); return /^Move to /.test(L[0]) && L.includes('Put on hold') && L.includes('Cancel') && L.includes('Archive'); }), await p.evaluate(() => document.querySelector('#peek').textContent));
136
+ /* M move and Undo, from the panel's ⋯ (BdActions) */
137
+ ok('M1 the row menu offers the next stage with how much is ready, hold, cancel and archive', await acts('pa-one') && await p.evaluate(() => { const L = [...document.querySelectorAll('#bdPop [data-rowact] span:first-of-type')].map((b) => b.textContent); return /^Move to /.test(L[0]) && L.includes('Hold') && L.includes('Cancel') && L.includes('Archive'); }), await p.evaluate(() => document.querySelector('#bdPop').textContent));
138
+ await p.keyboard.press('Escape');
139
+ ok('M2 Escape closes the menu and gives the focus back to the ⋯ button', await until(() => p.evaluate(() => document.querySelector('#bdPop').hidden && document.activeElement.dataset.pk === 'acts')));
124
140
  await p.keyboard.press('Escape');
125
- ok('M2 Escape closes the actions and gives the focus back to the row', await until(() => p.evaluate(() => document.querySelector('#peek').hidden && !!document.activeElement.closest('#ibBody'))));
141
+ ok('M2 a second Escape closes the panel and gives the focus back to the row', await until(() => p.evaluate(() => document.querySelector('#peek').hidden && !!document.activeElement.closest('#ibBody'))));
126
142
  const from = ready.model.initiatives.list.rows.find((r) => r.id === 'pa-one').acts.stage;
127
- await acts('pa-one'); await p.click('#peek .bd-ai[data-k^="mv:"]');
143
+ await acts('pa-one'); await p.click('#bdPop [data-rowact^="mv:"]');
128
144
  const mv = await toastIs(/^Moved to/);
129
145
  ok('M3 Move records one move line and says what it recorded', !!mv && lines('boards.jsonl').filter((l) => l.kind === 'move' && l.id === 'pa-one').length === 1, mv);
130
146
  await p.click('#bdToast .bd-undo');
131
147
  ok('M4 Undo writes the move back', !!(await toastIs(new RegExp('Back in ' + from))) && lines('boards.jsonl').filter((l) => l.kind === 'move' && l.id === 'pa-one').pop().to === from);
148
+ await closeAll();
132
149
 
133
- /* L hold, resume, cancel, reopen, archive, restore */
134
- await acts('pa-one'); await p.click('#peek .bd-ai[data-k="hold"]'); await peekOn('Put on hold');
135
- await p.fill('#peek textarea[name="why"]', 'Waiting for the Q1 budget'); await p.check('#peek input[name="back"][value="two"]'); await p.click('#peek form[data-form="hold"] [type="submit"]');
150
+ /* L hold, resume, cancel, reopen, archive, restore: each at once, with Undo */
151
+ await acts('pa-one'); await p.click('#bdPop [data-rowact="hold"]');
136
152
  const hl = await until(() => lines('lifecycle.jsonl').find((l) => l.initiative_id === 'pa-one' && l.state === 'on-hold'));
137
- ok('L1 Put on hold records one on-hold line with the reason and a check-back day', !!hl && hl.reason === 'Waiting for the Q1 budget' && /^\d{4}-\d{2}-\d{2}$/.test(hl.back || ''), JSON.stringify(hl) + ' ' + await p.evaluate(() => (document.querySelector('#formM') || {}).textContent));
153
+ ok('L1 Hold records one on-hold line at once, with a check-back day 30 days on, and Undo', !!hl && /^\d{4}-\d{2}-\d{2}$/.test(hl.back || '') && Math.round((Date.parse(hl.back) - Date.now()) / 86400000) >= 29 && !!(await toastIs(/On hold · .* check back/)), JSON.stringify(hl));
154
+ await closeAll();
138
155
  ok('L2 the row then says On hold', await until(async () => { const t = await p.evaluate(() => { const b = document.querySelector('#ibBody .ini2[data-key="board:pa-one"]'); return b ? b.textContent : ''; }); return /On hold/.test(t); }, 30000));
139
156
  await acts('pa-one');
140
- ok('L2 Resume is offered and the moves are not', await p.evaluate(() => !!document.querySelector('#peek .bd-ai[data-k="resume"]') && !document.querySelector('#peek .bd-ai[data-k^="mv:"]')));
141
- await p.click('#peek .bd-ai[data-k="resume"]');
157
+ ok('L2 Resume is offered and the moves are not', await p.evaluate(() => !!document.querySelector('#bdPop [data-rowact="resume"]') && !document.querySelector('#bdPop [data-rowact^="mv:"]')));
158
+ await p.click('#bdPop [data-rowact="resume"]');
142
159
  ok('L3 Resume records an active line', await until(() => { const L = lines('lifecycle.jsonl').filter((l) => l.initiative_id === 'pa-one'); return L.length && L[L.length - 1].state === 'active'; }));
160
+ await closeAll();
143
161
  await until(() => p.evaluate(() => { const b = document.querySelector('#ibBody .ini2[data-key="board:pa-one"]'); return b && !/On hold/.test(b.textContent); }), 30000);
144
- await acts('pa-one'); await p.click('#peek .bd-ai[data-k="cancel"]'); await peekOn('Cancel the initiative');
145
- await p.click('#peek form[data-form="cancel"] [type="submit"]');
146
- ok('L4 Cancel waits for a reason', await p.evaluate(() => /Pick a reason/.test(document.querySelector('#formM').textContent)) && !lines('lifecycle.jsonl').some((l) => l.initiative_id === 'pa-one' && l.state === 'cancelled'));
147
- await p.check('#peek input[name="why"][value="Not worth it now"]'); await p.click('#peek form[data-form="cancel"] [type="submit"]');
148
- ok('L4 Cancel records a cancelled line with the reason', await until(() => lines('lifecycle.jsonl').some((l) => l.initiative_id === 'pa-one' && l.state === 'cancelled' && l.reason === 'Not worth it now')));
149
- // re-pointed for the Agreed design: the track's footer carries only the fold and the sort (AgBoard), so the count moved to the ⋯ menu's item
162
+ await acts('pa-one'); await p.click('#bdPop [data-rowact="cancel"]');
163
+ ok('L4 Cancel asks why, with the same chips as Decline, and records nothing yet', !!(await popOn(/Why cancel .*Out of scope.*Already planned.*Not now.*Other/)) && !lines('lifecycle.jsonl').some((l) => l.initiative_id === 'pa-one' && l.state === 'cancelled'));
164
+ await p.click('#bdPop [data-why="Not now"]'); await p.click('#bdPop [data-rowact="cancel-go"]');
165
+ ok('L4 Cancel records a cancelled line with the reason', await until(() => lines('lifecycle.jsonl').some((l) => l.initiative_id === 'pa-one' && l.state === 'cancelled' && l.reason === 'Not now')));
150
166
  ok('L5 the row leaves the track and the ⋯ menu\'s Cancelled and archived item counts it', await until(() => p.evaluate(() => !document.querySelector('#ibBody .bt-l[data-row="board:pa-one"]') && /1 cancelled/.test((document.querySelector('#bdGone') || {}).textContent || '')), 30000));
167
+ await closeAll();
151
168
  await p.click('#moreBtn'); await p.click('#bdGone'); await peekOn('Cancelled and archived');
152
- ok('L6 a cancelled initiative offers Reopen only', await p.evaluate(() => [...document.querySelectorAll('#peek .bd-ar [data-act]')].map((b) => b.dataset.act).join() === 'reopen'));
153
- await p.click('#peek [data-act="reopen"]');
169
+ ok('L6 a cancelled initiative offers Reopen only', await p.evaluate(() => [...document.querySelectorAll('#peek .bd-gr [data-rowact]')].map((b) => b.dataset.rowact).join() === 'reopen'));
170
+ await p.click('#peek .bd-gr [data-rowact="reopen"]');
154
171
  ok('L6 Reopen records an active line', await until(() => { const L = lines('lifecycle.jsonl').filter((l) => l.initiative_id === 'pa-one'); return L[L.length - 1].state === 'active'; }));
172
+ await closeAll();
155
173
  await until(() => listed('pa-one'), 30000);
156
- await acts('pa-one'); await p.click('#peek .bd-ai[data-k="archive"]'); await peekOn('Archive the initiative');
157
- await p.check('#peek input[name="why"][value="Duplicate"]'); await p.fill('#peek textarea[name="note"]', 'Same as the CSV export'); await p.click('#peek form[data-form="archive"] [type="submit"]');
158
- ok('L7 Archive records one archive line with the reason', await until(() => lines('boards.jsonl').some((l) => l.kind === 'ini-archive' && l.id === 'pa-one' && l.archived === true && l.reason === 'Duplicate: Same as the CSV export')));
174
+ await acts('pa-one'); await p.click('#bdPop [data-rowact="archive"]');
175
+ ok('L7 Archive records one archive line at once, with no reason asked', await until(() => lines('boards.jsonl').some((l) => l.kind === 'ini-archive' && l.id === 'pa-one' && l.archived === true)));
159
176
  ok('L8 the ⋯ menu\'s item counts it as archived', await until(() => p.evaluate(() => /1 archived/.test((document.querySelector('#bdGone') || {}).textContent || '')), 30000));
160
177
  await p.click('#bdToast .bd-undo');
161
178
  ok('L9 Undo restores it with a restore line', await until(() => lines('boards.jsonl').some((l) => l.kind === 'ini-archive' && l.id === 'pa-one' && l.archived === false)));
162
179
  ok('L10 none of the presses opened the old dialog', await noDlg());
163
180
 
164
- /* I the Board's expand link: the initiative is a layout inside Home (premium-agreed-design). Its stage moves and lifecycle presses are in the Overview */
181
+ /* I the Board's expand link: the initiative is a layout inside Home (premium-agreed-design). Its stage moves and lifecycle presses are in the Overview's
182
+ Stage view; the card moves a stage with Move and Back (premium-uncovered-features, canvas InStage) */
165
183
  const I = await open('/premium-initiative.html?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id));
166
184
  const ip = I.page;
167
185
  const landed = await until(() => ip.evaluate(() => { const q = new URLSearchParams(location.search); return location.pathname === '/premium.html' && q.get('ini') === 'pa-one' && !!q.get('ws') && !!q.get('board') && !!document.querySelector('.hm-card [data-hm-ov]'); }), 60000);
168
186
  ok('I0 the expand link lands on Home with the initiative selected, ws and board kept', !!landed, await ip.evaluate(() => location.href));
169
187
  await ip.click('.hm-card [data-hm-ov]');
188
+ await until(() => ip.evaluate(() => !!document.querySelector('#czViewer [data-hi-view="stage"]')), 60000);
189
+ await ip.click('#czViewer [data-hi-view="stage"]');
170
190
  const bar = await until(() => ip.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); if (!v || !v.querySelector('[data-ov-move]')) return null; const cur = v.querySelector('[data-ov-move][aria-pressed="true"]'); return { moves: [...v.querySelectorAll('[data-ov-move]')].map((x) => x.dataset.ovMove), cur: cur ? cur.dataset.ovMove : '', life: [...v.querySelectorAll('[data-ov-life]')].map((x) => x.dataset.ovLife) }; }), 60000);
171
191
  ok('I1 the Overview offers the stages, the current one pressed, and the lifecycle presses', !!bar && bar.moves.length > 1 && !!bar.cur && bar.moves.indexOf(bar.cur) < bar.moves.length - 1 && bar.life.join() === 'on-hold,cancelled', JSON.stringify(bar) + ' ' + (await ip.evaluate(() => (document.querySelector('#czViewer .cz-vw-body') || {}).innerText || 'no Viewer')).slice(0, 400));
172
192
  const n0 = lines('boards.jsonl').filter((l) => l.kind === 'move').length;
@@ -180,6 +200,22 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
180
200
  await ip.click('#czViewer [data-ov-life-no]');
181
201
  ok('I3 Not now takes the question back', await until(() => ip.evaluate(() => !document.querySelector('#czViewer #ovWhy') && !!document.querySelector('#czViewer [data-ov-life="on-hold"]'))));
182
202
  await ip.keyboard.press('Escape');
203
+ // the card: Back always asks for a reason, and the move line carries it (InStage)
204
+ const back = await until(() => ip.evaluate(() => !!document.querySelector('.hm-card [data-hi-back]')), 30000);
205
+ ok('I4 the card has Move to the next stage and Back', back && await ip.evaluate(() => /^Move to /.test((document.querySelector('.hm-card [data-hi-move]') || {}).textContent || '')));
206
+ if (back) {
207
+ const m0 = lines('boards.jsonl').filter((l) => l.kind === 'move').length;
208
+ await ip.click('.hm-card [data-hi-back]');
209
+ const asked = await until(() => ip.evaluate(() => { const d = document.querySelector('.hi-pop[role="dialog"]'); return d ? { go: d.querySelector('[data-hi-go]').disabled, chips: d.querySelectorAll('[data-hi-why]').length } : null; }));
210
+ ok('I4 Back asks why first: Move back waits for a reason and records nothing yet', !!asked && asked.go === true && asked.chips === 4 && lines('boards.jsonl').filter((l) => l.kind === 'move').length === m0, JSON.stringify(asked));
211
+ await ip.click('.hi-pop [data-hi-why="New research"]'); await ip.fill('.hi-pop #hiWhy', 'Interviews changed the scope');
212
+ await ip.click('.hi-pop [data-hi-go]');
213
+ ok('I4 Move back records one move line with the reason as its why', await until(() => { const L = lines('boards.jsonl').filter((l) => l.kind === 'move'); const x = L[L.length - 1]; return L.length === m0 + 1 && x.id === 'pa-one' && x.to === bar.cur && x.why === 'Back: New research. Interviews changed the scope'; }), JSON.stringify(lines('boards.jsonl').filter((l) => l.kind === 'move').slice(-1)));
214
+ ok('I4 the Undo toast shows after the move', await until(() => ip.evaluate(() => { const t = document.querySelector('#hiToast'); return !!t && !t.hidden && /moved to/.test(t.textContent) && !!t.querySelector('[data-hi-undo]'); })));
215
+ await until(() => ip.evaluate(() => !!document.querySelector('.hm-card [data-hi-auto]')), 30000);
216
+ await ip.click('.hm-card [data-hi-auto]');
217
+ ok('I5 the Moves on by itself switch is a file-mode record of the initiative', await until(() => lines('initiative-layout.jsonl').some((l) => l.kind === 'auto' && l.initiative === 'pa-one' && l.on === false)) && await until(() => ip.evaluate(() => (document.querySelector('.hm-card [data-hi-auto]') || {}).getAttribute && document.querySelector('.hm-card [data-hi-auto]').getAttribute('aria-checked') === 'false')));
218
+ }
183
219
 
184
220
  /* S the PMOS-self board: the model says self, the page offers no move and no New initiative */
185
221
  {
@@ -189,17 +225,17 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
189
225
  await S.page.reload();
190
226
  await until(() => S.page.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0));
191
227
  await S.page.click('#chAsks');
192
- ok('S1 the PMOS-self board names the router in its asks panel and hides New initiative', await until(() => S.page.evaluate(() => /pmos-router/.test(document.querySelector('#peek').textContent) && document.querySelector('#newIni').hidden)));
228
+ ok('S1 the PMOS-self board names the router in its asks popover and hides New initiative', await until(() => S.page.evaluate(() => /pmos-router/.test((document.querySelector('#bdPop') || {}).textContent || '') && document.querySelector('#newIni').hidden)));
193
229
  await S.page.keyboard.press('Escape');
194
230
  await S.page.click('#ibBody .ini2'); await until(() => S.page.evaluate(() => !!document.querySelector('#peek [data-pk="acts"]'))); await S.page.click('#peek [data-pk="acts"]');
195
- ok('S2 its actions have no move', await until(() => S.page.evaluate(() => { const x = document.querySelector('#peek .bd-alist'); return x && !x.querySelector('[data-k^="mv:"]') && !!x.querySelector('[data-k="hold"]'); })));
231
+ ok('S2 its actions have no move', await until(() => S.page.evaluate(() => { const x = document.querySelector('#bdPop'); return x && !x.hidden && !x.querySelector('[data-rowact^="mv:"]') && !!x.querySelector('[data-rowact="hold"]'); })));
196
232
  await S.ctx.close();
197
233
  }
198
234
 
199
235
  /* P the POST allow-list and the refusals */
200
236
  const all = P.posts.concat(I.posts);
201
237
  const other = all.filter((x) => !ALLOWED.test(x.path) && x.path !== '/api/briefing-premium/seen'); // an opened popup's record (popup context slice 11, R1) is not a press
202
- ok('P1 the pages post only to the asks, move, lifecycle and archive routes', all.length > 10 && !other.length, JSON.stringify(other));
238
+ ok('P1 the pages post only to the asks, move, lifecycle, archive and initiative-layout routes', all.length > 10 && !other.length, JSON.stringify(other));
203
239
  const noNonce = await post('/api/boards/move', { id: 'fx-bare', to: ready.model.board.stages[1] }, { 'Content-Type': 'application/json', Origin: BASE });
204
240
  const lifeNo = await post('/api/lifecycle', { initiative_id: 'fx-bare', state: 'on-hold' }, { 'Content-Type': 'application/json', Origin: BASE });
205
241
  ok('P2 a press without the launch nonce is refused', noNonce.status === 403 && lifeNo.status === 403, JSON.stringify([noNonce.status, lifeNo.status]));
@@ -212,7 +248,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
212
248
  const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#ibBody .ini2, #chAsks, #newIni')].filter((b) => b.offsetParent && (b.getBoundingClientRect().width < 44 || b.getBoundingClientRect().height < 44)).map((b) => b.className + ':' + Math.round(b.getBoundingClientRect().width) + 'x' + Math.round(b.getBoundingClientRect().height)) }));
213
249
  ok('F1 at 390 px there is no sideways scroll and every new control is at least 44 px', !f.wide && !f.small.length, JSON.stringify(f));
214
250
  await S.page.click('#ibBody .ini2'); await until(() => S.page.evaluate(() => !!document.querySelector('#peek [data-pk="acts"]'))); await S.page.click('#peek [data-pk="acts"]');
215
- const mi = await until(() => S.page.evaluate(() => { const L = [...document.querySelectorAll('#peek .bd-ai')]; return L.length ? L.every((b) => b.getBoundingClientRect().height >= 44) && document.documentElement.scrollWidth <= innerWidth + 1 : null; }));
251
+ const mi = await until(() => S.page.evaluate(() => { const L = [...document.querySelectorAll('#bdPop.sheet:not([hidden]) .bd-mi')]; return L.length ? L.every((b) => b.getBoundingClientRect().height >= 44) && document.documentElement.scrollWidth <= innerWidth + 1 : null; }));
216
252
  ok('F2 the action rows are 44 px tall and the open sheet adds no sideways scroll', !!mi);
217
253
  await S.ctx.close();
218
254
  }