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,19 +1,17 @@
1
- /* pm/home-around.js — Around you on Home: what the agents and the outside world left for you (initiative premium-briefing-depth;
2
- * moved onto Home by premium-agreed-design). The Agreed design does not draw it, so it is a plain minimal card in the Viewer with a
3
- * "Waiting for design" marker, opened from More. It keeps every feature of the old Briefing card:
4
- * the six rows, in the PRD order: agent proposals · mentions · portfolio pulse · horizon scan · report found · data freshness
5
- * the prep line (the meetings left today and how many are prepped) and today's digests from the morning brief
6
- * each row opens its own view in the same card, with Back to the rows; Escape closes the Viewer
1
+ /* pm/home-around.js — the views Around you held on Home (initiative premium-briefing-depth; moved onto Home by premium-agreed-design).
2
+ * premium-uncovered-features (canvas HmAround): Around you is gone, and what it showed lives in one place each. New for you (cozy-news.js)
3
+ * holds the mentions, the finished results and today's digests, and its "Where the rest went" rows open these views, which keep every press
4
+ * of the old card: agent proposals · mentions · portfolio pulse · horizon scan · report found. Data freshness is Sources (cozy-sources.js).
5
+ * Each view opens in the Viewer with Back to New for you; Escape closes the Viewer.
7
6
  * Every read is a route the console already uses and every write is a press that says what it does first (pmPost carries the launch nonce).
8
- * A source that cannot be read is named in its row, never shown as empty. Which products: ?ws=<id> that one, otherwise every product Home reads.
7
+ * A source that cannot be read is named in its view, never shown as empty. Which products: ?ws=<id> that one, otherwise every product Home reads.
9
8
  * Nothing here posts to Slack, Jira, Confluence or mail.
10
- * openAround(key?) → the body element; key opens one row's view at once (prop | men | pulse | scan | rep | src) */
9
+ * openAround(key?) → the body element; key opens one view (prop | men | pulse | scan | rep); no key opens New for you, src opens Sources
10
+ * prepHtmlOf(brief) → the prep line (the meetings left today and how many are prepped), from one GET /api/brief-page answer; New for you shows it */
11
11
  import { pmGet, pmPost } from './http.js';
12
- import { open as vwOpen } from './cozy-viewer.js';
13
- import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
12
+ import { open as vwOpen, current as vwCurrent } from './cozy-viewer.js';
14
13
 
15
14
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
16
- const WAIT = '<p class="hx-wait"><i aria-hidden="true"></i>Waiting for design</p>';
17
15
  const STAMP = (n) => String(n).padStart(2, '0');
18
16
  const toast = (t) => { const el = document.getElementById('toast'); if (!el) return; el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
19
17
  const CHECK = '<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12l4.5 4.5L19 7"/></svg>';
@@ -34,13 +32,13 @@ const bdIco = (d) => `<svg class="i" viewBox="0 0 24 24" aria-hidden="true">${d}
34
32
  const H2 = (t) => `<h4>${esc(t)}</h4>`;
35
33
  const kv = (rows) => `<dl class="hv-facts">${rows.map(([k, v]) => `<div><dt>${esc(k)}</dt><dd>${esc(v)}</dd></div>`).join('')}</dl>`;
36
34
 
37
- const A = { prop: null, men: null, pulse: null, scan: null, rep: null, src: null, prep: null, dig: null }; // the last answer of each read
35
+ const A = { prop: null, men: null, pulse: null, scan: null, rep: null }; // the last answer of each read
38
36
  const DEC = new Map(); // proposals decided on this visit: id → { item, st: 'kept' | 'back' | 'dropped', note, wrote, warnings }
39
37
  const PNOTE = {}, PERR = {}, PBACK = new Set();
40
38
  const MREAD = new Map(), MADD = new Set();
41
39
  const SDEC = new Map();
42
40
  const SERR = {}, SWHY = {}, SOPEN = new Set();
43
- const REC = new Map(), RERR = {}, SNOTE = {};
41
+ const REC = new Map(), RERR = {};
44
42
  const PMORE = new Set();
45
43
  let MTAB = 'all', BUSY = '', PSEL = '', PINFO = false, VIEW = '', PRODS = null;
46
44
  const getj = async (p) => { const r = await pmGet(p); return r && r.ok !== false ? r : { ok: false, error: (r && r.error) || 'the server did not answer' }; };
@@ -118,17 +116,9 @@ async function readReps(P) {
118
116
  if (!got.length && errs.length) return { ok: false, error: errs[0] };
119
117
  return { ok: true, prods: got, errs };
120
118
  }
121
- const readSrc = () => getj('/api/sources' + (wsParam() ? '?' + wq(wsParam()) : ''));
122
- /** Today's digests from the morning brief (the Briefing model's Today items of kind digest). */
123
- async function readDig() {
124
- const r = await getj('/api/briefing-premium' + (wsParam() ? '?' + wq(wsParam()) : ''));
125
- if (!r.ok || !r.model) return { ok: false, error: r.error || 'the Briefing is not read yet' };
126
- const T = r.model.today || {};
127
- return { ok: true, items: [].concat(T.earlier || [], T.ahead || []).filter((e) => e && e.kind === 'digest') };
128
- }
129
119
  async function readAll(which) {
130
120
  const P = await prods(), all = !which;
131
- const job = { prop: () => readProps(P), men: () => readMen(), pulse: () => readPulse(P), scan: () => readScan(P), rep: () => readReps(P), src: () => readSrc(), prep: () => briefPage(), dig: () => readDig() };
121
+ const job = { prop: () => readProps(P), men: () => readMen(), pulse: () => readPulse(P), scan: () => readScan(P), rep: () => readReps(P) };
132
122
  await Promise.all(Object.keys(job).filter((k) => all || which.includes(k)).map(async (k) => { try { A[k] = await job[k](); } catch (e) { A[k] = { ok: false, error: String((e && e.message) || e) }; } }));
133
123
  redraw();
134
124
  }
@@ -174,71 +164,15 @@ const dayWord = (iso) => {
174
164
  };
175
165
  const scanOpen = () => (A.scan && A.scan.ok ? A.scan.scans.reduce((n, s) => n + (s.proposals_waiting || 0), 0) : 0);
176
166
  const repFound = () => (A.rep && A.rep.ok ? A.rep.prods.flatMap((q) => q.findings.map((f) => ({ ...f, ws: q.ws, pname: q.pname }))) : []);
177
- const behindSrc = () => { if (!A.src || !A.src.ok) return []; const ids = behindOf(lineItems(A.src.sources)).map((i) => i.id); return A.src.sources.filter((s) => ids.includes(s.id)); };
178
- const joinN = (a) => (a.length < 2 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
179
- function scanNowLine(S) {
180
- if (S.length && S.every((x) => x.switched_off)) return ' · Scan now is off here';
181
- const M = S.map((x) => x.manual).filter((m) => m && m.limit);
182
- if (!M.length) { const no = S.map((x) => x.manual).find((m) => m && m.ok === false && m.error); return no ? ' · ' + no.error : ''; }
183
- const left = M.reduce((n, m) => n + (m.left || 0), 0), lim = M.reduce((n, m) => n + m.limit, 0);
184
- return M.every((m) => m.ok === false) ? ' · Scan now: ' + (M[0].error || 'not now') : ' · Scan now: ' + left + ' of ' + lim + ' left today';
185
- }
186
- /** Refresh all's step, in words (the same run as the Sources card). */
187
- function allText(a) {
188
- if (!a) return '';
189
- const S = a.steps || [], reads = S.filter((x) => x.step === 'read'), der = S.filter((x) => x.step === 'derived');
190
- const left = reads.filter((x) => x.state === 'running' || x.state === 'waiting'), bad = S.filter((x) => x.state === 'failed').map((x) => x.label);
191
- if (a.phase === 'read') return 'Step 1 of 2: reading ' + left.map((x) => x.label).join(', ') + '. Home\'s list is written after them.';
192
- if (a.phase === 'derived') return 'Step 2 of 2: writing Home\'s list from the reads' + (bad.length ? ' (' + bad.join(', ') + ' failed, so its last read is used)' : '') + '.';
193
- const ok = der.length && der.every((x) => x.state === 'done');
194
- return 'Refresh all ended: ' + (ok ? 'the sources were read and Home\'s list was written again' : 'Home\'s list was not written again') + '.' + (bad.length ? ' Failed: ' + bad.join(', ') + '.' : '');
195
- }
196
-
197
- /** The six rows: { k, ic, t, s, m (count html), bar, wait }. Every word comes from A. */
198
- function aroundRows() {
199
- const R = [], rd = 'Reading…';
200
- { const a = A.prop, n = a && a.ok ? a.items.length : 0;
201
- R.push({ k: 'prop', ic: BDI.prop, wait: n > 0, t: !a ? rd : !a.ok ? 'Agent proposals ' + said(a) : n ? pl(n, 'agent proposal waits', 'agent proposals wait') + ' on you' : 'No agent proposals wait',
202
- s: !a || !a.ok ? '' : n ? 'Keep, send back or drop each one' : 'The agent files a draft here when it has one', m: n ? `<span class="due">${n}</span>` : '' }); }
203
- { const a = A.men, l = shownMen(), w = waitM(l);
204
- R.push({ k: 'men', ic: BDI.at, wait: w.length > 0, t: !a ? rd : !a.ok ? 'Mentions ' + said(a) : a.list === null ? 'No brief for today, so no mentions were read' : l.filter((m) => !m.read).length ? menLine(l) : 'No one has mentioned you today',
205
- s: !a || !a.ok || !l.filter((m) => !m.read).length ? '' : [...new Set(l.filter((m) => !m.read).map((m) => srcName(m.source)))].join(', '), m: w.length ? '<span class="due od">Reply</span>' : '' }); }
206
- { const a = A.pulse, g = a && a.ok ? groups(a.rows) : null, n = a && a.ok ? a.rows.length + a.none : 0;
207
- R.push({ k: 'pulse', ic: BDI.pulse, wait: !!(g && g.bad.length), t: !a ? rd : !a.ok ? 'Portfolio pulse ' + said(a) : n ? `Portfolio pulse: ${g.bad.length} late, ${g.warn.length} at risk` : 'Portfolio pulse: nothing to compare yet',
208
- s: !a || !a.ok ? '' : n ? `${g.ok.length} on plan · ${g.none.length + a.none} with no plan date` : 'No initiative has a promised date or a Jira read.', bar: n ? bar(g, n, a.none) : '', m: '' }); }
209
- { const a = A.scan, S = a && a.ok ? a.scans : [], w = scanOpen(), run = S.some((x) => x.open), last = S.map((x) => x.last && x.last.at).filter(Boolean).sort().pop(), nrep = S.reduce((n, x) => n + x.reports.filter((r) => r.written && !r.parent).length, 0);
210
- R.push({ k: 'scan', ic: BDI.scan, wait: w > 0, t: !a ? rd : !a.ok ? 'Horizon scan ' + said(a) : run ? 'Horizon scan: scanning now' : w ? 'Horizon scan: ' + pl(w, 'proposal waits', 'proposals wait') + ' for you' : S.every((x) => x.switched_off) ? 'Horizon scan: switched off' : last ? 'Horizon scan: nothing waits' : 'Horizon scan: no scan has run yet',
211
- s: !a || !a.ok ? '' : run ? 'Reading the web and the repository' : (last ? 'Ran ' + dayWord(last).toLowerCase() + (nrep ? ' · ' + pl(nrep, 'report', 'reports') : '') : 'Start one from here') + scanNowLine(S), m: w ? `<span class="due">${w}</span>` : '' }); }
212
- { const a = A.rep, L = repFound(), n = L.length, fd = a && a.ok ? a.prods.map((q) => q.finder).filter(Boolean) : [], off = fd.length > 0 && fd.every((x) => x.cadence === 'off'), nx = fd.map((x) => x.next_run).filter(Boolean).sort()[0];
213
- R.push({ k: 'rep', ic: BDI.rep, wait: n > 0, t: !a ? rd : !a.ok ? 'Report finder ' + said(a) : n === 1 ? 'Report found: ' + L[0].name : n ? pl(n, 'report', 'reports') + ' found in your work' : off ? 'The report finder is off' : 'No report found',
214
- s: !a || !a.ok ? '' : n ? 'Set it up, or say it is not a report' : nx ? 'The finder looks next ' + dayWord(nx) : off ? 'Switch it on in Settings' : 'It reads your calendar, Slack and the subjects of mail you sent', m: n ? `<span class="due">${n}</span>` : '' }); }
215
- { const a = A.src, b = behindSrc();
216
- R.push({ k: 'src', ic: BDI.src, wait: b.length > 0, t: !a ? rd : !a.ok ? 'Data freshness ' + said(a) : b.length > 2 ? b.length + ' sources need a new read' : b.length ? joinN(b.map((s) => s.label)) + (b.length === 1 ? ' needs' : ' need') + ' a new read' : 'Every source was read recently',
217
- s: !a || !a.ok ? '' : b.length > 2 ? joinN(b.map((s) => s.label)) + '. Read on a schedule, not live' : 'Sources are read on a schedule, not live', m: b.length ? `<span class="due">${b.length}</span>` : '' }); }
218
- return R;
219
- }
220
167
  const pHm = (iso) => { const d = new Date(iso); return STAMP(d.getHours()) + ':' + STAMP(d.getMinutes()); };
221
168
  /** The prep line: of the meetings still ahead today, how many have nothing left to do before them (/api/brief-page, `before` is the open items linked to a meeting). */
222
- function prepHtml() {
223
- const p = A.prep, t = p && p.ok ? p.today || [] : [], left = t.filter((m) => m.state !== 'past'), ok = left.filter((m) => !(m.before || []).length).length;
169
+ export function prepHtmlOf(p) {
170
+ const t = p && p.ok !== false ? p.today || [] : [], left = t.filter((m) => m.state !== 'past'), ok = left.filter((m) => !(m.before || []).length).length;
224
171
  if (!left.length) return '<div id="prep" class="ar-prep" hidden></div>';
225
172
  const cur = t.find((m) => m.state === 'now'), nxt = cur || t.find((m) => m.state === 'next'), R = 17, C = 2 * Math.PI * R;
226
173
  return `<div id="prep" class="ar-prep"><svg width="44" height="44" viewBox="0 0 44 44" role="img" aria-label="${ok} of ${left.length} prepped"><circle class="rb" cx="22" cy="22" r="${R}" fill="none" stroke-width="6"/><circle class="rg" cx="22" cy="22" r="${R}" fill="none" stroke-width="6" stroke-linecap="round" stroke-dasharray="${(C * ok / left.length).toFixed(2)} ${C.toFixed(2)}" transform="rotate(-90 22 22)"/><text class="rt" x="22" y="26" text-anchor="middle">${ok}/${left.length}</text></svg><div>${nxt ? `<b>${esc(nxt.title)}${cur ? ' is on now' : ' at ' + pHm(nxt.start) + ' is next'}</b>` : ''}<span>${pl(left.length, 'meeting', 'meetings')} left today. ${ok} of ${left.length} prepped.</span></div></div>`;
227
174
  }
228
175
  const bdLink = (href) => (/^https:\/\/\S+$/i.test(String(href || '')) ? href : '');
229
- /** Today's digests: each with its lines and its link (the morning brief's summary, not a copy of the source). */
230
- function digHtml() {
231
- const a = A.dig; if (!a || !a.ok || !a.items.length) return '';
232
- return `<section class="hx-sec" id="aroundDig"><h4>Digests ${a.items.length}</h4>${a.items.map((e) => { const d = e.dialog || {}, p = d.pane || {}, l = bdLink(d.link);
233
- return `<div class="bd-it ar-dig"><span class="bd-t">${esc(e.title)}</span><p class="bd-why">${esc(e.sub || '')}</p>${(p.paras || []).map((x) => `<p class="bd-q">${esc(x)}</p>`).join('')}${l ? `<div class="bd-acts"><a class="hx-b cta alt srcLink" href="${esc(l)}" target="_blank" rel="noopener noreferrer">${esc(d.linkLabel || 'Open it')}</a></div>` : ''}</div>`; }).join('')}</section>`;
234
- }
235
- function listHtml() {
236
- const R = aroundRows(), n = R.filter((r) => r.wait).length;
237
- const cap = [A.prop, A.men, A.pulse, A.scan, A.rep, A.src].some((x) => x === null) ? 'Reading' : n ? n + ' to look at' : 'quiet';
238
- return WAIT + `<div class="ar-hd"><b>Around you</b><small id="aroundCap">${esc(cap)}</small></div>` + prepHtml()
239
- + `<div id="aroundBody" class="ar-rows">${R.map((r) => `<button type="button" class="ar-row" data-bd="${r.k}"><span class="ar-ic">${bdIco(r.ic)}</span><span class="wtx"><span class="wtit">${esc(r.t)}</span>${r.s ? `<span class="ws">${esc(r.s)}</span>` : ''}${r.bar || ''}</span>${r.m ? `<span class="wm">${r.m}</span>` : ''}</button>`).join('')}</div>`
240
- + digHtml() + '<p class="hx-n">Nothing here posts to Slack, Jira, Confluence or mail. A button that records something says what, before you press it.</p>';
241
- }
242
176
 
243
177
  /* ── the pieces of a view ── */
244
178
  const bdActs = (...b) => `<div class="bd-acts">${b.join('')}</div>`;
@@ -425,44 +359,6 @@ async function repPress(b) {
425
359
  await readAll(['rep']); draw(`.bd-it[data-id="${CSS.escape(id)}"] .bd-done`);
426
360
  }
427
361
 
428
- /* ── data freshness ── */
429
- const SSTATE = { fresh: 'Recent', stale: 'Old', never: 'Never read', building: 'Reading now…', failed: 'Failed', off: 'Off' };
430
- const limitWord = (ms) => (ms >= 48 * 3600000 ? Math.round(ms / 86400000) + ' days' : Math.round(ms / 3600000) + ' hours');
431
- function srcHtml() {
432
- const a = A.src; if (!a || !a.ok) return `<p class="nodef err" role="alert">Data freshness ${esc(said(a))}</p>`;
433
- const b = behindSrc(), many = refreshTargets(a.sources);
434
- const row = (s) => {
435
- const when = s.id === 'repository' && s.state === 'fresh' ? 'watching' : s.as_of ? whenRead(s.as_of) : 'never';
436
- const sch = s.schedule ? [s.schedule.cadence, s.schedule.day, s.schedule.time].filter(Boolean).join(' ') : s.skill ? 'no schedule' : 'on every change';
437
- return `<div class="bd-src"><span><b>${esc(s.label)}</b><small><span class="bd-st ${esc(s.state)}">${esc(SSTATE[s.state] || s.state)}</span> · ${esc(when)} · ${esc(sch)}${s.stale_after_ms ? ' · old after ' + esc(limitWord(s.stale_after_ms)) : ''}</small><small>${s.skill ? 'Refresh starts the ' + esc(s.skill) + ' skill in an agent session, with your own connection.' : 'Refresh rebuilds the facts on this machine.'}</small>${SNOTE[s.id] ? `<small role="status">${esc(SNOTE[s.id])}</small>` : ''}</span>${bdBtn('Refresh', 'sfone', s.id, true, (s.state === 'off' || s.state === 'building' ? ' disabled' : '') + ` aria-label="Refresh ${esc(s.label)}"`)}</div>`;
438
- };
439
- return `<div class="bd-top"><p class="hx-n">Sources are read on a schedule, not live. ${b.length ? pl(b.length, 'source needs', 'sources need') + ' a new read.' : 'None is old.'}</p>${bdBtn('Refresh all', 'sfall', '', false, many.length ? '' : ' disabled')}</div>${a.sources.map(row).join('')}<p class="hx-n">Refresh all reads every source, then writes Home's list from those reads. The server calls nothing outside this machine: an outside source is read by a skill, with your own connection.</p>`;
440
- }
441
- let FPOLL = null;
442
- function srcPoll(n) {
443
- clearTimeout(FPOLL);
444
- if (!n || !A.src || !A.src.ok || !A.src.sources.some((s) => s.state === 'building')) return;
445
- FPOLL = setTimeout(async () => { if (VIEW !== 'src') return; await readAll(['src']); srcPoll(n - 1); }, 3000);
446
- }
447
- async function srcPress(b) {
448
- const act = b.dataset.bda; if (!['sfone', 'sfall'].includes(act)) return;
449
- const ids = act === 'sfall' ? refreshTargets(A.src.sources) : [b.dataset.id];
450
- BUSY = 'src'; b.disabled = true;
451
- if (act === 'sfall') {
452
- const r = await pmPost('/api/sources/refresh-all', { ws: A.src.ws || wsParam() || '' });
453
- BUSY = '';
454
- toast(!r || !r.ok ? 'Refresh all did not start: ' + ((r && r.error) || 'the server did not answer') + '.' : r.joined ? 'Refresh all is already running. ' + allText(r.all) : allText(r.all));
455
- await readAll(['src']); draw('[data-bda="sfall"]'); srcPoll(8);
456
- return;
457
- }
458
- const got = await Promise.all(ids.map(async (id) => [id, await pmPost('/api/sources/refresh', { ws: A.src.ws || wsParam() || '', source: id })]));
459
- BUSY = '';
460
- let bad = 0;
461
- for (const [id, r] of got) { if (r && r.ok) SNOTE[id] = r.started === 'session' ? 'An agent session started to read it.' : 'Rebuilding the facts on this machine.'; else { bad++; SNOTE[id] = 'It did not start: ' + ((r && r.error) || 'the server did not answer') + '.'; } }
462
- toast(bad ? bad + ' of ' + ids.length + ' did not start.' : 'Reading again.');
463
- await readAll(['src']); draw(`[data-bda="sfone"][data-id="${CSS.escape(ids[0])}"]`); srcPoll(8);
464
- }
465
-
466
362
  /* ── the card ── */
467
363
  const VIEWS = {
468
364
  prop: { kind: 'Agent proposals', title: propTitle, html: propsHtml, press: propPress, say: () => (A.prop && A.prop.ok ? (A.prop.items.length ? pl(A.prop.items.length, 'proposal waits', 'proposals wait') + ' for you. Keep one to record it, send it back with a note, or drop it.' : 'No proposal waits for you.') : 'The proposals could not be read.') },
@@ -470,17 +366,17 @@ const VIEWS = {
470
366
  pulse: { kind: 'Portfolio pulse', title: () => 'Portfolio pulse', html: pulseHtml, press: async () => {}, say: () => { const a = A.pulse, g = a && a.ok ? groups(a.rows) : null; return g ? `${g.bad.length} late and ${g.warn.length} at risk, of ${a.rows.length + a.none}. The late and at-risk ones are listed first.` : 'The initiatives could not be read.'; } },
471
367
  scan: { kind: 'Horizon scan', title: () => 'Horizon scan', html: scanHtml, press: scanPress, say: () => (A.scan && A.scan.ok ? (scanOpen() ? pl(scanOpen(), 'proposal waits', 'proposals wait') + ' for you. Nothing acts until you approve it.' : 'No proposal waits for you. Nothing acts until you approve it.') : 'The scan could not be read.') },
472
368
  rep: { kind: 'Report finder', title: () => 'Report found', html: repHtml, press: repPress, say: () => (A.rep && A.rep.ok ? (repFound().length ? pl(repFound().length, 'report was', 'reports were') + ' found in your work. Set it up, or say it is not a report. PMOS drafts only.' : 'No report waits for you.') : 'The findings could not be read.') },
473
- src: { kind: 'Data freshness', title: () => 'Data freshness', html: srcHtml, press: srcPress, say: () => { const b = behindSrc(); return A.src && A.src.ok ? (b.length ? joinN(b.map((s) => s.label)) + (b.length === 1 ? ' needs' : ' need') + ' a new read. Refresh one, or all.' : 'Every source was read recently.') : 'The sources could not be read.'; } },
474
369
  };
475
370
  let BODY = null;
476
371
  /** Draw the card: the rows, or the open view. focus: a selector to focus after the draw. */
477
372
  function draw(focus) {
478
373
  if (!BODY || !BODY.isConnected) return;
374
+ { const c = vwCurrent(); if (!c || !/^more:around/.test(c.id || '')) return; } // the Viewer moved on to another item: a late read draws nothing
479
375
  const V = VIEWS[VIEW];
480
- if (!V) BODY.innerHTML = `<div class="ar">${listHtml()}</div>`;
481
- else {
376
+ if (V) {
482
377
  const t = document.getElementById('czVwTitle'); if (t) t.textContent = V.title();
483
- BODY.innerHTML = `<div class="ar">${WAIT}<div class="ar-hd"><button type="button" class="hx-b alt" data-bda="back">Back to Around you</button></div><p class="hx-n ar-say">${esc(V.say())}</p><div class="bd-a" data-bd-view="${VIEW}">${V.html()}</div></div>`;
378
+ BODY.innerHTML = `<div class="ar"><div class="ar-hd"><button type="button" class="hx-b alt" data-bda="back">Back to New for you</button></div>${A[VIEW] === null ? '<p class="hx-n ar-say" role="status">Reading</p>' // the view opens before its first read ends
379
+ : `<p class="hx-n ar-say">${esc(V.say())}</p><div class="bd-a" data-bd-view="${VIEW}">${V.html()}</div>`}</div>`;
484
380
  }
485
381
  BODY.querySelectorAll('.bd-bar i[data-w]').forEach((i) => i.style.setProperty('--bd-w', i.dataset.w + '%')); // each part of the pulse bar is as wide as its share
486
382
  if (focus) { const f = BODY.querySelector(focus) || BODY.querySelector('.bd-a button:not([disabled]), .bd-a a'); if (f) f.focus(); }
@@ -490,16 +386,15 @@ function show(k) {
490
386
  VIEW = VIEWS[k] ? k : '';
491
387
  PSEL = ''; PINFO = false;
492
388
  BODY = vwOpen({ id: 'more:around' + (VIEW ? ':' + VIEW : ''), kind: VIEW ? VIEWS[VIEW].kind : 'Around you', title: VIEW ? VIEWS[VIEW].title() : 'What the agents and others left for you', icon: 'info',
493
- render: (b) => { b.classList.add('hx'); BODY = b; draw(); wire(b); }, onClose: () => { clearTimeout(SPOLL); clearTimeout(FPOLL); } });
389
+ render: (b) => { b.classList.add('hx'); BODY = b; draw(); wire(b); }, onClose: () => { clearTimeout(SPOLL); } });
494
390
  if (VIEW === 'scan') scanPoll();
495
- if (VIEW === 'src') srcPoll(8);
496
391
  return BODY;
497
392
  }
498
393
  function wire(b) {
499
394
  b.onclick = async (e) => {
500
395
  const r = e.target.closest('[data-bd]'); if (r && !VIEW) { show(r.dataset.bd); return; }
501
396
  const t = e.target.closest('[data-bda]'); if (!t || BUSY) return;
502
- if (t.dataset.bda === 'back') { show(''); return; }
397
+ if (t.dataset.bda === 'back') { import('./cozy-news.js').then((M) => M.openNews({})); return; } // Around you is gone: its views come from New for you
503
398
  if (t.disabled) return;
504
399
  if (VIEWS[VIEW]) await VIEWS[VIEW].press(t);
505
400
  };
@@ -508,8 +403,11 @@ function wire(b) {
508
403
  const s = e.target.closest('[data-bds]'); if (s) { SWHY[s.dataset.bds] = s.value; const k = b.querySelector(`[data-bda="sdis"][data-id="${CSS.escape(s.dataset.bds)}"]`); if (k) k.disabled = !s.value.trim(); }
509
404
  };
510
405
  }
406
+ /** premium-uncovered-features (HmAround): Around you is gone. No key opens New for you, src opens Sources; the other keys open their view. */
511
407
  export function openAround(key) {
512
- const body = show(key || '');
408
+ if (key === 'src') return import('./cozy-sources.js').then((M) => M.openSources());
409
+ if (!key || !VIEWS[key]) return import('./cozy-news.js').then((M) => M.openNews({}));
410
+ const body = show(key);
513
411
  readAll();
514
412
  return body;
515
413
  }
@@ -5,7 +5,10 @@
5
5
  * checklist while it works (from its own TodoWrite list); a permission card with the change before → after, Allow and Deny. Over the box: the
6
6
  * run strip with Stop, and "Also waiting on you". Two boxes: the basic one on Home (In: chip above, → send, the hint under it) and the rich
7
7
  * one in an initiative (+, /, @, the In:/To: chip, the key hint, ↑ send). The + menu holds Attach a file, and the Notes and the terminal of
8
- * the conversation (not in the design yet: marked Waiting for design).
8
+ * the conversation.
9
+ * The mic is part of the input (canvas HmMic): press it and speak, the words appear as text in the box with a small blue dot while it
10
+ * listens, press it again to stop, edit, send. On a phone it opens the "Speak to Claude" sheet (HmPhone): Discard, or stop and send.
11
+ * Nothing is saved as audio (home-dictate.js). A card the target brings (intro.card, the decision card of HmDecide) draws under the intro.
9
12
  *
10
13
  * The words are Claude Code's own transcript. A conversation is either a chat key (GET /api/briefing-premium/thread?key=, the session it
11
14
  * started, POST /ask and /press) or a session with no chat key (GET /api/sessions/conversation?id=, POST /api/session/say and /keys).
@@ -22,6 +25,7 @@ import { turnsOf } from './chat-context.js';
22
25
  import { askCardHtml, answerText } from './chat-ask.js';
23
26
  import { splitFiles, filesHtml, sizeText, MAX_BYTES, MAX_FILES, setAttachSink } from './premium-attach.js';
24
27
  import * as VWC from './cozy-viewer.js';
28
+ import { canDictate, dictate } from './home-dictate.js';
25
29
  /* The views a chat opens go in the Viewer: on a page with no dialog the old viewer's views draw in the cozy card (premium-viewer.js). */
26
30
  const views = {
27
31
  ctx: () => import('./premium-vw-ctx.js'), file: () => import('./premium-vw-file.js'), attach: () => import('./premium-attach.js'),
@@ -30,6 +34,7 @@ const views = {
30
34
 
31
35
  const SVG = (d, w = 16, sw = 2) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
32
36
  const CHEV = 'M9 6l6 6-6 6', ARROW = 'M5 12h14M13 6l6 6-6 6', UP = 'M12 19V5M6 11l6-6 6 6', PLUS = 'M12 5v14M5 12h14', DOWN = 'M6 9l6 6 6-6';
37
+ const MIC = 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3zM5 11a7 7 0 0 0 14 0M12 18v3', SQ = 'M6 6h12v12H6z', XX = 'M6 6l12 12M18 6L6 18', OK = 'M5 12l5 5 9-10';
33
38
  const PANE = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><rect x="3" y="4" width="18" height="16" rx="3"></rect><path d="M14 4v16"></path></svg>';
34
39
  const DOTS = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><circle cx="5" cy="12" r="1.8"/><circle cx="12" cy="12" r="1.8"/><circle cx="19" cy="12" r="1.8"/></svg>';
35
40
  const INTERRUPT = /^\[Request interrupted by user/;
@@ -101,7 +106,8 @@ export function mountChat(el, host) {
101
106
  function introHtml(o) {
102
107
  if (!o) return '';
103
108
  const r = o.role || { name: 'Claude', initial: 'C' };
104
- return `<div class="hm-a">${avHtml(r)}<div class="hm-ab"><p class="hm-who"><b>${esc(r.name)}</b> <span class="hm-say">${esc(o.text)}</span></p></div></div>`
109
+ const card = o.card && typeof o.card.html === 'function' ? o.card.html() : '';
110
+ return `<div class="hm-a">${avHtml(r)}<div class="hm-ab"><p class="hm-who"><b>${esc(r.name)}</b> <span class="hm-say">${esc(o.text)}</span></p>${card ? `<div class="hm-icard">${card}</div>` : ''}</div></div>`
105
111
  + (o.pills && o.pills.length ? `<div class="hm-pills">${o.pills.map((p, i) => `<button type="button" class="${p.primary ? 'pri' : ''}" data-hm-pill="${i}"${p.disabled ? ' disabled' : ''}>${esc(p.label)}</button>`).join('')}</div>` : '');
106
112
  }
107
113
  /** Claude's question card (AskUserQuestion), answerable until the PM writes again. */
@@ -253,32 +259,35 @@ export function mountChat(el, host) {
253
259
  const keep = foot.querySelector('textarea'); const val = keep ? keep.value : '';
254
260
  // the session's terminal: watch it read only while the session runs; copy the line that resumes an ended chat
255
261
  const live = sid() && C.conv && C.conv.state !== 'ended';
256
- // the + is the box's one quiet entry: Attach a file (the Agreed design's +), then the conversation's Notes and its terminal, which the
257
- // design does not draw yet (each marked Waiting for design). The toolbar stays "+ / @ chip" as the mockup has it.
258
- const W = '<em>Waiting for design</em>';
259
- const term = live ? `<button type="button" role="menuitem" id="hmTerm" data-hm-term aria-label="Watch its terminal"><b>Watch its terminal</b>${W}</button>`
260
- : C.th && C.th.resume ? `<button type="button" role="menuitem" id="hmTerm" data-hm-copyterm aria-label="Copy the terminal command"><b>Copy the terminal command</b>${W}</button>` : '';
261
- const notesBtn = t.key ? `<button type="button" role="menuitem" id="hmNotes" data-hm-notes aria-label="Notes for this conversation"><b>Notes</b>${W}</button>` : '';
262
+ // the + is the box's one quiet entry: Attach a file (the Agreed design's +), then the conversation's Notes and its terminal.
263
+ // The toolbar stays "+ / @ chip" as the mockup has it.
264
+ const term = live ? `<button type="button" role="menuitem" id="hmTerm" data-hm-term aria-label="Watch its terminal"><b>Watch its terminal</b><em>Read only, while it works</em></button>`
265
+ : C.th && C.th.resume ? `<button type="button" role="menuitem" id="hmTerm" data-hm-copyterm aria-label="Copy the terminal command"><b>Copy the terminal command</b><em>Picks this chat up in Terminal</em></button>` : '';
266
+ const notesBtn = t.key ? `<button type="button" role="menuitem" id="hmNotes" data-hm-notes aria-label="Notes for this conversation"><b>Notes</b><em>Your notepad for this conversation</em></button>` : '';
267
+ // the mic (HmMic): part of the input; a small blue dot while it listens, the stop square on the same button
268
+ const on = !!(C.dict && C.dict.on());
269
+ const mic = canDictate() ? `<button type="button" class="ut-mic${on ? ' on' : ''}" data-hm-mic aria-pressed="${on}" aria-label="${on ? 'Stop listening' : C.spoke ? 'Speak more' : 'Speak instead of typing'}" title="${on ? 'Stop listening' : 'Speak instead of typing'}">${SVG(on ? SQ : MIC, on ? 12 : 18)}</button>` : '';
270
+ const dot = on ? '<span class="ut-live" role="status"><span class="ut-rec b" aria-hidden="true"></span><span class="vh">Listening</span></span>' : '';
262
271
  const attach = t.key ? '<button type="button" role="menuitem" data-hm-file><b>Attach a file</b><em>Or paste or drop it on the conversation</em></button>' : '';
263
272
  const addOpen = !!C.addOpen && !!(attach || notesBtn || term);
264
273
  const add = attach || notesBtn || term ? `<span class="hm-mw hm-addw"><button type="button" class="hm-tool" id="hmAdd" data-hm-add aria-haspopup="menu" aria-expanded="${addOpen}" aria-label="${t.key ? 'Attach a file, notes and more' : 'More'}" title="${t.key ? 'Attach a file' : 'More'}">${SVG(PLUS)}</button>`
265
274
  + `<span class="hm-pmenu hm-addm" role="menu" aria-label="Add"${addOpen ? ' data-esc-layer' : ' hidden'}>${attach}${notesBtn}${term}</span>${t.key ? '<input type="file" id="hmFile" multiple hidden>' : ''}</span>` : '';
266
275
  let html;
267
276
  if (t.rich) {
268
- const wait = C.conv && C.conv.ask && t.also ? `<button type="button" class="hm-chip" data-hm-also><i class="dot" aria-hidden="true"></i><span>1 more needs you</span></button>` : '';
277
+ const wait = C.conv && C.conv.ask && t.also ? `<button type="button" class="hm-chip" data-hm-also><i class="dot" aria-hidden="true"></i><span>1 more next step</span></button>` : '';
269
278
  const to = t.to && !wait ? `<button type="button" class="hm-chip to" data-hm-to aria-label="Who reads this: ${esc(t.to.name)}. Change">${avHtml(t.to, 20)}<span>To: ${esc(t.to.name)}</span></button>` : '';
270
279
  const scope = !to && !wait ? `<button type="button" class="hm-chip" data-hm-scope aria-label="Where this goes: ${esc(sc.text)}. Change" title="Where this goes: ${esc(sc.text)}">${SVG(sc.icon, 14)}<span>In: ${esc(sc.text)}</span></button>` : '';
271
- html = `${also}${strip}<form class="hm-box" id="hmForm"><textarea id="hmIn" rows="1" aria-label="A message for ${esc(R.role.name)}" placeholder="${esc(ph)}"></textarea>`
280
+ html = `${also}${strip}<form class="hm-box${on ? ' ut-on' : ''}" id="hmForm">${dot}<textarea id="hmIn" rows="1" aria-label="A message for ${esc(R.role.name)}" placeholder="${esc(ph)}"></textarea>`
272
281
  + `<div class="hm-tb">${add}`
273
282
  + `<button type="button" class="hm-tool" data-hm-slash aria-label="Commands" title="Commands"><b>/</b></button><button type="button" class="hm-tool" data-hm-at aria-label="Bring in an agent" title="Bring in an agent"><b>@</b></button>`
274
283
  + to + wait + scope + `<span class="sp"></span>${host.viewerClosed() ? '<span class="hm-key">Enter sends · Shift+Enter for a new line</span>' : ''}`
275
- + `<button type="submit" class="hm-send" aria-label="Send" title="Send">${SVG(UP, 18)}</button></div>`
284
+ + `${mic}<button type="submit" class="hm-send" aria-label="Send" title="Send">${SVG(UP, 18)}</button></div>`
276
285
  + filesRow()
277
286
  + '</form>';
278
287
  } else {
279
288
  html = `${also}${strip}<div class="hm-scope"><button type="button" class="hm-chip${sc.loose ? ' loose' : ''}" data-hm-scope aria-label="Where this goes: ${esc(sc.text)}. Change" title="Where this goes: ${esc(sc.text)}">${SVG(sc.icon, 14)}<span>In: ${esc(sc.text)}</span>${SVG(DOWN, 12)}</button>`
280
289
  + (sc.loose && t.sid ? '<button type="button" class="hm-link" data-hm-link>Link to an initiative</button>' : '') + `<span class="sp"></span>${add}</div>`
281
- + filesRow() + `<form class="hm-basic" id="hmForm"><textarea id="hmIn" rows="1" aria-label="A message for Claude" placeholder="${esc(ph)}"></textarea><button type="submit" class="hm-go" aria-label="Send to Claude" title="Send">${SVG(ARROW, 18)}</button></form>`
290
+ + filesRow() + `<form class="hm-basic${on ? ' ut-on' : ''}" id="hmForm">${dot}<textarea id="hmIn" rows="1" aria-label="A message for Claude" placeholder="${esc(ph)}"></textarea>${mic}<button type="submit" class="hm-go" aria-label="Send to Claude" title="Send">${SVG(ARROW, 18)}</button></form>`
282
291
  + '<p class="hm-hint">It works in a real Claude Code session: it can read, change files, run commands and take slash commands.</p>';
283
292
  }
284
293
  if (foot.__h !== html) {
@@ -348,6 +357,10 @@ export function mountChat(el, host) {
348
357
  }
349
358
  const b = e.target.closest('button, [data-file], [data-att], [data-ctx]'); if (!b || !el.contains(b)) return;
350
359
  const d = b.dataset;
360
+ const ic = b.closest('.hm-icard'), card = C.t && C.t.intro && C.t.intro.card;
361
+ if (ic && card && card.press) { if (await card.press(b)) draw(); return; }
362
+ if ('hmMic' in d) { mic(); return; }
363
+ if (d.utSpeak) { speakPress(d.utSpeak); return; }
351
364
  if ('hmAdd' in d) { C.addOpen = !C.addOpen; drawFoot({ role: role() }); const f = C.addOpen && foot.querySelector('.hm-addm [role=menuitem]'); if (f) f.focus(); return; }
352
365
  if (C.addOpen && b.closest('.hm-addm')) { C.addOpen = false; drawFoot({ role: role() }); } // a press in the + menu closes it, then does its part
353
366
  if ('hmFile' in d) { const i = foot.querySelector('#hmFile'); if (i) i.click(); return; }
@@ -405,7 +418,47 @@ export function mountChat(el, host) {
405
418
  if (menu && e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); e.target.value = ''; drawSlash(); grow(e.target); return; }
406
419
  if (e.key === 'Enter' && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) { e.preventDefault(); el.querySelector('#hmForm').requestSubmit(); }
407
420
  });
408
- el.addEventListener('input', (e) => { if (e.target.id === 'hmIn') { grow(e.target); C.slashAt = 0; drawSlash(); } });
421
+ el.addEventListener('input', (e) => {
422
+ const card = C.t && C.t.intro && C.t.intro.card;
423
+ if (card && card.input && e.target.closest('.hm-icard')) { card.input(e.target, e.target.closest('.hm-icard')); return; }
424
+ if (e.target.id === 'hmIn') { grow(e.target); C.slashAt = 0; drawSlash(); }
425
+ });
426
+ /* ── the mic ── dictation into the box only (HmMic). A desk shows the blue dot in the box; a phone shows the Speak to Claude sheet. */
427
+ const box = () => foot.querySelector('textarea');
428
+ function mic() {
429
+ if (C.dict && C.dict.on()) { C.dict.stop(); return; }
430
+ C.spoke = false;
431
+ C.dict = dictate(box, { onState: (s) => {
432
+ if (s.error) host.toast(s.error);
433
+ if (s.text) C.spoke = true;
434
+ if (!host.desk()) sheetOf(s);
435
+ if (!s.on && C.sendAfter) { C.sendAfter = false; const ta = box(); if (ta && ta.value.trim()) el.querySelector('#hmForm').requestSubmit(); }
436
+ drawFoot({ role: role() });
437
+ } });
438
+ drawFoot({ role: role() });
439
+ const ta = box(); if (ta && host.desk()) ta.focus();
440
+ }
441
+ function sheetOf(s) {
442
+ let sh = document.getElementById('utSpeak');
443
+ if (!s.on) { if (sh) sh.hidden = true; return; }
444
+ if (!sh) {
445
+ document.body.insertAdjacentHTML('beforeend', '<div class="ut-sheet" id="utSpeak" role="dialog" aria-label="Speak to Claude" hidden></div>');
446
+ sh = document.getElementById('utSpeak');
447
+ sh.onclick = (e) => { const b = e.target.closest('[data-ut-speak]'); if (b) speakPress(b.dataset.utSpeak); };
448
+ }
449
+ const secs = s.secs || 0;
450
+ sh.innerHTML = '<div class="grab" aria-hidden="true"></div><h3>Speak to Claude</h3>'
451
+ + `<p class="ut-small ut-mut">${s.text ? '“' + esc(s.text.length > 90 ? '…' + s.text.slice(-90) : s.text) + '”' : 'Listening. Speak, and the words appear here.'}</p>`
452
+ + `<div class="bar"><span class="ut-rec b" aria-hidden="true"></span><b>${Math.floor(secs / 60)}:${String(secs % 60).padStart(2, '0')}</b><span class="sp"></span>`
453
+ + `<button type="button" class="ut-ib" data-ut-speak="discard" aria-label="Discard">${SVG(XX, 18)}</button><button type="button" class="ut-ib pri" data-ut-speak="send" aria-label="Stop and send as text">${SVG(OK, 18)}</button></div>`;
454
+ sh.hidden = false;
455
+ }
456
+ function speakPress(k) {
457
+ if (!C.dict) return;
458
+ if (k === 'discard') { C.sendAfter = false; C.dict.cancel(); }
459
+ else { C.sendAfter = true; C.dict.stop(); }
460
+ sheetOf({ on: false });
461
+ }
409
462
  /* the / menu: opens on a leading /, arrows move, Enter or Tab picks, Esc shuts it */
410
463
  function drawSlash() {
411
464
  const ta = foot.querySelector('textarea'); if (!ta) return;
@@ -424,7 +477,7 @@ export function mountChat(el, host) {
424
477
  const notesLib = () => notesM || (notesM = import('./premium-notes.js').then((M) => {
425
478
  M.mountNotes({ getKey: () => (C.t && C.t.key) || null, ws: (C.t && C.t.ws) || new URLSearchParams(location.search).get('ws') || undefined,
426
479
  get input() { return foot.querySelector('textarea'); }, note: { set textContent(v) { if (v) host.toast(v); } },
427
- show: () => { const b = VWC.body(); if (b && !b.querySelector(':scope > .hx-wait')) b.insertAdjacentHTML('afterbegin', host.wait || ''); },
480
+ show: () => { const b = VWC.body(); if (b && host.wait && !b.querySelector(':scope > .hx-wait')) b.insertAdjacentHTML('afterbegin', host.wait); }, // Notes is not drawn on the Home canvas: it keeps its marker
428
481
  toChat: () => { if (!host.desk()) VWC.close(); } });
429
482
  return M;
430
483
  }));
@@ -55,7 +55,7 @@ export function iniOfSession(s) {
55
55
  return m ? m[1] : null;
56
56
  }
57
57
  const stateOf = (s) => (s.shown === 'needs' ? 'needs' : s.shown === 'blocked' ? 'blocked' : s.shown === 'working' ? 'working' : s.shown === 'exited' ? 'exited' : 'quiet');
58
- function sessionRow(s, roles) {
58
+ export function sessionRow(s, roles) {
59
59
  const role = roleOf(s, roles);
60
60
  const st = stateOf(s);
61
61
  const name = s.hx && s.hx.title ? s.hx.title : s.name || 'Session';
@@ -90,7 +90,7 @@ export const UPDATE_KEY = 'chat:weekly-update';
90
90
 
91
91
  /* ── initiatives ── */
92
92
  export const boardRows = (D) => (D.board && D.board.initiatives && D.board.initiatives.list && D.board.initiatives.list.rows) || (D.board && D.board.rows) || [];
93
- const live = (s) => s.shown !== 'exited' && s.state !== 'exited';
93
+ export const live = (s) => s.shown !== 'exited' && s.state !== 'exited';
94
94
  /** The kids of one initiative: its needs, its live sessions and today's meetings about it, the loudest first. */
95
95
  export function kidsOf(D, id) {
96
96
  const needs = needsOf(D).filter((r) => r.ini === id && !r.needSession);
@@ -100,7 +100,7 @@ export function kidsOf(D, id) {
100
100
  }
101
101
  export function kidsChip(kids) {
102
102
  const need = kids.filter((x) => x.state === 'needs' || x.state === 'blocked').length, run = kids.filter((x) => x.state === 'working').length;
103
- return { text: need ? need + (need === 1 ? ' needs you' : ' need you') : run ? run + ' running' : String(kids.length), loud: need > 0 };
103
+ return { text: need ? (need === 1 ? 'your turn' : need + ' next steps') : run ? run + ' running' : String(kids.length), loud: need > 0 };
104
104
  }
105
105
  const TURN = (r, kids) => (kids.some((k) => k.state === 'needs' || k.state === 'blocked') ? 'your turn' : kids.some((k) => k.state === 'working') ? 'agents working' : /stalled|hold/i.test(String(r.status || '') + ' ' + String((r.acts && r.acts.life) || '')) ? 'stalled' : r.late ? 'late' : '');
106
106
  function iniRow(D, r) {
@@ -108,7 +108,7 @@ function iniRow(D, r) {
108
108
  const st = kids.some((k) => k.state === 'needs') ? 'needs' : kids.some((k) => k.state === 'blocked') ? 'blocked' : kids.some((k) => k.state === 'working') ? 'working' : 'quiet';
109
109
  return { id: 'i:' + r.id, kind: 'ini', ini: r.id, name: r.title, hint: [cap1(r.lane || 'feature'), r.stage, TURN(r, kids)].filter(Boolean).join(' · '), state: st, icon: 'goal', kids, chip: kids.length ? kidsChip(kids) : null, board: r };
110
110
  }
111
- const OPEN = (r) => !(r.acts && (r.acts.archived || r.acts.life === 'done' || r.acts.life === 'cancelled'));
111
+ export const OPEN = (r) => !(r.acts && (r.acts.archived || r.acts.life === 'done' || r.acts.life === 'cancelled'));
112
112
 
113
113
  /* ── the product ── */
114
114
  const statusOf = (r) => String(r.status || '').toLowerCase();
@@ -220,7 +220,7 @@ function productRow(D) {
220
220
  const kids = needsOf(D).filter((r) => r.kind === 'update');
221
221
  const upd = P.sent ? 'update sent' : 'update ready';
222
222
  return { id: 'p:product', kind: 'product', name: P.name, hint: 'Product · ' + upd + (risk ? ', ' + risk + ' at risk' : ''), state: P.sent ? 'quiet' : 'needs', icon: 'product',
223
- kids, chip: P.sent ? null : { text: '1 needs you', loud: true } };
223
+ kids, chip: P.sent ? null : { text: 'your turn', loud: true } };
224
224
  }
225
225
 
226
226
  /* ── one initiative as a layout ── */
@@ -246,7 +246,7 @@ export function iniLayout(D, id) {
246
246
  const byIni = new Map(); for (const r of other) { const k = r.ini || ''; byIni.set(k, (byIni.get(k) || 0) + 1); }
247
247
  const top = [...byIni.entries()].sort((a, b) => b[1] - a[1]);
248
248
  const titleOf = (k) => { const b = boardRows(D).find((r) => r.id === k); return b ? b.title : k || 'Home'; };
249
- const elsewhere = other.length ? { n: other.length, text: top.map(([k, n]) => n + (n === 1 ? ' needs' : ' need') + ' you in ' + titleOf(k)).join(' · '), first: other[0] } : null;
249
+ const elsewhere = other.length ? { n: other.length, text: top.map(([k, n]) => (n === 1 ? 'Your turn in ' : n + ' next steps in ') + titleOf(k)).join(' · '), first: other[0] } : null;
250
250
  return { groups, elsewhere };
251
251
  }
252
252
  export const initials = (name) => { const w = String(name || '').trim().split(/\s+/); return w.length > 1 ? (w[0][0] + w[1][0]).toUpperCase() : String(name || '?').slice(0, 2).replace(/^./, (c) => c.toUpperCase()); };
@@ -0,0 +1,54 @@
1
+ /* pm/home-dictate.js — the mic of the chat input: dictation into a text box (initiative premium-uncovered-features, H2; canvas HmMic and
2
+ * HmPhone). The mic is part of the input, nothing new to learn: press it, speak, the words appear as text in the box, stop, edit, send.
3
+ * It is the browser's own speech recognition (SpeechRecognition, as the console's live notes use it). Nothing is recorded as audio,
4
+ * nothing is saved, and nothing is sent: the text stays in the box until the PM sends it. A browser without speech recognition shows no mic.
5
+ * canDictate() true when this browser can turn speech into text
6
+ * dictate(box, { onState }) starts listening into the box (a textarea or an input) → { stop(), cancel(), on() }
7
+ * onState({ on, text, secs }) after each change; stop keeps the words, cancel puts the box back as it was */
8
+ const SR = () => (typeof window !== 'undefined' && (window.SpeechRecognition || window.webkitSpeechRecognition)) || null;
9
+ export const canDictate = () => !!SR();
10
+
11
+ let current = null;
12
+ export function dictate(box, o = {}) {
13
+ if (current) current.stop();
14
+ const Rec = SR();
15
+ const state = { on: false, text: '', secs: 0 };
16
+ const said = (v) => { try { o.onState && o.onState({ ...state, ...v }); } catch { /* the page redraws on its own */ } };
17
+ // box is the text box, or a function that finds it: a page that redraws its input still gets the words in the box shown now
18
+ const B = typeof box === 'function' ? box : () => box;
19
+ const el0 = B();
20
+ if (!Rec || !el0) { said({ on: false, error: 'This browser cannot turn speech into text. Type instead.' }); return { stop() {}, cancel() {}, on: () => false }; }
21
+ const before = el0.value || '';
22
+ const lead = before && !/\s$/.test(before) ? before + ' ' : before;
23
+ let finalText = '', interim = '', t0 = Date.now(), tick = null, stopped = false;
24
+ const r = new Rec();
25
+ r.continuous = true; r.interimResults = true;
26
+ r.lang = (typeof navigator !== 'undefined' && navigator.language) || 'en-US';
27
+ const put = () => {
28
+ const x = B(); if (x) { x.value = lead + finalText + interim; x.dispatchEvent(new Event('input', { bubbles: true })); }
29
+ state.text = (finalText + interim).trim();
30
+ said({});
31
+ };
32
+ r.onresult = (e) => {
33
+ interim = '';
34
+ for (let i = e.resultIndex; i < e.results.length; i++) {
35
+ const res = e.results[i];
36
+ if (res.isFinal) finalText += res[0].transcript.replace(/^\s+/, finalText ? ' ' : '');
37
+ else interim += res[0].transcript;
38
+ }
39
+ put();
40
+ };
41
+ const end = () => { clearInterval(tick); state.on = false; interim = ''; if (current === C) current = null; if (!stopped) put(); said({ on: false }); };
42
+ r.onerror = (e) => { said({ on: false, error: e && e.error === 'not-allowed' ? 'The browser did not allow the microphone.' : 'Listening stopped.' }); };
43
+ r.onend = end;
44
+ const C = {
45
+ stop() { stopped = false; try { r.stop(); } catch { end(); } },
46
+ cancel() { stopped = true; try { r.abort(); } catch { /* ended */ } const x = B(); if (x) { x.value = before; x.dispatchEvent(new Event('input', { bubbles: true })); } end(); },
47
+ on: () => state.on,
48
+ };
49
+ try { r.start(); } catch { said({ on: false, error: 'Listening could not start.' }); return C; }
50
+ current = C; state.on = true; t0 = Date.now();
51
+ tick = setInterval(() => { state.secs = Math.round((Date.now() - t0) / 1000); said({}); }, 1000);
52
+ said({});
53
+ return C;
54
+ }
@@ -1,10 +1,10 @@
1
1
  /* home-draft.js — a core document's draft, read in Home's Viewer, with Issue it (premium-agreed-design; initiative premium-core-doc-issue).
2
- * The Agreed design draws no draft reader, so this is the minimal version, marked Waiting for design: the Issue it bar above the text, Read and
3
- * Edit. Edit is the document page's own editor (premium-vw-doc.js, ctx.host), so a save goes through POST /api/doc-sheet/edit as everywhere else.
2
+ * Drawn in the Viewer's card shape (canvas HmMyWork: the title, the line under it, the chips, the foot): the Issue it bar above the text,
3
+ * Read and Edit. Edit is the document page's own editor (premium-vw-doc.js, ctx.host), so a save goes through POST /api/doc-sheet/edit as everywhere else.
4
4
  * Issue it posts POST /api/core-docs/issue { ws, scope, key, slot } and nothing else: it marks the draft issued and sends nothing to anyone.
5
5
  * Issue it is refused here while the editor holds typed text that is not saved.
6
6
  *
7
- * openDraftVw({ VW, pmGet, pmPost, toast, wait, ws, scope, doc, onIssued })
7
+ * openDraftVw({ VW, pmGet, pmPost, toast, ws, scope, doc, onIssued })
8
8
  * doc the docs row: { key, title, path, slot, st, state }
9
9
  * onIssued awaited after the route answers ok (the page reads again)
10
10
  */
@@ -22,10 +22,10 @@ export function openDraftVw(o) {
22
22
  : `<div class="hm-iss" data-issue-bar="draft"><span>A draft. Nothing is sent: issuing marks it issued and sends nothing to anyone.</span><button type="button" class="hx-b pri" data-ds="issue"${X.busy ? ' disabled' : ''}>Issue it</button></div>`);
23
23
  const draw = () => {
24
24
  if (!body) return;
25
- const tabs = `<div class="hx-tabs" role="tablist" aria-label="Draft">${[['read', 'Read'], ['edit', 'Edit']].map(([k, l]) => `<button type="button" role="tab" aria-selected="${X.tab === k}" aria-pressed="${X.tab === k}" data-ds="${k}">${l}</button>`).join('')}</div>`;
25
+ const tabs = `<div class="hx-tabs ut-chips" role="tablist" aria-label="Draft">${[['read', 'Read'], ['edit', 'Edit']].map(([k, l]) => `<button type="button" class="cz-chip${X.tab === k ? ' on' : ' gh'}" role="tab" aria-selected="${X.tab === k}" aria-pressed="${X.tab === k}" data-ds="${k}">${l}</button>`).join('')}</div>`;
26
26
  const text = X.text == null ? `<p class="hx-n">${esc(X.err || 'Reading the draft.')}</p>` : `<div class="dsbody hm-md">${mdHtml(X.text).html}</div>`;
27
- body.innerHTML = (o.wait || '') + bar() + `<p class="hx-n" id="dsErr" role="alert">${esc(X.msg)}</p>` + tabs
28
- + `<p class="hx-n">${esc(d.path)}</p>` + (X.tab === 'read' ? text : '<div class="hm-dsed" data-ds-host></div>');
27
+ body.innerHTML = `<div class="ut-vc"><div><h2 class="ut-h2">${esc(d.title || 'Draft')}</h2><p class="ut-sub">${esc(d.path)}</p></div>` + bar() + `<p class="hx-n" id="dsErr" role="alert">${esc(X.msg)}</p>` + tabs
28
+ + (X.tab === 'read' ? text : '<div class="hm-dsed" data-ds-host></div>') + '</div>';
29
29
  if (X.tab === 'edit') mountEditor();
30
30
  };
31
31
  async function read() {