create-pmos 0.406.0 → 0.408.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 (32) 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/briefing-premium-adddoc-test.js +4 -3
  8. package/workspace/briefing-premium-doc-edit-test.js +3 -5
  9. package/workspace/briefing-premium-initiative-test.js +46 -27
  10. package/workspace/changelog.json +24 -0
  11. package/workspace/guide/home.md +11 -5
  12. package/workspace/home-other-product-test.js +94 -0
  13. package/workspace/package-lock.json +2 -2
  14. package/workspace/package.json +1 -1
  15. package/workspace/premium-board-actions-test.js +2 -2
  16. package/workspace/premium-core-doc-issue-test.js +4 -1
  17. package/workspace/premium-vw-backlog-test.js +3 -3
  18. package/workspace/premium-vw-doc-test.js +4 -6
  19. package/workspace/premium-vw-item-test.js +1 -1
  20. package/workspace/premium-vw-jira-test.js +2 -2
  21. package/workspace/public/pm/bd-prog-panel.js +4 -3
  22. package/workspace/public/pm/cozy-home.css +5 -0
  23. package/workspace/public/pm/cozy-nav.js +4 -0
  24. package/workspace/public/pm/cozy-today.css +2 -0
  25. package/workspace/public/pm/cozy-viewer.js +24 -8
  26. package/workspace/public/pm/home-app.js +138 -62
  27. package/workspace/public/pm/home-ini.css +14 -0
  28. package/workspace/public/pm/home-ini.js +93 -81
  29. package/workspace/public/pm/home-today.js +7 -5
  30. package/workspace/public/premium.html +1 -1
  31. package/workspace/test-lists/briefing-premium.json +3 -1
  32. package/workspace/tk-tasks-test.js +2 -3
@@ -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)
@@ -163,6 +166,8 @@ async function load() {
163
166
  const others = await Promise.all(otherProducts(D).map((a) => getRetry('/api/board-premium?ws=' + encodeURIComponent(a.ws), 4).then((r) => (r && r.ok && r.model ? { ws: a.ws, name: a.name, model: r.model } : null))));
164
167
  const got = others.filter(Boolean);
165
168
  if (got.length || D.others.length) { D.others = got; drawList(); }
169
+ // an initiative of another product opened before its board was read (a link, a quick press): read it again from its own board
170
+ if (S.ini && !S.IM && otherIni(S.ini)) goIni(S.ini, { page: VW.isOpen() });
166
171
  }
167
172
  /** The products Home reads (Products, on) other than the board's own: each is a group of the list, read from its own board. At most four. */
168
173
  function otherProducts(D) {
@@ -173,7 +178,8 @@ function otherProducts(D) {
173
178
  async function loadIni() {
174
179
  const id = S.ini;
175
180
  if (!id || id === 'product') { S.IM = null; S.IMid = id; S.D.files = []; return; }
176
- const b = (S.D.board && S.D.board.board) || {};
181
+ // an initiative of another product is read from its own board, not this one (it is not on this board, so the read said it could not be read)
182
+ const oi = otherIni(id), b = oi ? { ws: oi.ws, id: oi.board } : (S.D.board && S.D.board.board) || {};
177
183
  const r = await getRetry('/api/initiative-premium?id=' + encodeURIComponent(id) + (b.ws ? '&ws=' + encodeURIComponent(b.ws) : wsQ('&')) + (b.id ? '&board=' + encodeURIComponent(b.id) : boardQ('&')), 16);
178
184
  S.IM = r && r.ok && r.model ? r.model : null; S.IMid = id;
179
185
  if (S.IM) { import('./premium-vw-jira.js').catch(() => {}); import('./premium-vw-item.js').catch(() => {}); } // the Overview's ticket, sprint and record views, ready before a press
@@ -213,11 +219,6 @@ function rowHtml(r, o = {}) {
213
219
  + `<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
220
  + `<span class="hm-rt"><b>${esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
215
221
  }
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
222
  /* ── the one list (premium-uncovered-features: HmMyWork, HmProducts, HmDay, HmMic, HmReview, HmPhone) ── */
222
223
  const NOW = () => S.D.now || Date.now();
223
224
  function recOf() { // a recording that is on and is no calendar meeting: the Today card shows it (HmMic)
@@ -246,7 +247,7 @@ function homeListHtml() {
246
247
  // 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
248
  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
249
  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] : '',
250
+ 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
251
  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
252
  });
252
253
  }
@@ -279,7 +280,17 @@ function filterMenu(b) {
279
280
  }
280
281
 
281
282
  /* ── the initiative card ── */
282
- function iniRowOf(id) { return H.boardRows(S.D).find((r) => r.id === id) || null; }
283
+ function iniRowOf(id) { return H.boardRows(S.D).find((r) => r.id === id) || (otherIni(id) || {}).row || null; }
284
+ /** An initiative of another product Home reads (D.others): its row, and the workspace and board it is read from. Null for the board's own. */
285
+ function otherIni(id) {
286
+ if (!id || id === 'product' || H.boardRows(S.D).some((r) => r.id === id)) return null;
287
+ for (const o of S.D.others || []) {
288
+ const rows = (o && o.model && o.model.initiatives && o.model.initiatives.list && o.model.initiatives.list.rows) || [];
289
+ const row = rows.find((r) => r.id === id);
290
+ if (row) return { ws: o.ws, board: (o.model.board || {}).id || null, row };
291
+ }
292
+ return null;
293
+ }
283
294
  function headOf(id) {
284
295
  const M = S.IM && S.IMid === id ? { ...S.IM } : { head: { stage: (iniRowOf(id) || {}).stage }, acts: (iniRowOf(id) || {}).acts || {} };
285
296
  const t = S.D.trail && S.D.trail.items && S.D.trail.items[id];
@@ -309,6 +320,8 @@ const MS = '<i class="cz-ms" aria-hidden="true"></i>'; // the milestone mark (
309
320
  const msStep = (label) => !!(STEPS.find((s) => s.label === label) || {}).ms;
310
321
  /** "To reach ◆ Deliver": the milestone mark before a milestone's name in the checklist's title. */
311
322
  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); };
323
+ /** "Feature · KR 2.1": an initiative's lane and anchor, the kind line over its name. */
324
+ 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
325
  function cardHtml(id) {
313
326
  const prod = id === 'product';
314
327
  let kind, title, turn, turnLabel, stage, lad = '', bars = '', ckh, items, then, time, cta, primary, over = false, foldSum = '', msNext = false;
@@ -323,7 +336,7 @@ function cardHtml(id) {
323
336
  } else {
324
337
  const r = iniRowOf(id) || { title: (S.IM && S.IM.title) || id };
325
338
  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(' · ');
339
+ kind = kindOf(id);
327
340
  title = r.title; turn = h.turn; turnLabel = h.turnLabel; stage = h.stage;
328
341
  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
342
  bars = `<div class="hm-bars" aria-hidden="true">${h.steps.map((s) => `<i class="${s.cls}"></i>`).join('')}</div>`;
@@ -336,10 +349,8 @@ function cardHtml(id) {
336
349
  then = h.payoff; time = h.time; over = h.over; cta = h.cta; primary = h.primary;
337
350
  foldSum = h.foldSum; msNext = msStep(h.toReach);
338
351
  }
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>`
352
+ // on the initiative's page the Viewer's header names it (kind, title, New session): the card is its stage box alone (HbCDesk)
353
+ return `<section class="hm-card hm-pcard" aria-label="${esc(title)}">`
343
354
  + `<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
355
  + lad + bars
345
356
  // the checklist folds to one line (AgInitSpec): its title, the summary and a chevron; Then and the time line show only unfolded
@@ -351,38 +362,18 @@ function cardHtml(id) {
351
362
  + `<div class="hm-acts"><button type="button" class="hm-cta${primary ? '' : ' alt'}" data-hm-cta>${esc(cta)}</button>`
352
363
  + `<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
364
  }
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
365
  function drawList() {
373
366
  const el = $('#hmList');
374
- // the list column: the groups scroll; the Elsewhere card is the column's foot (AgInitSpec, AgInitPhone)
367
+ // the list column: the groups scroll; the foot is empty since the Elsewhere card went (HbC: the list never leaves)
375
368
  let sc = el.querySelector(':scope > .hm-lsc'), ft = el.querySelector(':scope > .hm-lft'), dy = el.querySelector(':scope > .hm-lday');
376
369
  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();
370
+ const html = homeListHtml();
378
371
  if (sc.__h !== html) {
379
372
  const st = sc.scrollTop, cap = sc.querySelector('#hmCap'), capV = cap ? cap.value : '', capF = !!cap && document.activeElement === cap;
380
373
  sc.__h = html; sc.innerHTML = html; sc.scrollTop = st;
381
374
  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
375
  const c2 = sc.querySelector('#hmCap'); if (c2 && capV) { c2.value = capV; } if (c2 && capF) c2.focus(); // a task being typed survives a redraw
383
376
  }
384
- const fh = elseHtml();
385
- if (ft.__h !== fh) { ft.__h = fh; ft.innerHTML = fh; }
386
377
  const dh = dayHtml();
387
378
  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
379
  document.body.classList.toggle('hm-dayon', !!dh);
@@ -406,7 +397,6 @@ function allRows() {
406
397
  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
398
  if (M.list) M.list.rows.forEach(add);
408
399
  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
400
  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
401
  return out;
412
402
  }
@@ -507,7 +497,7 @@ const scopeOf = (ini) => (ini ? { text: iniTitle(ini), icon: I.flag } : { text:
507
497
  const rich = () => !!S.ini;
508
498
  function iniTarget(id) {
509
499
  const h = S.H || {};
510
- return { key: 'init:' + id, ini: id, ws: WS || undefined, title: iniTitle(id), sub: (S.IMid === id && h.stage) || '', scope: scopeOf(id), rich: true, placeholder: 'Message Claude about ' + iniTitle(id),
500
+ return { key: 'init:' + id, ini: id, ws: (otherIni(id) || {}).ws || WS || undefined, title: iniTitle(id), sub: (S.IMid === id && h.stage) || '', scope: scopeOf(id), rich: true, placeholder: 'Message Claude about ' + iniTitle(id),
511
501
  empty: 'Ask about ' + iniTitle(id) + '. Claude reads its records and works in a real Claude Code session.', also: alsoOf(id),
512
502
  // the initiative's conversation opens on where it stands (AgInitYou), until it has messages of its own
513
503
  intro: S.IMid === id && h.cur ? { role: CLAUDE, onlyEmpty: true, text: h.cur + '. ' + h.doneOf + '.' + (h.rest.length ? ' Waiting: ' + h.rest.map((x) => x.label).join(', ') + '.' : ''), pills: [{ label: h.cta, primary: true, go: () => cta() }, { label: 'Discuss', go: () => chat.focus() }] } : undefined, context: h.payoff ? 'Initiative ' + id + ': ' + (h.stage || '') + '. ' + (h.time || '') : undefined };
@@ -587,6 +577,51 @@ function updateTarget() {
587
577
  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
578
  placeholder: 'Tell Communicator what to change', also: null };
589
579
  }
580
+ /** The product's own conversation (its heading's name, HbCProduct): Claude with the product's goals as its context. */
581
+ function productTarget() {
582
+ const name = H.productName(S.D), C = H.productCard(S.D, S.D.now);
583
+ return { key: 'chat:product', ini: 'product', ws: WS || undefined, title: name, sub: 'Product', scope: scopeOf('product'), rich: false, role: CLAUDE, to: null,
584
+ placeholder: 'Message Claude about ' + name, empty: 'Ask about ' + name + '. Claude reads its goals, its initiatives and this week\'s update.',
585
+ context: 'Product ' + name + '. ' + C.of + (C.items.length ? ': ' + C.items.map((x) => x.label).join('; ') : '') + '.', also: null };
586
+ }
587
+ /** 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. */
588
+ const productKey = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return g ? g.key : null; };
589
+ /** 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
590
+ * metrics review. A press opens that one; ← comes back to the page. */
591
+ function openProductPage() {
592
+ const name = H.productName(S.D);
593
+ VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart',
594
+ render: (b) => {
595
+ 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);
596
+ 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>';
597
+ 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>`;
598
+ 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>`
599
+ + `<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>`
600
+ + (isPhone() ? `<button type="button" class="hi-talk" data-hp="talk">Message Claude about ${esc(name)}</button>` : '') + '</div>';
601
+ b.onclick = (e) => {
602
+ const t = e.target.closest('[data-hp]'); if (!t) return;
603
+ if (t.dataset.hp === 'update') { VW.drill(); openTarget(updateTarget()); openUpdateViewer(); }
604
+ else if (t.dataset.hp === 'metrics') { VW.drill(); openMetrics(); }
605
+ else if (t.dataset.hp === 'talk') talk();
606
+ };
607
+ } });
608
+ }
609
+ /** A phone: the page's "Message Claude about …" closes the sheet and opens the chat full screen; its ← goes back to the list (HbCPhone). */
610
+ function talk() { S.phoneChat = true; VW.close(); drawList(); chat.focus(); }
611
+ /** "Overview with Claude" on the initiative's card: the ask is typed into the chat box, for the PM to send or change. */
612
+ function overviewAsk(id) {
613
+ const ta = $('#hmIn'); if (!ta) return;
614
+ if (isPhone()) talk();
615
+ ta.value = 'Give me an overview of ' + iniTitle(id) + ': where it stands, what is at risk and what comes next.';
616
+ ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); ta.setSelectionRange(ta.value.length, ta.value.length);
617
+ }
618
+ /** Turn into a program (P7), from the page's ⋯: a charter named after the initiative, which joins it; then the program opens here. */
619
+ async function turnProgram(id) {
620
+ const res = await pmPost('/api/programs/turn', { ws: boardWs() || null, initiative: id, title: iniTitle(id) }).catch(() => null);
621
+ if (!res || !res.ok || !res.program) { toast((res && res.error) || 'The program was not made. Try again.'); return; }
622
+ toast('Now a program · ' + iniTitle(id) + '.');
623
+ await load(); goProgram(res.program.id);
624
+ }
590
625
  /** 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
626
  function programTarget(id, task) {
592
627
  const pr = (S.D.programs || []).find((p) => p && p.id === id) || { id, title: (P.get('label') || '').slice(0, 80) || id };
@@ -613,6 +648,7 @@ function select(id, o = {}) {
613
648
  if (!r) { S.phoneChat = false; if (S.ini) openTarget(iniTarget(S.ini)); else openTarget(homeTarget()); drawList(); return; }
614
649
  if (r.kind === 'ini') { goIni(r.ini); return; }
615
650
  if (r.kind === 'product') { goIni('product'); return; }
651
+ S.head = null;
616
652
  // a row with a conversation opens it; on a phone it opens over the list, with a back bar (HmPhone2)
617
653
  if (isPhone() && (r.kind === 'update' || (r.kind === 'need' && r.row) || r.kind === 'session' || r.needSession)) S.phoneChat = true;
618
654
  if (r.kind === 'update') { openTarget(updateTarget()); if (!o.keepViewer) openUpdateViewer(); }
@@ -629,18 +665,58 @@ function select(id, o = {}) {
629
665
  drawList();
630
666
  syncUrl();
631
667
  }
632
- async function goIni(id) {
633
- S.ini = id; S.sel = null; S.doneOpen = false;
668
+ /** 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
669
+ * stays as it is. o.page false: the chat alone, the Viewer as it is. */
670
+ async function goIni(id, o = {}) {
671
+ const was = S.ini;
672
+ S.ini = id; S.sel = null; S.head = id === 'product' ? productKey() : null; S.doneOpen = false;
673
+ if (was !== id) { S.IM = null; S.IMid = null; }
634
674
  if (isPhone()) sheet(false);
635
675
  syncUrl();
636
676
  drawList();
677
+ if (id === 'product') { openTarget(productTarget()); if (o.page !== false) { pushPage(); openProductPage(); } return; }
678
+ openTarget(iniTarget(id));
679
+ if (o.page !== false) { pushPage(); iniPage(); }
637
680
  await loadIni();
638
681
  if (S.ini !== id) return;
639
- drawList();
640
- if (id === 'product') { openTarget(updateTarget()); if (!VW.isOpen() && !isPhone()) openUpdateViewer(); }
641
- else openTarget(iniTarget(id));
682
+ drawList(); openTarget(iniTarget(id));
642
683
  }
643
- function goHome() { S.ini = null; S.sel = null; S.IM = null; syncUrl(); drawList(); openTarget(homeTarget()); }
684
+ /** Another product's heading name: its page in the Viewer and its own chat, as the board's own product opens. Home stays on this workspace,
685
+ * so the chat and the list do not change to that product's workspace. Its weekly update and metrics review open its own Home in a new tab. */
686
+ function goOtherProduct(g) {
687
+ const ws = g.product.ws, name = g.name, C = H.productCard({ board: g.product.model }, S.D.now);
688
+ S.ini = null; S.sel = null; S.IM = null; S.head = g.key;
689
+ if (isPhone()) sheet(false);
690
+ syncUrl(); drawList();
691
+ openTarget({ key: 'chat:product:' + ws, ws, title: name, sub: 'Product', scope: { text: name + ' · product', icon: I.flag }, rich: false, role: CLAUDE, to: null,
692
+ placeholder: 'Message Claude about ' + name, empty: 'Ask about ' + name + '. Claude reads its goals, its initiatives and this week\'s update.',
693
+ context: 'Product ' + name + '. ' + C.of + (C.items.length ? ': ' + C.items.map((x) => x.label).join('; ') : '') + '.', also: null });
694
+ pushPage();
695
+ const own = '/premium.html?ws=' + encodeURIComponent(ws) + '&ini=product';
696
+ VW.open({ id: 'product:' + ws, kind: 'Product', title: name, icon: 'chart',
697
+ render: (b) => {
698
+ 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>';
699
+ 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>`
700
+ + `<section class="hi-pg" aria-label="This week"><div class="hi-pgh"><b>This week</b></div><div class="hm-r hi-r"><a class="hm-rm" href="${esc(own)}" target="_blank" rel="noopener"><span class="hm-tile">${SVG(I.doc, 14)}</span><span class="hm-rt"><b>Weekly update and metrics review</b><em class="q">In ${esc(name)}'s own Home, in a new tab</em></span></a></div></section></div>`;
701
+ } });
702
+ }
703
+ /** A program heading's name: the program panel in the Viewer, the program's own chat (HbCProg). */
704
+ function goProgram(id) {
705
+ if (!(S.D.programs || []).some((p) => p && p.id === id)) { toast('That program is not on this machine.'); return; }
706
+ S.ini = null; S.sel = null; S.IM = null; S.head = 'g:' + id;
707
+ if (isPhone()) sheet(false);
708
+ syncUrl(); drawList();
709
+ openTarget(programTarget(id));
710
+ pushPage();
711
+ programPanel().then(() => { if (S.head === 'g:' + id) document.dispatchEvent(new CustomEvent('bd:program', { detail: { id } })); }).catch(() => toast('The program could not open.'));
712
+ }
713
+ function goHome() { S.ini = null; S.sel = null; S.IM = null; S.head = null; S.phoneChat = false; syncUrl(); drawList(); openTarget(homeTarget()); }
714
+ /* 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
715
+ * was. Close (×, Escape) takes the entry off too, so Back never stops at a page that is already closed. */
716
+ let pushed = false;
717
+ function pushPage() { if (pushed) return; pushed = true; history.pushState({ hmVw: 1 }, '', location.href); }
718
+ addEventListener('popstate', () => { if (!pushed) return; pushed = false; if (VW.isOpen()) VW.close(); goHome(); });
719
+ VW.onChange((d) => { if (!d.open && pushed) { pushed = false; history.back(); } });
644
720
  function syncUrl() {
645
721
  const q = new URLSearchParams(location.search);
646
722
  ['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 +725,7 @@ function syncUrl() {
649
725
  if (r && r.kind === 'ptask') q.set('item', r.id); // a program task: pt:<program>:<key>, the link the program panel makes
650
726
  else if (r && r.key && r.kind !== 'session') q.set('open', r.key); else if (r && r.sid) q.set('session', r.sid);
651
727
  const s = q.toString();
652
- history.replaceState(null, '', location.pathname + (s ? '?' + s : ''));
728
+ history.replaceState(history.state, '', location.pathname + (s ? '?' + s : ''));
653
729
  }
654
730
 
655
731
  /* ── the one list's own views: a task, a mention, finished work, the weekly review (premium-uncovered-features) ── */
@@ -876,7 +952,7 @@ async function sendUpdate() {
876
952
 
877
953
  /* the overview of an initiative: stage moves and hold, Tasks, Core documents (no design yet: a minimal version) */
878
954
  function openOverview() {
879
- if (iniOverview()) return;
955
+ if (iniPage()) return;
880
956
  const id = S.ini; if (!id || id === 'product') return;
881
957
  let M = S.IM;
882
958
  let ask = null; // on-hold | cancelled while its reason is asked
@@ -1207,7 +1283,8 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1207
1283
  if ('hmDay' in d) { day(!S.day); return; }
1208
1284
  if ('hmDayx' in d) { day(false); return; }
1209
1285
  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)
1286
+ if (d.hmProg) { goProgram(d.hmProg); return; } // the program panel, in Home's Viewer (HbCProg)
1287
+ 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) { goOtherProduct(g); return; } goIni('product'); return; }
1211
1288
  if (d.hmKids) { // the chevron of an initiative: what sits under it shows or hides
1212
1289
  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
1290
  keepKids(); drawList(); const f = $(`#hmList [data-hm-kids="${CSS.escape(d.hmKids)}"]`); if (f) f.focus(); return;
@@ -1231,14 +1308,6 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1231
1308
  if ('hmCal' in d) { openCalendar(); return; }
1232
1309
  if ('hmRec' in d) { MORE.openRecorder().then(() => drawList()); return; }
1233
1310
  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
1311
  };
1243
1312
  $('#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
1313
  $('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
@@ -1302,8 +1371,15 @@ function cta() {
1302
1371
  }
1303
1372
 
1304
1373
  /* ── 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() });
1374
+ 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,
1375
+ // the initiative's page (HbCDesk): its card, its header and its ⋯
1376
+ 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(),
1377
+ foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1378
+ /* 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.
1379
+ * 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. */
1380
+ let progPanel = null;
1381
+ 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; }));
1382
+ mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings(), here: () => { if (VW.isOpen()) VW.close(); goHome(); } });
1307
1383
  PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m) }); drawList();
1308
1384
  drawList(); drawTop();
1309
1385
  { // 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); } }