create-pmos 0.420.0 → 0.422.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/anchor-resolve.js +93 -15
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/board-programs-test.js +59 -3
  8. package/workspace/briefing-premium-board-test.js +1 -1
  9. package/workspace/changelog.json +24 -0
  10. package/workspace/fixtures/report-api/draft.json +2 -1
  11. package/workspace/guide/briefing-premium.md +2 -1
  12. package/workspace/guide/home.md +6 -2
  13. package/workspace/guide/programs.md +4 -3
  14. package/workspace/home-other-product-test.js +55 -0
  15. package/workspace/lib/board-premium.js +18 -4
  16. package/workspace/lib/briefing-premium-agent.js +8 -0
  17. package/workspace/lib/doc-live-root.js +37 -0
  18. package/workspace/lib/engine/anchor-resolve.js +93 -15
  19. package/workspace/lib/engine/boards.js +7 -2
  20. package/workspace/lib/engine/intake.js +1 -1
  21. package/workspace/lib/first-input.js +13 -6
  22. package/workspace/lib/hold-spans.js +24 -10
  23. package/workspace/lib/kg.js +1 -1
  24. package/workspace/lib/report-draft.js +3 -0
  25. package/workspace/lib/route-modules.js +1 -0
  26. package/workspace/lib/routes-board-premium.js +6 -0
  27. package/workspace/lib/routes-boards.js +48 -9
  28. package/workspace/lib/routes-doc-sheet.js +29 -1
  29. package/workspace/lib/routes-programs.js +44 -5
  30. package/workspace/lib/routes-task-plans.js +333 -0
  31. package/workspace/lib/task-cli.js +16 -9
  32. package/workspace/lib/task-items.js +1 -1
  33. package/workspace/lib/task-plans.js +232 -0
  34. package/workspace/lib/transcript-read.js +29 -1
  35. package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
  36. package/workspace/lib/vendor/scripts/intake.js +1 -1
  37. package/workspace/package-lock.json +2 -2
  38. package/workspace/package.json +1 -1
  39. package/workspace/premium-viewer-test.js +1 -1
  40. package/workspace/premium-vw-doc-test.js +26 -3
  41. package/workspace/program-leave-test.js +203 -0
  42. package/workspace/public/pm/bd-acts.js +5 -2
  43. package/workspace/public/pm/bd-ini-panel.js +20 -7
  44. package/workspace/public/pm/bd-prog-panel.js +22 -7
  45. package/workspace/public/pm/bd-span.js +177 -24
  46. package/workspace/public/pm/cozy-board.css +80 -0
  47. package/workspace/public/pm/cozy-home.css +3 -0
  48. package/workspace/public/pm/cozy-live-pill.js +1 -1
  49. package/workspace/public/pm/cozy-nav.js +1 -1
  50. package/workspace/public/pm/cozy-steps.js +1 -1
  51. package/workspace/public/pm/cozy-xv.js +1 -1
  52. package/workspace/public/pm/doc-follow.js +36 -0
  53. package/workspace/public/pm/home-app.js +38 -7
  54. package/workspace/public/pm/home-ask.js +7 -0
  55. package/workspace/public/pm/home-ini.js +13 -4
  56. package/workspace/public/pm/home-line.js +1 -1
  57. package/workspace/public/pm/home-list.js +2 -2
  58. package/workspace/public/pm/home-today.js +3 -1
  59. package/workspace/public/pm/ini-tasks.js +81 -16
  60. package/workspace/public/pm/ini-versions.js +343 -0
  61. package/workspace/public/pm/ini-view-model.js +27 -41
  62. package/workspace/public/pm/ini-view.css +82 -0
  63. package/workspace/public/pm/ini-view.js +18 -11
  64. package/workspace/public/pm/premium-board.js +109 -18
  65. package/workspace/public/pm/premium-insights.js +1 -1
  66. package/workspace/public/pm/premium-mtg-present.js +2 -2
  67. package/workspace/public/pm/premium-report-read.js +21 -2
  68. package/workspace/public/pm/premium-report-tab.js +1 -1
  69. package/workspace/public/pm/premium-shell.js +29 -4
  70. package/workspace/public/pm/premium-viewer.js +3 -3
  71. package/workspace/public/pm/premium-vw-doc.js +46 -11
  72. package/workspace/public/pm/premium-vw-mtg.js +1 -1
  73. package/workspace/public/pm/premium-vw-open.js +1 -1
  74. package/workspace/public/pm/premium-vw-slides.js +1 -1
  75. package/workspace/public/pm/prog-move.js +69 -0
  76. package/workspace/public/pm/prog-order.js +1 -1
  77. package/workspace/public/pm/task-card.css +3 -0
  78. package/workspace/public/pm/task-card.js +10 -3
  79. package/workspace/public/pm/tk-send.js +1 -1
  80. package/workspace/server.js +26 -2
  81. package/workspace/task-milestones-test.js +176 -0
  82. package/workspace/task-plans-test.js +175 -0
  83. package/workspace/task-views-test.js +2 -2
  84. package/workspace/test-lists/program-leave.json +6 -0
  85. package/workspace/test-lists/task-milestones.json +6 -0
  86. package/workspace/test-lists/task-plans.json +6 -0
  87. package/workspace/test-lists/viewer-live-file.json +9 -0
  88. package/workspace/timeline-holds-test.js +70 -5
@@ -0,0 +1,343 @@
1
+ /* pm/ini-versions.js — planned versus actual in the initiative's Tasks (feedback batch 11 item 8; canvas In development, row "Planned vs
2
+ * actual": PvaACGrill, PvaAC1Live, PvaAC2Menu, PvaAC3Draft, PvaAC5Phone). The fold and the routes are lib/task-plans.js and
3
+ * lib/routes-task-plans.js; the Board's row carries r.versions (null: no draft, no Not chosen, no saved plan).
4
+ *
5
+ * rowFor(r) → the row the one view draws: Live, or the draft the PM shows (its tasks as r.tasks, each `draft`), every task
6
+ * with `cmp` ({ start, due } of the compared version, where the dates differ, or a dropped task's line) and
7
+ * `added` (⊕: not in the compared version), and r.__vs: { v, show, cmp, slip, n } for the header
8
+ * headHtml(vs) the Tasks header's chip ("Live" grey, a draft's name blue, the blue count of drafts; hidden with nothing to show)
9
+ * and the end slip (+14d orange, −15d grey)
10
+ * liveHtml(vs) the seal icon "Make <draft> live", while a draft is shown
11
+ * countText(vs, count) "6 in Proposal A" while a draft is shown, else the count as it was
12
+ * wrap(h, body, shown) the host's handlers with a draft's writes routed here: a dt:<draft>:<key> task's dates and status, + in a draft,
13
+ * the first task of an initiative with no Live task and no plan (it goes to the draft "Proposal"); and the presses
14
+ * of the chip, its menu (a bottom sheet on a phone) and Make live with its summary, ✓, and Undo in the toast
15
+ * press(b, d, root, H) a press this file owns → true
16
+ *
17
+ * The host gives h.where() → { ws, board }, h.reload() (read the Board again, then draw), h.toast(text, undo?) and h.redraw(). A draft
18
+ * changes nothing in Live, on the Board or in Jira until Make live. Draft is not a status: the five task states stay as they are. */
19
+ import { pmPost } from './http.js';
20
+
21
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
22
+ const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
23
+ export const PV = {
24
+ down: 'M7 10l5 5 5-5', right: 'M10 7l5 5-5 5', check: 'M5 12l5 5 9-10', plus: 'M12 5v14M5 12h14', x: 'M6 6l12 12M18 6L6 18',
25
+ flag: 'M5 21V4M5 4h11l-2 4 2 4H5', pen: 'M4 20h4L19 9l-4-4L4 16zM13 7l4 4', copy: 'M9 9h10v10H9zM5 15V5h10', bin: 'M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13',
26
+ seal: 'M12 3l2.5 1.6 2.9-.2 1.1 2.7 2.5 1.6-.7 2.9.7 2.9-2.5 1.6-1.1 2.7-2.9-.2L12 21l-2.5-1.6-2.9.2-1.1-2.7-2.5-1.6.7-2.9-.7-2.9 2.5-1.6 1.1-2.7 2.9.2zM8.5 12l2.4 2.4 4.6-4.8',
27
+ line: 'M4 9v6M4 12h16M20 9v6', addc: 'M12 8v8M8 12h8M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18',
28
+ };
29
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
30
+ const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
31
+ const dn = (iso) => { const m = DAY.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
32
+ const md = (iso) => { const m = DAY.exec(String(iso || '')); return m ? MON[+m[2] - 1] + ' ' + +m[3] : ''; };
33
+ /** "+14d" late, "−15d" early, '' the same day (zero is silence). */
34
+ export const slipText = (n) => (!n ? '' : n > 0 ? '+' + n + 'd' : '−' + -n + 'd');
35
+
36
+ const SEL = new Map(); // initiative id → { show: 'live' | draft id, cmp: plan or draft id | 'none' } the PM's pick, for the session
37
+ const CACHE = new Map(); // initiative id → { v, t } the versions a write here answered, until a Board read is as new
38
+ const ROWS = new Map(); // initiative id → the row rowFor last drew (the presses read it)
39
+ /** For the tests: forget the picks and what the writes answered. */
40
+ export const resetVersions = () => { SEL.clear(); CACHE.clear(); ROWS.clear(); };
41
+ const counts = (k) => k && k.status !== "Won't do" && k.status !== 'Archived';
42
+ const spanEnd = (L) => { let b = null; for (const x of L) { const e = dn(x.due || x.end || x.start); if (e != null && (b == null || e > b)) b = e; } return b; };
43
+
44
+ function versionsOf(r) {
45
+ const c = CACHE.get(r.id), s = r.versions || null;
46
+ if (!c) return s;
47
+ if (s && String(s.t || '') > String(c.t || '')) { CACHE.delete(r.id); return s; }
48
+ return c.v;
49
+ }
50
+ /** The row as the one view draws it, with what the PM picked. */
51
+ export function rowFor(r) {
52
+ if (!r || !r.id) return r;
53
+ const v = versionsOf(r);
54
+ if (!v) { ROWS.set(r.id, { r, vs: null }); return r; }
55
+ const sel = SEL.get(r.id) || {}, live = (r.tasks || []).filter(counts);
56
+ let d = sel.show && sel.show !== 'live' ? v.drafts.find((x) => x.id === sel.show) : null;
57
+ // an initiative with no Live task opens on its newest draft (a proposal is all there is)
58
+ if (!d && !sel.show && !live.length && v.drafts.length) d = v.drafts[v.drafts.length - 1];
59
+ const show = d ? { kind: 'draft', id: d.id, name: d.name, auto: d.auto } : { kind: 'live', name: 'Live' };
60
+ const base = d ? d.tasks : r.tasks || [];
61
+ // what the thin line compares with: the PM's pick, else the newest saved plan
62
+ let cmp = null;
63
+ if (sel.cmp !== 'none') {
64
+ const p = sel.cmp ? v.plans.find((x) => x.id === sel.cmp) : null, o = sel.cmp && !p ? v.drafts.concat(v.notChosen).find((x) => x.id === sel.cmp && (!d || x.id !== d.id)) : null;
65
+ if (p) cmp = { kind: 'plan', id: p.id, name: p.name, at: p.at, tasks: p.tasks.map((t) => ({ key: t.uid, start: t.start, due: t.due })) };
66
+ else if (o) cmp = { kind: 'draft', id: o.id, name: o.name, at: o.at, tasks: o.tasks.map((t) => ({ key: t.src || t.uid, start: t.start, due: t.end })) };
67
+ else if (v.plans[0]) { const q = v.plans[0]; cmp = { kind: 'plan', id: q.id, name: q.name, at: q.at, tasks: q.tasks.map((t) => ({ key: t.uid, start: t.start, due: t.due })) }; }
68
+ }
69
+ const by = cmp ? new Map(cmp.tasks.map((t) => [t.key, t])) : null;
70
+ const tasks = base.map((k) => {
71
+ if (!by) return k;
72
+ const e = by.get(k.src || k.uid);
73
+ if (!e) return k.status === 'Archived' ? k : { ...k, added: true };
74
+ const differs = (e.start || '') !== (k.start || '') || (e.due || '') !== (k.end || '');
75
+ return differs || k.status === "Won't do" ? { ...k, cmp: { start: e.start || '', due: e.due || '' } } : k;
76
+ });
77
+ const a = spanEnd((d ? d.tasks : live).filter(counts)), b = cmp ? spanEnd(cmp.tasks) : null;
78
+ const vs = { id: r.id, v, show, cmp: cmp ? { kind: cmp.kind, id: cmp.id, name: cmp.name, at: cmp.at } : null, slip: a != null && b != null ? a - b : 0, n: v.drafts.length,
79
+ lines: tasks.some((k) => k.cmp), draft: !!d };
80
+ const out = { ...r, tasks, __vs: vs };
81
+ ROWS.set(r.id, { r, vs, d });
82
+ return out;
83
+ }
84
+
85
+ /* ── the header ── */
86
+ export function headHtml(vs) {
87
+ if (!vs) return '';
88
+ const dr = vs.show.kind === 'draft';
89
+ const lbl = dr ? 'Showing the draft ' + vs.show.name : 'Showing Live' + (vs.n ? ', ' + vs.n + (vs.n === 1 ? ' draft' : ' drafts') : '');
90
+ const chip = `<button type="button" class="vs-chip${dr ? ' dr' : ''}" data-vs-chip aria-haspopup="menu" aria-expanded="false" aria-label="${esc(lbl + '. Change')}" title="Versions and compare"><span class="t">${esc(vs.show.name)}</span>${!dr && vs.n ? `<span class="c" aria-hidden="true">${vs.n}</span>` : ''}${SVG(PV.down, 14, 2)}</button>`;
91
+ const s = slipText(vs.slip);
92
+ const slip = s ? `<span class="vs-slip${vs.slip > 0 ? ' late' : ''}" role="img" aria-label="${esc((vs.slip > 0 ? s.slice(1) + ' late' : s.slice(1) + ' early') + ' against ' + (vs.cmp ? vs.cmp.name : 'the plan'))}" title="${esc('End against ' + (vs.cmp ? vs.cmp.name : 'the plan'))}">${esc(s)}</span>` : '';
93
+ return chip + slip;
94
+ }
95
+ export function liveHtml(vs) {
96
+ if (!vs || vs.show.kind !== 'draft') return '';
97
+ const l = 'Make ' + vs.show.name + ' live';
98
+ return `<button type="button" class="vs-seal" data-vs-live aria-haspopup="dialog" aria-expanded="false" aria-label="${esc(l)}" title="${esc(l)}">${SVG(PV.seal, 18, 1.8)}</button>`;
99
+ }
100
+ export function countText(vs, count, n) { return vs && vs.show.kind === 'draft' ? n + (n === 1 ? ' task' : ' tasks') : count; }
101
+
102
+ /* ── the popover: right under its press; a bottom sheet on a phone ── */
103
+ let POP = null;
104
+ const phone = () => typeof matchMedia === 'function' && matchMedia('(max-width: 640px)').matches;
105
+ // a press on a phone sheet's scrim closes it (the document's listener: the scrim is not a control)
106
+ document.addEventListener('click', (e) => { if (POP && POP.scrim && e.target === POP.scrim) closePop(); });
107
+ function closePop() { if (!POP) return; const { el, scrim, anchor } = POP; POP = null; el.remove(); if (scrim) scrim.remove(); if (anchor && anchor.isConnected) anchor.setAttribute('aria-expanded', 'false'); }
108
+ function openPop(anchor, html, onPress, o = {}) {
109
+ closePop();
110
+ const sheet = o.sheet && phone();
111
+ const el = document.createElement('div');
112
+ el.className = 'tkc ivq vs-pop' + (sheet ? ' sheet' : ''); el.dataset.escLayer = ''; el.innerHTML = html;
113
+ let scrim = null;
114
+ if (sheet) { scrim = document.createElement('div'); scrim.className = 'vs-scrim'; document.body.appendChild(scrim); }
115
+ document.body.appendChild(el);
116
+ if (!sheet) {
117
+ const r = anchor.getBoundingClientRect(), w = el.offsetWidth, h = el.offsetHeight;
118
+ const left = Math.max(8, Math.min(o.right ? r.right - w : r.left, innerWidth - w - 8)), below = r.bottom + 6 + h <= innerHeight - 8;
119
+ el.style.setProperty('--tl-x', left + 'px'); el.style.setProperty('--tl-y', (below ? r.bottom + 6 : Math.max(8, r.top - 6 - h)) + 'px');
120
+ }
121
+ anchor.setAttribute('aria-expanded', 'true');
122
+ POP = { el, scrim, anchor, onPress };
123
+ const f = el.querySelector('[aria-checked="true"], button'); if (f) f.focus({ preventScroll: true });
124
+ return el;
125
+ }
126
+ if (typeof document !== 'undefined' && document.head) {
127
+ document.addEventListener('pointerdown', (e) => { if (POP && !POP.el.contains(e.target) && e.target !== POP.anchor && !(POP.anchor && POP.anchor.contains(e.target)) && e.target !== POP.scrim) closePop(); }, true);
128
+ document.addEventListener('click', (e) => { if (!POP) return; const b = e.target.closest && e.target.closest('button'); if (b && POP.el.contains(b)) POP.onPress(b, e); });
129
+ document.addEventListener('keydown', (e) => {
130
+ if (!POP) return;
131
+ if (e.key === 'Escape') { e.stopPropagation(); const a = POP.anchor; closePop(); if (a && a.isConnected) a.focus(); return; }
132
+ if (e.key === 'Enter' && e.target && e.target.matches && e.target.matches('.vs-pop input[data-vs-rn]')) { e.preventDefault(); const b = POP.el.querySelector('[data-vs-rnok]'); if (b) b.click(); }
133
+ }, true);
134
+ addEventListener('resize', () => { if (POP && !POP.scrim) closePop(); });
135
+ }
136
+
137
+ /* ── the menu: Show (Live, drafts, New draft), Compare with (saved plans, drafts, Nothing, Save Live as a plan), Not chosen ── */
138
+ let NC_OPEN = false, RENAME = null;
139
+ const ago = (iso) => (iso ? md(iso.slice(0, 10)) : '');
140
+ function menuHtml(vs, liveN) {
141
+ const v = vs.v, showId = vs.show.kind === 'draft' ? vs.show.id : 'live', cmpId = vs.cmp ? vs.cmp.id : 'none';
142
+ const row = (o) => `<div class="vs-r${o.on ? ' on' : ''}"><button type="button" class="o${o.on ? ' hl' : ''}" role="${o.role || 'menuitemradio'}"${o.role === 'menuitem' ? '' : ` aria-checked="${!!o.on}"`} ${o.attr}>`
143
+ + `<span class="ck" aria-hidden="true">${o.icon || (o.on ? SVG(PV.check, 15, 2.4) : '')}</span><span class="nn">${esc(o.label)}${o.sub ? `<small>${esc(o.sub)}</small>` : ''}</span>${o.dot ? '<i class="vs-dot" aria-hidden="true"></i>' : ''}${o.tail || ''}</button>${o.tools || ''}</div>`;
144
+ const tools = (d, more) => `<span class="vs-tl">${more ? '' : `<button type="button" class="vs-ti" data-vs-rename="${esc(d.id)}" aria-label="${esc('Rename ' + d.name)}" title="Rename">${SVG(PV.pen, 14)}</button>`}`
145
+ + `<button type="button" class="vs-ti" data-vs-copy="${esc(d.id)}" aria-label="${esc('New draft from ' + d.name)}" title="Copy">${SVG(PV.copy, 14)}</button>`
146
+ + `<button type="button" class="vs-ti" data-vs-del="${esc(d.id)}" aria-label="${esc('Delete ' + d.name)}" title="Delete">${SVG(PV.bin, 14)}</button></span>`;
147
+ const draftRow = (d, attr, on) => (RENAME === d.id
148
+ ? `<div class="vs-r rn"><input type="text" maxlength="60" data-vs-rn="${esc(d.id)}" value="${esc(d.name)}" aria-label="${esc('New name for ' + d.name)}"><button type="button" class="vs-ti" data-vs-rnok="${esc(d.id)}" aria-label="Save the name" title="Save">${SVG(PV.check, 15, 2.2)}</button></div>`
149
+ : row({ attr, on, label: d.name, sub: [d.auto ? 'Proposal' : d.from === 'live' ? 'Draft from Live' : 'Draft', d.tasks.length + (d.tasks.length === 1 ? ' task' : ' tasks'), d.liveChanged ? 'Live changed since' : ''].filter(Boolean).join(' · '), dot: d.liveChanged, tools: tools(d) }));
150
+ let h = '<span class="h">Show</span>';
151
+ h += row({ attr: 'data-vs-show="live"', on: showId === 'live', label: 'Live', sub: 'The real tasks' + (liveN ? ' · ' + liveN : '') });
152
+ for (const d of v.drafts) h += draftRow(d, `data-vs-show="${esc(d.id)}"`, showId === d.id);
153
+ h += row({ role: 'menuitem', attr: 'data-vs-new', icon: SVG(PV.plus, 15, 2), label: 'New draft from Live' });
154
+ h += '<hr><span class="h">Compare with</span>';
155
+ for (const p of v.plans) h += row({ attr: `data-vs-cmp="${esc(p.id)}"`, on: cmpId === p.id, label: 'Plan · ' + p.name, sub: ['Saved ' + ago(p.at) + (p.source === 'build' ? ' by PMOS' : p.source === 'draft' ? ' when it went live' : ''), p.span ? 'ends ' + md(p.span.end) : ''].filter(Boolean).join(' · '),
156
+ tail: cmpId === p.id ? `<span class="vs-k" aria-hidden="true">${SVG(PV.line, 16, 1.8)}</span>` : '' });
157
+ for (const d of v.drafts) if (d.id !== showId) h += row({ attr: `data-vs-cmp="${esc(d.id)}"`, on: cmpId === d.id, label: 'Draft · ' + d.name, sub: d.span ? 'ends ' + md(d.span.end) : '' });
158
+ h += row({ attr: 'data-vs-cmp="none"', on: cmpId === 'none', label: 'Nothing' });
159
+ h += row({ role: 'menuitem', attr: 'data-vs-save', icon: SVG(PV.flag, 15, 1.8), label: 'Save Live as a plan' });
160
+ if (v.notChosen.length) {
161
+ h += `<hr><button type="button" class="o vs-nc" data-vs-nc aria-expanded="${NC_OPEN}"><span class="ck" aria-hidden="true">${SVG(NC_OPEN ? PV.down : PV.right, 15, 2)}</span><span class="nn">Not chosen · ${v.notChosen.length}</span></button>`;
162
+ if (NC_OPEN) for (const d of v.notChosen) h += row({ role: 'menuitem', attr: `data-vs-open="${esc(d.id)}"`, label: d.name, sub: d.tasks.length + (d.tasks.length === 1 ? ' task' : ' tasks'), tools: tools(d, true) });
163
+ }
164
+ return `<div class="tkc-pop ivq-m vs-m" role="menu" aria-label="Versions and compare">${h}</div>`;
165
+ }
166
+
167
+ /* ── the writes ── */
168
+ async function write(H, route, body) {
169
+ const at = H.where ? H.where() : {};
170
+ return pmPost('/api/task-plans' + route, { ws: at.ws, board: at.board, ...body }).catch(() => null);
171
+ }
172
+ const say = (H, m, undo) => { if (H.toast) H.toast(m, undo); };
173
+ function took(id, res) { if (res && res.ok && 'versions' in res) CACHE.set(id, { v: res.versions, t: new Date().toISOString() }); }
174
+ const failed = (H, res, m) => { say(H, (res && res.error) || m || 'Nothing was changed.'); return false; };
175
+
176
+ /** The draft task a dt:<draft>:<key> uid names, as the row drew it. */
177
+ const draftTask = (id, uid) => { const R = ROWS.get(id); return R && R.d ? R.d.tasks.find((x) => x.uid === uid) : null; };
178
+ const iniOfUid = (uid) => { for (const [id, R] of ROWS) if (R.d && R.d.tasks.some((x) => x.uid === uid)) return id; return null; };
179
+ async function draftDates(H, uid, patch) {
180
+ const id = iniOfUid(uid), x = id && draftTask(id, uid);
181
+ const set = {}; if ('start' in patch) set.start = patch.start || ''; if ('due' in patch) set.due = patch.due || '';
182
+ const res = await write(H, '/task', { task: uid, set });
183
+ if (!res || res.ok === false) return failed(H, res);
184
+ took(id, res); if (H.redraw) H.redraw();
185
+ const R = ROWS.get(id), name = R && R.vs ? R.vs.show.name : 'the draft';
186
+ say(H, 'Dates saved in ' + name + (x ? ': ' + x.title : '') + '.', res.from ? async () => { const u = await write(H, '/task', { task: uid, set: res.from }); if (u && u.ok) { took(id, u); if (H.redraw) H.redraw(); } else failed(H, u, 'The undo did not land.'); } : undefined);
187
+ return true;
188
+ }
189
+ async function draftStatus(H, uid, state) {
190
+ const id = iniOfUid(uid), x = id && draftTask(id, uid);
191
+ const R = ROWS.get(id), name = R && R.vs ? R.vs.show.name : 'the draft';
192
+ if (state === "Won't do" || state === 'Archived') {
193
+ const res = await write(H, '/task', { task: uid, drop: true });
194
+ if (!res || res.ok === false) return failed(H, res);
195
+ took(id, res); if (H.redraw) H.redraw();
196
+ // a task copied from Live comes back with Undo; a task the draft added is gone, so Undo adds it again
197
+ const back = res.gone ? () => write(H, '/task', { draft: uid.split(':')[1], add: { title: x.title, start: x.start, due: x.end, owner: x.owner, ...(x.section ? { section: x.section } : {}) } }) : () => write(H, '/task', { task: uid, undrop: true });
198
+ say(H, 'Dropped from ' + name + (x ? ': ' + x.title : '') + '.', async () => { const u = await back(); if (u && u.ok) { took(id, u); if (H.redraw) H.redraw(); } else failed(H, u, 'The undo did not land.'); });
199
+ return true;
200
+ }
201
+ const res = await write(H, '/task', { task: uid, set: { status: state } });
202
+ if (!res || res.ok === false) return failed(H, res);
203
+ took(id, res); if (H.redraw) H.redraw();
204
+ say(H, state + ' in ' + name + (x ? ': ' + x.title : '') + '.', res.from ? async () => { const u = await write(H, '/task', { task: uid, set: res.from }); if (u && u.ok) { took(id, u); if (H.redraw) H.redraw(); } } : undefined);
205
+ return true;
206
+ }
207
+ /** + in the Tasks header: into the draft shown; the first task of an initiative with no Live task and no plan goes to "Proposal". → true when handled here. */
208
+ async function draftAdd(H, id, title, inp, section) {
209
+ const R = ROWS.get(id), vs = R && R.vs, live = R ? (R.r.tasks || []).filter(counts) : [];
210
+ let res = null;
211
+ if (vs && vs.show.kind === 'draft') res = await write(H, '/task', { draft: vs.show.id, add: { title, ...(section ? { section } : {}) } });
212
+ else if (!live.length && !(vs && vs.v.plans.length) && !(SEL.get(id) || {}).show) {
213
+ res = await write(H, '/propose', { initiative: id, title, ...(section ? { section } : {}) });
214
+ if (res && res.status === 409) return false;
215
+ if (res && res.ok === false && /Live tasks or a saved plan/.test(res.error || '')) return false;
216
+ if (res && res.ok) SEL.set(id, { ...(SEL.get(id) || {}), show: res.draft.id });
217
+ } else return false;
218
+ if (inp) inp.disabled = false;
219
+ if (!res || res.ok === false) { failed(H, res, 'The task was not added.'); return true; }
220
+ took(id, res);
221
+ say(H, 'Task added to ' + (res.draft ? res.draft.name : vs.show.name) + '. Nothing in Live changes until you make it live.');
222
+ if (H.redraw) H.redraw();
223
+ if (inp && inp.isConnected) { inp.value = ''; inp.focus(); } else { const n = document.querySelector('#ivAddTask'); if (n) { n.value = ''; n.focus(); } }
224
+ return true;
225
+ }
226
+
227
+ /* ── Make live: the summary right under the seal, then ✓; Undo in the toast ── */
228
+ async function makeLive(b, H, id) {
229
+ const R = ROWS.get(id); if (!R || !R.vs || R.vs.show.kind !== 'draft') return;
230
+ const at = H.where ? H.where() : {}, d = R.vs.show;
231
+ let pv = null;
232
+ try { pv = await (await fetch('/api/task-plans/preview?ws=' + encodeURIComponent(at.ws || '') + '&board=' + encodeURIComponent(at.board || '') + '&draft=' + encodeURIComponent(d.id), { credentials: 'same-origin' })).json(); } catch { pv = null; }
233
+ if (!pv || !pv.ok) { say(H, (pv && pv.error) || 'What Make live would change could not be read.'); return; }
234
+ const s = pv.summary, n = (k, one, many) => `<b>${k} ${k === 1 ? one : many}</b>`;
235
+ const lines = [];
236
+ if (s.added) lines.push(`<span>${n(s.added, 'task', 'tasks')} ${s.added === 1 ? 'becomes' : 'become'} To do</span>`);
237
+ if (s.moved) lines.push(`<span>${n(s.moved, 'date moved', 'dates moved')}</span>`);
238
+ if (s.changed > s.moved) lines.push(`<span>${n(s.changed - s.moved, 'task renamed or reassigned', 'tasks renamed or reassigned')}</span>`);
239
+ if (s.dropped) lines.push(`<span>${n(s.dropped, 'task', 'tasks')} ${s.dropped === 1 ? 'becomes' : 'become'} Won’t do</span>`);
240
+ for (const m of s.milestones || []) lines.push(`<span><b>Milestone</b>, ${esc(m.title)}${m.due ? ' · ' + esc(md(m.due)) : ''}</span>`);
241
+ if (s.conflicts && s.conflicts.length) lines.push(`<span class="w">Changed in Live too, the draft wins: ${esc(s.conflicts.join(', '))}</span>`);
242
+ if (!lines.length) lines.push('<span>Nothing in Live changes</span>');
243
+ lines.push(`<span>Saved as the plan <b>${esc(s.planName)}</b></span>`);
244
+ if (s.notChosen && s.notChosen.length) lines.push(`<span class="q">${esc(s.notChosen.join(', '))} ${s.notChosen.length === 1 ? 'moves' : 'move'} to Not chosen</span>`);
245
+ const html = `<div class="tkc-pop vs-cf" role="dialog" aria-label="${esc('Make ' + d.name + ' live')}"><b class="l1">Make ${esc(d.name)} live</b><div class="lst">${lines.join('')}</div>`
246
+ + `<span class="ft"><button type="button" class="vs-ti" data-vs-cf="no" aria-label="Cancel" title="Cancel">${SVG(PV.x, 16, 2)}</button><button type="button" class="vs-ok" data-vs-cf="yes" aria-label="Make it live" title="Make it live">${SVG(PV.check, 16, 2.4)}</button></span></div>`;
247
+ openPop(b, html, async (x) => {
248
+ const c = x.dataset.vsCf; if (!c) return;
249
+ closePop();
250
+ if (c !== 'yes') return;
251
+ const res = await write(H, '/live', { draft: d.id });
252
+ if (!res || res.ok === false) { failed(H, res, 'The draft was not made live.'); return; }
253
+ took(id, res); SEL.set(id, { show: 'live', cmp: res.plan });
254
+ say(H, d.name + ' is live. Its dates are saved as a plan.', async () => {
255
+ const u = await write(H, '/unlive', { draft: d.id });
256
+ if (!u || u.ok === false) { failed(H, u, 'The undo did not land.'); return; }
257
+ CACHE.delete(id); SEL.set(id, { show: d.id });
258
+ say(H, 'Back to the draft. Live is as it was' + (u.kept ? ', except ' + u.kept + (u.kept === 1 ? ' breakdown item that stays withdrawn' : ' breakdown items that stay withdrawn') : '') + '.');
259
+ if (H.reload) await H.reload(); else if (H.redraw) H.redraw();
260
+ });
261
+ if (H.reload) await H.reload(); else if (H.redraw) H.redraw();
262
+ }, { right: true });
263
+ }
264
+
265
+ /** The chip's menu, and each of its presses. */
266
+ function openMenu(b, H, id) {
267
+ const R = ROWS.get(id); if (!R || !R.vs) return;
268
+ const liveN = (R.r.tasks || []).filter(counts).length;
269
+ const draw = () => { const r2 = ROWS.get(id); if (POP && POP.anchor === b && r2 && r2.vs) POP.el.innerHTML = menuHtml(r2.vs, liveN); };
270
+ const after = () => { if (H.redraw) H.redraw(); };
271
+ openPop(b, menuHtml(R.vs, liveN), async (x) => {
272
+ const q = x.dataset, cur = SEL.get(id) || {};
273
+ if (q.vsShow) { SEL.set(id, { ...cur, show: q.vsShow }); closePop(); after(); return; }
274
+ if (q.vsCmp) { SEL.set(id, { ...cur, cmp: q.vsCmp }); closePop(); after(); return; }
275
+ if (q.vsOpen) { SEL.set(id, { ...cur, show: q.vsOpen }); closePop(); after(); return; }
276
+ if ('vsNc' in q) { NC_OPEN = !NC_OPEN; draw(); return; }
277
+ if (q.vsRename) { RENAME = q.vsRename; draw(); const i = POP && POP.el.querySelector('[data-vs-rn]'); if (i) { i.focus(); i.select(); } return; }
278
+ if (q.vsRnok) {
279
+ const i = POP && POP.el.querySelector('[data-vs-rn]'), name = i ? i.value.trim() : '';
280
+ RENAME = null;
281
+ if (!name) { draw(); return; }
282
+ const res = await write(H, '/name', { draft: q.vsRnok, name });
283
+ if (!res || res.ok === false) { failed(H, res); draw(); return; }
284
+ await refresh(H, id); draw(); after();
285
+ say(H, 'Renamed to ' + name + '.', async () => { await write(H, '/name', { draft: q.vsRnok, name: res.from }); await refresh(H, id); after(); });
286
+ return;
287
+ }
288
+ if ('vsNew' in q || q.vsCopy) {
289
+ closePop();
290
+ const res = await write(H, '/draft', { initiative: id, from: q.vsCopy || 'live' });
291
+ if (!res || res.ok === false) { failed(H, res, 'No draft was made.'); return; }
292
+ took(id, res); SEL.set(id, { ...cur, show: res.draft.id }); after();
293
+ say(H, res.draft.name + ' is a new draft. Nothing in Live changes until you make it live.');
294
+ return;
295
+ }
296
+ if (q.vsDel) {
297
+ closePop();
298
+ const res = await write(H, '/delete', { draft: q.vsDel });
299
+ if (!res || res.ok === false) { failed(H, res); return; }
300
+ if (cur.show === q.vsDel) SEL.set(id, { ...cur, show: 'live' });
301
+ await refresh(H, id); after();
302
+ say(H, res.name + ' is deleted.', async () => { const u = await write(H, '/restore', { draft: q.vsDel }); if (u && u.ok) { await refresh(H, id); after(); } else failed(H, u, 'The undo did not land.'); });
303
+ return;
304
+ }
305
+ if ('vsSave' in q) {
306
+ closePop();
307
+ const res = await write(H, '/plan', { initiative: id });
308
+ if (!res || res.ok === false) { failed(H, res, 'No plan was saved.'); return; }
309
+ took(id, res); SEL.set(id, { ...cur, cmp: res.plan.id }); after();
310
+ say(H, 'Live is saved as the plan ' + res.plan.name + '.', async () => { const u = await write(H, '/plan/remove', { plan: res.plan.id }); if (u && u.ok) { SEL.set(id, { ...(SEL.get(id) || {}), cmp: undefined }); await refresh(H, id); after(); } else failed(H, u, 'The undo did not land.'); });
311
+ }
312
+ }, { sheet: true });
313
+ }
314
+ /** Read one initiative's versions again (after a write that does not answer them). */
315
+ async function refresh(H, id) {
316
+ const at = H.where ? H.where() : {};
317
+ try { const r = await (await fetch('/api/task-plans?ws=' + encodeURIComponent(at.ws || '') + '&board=' + encodeURIComponent(at.board || '') + '&initiative=' + encodeURIComponent(id), { credentials: 'same-origin' })).json(); if (r && r.ok) took(id, r); } catch { /* the next Board read has it */ }
318
+ }
319
+
320
+ /** A press of this file's own controls in the Tasks header. → true when handled. */
321
+ export function press(b, d, root, H) {
322
+ const id = root && root.dataset.iv; if (!id) return false;
323
+ if ('vsChip' in d) { if (POP && POP.anchor === b) closePop(); else openMenu(b, H, id); return true; }
324
+ if ('vsLive' in d) { if (POP && POP.anchor === b) closePop(); else makeLive(b, H, id); return true; }
325
+ return false;
326
+ }
327
+ /** The host's handlers, with a draft's writes routed here. `shown(id)` → the view last drawn (the current stage a new draft task sits under). */
328
+ export function wrap(h, body, shown) {
329
+ const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : null; };
330
+ const isDraft = (uid) => /^dt:/.test(String(uid || ''));
331
+ const W = { ...h };
332
+ W.check = (uid, btn) => (isDraft(uid) ? undefined : h.check && h.check(uid, btn));
333
+ W.status = (uid, state) => (isDraft(uid) ? draftStatus(W, uid, state) : h.status && h.status(uid, state));
334
+ W.dates = (uid, patch) => (isDraft(uid) ? draftDates(W, uid, patch) : h.dates && h.dates(uid, patch));
335
+ W.openTask = (uid, b) => (isDraft(uid) ? undefined : h.openTask && h.openTask(uid, b));
336
+ W.addTask = async (title, inp) => {
337
+ const id = idOf(), v = id && shown ? shown(id) : null;
338
+ const now = v && v.tasks ? v.tasks.sections.find((s) => s.kind === 'stage' && s.status === 'now') : null;
339
+ if (id && await draftAdd(W, id, title, inp, now ? now.key : '')) return;
340
+ return h.addTask && h.addTask(title, inp);
341
+ };
342
+ return W;
343
+ }
@@ -4,7 +4,7 @@
4
4
  * initiative as GET /api/board-premium sends it (both pages read it), with its trail (GET /api/board-trail), so the two can no longer count
5
5
  * different things. Only the host's chrome differs.
6
6
  *
7
- * iniView(r, ctx) → { summary, stage, tasks } the whole view, as data
7
+ * iniView(r, ctx) → { summary, stage, tasks, vs } the whole view, as data (vs: what pm/ini-versions.js rowFor put on the row, or null)
8
8
  * ctx: { steps (Product feature's eight, the model's), today (YYYY-MM-DD, the model's day), usual ({ days } | null, the usual days in the
9
9
  * current stage), grill ({ open, later } | null), program ({ id, title } | null), jiraAt ('Jira · 2h ago' | ''), ask ({ title } | null: a
10
10
  * session that waits on the PM, Home's), docs (count | null), linked (count | null) }
@@ -19,8 +19,8 @@
19
19
  * 2 Tasks are the WBS: one section per stage, in workflow order; "Not in a stage" last. A section is a task's place, never its state.
20
20
  * 4 the stage card keeps where it is, its dates and the next stage; the tasks are said once, in Tasks.
21
21
  * 5 a stage is finished when its section is: every task Done or Won't do.
22
- * 6 only what is live shows: past stages fold into one line, later ones with nothing late into "Later"; the current section and any section
23
- * with a late task stay open.
22
+ * 6 every stage is its own row, never merged (batch 11 item 5); only what is live starts open: the current section and any section with a
23
+ * late task.
24
24
  * 9 what waits on you leads, with the one primary; the status then moves to the meta line.
25
25
  * 10 a new initiative with no breakdown draws its workflow's sections dashed, with Draft it.
26
26
  * 11 Build with Jira tickets: the open tickets are Build's section, by epic, with "N of M done in Jira" and how fresh.
@@ -111,10 +111,16 @@ function rowOf(k, today) {
111
111
  const who = ownerName(k.owner);
112
112
  // the List's meta draws the dates as their own press (batch 9 item 5b): days is the dates alone, lateText what follows them
113
113
  return { uid: k.uid, title: k.title, status: k.status || 'To do', closed, done: k.status === 'Done', wont: k.status === "Won't do", prog: k.status === 'In progress', late, due,
114
- days, lateText: late ? plural(between(d, today), 'day', 'days') + ' late' : '', item: !!k.item,
114
+ days, lateText: late ? plural(between(d, today), 'day', 'days') + ' late' : '', item: !!k.item, ms: !!k.milestone, // ms: the ◇ flag (batch 11 item 3)
115
115
  start: k.start || '', end: k.end || '', owner: who, av: initials(k.owner),
116
- sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid, order: k.order };
116
+ sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid && !k.draft, order: k.order,
117
+ // planned versus actual (batch 11 item 8, pm/ini-versions.js): the compared version's days where they differ, ⊕ added after it, a draft's task
118
+ cmp: k.cmp || null, added: !!k.added, dr: !!k.draft };
117
119
  }
120
+ /** The Jira key a task's title starts with ("MSD-4376 Navigation tabs" → 'MSD-4376'), or ''. A task named for a ticket IS that ticket:
121
+ * Build's section shows it once, as the task (it carries the dates and the owner), not again as a Jira row (batch 11 item 4). */
122
+ const KEY_RE = /^\s*([A-Z][A-Z0-9]+-\d+)\b/;
123
+ export const jiraKeyOf = (title) => { const m = KEY_RE.exec(String(title || '')); return m ? m[1] : ''; };
118
124
  const urgent = (a, b) => (b.late - a.late) || (a.end || '9999').localeCompare(b.end || '9999') || (a.order != null && b.order != null ? a.order - b.order : 0);
119
125
  /** A section's rows: open ones first by urgency; past 5 open, the 3 most urgent then the rest folded by the next WBS level; done fold last
120
126
  * (Won't do joins it), then the archived ones, which only the List draws, folded after Done (batch 9 item 5b). */
@@ -146,6 +152,9 @@ export function iniView(r, ctx = {}) {
146
152
  const archOf = (keys) => arch.filter((x) => keys.includes(x.sec));
147
153
  const open = rows.filter((x) => !x.closed), late = open.filter((x) => x.late);
148
154
  const jira = !ownWf(r) && (t.key === 'build' || t.key === 'deliver') && (t.tickets || []).length > 0;
155
+ // a ticket a task is named for shows once, as the task: it is not drawn or counted again as a Jira row
156
+ const named = new Set(T.map((k) => jiraKeyOf(k.title)).filter(Boolean));
157
+ const tkOwn = (t.tickets || []).filter((k) => !named.has(k.key));
149
158
 
150
159
  // the dates each stage ran: its board moves, oldest first; the first stage starts with the plan
151
160
  const moves = Array.isArray(tr.moves) ? tr.moves : [];
@@ -194,51 +203,28 @@ export function iniView(r, ctx = {}) {
194
203
  else { const p = planOf(rs); if (p) { sub = 'Plan ' + dateY(p, today); if (dayOf(p) < today && op.length) { sub += ', missed'; subWarn = true; } } }
195
204
  const h = headOf(rs); if (h) sub = [sub, h].filter(Boolean).join(' · ');
196
205
  return { kind: 'stage', key: s.key, n: i + 1, name: s.name, ms: s.ms, status: s.status, sub, subWarn, count: countOf(op.length, lt.length, dn), warn: lt.length > 0,
197
- open: s.status === 'now' || lt.length > 0, ...bodyOf(rs, archOf([s.key])), jira: null, why };
206
+ open: s.status === 'now' || lt.length > 0, ...bodyOf(rs, archOf([s.key])), jira: null, why, ...(s.status === 'skip' ? { skipWhy: s.why || '' } : {}) };
198
207
  };
199
208
  const anyTasks = rows.length > 0 || jira;
200
- // past: a done or skipped stage folds into one line unless it holds a late task
201
- const past = [], keep = new Set();
202
- list.forEach((s, i) => { if (cur >= 0 && i < cur) { const rs = secOf(s, i); if (rs.some((x) => !x.closed && x.late)) keep.add(i); else past.push(i); } });
203
- if (past.length) {
204
- const rs = past.flatMap((i) => secOf(list[i], i)), skips = past.filter((i) => list[i].status === 'skip');
205
- const a = past[0] + 1, b = past[past.length - 1] + 1;
206
- const from = past.map((i) => ran[i].from).filter(Boolean).sort()[0] || '', to = past.map((i) => ran[i].to).filter(Boolean).sort().pop() || (cur >= 0 ? ran[cur].from : '') || '';
207
- const sk = skips.map((i) => list[i].name + ' skipped' + (list[i].why ? ': ' + list[i].why.replace(/\.$/, '').replace(/^./, (c) => c.toLowerCase()) : '')).join(' · ');
208
- sections.push({ kind: 'past', key: 'past', label: a === b ? list[a - 1].name : 'Stages ' + a + '–' + b, sub: [span(from, to, today), sk].filter(Boolean).join(' · '),
209
- count: rs.length ? rs.filter((x) => x.closed).length + ' done' : '', open: false, ...bodyOf(rs, archOf(past.map((i) => list[i].key))), stages: past.map((i) => one(list[i], i)) });
210
- }
211
- // now and any past stage with a late task, in workflow order; later stages with a late task stay open, the rest fold into Later
212
- const later = [];
209
+ // one row per stage, in workflow order (batch 11 item 5, Wawan: "one row/group per stage. Do not combine"): past and later stages are no
210
+ // longer merged into "Stages 1–4" or "Later: …". A stage that is not live starts folded; the current one and any with a late task start open.
213
211
  list.forEach((s, i) => {
214
- if (cur >= 0 && i < cur) { if (keep.has(i)) sections.push(one(s, i)); return; }
215
- if (i === cur) {
216
- const x = one(s, i);
217
- if (jira) {
218
- const opn = tk.filter((k) => k.status !== 'Done').sort((a, b) => (b.blocked ? 1 : 0) - (a.blocked ? 1 : 0));
219
- x.jira = { open: opn.map((k) => ({ key: k.key, title: k.title, epic: k.epic || '', status: k.status || 'To do', due: k.due || k.sprintEnd || '', av: initials(k.assignee), sub: [k.blocked ? 'Blocked' + (k.reason ? ' by ' + String(k.reason).replace(/^Waiting on /i, '') : '') : k.status || 'To do', k.assignee || ''].filter(Boolean).join(' · '), warn: !!k.blocked })),
220
- done: tk.length - opn.length, total: tk.length, at: ctx.jiraAt || '' };
221
- x.count = countOf(opn.length + x.top.length + x.groups.reduce((n, g) => n + g.n, 0), x.top.filter((y) => y.late).length, 0);
222
- x.sub = x.sub + (x.sub ? ' · ' : '') + 'Jira tickets, by epic';
223
- }
224
- sections.push(x); return;
212
+ const x = one(s, i);
213
+ if (i === cur && jira && tkOwn.length) {
214
+ const opn = tkOwn.filter((k) => k.status !== 'Done').sort((a, b) => (b.blocked ? 1 : 0) - (a.blocked ? 1 : 0));
215
+ x.jira = { open: opn.map((k) => ({ key: k.key, title: k.title, epic: k.epic || '', status: k.status || 'To do', due: k.due || k.sprintEnd || '', av: initials(k.assignee), sub: [k.blocked ? 'Blocked' + (k.reason ? ' by ' + String(k.reason).replace(/^Waiting on /i, '') : '') : k.status || 'To do', k.assignee || ''].filter(Boolean).join(' · '), warn: !!k.blocked })),
216
+ done: tkOwn.length - opn.length, total: tkOwn.length, at: ctx.jiraAt || '' };
217
+ x.count = countOf(opn.length + x.top.length + x.groups.reduce((n, g) => n + g.n, 0), x.top.filter((y) => y.late).length, 0);
218
+ x.sub = x.sub + (x.sub ? ' · ' : '') + 'Jira tickets, by epic';
225
219
  }
226
- const rs = secOf(s, i);
227
- if (rs.some((x) => !x.closed && x.late)) sections.push(one(s, i));
228
- else later.push(i);
220
+ sections.push(x);
229
221
  });
230
- if (later.length) {
231
- const rs = later.flatMap((i) => secOf(list[i], i)), op = rs.filter((x) => !x.closed);
232
- const ds = rs.map((x) => x.end).filter(Boolean).sort();
233
- sections.push({ kind: 'later', key: 'later', label: 'Later: ' + later.map((i) => list[i].name).join(', '), sub: ds.length ? 'Plan ' + span(ds[0], ds[ds.length - 1], today) : '',
234
- count: op.length ? op.length + ' to do' : '', open: false, ...bodyOf(rs, archOf(later.map((i) => list[i].key))), stages: later.map((i) => one(list[i], i)) });
235
- }
236
222
  const loose = rows.filter((x) => !x.sec);
237
223
  if (loose.length) {
238
224
  const op = loose.filter((x) => !x.closed), lt = op.filter((x) => x.late);
239
225
  sections.push({ kind: 'none', key: '', label: 'Not in a stage', sub: '', count: countOf(op.length, lt.length, loose.length - op.length), warn: lt.length > 0, open: op.length > 0, ...bodyOf(loose, archOf([''])) });
240
226
  }
241
- const nOpen = open.length + (jira ? tk.filter((k) => k.status !== 'Done').length : 0), nDone = rows.length - open.length + (jira ? tk.filter((k) => k.status === 'Done').length : 0);
227
+ const nOpen = open.length + (jira ? tkOwn.filter((k) => k.status !== 'Done').length : 0), nDone = rows.length - open.length + (jira ? tkOwn.filter((k) => k.status === 'Done').length : 0);
242
228
  const tasks = { open: nOpen, done: nDone, late: late.length, count: [nOpen ? nOpen + ' open' : '', nDone ? nDone + ' done' : ''].filter(Boolean).join(' · '), sections,
243
229
  empty: !anyTasks ? { stages: list.map((s, i) => ({ n: i + 1, name: s.name, ms: s.ms, now: i === cur })) } : null };
244
230
 
@@ -264,7 +250,7 @@ export function iniView(r, ctx = {}) {
264
250
  summary.wf = r.wf || { id: PF_ID, name: 'Product feature', icon: 'feature' };
265
251
  summary.program = ctx.program || null;
266
252
  const today2 = (n) => String(n).padStart(2, '0');
267
- return { id: r.id || null, key: r.key, title: r.title, today: today.getFullYear() + '-' + today2(today.getMonth() + 1) + '-' + today2(today.getDate()), summary, stage, tasks, docs: ctx.docs != null ? ctx.docs : null, linked: linkedOf(r) };
253
+ return { vs: r.__vs || null, id: r.id || null, key: r.key, title: r.title, today: today.getFullYear() + '-' + today2(today.getMonth() + 1) + '-' + today2(today.getDate()), summary, stage, tasks, docs: ctx.docs != null ? ctx.docs : null, linked: linkedOf(r) };
268
254
  }
269
255
  /** What it links to, from its trail: the PRD (with its version), the rubric, the evaluation, the release notes, what it waits on, its epic. */
270
256
  export function linkedOf(r) {
@@ -280,3 +280,85 @@ button.iv-chip:hover { background: var(--cz-well) !important; }
280
280
  .tkc.ivq .ivq-m { min-width: 220px; }
281
281
  .tkc.ivq .ivq-m .ck { width: 16px; display: inline-flex; color: var(--cz-blueink); }
282
282
  .tkc.ivq .ivq-m .k { color: var(--cz-ink3); font-size: 12.5px; font-weight: 700; padding-left: 14px; }
283
+
284
+ /* Milestone tasks (feedback batch 11 item 3; canvas XmlA2Flag, XmlA3Viewer, XmlA6Suggest): a small grey ◇ after the title on every task row;
285
+ * in the Timeline the bar ends in its ◇ with the date beside it and a faint dashed guide drops through the grid; a milestone with no due date
286
+ * asks for one in a dashed chip. */
287
+ .iv-ms { display: inline-flex; align-items: center; flex: none; color: var(--cz-ink3); margin-left: 6px; vertical-align: 1px; }
288
+ .iv-ms.dn { opacity: .7; }
289
+ .iv-ms svg { display: block; }
290
+ .ivt-n .iv-ms { margin-left: 0; }
291
+ .iv-dc.ms { opacity: 1 !important; margin: 0 !important; border: 1.5px dashed color-mix(in srgb, var(--cz-ink3) 50%, var(--cz-card)) !important; padding: 0 8px !important; gap: 5px; font-size: 12px; }
292
+ span.iv-dc.ms { display: inline-flex; border-radius: 999px; }
293
+ .ivt-ms { position: absolute; top: 50%; height: 0; z-index: 2; display: flex; align-items: center; pointer-events: auto; }
294
+ .ivt-ms i { width: 11px; height: 11px; margin-left: -5.5px; transform: rotate(45deg); border-radius: 2px; background: var(--cz-card); border: 2px solid var(--cz-ink3); box-sizing: border-box; flex: none; }
295
+ .ivt-ms b { margin-left: 7px; font-size: 11.5px; font-weight: 700; color: var(--cz-ink2); white-space: nowrap; }
296
+ .ivt-ms.dn i { background: var(--cz-ink3); box-shadow: 0 0 0 2px var(--cz-card); }
297
+ .ivt-ms.lt i { border-color: var(--cz-dot-late, var(--cz-late)); }
298
+ .ivt-ms.lt b { color: var(--cz-late); font-weight: 800; }
299
+ .ivt-grid i.ms { width: 0; background: none; border-left: 1px dashed color-mix(in srgb, var(--cz-ink3) 45%, transparent); }
300
+ .ivt-lg svg { color: var(--cz-ink3); }
301
+ .tkc .seg .ivq-ms { color: var(--cz-ink3); }
302
+ .tkc .seg .ivq-ms.on { width: auto; padding: 0 12px 0 9px; gap: 6px; background: var(--cz-bluebg); color: var(--cz-blueink); font-weight: 800; font-size: 13px; box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
303
+ /* planned versus actual (batch 11 item 8; canvas In development, row "Planned vs actual"): pm/ini-versions.js and pm/ini-tasks.js */
304
+ .vs-chip { display: inline-flex !important; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 12px !important; border-radius: 999px !important; background: var(--cz-well) !important; font-size: 12.5px; font-weight: 800; color: var(--cz-ink2) !important; white-space: nowrap; max-width: 200px; flex: none; }
305
+ .vs-chip .t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
306
+ .vs-chip.dr { background: var(--cz-bluebg) !important; color: var(--cz-blueink) !important; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--cz-blue) 45%, var(--cz-card)); }
307
+ .vs-chip .c { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--cz-blue); color: var(--cz-card); font-size: 10.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
308
+ .vs-slip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--cz-well); color: var(--cz-ink3); font-size: 12px; font-weight: 800; flex: none; }
309
+ .vs-slip.late { background: var(--cz-latebg); color: var(--cz-late); }
310
+ .vs-seal { width: 36px; height: 36px; border-radius: 999px !important; display: inline-flex !important; align-items: center; justify-content: center; background: var(--cz-ink) !important; color: var(--cz-card) !important; flex: none; }
311
+ .vs-seal:hover { opacity: .9; }
312
+ .iv-cb.dr { border-style: dashed !important; border-radius: 50% !important; background: transparent !important; }
313
+ .vs-add { display: inline-flex; align-items: center; color: var(--cz-ink3); margin-left: 6px; flex: none; vertical-align: -2px; }
314
+ .vs-sl { font-weight: 800; color: var(--cz-ink3); }
315
+ .vs-sl.late { color: var(--cz-late); }
316
+ /* a draft's task: dashed, never solid (dashed blue stays the Jira forecast and Claude's ◇ suggestion) */
317
+ .ivt-b.dr { background: var(--cz-card) !important; border: 1.5px dashed color-mix(in srgb, var(--cz-ink3) 75%, var(--cz-card)) !important; box-sizing: border-box; }
318
+ .ivk-d.dr { border: 1.5px dashed color-mix(in srgb, var(--cz-ink3) 60%, var(--cz-card)) !important; background: transparent !important; }
319
+ /* the compared version: a thin dark line with end caps under the bar; the slip after the date */
320
+ .ivt-pl { position: absolute; left: var(--tl-x, 0); width: var(--tl-w, 0); bottom: 5px; height: 1.6px; background: var(--cz-ink2); z-index: 1; pointer-events: auto; }
321
+ .ivt-pl::before, .ivt-pl::after { content: ""; position: absolute; top: -3px; width: 1.6px; height: 7.6px; background: var(--cz-ink2); }
322
+ .ivt-pl::before { left: 0; } .ivt-pl::after { right: 0; }
323
+ .ivt-sl { position: absolute; left: var(--tl-x, 0); top: 50%; transform: translateY(-50%); font-size: 11.5px; font-weight: 700; color: var(--cz-ink2); white-space: nowrap; z-index: 1; pointer-events: none; }
324
+ .ivt-lg i.pl { height: 1.6px; border-radius: 0; background: var(--cz-ink2); position: relative; }
325
+ .ivt-lg i.pl::before, .ivt-lg i.pl::after { content: ""; position: absolute; top: -3px; width: 1.6px; height: 7.6px; background: var(--cz-ink2); }
326
+ .ivt-lg i.pl::before { left: 0; } .ivt-lg i.pl::after { right: 0; }
327
+ .ivt-lg i.dr { background: transparent; outline: 1.5px dashed var(--cz-ink3); outline-offset: -1.5px; }
328
+ /* the chip's menu (right under it; a bottom sheet on a phone) and Make live's summary */
329
+ .tkc.ivq.vs-pop .vs-m { width: 360px; max-width: calc(100vw - 16px); max-height: min(70vh, 560px); }
330
+ .vs-m .vs-r { position: relative; display: flex; align-items: center; }
331
+ .vs-m .vs-r .o { flex: 1; min-width: 0; min-height: 44px; }
332
+ .vs-m .nn { display: flex; flex-direction: column; min-width: 0; text-align: left; line-height: 1.25; padding: 4px 0; }
333
+ .vs-m .nn small { font-size: 11.5px; font-weight: 600; color: var(--cz-ink3); }
334
+ .vs-m .vs-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cz-blue); margin-left: auto; flex: none; }
335
+ .vs-m .vs-k { margin-left: auto; display: inline-flex; color: var(--cz-ink2); }
336
+ .vs-m .vs-tl { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: none; gap: 2px; background: var(--cz-well); border-radius: 10px; padding: 2px; }
337
+ .vs-m .vs-r:hover .vs-tl, .vs-m .vs-r:focus-within .vs-tl { display: inline-flex; }
338
+ .vs-ti { width: 30px; height: 30px; border-radius: 999px !important; display: inline-flex !important; align-items: center; justify-content: center; color: var(--cz-ink2) !important; flex: none; }
339
+ .vs-ti:hover { background: var(--cz-card) !important; color: var(--cz-ink) !important; }
340
+ .vs-m .vs-r.rn { gap: 6px; padding: 4px 6px; }
341
+ .vs-m .vs-r.rn input { flex: 1; min-width: 0; height: 36px; border-radius: 10px; border: 1px solid var(--cz-hair); padding: 0 10px; font: inherit; font-size: 13.5px; background: var(--cz-card); color: var(--cz-ink); }
342
+ .vs-cf { padding: 14px 14px 10px !important; width: 340px; max-width: calc(100vw - 16px); gap: 10px; }
343
+ .vs-cf .l1 { font-size: 14px; font-weight: 800; }
344
+ .vs-cf .lst { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--cz-ink2); }
345
+ .vs-cf .lst b { color: var(--cz-ink); font-weight: 800; }
346
+ .vs-cf .lst .q { color: var(--cz-ink3); }
347
+ .vs-cf .lst .w { color: var(--cz-late); }
348
+ .vs-cf .ft { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
349
+ .vs-ok { width: 40px; height: 40px; border-radius: 999px !important; display: inline-flex !important; align-items: center; justify-content: center; background: var(--cz-ink) !important; color: var(--cz-card) !important; }
350
+ .tkc.ivq.vs-pop.sheet { left: 0; right: 0; top: auto; bottom: 0; }
351
+ .tkc.ivq.vs-pop.sheet .tkc-pop { width: 100%; max-width: none; border-radius: 20px 20px 0 0; max-height: 75vh; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
352
+ .tkc.ivq.vs-pop.sheet .vs-tl { display: inline-flex; position: static; transform: none; background: transparent; }
353
+ .vs-scrim { position: fixed; inset: 0; z-index: 999; background: color-mix(in srgb, var(--cz-ink) 28%, transparent); }
354
+ /* A draft's name and the seal can outgrow a narrow Viewer: the head wraps to a second line, never scrolls sideways. */
355
+ .iv-th:has(.vs-chip) { flex-wrap: wrap; row-gap: 8px; }
356
+ .iv-th:has(.vs-chip) .n { white-space: nowrap; }
357
+ /* A skipped stage on the Timeline (feedback batch 11 item 13; canvas XgapA2Tasks): its group row keeps its place, » in its badge and its name muted;
358
+ a 2 px hairline in the To do grey runs from the band before it to the band after it, with » on it. No gap of 2 weeks: » alone at the joint. */
359
+ .ivt-ng { position: absolute; top: 50%; height: 24px; margin-top: -12px; z-index: 1; }
360
+ .ivt-ng::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--cz-well2); }
361
+ .ivt-sk { position: absolute; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; background: var(--cz-card); box-shadow: 0 0 0 1px var(--cz-hair); color: var(--cz-ink3); display: inline-flex; align-items: center; justify-content: center; z-index: 2; }
362
+ .ivt-ng > .ivt-sk { left: 50%; }
363
+ .ivt-lg i.ng { height: 2px; border-radius: 0; background: var(--cz-well2); }
364
+ .iv-no.skip svg { width: 12px; height: 12px; }