create-pmos 0.610.0 → 0.611.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 (114) hide show
  1. package/package.json +50 -14
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/board-columns-test.js +2 -1
  7. package/workspace/board-deliveries-test.js +2 -1
  8. package/workspace/board-programs-test.js +7 -3
  9. package/workspace/board-publish-ui-test.js +2 -1
  10. package/workspace/board-shared-ui-test.js +2 -1
  11. package/workspace/board-workflows-test.js +2 -1
  12. package/workspace/briefing-premium-board-test.js +3 -2
  13. package/workspace/briefing-premium-doc-edit-test.js +2 -1
  14. package/workspace/briefing-premium-insights-test.js +4 -3
  15. package/workspace/briefing-premium-test.js +3 -2
  16. package/workspace/calm-timeline-test.js +2 -1
  17. package/workspace/changelog.json +49 -0
  18. package/workspace/core-docs-workflow-test.js +2 -1
  19. package/workspace/ev-everywhere-test.js +3 -2
  20. package/workspace/guide/home.md +2 -2
  21. package/workspace/guide/index.md +4 -0
  22. package/workspace/guide/layout.md +62 -2
  23. package/workspace/guide/programs.md +16 -2
  24. package/workspace/guide/routine.md +50 -0
  25. package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
  26. package/workspace/guide/settings-and-switches.md +1 -1
  27. package/workspace/impact-screens-test.js +3 -1
  28. package/workspace/ini-workflow-test.js +2 -1
  29. package/workspace/lib/classic-board.js +15 -0
  30. package/workspace/lib/events-place.js +216 -0
  31. package/workspace/lib/library-items.js +78 -0
  32. package/workspace/lib/notes.js +6 -1
  33. package/workspace/lib/route-modules.js +4 -0
  34. package/workspace/lib/routes-events-place.js +166 -0
  35. package/workspace/lib/routes-library.js +89 -0
  36. package/workspace/lib/routes-pop-work.js +39 -0
  37. package/workspace/lib/routes-report-setups.js +20 -0
  38. package/workspace/lib/routes-today-log.js +48 -0
  39. package/workspace/lib/routine-reports.js +52 -0
  40. package/workspace/lib/today-log.js +131 -0
  41. package/workspace/live-pill-round-test.js +10 -7
  42. package/workspace/metric-drafts-ui-test.js +3 -1
  43. package/workspace/milestone-pins-test.js +2 -1
  44. package/workspace/milestone-suggest-test.js +3 -1
  45. package/workspace/package-lock.json +2 -2
  46. package/workspace/package.json +1 -1
  47. package/workspace/panels-test.js +2 -1
  48. package/workspace/premium-board-actions-test.js +3 -1
  49. package/workspace/premium-rec-tab-test.js +2 -1
  50. package/workspace/premium-vw-backlog-test.js +3 -1
  51. package/workspace/premium-vw-item-test.js +3 -1
  52. package/workspace/premium-vw-jira-test.js +3 -1
  53. package/workspace/product-lane-test.js +2 -1
  54. package/workspace/program-charter-test.js +3 -1
  55. package/workspace/program-leave-test.js +2 -1
  56. package/workspace/program-order-test.js +2 -1
  57. package/workspace/program-panel-test.js +3 -1
  58. package/workspace/public/pm/bd-ini-panel.js +72 -7
  59. package/workspace/public/pm/bd-prog-panel.js +55 -8
  60. package/workspace/public/pm/bd-work.css +130 -0
  61. package/workspace/public/pm/bd-work.js +356 -0
  62. package/workspace/public/pm/cozy-ev.css +2 -1
  63. package/workspace/public/pm/cozy-events-view.js +142 -0
  64. package/workspace/public/pm/cozy-events.css +107 -0
  65. package/workspace/public/pm/cozy-events.js +210 -0
  66. package/workspace/public/pm/cozy-evmodel.js +1 -1
  67. package/workspace/public/pm/cozy-library.css +36 -0
  68. package/workspace/public/pm/cozy-live-pill.js +1 -0
  69. package/workspace/public/pm/cozy-nav.js +5 -5
  70. package/workspace/public/pm/cozy-pop-work.css +165 -0
  71. package/workspace/public/pm/cozy-pop-work.js +427 -0
  72. package/workspace/public/pm/cozy-routine-model.js +111 -0
  73. package/workspace/public/pm/cozy-routine-pop.js +196 -0
  74. package/workspace/public/pm/cozy-routine.css +102 -0
  75. package/workspace/public/pm/cozy-routine.js +156 -0
  76. package/workspace/public/pm/cozy-schedwork.js +6 -5
  77. package/workspace/public/pm/cozy-today-app.js +236 -0
  78. package/workspace/public/pm/cozy-today-model.js +176 -0
  79. package/workspace/public/pm/cozy-today-page.css +100 -0
  80. package/workspace/public/pm/cozy-today-view.js +76 -0
  81. package/workspace/public/pm/home-app.js +18 -3
  82. package/workspace/public/pm/home-ini.js +36 -5
  83. package/workspace/public/pm/library-model.js +69 -0
  84. package/workspace/public/pm/library-open.js +34 -0
  85. package/workspace/public/pm/pop-work-model.js +335 -0
  86. package/workspace/public/pm/premium-board.js +130 -8
  87. package/workspace/public/pm/premium-library.js +122 -0
  88. package/workspace/public/premium-board.html +1 -0
  89. package/workspace/public/premium-events.html +42 -0
  90. package/workspace/public/premium-library.html +31 -0
  91. package/workspace/public/premium-routine.html +31 -0
  92. package/workspace/public/today.html +50 -0
  93. package/workspace/ready-dash-ui-test.js +3 -1
  94. package/workspace/rename-test.js +2 -1
  95. package/workspace/run-tests.js +4 -1
  96. package/workspace/server.js +3 -2
  97. package/workspace/sort-order-test.js +2 -1
  98. package/workspace/split-merge-ui-test.js +3 -1
  99. package/workspace/stage-card-tasks-test.js +3 -1
  100. package/workspace/stage-card-test.js +2 -1
  101. package/workspace/task-delete-test.js +2 -1
  102. package/workspace/task-links-test.js +2 -1
  103. package/workspace/task-milestones-test.js +4 -2
  104. package/workspace/task-plans-test.js +3 -1
  105. package/workspace/task-press-test.js +3 -1
  106. package/workspace/task-views-test.js +3 -1
  107. package/workspace/test-lists/events-place.json +11 -0
  108. package/workspace/test-lists/library-place.json +9 -0
  109. package/workspace/test-lists/pop-work.json +9 -0
  110. package/workspace/test-lists/routine-place.json +9 -0
  111. package/workspace/test-lists/today-log.json +9 -0
  112. package/workspace/test-lists/work-view.json +9 -0
  113. package/workspace/timeline-holds-test.js +3 -1
  114. package/workspace/tk-tasks-test.js +2 -1
@@ -0,0 +1,335 @@
1
+ /* pm/pop-work-model.js — what the popup shows for work, as data (slice 3 of the six-place navigation; boards 3, 20, 21, 22, 25 on Exploring 2,
2
+ * page "Navigation: Today, Work, Goals, Events, Library, Routine"; build plan /mnt/project-files/nav-structure/build-plan.md). Pure: no DOM, no
3
+ * reads. pm/cozy-pop-work.js draws it; pop-work.test.js checks it.
4
+ *
5
+ * workOf(r, v, o) → { title, overview, suggests, rowSuggests, more, rows, span, artefacts, many } one initiative in the popup
6
+ * r the initiative row as GET /api/board-premium sends it (Board and Home both read it)
7
+ * v pm/ini-view-model.js iniView(r, ctx): the stage, its dates, the tasks by stage, what PMOS proposes (v.props)
8
+ * o { steps (Product feature's eight), today ('YYYY-MM-DD'), docs (home-ini-model.js docRows of the initiative's read), items (the
9
+ * Library's rows for this initiative, GET /api/library-items, when that route is there), product (its name), program ({ title } | null),
10
+ * goal (the goal's name, else the anchor), mode ('full' | 'quarter' | 'half' | 'year' | '2y' | '5y': the timeline's span), open (Set of
11
+ * stage keys the PM unfolded), shut (Set of stage keys the PM folded), doneOpen (Set of stage keys whose done tasks show), farOpen (bool) }
12
+ * levelOf(L, o) → the same parts one level up: a program or a product (boards 26, 27). L: { kind, title, path, summary, facts, rows, docs, props }
13
+ * spanOf(dates, mode, today) → { a, b } ISO the window of the timeline: Full runs from the earliest start to the latest end (no bar is cut)
14
+ * barOf(x, span, today) → { l, w, pass, late, ms, dot } in % of the window one bar: the plan, the part that has passed, the missed date
15
+ * dayText(iso, today) → "4 Nov", "13 Jan 2027" dateLate(iso, today) → "4 Nov · 14 days late" | "4 Nov"
16
+ * summaryOf(r, v, o) → { text, own } own: the PM's words (the record's description); else PMOS wrote it (✦)
17
+ *
18
+ * THE RULES (design notes st2, boards 3, 20, 21, 22, 25):
19
+ * 1 Overview: the summary, then "PMOS suggests" (at most three; absent when there is none), then the facts. With many tasks the Overview
20
+ * folds to its summary and "Details" opens the facts (many: more than 6 rows of tasks in the open stage).
21
+ * 2 A suggestion about one task sits under that task (rowSuggests by uid); the same suggestion never shows twice.
22
+ * 3 The breakdown: a stage is a row that folds ("3 of 9 done"). Only the stage in progress opens by itself. In the open stage late tasks
23
+ * come first, then by date; done tasks fold to one line ("3 tasks done"). The stages after the next one fold into one row
24
+ * ("Prioritize to Evaluate, 5 stages").
25
+ * 4 Bars: light grey the plan, dark grey the part that has passed, the missed date a diamond, a red line from it to today. A row with no
26
+ * date has no bar: PMOS does not invent a date.
27
+ * 5 Artefacts: one table: Artefact, Kind, Updated. A core document a gate needs that is not written is a grey row that says which gate. */
28
+
29
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
30
+ const DAY = 864e5;
31
+ const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
32
+ const iso = (d) => d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
33
+ const between = (a, b) => Math.round((b - a) / DAY);
34
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
35
+ const todayOf = (o) => day(o && o.today) || (() => { const d = new Date(); return new Date(d.getFullYear(), d.getMonth(), d.getDate()); })();
36
+ const norm = (s) => String(s || '').trim().toLowerCase().replace(/\s+/g, ' ');
37
+ export const MAX_SUGGEST = 3;
38
+ export const MANY = 6;
39
+ export const MODES = [['quarter', 'Quarter'], ['half', 'Half'], ['year', 'Year'], ['2y', '2 yr'], ['5y', '5 yr'], ['full', 'Full']];
40
+
41
+ /** "4 Nov" this year, "13 Jan 2027" in any other. */
42
+ export function dayText(v, today) {
43
+ const d = day(v); if (!d) return '';
44
+ const t = today instanceof Date ? today : day(today) || new Date();
45
+ return d.getDate() + ' ' + MON[d.getMonth()] + (d.getFullYear() !== t.getFullYear() ? ' ' + d.getFullYear() : '');
46
+ }
47
+ /** A date and, when it has passed and the thing is open, how late: "4 Nov · 14 days late". */
48
+ export function dateLate(v, today, open = true) {
49
+ const d = day(v), t = today instanceof Date ? today : day(today); if (!d || !t) return { text: dayText(v, t), late: false };
50
+ const late = open && d < t;
51
+ return { text: dayText(v, t) + (late ? ' · ' + plural(between(d, t), 'day', 'days') + ' late' : ''), late };
52
+ }
53
+
54
+ /* ── the timeline ── */
55
+ /** The window: Full from the earliest date to the latest (and today), so no bar is cut; the others start at the period that holds today. */
56
+ export function spanOf(dates, mode, today) {
57
+ const t = today instanceof Date ? today : day(today) || new Date();
58
+ const ds = (dates || []).map(day).filter(Boolean).concat([t]);
59
+ if (!mode || mode === 'full') {
60
+ let a = new Date(Math.min(...ds)), b = new Date(Math.max(...ds));
61
+ if (between(a, b) < 28) b = new Date(a.getFullYear(), a.getMonth(), a.getDate() + 28);
62
+ const pad = Math.max(2, Math.round(between(a, b) * 0.03));
63
+ a = new Date(a.getFullYear(), a.getMonth(), a.getDate() - pad); b = new Date(b.getFullYear(), b.getMonth(), b.getDate() + pad);
64
+ return { a: iso(a), b: iso(b) };
65
+ }
66
+ const y = t.getFullYear(), m = t.getMonth();
67
+ const start = mode === 'quarter' ? new Date(y, m - (m % 3), 1) : mode === 'half' ? new Date(y, m < 6 ? 0 : 6, 1) : new Date(y, 0, 1);
68
+ const months = { quarter: 3, half: 6, year: 12, '2y': 24, '5y': 60 }[mode] || 12;
69
+ return { a: iso(start), b: iso(new Date(start.getFullYear(), start.getMonth() + months, 0)) };
70
+ }
71
+ const pct = (d, S) => { const a = day(S.a), b = day(S.b); return ((d - a) / Math.max(DAY, b - a)) * 100; };
72
+ const clamp = (n) => Math.max(0, Math.min(100, n));
73
+ /** One bar in the window. x: { start, end, done, open }. A row with neither date has no bar (null). */
74
+ export function barOf(x, S, today) {
75
+ const t = today instanceof Date ? today : day(today) || new Date();
76
+ const a0 = day(x.start), b0 = day(x.end);
77
+ if (!a0 && !b0) return null;
78
+ const a = a0 || b0, b = b0 || a0;
79
+ const l = clamp(pct(a, S)), r = clamp(pct(new Date(b.getFullYear(), b.getMonth(), b.getDate() + 1), S));
80
+ if (r <= 0 || l >= 100) return { off: true };
81
+ const tx = clamp(pct(t, S));
82
+ const pass = x.done ? r - l : Math.max(0, Math.min(r, tx) - l);
83
+ const missed = !x.done && x.open !== false && !!b0 && b0 < t;
84
+ return { l, w: Math.max(0.6, r - l), pass: Math.max(0, pass), dot: !a0 || !b0,
85
+ late: missed ? { l: clamp(pct(b0, S)), w: Math.max(0.3, tx - clamp(pct(b0, S))) } : null, ms: missed ? clamp(pct(b0, S)) : null };
86
+ }
87
+ /** The month marks on the header: the first of each month that fits, thinned to about six. */
88
+ export function marksOf(S, today) {
89
+ const a = day(S.a), b = day(S.b), t = today instanceof Date ? today : day(today) || new Date(), out = [];
90
+ const n = (b.getFullYear() - a.getFullYear()) * 12 + b.getMonth() - a.getMonth();
91
+ const step = n <= 6 ? 1 : n <= 14 ? 3 : n <= 30 ? 6 : 12;
92
+ for (let d = new Date(a.getFullYear(), a.getMonth() + 1, 1); d < b; d = new Date(d.getFullYear(), d.getMonth() + 1, 1)) {
93
+ if (d.getMonth() % step) continue;
94
+ out.push({ x: pct(d, S), label: d.getMonth() === 0 && step < 12 ? String(d.getFullYear()) : step >= 12 ? String(d.getFullYear()) : MON[d.getMonth()] });
95
+ }
96
+ const tx = pct(t, S);
97
+ return { months: out.filter((m) => m.x > 2 && m.x < 98), today: tx >= 0 && tx <= 100 ? tx : null };
98
+ }
99
+
100
+ /* ── the stages and the dates they ran (the record only) ── */
101
+ function ranOf(r, list) {
102
+ const tr = r.trail || {}, moves = Array.isArray(tr.moves) ? tr.moves : [];
103
+ const idx = (to) => list.findIndex((s) => s.key === to || norm(s.name) === norm(to));
104
+ const ran = list.map(() => ({ from: null, to: null }));
105
+ moves.forEach((m, i) => { const j = idx(m.to); if (j < 0) return; ran[j].from = m.at; const nx = moves[i + 1]; ran[j].to = nx ? nx.at : null; });
106
+ const cur = list.findIndex((s) => s.status === 'now');
107
+ if (cur >= 0 && tr.since) ran[cur].from = tr.since;
108
+ if (list.length && !ran[0].from && r.start) ran[0].from = String(r.start).slice(0, 10);
109
+ const fr = (r.found && r.found.ran) || {};
110
+ list.forEach((s, i) => { const f = fr[s.key] || fr[s.name]; if (f && f.from) ran[i].from = f.from; if (f && f.to) ran[i].to = f.to; });
111
+ return ran;
112
+ }
113
+ const isoOf = (v) => (v ? String(v).slice(0, 10) : '');
114
+ const taskSpan = (ts) => {
115
+ const a = ts.map((x) => x.start || x.end).filter(Boolean).sort(), b = ts.map((x) => x.end || x.start).filter(Boolean).sort();
116
+ return [a[0] || '', b[b.length - 1] || ''];
117
+ };
118
+ const urgent = (a, b) => (b.late - a.late) || (a.end || '9999').localeCompare(b.end || '9999');
119
+ const STATUS = { done: 'Done', now: 'In progress', next: 'To do', skip: 'Skipped' };
120
+ const taskStatus = (x) => (x.wont ? "Won't do" : x.status || 'To do');
121
+
122
+ /* ── the suggestions: what PMOS proposes (r.props, lib/proposals.js), and its split or merge ── */
123
+ const PROP_TITLE = {
124
+ status: (p) => plural(p.items.length, 'task looks', 'tasks look') + ' done. Mark ' + (p.items.length === 1 ? 'it' : 'them') + ' done?',
125
+ names: (p) => 'Tidy ' + plural(p.items.length, 'name', 'names') + '?',
126
+ description: () => 'Keep this description?',
127
+ build: () => 'Open a draft pull request?',
128
+ outcome: (p) => (p.type === 'date' ? 'Set a date to check the outcome?' : 'Say what should change once it ships?'),
129
+ };
130
+ /** One line of a proposal, in plain words. */
131
+ export function sayOf(p) {
132
+ if (!p) return '';
133
+ if (p.title) return String(p.title);
134
+ const f = PROP_TITLE[p.group];
135
+ if (f) return f(p);
136
+ if (p.group === 'dates') return 'New dates for ' + plural(p.items.length, 'task', 'tasks') + '?';
137
+ if (p.group === 'found') return 'Add what PMOS found elsewhere?';
138
+ return 'A change PMOS suggests';
139
+ }
140
+ /** The task a proposal is about, when it is about one task only (it then sits under that row). */
141
+ const aboutTask = (p) => { const it = p.items || []; return it.length === 1 && (it[0].task || it[0].uid) ? String(it[0].task || it[0].uid) : ''; };
142
+ export function suggestsOf(v) {
143
+ const P = (((v && v.props) || {}).groups || []).flatMap((g) => g.props || []).filter((p) => p && p.id && p.section !== 'unplaced' && p.group !== 'grill' && p.group !== 'description');
144
+ const seen = new Set(), rows = new Map(), top = [];
145
+ for (const p of P) {
146
+ const say = sayOf(p), k = norm(say);
147
+ if (seen.has(k)) continue; // the same suggestion never shows twice
148
+ seen.add(k);
149
+ const s = { id: p.id, sig: p.sig || '', say, why: p.why || '', group: p.group, type: p.type || '', sources: p.sources || [], items: p.items || [], data: p.data || {}, sure: p.section === 'sure' };
150
+ const t = aboutTask(p);
151
+ if (t && !rows.has(t)) rows.set(t, s); else top.push(s);
152
+ }
153
+ // split or merge (batch 11 item 14) is a suggestion about the whole initiative
154
+ if (v && v.suggest && v.suggest.kind && v.suggest.title) top.unshift({ id: 'sm', sm: true, say: String(v.suggest.title), why: v.suggest.why || v.suggest.reason || '', group: v.suggest.kind, sources: [], items: [] });
155
+ return { top: top.slice(0, MAX_SUGGEST), more: Math.max(0, top.length - MAX_SUGGEST), rows };
156
+ }
157
+ /** The description PMOS drafted for this initiative, waiting under the ✦ (lib/description-props.js), or null. */
158
+ export function draftDesc(v) {
159
+ const p = (((v && v.props) || {}).groups || []).flatMap((g) => g.props || []).find((x) => x && x.group === 'description' && x.data && x.data.text);
160
+ return p ? { id: p.id, sig: p.sig || '', text: String(p.data.text) } : null;
161
+ }
162
+
163
+ /* ── the Overview ── */
164
+ const firstSentences = (s, n = 2) => { const parts = String(s || '').replace(/\s+/g, ' ').trim().match(/[^.!?]+[.!?]+(\s|$)|[^.!?]+$/g) || []; return parts.slice(0, n).join('').trim(); };
165
+ /** The summary: what it is (the record's description, else PMOS's draft), then where it stands, in PMOS's words. own: the PM's words lead. */
166
+ export function summaryOf(r, v, o = {}) {
167
+ const t = todayOf(o), st = v.stage || {}, d = st.dates || {}, said = [];
168
+ const desc = v.desc ? String(v.desc) : '', draft = !desc ? draftDesc(v) : null;
169
+ const lead = desc || (draft && draft.text) || '';
170
+ if (st.name && st.n) said.push('It is in ' + st.name + (d.left ? (/over$/.test(d.left) ? ' and ' + d.left + ' its plan' : ', ' + d.left) : '') + '.');
171
+ const late = ((v.tasks || {}).sections || []).flatMap((s) => (s.top || []).concat(...(s.groups || []).map((g) => g.rows || []))).filter((x) => x.late);
172
+ if (late.length === 1) said.push('One task holds it: ' + late[0].title + ' is ' + late[0].lateText + '.');
173
+ else if (late.length > 1) said.push(plural(late.length, 'task is', 'tasks are') + ' late.');
174
+ const gate = st.gate && (st.gate.parts || []).filter((x) => !x.ok).map((x) => x.text);
175
+ if (gate && gate.length) said.push(gate.join(' and ').replace(/^./, (c) => c.toUpperCase()) + ', so it cannot pass the ' + String(st.gate.label || 'gate').replace(/^Gate/, 'gate') + '.');
176
+ return { lead: firstSentences(lead, 3), own: !!desc, draft, status: said.join(' '), text: [firstSentences(lead, 3), said.join(' ')].filter(Boolean).join(' ') };
177
+ }
178
+ /** The facts: name on the left, value on the right (a Confluence page). act: what a press on the value does (the host has it). */
179
+ export function factsOf(r, v, o = {}) {
180
+ const t = todayOf(o), st = v.stage || {}, d = st.dates || {}, F = [];
181
+ if (st.name) F.push({ k: 'Stage', v: st.name + (st.n ? ' · ' + (r.status === 'done' ? 'Done' : r.ended ? 'Ended' : 'In progress') : ''), act: 'stage' });
182
+ if (r.start || r.end) {
183
+ const p = [r.start ? dayText(r.start, t) : '', r.end ? dayText(r.end, t) : ''].filter(Boolean).join(' to ');
184
+ F.push({ k: 'Plan dates', v: p, note: d.over ? d.left : '', warn: !!d.over, act: 'dates' });
185
+ }
186
+ const nm = nextMilestone(v, t);
187
+ if (nm) F.push({ k: 'Next milestone', v: nm.name, note: nm.date, warn: nm.late, act: nm.uid ? 'task:' + nm.uid : '' });
188
+ else if (r.end) F.push({ k: 'Next milestone', v: 'Plan end', note: dayText(r.end, t), grey: true });
189
+ if (st.next && st.next.name) F.push({ k: 'Next stage', v: st.next.name, act: 'next' });
190
+ const wf = v.summary && v.summary.wf;
191
+ if (wf && wf.name) F.push({ k: 'Workflow', v: wf.name + (st.of ? ', ' + plural(st.of, 'stage', 'stages') : ''), act: 'wf' });
192
+ if (o.goal || v.anchor) F.push({ k: 'Goal', v: o.goal || v.anchor });
193
+ if (o.product) F.push({ k: 'Product', v: o.product, act: o.canProduct ? 'product' : '' }); // board 27: one level up
194
+ if (o.program) F.push({ k: 'Program', v: o.program.title, act: 'program' }); // board 26
195
+ if (st.gate && (st.gate.parts || []).length) {
196
+ const no = st.gate.parts.filter((x) => !x.ok);
197
+ const say = (no.length ? no : st.gate.parts).map((x) => x.text).join(' · ');
198
+ F.push({ k: st.gate.label || 'Gate', v: say.charAt(0).toUpperCase() + say.slice(1), warn: no.length > 0, read: true });
199
+ }
200
+ const tk = v.tasks || {}, docs = (o.docs || []).filter((x) => x.path).length;
201
+ const open = [tk.open ? plural(tk.open, 'task', 'tasks') : '', docs ? plural(docs, 'document', 'documents') : ''].filter(Boolean).join(' · ');
202
+ if (open) F.push({ k: 'Open', v: open, read: true });
203
+ return F;
204
+ }
205
+ /** The next open milestone task (◇), else null. */
206
+ function nextMilestone(v, t) {
207
+ const all = ((v.tasks || {}).sections || []).flatMap((s) => (s.top || []).concat(...(s.groups || []).map((g) => g.rows || [])));
208
+ const ms = all.filter((x) => x.ms && !x.closed && x.end).sort((a, b) => a.end.localeCompare(b.end))[0];
209
+ if (!ms) {
210
+ const g = (((v.stage || {}).gates || {}).open || [])[0];
211
+ return g ? { name: g.name, date: g.iso ? dateLate(g.iso, t).text : '', late: !!g.late, uid: g.id } : null;
212
+ }
213
+ const dl = dateLate(ms.end, t);
214
+ return { name: ms.title, date: dl.text, late: dl.late, uid: ms.uid };
215
+ }
216
+
217
+ /* ── the work breakdown ── */
218
+ function taskRow(x, t) {
219
+ const dl = x.end ? dateLate(x.end, t, !x.closed) : { text: x.start ? 'from ' + dayText(x.start, t) : '', late: false };
220
+ return { kind: 'task', uid: x.uid, title: x.title, status: taskStatus(x), date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck };
221
+ }
222
+ export function breakdownOf(r, v, o = {}) {
223
+ const t = todayOf(o), list = ((v.stage || {}).ladder || []).map((s, i) => ({ name: s.name, status: s.cls, ms: !!s.ms, i }));
224
+ const secs = (v.tasks || {}).sections || [];
225
+ const ran = ranOf(r, secs.filter((s) => s.kind === 'stage').map((s) => ({ key: s.key, name: s.name, status: s.status })));
226
+ const open = o.open || new Set(), shut = o.shut || new Set(), dOpen = o.doneOpen || new Set();
227
+ const stages = secs.filter((s) => s.kind === 'stage');
228
+ const cur = stages.findIndex((s) => s.status === 'now');
229
+ const rows = [];
230
+ let many = false;
231
+ const stageRow = (s, i) => {
232
+ const ts = (s.top || []).concat(...(s.groups || []).map((g) => g.rows || []));
233
+ const all = ts.concat(s.done || []);
234
+ const nDone = (s.done || []).length, n = all.length;
235
+ const [ta, tb] = taskSpan(all);
236
+ const rn = ran[i] || {};
237
+ let a = '', b = '';
238
+ if (s.status === 'done') { a = isoOf(rn.from) || ta; b = isoOf(rn.to) || tb; }
239
+ else if (s.status === 'now') { const pv = ran.slice(0, i).reverse().find((q) => q.to || q.from) || {}; a = isoOf(rn.from) || isoOf(pv.to) || ta || isoOf(pv.from); b = isoOf(r.end) || tb; } // no recorded start: since the last date the record holds before it // the stage in progress runs to the plan end: late is said against the plan
240
+ else if (s.status !== 'skip') { a = ta; b = tb; }
241
+ const live = s.status === 'now' && r.status !== 'done' && !r.ended;
242
+ const dl = b && (s.status === 'now' || s.status === 'next') ? dateLate(b, t, live || ts.some((x) => !x.closed)) : { text: b && s.status === 'done' ? '' : '', late: false };
243
+ const isOpen = shut.has(s.key) ? false : open.has(s.key) ? true : s.status === 'now' || ts.some((x) => x.late);
244
+ const count = n ? (s.status === 'next' && !nDone ? plural(n, 'task', 'tasks') : nDone + ' of ' + n + ' done') : '';
245
+ rows.push({ kind: 'stage', key: s.key, n: s.n, name: s.name, ms: !!s.ms, status: STATUS[s.status] || '', count, date: dl.text, late: dl.late, start: a, end: b,
246
+ done: s.status === 'done', open: isOpen && n > 0, can: n > 0, now: s.status === 'now', skip: s.status === 'skip' });
247
+ if (!(isOpen && n > 0)) return;
248
+ const sorted = ts.slice().sort(urgent);
249
+ if (s.status === 'now' && sorted.length > MANY) many = true;
250
+ for (const x of sorted) rows.push({ ...taskRow(x, t), sec: s.key });
251
+ if (nDone) {
252
+ const dd = s.done.map((x) => x.end).filter(Boolean).sort();
253
+ rows.push({ kind: 'done', key: s.key, n: nDone, label: plural(nDone, 'task', 'tasks') + ' done', open: dOpen.has(s.key), start: (s.done.map((x) => x.start).filter(Boolean).sort()[0]) || dd[0] || '', end: dd[dd.length - 1] || '' });
254
+ if (dOpen.has(s.key)) for (const x of s.done) rows.push({ ...taskRow(x, t), sec: s.key });
255
+ }
256
+ };
257
+ // the stages after the next one fold into one row (board 20), unless the PM opened it
258
+ const farFrom = cur >= 0 ? cur + 2 : -1;
259
+ stages.forEach((s, i) => {
260
+ if (farFrom > 0 && i >= farFrom && stages.length - farFrom >= 2 && !o.farOpen) {
261
+ if (i === farFrom) {
262
+ const far = stages.slice(farFrom), n = far.reduce((k, x) => k + (x.top || []).length + (x.done || []).length + (x.groups || []).reduce((m, g) => m + g.n, 0), 0);
263
+ rows.push({ kind: 'far', n: s.n, name: far[0].name + ' to ' + far[far.length - 1].name, count: plural(far.length, 'stage', 'stages'), status: 'To do', tasks: n });
264
+ }
265
+ return;
266
+ }
267
+ stageRow(s, i);
268
+ });
269
+ const loose = secs.find((s) => s.kind === 'none');
270
+ if (loose) {
271
+ const ts = (loose.top || []).concat(...(loose.groups || []).map((g) => g.rows || [])), isOpen = !shut.has('');
272
+ rows.push({ kind: 'stage', key: '', n: '', name: 'Not in a stage', status: '', count: plural(ts.length, 'open task', 'open tasks'), date: '', start: '', end: '', open: isOpen && ts.length > 0, can: ts.length > 0 });
273
+ if (isOpen) for (const x of ts.slice().sort(urgent)) rows.push({ ...taskRow(x, t), sec: '' });
274
+ }
275
+ return { rows, many, list };
276
+ }
277
+
278
+ /* ── the artefacts ── */
279
+ const KIND_OF_ITEM = { doc: 'Document', link: 'Link', meeting: 'Meeting notes', proto: 'Prototype', design: 'Design' };
280
+ /** One table: the Library's rows when that route answers, else the core documents the page already reads; then the missing ones a gate needs. */
281
+ export function artefactsOf(v, o = {}) {
282
+ const t = todayOf(o), out = [], seen = new Set();
283
+ const key = (s) => norm(s).replace(/[^a-z0-9]+/g, ' ').trim();
284
+ for (const it of o.items || []) {
285
+ if (!it || !it.name || seen.has(key(it.name))) continue;
286
+ seen.add(key(it.name));
287
+ out.push({ id: it.id, title: it.name, kind: it.kindText || KIND_OF_ITEM[it.kind] || 'Document', when: it.updated ? dayText(it.updated, t) || it.updated : '', item: it, link: it.kind === 'link' });
288
+ }
289
+ for (const d of o.docs || []) {
290
+ if (!d || !d.title || seen.has(key(d.title))) continue;
291
+ if (d.path || d.link) {
292
+ seen.add(key(d.title));
293
+ const lk = d.link && d.link.url;
294
+ out.push({ id: d.key, title: d.title, kind: lk ? 'Link · ' + (d.link.kind || 'page') : d.kind === 'Slides' ? 'Slides' : 'Document', when: whenOf(d.when, t), path: d.path || '', url: lk || '', link: !!lk });
295
+ }
296
+ }
297
+ // what a gate needs and is not written: grey rows that say which gate (board 21)
298
+ const st = (v && v.stage) || {}, gate = st.gate, next = (st.next && st.next.name) || '';
299
+ const gateName = gate && gate.label ? gate.label.replace(/^Gate to /, '') : next;
300
+ if (gate && (gate.parts || []).some((x) => !x.ok)) {
301
+ for (const d of o.docs || []) {
302
+ if (!d || d.path || d.link || !d.core || seen.has(key(d.title))) continue;
303
+ if (!/\b(prd|rubric|done test|brief|spec)\b/i.test(d.title) && !gate.parts.some((x) => !x.ok && norm(x.text).includes(norm(d.title).split(' ')[0]))) continue;
304
+ seen.add(key(d.title));
305
+ out.push({ id: d.key, title: d.title, kind: 'Document', missing: 'Not written · needed for the gate to ' + (gateName || 'the next stage'), key: d.key, act: d.act || null });
306
+ }
307
+ }
308
+ return out;
309
+ }
310
+ const whenOf = (w, t) => { const s = String(w || ''); return day(s) ? dayText(s, t) : s.replace(/^added\s+/, ''); };
311
+
312
+ /* ── one initiative ── */
313
+ export function workOf(r, v, o = {}) {
314
+ const t = todayOf(o);
315
+ const sum = summaryOf(r, v, o), sug = suggestsOf(v), bd = breakdownOf(r, v, o);
316
+ const dates = [r.start, r.end].concat(bd.rows.flatMap((x) => [x.start, x.end])).filter(Boolean);
317
+ const span = spanOf(dates, o.mode || 'full', t);
318
+ return { title: v.title || r.title || '', summary: sum, suggests: sug.top, more: sug.more, rowSuggests: sug.rows, facts: factsOf(r, v, o),
319
+ rows: bd.rows, many: bd.many, span, today: iso(t), artefacts: artefactsOf(v, o) };
320
+ }
321
+
322
+ /* ── one level up: a program or a product (boards 26, 27) ── */
323
+ /** L: { kind: 'program' | 'product', title, summary, facts: [{ k, v, warn?, note? }], rows: [{ id, kind, title, stage, start, end, done, sub? }],
324
+ * docs: [{ title, kind, when, path?, url? }], props? }. The rows one level down keep their own dates; a row with none has no bar. */
325
+ export function levelOf(L, o = {}) {
326
+ const t = todayOf(o);
327
+ const rows = (L.rows || []).map((x) => {
328
+ const dl = x.end ? dateLate(x.end, t, !x.done) : { text: '', late: false };
329
+ return { ...x, date: dl.text, late: dl.late };
330
+ });
331
+ const span = spanOf(rows.flatMap((x) => [x.start, x.end]).filter(Boolean), o.mode || 'full', t);
332
+ const late = rows.filter((x) => x.late).length;
333
+ return { kind: L.kind, title: L.title, summary: L.summary || '', facts: L.facts || [], rows, span, today: iso(t), late, artefacts: (L.docs || []).map((d) => ({ ...d, when: whenOf(d.when, t) })),
334
+ suggests: suggestsOf({ props: L.props || null }).top };
335
+ }
@@ -60,6 +60,7 @@ import { initiativeRename, taskRename } from './rename-press.js';
60
60
  import { setSay } from './cozy-xv.js';
61
61
  import { narrowForm } from './pn-narrow.js';
62
62
  import * as BP2 from './bd-pane.js';
63
+ import * as WV from './bd-work.js'; // Work, one view on a desk (slice 4 of the six-place navigation, initiative work-one-view)
63
64
  import * as LS from './load-shapes.js'; // the skeleton and the slow-case line while the board is read (page-open-speed, SpD) // the Board as the first panel: fit(), the rows that open beside, the open row's mark
64
65
 
65
66
  const VIEW_KEY = 'pmos.board.view', PVIEW_KEY = 'pmos.board.pview', SPAN_KEY = 'pmos.board.span', GROUPING_KEY = 'pmos.board.grouping';
@@ -135,6 +136,10 @@ let nview = 'list';
135
136
  const NF = narrowForm({ page: $('#stage'), sheets: /\/pm\/(cozy-board|bd-[\w-]+)\.css(\?|$)/, onChange: () => { if (M) { drawChips(); drawInit(); } } });
136
137
  const narrow = () => !PHONE.matches && NF.narrow();
137
138
  const small = () => PHONE.matches || narrow();
139
+ /** Work, one view (initiative work-one-view, boards 4, 5 and 24): on a desk the list of initiatives with its timeline replaces the four views.
140
+ * A phone, the narrow form and a published read-only copy keep their views. */
141
+ const CLASSIC = (() => { try { return localStorage.getItem('pmos.work.classic') === '1'; } catch { return false; } })(); // a test seam (lib/classic-board.js): suites of the four views
142
+ const workOn = () => !CLASSIC && !small() && !window.PMOS_READONLY;
138
143
  const goneRows = () => { const G = (M && M.initiatives && M.initiatives.gone) || {}; return [...(G.cancelled || []), ...(G.archived || [])]; };
139
144
  const rowOf = (key) => (M && M.rows || []).find((r) => r.key === key) || goneRows().find((r) => r.key === key) || null;
140
145
  /** 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. */
@@ -269,7 +274,7 @@ let jiraReading = false; // a press is reading Jira again: the chip's Adler we
269
274
  const CHIP_F = [['late', 'late', 'm-warn', 'Late'], ['risk', 'risk', 'm-warn', 'At risk'], ['blocked', 'red', 'm-crit', 'Blocked'], ['idle', 'q', '', 'Idle 30+ days']];
270
275
  /** 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);
271
276
  * the stage track keeps its chip. */
272
- const curView = () => (PHONE.matches ? pview : narrow() ? nview : view);
277
+ const curView = () => (PHONE.matches ? pview : narrow() ? nview : workOn() ? 'work' : view);
273
278
  const sprintFilterOn = () => curView() !== 'time' || span === 'sprint';
274
279
  /** What needs a look (batch 24 item 7, canvas BbB): new asks, late, at risk, blocked and idle are ONE pill of dots and numbers. A press opens the
275
280
  * rows; a row opens what its chip opened (the asks, a metric's trend, whose "Show only" filters); a filter that is on turns off at once.
@@ -311,6 +316,8 @@ function drawChips() {
311
316
  if (pip) pip.hidden = !(phone && (jMood === 'honest' || filtered())); fb.setAttribute('aria-label', say); fb.title = say; }
312
317
  TUNE = { jira, jMood };
313
318
  if (phone) { $('#bdChipset').innerHTML = need; return; }
319
+ // Work on a desk: no count pill and no (i); the rows say late and at risk, the key is under the list, the rest is in the view menu
320
+ if (workOn()) { $('#bdChipset').innerHTML = ''; if (WK_MENU) drawWorkMenu(); return; }
314
321
  // the pill's (i) (UI grill U2): the timeline's legend (PgTimeline; a program milestone only where a program is drawn and "On hold" only where a
315
322
  // hold is drawn, feedback batch 9 item 8), the sprints and releases the calendar icon opened (BdSprint), and the Jira read with its ↻
316
323
  const lo = menuOpen('bdLgdMenu');
@@ -422,7 +429,7 @@ function visible() {
422
429
  if (F.chips.has('blocked') && !t.blocked) return false;
423
430
  if (F.chips.has('idle') && t.idle == null) return false;
424
431
  if (F.chips.has('you') && !t.you) return false;
425
- if (F.chips.has('sprint') && sp && (view === 'track' || view === 'time' || small()) && sprintFilterOn() && !inSprint(r, sp)) return false;
432
+ if (F.chips.has('sprint') && sp && !workOn() && (view === 'track' || view === 'time' || small()) && sprintFilterOn() && !inSprint(r, sp)) return false;
426
433
  if (F.q && !String(r.title || '').toLowerCase().includes(F.q.toLowerCase())) return false;
427
434
  if (F.owners.size && !F.owners.has(r.owner || 'No owner')) return false;
428
435
  if (F.cats.size && !F.cats.has(WF.catOfRow(r))) return false;
@@ -525,7 +532,7 @@ function readGoals() {
525
532
  const rows = M.initiatives.list.rows, sig = ((M.board && M.board.ws) || '') + '|' + rows.map((r) => r.anchor || '').join(',');
526
533
  if (sig === goalsFor) return;
527
534
  goalsFor = sig;
528
- GL.readGoals((M.board && M.board.ws) || '', rows).then((R) => { if (sig !== goalsFor) return; const was = goalOn(); GOALS = R; if (goalOn() !== was || goalOn()) { drawChips(); drawInit(); } });
535
+ GL.readGoals((M.board && M.board.ws) || '', rows).then((R) => { if (sig !== goalsFor) return; const was = goalOn(); GOALS = R; if (goalOn() !== was || goalOn() || workOn()) { drawChips(); drawInit(); } });
529
536
  }
530
537
  function drawTrack(L) {
531
538
  TK = trackMode(L);
@@ -595,6 +602,115 @@ function drawTime(L) {
595
602
  lane: (c) => DL.laneHtml(c, { span, progState }) });
596
603
  return T.html;
597
604
  }
605
+ /* ── Work, one view on a desk (initiative work-one-view; pm/bd-work.js draws, this wires): the list, its view menu, the Stage cell ── */
606
+ let WK_MENU = null, WK_HOV = null, WK_STM = null;
607
+ const wkMany = () => !!(M && M.board.all && (M.board.products || []).length > 1);
608
+ const wkProduct = (r) => r.product || (M && M.board && (M.board.product || M.board.name)) || '';
609
+ const wkGoalOf = (r) => { if (!GOALS) return ''; const k = (GOALS.of || {})[String(r.anchor || '')], g = k && (GOALS.goals || []).find((x) => x.key === k); return g ? g.title : ''; };
610
+ const wkProgOf = (r) => { const p = programOf(PGS, r.ws || (M && M.board.ws) || '', r.id); return p ? p.title || p.id : ''; };
611
+ function drawWork(L) {
612
+ const pk = prodKey((M.board && (M.board.product || M.board.name)) || ''), lay = SO.layout();
613
+ return WV.listHtml(L, { many: wkMany(), sel: peek && peek.kind === 'ini' ? peek.key : null, hov: WK_HOV, rowOf,
614
+ product: wkProduct, goalOf: wkGoalOf, programOf: wkProgOf, order: (rows) => sortInis(pk, rows, lay, INI_ACC),
615
+ goalGroups: (rows) => (GOALS ? GL.asGroups(rows, GOALS, (rs) => sortInis(pk, rs, lay, INI_ACC)) : null),
616
+ canMove: (r) => !!(r.track && r.acts && (r.acts.stages || []).length > 1) });
617
+ }
618
+ /** A press in the list that is Work's own (a column title, the span, the timeline's hide, a Stage cell). → true when handled. */
619
+ function workPress(e) {
620
+ const p = WV.pressOf(e.target); if (!p) return false;
621
+ if (p.kind === 'spanmenu') { spanMenu(); return true; }
622
+ if (p.kind === 'stage') { stageMenu(rowOf(p.key), p.el); return true; }
623
+ if (!WV.apply(p)) return false;
624
+ drawInit(); if (WK_MENU) drawWorkMenu();
625
+ const f = p.kind === 'sort' ? `[data-wksort="${p.k}"]` : p.kind === 'span' ? '[data-wkspan]' : p.kind === 'timeline' ? (p.on ? '[data-wktl="off"]' : '[data-wktl="on"]') : null;
626
+ const n = f && $('#ibBody ' + f); if (n) n.focus();
627
+ return true;
628
+ }
629
+ function spanMenu(open) {
630
+ const m = $('#ibBody .wk-spm'), b = $('#ibBody [data-wkspan]'); if (!m || !b) return;
631
+ const o = open == null ? m.hidden : open; m.hidden = !o; b.setAttribute('aria-expanded', String(o));
632
+ if (o) (m.querySelector('.on') || m.querySelector('button')).focus();
633
+ }
634
+ document.addEventListener('click', (e) => { if (!e.target.closest('.wk-spw')) { const m = $('#ibBody .wk-spm'); if (m && !m.hidden) spanMenu(false); } if (WK_STM && !e.target.closest('.wk-stm, [data-wkstage]')) closeStageMenu(); });
635
+ $('#ibBody').addEventListener('keydown', (e) => {
636
+ if (curView() !== 'work') return;
637
+ if (e.key === 'Escape') { const m = $('#ibBody .wk-spm'); if (m && !m.hidden) { e.stopPropagation(); spanMenu(false); $('#ibBody [data-wkspan]').focus(); } return; }
638
+ // a row is a button: Enter or Space opens it in the popup
639
+ if ((e.key === 'Enter' || e.key === ' ') && e.target.matches('.wk-i[data-key]')) { e.preventDefault(); openIni(rowOf(e.target.dataset.key), e.target); }
640
+ });
641
+ // point at a row: its stages show on its bar and in a small card under it (board 4); the keyboard's focus does the same
642
+ const wkHov = (k) => { if (curView() === 'work') WK_HOV = WV.hover($('#ibBody'), k, WK_HOV); };
643
+ $('#ibBody').addEventListener('mouseover', (e) => { const r = e.target.closest('.wk-i[data-key]'); if (r && !e.target.closest('.wk-card')) wkHov(r.dataset.key); });
644
+ $('#ibBody').addEventListener('mouseleave', () => wkHov(null));
645
+ $('#ibBody').addEventListener('focusin', (e) => { const r = e.target.closest('.wk-i[data-key]'); wkHov(r ? r.dataset.key : null); });
646
+
647
+ /** The Stage cell: the stages of the row's own workflow in a short list; a pick moves it (POST /api/boards/move, the By stage drag's write), with Undo. */
648
+ function closeStageMenu() { if (WK_STM) { WK_STM.remove(); WK_STM = null; } }
649
+ function stageMenu(r, el) {
650
+ closeStageMenu(); if (!r || !r.acts) return;
651
+ const names = r.acts.stages || [], cur = r.acts.stage;
652
+ const m = document.createElement('div'); m.className = 'wk-stm'; m.setAttribute('role', 'menu'); m.setAttribute('aria-label', 'Stage of ' + r.title);
653
+ m.innerHTML = '<span class="h">Stage</span>' + names.map((n) => `<button type="button" role="menuitemradio" aria-checked="${n === cur}" class="${n === cur ? 'on' : ''}" data-to="${esc(n)}">${esc(n)}</button>`).join('');
654
+ document.body.appendChild(m); WK_STM = m;
655
+ const b = el.getBoundingClientRect();
656
+ m.style.left = Math.max(8, Math.min(b.left, innerWidth - m.offsetWidth - 8)) + 'px'; m.style.top = Math.max(8, Math.min(b.bottom + 4, innerHeight - m.offsetHeight - 8)) + 'px';
657
+ (m.querySelector('.on') || m.querySelector('[data-to]')).focus();
658
+ m.addEventListener('click', (e) => { const x = e.target.closest('[data-to]'); if (!x) return; closeStageMenu(); el.focus(); if (x.dataset.to !== cur) moveStage(r, cur, x.dataset.to); });
659
+ m.addEventListener('keydown', (e) => {
660
+ if (e.key === 'Escape' || e.key === 'Tab') { e.preventDefault(); e.stopPropagation(); closeStageMenu(); el.focus(); return; }
661
+ if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
662
+ e.preventDefault(); const B = [...m.querySelectorAll('[data-to]')], i = B.indexOf(document.activeElement);
663
+ B[(i + (e.key === 'ArrowDown' ? 1 : -1) + B.length) % B.length].focus();
664
+ });
665
+ }
666
+
667
+ /** The view menu under the tune button (board 5): Group by, the Timeline, the Columns; then what left the toolbar, so no feature is dropped. */
668
+ function workMore() {
669
+ const C = (M && M.chips) || {}, J = (M && M.jira) || {}, sp = J.sprint, rel = J.release, you = youRows().length;
670
+ const it = (k, icon, label, note) => `<button type="button" class="wk-mx" data-wkx="${k}">${SV(I[icon])}<span>${esc(label)}</span>${note ? `<span class="k">${esc(String(note))}</span>` : ''}</button>`;
671
+ const sprint = [sp ? sp.name : null, rel ? rel.name : null].filter(Boolean).join(' · ');
672
+ return it('filter', 'group', 'Sort and filter', filtered() ? 'on' : '')
673
+ + (C.asks ? it('asks', 'note', C.asks === 1 ? 'New ask' : 'New asks', C.asks) : '')
674
+ + (you ? it('you', 'flag', 'Only what waits on you', F.chips.has('you') ? 'on' : you) : '')
675
+ + (!ALL && sprint ? it('sprint', 'cal', 'Sprints and releases', sprint) : '')
676
+ + it('shared', 'people', tab === 'shared' ? 'Back to the initiatives' : 'Shared with me', tab === 'shared' ? '' : SH_N || '')
677
+ + it('jira', 'refresh', jiraReading ? 'Reading Jira' : 'Read Jira again', TUNE.jira.replace(/^Jira · /, ''));
678
+ }
679
+ function drawWorkMenu(focus) {
680
+ if (!WK_MENU) return;
681
+ const was = focus || (WK_MENU.contains(document.activeElement) ? wkSel(document.activeElement) : null);
682
+ WK_MENU.innerHTML = WV.menuHtml({ many: wkMany(), more: workMore() });
683
+ const m = WK_MENU.firstElementChild, b = WK_MENU.__btn.getBoundingClientRect();
684
+ m.style.top = Math.round(b.bottom + 8) + 'px'; m.style.left = Math.max(8, Math.round(b.right - m.offsetWidth)) + 'px';
685
+ const n = was && m.querySelector(was); if (n) n.focus();
686
+ }
687
+ const wkSel = (el) => { const x = el.closest('[data-wkgroup],[data-wkcolsw],[data-wktlsw],[data-wkreset],[data-wkx]'); if (!x) return null; for (const a of ['wkgroup', 'wkcolsw', 'wkx']) if (x.dataset[a]) return `[data-${a}="${x.dataset[a]}"]`; return x.hasAttribute('data-wktlsw') ? '[data-wktlsw]' : '[data-wkreset]'; };
688
+ function closeWorkMenu(back) { if (!WK_MENU) return; const b = WK_MENU.__btn; WK_MENU.remove(); WK_MENU = null; b.setAttribute('aria-expanded', 'false'); b.classList.remove('on'); if (back) b.focus(); }
689
+ function toggleWorkMenu(btn) {
690
+ if (WK_MENU) { closeWorkMenu(true); return; }
691
+ WK_MENU = document.createElement('div'); WK_MENU.__btn = btn; document.body.appendChild(WK_MENU);
692
+ btn.setAttribute('aria-expanded', 'true'); btn.classList.add('on');
693
+ drawWorkMenu();
694
+ const f = WK_MENU.querySelector('[data-wkgroup].on') || WK_MENU.querySelector('button'); if (f) f.focus();
695
+ WK_MENU.addEventListener('click', (e) => {
696
+ const x = e.target.closest('[data-wkx]');
697
+ if (x) { workExtra(x.dataset.wkx, btn); return; }
698
+ const p = WV.pressOf(e.target); if (!p || !WV.apply(p)) return;
699
+ const sel = wkSel(e.target); drawInit(); drawWorkMenu(sel);
700
+ });
701
+ WK_MENU.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); closeWorkMenu(true); } });
702
+ WV.wireDrag(WK_MENU, (k) => { drawInit(); drawWorkMenu(k ? `[data-wkcolsw="${k}"]` : null); });
703
+ }
704
+ document.addEventListener('click', (e) => { if (WK_MENU && !WK_MENU.contains(e.target) && !e.target.closest('#bdFilter')) closeWorkMenu(); });
705
+ function workExtra(k, btn) {
706
+ if (k === 'jira') { refreshJira(null).then(() => drawWorkMenu('[data-wkx="jira"]')); drawWorkMenu('[data-wkx="jira"]'); return; }
707
+ if (k === 'you') { if (F.chips.has('you')) F.chips.delete('you'); else F.chips.add('you'); drawInit(); drawWorkMenu('[data-wkx="you"]'); return; }
708
+ if (k === 'shared') { setTab(tab === 'shared' ? 'ini' : 'shared'); drawWorkMenu('[data-wkx="shared"]'); return; }
709
+ closeWorkMenu();
710
+ if (k === 'filter') Acts.open.filter(btn);
711
+ else if (k === 'asks') Acts.open.asks(btn);
712
+ else if (k === 'sprint') Acts.open.sprint(btn);
713
+ }
598
714
  /** The View chip (batch 28 item 3, canvas BhA; on a desktop too since UI grill U2): the four views, the span and (a desktop) the Columns where they
599
715
  * apply (the timeline), then Shared with me. */
600
716
  const VIEW_ITEMS = [['list', 'List'], ['stages', 'By stage'], ['track', 'Track'], ['time', 'Timeline']];
@@ -627,7 +743,8 @@ function drawInit() {
627
743
  const phone = small(), L = visible(), v = curView();
628
744
  const body = $('#ibBody');
629
745
  body.dataset.view = v; body.dataset.span = v === 'time' ? span : '';
630
- const html = v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
746
+ document.body.classList.toggle('wk-on', v === 'work');
747
+ const html = v === 'work' ? drawWork(L) : v === 'track' ? drawTrack(L) : v === 'time' ? drawTime(L) : v === 'list' ? (phone ? V.phoneListHtml(L) : V.listHtml(L, filtered())) : V.stagesHtml(L, { phone });
631
748
  // a phone has no ⋯ menu: Metrics and Cancelled and archived stay one press away in every view, not only the track
632
749
  const phx = phone && v !== 'track' ? `<div class="bd-whead bd-phx"><span class="bd-phb"><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>` : '';
633
750
  if (v === 'time') TL.hold(); else TL.forget();
@@ -661,6 +778,7 @@ $('#bdShowing').addEventListener('click', (e) => {
661
778
  });
662
779
  function setSpan(s) { span = s; store.set(SPAN_KEY, span); drawChips(); drawInit(); }
663
780
  $('#ibBody').addEventListener('click', (e) => {
781
+ if (curView() === 'work' && workPress(e)) return;
664
782
  if (e.target.closest('#fold, [data-mefold]')) { foldOpen = !foldOpen; drawInit(); const f = $('#fold') || $('#ibBody [data-mefold]'); if (f) f.focus(); return; }
665
783
  const gf = e.target.closest('[data-fold]'); if (gf) { const k = gf.dataset.fold; PG.fold(k); drawInit(); const b = $$('#ibBody [data-fold]').find((x) => x.dataset.fold === k); if (b) b.focus(); return; }
666
784
  const pc = e.target.closest('[data-pcat]'); if (pc) { const k = pc.dataset.pcat; V.togglePcat(k); drawInit(); const b = $$('#ibBody [data-pcat]').find((x) => x.dataset.pcat === k); if (b) b.focus(); return; }
@@ -717,12 +835,16 @@ $('#ibBody').addEventListener('drop', async (e) => {
717
835
  const step = M.steps[j]; to = (r.acts.stages || []).find((n) => stepOfName(n) === step.key) || (WF.isPF(WF.wfOf(r)) ? step.label : null); // batch 7 item 4
718
836
  if (!to) { say(step.label + ' is not one of this board\'s stages, so it did not move.'); return; }
719
837
  }
838
+ moveStage(r, from, to);
839
+ });
840
+ /** Move an initiative to another of its stages (POST /api/boards/move), with Undo in the toast: the By stage drag and Work's Stage cell. */
841
+ async function moveStage(r, from, to) {
720
842
  const body = { ws: r.ws || M.board.ws, board: r.boardId || M.board.id, id: r.id };
721
843
  const res = await pmPost('/api/boards/move', { ...body, to }).catch(() => null);
722
844
  if (!res || !res.ok) { say((res && res.error) || 'It did not move. The server did not say why.'); return; }
723
845
  say('Moved to ' + to + ' · ' + r.title + '.', async () => { const u = await pmPost('/api/boards/move', { ...body, to: from, why: 'Undo' }).catch(() => null); say(u && u.ok ? 'Back in ' + from + '.' : (u && u.error) || 'The undo did not land.'); load(); });
724
846
  load();
725
- });
847
+ }
726
848
  /** The step key of one of the board's own stage names, by the same old-name map as the model (lib/board-premium.js OLD_STEP). */
727
849
  const OLD_STEP = { ideate: 'discover', ideation: 'discover', strategize: 'prioritize', intake: 'triage', ship: 'deliver', release: 'deliver', learn: 'monitor' };
728
850
  function stepOfName(n) { const k = String(n || '').trim().toLowerCase(); const s = (M.steps || []).find((x) => x.key === k || x.label.toLowerCase() === k); return s ? s.key : OLD_STEP[k] || null; }
@@ -910,7 +1032,7 @@ function markOpen() {
910
1032
  const keys = new Set(BP2.openKeys(VW.panels.list(), M ? [...(M.rows || []), ...goneRows()] : [], BI.vidOf));
911
1033
  if (peek && peek.kind === 'ini') keys.add(peek.key);
912
1034
  $$('#ibBody [data-row]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.row)));
913
- $$('#ibBody .tgp-r, #ibBody .bd-lrow[data-key], #ibBody .bd-bc[data-key]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.key)));
1035
+ $$('#ibBody .tgp-r, #ibBody .bd-lrow[data-key], #ibBody .bd-bc[data-key], #ibBody .wk-i[data-key]').forEach((x) => x.classList.toggle('sel', keys.has(x.dataset.key)));
914
1036
  }
915
1037
  VW.onChange(() => markOpen());
916
1038
  BP2.wire();
@@ -926,7 +1048,7 @@ document.addEventListener('click', (e) => {
926
1048
  });
927
1049
  /* ── the tools the Agreed design draws but has no frame for: plain versions with a "Waiting for design" tag (pm/bd-acts.js) ─────────── */
928
1050
  $('#bdFind').addEventListener('click', (e) => Acts.open.find(e.currentTarget));
929
- $('#bdFilter').addEventListener('click', (e) => Acts.open.filter(e.currentTarget));
1051
+ $('#bdFilter').addEventListener('click', (e) => { if (workOn()) toggleWorkMenu(e.currentTarget); else Acts.open.filter(e.currentTarget); });
930
1052
  // New (PgBoard: "New program or initiative"): a menu of the two. The program panel's own "New initiative" presses this button from code,
931
1053
  // and that press opens New initiative at once.
932
1054
  $('#newIni').addEventListener('click', (e) => { if (e.isTrusted) Asks.openNewMenu(e.currentTarget); else Acts.open.new(e.currentTarget); });
@@ -1213,7 +1335,7 @@ V.init({ M: () => M, wf: wfState, statusOf, usual: usualOf, trail: TI, sel: () =
1213
1335
  Asks.init({ M: () => M, load, say, panel: actsPanel, close: closePanel, rowOf, openIni: openIniAny, openDoc: viewDoc, anchors, programs: () => PGS, reloadPrograms: loadPrograms });
1214
1336
  Acts.init({ M: () => M, wf: wfState, load, say, panel: actsPanel, close: closePanel, redraw: () => { drawChips(); drawInit(); }, F, rowOf, statusOf, openIni: openIniAny,
1215
1337
  openTicket: (ini, tk) => openTicket(ini, tk, $('#bdFind')), askHref, pageHref, trail: TI, viewDoc,
1216
- grouping: () => ({ on: groupingOn(), byProduct, by: grouping === 'goal' && !goalsHere() ? (groupingOn() ? 'program' : 'product') : grouping, goal: goalsHere() }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time',
1338
+ grouping: () => (workOn() ? null : { on: groupingOn(), byProduct, by: grouping === 'goal' && !goalsHere() ? (groupingOn() ? 'program' : 'product') : grouping, goal: goalsHere() }), setGrouping, sprintFilter: sprintFilterOn, timeline: () => curView() === 'time',
1217
1339
  tune: tuneParts, sprintOnly, toggleSprintOnly: () => { if (F.chips.has('sprint')) F.chips.delete('sprint'); else F.chips.add('sprint'); }, sortPick, refreshJira: () => refreshJira() });
1218
1340
  BI.mount({ M: () => M, statusOf, dayTitle, usual: usualOf, fmt, md, ago, segHtml, barHtml: V.barHtml, grill: (id) => GR[id], rowOf, pageHref, askHref, refreshJira: () => refreshJira(), viewDoc,
1219
1341
  send: (r) => import('./tk-send.js').then((S) => S.openSend({ ws: r.ws || M.board.ws || null, board: r.boardId || M.board.id, initiative: r.id, toast: say })),