create-pmos 0.402.0 → 0.404.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 (110) hide show
  1. package/package.json +25 -30
  2. package/payload/AGENTS.md +2 -0
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/mods/pmos-cockpit/hooks/lib/session-facts.mjs +1 -1
  5. package/payload/planning/evals/eval-calibration.md +1 -1
  6. package/payload/planning/okrs/health-budgets.md +1 -1
  7. package/payload/state/discoveries.md +1 -1
  8. package/workspace/board-programs-test.js +32 -5
  9. package/workspace/briefing-premium-adddoc-test.js +28 -22
  10. package/workspace/briefing-premium-board-test.js +91 -73
  11. package/workspace/briefing-premium-calendar-2-test.js +23 -10
  12. package/workspace/briefing-premium-calendar-3-test.js +23 -19
  13. package/workspace/briefing-premium-calendar-test.js +19 -17
  14. package/workspace/briefing-premium-initiative-test.js +25 -12
  15. package/workspace/briefing-premium-insights-test.js +31 -18
  16. package/workspace/briefing-premium-metrics-test.js +8 -8
  17. package/workspace/briefing-premium-test.js +4 -3
  18. package/workspace/changelog.json +24 -0
  19. package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
  20. package/workspace/guide/jira.md +38 -6
  21. package/workspace/guide/programs.md +2 -0
  22. package/workspace/home-rows-test.js +184 -0
  23. package/workspace/lib/briefing-premium-agent.js +3 -0
  24. package/workspace/lib/calendar-layers.js +8 -4
  25. package/workspace/lib/initiative-layout.js +4 -3
  26. package/workspace/lib/jira-cli.js +17 -12
  27. package/workspace/lib/jira-status.js +1 -1
  28. package/workspace/lib/jira-tickets.js +126 -24
  29. package/workspace/lib/meeting-files.js +58 -0
  30. package/workspace/lib/meeting-learn.js +139 -0
  31. package/workspace/lib/meeting-material.js +12 -5
  32. package/workspace/lib/notes.js +3 -0
  33. package/workspace/lib/program-chat.js +32 -0
  34. package/workspace/lib/routes-brief-page.js +8 -1
  35. package/workspace/lib/routes-calendar-views.js +24 -3
  36. package/workspace/lib/routes-meeting-material.js +38 -0
  37. package/workspace/lib/routes-meeting-points.js +23 -3
  38. package/workspace/package-lock.json +2 -2
  39. package/workspace/package.json +1 -1
  40. package/workspace/premium-board-actions-test.js +30 -24
  41. package/workspace/premium-chat-context-test.js +1 -1
  42. package/workspace/premium-chat-goal-view-test.js +1 -1
  43. package/workspace/premium-chat-viewer-test.js +1 -1
  44. package/workspace/premium-core-doc-issue-test.js +13 -7
  45. package/workspace/premium-discuss-landing-test.js +83 -0
  46. package/workspace/premium-link-suggest-test.js +103 -0
  47. package/workspace/premium-report-read-test.js +86 -82
  48. package/workspace/premium-vw-backlog-test.js +6 -5
  49. package/workspace/premium-vw-cal-test.js +46 -23
  50. package/workspace/premium-vw-item-test.js +8 -6
  51. package/workspace/premium-vw-jira-test.js +3 -2
  52. package/workspace/premium-vw-meet-test.js +122 -66
  53. package/workspace/premium-vw-notes-test.js +7 -6
  54. package/workspace/premium-vw-rec-test.js +14 -13
  55. package/workspace/premium-vw-slides-test.js +11 -5
  56. package/workspace/program-panel-test.js +64 -55
  57. package/workspace/public/pm/bd-acts.js +1 -1
  58. package/workspace/public/pm/bd-asks.js +22 -7
  59. package/workspace/public/pm/bd-ini-panel.js +232 -0
  60. package/workspace/public/pm/bd-pop.js +2 -2
  61. package/workspace/public/pm/bd-prog-panel.js +176 -191
  62. package/workspace/public/pm/cozy-board.css +5 -28
  63. package/workspace/public/pm/cozy-evui.js +4 -2
  64. package/workspace/public/pm/cozy-home-rows.css +54 -0
  65. package/workspace/public/pm/cozy-home.css +9 -0
  66. package/workspace/public/pm/cozy-insights.css +1 -2
  67. package/workspace/public/pm/cozy-mtg-present.css +160 -0
  68. package/workspace/public/pm/cozy-panel.css +11 -34
  69. package/workspace/public/pm/cozy-rec-pill.css +12 -0
  70. package/workspace/public/pm/cozy-rec-pill.js +46 -0
  71. package/workspace/public/pm/cozy-viewer.js +307 -43
  72. package/workspace/public/pm/cozy-vw-mtg.css +96 -94
  73. package/workspace/public/pm/cozy-vw-rp.css +40 -25
  74. package/workspace/public/pm/cozy-vw-shell.css +127 -0
  75. package/workspace/public/pm/cozy-xv.css +51 -0
  76. package/workspace/public/pm/cozy-xv.js +34 -0
  77. package/workspace/public/pm/goal-chat.js +1 -1
  78. package/workspace/public/pm/home-app.js +122 -58
  79. package/workspace/public/pm/home-chat.js +11 -2
  80. package/workspace/public/pm/home-day.js +64 -0
  81. package/workspace/public/pm/home-ini-model.js +1 -1
  82. package/workspace/public/pm/home-ini.js +197 -54
  83. package/workspace/public/pm/home-list.js +6 -14
  84. package/workspace/public/pm/home-mentions.js +187 -0
  85. package/workspace/public/pm/home-rec-row.js +67 -0
  86. package/workspace/public/pm/home-review.js +20 -10
  87. package/workspace/public/pm/home-task.js +19 -18
  88. package/workspace/public/pm/home-today.js +3 -3
  89. package/workspace/public/pm/premium-board.js +83 -235
  90. package/workspace/public/pm/premium-insights.js +118 -82
  91. package/workspace/public/pm/premium-mtg-present.js +408 -100
  92. package/workspace/public/pm/premium-mtg-replay.js +70 -10
  93. package/workspace/public/pm/premium-report-read.js +118 -63
  94. package/workspace/public/pm/premium-vw-cal.js +62 -34
  95. package/workspace/public/pm/premium-vw-mtg.js +348 -192
  96. package/workspace/public/pm/rec-state.js +63 -0
  97. package/workspace/public/pm/rp-parts.js +33 -8
  98. package/workspace/public/pm/tk-draft.js +107 -0
  99. package/workspace/public/pm/tk-model.js +134 -0
  100. package/workspace/public/pm/tk-send.js +124 -0
  101. package/workspace/public/pm/tk-tasks.css +120 -0
  102. package/workspace/public/premium-board.html +0 -1
  103. package/workspace/server.js +4 -2
  104. package/workspace/skills/jira-push.skill +3 -3
  105. package/workspace/test-lists/prd-to-jira.json +6 -0
  106. package/workspace/test-lists/program-chat.json +6 -0
  107. package/workspace/test-lists/viewer-home-rows.json +9 -0
  108. package/workspace/test-lists/viewer-meetings.json +9 -0
  109. package/workspace/test-lists/viewer-shell-a.json +15 -0
  110. package/workspace/tk-tasks-test.js +199 -0
@@ -11,8 +11,15 @@
11
11
  * milestone (Deliver, Evaluate), and says so in a toast with Undo; Undo moves it back and keeps it from moving out of that stage by itself again.
12
12
  * Tasks (InTasks): grouped by stage, by groups the PM names (drag a task between them; group sets are saved for the workspace), by owner, by status
13
13
  * or not at all. Core documents (InDocs): the list column shows only the documents that need a look; the Viewer lists them all with their details.
14
- * Every write is the PM's press, file mode only: /api/boards/move, /api/boards/tasks/*, /api/lifecycle, /api/core-docs/draft, /api/initiative-layout. */
14
+ * Every write is the PM's press, file mode only: /api/boards/move, /api/boards/tasks/*, /api/lifecycle, /api/core-docs/draft, /api/initiative-layout.
15
+ *
16
+ * PRD to Jira (kit 2, T1 to T3; canvas PgTkList, PgTkSent, XvATasks): Tasks group by Epic too, the default once the PRD's stories have
17
+ * drafted tickets (GET /api/jira/tickets). Each epic group lists its tasks, the drafted Jira tickets; its send icon opens the Send sheet
18
+ * (tk-send.js), and a task opens its drafted ticket (tk-draft.js) or, once in Jira, the ticket's Jira view. The PM's own tasks follow
19
+ * under "Your tasks". In shell A the summary card comes first and the group picker, Documents, Stage, the record and the sprint sit
20
+ * under ⋯; the phone keeps the Tasks | Documents | Stage switch. The pure half of the tickets is tk-model.js. */
15
21
  import * as MD from './home-ini-model.js';
22
+ import * as TKM from './tk-model.js';
16
23
 
17
24
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
18
25
  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>`;
@@ -22,7 +29,8 @@ const I = {
22
29
  };
23
30
  const PHONE = 760;
24
31
  const isPhone = () => innerWidth <= PHONE;
25
- const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'tasks', doc: { by: 'stage', filter: 'all', more: new Set() }, shut: new Set(), pop: null, toastT: 0, addTo: '' };
32
+ const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'tasks', doc: { by: 'stage', filter: 'all', more: new Set() }, shut: new Set(), pop: null, toastT: 0, addTo: '',
33
+ T: new Map(), tReading: new Set(), fold: new Map(), more: new Set() };
26
34
 
27
35
  /* ── reading the layout record ── */
28
36
  const curM = () => { const S = X.ctx && X.ctx.S; return S && S.ini && S.ini !== 'product' && S.IMid === S.ini ? S.IM : null; };
@@ -37,6 +45,18 @@ async function readL(id, M, force) {
37
45
  X.ctx.drawList(); redrawView();
38
46
  }
39
47
  const Lof = (id) => X.L.get(id) || { auto: true, held: [], by: 'stage', names: [], of: {}, stage: {}, sets: [], read: false };
48
+ /* ── the drafted Jira tickets (T1) ── */
49
+ async function readT(id, M, force) {
50
+ if (!force && (X.T.has(id) || X.tReading.has(id))) return;
51
+ X.tReading.add(id);
52
+ const r = await X.ctx.pmGet('/api/jira/tickets?initiative=' + encodeURIComponent(id) + (wsOf(M) ? '&ws=' + encodeURIComponent(wsOf(M)) : ''));
53
+ X.tReading.delete(id);
54
+ X.T.set(id, r && r.ok === true ? r : { ok: false, error: (r && r.error) || 'The tickets could not be read.' });
55
+ redrawView();
56
+ }
57
+ const Tof = (id) => X.T.get(id) || null;
58
+ /** The grouping: the PM's choice; until the PM chooses, Epic once tickets are drafted. */
59
+ const byOf = (L, T) => (L.picked ? L.by : T && T.ok && T.drafted ? 'epic' : L.by) || 'stage';
40
60
  async function press(id, M, body) {
41
61
  const r = await X.ctx.pmPost('/api/initiative-layout', { ws: wsOf(M), initiative: id, ...body });
42
62
  if (r && r.ok) { X.L.set(id, { ...r, read: true }); X.ctx.drawList(); redrawView(); return true; }
@@ -155,8 +175,8 @@ function menu(anchor, items, label) {
155
175
  : `<button type="button" class="hi-mi${x.on ? ' on' : ''}" role="${x.radio ? 'menuitemradio' : 'menuitem'}"${x.radio ? ` aria-checked="${!!x.on}"` : ''} data-hi-mi="${i}"${x.disabled ? ' disabled' : ''}>${x.icon ? SVG(x.icon, 16) : ''}<span>${esc(x.label)}</span>${x.sub ? `<em>${esc(x.sub)}</em>` : ''}</button>`)).join(''),
156
176
  (b) => { const it = items[+b.dataset.hiMi]; closePop(); if (it && it.go) it.go(anchor); }, { menu: true, label });
157
177
  }
158
- function ask(anchor, label, value, go) { // one line of words, inline (no browser prompt)
159
- openPop(anchor, 'ask', `<label class="hi-field"><span>${esc(label)}</span><input id="hiAsk" maxlength="40" autocomplete="off" value="${esc(value || '')}"></label><div class="hi-acts"><button type="button" class="hi-btn dark" data-hi-go>Save</button><button type="button" class="hi-btn ghost" data-hi-x>Cancel</button></div>`,
178
+ function ask(anchor, label, value, go, o = {}) { // one line of words, inline (no browser prompt)
179
+ openPop(anchor, 'ask', `<label class="hi-field"><span>${esc(label)}</span><input id="hiAsk" maxlength="${o.max || 40}" autocomplete="off" value="${esc(value || '')}"></label><div class="hi-acts"><button type="button" class="hi-btn dark" data-hi-go>Save</button><button type="button" class="hi-btn ghost" data-hi-x>Cancel</button></div>`,
160
180
  (b, el) => { if ('hiX' in b.dataset) { closePop(); return; } if ('hiGo' in b.dataset) { const v = el.querySelector('#hiAsk').value.trim(); if (!v) return; closePop(); go(v); } }, { label });
161
181
  const i = X.pop.el.querySelector('#hiAsk');
162
182
  i.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); const v = i.value.trim(); if (v) { closePop(); go(v); } } });
@@ -226,52 +246,103 @@ function taskRowHtml(t, mine, stages) {
226
246
  + pill + (t.av ? `<span class="hi-av" title="${esc(t.owner)}">${esc(t.av)}</span>` : '') + `<span class="hi-due${t.late ? ' late' : ''}">${esc(t.due || (t.req ? 'PRD' : t.state === 'In progress' ? 'running' : ''))}</span>`
227
247
  + `<button type="button" class="hi-ib sm" data-hi-tmore="${esc(t.key)}" aria-haspopup="menu" aria-label="More for ${esc(t.title)}">${SVG(I.more, 14, 3)}</button></div>`;
228
248
  }
249
+ /* ── the epic groups (T1) and shell A's summary card (XvATasks) ── */
250
+ const TI = { send: 'M4 12l16-8-6 16-3-7z' };
251
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
252
+ const foldOpen = (key, dflt) => (X.fold.has(key) ? X.fold.get(key) : dflt);
253
+ /** A group header: the name, an optional send icon, the count and the fold chevron (PgTkList .gh). */
254
+ function headHtml(key, title, n, open, send = '') {
255
+ return `<div class="tk-gh${send ? ' s' : ''}"><button type="button" class="tk-ghb" data-tk-gfold="${esc(key)}" aria-expanded="${open}"><b>${esc(title)}</b><span class="tk-ghr"><span class="tk-gn">${n}</span>${SVG(open ? I.down : I.right, 16, 2)}</span></button>${send}</div>`;
256
+ }
257
+ function tkRowHtml(r) {
258
+ const ck = r.inJira ? `<span class="tk-ck" role="img" aria-label="In Jira: ${esc(r.status)}"><i class="tk-sq ${esc(r.cat)}"></i></span>` : '<span class="tk-ck" aria-hidden="true"></span>';
259
+ const mark = r.mark ? `<span class="tk-mk ${esc(r.mark[0])}" role="img" aria-label="${esc(r.mark[1])}" title="${esc(r.mark[1])}"></span>` : '';
260
+ return `<button type="button" class="tk-row" data-tk-open="${esc(r.id)}">${ck}<span class="tk-t"><b>${esc(r.title)}</b>${r.sub ? `<span>${esc(r.sub)}</span>` : ''}</span>${mark}${r.av ? `<span class="tk-av" role="img" aria-label="Assigned to ${esc(r.who)}" title="${esc(r.who)}">${esc(r.av)}</span>` : ''}</button>`;
261
+ }
262
+ function epicGroupsHtml(id, M, T) {
263
+ if (!T) return '<p class="hi-small" role="status">Reading the tickets.</p>';
264
+ if (!T.ok) return `<p class="hi-empty">${esc(T.error)}</p>`;
265
+ if (!T.drafted) return T.items
266
+ ? `<div class="tk-card tk-empty"><p>The PRD lists ${plural(T.items, 'story', 'stories')}. Each one becomes a task with its Jira ticket drafted in your template. Nothing goes to Jira until you send it.</p><button type="button" class="hi-btn sm dark" data-tk-drafts>Draft the tickets</button></div>`
267
+ : '<p class="hi-empty">The PRD lists no user stories yet. Give it a "User stories" section, one subheading per story, and each one becomes a task here.</p>';
268
+ const out = TKM.ticketGroups(T).map((g) => {
269
+ const key = 'ep:' + id + ':' + g.id, open = foldOpen(key, true);
270
+ const shown = X.more.has(key) || g.rows.length <= 4 ? g.rows : g.rows.slice(0, 3);
271
+ const send = g.send && !T.pushing ? `<button type="button" class="tk-snd" data-tk-sendg="${esc(g.id)}" aria-label="Send ${esc(g.name)} to Jira" title="Send to Jira">${SVG(TI.send, 17)}</button>` : '';
272
+ return `<section class="tk-g" aria-label="${esc(g.name)}">${headHtml(key, g.name, g.n, open, send)}`
273
+ + (open ? `<div class="tk-list">${shown.map(tkRowHtml).join('')}${shown.length < g.rows.length ? `<button type="button" class="tk-fold" data-tk-more="${esc(key)}">${g.rows.length - shown.length} more${SVG(I.down, 16, 2)}</button>` : ''}</div>` : '') + '</section>';
274
+ }).join('');
275
+ return out + (T.inJira && T.checkedAt ? `<p class="tk-read">${esc(TKM.readLine(T.checkedAt))}</p>` : '');
276
+ }
277
+ /** The summary card (shell A, desktop): what waits on the PM in the tasks, with one primary. Zero is silence. */
278
+ function summaryHtml(id, M, rows, T, by) {
279
+ const VW = X.ctx.VW;
280
+ if (isPhone() || !VW.czSummary) return '';
281
+ const open = rows.filter((r) => !r.done && !r.req).length;
282
+ const meta = [open ? open + ' open' : '', 'grouped by ' + MD.BY_LABEL[by].toLowerCase()].filter(Boolean).join(' · ');
283
+ const G = T && T.ok ? TKM.ticketGroups(T) : [];
284
+ const send = G.reduce((a, g) => a + g.send, 0);
285
+ if (T && T.ok && T.pushing) return VW.czSummary({ line: 'Sending to Jira', tone: 'live', text: 'Claude is creating the tickets with your Atlassian connection. Each task shows its Jira key when it is done.', meta });
286
+ if (send) return VW.czSummary({ line: plural(send, 'ticket is', 'tickets are') + ' drafted, not in Jira', tone: 'you', text: 'Each PRD story is a task with its Jira ticket drafted. Nothing reaches Jira until you send it.', meta, primary: { label: 'Send to Jira', act: 'tk-sendall' } });
287
+ const week = Date.now() + 7 * 864e5;
288
+ const due = rows.filter((r) => !r.done && !r.req && r.end && Date.parse(r.end) <= week).sort((a, b) => a.end.localeCompare(b.end));
289
+ if (!due.length) return VW.czSummary({ meta });
290
+ const words = due.slice(0, 2).map((r) => r.title + (r.due ? ' ' + (/^(today|tomorrow|yesterday)$/.test(r.due) ? r.due : 'by ' + r.due) : ''));
291
+ return VW.czSummary({ line: plural(due.length, 'is', 'are') + ' due this week', tone: due.some((r) => r.late) ? 'warn' : 'you', text: words.join(', and ') + '.', meta,
292
+ primary: { label: 'Open ' + (due[0].title.length > 36 ? due[0].title.slice(0, 35) + '…' : due[0].title), act: 'tk-openfirst' } });
293
+ }
229
294
  function tasksView(id, M) {
230
- const L = Lof(id), by = L.by || 'stage', rows = MD.taskRows(M, L), stages = (M.acts && M.acts.stages) || [];
231
- const G = MD.taskGroups(rows, L, by, stages);
295
+ const L = Lof(id), T = Tof(id), by = byOf(L, T), rows = MD.taskRows(M, L), stages = (M.acts && M.acts.stages) || [];
296
+ if (!T) readT(id, M);
232
297
  const mine = by === 'mine';
233
298
  const target = mine ? (L.names.includes(X.addTo) ? X.addTo : L.names[0] || '') : by === 'stage' ? M.acts.stage || '' : '';
234
- const groups = G.map((g) => {
235
- const shut = X.shut.has('vt:' + g.key);
236
- const head = g.title == null ? '' : `<div class="hi-gh"><button type="button" class="hi-ghb" data-hi-vfold="${esc(g.key)}" aria-expanded="${!shut}">${SVG(shut ? I.right : I.down, 14, 2)}<b>${esc(g.title)}</b><span>${g.open} open</span></button>`
237
- + (g.mine ? `<button type="button" class="hi-ib sm" data-hi-gmore="${esc(g.title)}" aria-haspopup="menu" aria-label="More for ${esc(g.title)}">${SVG(I.more, 14, 3)}</button>` : '') + '</div>';
238
- return `<section class="hi-tg" data-hi-drop="${esc(g.mine ? g.title : g.loose ? '' : '')}"${mine ? ' data-hi-dz' : ''} aria-label="${esc(g.title || 'Tasks')}">${head}${shut ? '' : g.rows.map((t) => taskRowHtml(t, mine, stages)).join('') || '<p class="hi-empty">Drag a task here.</p>'}</section>`;
239
- }).join('');
240
- const note = mine ? 'You name the groups. Drag a task between groups. The stage still shows on each task, so grouping never hides where it sits.'
241
- : by === 'stage' ? 'A task keeps the stage you give it. Jira tickets and PRD requirements count for Build.' : '';
242
- return `<div class="hi-vh2"><h2>Tasks</h2><button type="button" class="cz-pick hi-pick" data-hi-by aria-haspopup="menu" aria-expanded="false">Group: ${esc(MD.BY_LABEL[by])}${SVG(I.down, 14)}</button>`
243
- + `<button type="button" class="hi-ib solid" data-hi-focusadd aria-label="Add a task">${SVG(I.plus, 16)}</button></div>`
244
- + (rows.length ? groups : `<p class="hi-empty">${esc((M.tasks && M.tasks.note) || 'No task yet.')} Add one below.</p>`)
299
+ let groups;
300
+ if (by === 'epic') {
301
+ // the PM's own tasks: the PRD stories are tasks of their epics once drafted, and a Jira row of a pushed ticket is that task
302
+ const keys = new Set(((T && T.ok && T.tickets) || []).map((t) => t.key).filter(Boolean));
303
+ const own = rows.filter((r) => !(T && T.ok && T.drafted && r.req) && !(r.jira && keys.has(r.ref)));
304
+ const k2 = 'ep:' + id + ':mine', open2 = foldOpen(k2, false), n2 = own.filter((r) => !r.done).length;
305
+ groups = epicGroupsHtml(id, M, T)
306
+ + `<section class="tk-g hi-tg" aria-label="Your tasks">${headHtml(k2, 'Your tasks', n2 || own.length, open2)}${open2 ? own.map((t) => taskRowHtml(t, false, stages)).join('') || '<p class="hi-empty">No task of yours yet. Add one below.</p>' : ''}</section>`;
307
+ } else {
308
+ const G = MD.taskGroups(rows, L, by, stages);
309
+ groups = rows.length ? G.map((g) => {
310
+ const shut = X.shut.has('vt:' + g.key);
311
+ const head = g.title == null ? '' : `<div class="hi-gh"><button type="button" class="hi-ghb" data-hi-vfold="${esc(g.key)}" aria-expanded="${!shut}">${SVG(shut ? I.right : I.down, 14, 2)}<b>${esc(g.title)}</b><span>${g.open} open</span></button>`
312
+ + (g.mine ? `<button type="button" class="hi-ib sm" data-hi-gmore="${esc(g.title)}" aria-haspopup="menu" aria-label="More for ${esc(g.title)}">${SVG(I.more, 14, 3)}</button>` : '') + '</div>';
313
+ return `<section class="hi-tg" data-hi-drop="${esc(g.mine ? g.title : g.loose ? '' : '')}"${mine ? ' data-hi-dz' : ''} aria-label="${esc(g.title || 'Tasks')}">${head}${shut ? '' : g.rows.map((t) => taskRowHtml(t, mine, stages)).join('') || '<p class="hi-empty">Drag a task here.</p>'}</section>`;
314
+ }).join('') : `<p class="hi-empty">${esc((M.tasks && M.tasks.note) || 'No task yet.')} Add one below.</p>`;
315
+ }
316
+ return summaryHtml(id, M, rows, T, by) + groups
245
317
  + (mine ? `<button type="button" class="hi-btn sm ghost hi-self" data-hi-newgroup>${SVG(I.plus, 14)}New group</button>` : '')
246
- + (note ? `<p class="hi-small">${esc(note)}</p>` : '')
247
- + `<div class="hi-add"><label for="ovTask" class="hi-vh">Add a task</label><input id="ovTask" maxlength="200" autocomplete="off" placeholder="Add a task${target ? ' to ' + esc(target) : ''}" data-hi-target="${esc(target)}"><button type="button" class="hi-ib sm" data-ov-add aria-label="Add the task">${SVG(I.next, 14)}</button></div>`
248
- + `<div class="hi-foot"><button type="button" class="hi-btn sm ghost" data-ov-record>Open the full record</button>${M.board && M.board.id ? '<button type="button" class="hi-btn sm ghost" data-ov-sprint>Sprint</button>' : ''}</div>`;
318
+ + `<div class="hi-add"><label for="ovTask" class="hi-vh">Add a task</label><input id="ovTask" maxlength="200" autocomplete="off" placeholder="Add a task${target ? ' to ' + esc(target) : ''}" data-hi-target="${esc(target)}"><button type="button" class="hi-ib sm" data-ov-add aria-label="Add the task">${SVG(I.next, 14)}</button></div>`;
249
319
  }
250
320
  function docRowHtml(d, cur, later) {
251
- if (later) return `<div class="hi-drow later" data-ov-doc="${esc(d.key)}"><span class="hi-dic dash">${SVG(I.doc, 16)}</span><span class="hi-dt">${esc(d.title)} · comes in ${esc(d.phase)}</span>${d.act && d.act.kind === 'draft' && !d.running ? `<button type="button" class="hi-btn sm ghost" data-ov-draft="${esc(d.key)}">Draft it now</button>` : ''}</div>`;
252
- const [pt, pc] = MD.docPill(d, cur);
321
+ const draft = d.act && d.act.kind === 'draft' && !d.running && !d.path && d.st !== 'stale';
322
+ if (later) return `<div class="czs-it hi-drow later" data-ov-doc="${esc(d.key)}"><span class="ut-tki dash" aria-hidden="true">${SVG(I.doc, 15)}</span><span class="w">${esc(d.title)}<span>comes in ${esc(d.phase)}</span></span>${draft ? `<button type="button" class="hi-btn sm ghost" data-ov-draft="${esc(d.key)}">Draft it now</button>` : ''}</div>`;
323
+ const [pt] = MD.docPill(d, cur);
253
324
  // a document with no file yet is never a dead press: it says what happens to it (data-ov-none), and offers the draft when PMOS can write it
254
325
  const open = d.path && d.st === 'draft' && d.slot ? `data-ov-dread="${esc(d.key)}"` : d.path ? `data-ov-open="${esc(d.path)}" data-ov-name="${esc(d.title)}"` : `data-ov-none="${esc(d.key)}"`;
255
- const meta = [d.when, d.by, d.link ? d.link.kind : ''].filter(Boolean).join(' · ') || d.what;
326
+ const meta = [d.when, d.by, d.link ? d.link.kind : '', d.look || !d.path ? pt : ''].filter(Boolean).join(' · ') || d.what;
256
327
  return `<div class="hi-drow${d.look ? ' look' : ''}" data-ov-doc="${esc(d.key)}">`
257
- + `<button type="button" class="hi-dmain" ${open} aria-label="${d.path ? 'Open ' : ''}${esc(d.title)}"><span class="hi-dic">${SVG(I.doc, 16)}</span><span class="hi-dtx"><b>${esc(d.title)}</b> <span class="hi-k">· ${esc(d.kind)}${d.core ? ' · core' : ''}</span><em>${esc(meta)}</em>${d.link ? `<small>${esc(d.link.kind + ': ' + d.link.url)}</small>` : ''}</span></button>`
258
- + (d.act && d.act.kind === 'draft' && !d.running && !d.path && d.st !== 'stale' ? `<button type="button" class="hi-btn sm" data-ov-draft="${esc(d.key)}">Draft it</button>` : `<span class="hi-pill ${pc}">${esc(pt)}</span>`) + '</div>';
328
+ + `<button type="button" class="czs-it" ${open} aria-label="${d.path ? 'Open ' : ''}${esc(d.title)}"><span class="ut-tki${d.path ? '' : ' dash'}" aria-hidden="true">${SVG(I.doc, 15)}</span><span class="w">${esc(d.title)}<span>${esc(meta)}</span>${d.link ? `<span>${esc(d.link.kind + ': ' + d.link.url)}</span>` : ''}</span>${d.look ? '<span class="czs-amb" role="img" aria-label="Needs a look"></span>' : ''}</button>`
329
+ + '</div>';
259
330
  }
331
+ /** Documents in shell A (canvas XvADocs): the summary says what needs a look and holds the one primary (draft the first missing document,
332
+ * else open the first that needs a look); the groups fold below it. Group by, Show and Add a document are under ⋯. */
260
333
  function docsView(id, M) {
261
334
  const rows = MD.docRows(M), cur = MD.phaseOf(M.acts && M.acts.stage);
262
- if (!rows.length) return `<div class="hi-vh2"><h2>No documents</h2><button type="button" class="hi-ib" data-ov-adddoc aria-label="Add a document" title="Add a document">${SVG(I.plus, 16)}</button></div><p class="hi-empty">${M.docs && M.docs.missing ? 'The core documents could not be read.' : 'This initiative has no core document yet.'}</p>`;
263
- const chips = MD.docChips(rows), G = MD.docGroups(rows, M.acts && M.acts.stage, X.doc);
264
- const groups = G.map((g) => {
265
- const fold = g.fold && !X.doc.more.has(g.key) && g.rows.length > g.fold + 1;
266
- const shown = fold ? g.rows.slice(0, g.fold) : g.rows;
267
- return (g.title ? `<p class="hi-lbl">${esc(g.title)}</p>` : '') + shown.map((d) => docRowHtml(d, cur, g.later)).join('')
268
- + (fold ? `<button type="button" class="hi-btn sm ghost hi-self" data-hi-dmore="${esc(g.key)}">Show ${g.rows.length - g.fold} more in ${esc(g.title)}</button>` : '');
269
- }).join('') || '<p class="hi-empty">No document matches.</p>';
270
- return `<div class="hi-vh2"><h2>${rows.length} ${rows.length === 1 ? 'document' : 'documents'}</h2><button type="button" class="cz-pick hi-pick" data-hi-dby aria-haspopup="menu" aria-expanded="false">Group: ${esc(MD.DOC_BY[X.doc.by])}${SVG(I.down, 14)}</button>`
271
- + `<button type="button" class="hi-ib" data-ov-adddoc aria-label="Add a document" title="Add a document">${SVG(I.plus, 16)}</button></div>`
272
- + (M.docs && M.docs.cap ? `<p class="hi-small" data-ov-dsum>${esc(M.docs.cap)}</p>` : '')
273
- + `<div class="hi-chips" role="group" aria-label="Show">${chips.map((c) => `<button type="button" class="cz-chip${X.doc.filter === c.k ? ' on' : ''}" aria-pressed="${X.doc.filter === c.k}" data-hi-dfilter="${esc(c.k)}">${esc(c.label)} ${c.n}</button>`).join('')}</div>`
274
- + groups + '<p class="hi-small">Press a row to open the document. Core marks the documents a stage needs.</p>';
335
+ if (!rows.length) return '<div class="hi-v hi-v2" data-hi-v="docs">' + VW().czSummary({ text: M.docs && M.docs.missing ? 'The core documents could not be read.' : 'This initiative has no core document yet.', primary: { label: 'Add a document', act: 'adddoc' } }) + '</div>';
336
+ const G = MD.docGroups(rows, M.acts && M.acts.stage, X.doc);
337
+ const look = rows.filter((d) => d.look), miss = rows.filter((d) => !d.path && d.act && d.act.kind === 'draft' && !d.running);
338
+ const said = look.slice(0, 2).map((d) => d.title + ' ' + String(MD.docPill(d, cur)[0] || '').toLowerCase()).concat(miss.filter((d) => !d.look).slice(0, 1).map((d) => 'The ' + d.title + ' is not written yet'));
339
+ const first = miss[0] || null, open = !first && look.find((d) => d.path);
340
+ const pri = first ? { label: 'Draft the ' + first.title, act: 'draft:' + first.key } : open ? { label: 'Open ' + open.title, act: 'open:' + open.key } : null;
341
+ const sum = VW().czSummary({ line: look.length ? look.length + (look.length === 1 ? ' needs a look' : ' need a look') : '', tone: look.length ? 'warn' : '',
342
+ text: said.length ? said.map((x) => x.replace(/^./, (c) => c.toUpperCase())).join('. ') + '.' : 'Every document is in place for ' + (cur || 'this stage') + '.',
343
+ meta: rows.length + (rows.length === 1 ? ' document' : ' documents') + ' · filter and sort are under More', extra: M.docs && M.docs.cap ? `<p class="czs-meta" data-ov-dsum>${esc(M.docs.cap)}</p>` : '', primary: pri });
344
+ const secs = VW().czSections(G.map((g, i) => ({ id: 'd:' + (g.key || i), title: g.title || 'Documents', count: g.rows.length, open: i === 0, html: g.rows.map((d) => docRowHtml(d, cur, g.later)).join('') })), { key: 'docs' });
345
+ return '<div class="hi-v hi-v2" data-hi-v="docs">' + sum + (secs || '<p class="hi-empty">No document matches.</p>') + '</div>';
275
346
  }
276
347
  function stageView(id, M, ask) {
277
348
  const mv = mvOf(id, M), stages = (M.acts && M.acts.stages) || [];
@@ -293,7 +364,10 @@ function draw(b) {
293
364
  const S = X.ctx.S, id = S.ini, M = curM();
294
365
  if (!M) { b.innerHTML = `<div class="hi-v"><p class="hi-small" role="status">${X.failed === id ? 'The initiative could not be read.' : 'Reading the initiative.'}</p></div>`; return; }
295
366
  const v = X.view;
296
- b.innerHTML = `<div class="hi-v" data-hi-v="${v}">${segHtml(v)}${v === 'docs' ? docsView(id, M) : v === 'stage' ? stageView(id, M, STAGE_ASK) : tasksView(id, M)}<p class="hi-small" role="status" id="ovMsg"></p></div>`;
367
+ // Documents is shell A (XvADocs): no tabs, the summary card and folding groups straight in the body
368
+ if (v === 'docs') { b.innerHTML = docsView(id, M) + '<p class="hi-small" role="status" id="ovMsg"></p>'; return; }
369
+ // the phone keeps the Tasks | Stage switch (PgTkList); in shell A on a desktop the other views sit under ⋯ (XvATasks)
370
+ b.innerHTML = `<div class="hi-v" data-hi-v="${v}">${isPhone() || !X.ctx.VW.czSummary ? segHtml(v) : ''}${v === 'stage' ? stageView(id, M, STAGE_ASK) : tasksView(id, M)}<p class="hi-small" role="status" id="ovMsg"></p></div>`;
297
371
  }
298
372
  function redrawView() {
299
373
  if (!BODY || !BODY.isConnected || !X.ctx) return;
@@ -302,6 +376,41 @@ function redrawView() {
302
376
  const st = BODY.scrollTop; draw(BODY); BODY.scrollTop = st;
303
377
  if (keep) { const n = BODY.querySelector('#' + keep); if (n) { if (val != null) n.value = val; n.focus(); } }
304
378
  }
379
+ /** ⋯ of the initiative in the Viewer (xvMore order: change it, then look back). */
380
+ function moreOf(id, view) {
381
+ const M0 = () => curM();
382
+ const out = [];
383
+ if (view === 'tasks') out.push({ label: 'Group tasks by', on: (b) => { const M = M0(); if (M) groupMenu(b, id, M); } });
384
+ for (const [k, l] of Object.entries(KIND)) if (k !== view) out.push({ label: l, on: () => iniOverview(k) });
385
+ out.push({ sep: true }, { label: 'Open the full record', on: async () => { const M = M0(); if (M) (await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }); } });
386
+ if (M0() && M0().board && M0().board.id) out.push({ label: 'Sprint', on: async () => { const M = M0(); if (M) (await import('./premium-vw-jira.js')).openSprint(bw(M)); } });
387
+ return out;
388
+ }
389
+ function groupMenu(t, id, M) {
390
+ const L = Lof(id), T = Tof(id), by = byOf(L, T);
391
+ const same = (n) => n.join('|').toLowerCase() === L.names.join('|').toLowerCase();
392
+ const st = (M.acts && M.acts.stages) || [], at = Math.max(0, st.indexOf(M.acts.stage));
393
+ const G = T && T.ok ? TKM.ticketGroups(T) : [];
394
+ menu(t, [{ head: 'Group by' }, ...['epic', 'stage', 'mine', 'owner', 'status', 'none'].map((k) => ({ label: MD.BY_LABEL[k],
395
+ sub: k === 'stage' ? st.slice(at, at + 3).join(', ') : k === 'mine' && L.names.length ? L.names.join(', ') : k === 'epic' && G.length ? G.map((g) => g.name).slice(0, 2).join(', ') : '',
396
+ radio: true, on: by === k, go: () => press(id, M, { kind: 'by', by: k }) })),
397
+ { hr: true }, { head: 'Saved group sets' },
398
+ ...(L.sets || []).map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : s.name !== s.names.join(' · ') ? s.name : '', go: async () => { if (await press(id, M, { kind: 'groups', names: s.names })) press(id, M, { kind: 'by', by: 'mine' }); } })),
399
+ { label: 'Save these groups as a set', icon: I.plus, disabled: !L.names.length, go: () => press(id, M, { kind: 'set', name: L.names.join(' · '), names: L.names }) }], 'Group tasks by');
400
+ }
401
+ /** The Send sheet (T3): one path to Jira, from a group's send icon, a drafted ticket, the summary card or the Board's Commit row. */
402
+ async function sendSheet(id, M, o = {}) {
403
+ const S = await import('./tk-send.js');
404
+ return S.openSend({ ws: wsOf(M), board: M.board && M.board.id, initiative: id, ...o, toast: X.ctx.toast,
405
+ onDone: async () => { await readT(id, M, true); setTimeout(() => readT(id, curM() || M, true), 4000); } });
406
+ }
407
+ async function openTicket(id, M, tid) {
408
+ const T = Tof(id), t = T && T.ok ? (T.tickets || []).find((x) => x.id === tid) : null;
409
+ if (t && t.inJira && !t.selectable) { (await import('./premium-vw-jira.js')).openTicket({ ...bw(M), initiative: id, ref: t.key }); return; }
410
+ const D = await import('./tk-draft.js');
411
+ D.openDraft({ VW: X.ctx.VW, ws: wsOf(M), initiative: id, id: tid, view: T && T.ok ? T : null, toast: X.ctx.toast, ui: { menu, ask },
412
+ onChange: () => readT(id, M, true), onSend: (x) => sendSheet(id, M, { ticket: x }) });
413
+ }
305
414
  export function iniOverview(view) {
306
415
  if (!X.ctx) return false;
307
416
  const S = X.ctx.S, id = S.ini;
@@ -309,11 +418,33 @@ export function iniOverview(view) {
309
418
  X.view = KIND[view] ? view : 'tasks'; // the card's Overview opens on Tasks (InTasks); a list line or the switch names its own view
310
419
  STAGE_ASK = null;
311
420
  const VW = X.ctx.VW;
312
- BODY = VW.open({ id: 'ov:' + id, kind: KIND[X.view], title: X.ctx.iniTitle(id), icon: ICON[X.view], render: draw });
421
+ const docs = X.view === 'docs';
422
+ // render wires the body too, so ← from a drill-in (a drafted ticket) draws the view again with its presses
423
+ BODY = VW.open({ id: 'ov:' + id, kind: KIND[X.view], title: KIND[X.view] + ' · ' + X.ctx.iniTitle(id), icon: ICON[X.view], more: docs ? () => docsMore(id) : moreOf(id, X.view),
424
+ render: (b) => { BODY = b; draw(b); wire(b, id); } });
313
425
  if (!curM()) { X.failed = null; X.ctx.loadIni().then(() => { if (S.ini !== id) return; if (!curM()) X.failed = id; X.ctx.drawList(); redrawView(); }); } // a slow first read: read it again rather than say it failed
314
- wire(BODY, id);
315
426
  return true;
316
427
  }
428
+ const VW = () => X.ctx.VW;
429
+ /** ⋯ of Documents (the xvMore note: change it, then look back): Group by, Show, Add a document, the tasks and stage, the full record. */
430
+ function docsMore(id) {
431
+ const M = curM(); if (!M) return [];
432
+ const chips = MD.docChips(MD.docRows(M)), on = chips.find((c) => c.k === X.doc.filter);
433
+ return [
434
+ { label: 'Group by', note: MD.DOC_BY[X.doc.by], on: (b) => menu(b, Object.entries(MD.DOC_BY).map(([k, l]) => ({ label: l, radio: true, on: X.doc.by === k, go: () => { X.doc.by = k; redrawView(); } })), 'Group documents by') },
435
+ { label: 'Show', note: on ? on.label : '', on: (b) => menu(b, chips.map((c) => ({ label: c.label + ' ' + c.n, radio: true, on: X.doc.filter === c.k, go: () => { X.doc.filter = c.k; redrawView(); } })), 'Show documents') },
436
+ { label: 'Add a document', on: () => addDoc(id) },
437
+ { sep: true },
438
+ { label: 'Tasks', on: () => iniOverview('tasks') },
439
+ { label: 'Stage', on: () => iniOverview('stage') },
440
+ { label: 'Open the full record', on: async () => (await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }) },
441
+ ];
442
+ }
443
+ async function addDoc(id) {
444
+ const M = curM(), S = X.ctx.S; if (!M) return;
445
+ const A = await import('./home-adddoc.js');
446
+ A.openAddDocVw({ VW: X.ctx.VW, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, phases: MD.PHASES, title: X.ctx.iniTitle(id), back: () => iniOverview('docs'), onAdded: async () => { await X.ctx.load(); if (S.ini === id) iniOverview('docs'); } });
447
+ }
317
448
  function wire(body, id) {
318
449
  const S = X.ctx.S;
319
450
  const say = (m) => { const el = body.querySelector('#ovMsg'); if (el) el.textContent = m; };
@@ -340,14 +471,22 @@ function wire(body, id) {
340
471
  const d = t.dataset;
341
472
  if (d.hiView) { iniOverview(d.hiView); return; }
342
473
  if ('hiAuto' in d) { press(id, M, { kind: 'auto', on: t.getAttribute('aria-checked') !== 'true' }); return; }
343
- if ('hiBy' in d) {
344
- const L = Lof(id);
345
- const same = (n) => n.join('|').toLowerCase() === L.names.join('|').toLowerCase();
346
- menu(t, [{ head: 'Group by' }, ...['stage', 'mine', 'owner', 'status', 'none'].map((k) => ({ label: MD.BY_LABEL[k], sub: k === 'stage' ? ((M.acts && M.acts.stages) || []).slice(Math.max(0, ((M.acts && M.acts.stages) || []).indexOf(M.acts.stage)), Math.max(0, ((M.acts && M.acts.stages) || []).indexOf(M.acts.stage)) + 3).join(', ') : k === 'mine' && L.names.length ? L.names.join(', ') : '', radio: true, on: L.by === k, go: () => press(id, M, { kind: 'by', by: k }) })),
347
- { hr: true }, { head: 'Saved group sets' },
348
- ...(L.sets || []).map((s) => ({ label: s.names.join(' · '), sub: same(s.names) ? 'this one' : s.name !== s.names.join(' · ') ? s.name : '', go: async () => { if (await press(id, M, { kind: 'groups', names: s.names })) press(id, M, { kind: 'by', by: 'mine' }); } })),
349
- { label: 'Save these groups as a set', icon: I.plus, disabled: !L.names.length, go: () => press(id, M, { kind: 'set', name: L.names.join(' · '), names: L.names }) }], 'Group tasks by');
350
- return;
474
+ if ('hiBy' in d) { groupMenu(t, id, M); return; }
475
+ // PRD to Jira (T1 to T3)
476
+ if (d.czsAct === 'tk-sendall') { sendSheet(id, M); return; }
477
+ if (d.czsAct === 'tk-openfirst') {
478
+ const wk = Date.now() + 7 * 864e5, r = MD.taskRows(M, Lof(id)).filter((x) => !x.done && !x.req && x.end && Date.parse(x.end) <= wk).sort((a, b) => a.end.localeCompare(b.end))[0];
479
+ if (r) openTask(id, M, r.key); return;
480
+ }
481
+ if (d.tkGfold) { X.fold.set(d.tkGfold, t.getAttribute('aria-expanded') !== 'true'); redrawView(); return; }
482
+ if (d.tkMore) { X.more.add(d.tkMore); redrawView(); return; }
483
+ if (d.tkSendg != null) { sendSheet(id, M, { group: d.tkSendg }); return; }
484
+ if (d.tkOpen) { openTicket(id, M, d.tkOpen); return; }
485
+ if ('tkDrafts' in d) {
486
+ t.disabled = true;
487
+ const r = await X.ctx.pmPost('/api/jira/draft', { ws: wsOf(M), initiative: id });
488
+ if (!r || r.ok === false) { say((r && r.error) || 'The tickets were not drafted.'); t.disabled = false; return; }
489
+ X.ctx.toast(plural(r.tickets, 'ticket', 'tickets') + ' drafted. Nothing is in Jira yet.'); await readT(id, M, true); return;
351
490
  }
352
491
  if ('hiNewgroup' in d) { const L = Lof(id); ask(t, 'Name the group', '', (v) => press(id, M, { kind: 'groups', names: L.names.concat(v) })); return; }
353
492
  if (d.hiGmore) {
@@ -383,6 +522,13 @@ function wire(body, id) {
383
522
  return;
384
523
  }
385
524
  // documents
525
+ if (d.czsAct === 'adddoc') { addDoc(id); return; }
526
+ if (/^(draft|open):/.test(d.czsAct || '')) {
527
+ const key = d.czsAct.slice(d.czsAct.indexOf(':') + 1), doc = (M.docs.rows || []).find((x) => x.key === key); if (!doc) return;
528
+ if (d.czsAct.startsWith('draft:')) { after(await X.ctx.pmPost('/api/core-docs/draft', { ws: M.board.ws, scope: M.docs.scope, key }), 'The draft started. It waits for you to read.'); return; }
529
+ if (doc.path && doc.st === 'draft' && doc.slot) { const A = await import('./home-draft.js'); A.openDraftVw({ VW: X.ctx.VW, pmGet: X.ctx.pmGet, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, doc, onIssued: () => X.ctx.load() }); return; }
530
+ X.ctx.openFile({ path: doc.path, name: doc.title }); return;
531
+ }
386
532
  if ('hiDby' in d) { menu(t, Object.entries(MD.DOC_BY).map(([k, l]) => ({ label: l, radio: true, on: X.doc.by === k, go: () => { X.doc.by = k; redrawView(); } })), 'Group documents by'); return; }
387
533
  if (d.hiDfilter) { X.doc.filter = d.hiDfilter; redrawView(); return; }
388
534
  if (d.hiDmore) { X.doc.more.add(d.hiDmore); redrawView(); return; }
@@ -403,11 +549,7 @@ function wire(body, id) {
403
549
  A.openDraftVw({ VW: X.ctx.VW, pmGet: X.ctx.pmGet, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, doc, onIssued: () => X.ctx.load() });
404
550
  return;
405
551
  }
406
- if ('ovAdddoc' in d) {
407
- const A = await import('./home-adddoc.js');
408
- A.openAddDocVw({ VW: X.ctx.VW, pmPost: X.ctx.pmPost, toast: X.ctx.toast, wait: X.ctx.wait || '', ws: M.board.ws, scope: M.docs.scope, phases: MD.PHASES, title: X.ctx.iniTitle(id), back: () => iniOverview('docs'), onAdded: async () => { await X.ctx.load(); if (S.ini === id) iniOverview('docs'); } });
409
- return;
410
- }
552
+ if ('ovAdddoc' in d) { addDoc(id); return; }
411
553
  // stage
412
554
  if (d.ovMove) { if (t.getAttribute('aria-pressed') === 'true') return; const ok = await after(await X.ctx.pmPost('/api/boards/move', { ...bw(M), id, to: d.ovMove, why: 'Moved by hand' }), 'Moved to ' + d.ovMove + '.'); void ok; return; }
413
555
  if (d.ovLife === 'active') { after(await X.ctx.pmPost('/api/lifecycle', { ws: M.board.ws, initiative_id: id, state: 'active', reason: '' }), 'Recorded.'); return; }
@@ -457,6 +599,7 @@ export function mountIni(ctx) {
457
599
  X.ctx = ctx;
458
600
  if (typeof document === 'undefined') return X;
459
601
  if (!document.querySelector('link[data-hi-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '/pm/home-ini.css'; l.dataset.hiCss = ''; document.head.appendChild(l); }
602
+ if (!document.querySelector('link[data-tk-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '/pm/tk-tasks.css'; l.dataset.tkCss = ''; document.head.appendChild(l); }
460
603
  const list = document.getElementById('hmList');
461
604
  if (list) list.addEventListener('click', onList);
462
605
  ctx.VW.onChange((v) => { if (!v.open || !/^ov:/.test(v.id || '')) closePop(); });
@@ -97,23 +97,17 @@ export function tasksOf(D, ini, now = Date.now()) {
97
97
  function meetRow(m, ini) {
98
98
  return { id: 'm:' + (m.id || m.title), kind: 'meeting', ini: ini || null, name: m.title, hint: (m.state === 'now' ? 'Now' : hm(m.start)) + (ini ? ' meeting' : ' · not linked'), state: m.state === 'now' ? 'working' : 'quiet', icon: 'clock', meeting: m };
99
99
  }
100
- /** Today's unread mentions of the PM (GET /api/brief-page mentions). One that names an initiative is that initiative's next step. */
101
- const mentionsOf = (D) => (D.today && Array.isArray(D.today.mentions) ? D.today.mentions : []).filter((m) => m && !m.read && !m.done);
102
- function mentionRow(m, ini) {
103
- return { id: 'men:' + (m.id || m.at), kind: 'mention', ini: ini || null, name: (m.who ? m.who + ' ' : '') + (m.text ? 'asks: ' + m.text : 'named you'),
104
- hint: (ini ? 'Next step · ' : '') + 'Mention' + (m.where ? ' · ' + m.where : m.source ? ' · ' + cap1(m.source) : ''), state: 'needs', mention: m, link: m.link || '', step: !!ini };
105
- }
106
100
  const meetIni = (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null;
107
101
  /** A next step's hint without its product's name: the product is the group's header. */
108
102
  const bareHint = (x) => { const h = String(x.hint || ''), p = prodOf(x); return p && h.startsWith(p + ' · ') ? h.slice(p.length + 3) : p && h === p ? '' : h; }; // the group names the product; "Across products" stays
109
103
  /** Where an initiative is on the eight stages (the row's stage track, HvAC .mt): 0 Triage … 7 Evaluate, or -1 when its stage is not one of them. */
110
104
  export const stageAt = (stage) => { const k = stageKey(stage); return k ? STEPS.findIndex((s) => s.key === k) : -1; };
111
- /** A row under an initiative that is the PM's move now (Your move, and the initiative's count badge): a next step, a mention, a session
105
+ /** A row under an initiative that is the PM's move now (Your move, and the initiative's count badge): a next step, a session
112
106
  * that waits on the PM, or a task of the PM's own that is late. */
113
- const isMove = (k) => k.step || k.kind === 'mention' || (k.kind === 'session' && (k.state === 'needs' || k.state === 'blocked')) || (k.kind === 'task' && k.mine && k.late);
107
+ const isMove = (k) => k.step || (k.kind === 'session' && (k.state === 'needs' || k.state === 'blocked')) || (k.kind === 'task' && k.mine && k.late);
114
108
  function iniRowOf(D, r, needs, now) {
115
- const steps = needs.filter((x) => x.ini === r.id && !x.needSession).map((x) => ({ ...x, step: true, hint: 'Next step' + (bareHint(x) ? ' · ' + bareHint(x) : '') }))
116
- .concat(mentionsOf(D).filter((m) => m.initiative === r.id).map((m) => mentionRow(m, r.id)));
109
+ // a mention is not a row here: Mentions is its own row at the top of Home (home-mentions.js, XvANew), so it shows once
110
+ const steps = needs.filter((x) => x.ini === r.id && !x.needSession).map((x) => ({ ...x, step: true, hint: 'Next step' + (bareHint(x) ? ' · ' + bareHint(x) : '') }));
117
111
  const ses = (D.sessions || []).filter((s) => live(s) && iniOfSession(s) === r.id).map((s) => sessionRow(s, D.desk && D.desk.roles));
118
112
  const tasks = tasksOf(D, r.id, now);
119
113
  const meet = todayOf(D).filter((m) => meetIni(m) === r.id && m.state !== 'past').map((m) => meetRow(m, r.id));
@@ -215,8 +209,6 @@ export function homeList(D, o = {}) {
215
209
  const loose = [];
216
210
  for (const x of looseNeeds) loose.push({ ...x, flat: true });
217
211
  for (const r of tabRows('today')) loose.push({ id: 'w:' + r.key, kind: 'item', key: r.key, name: r.title, hint: [r.overdue ? 'late' : '', String(r.sub || '').replace(/^Yours\b\s*(·\s*)?/, '')].filter(Boolean).join(' · '), check: true, mine: true, late: !!r.overdue, item: r }); // the check box says it is the PM's own: no "your own note" on every row (testing fixes)
218
- const inIni = new Set(groups.flatMap((g) => g.inis.concat(g.rest)).map((i) => i.ini));
219
- for (const m of mentionsOf(D).filter((x) => !(x.initiative && inIni.has(x.initiative)))) loose.push(mentionRow(m, null));
220
212
  for (const m of todayOf(D).filter((x) => !meetIni(x) && x.state !== 'past')) loose.push(meetRow(m, null));
221
213
  for (const s of (D.sessions || []).filter((s) => live(s) && !iniOfSession(s) && s.shown !== 'needs' && s.shown !== 'blocked')) loose.push({ ...sessionRow(s, D.desk && D.desk.roles), loose: true });
222
214
  // the folded line's signals (HvAC .lh): a blue dot when a row waits on the PM, an amber square when one of the PM's own is late
@@ -241,8 +233,8 @@ export function homeList(D, o = {}) {
241
233
  }
242
234
 
243
235
  /* ── Your move (HvAOpen) ── */
244
- /** Every row that is the PM's move, in one list for the Your day sheet: the PM's own late tasks and items first, then each next step,
245
- * mention and waiting session in the list's order. A row keeps its list id, so a press opens what the list row opens. Each row:
236
+ /** Every row that is the PM's move, in one list for the Your day sheet: the PM's own late tasks and items first, then each next step and
237
+ * waiting session in the list's order. A row keeps its list id, so a press opens what the list row opens. Each row:
246
238
  * { id, name, sub (its initiative, or the hint of a row with none), late, state, when (the weekly update's send time) }. */
247
239
  function moveOf(groups, needs) {
248
240
  const late = [], rest = [], seen = new Set();