create-pmos 0.398.0 → 0.399.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 (126) hide show
  1. package/package.json +13 -13
  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/briefing-premium-adddoc-test.js +18 -14
  7. package/workspace/briefing-premium-board-test.js +80 -48
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +6 -2
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +46 -42
  18. package/workspace/briefing-premium-work-test.js +9 -9
  19. package/workspace/changelog.json +12 -0
  20. package/workspace/ev-everywhere-test.js +210 -0
  21. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  22. package/workspace/guide/home.md +39 -18
  23. package/workspace/guide/index.md +1 -1
  24. package/workspace/lib/board-grill.js +63 -0
  25. package/workspace/lib/board-premium.js +36 -5
  26. package/workspace/lib/initiative-layout.js +77 -0
  27. package/workspace/lib/insights-premium.js +3 -2
  28. package/workspace/lib/insights-records.js +21 -7
  29. package/workspace/lib/meeting-points.js +52 -0
  30. package/workspace/lib/news-for-you.js +88 -0
  31. package/workspace/lib/notes-series.js +29 -6
  32. package/workspace/lib/report-confirm.js +48 -0
  33. package/workspace/lib/route-modules.js +8 -0
  34. package/workspace/lib/routes-board-docs.js +46 -0
  35. package/workspace/lib/routes-board-grill.js +90 -0
  36. package/workspace/lib/routes-home-review.js +108 -0
  37. package/workspace/lib/routes-initiative-layout.js +57 -0
  38. package/workspace/lib/routes-insights-premium.js +4 -1
  39. package/workspace/lib/routes-insights-records.js +8 -4
  40. package/workspace/lib/routes-meeting-points.js +37 -0
  41. package/workspace/lib/routes-news.js +57 -0
  42. package/workspace/lib/routes-notes.js +2 -1
  43. package/workspace/lib/routes-report-confirm.js +31 -0
  44. package/workspace/lib/routes-search.js +38 -0
  45. package/workspace/lib/search-index.js +176 -0
  46. package/workspace/package-lock.json +2 -2
  47. package/workspace/package.json +1 -1
  48. package/workspace/premium-board-actions-test.js +86 -50
  49. package/workspace/premium-briefing-depth-test.js +55 -54
  50. package/workspace/premium-chat-chart-tab-test.js +4 -2
  51. package/workspace/premium-chat-report-tab-test.js +16 -2
  52. package/workspace/premium-core-doc-issue-test.js +15 -13
  53. package/workspace/premium-phone-card-test.js +5 -3
  54. package/workspace/premium-report-read-test.js +55 -18
  55. package/workspace/premium-vw-backlog-test.js +2 -2
  56. package/workspace/premium-vw-cal-test.js +50 -35
  57. package/workspace/premium-vw-doc-test.js +9 -3
  58. package/workspace/premium-vw-item-test.js +1 -1
  59. package/workspace/premium-vw-jira-test.js +2 -2
  60. package/workspace/premium-vw-meet-test.js +37 -40
  61. package/workspace/premium-vw-notes-test.js +21 -19
  62. package/workspace/premium-vw-rec-test.js +11 -12
  63. package/workspace/premium-welcome-test.js +3 -3
  64. package/workspace/premium-work-depth-test.js +3 -3
  65. package/workspace/public/pm/bd-acts.js +303 -225
  66. package/workspace/public/pm/bd-asks.js +261 -0
  67. package/workspace/public/pm/bd-pop.js +59 -0
  68. package/workspace/public/pm/bd-span.js +49 -13
  69. package/workspace/public/pm/bd-views.js +169 -0
  70. package/workspace/public/pm/cozy-board.css +301 -0
  71. package/workspace/public/pm/cozy-ev.css +228 -0
  72. package/workspace/public/pm/cozy-evmodel.js +106 -0
  73. package/workspace/public/pm/cozy-evui.js +47 -0
  74. package/workspace/public/pm/cozy-insights.css +148 -10
  75. package/workspace/public/pm/cozy-nav.js +103 -39
  76. package/workspace/public/pm/cozy-news.js +140 -0
  77. package/workspace/public/pm/cozy-search.js +203 -0
  78. package/workspace/public/pm/cozy-settings.js +198 -0
  79. package/workspace/public/pm/cozy-sources.js +89 -0
  80. package/workspace/public/pm/cozy-today.css +217 -0
  81. package/workspace/public/pm/cozy-viewer.js +1 -0
  82. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  83. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  84. package/workspace/public/pm/home-adddoc.js +5 -5
  85. package/workspace/public/pm/home-app.js +329 -55
  86. package/workspace/public/pm/home-around.js +24 -126
  87. package/workspace/public/pm/home-chat.js +67 -14
  88. package/workspace/public/pm/home-data.js +6 -6
  89. package/workspace/public/pm/home-dictate.js +54 -0
  90. package/workspace/public/pm/home-draft.js +6 -6
  91. package/workspace/public/pm/home-ini-model.js +190 -0
  92. package/workspace/public/pm/home-ini.css +171 -0
  93. package/workspace/public/pm/home-ini.js +456 -0
  94. package/workspace/public/pm/home-list.js +276 -0
  95. package/workspace/public/pm/home-more.js +17 -134
  96. package/workspace/public/pm/home-phone-card.js +4 -4
  97. package/workspace/public/pm/home-review.js +104 -0
  98. package/workspace/public/pm/home-task.js +67 -0
  99. package/workspace/public/pm/home-today.js +144 -0
  100. package/workspace/public/pm/home-work.js +54 -26
  101. package/workspace/public/pm/premium-board.js +163 -39
  102. package/workspace/public/pm/premium-chart-tab.js +4 -5
  103. package/workspace/public/pm/premium-first.js +5 -7
  104. package/workspace/public/pm/premium-insights.js +499 -202
  105. package/workspace/public/pm/premium-mtg-present.js +138 -0
  106. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  107. package/workspace/public/pm/premium-report-read.js +216 -52
  108. package/workspace/public/pm/premium-report-tab.js +44 -19
  109. package/workspace/public/pm/premium-shell.js +7 -7
  110. package/workspace/public/pm/premium-vw-cal.js +150 -60
  111. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  112. package/workspace/public/pm/premium-vw-notes.js +61 -0
  113. package/workspace/public/pm/rp-parts.js +269 -0
  114. package/workspace/public/premium-board.html +4 -3
  115. package/workspace/public/premium-insights.html +10 -10
  116. package/workspace/public/premium.html +3 -1
  117. package/workspace/r/m1.png +0 -0
  118. package/workspace/r/m2.png +0 -0
  119. package/workspace/r/m3.png +0 -0
  120. package/workspace/r/nl.png +0 -0
  121. package/workspace/test-lists/initiative-layout.json +9 -0
  122. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  123. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  124. package/workspace/test-lists/uf-everywhere.json +15 -0
  125. package/workspace/test-lists/uf-home.json +9 -0
  126. package/workspace/test-lists/uncovered-board.json +9 -0
@@ -1,14 +1,17 @@
1
1
  /* pm/home-app.js — Home in the Agreed design (initiative premium-agreed-design, Home; mockup Main.dc.html place="work": AgHome, AgHomePhone,
2
- * AgInit*, AgProduct, AgChat*).
2
+ * AgInit*, AgProduct, AgChat*), with the one list of the Uncovered features canvas (initiative premium-uncovered-features, H1 and H2:
3
+ * HmMyWork, HmReview, HmProducts, HmMic, HmDay, HmDecide, HmPhone, HmPhone2).
3
4
  *
4
- * One desk. The list on the left: Today with New and the fold, the meeting line (+N, the record dot), then only three groups, Needs you
5
- * (the top 3 and "N more · Show"), Initiatives (the product first) and Loose. An initiative is a layout of this page (?ini=<id>): its card
6
- * sits at the top of the list with its own groups and the Elsewhere card under it. The chat is in the middle (home-chat.js) and the Viewer
7
- * on the right (cozy-viewer.js). On a phone the chat is the page; the top bar names what is open and "N need you" opens the list as a sheet.
5
+ * One desk. The list on the left is one list grouped by product (home-list.js builds it, home-today.js draws it): the Today card through
6
+ * the day, the filters (Today, Waiting, Kept, Done), each product's group with its initiatives (yours first, marked "your turn") and their
7
+ * tasks, next steps, sessions and meetings under them, then "Not in an initiative", the capture box and the untouched work. There is no
8
+ * Needs you group and no Your list. An initiative is a layout of this page (?ini=<id>): its card sits at the top of the list with its own
9
+ * groups and the Elsewhere card under it. The chat is in the middle (home-chat.js) and the Viewer on the right (cozy-viewer.js): a task opens
10
+ * there (home-task.js), and so does the weekly review (home-review.js). On a phone the list is the page; a row opens its conversation over
11
+ * it, with a back bar.
8
12
  *
9
- * The models are in home-data.js (pure). This file reads the routes, draws, and wires the presses. Every write is the PM's press (pmPost).
10
- * The features the design does not draw yet open from a quiet entry (the ⋯ menu on a phone, the place menu on desktop) as minimal
11
- * versions with a "Waiting for design" marker (home-more.js). Nothing here opens the old dialog or links to the console. */
13
+ * The models are in home-data.js and home-list.js (pure). This file reads the routes, draws, and wires the presses. Every write is the PM's
14
+ * press (pmPost). Nothing here opens the old dialog or links to the console. */
12
15
  import { mountNav } from './cozy-nav.js';
13
16
  import * as VW from './cozy-viewer.js';
14
17
  import { pmGet, pmPost, pmHeaders } from './http.js';
@@ -20,13 +23,17 @@ import { startAgent } from './page-agent.js';
20
23
  import { mdHtml } from './chat-md.js';
21
24
  import { mountPhoneCard } from './home-phone-card.js';
22
25
  import { mountFirst } from './premium-first.js';
26
+ import * as L from './home-list.js';
27
+ import * as TD from './home-today.js';
28
+ import { canDictate, dictate } from './home-dictate.js';
29
+ import { mountIni, iniList, iniOverview } from './home-ini.js'; // the initiative's stage move, Tasks and Core documents (premium-uncovered-features)
23
30
 
24
31
  const $ = (s, r = document) => r.querySelector(s);
25
32
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
26
33
  const P = new URLSearchParams(location.search);
27
34
  const WS = P.get('ws') || '';
28
35
  let PHC = null; // the phone moment card (home-phone-card.js): the top of the phone's sheet
29
- const FST = mountFirst(); // the first-run card after an import (?first=<import id>, premium-first.js): the top of the list, Waiting for design
36
+ const FST = mountFirst(); // the first-run card after an import (?first=<import id>, premium-first.js): the top of the list
30
37
  const wsQ = (pre = '?') => (WS ? pre + 'ws=' + encodeURIComponent(WS) : '');
31
38
  const BOARD = P.get('board') || ''; // the Board's expand link names its board: Home reads that board, not the default one
32
39
  const boardQ = (pre = '?') => (BOARD ? pre + 'board=' + encodeURIComponent(BOARD) : '');
@@ -44,6 +51,7 @@ const ROW_ICON = { gate: I.gate, warn: I.warn, clock: I.clock, doc: I.doc, chat:
44
51
  const COMMS = { key: 'comms', name: 'Communicator', initial: 'Co' };
45
52
  const CLAUDE = { key: 'claude', name: 'Claude', initial: 'C' };
46
53
  const RET_REASONS = ['wrong facts', 'wrong scope', 'not now', 'too long'];
54
+ const RET_LABEL = { 'wrong facts': 'Facts are wrong', 'wrong scope': 'Wrong scope', 'not now': 'Not needed now', 'too long': 'Too long' };
47
55
  const store = {
48
56
  get(k) { try { return localStorage.getItem(k); } catch { return null; } },
49
57
  set(k, v) { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, v); } catch { /* a private window */ } },
@@ -66,6 +74,10 @@ const S = {
66
74
  IM: null, IMid: null, // the selected initiative's model (GET /api/initiative-premium)
67
75
  doneOpen: false, sheet: false, rec: {}, pin: new Set(JSON.parse(store.get('pmos.home.pin') || '[]')),
68
76
  cardFold: store.get('pmos.home.cardfold') === '1', // the card's checklist folded to one line (AgInitSpec), kept in this browser
77
+ // the one list (premium-uncovered-features): the filter, the picked product, which groups and initiatives are open, kept in this browser
78
+ filter: 'today', product: store.get('pmos.home.product') || null, kidsOff: new Set(), rest: new Set(),
79
+ pg: (() => { try { return JSON.parse(store.get('pmos.home.pg') || '{}') || {}; } catch { return {}; } })(),
80
+ eodHidden: store.get('pmos.home.eod') === L.dayOf(), phoneChat: false,
69
81
  };
70
82
  const toast = (t) => { const el = $('#toast'); el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
71
83
 
@@ -79,9 +91,9 @@ async function getRetry(path, tries = 20) {
79
91
  return { ok: false, error: 'still reading' };
80
92
  }
81
93
  async function load() {
82
- const [brief, board, ses, desk, today, sch] = await Promise.all([
94
+ const [brief, board, ses, desk, today, sch, work, day, rev] = await Promise.all([
83
95
  getRetry('/api/briefing-premium' + wsQ()), getRetry('/api/board-premium' + wsQ() + boardQ(WS ? '&' : '?')), pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ()),
84
- pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()),
96
+ pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()), pmGet('/api/my-work-premium' + wsQ()), pmGet('/api/phone-day'), pmGet('/api/home-review' + wsQ()),
85
97
  ]);
86
98
  const D = S.D;
87
99
  D.brief = brief && brief.ok && brief.model ? brief.model : null;
@@ -90,6 +102,9 @@ async function load() {
90
102
  D.desk = desk && desk.ok ? desk : null;
91
103
  D.today = today && today.ok ? today : null;
92
104
  D.schedules = sch && Array.isArray(sch.schedules) ? sch : null;
105
+ D.work = work && work.ok && work.model ? work.model : null; // the PM's own list (GET /api/my-work-premium): the filters and "Not in an initiative"
106
+ D.phoneDay = day && day.ok ? day : null; // what finished today, the recap and tomorrow (the end-of-day card, the Done filter)
107
+ D.review = rev && rev.ok ? rev : null; // this week's review (GET /api/home-review)
93
108
  D.now = Date.now();
94
109
  D.err = [brief, board].filter((x) => !x || !x.ok).map((x) => (x && x.error) || 'the server did not answer');
95
110
  const rows = H.boardRows(D);
@@ -98,9 +113,24 @@ async function load() {
98
113
  const tr = await pmGet('/api/board-trail?ids=' + encodeURIComponent(rows.slice(0, 150).map((r) => r.id).join(',')) + (b.ws ? '&ws=' + encodeURIComponent(b.ws) : wsQ('&')) + (b.id ? '&board=' + encodeURIComponent(b.id) : boardQ('&')));
99
114
  D.trail = tr && tr.ok ? tr : null;
100
115
  }
116
+ // the PMOS tasks of the board, so each sits under its initiative
117
+ const b0 = (D.board && D.board.board) || {};
118
+ const items = b0.id ? await pmGet('/api/boards/items?ws=' + encodeURIComponent(b0.ws || WS || '') + '&board=' + encodeURIComponent(b0.id)) : null;
119
+ D.items = items && items.ok ? items : null;
120
+ D.others = D.others || [];
101
121
  S.ready = true;
102
122
  await loadIni();
103
123
  draw();
124
+ // the boards of the other products Home reads, each its own closed group: read after the list is drawn, so a slow one never holds it up
125
+ const others = await Promise.all(otherProducts(D).map((a) => getRetry('/api/board-premium?ws=' + encodeURIComponent(a.ws), 4).then((r) => (r && r.ok && r.model ? { ws: a.ws, name: a.name, model: r.model } : null))));
126
+ const got = others.filter(Boolean);
127
+ if (got.length || D.others.length) { D.others = got; drawList(); }
128
+ }
129
+ /** The products Home reads (Products, on) other than the board's own: each is a group of the list, read from its own board. At most four. */
130
+ function otherProducts(D) {
131
+ const av = (D.brief && D.brief.products && D.brief.products.available) || [];
132
+ const own = ((D.board && D.board.board) || {}).ws || WS;
133
+ return av.filter((a) => a.on && a.ws && a.ws !== own).slice(0, 4);
104
134
  }
105
135
  async function loadIni() {
106
136
  const id = S.ini;
@@ -150,28 +180,37 @@ function groupHtml(key, title, rows, extra = '', head = '') {
150
180
  return `<section class="hm-g" aria-label="${esc(title)}"><div class="hm-ghr"><button type="button" class="hm-gh" data-hm-group="${esc(key)}" aria-expanded="${!shut}">${SVG(shut ? I.chev : I.down, 12, 2.2)}<span>${esc(title)}</span></button>${head}</div>`
151
181
  + (shut ? '' : rows.map((r) => rowHtml(r)).join('') + extra) + '</section>';
152
182
  }
153
- function meetHtml() {
154
- const m = H.meetLineOf(S.D.today);
155
- const live = recLive();
156
- const rec = live ? `<button type="button" class="hm-mp rec on" data-hm-recopen="${esc(live.id)}" aria-label="Recording: ${esc(live.title || 'a meeting')}. Open it" title="Recording: ${esc(live.title || 'a meeting')}"><i aria-hidden="true"></i></button>`
157
- : `<button type="button" class="hm-mp rec" data-hm-rec aria-label="Record a note now" title="Record a note now"><i aria-hidden="true"></i></button>`;
158
- if (!m) return `<div class="hm-meet"><button type="button" class="hm-mt" data-hm-cal>${SVG(I.clock, 16)}<span><b>No meeting left today</b></span></button>${rec}</div>`;
159
- return `<div class="hm-meet"><button type="button" class="hm-mt" data-hm-meet aria-label="${esc(m.aria)}">${SVG(I.clock, 16)}<span><b>${esc(m.time)}</b> ${esc(m.meeting.title)}${m.note ? ` · <em>${esc(m.note)}</em>` : ''}</span></button>`
160
- + (m.more ? `<button type="button" class="hm-mp" data-hm-cal aria-label="${m.more} more ${m.more === 1 ? 'meeting' : 'meetings'} today. Open the calendar">+${m.more}</button>` : '') + rec + '</div>';
183
+ /* ── the one list (premium-uncovered-features: HmMyWork, HmProducts, HmDay, HmMic, HmReview, HmPhone) ── */
184
+ const NOW = () => S.D.now || Date.now();
185
+ function recOf() { // a recording that is on and is no calendar meeting: the Today card shows it (HmMic)
186
+ const r = recLive(); if (!r) return null;
187
+ const n = REC && REC.note ? REC.note(r.id) : null;
188
+ const meeting = !!(n && (n.meeting || n.event || n.calendar));
189
+ return { id: r.id, title: r.title || (n && n.title) || '', at: (REC && REC.started && REC.started()) || (n && (n.started || n.created)) || null, paused: !!(n && n.state === 'paused'), meeting };
190
+ }
191
+ function todayModel() {
192
+ const T = L.todayCard(S.D, { now: NOW(), rec: recOf(), hidden: S.eodHidden, titleOf: (id) => iniTitle(id) });
193
+ const R = L.reviewModel(S.D, NOW());
194
+ if (T.mode === 'day' && R.open && R.started) {
195
+ const left = R.steps.filter((x) => !x.done).length;
196
+ return { mode: 'review', big: 'Friday. Your weekly review is open.', sub: 'Step ' + (R.at + 1) + ' of 4 · about ' + left * 3 + ' minutes left' };
197
+ }
198
+ return T;
161
199
  }
162
200
  function homeListHtml() {
163
- const L = H.homeLists(S.D, { allNeeds: S.allNeeds });
164
- S.L = L;
165
- const pinned = L.needs.rows.filter((r) => S.pin.has(r.key));
166
- const needRows = pinned.concat(L.needs.rows.filter((r) => !S.pin.has(r.key)));
167
- const more = !S.allNeeds && L.needs.more ? `<button type="button" class="hm-more" data-hm-allneeds>${L.needs.more} more · Show</button>` : S.allNeeds && L.needs.all > 3 ? '<button type="button" class="hm-more" data-hm-allneeds>Show fewer</button>' : '';
168
- const err = !S.ready ? '<p class="hm-none" role="status">Reading your work.</p>' : S.D.err.length && !L.initiatives.length && !L.needs.all ? `<p class="hm-none" role="status">Home could not read the repository: ${esc(S.D.err[0])}.</p>` : '';
169
- return `<div class="hm-hd"><h1>Today</h1><button type="button" class="hm-new" data-hm-new aria-haspopup="menu">${SVG(I.plus, 14, 2.2)}New</button>`
170
- + `<button type="button" class="hm-ib" data-hm-fold aria-label="Fold the list" title="Fold the list">${SVG(I.fold, 16)}</button></div>`
171
- + meetHtml() + err
172
- + (L.needs.all ? groupHtml('needs', 'Needs you', needRows, more) : S.ready ? '<section class="hm-g"><p class="hm-none">Nothing needs you now.</p></section>' : '')
173
- + (L.initiatives.length ? groupHtml('inis', 'Initiatives', L.initiatives) : '')
174
- + (L.loose.length ? groupHtml('loose', 'Loose', L.loose) : '');
201
+ const M = L.homeList(S.D, { now: NOW(), filter: S.filter, product: S.product && L.productsOf(S.D).some((p) => p.key === S.product) ? S.product : null });
202
+ S.M = M;
203
+ const R = L.reviewModel(S.D, NOW());
204
+ // the first initiative where it is your turn shows what is under it, until the PM closes it
205
+ const firstTurn = M.groups.filter((g) => g.kind === 'product').flatMap((g) => g.inis).find((x) => x.turn);
206
+ const open = (id) => S.kids.has(id) || (!!firstTurn && firstTurn.id === id && !S.kidsOff.has(id));
207
+ const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.primary || M.products.length === 1 || (!!S.product && S.product === g.product.key));
208
+ const nPick = M.products.length > 1 ? M.counts.products + ' products · ' + M.counts.initiatives + ' initiatives' : '';
209
+ const pins = H.needsOf(S.D).filter((r) => S.pin.has(r.key)).length;
210
+ return TD.listHtml(M, todayModel(), {
211
+ sel: S.sel, isOpen: open, pOpen, restOpen: (k) => S.rest.has(k), pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
212
+ product: S.product, review: R, mic: canDictate(), sub: pins ? pins + ' pinned' : nPick || 'Each one sits under its initiative',
213
+ });
175
214
  }
176
215
 
177
216
  /* ── the initiative card ── */
@@ -270,13 +309,20 @@ function drawList() {
270
309
  let sc = el.querySelector(':scope > .hm-lsc'), ft = el.querySelector(':scope > .hm-lft');
271
310
  if (!sc || !ft) { el.innerHTML = '<div class="hm-lsc"></div><div class="hm-lft"></div>'; sc = el.firstElementChild; ft = el.lastElementChild; }
272
311
  const html = S.ini ? iniListHtml() : homeListHtml();
273
- if (sc.__h !== html) { const st = sc.scrollTop; sc.__h = html; sc.innerHTML = html; sc.scrollTop = st; }
312
+ if (sc.__h !== html) {
313
+ const st = sc.scrollTop, cap = sc.querySelector('#hmCap'), capV = cap ? cap.value : '', capF = !!cap && document.activeElement === cap;
314
+ sc.__h = html; sc.innerHTML = html; sc.scrollTop = st;
315
+ sc.querySelectorAll('.hm-load i[data-f]').forEach((i) => i.style.setProperty('--bd-f', i.dataset.f)); // the day's load: run-time geometry
316
+ const c2 = sc.querySelector('#hmCap'); if (c2 && capV) { c2.value = capV; } if (c2 && capF) c2.focus(); // a task being typed survives a redraw
317
+ }
274
318
  const fh = elseHtml();
275
319
  if (ft.__h !== fh) { ft.__h = fh; ft.innerHTML = fh; }
276
- // the first-run card after an import tops the list; the phone moment card (not in the Agreed design, Waiting for design) sits after the groups
320
+ iniList(sc);
321
+ // the first-run card after an import tops the list; the phone moment card sits after the groups
277
322
  if (FST && sc.firstElementChild !== FST) sc.prepend(FST);
278
323
  if (PHC && sc.lastElementChild !== PHC.el) sc.append(PHC.el);
279
324
  document.body.classList.toggle('hm-folded', S.folded && !isPhone());
325
+ document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
280
326
  }
281
327
 
282
328
  function draw() { drawList(); drawTop(); chat.refresh(); }
@@ -284,9 +330,12 @@ function draw() { drawList(); drawTop(); chat.refresh(); }
284
330
  /* ── rows by id ── */
285
331
  function allRows() {
286
332
  const out = [];
287
- const L = S.L || H.homeLists(S.D, { allNeeds: true });
333
+ const M = S.M || L.homeList(S.D, { now: NOW() });
288
334
  const add = (r) => { if (!r) return; out.push(r); (r.kids || []).forEach(add); };
289
- H.needsOf(S.D).forEach(add); L.initiatives.forEach(add); L.loose.forEach(add);
335
+ H.needsOf(S.D).forEach(add);
336
+ for (const g of M.groups) { (g.flat || []).forEach(add); (g.inis || []).forEach(add); (g.rest || []).forEach(add); (g.rows || []).forEach(add); }
337
+ if (M.list) M.list.rows.forEach(add);
338
+ if (S.filter !== 'today') { const T = L.homeList(S.D, { now: NOW() }); T.groups.forEach((g) => { (g.rows || []).forEach(add); (g.inis || []).concat(g.rest || []).forEach(add); }); }
290
339
  if (S.lay) S.lay.groups.forEach((g) => g.rows.forEach(add));
291
340
  for (const s of S.D.sessions) { const r = { id: 's:' + s.id, kind: 'session', sid: s.id, key: H.keyOfSession(s), ini: H.iniOfSession(s), name: (s.hx && s.hx.title) || s.name, role: H.roleOf(s, S.D.desk && S.D.desk.roles), state: s.shown }; out.push(r); }
292
341
  return out;
@@ -298,7 +347,7 @@ function drawTop() {
298
347
  const n = H.needsOf(S.D).length;
299
348
  const cur = S.cur || { title: 'Home', sub: '' };
300
349
  $('#hmTopTitle').textContent = cur.title; $('#hmTopSub').textContent = cur.sub || '';
301
- $('#hmNeedsN').textContent = !S.ready ? 'Reading' : n ? n + (n === 1 ? ' needs you' : ' need you') : 'Your list';
350
+ $('#hmNeedsN').textContent = !S.ready ? 'Reading' : n ? n + (n === 1 ? ' next step' : ' next steps') : 'Today';
302
351
  $('#hmNeeds').classList.toggle('loud', n > 0);
303
352
  document.title = 'PMOS · ' + (cur.title || 'Home');
304
353
  }
@@ -319,7 +368,7 @@ const chat = mountChat($('#hmChat'), {
319
368
  workItem: (text, t) => workItem(text, t),
320
369
  openTerminal: (sid) => openTerminal(sid),
321
370
  viewerClosed: () => !VW.isOpen() && !isPhone(),
322
- wait: MORE.WAIT,
371
+ wait: MORE.WAIT, // the Notes viewer only: the Home canvas does not draw it
323
372
  desk: () => !isPhone(),
324
373
  reopenViewer: () => reopenViewer(),
325
374
  });
@@ -370,15 +419,53 @@ function alsoOf(ini) {
370
419
  const n = other.find((r) => r.ini === ini) || other[0];
371
420
  return n ? { text: n.name, go: () => select(n.id) } : null;
372
421
  }
422
+ /* HmDecide: a decision is recorded in the chat, on a card under the agent's question: the choices, Why (kept in the journal), Record,
423
+ * Later (Later today, Tomorrow 09:00, Next week) and Pin. Nothing changes until the PM presses Record (POST /api/briefing-premium/decide). */
424
+ function decisionCard(r) {
425
+ const d = r.row.dialog || {};
426
+ const st = S.rec[r.key] || (S.rec[r.key] = { choice: d.sel || null, why: '', ret: null, note: '' });
427
+ if (st.whyShown == null) st.whyShown = st.why;
428
+ const ok = () => !!st.choice && st.why.trim().length >= 3;
429
+ return {
430
+ html: () => `<div class="ut-card ut-dec" role="group" aria-label="Your decision"><p class="ut-lbl">Your decision</p><div role="radiogroup" aria-label="Choices">${(d.opts || []).map((o) => `<button type="button" class="ut-radio" role="radio" aria-checked="${st.choice === o.k}" data-dc-opt="${esc(o.k)}"><span class="o" aria-hidden="true"></span><span><b>${esc(o.t)}</b>${o.d ? `<br><span class="ut-small ut-mut">${esc(o.d)}</span>` : ''}</span></button>`).join('')}</div>`
431
+ + `<div class="ut-field"><label for="dcWhy">Why <span class="ut-mut">· kept in the journal</span></label><textarea id="dcWhy" rows="2" placeholder="The reason goes in pm-decisions.md with your choice">${esc(st.whyShown)}</textarea></div>`
432
+ + `<div class="ut-acts"><button type="button" class="ut-btn pri" data-dc-rec${ok() ? '' : ' disabled'}>Record</button><button type="button" class="ut-btn" data-dc-later aria-haspopup="menu">Later${TD.svg(TD.P.chevD, 14)}</button>`
433
+ + `<button type="button" class="ut-ib${S.pin.has(r.key) ? ' on' : ''}" data-dc-pin aria-pressed="${S.pin.has(r.key)}" aria-label="${S.pin.has(r.key) ? 'Unpin' : 'Pin to the top'}" title="${S.pin.has(r.key) ? 'Unpin' : 'Pin to the top'}">${TD.svg(TD.P.pin, 16)}</button><span class="sp">Nothing changes until you press Record</span></div>`
434
+ + '<p class="ut-small ut-mut" role="status" id="dcMsg"></p></div>',
435
+ input: (t, card) => { if (t.id !== 'dcWhy') return; st.why = t.value; const b = card.querySelector('[data-dc-rec]'); if (b) b.disabled = !ok(); },
436
+ press: async (b) => {
437
+ st.whyShown = st.why; // a redraw after a press keeps what was typed; typing itself never changes the card's html
438
+ const say = (m) => { const el = document.getElementById('dcMsg'); if (el) el.textContent = m; };
439
+ if (b.dataset.dcOpt) { st.choice = b.dataset.dcOpt; return true; }
440
+ if ('dcPin' in b.dataset) { if (S.pin.has(r.key)) S.pin.delete(r.key); else S.pin.add(r.key); store.set('pmos.home.pin', JSON.stringify([...S.pin])); drawList(); return true; }
441
+ if ('dcLater' in b.dataset) {
442
+ const at = new Date(NOW() + 3 * 3600000);
443
+ const put = async (until) => { const res = await bpPost('put-off', { key: r.key, until }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); delete S.rec[r.key]; VW.close(); await load(); select(null); } else say(res.error); };
444
+ menu(b, [{ label: 'Later today', k: H.hm(at.toISOString()), go: () => put('later') }, { label: 'Tomorrow', k: '09:00', go: () => put('tomorrow') }, { label: 'Next week', k: 'Mon', go: () => put('nextweek') }], '');
445
+ return false;
446
+ }
447
+ if ('dcRec' in b.dataset) {
448
+ b.disabled = true;
449
+ const res = await bpPost('decide', { key: r.key, choice: st.choice, why: st.why });
450
+ if (!res.ok) { b.disabled = false; say(res.error); return false; }
451
+ delete S.rec[r.key];
452
+ toast('Recorded in pm-decisions.md.');
453
+ VW.close(); await load(); select(null);
454
+ }
455
+ return false;
456
+ },
457
+ };
458
+ }
373
459
  function needTarget(r) {
374
460
  const row = r.row, d = row.dialog || {};
375
461
  const pills = [];
376
- for (const o of d.opts || []) pills.push({ label: o.t, primary: o.k === (d.prim || d.sel), go: () => { S.rec[r.key] = { ...(S.rec[r.key] || {}), choice: o.k }; openNeedViewer(r, true); } });
462
+ const dec = d.write && d.write.kind === 'decision';
463
+ if (!dec) for (const o of d.opts || []) pills.push({ label: o.t, primary: o.k === (d.prim || d.sel), go: () => { S.rec[r.key] = { ...(S.rec[r.key] || {}), choice: o.k }; openNeedViewer(r, true); } });
377
464
  if (d.write && d.write.kind === 'start') pills.unshift({ label: 'Start the agent', primary: true, go: () => start(r) });
378
465
  if (d.write && d.write.kind === 'return') pills.push({ label: 'Return it', go: () => openNeedViewer(r, true) });
379
- pills.push({ label: 'Discuss', go: () => chat.focus() });
466
+ if (!dec) pills.push({ label: 'Discuss', go: () => chat.focus() });
380
467
  return { key: r.key, ini: r.ini, ws: WS || undefined, title: r.name, sub: r.hint || '', scope: scopeOf(r.ini), rich: rich(), role: CLAUDE,
381
- intro: { role: CLAUDE, text: d.say || row.subject || row.title, pills }, placeholder: 'Ask about ' + r.name, also: null };
468
+ intro: { role: CLAUDE, text: d.say || row.subject || row.title, pills: dec ? [] : pills, card: dec ? decisionCard(r) : undefined }, placeholder: dec ? 'Answer, or type /' : 'Ask about ' + r.name, also: null };
382
469
  }
383
470
  function updateTarget() {
384
471
  const U = H.weeklyUpdate(S.D, S.D.now);
@@ -406,12 +493,18 @@ function select(id, o = {}) {
406
493
  S.sel = id;
407
494
  const r = id ? rowById(id) : null;
408
495
  if (isPhone()) sheet(false);
409
- if (!r) { if (S.ini) openTarget(iniTarget(S.ini)); else openTarget(homeTarget()); drawList(); return; }
496
+ if (!r) { S.phoneChat = false; if (S.ini) openTarget(iniTarget(S.ini)); else openTarget(homeTarget()); drawList(); return; }
410
497
  if (r.kind === 'ini') { goIni(r.ini); return; }
411
498
  if (r.kind === 'product') { goIni('product'); return; }
499
+ // a row with a conversation opens it; on a phone it opens over the list, with a back bar (HmPhone2)
500
+ if (isPhone() && (r.kind === 'update' || (r.kind === 'need' && r.row) || r.kind === 'session' || r.needSession)) S.phoneChat = true;
412
501
  if (r.kind === 'update') { openTarget(updateTarget()); if (!o.keepViewer) openUpdateViewer(); }
413
502
  else if (r.kind === 'need' && r.row) { openTarget(needTarget(r)); if (!o.keepViewer) openNeedViewer(r); }
414
503
  else if (r.kind === 'session' || r.needSession) { const s = S.D.sessions.find((x) => x.id === r.sid); if (s) { openTarget(sessionTarget(s)); if (isMetricsSession(s) && !o.keepViewer && !isPhone()) openMetricsViewer(); } }
504
+ else if (r.kind === 'task') { openBoardTask(r.task); }
505
+ else if (r.kind === 'item') { import('./home-work.js').then((M) => M.openWorkItem(r.key)); }
506
+ else if (r.kind === 'mention') { openMention(r); }
507
+ else if (r.kind === 'finished') { openFinished(r.finished); }
415
508
  else if (r.kind === 'meeting') { openMeeting(r.meeting); }
416
509
  else if (r.kind === 'routine') { if (isMetrics(r.schedule)) openMetrics(o); else openRoutine(r.schedule); }
417
510
  else if (r.kind === 'file') { openFile(r.file); }
@@ -441,6 +534,100 @@ function syncUrl() {
441
534
  history.replaceState(null, '', location.pathname + (s ? '?' + s : ''));
442
535
  }
443
536
 
537
+ /* ── the one list's own views: a task, a mention, finished work, the weekly review (premium-uncovered-features) ── */
538
+ const boardWs = () => ((S.D.board && S.D.board.board) || {}).ws || WS || undefined;
539
+ const boardId = () => ((S.D.board && S.D.board.board) || {}).id || BOARD || undefined;
540
+ const HTTPS = /^https:\/\//;
541
+ function openBoardTask(t) {
542
+ if (!t) return;
543
+ import('./home-task.js').then((M) => M.openTask(t, {
544
+ VW, pmPost, toast, now: NOW, ws: t.ws || boardWs(), board: t.board || boardId(), iniTitle,
545
+ docs: (id) => (S.IMid === id && S.IM ? (S.IM.docs.rows || []).filter((d) => d.path && !d.tech).map((d) => ({ title: d.title, path: d.path })) : []),
546
+ openIni: (id) => goIni(id), openDoc: (d) => openFile({ path: d.path, name: d.title }),
547
+ askInChat: (task) => {
548
+ S.phoneChat = isPhone();
549
+ openTarget({ ...iniTarget(task.ini), placeholder: 'Ask about ' + task.title });
550
+ setTimeout(() => { const ta = $('#hmIn'); if (ta) { ta.value = 'About the task "' + task.title + '": '; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); } }, 0);
551
+ drawList();
552
+ },
553
+ openRecord: (task) => import('./premium-vw-item.js').then((V) => V.openWorkItem({ kind: 'task', ini: task.ini, key: 'task:' + task.uid, title: task.title, ws: boardWs(), board: boardId() })).catch(() => toast('The record could not open.')),
554
+ onChange: () => load(),
555
+ }));
556
+ }
557
+ function openMention(r) {
558
+ const m = r.mention || {};
559
+ const draw = (b) => {
560
+ b.innerHTML = `<div class="ut-vc"><div><h2 class="ut-h2">${esc(r.name)}</h2><p class="ut-sub">${esc(['Mention', m.where || m.source, m.at ? H.hm(m.at) : ''].filter(Boolean).join(' · '))}</p></div>`
561
+ + (m.text ? `<div class="ut-box">${esc(m.text)}</div>` : '') + (m.reply ? `<p class="ut-lbl">A reply you could send</p><div class="ut-box">${esc(m.reply)}</div>` : '')
562
+ + `<div class="ut-foot">${HTTPS.test(m.link || '') ? `<a class="ut-btn pri" href="${esc(m.link)}" target="_blank" rel="noopener noreferrer">Open it</a>` : ''}<button type="button" class="ut-btn" data-mn-read>Mark it read</button></div>`
563
+ + '<p class="ut-small ut-mut">PMOS sends nothing. Reply where the mention is.</p></div>';
564
+ };
565
+ const body = VW.open({ id: 'mention:' + (m.id || r.id), kind: 'Mention', title: r.name, icon: 'info', render: draw });
566
+ body.onclick = async (e) => {
567
+ if (!e.target.closest('[data-mn-read]')) return;
568
+ const res = await pmPost('/api/mentions/read', { id: m.id, read: true });
569
+ if (res && res.ok) { toast('Marked read.'); VW.close(); load(); } else toast((res && res.error) || 'Not marked read.');
570
+ };
571
+ }
572
+ function openFinished(f) {
573
+ if (!f) return;
574
+ VW.open({ id: 'fin:' + (f.id || f.title), kind: f.status === 'review' ? 'Finished · waits for your review' : 'Finished', title: f.title, icon: 'doc',
575
+ html: `<div class="ut-vc">${f.summary ? `<p class="ut-sub">${esc(f.summary)}</p>` : ''}${f.body ? `<article class="hv-doc">${mdHtml(f.body)}</article>` : ''}${HTTPS.test(f.link || '') ? `<div class="ut-foot"><a class="ut-btn" href="${esc(f.link)}" target="_blank" rel="noopener noreferrer">Open it</a></div>` : ''}</div>` });
576
+ }
577
+ function openReviewVw() {
578
+ S.sel = 'review'; drawList();
579
+ import('./home-review.js').then((M) => M.openReview({
580
+ VW, pmPost, toast, D: () => S.D, reload: () => load(), ws: () => boardWs(), iniTitle, now: NOW,
581
+ openWork: () => MORE.openMyWork(),
582
+ askAbout: (st, act) => {
583
+ S.phoneChat = isPhone();
584
+ const owner = st.owner ? ' It is ' + st.owner + '’s.' : ' It has no owner.';
585
+ openTarget({ ...homeTarget(), key: 'chat:review-' + st.id, title: 'Weekly review · ' + st.title, scope: { text: st.title, icon: I.flag },
586
+ intro: { role: CLAUDE, text: st.title + ' has had no change for ' + st.days + ' days, in ' + (st.stage || 'its stage') + '.' + owner + ' Do you want to hold it, or keep it going?',
587
+ pills: [{ label: 'Hold it', go: async () => { if (await act.hold()) chat.focus(); } }, { label: 'Keep it going', go: () => act.keep() }, { label: 'Skip', go: () => chat.focus() }] },
588
+ placeholder: 'Answer, or type /', context: 'Weekly review: ' + st.title + ' (' + st.id + ') has had no change for ' + st.days + ' days.' });
589
+ drawList();
590
+ },
591
+ }));
592
+ }
593
+ /* the capture box: a typed task goes under the initiative it names (POST /api/boards/tasks/add), else on the PM's own list (POST /api/pm-items/add) */
594
+ async function capture(text) {
595
+ const line = String(text || '').trim(); if (!line) return false;
596
+ const ini = L.fileUnder(line, H.boardRows(S.D).filter(H.OPEN));
597
+ const b = (S.D.board && S.D.board.board) || {};
598
+ const r = ini && b.id ? await pmPost('/api/boards/tasks/add', { ws: b.ws || WS || undefined, board: b.id, initiative: ini, title: line })
599
+ : await pmPost('/api/pm-items/add', { line });
600
+ if (!r || r.ok !== true) { toast((r && r.error) || 'The task was not added.'); return false; }
601
+ toast(ini ? 'Added under ' + iniTitle(ini) + '.' : 'Added. It names no initiative, so it is under Not in an initiative.');
602
+ if (ini) { S.kids.add('i:' + ini); S.kidsOff.delete('i:' + ini); }
603
+ await load();
604
+ return true;
605
+ }
606
+ /* a check in the list: a task or a note is done (the board's task route, or My work's) */
607
+ async function checkRow(id) {
608
+ const r = rowById(id); if (!r) return;
609
+ let res = null;
610
+ if (r.kind === 'task' && r.task) res = await pmPost('/api/boards/tasks/state', { ws: r.task.ws || boardWs(), board: r.task.board || boardId(), task: r.task.uid, state: 'Done' });
611
+ else if (r.kind === 'item' && r.item) res = await pmPost('/api/pm-items/done', { id: r.item.id });
612
+ else return;
613
+ if (!res || !res.ok) { toast((res && res.error) || 'Not marked done.'); return; }
614
+ toast('Done.');
615
+ await load();
616
+ }
617
+ /* the products picker (HmProducts): All products, each product with its goals, Add a product */
618
+ function pickProduct(anchor) {
619
+ const M = S.M || L.homeList(S.D, { now: NOW() });
620
+ const items = [{ label: 'All products', sub: 'Home only · Board and Insights show one', checked: !S.product, go: () => setProduct(null) }, { sep: true }]
621
+ .concat(M.products.map((p) => {
622
+ const g = M.groups.find((x) => x.product && x.product.key === p.key);
623
+ const n = g ? g.count : ((p.model && p.model.initiatives && p.model.initiatives.list && p.model.initiatives.list.rows) || []).filter(H.OPEN).length;
624
+ return { label: p.name, sub: [n + (n === 1 ? ' initiative' : ' initiatives'), p.goals && p.goals.n ? p.goals.ok + ' of ' + p.goals.n + ' goals' : ''].filter(Boolean).join(' · '), tile: p.initials, primary: p.primary, checked: S.product === p.key, go: () => setProduct(p.key) };
625
+ }))
626
+ .concat([{ sep: true }, { label: 'Add a product', icon: TD.P.plus, go: () => MORE.openProducts() }]);
627
+ menu(anchor, items, '');
628
+ }
629
+ function setProduct(key) { S.product = key; store.set('pmos.home.product', key); if (key) S.pg['p:' + key] = true; drawList(); }
630
+
444
631
  /* ── the Viewer: needs rows, the weekly update, the overview, files, people, routines ── */
445
632
  let lastViewer = null;
446
633
  VW.onChange((d) => { if (d.open) lastViewer = d.id; chat.refresh(); document.body.classList.toggle('hm-vw-open', d.open); });
@@ -466,20 +653,26 @@ function openNeedViewer(r, focusWhy) {
466
653
  const link = /^https:\/\//.test(d.link || '') ? `<a class="hx-b hv-link" id="srcLink" href="${esc(d.link)}" target="_blank" rel="noopener noreferrer">${esc(d.linkLabel || 'Open it')}</a>` : '';
467
654
  let rec = '';
468
655
  if (w.kind === 'decision') {
469
- rec = `<section class="hv-sec"><h4>Your decision</h4><div class="hv-opts" role="radiogroup" aria-label="Choices">${(d.opts || []).map((o) => `<button type="button" role="radio" aria-checked="${st.choice === o.k}" data-hv-opt="${esc(o.k)}"><b>${esc(o.t)}</b>${o.d ? `<em>${esc(o.d)}</em>` : ''}</button>`).join('')}</div>`
470
- + `<label class="hv-why"><span>Why</span><textarea id="hvWhy" rows="3" placeholder="The reason goes in pm-decisions.md with your choice">${esc(st.why)}</textarea></label>`
471
- + `<div class="hv-acts"><button type="button" class="hx-b pri" data-hv-rec${st.choice && st.why.trim().length >= 3 ? '' : ' disabled'}>Record the decision</button>${laterHtml()}${pinHtml(r)}</div></section>`;
656
+ // the decision is recorded on the chat's card (HmDecide); the Viewer keeps the facts it rests on
657
+ rec = '<p class="ut-small ut-mut">Record your decision on the card in the chat.</p>';
472
658
  } else if (w.kind === 'return') {
473
- rec = `<section class="hv-sec"><h4>Return this run: why</h4><div class="hv-seg">${RET_REASONS.map((x) => `<button type="button" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(x)}</button>`).join('')}</div>`
474
- + `<div class="hv-acts"><button type="button" class="hx-b pri" data-hv-rec${st.ret ? '' : ' disabled'}>Return it to the agent</button>${laterHtml()}${pinHtml(r)}</div></section>`;
659
+ // HmDecide, the Viewer's "Return a run": why it goes back, what to change, Return it or Keep it as is
660
+ b.innerHTML = `<div class="ut-vc"><div><h2 class="ut-h2">${esc(r.name)}</h2><p class="ut-sub">${esc(r.hint || pane.h || '')}</p></div>${facts}`
661
+ + `<p class="ut-lbl">Why it goes back</p><div class="ut-chips" role="group" aria-label="Why it goes back">${RET_REASONS.map((x) => `<button type="button" class="cz-chip${st.ret === x ? ' on' : ''}" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(RET_LABEL[x] || x)}</button>`).join('')}</div>`
662
+ + `<div class="ut-field"><label for="hvNote">What to change</label><textarea id="hvNote" rows="3" placeholder="Say what the agent should change">${esc(st.note || '')}</textarea></div>`
663
+ + '<div class="ut-box ut-small">The agent gets this note in its conversation and tries again. It counts as one correction.</div>'
664
+ + `<div class="ut-foot"><button type="button" class="ut-btn dark" data-hv-rec${st.ret ? '' : ' disabled'}>Return it</button><button type="button" class="ut-btn ghost" data-hv-keep>Keep it as is</button></div>`
665
+ + '<p class="ut-small ut-mut" role="status" id="hvMsg"></p></div>';
666
+ if (focusWhy) { const t = b.querySelector('#hvNote'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
667
+ return;
475
668
  } else if (w.kind === 'start') {
476
669
  rec = `<section class="hv-sec"><h4>Start</h4><p class="hx-n">The agent drafts ${esc(w.what || 'it')} in a real session. Its draft waits for you to read.</p><div class="hv-acts"><button type="button" class="hx-b pri" data-hv-start>Start the agent</button>${laterHtml()}${pinHtml(r)}</div></section>`;
477
670
  } else rec = `<div class="hv-acts">${link}${src ? '' : laterHtml()}${pinHtml(r)}</div>`; // a source row cannot be put off (the server refuses it)
478
- b.innerHTML = `<div class="hv">${pane.note ? `<p class="hv-note">${esc(pane.note)}</p>` : ''}${pane.h ? `<h4 class="hv-h">${esc(pane.h)}</h4>` : ''}${intro}${facts}${paras}${MORE.WAIT}${rec}<p class="hx-n" role="status" id="hvMsg"></p></div>`;
671
+ b.innerHTML = `<div class="hv">${pane.note ? `<p class="hv-note">${esc(pane.note)}</p>` : ''}${pane.h ? `<h4 class="hv-h">${esc(pane.h)}</h4>` : ''}${intro}${facts}${paras}${rec}<p class="hx-n" role="status" id="hvMsg"></p></div>`;
479
672
  if (focusWhy) { const t = b.querySelector('#hvWhy'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
480
673
  };
481
674
  const body = VW.open({ id: 'need:' + r.key, kind: ({ decision: 'Decision', blocked: 'Blocked', waited: 'Waiting', src: 'Source', ev: 'Event' }[row.kind] || 'Needs you'), title: r.name, icon: 'info', url: d.pane && d.pane.file ? '/premium-board.html?doc=' + encodeURIComponent(d.pane.file) : '', render: draw });
482
- body.oninput = (e) => { if (e.target.id === 'hvWhy') { st.why = e.target.value; const b = body.querySelector('[data-hv-rec]'); if (b) b.disabled = !(st.choice && st.why.trim().length >= 3); } };
675
+ body.oninput = (e) => { if (e.target.id === 'hvNote') { st.note = e.target.value; return; } if (e.target.id === 'hvWhy') { st.why = e.target.value; const b = body.querySelector('[data-hv-rec]'); if (b) b.disabled = !(st.choice && st.why.trim().length >= 3); } };
483
676
  body.onclick = async (e) => {
484
677
  const t = e.target.closest('button'); if (!t || t.disabled) return;
485
678
  const say = (m) => { const el = body.querySelector('#hvMsg'); if (el) el.textContent = m; };
@@ -489,12 +682,15 @@ function openNeedViewer(r, focusWhy) {
489
682
  if (t.dataset.hvUntil) { const res = await bpPost('put-off', { key: r.key, until: t.dataset.hvUntil }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); VW.close(); await load(); select(null); } else say(res.error); return; }
490
683
  if ('hvPin' in t.dataset) { if (S.pin.has(r.key)) S.pin.delete(r.key); else S.pin.add(r.key); store.set('pmos.home.pin', JSON.stringify([...S.pin])); draw(body); drawList(); return; }
491
684
  if ('hvStart' in t.dataset) { start(r); return; }
685
+ if ('hvKeep' in t.dataset) { delete S.rec[r.key]; VW.close(); return; }
492
686
  if ('hvRec' in t.dataset) {
493
687
  t.disabled = true;
494
688
  const res = w.kind === 'decision' ? await bpPost('decide', { key: r.key, choice: st.choice, why: st.why }) : await bpPost('return', { run: w.run, reason: st.ret, ...(w.ws ? { ws: w.ws } : {}) });
495
689
  if (!res.ok) { t.disabled = false; say(res.error); return; }
496
690
  delete S.rec[r.key];
497
691
  toast(w.kind === 'decision' ? 'Recorded in pm-decisions.md.' : 'Returned to the agent. It counts as a correction.');
692
+ const note = w.kind === 'return' && String(st.note || '').trim();
693
+ if (note && chat.current() && chat.current().key === r.key) chat.send('What to change: ' + note);
498
694
  VW.close(); await load(); select(null);
499
695
  }
500
696
  };
@@ -550,6 +746,7 @@ async function sendUpdate() {
550
746
 
551
747
  /* the overview of an initiative: stage moves and hold, Tasks, Core documents (no design yet: a minimal version) */
552
748
  function openOverview() {
749
+ if (iniOverview()) return;
553
750
  const id = S.ini; if (!id || id === 'product') return;
554
751
  let M = S.IM;
555
752
  let ask = null; // on-hold | cancelled while its reason is asked
@@ -589,15 +786,15 @@ function openOverview() {
589
786
  (await import('./premium-vw-item.js')).openWorkItem({ kind: 'task', ini: id, key: row.key, title: row.title, ...o });
590
787
  return;
591
788
  }
592
- if (t.dataset.ovDread) { // a draft: read it, edit it, Issue it (a minimal reader in the Viewer, Waiting for design)
789
+ if (t.dataset.ovDread) { // a draft: read it, edit it, Issue it (home-draft.js, in the Viewer's card shape)
593
790
  const d = (M.docs.rows || []).find((x) => x.key === t.dataset.ovDread); if (!d) return;
594
791
  const A = await import('./home-draft.js');
595
- A.openDraftVw({ VW, pmGet, pmPost, toast, wait: MORE.WAIT, ws: M.board.ws, scope: M.docs.scope, doc: d, onIssued: () => load() });
792
+ A.openDraftVw({ VW, pmGet, pmPost, toast, ws: M.board.ws, scope: M.docs.scope, doc: d, onIssued: () => load() });
596
793
  return;
597
794
  }
598
- if ('ovAdddoc' in t.dataset) { // a minimal form in the Viewer (Waiting for design): it posts to /api/custom-docs/add only
795
+ if ('ovAdddoc' in t.dataset) { // the form in the Viewer (home-adddoc.js): it posts to /api/custom-docs/add only
599
796
  const A = await import('./home-adddoc.js');
600
- A.openAddDocVw({ VW, pmPost, toast, wait: MORE.WAIT, ws: M.board.ws, scope: M.docs.scope, phases: (M.acts && M.acts.stages) || [], title: iniTitle(id), back: () => openOverview(), onAdded: async () => { await load(); if (S.ini === id) openOverview(); } });
797
+ A.openAddDocVw({ VW, pmPost, toast, ws: M.board.ws, scope: M.docs.scope, phases: (M.acts && M.acts.stages) || [], title: iniTitle(id), back: () => openOverview(), onAdded: async () => { await load(); if (S.ini === id) openOverview(); } });
601
798
  }
602
799
  };
603
800
  body.onchange = async (e) => { const s = e.target.closest('[data-ov-task]'); if (s) after(await pmPost('/api/boards/tasks/state', { ...bw(), task: s.dataset.ovTask, state: s.value }), 'Status changed.'); };
@@ -743,6 +940,7 @@ function newItems() {
743
940
  { label: here ? 'New session in ' + iniTitle(here) : 'New session in an initiative', sub: 'A fresh chat with its own history', go: (b) => (here ? newIn(here) : menu(b, inis.map((r) => ({ label: r.title, sub: r.stage, go: () => newIn(r.id) })), 'In which initiative')) },
744
941
  { label: 'Quick ask', sub: 'Your own chat, about all work', go: () => { goHome(); chat.focus(); } },
745
942
  { label: 'Something unrelated', sub: 'A loose chat; link it later', go: () => newLoose() },
943
+ { label: 'Record a note now', sub: 'A conversation that is not on the calendar', go: () => MORE.openRecorder().then(() => drawList()) },
746
944
  ];
747
945
  }
748
946
  function newIn(id) {
@@ -784,7 +982,17 @@ const menuEl = $('#hmMenu');
784
982
  let menuItems = [];
785
983
  function menu(anchor, items, label) {
786
984
  menuItems = items;
787
- menuEl.innerHTML = (label ? `<p class="hm-ml">${esc(label)}</p>` : '') + items.map((x, i) => `<button type="button" role="menuitem" data-hm-mi="${i}"${x.disabled ? ' disabled' : ''}><b>${esc(x.label)}</b>${x.sub ? `<em>${esc(x.sub)}</em>` : ''}</button>`).join('') || '<p class="hm-ml">Nothing to choose.</p>';
985
+ // an item: { label, sub?, go, disabled? } and, for the products picker and Later (HmProducts, HmDecide): tile (initials), checked
986
+ // (a radio item with its check), icon (a path), k (the time on the right), or { sep: true } for a hairline
987
+ const itemHtml = (x, i) => {
988
+ if (x.sep) return '<div class="ut-hr" role="separator"></div>';
989
+ const rich = x.tile || x.checked != null || x.icon || x.k;
990
+ const role = x.checked != null ? `role="menuitemradio" aria-checked="${!!x.checked}"` : 'role="menuitem"';
991
+ if (!rich) return `<button type="button" ${role} data-hm-mi="${i}"${x.disabled ? ' disabled' : ''}><b>${esc(x.label)}</b>${x.sub ? `<em>${esc(x.sub)}</em>` : ''}</button>`;
992
+ return `<button type="button" ${role} class="ut-mi${x.tile ? ' tall' : ''}" data-hm-mi="${i}"${x.disabled ? ' disabled' : ''}>${x.tile ? `<span class="ut-it${x.primary ? ' p' : ''}" aria-hidden="true">${esc(x.tile)}</span>` : ''}${x.icon ? TD.svg(x.icon, 16) : ''}`
993
+ + `<span><b>${esc(x.label)}</b>${x.sub ? `<em>${esc(x.sub)}</em>` : ''}</span>${x.k ? `<span class="k">${esc(x.k)}</span>` : ''}${x.checked ? TD.svg(TD.P.check, 16) : ''}</button>`;
994
+ };
995
+ menuEl.innerHTML = (label ? `<p class="hm-ml">${esc(label)}</p>` : '') + items.map(itemHtml).join('') || '<p class="hm-ml">Nothing to choose.</p>';
788
996
  menuEl.hidden = false; menuEl.setAttribute('data-esc-layer', '');
789
997
  // the menu sits under (or over) the button that opened it: CSS anchor positioning reads .hm-anc, so no geometry is set from here
790
998
  if (menu.anchor && menu.anchor !== anchor) menu.anchor.classList.remove('hm-anc');
@@ -824,6 +1032,10 @@ function sheet(on) {
824
1032
  if (S.sheet) { const f = $('#hmList button'); if (f) f.focus(); }
825
1033
  }
826
1034
  $('#hmNeeds').onclick = () => sheet(!S.sheet);
1035
+ // a phone: the back bar of a conversation returns to the list, which is the page (HmPhone2)
1036
+ // My work's "Weekly review" (home-work.js) asks Home, which holds the data the review reads
1037
+ addEventListener('hm:review', (e) => { e.preventDefault(); openReviewVw(); });
1038
+ $('#hmBack').onclick = () => { S.phoneChat = false; S.sel = null; drawList(); syncUrl(); const f = $('#hmList .hm-rm'); if (f) f.focus(); };
827
1039
  $('#hmMoreP').onclick = (e) => moreMenu(e.currentTarget);
828
1040
  $('#hmDesk').onclick = (e) => { if (S.sheet && e.target === $('#hmDesk')) sheet(false); }; // a press beside the sheet closes it; Escape and the N need you button do too
829
1041
 
@@ -832,7 +1044,20 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
832
1044
  const b = e.target.closest('button'); if (!b) return;
833
1045
  const d = b.dataset;
834
1046
  if (d.hmSel) { select(d.hmSel); return; }
835
- if (d.hmKids) { if (S.kids.has(d.hmKids)) S.kids.delete(d.hmKids); else S.kids.add(d.hmKids); drawList(); return; }
1047
+ if (d.hmKids) { // the chevron of an initiative: what sits under it shows or hides
1048
+ if (b.getAttribute('aria-expanded') === 'true') { S.kids.delete(d.hmKids); S.kidsOff.add(d.hmKids); } else { S.kids.add(d.hmKids); S.kidsOff.delete(d.hmKids); }
1049
+ drawList(); const f = $(`#hmList [data-hm-kids="${CSS.escape(d.hmKids)}"]`); if (f) f.focus(); return;
1050
+ }
1051
+ if (d.hmPg) { const open = b.getAttribute('aria-expanded') === 'true'; S.pg[d.hmPg] = !open; store.set('pmos.home.pg', JSON.stringify(S.pg)); drawList(); const f = $(`#hmList [data-hm-pg="${CSS.escape(d.hmPg)}"]`); if (f) f.focus(); return; }
1052
+ if ('hmProd' in d) { goIni('product'); return; }
1053
+ if (d.hmRest) { if (S.rest.has(d.hmRest)) S.rest.delete(d.hmRest); else S.rest.add(d.hmRest); drawList(); return; }
1054
+ if (d.hmFilter) { S.filter = d.hmFilter; drawList(); const f = $(`#hmList [data-hm-filter="${d.hmFilter}"]`); if (f) f.focus(); return; }
1055
+ if (d.hmCheck) { checkRow(d.hmCheck); return; }
1056
+ if ('hmReview' in d) { openReviewVw(); return; }
1057
+ if ('hmWork' in d) { MORE.openMyWork(); return; }
1058
+ if ('hmPick' in d) { pickProduct(b); return; }
1059
+ if ('hmCapmic' in d) { const i = $('#hmCap'); if (i) capMic(i, b); return; }
1060
+ if (d.hmTc) { todayPress(d.hmTc, b); return; }
836
1061
  if (d.hmEnd) { endRow(d.hmEnd); return; }
837
1062
  if (d.hmGroup) { if (S.shut.has(d.hmGroup)) S.shut.delete(d.hmGroup); else S.shut.add(d.hmGroup); store.set('pmos.home.shut', JSON.stringify([...S.shut])); drawList(); return; }
838
1063
  if ('hmAllneeds' in d) { S.allNeeds = !S.allNeeds; drawList(); return; }
@@ -851,6 +1076,52 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
851
1076
  if ('hmElse' in d) { const f = S.lay && S.lay.elsewhere && S.lay.elsewhere.first; goHome(); if (f) select(f.id); return; }
852
1077
  if ('hmPerson' in d) addPerson();
853
1078
  };
1079
+ $('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
1080
+ if (e.target.id !== 'hmCapF') return;
1081
+ e.preventDefault();
1082
+ const i = $('#hmCap'); if (!i || !i.value.trim()) return;
1083
+ i.disabled = true;
1084
+ const ok = await capture(i.value);
1085
+ const j = $('#hmCap'); if (j) { j.disabled = false; if (ok) j.value = ''; j.focus(); }
1086
+ });
1087
+ /* the mic of the capture box: the words are typed into it, nothing is saved as audio (home-dictate.js) */
1088
+ let capDict = null;
1089
+ function capMic(input, b) {
1090
+ if (capDict && capDict.on()) { capDict.stop(); return; }
1091
+ capDict = dictate(input, { onState: (x) => {
1092
+ const btn = $('#hmList [data-hm-capmic]'), form = $('#hmCapF');
1093
+ if (btn) { btn.classList.toggle('on', !!x.on); btn.setAttribute('aria-label', x.on ? 'Stop listening' : 'Say it instead'); }
1094
+ if (form) form.classList.toggle('on', !!x.on);
1095
+ if (x.error) toast(x.error);
1096
+ } });
1097
+ b.classList.add('on');
1098
+ }
1099
+ /* the Today card's presses (HmDay, HmMic): the calendar, the meeting's prep, the live meeting, the recording, the end of the day */
1100
+ async function todayPress(k, b) {
1101
+ const T = todayModel();
1102
+ if (k === 'cal') { openCalendar(); return; }
1103
+ if ((k === 'prep' || k === 'open') && T.meeting) { openMeeting(T.meeting); return; }
1104
+ if (k === 'record') { MORE.openRecorder().then(() => drawList()); return; }
1105
+ if (k === 'hl') { const r = REC && await REC.highlight(); toast(r && r.ok ? 'Highlighting the last 30 seconds and the next ones.' : (r && r.error) || 'The highlight did not start.'); return; }
1106
+ if (k === 'pause' || k === 'resume' || k === 'stop') {
1107
+ if (!REC || T.mode !== 'rec') return;
1108
+ b.disabled = true;
1109
+ const r = k === 'pause' ? await REC.pause() : k === 'resume' ? await REC.resume(T.id) : await REC.stop(T.id);
1110
+ if (!r || !r.ok) toast((r && r.error) || 'The recording did not change.');
1111
+ else if (k === 'stop') toast(r.discarded ? 'Stopped. Nothing was said, so nothing was kept.' : 'Stopped. The notes are under Not in an initiative until you link them.');
1112
+ await REC.refresh(); drawList();
1113
+ if (k === 'stop') load();
1114
+ return;
1115
+ }
1116
+ if (k === 'hide') { S.eodHidden = true; store.set('pmos.home.eod', L.dayOf()); drawList(); return; }
1117
+ if (k === 'now' && T.block) { select(T.block.id); return; }
1118
+ if (k === 'tomorrow' && T.block && T.block.key) {
1119
+ const res = await bpPost('put-off', { key: T.block.key, until: 'tomorrow' });
1120
+ if (!res.ok) { toast(res.error); return; }
1121
+ toast('Tomorrow 09:00. It comes back by itself, and it is not counted as done.');
1122
+ load();
1123
+ }
1124
+ }
854
1125
  $('#hmDesk').insertAdjacentHTML('afterbegin', `<button type="button" class="hm-unfold" id="hmUnfold" aria-label="Show the list" title="Show the list">${SVG(I.fold, 16)}</button>`);
855
1126
  $('#hmUnfold').onclick = () => { S.folded = false; store.set('pmos.home.fold', null); drawList(); };
856
1127
  function cta() {
@@ -863,12 +1134,14 @@ function cta() {
863
1134
  }
864
1135
 
865
1136
  /* ── start ── */
1137
+ mountIni({ S, VW, pmGet, pmPost, toast, load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT });
866
1138
  mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings() });
867
- PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m), wait: MORE.WAIT }); drawList();
1139
+ PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m) }); drawList();
868
1140
  drawList(); drawTop();
869
1141
  { // a conversation the address names opens at once, before the lists are read, so nothing typed or attached lands in the Home chat
870
1142
  const a = P.get('about') || '', early = /^(decision|blocked|waited|src|ev|work|board|doc|ins|chat|pop):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/.test(a) && !P.get('open') && !P.get('session') ? a : null;
871
1143
  const sidAt = !early && !P.get('open') && /^[A-Za-z0-9._:-]{1,120}$/.test(P.get('session') || ''); // a session link: read nothing until its session is known, so Home's own chat never shows first
1144
+ if (early || sidAt) { S.phoneChat = isPhone(); drawList(); } // a phone: a conversation the address names is the page, not the list (HmPhone2)
872
1145
  openTarget(early ? { ...homeTarget(), key: early, title: (P.get('label') || '').slice(0, 80) || early }
873
1146
  : sidAt ? { ...homeTarget(), key: '', title: 'Reading', empty: 'Reading the session.' }
874
1147
  : S.ini ? (S.ini === 'product' ? { ...homeTarget(), title: 'Reading' } : iniTarget(S.ini)) : homeTarget());
@@ -884,6 +1157,7 @@ load().then(() => {
884
1157
  const say = (P.get('say') || P.get('q') || '').slice(0, 500);
885
1158
  const asked = !ask ? '' : /^board:/.test(ask) ? ask : /^(insights|verdict)$/.test(ask) ? 'ins:' + ask : 'init:' + ask;
886
1159
  const about = KEY.test(P.get('about') || '') ? P.get('about') : KEY.test(asked) ? asked : null;
1160
+ if (isPhone() && ((open && !blockOpen) || sid || about)) { S.phoneChat = true; drawList(); } // the conversation the address names, not the list
887
1161
  if (open && !blockOpen) { const r = allRows().find((x) => x.key === open); if (r) select(r.id); else if (KEY.test(open)) openTarget({ ...homeTarget(), key: open, title: open }); }
888
1162
  else if (sid) { const s = S.D.sessions.find((x) => x.id === sid); if (s) { S.sel = 's:' + s.id; openTarget(sessionTarget(s)); drawList(); } else { openTarget(homeTarget()); toast('That session is not on this machine.'); } }
889
1163
  else if (about && /^init:/.test(about) && iniRowOf(about.slice(5))) goIni(about.slice(5));