create-pmos 0.406.0 → 0.407.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.
@@ -27,10 +27,16 @@
27
27
  * The caller writes the record and says "Renamed" with Undo; the header shows the saved name at once.
28
28
  * true goes to Home with ?about=<kind>:<id>&label=<title>; { href } goes there; fn() runs instead.
29
29
  * back true: keep the item shown now, so ← comes back to it. Without back, opening an item forgets what was behind it.
30
+ * keep true: this item takes the place of the one shown now, and what was behind that one stays behind this one (a view switch)
31
+ * add { label, on(button) }: a quiet + before ⋯ (Home's "New session" on an initiative, canvas HbC). Not drawn on a phone.
30
32
  * render called with the body element to draw into; html is the same as a string. Neither: the body is left empty for the caller.
31
33
  * id optional; current() returns it, so a caller can tell whether its item is the one shown
32
34
  * onClose called once when this item leaves the card (Close, Escape, close(), or another open())
33
35
  * close() · back() · isOpen() · current() → { id, kind, title, url } | null · body() → the body element or null
36
+ * drill() the next open() keeps the item shown now behind it, as back: true does (a page opens a task or a document from its own
37
+ * rows through a module that does not know it is a drill-in: Home's initiative page, canvas HbCDrill)
38
+ * Overlay (canvas HbCNarrow): a host marked data-cz-vw-overlay keeps its list when there is no room beside the chat; the Viewer then
39
+ * lies over the chat (body.cz-vw-over) instead of folding the list to a rail. Open wide still folds it.
34
40
  * placeholder(featureName, { kind?, icon? }) opens the card with czPlaceholder(featureName) in it (cozy-placeholder.js)
35
41
  * onChange(fn) → fn({ open, id, kind, title }) after each open and close; document also gets the event 'cz-viewer' with the same detail.
36
42
  * czSummary({ line, tone, right, text, meta, primary, also, extra }) → the summary card's markup: one line of state, the words, one quiet meta
@@ -66,7 +72,7 @@ export const ICONS = {
66
72
  warn: 'M12 3l9 16H3zM12 10v4M12 17h.01',
67
73
  };
68
74
  const P = {
69
- back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
75
+ add: 'M12 5v14M5 12h14', back: 'M14 6l-6 6 6 6', more: 'M5 12h.01M12 12h.01M19 12h.01', close: 'M6 6l12 12M18 6L6 18',
70
76
  wide: 'M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7', side: 'M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7',
71
77
  chat: 'M5 6.5A2.5 2.5 0 0 1 7.5 4h9A2.5 2.5 0 0 1 19 6.5v7a2.5 2.5 0 0 1-2.5 2.5H11l-4 3.5V16h.5A2.5 2.5 0 0 1 5 13.5z',
72
78
  tab: 'M14 4h6v6M20 4l-9 9M18 14v6H4V6h6', chev: 'M10 7l5 5-5 5', down: 'M7 10l5 5 5-5', list: 'M3.5 4.5h17v15h-17zM14 4.5v15',
@@ -84,7 +90,7 @@ const isPhone = () => typeof innerWidth === 'number' && innerWidth <= PHONE;
84
90
  const onHome = () => typeof document !== 'undefined' && !!document.body && document.body.classList.contains('cz-home');
85
91
  const kindKey = (k) => String(k || 'item').trim().toLowerCase().replace(/^file · .*/, 'file').replace(/[^a-z0-9]+/g, '-').slice(0, 40) || 'item';
86
92
 
87
- const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, rail: false, w: 0 };
93
+ const V = { el: null, cur: null, back: null, subs: [], stack: [], wide: false, rail: false, w: 0, drill: false, over: false };
88
94
 
89
95
  /** "PRD" over "PRD", or "File · plans/x.md" over "x.md": the kind is left out when it only repeats the title */
90
96
  const sameAs = (kind, title) => { const k = String(kind || '').trim().toLowerCase().replace(/^file · /, ''), t = String(title || '').trim().toLowerCase(); return !!t && (k === t || k.split('/').pop() === t || k.split('/').pop().replace(/\.[a-z]+$/, '') === t); };
@@ -104,10 +110,11 @@ export function headHtml(it) {
104
110
  const kind = o.kind && !sameAs(o.kind, o.title) ? `<p class="cz-vw-kind">${esc(o.kind)}</p>` : '';
105
111
  const disc = o.discuss && !o.home ? ib('discuss', 'Discuss in chat', P.chat) : '';
106
112
  const more = typeof o.more === 'function' || (Array.isArray(o.more) && o.more.some((m) => m && !m.sep)) || o.url ? ib('more', 'More', P.more, ' aria-haspopup="menu" aria-expanded="false"') : '';
113
+ const add = o.add && o.add.label && !phone ? ib('add', o.add.label, P.add) : '';
107
114
  return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
108
115
  + `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`
109
116
  + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : esc(o.title || '')}</h3></div>`)
110
- + disc + more
117
+ + disc + add + more
111
118
  + (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
112
119
  + (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
113
120
  }
@@ -182,7 +189,7 @@ function room() {
182
189
  const right = inner - (lw ? lw + gap : 0);
183
190
  const side = right - gap - CHAT;
184
191
  const wideMax = Math.min(Math.round(innerWidth * MAXF), inner - (list ? RAIL + gap : 0) - gap - CHAT);
185
- return { float: false, def: Math.max(MIN, Math.round(right / 2)), side, wideMax: Math.max(wideMax, side), hasList: !!list };
192
+ return { float: false, def: Math.max(MIN, Math.round(right / 2)), side, wideMax: Math.max(wideMax, side), hasList: !!list, right };
186
193
  }
187
194
  export const widthOf = (kind) => { const n = parseInt(store.get('cz-vw-w:' + kindKey(kind)) || '', 10); return n > 0 ? n : null; };
188
195
  function setRail(on) {
@@ -223,6 +230,10 @@ function apply(px) {
223
230
  const el = V.el; if (!el) return;
224
231
  if (isPhone()) { el.style.width = ''; el.style.flexBasis = ''; el.classList.remove('cz-vw-w2'); setRail(false); return; }
225
232
  let r = room();
233
+ // a host that keeps its list (Home, HbCNarrow): with no room beside the chat the Viewer lies over the chat, at most the room right of the list
234
+ const over = !r.float && r.hasList && r.side < MIN && !V.wide && !!(el.parentNode && el.parentNode.hasAttribute('data-cz-vw-overlay'));
235
+ if (over !== V.over) { V.over = over; document.body.classList.toggle('cz-vw-over', over); }
236
+ if (over) { setRail(false); r = room(); const w = Math.max(Math.min(MIN, r.right), Math.min(Math.round(px || r.def), r.right)); V.w = w; el.style.width = w + 'px'; el.style.flexBasis = w + 'px'; el.classList.toggle('cz-vw-w2', w >= W2); return; }
226
237
  if (!r.float && r.hasList && r.side < MIN) { setRail(true); r = room(); } // under 1100 px: the list folds as the Viewer opens
227
238
  let w = Math.max(MIN, Math.round(px || r.def));
228
239
  if (!r.float) {
@@ -329,6 +340,7 @@ function mount() {
329
340
  if (a === 'close') close();
330
341
  else if (a === 'back') { if (V.stack.length) back(); else close(); }
331
342
  else if (a === 'more') moreMenu(b);
343
+ else if (a === 'add') { if (V.cur && V.cur.add && typeof V.cur.add.on === 'function') V.cur.add.on(b); }
332
344
  else if (a === 'wide') wide();
333
345
  else if (a === 'discuss') discuss();
334
346
  });
@@ -402,10 +414,11 @@ export function open(it) {
402
414
  const o = it || {};
403
415
  const el = mount(); place(el);
404
416
  if (!V.cur) { const ae = document.activeElement; V.back = ae && ae !== document.body && !el.contains(ae) ? ae : null; }
405
- if (o.back && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back) V.stack = [];
417
+ if ((o.back || V.drill) && V.cur && V.cur.args) V.stack.push(V.cur.args); else if (!o._back && !o.keep) V.stack = [];
418
+ V.drill = false;
406
419
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
407
420
  leave();
408
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
421
+ V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, add: o.add || null, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
409
422
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
410
423
  redraw();
411
424
  const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
@@ -420,6 +433,8 @@ export function open(it) {
420
433
  if (isPhone()) el.focus();
421
434
  return body;
422
435
  }
436
+ /** The next open() is a drill-in: the item shown now stays behind it, and ← comes back to it. Nothing open: nothing to keep. */
437
+ export function drill() { V.drill = isOpen(); }
423
438
  /** ← : the item that was shown before this drill-in, drawn again. With nothing behind, ← closes. */
424
439
  export function back() {
425
440
  const prev = V.stack.pop();
@@ -430,7 +445,8 @@ export function back() {
430
445
  export function close() {
431
446
  if (!V.el || V.el.hidden) return;
432
447
  leave();
433
- V.stack = []; V.wide = false;
448
+ V.stack = []; V.wide = false; V.drill = false;
449
+ if (V.over) { V.over = false; document.body.classList.remove('cz-vw-over'); }
434
450
  V.el.hidden = true;
435
451
  V.el.querySelector('.cz-vw-body').innerHTML = '';
436
452
  const m = V.el.querySelector('.cz-vw-menu'); if (m) m.remove();
@@ -457,4 +473,4 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
457
473
  e.preventDefault(); e.stopImmediatePropagation(); close();
458
474
  }, true);
459
475
  }
460
- if (typeof window !== 'undefined') window.czViewer = { open, close, back, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
476
+ if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
@@ -5,10 +5,12 @@
5
5
  * One desk. The list on the left is one list grouped by product (home-list.js builds it, home-today.js draws it): the Today card through
6
6
  * the day, the filters (Today, Waiting, Kept, Done), each product's group with its initiatives (yours first, marked "your turn") and their
7
7
  * tasks, next steps, sessions and meetings under them, then "Not in an initiative", the capture box and the untouched work. There is no
8
- * Needs you group and no Your list. An initiative is a layout of this page (?ini=<id>): its card sits at the top of the list with its own
9
- * groups and the Elsewhere card under it. The chat is in the middle (home-chat.js) and the Viewer on the right (cozy-viewer.js): a task opens
10
- * there (home-task.js), and so does the weekly review (home-review.js). On a phone the list is the page; a row opens its conversation over
11
- * it, with a back bar.
8
+ * Needs you group and no Your list. The list never changes for an initiative (canvas HbC): its row's name selects it, scopes the chat to it
9
+ * and opens its page in the Viewer (home-ini.js iniPage, ?ini=<id>). A program heading's name opens the program panel (bd-prog-panel.js) and
10
+ * a product heading's name the product's page, each with its own chat. The browser's Back closes the page, and so does Menu > Home. The chat
11
+ * is in the middle (home-chat.js) and the Viewer on the right (cozy-viewer.js): a task opens there (home-task.js), and so does the weekly
12
+ * review (home-review.js). With no room beside the chat the Viewer lies over the chat, not the list. On a phone the list is the page; a row
13
+ * opens its conversation over it, with a back bar.
12
14
  *
13
15
  * The models are in home-data.js and home-list.js (pure). This file reads the routes, draws, and wires the presses. Every write is the PM's
14
16
  * press (pmPost). Nothing here opens the old dialog or links to the console. */
@@ -27,7 +29,7 @@ import * as L from './home-list.js';
27
29
  import * as TD from './home-today.js';
28
30
  import * as YD from './home-day.js'; // Your day in the Viewer (XvAPhDay)
29
31
  import { canDictate, dictate } from './home-dictate.js';
30
- import { mountIni, iniList, iniOverview } from './home-ini.js'; // the initiative's stage move, Tasks and Core documents (premium-uncovered-features)
32
+ import { mountIni, iniList, iniOverview, iniPage } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
31
33
  import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
32
34
  import { mountRecRow } from './home-rec-row.js';
33
35
  import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
@@ -72,7 +74,8 @@ const store = {
72
74
  /* ── state ── */
73
75
  const S = {
74
76
  D: { now: Date.now(), sessions: [], err: [], files: [] }, ready: false,
75
- ini: P.get('ini') || null, // the initiative layout ('product' for the product)
77
+ ini: P.get('ini') || null, // the initiative whose page is open ('product' for the product)
78
+ head: null, // the selected heading of the list: a program's or a product's group key
76
79
  sel: null, // the selected row's id
77
80
  allNeeds: false, kids: new Set(), shut: new Set(JSON.parse(store.get('pmos.home.shut') || '[]')), folded: store.get('pmos.home.fold') === '1',
78
81
  IM: null, IMid: null, // the selected initiative's model (GET /api/initiative-premium)
@@ -213,11 +216,6 @@ function rowHtml(r, o = {}) {
213
216
  + `<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${sel ? ' aria-current="true"' : ''}><i class="hm-dot ${dotCls(r.state)}" aria-hidden="true"></i>${tileHtml(r)}`
214
217
  + `<span class="hm-rt"><b>${esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
215
218
  }
216
- function groupHtml(key, title, rows, extra = '', head = '') {
217
- const shut = S.shut.has(key);
218
- return `<section class="hm-g" aria-label="${esc(title)}"><div class="hm-ghr"><button type="button" class="hm-gh" data-hm-group="${esc(key)}" aria-expanded="${!shut}">${SVG(shut ? I.chev : I.down, 12, 2.2)}<span>${esc(title)}</span></button>${head}</div>`
219
- + (shut ? '' : rows.map((r) => rowHtml(r)).join('') + extra) + '</section>';
220
- }
221
219
  /* ── the one list (premium-uncovered-features: HmMyWork, HmProducts, HmDay, HmMic, HmReview, HmPhone) ── */
222
220
  const NOW = () => S.D.now || Date.now();
223
221
  function recOf() { // a recording that is on and is no calendar meeting: the Today card shows it (HmMic)
@@ -246,7 +244,7 @@ function homeListHtml() {
246
244
  // a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
247
245
  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));
248
246
  return TD.listHtml(M, todayModel(), {
249
- 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] : '',
247
+ sel: S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null), selHead: S.head, 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] : '',
250
248
  product: S.product, review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
251
249
  });
252
250
  }
@@ -309,6 +307,8 @@ const MS = '<i class="cz-ms" aria-hidden="true"></i>'; // the milestone mark (
309
307
  const msStep = (label) => !!(STEPS.find((s) => s.label === label) || {}).ms;
310
308
  /** "To reach ◆ Deliver": the milestone mark before a milestone's name in the checklist's title. */
311
309
  const ckTitle = (t, ms) => { const m = ms && /^(To reach |To finish )(.+)$/.exec(String(t || '')); return m ? esc(m[1]) + MS + esc(m[2]) : esc(t); };
310
+ /** "Feature · KR 2.1": an initiative's lane and anchor, the kind line over its name. */
311
+ function kindOf(id) { const r = iniRowOf(id) || {}; return [r.lane ? r.lane.charAt(0).toUpperCase() + r.lane.slice(1) : 'Feature', r.kr || r.anchor || ''].filter(Boolean).join(' · '); }
312
312
  function cardHtml(id) {
313
313
  const prod = id === 'product';
314
314
  let kind, title, turn, turnLabel, stage, lad = '', bars = '', ckh, items, then, time, cta, primary, over = false, foldSum = '', msNext = false;
@@ -323,7 +323,7 @@ function cardHtml(id) {
323
323
  } else {
324
324
  const r = iniRowOf(id) || { title: (S.IM && S.IM.title) || id };
325
325
  const h = headOf(id); S.H = h;
326
- kind = [r.lane ? r.lane.charAt(0).toUpperCase() + r.lane.slice(1) : 'Feature', r.kr || r.anchor || ''].filter(Boolean).join(' · ');
326
+ kind = kindOf(id);
327
327
  title = r.title; turn = h.turn; turnLabel = h.turnLabel; stage = h.stage;
328
328
  lad = `<p class="hm-lad" role="img" aria-label="${esc(h.ladderAria)}">${h.prev ? `<span class="pv">${SVG(I.check, 11, 2.6)}${esc(h.prev)}</span>${SVG(I.chev, 11, 2.2)}` : ''}<b>${esc(h.cur)}</b>${h.toReach && h.toReach !== 'Done' ? SVG(I.chev, 11, 2.2) + `<span class="nx">${msStep(h.toReach) ? MS : ''}${esc(h.toReach)}</span>` : ''}</p>`;
329
329
  bars = `<div class="hm-bars" aria-hidden="true">${h.steps.map((s) => `<i class="${s.cls}"></i>`).join('')}</div>`;
@@ -336,10 +336,8 @@ function cardHtml(id) {
336
336
  then = h.payoff; time = h.time; over = h.over; cta = h.cta; primary = h.primary;
337
337
  foldSum = h.foldSum; msNext = msStep(h.toReach);
338
338
  }
339
- return `<section class="hm-card" aria-label="${esc(title)}"><div class="hm-ch"><span class="hm-tile sq">${SVG(prod ? I.flag : I.flag, 15)}</span>`
340
- + `<button type="button" class="hm-sw" data-hm-switch aria-haspopup="menu" aria-label="${esc(title)}. Switch"><span class="k">${esc(kind)}</span><b>${esc(title)}</b></button>`
341
- + `<button type="button" class="hm-ib sm" data-hm-switch aria-hidden="true" tabindex="-1">${SVG(I.down, 14, 2)}</button>`
342
- + `<button type="button" class="hm-plus" data-hm-newin aria-label="New session in ${esc(title)}" title="New session">${SVG(I.plus, 16, 2)}</button></div>`
339
+ // on the initiative's page the Viewer's header names it (kind, title, New session): the card is its stage box alone (HbCDesk)
340
+ return `<section class="hm-card hm-pcard" aria-label="${esc(title)}">`
343
341
  + `<div class="hm-box ${esc(turn)}"><div class="hm-br"><span class="hm-turn ${esc(turn)}"><i aria-hidden="true"></i>${esc(turnLabel)}</span><span class="st">${esc(stage)}</span></div>`
344
342
  + lad + bars
345
343
  // the checklist folds to one line (AgInitSpec): its title, the summary and a chevron; Then and the time line show only unfolded
@@ -351,38 +349,18 @@ function cardHtml(id) {
351
349
  + `<div class="hm-acts"><button type="button" class="hm-cta${primary ? '' : ' alt'}" data-hm-cta>${esc(cta)}</button>`
352
350
  + `<button type="button" class="hm-ov" data-hm-ov aria-label="Overview of ${esc(title)} with Claude" title="Overview with Claude">${avHtml(CLAUDE, 24)}</button></div></div></section>`;
353
351
  }
354
- function iniListHtml() {
355
- const id = S.ini;
356
- const lay = H.iniLayout(S.D, id);
357
- if (id === 'product') { // the product's sessions are its update and its own chats
358
- const g = lay.groups.find((x) => x.key === 'sessions');
359
- const upd = S.D.sessions.filter((s) => H.keyOfSession(s) === H.UPDATE_KEY.slice(5) || H.keyOfSession(s) === H.UPDATE_KEY);
360
- if (upd.length && !g) lay.groups.splice(1, 0, { key: 'sessions', title: 'Sessions', rows: [] });
361
- }
362
- // Add a stakeholder is offered from the Stakeholders group's head and the card's switch menu, not as a row of the list (AgProduct, AgInitSpec)
363
- const groups = lay.groups.map((g) => groupHtml('i:' + g.key, g.title, g.rows, '', g.key === 'people' ? `<button type="button" class="hm-gadd" data-hm-person aria-label="Add a stakeholder to ${esc(iniTitle(id))}" title="Add a stakeholder">${SVG(I.plus, 14, 2.2)}</button>` : '')).join('');
364
- S.lay = lay;
365
- return cardHtml(id) + groups;
366
- }
367
- /** The Elsewhere card of an initiative's layout: pinned to the bottom of the list column, under the groups, never over them. */
368
- function elseHtml() {
369
- const e = S.ini && S.lay && S.lay.elsewhere;
370
- return e ? `<button type="button" class="hm-else" data-hm-else><i class="hm-dot you" aria-hidden="true"></i><span><em>Elsewhere</em><b>${esc(e.text)}</b></span>${SVG(I.chev, 14, 2)}</button>` : '';
371
- }
372
352
  function drawList() {
373
353
  const el = $('#hmList');
374
- // the list column: the groups scroll; the Elsewhere card is the column's foot (AgInitSpec, AgInitPhone)
354
+ // the list column: the groups scroll; the foot is empty since the Elsewhere card went (HbC: the list never leaves)
375
355
  let sc = el.querySelector(':scope > .hm-lsc'), ft = el.querySelector(':scope > .hm-lft'), dy = el.querySelector(':scope > .hm-lday');
376
356
  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; }
377
- const html = S.ini ? iniListHtml() : homeListHtml();
357
+ const html = homeListHtml();
378
358
  if (sc.__h !== html) {
379
359
  const st = sc.scrollTop, cap = sc.querySelector('#hmCap'), capV = cap ? cap.value : '', capF = !!cap && document.activeElement === cap;
380
360
  sc.__h = html; sc.innerHTML = html; sc.scrollTop = st;
381
361
  sc.querySelectorAll('.hm-load i[data-f]').forEach((i) => i.style.setProperty('--bd-f', i.dataset.f)); // the day's load: run-time geometry
382
362
  const c2 = sc.querySelector('#hmCap'); if (c2 && capV) { c2.value = capV; } if (c2 && capF) c2.focus(); // a task being typed survives a redraw
383
363
  }
384
- const fh = elseHtml();
385
- if (ft.__h !== fh) { ft.__h = fh; ft.innerHTML = fh; }
386
364
  const dh = dayHtml();
387
365
  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)); }
388
366
  document.body.classList.toggle('hm-dayon', !!dh);
@@ -406,7 +384,6 @@ function allRows() {
406
384
  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); }
407
385
  if (M.list) M.list.rows.forEach(add);
408
386
  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); }); }
409
- if (S.lay) S.lay.groups.forEach((g) => g.rows.forEach(add));
410
387
  for (const s of S.D.sessions) { const r = { id: 's:' + s.id, kind: 'session', sid: s.id, key: H.keyOfSession(s), ini: H.iniOfSession(s), name: (s.hx && s.hx.title) || s.name, role: H.roleOf(s, S.D.desk && S.D.desk.roles), state: s.shown }; out.push(r); }
411
388
  return out;
412
389
  }
@@ -587,6 +564,51 @@ function updateTarget() {
587
564
  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.',
588
565
  placeholder: 'Tell Communicator what to change', also: null };
589
566
  }
567
+ /** The product's own conversation (its heading's name, HbCProduct): Claude with the product's goals as its context. */
568
+ function productTarget() {
569
+ const name = H.productName(S.D), C = H.productCard(S.D, S.D.now);
570
+ return { key: 'chat:product', ini: 'product', ws: WS || undefined, title: name, sub: 'Product', scope: scopeOf('product'), rich: false, role: CLAUDE, to: null,
571
+ placeholder: 'Message Claude about ' + name, empty: 'Ask about ' + name + '. Claude reads its goals, its initiatives and this week\'s update.',
572
+ context: 'Product ' + name + '. ' + C.of + (C.items.length ? ': ' + C.items.map((x) => x.label).join('; ') : '') + '.', also: null };
573
+ }
574
+ /** The list's key of the board's own product group ('p:<key>'): its heading shows as selected while the product's page is open. */
575
+ const productKey = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return g ? g.key : null; };
576
+ /** The product's page in the Viewer (HbCProduct): Goals, the KRs and budgets with what is at risk, and This week, the weekly update and the
577
+ * metrics review. A press opens that one; ← comes back to the page. */
578
+ function openProductPage() {
579
+ const name = H.productName(S.D);
580
+ VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart',
581
+ render: (b) => {
582
+ const C = H.productCard(S.D, S.D.now), U = H.weeklyUpdate(S.D, S.D.now), sent = (U.sent || []).some((x) => x.week === U.week.iso);
583
+ const goals = C.items.map((x) => itemHtml({ kind: x.kind === 'ok' ? 'done' : 'risk', label: x.label })).join('') || '<p class="hm-none">No KR or budget is anchored on this board.</p>';
584
+ const row = (k, icon, t, sub) => `<div class="hm-r hi-r"><button type="button" class="hm-rm" data-hp="${k}"><span class="hm-tile">${SVG(icon, 14)}</span><span class="hm-rt"><b>${esc(t)}</b><em class="q">${esc(sub)}</em></span></button></div>`;
585
+ b.innerHTML = `<div class="hi-v hi-page"><section class="hi-pg" aria-label="Goals"><div class="hi-pgh"><b>Goals</b><span class="hi-n">${esc(C.of)}</span></div>${goals}</section>`
586
+ + `<section class="hi-pg" aria-label="This week"><div class="hi-pgh"><b>This week</b></div>${row('update', I.doc, 'Weekly update', sent ? 'Sent this week' : 'Ready to send')}${row('metrics', I.chart, 'Metrics review', 'With Strategist')}</section>`
587
+ + (isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '') + '</div>';
588
+ b.onclick = (e) => {
589
+ const t = e.target.closest('[data-hp]'); if (!t) return;
590
+ if (t.dataset.hp === 'update') { VW.drill(); openTarget(updateTarget()); openUpdateViewer(); }
591
+ else if (t.dataset.hp === 'metrics') { VW.drill(); openMetrics(); }
592
+ else if (t.dataset.hp === 'talk') talk();
593
+ };
594
+ } });
595
+ }
596
+ /** A phone: the page's "Message Claude about …" closes the sheet and opens the chat full screen; its ← goes back to the list (HbCPhone). */
597
+ function talk() { S.phoneChat = true; VW.close(); drawList(); chat.focus(); }
598
+ /** "Overview with Claude" on the initiative's card: the ask is typed into the chat box, for the PM to send or change. */
599
+ function overviewAsk(id) {
600
+ const ta = $('#hmIn'); if (!ta) return;
601
+ if (isPhone()) talk();
602
+ ta.value = 'Give me an overview of ' + iniTitle(id) + ': where it stands, what is at risk and what comes next.';
603
+ ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); ta.setSelectionRange(ta.value.length, ta.value.length);
604
+ }
605
+ /** Turn into a program (P7), from the page's ⋯: a charter named after the initiative, which joins it; then the program opens here. */
606
+ async function turnProgram(id) {
607
+ const res = await pmPost('/api/programs/turn', { ws: boardWs() || null, initiative: id, title: iniTitle(id) }).catch(() => null);
608
+ if (!res || !res.ok || !res.program) { toast((res && res.error) || 'The program was not made. Try again.'); return; }
609
+ toast('Now a program · ' + iniTitle(id) + '.');
610
+ await load(); goProgram(res.program.id);
611
+ }
590
612
  /** A program's conversation (?ask=program:<id>, a program task's row): Claude with the program as its scope. task names the open row. */
591
613
  function programTarget(id, task) {
592
614
  const pr = (S.D.programs || []).find((p) => p && p.id === id) || { id, title: (P.get('label') || '').slice(0, 80) || id };
@@ -613,6 +635,7 @@ function select(id, o = {}) {
613
635
  if (!r) { S.phoneChat = false; if (S.ini) openTarget(iniTarget(S.ini)); else openTarget(homeTarget()); drawList(); return; }
614
636
  if (r.kind === 'ini') { goIni(r.ini); return; }
615
637
  if (r.kind === 'product') { goIni('product'); return; }
638
+ S.head = null;
616
639
  // a row with a conversation opens it; on a phone it opens over the list, with a back bar (HmPhone2)
617
640
  if (isPhone() && (r.kind === 'update' || (r.kind === 'need' && r.row) || r.kind === 'session' || r.needSession)) S.phoneChat = true;
618
641
  if (r.kind === 'update') { openTarget(updateTarget()); if (!o.keepViewer) openUpdateViewer(); }
@@ -629,18 +652,39 @@ function select(id, o = {}) {
629
652
  drawList();
630
653
  syncUrl();
631
654
  }
632
- async function goIni(id) {
633
- S.ini = id; S.sel = null; S.doneOpen = false;
655
+ /** An initiative's name in the list (or 'product'): it is selected, the chat is its own and its page opens in the Viewer (HbCDesk). The list
656
+ * stays as it is. o.page false: the chat alone, the Viewer as it is. */
657
+ async function goIni(id, o = {}) {
658
+ const was = S.ini;
659
+ S.ini = id; S.sel = null; S.head = id === 'product' ? productKey() : null; S.doneOpen = false;
660
+ if (was !== id) { S.IM = null; S.IMid = null; }
634
661
  if (isPhone()) sheet(false);
635
662
  syncUrl();
636
663
  drawList();
664
+ if (id === 'product') { openTarget(productTarget()); if (o.page !== false) { pushPage(); openProductPage(); } return; }
665
+ openTarget(iniTarget(id));
666
+ if (o.page !== false) { pushPage(); iniPage(); }
637
667
  await loadIni();
638
668
  if (S.ini !== id) return;
639
- drawList();
640
- if (id === 'product') { openTarget(updateTarget()); if (!VW.isOpen() && !isPhone()) openUpdateViewer(); }
641
- else openTarget(iniTarget(id));
669
+ drawList(); openTarget(iniTarget(id));
642
670
  }
643
- function goHome() { S.ini = null; S.sel = null; S.IM = null; syncUrl(); drawList(); openTarget(homeTarget()); }
671
+ /** A program heading's name: the program panel in the Viewer, the program's own chat (HbCProg). */
672
+ function goProgram(id) {
673
+ if (!(S.D.programs || []).some((p) => p && p.id === id)) { toast('That program is not on this machine.'); return; }
674
+ S.ini = null; S.sel = null; S.IM = null; S.head = 'g:' + id;
675
+ if (isPhone()) sheet(false);
676
+ syncUrl(); drawList();
677
+ openTarget(programTarget(id));
678
+ pushPage();
679
+ programPanel().then(() => { if (S.head === 'g:' + id) document.dispatchEvent(new CustomEvent('bd:program', { detail: { id } })); }).catch(() => toast('The program could not open.'));
680
+ }
681
+ function goHome() { S.ini = null; S.sel = null; S.IM = null; S.head = null; S.phoneChat = false; syncUrl(); drawList(); openTarget(homeTarget()); }
682
+ /* The browser's Back closes the page a name opened (HbC): opening one adds an entry to the history, Back takes it off and Home is as it
683
+ * was. Close (×, Escape) takes the entry off too, so Back never stops at a page that is already closed. */
684
+ let pushed = false;
685
+ function pushPage() { if (pushed) return; pushed = true; history.pushState({ hmVw: 1 }, '', location.href); }
686
+ addEventListener('popstate', () => { if (!pushed) return; pushed = false; if (VW.isOpen()) VW.close(); goHome(); });
687
+ VW.onChange((d) => { if (!d.open && pushed) { pushed = false; history.back(); } });
644
688
  function syncUrl() {
645
689
  const q = new URLSearchParams(location.search);
646
690
  ['ini', 'open', 'item', 'session', 'ask', 'say', 'q', 'about', 'label', 'meeting', 'id', 'view', 'vk', 'vid'].forEach((k) => { if (!(k === 'open' && /^(report|chart|dashboard):/.test(q.get('open') || ''))) q.delete(k); });
@@ -649,7 +693,7 @@ function syncUrl() {
649
693
  if (r && r.kind === 'ptask') q.set('item', r.id); // a program task: pt:<program>:<key>, the link the program panel makes
650
694
  else if (r && r.key && r.kind !== 'session') q.set('open', r.key); else if (r && r.sid) q.set('session', r.sid);
651
695
  const s = q.toString();
652
- history.replaceState(null, '', location.pathname + (s ? '?' + s : ''));
696
+ history.replaceState(history.state, '', location.pathname + (s ? '?' + s : ''));
653
697
  }
654
698
 
655
699
  /* ── the one list's own views: a task, a mention, finished work, the weekly review (premium-uncovered-features) ── */
@@ -876,7 +920,7 @@ async function sendUpdate() {
876
920
 
877
921
  /* the overview of an initiative: stage moves and hold, Tasks, Core documents (no design yet: a minimal version) */
878
922
  function openOverview() {
879
- if (iniOverview()) return;
923
+ if (iniPage()) return;
880
924
  const id = S.ini; if (!id || id === 'product') return;
881
925
  let M = S.IM;
882
926
  let ask = null; // on-hold | cancelled while its reason is asked
@@ -1207,7 +1251,8 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1207
1251
  if ('hmDay' in d) { day(!S.day); return; }
1208
1252
  if ('hmDayx' in d) { day(false); return; }
1209
1253
  if ('hmFlt' in d) { filterMenu(b); return; }
1210
- if (d.hmProg) { location.href = '/premium-board.html?program=' + encodeURIComponent(d.hmProg) + wsQ('&'); return; } // the program panel (the Board opens it)
1254
+ if (d.hmProg) { goProgram(d.hmProg); return; } // the program panel, in Home's Viewer (HbCProg)
1255
+ if (d.hmProdopen) { const g = ((S.M && S.M.groups) || []).find((x) => x.key === d.hmProdopen); if (g && !g.primary && g.product && g.product.ws) { location.href = '/premium.html?ws=' + encodeURIComponent(g.product.ws) + '&ini=product'; return; } goIni('product'); return; }
1211
1256
  if (d.hmKids) { // the chevron of an initiative: what sits under it shows or hides
1212
1257
  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); }
1213
1258
  keepKids(); drawList(); const f = $(`#hmList [data-hm-kids="${CSS.escape(d.hmKids)}"]`); if (f) f.focus(); return;
@@ -1231,14 +1276,6 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1231
1276
  if ('hmCal' in d) { openCalendar(); return; }
1232
1277
  if ('hmRec' in d) { MORE.openRecorder().then(() => drawList()); return; }
1233
1278
  if (d.hmRecopen) { openMeeting({ note: d.hmRecopen }); return; }
1234
- if ('hmSwitch' in d) { menu(b, [{ label: 'Home', sub: 'All work', go: () => goHome() }].concat(scopeItems().slice(1), S.ini ? [{ label: 'Add a stakeholder', sub: 'To ' + iniTitle(S.ini), go: () => addPerson() }] : []), 'Switch'); return; }
1235
- if ('hmNewin' in d) { if (S.ini === 'product') { openTarget(updateTarget()); chat.focus(); } else newIn(S.ini); return; }
1236
- if ('hmDone' in d) { S.doneOpen = !S.doneOpen; drawList(); return; }
1237
- if ('hmCfold' in d) { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); drawList(); const f = $('#hmList [data-hm-cfold]'); if (f) f.focus(); return; }
1238
- if ('hmCta' in d) { cta(); return; }
1239
- if ('hmOv' in d) { if (S.ini === 'product') openUpdateViewer(); else openOverview(); return; }
1240
- if ('hmElse' in d) { const f = S.lay && S.lay.elsewhere && S.lay.elsewhere.first; goHome(); if (f) select(f.id); return; }
1241
- if ('hmPerson' in d) addPerson();
1242
1279
  };
1243
1280
  $('#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); } });
1244
1281
  $('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
@@ -1302,8 +1339,15 @@ function cta() {
1302
1339
  }
1303
1340
 
1304
1341
  /* ── start ── */
1305
- mountIni({ S, VW, pmGet, pmPost, toast, renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT });
1306
- mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings() });
1342
+ mountIni({ S, VW, pmGet, pmPost, toast, renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
1343
+ // the initiative's page (HbCDesk): its card, its header and its ⋯
1344
+ cardHtml: (id) => cardHtml(id), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), talk: () => talk(),
1345
+ foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1346
+ /* The program panel in Home's Viewer (HbCProg): Home's board model and programs; an initiative of it opens here, with ← back to the program.
1347
+ * Read on the first program press, never at start: the panel's modules load premium-shell.js, whose start reads ?session= for the old dialog. */
1348
+ let progPanel = null;
1349
+ const programPanel = () => progPanel || (progPanel = import('./bd-prog-panel.js').then((PP) => { PP.mount({ M: () => S.D.board, programs: () => S.D.programs || [], openIni: (id) => goIni(id), close: () => {}, reload: () => load(), say: (m) => toast(m), drill: true }); return PP; }));
1350
+ mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings(), here: () => { if (VW.isOpen()) VW.close(); goHome(); } });
1307
1351
  PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m) }); drawList();
1308
1352
  drawList(); drawTop();
1309
1353
  { // a conversation the address names opens at once, before the lists are read, so nothing typed or attached lands in the Home chat
@@ -169,3 +169,17 @@ button.hi-pill { cursor: pointer; }
169
169
  .hi-sw[aria-checked="true"]::after { left: 20px; }
170
170
  .hi-toast { bottom: 96px; }
171
171
  }
172
+
173
+ /* ── the initiative's page in the Viewer (canvas HbCDesk, HbCNew, HbCPhone): the stage card, three tasks, the documents that need a look ── */
174
+ .hi-page { display: flex; flex-direction: column; gap: 14px; }
175
+ .hi-page .hm-pcard { margin: 0; }
176
+ .hi-pg { display: flex; flex-direction: column; gap: 2px; }
177
+ .hi-pgh { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 4px; }
178
+ .hi-pgh b { font-size: 14px; font-weight: 800; color: var(--cz-ink); }
179
+ .hi-pgh .hi-n { font-size: 12px; font-weight: 700; color: var(--cz-ink3); }
180
+ .hi-pgh .hm-gadd { margin-left: auto; }
181
+ .hi-pgm { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 8px; border: 0; border-radius: 10px; background: none; color: var(--cz-ink2); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
182
+ .hi-pge { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 6px; }
183
+ .hi-pge p { margin: 0; font-size: 13px; color: var(--cz-ink3); }
184
+ .hi-talk { min-height: 44px; border: 0; border-radius: 22px; background: var(--cz-well); color: var(--cz-ink3); font: inherit; font-size: 14px; text-align: left; padding: 0 16px; cursor: pointer; }
185
+ @media (hover: hover) { .hi-pgm:hover { background: var(--cz-well2); } }