create-pmos 0.420.0 → 0.422.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 (88) hide show
  1. package/package.json +25 -25
  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/scripts/anchor-resolve.js +93 -15
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/board-programs-test.js +59 -3
  8. package/workspace/briefing-premium-board-test.js +1 -1
  9. package/workspace/changelog.json +24 -0
  10. package/workspace/fixtures/report-api/draft.json +2 -1
  11. package/workspace/guide/briefing-premium.md +2 -1
  12. package/workspace/guide/home.md +6 -2
  13. package/workspace/guide/programs.md +4 -3
  14. package/workspace/home-other-product-test.js +55 -0
  15. package/workspace/lib/board-premium.js +18 -4
  16. package/workspace/lib/briefing-premium-agent.js +8 -0
  17. package/workspace/lib/doc-live-root.js +37 -0
  18. package/workspace/lib/engine/anchor-resolve.js +93 -15
  19. package/workspace/lib/engine/boards.js +7 -2
  20. package/workspace/lib/engine/intake.js +1 -1
  21. package/workspace/lib/first-input.js +13 -6
  22. package/workspace/lib/hold-spans.js +24 -10
  23. package/workspace/lib/kg.js +1 -1
  24. package/workspace/lib/report-draft.js +3 -0
  25. package/workspace/lib/route-modules.js +1 -0
  26. package/workspace/lib/routes-board-premium.js +6 -0
  27. package/workspace/lib/routes-boards.js +48 -9
  28. package/workspace/lib/routes-doc-sheet.js +29 -1
  29. package/workspace/lib/routes-programs.js +44 -5
  30. package/workspace/lib/routes-task-plans.js +333 -0
  31. package/workspace/lib/task-cli.js +16 -9
  32. package/workspace/lib/task-items.js +1 -1
  33. package/workspace/lib/task-plans.js +232 -0
  34. package/workspace/lib/transcript-read.js +29 -1
  35. package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
  36. package/workspace/lib/vendor/scripts/intake.js +1 -1
  37. package/workspace/package-lock.json +2 -2
  38. package/workspace/package.json +1 -1
  39. package/workspace/premium-viewer-test.js +1 -1
  40. package/workspace/premium-vw-doc-test.js +26 -3
  41. package/workspace/program-leave-test.js +203 -0
  42. package/workspace/public/pm/bd-acts.js +5 -2
  43. package/workspace/public/pm/bd-ini-panel.js +20 -7
  44. package/workspace/public/pm/bd-prog-panel.js +22 -7
  45. package/workspace/public/pm/bd-span.js +177 -24
  46. package/workspace/public/pm/cozy-board.css +80 -0
  47. package/workspace/public/pm/cozy-home.css +3 -0
  48. package/workspace/public/pm/cozy-live-pill.js +1 -1
  49. package/workspace/public/pm/cozy-nav.js +1 -1
  50. package/workspace/public/pm/cozy-steps.js +1 -1
  51. package/workspace/public/pm/cozy-xv.js +1 -1
  52. package/workspace/public/pm/doc-follow.js +36 -0
  53. package/workspace/public/pm/home-app.js +38 -7
  54. package/workspace/public/pm/home-ask.js +7 -0
  55. package/workspace/public/pm/home-ini.js +13 -4
  56. package/workspace/public/pm/home-line.js +1 -1
  57. package/workspace/public/pm/home-list.js +2 -2
  58. package/workspace/public/pm/home-today.js +3 -1
  59. package/workspace/public/pm/ini-tasks.js +81 -16
  60. package/workspace/public/pm/ini-versions.js +343 -0
  61. package/workspace/public/pm/ini-view-model.js +27 -41
  62. package/workspace/public/pm/ini-view.css +82 -0
  63. package/workspace/public/pm/ini-view.js +18 -11
  64. package/workspace/public/pm/premium-board.js +109 -18
  65. package/workspace/public/pm/premium-insights.js +1 -1
  66. package/workspace/public/pm/premium-mtg-present.js +2 -2
  67. package/workspace/public/pm/premium-report-read.js +21 -2
  68. package/workspace/public/pm/premium-report-tab.js +1 -1
  69. package/workspace/public/pm/premium-shell.js +29 -4
  70. package/workspace/public/pm/premium-viewer.js +3 -3
  71. package/workspace/public/pm/premium-vw-doc.js +46 -11
  72. package/workspace/public/pm/premium-vw-mtg.js +1 -1
  73. package/workspace/public/pm/premium-vw-open.js +1 -1
  74. package/workspace/public/pm/premium-vw-slides.js +1 -1
  75. package/workspace/public/pm/prog-move.js +69 -0
  76. package/workspace/public/pm/prog-order.js +1 -1
  77. package/workspace/public/pm/task-card.css +3 -0
  78. package/workspace/public/pm/task-card.js +10 -3
  79. package/workspace/public/pm/tk-send.js +1 -1
  80. package/workspace/server.js +26 -2
  81. package/workspace/task-milestones-test.js +176 -0
  82. package/workspace/task-plans-test.js +175 -0
  83. package/workspace/task-views-test.js +2 -2
  84. package/workspace/test-lists/program-leave.json +6 -0
  85. package/workspace/test-lists/task-milestones.json +6 -0
  86. package/workspace/test-lists/task-plans.json +6 -0
  87. package/workspace/test-lists/viewer-live-file.json +9 -0
  88. package/workspace/timeline-holds-test.js +70 -5
@@ -3,7 +3,11 @@
3
3
  * Undo all. Built on the viewer frame (premium-viewer.js) and the existing /api/doc-sheet routes: log and at to read, edit to save, proposals, accept and
4
4
  * reject for an agent's edit, ask to request one. Nothing here is stored anywhere else. The pure half is premium-vw-doc-model.js.
5
5
  * ctx.host (an element) draws the page editor inside it instead of a viewer tab (the report dialog's Edit, PM 2026-10-22: one place to edit a
6
- * report). It opens in Edit, offers only Edit and Markdown, and Cancel or a save calls ctx.onClose. No Health, Links, Copies, extras or Ask. */
6
+ * report). It opens in Edit, offers only Edit and Markdown, and Cancel or a save calls ctx.onClose. No Health, Links, Copies, extras or Ask.
7
+ * The page follows the file (PM, 2026-10-26: "When chat make update on the file that being shown on the current viewer, I should not need to refresh
8
+ * page. I should not need to manually commit as well"): every few seconds GET /api/doc-sheet/stamp says which workspace holds the live copy (an
9
+ * initiative's own worktree, where its chat writes and does not commit, when ctx.ini names it) and the text's hash. A change is read and drawn again.
10
+ * What the PM typed and did not save is never replaced: the page keeps it and says the file changed, as a save would (409). */
7
11
  import { pmPost } from './http.js';
8
12
  import { vwOpen, vwStyle, vwConfirm } from './premium-viewer.js';
9
13
  import { $, $$, esc, toast, AI, CHECK } from './premium-shell.js';
@@ -73,11 +77,14 @@ const BLOCKS = [
73
77
  { k: 'table', t: 'Table', ic: 'tbl' }, { k: 'info', t: 'Info panel', ic: 'info' }, { k: 'note', t: 'Note panel', ic: 'info' }, { k: 'warning', t: 'Warning panel', ic: 'info' }, { k: 'success', t: 'Success panel', ic: 'info' }, { k: 'decision', t: 'Decision', ic: 'info' },
74
78
  { k: 'status', t: 'Status label', ic: 'dot' }, { k: 'code', t: 'Code block', ic: 'code', kbd: '```' }, { k: 'expand', t: 'Expand', ic: 'chev' }, { k: 'hr', t: 'Divider', g: '—', kbd: '---' },
75
79
  ];
80
+ const CHECK_MS = 2500; // how often an open page asks whether its file changed (premium-vw-file.js checks a chat file as often)
81
+ const STALE = 'The chat changed this file while you were editing. Your edit is kept and is not saved. Cancel shows the new text.';
76
82
  const STATUSES = ['To do', 'In progress', 'In review', 'Done', 'Blocked'];
77
83
  const tb = (c, label, icon) => `<button type="button" class="vwtb" data-c="${c}" title="${label}" aria-label="${label}">${IC[icon] || icon}</button>`;
78
84
 
79
- /** Open a markdown file as a page in the viewer. `d` is { path, title }; `ctx` gives { ws(), onWrite() } — onWrite runs after the file or a proposal changed,
80
- * so the page that opened it can read again. */
85
+ /** Open a markdown file as a page in the viewer. `d` is { path, title }; `ctx` gives { ws(), ini?, onWrite() } — onWrite runs after the file or a proposal
86
+ * changed, so the page that opened it can read again. ini (a string or a function) is the initiative the document is opened from: its worktree's copy is
87
+ * the one shown. */
81
88
  export function openDocPage(d, ctx = {}) {
82
89
  if (!d || !d.path) return null;
83
90
  vwStyle('doc');
@@ -89,17 +96,24 @@ export function openDocPage(d, ctx = {}) {
89
96
  const OPEN = new Map();
90
97
  function makePage(d, ctx) {
91
98
  const id = 'doc:' + d.path;
92
- const ws = () => (ctx.ws ? ctx.ws() : '') || '';
99
+ const baseWs = () => (ctx.ws ? ctx.ws() : '') || '';
100
+ const iniOf = () => String((typeof ctx.ini === 'function' ? ctx.ini() : ctx.ini) || '');
101
+ // live: the workspace GET /api/doc-sheet/stamp named as holding the live copy; every read and write goes there
102
+ const ws = () => P.live || baseWs();
93
103
  const wsq = () => (ws() ? '&ws=' + encodeURIComponent(ws()) : '');
94
104
  // work: the text being edited and not saved yet (null when nothing is); base: the page serialized as drawn, so a save writes back only what was typed
95
- const P = { d, more: null, health: null, lib: undefined, copies: null, cpUrl: '', cpMsg: '', checkRun: null, text: null, log: null, props: null, kept: null, mode: 'read', busy: false, msg: '', why: '', err: null, base: null, work: null, ask: null, askOpen: false, askText: '', pop: null };
105
+ const P = { d, more: null, health: null, lib: undefined, copies: null, cpUrl: '', cpMsg: '', checkRun: null, text: null, log: null, props: null, kept: null, mode: 'read', busy: false, msg: '', why: '', err: null, base: null, work: null, ask: null, askOpen: false, askText: '', pop: null, live: null, stale: false, timer: null };
96
106
  let el = null;
97
107
  const v = () => ((P.log && P.log.revisions) || []).length;
98
108
  const openProp = () => (P.props || []).filter((p) => p.state === 'proposed').slice(-1)[0] || null;
99
109
 
100
- async function load() {
110
+ const stampOf = () => getJson('/api/doc-sheet/stamp?path=' + encodeURIComponent(d.path) + (baseWs() ? '&ws=' + encodeURIComponent(baseWs()) : '') + (iniOf() ? '&ini=' + encodeURIComponent(iniOf()) : ''));
111
+ const shownHash = () => { const r = (P.log && P.log.revisions) || []; return r.length ? r[r.length - 1].after_hash : null; };
112
+ async function load(stamp) {
101
113
  const p = encodeURIComponent(d.path);
102
- P.err = null;
114
+ const s = stamp || (ctx.host ? null : await stampOf());
115
+ if (s && s.ok) P.live = s.ws || null;
116
+ P.err = null; P.stale = false;
103
117
  const [lg, pr] = await Promise.all([getJson('/api/doc-sheet/log?path=' + p + wsq()), getJson('/api/doc-sheet/proposals?path=' + p + wsq())]);
104
118
  P.log = lg && lg.ok ? lg : null;
105
119
  P.props = pr && pr.ok ? pr.proposals || [] : [];
@@ -259,7 +273,7 @@ function makePage(d, ctx) {
259
273
  const o = p ? overlay(P.text, p, P.kept) : null;
260
274
  if (P.mode === 'md') return toolsHtml(p) + `<textarea id="vwMd" class="vwmd" spellcheck="false" aria-label="The file as Markdown">${esc(P.work != null ? P.work : P.text)}</textarea>` + saveRow();
261
275
  const body = o ? overlayBody(h, o) : readBody(h, P.mode === 'edit' && P.work != null ? P.work : P.text);
262
- const unsaved = P.mode === 'read' && P.work != null && P.work !== P.text ? '<p class="vwmut vwline" role="status">You have changes that are not saved yet. Edit shows them again.</p>' : '';
276
+ const unsaved = P.mode === 'read' && P.work != null && P.work !== P.text ? `<p class="vwmut vwline" role="status">You have changes that are not saved yet. Edit shows them again.${P.stale ? ' The chat changed the file since. Cancel there shows the new text.' : ''}</p>` : '';
263
277
  return toolsHtml(p) + (P.mode === 'read' ? moreBar() : '') + unsaved + agentBar(p, o) + (P.mode === 'edit' ? editBar() : '')
264
278
  + `<article class="cf${P.mode === 'edit' ? ' editing' : ''}">${headHtml(h)}<div class="cfb"${P.mode === 'edit' ? ' contenteditable="true" spellcheck="true" aria-label="The page" role="textbox" aria-multiline="true"' : ''}>${body || '<p class="vwmut">The file has no text yet.</p>'}</div>`
265
279
  + `<footer class="cff"><span>${v() ? 'v' + v() + (p ? ' · edited by the agent, not kept yet' : '') : ''}</span><span class="gap"></span><code>${esc(d.path)}</code></footer></article>`
@@ -373,7 +387,7 @@ function makePage(d, ctx) {
373
387
  const p = openProp();
374
388
  if (k === 'mode') { if (P.mode === arg) return; if (P.mode !== 'read') { const t = current(); P.work = t !== P.text ? t : null; } P.mode = arg; P.msg = ''; P.base = null; draw(); return; }
375
389
  if (k === 'more') { P.more = P.more === arg ? null : arg; draw(); if (P.more === 'links' && P.lib === undefined) loadLib(); return; }
376
- if (k === 'open') { openDocPage({ path: arg, title: String(arg).split('/').pop() }, { ws: ctx.ws }); return; }
390
+ if (k === 'open') { openDocPage({ path: arg, title: String(arg).split('/').pop() }, { ws: ctx.ws, ini: ctx.ini }); return; }
377
391
  if (k === 'cplink') {
378
392
  const t = String(($('#vwCpUrl', el) || {}).value || '').trim(), kind = copyKindOf(t); P.cpUrl = t;
379
393
  if (!kind) { P.cpMsg = 'Paste a Confluence page or Google Doc link.'; draw(); const f = $('#vwCpUrl', el); if (f) f.focus(); return; }
@@ -459,6 +473,26 @@ function makePage(d, ctx) {
459
473
  await load(); if (ctx.onWrite) ctx.onWrite();
460
474
  }
461
475
  }
476
+ /** The file changed on disk (a chat wrote it) or moved to the initiative's worktree: read and draw it again, unless the PM has typed something not
477
+ * saved. Then the edit stays and the page says the file changed; a save of it would be refused as stale (409). */
478
+ async function check() {
479
+ P.timer = null;
480
+ if (!el || !el.isConnected) return; // the tab closed: stop checking
481
+ if (!document.hidden && !P.busy && P.text != null) {
482
+ const s = await stampOf();
483
+ if (!el || !el.isConnected) return;
484
+ const moved = s && s.ok && (s.ws || null) !== (P.live || null);
485
+ if (s && s.ok && !P.busy && (moved || s.hash !== shownHash())) {
486
+ if (P.mode === 'read' && P.work == null) await load(s);
487
+ else if (!P.stale) {
488
+ P.stale = true;
489
+ if (P.mode === 'read') draw();
490
+ else { P.msg = STALE; const e = $('#vwErr', el); if (e) e.textContent = STALE; } // no redraw while editing: the caret and the typing stay
491
+ }
492
+ }
493
+ }
494
+ if (el && el.isConnected && !P.timer) P.timer = setTimeout(check, CHECK_MS);
495
+ }
462
496
  async function pollAsk(id) {
463
497
  for (let i = 0; i < 400 && el && el.isConnected; i++) {
464
498
  await new Promise((r) => setTimeout(r, 2000));
@@ -530,11 +564,12 @@ function makePage(d, ctx) {
530
564
 
531
565
  if (ctx.host) { P.mode = 'edit'; el = ctx.host; el.innerHTML = '<p class="vwempty">Reading the file.</p>'; if (!WIRED.has(el)) { WIRED.add(el); wire(el); } load(); return el; }
532
566
  const spec = { id, title: d.title || String(d.path).split('/').pop(), icon: 'doc', render(e) { el = e; draw(); }, wire(e) { if (WIRED.has(e)) return; WIRED.add(e); wire(e); } };
533
- const api = { show(c2) { if (!el || !el.isConnected) { OPEN.delete(id); return makePage(d, c2 || ctx); } if (c2) ctx = c2; el = vwOpen(spec) || el; if (P.mode === 'read') load(); return el; } };
567
+ const api = { show(c2) { if (!el || !el.isConnected) { OPEN.delete(id); return makePage(d, c2 || ctx); } if (c2) ctx = c2; el = vwOpen(spec) || el; if (P.mode === 'read' && P.work == null) load(); watch(); return el; } };
568
+ const watch = () => { if (!P.timer) P.timer = setTimeout(check, CHECK_MS); };
534
569
  OPEN.set(id, api);
535
570
  const pane = vwOpen(spec);
536
571
  if (pane) el = pane;
537
- load();
572
+ load().then(watch);
538
573
  return pane;
539
574
  }
540
575
  const WIRED = new WeakSet();
@@ -494,7 +494,7 @@ let WEEKS = new Map(); // date → weekView, read once per open
494
494
  const q = (o) => Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
495
495
  const toast = (t) => { try { if (typeof window !== 'undefined' && window.pmToast) window.pmToast(t); } catch { /* none */ } };
496
496
  /** This module's sheet (the redesign's parts), added to the page once. */
497
- const CSS = '/pm/cozy-vw-mtg.css';
497
+ const CSS = new URL('./cozy-vw-mtg.css', import.meta.url).href;
498
498
  export function mtgStyle() { if (typeof document === 'undefined' || document.querySelector(`link[href="${CSS}"]`)) return; const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.append(l); }
499
499
  /** The Viewer is wider for a meeting (MtReplay: 780px) while it shows one; the page's own rule sizes it otherwise. */
500
500
  export function widen(k) { const v = typeof document !== 'undefined' && document.getElementById('czViewer'); if (v) { if (k) v.dataset.vzw = k; else delete v.dataset.vzw; } }
@@ -11,7 +11,7 @@
11
11
  * The modules load on first use (dynamic import), so this file has no import cycle with the view modules that import it.
12
12
  * It also adds the Viewer's style sheet (cozy-vw.css) to the page once. */
13
13
 
14
- const CSS = '/pm/cozy-vw.css';
14
+ const CSS = new URL('./cozy-vw.css', import.meta.url).href;
15
15
  export function vzStyle() {
16
16
  if (typeof document === 'undefined' || document.querySelector(`link[href="${CSS}"]`)) return;
17
17
  const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.append(l);
@@ -112,7 +112,7 @@ export function present(deck, ws, start, opt = {}) {
112
112
  if (!w || w.closed) { toast('The browser blocked the audience window. Allow pop-ups for PMOS, then press Audience window again.'); return; }
113
113
  const d = w.document;
114
114
  d.title = 'Audience · ' + deck.title;
115
- if (!d.querySelector('link[data-sl]')) for (const h of ['/pm/cozy.css', '/pm/premium-vw-slides.css']) { const l = d.createElement('link'); l.rel = 'stylesheet'; l.href = location.origin + h; l.dataset.sl = ''; d.head.append(l); }
115
+ if (!d.querySelector('link[data-sl]')) for (const h of ['./cozy.css', './premium-vw-slides.css']) { const l = d.createElement('link'); l.rel = 'stylesheet'; l.href = new URL(h, import.meta.url).href; l.dataset.sl = ''; d.head.append(l); }
116
116
  d.documentElement.dataset.theme = 'dark'; d.body.className = 'cz sl-audw';
117
117
  w.onkeydown = (e) => key(e); w.onresize = drawWin; w.onclick = () => go(1);
118
118
  P.win = w; drawWin(); o.focus();
@@ -0,0 +1,69 @@
1
+ /* pm/prog-move.js — move an initiative out of its program, or to another one (feedback batch 11 item 2, option A agreed 2026-10-26; canvas
2
+ * LpA1More, LpA2Other, LpA3Done, LpA4Phone, LpA5PhoneDone). The initiative's ⋯ gets the two items on the Board panel (bd-ini-panel.js), the Home
3
+ * initiative page (home-ini.js) and the phone sheet that uses the same menu. "Turn into a program" stays for an initiative in no program.
4
+ *
5
+ * moveItems(o) the ⋯ items, or [] when the initiative is in no program:
6
+ * "Move out of <program>" one press, no confirm (POST /api/programs/member leave)
7
+ * "Move to another program ›" the other open programs, "state · N initiatives"; hidden when there is none
8
+ * o: { programs() GET /api/programs' list, ws the initiative's workspace, id, product the product group it lands in, pmPost, say(msg, undo)
9
+ * the page's toast, reload() the page and its programs read again, openList(anchor, label, rows [{ label, sub, icon, go }]) the page's
10
+ * small menu, phone() true on a phone, stateOf?(p) the program's state from programState }
11
+ * outText(program, product, n, phone) the toast: "Moved out of Project Ascent · now under IDPF · off 1 milestone"; a phone says only
12
+ * "Now under IDPF · off 1 milestone". Zero milestones is silence.
13
+ *
14
+ * The leave also takes the initiative off the charter's milestones that wait on it (lib/routes-programs.js answers `off`): a milestone that waits
15
+ * on an initiative that left could never be done. Undo rejoins the old program with `back` = that list, so the milestones wait on it again; the
16
+ * program's order line still names it, so it comes back to its place. Tasks, the KR anchor, the workflow, Jira links and the chat do not move. */
17
+ import { programOf } from './program-model.js';
18
+
19
+ export const OUT_ICON = 'M14 4h6v6M20 4l-8 8M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5';
20
+ export const LAYERS_ICON = 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5M3 17.5l9 5 9-5';
21
+ const ms = (n) => (n ? ' · off ' + n + ' milestone' + (n === 1 ? '' : 's') : '');
22
+
23
+ export function outText(p, product, n, phone) {
24
+ if (phone && product) return 'Now under ' + product + ms(n);
25
+ return 'Moved out of ' + p.title + (product ? ' · now under ' + product : '') + ms(n);
26
+ }
27
+ /** The program's line in the list: its state and how many initiatives it holds ("Running · 3 initiatives"). */
28
+ function subOf(o, p) {
29
+ const n = (p.members || []).length, st = o.stateOf ? o.stateOf(p) : null;
30
+ return (st && st.state ? st.state + ' · ' : '') + n + ' initiative' + (n === 1 ? '' : 's');
31
+ }
32
+ /** The workspace of the initiative's member line: the leave goes beside it, where the ledger folds it. */
33
+ const wsIn = (p, o) => ((p.members || []).find((m) => m.initiative === o.id && (!m.ws || !o.ws || m.ws === o.ws)) || {}).ws || o.ws || null;
34
+
35
+ export function moveItems(o) {
36
+ const L = (o.programs && o.programs()) || [], p = o.id ? programOf(L, o.ws || '', o.id) : null;
37
+ if (!p) return [];
38
+ const out = [{ label: 'Move out of ' + p.title, icon: OUT_ICON, on: () => moveOut(o, p) }];
39
+ const others = L.filter((x) => x && x.id !== p.id && !x.archived);
40
+ if (others.length) {
41
+ out.push({ label: 'Move to another program', icon: LAYERS_ICON, note: '›',
42
+ on: (b) => o.openList(b, 'Move to', others.map((x) => ({ label: x.title, sub: subOf(o, x), icon: LAYERS_ICON, go: () => moveInto(o, p, x) }))) });
43
+ }
44
+ return out;
45
+ }
46
+
47
+ async function moveOut(o, p) {
48
+ const ws = wsIn(p, o);
49
+ const r = await o.pmPost('/api/programs/member', { ws, program: p.id, initiative: o.id, leave: true }).catch(() => null);
50
+ if (!r || !r.ok) { o.say((r && r.error) || 'It did not move out. The server did not say why.'); return; }
51
+ const off = r.off || [];
52
+ o.say(outText(p, o.product, off.length, o.phone && o.phone()), () => back(o, ws, p, off));
53
+ await o.reload();
54
+ }
55
+ async function moveInto(o, p, to) {
56
+ const ws = wsIn(p, o);
57
+ const r = await o.pmPost('/api/programs/member', { ws, program: to.id, initiative: o.id }).catch(() => null);
58
+ if (!r || !r.ok) { o.say((r && r.error) || 'It did not move. The server did not say why.'); return; }
59
+ const off = (r.left && r.left.off) || [];
60
+ o.say('Moved to ' + to.title + ms(off.length), () => back(o, ws, p, off));
61
+ await o.reload();
62
+ }
63
+ /** Undo: rejoin the old program (which leaves the new one), and wait on the milestones again. */
64
+ async function back(o, ws, p, off) {
65
+ const u = await o.pmPost('/api/programs/member', { ws, program: p.id, initiative: o.id, back: off }).catch(() => null);
66
+ o.say(u && u.ok ? 'Back in ' + p.title + '.' : (u && u.error) || 'The undo did not land.');
67
+ await o.reload();
68
+ return u;
69
+ }
@@ -21,7 +21,7 @@ const SV = (d, w = 2) => `<svg viewBox="0 0 24 24" fill="none" stroke="currentCo
21
21
  const GRIP = 'M9 6h.01M9 12h.01M9 18h.01M15 6h.01M15 12h.01M15 18h.01';
22
22
  const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8zM18 15l.7 1.8 1.8.7-1.8.7L18 20l-.7-1.8-1.8-.7 1.8-.7z';
23
23
  const X = 'M6 6l12 12M18 6L6 18', OK = 'M5 12l5 5 9-10', CAL = 'M4 6h16v14H4zM4 10h16M8 3v4M16 3v4M12 13v5M9.5 15.5h5';
24
- const CSS = '/pm/prog-order.css';
24
+ const CSS = new URL('./prog-order.css', import.meta.url).href;
25
25
 
26
26
  /* ── "not now", per program, until a date changes ── */
27
27
  const NN_KEY = 'pmos.order.notnow';
@@ -81,3 +81,6 @@
81
81
  .tkc .ovf { column-gap: 12px; padding: 12px 14px; }
82
82
  .tkc .ovf .tkc-dp { left: -64px; } /* the picker starts at the card's edge, so it stays on the screen */
83
83
  }
84
+ /* the ◇ milestone toggle after a divider (feedback batch 11 item 3, canvas XmlA2Flag) */
85
+ .tkc .seg .vr { width: 1px; height: 20px; background: var(--cz-hair); margin: 0 3px; align-self: center; }
86
+ .tkc .seg .ivq-ms.on { width: auto; padding: 0 12px 0 9px; gap: 6px; background: var(--cz-bluebg); color: var(--cz-blueink); font-weight: 800; font-size: 13px; box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
@@ -57,7 +57,7 @@ export function taskOf(row, extra = {}) {
57
57
  uid: r.uid || '', key: r.key && /^task:/.test(r.key) ? r.key : 'task:' + (r.uid || r.key || ''), title: r.title || '', status: r.status || r.state || 'To do',
58
58
  start: r.start || '', due: r.end || r.due || '', owner: r.owner || '', notes: r.notes || '', ini: r.ini || extra.ini || '',
59
59
  iniTitle: extra.iniTitle || '', group: extra.group != null ? extra.group : '', board: r.board || extra.board || '',
60
- section: typeof r.section === 'string' ? r.section : '', wbs: r.wbs && (r.wbs.title || r.wbs.id) ? { id: r.wbs.id || '', title: r.wbs.title || r.wbs.id } : null,
60
+ section: typeof r.section === 'string' ? r.section : '', milestone: !!r.milestone, wbs: r.wbs && (r.wbs.title || r.wbs.id) ? { id: r.wbs.id || '', title: r.wbs.title || r.wbs.id } : null,
61
61
  jira: jira ? { key: r.ref || r.key || r.uid || '', readAt: r.readAt || extra.readAt || '' } : null,
62
62
  };
63
63
  }
@@ -167,7 +167,10 @@ export function cardHtml(t, o = {}) {
167
167
  const ownerBtn = t.owner
168
168
  ? `<button type="button" class="own-b${oOpen ? ' open' : ''}" data-tkc="owner" aria-label="Owner: ${esc(t.owner)}. Change" title="Owner" aria-expanded="${oOpen}"><span class="av">${esc(initials(t.owner))}</span>${esc(t.owner)}</button>`
169
169
  : `<button type="button" class="own-b ghost${oOpen ? ' open' : ''}" data-tkc="owner" aria-label="Add an owner" title="Owner" aria-expanded="${oOpen}"><span class="av no"></span></button>`;
170
- const facts = `<div class="ovf tkc-f"><span class="k">Status</span><div class="v"><div class="seg" role="radiogroup" aria-label="Status">${seg}</div></div>`
170
+ // after a divider, the ◇ toggle (feedback batch 11 item 3, canvas XmlA2Flag): its due date shows as ◇ on the Board and the timeline
171
+ const msOn = !!t.milestone, msTip = msOn ? 'A milestone. Press to make it a plain task' : 'Make it a milestone: its due date shows as ◇ on the Board and the timeline';
172
+ const msBtn = `<span class="vr" aria-hidden="true"></span><button type="button" class="ivq-ms${msOn ? ' on' : ''}" data-tkc-ms aria-pressed="${msOn}" aria-label="${msOn ? 'Milestone' : 'Make it a milestone'}" title="${msTip}">${ico(I.dia, 15)}${msOn ? 'Milestone' : ''}</button>`;
173
+ const facts = `<div class="ovf tkc-f"><span class="k">Status</span><div class="v"><div class="seg" role="radiogroup" aria-label="Status">${seg}${msBtn}</div></div>`
171
174
  + `<span class="k">Due</span><div class="v"><span class="anc">${dueBtn}${dOpen ? picker(t, o, now) : ''}</span>${late}</div>`
172
175
  + `<span class="k">Owner</span><div class="v"><span class="anc">${ownerBtn}${ownerPop}</span></div></div>`;
173
176
  const notes = `<div class="ovb"><label class="ovl" for="tkcNotes">Notes</label><textarea class="nt" id="tkcNotes" data-tkc-notes rows="2" maxlength="4000" placeholder="Add notes">${esc(t.notes)}</textarea></div>`;
@@ -196,6 +199,7 @@ const WORDS = {
196
199
  notes: () => 'Notes saved',
197
200
  dates: (t) => (dueLine(t).text || 'No dates'),
198
201
  initiative: (t) => 'Moved to ' + (t.iniTitle || t.ini),
202
+ milestone: (t) => (t.milestone ? 'Milestone' : 'Not a milestone'),
199
203
  };
200
204
 
201
205
  export function mountCard(el, t, h) {
@@ -234,6 +238,7 @@ export function mountCard(el, t, h) {
234
238
  const b = e.target.closest('button'); if (!b || b.disabled || !el.contains(b)) return;
235
239
  const d = b.dataset;
236
240
  if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } return; }
241
+ if ('tkcMs' in d) { st.open = null; change('milestone', { milestone: !t.milestone }); return; }
237
242
  if (d.tkcDay != null && b.closest('.tkc-dp')) { pick(d.tkcDay); return; }
238
243
  if (d.tkcField) { st.field = d.tkcField; st.month = ''; draw(); return; }
239
244
  if (d.tkcMonth) { st.month = d.tkcMonth; draw(); return; }
@@ -303,13 +308,15 @@ export function boardSaver(o) {
303
308
  const { ws, board, t, post } = o;
304
309
  return async (patch) => {
305
310
  if (t.jira) {
311
+ // a Jira ticket takes the ◇ flag only (batch 11 item 3); its date stays Jira's
312
+ if (patch.milestone != null) return post('/api/boards/tasks/edit', { ws, board, task: t.jira.key, milestone: !!patch.milestone });
306
313
  if (patch.notes == null) return { ok: false, error: 'Jira owns this. Change it in Jira.' };
307
314
  return post('/api/boards/tickets/note', { ws, board, ref: t.jira.key, notes: patch.notes });
308
315
  }
309
316
  if (patch.status != null) return post('/api/boards/tasks/state', { ws, board, task: t.uid, state: patch.status });
310
317
  if (patch.group != null) return post('/api/initiative-layout', { ws, kind: 'place', initiative: t.ini, task: t.key, group: patch.group });
311
318
  const body = {};
312
- for (const k of ['owner', 'notes', 'start', 'due', 'section', 'initiative']) if (patch[k] != null) body[k] = patch[k];
319
+ for (const k of ['owner', 'notes', 'start', 'due', 'section', 'initiative', 'milestone']) if (patch[k] != null) body[k] = patch[k];
313
320
  return post('/api/boards/tasks/edit', { ws, board, task: t.uid, ...body });
314
321
  };
315
322
  }
@@ -18,7 +18,7 @@ const TICK = 'M5 12l4 4 10-10', RIGHT = 'M10 7l5 5-5 5';
18
18
  const isPhone = () => typeof innerWidth === 'number' && innerWidth <= 760;
19
19
  export function ensureCss() {
20
20
  if (typeof document === 'undefined' || document.querySelector('link[data-tk-css]')) return;
21
- const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '/pm/tk-tasks.css'; l.dataset.tkCss = ''; document.head.appendChild(l);
21
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./tk-tasks.css', import.meta.url).href; l.dataset.tkCss = ''; document.head.appendChild(l);
22
22
  }
23
23
  const viewUrl = (ws, id) => '/api/jira/tickets?initiative=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) : '');
24
24
 
@@ -3246,7 +3246,9 @@ function sessionConversation(s) {
3246
3246
  const found = txFound(s);
3247
3247
  if (found.missing) {
3248
3248
  if (s.agent === 'shell' && /wrote no session record/.test(found.missing)) return { messages: [], state: 'shell', missing: 'No agent is running in this shell yet.' };
3249
- return { messages: [], state: 'unlinked', missing: found.missing };
3249
+ // batch 10 item 1: before its first message Claude Code can wait on its folder trust prompt; the chat shows it as an ask
3250
+ const trust = s.agent === 'claude' ? paneTrust(s) : null;
3251
+ return { messages: [], state: 'unlinked', missing: found.missing, ...(trust ? { ask: trust } : {}) };
3250
3252
  }
3251
3253
  let stamp = null;
3252
3254
  try { const st = fs.statSync(found.file); stamp = `${st.size}:${st.mtimeMs}`; } catch {}
@@ -3277,6 +3279,15 @@ function paneAsk(s, now = Date.now()) {
3277
3279
  s.ask = r.status === 0 && r.stdout ? transcript.permissionAsk(r.stdout, scrub) : null;
3278
3280
  return s.ask;
3279
3281
  }
3282
+ // The folder trust prompt on the pane's screen ({ question, options, trust }), read at most once every 1.5s like paneAsk.
3283
+ function paneTrust(s, now = Date.now()) {
3284
+ if (!s.tmux || !TMUX) return null;
3285
+ if (s.trustAt && now - s.trustAt < 1500) return s.trust || null;
3286
+ s.trustAt = now;
3287
+ const r = tmuxCtl(['capture-pane', '-p', '-t', s.tmux]);
3288
+ s.trust = r.status === 0 && r.stdout ? transcript.trustAsk(r.stdout, scrub) : null;
3289
+ return s.trust;
3290
+ }
3280
3291
  // The pane's visible screen, plain text, or '' (no tmux pane). lib/first-input.js reads Claude Code's input box from it.
3281
3292
  function paneScreen(s) {
3282
3293
  if (!s || !s.tmux || !TMUX) return '';
@@ -3300,7 +3311,7 @@ function paneNotReady(s) {
3300
3311
  const cmd = paneCommand(s);
3301
3312
  if (!cmd) return false;
3302
3313
  if (LOGIN_SHELLS.has(cmd)) return true;
3303
- if (/^(claude|\d+\.\d+\.\d+)$/i.test(cmd)) return firstInput.boxText(paneScreen(s)) === null;
3314
+ if (/^(claude|\d+\.\d+\.\d+)$/i.test(cmd)) { const sc = paneScreen(s); return transcript.trustAsk(sc) ? 'hold' : firstInput.boxText(sc) === null; }
3304
3315
  return false;
3305
3316
  }
3306
3317
  function deliverInput(s, input) {
@@ -3308,6 +3319,7 @@ function deliverInput(s, input) {
3308
3319
  firstInput.deliver(s, input, { screen, wait: screen ? () => paneNotReady(s) : null, onDone: (why) => {
3309
3320
  if (why === 'resubmitted' || why === 'unsent') { try { s.firstInput = { result: why, at: Date.now() }; } catch { /* nothing to keep */ } }
3310
3321
  if (why === 'unsent') { s.note = 'its prompt was typed but not sent'; try { pushSessions(); } catch { /* the next list shows it */ } }
3322
+ if (why === 'held') { s.note = 'its prompt waited on the folder trust question and was not sent'; try { pushSessions(); } catch { /* the next list shows it */ } }
3311
3323
  } });
3312
3324
  }
3313
3325
  function transcriptHarness(s) {
@@ -4012,6 +4024,16 @@ const chatSessions = {
4012
4024
  try { deliverInput(s, t + '\r'); return true; } catch { return false; }
4013
4025
  },
4014
4026
  keys: (id, data) => { const s = sessions.get(String(id || '')); if (!s || !s.pty || s.state === 'exited') return false; try { s.pty.write(String(data)); return true; } catch { return false; } },
4027
+ // batch 10 item 1: answer the folder trust prompt with its n-th answer: arrow keys from the selected one, then Enter
4028
+ pick: (id, n) => {
4029
+ const s = sessions.get(String(id || '')); if (!s || !s.pty || s.state === 'exited') return false;
4030
+ s.trustAt = 0; const q = paneTrust(s);
4031
+ if (!q || !(n >= 1 && n <= q.options.length)) return false;
4032
+ const d = n - q.sel;
4033
+ try { s.pty.write((d > 0 ? '\x1b[B' : '\x1b[A').repeat(Math.abs(d))); setTimeout(() => { try { s.pty.write('\r'); } catch { /* gone */ } }, 200); } catch { return false; }
4034
+ s.trust = null; s.trustAt = Date.now();
4035
+ return true;
4036
+ },
4015
4037
  // slice 4 (PRD L3): the live chat sessions, so a new one can end the longest idle; busy = working or a permission prompt waits
4016
4038
  list: (now = Date.now()) => [...sessions.values()].filter((s) => /^chat:/.test(String(s.origin || '')) && s.pty && s.state !== 'exited')
4017
4039
  .map((s) => ({ id: s.id, origin: s.origin, lastOutputAt: s.lastOutputAt, busy: harness.deriveState(s.state, s.lastOutputAt, now).state === 'working' || sessionShown(s, now) === 'blocked' })),
@@ -6830,6 +6852,8 @@ async function handleRequest(req, res) {
6830
6852
  if (t.length > 8000) return json(res, { ok: false, error: 'The message is too long (8000 characters at most).' }, 400);
6831
6853
  return chatSessions.type(sess.id, t) ? json(res, { ok: true, session: sess.id }) : json(res, { ok: false, error: 'The message did not reach the session.' }, 409);
6832
6854
  }
6855
+ const tp = /^t([1-6])$/.exec(String(body.press)); // the folder trust prompt's n-th answer (batch 10 item 1)
6856
+ if (tp) return chatSessions.pick(sess.id, +tp[1]) ? json(res, { ok: true, session: sess.id }) : json(res, { ok: false, error: 'The question is no longer on the screen.' }, 409);
6833
6857
  const KEYS = { esc: '\x1b', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9' };
6834
6858
  const data = Object.prototype.hasOwnProperty.call(KEYS, String(body.press)) ? KEYS[String(body.press)] : null;
6835
6859
  if (!data) return json(res, { ok: false, error: 'press must be esc or 1 to 9' }, 400);
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* task-milestones-test.js — several milestones per initiative on the page (feedback batch 11 item 3; canvas In development, row "Several
4
+ * milestones per initiative": XmlA1Board, XmlA4Hover, XmlA5Phone, XmlA7Spans, XmlA2Flag, XmlA3Viewer, XmlAGrill). Serves the real page from the
5
+ * real server; GET /api/board-premium answers a board built by lib/board-premium.js from rows and work items that carry the ◇ flag. The page's
6
+ * clock is the fixture's (17 Oct 2026). POST /api/boards/tasks/edit is answered here and its bodies are kept.
7
+ * B the Board row: one ◇ per milestone at its due date, filled when done, orange and an orange date when late (the row's dot turns orange
8
+ * too); the Evaluate task IS the end ◇ (said once); the Deliver task keeps its own ◇ with "◆ Deliver" in its name; the legend says Milestone
9
+ * M close ◇s merge into one counted ◇; pressing it lists them under it; a row opens the task card
10
+ * S Quarter puts a date under each ◇; 5 yr none
11
+ * F the status picker: ◇ after a divider; a press writes milestone true; the List shows ◇ after a milestone's title and asks for a due date
12
+ * V the Tasks Timeline: a milestone's bar ends in its ◇ with the date; a dashed guide drops at its date
13
+ * P the phone: no dates; a tap on the row's lane opens a sheet with its milestones
14
+ * SHOTS_3=<dir>: the Board, the counted ◇'s list, the picker, the Tasks Timeline and the phone sheet, into <dir>. */
15
+ const path = require('path');
16
+ const { spawn } = require('child_process');
17
+ const { findBrowser } = require('./lib/find-browser');
18
+ const T = require('./test-run').configure({ name: 'task-milestones' });
19
+ const BP = require('./lib/board-premium.js');
20
+ const F = require('./fixtures/board-premium-facts.js');
21
+
22
+ const BASE = T.BASE;
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} task-milestones assertions passed`);
32
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
33
+ };
34
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
35
+
36
+ const ROWS = [
37
+ F.row('scarlet', 'Scarlet — ST What’s The News', { owner: 'Wawan', stage: 'Build', start: '2026-11-02', end: '2027-03-31', progress: 30 }),
38
+ F.row('passkey', 'Passkey sign-in', { owner: 'Lee', start: '2026-09-15', end: '2027-02-26', progress: 45 }),
39
+ F.row('recovery', 'Recovery codes', { owner: 'Dara', start: '2026-12-01', end: '2027-04-30', progress: 10 }),
40
+ F.row('email-otp', 'Email OTP', { start: '2026-11-10', end: '2027-06-30', progress: 5 }),
41
+ ];
42
+ const it = (ini, uid, title, o) => ({ uid, key: '', kind: 'Task', src: 'pmos', title, status: 'To do', owner: 'Wawan', ini, start: null, end: null, ref: uid, board: 'w1', milestone: true, ...o });
43
+ const ITEMS = [
44
+ it('scarlet', 'task-pilot', 'Pilot with 2 newsrooms', { status: 'Done', start: '2026-11-02', end: '2026-12-11', section: 'build' }),
45
+ it('scarlet', 'task-api', 'Ship the article summaries API', { status: 'In progress', start: '2026-11-02', end: '2027-01-08', section: 'build', milestone: false }),
46
+ it('scarlet', 'task-feat', 'Feature delivered', { start: '2027-01-18', end: '2027-01-29', section: 'deliver' }),
47
+ it('scarlet', 'task-kpi', 'KPI evaluated', { start: '2027-03-22', end: '2027-03-31', section: 'evaluate' }),
48
+ it('scarlet', 'task-faq', 'Support FAQ', { section: 'evaluate', end: null }),
49
+ it('passkey', 'task-late', 'Beta to staff', { start: '2026-10-01', end: '2026-10-16' }),
50
+ it('passkey', 'task-pk2', 'Rollout 50%', { end: '2026-12-18' }),
51
+ it('recovery', 'task-c1', 'Codes live', { end: '2027-03-02' }),
52
+ it('recovery', 'task-c2', 'Support FAQ live', { end: '2027-03-06' }),
53
+ it('recovery', 'task-wont', 'Dropped', { end: '2027-02-01', status: "Won't do" }),
54
+ ];
55
+
56
+ (async () => {
57
+ const exe = findBrowser();
58
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
59
+ let chromium;
60
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
61
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
62
+ await T.waitForServer(BASE);
63
+ browser = await chromium.launch({ executablePath: exe });
64
+
65
+ /** The Board on the timeline. o: { w, h, span, dark, tasksView } */
66
+ const open = async (o = {}) => {
67
+ const ctx = await browser.newContext({ viewport: { width: o.w || 1440, height: o.h || 900 }, colorScheme: o.dark ? 'dark' : 'light', hasTouch: !!o.phone, isMobile: !!o.phone });
68
+ const page = await ctx.newPage();
69
+ const errors = [], posts = [];
70
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
71
+ await page.clock.setFixedTime(new Date(F.NOW));
72
+ const rows = ROWS.map((r) => ({ ...r }));
73
+ await page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.facts({ rows, total: rows.length, columns: [], items: ITEMS.map((x) => ({ ...x })) })), as_of: Date.now() }) }));
74
+ await page.route('**/api/programs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, programs: [] }) }));
75
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'not in this check' }) }));
76
+ await page.route('**/api/boards/tasks/edit', (r) => { posts.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, from: { milestone: false } }) }); });
77
+ await page.addInitScript(([s]) => { try { if (!sessionStorage.getItem('set')) { sessionStorage.setItem('set', '1'); for (const [k, v] of Object.entries(s)) localStorage.setItem(k, v); } } catch { /* none */ } }, [{ 'pmos.board.view': 'time', 'pmos.board.pview': 'time', 'pmos.board.span': o.span || 'year', 'pmos.tasks.view': o.tasksView || 'list', 'pmos.tasks.zoom': 'month' }]);
78
+ await page.goto(BASE + '/premium-board.html?ws=w1&board=w1');
79
+ await page.waitForSelector('#ibBody [data-row]', { timeout: 15000 });
80
+ await page.waitForTimeout(500);
81
+ return { ctx, page, errors, posts };
82
+ };
83
+ const shots = process.env.SHOTS_3;
84
+ const shot = async (p, name) => { if (shots) await p.screenshot({ path: path.join(shots, name + '.png') }); };
85
+ const rowOf = (p, key) => p.evaluate((k) => {
86
+ const r = document.querySelector(`#ibBody [data-row="${k}"]`); if (!r) return null;
87
+ return {
88
+ dot: (r.querySelector('.cz-dot') || {}).className || '',
89
+ tm: [...r.querySelectorAll('.tg-tm')].map((x) => x.className + '|' + x.getAttribute('title')),
90
+ tmc: [...r.querySelectorAll('.tg-tmc')].map((x) => x.className + '|' + x.textContent + '|' + x.dataset.msIds),
91
+ tml: [...r.querySelectorAll('.tg-tml')].map((x) => x.className + '|' + x.textContent),
92
+ end: r.querySelector('.tg-end') ? r.querySelector('.tg-end').className + '|' + r.querySelector('.tg-end').getAttribute('title') : '',
93
+ };
94
+ }, key);
95
+
96
+ /* B M — desktop, Year */
97
+ {
98
+ const { ctx, page: p, errors } = await open();
99
+ const sc = await rowOf(p, 'board:scarlet');
100
+ ok('B one ◇ per milestone: the done Pilot filled, Feature delivered open with "◆ Deliver" in its name; no ◇ for a plain task or one with no due date',
101
+ sc && sc.tm.length === 2 && /tg-tm dn\|Pilot with 2 newsrooms · Dec 11 · done/.test(sc.tm[0]) && /^tg-tm\|Feature delivered · Jan 29 · ◆ Deliver$/.test(sc.tm[1]), JSON.stringify(sc));
102
+ ok('B said once: the Evaluate task IS the end ◇ and takes its name; it is not drawn again', sc && /^tg-end\|KPI evaluated · Mar 31 · ◆ Evaluate$/.test(sc.end) && !sc.tm.some((x) => /KPI/.test(x)), JSON.stringify(sc));
103
+ ok('S Year cuts each date to fit and puts it under its ◇', sc && sc.tml.map((x) => x.split('|')[1]).join() === 'Dec 11,Jan 29', JSON.stringify(sc && sc.tml));
104
+ const pk = await rowOf(p, 'board:passkey');
105
+ ok('B a late milestone: an orange outline and an orange date, and the row\'s dot turns orange', pk && /tg-tm late/.test(pk.tm[0]) && /tg-tml late\|Oct 16/.test(pk.tml[0]) && /cz-dot late/.test(pk.dot), JSON.stringify(pk));
106
+ const rc = await rowOf(p, 'board:recovery');
107
+ ok('M two milestones four days apart merge into one counted ◇ with the range under it; Won\'t do is not drawn', rc && rc.tm.length === 0 && rc.tmc.length === 1 && /^tg-tmc\|2\|task-c1 task-c2$/.test(rc.tmc[0]) && rc.tml.join() === 'tg-tml|Mar 2–6', JSON.stringify(rc));
108
+ const lg = await p.evaluate(() => (document.querySelector('#bdChipset .tg-lgd') || document.querySelector('.tg-lgd') || {}).textContent || '');
109
+ ok('B the legend says Milestone, not "Deliver or Evaluate"', /Milestone/.test(lg) && !/Deliver or Evaluate/.test(lg), lg);
110
+ await shot(p, 'milestones-board-1440');
111
+ await p.click('#ibBody [data-row="board:recovery"] .tg-tmc');
112
+ const list = await p.evaluate(() => { const m = document.querySelector('.tg-msp'); return m ? [...m.querySelectorAll('[data-ms-open]')].map((b) => b.textContent) : null; });
113
+ ok('M the counted ◇ lists its milestones right under it: ◇, name, date', list && list.join('|') === 'Codes liveMar 2|Support FAQ liveMar 6', JSON.stringify(list));
114
+ await shot(p, 'milestones-board-list-1440');
115
+ await p.keyboard.press('Escape');
116
+ ok('M Escape closes the list', await p.evaluate(() => !document.querySelector('.tg-msp')));
117
+ ok('the Board threw nothing', !errors.length, errors.join('\n'));
118
+ await ctx.close();
119
+ }
120
+
121
+ /* S — Quarter and 5 yr */
122
+ {
123
+ const { ctx, page: p } = await open({ span: 'quarter' });
124
+ const sc = await rowOf(p, 'board:scarlet');
125
+ ok('S Quarter puts a short date under every ◇', sc && sc.tml.map((x) => x.split('|')[1]).join() === 'Dec 11,Jan 29', JSON.stringify(sc && sc.tml));
126
+ await ctx.close();
127
+ const { ctx: c5, page: p5 } = await open({ span: 'y5' });
128
+ const s5 = await rowOf(p5, 'board:scarlet');
129
+ ok('S 5 yr draws the ◇s with no dates', s5 && !s5.tml.length && (s5.tm.length + s5.tmc.length) >= 1, JSON.stringify(s5));
130
+ await c5.close();
131
+ }
132
+
133
+ /* F V — the initiative panel: the List, the status picker, the Tasks Timeline */
134
+ {
135
+ const { ctx, page: p, errors, posts } = await open();
136
+ await p.click('#ibBody [data-key="board:scarlet"]');
137
+ await p.waitForSelector('.iv-tr', { timeout: 8000 });
138
+ // every stage open, so each task row is drawn
139
+ const unfold = async (sel) => { for (let i = 0; i < 12; i++) { const b = await p.$(sel); if (!b) break; await b.click(); await p.waitForTimeout(80); } };
140
+ await unfold('.iv-ws[data-iv-fold^="sec:"][aria-expanded="false"]');
141
+ const rows = await p.evaluate(() => [...document.querySelectorAll('.iv-tr')].map((r) => ({ t: (r.querySelector('.iv-tt') || {}).textContent, ms: !!r.querySelector('.iv-ms'), ask: (r.querySelector('.iv-dc.ms') || {}).textContent || '' })));
142
+ const by = (t) => rows.find((x) => x.t === t) || {};
143
+ ok('F the List shows a small ◇ after a milestone task\'s title, none after a plain task', by('Feature delivered').ms && by('KPI evaluated').ms && !by('Ship the article summaries API').ms, JSON.stringify(rows));
144
+ ok('F a milestone with no due date asks for it in a dashed chip', by('Support FAQ').ask === 'Set the due date', JSON.stringify(by('Support FAQ')));
145
+ await p.click('.iv-tr:has(.iv-tt:text-is("Ship the article summaries API")) .iv-car');
146
+ const pick = await p.evaluate(() => { const b = document.querySelector('.ivq-st .ivq-ms'); return b ? { lbl: b.getAttribute('aria-label'), tip: b.getAttribute('title'), pressed: b.getAttribute('aria-pressed'), vr: document.querySelectorAll('.ivq-st .vr').length, text: b.textContent } : null; });
147
+ ok('F the status picker holds ◇ after a divider, icon only, its tooltip says what it does', pick && pick.lbl === 'Make it a milestone' && pick.pressed === 'false' && pick.vr === 2 && pick.text === '' && /due date shows as ◇ on the Board and the timeline/.test(pick.tip), JSON.stringify(pick));
148
+ await shot(p, 'milestones-picker-1440');
149
+ await p.click('.ivq-st .ivq-ms'); await p.waitForTimeout(300);
150
+ ok('F pressing ◇ writes milestone true for that task', posts.length === 1 && posts[0].task === 'task-api' && posts[0].milestone === true, JSON.stringify(posts));
151
+ // the Tasks Timeline
152
+ await p.evaluate(() => { const b = document.querySelector('[data-iv-view="timeline"]'); if (b) b.click(); });
153
+ await p.waitForSelector('.ivt', { timeout: 5000 });
154
+ await unfold('.ivt-gh[data-iv-fold^="sec:"][aria-expanded="false"]');
155
+ const tv = await p.evaluate(() => ({ ms: [...document.querySelectorAll('.ivt-ms')].map((x) => x.className + '|' + x.textContent), guides: document.querySelectorAll('.ivt-grid i.ms').length, lg: (document.querySelector('.ivt-lg') || {}).textContent || '' }));
156
+ ok('V a milestone\'s bar ends in its ◇ with the date beside it; a done one filled', tv.ms.some((x) => /^ivt-ms dn\|Dec 11$/.test(x)) && tv.ms.some((x) => /^ivt-ms\|Jan 29$/.test(x)) && tv.ms.some((x) => /^ivt-ms\|Mar 31$/.test(x)), JSON.stringify(tv));
157
+ ok('V a faint dashed guide drops at each milestone date, and the legend names Milestone', tv.guides === 3 && /Milestone/.test(tv.lg), JSON.stringify(tv));
158
+ await shot(p, 'milestones-viewer-timeline-1440');
159
+ ok('the panel threw nothing', !errors.length, errors.join('\n'));
160
+ await ctx.close();
161
+ }
162
+
163
+ /* P — the phone */
164
+ {
165
+ const { ctx, page: p, errors } = await open({ w: 390, h: 844, phone: true });
166
+ const sc = await rowOf(p, 'board:scarlet');
167
+ ok('P the phone draws the ◇s with no dates', sc && sc.tm.length === 2 && !sc.tml.length, JSON.stringify(sc));
168
+ await p.click('#ibBody .tgq-r[data-row="board:scarlet"] > .tg-p', { position: { x: 300, y: 10 } });
169
+ const sh = await p.evaluate(() => { const m = document.querySelector('.tg-msp.sh'); return m ? { h: (m.querySelector('.h') || {}).textContent, rows: [...m.querySelectorAll('[data-ms-open]')].map((b) => b.textContent) } : null; });
170
+ ok('P a tap on the row opens a sheet with its milestones, the end one too', sh && sh.h === 'Scarlet — ST What’s The News' && sh.rows.join('|') === 'Pilot with 2 newsroomsDec 11|Feature deliveredJan 29|KPI evaluatedMar 31', JSON.stringify(sh));
171
+ await shot(p, 'milestones-phone-390');
172
+ ok('the phone threw nothing', !errors.length, errors.join('\n'));
173
+ await ctx.close();
174
+ }
175
+ finish();
176
+ })();