create-pmos 0.421.0 → 0.423.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 (112) 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 +87 -3
  8. package/workspace/briefing-premium-adddoc-test.js +1 -1
  9. package/workspace/briefing-premium-board-test.js +13 -11
  10. package/workspace/briefing-premium-initiative-test.js +30 -38
  11. package/workspace/changelog.json +24 -0
  12. package/workspace/fixtures/report-api/draft.json +2 -1
  13. package/workspace/guide/briefing-premium.md +2 -1
  14. package/workspace/guide/home.md +14 -4
  15. package/workspace/guide/programs.md +5 -3
  16. package/workspace/guide/workflows.md +5 -1
  17. package/workspace/home-other-product-test.js +55 -0
  18. package/workspace/ini-workflow-test.js +4 -4
  19. package/workspace/lib/board-premium.js +21 -6
  20. package/workspace/lib/custom-docs.js +65 -3
  21. package/workspace/lib/doc-live-root.js +37 -0
  22. package/workspace/lib/engine/anchor-resolve.js +93 -15
  23. package/workspace/lib/engine/boards.js +30 -2
  24. package/workspace/lib/engine/intake.js +1 -1
  25. package/workspace/lib/hold-spans.js +24 -10
  26. package/workspace/lib/initiative-writer.js +63 -1
  27. package/workspace/lib/kg.js +1 -1
  28. package/workspace/lib/plan-items.js +36 -5
  29. package/workspace/lib/programs.js +11 -3
  30. package/workspace/lib/report-draft.js +3 -0
  31. package/workspace/lib/route-modules.js +2 -0
  32. package/workspace/lib/routes-board-premium.js +28 -0
  33. package/workspace/lib/routes-boards.js +92 -13
  34. package/workspace/lib/routes-doc-sheet.js +29 -1
  35. package/workspace/lib/routes-initiatives.js +12 -0
  36. package/workspace/lib/routes-programs.js +44 -5
  37. package/workspace/lib/routes-task-links.js +329 -0
  38. package/workspace/lib/routes-task-plans.js +333 -0
  39. package/workspace/lib/split-merge-suggest.js +162 -0
  40. package/workspace/lib/split-merge.js +379 -0
  41. package/workspace/lib/task-cli.js +73 -13
  42. package/workspace/lib/task-items.js +15 -3
  43. package/workspace/lib/task-links.js +422 -0
  44. package/workspace/lib/task-plans.js +232 -0
  45. package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
  46. package/workspace/lib/vendor/scripts/intake.js +1 -1
  47. package/workspace/package-lock.json +2 -2
  48. package/workspace/package.json +1 -1
  49. package/workspace/premium-board-actions-test.js +2 -2
  50. package/workspace/premium-core-doc-issue-test.js +2 -2
  51. package/workspace/premium-vw-backlog-test.js +3 -3
  52. package/workspace/premium-vw-doc-test.js +26 -3
  53. package/workspace/premium-vw-item-test.js +3 -3
  54. package/workspace/premium-vw-jira-test.js +6 -6
  55. package/workspace/product-lane-test.js +165 -0
  56. package/workspace/program-leave-test.js +203 -0
  57. package/workspace/program-panel-test.js +1 -1
  58. package/workspace/public/pm/bd-acts.js +5 -2
  59. package/workspace/public/pm/bd-ini-panel.js +32 -9
  60. package/workspace/public/pm/bd-prog-panel.js +22 -7
  61. package/workspace/public/pm/bd-prog.js +6 -1
  62. package/workspace/public/pm/bd-span.js +234 -30
  63. package/workspace/public/pm/bd-views.js +3 -2
  64. package/workspace/public/pm/cozy-board.css +90 -0
  65. package/workspace/public/pm/cozy-home.css +3 -0
  66. package/workspace/public/pm/doc-follow.js +36 -0
  67. package/workspace/public/pm/home-app.js +62 -14
  68. package/workspace/public/pm/home-ini-model.js +0 -34
  69. package/workspace/public/pm/home-ini.js +81 -204
  70. package/workspace/public/pm/home-list.js +2 -2
  71. package/workspace/public/pm/home-today.js +3 -1
  72. package/workspace/public/pm/ini-groups.js +228 -0
  73. package/workspace/public/pm/ini-links.js +561 -0
  74. package/workspace/public/pm/ini-tasks.js +131 -30
  75. package/workspace/public/pm/ini-versions.js +348 -0
  76. package/workspace/public/pm/ini-view-model.js +113 -43
  77. package/workspace/public/pm/ini-view.css +341 -18
  78. package/workspace/public/pm/ini-view.js +153 -38
  79. package/workspace/public/pm/premium-board.js +160 -21
  80. package/workspace/public/pm/premium-report-read.js +20 -1
  81. package/workspace/public/pm/premium-shell.js +29 -4
  82. package/workspace/public/pm/premium-vw-doc.js +46 -11
  83. package/workspace/public/pm/prog-move.js +69 -0
  84. package/workspace/public/pm/split-merge.css +77 -0
  85. package/workspace/public/pm/split-merge.js +265 -0
  86. package/workspace/public/pm/stage-line.js +414 -0
  87. package/workspace/public/pm/task-card.css +3 -0
  88. package/workspace/public/pm/task-card.js +15 -6
  89. package/workspace/public/pm/wf-page.css +2 -0
  90. package/workspace/public/pm/wf-page.js +2 -0
  91. package/workspace/public/pm/wf-stage.js +2 -1
  92. package/workspace/server.js +15 -1
  93. package/workspace/split-merge-ui-test.js +175 -0
  94. package/workspace/stage-card-test.js +12 -11
  95. package/workspace/task-card-test.js +3 -2
  96. package/workspace/task-delete-test.js +126 -0
  97. package/workspace/task-links-test.js +227 -0
  98. package/workspace/task-milestones-test.js +176 -0
  99. package/workspace/task-plans-test.js +181 -0
  100. package/workspace/task-views-test.js +3 -3
  101. package/workspace/test-lists/bd-ini-panel.json +8 -2
  102. package/workspace/test-lists/product-lane.json +6 -0
  103. package/workspace/test-lists/program-leave.json +6 -0
  104. package/workspace/test-lists/split-merge.json +15 -0
  105. package/workspace/test-lists/task-delete.json +5 -0
  106. package/workspace/test-lists/task-links.json +6 -0
  107. package/workspace/test-lists/task-milestones.json +6 -0
  108. package/workspace/test-lists/task-plans.json +6 -0
  109. package/workspace/test-lists/viewer-live-file.json +9 -0
  110. package/workspace/timeline-holds-test.js +61 -4
  111. package/workspace/tk-tasks-test.js +173 -57
  112. package/workspace/workflows-setup-test.js +4 -3
@@ -18,11 +18,12 @@
18
18
  * chip row picks one (its own stages become the columns and the track's header) or All (the three categories, each row its own stages).
19
19
  * Where no record holds a value for an initiative, the element says so: nothing is invented. */
20
20
  import { pmPost } from './http.js';
21
+ import { followDoc } from './doc-follow.js';
21
22
  import { $, $$, esc, store, crumbHtml, wireCrumb, chatAbout, setPageGaps } from './premium-shell.js';
22
23
  import { mountNav } from './cozy-nav.js';
23
24
  import { mountLivePill } from './cozy-live-pill.js';
24
25
  import { stepsHelpHtml } from './bd-stages.js';
25
- import { timelineHtml, legendHtml, hasHold, SPANS, md } from './bd-span.js';
26
+ import { timelineHtml, legendHtml, hasHold, planKeys, gapKeys, plainGaps, skipsOf, skipWords, gapWords, SPANS, md } from './bd-span.js';
26
27
  import * as TL from './bd-scroll.js';
27
28
  import * as Acts from './bd-acts.js';
28
29
  import * as V from './bd-views.js';
@@ -30,10 +31,13 @@ import * as WF from './bd-wf.js';
30
31
  import * as Asks from './bd-asks.js';
31
32
  import * as PG from './bd-prog.js';
32
33
  import { programOf } from './program-model.js';
33
- import { open as viewerOpen } from './cozy-viewer.js';
34
+ import { open as viewerOpen, current as viewerCur } from './cozy-viewer.js';
34
35
  import * as VW from './cozy-viewer.js';
35
36
  import * as PP from './bd-prog-panel.js';
36
- import * as PO from './prog-order.js'; // the order of a program's initiatives: the grip and Claude's order from the dates (canvas RoADrag, RoASuggest)
37
+ import * as PO from './prog-order.js';
38
+ import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
39
+ import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other)
40
+ import * as Pop from './bd-pop.js'; // the order of a program's initiatives: the grip and Claude's order from the dates (canvas RoADrag, RoASuggest)
37
41
  import * as BI from './bd-ini-panel.js';
38
42
  import { nextHtml } from './bd-next.js';
39
43
  import { statusOf as ivStatus } from './ini-view-model.js';
@@ -54,7 +58,9 @@ const F = { chips: new Set(), q: '', owners: new Set(), cats: new Set(), sprints
54
58
  let GR = {}; // the first questions still open per initiative (GET /api/board-grill?ids=): { [id]: { open, total, later } }
55
59
  let PGS = []; // the programs (GET /api/programs): every view groups the rows a program holds under it (PgBoard)
56
60
  let XR = {}; // the other products' rows a program here holds, read once (GET /api/board-premium?ws=): { [ws]: { name, rows } }
57
- const ALL = new URLSearchParams(location.search).get('all') === '1'; // All products: every product's board on one page (PgBoard)
61
+ // the products picked (batch 11 item 7): ?all=1 every product, ?pick=<ws>|<board> repeated several, else one board
62
+ const PICK = new URLSearchParams(location.search).getAll('pick').filter((x) => /\|/.test(x));
63
+ const ALL = new URLSearchParams(location.search).get('all') === '1' || PICK.length > 1; // All products, or several: their boards on one page (PgBoard)
58
64
  let byProduct = store.get(GROUPING_KEY) === 'product'; // the grouping: programs first (default) or By product (PgBoardProduct)
59
65
  let DM = {}; // the documents' history (GET /api/board-docs): { [path]: { changed, by, log } }
60
66
  let peek = null; // what the Viewer shows for the Board: { kind: 'ini', key } an initiative or its ticket, { kind: 'acts' } an acts panel
@@ -139,10 +145,21 @@ function drawHead() {
139
145
  crumbed = true;
140
146
  // the picker: All products first when there is more than one product, then each product's board
141
147
  const list = M.board.switcher || [], boards = list.length > 1 ? [{ ws: '*', id: '*', name: 'All products' }, ...list] : list;
148
+ // the button says it once: All products, the one product, or the first product and "+N" (several)
149
+ const names = (M.board.products || []).map((p) => p.name), some = ALL && PICK.length > 1;
150
+ const label = some ? esc(names[0] || 'Products') + ' <b>+' + (names.length - 1) + '</b>' : esc(M.board.name || 'Board');
142
151
  $('#crumbHost').innerHTML = crumbHtml({ page: '', board: M.board.name || 'Board', boards });
143
- wireCrumb({ boards, board: ALL ? '*' : M.board.id, goBoard: (ws, id) => location.assign(id === '*' ? '/premium-board.html?all=1' : '/premium-board.html?ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(id)) });
144
- $('#crBoard').setAttribute('aria-label', 'Product: ' + (M.board.name || 'Board'));
145
- chatAbout('board:this-board', ALL ? 'all products' : M.board.name ? 'the ' + M.board.name + ' board' : 'this board');
152
+ $('#crBoard').innerHTML = label;
153
+ // several products can be ticked (batch 11 item 7); the pick goes into the address, so a reload keeps it
154
+ const picked = !ALL ? [M.board.ws + '|' + M.board.id] : (M.board.products || []).map((p) => p.ws + '|' + p.id);
155
+ const goBoard = (ws, id) => location.assign(id === '*' ? '/premium-board.html?all=1' : '/premium-board.html?ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(id));
156
+ wireCrumb({ boards, board: ALL ? '*' : M.board.id, goBoard, picked: list.length > 1 ? picked : null, goPicked: (keys) => {
157
+ if (keys.length === list.length) return goBoard('*', '*');
158
+ if (keys.length === 1) { const [ws, id] = keys[0].split('|'); return goBoard(ws, id); }
159
+ location.assign('/premium-board.html?' + keys.map((k) => 'pick=' + encodeURIComponent(k)).join('&'));
160
+ } });
161
+ $('#crBoard').setAttribute('aria-label', 'Product: ' + (some ? names.join(', ') : M.board.name || 'Board'));
162
+ chatAbout('board:this-board', some ? 'the ' + names.join(', ') + ' boards' : ALL ? 'all products' : M.board.name ? 'the ' + M.board.name + ' board' : 'this board');
146
163
  }
147
164
  $('#snap').textContent = M.header.text;
148
165
  // PMOS-self: new work starts at the pmos-router skill. All products: New asks which product the initiative is for
@@ -171,7 +188,7 @@ function drawChips() {
171
188
  }
172
189
  // the timeline's legend sits at the end of the chip row (PgTimeline), with a program milestone only where a program is drawn and "On hold" only
173
190
  // where a hold is drawn (feedback batch 9 item 8: zero is silence)
174
- const lgd = view === 'time' && span !== 'sprint' ? '<span class="bd-sp"></span>' + legendHtml(!byProduct && !!groups(visible()), hasHold(visible())) : '';
191
+ const lgd = view === 'time' && span !== 'sprint' ? '<span class="bd-sp"></span>' + legendHtml(!byProduct && !!groups(visible()), hasHold(visible()), { ...planKeys(visible()), ...gapKeys(visible()) }) : '';
175
192
  $('#bdChipset').innerHTML = jiraChip
176
193
  + (ALL ? '' : `<button type="button" class="bd-chip" id="chSprint" aria-haspopup="dialog">${SV(I.cal)}<span>${esc(sprint)}</span></button>`)
177
194
  + askChip + '<span class="bd-vr"></span>' + flt(['late', 'risk', 'blocked', 'idle'])
@@ -330,7 +347,7 @@ function trackRow(r, cls = '', po = false) {
330
347
  }).join('');
331
348
  const many = TK.mode === 'cats'; // All: each row names its workflow with its icon (WfATrack)
332
349
  return `<div class="bt-r bt-l${cls}${peek && peek.key === r.key && peek.kind !== 'acts' ? ' sel' : ''}${r.acts && r.acts.life === 'hold' ? ' held' : ''}" role="row" data-row="${esc(r.key)}"${po ? ` data-po-id="${esc(r.id)}"` : ''}>${po ? PO.gripHtml(r.title) : ''}`
333
- + `<button type="button" class="ini2 bt-nm" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${r.inProgram ? PG.memberIcon(PGS, r.inProgram) : ''}${many ? WF.wfIcon(WF.wfOf(r), 18) : ''}${esc(r.title)}</b><span class="cs s-${s.tone}"><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span><span class="bt-pst">${t.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(t.label)} · ${DAYS(t)}</span></button>`
350
+ + `<button type="button" class="ini2 bt-nm" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${r.inProgram ? PG.memberIcon(PGS, r.inProgram) : ''}${many ? WF.wfIcon(WF.wfOf(r), 18) : ''}${SM.nameHtml(r)}</b><span class="cs s-${s.tone}"><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span><span class="bt-pst">${t.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(t.label)} · ${DAYS(t)}</span></button>`
334
351
  + `<div class="${cellsCls()}" role="presentation"${cellsStyle()}>${cells}</div>`
335
352
  + `<div class="bt-dl" role="cell">${nextHtml(r, { self: M.board.self, icon: !PHONE.matches })}</div></div>`; // the Next cell (XocA): what finishes the step next
336
353
  }
@@ -380,7 +397,7 @@ function drawTrack(L) {
380
397
  /* ── the timeline (AgBoardTimeline; TsCOpen, TsCDesk, TsAllSpans, TsCPhone) ───────────────────────────────────────── */
381
398
  function drawTime(L) {
382
399
  const S = M.steps || [], phone = PHONE.matches, bw = $('#ibBody').clientWidth || innerWidth;
383
- const T = timelineHtml(L, M, span, { groups: groups(L), progState, folded: PG.folded, prodHtml: (g) => PG.prodHtml(g, 'tg-prd'), subHtml: (n) => PG.subHtml(n, 'tg-psb'), progTile: () => PG.progTile(), productsOf: PG.productsOf,
400
+ const T = timelineHtml(L, M, span, { groups: groups(L), progState, folded: PG.folded, prodHtml: (g) => PG.prodHtml(g, 'tg-prd'), prodCell: (g) => PG.prodCell(g), subHtml: (n) => PG.subHtml(n, 'tg-psb'), progTile: () => PG.progTile(), productsOf: PG.productsOf,
384
401
  foldBtn: (g) => PG.foldBtn(g.key, g.program.title), memberIcon: (id) => PG.memberIcon(PGS, id), sel: peek && peek.kind !== 'acts' ? peek.key : null, status: statusOf, phone, trackPx: bw - 2 - (phone ? 0 : matchMedia('(max-width: 980px)').matches ? 180 : 250), avatar: (n) => V.avatar(n, 'sm'),
385
402
  askHref: (none) => askHref(null, 'Propose start and end dates for ' + none.map((r) => r.title).join(', ')) });
386
403
  return T.html;
@@ -472,6 +489,15 @@ $('#ibBody').addEventListener('click', (e) => {
472
489
  const tk = e.target.closest('[data-tk]'); if (tk) { openTicket(tk.dataset.ini, tk.dataset.tk, tk); return; }
473
490
  if (e.target.closest('[data-act], [data-hold]')) return; // pm/bd-acts.js handles its own presses (a ⏸ on the timeline opens its hold there)
474
491
  const pg = e.target.closest('[data-prog]'); if (pg) { PG.openProgram(pg.dataset.prog, pg); return; }
492
+ // a counted milestone ◇ lists its milestones right under it; on a phone the row's bar lane opens them in a sheet (batch 11 item 3)
493
+ const mc = e.target.closest('[data-ms-row]'); if (mc) { msPop(mc, rowOf(mc.dataset.msRow), mc.dataset.msIds.split(' ')); return; }
494
+ // a product lane's counted ◇ lists its milestones with their initiatives; on a phone a tap on the lane lists them all in a sheet (batch 11 item 17)
495
+ const ml = e.target.closest('[data-ms-lane]'); if (ml) { lanePop(ml, ml.dataset.msLane); return; }
496
+ const pl = PHONE.matches && e.target.closest('.tgq-r.tg-lane > .tg-p[data-lane-ms]'); if (pl) { lanePop(pl, pl.dataset.laneMs, pl.dataset.laneName); return; }
497
+ // a gap's press (batch 11 item 13): its words, and + New task with its dates while part of it is ahead
498
+ const gp = e.target.closest('[data-gap]'); if (gp) { gapPop(gp, rowOf(gp.dataset.gap)); return; }
499
+ // the phone's row sheet lists the milestones, the gaps and the skipped stages in date order (XmlA5Phone, XgapA3Phone)
500
+ const lane = PHONE.matches && e.target.closest('.tgq-r[data-row] > .tg-p'); if (lane) { const r = rowOf(lane.parentElement.dataset.row); if (r && ((r.milestones || []).length || plainGaps(r).length || skipsOf(r).length)) { msPop(lane, r, null, true); return; } }
475
501
  const b = e.target.closest('[data-key]'); if (b) openIni(rowOf(b.dataset.key), b, view === 'time' ? 'time' : 'track');
476
502
  });
477
503
  $('#ibBody').addEventListener('keydown', (e) => { if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('[data-steps]')) { e.preventDefault(); togglePop('popSteps', e.target); } });
@@ -532,6 +558,35 @@ async function turnProgram(r) {
532
558
  say('Now a program · ' + r.title + '.');
533
559
  PG.openProgram(res.program.id);
534
560
  }
561
+ /** The ⋯ items of an initiative in a program: Move out of it, Move to another program (pm/prog-move.js). The rows stay; the panel stays on it. */
562
+ function moveItems(r) {
563
+ return PM.moveItems({ programs: () => PGS, ws: r.ws || M.board.ws || '', id: r.id, product: r.product || M.board.product || M.board.name || '', pmPost, say,
564
+ reload: async () => { await loadPrograms(); load(); }, phone: () => PHONE.matches, stateOf: (p) => progState(p), openList: moveList });
565
+ }
566
+ /** Split or merge (pm/split-merge.js; canvas XsmA1Menu, XsmA1Suggest): the context of one row. After the write the Board reads again and the
567
+ * row the PM lands on (the new one after a split, the one that stays after a merge) is selected and open. */
568
+ function smCtx(r) {
569
+ const ws = r.ws || M.board.ws || '';
570
+ return { row: r, rows: () => ((M.initiatives && M.initiatives.list && M.initiatives.list.rows) || []).filter((x) => (x.boardId || M.board.id) === (r.boardId || M.board.id)),
571
+ ws, board: r.boardId || M.board.id, product: r.product || M.board.product || M.board.name || '', program: programOf(PGS, ws, r.id), pmPost, say,
572
+ reload: async () => { await loadPrograms(); await load(); }, openIni: (id) => openIniId(id), openList: moveList };
573
+ }
574
+ const smItems = (r) => (M.board.self ? [] : SM.menuItems(smCtx(r)));
575
+ const smPress = (r, act) => SM.press(smCtx(r), act);
576
+ /** Open a row by its record id once the read holds it (a split's new row can take a read or two to show). */
577
+ async function openIniId(id, tries = 8) {
578
+ const r = (M && M.rows || []).find((x) => x.id === id) || goneRows().find((x) => x.id === id);
579
+ if (r && r.track) { if (curView() === 'time') TL.reveal(r.key); openIni(r, null); return true; }
580
+ if (tries <= 0) return false;
581
+ await new Promise((ok) => setTimeout(ok, 900));
582
+ await load();
583
+ return openIniId(id, tries - 1);
584
+ }
585
+ function moveList(b, label, rows) {
586
+ const host = Pop.open(`<p class="bd-mlbl">${esc(label)}</p>${rows.map((x, i) => `<button type="button" class="bd-mi" role="menuitem" data-pm-to="${i}">${x.icon ? `<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${x.icon}"/></svg>` : ''}<span class="tx"><span>${esc(x.label)}</span>${x.sub ? `<small>${esc(x.sub)}</small>` : ''}</span></button>`).join('')}`,
587
+ b, { label: 'Move to another program', role: 'menu', width: 280, align: 'right', cls: 'bd-menu', focus: '.bd-mi' });
588
+ if (host) host.onclick = (e) => { const t = e.target.closest('[data-pm-to]'); if (!t) return; const x = rows[+t.dataset.pmTo]; host.onclick = null; Pop.close(true); if (x) x.go(); };
589
+ }
535
590
  async function loadPrograms() {
536
591
  let r = null; try { r = await (await fetch('/api/programs', { credentials: 'same-origin' })).json(); } catch { r = null; }
537
592
  if (!r || !r.ok) return;
@@ -578,6 +633,74 @@ function openTicket(iniKey, key, from) {
578
633
  const r = rowOf(iniKey); if (!r || !r.track) return;
579
634
  const k = (r.track.tickets || []).find((x) => x.key === key); if (k) BI.openTicket(r, k, from);
580
635
  }
636
+ /** A row's milestones as a list (batch 11 item 3, canvas XmlA4Hover and XmlA5Phone): ◇, name, date. Under a counted ◇ it holds that ◇'s
637
+ * milestones; on a phone a sheet holds every milestone of the row. A row opens the task card (a Jira ticket its ticket Viewer). */
638
+ let msEl = null;
639
+ function msClose() { if (msEl) { const a = msEl.__a; msEl.remove(); msEl = null; if (a && a.isConnected) a.setAttribute('aria-expanded', 'false'); } }
640
+ function msPop(anchor, r, ids, sheet) {
641
+ const was = msEl && msEl.__a === anchor; msClose(); if (was || !r) return;
642
+ const today = M.today ? String(M.today).slice(0, 10) : new Date().toISOString().slice(0, 10);
643
+ const L = (r.milestones || []).filter((m) => !ids || ids.includes(m.id));
644
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], md = (iso) => MON[+iso.slice(5, 7) - 1] + ' ' + +iso.slice(8, 10);
645
+ const row = (m) => { const late = !m.done && m.date < today;
646
+ return `<button type="button" role="menuitem" class="o" data-ms-open="${esc(m.id)}"><i class="tg-tm-i${m.done ? ' dn' : late ? ' late' : ''}" aria-hidden="true"></i><span>${esc(m.name)}</span><span class="k${late ? ' late' : ''}">${esc(md(m.date))}</span></button>`; };
647
+ // the sheet adds each gap and each skipped stage, in date order with the milestones (batch 11 item 13, XgapA3Phone): words only, no press
648
+ const ymd = (d) => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
649
+ const extra = !sheet ? [] : plainGaps(r).map(([a, b]) => ({ at: ymd(a), html: `<div class="o i" role="menuitem" aria-disabled="true"><i class="tg-ng-i" aria-hidden="true"></i><span>${esc(gapWords(a, b, new Date(today + 'T00:00')).map((w) => w.replace(/, .* · /, ' · ')).join(' · '))}</span><span class="k">${esc(md(ymd(a)) + ' – ' + md(ymd(b)))}</span></div>` }))
650
+ .concat(skipsOf(r).flatMap((k) => k.items.map((x) => ({ at: ymd(k.lo), html: `<div class="o i" role="menuitem" aria-disabled="true"><i class="tg-sk-i" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 7l5 5-5 5M13 7l5 5-5 5"/></svg></i><span>${esc(x.name + ' skipped')}${x.why ? `<small>${esc(x.why)}</small>` : ''}</span></div>` }))));
651
+ const items = L.map((m) => ({ at: m.date, html: row(m) })).concat(extra).sort((a, b) => (a.at < b.at ? -1 : a.at > b.at ? 1 : 0));
652
+ const el = document.createElement('div');
653
+ el.className = 'tg-msp' + (sheet ? ' sh' : ''); el.setAttribute('role', 'menu'); el.setAttribute('aria-label', (sheet ? '' : 'Milestones of ') + r.title); el.dataset.escLayer = '';
654
+ el.innerHTML = (sheet ? `<i class="gr" aria-hidden="true"></i><b class="h">${esc(r.title)}</b>` : '') + items.map((x) => x.html).join('');
655
+ document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
656
+ if (!sheet) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = b.bottom + 8 + 'px'; }
657
+ el.onclick = (e) => {
658
+ const o = e.target.closest('[data-ms-open]'); if (!o) return;
659
+ const id = o.dataset.msOpen, m = L.find((x) => x.id === id); msClose();
660
+ if (m && m.jira) { const k = ((r.track && r.track.tickets) || []).find((x) => x.key === id); if (k) BI.openTicket(r, k, anchor); else openIni(r, anchor); return; }
661
+ const k = (r.tasks || []).find((x) => x.uid === id); if (k) openTask(r, k); else openIni(r, anchor);
662
+ };
663
+ const f = el.querySelector('button'); if (f) f.focus({ preventScroll: true });
664
+ }
665
+ document.addEventListener('pointerdown', (e) => { if (msEl && !msEl.contains(e.target) && !(msEl.__a && msEl.__a.contains(e.target))) msClose(); }, true);
666
+ document.addEventListener('keydown', (e) => { if (msEl && e.key === 'Escape') { e.stopPropagation(); const a = msEl.__a; msClose(); if (a && a.focus) a.focus(); } }, true);
667
+ addEventListener('resize', () => msClose());
668
+ /** A product lane's milestones as a list (batch 11 item 17; PlmA2Folded, PlmA3Phone): ◇, the name over its initiative, the date. Under a counted
669
+ * ◇ it holds that ◇'s milestones; a phone's sheet (title: the product) holds every one, in date order. A line opens its initiative. */
670
+ function lanePop(anchor, data, title) {
671
+ const was = msEl && msEl.__a === anchor; msClose(); if (was) return;
672
+ let L = []; try { L = JSON.parse(data || '[]'); } catch { L = []; }
673
+ if (!L.length) return;
674
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], md = (iso) => MON[+iso.slice(5, 7) - 1] + ' ' + +iso.slice(8, 10);
675
+ const el = document.createElement('div');
676
+ el.className = 'tg-msp tg-lnp' + (title ? ' sh' : ''); el.setAttribute('role', 'menu'); el.setAttribute('aria-label', title || 'Milestones'); el.dataset.escLayer = '';
677
+ el.innerHTML = (title ? `<i class="gr" aria-hidden="true"></i><b class="h">${esc(title)}</b>` : '')
678
+ + L.map((m) => `<button type="button" role="menuitem" class="o" data-ms-ini="${esc(m.k)}"><i class="tg-tm-i${m.s ? ' ' + m.s : ''}" aria-hidden="true"></i><span>${esc(m.n)}<small>${esc(m.t)}</small></span><span class="k${m.s === 'late' ? ' late' : ''}">${esc(md(m.d))}</span></button>`).join('');
679
+ document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
680
+ if (!title) { const b = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(b.left + b.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = b.bottom + 8 + 'px'; }
681
+ el.onclick = (e) => { const o = e.target.closest('[data-ms-ini]'); if (!o) return; msClose(); openIni(rowOf(o.dataset.msIni), anchor); };
682
+ const f = el.querySelector('button'); if (f) f.focus({ preventScroll: true });
683
+ }
684
+ /** A gap's card (batch 11 item 13; XgapAHard 2): its words under it; while part of it is ahead, + opens New task with those dates filled in. */
685
+ function gapPop(anchor, r) {
686
+ const was = msEl && msEl.__a === anchor; msClose(); if (was || !r) return;
687
+ const today = M.today ? String(M.today).slice(0, 10) : new Date().toISOString().slice(0, 10);
688
+ const a = anchor.dataset.from, b = anchor.dataset.to, d = (v) => new Date(v + 'T00:00');
689
+ const lines = gapWords(d(a), d(b), d(today)), sk = skipsOf(r).filter((k) => { const lo = k.lo < k.hi ? k.lo : k.hi, hi = k.lo < k.hi ? k.hi : k.lo; return d(a) <= hi && d(b) >= lo; });
690
+ // the gap's empty days ahead: from the day after the work before it (or today) to the day before the work after it
691
+ const ymd = (x) => x.getFullYear() + '-' + String(x.getMonth() + 1).padStart(2, '0') + '-' + String(x.getDate()).padStart(2, '0');
692
+ const plus = (v, n) => { const x = d(v); x.setDate(x.getDate() + n); return ymd(x); };
693
+ const first = plus(a, 1), start = first > today ? first : today, due = plus(b, -1);
694
+ const el = document.createElement('div');
695
+ el.className = 'tg-msp tg-gpc'; el.setAttribute('role', 'dialog'); el.setAttribute('aria-label', lines[0]); el.dataset.escLayer = '';
696
+ el.innerHTML = `<div class="w">${lines.map((t, i) => `<p class="${i ? 's' : ''}">${esc(t)}</p>`).join('')}${sk.map((k) => `<p class="s">${esc(skipWords(k.items))}</p>`).join('')}</div>`
697
+ + (anchor.dataset.ahead ? `<button type="button" class="gp-add" aria-label="${esc('New task, ' + md(d(start)) + ' to ' + md(d(due)))}" title="New task">${'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>'}</button>` : '');
698
+ document.body.appendChild(el); el.__a = anchor; msEl = el; anchor.setAttribute('aria-expanded', 'true');
699
+ const bx = anchor.getBoundingClientRect(), w = el.offsetWidth; el.style.left = Math.max(8, Math.min(bx.left + bx.width / 2 - w / 2, innerWidth - w - 8)) + 'px'; el.style.top = bx.bottom + 6 + 'px';
700
+ const add = el.querySelector('.gp-add');
701
+ if (add) { add.onclick = () => { msClose(); BI.openIni(r, anchor, { addTo: '', addDates: { start, due } }); }; add.focus({ preventScroll: true }); }
702
+ }
703
+
581
704
  /** The Viewer shows an initiative of this board: its row is marked. */
582
705
  function iniShown(key) {
583
706
  peek = { kind: 'ini', key };
@@ -588,14 +711,14 @@ function iniHidden() {
588
711
  if (!peek || peek.kind !== 'ini') return;
589
712
  peek = null; $$('#ibBody .sel').forEach((x) => x.classList.remove('sel'));
590
713
  }
591
- /** A linked document opens in the Viewer: GET /api/doc, shown as its text. */
714
+ /** A linked document opens in the Viewer: GET /api/doc, shown as its text, and drawn again when the file changes (pm/doc-follow.js). */
592
715
  document.addEventListener('click', (e) => {
593
716
  const d = e.target.closest('[data-doc]'); if (!d || !M) return;
594
717
  const path = d.dataset.doc, ws = M.board.ws || '', inVw = !!d.closest('#czViewer');
595
718
  viewerOpen({ kind: 'Document', title: path.split('/').pop(), icon: 'doc', id: 'doc:' + path, back: inVw, render: async (body) => {
596
719
  body.innerHTML = '<p class="bd-amut">Reading the document…</p>';
597
- let text = null; try { const res = await fetch('/api/doc?ws=' + encodeURIComponent(ws) + '&path=' + encodeURIComponent(path), { credentials: 'same-origin' }); text = res.ok ? await res.text() : null; } catch { text = null; }
598
- body.innerHTML = text == null ? `<p class="bd-amut">${esc(path)} could not be read.</p>` : `<p class="bd-amut">${esc(path)}</p><pre class="bd-doc">${esc(text)}</pre>`;
720
+ await followDoc({ ws, path, alive: () => body.isConnected && !!viewerCur() && viewerCur().id === 'doc:' + path,
721
+ onText: (text) => { body.innerHTML = text == null ? `<p class="bd-amut">${esc(path)} could not be read.</p>` : `<p class="bd-amut">${esc(path)}</p><pre class="bd-doc">${esc(text)}</pre>`; } });
599
722
  } });
600
723
  });
601
724
  /* ── the tools the Agreed design draws but has no frame for: plain versions with a "Waiting for design" tag (pm/bd-acts.js) ─────────── */
@@ -745,18 +868,20 @@ async function readBoard(q) {
745
868
  async function readAll(q) {
746
869
  const h = await readBoard(q);
747
870
  if (!h.r || !h.r.ok || h.r.state === 'reading') return h;
748
- const home = h.r.model, list = (home.board.switcher || []).filter((b) => !(b.ws === home.board.ws && b.id === home.board.id));
871
+ // several picked (?pick=): only those boards, the first one read first
872
+ const home = h.r.model, list = (home.board.switcher || []).filter((b) => !(b.ws === home.board.ws && b.id === home.board.id) && (PICK.length < 2 || PICK.includes(b.ws + '|' + b.id)));
749
873
  const got = await Promise.all(list.map((b) => readBoard('ws=' + encodeURIComponent(b.ws) + '&board=' + encodeURIComponent(b.id))));
750
874
  if (got.some((g) => g.r && g.r.state === 'reading')) return { r: { state: 'reading' }, status: 200 };
751
875
  const B = [{ ws: home.board.ws || '', id: home.board.id, name: home.board.name, model: home }];
752
876
  const lost = [];
753
877
  got.forEach((g, i) => { if (g.r && g.r.ok && g.r.model) B.push({ ...list[i], model: g.r.model }); else lost.push(list[i].name + ' board'); });
754
878
  const model = PG.mergeBoards(B);
879
+ if (PICK.length > 1 && B.length < (home.board.switcher || []).length) model.board.name = B.map((b) => model.board.products.find((p) => p.ws === b.ws && p.id === b.id)).filter(Boolean).map((p) => p.name).join(', ');
755
880
  if (lost.length) { model.header.missing = [...model.header.missing, ...lost]; model.header.text += (/not read: /.test(model.header.text) ? ', ' : ' · not read: ') + lost.join(', '); }
756
881
  return { r: { ok: true, model, stale: got.some((g) => g.r && g.r.stale) || h.r.stale }, status: 200 };
757
882
  }
758
883
  async function load() {
759
- const p = new URLSearchParams(location.search), q = [p.get('ws') ? 'ws=' + encodeURIComponent(p.get('ws')) : '', p.get('board') ? 'board=' + encodeURIComponent(p.get('board')) : ''].filter(Boolean).join('&');
884
+ const p = new URLSearchParams(location.search), [pw, pb] = PICK.length > 1 ? PICK[0].split('|') : [p.get('ws'), p.get('board')], q = [pw ? 'ws=' + encodeURIComponent(pw) : '', pb ? 'board=' + encodeURIComponent(pb) : ''].filter(Boolean).join('&');
760
885
  const { r, status } = ALL ? await readAll(q) : await readBoard(q);
761
886
  clearInterval(readTimer);
762
887
  if (r && r.state === 'reading') {
@@ -795,13 +920,25 @@ async function setTask(r, uid, state) {
795
920
  say(state + ': ' + (k ? k.title : uid) + '.', undo ? async () => { const u = await pmPost('/api/boards/tasks/state', { ...body, state: k.status }).catch(() => null); say(u && u.ok ? 'Back to ' + k.status + '.' : (u && u.error) || 'The undo did not land.'); load(); } : undefined);
796
921
  load();
797
922
  }
798
- /** A task's start and due from the panel's Tasks (the date press, a Timeline drag): POST /api/boards/tasks/edit; Undo puts the old days back. */
923
+ /** A task's start and due from the panel's Tasks (the date press, a Timeline drag), or its ◇ milestone flag (batch 11 item 3): POST
924
+ * /api/boards/tasks/edit; Undo puts the old days or the old flag back. */
799
925
  async function setDates(r, uid, patch) {
800
926
  const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid };
801
927
  const res = await pmPost('/api/boards/tasks/edit', { ...body, ...patch }).catch(() => null);
802
928
  if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); return; }
803
- const back = {}; for (const f of Object.keys(patch)) back[f] = k ? (f === 'due' ? k.end : k[f]) || '' : '';
804
- say('Dates saved' + (k ? ': ' + k.title : '') + '.', k ? async () => { const u = await pmPost('/api/boards/tasks/edit', { ...body, ...back }).catch(() => null); say(u && u.ok !== false ? 'Dates put back.' : (u && u.error) || 'The undo did not land.'); load(); } : undefined);
929
+ const ms = 'milestone' in patch;
930
+ const back = {}; for (const f of Object.keys(patch)) back[f] = f === 'milestone' ? (res.from && 'milestone' in res.from ? !!res.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : res.from && f in res.from ? res.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
931
+ const words = ms ? (patch.milestone ? 'Milestone' : 'Not a milestone') : 'Dates saved';
932
+ const jd = !k && !ms && res.from && ('start' in res.from || 'due' in res.from); // a Jira ticket's days, kept in PMOS (batch 11 item 23)
933
+ say(words + (k ? ': ' + k.title : jd ? ': ' + uid + ', kept in PMOS' : '') + '.', k || ms || jd ? async () => { const u = await pmPost('/api/boards/tasks/edit', { ...body, ...back }).catch(() => null); say(u && u.ok !== false ? (ms ? 'Put back.' : 'Dates put back.') : (u && u.error) || 'The undo did not land.'); load(); } : undefined);
934
+ load();
935
+ }
936
+ /** The status picker's trash on the panel's Tasks (batch 11 item 16): POST /api/boards/tasks/delete, a Board task or a breakdown item; Undo restores it. */
937
+ async function removeTask(r, uid) {
938
+ const k = (r.tasks || []).find((x) => x.uid === uid), body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, task: uid };
939
+ const res = await pmPost('/api/boards/tasks/delete', body).catch(() => null);
940
+ if (!res || res.ok === false) { say((res && res.error) || 'The task was not deleted.'); return; }
941
+ say('Deleted · ' + (k ? k.title : uid) + '.', async () => { const u = await pmPost('/api/boards/tasks/restore', body).catch(() => null); if (!u || u.ok === false) say((u && u.error) || 'The undo did not land.'); load(); });
805
942
  load();
806
943
  }
807
944
  /** A task's title on the initiative view: the one task editor (task-card.js through home-task.js), as Home opens it; ← is the initiative. */
@@ -820,11 +957,13 @@ function openTask(r, k) {
820
957
  }
821
958
  /** A new task from the initiative view's + (the same box Home's page draws): POST /api/boards/tasks/add. → true when it was added.
822
959
  * section: the stage it finishes (the Next cell's +, "Add what finishes <stage>"): the task is placed under it (POST /api/boards/tasks/edit). */
823
- async function addTask(r, title, section) {
960
+ async function addTask(r, title, section, dates) {
824
961
  const body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id };
825
962
  const res = await pmPost('/api/boards/tasks/add', { ...body, initiative: r.id, title }).catch(() => null);
826
963
  if (!res || res.ok === false) { say((res && res.error) || 'The task was not added.'); return false; }
827
964
  const uid = res.item && res.item.uid;
965
+ // dates: a gap's + (batch 11 item 13) fills the task's start and due with the gap's days ahead
966
+ if (dates && uid) { const s1 = await pmPost('/api/boards/tasks/edit', { ...body, task: uid, start: dates.start, due: dates.due }).catch(() => null); if (!s1 || s1.ok === false) { say('Task added, but not its dates: ' + ((s1 && s1.error) || 'the server did not say why') + '.'); load(); return true; } }
828
967
  if (section && uid) { const s2 = await pmPost('/api/boards/tasks/edit', { ...body, task: uid, section }).catch(() => null); if (!s2 || s2.ok === false) { say('Task added, but not under its stage: ' + ((s2 && s2.error) || 'the server did not say why') + '.'); load(); return true; } }
829
968
  say('Task added.'); load();
830
969
  return true;
@@ -852,8 +991,8 @@ Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePa
852
991
  grouping: () => ({ on: groupingOn(), byProduct }), setGrouping, sprintFilter: sprintFilterOn });
853
992
  BI.mount({ M: () => M, statusOf, dayTitle, usual: usualOf, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
854
993
  send: (r) => import('./tk-send.js').then((S) => S.openSend({ ws: r.ws || M.board.ws || null, board: r.boardId || M.board.id, initiative: r.id, toast: say })),
855
- acts: (r, b) => Acts.open.row(r, b), grillOpen: (r, b) => Asks.openGrill(r.id, r.title, (r.track && r.track.label) || 'Triage', false, b), onShow: iniShown, onHide: iniHidden,
856
- programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), openProgram: (id, b) => PG.openProgram(id, b), rename: renameIni, setTask, setDates, addTask, openTask, turnProgram });
994
+ acts: (r, b) => Acts.open.row(r, b), hold: (r, i, b) => Acts.open.hold(r, i, b), grillOpen: (r, b) => Asks.openGrill(r.id, r.title, (r.track && r.track.label) || 'Triage', false, b), onShow: iniShown, onHide: iniHidden,
995
+ programOf: (r) => programOf(PGS, r.ws || M.board.ws || '', r.id), openProgram: (id, b) => PG.openProgram(id, b), reload: load, toast: say, rename: renameIni, setTask, setDates, removeTask, addTask, openTask, turnProgram, moveItems, smItems, smPress, openIniId });
857
996
  /** Tap the title to rename (canvas RnAIni): the list, the Timeline and the panel show the new name at once; Undo is the same press.
858
997
  * The Jira box opens Home's chat about it with the request typed, for the PM to send (PMOS holds no Jira credential, D53). */
859
998
  // a name the PM just saved holds over a read that predates it (the board derives off the request path) until a read says it too
@@ -36,7 +36,10 @@
36
36
  * wordsOf(md, fallback) the document as { title, sections: [{ h, lines }] } (pure)
37
37
  * slideHtml(lines) a section's lines as html (pure) · splitRender(html) · slideCard(s, mini) · fit(root) · schedLabel(setup) (pure)
38
38
  *
39
- * READS: GET /api/doc, /api/report-design/cycle and cycle-html (a cycle drawn to its saved design), /api/report-setups (schedule and audience),
39
+ * The open report follows its file (PM, 2026-10-26: "When chat make update on the file that being shown on the current viewer, I should not need to
40
+ * refresh page"): every few seconds GET /api/doc-sheet/stamp gives the text's hash, and a change is read and drawn again. Not while editing or while a
41
+ * popover is open; the next check after that catches it.
42
+ * READS: GET /api/doc, /api/doc-sheet/stamp, /api/report-design/cycle and cycle-html (a cycle drawn to its saved design), /api/report-setups (schedule and audience),
40
43
  * /api/viewer-report/checks, /api/report-structure and /api/report-design (the Brief), /api/report-confirm, /api/insights-premium (Live page),
41
44
  * /api/shares, /api/shares/password, /api/report-export (the files). Every render is HTML the server sanitized, shown in a frame with an empty
42
45
  * sandbox: nothing in it runs.
@@ -870,8 +873,24 @@ export async function openReport(row, hand = {}) {
870
873
  readBrief(); // the Brief tab's count shows at once
871
874
  if (vCur() && vCur().id === me.vid && (vCur().title !== me.name || me.audience)) { me.reopen = true; vOpen(head()); me.reopen = false; } // the name and audience are known now
872
875
  draw();
876
+ watchFile(me);
873
877
  return me;
874
878
  }
879
+ const CHECK_MS = 2500;
880
+ /** Read the report again when its file changed on disk (a chat or a draft run wrote it). Stops when another report opens or the panel closes. */
881
+ async function watchFile(me) {
882
+ const stamp = async () => { const j = await Promise.resolve(pmGet('/api/doc-sheet/stamp?' + q({ ws: me.ws, path: me.row.path }))).catch(() => null); return j && j.ok ? j.hash : null; };
883
+ let seen = await stamp();
884
+ while (R === me) {
885
+ await new Promise((ok) => setTimeout(ok, CHECK_MS));
886
+ if (R !== me) return;
887
+ if (document.hidden || me.edit || me.busy || me.pop) continue;
888
+ const h = await stamp();
889
+ if (R !== me || !h) continue;
890
+ if (seen && h !== seen) { await reread(); if (R === me && !me.edit && !me.pop) draw(); }
891
+ seen = h;
892
+ }
893
+ }
875
894
 
876
895
  /** The window.czViews entry: a report path (reports/<cadence>/<date>.md) or a Reports row. o = { ws, name, cycles, onIssue, onChange } */
877
896
  export async function openReportView(ref, o = {}) {
@@ -826,15 +826,30 @@ export function crumbHtml(o) {
826
826
  : `<nav class="crumb" aria-label="Where you are">${o.page ? `<span class="crpg">${esc(o.page)}</span>` : ''}<button id="crBoard" aria-current="page" disabled>${esc(o.board)}</button>${chev('crSw', 'Switch board', o.boards && o.boards.length > 1)}${menu}</nav>`;
827
827
  return `<div class="where">${left}</div>`;
828
828
  }
829
- /** o: { boards: [{ws,id,name}], board: id, siblings: [{id,title}], ini: id, goBoard(ws, id), goIni(id) }. Escape and a click outside close the menu; the arrows move in it. */
829
+ /** o: { boards: [{ws,id,name}], board: id, siblings: [{id,title}], ini: id, goBoard(ws, id), goIni(id) }. Escape and a click outside close the menu; the arrows move in it.
830
+ * With o.picked (['ws|id', …]) and o.goPicked(keys) the board menu ticks several (the Board's products, batch 11 item 7): a press ticks or unticks
831
+ * and the menu stays open; the board with id '*' (All products) ticks every one; the last tick stays; the pick goes when the menu closes. */
830
832
  export function wireCrumb(o) {
831
833
  const menu = $('#crMenu'); if (!menu) return;
832
- const close = () => { menu.hidden = true; $$('#crSw,#crSw2').forEach((b) => b.setAttribute('aria-expanded', 'false')); };
834
+ const multi = !!(o.picked && o.goPicked), one = (o.boards || []).filter((b) => b.id !== '*'), kOf = (b) => b.ws + '|' + b.id;
835
+ let tick = null; // the ticks while the menu is open (multi): a Set of 'ws|id'
836
+ const close = () => {
837
+ const was = !menu.hidden && menu.dataset.k === 'b' && tick;
838
+ menu.hidden = true; $$('#crSw,#crSw2').forEach((b) => b.setAttribute('aria-expanded', 'false'));
839
+ if (was) { const k = one.map(kOf).filter((x) => tick.has(x)); tick = null; if (k.join(',') !== one.map(kOf).filter((x) => o.picked.includes(x)).join(',')) o.goPicked(k); }
840
+ };
841
+ const TK = '<i class="crtk" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></i>', PART = '<i class="crtk part" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M7 12h10"/></svg></i>';
842
+ const ticks = () => (o.boards || []).map((b) => {
843
+ if (b.id === '*') { const n = one.filter((x) => tick.has(kOf(x))).length, st = n === one.length ? 'true' : 'mixed'; return `<button role="menuitemcheckbox" data-sw="*|*" aria-checked="${st}">${esc(b.name)}${st === 'true' ? TK : PART}</button><span class="crsep" role="separator"></span>`; }
844
+ const on = tick.has(kOf(b));
845
+ return `<button role="menuitemcheckbox" data-sw="${esc(kOf(b))}" aria-checked="${on}">${esc(b.name)}${on ? TK : '<i class="crtk"></i>'}</button>`;
846
+ }).join('');
833
847
  const open = (kind, btn) => {
834
848
  if (!menu.hidden && menu.dataset.k === kind) { close(); return; }
835
849
  close(); menu.dataset.k = kind;
850
+ if (kind === 'b' && multi) tick = new Set(o.picked);
836
851
  menu.innerHTML = kind === 'b'
837
- ? (o.boards || []).map((b) => `<button role="menuitem" data-sw="${esc(b.ws + '|' + b.id)}"${b.id === o.board ? ' aria-current="true"' : ''}>${esc(b.name)}</button>`).join('')
852
+ ? multi ? ticks() : (o.boards || []).map((b) => `<button role="menuitem" data-sw="${esc(b.ws + '|' + b.id)}"${b.id === o.board ? ' aria-current="true"' : ''}>${esc(b.name)}</button>`).join('')
838
853
  : (o.siblings || []).map((s) => `<button role="menuitem" data-swi="${esc(s.id)}"${s.id === o.ini ? ' aria-current="true"' : ''}>${esc(s.title)}</button>`).join('');
839
854
  menu.hidden = false; btn.setAttribute('aria-expanded', 'true'); const f = $('button', menu); if (f) f.focus();
840
855
  };
@@ -843,7 +858,17 @@ export function wireCrumb(o) {
843
858
  if (b2) b2.onclick = (e) => { e.stopPropagation(); open('i', b2); };
844
859
  $('#crBoard').onclick = () => { if (o.ini && o.goBoard) { const b = (o.boards || []).find((x) => x.id === o.board); o.goBoard(b ? b.ws : null, o.board); } };
845
860
  menu.onclick = (e) => {
846
- const k = e.target.closest('[data-sw]'); if (k && o.goBoard) { const [ws, id] = k.dataset.sw.split('|'); close(); o.goBoard(ws, id); return; }
861
+ const k = e.target.closest('[data-sw]');
862
+ if (k && tick) {
863
+ // a tick: All products ticks every product; a product ticks or unticks, the last one stays ticked; the menu stays open
864
+ e.stopPropagation();
865
+ if (k.dataset.sw === '*|*') one.forEach((b) => tick.add(kOf(b)));
866
+ else if (!tick.has(k.dataset.sw)) tick.add(k.dataset.sw);
867
+ else if (tick.size > 1) tick.delete(k.dataset.sw);
868
+ const at = k.dataset.sw; menu.innerHTML = ticks(); const f = menu.querySelector(`[data-sw="${CSS.escape(at)}"]`); if (f) f.focus();
869
+ return;
870
+ }
871
+ if (k && o.goBoard) { const [ws, id] = k.dataset.sw.split('|'); close(); o.goBoard(ws, id); return; }
847
872
  const q = e.target.closest('[data-swi]'); if (q && o.goIni) { close(); o.goIni(q.dataset.swi); }
848
873
  };
849
874
  document.addEventListener('click', (e) => { if (!e.target.closest('#crSw,#crSw2,#crMenu')) close(); });
@@ -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();