create-pmos 0.431.0 → 0.432.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 (58) 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/board-programs-test.js +10 -4
  7. package/workspace/briefing-premium-board-test.js +24 -22
  8. package/workspace/briefing-premium-initiative-test.js +10 -5
  9. package/workspace/briefing-premium-products-test.js +2 -0
  10. package/workspace/briefing-premium-sources-test.js +15 -8
  11. package/workspace/briefing-premium-work-test.js +6 -3
  12. package/workspace/changelog.json +12 -0
  13. package/workspace/ev-everywhere-test.js +40 -33
  14. package/workspace/guide/briefing-premium.md +1 -1
  15. package/workspace/guide/data-freshness.md +3 -1
  16. package/workspace/guide/home.md +25 -16
  17. package/workspace/guide/initiative-boards.md +6 -6
  18. package/workspace/guide/programs.md +2 -2
  19. package/workspace/ini-workflow-test.js +13 -8
  20. package/workspace/lib/briefing-premium.js +6 -3
  21. package/workspace/lib/engine/boards.js +13 -2
  22. package/workspace/lib/ini-deleted.js +58 -0
  23. package/workspace/lib/initiative-rows.js +4 -1
  24. package/workspace/lib/routes-boards.js +48 -0
  25. package/workspace/lib/search-index.js +3 -1
  26. package/workspace/package-lock.json +2 -2
  27. package/workspace/package.json +1 -1
  28. package/workspace/premium-board-actions-test.js +50 -32
  29. package/workspace/premium-briefing-depth-test.js +33 -34
  30. package/workspace/premium-core-doc-issue-test.js +1 -1
  31. package/workspace/premium-vw-backlog-test.js +1 -1
  32. package/workspace/premium-vw-item-test.js +1 -1
  33. package/workspace/premium-vw-jira-test.js +1 -1
  34. package/workspace/program-leave-test.js +20 -19
  35. package/workspace/public/pm/bd-acts.js +7 -5
  36. package/workspace/public/pm/bd-ini-panel.js +57 -25
  37. package/workspace/public/pm/cozy-ev.css +22 -7
  38. package/workspace/public/pm/cozy-evmodel.js +3 -3
  39. package/workspace/public/pm/cozy-nav.js +29 -32
  40. package/workspace/public/pm/cozy-news.js +11 -27
  41. package/workspace/public/pm/cozy-settings.js +68 -11
  42. package/workspace/public/pm/cozy-sources.js +5 -89
  43. package/workspace/public/pm/cozy-today.css +19 -1
  44. package/workspace/public/pm/hi-pop.css +21 -0
  45. package/workspace/public/pm/hi-pop.js +5 -5
  46. package/workspace/public/pm/home-app.js +62 -25
  47. package/workspace/public/pm/home-day.js +60 -2
  48. package/workspace/public/pm/home-ini.js +66 -27
  49. package/workspace/public/pm/home-more.js +9 -50
  50. package/workspace/public/pm/home-today.js +4 -2
  51. package/workspace/public/pm/ini-more.js +78 -42
  52. package/workspace/public/pm/ini-view-model.js +1 -1
  53. package/workspace/public/pm/ini-view.css +17 -0
  54. package/workspace/public/pm/ini-view.js +25 -7
  55. package/workspace/public/pm/premium-board.js +4 -3
  56. package/workspace/public/pm/prog-move.js +26 -0
  57. package/workspace/public/premium.html +0 -1
  58. package/workspace/stage-card-test.js +10 -1
@@ -1,89 +1,5 @@
1
- /* pm/cozy-sources.js — Sources, in the Viewer (initiative premium-uncovered-features, E3; canvas EvSources).
2
- *
3
- * What PMOS reads, and how old each reading is (GET /api/sources). The source furthest behind leads in an amber box that names what may be
4
- * out of date, with Read again. Then the table: each source, when it was last read, and Read again for one that is old, failed or never
5
- * read (POST /api/sources/refresh), or Connect for one that is off (Settings › Connectors). Read all again reads every source and then
6
- * writes Home's list from those reads (POST /api/sources/refresh-all). The read lines say which reads Home shows. Every press is the PM's
7
- * (pmPost carries the launch nonce); PMOS reads these sources and never posts to them.
8
- * openSources() → the body element */
9
- import { pmGet, pmPost } from './http.js';
10
- import { open as vwOpen, current as vwCurrent } from './cozy-viewer.js';
11
- import { esc, svg, ICON, toast, wsParam, wsQ, skelRows, cantRead } from './cozy-evui.js';
12
- import { sourceRows, staleOf, partsOf } from './cozy-evmodel.js';
13
-
14
- const TILE = { repository: ICON.repo, initiatives: ICON.flag, calendar: ICON.cal, jira: ICON.jira, 'my-work': ICON.check, tracker: ICON.board, tools: ICON.tools };
15
- const two = (n) => String(n).padStart(2, '0');
16
- const hm = (d) => two(d.getHours()) + ':' + two(d.getMinutes());
17
- const M = { r: null, at: null, busy: '', note: {}, body: null };
18
-
19
- /** The read line of each part of Home (briefing-source-flow slice 5), from one GET /api/sources answer; home-more.js readLine words. */
20
- function readsHtml(s) {
21
- return import('./home-more.js').then((H) => {
22
- const L = [['Today', H.readLine(s, ['calendar'])], ['Needs you', H.readLine(s, ['initiatives', 'my-work', 'd:brief'])]].filter((x) => x[1]);
23
- return L.map(([k, v]) => `<p class="ev-small ev-mut ev-reads" data-reads="${esc(k)}"><b>${esc(k)}:</b> ${esc(v)}</p>`).join('');
24
- }).catch(() => '');
25
- }
26
- async function draw() {
27
- const b = M.body; if (!b || !b.isConnected) return;
28
- { const c = vwCurrent(); if (!c || c.id !== 'sources') return; } // the Viewer moved on to another item: a late read draws nothing
29
- const s = M.r;
30
- const head = `<div><h2 class="ev-h2">Sources</h2><p class="ev-sub">What PMOS reads, and how old each reading is. All real data${M.at ? ', as of ' + hm(M.at) : ''}.</p></div>`;
31
- if (!s) { b.innerHTML = head + skelRows(4); return; }
32
- if (!s.ok) { b.innerHTML = head + cantRead({ what: 'The sources', why: s.error || '', sources: false }); return; }
33
- const st = staleOf(s.sources);
34
- const warn = st ? `<div class="ev-warn ev-line" id="srcWarn"><i class="ev-dot risk" aria-hidden="true"></i><p class="ev-grow"><b>${esc(st.state === 'stale' ? st.name + ' was last read ' + st.ago + '.' : st.text + '.')}</b> ${esc(partsOf(st.id))} may be out of date.</p><button type="button" class="ev-btn sm" data-ev-read="${esc(st.id)}"${M.busy ? ' disabled' : ''}>${svg(ICON.refresh, 16)}Read again</button></div>` : '';
35
- // the background line (harness-health): quiet when all is well, a box when something needs a look
36
- const hl = s.health && s.health.level;
37
- const health = !s.health ? '' : hl === 'warn' || hl === 'bad'
38
- ? `<div class="ev-box ev-small ev-line" id="srcHealth" data-level="${esc(hl)}" role="status"><i class="ev-dot risk" aria-hidden="true"></i><p class="ev-grow"><b>${esc(s.health.line)}</b>${(s.health.issues || []).slice(1, 4).map((i) => `<br>${esc(i.text)}`).join('')}</p></div>`
39
- : `<p class="ev-small ev-mut ev-line" id="srcHealth" data-level="ok"><i class="ev-dot ok" aria-hidden="true"></i>${esc(s.health.line || '')}</p>`;
40
- const rows = sourceRows(s.sources).map((x) => {
41
- const name = x.id === 'repository' ? (s.ws || 'This product') + ' · main' : x.sub;
42
- const act = x.act === 'read' ? `<button type="button" class="ev-btn sm soft" data-ev-read="${esc(x.id)}" aria-label="Read ${esc(x.name)} again"${M.busy ? ' disabled' : ''}>Read again</button>`
43
- : x.act === 'connect' ? `<button type="button" class="ev-btn sm" data-ev-connect="${esc(x.id)}">Connect</button>` : '';
44
- return `<div class="ev-trow" data-src="${esc(x.id)}"><span class="ev-tile" aria-hidden="true">${svg(TILE[x.id] || ICON.sources, 16)}</span><div class="ev-tx"><b>${esc(x.name)}</b><p class="ev-small ev-mut">${esc(name)}</p>${M.note[x.id] ? `<p class="ev-small" role="status">${esc(M.note[x.id])}</p>` : ''}</div><span class="ev-w-140 ev-small ${x.risk ? 'ev-late' : 'ev-mut'}">${esc(x.when)}</span><span class="ev-w-96">${act}</span></div>`;
45
- }).join('');
46
- const all = s.all && !s.all.done;
47
- b.innerHTML = head + warn + health
48
- + `<div><div class="ev-th"><span class="ev-grow">Source</span><span class="ev-w-140">Last read</span><span class="ev-w-96"></span></div>${rows}</div>`
49
- + `<div class="ev-acts"><button type="button" class="ev-btn sm" data-ev-all${M.busy || all ? ' disabled' : ''}>${svg(ICON.refresh, 16)}${all ? 'Reading every source' : 'Read all again'}</button></div>`
50
- + '<div id="srcReads"></div>'
51
- + '<p class="ev-small ev-mut">PMOS reads these sources and never posts to them. To send anything, you press Send.</p>';
52
- const reads = await readsHtml(s);
53
- const box = b.querySelector('#srcReads'); if (box) box.innerHTML = reads;
54
- }
55
- async function read() {
56
- M.r = await pmGet('/api/sources' + wsQ());
57
- if (!M.r || M.r.ok === false) M.r = { ok: false, error: (M.r && M.r.error) || 'the server did not answer' };
58
- M.at = new Date();
59
- draw();
60
- if (M.r.ok) window.dispatchEvent(new CustomEvent('pm:sources', { detail: M.r }));
61
- }
62
- export function openSources() {
63
- M.r = null; M.note = {};
64
- M.body = vwOpen({ id: 'sources', kind: 'What PMOS reads', title: 'Sources', icon: 'source', render: (b) => { b.classList.add('ev-card-b', 'ev-src'); M.body = b; draw(); } });
65
- M.body.onclick = async (e) => {
66
- const t = e.target.closest('button'); if (!t || M.busy) return;
67
- if ('evRetry' in t.dataset) { M.r = null; draw(); read(); return; }
68
- if (t.dataset.evConnect) { import('./cozy-settings.js').then((S) => S.openSettings('connectors')); return; }
69
- const ws = (M.r && M.r.ws) || wsParam() || '';
70
- if ('evAll' in t.dataset) {
71
- M.busy = 'all'; draw();
72
- const r = await pmPost('/api/sources/refresh-all', { ws });
73
- M.busy = '';
74
- toast(r && r.ok ? (r.joined ? 'Every source is already being read.' : 'Reading every source, then Home\'s list.') : 'Read all again did not start: ' + ((r && r.error) || 'the server did not answer') + '.');
75
- await read(); setTimeout(read, 4000); return;
76
- }
77
- if (t.dataset.evRead) {
78
- const id = t.dataset.evRead;
79
- M.busy = id; draw();
80
- const r = await pmPost('/api/sources/refresh', { ws, source: id });
81
- M.busy = '';
82
- M.note[id] = r && r.ok ? (r.started === 'session' ? 'An agent session started to read it, with your own connection.' : 'Reading it again on this machine.') : 'It did not start: ' + ((r && r.error) || 'the server did not answer') + '.';
83
- toast(r && r.ok ? 'Reading again.' : M.note[id]);
84
- await read(); setTimeout(read, 4000);
85
- }
86
- };
87
- read();
88
- return M.body;
89
- }
1
+ /* pm/cozy-sources.js — Sources (initiative premium-uncovered-features, E3; canvas EvSources) is no longer a card of its own: since feedback
2
+ * batch 16 item 5 (canvas FmA3Settings) each source's last read, the amber box and Read again live in Settings › Connectors
3
+ * (pm/cozy-settings.js). This module stays so the old openers (premium-shell.js, home-around.js) still land in the right place.
4
+ * openSources() → Settings, open at Connectors */
5
+ export function openSources() { return import('./cozy-settings.js').then((M) => M.openSettings('connectors')); }
@@ -211,7 +211,7 @@ body.cz-home .hm-r.lr .hm-tile { width: 32px; height: 32px; }
211
211
  body.cz-home.hm-plist .hm-lsc { margin: 0; padding: 0; overflow: visible; }
212
212
  body.cz-home.hm-plist .hm-chat, body.cz-home.hm-plist:not(.hm-vw-open) .hm-vw { display: none; }
213
213
  body.cz-home.hm-plist .cz-fabw { bottom: 24px; }
214
- body.cz-home .hm-needs, body.cz-home #hmMoreP { display: none; }
214
+ body.cz-home .hm-needs { display: none; }
215
215
  body.cz-home .hm-top .hm-back { display: grid; }
216
216
  body.cz-home .hm-top { background: var(--cz-card); padding: 8px 12px 4px 8px; }
217
217
  body.cz-home:not(.hm-plist) { background: var(--cz-card); }
@@ -245,6 +245,7 @@ body.cz-home .hm-lsc { margin: 0 -12px; padding: 0 12px 4px; }
245
245
  .hv-hi { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 0 0 6px; border: 0; background: none; color: var(--cz-ink); cursor: pointer; text-align: left; font-family: var(--cz-sans); border-radius: 14px; }
246
246
  .hv-hi b { font-size: var(--fs-5); font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
247
247
  .hv-hi svg { color: var(--cz-ink3); flex: none; width: 16px; height: 16px; }
248
+ .hv-hi .hv-nd { width: 8px; height: 8px; border-radius: 4px; background: var(--cz-blue); flex: none; display: block; }
248
249
  .hv-hi[aria-expanded="true"] svg { transform: rotate(180deg); }
249
250
  .hv-pk { height: 32px; padding: 0 10px 0 12px; border-radius: 999px; border: 0; background: var(--cz-card); font-family: var(--cz-sans); font-size: var(--fs-2); font-weight: 700; color: var(--cz-ink2); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; flex: none; max-width: 140px; }
250
251
  .hv-pk svg { width: 13px; height: 13px; flex: none; }
@@ -489,6 +490,23 @@ body.cz-home .hm-hd.hv-bar { padding: 0; }
489
490
  .yd-tick { width: 22px; height: 22px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: var(--cz-bluebg); color: var(--cz-blue); }
490
491
  .yd-fin .hm-rm { cursor: default; }
491
492
  .yd .hv-r.two .hm-rt em { white-space: normal; }
493
+ /* New for you, a fold of Your day (feedback batch 16 item 5b, FmA2Day): 3 newest rows, "N more", ✓✓ in the fold's header marks all seen */
494
+ .yd-news { display: flex; flex-direction: column; }
495
+ .yd-nw { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 10px 6px; border: 0; background: none; border-radius: 14px; text-align: left; cursor: pointer; font: inherit; color: inherit; }
496
+ .yd-nw:hover { background: var(--cz-well); }
497
+ .yd-nw:focus-visible, .yd-more:focus-visible, .yd-all:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
498
+ .yd-nd { width: 8px; height: 8px; border-radius: 4px; background: var(--cz-blue); flex: none; margin-top: 12px; }
499
+ .yd-av { width: 32px; height: 32px; border-radius: 16px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--cz-well); color: var(--cz-ink2); font-size: var(--fs-1); font-weight: 800; }
500
+ .yd-av.b { background: var(--cz-bluebg); color: var(--cz-blueink); }
501
+ .yd-nw .yd-mt b { font-weight: 600; }
502
+ .yd-more { align-self: flex-start; border: 0; background: none; padding: 6px 6px 8px 58px; min-height: 36px; font: inherit; font-size: var(--fs-3); font-weight: 700; color: var(--cz-blueink); cursor: pointer; }
503
+ .yd-all { width: 40px; height: 40px; border-radius: 20px; border: 0; background: none; color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
504
+ .yd-all:hover { background: var(--cz-well); }
505
+ .yd-all:disabled { opacity: .5; cursor: default; }
506
+ /* Tomorrow, a fold of Your day after 17:00 (FmA5Evening, was More › End of the day): time, title */
507
+ .yd-tmr { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 6px; font-size: var(--fs-4); color: var(--cz-ink); }
508
+ .yd-tt { width: 48px; flex: none; font-size: var(--fs-3); font-weight: 700; color: var(--cz-ink3); font-variant-numeric: tabular-nums; }
509
+ .yd-tn { flex: 1; min-width: 0; }
492
510
  /* the moment card inside Your day: the morning's meetings (time, title) and a real thank-you in the evening recap (YdE1Ready, YdE3Evening) */
493
511
  .hm-phc .phrow { display: flex; align-items: center; gap: 10px; min-height: 40px; margin: 0; font-size: var(--fs-4); color: var(--cz-ink); }
494
512
  .hm-phc .phrow b { width: 48px; flex: none; font-size: var(--fs-3); font-weight: 700; color: var(--cz-ink3); }
@@ -80,3 +80,24 @@
80
80
  .hi-pop .wfi svg { width: 70%; height: 70%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
81
81
  /* a small form in the Viewer (the Board's Add a stakeholder) */
82
82
  .hi-form { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 24px; font-size: var(--fs-3); color: var(--cz-ink); }
83
+ /* the stage chip's picker (pm/ini-more.js stagePick; batch 16 item 5c, FmI2Stage): every stage, the current one marked, the switch, then the endings */
84
+ .hi-sp.on { background: var(--cz-bluebg); font-weight: 800; }
85
+ .hi-spn { flex: none; width: 22px; height: 22px; border-radius: 7px; background: var(--cz-well); font-style: normal; font-size: var(--fs-1); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; color: var(--cz-ink2); }
86
+ .hi-spn.ms { transform: rotate(45deg) scale(.7); border-radius: 3px; background: var(--cz-ink3); }
87
+ .hi-sp.on .hi-spn { background: var(--cz-blue); color: var(--cz-card); }
88
+ .hi-spm span { color: var(--cz-ink3); font-size: var(--fs-2); }
89
+ .hi-spw { cursor: default; }
90
+ .hi-spw:hover { background: none; }
91
+ .hi-spw span { flex: 1; }
92
+ .hi-spw .hi-sw { position: relative; flex: none; width: 32px; height: 20px; border-radius: 999px; background: var(--cz-c-d9dce1); border: 0; padding: 0; cursor: pointer; }
93
+ .hi-spw .hi-sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--cz-card); transition: left .15s; }
94
+ .hi-spw .hi-sw[aria-checked="true"] { background: var(--cz-blue); }
95
+ .hi-spw .hi-sw[aria-checked="true"]::after { left: 15px; }
96
+ :root[data-theme="dark"] .hi-spw .hi-sw { background: var(--cz-c-4a4f58); }
97
+ :root[data-theme="dark"] .hi-spw .hi-sw[aria-checked="true"] { background: var(--cz-blue); }
98
+ @media (max-width: 760px) {
99
+ .hi-pop .hi-mi { min-height: 44px; }
100
+ .hi-spw .hi-sw { width: 44px; height: 28px; }
101
+ .hi-spw .hi-sw::after { top: 4px; left: 4px; width: 20px; height: 20px; }
102
+ .hi-spw .hi-sw[aria-checked="true"]::after { left: 20px; }
103
+ }
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * ensureCss() adds hi-pop.css once, before home-ini.css, so Home's phone rules still win
5
5
  * openPop(anchor, kind, html, onClick, o?) a dialog (or o.menu: a menu) under the button that opened it; a sheet on a phone.
6
- * o: { menu, wide, role, label, focus, sheetFocus }. → the popover element
6
+ * o: { menu, sheet (a menu that is still a sheet on a phone), wide, role, label, focus, sheetFocus }. → the popover element
7
7
  * closePop() · popEl() the open popover, or null
8
- * undoToast(text, undo) the dark toast with Undo, for 9 seconds */
8
+ * undoToast(text, undo, ms?) the dark toast with Undo, for 9 seconds (ms: another time, the initiative's Delete's 8) */
9
9
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
10
10
  const PHONE = 760;
11
11
  const isPhone = () => innerWidth <= PHONE;
@@ -27,7 +27,7 @@ export function openPop(anchor, kind, html, onClick, o = {}) {
27
27
  ensureCss();
28
28
  closePop();
29
29
  const el = document.createElement('div');
30
- const sheet = isPhone() && !o.menu;
30
+ const sheet = isPhone() && (!o.menu || o.sheet);
31
31
  el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '') + (o.wide ? ' wide' : '');
32
32
  el.setAttribute('role', o.role || (o.menu ? 'menu' : 'dialog')); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
33
33
  el.innerHTML = (sheet ? '<div class="hi-grab" aria-hidden="true"></div>' : '') + html;
@@ -50,7 +50,7 @@ export function openPop(anchor, kind, html, onClick, o = {}) {
50
50
  const f = el.querySelector((sheet && o.sheetFocus) || o.focus || 'input, textarea, button:not([disabled])'); if (f) setTimeout(() => f.focus(), 0);
51
51
  return el;
52
52
  }
53
- export function undoToast(text, undo) {
53
+ export function undoToast(text, undo, ms = 9000) {
54
54
  ensureCss();
55
55
  let el = document.getElementById('hiToast');
56
56
  if (!el) { el = document.createElement('div'); el.id = 'hiToast'; el.className = 'hi-toast'; el.setAttribute('role', 'status'); el.setAttribute('aria-live', 'polite'); document.body.appendChild(el); }
@@ -58,7 +58,7 @@ export function undoToast(text, undo) {
58
58
  el.hidden = false; el.classList.add('on');
59
59
  el.querySelector('[data-hi-undo]').onclick = () => { hide(); undo(); };
60
60
  const hide = () => { el.classList.remove('on'); el.hidden = true; };
61
- clearTimeout(P.toastT); P.toastT = setTimeout(hide, 9000);
61
+ clearTimeout(P.toastT); P.toastT = setTimeout(hide, ms);
62
62
  }
63
63
  // Escape closes the popover first: on window in the capture phase, so the page's own Escape (the phone's list sheet, the Viewer) waits for the next press
64
64
  if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && P.pop) { e.stopPropagation(); e.preventDefault(); closePop(); } }, true);
@@ -37,7 +37,7 @@ import { mountFirst } from './premium-first.js';
37
37
  import * as L from './home-list.js';
38
38
  import * as TD from './home-today.js';
39
39
  import * as YD from './home-day.js';
40
- import * as AD from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2) // Your day in the Viewer (XvAPhDay)
40
+ import * as AD from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2)
41
41
  import { canDictate, dictate } from './home-dictate.js';
42
42
  import { mountIni, iniList, iniOverview, iniPage, iniAddTask } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
43
43
  import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
@@ -158,7 +158,9 @@ async function getRetry(path, tries = 20) {
158
158
  }
159
159
  return { ok: false, error: 'still reading' };
160
160
  }
161
+ let pickGen = 0; // bumped by every saved pick, so a read that started before the save does not put the old pick back
161
162
  async function load() {
163
+ const gen = pickGen;
162
164
  const [brief, board, ses, desk, today, sch, work, day, rev, progs, , pick] = await Promise.all([
163
165
  getRetry('/api/briefing-premium' + wsQ()), getRetry('/api/board-premium' + wsQ() + boardQ(WS ? '&' : '?')), pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ()),
164
166
  pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()), pmGet('/api/my-work-premium' + wsQ()), pmGet('/api/phone-day'), pmGet('/api/home-review' + wsQ()),
@@ -176,7 +178,7 @@ async function load() {
176
178
  D.review = rev && rev.ok ? rev : null; // this week's review (GET /api/home-review)
177
179
  D.programs = progs && progs.ok ? progs.programs : []; // programs above initiatives, across products (GET /api/programs)
178
180
  D.order = SO.layout(); // the PM's sort and own order, shared with the Board (batch 14 item 8)
179
- D.pick = pick || D.pick || null; // the one product pick (the chip): which products are on Home and read
181
+ D.pick = (gen === pickGen && pick) || D.pick || null; // the one product pick (the chip): which products are on Home and read
180
182
  if (D.pick && WS) D.pick = { ...D.pick, products: D.pick.products.map((p) => ({ ...p, on: p.ws === WS })) }; // ?ws= is a one-off view of that product
181
183
  D.now = Date.now();
182
184
  D.err = [brief, board].filter((x) => !x || !x.ok).map((x) => (x && x.error) || 'the server did not answer');
@@ -292,33 +294,75 @@ function homeListHtml() {
292
294
  const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1);
293
295
  return TD.listHtml(M, todayModel(), {
294
296
  sel: S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null), selHead: S.head, ses: S.ses, pOpen, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
295
- pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
297
+ pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, news: S.news && S.news.ok ? S.news.count : 0, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
296
298
  });
297
299
  }
298
- /** Your day (XvAPhDay, was the HvAOpen sheet): "Good morning" opens it in the Viewer on a phone and a desktop alike (batch 16, Wawan: the same
299
- * press must lead to the same place); the calendar is under ⋯. A phone also draws the moment card (TfPhone) as its Now section. */
300
+ /** Your day (XvAPhDay): "Good morning" opens it in the Viewer on a phone and a desktop alike (batch 16, Wawan: the same press must lead to
301
+ * the same place). The calendar is an icon in its header (batch 16 item 5, FmA2Day). A phone also draws the moment card (TfPhone) as its
302
+ * Now section. New for you is a fold of it (FmA2Day): S.news is the latest GET /api/news-for-you answer, read by the place menu every two
303
+ * minutes (the event 'cz:news-for-you') and again when Your day opens; a row opens the item in the Viewer, "N more" the whole list, ✓✓
304
+ * marks all seen. An item leaves once it is opened or marked seen. */
300
305
  function dayHtml() { return ''; }
306
+ function dayParts() {
307
+ const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW(), { delightOk: !!S.joyOk, news: S.news });
308
+ return { Y, P: YD.dayParts(Y, { moment: !!(isPhone() && PHC), now: NOW(), first: !!S.first }) };
309
+ }
310
+ function drawDayBody(body, P) {
311
+ const ph = isPhone() && PHC;
312
+ YD.drawDay(body, P, VW, ph ? (el) => { el.append(PHC.el); PHC.read(true); } : null);
313
+ }
301
314
  function day(on) {
302
315
  S.day = !!on;
303
316
  if (!on) { const c = VW.current(); if (c && c.id === 'day') VW.close(); return; }
304
317
  if (!S.M) return;
305
- const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW(), { delightOk: delightOk() && AD.mayCelebrate(NOW()) });
318
+ // the week's one celebration and the morning scene are read once per open, so a redraw (a new read of New for you) keeps the same day
319
+ S.joyOk = delightOk() && AD.mayCelebrate(NOW()); S.first = YD.firstOpenToday('day', NOW());
320
+ const { Y, P } = dayParts();
321
+ S.Y = Y;
306
322
  if (Y.mood === 'delighted') { try { localStorage.setItem(DELIGHT_KEY, new Date(NOW()).toDateString()); } catch { /* the face still shows */ } AD.celebrated(NOW()); }
307
- const ph = isPhone() && PHC;
308
- const P = YD.dayParts(Y, { moment: !!ph, now: NOW(), first: YD.firstOpenToday('day', NOW()) });
309
- VW.open({ id: 'day', kind: 'Your day', title: 'Your day', icon: YD.DAY_ICON, more: [{ label: 'Open the calendar', on: () => openCalendar() }],
323
+ VW.open({ id: 'day', kind: 'Your day', title: 'Your day', icon: YD.DAY_ICON,
324
+ presses: [{ act: 'cal', label: 'Open the calendar', icon: 'cal' }], onPress: (act) => { if (act === 'cal') openCalendar(); },
310
325
  onClose: () => { S.day = false; },
311
326
  render: (body) => {
312
- YD.drawDay(body, P, VW, ph ? (el) => { el.append(PHC.el); PHC.read(true); } : null);
327
+ drawDayBody(body, P);
313
328
  body.onclick = (e) => { // the rows are the list's own rows: the same presses open them
314
329
  const b = e.target.closest('button'); if (!b) return;
315
330
  if (b.dataset.hmSel) { select(b.dataset.hmSel); return; }
316
331
  if (b.dataset.yd === 'sel') { const c = b.closest('.yd-call'); if (c) select(c.dataset.id); return; }
317
332
  if (b.dataset.yd === 'retry' || b.dataset.yd === 'prep') { dayAct(b); return; }
333
+ if (b.dataset.yd === 'news' || b.dataset.yd === 'news-all') { VW.drill(); MORE.openInbox(searchGo, b.dataset.yd === 'news' ? b.dataset.id : ''); return; }
334
+ if (b.dataset.yd === 'seen') { daySeen(b); return; }
318
335
  if ('hmReview' in b.dataset) { openReviewVw(); return; }
319
- if ('hdMeet' in b.dataset && Y.next) openMeeting(Y.next.meeting);
336
+ if ('hdMeet' in b.dataset && S.Y && S.Y.next) openMeeting(S.Y.next.meeting);
320
337
  };
321
338
  } });
339
+ readNews();
340
+ }
341
+ /** Your day drawn again in place (a new read of New for you, a seen item), when it is the item shown. */
342
+ function redrawDay() {
343
+ const c = VW.current(), body = VW.body(); if (!S.day || !c || c.id !== 'day' || !body || !S.M) return;
344
+ const { Y, P } = dayParts(); S.Y = Y; drawDayBody(body, P);
345
+ }
346
+ async function readNews() {
347
+ const r = await pmGet('/api/news-for-you' + wsQ()).catch(() => null);
348
+ if (!r || !r.ok) return;
349
+ document.dispatchEvent(new CustomEvent('cz:news', { detail: { count: r.count } })); // the place menu's dots follow
350
+ newsIn(r);
351
+ }
352
+ function newsIn(r) {
353
+ const was = S.news ? S.news.count : -1; S.news = r;
354
+ if (r.count !== was) { drawList(); redrawDay(); }
355
+ }
356
+ document.addEventListener('cz:news-for-you', (e) => { if (e.detail && e.detail.ok) newsIn(e.detail); });
357
+ /** ✓✓ in the New for you fold: every item is marked seen (POST /api/news-for-you/seen), so the fold goes. */
358
+ async function daySeen(b) {
359
+ const ids = YD.newsOf(S.news).map((x) => x.id); if (!ids.length || b.disabled) return;
360
+ b.disabled = true;
361
+ let ok = true;
362
+ for (let i = 0; i < ids.length; i += 300) { const r = await pmPost('/api/news-for-you/seen', { ids: ids.slice(i, i + 300) }).catch(() => null); if (!r || !r.ok) ok = false; }
363
+ if (!ok) { b.disabled = false; toast('It was not marked seen. The server did not answer.'); return; }
364
+ toast(ids.length === 1 ? 'Marked seen.' : 'Marked all ' + ids.length + ' seen.');
365
+ await readNews();
322
366
  }
323
367
  /* Delighted shows at most once a week (canvas note ydEBuild): the day it last showed, kept in this browser. Another day of this week says no. */
324
368
  const DELIGHT_KEY = 'pmos-yd-delight';
@@ -341,7 +385,7 @@ async function dayAct(b) {
341
385
  toast(prep ? 'I’m on it. Your day fills in as I finish.' : 'Running it again.');
342
386
  const pd = await pmGet('/api/phone-day').catch(() => null);
343
387
  if (pd && pd.ok) S.D.phoneDay = pd;
344
- if (S.day) { const c = VW.current(); if (c && c.id === 'day') day(true); }
388
+ redrawDay();
345
389
  }
346
390
  /* the list's filter (HvACDesk): Today, Kept or Done, behind the icon in the list's top bar */
347
391
  function filterMenu(b) {
@@ -773,15 +817,15 @@ async function turnProgram(id) {
773
817
  toast('Now a program · ' + iniTitle(id) + '.');
774
818
  await load(); goProgram(res.program.id);
775
819
  }
776
- /** The page's ⋯ items for an initiative in a program (pm/prog-move.js): Move out of it, Move to another program. openList is home-ini.js's menu. */
820
+ /** The page's ⋯ "Program" entry (pm/prog-move.js programItem, batch 16 item 5c): one picker to move, leave, join or make a program. openList is home-ini.js's menu. */
777
821
  function moveItems(id, openList) {
778
822
  const row = iniRowOf(id) || {}, o = otherIni(id), B = S.D.board || {};
779
823
  const other = o ? ((S.D.others || []).find((x) => x && x.ws === o.ws) || {}).model || {} : null;
780
824
  const product = other ? (o.row && o.row.product) || (other.board || {}).product || (other.board || {}).name || '' : H.productName(S.D);
781
- return PM.moveItems({ programs: () => S.D.programs || [], ws: row.ws || (o && o.ws) || (B.board || {}).ws || '', id, product, pmPost, phone: isPhone, openList,
825
+ return [PM.programItem({ programs: () => S.D.programs || [], ws: row.ws || (o && o.ws) || (B.board || {}).ws || '', id, product, pmPost, phone: isPhone, openList, turn: () => turnProgram(id),
782
826
  say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)),
783
827
  stateOf: (p) => (((S.M && S.M.groups) || []).find((g) => g.kind === 'program' && g.program.id === p.id) || {}).st || null,
784
- reload: async () => { await load(); if (S.ini === id && VW.isOpen()) iniPage(); } });
828
+ reload: async () => { await load(); if (S.ini === id && VW.isOpen()) iniPage(); } })].filter(Boolean);
785
829
  }
786
830
  /** Split or merge (pm/split-merge.js; canvas XsmA1Menu, XsmA1Suggest): the context of one initiative on Home. Only this board's rows: a
787
831
  * merge stays on one board. After the write Home reads again and opens the one the PM lands on. openList is home-ini.js's menu. */
@@ -1011,7 +1055,7 @@ function pickProduct(chip) {
1011
1055
  PP.openPicker(chip, { P: S.D.pick, label: 'Products on Home', tones: pickTones(), lines: pickLine, onApply: async (on) => { const r = await PP.savePick(on); if (!r.ok) toast(r.error); } });
1012
1056
  }
1013
1057
  // a saved pick (from this chip or Settings): Home shows and reads the ticked products
1014
- addEventListener('pp:changed', (e) => { if (WS) { location.assign('/premium.html'); return; } S.D.pick = e.detail; drawList(); toast('Saved. Home, Board and Intelligence show the products you picked.'); load(); });
1058
+ addEventListener('pp:changed', (e) => { if (WS) { location.assign('/premium.html'); return; } pickGen++; S.D.pick = e.detail; drawList(); toast('Saved. Home, Board and Intelligence show the products you picked.'); load(); });
1015
1059
 
1016
1060
  /* ── the Viewer: needs rows, the weekly update, the overview, files, people, routines ── */
1017
1061
  let lastViewer = null;
@@ -1476,13 +1520,6 @@ menuEl.onclick = (e) => { // delegated: every item is a <button role=menuitem>
1476
1520
  };
1477
1521
  document.addEventListener('click', (e) => { if (!menuEl.hidden && !menuEl.contains(e.target) && !(menu.anchor && menu.anchor.contains(e.target))) closeMenu(); }, true);
1478
1522
  document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menuEl.hidden) { e.stopPropagation(); closeMenu(); } else if (e.key === 'Escape' && S.sheet) sheet(false); }, true);
1479
- function moreMenu(anchor) {
1480
- const go = {
1481
- around: () => MORE.openAround(), inbox: () => MORE.openInbox(searchGo), eod: () => MORE.openEndOfDay(), cal: () => openCalendar(),
1482
- rec: () => MORE.openRecorder(), search: () => MORE.openSearch(searchGo), sources: () => MORE.openSources(), settings: () => MORE.openSettings(),
1483
- };
1484
- menu(anchor, MORE.moreItems.map(([k, l]) => ({ label: l, go: go[k] })), 'Waiting for design');
1485
- }
1486
1523
  function searchGo(d) {
1487
1524
  if (d.ini) goIni(d.ini);
1488
1525
  else if (d.doc) openFile({ path: d.doc, name: d.doc.split('/').pop() });
@@ -1504,7 +1541,6 @@ addEventListener('hm:review', (e) => { e.preventDefault(); openReviewVw(); });
1504
1541
  // a phone: the day's moment card opens on the greeting's press, and on this event from any other place that asks for the day
1505
1542
  addEventListener('hm:day', () => day(true));
1506
1543
  $('#hmBack').onclick = () => { S.phoneChat = false; S.sel = null; drawList(); syncUrl(); const f = $('#hmList .hm-rm'); if (f) f.focus(); };
1507
- $('#hmMoreP').onclick = (e) => moreMenu(e.currentTarget);
1508
1544
  $('#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
1509
1545
 
1510
1546
  /* ── presses on the list ── */
@@ -1638,6 +1674,7 @@ function cta() {
1638
1674
  mountIni({ S, VW, pmGet, pmPost, toast, rowOf: (id) => iniRowOf(id), renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
1639
1675
  // the initiative's page (HbCDesk): its card, its header and its ⋯
1640
1676
  openBoardTask: (t) => openBoardTask(t),
1677
+ goHome: () => { VW.close(); goHome(); }, // after the initiative's Delete (batch 16 item 5d): it is gone, so Home shows the list again
1641
1678
  cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), askIn: (id, q) => askIn(id, q), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), smItems: (id, openList) => smItems(id, openList), smPress: (id, act) => SM.press(smCtx(id), act), goIni: (id) => goIni(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1642
1679
  foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1643
1680
  /* The program panel in Home's Viewer (HbCProg): Home's board model and programs; an initiative of it opens here, with ← back to the program.
@@ -1648,7 +1685,7 @@ PO.mount({ programs: () => S.D.programs || [], stateOf: (p) => (((S.M && S.M.gro
1648
1685
  saved: (p) => { const L2 = S.D.programs || [], i = L2.findIndex((x) => x.id === p.id); if (i >= 0) L2[i] = { ...L2[i], ...p }; drawList(); },
1649
1686
  say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)), openIni: (id) => goIni(id) });
1650
1687
  SO.mount({ redraw: () => { S.D.order = SO.layout(); drawList(); }, say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) });
1651
- mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings(), here: () => { if (VW.isOpen()) VW.close(); goHome(); } });
1688
+ mountNav('home', document, { here: () => { if (VW.isOpen()) VW.close(); goHome(); } });
1652
1689
  // the Live pill (batch 6 item 2): on Home a row opens in place, the session's chat (with its Viewer page) or the meeting; the open one is tinted
1653
1690
  mountLivePill(document, {
1654
1691
  open: () => (S.cur && S.cur.ses) || null,
@@ -4,10 +4,17 @@
4
4
  * YdE2AllClear, YdE3Evening, YdE6BigDay, YdE7Rough): the opening card is Claude's small mood face and one first-person line, with chips for
5
5
  * the work Claude really did; Your move holds only the calls that need the PM; the rest folds:
6
6
  * Your move the calls only the PM can make (homeList's move rows with call: true), open by default
7
+ * New for you (feedback batch 16 item 5b, canvas FmA2Day) the FYI items of GET /api/news-for-you: mentions, tasks given to the PM and work
8
+ * finished while away. The 3 newest, then "N more" (the whole list in the Viewer, cozy-news.js); ✓✓ in the fold's header
9
+ * marks all seen; today's digests of the morning brief are one row. No item and no digest, no fold. It replaces the New
10
+ * for you page of the place menu.
7
11
  * Drafted for you the drafts of today's morning prep run (GET /api/phone-day finished) and the weekly update
8
12
  * Can wait every other row that was "Your move" (tasks, brief items, Jira)
9
13
  * Now the phone's moment card (home-phone-card.js), open by default
14
+ * Tomorrow after 17:00 only (canvas FmA5Evening, was More › End of the day): tomorrow's meetings (GET /api/phone-day tomorrow);
15
+ * not on a phone, whose Now card shows tomorrow then
10
16
  * This week the Weekly review
17
+ * The calendar is an icon in Your day's header (home-app.js), no longer a ⋯ with one entry.
11
18
  * Every claim comes from what PMOS holds: a meeting is "prepped" only when it has the agent's prep note, "drafted" only from today's run,
12
19
  * a thank-you only from a real mention, a miss only from a failed task. No data, no line (zero is silence). The mood is never happier than
13
20
  * the data: concerned when something failed or is blocked, delighted at most once a week, calm on a packed or ordinary day.
@@ -20,6 +27,7 @@
20
27
 
21
28
  import { todayOf, hm } from './home-data.js';
22
29
  import { adler, adlerScene, asleep, firstOpenToday } from './cozy-adler.js'; // Adler, Claude's face (batch 16 item 2): AdB1-3, AdP1, AdP4
30
+ import { initials, ago } from './cozy-evmodel.js';
23
31
 
24
32
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
25
33
  const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
@@ -51,9 +59,22 @@ export function thanksOf(D, now) {
51
59
  return m ? { quote: clip(m.text, 160), who: m.who || '', where: m.source ? m.source.charAt(0).toUpperCase() + m.source.slice(1) : '', at: m.at ? hm(m.at) : '' } : null;
52
60
  }
53
61
 
62
+ /** New for you, newest first: the items of one GET /api/news-for-you answer (its groups), or [] when it did not answer. */
63
+ export function newsOf(r) {
64
+ if (!r || !r.ok || !Array.isArray(r.groups)) return [];
65
+ return r.groups.flatMap((g) => (g && Array.isArray(g.items) ? g.items : [])).filter((x) => x && x.id).sort((a, b) => (b.at || 0) - (a.at || 0));
66
+ }
67
+ /** Tomorrow's meetings, after 17:00 only (FmA5Evening): { label, meetings } or null when it is earlier or tomorrow has none (zero is silence). */
68
+ export function tomorrowOf(D, now) {
69
+ const T = D && D.phoneDay && D.phoneDay.tomorrow;
70
+ if (new Date(now).getHours() < 17 || !T || !Array.isArray(T.meetings)) return null;
71
+ const L = T.meetings.filter((m) => m && m.start && !Number.isNaN(Date.parse(m.start))).sort((x, y) => Date.parse(x.start) - Date.parse(y.start));
72
+ return L.length ? { label: T.label || 'Tomorrow', meetings: L } : null;
73
+ }
74
+
54
75
  /** Your day's words. M: homeList's model (move); D: Home's data (today's meetings, phoneDay, the brief page's me and mentions);
55
- * R: reviewModel. o: { delightOk: false when the delighted face showed on another day this week }.
56
- * → { mood, line, sub, chips, misses, offer, calls, drafts, wait, done, next, week, thanks } */
76
+ * R: reviewModel. o: { delightOk: false when the delighted face showed on another day this week, news: the GET /api/news-for-you answer }.
77
+ * → { mood, line, sub, chips, misses, offer, calls, drafts, wait, done, next, week, thanks, news, tomorrow } */
57
78
  export function dayModel(M, D, R, now = Date.now(), o = {}) {
58
79
  D = D || {};
59
80
  const move = (M && M.move) || [];
@@ -110,6 +131,7 @@ export function dayModel(M, D, R, now = Date.now(), o = {}) {
110
131
  if (!run && h < 17) offer = { kind: 'prep', text: 'I haven’t prepared today yet.', sub: 'Shall I prep your meetings and draft what I can?' };
111
132
  return {
112
133
  mood, face: run && run.working && mood === 'calm' ? 'working' : mood, line, sub, chips, misses, offer, calls, drafts, wait, done, thanks,
134
+ news: newsOf(o.news), digests: digestsOf(D), tomorrow: tomorrowOf(D, now),
113
135
  next: next ? { meeting: next, now: next.state === 'now', time: hm(next.start), title: next.title || 'A meeting' } : null,
114
136
  week: { sub: un || 'Weekly review' },
115
137
  };
@@ -158,6 +180,40 @@ export function nightHtml(Y) {
158
180
  return `<div class="yd-night">${adlerScene('night', 'resting')}<b>It’ll keep till morning.</b><em>${esc(sub)}</em><button type="button" class="yd-awake" data-yd="awake">Open anyway</button></div>`;
159
181
  }
160
182
 
183
+ /* one New for you item (FmA2Day): the blue dot, who, the words and where it came from; a press opens it in the Viewer (cozy-news.js) */
184
+ const SRC = { slack: 'Slack', jira: 'Jira', confluence: 'Confluence', mail: 'Mail' };
185
+ const MARK2 = 'M2 12.5l4.5 4.5L15 8M9 15l2 2L22 7';
186
+ export const NEWS_SHOWN = 3;
187
+ function newsRow(it, now) {
188
+ const who = it.kind === 'mention' ? it.who : it.kind === 'task' ? (it.from || 'Someone') : (it.product || 'Claude');
189
+ const when = it.at ? ago(new Date(it.at).toISOString(), now) : '';
190
+ const head = it.kind === 'mention' ? '“' + clip(it.text || it.title, 120) + '”' : it.title;
191
+ const sub = it.kind === 'mention' ? [it.who, [SRC[it.source] || it.source, it.where].filter(Boolean).join(' '), when].filter(Boolean).join(' · ')
192
+ : it.kind === 'task' ? ['Given to you' + (it.from ? ' by ' + it.from : ''), it.due ? 'due ' + it.due : '', it.initiative ? 'filed under ' + it.initiative : ''].filter(Boolean).join(' · ')
193
+ : ['Finished while you were away', it.target, when].filter(Boolean).join(' · ');
194
+ return `<button type="button" class="yd-nw" data-yd="news" data-id="${esc(it.id)}"><i class="yd-nd" aria-hidden="true"></i><span class="yd-av${it.kind === 'finished' ? ' b' : ''}" aria-hidden="true">${esc(initials(who))}</span><span class="yd-mt"><b>${esc(head)}</b><em>${esc(sub)}</em></span></button>`;
195
+ }
196
+ /** The New for you fold's parts: the 3 newest rows, "N more", the morning brief's digests as one row, and the ✓✓ that marks all seen.
197
+ * → a czSections row, or null when nothing is new and there is no digest (zero is silence). */
198
+ export function newsSection(items, now = Date.now(), digests = 0) {
199
+ items = items || [];
200
+ if (!items.length && !(digests > 0)) return null;
201
+ const more = items.length - NEWS_SHOWN;
202
+ const dig = digests > 0 ? `<button type="button" class="yd-more" data-yd="news-all">${digests === 1 ? 'Today’s digest' : 'Today’s ' + digests + ' digests'}</button>` : '';
203
+ return { id: 'news', title: 'New for you', count: items.length + (digests > 0 ? digests : 0), open: true,
204
+ tail: items.length ? `<button type="button" class="yd-all" data-yd="seen" aria-label="Mark all ${items.length} seen" title="Mark all seen">${svg(MARK2, 20, 1.9)}</button>` : '',
205
+ html: `<div class="yd-news">${items.slice(0, NEWS_SHOWN).map((x) => newsRow(x, now)).join('')}${more > 0 ? `<button type="button" class="yd-more" data-yd="news-all">${more} more</button>` : ''}${dig}</div>` };
206
+ }
207
+ /** The morning brief's digests of today (GET /api/briefing-premium model.today), which New for you's list shows. */
208
+ export function digestsOf(D) {
209
+ const T = D && D.brief && D.brief.today; if (!T) return 0;
210
+ return [].concat(T.earlier || [], T.ahead || []).filter((e) => e && e.kind === 'digest').length;
211
+ }
212
+ function tomorrowSection(T) {
213
+ return { id: 'tomorrow', title: 'Tomorrow', count: T.meetings.length, open: true,
214
+ html: `<div class="yd-tm">${T.meetings.map((m) => `<div class="yd-tmr"><span class="yd-tt">${esc(hm(m.start))}</span><span class="yd-tn">${esc(m.title || 'A meeting')}</span></div>`).join('')}</div>` };
215
+ }
216
+
161
217
  /** The shell's parts for Your day (czSections takes them). o: { moment: true on a phone with the moment card, now, first: the day's first
162
218
  * open (the morning scene) } → { open, sections, night } */
163
219
  export function dayParts(Y, o = {}) {
@@ -167,12 +223,14 @@ export function dayParts(Y, o = {}) {
167
223
  const big = Y.calls.length || Y.mood === 'concerned' ? null : Y.mood === 'delighted' ? 'win' : real ? 'tea' : null;
168
224
  if (Y.calls.length) sections.push({ id: 'move', title: 'Your move', count: Y.calls.length, open: true, html: Y.calls.map(callHtml).join('') });
169
225
  else if (big) sections.push({ id: 'move', title: 'Your move', open: true, html: bigHtml(big) });
226
+ { const nw = newsSection(Y.news || [], o.now, Y.digests || 0); if (nw) sections.push(nw); }
170
227
  if (Y.drafts.length) sections.push({ id: 'drafts', title: 'Drafted for you', count: Y.drafts.length, html: `<div class="hv-card">${Y.drafts.map(draftRow).join('')}</div>` });
171
228
  if (Y.wait.length) sections.push({ id: 'wait', title: 'Can wait', count: Y.wait.length, html: `<div class="hv-card hd-move">${Y.wait.map(waitRow).join('')}</div>` });
172
229
  if (o.moment) sections.push({ id: 'now', title: 'Now', open: true, html: '<div class="hd-now"></div>' }); // drawDay puts the moment card in
173
230
  else if (Y.next) {
174
231
  sections.push({ id: 'next', title: Y.next.now ? 'On now' : 'Next meeting', count: Y.next.now ? '' : Y.next.time, html: `<div class="hv-card"><div class="hm-r hv-r two"><button type="button" class="hm-rm" data-hd-meet><span class="hv-mk">${svg(CLOCK, 15)}</span><span class="hm-rt"><b>${esc(Y.next.title)}</b><em>${esc(Y.next.now ? 'On now' : Y.next.time)}</em></span><span class="hv-cv">${svg(CHEV, 16)}</span></button></div></div>` });
175
232
  }
233
+ if (Y.tomorrow && !o.moment) sections.push(tomorrowSection(Y.tomorrow)); // a phone's moment card already shows tomorrow at the end of the day (say it once)
176
234
  sections.push({ id: 'week', title: 'This week', count: Y.week.sub, html: `<div class="hv-card"><div class="hm-r hv-r two" data-id="review"><button type="button" class="hm-rm" data-hm-review aria-label="Weekly review: ${esc(Y.week.sub)}. Open"><span class="hv-mk">${svg(CAL, 16)}</span><span class="hm-rt"><b>Weekly review</b><em>${esc(Y.week.sub)}</em></span><span class="hv-cv">${svg(CHEV, 16)}</span></button></div></div>` });
177
235
  const scene = !big && o.first && Y.mood !== 'concerned' && new Date(now).getHours() < 12;
178
236
  const night = Y.mood !== 'concerned' && asleep(now) ? nightHtml(Y) : '';