create-pmos 0.443.0 → 0.445.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 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/adler-moments-test.js +8 -0
  8. package/workspace/adler-seasons-art-test.js +3 -0
  9. package/workspace/board-columns-test.js +168 -0
  10. package/workspace/board-programs-test.js +1 -1
  11. package/workspace/briefing-premium-board-test.js +91 -8
  12. package/workspace/briefing-premium-insights-test.js +83 -38
  13. package/workspace/briefing-premium-test.js +2 -1
  14. package/workspace/calm-timeline-test.js +3 -1
  15. package/workspace/changelog.json +24 -0
  16. package/workspace/goals-clear-ui-test.js +34 -20
  17. package/workspace/guide/home.md +5 -0
  18. package/workspace/guide/jira.md +13 -1
  19. package/workspace/guide/ready-made-dashboards.md +2 -2
  20. package/workspace/intel-report-ui-test.js +1 -1
  21. package/workspace/lib/board-fold.js +33 -5
  22. package/workspace/lib/board-premium.js +1 -1
  23. package/workspace/lib/console-state.js +5 -1
  24. package/workspace/lib/engine/boards.js +9 -2
  25. package/workspace/lib/factory-join.js +46 -14
  26. package/workspace/lib/freshness.js +14 -1
  27. package/workspace/lib/initiative-rows.js +38 -4
  28. package/workspace/lib/issues.js +8 -1
  29. package/workspace/lib/jira-cli.js +18 -2
  30. package/workspace/lib/jira-moves.js +119 -0
  31. package/workspace/lib/jira-tickets.js +23 -4
  32. package/workspace/lib/notes.js +4 -2
  33. package/workspace/lib/offloop.js +75 -29
  34. package/workspace/lib/page-build.js +97 -0
  35. package/workspace/lib/plan-items.js +24 -3
  36. package/workspace/lib/plan-tree.js +62 -9
  37. package/workspace/lib/ready-reports.js +22 -8
  38. package/workspace/lib/refresh.js +14 -2
  39. package/workspace/lib/routes-board-premium.js +9 -1
  40. package/workspace/lib/routes-boards.js +114 -16
  41. package/workspace/lib/routes-brief-page.js +3 -1
  42. package/workspace/lib/routes-calendar-import.js +13 -1
  43. package/workspace/lib/routes-ready-reports.js +28 -5
  44. package/workspace/lib/task-links.js +12 -1
  45. package/workspace/lib/workflows-store.js +14 -3
  46. package/workspace/live-pill-round-test.js +178 -0
  47. package/workspace/milestone-pins-test.js +1 -1
  48. package/workspace/okr-goals-ui-test.js +21 -19
  49. package/workspace/package-lock.json +2 -2
  50. package/workspace/package.json +1 -1
  51. package/workspace/panels-test.js +375 -0
  52. package/workspace/premium-rec-tab-test.js +2 -1
  53. package/workspace/premium-vw-item-test.js +10 -2
  54. package/workspace/premium-vw-jira-test.js +3 -0
  55. package/workspace/program-panel-test.js +6 -6
  56. package/workspace/public/pm/bd-cols.js +149 -0
  57. package/workspace/public/pm/bd-ini-panel.js +3 -2
  58. package/workspace/public/pm/bd-pane.js +41 -0
  59. package/workspace/public/pm/bd-span.js +29 -11
  60. package/workspace/public/pm/cozy-adler.js +21 -0
  61. package/workspace/public/pm/cozy-board.css +45 -0
  62. package/workspace/public/pm/cozy-divider.css +32 -0
  63. package/workspace/public/pm/cozy-divider.js +45 -0
  64. package/workspace/public/pm/cozy-insights.css +22 -0
  65. package/workspace/public/pm/cozy-live-pill.css +17 -22
  66. package/workspace/public/pm/cozy-live-pill.js +38 -18
  67. package/workspace/public/pm/cozy-panels.css +80 -0
  68. package/workspace/public/pm/cozy-panels.js +691 -0
  69. package/workspace/public/pm/cozy-viewer.js +148 -70
  70. package/workspace/public/pm/dash-view.js +5 -2
  71. package/workspace/public/pm/goals-clear.js +9 -2
  72. package/workspace/public/pm/home-app.js +30 -19
  73. package/workspace/public/pm/home-ini.js +9 -3
  74. package/workspace/public/pm/home-today.js +4 -2
  75. package/workspace/public/pm/ini-edit.js +405 -0
  76. package/workspace/public/pm/ini-tasks.js +175 -46
  77. package/workspace/public/pm/ini-versions.js +18 -4
  78. package/workspace/public/pm/ini-view-model.js +12 -7
  79. package/workspace/public/pm/ini-view.css +162 -26
  80. package/workspace/public/pm/ini-view.js +44 -13
  81. package/workspace/public/pm/ini-wf-model.js +9 -0
  82. package/workspace/public/pm/ini-wf.js +14 -9
  83. package/workspace/public/pm/ins-pane.js +55 -0
  84. package/workspace/public/pm/jira-move.js +50 -0
  85. package/workspace/public/pm/live-model.js +3 -2
  86. package/workspace/public/pm/pn-narrow.js +76 -0
  87. package/workspace/public/pm/premium-board.js +85 -32
  88. package/workspace/public/pm/premium-insights.js +211 -43
  89. package/workspace/public/pm/task-card.css +2 -0
  90. package/workspace/public/pm/task-card.js +4 -1
  91. package/workspace/public/premium-board.html +2 -0
  92. package/workspace/ready-dash-ui-test.js +4 -4
  93. package/workspace/server.js +71 -20
  94. package/workspace/skills/jira-move.skill +35 -0
  95. package/workspace/stage-card-tasks-test.js +397 -0
  96. package/workspace/stage-card-test.js +1 -1
  97. package/workspace/task-delete-test.js +9 -1
  98. package/workspace/task-links-test.js +1 -0
  99. package/workspace/task-milestones-test.js +3 -3
  100. package/workspace/task-plans-test.js +1 -1
  101. package/workspace/task-press-test.js +12 -4
  102. package/workspace/task-views-test.js +166 -13
  103. package/workspace/test-lists/batch18-live-pill-round.json +10 -0
  104. package/workspace/test-lists/batch18-panels.json +9 -0
  105. package/workspace/test-lists/board-columns.json +5 -0
  106. package/workspace/test-lists/jira-moves.json +11 -0
  107. package/workspace/test-lists/page-speed-fold.json +5 -0
  108. package/workspace/test-lists/page-speed-reads.json +5 -0
  109. package/workspace/test-lists/stage-card-tasks.json +6 -0
  110. package/workspace/timeline-holds-test.js +1 -1
@@ -0,0 +1,50 @@
1
+ /* pm/jira-move.js — a Jira ticket's status moved from PMOS (Wawan 2026-10-29 "why can't move Jira task here on PMOS?"; main canvas page
2
+ * "Exploring · Move Jira tasks", JmA1Kanban, JmA3States). A Kanban drag, or the status press on the List or the Timeline, asks the move:
3
+ * POST /api/jira/move. The server writes it and starts the jira-move agent, which moves the ticket with the PM's own Atlassian connection
4
+ * (PMOS holds no Jira login, D53). Until Jira answers, the next read draws the ticket in its new place as "Moving in Jira"; this file asks
5
+ * GET /api/jira/move every few seconds and says what Jira did in the host's toast: moved (with Undo, the same move back), refused (Jira's
6
+ * reason), or not reached.
7
+ *
8
+ * move(H, { key, to, from, fromRaw }) H: the Tasks host (where, reload, toast, __id); to/from: To do | In progress | Done
9
+ * TO the three states a Jira ticket offers here (Won't do and Archive stay PMOS-only) */
10
+ import { pmPost } from './http.js';
11
+
12
+ export const TO = ['To do', 'In progress', 'Done'];
13
+ const EVERY = 4000, FOR = 16 * 60 * 1000;
14
+ const WATCH = new Map(); // move id → true while this page waits on it
15
+ const say = (H, m, undo) => { if (H && H.toast) H.toast(m, undo); };
16
+ const after = async (H) => { if (H && H.reload) await H.reload(); else if (H && H.redraw) H.redraw(); };
17
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
18
+
19
+ async function read(ws, id) {
20
+ try { const r = await fetch('/api/jira/move?' + new URLSearchParams({ ...(ws ? { ws } : {}), id }), { credentials: 'same-origin' }); return await r.json(); } catch { return null; }
21
+ }
22
+ async function watch(H, ws, id, m) {
23
+ if (WATCH.has(id)) return;
24
+ WATCH.set(id, true);
25
+ const t0 = Date.now();
26
+ try {
27
+ while (Date.now() - t0 < FOR) {
28
+ await sleep(EVERY);
29
+ const r = await read(ws, id), x = r && r.ok ? r.move : null;
30
+ if (r && r.ok === false && /newer move/.test(r.error || '')) return; // a newer move of the ticket took over; its own watch speaks
31
+ if (!x || x.state === 'moving') continue;
32
+ await after(H);
33
+ if (x.state === 'moved') { say(H, `${m.key} is ${x.status || x.to} in Jira.`, m.from && m.from !== m.to ? () => move(H, { key: m.key, to: m.from, from: m.to, fromRaw: x.status || '' }) : undefined); return; }
34
+ if (x.state === 'refused') { say(H, `Jira kept ${m.key} in ${m.fromRaw || m.from || 'its status'}: ${String(x.why || 'Jira did not say why').replace(/\.$/, '')}.`); return; }
35
+ if (x.state === 'stale') break;
36
+ }
37
+ say(H, `Jira did not answer. ${m.key} stays in ${m.fromRaw || m.from || 'its status'} until it does.`);
38
+ } finally { WATCH.delete(id); }
39
+ }
40
+ /** Ask Jira to move one ticket. → true when the move was asked. */
41
+ export async function move(H, m) {
42
+ if (!m || !m.key || !TO.includes(m.to) || m.to === m.from) return false;
43
+ const at = H && H.where ? H.where() : {}, ini = H && H.__id ? H.__id() : '';
44
+ const r = await pmPost('/api/jira/move', { ws: at.ws, initiative: ini, key: m.key, to: m.to, from: m.from || '', fromRaw: m.fromRaw || '' }).catch(() => null);
45
+ if (!r || r.ok === false) { say(H, (r && r.error) || `Jira was not asked: ${m.key} stays where it is.`); await after(H); return false; }
46
+ if (r.unchanged) return false;
47
+ await after(H);
48
+ watch(H, at.ws, r.id, m);
49
+ return true;
50
+ }
@@ -85,13 +85,13 @@ export function keepOrder(prev, items) {
85
85
  return prev.map((p) => by.get(p.id)).filter(Boolean);
86
86
  }
87
87
 
88
- const WORD = { ask: 'asks you', run: 'running', stop: 'stopped, open it to restart', done: 'finished, not read yet' };
88
+ const WORD = { ask: 'asks you', run: 'running', stop: 'stopped, open it to restart', done: 'finished, not read yet', away: 'put away, open it to bring it back' };
89
89
  /** The pill's name for a screen reader and its tooltip: what is live, by kind, then the key. */
90
90
  export function pillLabel(items, { mac = false } = {}) {
91
91
  const parts = [];
92
92
  const r = items.find((x) => x.kind === 'rec');
93
93
  if (r) parts.push((r.paused ? 'recording paused at ' : 'recording ') + r.time);
94
- for (const k of ['ask', 'run', 'stop', 'done']) {
94
+ for (const k of ['ask', 'run', 'stop', 'done', 'away']) {
95
95
  const n = items.filter((x) => x.mark === k).length;
96
96
  if (n) parts.push(n + ' ' + WORD[k]);
97
97
  }
@@ -99,6 +99,7 @@ export function pillLabel(items, { mac = false } = {}) {
99
99
  }
100
100
  /** One row's spoken name: its name, its state, when the PM last touched it, and "open now" for the one on screen. */
101
101
  export function rowLabel(x) {
102
+ if (x.kind === 'away') return x.name + ', ' + WORD.away; // a panel put away (cozy-panels.js): no time
102
103
  const st = x.kind === 'rec' ? (x.paused ? 'recording, paused' : 'recording') : WORD[x.mark];
103
104
  return x.name + ', ' + st + (x.kind === 'rec' ? ', ' + x.time : ', last touched ' + x.time) + (x.open ? ', open now' : '');
104
105
  }
@@ -0,0 +1,76 @@
1
+ /* pm/pn-narrow.js — a page's narrow form, keyed on its panel's width and not the window's (panels on Board and Intelligence, P-B; canvas
2
+ * In development BiB2Half, BiI2Half, sticky "What to build" item 3).
3
+ *
4
+ * The panels engine (cozy-panels.js) puts the class cz-pn-narrow on the page element while the page panel is narrower than the page's fit().
5
+ * The narrow form is the page's phone form, so the phone CSS stays the one source: for each of the page's own style sheets, every rule in a
6
+ * phone media block (max-width up to 760 px) is copied right after the block, scoped to the narrow page element and what is inside it; every
7
+ * rule in a desktop-only block (min-width 721 px or more) is narrowed so it does not match there. The cascade order and the specificity stay
8
+ * as written (:is() and :where()). The shell (the menu, the Live pill, popovers on the body) and the shared sheets keep their desktop look, and
9
+ * a phone is exactly as before, because the copies match only under the class.
10
+ *
11
+ * narrowForm({ page, sheets: RegExp, onChange?(narrow) }) → { narrow() } once, on the page. sheets: the hrefs of the page's own sheets
12
+ * (a sheet the page adds later is scoped when it loads). onChange runs when the class comes or goes. */
13
+ const N = '.cz-pn-narrow';
14
+ const IN = `:where(${N}, ${N} *)`, OUT = `:where(:not(${N}, ${N} *))`;
15
+ const PH = /\(max-width:\s*(\d+)px\)/, DESK = /\(min-width:\s*(\d+)px\)/;
16
+ const done = new WeakSet();
17
+
18
+ /** The top-level parts of a selector list (commas inside :is(), :not() and [..] stay put). */
19
+ function parts(sel) {
20
+ const out = []; let d = 0, q = '', cur = '';
21
+ for (const c of sel) {
22
+ if (q) { if (c === q) q = ''; cur += c; continue; }
23
+ if (c === '"' || c === "'") q = c;
24
+ else if (c === '(' || c === '[') d++;
25
+ else if (c === ')' || c === ']') d--;
26
+ else if (c === ',' && !d) { out.push(cur.trim()); cur = ''; continue; }
27
+ cur += c;
28
+ }
29
+ if (cur.trim()) out.push(cur.trim());
30
+ return out;
31
+ }
32
+ /** One selector with the guard added; a pseudo-element stays last, where it must be. */
33
+ function guard(one, g) {
34
+ const m = /(::[\w-]+(\([^)]*\))?(:[\w-]+)*|:(before|after|first-line|first-letter))$/.exec(one);
35
+ const base = m ? one.slice(0, m.index) : one, tail = m ? m[0] : '';
36
+ return `:is(${base || '*'})${g}${tail}`;
37
+ }
38
+ export const scoped = (sel, g = IN) => parts(sel).map((x) => guard(x, g)).join(', ');
39
+
40
+ /** A media block's kind: 'phone' (max-width up to 760 px, no min-width), 'desk' (min-width over 720 px), or null (left as it is). */
41
+ function kindOf(media) {
42
+ const t = String(media || ''), mx = PH.exec(t), mn = DESK.exec(t);
43
+ if (/print|orientation|prefers|hover|pointer/.test(t) && !mx && !mn) return null;
44
+ if (mx && !mn && +mx[1] <= 760) return 'phone';
45
+ if (mn && +mn[1] > 720 && +mn[1] <= 761) return 'desk';
46
+ return null;
47
+ }
48
+ function scopeSheet(sheet) {
49
+ if (!sheet || done.has(sheet)) return;
50
+ let R; try { R = sheet.cssRules; } catch { return; } // not ours (another origin) or not loaded yet
51
+ done.add(sheet);
52
+ for (let i = R.length - 1; i >= 0; i--) {
53
+ const r = R[i]; if (!(r instanceof CSSMediaRule)) continue;
54
+ const k = kindOf(r.conditionText || r.media.mediaText); if (!k) continue;
55
+ if (k === 'desk') { for (const s of r.cssRules) if (s instanceof CSSStyleRule) { try { s.selectorText = scoped(s.selectorText, OUT); } catch { /* left as written */ } } continue; }
56
+ const copies = [...r.cssRules].filter((s) => s instanceof CSSStyleRule && s.style.length).map((s) => `${scoped(s.selectorText)} { ${s.style.cssText} }`);
57
+ for (let j = copies.length - 1; j >= 0; j--) { try { sheet.insertRule(copies[j], i + 1); } catch { /* a selector this browser cannot read */ } }
58
+ }
59
+ }
60
+ const ours = (l, re) => !!(l && l.href && re.test(l.href));
61
+
62
+ export function narrowForm(o = {}) {
63
+ const page = o.page, re = o.sheets instanceof RegExp ? o.sheets : /$^/;
64
+ const each = () => [...document.styleSheets].forEach((s) => { if (ours(s, re)) scopeSheet(s); });
65
+ each();
66
+ // a sheet a module adds later (a panel's own CSS): scoped once it has loaded
67
+ new MutationObserver((ms) => ms.forEach((m) => m.addedNodes.forEach((n) => {
68
+ if (n.tagName === 'LINK' && ours(n, re)) { if (n.sheet) scopeSheet(n.sheet); else n.addEventListener('load', () => scopeSheet(n.sheet), { once: true }); }
69
+ }))).observe(document.head, { childList: true });
70
+ document.querySelectorAll('link[rel="stylesheet"]').forEach((l) => { if (ours(l, re) && !l.sheet) l.addEventListener('load', () => scopeSheet(l.sheet), { once: true }); });
71
+ let was = !!(page && page.classList.contains('cz-pn-narrow'));
72
+ if (page && typeof o.onChange === 'function') {
73
+ new MutationObserver(() => { const now = page.classList.contains('cz-pn-narrow'); if (now !== was) { was = now; o.onChange(now); } }).observe(page, { attributes: true, attributeFilter: ['class'] });
74
+ }
75
+ return { narrow: () => !!(page && page.classList.contains('cz-pn-narrow')) };
76
+ }
@@ -35,6 +35,7 @@ import * as PG from './bd-prog.js';
35
35
  import { programOf, liveRows } from './program-model.js';
36
36
  import { open as viewerOpen, current as viewerCur } from './cozy-viewer.js';
37
37
  import * as VW from './cozy-viewer.js';
38
+ import { mountPanels } from './cozy-panels.js';
38
39
  import * as PP from './bd-prog-panel.js';
39
40
  import * as PO from './prog-order.js';
40
41
  import * as SO from './sort-order.js';
@@ -44,11 +45,14 @@ import * as SM from './split-merge.js'; // split one initiative in two, or mer
44
45
  import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other)
45
46
  import * as Pop from './bd-pop.js'; // the order of a program's initiatives: the grip and Claude's order from the dates (canvas RoADrag, RoASuggest)
46
47
  import * as BI from './bd-ini-panel.js';
47
- import * as DL from './bd-deliveries.js'; // the Deliveries lane under the timeline's axis (batch 13 item 4, XcalmA6Lane)
48
+ import * as DL from './bd-deliveries.js';
49
+ import * as CO from './bd-cols.js'; // the timeline's columns, their menu and their sort (batch 19 item 5, StsA8Board) // the Deliveries lane under the timeline's axis (batch 13 item 4, XcalmA6Lane)
48
50
  import { nextHtml } from './bd-next.js';
49
51
  import { statusOf as ivStatus } from './ini-view-model.js';
50
52
  import { initiativeRename, taskRename } from './rename-press.js';
51
53
  import { setSay } from './cozy-xv.js';
54
+ import { narrowForm } from './pn-narrow.js';
55
+ import * as BP2 from './bd-pane.js'; // the Board as the first panel: fit(), the rows that open beside, the open row's mark
52
56
 
53
57
  const VIEW_KEY = 'pmos.board.view', PVIEW_KEY = 'pmos.board.pview', SPAN_KEY = 'pmos.board.span', GROUPING_KEY = 'pmos.board.grouping';
54
58
  let M = null; // the model
@@ -58,6 +62,7 @@ let pview = ['list', 'stages', 'track', 'time'].includes(store.get(PVIEW_KEY)) ?
58
62
  let span = SPANS.some(([k]) => k === store.get(SPAN_KEY)) ? store.get(SPAN_KEY) : 'quarter';
59
63
  let tab = 'ini';
60
64
  let readTimer = null;
65
+ let readTries = 0; // reads that answered "reading" in a row: the next ask waits longer each time
61
66
  let foldOpen = false; // the Monitor and Evaluate rows under the table
62
67
  let sprintSet = false; // "This sprint" starts on, once, when the board has a sprint
63
68
  const F = { chips: new Set(), q: '', owners: new Set(), cats: new Set(), sprints: new Set() }; // the chip filters, Find and Filter (the workflow is pm/bd-wf.js picked())
@@ -77,6 +82,10 @@ let DM = {}; // the documents' history (GET /api/board-docs
77
82
  let peek = null; // what the Viewer shows for the Board: { kind: 'ini', key } an initiative or its ticket, { kind: 'acts' } an acts panel
78
83
  mountNav('board');
79
84
  mountLivePill();
85
+ /* The page is the first panel (panels on Board and Intelligence, canvas BiB1Split): a Viewer opens beside it, behind the divider. A row's
86
+ * name drags beside, or ⌘/Ctrl-click opens it beside (a By stage card's drag moves the stage, so it is no source). fit(): the width the
87
+ * view needs whole, so the Viewer opens no wider than that leaves. */
88
+ mountPanels({ page: document.getElementById('stage'), key: 'board', sources: BP2.SOURCES, fit: BP2.fit });
80
89
  // a product head's goal dots (PgBoard .gd) count that product's open initiatives, the way Home's product header does
81
90
  PG.goalsFrom((name) => (M ? M.initiatives.list.rows.filter((r) => !M.board.all || r.product === name) : null));
82
91
  const SV = (d) => `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
@@ -93,6 +102,13 @@ const ago = (iso, short) => { const t = Date.parse(iso || ''); if (!t) return ''
93
102
  const isoDate = (iso) => { const x = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return x ? new Date(+x[1], +x[2] - 1, +x[3]) : null; };
94
103
  const fmt = (iso) => { const d = isoDate(iso); return d ? md(d) : ''; };
95
104
  const PHONE = matchMedia('(max-width: 720px)');
105
+ /* The narrow form (panels on Board and Intelligence, BiB2Half): while the page panel is narrower than its view needs, the Board draws its phone
106
+ * form (pm/pn-narrow.js keys the phone CSS on the class). It keeps its own view, List first, and is never stored: a wider panel goes back to
107
+ * the desktop's view. A phone is as before. */
108
+ let nview = 'list';
109
+ const NF = narrowForm({ page: $('#stage'), sheets: /\/pm\/(cozy-board|bd-[\w-]+)\.css(\?|$)/, onChange: () => { if (M) { drawChips(); drawInit(); } } });
110
+ const narrow = () => !PHONE.matches && NF.narrow();
111
+ const small = () => PHONE.matches || narrow();
96
112
  const goneRows = () => { const G = (M && M.initiatives && M.initiatives.gone) || {}; return [...(G.cancelled || []), ...(G.archived || [])]; };
97
113
  const rowOf = (key) => (M && M.rows || []).find((r) => r.key === key) || goneRows().find((r) => r.key === key) || null;
98
114
  /** The rows on screen grouped (pm/bd-prog.js groupsOf): programs first, then the product; or By product. null when no program holds a row here. */
@@ -135,7 +151,7 @@ function actsPanel(html, from, cls, o = {}) {
135
151
  const body = VW.body(); body.className = 'cz-vw-body bd-actsvw' + (cls ? ' ' + cls : ''); body.innerHTML = inner; return;
136
152
  }
137
153
  const more = tools.map((a) => ({ label: a.getAttribute('aria-label') || a.textContent.trim(), on: () => location.assign(a.getAttribute('href')) }));
138
- const back = !!(from && from.closest && from.closest('#czViewer')) && VW.isOpen();
154
+ const back = !!(from && from.closest && from.closest('.cz-vw')) && VW.isOpen();
139
155
  const me = { id, onClose: o.onClose || null };
140
156
  VW.open({ kind: eye || 'Board', title: title || eye, icon: 'flag', id, back, more: more.length ? more : undefined,
141
157
  render: (body) => {
@@ -221,10 +237,10 @@ let jiraReading = false; // a press is reading Jira again: the chip's Adler we
221
237
  const CHIP_F = [['late', 'late', 'm-warn', (n) => n + ' late'], ['risk', 'risk', 'm-warn', (n) => n + ' at risk'], ['blocked', 'red', 'm-crit', (n) => n + ' blocked'], ['idle', 'q', '', (n) => n + ' idle 30+ days']];
222
238
  /** The sprint filter (the "Sprint N only" chip and Filter's Sprint group) shows on the Sprint span only among the timeline's spans (TsSprintFilter);
223
239
  * the stage track keeps its chip. */
224
- const curView = () => (PHONE.matches ? pview : view);
240
+ const curView = () => (PHONE.matches ? pview : narrow() ? nview : view);
225
241
  const sprintFilterOn = () => curView() !== 'time' || span === 'sprint';
226
242
  function drawChips() {
227
- const J = M.jira || {}, C = M.chips || {}, sp = J.sprint, rel = J.release, phone = PHONE.matches;
243
+ const J = M.jira || {}, C = M.chips || {}, sp = J.sprint, rel = J.release, phone = small();
228
244
  const jira = J.readAt ? (phone ? 'Jira ' + ago(J.readAt, true) : 'Jira · read ' + ago(J.readAt)) : phone ? 'Jira not read' : 'Jira · not read';
229
245
  const sprint = [sp ? sp.name : null, rel ? rel.name + ' ships ' + rel.at.replace(/^(\d+) (\w+)$/, '$2 $1') : null].filter(Boolean).join(' · ') || 'No sprint on record';
230
246
  const asks = C.asks == null ? 'New asks · not read' : null;
@@ -315,7 +331,7 @@ function visible() {
315
331
  if (F.chips.has('risk') && r.status !== 'at risk') return false;
316
332
  if (F.chips.has('blocked') && !t.blocked) return false;
317
333
  if (F.chips.has('idle') && t.idle == null) return false;
318
- if (F.chips.has('sprint') && sp && (view === 'track' || view === 'time' || PHONE.matches) && sprintFilterOn() && !inSprint(r, sp)) return false;
334
+ if (F.chips.has('sprint') && sp && (view === 'track' || view === 'time' || small()) && sprintFilterOn() && !inSprint(r, sp)) return false;
319
335
  if (F.q && !String(r.title || '').toLowerCase().includes(F.q.toLowerCase())) return false;
320
336
  if (F.owners.size && !F.owners.has(r.owner || 'No owner')) return false;
321
337
  if (F.cats.size && !F.cats.has(WF.catOfRow(r))) return false;
@@ -331,7 +347,7 @@ const wfState = () => { const list = WF.workflowsOf(M); return { list, cur: WF.p
331
347
  function showingHtml(n) {
332
348
  const G = [['owners', 'Owner'], ['cats', 'Category'], ['sprints', 'Sprint']].filter(([k]) => F[k].size);
333
349
  // the picked workflow shows here only where no chip row says it already: the desktop List (WfAElse)
334
- const W = wfState(), wfOn = WF.narrowed(W.list) && view === 'list' && !PHONE.matches;
350
+ const W = wfState(), wfOn = WF.narrowed(W.list) && view === 'list' && !small();
335
351
  if (!G.length && !F.q && !wfOn) return '';
336
352
  const word = (k, v) => (k === 'cats' ? WF.catLabel(v) : v);
337
353
  const chips = (wfOn ? `<button type="button" class="bd-chip on" data-unf="wf" aria-label="Remove Workflow: ${esc(W.cur.name)}">Workflow: ${esc(W.cur.name)}${SV(I.x)}</button>` : '')
@@ -407,7 +423,7 @@ function trackRow(r, cls = '', po = false) {
407
423
  return `<div class="bt-r bt-l${cls}${peek && peek.key === r.key && peek.kind !== 'acts' ? ' sel' : ''}${r.acts && r.acts.life === 'hold' ? ' held' : ''}" role="row" data-row="${esc(r.key)}"${po ? ` data-po-id="${esc(r.id)}"` : ''}>${po ? PO.gripHtml(r.title) : ''}`
408
424
  + `<button type="button" class="ini2 bt-nm" data-key="${esc(r.key)}" role="rowheader" aria-haspopup="dialog"><b>${r.inProgram ? PG.memberIcon(PGS, r.inProgram) : ''}${many ? WF.wfIcon(WF.wfOf(r), 18) : ''}${SM.nameHtml(r)}</b><span class="cs s-${s.tone}"><i class="cz-dot ${s.tone}"></i>${esc(s.text)}</span><span class="bt-pst">${t.ms ? '<i class="cz-ms" aria-hidden="true"></i>' : ''}${esc(t.label)} · ${DAYS(t)}</span></button>`
409
425
  + `<div class="${cellsCls()}" role="presentation"${cellsStyle()}>${cells}</div>`
410
- + `<div class="bt-dl" role="cell">${nextHtml(r, { self: M.board.self, icon: !PHONE.matches })}</div></div>`; // the Next cell (XocA): what finishes the step next
426
+ + `<div class="bt-dl" role="cell">${nextHtml(r, { self: M.board.self, icon: !small() })}</div></div>`; // the Next cell (XocA): what finishes the step next
411
427
  }
412
428
  const cellsCls = () => 'bt-cells' + (TK.mode === 'cats' ? ' bands' : TK.mode === 'wf' ? ' wfn' : '');
413
429
  const cellsStyle = () => (TK.mode === 'wf' ? ` style="--n:${Math.max(1, TK.steps.length)}"` : '');
@@ -453,14 +469,18 @@ function drawTrack(L) {
453
469
  }).join('')}</div>` : own(prodKey((M.board && (M.board.product || M.board.name)) || ''), shown.map((r) => trackRow(r, '', true)).join(''));
454
470
  const rest = G ? Math.max(0, meTotal - sorted.filter(isME).length) : more; // grouped: the ones not loaded here
455
471
  const tf2 = !G ? tf : rest > 0 && !foldOpen && !inGroups ? `<button type="button" class="dlink" id="fold" aria-expanded="false">${SV(I.chev)}${rest} more in Monitor and Evaluate</button>` : foldOpen && meTotal > 1 ? tf : '<span></span>';
456
- return `<div class="bt" role="table" aria-label="Initiatives by stage">${head}${rows}<div class="bt-tf">${tf2}</div>${PHONE.matches ? `<div class="bd-whead bd-phx"><span class="bd-phb"><button type="button" class="bd-chip" data-steps aria-haspopup="dialog">What finishes each step</button><button type="button" class="bd-chip" data-open="metrics" aria-haspopup="dialog">Metrics</button><button type="button" class="bd-chip" data-open="gone" aria-haspopup="dialog">Cancelled and archived</button></span></div>` : ''}</div>`; // the phone has no step heads: a plain entry to the steps help
472
+ return `<div class="bt" role="table" aria-label="Initiatives by stage">${head}${rows}<div class="bt-tf">${tf2}</div>${small() ? `<div class="bd-whead bd-phx"><span class="bd-phb"><button type="button" class="bd-chip" data-steps aria-haspopup="dialog">What finishes each step</button><button type="button" class="bd-chip" data-open="metrics" aria-haspopup="dialog">Metrics</button><button type="button" class="bd-chip" data-open="gone" aria-haspopup="dialog">Cancelled and archived</button></span></div>` : ''}</div>`; // the phone has no step heads: a plain entry to the steps help
457
473
  }
458
474
 
459
475
  /* ── the timeline (AgBoardTimeline; TsCOpen, TsCDesk, TsAllSpans, TsCPhone) ───────────────────────────────────────── */
476
+ let colsFit = 0; // how many columns the timeline drew; the Board redraws when its width fits another count
460
477
  function drawTime(L) {
461
- const S = M.steps || [], phone = PHONE.matches, bw = $('#ibBody').clientWidth || innerWidth;
478
+ const S = M.steps || [], phone = small(), bw = $('#ibBody').clientWidth || innerWidth;
479
+ const cols = phone ? null : CO.colsFor(bw - 2, { avatar: (n) => V.avatar(n, 'sm') });
480
+ colsFit = cols ? cols.keys.length : 1;
481
+ const nameW = cols ? cols.nw : phone ? 0 : matchMedia('(max-width: 980px)').matches ? 180 : 250;
462
482
  const T = timelineHtml(L, M, span, { groups: groups(L), progState, folded: PG.folded, prodHtml: (g) => PG.prodHtml(g, 'tg-prd'), prodCell: (g, dots) => PG.prodCell(g, dots), msMode: msMode(), subHtml: (n) => PG.subHtml(n, 'tg-psb'), progTile: () => PG.progTile(), productsOf: PG.productsOf,
463
- foldBtn: (g) => PG.foldBtn(g.key, g.program.title), memberIcon: (id) => PG.memberIcon(PGS, id), sel: peek && peek.kind !== 'acts' ? peek.key : null, status: statusOf, phone, trackPx: bw - 2 - (phone ? 0 : matchMedia('(max-width: 980px)').matches ? 180 : 250), avatar: (n) => V.avatar(n, 'sm'),
483
+ foldBtn: (g) => PG.foldBtn(g.key, g.program.title), memberIcon: (id) => PG.memberIcon(PGS, id), sel: peek && peek.kind !== 'acts' ? peek.key : null, status: statusOf, phone, cols, trackPx: bw - 2 - nameW, avatar: (n) => V.avatar(n, 'sm'),
464
484
  askHref: (none) => askHref(null, 'Propose start and end dates for ' + none.map((r) => r.title).join(', ')),
465
485
  lane: (c) => DL.laneHtml(c, { span, progState }) });
466
486
  return T.html;
@@ -469,7 +489,7 @@ function drawTime(L) {
469
489
  const phoneSeg = (v) => `<div class="bd-phseg"><div class="bd-seg" role="group" aria-label="View">${[['list', 'List'], ['stages', 'By stage'], ['track', 'Track'], ['time', 'Timeline']].map(([k, n]) => `<button type="button" data-pv="${k}" aria-pressed="${v === k}">${n}</button>`).join('')}</div></div>`;
470
490
  function drawInit() {
471
491
  $('#nIni').textContent = String(M.initiatives.open || M.initiatives.list.rows.length);
472
- const phone = PHONE.matches, L = visible(), v = phone ? pview : view;
492
+ const phone = small(), L = visible(), v = curView();
473
493
  const body = $('#ibBody');
474
494
  body.dataset.view = v; body.dataset.span = v === 'time' ? span : '';
475
495
  const html = v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
@@ -478,17 +498,23 @@ function drawInit() {
478
498
  // the workflow chips (WfABoard, WfATrack, WfAPhone): By stage and the track on a desktop, every view on a phone; the List filters in Filter
479
499
  const W = wfState(), wfc = phone || v === 'stages' || v === 'track' ? WF.chipsHtml(W.list, W.cur, { phone }) : '';
480
500
  if (v === 'time') TL.hold(); else TL.forget();
501
+ // a row with the focus keeps it when the rows are drawn again (the page panel changes form as a Viewer opens or closes beside it)
502
+ const fe = document.activeElement, fk = fe && body.contains(fe) && fe.matches('[data-key]') ? fe.dataset.key : null;
481
503
  body.innerHTML = (phone ? phoneSeg(v) : '') + wfc + html + phx;
504
+ if (fk) { const n = $$('#ibBody [data-key]').find((x) => x.dataset.key === fk); if (n) n.focus({ preventScroll: true }); }
482
505
  if (v === 'time') TL.mount(body);
483
506
  $('#bdShowing').innerHTML = showingHtml(L.length); $('#bdShowing').hidden = !$('#bdShowing').innerHTML;
484
507
  $$('#ibTabs [data-v]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.v === v)));
485
508
  { const sb = $('#bdSort'), Ls = SO.labels(); if (sb) { sb.setAttribute('aria-label', Ls.aria); sb.title = Ls.title; sb.classList.toggle('on', Ls.on); } }
486
509
  $('#bdView').innerHTML = SV(v === 'time' ? I.time : I.track); $('#bdView').setAttribute('aria-label', 'Change view. Now: ' + (v === 'time' ? 'Timeline' : 'Stage track'));
487
510
  $('#bdSpans').hidden = v !== 'time' || phone;
511
+ $('#bdColsw').hidden = v !== 'time' || phone; if ($('#bdColsw').hidden) closeCols();
488
512
  $$('#bdSpans [data-sp]').forEach((b) => b.setAttribute('aria-pressed', String(b.dataset.sp === span)));
489
513
  drawSpanPick(phone && v === 'time');
490
514
  document.body.dataset.bdView = v;
515
+ $('#stage').dataset.bdDesk = view; // what fit() measures: the desktop's view, so the narrow form never flips it back and forth
491
516
  drawGrouping();
517
+ markOpen();
492
518
  }
493
519
  PHONE.addEventListener('change', () => { if (M) { drawChips(); drawInit(); } });
494
520
  /** The grouping (PgBoard, PgBoardProduct): programs first is the default and draws nothing in the toolbar (PgBoard); the choice is in Filter.
@@ -509,9 +535,26 @@ $('#bdGrpw').addEventListener('click', (e) => {
509
535
  });
510
536
  document.addEventListener('click', (e) => { if (!e.target.closest('#bdGrpw')) { const m = $('#bdGrpMenu'); if (m && !m.hidden) { m.hidden = true; $('#bdGroup').setAttribute('aria-expanded', 'false'); } } });
511
537
  $('#bdGrpw').addEventListener('keydown', (e) => { if (e.key === 'Escape') { const m = $('#bdGrpMenu'); if (m && !m.hidden) { e.stopPropagation(); m.hidden = true; $('#bdGroup').setAttribute('aria-expanded', 'false'); $('#bdGroup').focus(); } } });
512
- function setView(v) { if (PHONE.matches) { pview = v; store.set(PVIEW_KEY, v); } else { view = v; store.set(VIEW_KEY, view); } closePanel(); drawChips(); drawInit(); }
538
+ /* the Columns menu (StsA8Board): a check box per column, Initiative always on; the choice is remembered (pm/bd-cols.js) */
539
+ function closeCols(back) { const m = $('#bdColsMenu'); if (!m || m.hidden) return false; m.hidden = true; $('#bdCols').setAttribute('aria-expanded', 'false'); if (back) $('#bdCols').focus(); return true; }
540
+ $('#bdCols').addEventListener('click', () => {
541
+ const m = $('#bdColsMenu'), o = m.hidden;
542
+ if (!o) { closeCols(); return; }
543
+ m.innerHTML = CO.menuHtml(); m.hidden = false; $('#bdCols').setAttribute('aria-expanded', 'true');
544
+ const f = m.querySelector('input:not([disabled])'); if (f) f.focus();
545
+ });
546
+ $('#bdColsMenu').addEventListener('change', (e) => { const c = e.target.closest('[data-tcol]'); if (!c) return; CO.setOn(c.dataset.tcol, c.checked); if (M) drawInit(); });
547
+ $('#bdColsw').addEventListener('keydown', (e) => { if (e.key === 'Escape' && closeCols(true)) e.stopPropagation(); });
548
+ document.addEventListener('click', (e) => { if (!e.target.closest('#bdColsw')) closeCols(); });
549
+ /* a narrower or wider Board fits another number of columns: redraw the timeline then, and only then */
550
+ new ResizeObserver(() => {
551
+ if (!M || curView() !== 'time' || small()) return;
552
+ const c = CO.colsFor(($('#ibBody').clientWidth || innerWidth) - 2);
553
+ if ((c ? c.keys.length : 1) !== colsFit) drawInit();
554
+ }).observe($('#ibBody'));
555
+ function setView(v) { if (PHONE.matches) { pview = v; store.set(PVIEW_KEY, v); } else if (narrow()) nview = v; else { view = v; store.set(VIEW_KEY, view); } if (!narrow()) closePanel(); drawChips(); drawInit(); }
513
556
  $('#ibTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-v]'); if (!b || !M) return; setTab('ini'); setView(b.dataset.v); });
514
- $('#bdView').addEventListener('click', () => { if (M) setView(PHONE.matches ? (pview === 'list' ? 'stages' : pview === 'stages' ? 'track' : pview === 'track' ? 'time' : 'list') : view === 'time' ? 'track' : 'time'); });
557
+ $('#bdView').addEventListener('click', () => { if (M) { const c = curView(); setView(small() ? (c === 'list' ? 'stages' : c === 'stages' ? 'track' : c === 'track' ? 'time' : 'list') : view === 'time' ? 'track' : 'time'); } });
515
558
  $('#bdShowing').addEventListener('click', (e) => {
516
559
  if (e.target.closest('#fClear')) { clearFilters(); drawChips(); drawInit(); return; }
517
560
  const u = e.target.closest('[data-unf]'); if (!u) return;
@@ -543,6 +586,7 @@ $('#ibBody').addEventListener('click', (e) => {
543
586
  const cf = e.target.closest('[data-colfold]'); if (cf) { const k = cf.dataset.colfold; V.toggleCol(k); drawInit(); const b = $$('#ibBody [data-colfold]').find((x) => x.dataset.colfold === k); if (b) b.focus(); return; }
544
587
  if (e.target.closest('#fClear')) { clearFilters(); drawChips(); drawInit(); return; }
545
588
  const pv = e.target.closest('[data-pv]'); if (pv) { setView(pv.dataset.pv); const b = $(`#ibBody [data-pv="${pv.dataset.pv}"]`); if (b) b.focus(); return; }
589
+ const ts = e.target.closest('[data-tsort]'); if (ts) { const k = ts.dataset.tsort; CO.setSort(CO.sorted() === k ? null : k); drawInit(); const b = $(`#ibBody [data-tsort="${k}"]`); if (b) b.focus(); return; }
546
590
  const so = e.target.closest('[data-sort]'); if (so) { V.setSort(so.dataset.sort); drawInit(); const b = $(`#ibBody [data-sort="${so.dataset.sort}"]`); if (b) b.focus(); return; }
547
591
  if (e.target.closest('[data-me]')) { V.toggleME(); drawInit(); const b = $('#ibBody [data-me]'); if (b) b.focus(); return; }
548
592
  const nx = e.target.closest('[data-nx]'); if (nx) { nextAct(nx); return; }
@@ -557,11 +601,11 @@ $('#ibBody').addEventListener('click', (e) => {
557
601
  const mc = e.target.closest('[data-ms-row]'); if (mc) { msPop(mc, rowOf(mc.dataset.msRow), mc.dataset.msIds.split(' ')); return; }
558
602
  // a product lane's counted ◇ lists its milestones with their initiatives; on a phone a tap on the lane lists them all in a sheet (batch 11 item 17)
559
603
  const ml = e.target.closest('[data-ms-lane]'); if (ml) { lanePop(ml, ml.dataset.msLane, ml.dataset.laneName); return; }
560
- const pl = PHONE.matches && e.target.closest('.tgq-r.tg-lane > .tg-p[data-lane-ms]'); if (pl) { lanePop(pl, pl.dataset.laneMs, pl.dataset.laneName); return; }
604
+ const pl = small() && e.target.closest('.tgq-r.tg-lane > .tg-p[data-lane-ms]'); if (pl) { lanePop(pl, pl.dataset.laneMs, pl.dataset.laneName); return; }
561
605
  // a gap's press (batch 11 item 13): its words, and + New task with its dates while part of it is ahead
562
606
  const gp = e.target.closest('[data-gap]'); if (gp) { gapPop(gp, rowOf(gp.dataset.gap)); return; }
563
607
  // the phone's row sheet lists the milestones, the gaps and the skipped stages in date order (XmlA5Phone, XgapA3Phone)
564
- const lane = PHONE.matches && e.target.closest('.tgq-r[data-row] > .tg-p'); if (lane) { const r = rowOf(lane.parentElement.dataset.row); if (r && ((r.milestones || []).length || plainGaps(r).length || skipsOf(r).length)) { msPop(lane, r, null, true); return; } }
608
+ const lane = small() && e.target.closest('.tgq-r[data-row] > .tg-p'); if (lane) { const r = rowOf(lane.parentElement.dataset.row); if (r && ((r.milestones || []).length || plainGaps(r).length || skipsOf(r).length)) { msPop(lane, r, null, true); return; } }
565
609
  const b = e.target.closest('[data-key]'); if (b) openIni(rowOf(b.dataset.key), b, view === 'time' ? 'time' : 'track');
566
610
  });
567
611
  DL.wire($('#ibBody'), { redraw: () => drawInit() }); // the Deliveries lane: hover links the row, the fold is remembered
@@ -626,7 +670,7 @@ async function turnProgram(r) {
626
670
  /** The ⋯ "Program" entry (pm/prog-move.js programItem, batch 16 item 5c): move, leave, join or make a program. The rows stay; the panel stays on it. */
627
671
  function moveItems(r) {
628
672
  return [PM.programItem({ programs: () => PGS, ws: r.ws || M.board.ws || '', id: r.id, product: r.product || M.board.product || M.board.name || '', pmPost, say,
629
- reload: async () => { await loadPrograms(); load(); }, phone: () => PHONE.matches, stateOf: (p) => progState(p), openList: moveList,
673
+ reload: async () => { await loadPrograms(); load(); }, phone: () => small(), stateOf: (p) => progState(p), openList: moveList,
630
674
  turn: M.board.self ? null : () => turnProgram(r) })].filter(Boolean);
631
675
  }
632
676
  /** Split or merge (pm/split-merge.js; canvas XsmA1Menu, XsmA1Suggest): the context of one row. After the write the Board reads again and the
@@ -768,19 +812,25 @@ function gapPop(anchor, r) {
768
812
  }
769
813
 
770
814
  /** The Viewer shows an initiative of this board: its row is marked. */
771
- function iniShown(key) {
772
- peek = { kind: 'ini', key };
773
- $$('#ibBody [data-row]').forEach((x) => x.classList.toggle('sel', x.dataset.row === key));
774
- $$('#ibBody .tgp-r').forEach((x) => x.classList.toggle('sel', x.dataset.key === key));
775
- }
815
+ function iniShown(key) { peek = { kind: 'ini', key }; markOpen(); }
776
816
  function iniHidden() {
777
817
  if (!peek || peek.kind !== 'ini') return;
778
- peek = null; $$('#ibBody .sel').forEach((x) => x.classList.remove('sel'));
818
+ peek = null; markOpen();
779
819
  }
820
+ /** The open rows are marked blue in every view, the narrow form too (BiB1Split, BiB2Half): the initiative the Viewer shows (or the ticket of
821
+ * it), and with several Viewers each initiative one of them shows. */
822
+ function markOpen() {
823
+ const keys = new Set(BP2.openKeys(VW.panels.list(), M ? [...(M.rows || []), ...goneRows()] : [], BI.vidOf));
824
+ if (peek && peek.kind === 'ini') keys.add(peek.key);
825
+ $$('#ibBody [data-row]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.row)));
826
+ $$('#ibBody .tgp-r, #ibBody .bd-lrow[data-key], #ibBody .bd-bc[data-key]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.key)));
827
+ }
828
+ VW.onChange(() => markOpen());
829
+ BP2.wire();
780
830
  /** A linked document opens in the Viewer: GET /api/doc, shown as its text, and drawn again when the file changes (pm/doc-follow.js). */
781
831
  document.addEventListener('click', (e) => {
782
832
  const d = e.target.closest('[data-doc]'); if (!d || !M) return;
783
- const path = d.dataset.doc, ws = M.board.ws || '', inVw = !!d.closest('#czViewer');
833
+ const path = d.dataset.doc, ws = M.board.ws || '', inVw = !!d.closest('.cz-vw');
784
834
  viewerOpen({ kind: 'Document', title: path.split('/').pop(), icon: 'doc', id: 'doc:' + path, back: inVw, render: async (body) => {
785
835
  body.innerHTML = '<p class="bd-amut">Reading the document…</p>';
786
836
  await followDoc({ ws, path, alive: () => body.isConnected && !!viewerCur() && viewerCur().id === 'doc:' + path,
@@ -836,7 +886,7 @@ const docMeta = (p, ws) => { const d = DM[(ws || (M && M.board.ws) || '') + ':'
836
886
  $$('#moreMenu [data-open]').forEach((b) => { b.onclick = () => { if (M) Acts.open[b.dataset.open]($('#moreBtn')); }; });
837
887
  }
838
888
  window.addEventListener('keydown', (e) => {
839
- if (e.key !== 'Escape' || document.querySelector('.pv-ov:not([hidden]), #moreMenu:not([hidden]), #crMenu:not([hidden]), #czMenu:not([hidden]), #bdPop:not([hidden]), #bdGrpMenu:not([hidden])')) return;
889
+ if (e.key !== 'Escape' || document.querySelector('.pv-ov:not([hidden]), #moreMenu:not([hidden]), #crMenu:not([hidden]), #czMenu:not([hidden]), #bdPop:not([hidden]), #bdGrpMenu:not([hidden]), #bdColsMenu:not([hidden])')) return;
840
890
  if ($$('.bd-pop').some((p) => !p.hidden)) closePops(true); // the shell closes itself on Escape (cozy-viewer.js)
841
891
  }, true);
842
892
 
@@ -971,7 +1021,8 @@ async function load() {
971
1021
  const reading = () => {
972
1022
  const t0 = Date.now(), tick = () => { const s = 'Reading the board · ' + Math.round((Date.now() - t0) / 1000) + ' s so far'; $('#snap').textContent = s; if (!M) $('#ibBody').innerHTML = `<p class="bd-msg"><b>${esc(s)}</b> The board derives each initiative from its records. This page shows nothing until it has read, rather than guess.</p>`; };
973
1023
  tick(); readTimer = setInterval(tick, 1000);
974
- setTimeout(load, 3000);
1024
+ // a first read after a restart usually lands within a second: ask again soon, then less often (page-speed)
1025
+ setTimeout(load, Math.min(3000, 300 * 2 ** readTries++));
975
1026
  };
976
1027
  if (!(await resolvePick())) { clearInterval(readTimer); reading(); return; }
977
1028
  const p = new URLSearchParams(location.search), [pw, pb] = PICK.length > 1 ? PICK[0].split('|') : ONE ? ONE.split('|') : [p.get('ws'), p.get('board')], q = [pw ? 'ws=' + encodeURIComponent(pw) : '', pb ? 'board=' + encodeURIComponent(pb) : ''].filter(Boolean).join('&');
@@ -984,7 +1035,7 @@ async function load() {
984
1035
  setTimeout(load, 15000);
985
1036
  return;
986
1037
  }
987
- M = r.model; jiraReading = false; holdNames(); draw();
1038
+ M = r.model; readTries = 0; jiraReading = false; holdNames(); draw();
988
1039
  focusOnce(); programOnce(); newOnce(); loadOthers(); loadWorkflows();
989
1040
  if (r.stale) setTimeout(load, 2000); // a press is still being derived: ask again
990
1041
  else { loadTrail(); loadGrill(); }
@@ -1045,15 +1096,17 @@ function openTask(r, k) {
1045
1096
  }
1046
1097
  /** A new task from the initiative view's + (the same box Home's page draws): POST /api/boards/tasks/add. → true when it was added.
1047
1098
  * section: the stage it finishes (the Next cell's +, "Add what finishes <stage>"): the task is placed under it (POST /api/boards/tasks/edit). */
1048
- async function addTask(r, title, section, dates) {
1099
+ async function addTask(r, title, section, dates, name) {
1049
1100
  const body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id };
1050
- const res = await pmPost('/api/boards/tasks/add', { ...body, initiative: r.id, title }).catch(() => null);
1101
+ // dates: a gap's + (batch 11 item 13) fills the task's start and due with the gap's days ahead; section: the stage it goes under (the
1102
+ // add route places it, batch 18 item 16)
1103
+ const res = await pmPost('/api/boards/tasks/add', { ...body, initiative: r.id, title, ...(dates && dates.start ? { start: dates.start } : {}), ...(dates && dates.due ? { due: dates.due } : {}), ...(section ? { section } : {}) }).catch(() => null);
1051
1104
  if (!res || res.ok === false) { say((res && res.error) || 'The task was not added.'); return false; }
1052
1105
  const uid = res.item && res.item.uid;
1053
- // dates: a gap's + (batch 11 item 13) fills the task's start and due with the gap's days ahead
1054
- if (dates && uid) { const s1 = await pmPost('/api/boards/tasks/edit', { ...body, task: uid, start: dates.start, due: dates.due }).catch(() => null); if (!s1 || s1.ok === false) { say('Task added, but not its dates: ' + ((s1 && s1.error) || 'the server did not say why') + '.'); load(); return true; } }
1055
- if (section && uid) { const s2 = await pmPost('/api/boards/tasks/edit', { ...body, task: uid, section }).catch(() => null); if (!s2 || s2.ok === false) { say('Task added, but not under its stage: ' + ((s2 && s2.error) || 'the server did not say why') + '.'); load(); return true; } }
1056
- say('Task added.'); load();
1106
+ // the + on a stage (batch 18 item 16, StA5Add): "Added to Build" with Undo
1107
+ if (name && uid) say('Added to ' + name + '.', async () => { const u = await pmPost('/api/boards/tasks/delete', { ...body, task: uid, why: 'undo of add' }).catch(() => null); if (!u || u.ok === false) say((u && u.error) || 'The undo did not land.'); load(); });
1108
+ else say('Task added.');
1109
+ load();
1057
1110
  return true;
1058
1111
  }
1059
1112
  /** The Next cell's icon (pm/bd-next.js): draft with Claude in Home's chat, move to the next stage, add a task to the stage, link the epic, read Jira. */