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
@@ -71,12 +71,17 @@ function rowsOf(ws) {
71
71
  return a && a !== 'reading' ? { name: a.name, rows: shape(a.rows) } : null;
72
72
  }
73
73
  /** Reads the board of each product of the program that is not this one, once per page load; the panel draws again when one arrives. */
74
+ const TRIES = new Map(); // ws → reads tried this page load
74
75
  function readAway(p) {
75
- for (const m of (p && p.members) || []) {
76
- const ws = m.ws; if (!ws || ws === board().ws || AWAY.has(ws)) continue;
76
+ // the program's own product too: its initiatives are the ones Move an initiative in offers (moreOf)
77
+ const wss = [...new Set([p && p.home, ...((p && p.members) || []).map((m) => m.ws)])];
78
+ for (const ws of wss) {
79
+ if (!ws || !board().ws || ws === board().ws || AWAY.has(ws)) continue;
77
80
  AWAY.set(ws, 'reading');
78
81
  fetch('/api/board-premium?ws=' + encodeURIComponent(ws), { credentials: 'same-origin' }).then((r) => r.json()).catch(() => null).then((r) => {
79
- if (!r || !r.ok || !r.model) { AWAY.delete(ws); return; } // still reading, or refused: the next open asks again
82
+ // still reading (a cold board answers before its model is ready), or refused: ask again a few times, then the next open asks again,
83
+ // so a member does not stay "not read" until the panel is opened again
84
+ if (!r || !r.ok || !r.model) { AWAY.delete(ws); const n = (TRIES.get(ws) || 0) + 1; TRIES.set(ws, n); if (n < 4 && cur && cur.id === p.id) setTimeout(() => { if (cur && cur.id === p.id) { readAway(p); draw(); } }, 1500 * n); return; }
80
85
  AWAY.set(ws, { name: (r.model.board && (r.model.board.product || r.model.board.name)) || ws, board: (r.model.board && r.model.board.id) || ws, rows: r.model.rows || [] });
81
86
  if (cur && cur.id === p.id) draw();
82
87
  });
@@ -366,12 +371,22 @@ function draw(keepFocus) {
366
371
  }
367
372
  /** ⋯ in the shell's order: change it (add, move in), look back (the charter), copy, then archive in red, last. */
368
373
  function moreOf(p) {
369
- const M = O.M(), taken = new Set(((O.programs()) || []).flatMap((x) => (x.members || []).filter((m) => !m.ws || m.ws === board().ws).map((m) => m.initiative)));
374
+ // the initiatives that can move in, grouped by product with the PROGRAM's own product first (batch 11 item 11: a pmos-microsites program
375
+ // on Home listed only pmos-idpf initiatives, with no product named). A program spans products, so the others stay, each under its name.
376
+ const M = O.M(), hw = p.home || board().ws || '';
377
+ const taken = new Set(((O.programs()) || []).flatMap((x) => (x.members || []).map((m) => (m.ws || hw) + '|' + m.initiative)));
370
378
  // only the open initiatives: a cancelled or archived one moved in would not show in the program
371
379
  const gone = new Set(Object.values((M && M.initiatives && M.initiatives.gone) || {}).flat().map((r) => r.key));
372
- const free = ((M && M.rows) || []).filter((r) => r.id && r.track && !gone.has(r.key) && !taken.has(r.id)).slice(0, 8);
380
+ const here = board().ws || '', groups = new Map(); // ws → { name, rows }
381
+ const add = (ws, name, rows) => { const g = groups.get(ws) || { name, rows: [] }; g.rows.push(...rows.filter((r) => r.id && r.track && !gone.has(r.key) && !taken.has(ws + '|' + r.id))); groups.set(ws, g); };
382
+ if (hw && here && hw !== here) { const a = AWAY.get(hw); add(hw, a && a !== 'reading' ? a.name : '', a && a !== 'reading' ? a.rows : []); }
383
+ if (here) add(here, board().product || board().name || '', (M && M.rows) || []);
384
+ else for (const r of (M && M.rows) || []) add(r.ws || '', r.product || r.ws || '', [r]); // All products: each row keeps its own product
385
+ const order = [...groups.keys()].sort((x, y) => (y === hw) - (x === hw));
386
+ const named = order.filter((w) => groups.get(w).rows.length).length > 1;
387
+ const free = order.flatMap((w) => groups.get(w).rows.slice(0, 8).map((r, i) => ({ r, ws: w, head: named && i === 0 ? groups.get(w).name || w : '' })));
373
388
  const more = [{ label: 'Add a new initiative', on: () => { VW.close(); const n = document.getElementById('newIni'); if (n) n.click(); } }];
374
- if (free.length) more.push({ label: 'Move an initiative in', on: (b) => Pop.open(`<p class="bd-mlbl">Move an initiative into ${esc(p.title)}</p>${free.map((r) => `<button type="button" class="bd-mi" role="menuitem" data-ppjoin="${esc(r.id)}">${esc(r.title)}</button>`).join('')}`, b, { label: 'Move an initiative in', role: 'menu', width: 280, align: 'right', cls: 'bd-menu', focus: '.bd-mi' }) });
389
+ if (free.length) more.push({ label: 'Move an initiative in', on: (b) => Pop.open(`<p class="bd-mlbl">Move an initiative into ${esc(p.title)}</p>${free.map((x) => (x.head ? `<p class="bd-mlbl">${esc(x.head)}</p>` : '') + `<button type="button" class="bd-mi" role="menuitem" data-ppjoin="${esc(x.r.id)}" data-ppws="${esc(x.ws)}">${esc(x.r.title)}</button>`).join('')}`, b, { label: 'Move an initiative in', role: 'menu', width: 280, align: 'right', cls: 'bd-menu', focus: '.bd-mi' }) });
375
390
  more.push({ label: 'Add a task to the program', on: () => { adding = true; try { localStorage.setItem('cz-vw-fold:program:tasks', '1'); } catch { /* a private window */ } draw(); const i = VW.body() && VW.body().querySelector('.pp-add input'); if (i) i.focus(); } });
376
391
  more.push({ sep: true }, { label: 'Copy link', on: () => copyText(new URL('/premium-board.html?' + (p.home ? 'ws=' + encodeURIComponent(p.home) + '&' : '') + 'program=' + encodeURIComponent(p.id), location.href).href, 'Link copied.') },
377
392
  { label: 'Copy as text', on: () => copyText(textOf(p), 'Copied as text.') });
@@ -476,7 +491,7 @@ async function popPress(e) {
476
491
  const j = e.target.closest('[data-ppjoin]'), x = e.target.closest('[data-pparch]'); if (!j && !x) return;
477
492
  const p = cur && progOf(cur.id); Pop.close(true); if (!p) return;
478
493
  if (j) {
479
- const r = await pmPost('/api/programs/member', { ws: board().ws || null, program: p.id, initiative: j.dataset.ppjoin });
494
+ const r = await pmPost('/api/programs/member', { ws: j.dataset.ppws || board().ws || null, program: p.id, initiative: j.dataset.ppjoin });
480
495
  if (!r || !r.ok) { O.say((r && r.error) || 'It did not move in. The server did not say why.'); return; }
481
496
  O.say('Moved into ' + p.title + '.'); O.reload();
482
497
  } else if (x.dataset.pparch === '1') {
@@ -11,6 +11,7 @@
11
11
  * mergeBoards(list) All products: one Board model from every product's model, each row keeping its own product
12
12
  * bandHtml(g, st, o) the stage track's program row: tile, title, products, your count, its spread, its next milestones
13
13
  * prodHtml(g, o) · subHtml(name) a product group's head row (tile, name, goal dots, chevron) and a program's product sub-row
14
+ * prodCell(g) the head's fold button alone (the timeline's product lane, batch 11 item 17)
14
15
  * goalsFrom(fn) · goalsHtml(name) the goal dots of a product head, from Home's source (pm/home-list.js goalsOf); fn(name) gives its rows
15
16
  *
16
17
  * A program has no stage of its own (PM, 2026-10-23): the band shows only what its initiatives say. With one product picked, the program shows
@@ -167,8 +168,12 @@ export function bandHtml(g, st, o) {
167
168
  }
168
169
  /** A product group's head row (PgBoard .prd): the tile, the name and the fold chevron; folded, the count of its initiatives. */
169
170
  export function prodHtml(g, cls = 'bt-prd') {
171
+ return `<div class="${cls}${folded(g.key) ? ' closed' : ''}" role="row">${prodCell(g)}</div>`;
172
+ }
173
+ /** The fold button of a product head alone: the timeline's product lane (batch 11 item 17, PlmA1Board) puts it in the name cell, its track beside it. */
174
+ export function prodCell(g) {
170
175
  const open = !folded(g.key), gl = open ? goalsHtml(g.name) : '';
171
- return `<div class="${cls}${open ? '' : ' closed'}" role="row"><button type="button" class="bd-prdb" data-fold="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}, ${g.rows.length} ${plural(g.rows.length, 'initiative', 'initiatives')}. ${open ? 'Fold' : 'Show'}">${tileHtml(g.name)}<span>${esc(g.name)}</span>${gl}${open ? '' : `<span class="n">${g.rows.length}</span>`}${SV(open ? CHEV_D : CHEV_R)}</button></div>`;
176
+ return `<button type="button" class="bd-prdb" data-fold="${esc(g.key)}" aria-expanded="${open}" aria-label="${esc(g.name)}, ${g.rows.length} ${plural(g.rows.length, 'initiative', 'initiatives')}. ${open ? 'Fold' : 'Show'}">${tileHtml(g.name)}<span>${esc(g.name)}</span>${gl}${open ? '' : `<span class="n">${g.rows.length}</span>`}${SV(open ? CHEV_D : CHEV_R)}</button>`;
172
177
  }
173
178
  /** The goal dots of a product's head (PgBoard .gd), from the same source as Home's product header (pm/home-list.js goalsOf): one per KR or
174
179
  * budget its open initiatives anchor to, green on track, amber at risk. With no goal anchored, nothing is drawn. The page sets the rows. */
@@ -19,9 +19,16 @@
19
19
  * ⏸ button where it stopped and the return date where it starts again (a phone keeps the ⏸ only); a stretch of 4 weeks or more with no dated work just
20
20
  * breaks it. The done part fills the pieces in order and skips the gaps. No return date: dotted to today, the rest faded. Return date passed: dotted to
21
21
  * today in the late colour. Return after Deliver: the ◇ turns amber and says so; no date is moved. A gap narrower than 8 px closes up. The program line
22
- * is dotted where every member is on hold. */
22
+ * is dotted where every member is on hold.
23
+ * No activity (feedback batch 11 item 13; XgapA1Board, XgapAHard, XgapA3Phone, XgapAGrill): a stretch of 2 weeks or more with no dated work draws a
24
+ * 2 px hairline in the To do grey at the bar's middle; a hold still wins for its dates. Its words: "No activity, Sep 19 to Oct 18 · 4 wk" before
25
+ * today, "Nothing planned, Oct 27 to Nov 29 · 5 wk" after it, both across it. One press per gap: a card with the words, and + (New task with the
26
+ * gap's dates) while part of it is ahead. A skipped stage between two dated stages is one » on the hairline, or on the bar at the joint when
27
+ * there is no gap; skips at either end are not drawn; a » with less than 24 px is dropped and its words go to the bar's title. A phone draws
28
+ * the hairline and » only; its row sheet lists them. A gap never changes the row's dot or risk. */
23
29
  import { esc } from './premium-shell.js';
24
30
  import { mergeClose } from './program-model.js';
31
+ import { stagesOfRow } from './bd-wf.js';
25
32
 
26
33
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
27
34
  const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
@@ -36,7 +43,7 @@ export const DRAWN = new Set(SPANS.map(([k]) => k));
36
43
  const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
37
44
  const FLAG = 'M5 21V4M5 4h11l-2 4 2 4H5';
38
45
  const LINK = 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1';
39
- const CHL = 'M15 6l-6 6 6 6', CHR = 'M9 6l6 6-6 6', PAUSE = 'M9 6v12M15 6v12';
46
+ const CHL = 'M15 6l-6 6 6 6', CHR = 'M9 6l6 6-6 6', PAUSE = 'M9 6v12M15 6v12', SKIP = 'M6 7l5 5-5 5M13 7l5 5-5 5';
40
47
 
41
48
  /** The scale of each span from Quarter on (TsAllSpans): its column, and how many columns one screen shows on a desktop and on a phone. */
42
49
  export const SCALE = { quarter: { unit: 'w', cols: 7, ph: 3 }, half: { unit: 'm', cols: 6, ph: 3 }, year: { unit: 'm', cols: 12, ph: 4 }, y2: { unit: 'q', cols: 8, ph: 4 }, y5: { unit: 'y', cols: 5, ph: 2 } };
@@ -78,8 +85,11 @@ export function windowOf(span, now, phone, sprint, dates) {
78
85
  const pctOf = (W) => (d) => Math.max(0, Math.min(100, ((d - W.from) / (W.to - W.from)) * 100));
79
86
  const P = (x) => x.toFixed(2) + '%';
80
87
  const doneOf = (r) => { const p = r.track && r.track.prog; return p ? Math.max(0, Math.min(100, (p.done / Math.max(1, p.total)) * 100)) : 0; };
81
- const toneOf = (r) => (r.late ? 'late' : r.status === 'at risk' ? 'risk' : r.track && r.track.you ? 'you' : r.status === 'on track' ? 'ok' : 'q');
82
- const dated = (r) => day(r.start) || day(r.end) || (r.track && day(r.track.forecast));
88
+ /** A milestone task past its due date and not done (feedback batch 11 item 3): its ◇ turns orange, and so does the row's dot. */
89
+ const msLate = (m, now) => !m.done && day(m.date) && day(m.date) < new Date(now.getFullYear(), now.getMonth(), now.getDate());
90
+ export const anyMsLate = (r, now) => !!(now && (r.milestones || []).some((m) => msLate(m, now)));
91
+ const toneOf = (r, now) => (r.late || anyMsLate(r, now) ? 'late' : r.status === 'at risk' ? 'risk' : r.track && r.track.you ? 'you' : r.status === 'on track' ? 'ok' : 'q');
92
+ const dated = (r) => day(r.start) || day(r.end) || (r.track && day(r.track.forecast)) || (r.draft && day(r.draft.start));
83
93
  /** Done work leaves no edge tab (TsCGrill 5): the initiative is past Deliver, or every part it counts is done. */
84
94
  const isDone = (r) => !!(r.track && (r.track.k >= 6 || (r.track.prog && r.track.prog.total > 0 && r.track.prog.done >= r.track.prog.total)));
85
95
  /** A row's holds as spans on the bar: [{ a, b, kind, h, i }]. kind: past (resumed), open (the return date ahead), over (the return date passed:
@@ -100,6 +110,52 @@ export function holdSpans(r, now) {
100
110
  const openBack = (r, now) => { const o = holdSpans(r, now).find((x) => x.kind === 'open'); return o ? o.b : null; };
101
111
  /** Whether any of `rows` draws a hold (the legend's "On hold" key shows only then: zero is silence). */
102
112
  export const hasHold = (rows, now = new Date()) => (rows || []).some((r) => day(r.start) && day(r.end) && holdSpans(r, now).length);
113
+ /** What planned versus actual draws on these rows, for the legend's Plan and Draft keys (zero is silence). */
114
+ export const planKeys = (rows) => ({ plan: (rows || []).some((r) => r.plan && day(r.plan.start) && !(r.plan.start === r.start && r.plan.end === r.end)), draft: (rows || []).some((r) => r.draft && !day(r.start) && !day(r.end)) });
115
+ /** What the no-activity marks draw on these rows, for the legend's No activity and Skipped keys (zero is silence). */
116
+ export const gapKeys = (rows) => ({ gap: (rows || []).some((r) => plainGaps(r).length), skip: (rows || []).some((r) => skipsOf(r).length) });
117
+ /** A row's plain gaps inside its plan, as [a, b] days, less the part a hold covers (a hold wins for its dates). */
118
+ export function plainGaps(r, now = new Date()) {
119
+ const s = day(r.start), e = day(r.end); if (!s || !e) return [];
120
+ const H = holdSpans(r, now), out = [];
121
+ for (const g of Array.isArray(r.gaps) ? r.gaps : []) {
122
+ let parts = [[day(g.from), day(g.to)]];
123
+ if (!parts[0][0] || !parts[0][1]) continue;
124
+ for (const x of H) parts = parts.flatMap(([a, b]) => (x.a < b && x.b > a ? [[a, x.a], [x.b, b]].filter(([p, q]) => q > p) : [[a, b]]));
125
+ for (const [a, b] of parts) if (b > s && a < e) out.push([a < s ? s : a, b > e ? e : b, g]);
126
+ }
127
+ return out.sort((p, q) => p[0] - q[0]);
128
+ }
129
+ /** The length of a stretch of days, counted both ends: "4 wk", or "5 days" under a week. */
130
+ const lenOf = (a, b) => { const n = Math.round((b - a) / 864e5) + 1; return n < 7 ? n + (n === 1 ? ' day' : ' days') : Math.round(n / 7) + ' wk'; };
131
+ /** A gap's words (XgapAGrill): its empty days, the day after the work before it to the day before the work after it. Before today "No activity",
132
+ * after it "Nothing planned", split at today when it runs across. → [line, line?] */
133
+ export function gapWords(a, b, now) {
134
+ const t = new Date(now.getFullYear(), now.getMonth(), now.getDate()), p = addDays(a, 1), q = addDays(b, -1);
135
+ const say = (w, u, v) => w + ', ' + md(u) + ' to ' + md(v) + ' · ' + lenOf(u, v);
136
+ if (q < t) return [say('No activity', p, q)];
137
+ if (p >= t) return [say('Nothing planned', p, q)];
138
+ return [say('No activity', p, addDays(t, -1)), say('Nothing planned', t, q)];
139
+ }
140
+ /** The skipped stages of a row that sit between two stages with dated work: [{ lo, hi, items: [{ name, why }] }]. lo is the end of the dated work
141
+ * before them, hi the start of the dated work after. Skips before the first dated stage or after the last are not drawn (XgapAGrill). */
142
+ export function skipsOf(r) {
143
+ const S = stagesOfRow(r), SP = Array.isArray(r.stageSpans) ? r.stageSpans : [];
144
+ if (!S.some((x) => x.skipped || x.status === 'skipped') || !SP.length) return [];
145
+ const norm = (v) => String(v || '').toLowerCase().replace(/[^a-z0-9]/g, '');
146
+ const spanOf = (st) => SP.find((x) => x.stage === st.key || norm(x.stage) === norm(st.key) || norm(x.stage) === norm(st.name));
147
+ const dated = S.map((st, i) => ({ i, sp: spanOf(st) })).filter((x) => x.sp && day(x.sp.start));
148
+ const out = [];
149
+ for (let n = 1; n < dated.length; n++) {
150
+ const p = dated[n - 1], q = dated[n];
151
+ const items = S.slice(p.i + 1, q.i).filter((x) => x.skipped || x.status === 'skipped').map((x) => ({ name: x.name, why: ((x.skipped || x.reading || {}).why) || '' }));
152
+ if (items.length) out.push({ lo: day(p.sp.due) || day(p.sp.start), hi: day(q.sp.start), items });
153
+ }
154
+ return out;
155
+ }
156
+ /** One » mark's words: "Plan skipped: the security review fixed the scope", one sentence for each stage. */
157
+ export const skipWords = (items) => items.map((x) => x.name + ' skipped' + (x.why ? ': ' + x.why.replace(/\.$/, '').replace(/^./, (c) => c.toLowerCase()) : '')).join('. ');
158
+
103
159
  /** The first and last mark of a row: the plan, the forecast, a return date ahead, and today while it is over. */
104
160
  function extentOf(r, now) {
105
161
  const s = day(r.start), e = day(r.end), fc = r.track && day(r.track.forecast), ds = [s, e, fc].filter(Boolean);
@@ -110,9 +166,10 @@ function extentOf(r, now) {
110
166
 
111
167
  /** One initiative's marks: the plan with its done part, the days over, the forecast past the plan, and one label after the furthest mark. A
112
168
  * date reads by the span's scale (o.fmt). */
113
- function qBar(r, X, now, phone, fmt, pxPct) {
169
+ function qBar(r, X, now, phone, fmt, pxPct, ms = {}) {
114
170
  const s = day(r.start), e = day(r.end), fc = r.track && day(r.track.forecast), tone = toneOf(r);
115
- let out = marks(r, X, now, phone), clash = null;
171
+ const tm = taskMarks(r, X, now, phone, pxPct, ms), et = tm.end;
172
+ let out = marks(r, X, now, phone) + tm.html, clash = null;
116
173
  if (s && e) {
117
174
  const g = gapsHtml(r, X, now, phone, fmt, pxPct || 0, s, e, tone);
118
175
  out += g.html; clash = g.clash;
@@ -120,16 +177,42 @@ function qBar(r, X, now, phone, fmt, pxPct) {
120
177
  if (over) { out += `<span class="tg-over" style="left:${P(X(e))};width:${P(Math.max(0.1, X(now) - X(e)))}"></span>`; words.push(r.overDays + ' ' + (r.overDays === 1 ? 'day' : 'days') + ' over'); }
121
178
  if (late) { out += `<span class="tg-fc" style="left:${P(X(e))};width:${P(X(fc) - X(e))}" title="Jira forecast ${esc(md(fc))}"></span>`; words.push('Jira forecast ' + fmt(fc)); }
122
179
  // the committed end is the Deliver or Evaluate ◇ (PgTimeline), with its date right of it; filled while the initiative is at that milestone
123
- out += `<i class="tg-end${r.track && r.track.ms ? ' ms' : ''}${over || clash ? ' late' : ''}" style="left:${P(X(e))}" title="${esc((r.track && r.track.k >= 6 ? 'Committed evaluation date ' : 'Committed delivery date ') + md(e) + (clash ? '. ' + clash : ''))}"></i>`;
124
- if (clash && !phone) out += `<span class="tg-lab late tg-clash" style="left:${P(X(e))}">${esc(fmt(e) + ' · ' + clash)}</span>`;
125
- else if (words.length && !phone) out += `<span class="tg-lab ${over ? 'late' : 'fc'}" style="left:${P(Math.max(over ? X(now) : 0, late ? X(fc) : 0))}">${esc((over ? '' : fmt(e) + ' · ') + words.join(' · '))}</span>`;
126
- else if (!phone) out += `<span class="tg-endl" style="left:${P(X(e))}">${esc(fmt(e))}</span>`;
180
+ // a milestone task in the stage the end ◇ stands for IS that ◇ (say it once, batch 11 item 3): the ◇ takes its name, and its done
181
+ const eTitle = et ? et.name + ' · ' + md(day(et.date)) + (et.stage ? ' · ◆ ' + et.stage : '') : (r.track && r.track.k >= 6 ? 'Committed evaluation date ' : 'Committed delivery date ') + md(e);
182
+ out += `<i class="tg-end${r.track && r.track.ms ? ' ms' : ''}${et && et.done ? ' dn' : ''}${over || clash || (et && msLate(et, now)) ? ' late' : ''}" style="left:${P(X(e))}" title="${esc(eTitle + (clash ? '. ' + clash : ''))}"></i>`;
183
+ if (clash && !phone) out += `<span class="tg-lab late tg-clash" style="left:${P(X(e))}">${esc(fmt(e) + ' · ' + clash)}${slipHtml(r)}</span>`;
184
+ else if (words.length && !phone) out += `<span class="tg-lab ${over ? 'late' : 'fc'}" style="left:${P(Math.max(over ? X(now) : 0, late ? X(fc) : 0))}">${esc((over ? '' : fmt(e) + ' · ') + words.join(' · '))}${slipHtml(r)}</span>`;
185
+ else if (!phone) out += `<span class="tg-endl" style="left:${P(X(e))}">${esc(fmt(e))}${slipHtml(r)}</span>`;
127
186
  } else if (fc) {
128
187
  out += `<span class="tg-fc solo" style="left:${P(X(fc))};width:12px;margin-left:-12px" title="Jira forecast ${esc(md(fc))}"></span>${phone ? '' : `<span class="tg-lab fc" style="left:${P(X(fc))}">Jira forecast ${esc(fmt(fc))}</span>`}`;
188
+ } else if (r.draft && day(r.draft.start)) {
189
+ out += draftBar(r, X, phone, fmt);
129
190
  } else {
130
191
  const d = s || e; out += `<i class="tg-dm" style="left:${P(X(d))}" title="${s ? 'Starts' : 'Ends'} ${esc(md(d))}"></i>`;
131
192
  }
132
- return out;
193
+ return out + planMarks(r, X, phone, fmt);
194
+ }
195
+
196
+ /* ── planned versus actual (batch 11 item 8; canvas PvaAC4Board): the Board draws Live only ──
197
+ * r.plan: the newest saved plan's span and the end slip (lib/task-plans.js decorate). A thin dark line with end caps under the bar, only where
198
+ * the dates differ; +14d orange after the end date when late, −15d grey when early. r.draft: an initiative with drafts only draws its newest
199
+ * draft dashed, and its title names the drafts. */
200
+ function planMarks(r, X, phone, fmt) {
201
+ const p = r.plan, a = p && day(p.start), b = p && day(p.end);
202
+ if (!a || !b || (p.start === r.start && p.end === r.end)) return '';
203
+ const words = 'Plan · ' + p.name + ' · ' + md(a) + ' to ' + md(b);
204
+ return `<span class="tg-pl" style="left:${P(X(a))};width:${P(Math.max(0.15, X(b) - X(a)))}" role="img" aria-label="${esc(words)}" title="${esc(words)}"></span>`;
205
+ }
206
+ /** The slip after an end date: " +14d" orange, " −15d" grey; nothing when the end did not move. */
207
+ export function slipHtml(r) {
208
+ const n = r && r.plan && r.plan.slip;
209
+ return n ? ` <b class="tg-slip${n > 0 ? ' late' : ''}">${n > 0 ? '+' + n : '\u2212' + -n}d</b>` : '';
210
+ }
211
+ function draftBar(r, X, phone, fmt) {
212
+ const D = r.draft, a = day(D.start), b = day(D.end) || a;
213
+ const tip = r.title + ' · draft. Newest: ' + D.name + (D.end ? ' · ends ' + md(b) : '') + (D.others && D.others.length ? '. Also: ' + D.others.map((x) => x.name + (x.end ? ' · ends ' + md(day(x.end)) : '')).join(', ') : '');
214
+ return `<span class="tg-bar tg-dr" data-key="${esc(r.key)}" style="left:${P(X(a))};width:${P(Math.max(0.15, X(b) - X(a)))}" title="${esc(tip)}" role="img" aria-label="${esc(tip)}"></span>`
215
+ + (phone ? '' : `<span class="tg-endl" style="left:${P(X(b))}">${esc(fmt(b))}</span>`);
133
216
  }
134
217
 
135
218
  const MIN_PX = 8; // a hold or a gap narrower than this closes up (XtiA4Long, XtiAGrill 12)
@@ -152,13 +235,21 @@ function gapsHtml(r, X, now, phone, fmt, pxPct, s, e, tone) {
152
235
  const cut = shown.map((x) => [x.a, x.b, x]);
153
236
  // a plain gap that a hold covers in part keeps the part outside it: a hold with no return date runs to today, and the work dated after it
154
237
  // starts where its tasks start, not today (feedback batch 10 item 3, Email OTP: the bar came back at today, months before its Build tasks)
155
- for (const g of Array.isArray(r.gaps) ? r.gaps : []) {
156
- let parts = [[day(g.from), day(g.to)]];
157
- if (!parts[0][0] || !parts[0][1]) continue;
158
- for (const x of H) parts = parts.flatMap(([a, b]) => (x.a < b && x.b > a ? [[a, x.a], [x.b, b]].filter(([p, q]) => q > p) : [[a, b]]));
159
- for (const [a, b] of parts) if (b > s && a < e && wide(a, b)) cut.push([a < s ? s : a, b > e ? e : b, null]);
160
- }
238
+ const plain = plainGaps(r, now).filter(([a, b]) => wide(a, b));
239
+ for (const [a, b] of plain) cut.push([a, b, null]);
161
240
  cut.sort((p, q) => p[0] - q[0]);
241
+ // the » of each skipped stage between two dated ones (batch 11 item 13): on the gap that lies between them, else on the bar at the joint
242
+ const marks = [], dropped = [];
243
+ for (const k of skipsOf(r)) {
244
+ const lo = k.lo < k.hi ? k.lo : k.hi, hi = k.lo < k.hi ? k.hi : k.lo;
245
+ const gi = plain.findIndex(([a, b]) => a <= hi && b >= lo);
246
+ const words = skipWords(k.items);
247
+ if (gi >= 0) {
248
+ const [a, b] = plain[gi];
249
+ if (pxPct && (X(b) - X(a)) * pxPct < 24) dropped.push(words); else marks.push({ gi, words });
250
+ } else if (k.hi > s && k.hi < e) marks.push({ x: X(k.hi), words });
251
+ else dropped.push(words);
252
+ }
162
253
  // the pieces: the plan minus the cuts; after a hold with no return date the rest of the plan is faded (nobody knows when it starts)
163
254
  const pieces = []; let at = s, faded = false;
164
255
  for (const [a, b, x] of cut) {
@@ -169,12 +260,25 @@ function gapsHtml(r, X, now, phone, fmt, pxPct, s, e, tone) {
169
260
  if (at < e) pieces.push([at, e, faded]);
170
261
  const days = (p) => Math.max(0, (p[1] - p[0]) / 86400000), total = pieces.reduce((n, p) => n + days(p), 0);
171
262
  let left = (doneOf(r) / 100) * total;
172
- const hold = H.length ? '. ' + H.map((x) => holdWords(x, now)).join('. ') : '';
263
+ const hold = (H.length ? '. ' + H.map((x) => holdWords(x, now)).join('. ') : '') + (dropped.length ? '. ' + dropped.join('. ') : '');
173
264
  let html = pieces.map((p, i) => {
174
265
  const d = days(p), f = d ? Math.max(0, Math.min(1, left / d)) : 0; left -= d;
175
266
  const xl = i > 0 || p[0] > s ? ' xl' : '', xr = i < pieces.length - 1 || p[1] < e ? ' xr' : '';
176
267
  return `<span class="tg-bar t-${tone}${xl}${xr}${p[2] ? ' fd' : ''}" data-key="${esc(r.key)}" style="left:${P(X(p[0]))};width:${P(Math.max(0.15, X(p[1]) - X(p[0])))}" title="${esc('PMOS plan ' + md(s) + ' to ' + md(e) + hold)}"><b style="width:${(f * 100).toFixed(1)}%"></b></span>`;
177
268
  }).join('');
269
+ // each plain gap: the hairline, one press (a 24 px area) with its words; a phone draws the line alone and its row sheet says it
270
+ plain.forEach(([a, b], gi) => {
271
+ const sk = marks.filter((m) => m.gi === gi), lines = gapWords(a, b, now).concat(sk.map((m) => m.words));
272
+ const l = X(a), w = X(b) - l, ahead = addDays(b, -1) >= new Date(now.getFullYear(), now.getMonth(), now.getDate());
273
+ const chev = sk.length ? `<i class="tg-sk" aria-hidden="true">${SV(SKIP)}</i>` : '';
274
+ if (phone) { html += `<span class="tg-ng" style="left:${P(l)};width:${P(w)}" aria-hidden="true">${chev}</span>`; return; }
275
+ html += `<button type="button" class="tg-ng" data-gap="${esc(r.key)}" data-from="${iso(a)}" data-to="${iso(b)}"${ahead ? ' data-ahead="1"' : ''} style="left:${P(l)};width:${P(w)}" aria-label="${esc(lines.join('. '))}" title="${esc(lines.join('\n'))}" aria-haspopup="dialog">${chev}</button>`;
276
+ });
277
+ // a » at a joint (no gap between the two stages) sits on the bar
278
+ for (const m of marks.filter((x) => x.gi == null)) {
279
+ html += phone ? `<i class="tg-sk on" style="left:${P(m.x)}" aria-hidden="true">${SV(SKIP)}</i>`
280
+ : `<span class="tg-sk on" style="left:${P(m.x)}" role="img" aria-label="${esc(m.words)}" title="${esc(m.words)}">${SV(SKIP)}</span>`;
281
+ }
178
282
  for (const x of shown) {
179
283
  const late = x.kind === 'over' ? ' late' : '', l = X(x.a), w = X(x.b) - l, narrow = pxPct && w * pxPct < 34;
180
284
  html += `<span class="tg-gap${late}" style="left:${P(l)};width:${P(w)}" aria-hidden="true"></span>`;
@@ -188,6 +292,93 @@ function gapsHtml(r, X, now, phone, fmt, pxPct, s, e, tone) {
188
292
  const clash = ob ? (r.track && r.track.k >= 6 ? 'Evaluate' : 'Deliver') + ' is before the return, ' + md(ob.b) : null;
189
293
  return { html, clash };
190
294
  }
295
+ const iso = (d) => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
296
+
297
+ /** The key of the workflow's last ◆ stage: its own list's, else Product feature's Evaluate. */
298
+ const lastMs = (r) => { const S = (r.wfStages || []).filter((x) => x && x.milestone); return S.length ? String(S[S.length - 1].key).toLowerCase() : 'evaluate'; };
299
+ /** The ◆ stage a milestone task sits in, by name, or ''. */
300
+ const msStage = (r, m) => { if (!m.sec) return ''; const st = (r.wfStages || []).find((x) => x.key === m.sec); return st ? (st.milestone ? st.name : '') : /^(deliver|evaluate)$/i.test(m.sec) ? m.sec.replace(/^./, (c) => c.toUpperCase()) : ''; };
301
+ /** The milestone task the bar's end ◇ stands for, or null. The end ◇ is the workflow's last ◆ stage (Evaluate on Product feature): the latest
302
+ * milestone task in that stage IS it, else one on the end's own day; it takes that task's name and done, and is not drawn twice. A task in an
303
+ * earlier ◆ stage keeps its own ◇. M: the row's dated milestones. */
304
+ function endTask(r, M) {
305
+ const e = day(r.end); if (!e) return null;
306
+ const last = lastMs(r), inLast = M.filter((m) => m.sec && m.sec.toLowerCase() === last);
307
+ const end = inLast.length ? inLast[inLast.length - 1] : M.find((m) => +day(m.date) === +e) || null;
308
+ return end ? { ...end, stage: msStage(r, end) } : null;
309
+ }
310
+ /** One ◇ per milestone task on the row (feedback batch 11 item 3; canvas XmlA1Board, XmlA4Hover, XmlA7Spans): at its due date, hollow while open,
311
+ * filled grey when done, an orange outline and an orange date when late. Quarter and Half put a short date under each ◇, Year and 2 yr cut the
312
+ * date to fit, 5 yr and a phone none. ◇s closer than about 40 px merge into one counted ◇ that lists them under it. The latest milestone task in
313
+ * a ◆ stage, or one on the end's own day, is the end ◇ and is not drawn again. Not draggable. → { html, end } */
314
+ function taskMarks(r, X, now, phone, pxPct, ms) {
315
+ const M = (r.milestones || []).filter((m) => day(m.date));
316
+ if (!M.length) return { html: '', end: null };
317
+ const end = endTask(r, M);
318
+ const L = M.filter((m) => !end || m.id !== end.id).map((m) => ({ ...m, late: msLate(m, now), stage: msStage(r, m) }))
319
+ .filter((m) => { const x = X(day(m.date)); return x > 0 && x < 100; });
320
+ const C = mergeClose(L, Math.max(1, ms.reach || 7));
321
+ const sp = ms.sp || 'quarter', dates = !phone && sp !== 'y5', cut = sp === 'year' || sp === 'y2';
322
+ const xs = C.map((c) => X(day(c.date))), room = (i) => (pxPct ? Math.min(i ? xs[i] - xs[i - 1] : 1e3, i < xs.length - 1 ? xs[i + 1] - xs[i] : 1e3) * pxPct - 6 : 0);
323
+ const fmtD = (d) => (sp === 'y2' ? my(d) : md(d));
324
+ const html = C.map((c, i) => {
325
+ const x = P(xs[i]), tone = c.late ? ' late' : c.done ? ' dn' : '';
326
+ const one = c.items[0], words = (m) => m.name + ' · ' + md(day(m.date)) + (m.stage ? ' · ◆ ' + m.stage : '') + (m.late ? ' · late' : m.done ? ' · done' : '');
327
+ const mark = c.n > 1
328
+ ? `<button type="button" class="tg-tmc${tone}" data-ms-row="${esc(r.key)}" data-ms-ids="${esc(c.items.map((m) => m.id).join(' '))}" style="left:${x}" aria-haspopup="menu" aria-label="${esc(c.n + ' milestones, ' + c.range + ': ' + c.items.map((m) => m.name).join(', '))}" title="${esc(c.items.map(words).join('\n'))}"><b aria-hidden="true">${c.n}</b></button>`
329
+ : `<span class="tg-tm${tone}" style="left:${x}" role="img" aria-label="${esc('Milestone ' + words(one))}" title="${esc(words(one))}"></span>`;
330
+ if (!dates) return mark;
331
+ const label = c.n > 1 ? c.range : fmtD(day(one.date)), w = cut && room(i) > 0 ? `;max-width:${Math.max(18, Math.round(room(i)))}px` : '';
332
+ return mark + `<span class="tg-tml${c.late ? ' late' : ''}" style="left:${x}${w}">${esc(label)}</span>`;
333
+ }).join('');
334
+ return { html, end };
335
+ }
336
+
337
+ /* ── the product lane (feedback batch 11 item 17; canvas PlmA1Board, PlmA2Folded, PlmA3Phone) ──
338
+ * A product's head row on the timeline carries every milestone of its initiatives: each row's milestone tasks and each row's end ◇ (the
339
+ * committed Deliver or Evaluate date, as qBar draws it). Derived, nothing stored. The same ◇ as the rows: open, filled when done, orange when
340
+ * late. Close ◇s merge into one counted ◇ (the rows' reach, about 40 px) with the date range under it; pressing it lists them, each line opening
341
+ * its initiative. A thin line runs from the first start to the last end. A phone draws the ◇s alone; a tap on the lane lists them in a sheet. */
342
+ /** A product's milestones, by date: [{ id, name, date, done, late, row }]. */
343
+ export function laneMilestones(rows, now) {
344
+ const out = [];
345
+ for (const r of rows || []) {
346
+ const M = (r.milestones || []).filter((m) => day(m.date)), s = day(r.start), e = day(r.end), et = endTask(r, M);
347
+ for (const m of M) if (!et || m.id !== et.id) out.push({ id: m.id, name: m.name, date: m.date, done: !!m.done, late: msLate(m, now), row: r });
348
+ if (!s || !e) continue;
349
+ const ob = openBack(r, now), late = (r.over && now > e) || (ob && ob > e) || (et && msLate(et, now));
350
+ out.push({ id: et ? et.id : '', name: et ? et.name : r.track && r.track.k >= 6 ? 'Evaluate' : 'Deliver', date: iso(e), done: !!(et && et.done), late: !!late, row: r });
351
+ }
352
+ return out.sort((a, b) => day(a.date) - day(b.date));
353
+ }
354
+ /** The lines a lane's list or sheet shows, as data on its ◇ or its track: name, initiative, date and tone. */
355
+ const laneData = (L) => esc(JSON.stringify(L.map((m) => ({ k: m.row.key, n: m.name, t: m.row.title, d: String(m.date).slice(0, 10), s: m.late ? 'late' : m.done ? 'dn' : '' }))));
356
+ /** The lane's ◇s: one per milestone, close ones merged into a counted ◇ (a button on a desktop, a mark on a phone, where the lane's tap lists
357
+ * them); Quarter and Half put the date under each, Year and 2 yr cut it to fit, 5 yr and a phone none (XmlA7Spans). */
358
+ function laneMarks(L, X, phone, pxPct, ms) {
359
+ const C = mergeClose(L.filter((m) => { const x = X(day(m.date)); return x > 0 && x < 100; }), Math.max(1, ms.reach || 7));
360
+ const sp = ms.sp || 'quarter', dates = !phone && sp !== 'y5', cut = sp === 'year' || sp === 'y2';
361
+ const xs = C.map((c) => X(day(c.date))), room = (i) => (pxPct ? Math.min(i ? xs[i] - xs[i - 1] : 1e3, i < xs.length - 1 ? xs[i + 1] - xs[i] : 1e3) * pxPct - 6 : 0);
362
+ const fmtD = (d) => (sp === 'y2' ? my(d) : md(d));
363
+ const words = (m) => m.name + ' · ' + m.row.title + ' · ' + md(day(m.date)) + (m.late ? ' · late' : m.done ? ' · done' : '');
364
+ return C.map((c, i) => {
365
+ const x = P(xs[i]), tone = c.late ? ' late' : c.done ? ' dn' : '', one = c.items[0];
366
+ const mark = c.n < 2 ? `<span class="tg-tm${tone}" style="left:${x}" role="img" aria-label="${esc('Milestone ' + words(one))}" title="${esc(words(one))}"></span>`
367
+ : phone ? `<span class="tg-tmc${tone}" style="left:${x}" aria-hidden="true"><b>${c.n}</b></span>`
368
+ : `<button type="button" class="tg-tmc${tone}" data-ms-lane="${laneData(c.items)}" style="left:${x}" aria-haspopup="menu" aria-label="${esc(c.n + ' milestones, ' + c.range + ': ' + c.items.map((m) => m.name + ', ' + m.row.title).join('; '))}" title="${esc(c.items.map(words).join('\n'))}"><b aria-hidden="true">${c.n}</b></button>`;
369
+ if (!dates) return mark;
370
+ const label = c.n > 1 ? c.range : fmtD(day(one.date)), w = cut && room(i) > 0 ? `;max-width:${Math.max(18, Math.round(room(i)))}px` : '';
371
+ return mark + `<span class="tg-tml${c.late ? ' late' : ''}" style="left:${x}${w}">${esc(label)}</span>`;
372
+ }).join('');
373
+ }
374
+ /** The product's head row on the timeline: the name cell (tile, name, goal dots, count when folded, the fold) and the lane. Open or folded it
375
+ * looks the same: folded, it is the product's summary. */
376
+ function laneRow(g, X, W, ov, o, ms, pxPct, now) {
377
+ const sp = progSpan(g), br = sp && sp.hi > W.from && sp.lo < W.to ? progLine(g, sp, X, now) : '';
378
+ const L = laneMilestones(g.rows, now), marks = laneMarks(L, X, o.phone, pxPct, ms), shut = o.folded(g.key) ? ' closed' : '';
379
+ if (o.phone) return `<div class="tgq-r tg-lane${shut}" data-lane="${esc(g.key)}"><div class="tgq-n tg-lnn">${o.prodCell(g)}</div><div class="tg-p"${L.length ? ` data-lane-ms="${laneData(L)}" data-lane-name="${esc(g.name)}"` : ''}>${ov}${br}${marks}</div></div>`;
380
+ return `<div class="tg-r tg-lane${shut}" role="row" data-lane="${esc(g.key)}"><div class="tg-n tg-lnn" role="rowheader">${o.prodCell(g)}</div><div class="tg-p" role="cell">${ov}${br}${marks}</div></div>`;
381
+ }
191
382
 
192
383
  /** A row's milestones: its release's sign-off (◆ at the release date), "Push tickets" where drafted tickets wait on your Commit (today), and
193
384
  * "after <initiative>" at the plan start where a dependency is not done. Each one only from a record. */
@@ -226,13 +417,15 @@ function edgeTabs(r, X, now, phone) {
226
417
  return (isDone(r) ? '' : tab('l', lw, late ? ' late' : '')) + (isDone(r) ? '' : tab('r', rw, ''));
227
418
  }
228
419
 
229
- /** The legend (PgTimeline), in the chip row on every span from Quarter on: done, planned, on hold while a hold is drawn, the Jira forecast, a
230
- * program milestone where a program is drawn, Deliver or Evaluate, today. */
231
- export const legendHtml = (prog, hold) => `<span class="tg-lgd" role="group" aria-label="Legend"><span><i class="k dn"></i>Done in Jira</span><span><i class="k pl"></i>Planned</span>${hold ? '<span><i class="k ho"></i>On hold</span>' : ''}<span><i class="k fc"></i>Jira forecast</span>${prog ? '<span><i class="k pdm"></i>Program milestone</span>' : ''}<span><i class="k dlv"></i>Deliver or Evaluate</span><span><i class="k td"></i>Today</span></span>`;
420
+ /** The legend (PgTimeline), in the chip row on every span from Quarter on: done, to do, a saved plan's line and a draft while one is drawn,
421
+ * No activity and Skipped while one is drawn (extra: { gap, skip }; batch 11 item 13)
422
+ * (extra: { plan, draft }; batch 11 item 8), on hold while a hold is drawn, the Jira forecast, a program milestone where a program is
423
+ * drawn, Milestone (Deliver, Evaluate and every milestone task, batch 11 item 3), today. */
424
+ export const legendHtml = (prog, hold, extra = {}) => `<span class="tg-lgd" role="group" aria-label="Legend"><span><i class="k dn"></i>Done in Jira</span><span><i class="k pl"></i>To do</span>${extra.plan ? '<span><i class="k pln"></i>Plan</span>' : ''}${extra.draft ? '<span><i class="k drf"></i>Draft</span>' : ''}${hold ? '<span><i class="k ho"></i>On hold</span>' : ''}${extra.gap ? '<span><i class="k ng"></i>No activity</span>' : ''}${extra.skip ? `<span><i class="k sk">${SV(SKIP)}</i>Skipped</span>` : ''}<span><i class="k fc"></i>Jira forecast</span>${prog ? '<span><i class="k pdm"></i>Program milestone</span>' : ''}<span><i class="k dlv"></i>Milestone</span><span><i class="k td"></i>Today</span></span>`;
232
425
 
233
426
  /** The dates on record a window must hold: every shown row's plan and forecast, the programs' spans and milestones, the release. */
234
427
  function datesOf(list, M, o) {
235
- const ds = list.flatMap((r) => [day(r.start), day(r.end), r.track && day(r.track.forecast), day(r.start) ? openBack(r, o.now) : null]);
428
+ const ds = list.flatMap((r) => [day(r.start), day(r.end), r.track && day(r.track.forecast), day(r.start) ? openBack(r, o.now) : null, r.plan && day(r.plan.start), r.plan && day(r.plan.end), r.draft && day(r.draft.start), r.draft && day(r.draft.end)]);
236
429
  for (const { g, st } of progGroups(o)) { const sp = progSpan(g); if (sp) ds.push(sp.lo, sp.hi); for (const m of st.milestones || []) ds.push(day(m.date)); }
237
430
  const rel = M.jira && M.jira.release; if (rel) ds.push(day(rel.iso));
238
431
  return ds.filter(Boolean);
@@ -248,6 +441,7 @@ function scaled(rows, M, o) {
248
441
  const days = (W.to - W.from) / 86400000, viewDays = W.fixed ? days : W.cols * COL_DAYS[W.unit];
249
442
  const ratio = days / viewDays, tpx = Math.max(200, o.trackPx || (o.phone ? 340 : 1100)), pxDay = tpx / viewDays;
250
443
  const reach = Math.max(W.fixed ? 1 : 2, Math.round(120 / pxDay)); // program milestones closer than ~120 px merge (TsCGrill 9)
444
+ const msO = { sp, reach: Math.max(1, Math.round(40 / pxDay)) }; // a row's milestone ◇s closer than ~40 px merge (batch 11 item 3)
251
445
  const ov = overlay(W, X, now, sprint, rel), pxPct = (tpx * (W.fixed ? 1 : ratio)) / 100;
252
446
  const ra = rel && day(rel.iso), sa = sprint && day(sprint.start), sb = sprint && day(sprint.end);
253
447
  // an undated program member's track says so beside today, where the view opens
@@ -261,30 +455,40 @@ function scaled(rows, M, o) {
261
455
  const style = `--tw:${Math.round(tpx * (W.fixed ? 1 : ratio))}px`;
262
456
  // a program keeps its undated initiatives as rows that say "No dates" (feedback batch 8 item 4: initiatives just moved into a program
263
457
  // were missing under it); a product group keeps only the dated ones, and the foot names the rest
264
- const G = o.groups ? o.groups.map((g) => (g.kind === 'program' ? { ...g, products: g.products.filter((x) => x.rows.length) } : { ...g, rows: g.rows.filter((r) => list.includes(r)) })).filter((g) => g.rows.length || g.kind === 'program') : null;
458
+ // by key, not by identity: By product copies a program's row ({ ...r, inProgram }), and that copy is never in `list` (batch 11 item 12: a
459
+ // program's initiatives were missing from their product on the timeline)
460
+ // By product, a program's undated initiative keeps its "No dates" row under its product too (batch 11 item 19: they disappeared once grouped by product)
461
+ const onList = new Set(list.map((r) => r.key));
462
+ // a timeline reads in time (batch 11 item 22): each group's rows by start, then end; undated ones last. The health dot still says late or at risk
463
+ const at = (r) => { const x = extentOf(r, now); return x ? [+x.a, +x.b] : [Infinity, Infinity]; };
464
+ const byTime = (L) => L.map((r) => [at(r), r]).sort((p, q) => p[0][0] - q[0][0] || p[0][1] - q[0][1]).map((x) => x[1]);
465
+ list.splice(0, list.length, ...byTime(list));
466
+ const G = o.groups ? o.groups.map((g) => (g.kind === 'program' ? { ...g, products: g.products.filter((x) => x.rows.length).map((x) => ({ ...x, rows: byTime(x.rows) })) } : { ...g, rows: byTime(g.rows.filter((r) => onList.has(r.key) || r.inProgram)) })).filter((g) => g.rows.length || g.kind === 'program') : null;
265
467
  const empty = '<p class="tg-empty">No initiative on screen has a date on record.</p>';
266
468
  const ext = (r) => { const x = extentOf(r, now); return x ? ` data-a="${X(x.a).toFixed(3)}" data-b="${X(x.b).toFixed(3)}"` : ''; };
469
+ // a product's head carries its lane from Quarter on (batch 11 item 17); Sprint on a phone, and a page that gives no head cell, keep the plain head
470
+ const lane = (g) => (o.prodCell && sp !== 'sprint' ? laneRow(g, X, W, ov, o, msO, pxPct, now) : o.prodHtml(g));
267
471
  if (o.phone) {
268
472
  // TsCPhone: each row carries its name above its bar; the name stays at the left while you swipe
269
- const one = (r) => `<div class="tgq-r${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tgq-n ini2" data-key="${esc(r.key)}" aria-label="${esc(r.title + ', ' + o.status(r).text)}"><i class="cz-dot ${toneOf(r)}" aria-hidden="true"></i><b>${esc(r.title)}</b></button><div class="tg-p"${ext(r)}>${ov}${dated(r) ? qBar(r, X, now, true, fmt, pxPct) + edgeTabs(r, X, now, true) : ND}</div></div>`;
473
+ const one = (r) => `<div class="tgq-r${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tgq-n ini2" data-key="${esc(r.key)}" aria-label="${esc(r.title + ', ' + o.status(r).text)}"><i class="cz-dot ${toneOf(r, now)}" aria-hidden="true"></i><b>${esc(r.title)}</b></button><div class="tg-p"${ext(r)}>${ov}${dated(r) ? qBar(r, X, now, true, fmt, pxPct, msO) + edgeTabs(r, X, now, true) : ND}</div></div>`;
270
474
  const body = G ? G.map((g) => {
271
- if (g.kind !== 'program') return o.prodHtml(g) + (o.folded(g.key) ? '' : g.rows.map(one).join(''));
475
+ if (g.kind !== 'program') return lane(g) + (o.folded(g.key) ? '' : g.rows.map(one).join(''));
272
476
  const st = o.progState(g.program), s2 = progSpan(g);
273
477
  const br = s2 ? progLine(g, s2, X, now) : '';
274
478
  return `<div class="tgq-r tg-pg" data-prow="${esc(g.program.id)}"><div class="tgq-n tg-pgn">${progName(g, st, o)}</div><div class="tg-p">${ov}${br}${progMarks(g, st, X, W, reach, long ? my : null, true)}</div></div>` + (o.folded(g.key) ? '' : g.products.map((x) => x.rows.map(one).join('')).join(''));
275
479
  }).join('') : list.map(one).join('');
276
- const head = `<div class="tgq-h"><div class="tg-p">${ticks}${pill}</div></div>`;
480
+ const top = `<div class="tgq-h"><div class="tg-p">${ticks}${pill}</div></div>`;
277
481
  const below = none.length ? `<div class="tg-none"><span>${none.length} ${none.length === 1 ? 'has' : 'have'} no dates</span>${askBtn}</div>` : '';
278
- return { html: `<div class="tg tg-s tgq" ${attrs}><div class="tg-scw"><div class="tg-sc" tabindex="0" role="group" aria-label="Timeline" style="${style}"><div class="tg-in">${head}<div class="tg-body">${body || empty}</div></div></div>${back}<i class="tg-fade l" aria-hidden="true"></i><i class="tg-fade r" aria-hidden="true"></i></div></div>${below}`, none };
482
+ return { html: `<div class="tg tg-s tgq" ${attrs}><div class="tg-scw"><div class="tg-sc" tabindex="0" role="group" aria-label="Timeline" style="${style}"><div class="tg-in">${top}<div class="tg-body">${body || empty}</div></div></div>${back}<i class="tg-fade l" aria-hidden="true"></i><i class="tg-fade r" aria-hidden="true"></i></div></div>${below}`, none };
279
483
  }
280
484
  const head = `<div class="tg-r tg-h"><div class="tg-n"><b>Initiative</b>${back}</div><div class="tg-p">${ticks}${pill}</div></div>`;
281
485
  // one line per initiative (PgTimeline): its status dot and its name; the owner and the step stay in the row's title for a pointer and a reader
282
486
  const one = (r, cls) => { const s = o.status(r), sub = [r.owner, r.track ? r.track.label : r.stage, s.text].filter(Boolean).join(' · ');
283
- return `<div class="tg-r${cls || ''}${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tg-n ini2" data-key="${esc(r.key)}" title="${esc(sub)}" aria-label="${esc(r.title + ', ' + sub)}"><i class="cz-dot ${toneOf(r)}${toneOf(r) === 'you' ? ' m-info' : toneOf(r) === 'late' || toneOf(r) === 'risk' ? ' m-warn' : ''}" aria-hidden="true"></i><b>${r.inProgram && o.memberIcon ? o.memberIcon(r.inProgram) : ''}${esc(r.title)}</b></button><div class="tg-p"${ext(r)}>${ov}${dated(r) ? qBar(r, X, now, false, fmt, pxPct) + edgeTabs(r, X, now, false) : ND}</div></div>`; };
487
+ return `<div class="tg-r${cls || ''}${o.sel === r.key ? ' sel' : ''}" data-row="${esc(r.key)}"><button type="button" class="tg-n ini2" data-key="${esc(r.key)}" title="${esc(sub)}" aria-label="${esc(r.title + ', ' + sub)}"><i class="cz-dot ${toneOf(r, now)}${toneOf(r, now) === 'you' ? ' m-info' : toneOf(r, now) === 'late' || toneOf(r, now) === 'risk' ? ' m-warn' : ''}" aria-hidden="true"></i><b>${r.inProgram && o.memberIcon ? o.memberIcon(r.inProgram) : ''}${esc(r.title)}</b></button><div class="tg-p"${ext(r)}>${ov}${dated(r) ? qBar(r, X, now, false, fmt, pxPct, msO) + edgeTabs(r, X, now, false) : ND}</div></div>`; };
284
488
  // programs first, then the product (PgTimeline): the program's row brackets its initiatives' bars and draws its milestones as diamonds
285
489
  const body = G ? G.map((g) => {
286
- if (g.kind !== 'program') return o.prodHtml(g) + (o.folded(g.key) ? '' : g.rows.map((r) => one(r, ' tg-gr')).join(''));
287
- const last = g.rows[g.rows.length - 1];
490
+ if (g.kind !== 'program') return lane(g) + (o.folded(g.key) ? '' : g.rows.map((r) => one(r, ' tg-gr')).join(''));
491
+ const lp = g.products[g.products.length - 1], last = lp ? lp.rows[lp.rows.length - 1] : null;
288
492
  return progRow(g, o.progState(g.program), X, W, ov, o, reach, long ? my : null, pxPct, now) + (o.folded(g.key) ? '' : g.products.map((x) => (g.products.length > 1 ? o.subHtml(x.name) : '') + x.rows.map((r) => one(r, ' tg-kid' + (r === last ? ' last' : ''))).join('')).join(''));
289
493
  }).join('') : list.map((r) => one(r)).join('');
290
494
  // the sprint band and the release keep their labels under the axis on Quarter, where a week is wide enough to read them
@@ -8,6 +8,7 @@
8
8
  * · Documents (BdDocs): the board's core documents and the documents its initiatives link (PRD, rubric, evaluation, release notes), with
9
9
  * kind chips, health, when it changed and who changed it (GET /api/board-docs), and a row opens the document's panel.
10
10
  * Nothing here invents a value: what no record holds is shown as "—" or not drawn. */
11
+ import { nameHtml } from './split-merge.js'; // Claude suggests a split or a merge: the purple dot after the name (batch 11 item 14)
11
12
  import { esc } from './premium-shell.js';
12
13
  import * as WF from './bd-wf.js';
13
14
  import { nextHtml } from './bd-next.js';
@@ -81,7 +82,7 @@ function listRow(r, pg) {
81
82
  const p = pg ? progOf(r) : null, prod = pg ? r.product || A.product() : '';
82
83
  const pcells = pg ? `<span role="cell" class="bd-pt">${A.tileHtml(prod, 'bd-ti s')}<span class="bd-ell">${esc(prod)}</span></span><span role="cell" class="bd-pt">${p ? A.progTile('bd-pti s') + `<span class="bd-ell">${esc(p.title)}</span>` : ''}</span>` : '';
83
84
  return `<div class="bd-lt${sel ? ' sel' : ''}${r.acts && r.acts.life === 'hold' ? ' held' : ''}" role="row" data-row="${esc(r.key)}">`
84
- + `<button type="button" class="bd-ltn ini2" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${esc(r.title)}</b></button>${pcells}`
85
+ + `<button type="button" class="bd-ltn ini2" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${nameHtml(r)}</b></button>${pcells}`
85
86
  + `<span role="cell" class="bd-wfn">${WF.wfIcon(WF.wfOf(r), 18)}<span class="bd-ell">${esc(WF.wfOf(r).name)}</span></span><span role="cell">${(r.track || {}).ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(stepText(r, true))}</span><span role="cell">${catPill(r)}</span>`
86
87
  + `<span role="cell" class="cs s-${s.tone}"><i class="cz-dot ${s.tone} ${s.mo || ''}"></i>${esc(s.text)}</span>`
87
88
  + `<span role="cell">${avatar(r.owner)}</span><span role="cell" class="bd-nxc">${nextHtml(r, { self: M().board.self, due: false })}</span>`
@@ -258,7 +259,7 @@ export function stagesHtml(L, o = {}) {
258
259
  function phoneRow(r) {
259
260
  const s = statusLine(r), t = r.track || {}, w = WF.stageOfRow(r);
260
261
  const sub = [(w && w.name) || t.label || r.stage, t.you ? t.you.replace(/^Your /, 'your ') : s.tone !== 'ok' && s.tone !== 'q' ? s.text.toLowerCase() : '', r.owner].filter(Boolean).join(' · ');
261
- return `<button type="button" class="bd-lrow ini2${A.sel && A.sel() === r.key ? ' sel' : ''}" data-key="${esc(r.key)}" aria-haspopup="dialog"><i class="cz-dot ${s.tone} ${s.mo || ''}"></i><span class="tx"><span class="t">${esc(r.title)}</span><span class="s${t.you ? '' : ' q'}">${esc(sub)}</span></span>${t.you && t.days != null ? `<span class="r">${t.days}d</span>` : ''}${many() ? WF.wfIcon(WF.wfOf(r), 18) : ''}</button>`;
262
+ return `<button type="button" class="bd-lrow ini2${A.sel && A.sel() === r.key ? ' sel' : ''}" data-key="${esc(r.key)}" aria-haspopup="dialog"><i class="cz-dot ${s.tone} ${s.mo || ''}"></i><span class="tx"><span class="t">${nameHtml(r)}</span><span class="s${t.you ? '' : ' q'}">${esc(sub)}</span></span>${t.you && t.days != null ? `<span class="r">${t.days}d</span>` : ''}${many() ? WF.wfIcon(WF.wfOf(r), 18) : ''}</button>`;
262
263
  }
263
264
  export function phoneListHtml(L) {
264
265
  const you = L.filter((r) => r.track && r.track.you), bad = L.filter((r) => !you.includes(r) && needOf(r) <= 3), rest = L.filter((r) => !you.includes(r) && !bad.includes(r));