create-pmos 0.440.0 → 0.441.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 (51) 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 +16 -13
  7. package/workspace/briefing-premium-products-test.js +4 -4
  8. package/workspace/briefing-premium-sources-test.js +2 -2
  9. package/workspace/briefing-premium-test.js +29 -23
  10. package/workspace/changelog.json +12 -0
  11. package/workspace/guide/core-documents.md +2 -2
  12. package/workspace/guide/data-freshness.md +7 -5
  13. package/workspace/guide/home.md +1 -1
  14. package/workspace/guide/horizon-scan.md +1 -1
  15. package/workspace/lib/agent-inbox.js +20 -2
  16. package/workspace/lib/briefing-premium-sources.js +3 -0
  17. package/workspace/lib/briefing-premium.js +37 -7
  18. package/workspace/lib/driver-cli.js +1 -1
  19. package/workspace/lib/driver-run.js +15 -1
  20. package/workspace/lib/driver.js +31 -2
  21. package/workspace/lib/news-for-you.js +24 -9
  22. package/workspace/lib/pm-idle.js +12 -0
  23. package/workspace/lib/refresh.js +17 -8
  24. package/workspace/lib/routes-core-docs.js +1 -1
  25. package/workspace/lib/routes-news.js +15 -1
  26. package/workspace/lib/routes-phone-day.js +6 -4
  27. package/workspace/need-shot.js +57 -0
  28. package/workspace/news-viewers-test.js +183 -0
  29. package/workspace/package-lock.json +2 -2
  30. package/workspace/package.json +1 -1
  31. package/workspace/premium-core-doc-issue-test.js +9 -8
  32. package/workspace/public/pm/bd-ini-panel.js +4 -11
  33. package/workspace/public/pm/cozy-ev.css +29 -0
  34. package/workspace/public/pm/cozy-news.js +186 -22
  35. package/workspace/public/pm/cozy-today.css +5 -0
  36. package/workspace/public/pm/cozy-viewer.js +4 -3
  37. package/workspace/public/pm/cozy-vw-shell.css +49 -0
  38. package/workspace/public/pm/home-adddoc.js +46 -26
  39. package/workspace/public/pm/home-app.js +134 -112
  40. package/workspace/public/pm/home-day.js +10 -5
  41. package/workspace/public/pm/home-draft.js +35 -23
  42. package/workspace/public/pm/home-ini.js +2 -2
  43. package/workspace/public/pm/home-need.js +336 -0
  44. package/workspace/public/pm/home-today.js +2 -2
  45. package/workspace/public/pm/home-work.js +51 -4
  46. package/workspace/public/pm/small-vw.js +128 -0
  47. package/workspace/server.js +10 -6
  48. package/workspace/skills/initiative-drive.skill +4 -1
  49. package/workspace/test-lists/batch18-asks.json +5 -0
  50. package/workspace/test-lists/news-viewers.json +13 -0
  51. package/workspace/test-lists/small-viewers.json +5 -0
@@ -1,48 +1,68 @@
1
- /* home-adddoc.js — Add a document, in Home's Viewer (premium-agreed-design; initiative briefing-premium-adddoc).
2
- * Drawn in the Viewer's card shape (canvas HmMyWork: the title, the fields, the foot with the press). It is the form the old
3
- * dialog had (title, phase, who writes it, where it lives, the address) and its one press posts to POST /api/custom-docs/add, nothing else.
1
+ /* home-adddoc.js — Add a document, in Home's Viewer (premium-agreed-design; initiative briefing-premium-adddoc; batch 18 item 2-C, canvas OvA9Docs).
2
+ * Shell A's form: ✓ in the header adds, ← cancels. A short note line, the title, Stage chips (an initiative only), Who writes it chips,
3
+ * Where it lives, and the page address only when it does not live in PMOS. Its one press posts to POST /api/custom-docs/add, nothing else.
4
4
  *
5
5
  * openAddDocVw({ VW, pmPost, toast, ws, scope, phases, title, back, onAdded })
6
6
  * VW the Home Viewer host (cozy-viewer): open({ id, kind, title, icon, render }) gives the body to draw in
7
7
  * ws the workspace the record is written in; scope 'initiative:<id>' or 'board:<id>'
8
- * phases the stages a phase can name (an initiative only); back() reopens what the form came from (Cancel)
8
+ * phases the stages a phase can name (an initiative only); back() reopens what the form came from (←)
9
9
  * onAdded awaited after the route answers ok
10
10
  */
11
11
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
12
12
  const KINDS = ['Confluence', 'Google Docs', 'Google Slides'];
13
+ const I = { doc: 'M7 3h7l5 5v13H7zM14 3v5h5', check: 'M5 12.5l4.5 4.5L19 7.5', spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z' };
14
+ const svg = (d) => `<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
15
+ /** The ✦ line under the form: what happens to the record, said once, for the choices made. Pure. */
16
+ export function whereLine(kind, who) {
17
+ if (kind) return 'It is saved on the record with the ' + kind + ' page’s address. PMOS does not read or sync that page.';
18
+ return (who === 'you' ? 'You write it, and it is saved on the record.' : 'It is saved on the record as mine to draft.') + ' Pick Confluence or Google Docs to paste a page address instead.';
19
+ }
13
20
 
14
21
  export function openAddDocVw(o) {
15
22
  const ini = String(o.scope).startsWith('initiative:');
16
23
  const phases = (o.phases && o.phases.length ? o.phases : ['Discover', 'Plan', 'Build', 'Evaluate']);
17
- let who = 'drafts';
24
+ const X = { who: 'drafts', phase: phases[0], kind: '', busy: false };
25
+ const chips = (id, label, list, cur, attr) => `<div class="czf-l" role="group" aria-label="${label}"><span>${label}</span><div class="czf-chips" id="${id}">${list.map(([v, t, ic]) => `<button type="button" class="cz-chip" ${attr}="${esc(v)}" aria-pressed="${v === cur}">${ic ? svg(ic) : ''}${esc(t)}</button>`).join('')}</div></div>`;
18
26
  const draw = (b) => {
19
- b.innerHTML = `<div class="hx-sec hm-adf ut-vc"><div><h2 class="ut-h2">Add a document</h2>${o.title ? `<p class="ut-sub">${esc(o.title)}</p>` : ''}</div>`
20
- + `<p class="ut-small ut-mut" data-ad-note>Add a document the core set does not cover, for example a research plan, a UAT plan or a contract. It is saved on the ${ini ? 'initiative' : 'board'}'s record with the address of a copy that lives in Confluence or Google Docs. PMOS does not read or sync that page.</p>`
21
- + `<label class="hv-why"><span>Title</span><input id="adT" maxlength="80" placeholder="For example: UAT plan" autocomplete="off"></label>`
22
- + (ini ? `<label class="hv-why"><span>Phase</span><select id="adPh">${phases.map((k) => `<option>${esc(k)}</option>`).join('')}</select></label>` : '')
23
- + `<div class="hv-why"><span>Who writes it</span><div class="hx-tabs" id="adW" role="group" aria-label="Who writes it"><button type="button" data-w="drafts" aria-pressed="true">PMOS drafts it</button><button type="button" data-w="you" aria-pressed="false">I write it</button></div></div>`
24
- + `<label class="hv-why"><span>Where it lives</span><select id="adK"><option value="">In PMOS</option>${KINDS.map((k) => `<option>${k}</option>`).join('')}</select></label>`
25
- + `<label class="hv-why"><span>Page address</span><input id="adU" maxlength="300" placeholder="Paste the page address" disabled autocomplete="off"></label>`
26
- + `<p class="hx-n" id="adM" role="status"></p>`
27
- + `<div class="ut-foot"><button type="button" class="ut-btn pri" id="adGo">Add document</button><button type="button" class="ut-btn ghost" id="adNo">Cancel</button></div></div>`;
27
+ b.innerHTML = `<form class="czf hm-adf" data-czf-adddoc novalidate>`
28
+ + `<p class="czf-note" data-ad-note>For a document the core set does not cover, like a UAT plan or a contract.</p>`
29
+ + `<label class="czf-l"><span>Title</span><input id="adT" maxlength="80" placeholder="For example: UAT plan" autocomplete="off"></label>`
30
+ + (ini ? chips('adPh', 'Stage', phases.map((k) => [k, k]), X.phase, 'data-ph') : '')
31
+ + chips('adW', 'Who writes it', [['drafts', 'I draft it', I.spark], ['you', 'You write it']], X.who, 'data-w')
32
+ + `<label class="czf-l"><span>Where it lives</span><select id="adK"><option value="">In PMOS</option>${KINDS.map((k) => `<option>${k}</option>`).join('')}</select></label>`
33
+ + `<label class="czf-l" id="adUL" hidden><span>Page address</span><input id="adU" maxlength="300" placeholder="Paste the page address" autocomplete="off"></label>`
34
+ + `<p class="czf-spark" id="adS">${svg(I.spark)}<span>${esc(whereLine(X.kind, X.who))}</span></p>`
35
+ + `<p class="czf-err" id="adM" role="status"></p><button type="submit" hidden></button></form>`;
28
36
  };
29
- const body = o.VW.open({ id: 'adddoc:' + o.scope, kind: 'New document', title: 'Add a document' + (o.title ? ' · ' + o.title : ''), icon: 'doc', render: draw });
37
+ const body = o.VW.open({ id: 'adddoc:' + o.scope, kind: 'New document', title: 'Add a document', sub: o.title || '', icon: I.doc, back: true,
38
+ presses: [{ act: 'add', label: 'Add the document', icon: I.check, solid: true, blue: true }],
39
+ onPress: (a) => { if (a === 'add') add(); },
40
+ render: draw });
30
41
  const $ = (s) => body.querySelector(s);
31
- body.onchange = (e) => { if (e.target.id === 'adK') { $('#adU').disabled = !e.target.value; if (e.target.value) $('#adU').focus(); } };
32
- body.onclick = async (e) => {
33
- const w = e.target.closest('[data-w]');
34
- if (w) { who = w.dataset.w; body.querySelectorAll('#adW button').forEach((x) => x.setAttribute('aria-pressed', String(x === w))); return; }
35
- if (e.target.closest('#adNo')) { if (o.back) o.back(); return; }
36
- if (!e.target.closest('#adGo')) return;
37
- const title = $('#adT').value.trim(), m = $('#adM'), kind = $('#adK').value, url = ($('#adU').value || '').trim();
42
+ const say = () => { const s = $('#adS span'); if (s) s.textContent = whereLine(X.kind, X.who); };
43
+ body.onchange = (e) => {
44
+ if (e.target.id !== 'adK') return;
45
+ X.kind = e.target.value; $('#adUL').hidden = !X.kind; say();
46
+ if (X.kind) $('#adU').focus();
47
+ };
48
+ body.onclick = (e) => {
49
+ const w = e.target.closest('[data-w]'), ph = e.target.closest('[data-ph]');
50
+ if (w) { X.who = w.dataset.w; body.querySelectorAll('#adW [data-w]').forEach((x) => x.setAttribute('aria-pressed', String(x === w))); say(); }
51
+ if (ph) { X.phase = ph.dataset.ph; body.querySelectorAll('#adPh [data-ph]').forEach((x) => x.setAttribute('aria-pressed', String(x === ph))); }
52
+ };
53
+ body.addEventListener('submit', (e) => { e.preventDefault(); add(); });
54
+ async function add() {
55
+ if (X.busy) return;
56
+ const title = $('#adT').value.trim(), m = $('#adM'), kind = X.kind, url = ($('#adU').value || '').trim();
38
57
  if (!title) { m.textContent = 'Give the document a title.'; $('#adT').focus(); return; }
39
58
  if (kind && !url) { m.textContent = 'Paste the address of the ' + kind + ' page, or choose In PMOS.'; $('#adU').focus(); return; }
40
- const go = $('#adGo'); go.disabled = true;
41
- const res = await o.pmPost('/api/custom-docs/add', { ws: o.ws, scope: o.scope, title, writer: who, phase: ini ? $('#adPh').value : undefined, kind: kind || undefined, url: kind ? url : undefined });
42
- if (!res || res.ok !== true) { go.disabled = false; m.textContent = (res && res.error) || 'The document could not be added.'; return; }
59
+ X.busy = true; m.textContent = '';
60
+ const res = await o.pmPost('/api/custom-docs/add', { ws: o.ws, scope: o.scope, title, writer: X.who, phase: ini ? X.phase : undefined, kind: kind || undefined, url: kind ? url : undefined });
61
+ X.busy = false;
62
+ if (!res || res.ok !== true) { m.textContent = (res && res.error) || 'The document could not be added.'; return; }
43
63
  o.toast('Document added. It is saved on the record.');
44
64
  if (o.onAdded) await o.onAdded();
45
- };
65
+ }
46
66
  const t = $('#adT'); if (t) t.focus();
47
67
  return body;
48
68
  }
@@ -18,6 +18,7 @@ import { mountNav } from './cozy-nav.js';
18
18
  import { mountLivePill } from './cozy-live-pill.js';
19
19
  import { ownTab, bring, tabUrl } from './rec-tab-core.js';
20
20
  import * as VW from './cozy-viewer.js';
21
+ import * as SV from './small-vw.js'; // the small Viewers: a stakeholder, its form, a routine (batch 18 item 2-C)
21
22
  import { pmGet, pmPost, pmHeaders } from './http.js';
22
23
  import * as H from './home-data.js';
23
24
  import { mountChat, avHtml } from './home-chat.js';
@@ -31,6 +32,7 @@ import { iniView } from './ini-view-model.js'; // the one initiative view (bat
31
32
  import { rowFor } from './ini-versions.js'; // planned versus actual (batch 11 item 8): Live or the draft the PM shows, with the plan line
32
33
  import { programOf } from './program-model.js';
33
34
  import { startAgent } from './page-agent.js';
35
+ import * as NEED from './home-need.js'; // the asks in the Viewer: start, decision, waited, source (batch 18 item 2-A)
34
36
  import { mdHtml } from './chat-md.js';
35
37
  import { mountPhoneCard } from './home-phone-card.js';
36
38
  import { mountFirst } from './premium-first.js';
@@ -201,6 +203,7 @@ async function load() {
201
203
  S.ready = true;
202
204
  await loadIni();
203
205
  draw();
206
+ NEED.refresh(); // an open ask: its agent finished, or it left Home while it was open
204
207
  loadImpact();
205
208
  readImpact();
206
209
  // the boards of the other products Home reads, each its own closed group: read after the list is drawn, so a slow one never holds it up
@@ -245,7 +248,7 @@ function poll() {
245
248
  if (ses && Array.isArray(ses.sessions)) S.D.sessions = H.homeSessions(ses.sessions);
246
249
  if (desk && desk.ok) S.D.desk = desk;
247
250
  S.D.now = Date.now();
248
- drawList(); drawTop();
251
+ drawList(); drawTop(); NEED.refresh();
249
252
  }
250
253
  poll();
251
254
  }, 8000);
@@ -354,7 +357,8 @@ function day(on) {
354
357
  presses: [{ act: 'cal', label: 'Open the calendar', icon: 'cal' }], onPress: (act) => { if (act === 'cal') openCalendar(); },
355
358
  onClose: () => { S.day = false; },
356
359
  render: (body) => {
357
- drawDayBody(body, P);
360
+ // ← back from a row's Viewer draws the day as it is now (a draft the PM is done with has left Drafted for you, batch 18 item 2)
361
+ if (body.dataset.ydDrawn) { const f = dayParts(); S.Y = f.Y; drawDayBody(body, f.P); } else { body.dataset.ydDrawn = '1'; drawDayBody(body, P); }
358
362
  if (isPhone()) mountPull(body, { read: rereadDay, label: 'Reading your day again' });
359
363
  body.onclick = (e) => { // the rows are the list's own rows: the same presses open them
360
364
  const b = e.target.closest('button'); if (!b) return;
@@ -757,53 +761,15 @@ function alsoOf(ini) {
757
761
  const n = ini ? other.find((r) => r.ini === ini) : other[0];
758
762
  return n ? { text: n.name, go: () => select(n.id) } : null;
759
763
  }
760
- /* HmDecide: a decision is recorded in the chat, on a card under the agent's question: the choices, Why (kept in the journal), Record,
761
- * Later (Later today, Tomorrow 09:00, Next week) and Pin. Nothing changes until the PM presses Record (POST /api/briefing-premium/decide). */
762
- function decisionCard(r) {
763
- const d = r.row.dialog || {};
764
- const st = S.rec[r.key] || (S.rec[r.key] = { choice: d.sel || null, why: '', ret: null, note: '' });
765
- if (st.whyShown == null) st.whyShown = st.why;
766
- const ok = () => !!st.choice && st.why.trim().length >= 3;
767
- return {
768
- html: () => `<div class="ut-card ut-dec" role="group" aria-label="Your decision"><p class="ut-lbl">Your decision</p><div role="radiogroup" aria-label="Choices">${(d.opts || []).map((o) => `<button type="button" class="ut-radio" role="radio" aria-checked="${st.choice === o.k}" data-dc-opt="${esc(o.k)}"><span class="o" aria-hidden="true"></span><span><b>${esc(o.t)}</b>${o.d ? `<br><span class="ut-small ut-mut">${esc(o.d)}</span>` : ''}</span></button>`).join('')}</div>`
769
- + `<div class="ut-field"><label for="dcWhy">Why <span class="ut-mut">· kept in the journal</span></label><textarea id="dcWhy" rows="2" placeholder="The reason goes in pm-decisions.md with your choice">${esc(st.whyShown)}</textarea></div>`
770
- + `<div class="ut-acts"><button type="button" class="ut-btn pri" data-dc-rec${ok() ? '' : ' disabled'}>Record</button><button type="button" class="ut-btn" data-dc-later aria-haspopup="menu">Later${TD.svg(TD.P.chevD, 14)}</button>`
771
- + `<button type="button" class="ut-ib${S.pin.has(r.key) ? ' on' : ''}" data-dc-pin aria-pressed="${S.pin.has(r.key)}" aria-label="${S.pin.has(r.key) ? 'Unpin' : 'Pin to the top'}" title="${S.pin.has(r.key) ? 'Unpin' : 'Pin to the top'}">${TD.svg(TD.P.pin, 16)}</button><span class="sp">Nothing changes until you press Record</span></div>`
772
- + '<p class="ut-small ut-mut" role="status" id="dcMsg"></p></div>',
773
- input: (t, card) => { if (t.id !== 'dcWhy') return; st.why = t.value; const b = card.querySelector('[data-dc-rec]'); if (b) b.disabled = !ok(); },
774
- press: async (b) => {
775
- st.whyShown = st.why; // a redraw after a press keeps what was typed; typing itself never changes the card's html
776
- const say = (m) => { const el = document.getElementById('dcMsg'); if (el) el.textContent = m; };
777
- if (b.dataset.dcOpt) { st.choice = b.dataset.dcOpt; return true; }
778
- if ('dcPin' in b.dataset) { if (S.pin.has(r.key)) S.pin.delete(r.key); else S.pin.add(r.key); store.set('pmos.home.pin', JSON.stringify([...S.pin])); drawList(); return true; }
779
- if ('dcLater' in b.dataset) {
780
- const at = new Date(NOW() + 3 * 3600000);
781
- const put = async (until) => { const res = await bpPost('put-off', { key: r.key, until }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); delete S.rec[r.key]; VW.close(); await load(); select(null); } else say(res.error); };
782
- menu(b, [{ label: 'Later today', k: H.hm(at.toISOString()), go: () => put('later') }, { label: 'Tomorrow', k: '09:00', go: () => put('tomorrow') }, { label: 'Next week', k: 'Mon', go: () => put('nextweek') }], '');
783
- return false;
784
- }
785
- if ('dcRec' in b.dataset) {
786
- b.disabled = true;
787
- const res = await bpPost('decide', { key: r.key, choice: st.choice, why: st.why });
788
- if (!res.ok) { b.disabled = false; say(res.error); return false; }
789
- delete S.rec[r.key];
790
- toast('Recorded in pm-decisions.md.');
791
- VW.close(); await load(); select(null);
792
- }
793
- return false;
794
- },
795
- };
796
- }
764
+ /* An ask's conversation (batch 18 item 2-A, OvA10Desk): the Viewer holds the summary and the one verb, so the chat asks a question instead
765
+ * of saying it again. A decision's choices are pills that open the Viewer with that choice picked; it is recorded there. */
797
766
  function needTarget(r) {
798
767
  const row = r.row, d = row.dialog || {};
799
768
  const pills = [];
800
- const dec = d.write && d.write.kind === 'decision';
801
- if (!dec) for (const o of d.opts || []) pills.push({ label: o.t, primary: o.k === (d.prim || d.sel), go: () => { S.rec[r.key] = { ...(S.rec[r.key] || {}), choice: o.k }; openNeedViewer(r, true); } });
802
- if (d.write && d.write.kind === 'start') pills.unshift({ label: 'Start the agent', primary: true, go: () => start(r) });
769
+ if (d.write && d.write.kind === 'decision') for (const o of d.opts || []) pills.push({ label: o.t, go: () => openNeedViewer(r, o.k) });
803
770
  if (d.write && d.write.kind === 'return') pills.push({ label: 'Return it', go: () => openNeedViewer(r, true) });
804
- if (!dec) pills.push({ label: 'Discuss', go: () => chat.focus() });
805
771
  return { key: r.key, ini: r.ini, ws: WS || undefined, title: r.name, sub: r.hint || '', scope: scopeOf(r.ini), rich: rich(), role: CLAUDE,
806
- intro: { role: CLAUDE, text: d.say || row.subject || row.title, pills: dec ? [] : pills, card: dec ? decisionCard(r) : undefined }, placeholder: dec ? 'Answer, or type /' : 'Ask about ' + r.name, also: null };
772
+ intro: { role: CLAUDE, text: d.write && d.write.kind === 'return' ? (d.say || row.subject || row.title) : NEED.introOf(r), pills }, placeholder: 'Ask about ' + r.name, also: null };
807
773
  }
808
774
  function updateTarget() {
809
775
  const U = H.weeklyUpdate(S.D, S.D.now);
@@ -1093,10 +1059,50 @@ function openBoardTask(t) {
1093
1059
  rename: taskRenameOf,
1094
1060
  }));
1095
1061
  }
1062
+ /* Finished (batch 18 item 2, canvas OvA7Drafted): a draft of today's prep run, open to read. Summary first: when it finished and that nothing
1063
+ * was sent (a sent one says so), Claude's one line, ONE primary "Done with it" (it leaves Drafted for you: New for you's seen line,
1064
+ * fin:<date>:<id>), ↗ the draft's own page when it has one; the chat icon in the header asks Claude to change it in Home's chat. */
1065
+ const WHEN_OF = (iso) => { const t = Date.parse(iso || ''); if (!Number.isFinite(t)) return ''; const h = new Date(t).getHours(); return h < 12 ? 'this morning' : h < 17 ? 'this afternoon' : 'this evening'; };
1066
+ function finSummary(f) {
1067
+ const when = WHEN_OF(f.at);
1068
+ const line = f.status === 'sent' ? 'Sent' + (when ? ' · ' + when : '') : f.status === 'review' ? 'Ready for you at your desk' : 'Finished' + (when ? ' · ' + when : '');
1069
+ const meta = f.status === 'sent' ? '' : 'Nothing is sent. It stays on this machine.';
1070
+ return VW.czSummary({ line, tone: 'ok', text: f.summary && f.body ? '' : f.summary || '', meta, primary: f.key ? { label: 'Done with it', act: 'fin-done' } : null,
1071
+ also: HTTPS.test(f.link || '') ? [{ act: 'fin-open', label: 'Open it', icon: 'M14 4h6v6M20 4l-9 9M18 14v5H5V6h5' }] : [] });
1072
+ }
1096
1073
  function openFinished(f) {
1097
1074
  if (!f) return;
1098
- VW.open({ id: 'fin:' + (f.id || f.title), kind: f.status === 'review' ? 'Finished · waits for your review' : 'Finished', title: f.title, icon: 'doc',
1099
- html: `<div class="ut-vc">${f.summary ? `<p class="ut-sub">${esc(f.summary)}</p>` : ''}${f.body ? `<article class="hv-doc">${mdHtml(f.body)}</article>` : ''}${HTTPS.test(f.link || '') ? `<div class="ut-foot"><a class="ut-btn" href="${esc(f.link)}" target="_blank" rel="noopener noreferrer">Open it</a></div>` : ''}</div>` });
1075
+ const id = 'fin:' + (f.id || f.title);
1076
+ VW.open({ id, kind: 'Finished', title: f.title, icon: 'doc',
1077
+ presses: [{ act: 'chat', label: 'Change it in chat', icon: I.chat }],
1078
+ more: [{ label: 'Copy the text', on: () => { try { navigator.clipboard.writeText(f.body || f.summary || ''); toast('Copied.'); } catch { toast('It was not copied.'); } } }],
1079
+ onPress: (act) => { if (act === 'chat') finChat(f); },
1080
+ render: (body) => {
1081
+ body.innerHTML = `<div class="ut-vc">${finSummary(f)}${f.body ? `<article class="hv-doc">${mdHtml(f.body)}</article>` : ''}</div>`;
1082
+ body.onclick = async (e) => {
1083
+ const b = e.target.closest('[data-czs-act]'); if (!b || b.disabled) return;
1084
+ if (b.dataset.czsAct === 'fin-open') { window.open(f.link, '_blank', 'noopener'); return; }
1085
+ if (b.dataset.czsAct !== 'fin-done') return;
1086
+ b.disabled = true;
1087
+ const r = await pmPost('/api/news-for-you/seen', { ids: [f.key] }).catch(() => null);
1088
+ if (!r || !r.ok) { b.disabled = false; toast('It was not marked done. The server did not answer.'); return; }
1089
+ toast('Done with ' + f.title + '.');
1090
+ const pd = await pmGet('/api/phone-day').catch(() => null);
1091
+ if (pd && pd.ok) S.D.phoneDay = pd;
1092
+ const c = VW.current(); if (c && c.id === id) VW.back();
1093
+ redrawDay();
1094
+ };
1095
+ } });
1096
+ }
1097
+ /** "Change it in chat": Home's chat about this one draft, with its text as the context. The draft changes only when the PM says so. */
1098
+ function finChat(f) {
1099
+ S.phoneChat = isPhone();
1100
+ openTarget({ ...homeTarget(), key: 'chat:fin-' + (f.id || f.title), title: f.title, sub: 'Drafted for you', scope: { text: f.title, icon: I.doc },
1101
+ intro: { role: CLAUDE, text: 'What should I change in ' + f.title + '?' }, placeholder: 'Tell Claude what to change',
1102
+ context: 'The PM wants to change a draft from today\'s prep run: "' + f.title + '".' + (f.summary ? ' Summary: ' + f.summary : '') + (f.body ? '\nThe draft:\n' + String(f.body).slice(0, 6000) : '') + '\nNothing is sent: write the changed draft here for the PM to read.' });
1103
+ drawList();
1104
+ if (isPhone()) VW.close();
1105
+ chat.focus();
1100
1106
  }
1101
1107
  function openReviewVw() {
1102
1108
  S.sel = 'review'; drawList();
@@ -1177,67 +1183,85 @@ function reopenViewer() {
1177
1183
  openUpdateViewer(); // nothing picked on Home: the product's weekly update (My work is no longer a page of its own)
1178
1184
  }
1179
1185
  function factsHtml(rows) { return rows && rows.length ? `<dl class="hv-facts">${rows.map(([k, v]) => `<div><dt>${esc(k)}</dt><dd>${esc(v)}</dd></div>`).join('')}</dl>` : ''; }
1180
- function openNeedViewer(r, focusWhy) {
1186
+ /** An ask in the Viewer. The asks (start / blocked, decision, waited, source) are home-need.js's (batch 18 item 2-A); a run's return stays
1187
+ * here (XvAReturn). pick: a decision's choice from the chat's pills, or true to focus a return's note. */
1188
+ function openNeedViewer(r, pick) {
1181
1189
  const row = r.row, d = row.dialog || {}, w = d.write || {};
1190
+ if (w.kind !== 'return') return NEED.openNeed(r, needHost(), { choice: typeof pick === 'string' ? pick : null });
1191
+ let focusWhy = !!pick;
1182
1192
  const st = S.rec[r.key] || (S.rec[r.key] = { choice: d.sel || null, why: '', ret: null });
1183
1193
  const draw = (b) => {
1184
1194
  const pane = d.pane || {};
1185
1195
  const facts = factsHtml(pane.rows || d.facts || []);
1186
- // a source row (mail, Jira, Confluence, from the morning brief): why it is here now, and its own https link; nothing is recorded or sent
1187
- const src = row.kind === 'source';
1188
- const intro = pane.intro ? `<p class="hv-intro">${src ? '<b>Why now</b> ' : ''}${esc(pane.intro)}</p>` : '';
1189
- const paras = (pane.paras || []).length ? `<section class="hv-sec"><h4>${esc(pane.parasTitle || 'More')}</h4>${pane.paras.map((x) => `<p class="hx-n">${esc(x)}</p>`).join('')}</section>` : '';
1190
- const link = /^https:\/\//.test(d.link || '') ? `<a class="hx-b hv-link" id="srcLink" href="${esc(d.link)}" target="_blank" rel="noopener noreferrer">${esc(d.linkLabel || 'Open it')}</a>` : '';
1191
- let rec = '';
1192
- if (w.kind === 'decision') {
1193
- // the decision is recorded on the chat's card (HmDecide); the Viewer keeps the facts it rests on
1194
- rec = '<p class="ut-small ut-mut">Record your decision on the card in the chat.</p>';
1195
- } else if (w.kind === 'return') {
1196
- // shell A (canvas XvAReturn): the summary says what the review found and holds Return it with Keep it as is beside it;
1197
- // why it goes back and what to change are open rows below, the facts the review rests on fold under them
1198
- const score = (pane.rows || d.facts || []).find((x) => /score|rubric/i.test(String(x[0] || '')));
1199
- b.innerHTML = VW.czSummary({ line: score ? String(score[1]) : r.hint || pane.h || 'Waits for your review', tone: 'warn', text: pane.intro || (pane.paras || [])[0] || r.hint || '',
1200
- meta: (w.agent || 'The agent') + ' gets this note and tries again. It counts as one correction.', primary: { label: 'Return it', act: 'return', disabled: !st.ret }, second: { label: 'Keep it as is', act: 'keep' } })
1201
- + VW.czSections([
1202
- { id: 'why', title: 'Why it goes back', open: true, html: `<div class="ut-chips" role="group" aria-label="Why it goes back">${RET_REASONS.map((x) => `<button type="button" class="cz-chip${st.ret === x ? ' on' : ''}" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(RET_LABEL[x] || x)}</button>`).join('')}</div>` },
1203
- { id: 'note', title: 'What to change', open: true, html: `<div class="ut-field"><label for="hvNote" class="hi-vh">What to change</label><textarea id="hvNote" rows="3" placeholder="Say what the agent should change">${esc(st.note || '')}</textarea></div>` },
1204
- facts ? { id: 'facts', title: pane.h || 'The review', count: (pane.rows || d.facts || []).length, html: facts } : null,
1205
- ], { key: 'return' })
1206
- + '<p class="ut-small ut-mut" role="status" id="hvMsg"></p>';
1207
- if (focusWhy) { const t = b.querySelector('#hvNote'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
1208
- return;
1209
- } else if (w.kind === 'start') {
1210
- rec = `<section class="hv-sec"><h4>Start</h4><p class="hx-n">The agent drafts ${esc(w.what || 'it')} in a real session. Its draft waits for you to read.</p><div class="hv-acts"><button type="button" class="hx-b pri" data-hv-start>Start the agent</button>${laterHtml()}${pinHtml(r)}</div></section>`;
1211
- } else rec = `<div class="hv-acts">${link}${src ? '' : laterHtml()}${pinHtml(r)}</div>`; // a source row cannot be put off (the server refuses it)
1212
- b.innerHTML = `<div class="hv">${pane.note ? `<p class="hv-note">${esc(pane.note)}</p>` : ''}${pane.h ? `<h4 class="hv-h">${esc(pane.h)}</h4>` : ''}${intro}${facts}${paras}${rec}<p class="hx-n" role="status" id="hvMsg"></p></div>`;
1213
- if (focusWhy) { const t = b.querySelector('#hvWhy'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
1196
+ // shell A (canvas XvAReturn): the summary says what the review found and holds Return it with Keep it as is beside it;
1197
+ // why it goes back and what to change are open rows below, the facts the review rests on fold under them
1198
+ const score = (pane.rows || d.facts || []).find((x) => /score|rubric/i.test(String(x[0] || '')));
1199
+ b.innerHTML = VW.czSummary({ line: score ? String(score[1]) : r.hint || pane.h || 'Waits for your review', tone: 'warn', text: pane.intro || (pane.paras || [])[0] || r.hint || '',
1200
+ meta: (w.agent || 'The agent') + ' gets this note and tries again. It counts as one correction.', primary: { label: 'Return it', act: 'return', disabled: !st.ret }, second: { label: 'Keep it as is', act: 'keep' } })
1201
+ + VW.czSections([
1202
+ { id: 'why', title: 'Why it goes back', open: true, html: `<div class="ut-chips" role="group" aria-label="Why it goes back">${RET_REASONS.map((x) => `<button type="button" class="cz-chip${st.ret === x ? ' on' : ''}" aria-pressed="${st.ret === x}" data-hv-ret="${esc(x)}">${esc(RET_LABEL[x] || x)}</button>`).join('')}</div>` },
1203
+ { id: 'note', title: 'What to change', open: true, html: `<div class="ut-field"><label for="hvNote" class="hi-vh">What to change</label><textarea id="hvNote" rows="3" placeholder="Say what the agent should change">${esc(st.note || '')}</textarea></div>` },
1204
+ facts ? { id: 'facts', title: pane.h || 'The review', count: (pane.rows || d.facts || []).length, html: facts } : null,
1205
+ ], { key: 'return' })
1206
+ + '<p class="ut-small ut-mut" role="status" id="hvMsg"></p>';
1207
+ if (focusWhy) { const t = b.querySelector('#hvNote'); if (t) setTimeout(() => t.focus(), 0); focusWhy = false; }
1214
1208
  };
1215
- const body = VW.open({ id: 'need:' + r.key, kind: ({ decision: 'Decision', blocked: 'Blocked', waited: 'Waiting', src: 'Source', ev: 'Event' }[row.kind] || 'Needs you'), title: r.name, icon: 'info', url: d.pane && d.pane.file ? '/premium-board.html?doc=' + encodeURIComponent(d.pane.file) : '', render: draw });
1216
- body.oninput = (e) => { if (e.target.id === 'hvNote') { st.note = e.target.value; return; } if (e.target.id === 'hvWhy') { st.why = e.target.value; const b = body.querySelector('[data-hv-rec]'); if (b) b.disabled = !(st.choice && st.why.trim().length >= 3); } };
1209
+ const body = VW.open({ id: 'need:' + r.key, kind: 'Waiting', title: r.name, icon: 'info', render: draw });
1210
+ body.oninput = (e) => { if (e.target.id === 'hvNote') st.note = e.target.value; };
1217
1211
  body.onclick = async (e) => {
1218
1212
  const t = e.target.closest('button'); if (!t || t.disabled) return;
1219
1213
  const say = (m) => { const el = body.querySelector('#hvMsg'); if (el) el.textContent = m; };
1220
- if (t.dataset.hvOpt) { st.choice = t.dataset.hvOpt; draw(body); return; }
1221
1214
  if (t.dataset.hvRet) { st.ret = t.dataset.hvRet; draw(body); return; }
1222
- if ('hvLater' in t.dataset) { const m = t.nextElementSibling; m.hidden = !m.hidden; t.setAttribute('aria-expanded', String(!m.hidden)); return; }
1223
- if (t.dataset.hvUntil) { const res = await bpPost('put-off', { key: r.key, until: t.dataset.hvUntil }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); VW.close(); await load(); select(null); } else say(res.error); return; }
1224
- if ('hvPin' in t.dataset) { if (S.pin.has(r.key)) S.pin.delete(r.key); else S.pin.add(r.key); store.set('pmos.home.pin', JSON.stringify([...S.pin])); draw(body); drawList(); return; }
1225
- if ('hvStart' in t.dataset) { start(r); return; }
1226
- if ('hvKeep' in t.dataset || t.dataset.czsAct === 'keep') { delete S.rec[r.key]; VW.close(); return; }
1227
- if ('hvRec' in t.dataset || t.dataset.czsAct === 'return') {
1215
+ if (t.dataset.czsAct === 'keep') { delete S.rec[r.key]; VW.close(); return; }
1216
+ if (t.dataset.czsAct === 'return') {
1228
1217
  t.disabled = true;
1229
- const res = w.kind === 'decision' ? await bpPost('decide', { key: r.key, choice: st.choice, why: st.why }) : await bpPost('return', { run: w.run, reason: st.ret, ...(w.ws ? { ws: w.ws } : {}) });
1218
+ const res = await bpPost('return', { run: w.run, reason: st.ret, ...(w.ws ? { ws: w.ws } : {}) });
1230
1219
  if (!res.ok) { t.disabled = false; say(res.error); return; }
1231
1220
  delete S.rec[r.key];
1232
- toast(w.kind === 'decision' ? 'Recorded in pm-decisions.md.' : 'Returned to the agent. It counts as a correction.');
1233
- const note = w.kind === 'return' && String(st.note || '').trim();
1221
+ toast('Returned to the agent. It counts as a correction.');
1222
+ const note = String(st.note || '').trim();
1234
1223
  if (note && chat.current() && chat.current().key === r.key) chat.send('What to change: ' + note);
1235
1224
  VW.close(); await load(); select(null);
1236
1225
  }
1237
1226
  };
1238
1227
  }
1239
- const laterHtml = () => `<span class="hv-later"><button type="button" class="hx-b" data-hv-later aria-haspopup="menu" aria-expanded="false">Put off</button><span class="hv-lm" role="menu" hidden>${[['later', 'Later today'], ['tomorrow', 'Tomorrow'], ['nextweek', 'Next week']].map(([k, t]) => `<button type="button" role="menuitem" data-hv-until="${k}">${t}</button>`).join('')}</span></span>`;
1240
- const pinHtml = (r) => `<button type="button" class="hx-b" data-hv-pin aria-pressed="${S.pin.has(r.key)}">${S.pin.has(r.key) ? 'Unpin' : 'Pin to the top'}</button>`;
1228
+ /** What home-need.js reads and calls on Home. */
1229
+ function needHost() {
1230
+ return {
1231
+ VW, P: TD.P, esc, svg: TD.svg, toast, menu,
1232
+ me: () => (String((S.D.today && S.D.today.me) || 'You').trim()[0] || 'Y').toUpperCase(),
1233
+ pinned: (k) => S.pin.has(k),
1234
+ togglePin: (k) => { if (S.pin.has(k)) S.pin.delete(k); else S.pin.add(k); store.set('pmos.home.pin', JSON.stringify([...S.pin])); drawList(); },
1235
+ putOff: async (k, until) => { const res = await bpPost('put-off', { key: k, until }); if (res.ok) { toast('Put off. It comes back by itself, and it is not counted as done.'); delete S.rec[k]; VW.close(); await load(); select(null); } else toast(res.error); },
1236
+ start: (r) => start(r),
1237
+ sessions: () => S.D.sessions || [],
1238
+ stopSession: async (sid) => { const res = await pmPost('/api/session/remove', { id: sid }).catch(() => null); if (res && res.ok) { load(); return true; } return false; },
1239
+ openSession: (sid) => { const s = (S.D.sessions || []).find((x) => x.id === sid); if (!s) { toast('That session has ended. Its conversation is in Sessions.'); return; } if (isPhone()) { S.phoneChat = true; VW.close(); } openTarget(sessionTarget(s)); drawList(); chat.focus(); },
1240
+ ask: (r, text) => {
1241
+ const c = chat.current && chat.current();
1242
+ if (!c || c.key !== r.key) openTarget(needTarget(r));
1243
+ if (isPhone()) { S.phoneChat = true; VW.close(); drawList(); }
1244
+ if (text) chat.send(text); else chat.focus();
1245
+ },
1246
+ decide: async (r, choice, why) => {
1247
+ const res = await bpPost('decide', { key: r.key, choice, why });
1248
+ if (!res.ok) return res;
1249
+ delete S.rec[r.key]; toast('Recorded in pm-decisions.md.'); VW.close(); await load(); select(null);
1250
+ return res;
1251
+ },
1252
+ openReturn: (it) => {
1253
+ if (!it.run) { if (it.id) goIni(it.id); return; }
1254
+ VW.drill();
1255
+ openNeedViewer({ key: 'ret:' + it.run, name: it.t, hint: '', row: { kind: 'run', dialog: { write: { kind: 'return', run: it.run, ...(it.ws ? { ws: it.ws } : {}) },
1256
+ pane: { h: 'The review', intro: it.lead || '', rows: [['Score', it.s], ['Waiting', it.days != null ? it.days + ' days' : '']].filter((x) => x[1]) } } } });
1257
+ },
1258
+ recordHref: (r) => { const f = (r.row.detail || {}).record || ((r.row.dialog || {}).pane || {}).file; return f && /\.md$/.test(f) ? '/premium-board.html?doc=' + encodeURIComponent(f) : ''; },
1259
+ boardHref: (r) => { const t = r.row.detail || {}, ws = t.ws || r.row.ws || boardWs() || ''; return t.id && t.lane ? '/premium-board.html?' + (ws ? 'ws=' + encodeURIComponent(ws) + '&' : '') + 'focus=' + encodeURIComponent(t.id) : ''; },
1260
+ linkOf: (r) => location.origin + selfUrl({ open: r.key }),
1261
+ signIn: () => import('./cozy-settings.js').then((M) => M.openSettings('connectors')),
1262
+ rowGone: (k) => !!S.D.brief && !H.needsOf(S.D).some((x) => x.key === k),
1263
+ };
1264
+ }
1241
1265
  async function bpPost(act, body) {
1242
1266
  const r = await pmPost('/api/briefing-premium/' + act + wsQ(), body);
1243
1267
  return r && r.ok === true ? r : { ok: false, error: (r && r.error) || 'The record was not written.' };
@@ -1247,6 +1271,7 @@ async function start(r) {
1247
1271
  const res = await startAgent({ ws: w.ws || WS || undefined, task: 'draft', initiative: w.initiative, what: w.what });
1248
1272
  toast(res.ok ? 'The agent started. Its draft waits for you to read.' : 'Not started: ' + res.error);
1249
1273
  if (res.ok) load();
1274
+ return res;
1250
1275
  }
1251
1276
 
1252
1277
  /* the weekly update: the recipients are editable; Send opens a mail draft in the PM's own mail and records that it was sent */
@@ -1346,7 +1371,7 @@ function openOverview() {
1346
1371
  if (t.dataset.ovDread) { // a draft: read it, edit it, Issue it (home-draft.js, in the Viewer's card shape)
1347
1372
  const d = (M.docs.rows || []).find((x) => x.key === t.dataset.ovDread); if (!d) return;
1348
1373
  const A = await import('./home-draft.js');
1349
- A.openDraftVw({ VW, pmGet, pmPost, toast, ws: M.board.ws, scope: M.docs.scope, doc: d, onIssued: () => load() });
1374
+ A.openDraftVw({ VW, pmGet, pmPost, toast, ws: M.board.ws, scope: M.docs.scope, doc: d, iniTitle: iniTitle(id), onIssued: () => load() });
1350
1375
  return;
1351
1376
  }
1352
1377
  if ('ovAdddoc' in t.dataset) { // the form in the Viewer (home-adddoc.js): it posts to /api/custom-docs/add only
@@ -1363,28 +1388,17 @@ async function openFile(f) {
1363
1388
  const fws = () => (S.ini && S.IM && S.IM.board && S.IM.board.ws) || deskWs(); // an initiative's document lives in its board's workspace
1364
1389
  const ini = S.ini || ''; // its chat edits the document in the initiative's own worktree: the page reads it there (premium-vw-doc.js)
1365
1390
  if (/\.md$/i.test(f.path)) { try { const M = await import('./premium-vw-doc.js'); if (M.openDocPage({ path: f.path, title: f.name || f.path.split('/').pop() }, { ws: () => fws(), ini })) return; } catch { /* the plain view below */ } }
1366
- const body = VW.open({ id: 'file:' + f.path, kind: 'File · ' + f.path, title: f.name || f.path, icon: 'doc', html: '<p class="hx-n hv">Reading the file.</p>' });
1391
+ // shell A (batch 18 item 2-C): the kind is a Document and the path is under ⋯ (Copy path), never in the body
1392
+ const body = VW.open({ id: 'file:' + f.path, kind: 'Document', title: f.name || f.path.split('/').pop(), icon: 'doc', html: '<p class="hx-n hv">Reading the file.</p>',
1393
+ more: [{ label: 'Copy path', icon: 'M8 8h11v12H8zM5 16V4h11', on: async () => { try { await navigator.clipboard.writeText(f.path); toast('Path copied.'); } catch { toast('The path was not copied: ' + f.path); } } }] });
1367
1394
  let txt = null;
1368
1395
  try { const r = await fetch('/api/doc?path=' + encodeURIComponent(f.path) + (deskWs() ? '&ws=' + encodeURIComponent(deskWs()) : ''), { credentials: 'same-origin' }); txt = r.ok ? await r.text() : null; } catch { txt = null; }
1369
1396
  if (VW.current() && VW.current().id === 'file:' + f.path) body.innerHTML = txt == null ? '<p class="hx-n hv">The file could not be read.</p>' : `<article class="hv hv-doc">${mdHtml(txt.replace(/^---\n[\s\S]*?\n---\n/, ''))}</article>`;
1370
1397
  }
1371
- function openPerson(p) {
1372
- const id = S.ini;
1373
- const body = VW.open({ id: 'person:' + p.name, kind: 'Stakeholder', title: p.name, icon: 'info', html: `<div class="hv">${factsHtml([['Role', p.role], ['Note', p.note], ['Added', p.at ? new Date(p.at).toDateString() : '']].filter((x) => x[1]))}<div class="hv-acts"><button type="button" class="hx-b" data-hv-rmp>Remove from ${esc(iniTitle(id))}</button></div></div>` });
1374
- body.onclick = async (e) => { if (!e.target.closest('[data-hv-rmp]')) return; const r = await pmPost('/api/home-desk/stakeholder', { ws: deskWs(), initiative: id, name: p.name, remove: true }); if (r && r.ok) { VW.close(); await load(); } else toast((r && r.error) || 'Not removed.'); };
1375
- }
1376
- function addPerson() {
1377
- const id = S.ini;
1378
- const body = VW.open({ id: 'person:new', kind: 'Stakeholder', title: 'Add a stakeholder to ' + iniTitle(id), icon: 'info',
1379
- html: '<div class="hv"><label class="hv-why"><span>Name</span><input id="hpN" autocomplete="off"></label><label class="hv-why"><span>Role</span><input id="hpR" placeholder="e.g. Head of Sales"></label><label class="hv-why"><span>Note</span><input id="hpT" placeholder="What they care about"></label><div class="hv-acts"><button type="button" class="hx-b pri" data-hv-addp>Add</button></div></div>' });
1380
- setTimeout(() => { const i = body.querySelector('#hpN'); if (i) i.focus(); }, 0);
1381
- body.onclick = async (e) => {
1382
- if (!e.target.closest('[data-hv-addp]')) return;
1383
- const name = body.querySelector('#hpN').value.trim(); if (!name) return;
1384
- const r = await pmPost('/api/home-desk/stakeholder', { ws: deskWs(), initiative: id, name, role: body.querySelector('#hpR').value.trim(), note: body.querySelector('#hpT').value.trim() });
1385
- if (r && r.ok) { toast('Added ' + name + '.'); VW.close(); await load(); } else toast((r && r.error) || 'Not added.');
1386
- };
1387
- }
1398
+ /* a stakeholder and the one stakeholder form (pm/small-vw.js; batch 18 item 2-C, canvas OvA8People), the same as the Board's */
1399
+ const personCtx = () => { const id = S.ini; return { VW, pmPost, toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)), ws: deskWs(), ini: id, iniTitle: iniTitle(id), saved: () => load(), back: () => VW.back() }; };
1400
+ function openPerson(p) { SV.openPersonVw(p, { ...personCtx(), back: null }); }
1401
+ function addPerson() { SV.openPersonForm(personCtx()); }
1388
1402
  /* ── the metrics review (AgMetrics): the Strategist's conversation, and the review in the Viewer: three tiles, the correction rate by week
1389
1403
  * (the current week in blue) and what moved it. Every number is a record of the product's repository (GET /api/board-metrics-premium:
1390
1404
  * corrections from its run log, merges from its trunk, blocked from its workflow state); a measure that is not read says so. ── */
@@ -1458,10 +1472,7 @@ async function openMetrics(o = {}) {
1458
1472
  if (S.sel !== id) return;
1459
1473
  openTarget(metricsTarget());
1460
1474
  }
1461
- function openRoutine(s) {
1462
- VW.open({ id: 'routine:' + (s.id || s.name), kind: 'Routine', title: String(s.name || s.task || s.skill || 'Routine'), icon: 'cal',
1463
- html: `<div class="hv">${MORE.WAIT}${factsHtml([['Task', s.task || s.skill], ['Next run', s.next ? new Date(s.next).toString().slice(0, 21) : 'Not scheduled'], ['Repeats', s.cron || s.every || s.when || ''], ['On', s.enabled === false ? 'Off' : 'On']].filter((x) => x[1]))}</div>` });
1464
- }
1475
+ function openRoutine(s) { SV.openRoutineVw(s, { VW, now: S.D && S.D.now }); }
1465
1476
 
1466
1477
  /* the agent's terminal, read only, in the Viewer (term-view.js) */
1467
1478
  function openTerminal(sid) {
@@ -1629,12 +1640,23 @@ menuEl.onclick = (e) => { // delegated: every item is a <button role=menuitem>
1629
1640
  document.addEventListener('click', (e) => { if (!menuEl.hidden && !menuEl.contains(e.target) && !(menu.anchor && menu.anchor.contains(e.target))) closeMenu(); }, true);
1630
1641
  document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menuEl.hidden) { e.stopPropagation(); closeMenu(); } else if (e.key === 'Escape' && S.sheet) sheet(false); }, true);
1631
1642
  function searchGo(d) {
1643
+ if (d.merge) { mergeFrom(d.merge.from, d.merge.into); return; }
1632
1644
  if (d.ini) goIni(d.ini);
1633
1645
  else if (d.doc) openFile({ path: d.doc, name: d.doc.split('/').pop() });
1634
1646
  else if (d.ses) { const s = S.D.sessions.find((x) => x.id === d.ses); if (s) { S.sel = 's:' + s.id; openTarget(sessionTarget(s)); followViewer(s); drawList(); } }
1635
1647
  else if (d.link) location.href = d.link;
1636
1648
  }
1637
1649
 
1650
+ /** Merge from New for you's overlap note (batch 18 item 2b, OvA5): the initiative that goes opens, then the merge check with both set, as its
1651
+ * ⋯ › Merge into does. A merge stays on one board: when the two are not both on this board, the initiative opens and a toast says why. */
1652
+ async function mergeFrom(from, into) {
1653
+ const rows = H.boardRows(S.D), both = rows.some((r) => r.id === from) && rows.some((r) => r.id === into);
1654
+ await goIni(from);
1655
+ if (!both || (S.D.board && S.D.board.board && S.D.board.board.self)) { toast('These two are on different boards, so they cannot be merged here.'); return; }
1656
+ VW.drill();
1657
+ SM.openMerge(smCtx(from), into);
1658
+ }
1659
+
1638
1660
  /* ── the phone sheet ── */
1639
1661
  function sheet(on) {
1640
1662
  S.sheet = !!on;
@@ -8,7 +8,8 @@
8
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
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
10
  * for you page of the place menu.
11
- * Drafted for you the drafts of today's morning prep run (GET /api/phone-day finished) and the weekly update
11
+ * Drafted for you the drafts of today's morning prep run (GET /api/phone-day finished) and the weekly update; a draft the PM is done
12
+ * with ("Done with it" in the Finished Viewer, batch 18 item 2) leaves it
12
13
  * Can wait every other row that was "Your move" (tasks, brief items, Jira)
13
14
  * Now the phone's moment card (home-phone-card.js), open by default
14
15
  * Tomorrow after 17:00 only (canvas FmA5Evening, was More › End of the day): tomorrow's meetings (GET /api/phone-day tomorrow);
@@ -114,7 +115,7 @@ export function dayModel(M, D, R, now = Date.now(), o = {}) {
114
115
  const drafted = fin.filter((x) => x.status !== 'sent').length, sent = fin.filter((x) => x.status === 'sent').length;
115
116
  const chips = [prepped && plural(prepped, 'meeting prepped', 'meetings prepped'), drafted && plural(drafted, 'draft ready', 'drafts ready'), sent && sent + ' sent'].filter(Boolean);
116
117
 
117
- const calls = move.filter((r) => r.call), drafts = [...fin.map((x) => ({ fin: x })), ...move.filter((r) => r.kind === 'update').map((r) => ({ row: r }))];
118
+ const calls = move.filter((r) => r.call), drafts = [...fin.filter((x) => !x.seen).map((x) => ({ fin: x })), ...move.filter((r) => r.kind === 'update').map((r) => ({ row: r }))];
118
119
  const wait = move.filter((r) => !r.call && r.kind !== 'update');
119
120
  const misses = run ? (run.failed || []).map((f) => ({ id: f.id, title: f.title, why: f.error || '' })) : [];
120
121
  const blocked = calls.filter((r) => r.state === 'blocked');
@@ -217,14 +218,18 @@ export function nightHtml(Y) {
217
218
 
218
219
  /* 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) */
219
220
  const MARK2 = 'M2 12.5l4.5 4.5L15 8M9 15l2 2L22 7';
221
+ const SPARK = 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z';
220
222
  export const NEWS_SHOWN = 3;
221
223
  function newsRow(it, now) {
222
224
  const who = it.kind === 'task' ? (it.from || 'Someone') : (it.product || 'Claude');
223
225
  const when = it.at ? ago(new Date(it.at).toISOString(), now) : '';
224
- const head = it.title;
225
- const sub = 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(' · ')
226
+ const head = it.kind === 'task' ? String(it.title || '').replace(/^New task: /, '') : it.title;
227
+ // an overlap note is Claude's proposal (batch 18 item 2b): the ✦ tile and both initiatives by name, never an id
228
+ const sub = it.kind === 'overlap' ? [it.a && it.a.title, it.b && it.b.title].filter(Boolean).join(' and ') || 'Two open initiatives'
229
+ : it.kind === 'task' ? ['Given to you' + (it.from ? ' from ' + it.from : ''), it.due ? 'due ' + it.due : '', it.iniTitle ? 'filed under ' + it.iniTitle : ''].filter(Boolean).join(' · ')
226
230
  : ['Finished while you were away', it.target, when].filter(Boolean).join(' · ');
227
- 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>`;
231
+ const av = it.kind === 'overlap' ? `<span class="yd-av sp" aria-hidden="true">${svg(SPARK, 13, 2)}</span>` : `<span class="yd-av${it.kind === 'finished' ? ' b' : ''}" aria-hidden="true">${esc(initials(who))}</span>`;
232
+ return `<button type="button" class="yd-nw" data-yd="news" data-id="${esc(it.id)}"><i class="yd-nd" aria-hidden="true"></i>${av}<span class="yd-mt"><b>${esc(head)}</b><em>${esc(sub)}</em></span></button>`;
228
233
  }
229
234
  /** 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.
230
235
  * → a czSections row, or null when nothing is new and there is no digest (zero is silence). */