create-pmos 0.400.0 → 0.402.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 (57) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +226 -0
  8. package/workspace/board-shot.js +54 -0
  9. package/workspace/briefing-premium-board-test.js +23 -16
  10. package/workspace/briefing-premium-calendar-test.js +6 -3
  11. package/workspace/briefing-premium-sources-test.js +17 -10
  12. package/workspace/briefing-premium-test.js +41 -16
  13. package/workspace/changelog.json +24 -0
  14. package/workspace/fixtures/board-premium-facts.js +20 -3
  15. package/workspace/fixtures/briefing-premium-facts.js +18 -2
  16. package/workspace/fixtures/program-ascent.js +101 -0
  17. package/workspace/guide/home.md +15 -8
  18. package/workspace/guide/index.md +1 -0
  19. package/workspace/guide/programs.md +37 -0
  20. package/workspace/lib/briefing-premium-products.js +4 -4
  21. package/workspace/lib/briefing-premium.js +2 -2
  22. package/workspace/lib/core-docs.js +2 -2
  23. package/workspace/lib/programs.js +129 -0
  24. package/workspace/lib/route-modules.js +1 -0
  25. package/workspace/lib/routes-briefing-premium.js +1 -1
  26. package/workspace/lib/routes-programs.js +122 -0
  27. package/workspace/package-lock.json +2 -2
  28. package/workspace/package.json +1 -1
  29. package/workspace/premium-board-actions-test.js +1 -1
  30. package/workspace/premium-phone-card-test.js +6 -1
  31. package/workspace/premium-vw-cal-test.js +10 -4
  32. package/workspace/program-panel-test.js +143 -0
  33. package/workspace/public/pm/bd-acts.js +23 -14
  34. package/workspace/public/pm/bd-asks.js +89 -23
  35. package/workspace/public/pm/bd-prog-panel.js +451 -0
  36. package/workspace/public/pm/bd-prog.js +191 -0
  37. package/workspace/public/pm/bd-span.js +98 -15
  38. package/workspace/public/pm/bd-views.js +93 -29
  39. package/workspace/public/pm/cozy-board.css +226 -9
  40. package/workspace/public/pm/cozy-home.css +27 -1
  41. package/workspace/public/pm/cozy-panel.css +178 -0
  42. package/workspace/public/pm/cozy-today.css +190 -3
  43. package/workspace/public/pm/home-app.js +93 -26
  44. package/workspace/public/pm/home-chat.js +35 -32
  45. package/workspace/public/pm/home-data.js +8 -2
  46. package/workspace/public/pm/home-ini.js +1 -1
  47. package/workspace/public/pm/home-list.js +100 -24
  48. package/workspace/public/pm/home-today.js +138 -61
  49. package/workspace/public/pm/home-work.js +1 -3
  50. package/workspace/public/pm/premium-board.js +225 -57
  51. package/workspace/public/pm/premium-vw-item.css +6 -0
  52. package/workspace/public/pm/program-model.js +192 -0
  53. package/workspace/public/premium-board.html +4 -1
  54. package/workspace/test-files.json +1 -0
  55. package/workspace/test-lists/board-programs.json +9 -0
  56. package/workspace/test-lists/program-hierarchy.json +11 -0
  57. package/workspace/test-lists/program-panel.json +9 -0
@@ -75,10 +75,14 @@ const S = {
75
75
  doneOpen: false, sheet: false, rec: {}, pin: new Set(JSON.parse(store.get('pmos.home.pin') || '[]')),
76
76
  cardFold: store.get('pmos.home.cardfold') === '1', // the card's checklist folded to one line (AgInitSpec), kept in this browser
77
77
  // the one list (premium-uncovered-features): the filter, the picked product, which groups and initiatives are open, kept in this browser
78
- filter: 'today', product: store.get('pmos.home.product') || null, kidsOff: new Set(), rest: new Set(), tasks: new Set(), cap: false,
78
+ filter: 'today', product: store.get('pmos.home.product') || null, kidsOff: new Set(), rest: new Set(), tasks: new Set(), cap: false, day: false,
79
79
  pg: (() => { try { return JSON.parse(store.get('pmos.home.pg') || '{}') || {}; } catch { return {}; } })(),
80
80
  eodHidden: store.get('pmos.home.eod') === L.dayOf(), phoneChat: false,
81
81
  };
82
+ // every fold of the list is kept in this browser (HvAC: "every group can be hidden or shown, and the choice is remembered"): the groups in
83
+ // pmos.home.pg, an initiative's rows and its "N more" in pmos.home.kids
84
+ (() => { try { const k = JSON.parse(store.get('pmos.home.kids') || '{}') || {}; for (const [n, v] of [['on', S.kids], ['off', S.kidsOff], ['rest', S.rest], ['tasks', S.tasks]]) for (const x of k[n] || []) v.add(x); } catch { /* none kept */ } })();
85
+ const keepKids = () => store.set('pmos.home.kids', JSON.stringify({ on: [...S.kids], off: [...S.kidsOff], rest: [...S.rest], tasks: [...S.tasks] }));
82
86
  const toast = (t) => { const el = $('#toast'); el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
83
87
 
84
88
  /* ── reading ── */
@@ -91,20 +95,22 @@ async function getRetry(path, tries = 20) {
91
95
  return { ok: false, error: 'still reading' };
92
96
  }
93
97
  async function load() {
94
- const [brief, board, ses, desk, today, sch, work, day, rev] = await Promise.all([
98
+ const [brief, board, ses, desk, today, sch, work, day, rev, progs] = await Promise.all([
95
99
  getRetry('/api/briefing-premium' + wsQ()), getRetry('/api/board-premium' + wsQ() + boardQ(WS ? '&' : '?')), pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ()),
96
100
  pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()), pmGet('/api/my-work-premium' + wsQ()), pmGet('/api/phone-day'), pmGet('/api/home-review' + wsQ()),
101
+ pmGet('/api/programs'),
97
102
  ]);
98
103
  const D = S.D;
99
104
  D.brief = brief && brief.ok && brief.model ? brief.model : null;
100
105
  D.board = board && board.ok && board.model ? board.model : null;
101
- D.sessions = ses && Array.isArray(ses.sessions) ? ses.sessions : [];
106
+ D.sessions = H.homeSessions(ses && ses.sessions);
102
107
  D.desk = desk && desk.ok ? desk : null;
103
108
  D.today = today && today.ok ? today : null;
104
109
  D.schedules = sch && Array.isArray(sch.schedules) ? sch : null;
105
110
  D.work = work && work.ok && work.model ? work.model : null; // the PM's own list (GET /api/my-work-premium): the filters and "Not in an initiative"
106
111
  D.phoneDay = day && day.ok ? day : null; // what finished today, the recap and tomorrow (the end-of-day card, the Done filter)
107
112
  D.review = rev && rev.ok ? rev : null; // this week's review (GET /api/home-review)
113
+ D.programs = progs && progs.ok ? progs.programs : []; // programs above initiatives, across products (GET /api/programs)
108
114
  D.now = Date.now();
109
115
  D.err = [brief, board].filter((x) => !x || !x.ok).map((x) => (x && x.error) || 'the server did not answer');
110
116
  const rows = H.boardRows(D);
@@ -147,7 +153,7 @@ function poll() {
147
153
  pollT = setTimeout(async () => {
148
154
  if (!document.hidden) {
149
155
  const [ses, desk] = await Promise.all([pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ())]);
150
- if (ses && Array.isArray(ses.sessions)) S.D.sessions = ses.sessions;
156
+ if (ses && Array.isArray(ses.sessions)) S.D.sessions = H.homeSessions(ses.sessions);
151
157
  if (desk && desk.ok) S.D.desk = desk;
152
158
  S.D.now = Date.now();
153
159
  drawList(); drawTop();
@@ -202,16 +208,26 @@ function homeListHtml() {
202
208
  S.M = M;
203
209
  const R = L.reviewModel(S.D, NOW());
204
210
  // the first initiative where it is your turn shows what is under it, until the PM closes it
205
- const firstTurn = M.groups.filter((g) => g.kind === 'product').flatMap((g) => g.inis).find((x) => x.turn);
211
+ const firstTurn = M.groups.filter((g) => g.kind === 'product' || g.kind === 'program').flatMap((g) => g.inis).find((x) => x.turn);
206
212
  const open = (id) => S.kids.has(id) || (!!firstTurn && firstTurn.id === id && !S.kidsOff.has(id));
207
- const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.primary || M.products.length === 1 || (!!S.product && S.product === g.product.key));
208
- const nPick = M.products.length > 1 ? M.counts.products + ' products · ' + M.counts.initiatives + ' initiatives' : '';
209
- const pins = H.needsOf(S.D).filter((r) => S.pin.has(r.key)).length;
213
+ // a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
214
+ 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 || (!!S.product && !!g.product && S.product === g.product.key));
210
215
  return TD.listHtml(M, todayModel(), {
211
216
  sel: S.sel, isOpen: open, pOpen, restOpen: (k) => S.rest.has(k), cap: S.cap, tasksOpen: (k) => S.tasks.has(k), pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
212
- product: S.product, review: R, mic: canDictate(), sub: pins ? pins + ' pinned' : nPick || 'Each one sits under its initiative',
217
+ product: S.product, review: R, mic: canDictate(), phone: isPhone(), day: S.day,
213
218
  });
214
219
  }
220
+ /** Your day (HvAOpen): the sheet "Good morning" opens over the list. */
221
+ function dayHtml() { return S.day && !S.ini && S.M ? TD.dayHtml(S.M, todayModel(), L.reviewModel(S.D, NOW()), { sel: S.sel, now: NOW(), phone: isPhone() }) : ''; }
222
+ function day(on) {
223
+ S.day = !!on; drawList();
224
+ const f = $(on ? '#hmList .hv-sheet' : '#hmList [data-hm-day]'); if (f) f.focus();
225
+ }
226
+ /* the list's filter (HvACDesk): Today, Kept or Done, behind the icon in the list's top bar */
227
+ function filterMenu(b) {
228
+ const M = S.M || L.homeList(S.D, { now: NOW() });
229
+ menu(b, [{ key: 'today', label: 'Today' }].concat(M.filters).map((f) => ({ label: f.label, k: f.n ? String(f.n) : '', checked: S.filter === f.key, go: () => { S.filter = f.key; drawList(); const x = $('#hmList [data-hm-flt]'); if (x) x.focus(); } })), 'Show');
230
+ }
215
231
 
216
232
  /* ── the initiative card ── */
217
233
  function iniRowOf(id) { return H.boardRows(S.D).find((r) => r.id === id) || null; }
@@ -307,8 +323,8 @@ function elseHtml() {
307
323
  function drawList() {
308
324
  const el = $('#hmList');
309
325
  // the list column: the groups scroll; the Elsewhere card is the column's foot (AgInitSpec, AgInitPhone)
310
- let sc = el.querySelector(':scope > .hm-lsc'), ft = el.querySelector(':scope > .hm-lft');
311
- if (!sc || !ft) { el.innerHTML = '<div class="hm-lsc"></div><div class="hm-lft"></div>'; sc = el.firstElementChild; ft = el.lastElementChild; }
326
+ let sc = el.querySelector(':scope > .hm-lsc'), ft = el.querySelector(':scope > .hm-lft'), dy = el.querySelector(':scope > .hm-lday');
327
+ if (!sc || !ft || !dy) { el.innerHTML = '<div class="hm-lsc"></div><div class="hm-lft"></div><div class="hm-lday"></div>'; [sc, ft, dy] = el.children; }
312
328
  const html = S.ini ? iniListHtml() : homeListHtml();
313
329
  if (sc.__h !== html) {
314
330
  const st = sc.scrollTop, cap = sc.querySelector('#hmCap'), capV = cap ? cap.value : '', capF = !!cap && document.activeElement === cap;
@@ -318,10 +334,14 @@ function drawList() {
318
334
  }
319
335
  const fh = elseHtml();
320
336
  if (ft.__h !== fh) { ft.__h = fh; ft.innerHTML = fh; }
337
+ const dh = dayHtml();
338
+ if (dy.__h !== dh) { dy.__h = dh; dy.innerHTML = dh; dy.querySelectorAll('.hm-load i[data-f]').forEach((i) => i.style.setProperty('--bd-f', i.dataset.f)); }
339
+ document.body.classList.toggle('hm-dayon', !!dh);
321
340
  iniList(sc);
322
- // the first-run card after an import tops the list; the phone moment card sits after the groups
341
+ // the first-run card after an import tops the list. The phone moment card is not in the list: it is the detail of the greeting
342
+ // at the top, and opens in the Viewer when the greeting is pressed (testing fixes: in the list it took a screen of room)
323
343
  if (FST && sc.firstElementChild !== FST) sc.prepend(FST);
324
- if (PHC && sc.lastElementChild !== PHC.el) sc.append(PHC.el);
344
+ if (PHC && PHC.el.parentNode === sc) PHC.el.remove();
325
345
  document.body.classList.toggle('hm-folded', S.folded && !isPhone());
326
346
  document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
327
347
  }
@@ -334,7 +354,7 @@ function allRows() {
334
354
  const M = S.M || L.homeList(S.D, { now: NOW() });
335
355
  const add = (r) => { if (!r) return; out.push(r); (r.kids || []).forEach(add); };
336
356
  H.needsOf(S.D).forEach(add);
337
- for (const g of M.groups) { (g.flat || []).forEach(add); (g.inis || []).forEach(add); (g.rest || []).forEach(add); (g.rows || []).forEach(add); }
357
+ for (const g of M.groups) { (g.flat || []).forEach(add); (g.inis || []).forEach(add); (g.rest || []).forEach(add); (g.rows || []).forEach(add); (g.tasks || []).forEach(add); }
338
358
  if (M.list) M.list.rows.forEach(add);
339
359
  if (S.filter !== 'today') { const T = L.homeList(S.D, { now: NOW() }); T.groups.forEach((g) => { (g.rows || []).forEach(add); (g.inis || []).concat(g.rest || []).forEach(add); }); }
340
360
  if (S.lay) S.lay.groups.forEach((g) => g.rows.forEach(add));
@@ -372,7 +392,22 @@ const chat = mountChat($('#hmChat'), {
372
392
  wait: MORE.WAIT, // the Notes viewer only: the Home canvas does not draw it
373
393
  desk: () => !isPhone(),
374
394
  reopenViewer: () => reopenViewer(),
395
+ head: (t) => (isPhone() ? '' : TD.chatHeadHtml(chatHead(t))), // the phone names it in its top bar (#hmTop)
375
396
  });
397
+ /* The chat's header line on a desktop (HvACDesk): the open row's mark and title, and where it sits: its initiative with the stage track, or
398
+ * its program. Home's own chat names nothing. */
399
+ function chatHead(t) {
400
+ if (!t || t.key === 'chat:main' || !t.title || t.title === 'Reading') return null;
401
+ const r = S.sel ? rowById(S.sel) : null;
402
+ if (t.prog) return { row: r, title: t.title, scope: t.prog.title, prog: true };
403
+ const title = r && r.kind !== 'ini' ? r.name : t.title;
404
+ // the weekly update and the product's own chat sit in the product: its name, no stage track
405
+ if (t.ini === 'product' || (r && r.ini === 'product')) return { row: r, title, scope: H.productName(S.D) };
406
+ const ini = t.ini || (r && r.ini) || null;
407
+ const ir = ini ? rowById('i:' + ini) : null, b = ini ? iniRowOf(ini) : null;
408
+ const stage = (ir && ir.stage) || (b && b.stage) || '';
409
+ return { row: r || ir, title, scope: ini ? iniTitle(ini) : '', at: L.stageAt(stage), stage };
410
+ }
376
411
  function scopeItems() {
377
412
  return [{ label: 'All work', sub: 'Home', go: () => select(null) }, { label: H.productName(S.D) + ' · product', go: () => goIni('product') }]
378
413
  .concat(H.boardRows(S.D).map((r) => ({ label: r.title, sub: [r.lane, r.stage].filter(Boolean).join(' · '), go: () => goIni(r.id) })));
@@ -482,6 +517,15 @@ function updateTarget() {
482
517
  context: 'The weekly update draft for ' + H.productName(S.D) + ':\n' + H.updateText(U, H.productName(S.D)) + '\nRecipients: ' + (U.to.join(', ') || 'none yet') + '. You can change the draft; the PM sends it from their own mail.',
483
518
  placeholder: 'Tell Communicator what to change', also: null };
484
519
  }
520
+ /** A program's conversation (?ask=program:<id>, a program task's row): Claude with the program as its scope. task names the open row. */
521
+ function programTarget(id, task) {
522
+ const pr = (S.D.programs || []).find((p) => p && p.id === id) || { id, title: (P.get('label') || '').slice(0, 80) || id };
523
+ const inis = (pr.members || []).map((m) => m && m.initiative).filter(Boolean);
524
+ return { key: 'chat:program:' + id, ws: WS || undefined, title: task ? task.name : pr.title, sub: task ? pr.title : 'Program', prog: { id, title: pr.title },
525
+ scope: { text: pr.title, icon: TD.P.layers }, rich: false, role: CLAUDE, placeholder: 'Message Claude about ' + pr.title,
526
+ empty: 'Ask about ' + pr.title + '. Claude reads the program and its initiatives in a real Claude Code session.',
527
+ context: 'Program ' + pr.title + ' (' + id + ')' + (inis.length ? ', with the initiatives ' + inis.join(', ') : '') + '.' + (task ? ' The PM opened its task "' + task.name + '"' + (task.hint ? ' (' + task.hint + ')' : '') + '.' : ''), also: null };
528
+ }
485
529
  function homeTarget() {
486
530
  return { key: 'chat:main', ws: WS || undefined, title: 'Home', scope: { text: 'All work', icon: I.home }, rich: false, placeholder: 'Message Claude', role: CLAUDE,
487
531
  empty: 'Ask anything about your work. Claude reads your repositories and works in a real Claude Code session.', also: alsoOf(null) };
@@ -504,6 +548,7 @@ function select(id, o = {}) {
504
548
  if (r.kind === 'update') { openTarget(updateTarget()); if (!o.keepViewer) openUpdateViewer(); }
505
549
  else if (r.kind === 'need' && r.row) { openTarget(needTarget(r)); if (!o.keepViewer) openNeedViewer(r); }
506
550
  else if (r.kind === 'session' || r.needSession) { const s = S.D.sessions.find((x) => x.id === r.sid); if (s) { openTarget(sessionTarget(s)); if (isMetricsSession(s) && !o.keepViewer && !isPhone()) openMetricsViewer(); } }
551
+ else if (r.kind === 'ptask') { S.phoneChat = isPhone(); openTarget(programTarget(r.program, r)); }
507
552
  else if (r.kind === 'task') { openBoardTask(r.task); }
508
553
  else if (r.kind === 'item') { import('./home-work.js').then((M) => M.openWorkItem(r.key)); }
509
554
  else if (r.kind === 'mention') { openMention(r); }
@@ -532,7 +577,8 @@ function syncUrl() {
532
577
  ['ini', 'open', 'item', 'session', 'ask', 'say', 'q', 'about', 'label', 'meeting', 'id', 'view'].forEach((k) => { if (!(k === 'open' && /^(report|chart|dashboard):/.test(q.get('open') || ''))) q.delete(k); });
533
578
  if (S.ini) q.set('ini', S.ini);
534
579
  const r = S.sel ? rowById(S.sel) : null;
535
- if (r && r.key && r.kind !== 'session') q.set('open', r.key); else if (r && r.sid) q.set('session', r.sid);
580
+ if (r && r.kind === 'ptask') q.set('item', r.id); // a program task: pt:<program>:<key>, the link the program panel makes
581
+ else if (r && r.key && r.kind !== 'session') q.set('open', r.key); else if (r && r.sid) q.set('session', r.sid);
536
582
  const s = q.toString();
537
583
  history.replaceState(null, '', location.pathname + (s ? '?' + s : ''));
538
584
  }
@@ -616,6 +662,7 @@ async function checkRow(id) {
616
662
  let res = null;
617
663
  if (r.kind === 'task' && r.task) res = await pmPost('/api/boards/tasks/state', { ws: r.task.ws || boardWs(), board: r.task.board || boardId(), task: r.task.uid, state: 'Done' });
618
664
  else if (r.kind === 'item' && r.item) res = await pmPost('/api/pm-items/done', { id: r.item.id });
665
+ else if (r.kind === 'ptask') res = await pmPost('/api/programs/task-done', { ws: r.ws, program: r.program, key: r.key, done: true });
619
666
  else return;
620
667
  if (!res || !res.ok) { toast((res && res.error) || 'Not marked done.'); return; }
621
668
  toast('Done.');
@@ -921,6 +968,15 @@ async function openMeeting(m) {
921
968
  if (typeof v.openMeeting === 'function') return v.openMeeting(m.note ? { note: m.note } : m, { ws: deskWs() });
922
969
  try { const M = await import('./premium-vw-mtg.js'); return M.openMeeting(m.note ? { note: m.note } : m, { ws: deskWs() }); } catch { return VW.placeholder('Meeting', { icon: 'meet' }); }
923
970
  }
971
+ /** A phone: the greeting's detail, the moment card of the day (home-phone-card.js) in the Viewer, with the calendar one press on. */
972
+ function openMoment() {
973
+ VW.open({ id: 'moment', kind: 'Your day', title: L.greetWord(), icon: 'cal', render: (body) => {
974
+ body.append(PHC.el);
975
+ body.insertAdjacentHTML('beforeend', '<p class="ut-acts hm-mcal"><button type="button" class="ut-btn sm soft" data-hm-mcal>Open the calendar</button></p>');
976
+ body.onclick = (e) => { if (e.target.closest('[data-hm-mcal]')) openCalendar(); };
977
+ PHC.read(true);
978
+ } });
979
+ }
924
980
  async function openCalendar() {
925
981
  const v = await V();
926
982
  if (typeof v.openCalendar === 'function') return v.openCalendar({ ws: deskWs(), view: 'day' });
@@ -1051,6 +1107,8 @@ $('#hmNeeds').onclick = () => sheet(!S.sheet);
1051
1107
  // a phone: the back bar of a conversation returns to the list, which is the page (HmPhone2)
1052
1108
  // My work's "Weekly review" (home-work.js) asks Home, which holds the data the review reads
1053
1109
  addEventListener('hm:review', (e) => { e.preventDefault(); openReviewVw(); });
1110
+ // 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
1111
+ addEventListener('hm:day', () => { if (isPhone() && PHC) openMoment(); });
1054
1112
  $('#hmBack').onclick = () => { S.phoneChat = false; S.sel = null; drawList(); syncUrl(); const f = $('#hmList .hm-rm'); if (f) f.focus(); };
1055
1113
  $('#hmMoreP').onclick = (e) => moreMenu(e.currentTarget);
1056
1114
  $('#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
@@ -1059,22 +1117,25 @@ $('#hmDesk').onclick = (e) => { if (S.sheet && e.target === $('#hmDesk')) sheet(
1059
1117
  $('#hmList').onclick = (e) => { // delegated: every press on the list is a <button>
1060
1118
  const b = e.target.closest('button'); if (!b) return;
1061
1119
  const d = b.dataset;
1062
- if (d.hmSel) { select(d.hmSel); return; }
1120
+ if (d.hmSel) { if (S.day) S.day = false; select(d.hmSel); return; }
1121
+ if ('hmDay' in d) { day(!S.day); return; }
1122
+ if ('hmDayx' in d) { day(false); return; }
1123
+ if ('hmFlt' in d) { filterMenu(b); return; }
1124
+ if (d.hmProg) { location.href = '/premium-board.html?program=' + encodeURIComponent(d.hmProg) + wsQ('&'); return; } // the program panel (the Board opens it)
1063
1125
  if (d.hmKids) { // the chevron of an initiative: what sits under it shows or hides
1064
1126
  if (b.getAttribute('aria-expanded') === 'true') { S.kids.delete(d.hmKids); S.kidsOff.add(d.hmKids); } else { S.kids.add(d.hmKids); S.kidsOff.delete(d.hmKids); }
1065
- drawList(); const f = $(`#hmList [data-hm-kids="${CSS.escape(d.hmKids)}"]`); if (f) f.focus(); return;
1127
+ keepKids(); drawList(); const f = $(`#hmList [data-hm-kids="${CSS.escape(d.hmKids)}"]`); if (f) f.focus(); return;
1066
1128
  }
1067
1129
  if (d.hmPg) { const open = b.getAttribute('aria-expanded') === 'true'; S.pg[d.hmPg] = !open; store.set('pmos.home.pg', JSON.stringify(S.pg)); drawList(); const f = $(`#hmList [data-hm-pg="${CSS.escape(d.hmPg)}"]`); if (f) f.focus(); return; }
1068
1130
  if ('hmProd' in d) { goIni('product'); return; }
1069
- if (d.hmTasks) { if (S.tasks.has(d.hmTasks)) S.tasks.delete(d.hmTasks); else S.tasks.add(d.hmTasks); drawList(); return; }
1070
- if (d.hmRest) { if (S.rest.has(d.hmRest)) S.rest.delete(d.hmRest); else S.rest.add(d.hmRest); drawList(); return; }
1071
- if (d.hmFilter) { S.filter = d.hmFilter; drawList(); const f = $(`#hmList [data-hm-filter="${d.hmFilter}"]`); if (f) f.focus(); return; }
1131
+ if (d.hmTasks) { if (S.tasks.has(d.hmTasks)) S.tasks.delete(d.hmTasks); else S.tasks.add(d.hmTasks); keepKids(); drawList(); return; }
1132
+ if (d.hmRest) { if (S.rest.has(d.hmRest)) S.rest.delete(d.hmRest); else S.rest.add(d.hmRest); keepKids(); drawList(); return; }
1133
+ if (d.hmFilter) { S.filter = S.filter === d.hmFilter ? 'today' : d.hmFilter; drawList(); const f = $(`#hmList [data-hm-filter="${d.hmFilter}"]`); if (f) f.focus(); return; }
1072
1134
  if (d.hmCheck) { checkRow(d.hmCheck); return; }
1073
- if ('hmReview' in d) { openReviewVw(); return; }
1074
- if ('hmFocus' in d) { import('./home-work.js').then((M) => M.openFocus()); return; }
1135
+ if ('hmReview' in d) { if (S.day) day(false); openReviewVw(); return; }
1075
1136
  if ('hmPick' in d) { pickProduct(b); return; }
1076
1137
  if ('hmCapmic' in d) { const i = $('#hmCap'); if (i) capMic(i, b); return; }
1077
- if (d.hmTc) { todayPress(d.hmTc, b); return; }
1138
+ if (d.hmTc) { if (S.day && d.hmTc === 'cal') day(false); todayPress(d.hmTc, b); return; }
1078
1139
  if (d.hmEnd) { endRow(d.hmEnd); return; }
1079
1140
  if (d.hmGroup) { if (S.shut.has(d.hmGroup)) S.shut.delete(d.hmGroup); else S.shut.add(d.hmGroup); store.set('pmos.home.shut', JSON.stringify([...S.shut])); drawList(); return; }
1080
1141
  if ('hmAllneeds' in d) { S.allNeeds = !S.allNeeds; drawList(); return; }
@@ -1093,7 +1154,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1093
1154
  if ('hmElse' in d) { const f = S.lay && S.lay.elsewhere && S.lay.elsewhere.first; goHome(); if (f) select(f.id); return; }
1094
1155
  if ('hmPerson' in d) addPerson();
1095
1156
  };
1096
- $('#hmList').addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.id === 'hmCap' && S.cap) { e.stopPropagation(); S.cap = false; drawList(); } });
1157
+ $('#hmList').addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.id === 'hmCap' && S.cap) { e.stopPropagation(); S.cap = false; drawList(); } else if (e.key === 'Escape' && S.day) { e.stopPropagation(); day(false); } });
1097
1158
  $('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
1098
1159
  if (e.target.id !== 'hmCapF') return;
1099
1160
  e.preventDefault();
@@ -1117,7 +1178,7 @@ function capMic(input, b) {
1117
1178
  /* the Today card's presses (HmDay, HmMic): the calendar, the meeting's prep, the live meeting, the recording, the end of the day */
1118
1179
  async function todayPress(k, b) {
1119
1180
  const T = todayModel();
1120
- if (k === 'cal') { openCalendar(); return; }
1181
+ if (k === 'cal') { if (isPhone() && PHC) openMoment(); else openCalendar(); return; }
1121
1182
  if ((k === 'prep' || k === 'open') && T.meeting) { openMeeting(T.meeting); return; }
1122
1183
  if (k === 'record') { MORE.openRecorder().then(() => drawList()); return; }
1123
1184
  if (k === 'hl') { const r = REC && await REC.highlight(); toast(r && r.ok ? 'Highlighting the last 30 seconds and the next ones.' : (r && r.error) || 'The highlight did not start.'); return; }
@@ -1179,8 +1240,14 @@ load().then(() => {
1179
1240
  const asked = !ask ? '' : /^board:/.test(ask) ? ask : /^(insights|verdict)$/.test(ask) ? 'ins:' + ask : 'init:' + ask;
1180
1241
  const about = KEY.test(P.get('about') || '') ? P.get('about') : KEY.test(asked) ? asked : null;
1181
1242
  if (isPhone() && ((open && !blockOpen) || sid || about)) { S.phoneChat = true; drawList(); } // the conversation the address names, not the list
1182
- if (open && !blockOpen) { const r = allRows().find((x) => x.key === open); if (r) select(r.id); else if (KEY.test(open)) openTarget({ ...homeTarget(), key: open, title: open }); }
1243
+ if (open && !blockOpen) {
1244
+ // ?item=pt:<program>:<key> (the program panel's link to a program task) names the row by its id; its program group opens to show it
1245
+ const r = allRows().find((x) => x.key === open || (/^pt:/.test(open) && x.id === open));
1246
+ if (r && r.kind === 'ptask') { S.pg['g:' + r.program] = true; drawList(); }
1247
+ if (r) select(r.id); else if (KEY.test(open)) openTarget({ ...homeTarget(), key: open, title: open });
1248
+ }
1183
1249
  else if (sid) { const s = S.D.sessions.find((x) => x.id === sid); if (s) { S.sel = 's:' + s.id; openTarget(sessionTarget(s)); drawList(); } else { openTarget(homeTarget()); toast('That session is not on this machine.'); } }
1250
+ else if (/^program:[A-Za-z0-9][A-Za-z0-9._-]{0,100}$/.test(ask)) openTarget(programTarget(ask.slice(8))); // Ask in Home from the program panel
1184
1251
  else if (about && /^init:/.test(about) && iniRowOf(about.slice(5))) goIni(about.slice(5));
1185
1252
  else if (about) openTarget({ ...homeTarget(), key: about, title: (P.get('label') || '').slice(0, 80) || about });
1186
1253
  else if (S.ini && P.get('view') === 'metrics') goIni(S.ini).then(() => openMetrics()); // ?view=metrics: the metrics review, as its Open in a new tab names it
@@ -1,11 +1,11 @@
1
1
  /* pm/home-chat.js — Home's chat column (initiative premium-agreed-design, Home; mockup Main.dc.html section "Conversation", AgChat*).
2
2
  *
3
- * No header on the docked desk. The stream: the role's avatar and name over each agent message with Copy, Retry and Make a work-item; the
3
+ * On a desktop a header line names what is open: its mark, its title and the chip of where it sits (HvACDesk; host.head(t) draws it).
4
+ * Home's own chat has none. The stream: the role's avatar and name over each agent message with Copy, Retry and Make a work-item; the
4
5
  * PM's bubbles with "You · HH:MM"; "Worked …" folds (under the message that asks, while it asks); a Today divider; "New since you left"; "N earlier messages · show"; the agent's step
5
6
  * checklist while it works (from its own TodoWrite list); a permission card with the change before → after, Allow and Deny. Over the box: the
6
- * run strip with Stop, and "Also waiting on you". Two boxes: the basic one on Home (In: chip above, → send, the hint under it) and the rich
7
- * one in an initiative (+, /, @, the In:/To: chip, the key hint, ↑ send). The + menu holds Attach a file, and the Notes and the terminal of
8
- * the conversation.
7
+ * run strip with Stop, and "Also waiting on you". One box for every conversation (+, /, @ in an initiative, the In:/To: chip, the key hint,
8
+ * ↑ send). The + menu holds Attach a file, the Notes and the terminal of the conversation, and Link to an initiative for a loose session.
9
9
  * The mic is part of the input (canvas HmMic): press it and speak, the words appear as text in the box with a small blue dot while it
10
10
  * listens, press it again to stop, edit, send. On a phone it opens the "Speak to Claude" sheet (HmPhone): Discard, or stop and send.
11
11
  * Nothing is saved as audio (home-dictate.js). A card the target brings (intro.card, the decision card of HmDecide) draws under the intro.
@@ -16,7 +16,7 @@
16
16
  * target: { key?, sid?, title, scope: { text, icon, loose }, role: { name, initial }, intro?: { role, text, at, pills: [{ label, primary, go }] },
17
17
  * ini?, rich, also?: { text, go } }
18
18
  * host: { esc, toast, pmGet, pmPost, roles(), seen(key), markSeen(key), onScope(btn), onLink(btn), onTo(btn), workItem(text, target),
19
- * viewerClosed(), reopenViewer() } */
19
+ * viewerClosed(), reopenViewer(), head(target) } */
20
20
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
21
21
  import { streamOf, runOf, roleOf, tintOf, hm } from './home-data.js';
22
22
  import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches, loadSlash } from './goal-chat.js';
@@ -49,11 +49,14 @@ export function mountChat(el, host) {
49
49
  const esc = host.esc;
50
50
  const C = { t: null, th: null, conv: null, timer: null, show: 12, open: new Set(), seq: 0, sending: false, files: [], seenAt: null, lastKey: null, picked: {}, auto: { key: null, ctx: new Set(), rep: null, goal: null }, slashAt: 0 };
51
51
  el.innerHTML = `<button type="button" class="hm-reopen" id="hmReopen" aria-label="Open the Viewer" title="Open the Viewer" hidden>${PANE}</button>`
52
- + '<div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
53
- const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen');
52
+ + '<div class="hm-chd" id="hmCh" hidden></div><div class="hm-log" id="hmLog" role="log" aria-live="polite"></div><div class="hm-foot" id="hmFoot"></div>';
53
+ const log = el.querySelector('#hmLog'), foot = el.querySelector('#hmFoot'), reopen = el.querySelector('#hmReopen'), head = el.querySelector('#hmCh');
54
54
  loadSlash(host.pmGet).then(() => { if (el.querySelector('#hmSlash:not([hidden])')) drawSlash(); });
55
55
  // when a hidden log is shown (the phone's chat over the list), a jump still owed is made then
56
- if (typeof ResizeObserver === 'function') new ResizeObserver(() => { if (C.jump && log.clientHeight) { log.scrollTop = log.scrollHeight; if (C.conv) C.jump = false; } }).observe(log);
56
+ // On a phone the chat is the page: the log grows and the page scrolls, so "the end" is the page's end (testing fixes: a chat opened at its oldest message)
57
+ const pageScrolls = () => log.scrollHeight <= log.clientHeight + 1;
58
+ const toEnd = () => { log.scrollTop = log.scrollHeight; if (log.clientHeight && pageScrolls()) { const se = document.scrollingElement || document.documentElement; se.scrollTop = se.scrollHeight; } };
59
+ if (typeof ResizeObserver === 'function') new ResizeObserver(() => { if (C.jump && log.clientHeight) { toEnd(); if (C.conv) C.jump = false; } }).observe(log);
57
60
  reopen.onclick = () => host.reopenViewer();
58
61
  // the foot's height, for the place menu's button on a phone: it sits just above the box and its bars (cozy-home.css --hm-foot-h)
59
62
  if (typeof ResizeObserver === 'function') new ResizeObserver(() => document.body.style.setProperty('--bd-hmfoot', Math.round(foot.getBoundingClientRect().height) + 'px')).observe(foot);
@@ -172,7 +175,8 @@ export function mountChat(el, host) {
172
175
  R.waiting = !!C.conv && !C.conv.ask && C.conv.turn !== 'agent' && C.conv.turn !== 'tool';
173
176
  const ctx = new Map(turnsOf(msgs, R.waiting || (C.conv && C.conv.state === 'ended')).filter((x) => x.done).map((x) => [x.at, x.items]));
174
177
  R.chips = (mi) => (ctx.get(mi) ? chipsOf(ctx.get(mi)) : '');
175
- const atEnd = log.scrollHeight - log.scrollTop - log.clientHeight < 80;
178
+ const se = document.scrollingElement || document.documentElement;
179
+ const atEnd = pageScrolls() ? se.scrollHeight - se.scrollTop - innerHeight < 80 : log.scrollHeight - log.scrollTop - log.clientHeight < 80;
176
180
  const goal = C.th && C.th.goal;
177
181
  let html = (t.intro && !(t.intro.onlyEmpty && items.length) ? introHtml(t.intro) : '') + items.map((it, i) => msgHtml(it, i, R)).join('') + (goalProgressHtml(goal) ? goalChipHtml(goal) : '') + liveHtml(R) + askHtml(R) + queuedHtml();
178
182
  if (C.th && C.th.working) html += `<p class="hm-note" role="status">The agent is answering. You can write again when it has.</p>`;
@@ -182,9 +186,12 @@ export function mountChat(el, host) {
182
186
  C.items = items;
183
187
  // a session opens at its latest message: the jump waits until the conversation is read and the log is shown (on a phone the chat
184
188
  // can be drawn while hidden, where scrollTop does nothing and the session then opened at the top)
185
- if (atEnd || C.jump) { log.scrollTop = log.scrollHeight; if (C.conv && log.clientHeight) C.jump = false; }
189
+ if (atEnd || C.jump) { toEnd(); if (C.conv && log.clientHeight) C.jump = false; }
186
190
  drawFoot(R);
187
191
  reopen.hidden = !host.viewerClosed();
192
+ // the header line over the conversation on a desktop (HvACDesk): what is open and where it sits; Home's own chat has none
193
+ const hh = host.head ? host.head(t) : '';
194
+ put(head, hh); head.hidden = !hh; el.classList.toggle('hm-has-ch', !!hh);
188
195
  // the PM has seen what is here now
189
196
  const lastAt = msgs.length ? msgs[msgs.length - 1].at : null;
190
197
  if (t.key && lastAt && (!C.marked || C.marked < lastAt)) { C.marked = lastAt; host.markSeen(t.key); }
@@ -274,27 +281,23 @@ export function mountChat(el, host) {
274
281
  const mic = canDictate() ? `<button type="button" class="ut-mic${on ? ' on' : ''}" data-hm-mic aria-pressed="${on}" aria-label="${on ? 'Stop listening' : C.spoke ? 'Speak more' : 'Speak instead of typing'}" title="${on ? 'Stop listening' : 'Speak instead of typing'}">${SVG(on ? SQ : MIC, on ? 12 : 18)}</button>` : '';
275
282
  const dot = on ? '<span class="ut-live" role="status"><span class="ut-rec b" aria-hidden="true"></span><span class="vh">Listening</span></span>' : '';
276
283
  const attach = t.key ? '<button type="button" role="menuitem" data-hm-file><b>Attach a file</b><em>Or paste or drop it on the conversation</em></button>' : '';
277
- const addOpen = !!C.addOpen && !!(attach || notesBtn || term);
278
- const add = attach || notesBtn || term ? `<span class="hm-mw hm-addw"><button type="button" class="hm-tool" id="hmAdd" data-hm-add aria-haspopup="menu" aria-expanded="${addOpen}" aria-label="${t.key ? 'Attach a file, notes and more' : 'More'}" title="${t.key ? 'Attach a file' : 'More'}">${SVG(PLUS)}</button>`
279
- + `<span class="hm-pmenu hm-addm" role="menu" aria-label="Add"${addOpen ? ' data-esc-layer' : ' hidden'}>${attach}${notesBtn}${term}</span>${t.key ? '<input type="file" id="hmFile" multiple hidden>' : ''}</span>` : '';
280
- let html;
281
- if (t.rich) {
282
- const wait = C.conv && C.conv.ask && t.also ? `<button type="button" class="hm-chip" data-hm-also><i class="dot" aria-hidden="true"></i><span>1 more next step</span></button>` : '';
283
- const to = t.to && !wait ? `<button type="button" class="hm-chip to" data-hm-to aria-label="Who reads this: ${esc(t.to.name)}. Change">${avHtml(t.to, 20)}<span>To: ${esc(t.to.name)}</span></button>` : '';
284
- const scope = !to && !wait ? `<button type="button" class="hm-chip" data-hm-scope aria-label="Where this goes: ${esc(sc.text)}. Change" title="Where this goes: ${esc(sc.text)}">${SVG(sc.icon, 14)}<span>In: ${esc(sc.text)}</span></button>` : '';
285
- html = `${also}${strip}<form class="hm-box${on ? ' ut-on' : ''}" id="hmForm">${dot}<textarea id="hmIn" rows="1" aria-label="A message for ${esc(R.role.name)}" placeholder="${esc(ph)}"></textarea>`
286
- + `<div class="hm-tb">${add}`
287
- + `<button type="button" class="hm-tool" data-hm-slash aria-label="Commands" title="Commands"><b>/</b></button><button type="button" class="hm-tool" data-hm-at aria-label="Choose which conversation reads this" title="Send to another session of this initiative"><b>@</b></button>`
288
- + to + wait + scope + `<span class="sp"></span>${host.viewerClosed() ? '<span class="hm-key">Enter sends · Shift+Enter for a new line</span>' : ''}`
289
- + `${mic}<button type="submit" class="hm-send" aria-label="Send" title="Send">${SVG(UP, 18)}</button></div>`
290
- + filesRow()
291
- + '</form>';
292
- } else {
293
- html = `${also}${strip}<div class="hm-scope"><button type="button" class="hm-chip${sc.loose ? ' loose' : ''}" data-hm-scope aria-label="Where this goes: ${esc(sc.text)}. Change" title="Where this goes: ${esc(sc.text)}">${SVG(sc.icon, 14)}<span>In: ${esc(sc.text)}</span>${SVG(DOWN, 12)}</button>`
294
- + (sc.loose && t.sid ? '<button type="button" class="hm-link" data-hm-link>Link to an initiative</button>' : '') + `<span class="sp"></span>${add}</div>`
295
- + filesRow() + `<form class="hm-basic${on ? ' ut-on' : ''}" id="hmForm">${dot}<textarea id="hmIn" rows="1" aria-label="A message for Claude" placeholder="${esc(ph)}"></textarea>${mic}<button type="submit" class="hm-go" aria-label="Send to Claude" title="Send">${SVG(ARROW, 18)}</button></form>`
296
- + '<p class="hm-hint">It works in a real Claude Code session: it can read, change files, run commands and take slash commands.</p>';
297
- }
284
+ // One box everywhere (testing fixes: a loose chat and an initiative's chat drew two different boxes): +, / and @ (in an initiative), the
285
+ // To: or In: chip, the mic and ↑ send. A loose session's "Link to an initiative" is in the + menu, and no hint line repeats under the box.
286
+ const link = sc.loose && t.sid ? '<button type="button" role="menuitem" data-hm-link><b>Link to an initiative</b><em>Move this chat under one</em></button>' : '';
287
+ const addOpen = !!C.addOpen && !!(attach || notesBtn || term || link);
288
+ const add = attach || notesBtn || term || link ? `<span class="hm-mw hm-addw"><button type="button" class="hm-tool" id="hmAdd" data-hm-add aria-haspopup="menu" aria-expanded="${addOpen}" aria-label="${t.key ? 'Attach a file, notes and more' : 'More'}" title="${t.key ? 'Attach a file' : 'More'}">${SVG(PLUS)}</button>`
289
+ + `<span class="hm-pmenu hm-addm" role="menu" aria-label="Add"${addOpen ? ' data-esc-layer' : ' hidden'}>${attach}${notesBtn}${term}${link}</span>${t.key ? '<input type="file" id="hmFile" multiple hidden>' : ''}</span>` : '';
290
+ const wait = C.conv && C.conv.ask && t.also ? `<button type="button" class="hm-chip" data-hm-also><i class="dot" aria-hidden="true"></i><span>1 more next step</span></button>` : '';
291
+ const to = t.to && !wait ? `<button type="button" class="hm-chip to" data-hm-to aria-label="Who reads this: ${esc(t.to.name)}. Change">${avHtml(t.to, 20)}<span>To: ${esc(t.to.name)}</span></button>` : '';
292
+ const scope = !to && !wait ? `<button type="button" class="hm-chip${sc.loose ? ' loose' : ''}" data-hm-scope aria-label="Where this goes: ${esc(sc.text)}. Change" title="Where this goes: ${esc(sc.text)}">${SVG(sc.icon, 14)}<span>In: ${esc(sc.text)}</span></button>` : '';
293
+ const at = t.ini ? '<button type="button" class="hm-tool" data-hm-at aria-label="Choose which conversation reads this" title="Send to another session of this initiative"><b>@</b></button>' : '';
294
+ const html = `${also}${strip}<form class="hm-box${on ? ' ut-on' : ''}" id="hmForm">${dot}<textarea id="hmIn" rows="1" aria-label="A message for ${esc(R.role.name)}" placeholder="${esc(ph)}"></textarea>`
295
+ + `<div class="hm-tb">${add}`
296
+ + `<button type="button" class="hm-tool" data-hm-slash aria-label="Commands" title="Commands"><b>/</b></button>${at}`
297
+ + to + wait + scope + `<span class="sp"></span>${host.viewerClosed() ? '<span class="hm-key">Enter sends · Shift+Enter for a new line</span>' : ''}`
298
+ + `${mic}<button type="submit" class="hm-send" aria-label="Send" title="Send">${SVG(UP, 18)}</button></div>`
299
+ + filesRow()
300
+ + '</form>';
298
301
  if (foot.__h !== html) {
299
302
  const focused = document.activeElement && document.activeElement.id === 'hmIn';
300
303
  foot.__h = html; foot.innerHTML = html;
@@ -400,7 +403,7 @@ export function mountChat(el, host) {
400
403
  if ('hmAlso' in d) { if (C.t.also && C.t.also.go) C.t.also.go(); return; }
401
404
  if ('hmNotes' in d) { openNotesHere(); return; }
402
405
  if ('hmScope' in d) { host.onScope(b); return; }
403
- if ('hmLink' in d) { host.onLink(b, C.t); return; }
406
+ if ('hmLink' in d) { host.onLink(foot.querySelector('#hmAdd') || b, C.t); return; } // the + menu has closed: the list opens from the +
404
407
  if ('hmTo' in d || 'hmAt' in d) { host.onTo(b, C.t); return; }
405
408
  if ('hmSlash' in d) { const ta = foot.querySelector('textarea'); if (!ta.value.startsWith('/')) ta.value = '/' + ta.value; ta.focus(); drawSlash(); return; }
406
409
  if (d.hmUnfile) {
@@ -60,8 +60,14 @@ export function sessionRow(s, roles) {
60
60
  const st = stateOf(s);
61
61
  const name = s.hx && s.hx.title ? s.hx.title : s.name || 'Session';
62
62
  return { id: 's:' + s.id, kind: 'session', sid: s.id, key: keyOfSession(s), ini: iniOfSession(s), name, state: st, initial: role.initial, role,
63
- hint: role.name + ' · ' + (s.label || (st === 'working' ? 'Running' : st === 'needs' ? 'Ready for you' : 'Idle')), icon: 'chat', created: s.created || '' };
63
+ hint: role.name, icon: 'chat', created: s.created || '' }; // the state is the dot beside the row, not a word (testing fixes)
64
64
  }
65
+ /** The sessions as Home reads them. A session PMOS started (a skill, a background job) reads 'needs' as soon as its prompt is done:
66
+ * its turn ending asks nothing of the PM, so it is a finished run, quiet, and never a row that waits on the PM (testing fixes).
67
+ * A permission prompt ('blocked') still is. */
68
+ // A session PMOS started itself shows on Home only while it works or asks the PM something (a permission or a question): one that
69
+ // finished its prompt is not shown at all (testing fixes; Wawan on the canvas, 2026-10-23)
70
+ export const homeSessions = (list) => (Array.isArray(list) ? list : []).filter((s) => !(s && s.automatic && ['needs', 'quiet', 'exited'].includes(s.shown) && !s.ask));
65
71
 
66
72
  /* ── needs you ── */
67
73
  const NEED_ICON = { decision: 'gate', blocked: 'warn', waited: 'clock', src: 'doc', ev: 'gate' };
@@ -81,7 +87,7 @@ export function needsOf(D) {
81
87
  const P = (D.desk && D.desk.product) || {}, wk = weekOf(D.now || Date.now());
82
88
  if (!(P.sent || []).some((x) => x.week === wk.iso)) {
83
89
  const rt = nextRoutine(D, D.now || Date.now(), /comm|update|weekly|status|stakeholder/i);
84
- rows.push({ id: 'n:update', kind: 'update', key: UPDATE_KEY, ini: 'product', name: 'Weekly update · ready to send', hint: 'Communicator · ' + (rt ? 'goes out ' + rt.when : 'send it when it reads right'), state: 'needs', icon: 'doc', initialRole: 'Co' });
90
+ rows.push({ id: 'n:update', kind: 'update', key: UPDATE_KEY, ini: 'product', name: 'Weekly update is ready to send', hint: 'Communicator · ' + (rt ? 'goes out ' + rt.when : 'send it when it reads right'), state: 'needs', icon: 'doc', initialRole: 'Co' });
85
91
  }
86
92
  }
87
93
  return rows;
@@ -255,7 +255,7 @@ function docRowHtml(d, cur, later) {
255
255
  const meta = [d.when, d.by, d.link ? d.link.kind : ''].filter(Boolean).join(' · ') || d.what;
256
256
  return `<div class="hi-drow${d.look ? ' look' : ''}" data-ov-doc="${esc(d.key)}">`
257
257
  + `<button type="button" class="hi-dmain" ${open} aria-label="${d.path ? 'Open ' : ''}${esc(d.title)}"><span class="hi-dic">${SVG(I.doc, 16)}</span><span class="hi-dtx"><b>${esc(d.title)}</b> <span class="hi-k">· ${esc(d.kind)}${d.core ? ' · core' : ''}</span><em>${esc(meta)}</em>${d.link ? `<small>${esc(d.link.kind + ': ' + d.link.url)}</small>` : ''}</span></button>`
258
- + (d.act && d.act.kind === 'draft' && !d.running && d.st === 'missing' ? `<button type="button" class="hi-btn sm" data-ov-draft="${esc(d.key)}">Draft it</button>` : `<span class="hi-pill ${pc}">${esc(pt)}</span>`) + '</div>';
258
+ + (d.act && d.act.kind === 'draft' && !d.running && !d.path && d.st !== 'stale' ? `<button type="button" class="hi-btn sm" data-ov-draft="${esc(d.key)}">Draft it</button>` : `<span class="hi-pill ${pc}">${esc(pt)}</span>`) + '</div>';
259
259
  }
260
260
  function docsView(id, M) {
261
261
  const rows = MD.docRows(M), cur = MD.phaseOf(M.acts && M.acts.stage);