create-pmos 0.614.0 → 0.616.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 (44) hide show
  1. package/package.json +57 -39
  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/changelog.json +56 -0
  7. package/workspace/guide/backlog.md +70 -0
  8. package/workspace/guide/cli.md +1 -0
  9. package/workspace/guide/index.md +1 -0
  10. package/workspace/guide/layout.md +5 -4
  11. package/workspace/guide/programs.md +1 -1
  12. package/workspace/guide/routine.md +1 -1
  13. package/workspace/lib/backlog.js +323 -0
  14. package/workspace/lib/day-run.js +3 -2
  15. package/workspace/lib/doc-library.js +26 -3
  16. package/workspace/lib/events-place.js +45 -9
  17. package/workspace/lib/jira-status.js +4 -1
  18. package/workspace/lib/mention-cli.js +7 -5
  19. package/workspace/lib/mention-store.js +9 -5
  20. package/workspace/lib/route-modules.js +1 -0
  21. package/workspace/lib/routes-backlog.js +283 -0
  22. package/workspace/lib/routes-boards.js +13 -0
  23. package/workspace/package-lock.json +2 -2
  24. package/workspace/package.json +1 -1
  25. package/workspace/public/pm/bd-backlog.css +158 -0
  26. package/workspace/public/pm/bd-backlog.js +531 -0
  27. package/workspace/public/pm/bk-model.js +169 -0
  28. package/workspace/public/pm/cozy-events-view.js +23 -4
  29. package/workspace/public/pm/cozy-events.js +8 -2
  30. package/workspace/public/pm/cozy-pick.js +6 -3
  31. package/workspace/public/pm/cozy-routine.js +3 -2
  32. package/workspace/public/pm/cozy-today-app.js +23 -5
  33. package/workspace/public/pm/cozy-today-model.js +44 -10
  34. package/workspace/public/pm/cozy-today-page.css +9 -1
  35. package/workspace/public/pm/cozy-today-view.js +14 -9
  36. package/workspace/public/pm/home-app.js +5 -0
  37. package/workspace/public/pm/mention-one-model.js +6 -4
  38. package/workspace/public/pm/premium-board.js +21 -3
  39. package/workspace/public/pm/premium-goals.js +12 -9
  40. package/workspace/public/pm/premium-library.js +15 -3
  41. package/workspace/public/pm/scope-chip.js +5 -2
  42. package/workspace/public/premium-board.html +1 -0
  43. package/workspace/skills/morning-brief.skill +1 -1
  44. package/workspace/test-lists/backlog.json +9 -0
@@ -0,0 +1,169 @@
1
+ /* pm/bk-model.js — the pure half of the Backlog in Work (initiative work-backlog; boards BkList and BkSelect on Exploring 2): which group a
2
+ * task sits in, the quick filters with their counts, the tune panel's facets and sort, and the "Showing … · N hidden" line. No DOM, no fetch:
3
+ * pm/bd-backlog.js draws and wires; bk-model.test.js tests this file in node.
4
+ *
5
+ * THE GROUPS, in this order (brief Part A 4): Needs your review · PMOS is working · PMOS can take these · With people · Nobody has these ·
6
+ * No home · Done by PMOS today. With Part B off (partB false) only With people, Nobody has these and No home exist; the grouping is the same code, so Part B adds
7
+ * groups without a redraw. A task is in one group: what PMOS is doing with it first, then where it lives (no initiative = No home), then
8
+ * whether PMOS can take it, then whether a person has it.
9
+ *
10
+ * Stage is not a task's (Wawan, 2026-11-19: "Stage not apply to task, it only apply to initiative"): nothing here reads a task's stage. */
11
+
12
+ export const GROUPS = [
13
+ { k: 'review', n: 'Needs your review', sub: 'PMOS finished these and cannot pass them alone', open: true, b: true },
14
+ { k: 'working', n: 'PMOS is working', sub: 'nothing needed from you', open: true, b: true },
15
+ { k: 'take', n: 'PMOS can take these', sub: 'it has what it needs to start', open: true, b: true },
16
+ { k: 'people', n: 'With people', sub: '', open: false },
17
+ { k: 'open', n: 'Nobody has these', sub: '', open: false }, // design check 1: "Open" already means every open task (the first chip)
18
+ { k: 'nohome', n: 'No home', sub: 'in no initiative', open: false },
19
+ { k: 'done', n: 'Done by PMOS today', sub: 'passed its checks, no review needed. Undo is on each', open: false, b: true },
20
+ ];
21
+ export const CHIPS = [
22
+ ['all', 'All open'], ['review', 'Needs you'], ['working', 'PMOS working'], ['take', 'PMOS can take'], ['people', 'With people'], ['nohome', 'No home'], ['jira', 'Jira tickets'], ['sprint', 'This sprint'],
23
+ ];
24
+ const GROUP_CHIPS = new Set(['review', 'working', 'take', 'people', 'nohome']);
25
+ export const FACETS = [['ini', 'Initiative'], ['who', 'Who'], ['epic', 'Epic'], ['sprint', 'Sprint'], ['status', 'Status']];
26
+ export const SORTS = [['due', 'Due date'], ['ini', 'Initiative'], ['who', 'Who'], ['name', 'Name']];
27
+ export const SHOW = 5; // the rows an open group shows before its "N more"
28
+
29
+ /** The group of one task. */
30
+ export function groupOf(t, partB = true) {
31
+ const a = t.agent;
32
+ if (partB && a && a.state === 'review') return 'review';
33
+ if (partB && a && a.state === 'working') return 'working';
34
+ if (partB && a && a.state === 'done' && a.today !== false) return 'done'; // an earlier day's result is a plain row again
35
+ if (!t.ini) return 'nohome';
36
+ if (partB && t.take && !t.declined) return 'take';
37
+ if (t.whoKind && t.whoKind !== 'none') return 'people';
38
+ return 'open';
39
+ }
40
+ /** An open task: anything but a task PMOS finished today. */
41
+ export const isOpen = (t) => !(t.agent && t.agent.state === 'done' && t.agent.today !== false);
42
+
43
+ /** The value of a facet on a task (what the tune panel lists and filters by). */
44
+ export function facetOf(t, f) {
45
+ if (f === 'ini') return t.iniTitle || 'No initiative';
46
+ if (f === 'who') return t.agent && t.agent.state !== 'failed' ? 'PMOS' : t.who || 'None';
47
+ if (f === 'epic') return t.src === 'jira' ? (t.epic ? t.epic.name || t.epic.key : 'No epic') : 'Not a Jira ticket';
48
+ if (f === 'sprint') return t.sprint ? t.sprint.name : 'No sprint';
49
+ if (f === 'status') return t.state;
50
+ return '';
51
+ }
52
+ /** Each facet's values with their counts, most first: { ini: [[value, n]], … } over `tasks`. */
53
+ export function facetsOf(tasks) {
54
+ const out = {};
55
+ for (const [f] of FACETS) {
56
+ const m = new Map();
57
+ for (const t of tasks) { const v = facetOf(t, f); m.set(v, (m.get(v) || 0) + 1); }
58
+ out[f] = [...m].sort((a, b) => b[1] - a[1] || String(a[0]).localeCompare(String(b[0])));
59
+ }
60
+ return out;
61
+ }
62
+
63
+ /** Does task `t` pass the quick filters `chips` (a Set) and the facet picks `pick` ({ facet: Set of values })? Group chips widen each
64
+ * other (Needs you + No home shows both); Jira tickets and This sprint narrow. */
65
+ export function keeps(t, chips, pick, partB = true) {
66
+ const C = chips || new Set();
67
+ const groups = [...C].filter((c) => GROUP_CHIPS.has(c));
68
+ if (groups.length && !groups.includes(groupOf(t, partB))) return false;
69
+ if (C.has('jira') && t.src !== 'jira') return false;
70
+ if (C.has('sprint') && !(t.sprint && t.sprint.state === 'active')) return false;
71
+ for (const [f, set] of Object.entries(pick || {})) if (set && set.size && !set.has(facetOf(t, f))) return false;
72
+ return true;
73
+ }
74
+ /** The counts the chips show: over the open tasks, each chip alone. */
75
+ export function chipCounts(tasks, partB = true) {
76
+ const open = tasks.filter(isOpen), n = { all: open.length };
77
+ for (const [k] of CHIPS) if (k !== 'all') n[k] = open.filter((t) => keeps(t, new Set([k]), null, partB)).length;
78
+ return n;
79
+ }
80
+
81
+ const dueKey = (t) => (t.due ? String(t.due).slice(0, 10) : '9999');
82
+ /** The rows in an order: late first by how late, then by due day, then by name; or by initiative, who or name. */
83
+ export function sortRows(rows, by = 'due') {
84
+ const name = (t) => String(t.title || '').toLowerCase();
85
+ const cmp = {
86
+ due: (a, b) => (b.late || 0) - (a.late || 0) || dueKey(a).localeCompare(dueKey(b)) || name(a).localeCompare(name(b)),
87
+ ini: (a, b) => String(a.iniTitle || '~').localeCompare(String(b.iniTitle || '~')) || dueKey(a).localeCompare(dueKey(b)),
88
+ who: (a, b) => String(a.who || '~').localeCompare(String(b.who || '~')) || dueKey(a).localeCompare(dueKey(b)),
89
+ name: (a, b) => name(a).localeCompare(name(b)),
90
+ }[by] || ((a, b) => name(a).localeCompare(name(b)));
91
+ return rows.slice().sort(cmp);
92
+ }
93
+
94
+ /** The groups to draw: [{ k, n, sub, rows, people? }], empty groups left out (zero is silence). o: { chips, pick, sort, partB, ini }. */
95
+ export function groupsOf(tasks, o = {}) {
96
+ const partB = o.partB !== false;
97
+ // o.ini: one initiative's tasks only (the initiative popup draws its tasks with this list; No home is then empty)
98
+ const shown = tasks.filter((t) => (!o.ini || t.ini === o.ini) && keeps(t, o.chips, o.pick, partB));
99
+ const out = [];
100
+ for (const g of GROUPS) {
101
+ if (g.b && !partB) continue;
102
+ let rows = sortRows(shown.filter((t) => groupOf(t, partB) === g.k), o.sort);
103
+ if (g.k === 'nohome') rows = rows.filter((t) => t.propose).concat(rows.filter((t) => !t.propose)); // PMOS's ✦ proposals first
104
+ if (!rows.length) continue;
105
+ let sub = g.sub;
106
+ if (g.k === 'people') {
107
+ const by = new Map();
108
+ for (const t of rows) by.set(t.who, (by.get(t.who) || 0) + 1);
109
+ sub = [...by].sort((a, b) => (a[0] === 'You') - (b[0] === 'You') || b[1] - a[1]).map(([w, n]) => (w === 'You' ? 'you' : w) + ' ' + n).join(', ');
110
+ }
111
+ if (g.k === 'nohome') { const p = rows.filter((t) => t.propose).length; sub = 'in no initiative' + (p ? '. PMOS can place ' + p : ''); }
112
+ out.push({ k: g.k, n: g.n, sub, rows, open: g.open });
113
+ }
114
+ return out;
115
+ }
116
+
117
+ /** The "Showing … · N hidden · Show all" line: '' when nothing is filtered. */
118
+ export function showingLine(tasks, o = {}) {
119
+ const open = tasks.filter(isOpen), partB = o.partB !== false;
120
+ const on = (o.chips && o.chips.size) || Object.values(o.pick || {}).some((s) => s && s.size);
121
+ if (!on) return null;
122
+ const kept = open.filter((t) => keeps(t, o.chips, o.pick, partB)).length;
123
+ const what = [...(o.chips || [])].map((c) => (CHIPS.find(([k]) => k === c) || [c, c])[1]);
124
+ for (const [f, set] of Object.entries(o.pick || {})) if (set && set.size) what.push((FACETS.find(([k]) => k === f) || [f, f])[1] + ': ' + [...set].join(', '));
125
+ return { text: 'Showing ' + what.join(' · '), hidden: open.length - kept };
126
+ }
127
+
128
+ /** The State cell's words: the state, then one short note (late, what PMOS will do, where PMOS stands). → { dot, text, note, tone }
129
+ * In "PMOS can take these" the point of the row is what PMOS will do: late first (red, short), then the action, and no "To do" (the group
130
+ * says it). A reason is two or three words ("goes out to Daryl", "changes sign-in", "goes to the CFO"). */
131
+ const REVIEW_WORD = { pr: 'Pull request ready', message: 'Message ready', doc: 'Document ready' };
132
+ export function stateOf(t, gk, o = {}) {
133
+ const a = t.agent;
134
+ // o.noLate: a Due column shows beside (the initiative popup's list), so the late words live there and State says only the state
135
+ const late = t.late && !o.noLate ? t.late + (t.late === 1 ? ' day late' : ' days late') : '';
136
+ if (a && a.state === 'review') return { dot: 'amber', text: REVIEW_WORD[a.review] || 'Ready', note: a.why || '', tone: '' };
137
+ if (a && a.state === 'working') {
138
+ if (a.pr) return { dot: 'blue', text: 'Pull request open', note: "the repo's checks decide", tone: '' };
139
+ return { dot: 'blue', text: 'Working', note: a.why || '', tone: '' };
140
+ }
141
+ if (a && a.state === 'done' && a.today !== false) return { dot: 'green', text: 'Done', note: a.why || '', tone: '' };
142
+ if (a && a.state === 'failed') return { dot: 'grey', text: t.state, note: 'PMOS could not finish: ' + (a.why || 'it stopped'), tone: 'late' };
143
+ if ((gk ? gk === 'take' : groupOf(t) === 'take') && t.take) {
144
+ return late ? { dot: 'red', text: late, note: t.take.what, tone: 'late' } : { dot: 'grey', text: t.take.what, note: '', tone: '' };
145
+ }
146
+ if (late) return { dot: 'red', text: t.state, note: late, tone: 'late' };
147
+ return { dot: t.state === 'To do' ? 'grey' : 'blue', text: t.state, note: '', tone: '' };
148
+ }
149
+
150
+ /** The line under the chips: the kind of work and what it means. modes: [{ product, mode, label, kinds: { product, project, sdlc } }].
151
+ * The line is true (design check 1): one kind on every initiative → "IDPF runs as Full SDLC: …"; kinds that differ → "Most work here runs
152
+ * as Full SDLC (9 of 12 initiatives): …". → { lead, label, tail, what } | '' */
153
+ const WHAT = {
154
+ product: 'PMOS writes documents and drafts replies; a reply waits for you before it goes.',
155
+ project: 'PMOS also chases dates and drafts status notes; anything that goes out waits for you.',
156
+ sdlc: 'PMOS does the task and asks you only when the result cannot be undone or goes out to people.',
157
+ };
158
+ const LABEL = { product: 'Product management', project: 'Project management', sdlc: 'Full SDLC' };
159
+ export function modeLine(modes) {
160
+ const L = (modes || []).filter(Boolean);
161
+ if (!L.length) return '';
162
+ const n = { product: 0, project: 0, sdlc: 0 };
163
+ for (const m of L) for (const k of Object.keys(n)) n[k] += (m.kinds && m.kinds[k]) || 0;
164
+ const total = n.product + n.project + n.sdlc;
165
+ const top = total ? ['sdlc', 'project', 'product'].reduce((b, k) => (n[k] > n[b] ? k : b), 'sdlc') : (L[0].mode || 'product');
166
+ const name = L.length === 1 ? L[0].product : null;
167
+ if (!total || n[top] === total) return { lead: (name || 'All work here') + ' runs as ', label: LABEL[top], tail: '', what: WHAT[top] };
168
+ return { lead: 'Most work here runs as ', label: LABEL[top], tail: ` (${n[top]} of ${total} initiatives)`, what: WHAT[top] };
169
+ }
@@ -16,6 +16,8 @@
16
16
  * KINDS · KIND_LABEL · LATE_SHOWN · shiftMonth(ym, n) · weekOf(day)
17
17
  * Text from records goes through esc(). Every icon-only button has an aria-label. The words say PMOS. */
18
18
 
19
+ import { productName } from './scope-chip.js'; // the one product-name function (audit round 2: names, not ids)
20
+
19
21
  export const TYPES = ['meeting', 'focus', 'milestone', 'task', 'report', 'deadline'];
20
22
  export const KINDS = TYPES; // the filter is by type since round 2
21
23
  export const LATE_SHOWN = 5;
@@ -24,8 +26,16 @@ export const TYPE_WORD = { meeting: 'Meeting', focus: 'Focus time', milestone: '
24
26
  export const TYPE_LABEL = { meeting: 'Meetings', focus: 'Focus time', milestone: 'Milestones', task: 'Tasks', report: 'Reports', deadline: 'Deadlines' };
25
27
  export const KIND_LABEL = TYPE_LABEL;
26
28
  const typeOf = (x) => x.type || x.kind;
29
+ /** The model's line with the product by its display name ("Planned finish · IDPF", not "· pmos-idpf"). */
30
+ export const lineText = (x) => {
31
+ const l = String(x.line || '');
32
+ if (!l || !x.product) return l;
33
+ const ws = (x.work && x.work.ws) || ((x.scope || []).find((t) => /^p:/.test(t)) || '').slice(2);
34
+ const n = ws ? productName(ws, x.product) : x.product;
35
+ return n === x.product ? l : l.split(x.product).join(n);
36
+ };
27
37
  /** The grey line: the type word first, then what the model says. */
28
- export const lineOf = (x) => TYPE_WORD[typeOf(x)] + (x.line ? ' · ' + x.line : '');
38
+ export const lineOf = (x) => TYPE_WORD[typeOf(x)] + (x.line ? ' · ' + lineText(x) : '');
29
39
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
30
40
  const MONTH = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
31
41
  const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -79,7 +89,10 @@ export function rowHtml(x, o = {}) {
79
89
  // a meeting under an opened busy day: only its time, the day row above names the day
80
90
  const d = o.child ? { b: x.time || 'All day', s: x.until ? 'to ' + x.until : '' } : dayCell(x, today);
81
91
  const kindWord = TYPE_WORD[typeOf(x)];
82
- const what = `<b>${esc(x.title)}</b><small><em class="evp-ty">${esc(kindWord)}</em>${x.line ? ' · ' + esc(x.line) : ''}</small>`;
92
+ // a row whose name is its type ("Focus time") does not say the type again
93
+ const same = String(x.title || '').trim().toLowerCase() === String(kindWord || '').toLowerCase();
94
+ const small = same ? (x.line ? `<small>${esc(lineText(x))}</small>` : '') : `<small><em class="evp-ty">${esc(kindWord)}</em>${x.line ? ' · ' + esc(lineText(x)) : ''}</small>`;
95
+ const what = `<b>${esc(x.title)}</b>${small}`;
83
96
  const srcOpen = x.source && o.open && o.open.has('src:' + x.key);
84
97
  const t = x.source ? `<button type="button" class="evp-t" data-evp-src aria-expanded="${srcOpen ? 'true' : 'false'}" aria-label="${esc(x.title)}. ${esc(lineOf(x))}. Show what was said">${what}</button>`
85
98
  : x.work || x.task || x.own || x.link ? `<button type="button" class="evp-t" data-evp-open aria-label="${esc(x.title)}. ${esc(lineOf(x))}. Open it">${what}</button>` : `<span class="evp-t">${what}</span>`;
@@ -153,13 +166,19 @@ export function hiddenHtml(items, o = {}) {
153
166
  }
154
167
  const fold = (key, open, text) => `<button type="button" class="evp-fold" data-evp-fold="${key}" aria-expanded="${open ? 'true' : 'false'}"><i aria-hidden="true">${svg(ICON.go, 14)}</i><span>${text}</span></button>`;
155
168
 
169
+ /** The late rows in view: the newest LATE_SHOWN while the rest are folded, else all. Yes to all takes these. */
170
+ export function lateInView(model, o = {}) {
171
+ const late = groupsOf(model.items, o).late;
172
+ return !o.day && late.length > LATE_SHOWN + 1 && !(o.open && o.open.has('late')) ? late.slice(0, LATE_SHOWN) : late;
173
+ }
156
174
  /** The left side. model: { today, items, later }; o: { show, day, busy } */
157
175
  export function listHtml(model, o = {}) {
158
176
  const today = model.today;
159
177
  const G = groupsOf(model.items, o);
160
- const yes = G.late.filter((x) => x.suggest).length;
161
- const all = yes > 1 ? `<button type="button" class="evp-all" data-evp-all>Yes to all ${yes}</button>` : '';
162
178
  const open = o.open || new Set();
179
+ // Yes to all says yes only to what is in view: "Yes to these 5" while the older late rows are folded (as the Backlog does)
180
+ const seen = lateInView(model, o), yes = seen.filter((x) => x.suggest).length, folded = seen.length < G.late.length;
181
+ const all = yes > 1 ? `<button type="button" class="evp-all" data-evp-all>${folded ? 'Yes to these' : 'Yes to all'} ${yes}</button>` : '';
163
182
  const ro = { today, busy: o.busy, open };
164
183
  let later = '';
165
184
  const on = new Set(o.show || TYPES);
@@ -19,7 +19,7 @@
19
19
  import { mountNav } from './cozy-nav.js';
20
20
  import * as POP from './cozy-popup.js';
21
21
  import { pmGet, pmPost } from './http.js';
22
- import { TYPES, listHtml, calHtml, monthHtml, showHtml, hiddenHtml, countsOf, shiftMonth, esc } from './cozy-events-view.js';
22
+ import { TYPES, listHtml, calHtml, monthHtml, showHtml, hiddenHtml, countsOf, shiftMonth, esc, lateInView } from './cozy-events-view.js';
23
23
  import { readPick } from './cozy-pick.js';
24
24
  import { scopeChipHtml, openScope, matches, narrowed, scopeWords, whenNames } from './scope-chip.js';
25
25
 
@@ -123,6 +123,11 @@ async function apply(x, s) {
123
123
  if (x.own) { const r = await pmPost('/api/pm-items/remove', { id: x.own }); return { ok: r && r.ok !== false, error: r && r.error, undo: () => pmPost('/api/pm-items/undo', { id: x.own }) }; }
124
124
  const r = await setState(x, "Won't do"); return { ok: r && r.ok !== false, error: r && r.error, undo: () => setState(x, was) };
125
125
  }
126
+ if (s.op === 'gone' && Array.isArray(s.keys)) { // the old report drafts: each one marked dropped; the files stay
127
+ const done = [];
128
+ for (const key of s.keys) { const r = await pmPost('/api/events-place/mark', { key, gone: 'dropped' }); if (r && r.ok !== false) done.push(key); else return { ok: false, error: (r && r.error) || 'Nothing was changed.', undo: null }; }
129
+ return { ok: true, undo: async () => { for (const key of done) await pmPost('/api/events-place/mark', { key, gone: false }); } };
130
+ }
126
131
  if (s.op === 'met' || s.op === 'gone') {
127
132
  const r = await pmPost('/api/events-place/mark', { key: x.key, gone: s.op === 'met' ? 'met' : 'dropped' });
128
133
  return { ok: r && r.ok !== false, error: r && r.error, undo: () => pmPost('/api/events-place/mark', { key: x.key, gone: false }) };
@@ -150,7 +155,8 @@ async function yes(x) {
150
155
  }
151
156
  async function yesAll() {
152
157
  const ok = scopeOk();
153
- const list = S.model.items.filter((x) => x.group === 'late' && x.suggest && S.show.includes(x.type || x.kind) && (!ok || ok(x)) && (!S.day || x.date === S.day));
158
+ // only the late rows in view (the list's own rule): while the older ones are folded, the button says "Yes to these N"
159
+ const list = lateInView(S.model, { show: S.show, scopeOk: ok || undefined, day: S.day, open: S.open }).filter((x) => x.suggest);
154
160
  if (!list.length) return;
155
161
  list.forEach((x) => S.busy.add(x.key)); draw();
156
162
  const undos = [];
@@ -15,6 +15,9 @@
15
15
  * a press ticks or unticks and the list stays open, the last tick stays, and the pick applies when the list closes (Escape, a press outside,
16
16
  * the chip again, or the sheet's scrim). Arrow keys move in the list. Add a product is the last row. Nothing here writes but savePick. */
17
17
  import { pmGet, pmPost } from './http.js';
18
+ import { productName } from './scope-chip.js'; // one display name per product on every page ("IDPF", not "pmos-idpf"); used at draw time only
19
+ /** A product's name as every page prints it; the pick's own name until the names are in. */
20
+ const nameOf = (p) => productName(p && p.ws, (p && p.name) || '');
18
21
 
19
22
  export const TONES = 3;
20
23
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
@@ -45,13 +48,13 @@ const isAll = (P) => !!P && P.products.length > 1 && P.products.every((p) => p.o
45
48
  /** The words of the chip (its tooltip and accessible name): "Products on Home: acme-shop, acme-web", or "… all 3". */
46
49
  export function chipWords(P, label) {
47
50
  if (!P || !P.products.length) return label + ': none registered';
48
- return label + ': ' + (isAll(P) ? 'all ' + P.products.length : P.products.filter((p) => p.on).map((p) => p.name).join(', '));
51
+ return label + ': ' + (isAll(P) ? 'all ' + P.products.length : P.products.filter((p) => p.on).map(nameOf).join(', '));
49
52
  }
50
53
  export function chipHtml(P, o = {}) {
51
54
  const T = o.tones || tonesOf(P ? P.products : []), on = P ? P.products.filter((p) => p.on) : [];
52
55
  // o.names (Work and Goals, slice 1): the full name of the first ticked product, "+2" for the others, "All products" when every one is ticked
53
56
  const first = on.slice().sort((a, b) => (b.primary ? 1 : 0) - (a.primary ? 1 : 0))[0];
54
- const inner = !P ? '' : o.names ? `<span class="ppk-all ppk-nmc">${isAll(P) ? 'All products' : first ? esc(first.name) + (on.length > 1 ? ` <em>+${on.length - 1}</em>` : '') : 'No product'}</span>`
57
+ const inner = !P ? '' : o.names ? `<span class="ppk-all ppk-nmc">${isAll(P) ? 'All products' : first ? esc(nameOf(first)) + (on.length > 1 ? ` <em>+${on.length - 1}</em>` : '') : 'No product'}</span>`
55
58
  : isAll(P) ? '<span class="ppk-all">All</span>'
56
59
  : `<span class="ppk-stk">${on.slice(0, 3).map((p) => `<i class="ppk-t t${T[p.ws] || 0}">${esc(codeOf(p))}</i>`).join('')}${on.length > 3 ? `<i class="ppk-t ppk-n">+${on.length - 3}</i>` : ''}</span>`;
57
60
  const words = chipWords(P, o.label || 'Products'), id = o.id || 'ppChip', open = !!cur && cur.id === id; // a page that draws again keeps the open state
@@ -67,7 +70,7 @@ function itemsHtml(c) {
67
70
  const box = (st) => `<i class="ppk-tk${st === 'true' ? ' on' : st === 'mixed' ? ' part' : ''}" aria-hidden="true">${st === 'true' ? svg(TICK, 13, 3.4) : st === 'mixed' ? svg(PART, 12, 3.4) : ''}</i>`;
68
71
  const rows = P.products.map((p) => {
69
72
  const on = c.tick.has(p.ws), line = c.o.lines ? c.o.lines(p.ws) : '';
70
- return `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${on}" data-pp="${esc(p.ws)}"><span class="ppk-tl t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</span><span class="ppk-nm"><b>${esc(p.name)}</b>${line ? `<em>${esc(line)}</em>` : ''}</span>${box(String(on))}</button>`;
73
+ return `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${on}" data-pp="${esc(p.ws)}"><span class="ppk-tl t${T[p.ws] || 0}" aria-hidden="true">${esc(codeOf(p))}</span><span class="ppk-nm"><b>${esc(nameOf(p))}</b>${line ? `<em>${esc(line)}</em>` : ''}</span>${box(String(on))}</button>`;
71
74
  }).join('');
72
75
  return (P.products.length > 1 ? `<button type="button" class="ppk-mi" role="menuitemcheckbox" aria-checked="${all}" data-pp="*"><span class="ppk-nm"><b>All products</b></span>${box(all)}</button><div class="ppk-sep" role="separator"></div>` : '')
73
76
  + rows + (`${P.products.length ? '<div class="ppk-sep" role="separator"></div>' : ''}<button type="button" class="ppk-mi" role="menuitem" data-pp-add><span class="ppk-pl" aria-hidden="true">${svg(PLUS, 18, 2.2)}</span><span class="ppk-nm"><b>Add a product</b></span></button>`)
@@ -18,7 +18,7 @@ import * as VW from './cozy-viewer.js';
18
18
  import * as POP from './cozy-popup.js';
19
19
  import { KINDS, routineRows, routineGroups, didLine, kindCounts, productsOf, productName } from './cozy-routine-model.js';
20
20
  import * as PK from './cozy-pick.js'; // the saved product pick of Work, Today and Goals
21
- import { scopeChipHtml, openScope, scopeWords, whenNames, displayName } from './scope-chip.js'; // one chip for products, programs and projects (shared with Events)
21
+ import { scopeChipHtml, openScope, scopeWords, whenNames, displayName, productName as shownName } from './scope-chip.js'; // one chip for products, programs and projects (shared with Events)
22
22
  import { atOf } from './cozy-evmodel.js';
23
23
  import { openReport } from './cozy-routine-pop.js';
24
24
  import { openJob, openNew } from './cozy-routine-job.js'; // reads, jobs, services and your tasks: manage them in the popup (round 3 item 3)
@@ -59,7 +59,8 @@ async function load() {
59
59
  return up && up !== x ? up : null;
60
60
  };
61
61
  const own = displayName; // the chip's rule (pm/scope-chip.js), so the column and the chip agree
62
- S.ws = raw.map((x) => { const m = mainOf(x); return { id: x.id, name: m ? own(m) : own(x), slug: x.name || x.id, main: m ? m.id : null }; });
62
+ await whenNames(); // every page prints a product by the one shared name (productName in pm/scope-chip.js), never a second map
63
+ S.ws = raw.map((x) => { const m = mainOf(x); return { id: x.id, name: shownName(x.id, m ? own(m) : own(x)), slug: x.name || x.id, main: m ? m.id : null }; });
63
64
  const home = (raw.find((x) => x.home) || raw[0] || {}).id; // Horizon scan and Report finder are settings of the home product
64
65
  const per = await Promise.all(S.ws.map((x) => Promise.all([pmGet('/api/report-setups/routine?ws=' + enc(x.id)).catch(() => null), pmGet('/api/autonomy?ws=' + enc(x.id)).catch(() => null)])));
65
66
  const [rf, sc, pk, scan, rs, pg] = await Promise.all([pmGet('/api/refresh').catch(() => null), pmGet('/api/schedules?all=1').catch(() => null), PK.readPick().catch(() => null),
@@ -2,7 +2,7 @@
2
2
  *
3
3
  * mountToday(ctx) once, from home-app.js on today.html (body[data-today]). ctx is what Home already has:
4
4
  * { S, VW, POP, pmGet, pmPost, toast, toastUndo, isPhone, now(), rank() → rankMove's answer, rows() → Home's rows by id (a Map),
5
- * titleOf(ini), hasIni(ini), boardWs(), boardId(), goIni(id), select(id), movePress(btn), openFinished(f), openReviewVw(), openMeeting(m),
5
+ * titleOf(ini), hasIni(ini), boardWs(), boardId(), goIni(id), select(id), movePress(btn), openFinished(f), openReviewVw(), openMeeting(m), startCalls(ids) → { started, failed },
6
6
  * openCalendar(), openInbox(), openLab(l), reload(), review() → the weekly review's model, meetings() → today's meetings, news() → how
7
7
  * many are new for you, chatNow() → the chat's target }
8
8
  * → { on() → Today is drawn, draw(), read() }
@@ -14,12 +14,13 @@
14
14
  * a Lab finding kept or dropped (POST /api/lab/*). Each says what it did in the toast, with Undo. Reads: GET /api/today-log, and GET
15
15
  * /api/events-place for the reports that go out today (placed at their time on the agenda). */
16
16
  import * as TM from './cozy-today-model.js';
17
+ import { productName, whenNames } from './scope-chip.js';
17
18
  import * as TP from './cozy-today-view.js';
18
19
  import * as OM from './mention-one-model.js'; // the one mention's title and the self check's proof line (Today round 3)
19
20
 
20
21
  const ASK_SEND = new Set(['session']);
21
22
  export function mountToday(ctx) {
22
- const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), type: '', open: false, hide: new Set() };
23
+ const X = { log: { entries: [], marks: {} }, html: '', model: null, agenda: null, read: false, busy: new Set(), type: '', open: false, hide: new Set(), sopen: new Set() };
23
24
  const el = document.getElementById('tdPage');
24
25
  const on = () => !!el && !ctx.isPhone();
25
26
  const day = () => TM.dayKey(ctx.now());
@@ -46,6 +47,12 @@ export function mountToday(ctx) {
46
47
  const tabs = (ctx.S.D.work && ctx.S.D.work.queue && ctx.S.D.work.queue.tabs) || [];
47
48
  return ((tabs.find((t) => t.key === 'today') || { groups: [] }).groups || []).flatMap((g) => g.rows || []);
48
49
  };
50
+ /* a product's display name, never its id (audit round 2): the one name function every page prints (pm/scope-chip.js); redrawn once the names are in */
51
+ let namesIn = false;
52
+ function productOf(ws) {
53
+ if (!namesIn) { namesIn = true; Promise.resolve(whenNames()).then(() => { X.html = ''; draw(); }).catch(() => {}); }
54
+ return productName(ws, '');
55
+ }
49
56
  function models() {
50
57
  const S = ctx.S, D = S.D, now = ctx.now(), byId = ctx.rows();
51
58
  // Your move's rows, with what Home's own rows know of each (its task and its due day): a late task is dated, a next step is not
@@ -55,7 +62,7 @@ export function mountToday(ctx) {
55
62
  const R = ctx.review();
56
63
  const lab = (S.lab || []).flatMap((l) => (l.items || []).map((f) => ({ ...f, ws: l.ws, board: l.board })));
57
64
  const L = TM.logModel({ rank: ctx.rank(), move, items: tdItems(), drafts, review: R && R.open && !R.done ? { title: 'Your weekly review' } : null,
58
- own: X.log.entries, marks: X.log.marks, lab, titleOf: ctx.titleOf, now });
65
+ own: X.log.entries, marks: X.log.marks, lab, titleOf: ctx.titleOf, productOf, now });
59
66
  const lead = L.rows.find((r) => !r.done && r.src !== 'note' && r.src !== 'own' && r.src !== 'lab');
60
67
  const A = TM.agendaModel({ meetings: ctx.meetings(), own: X.log.entries, reports: X.reports || [], focus: lead ? { key: lead.key, title: lead.title } : null, now,
61
68
  iniOf: (m) => (m && (m.initiative || (m.level && m.level.kind === 'initiative' && m.level.id) || (m.about && m.about.kind === 'initiative' && m.about.id))) || null });
@@ -81,7 +88,7 @@ export function mountToday(ctx) {
81
88
  }
82
89
  if (X.type && !(L.types || {})[X.type]) X.type = '';
83
90
  const cap = document.getElementById('tdCap'), draft = cap ? cap.value : '', focus = !!cap && document.activeElement === cap;
84
- const html = TP.pageHtml(L, A, { draft, overview: O, type: X.type, open: X.open || !!X.type, handled: X.type && X.type !== 'Ask' ? [] : handled(), hopen: X.hopen });
91
+ const html = TP.pageHtml(L, A, { draft, overview: O, type: X.type, open: X.open || !!X.type, handled: X.type && X.type !== 'Ask' ? [] : handled(), hopen: X.hopen, sopen: [...X.sopen] });
85
92
  if (html === X.html && el.firstChild) return;
86
93
  X.html = html;
87
94
  const st = el.parentNode ? el.parentNode.scrollTop : 0;
@@ -89,7 +96,7 @@ export function mountToday(ctx) {
89
96
  if (el.parentNode) el.parentNode.scrollTop = st;
90
97
  const c2 = document.getElementById('tdCap'); if (c2 && focus) { c2.focus(); c2.setSelectionRange(c2.value.length, c2.value.length); }
91
98
  }
92
- const rowOf = (key) => (X.model ? X.model.rows.find((r) => r.key === key) : null);
99
+ const rowOf = (key) => (X.model ? X.model.rows.flatMap((r) => [r, ...(r.members || [])]).find((r) => r.key === key) : null);
93
100
  const snap = (r) => ({ title: r.title, work: r.work, job: r.job, type: r.type });
94
101
  async function mark1(key, act, extra) {
95
102
  const r = await ctx.pmPost('/api/today-log/mark', { key, act, day: day(), ...extra }).catch(() => null);
@@ -121,6 +128,7 @@ export function mountToday(ctx) {
121
128
  function open(r) {
122
129
  if (!r) return;
123
130
  const ref = r.ref || {};
131
+ if (r.members) { if (X.sopen.has(r.key)) X.sopen.delete(r.key); else X.sopen.add(r.key); draw(); return; } // the same step for N initiatives: list them
124
132
  X.last = r.key; // ↑ ↓ (j k) step from here (round 3 point 6)
125
133
  if (r.src === 'ask') {
126
134
  // a mention opens that one mention in the popup, about it, with the chat hidden (round 3 points 1 to 7); never the Mentions list
@@ -209,6 +217,15 @@ export function mountToday(ctx) {
209
217
  ctx.toastUndo('Dropped from your log.', async () => { const u = await mark(r.key, 'undrop'); after(false); return u; });
210
218
  return after(false);
211
219
  }
220
+ /** ✓ on "N initiatives have no PRD": PMOS starts one draft per initiative, each for the PM to read; ✕ is not offered again for a month. */
221
+ async function same(r, yes) {
222
+ if (!yes) { const m = await mark1(r.key, 'keep', {}); if (!m.ok) return ctx.toast('It did not go through: ' + m.error + '.'); ctx.toast('PMOS will not offer it again for a month.'); return after(false); }
223
+ const ids = r.members.map((x) => x.ref && x.ref.call && x.ref.call.id).filter(Boolean);
224
+ const res = ctx.startCalls ? await ctx.startCalls(ids).catch(() => null) : null;
225
+ if (!res || !res.started) return ctx.toast((res && res.error) || 'PMOS did not start them. Nothing changed.');
226
+ ctx.toast('PMOS started ' + res.started + (res.started === 1 ? ' draft' : ' drafts') + '. Each waits for you to read' + (res.failed ? '; ' + res.failed + ' did not start' : '') + '.');
227
+ return after(true);
228
+ }
212
229
  async function keep(r) {
213
230
  const m = await mark(r.key, 'keep');
214
231
  if (!m.ok) return ctx.toast('It was not kept: ' + m.error + '.');
@@ -322,6 +339,7 @@ export function mountToday(ctx) {
322
339
  else if (act === 'keep') await keep(r);
323
340
  else if (act === 'lab-keep' || act === 'lab-drop') await lab(r, act === 'lab-keep');
324
341
  else if (act === 'lk-yes' || act === 'lk-no') await looks(r, act === 'lk-yes');
342
+ else if (act === 'same-yes' || act === 'same-no') await same(r, act === 'same-yes');
325
343
  } finally { X.busy.delete(key); if (b.isConnected) b.disabled = false; }
326
344
  });
327
345
  // the first line: Enter adds the row, and nothing else happens (no popup, no session)
@@ -63,6 +63,9 @@ const DECIDE_RE = /^(decide|confirm|choose|pick|approve|accept|sign|agree|review
63
63
  const jobOfAsk = (r) => (r.kind === 'call' ? (r.call && r.call.kind === 'update' ? 'Send' : DECIDE_RE.test(String((r.call && r.call.name) || r.title || '')) ? 'Decide' : 'Do')
64
64
  : r.kind === 'mention' ? 'Reply' : SEND_KINDS.has(r.kind) ? 'Send' : r.kind === 'kr' || r.kind === 'extra' ? 'Do' : 'Decide');
65
65
  const cap1 = (s) => String(s || '').replace(/^[a-z]/, (c) => c.toUpperCase());
66
+ /** No ids in a title (audit round 2): "KR-A1 Signup conversion up: …" reads "Signup conversion up: …". */
67
+ const ID_SHAPED = /^(?:[0-9a-f]{8,}|[a-z0-9]+(?:[-_][a-z0-9]+)+)$/;
68
+ export const noId = (t) => String(t || '').replace(/^(?:[A-Z]{1,4}-[A-Z0-9][\w.]*|health:[\w-]+)\s+/, '');
66
69
  /** An ask's What and Work, split as the board says them: the rank names a row "<work>: <what>" (a verdict, a grill finding, a meeting's or a
67
70
  * program's milestone changes, the changes to keep); What is the thing to do, Work the initiative or program it is about. */
68
71
  export function splitAsk(r, workName) {
@@ -145,6 +148,8 @@ export function logModel(o = {}) {
145
148
  const marks = o.marks || {}, titleOf = typeof o.titleOf === 'function' ? o.titleOf : () => '';
146
149
  const out = [], seen = new Set(), old = [];
147
150
  const work = (ini, fallback) => (ini ? titleOf(ini) || fallback || '' : fallback || '');
151
+ // a product's display name (o.productOf(ws)); a bare id ("pmos-idpf", a hex hash) is never shown
152
+ const productOf = (x) => { const v = String(x || '').trim(); if (!v) return ''; const n = typeof o.productOf === 'function' ? o.productOf(v) || '' : ''; return n || (ID_SHAPED.test(v) ? '' : v); };
148
153
  const put = (r) => {
149
154
  if (!r.key || seen.has(r.key)) return;
150
155
  seen.add(r.key);
@@ -185,8 +190,10 @@ export function logModel(o = {}) {
185
190
  did: didLeft(m).did, ...(m.looks ? { looks: { who: String(m.looks.who || '').trim().split(/\s+/)[0], text: m.looks.text } } : {}) });
186
191
  continue;
187
192
  }
188
- put({ key: c ? 'call:' + c.id : r.key, src: 'ask', bullet: 'task', title: sp.what || r.title || (c && c.name) || '', ini: r.ini || (c && c.ini) || null, ws: r.ws || '',
189
- work: work(r.ini || (c && c.ini), c ? c.sub : (r.shared || [])[0] || '') || sp.work, job: jobOfAsk(r), carried, late: carried >= LATE_DAYS,
193
+ // Work holds an initiative; a product shows by its display name, never its id (audit round 2)
194
+ const prodW = c ? c.sub : (r.shared || []).map((x) => productOf(x)).filter(Boolean)[0] || productOf(r.ws || '');
195
+ put({ key: c ? 'call:' + c.id : r.key, src: 'ask', bullet: 'task', title: noId(sp.what || r.title || (c && c.name) || ''), ini: r.ini || (c && c.ini) || null, ws: r.ws || '',
196
+ work: work(r.ini || (c && c.ini), prodW) || sp.work, job: jobOfAsk(r), carried, late: carried >= LATE_DAYS,
190
197
  when: whenWord({ carried, send }, today), first: r.rank <= 2 || (c && c.kind === 'update' && /^(today|now)/i.test(String(c.when || ''))) || false, ref: r });
191
198
  }
192
199
  // the rest of Your move: the PM's own late tasks and the next steps (a call is in the asks already; an item is in the items)
@@ -227,6 +234,7 @@ export function logModel(o = {}) {
227
234
  const ex = (rank.expired || []).length;
228
235
  if (ex) out.push({ key: 'expired:' + today, keys: ['expired:' + today], src: 'note', bullet: 'note', type: 'Note', first: false, title: plural(ex, 'ask', 'asks') + ' expired after 14 days with no answer. PMOS wrote why in History',
229
236
  work: '', ini: null, ws: '', job: 'Note', when: '', late: false, carried: 0, done: false, drop: false, dates: 'mark', ref: null });
237
+ sameJob(out, marks);
230
238
  const open = out.filter((r) => !r.done), done = out.filter((r) => r.done);
231
239
  const n = (j) => open.filter((r) => r.job === j).length;
232
240
  const counts = { decide: n('Decide'), do: n('Do'), reply: n('Reply'), send: n('Send'), notes: open.filter((r) => r.bullet === 'note').length, events: open.filter((r) => r.bullet === 'event').length };
@@ -241,14 +249,37 @@ export function logModel(o = {}) {
241
249
  const merged = open.reduce((k, r) => k + (r.merged ? r.merged - 1 : 0), 0);
242
250
  return { rows: G.first.concat(G.today, done, G.wait), first: G.first, todayRows: G.today.concat(done), wait: G.wait, open: open.length, done: done.length, counts, types, merged, line, today, old };
243
251
  }
252
+ /** SAME JOB, MANY INITIATIVES (audit round 2): open asks that read the same for two or more initiatives ("Draft the PRD, or let PMOS draft
253
+ * it" five times) become one row: "5 initiatives have no PRD", its members under it when opened. When each one is a step PMOS drafts, a ✦
254
+ * line says "PMOS drafts them for you to read" with ✓ ✕ (✕ is kept for a month as the mark kept on the group). In place, on out. */
255
+ export function sameJob(out, marks = {}) {
256
+ const by = new Map();
257
+ for (const r of out) {
258
+ if (r.done || r.src !== 'ask' || !r.ref || r.ref.kind !== 'call' || !(r.ini || r.work)) continue;
259
+ const k = r.job + '|' + String(r.title).toLowerCase(); if (!by.has(k)) by.set(k, []); by.get(k).push(r);
260
+ }
261
+ for (const L of by.values()) {
262
+ const inis = new Set(L.map((r) => r.ini || r.work)); if (inis.size < 2) continue; // the initiative, or its name when the call carries no id
263
+ const t = L[0].title, m = /^Draft the (.+?)(?:, or let PMOS draft it)?$/i.exec(t), n = inis.size;
264
+ const key = 'same:' + String(t).toLowerCase().replace(/[^a-z0-9]+/g, '-'), mk = marks[key] || {};
265
+ const at = out.indexOf(L[0]);
266
+ const row = { ...L[0], key, keys: L.flatMap((r) => r.keys || [r.key]), title: m ? n + ' initiatives have no ' + m[1] : n + ' initiatives: ' + t, ini: null, work: '',
267
+ carried: Math.max(...L.map((r) => r.carried || 0)), late: L.some((r) => r.late), first: L.some((r) => r.first), members: L.map((r) => ({ ...r, member: true, title: r.work || r.title, work: '', type: '', job: '', reason: '' })), ref: { kind: 'same' }, // under the group each one is named by its initiative
268
+ drafts: !!m && !(mk.kept), reason: '' };
269
+ row.when = '';
270
+ for (const r of L) out.splice(out.indexOf(r), 1);
271
+ out.splice(Math.min(at, out.length), 0, row);
272
+ }
273
+ return out;
274
+ }
244
275
  /** PMOS HANDLED (design check of round 3, point 6): the asks the self check cleared today from proof (his reply, a closed ticket, the ask
245
276
  * taken back), as the folded last group, each with Undo. answered: the Mentions answered list; o: { today, now, cleared: ids PMOS saw
246
277
  * leave Today today }. A row: { id, title, proof }. An ask whose proof is from today, or that PMOS saw leave today, is one of them. */
247
278
  export function handledModel(answered, o = {}) {
248
279
  const today = o.today || dayKey(o.now || Date.now()), cleared = new Set(o.cleared || []);
249
- return (answered || []).filter((m) => m && m.auto && m.proof && (cleared.has(m.id) || dayKey(Date.parse(m.proof.at || '') || 0) === today))
280
+ return (answered || []).filter((m) => m && m.auto && m.proof && (cleared.has(m.id) || dayKey(Date.parse(m.proof.cleared || m.proof.at || '') || 0) === today))
250
281
  .map((m) => { const who = (Array.isArray(m.people) && m.people.length ? m.people : [m.who || '']).map((x) => String(x).trim().split(/\s+/)[0]).filter(Boolean);
251
- return { id: m.id, title: (who.length ? names(who) + ': ' : '') + askTitle(m), proof: proofText(m.proof, o.now) }; });
282
+ return { id: m.id, title: (who.length ? names(who) + ': ' : '') + askTitle(m), proof: proofText(m.proof, o.now, { full: true }) }; });
252
283
  }
253
284
  /** A task late more than this many days is an old import, not a Today row (round 3 point 12). */
254
285
  export const OLD_TASK_DAYS = 30;
@@ -270,6 +301,7 @@ export function whyOf(r, today) {
270
301
  if (r.src === 'draft') return 'PMOS finished it, needs your look';
271
302
  if (r.src === 'review') return 'Your weekly review is open';
272
303
  if (r.src === 'lab') return 'PMOS found it, keep or drop';
304
+ if (ref.kind === 'same') return ''; // the title says it already; the ✦ line is the whole of it (design check of #1392)
273
305
  if (c) {
274
306
  if (c.kind === 'update') return c.when ? 'Goes out ' + c.when : 'Ready to send';
275
307
  if (c.kind === 'session' && (c.state === 'blocked' || c.state === 'needs')) return 'A session waits on you';
@@ -382,18 +414,18 @@ export function agendaModel(o = {}) {
382
414
  items.push({ key: 'r:' + (r.key || r.title), kind: 'report', title: r.title || 'A report', sub: r.time + ' · the report goes out', a: a.getTime(), b: a.getTime() + 30 * 60000, ini: null, ref: r });
383
415
  }
384
416
  items.sort((x, y) => x.a - y.a);
385
- // focus time: the first open row of the log, in the first free stretch of 30 minutes or more from now until 18:00 (a dashed box)
386
- const F = o.focus;
387
- if (F && F.key && F.title) {
417
+ // focus time: the first open row of the log, in the first free gap of 30 minutes or more BETWEEN two events from now (a dashed box; audit
418
+ // round 2: it ends at the next event, never after the last one, and none on a day with no events)
419
+ const F = o.focus, evs = items.filter((y) => y.kind === 'meeting' || y.kind === 'own');
420
+ if (F && F.key && F.title && evs.length) {
388
421
  const end = new Date(now); end.setHours(18, 0, 0, 0);
389
422
  const d8 = new Date(now); d8.setHours(8, 0, 0, 0); // focus time is in the working day: from now, never before 08:00
390
423
  let at = Math.max(Math.ceil(now / (5 * 60000)) * 5 * 60000, d8.getTime()), got = null;
391
- for (const x of items.filter((y) => y.kind !== 'report')) {
424
+ for (const x of evs) { // the gap ends at the next event's start; the stretch after the last event is not a gap
392
425
  if (x.b <= at) continue;
393
426
  if (x.a - at >= 30 * 60000) { got = [at, Math.min(x.a, end.getTime())]; break; }
394
427
  at = Math.max(at, x.b);
395
428
  }
396
- if (!got && end.getTime() - at >= 30 * 60000) got = [at, end.getTime()];
397
429
  if (got && got[1] - got[0] >= 30 * 60000) {
398
430
  items.push({ key: 'f:' + F.key, kind: 'focus', title: F.title, sub: hm(got[0]) + ' to ' + hm(got[1]) + ' · focus time PMOS holds for this call', a: got[0], b: got[1], ini: null, ref: F, row: F.key });
399
431
  items.sort((x, y) => x.a - y.a);
@@ -421,7 +453,9 @@ export function agendaModel(o = {}) {
421
453
  const sub = DOW[d.getDay()] + ' ' + d.getDate() + ' ' + MON[d.getMonth()] + (free ? ' · ' + durWord(free) + ' free' : '');
422
454
  const meets = items.filter((x) => x.kind === 'meeting' || x.kind === 'own');
423
455
  const nx = meets.find((x) => x.a >= now);
424
- return { items, from, to, now: t >= 0 && t <= to - from ? t : null, sub, empty: !items.length, free, next: nx ? hm(nx.a) : '', nextFirst: !!nx && !meets.some((x) => x.a < now) };
456
+ // a day with no event: one quiet line, not an empty grid (audit round 2)
457
+ const quiet = meets.length ? '' : 'No events today' + (free ? ' · ' + durWord(free) + ' free' : '');
458
+ return { items, from, to, now: t >= 0 && t <= to - from ? t : null, sub, empty: !items.length, quiet, free, next: nx ? hm(nx.a) : '', nextFirst: !!nx && !meets.some((x) => x.a < now) };
425
459
  }
426
460
 
427
461
  const DOW_LONG = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
@@ -156,4 +156,12 @@ button.td-ev:focus-visible { outline: 2px solid var(--cz-blue); outline-offset:
156
156
  /* PMOS handled · N (design check of round 3): the asks the self check cleared today, each with Undo */
157
157
  .td-undo { border: 0; background: none; padding: 4px 6px; font: inherit; font-size: var(--fs-meta); color: var(--cz-blueink); cursor: pointer; }
158
158
  .td-undo:hover, .td-undo:focus-visible { text-decoration: underline; }
159
- .td-r.hd .td-rs { text-decoration: none; }
159
+ .td-r.hd .td-rs { text-decoration: none; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; } /* the proof in full: it is why he can trust it */
160
+ .td-r.hd .td-a { opacity: 1; } /* Undo on every handled row, not only on hover */
161
+ /* audit round 2: the same step for N initiatives lists its members under it when opened; a day with no event is one quiet line */
162
+ .td-t svg { vertical-align: -2px; margin-left: 4px; color: var(--cz-ink3); }
163
+ .td-t[aria-expanded="true"] svg { transform: rotate(180deg); }
164
+ .td-r.mem .td-wt { padding-left: 18px; }
165
+ .td-r.mem .td-t { font-weight: var(--fw-regular); }
166
+ .td-ag.quiet { align-self: start; }
167
+ .td-quiet { margin: 6px 0 0; font-size: var(--fs-row); color: var(--cz-ink2); }