create-pmos 0.405.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.
Files changed (43) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +4 -3
  7. package/workspace/briefing-premium-doc-edit-test.js +3 -5
  8. package/workspace/briefing-premium-initiative-test.js +46 -27
  9. package/workspace/changelog.json +24 -0
  10. package/workspace/guide/home.md +21 -4
  11. package/workspace/guide/programs.md +1 -0
  12. package/workspace/lib/engine/boards.js +2 -1
  13. package/workspace/lib/initiative-writer.js +45 -1
  14. package/workspace/lib/routes-boards.js +13 -0
  15. package/workspace/lib/routes-initiatives.js +12 -0
  16. package/workspace/package-lock.json +2 -2
  17. package/workspace/package.json +1 -1
  18. package/workspace/premium-board-actions-test.js +2 -2
  19. package/workspace/premium-core-doc-issue-test.js +4 -1
  20. package/workspace/premium-vw-backlog-test.js +3 -3
  21. package/workspace/premium-vw-doc-test.js +4 -6
  22. package/workspace/premium-vw-item-test.js +1 -1
  23. package/workspace/premium-vw-jira-test.js +2 -2
  24. package/workspace/public/pm/bd-ini-panel.js +2 -2
  25. package/workspace/public/pm/bd-prog-panel.js +15 -5
  26. package/workspace/public/pm/cozy-home.css +5 -0
  27. package/workspace/public/pm/cozy-nav.js +4 -0
  28. package/workspace/public/pm/cozy-today.css +2 -0
  29. package/workspace/public/pm/cozy-viewer.js +75 -10
  30. package/workspace/public/pm/cozy-vw-shell.css +20 -1
  31. package/workspace/public/pm/home-app.js +135 -61
  32. package/workspace/public/pm/home-ini.css +14 -0
  33. package/workspace/public/pm/home-ini.js +98 -81
  34. package/workspace/public/pm/home-task.js +5 -2
  35. package/workspace/public/pm/home-today.js +7 -5
  36. package/workspace/public/pm/premium-board.js +21 -2
  37. package/workspace/public/pm/premium-viewer.js +1 -1
  38. package/workspace/public/pm/premium-vw-item.js +1 -0
  39. package/workspace/public/pm/rename-press.js +81 -0
  40. package/workspace/public/premium.html +1 -1
  41. package/workspace/rename-test.js +166 -0
  42. package/workspace/test-lists/rename.json +9 -0
  43. 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,9 +29,10 @@ 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
- import { mountRecRow } from './home-rec-row.js'; // the pinned recording row above it (XvARecHome)
34
+ import { mountRecRow } from './home-rec-row.js';
35
+ import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
33
36
 
34
37
  const $ = (s, r = document) => r.querySelector(s);
35
38
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -71,7 +74,8 @@ const store = {
71
74
  /* ── state ── */
72
75
  const S = {
73
76
  D: { now: Date.now(), sessions: [], err: [], files: [] }, ready: false,
74
- 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
75
79
  sel: null, // the selected row's id
76
80
  allNeeds: false, kids: new Set(), shut: new Set(JSON.parse(store.get('pmos.home.shut') || '[]')), folded: store.get('pmos.home.fold') === '1',
77
81
  IM: null, IMid: null, // the selected initiative's model (GET /api/initiative-premium)
@@ -86,7 +90,35 @@ const S = {
86
90
  // pmos.home.pg, an initiative's rows and its "N more" in pmos.home.kids
87
91
  (() => { 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 */ } })();
88
92
  const keepKids = () => store.set('pmos.home.kids', JSON.stringify({ on: [...S.kids], off: [...S.kidsOff], rest: [...S.rest], tasks: [...S.tasks] }));
89
- const toast = (t) => { const el = $('#toast'); el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
93
+ const toast = (t) => { const el = $('#toast'); el.classList.remove('act'); el.textContent = t; el.classList.add('on'); clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on'), 4200); };
94
+ /** The toast with Undo (RnASaved: "Renamed · Undo"), the shape home-work.js draws: undo() runs the write's opposite once. */
95
+ function toastUndo(msg, undo) {
96
+ const el = $('#toast');
97
+ el.innerHTML = esc(msg) + ' <button class="undo" type="button">Undo</button>'; el.classList.add('on', 'act');
98
+ el.querySelector('.undo').onclick = async () => { el.classList.remove('on', 'act'); const r = await undo(); if (r && r.ok === false) toast(r.error || 'It could not be undone.'); };
99
+ clearTimeout(toast.t); toast.t = setTimeout(() => el.classList.remove('on', 'act'), 8000);
100
+ }
101
+ /** A rename landed (or its Undo did): every place that names it reads the new name now, and the server's read follows. */
102
+ function renamedHere(kind, id, title) {
103
+ if (kind === 'task') for (const t of ((S.D.items && S.D.items.items) || [])) { if (t && t.uid === id) t.title = title; }
104
+ if (kind === 'ini') for (const r of H.boardRows(S.D)) { if (r && r.id === id) r.title = title; }
105
+ if (kind === 'ini' && S.IMid === id && S.IM) S.IM.title = title;
106
+ if (S.cur && kind === 'ini' && S.ini === id && S.cur.title !== title) { S.cur.title = title; }
107
+ drawList(); if (chat.refresh) chat.refresh();
108
+ }
109
+ const taskRenameOf = (t) => taskRename({ pmPost, ws: t.ws || boardWs(), board: t.board || boardId(), uid: t.uid, ref: null,
110
+ onSaved: (o) => {
111
+ renamedHere('task', t.uid, o.title); t.title = o.title;
112
+ toastUndo('Renamed', async () => { const u = await o.undo(); if (u.ok) { renamedHere('task', t.uid, u.title); t.title = u.title; { const c = VW.current(); if (c && String(c.id).endsWith(t.uid)) VW.retitle(c.id, u.title); } load(); } return u; });
113
+ load();
114
+ } });
115
+ const iniRenameOf = (id, prefix) => initiativeRename({ pmPost, ws: WS || undefined, id, epics: ((H.boardRows(S.D).find((r) => r.id === id) || {}).epics) || [],
116
+ onSaved: (o) => {
117
+ renamedHere('ini', id, o.title);
118
+ if (o.jira) { S.phoneChat = isPhone(); openTarget(iniTarget(id)); setTimeout(() => { const ta = $('#hmIn'); if (ta) { ta.value = o.jira; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); } }, 0); }
119
+ toastUndo('Renamed', async () => { const u = await o.undo(); if (u.ok) { renamedHere('ini', id, u.title); VW.retitle('ov:' + id, (prefix || '') + u.title); load(); } return u; });
120
+ load();
121
+ } });
90
122
 
91
123
  /* ── reading ── */
92
124
  async function getRetry(path, tries = 20) {
@@ -184,11 +216,6 @@ function rowHtml(r, o = {}) {
184
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)}`
185
217
  + `<span class="hm-rt"><b>${esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
186
218
  }
187
- function groupHtml(key, title, rows, extra = '', head = '') {
188
- const shut = S.shut.has(key);
189
- 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>`
190
- + (shut ? '' : rows.map((r) => rowHtml(r)).join('') + extra) + '</section>';
191
- }
192
219
  /* ── the one list (premium-uncovered-features: HmMyWork, HmProducts, HmDay, HmMic, HmReview, HmPhone) ── */
193
220
  const NOW = () => S.D.now || Date.now();
194
221
  function recOf() { // a recording that is on and is no calendar meeting: the Today card shows it (HmMic)
@@ -217,7 +244,7 @@ function homeListHtml() {
217
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)
218
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));
219
246
  return TD.listHtml(M, todayModel(), {
220
- 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] : '',
221
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 }) : '',
222
249
  });
223
250
  }
@@ -280,6 +307,8 @@ const MS = '<i class="cz-ms" aria-hidden="true"></i>'; // the milestone mark (
280
307
  const msStep = (label) => !!(STEPS.find((s) => s.label === label) || {}).ms;
281
308
  /** "To reach ◆ Deliver": the milestone mark before a milestone's name in the checklist's title. */
282
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(' · '); }
283
312
  function cardHtml(id) {
284
313
  const prod = id === 'product';
285
314
  let kind, title, turn, turnLabel, stage, lad = '', bars = '', ckh, items, then, time, cta, primary, over = false, foldSum = '', msNext = false;
@@ -294,7 +323,7 @@ function cardHtml(id) {
294
323
  } else {
295
324
  const r = iniRowOf(id) || { title: (S.IM && S.IM.title) || id };
296
325
  const h = headOf(id); S.H = h;
297
- kind = [r.lane ? r.lane.charAt(0).toUpperCase() + r.lane.slice(1) : 'Feature', r.kr || r.anchor || ''].filter(Boolean).join(' · ');
326
+ kind = kindOf(id);
298
327
  title = r.title; turn = h.turn; turnLabel = h.turnLabel; stage = h.stage;
299
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>`;
300
329
  bars = `<div class="hm-bars" aria-hidden="true">${h.steps.map((s) => `<i class="${s.cls}"></i>`).join('')}</div>`;
@@ -307,10 +336,8 @@ function cardHtml(id) {
307
336
  then = h.payoff; time = h.time; over = h.over; cta = h.cta; primary = h.primary;
308
337
  foldSum = h.foldSum; msNext = msStep(h.toReach);
309
338
  }
310
- 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>`
311
- + `<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>`
312
- + `<button type="button" class="hm-ib sm" data-hm-switch aria-hidden="true" tabindex="-1">${SVG(I.down, 14, 2)}</button>`
313
- + `<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)}">`
314
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>`
315
342
  + lad + bars
316
343
  // the checklist folds to one line (AgInitSpec): its title, the summary and a chevron; Then and the time line show only unfolded
@@ -322,38 +349,18 @@ function cardHtml(id) {
322
349
  + `<div class="hm-acts"><button type="button" class="hm-cta${primary ? '' : ' alt'}" data-hm-cta>${esc(cta)}</button>`
323
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>`;
324
351
  }
325
- function iniListHtml() {
326
- const id = S.ini;
327
- const lay = H.iniLayout(S.D, id);
328
- if (id === 'product') { // the product's sessions are its update and its own chats
329
- const g = lay.groups.find((x) => x.key === 'sessions');
330
- const upd = S.D.sessions.filter((s) => H.keyOfSession(s) === H.UPDATE_KEY.slice(5) || H.keyOfSession(s) === H.UPDATE_KEY);
331
- if (upd.length && !g) lay.groups.splice(1, 0, { key: 'sessions', title: 'Sessions', rows: [] });
332
- }
333
- // 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)
334
- 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('');
335
- S.lay = lay;
336
- return cardHtml(id) + groups;
337
- }
338
- /** The Elsewhere card of an initiative's layout: pinned to the bottom of the list column, under the groups, never over them. */
339
- function elseHtml() {
340
- const e = S.ini && S.lay && S.lay.elsewhere;
341
- 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>` : '';
342
- }
343
352
  function drawList() {
344
353
  const el = $('#hmList');
345
- // 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)
346
355
  let sc = el.querySelector(':scope > .hm-lsc'), ft = el.querySelector(':scope > .hm-lft'), dy = el.querySelector(':scope > .hm-lday');
347
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; }
348
- const html = S.ini ? iniListHtml() : homeListHtml();
357
+ const html = homeListHtml();
349
358
  if (sc.__h !== html) {
350
359
  const st = sc.scrollTop, cap = sc.querySelector('#hmCap'), capV = cap ? cap.value : '', capF = !!cap && document.activeElement === cap;
351
360
  sc.__h = html; sc.innerHTML = html; sc.scrollTop = st;
352
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
353
362
  const c2 = sc.querySelector('#hmCap'); if (c2 && capV) { c2.value = capV; } if (c2 && capF) c2.focus(); // a task being typed survives a redraw
354
363
  }
355
- const fh = elseHtml();
356
- if (ft.__h !== fh) { ft.__h = fh; ft.innerHTML = fh; }
357
364
  const dh = dayHtml();
358
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)); }
359
366
  document.body.classList.toggle('hm-dayon', !!dh);
@@ -377,7 +384,6 @@ function allRows() {
377
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); }
378
385
  if (M.list) M.list.rows.forEach(add);
379
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); }); }
380
- if (S.lay) S.lay.groups.forEach((g) => g.rows.forEach(add));
381
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); }
382
388
  return out;
383
389
  }
@@ -558,6 +564,51 @@ function updateTarget() {
558
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.',
559
565
  placeholder: 'Tell Communicator what to change', also: null };
560
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
+ }
561
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. */
562
613
  function programTarget(id, task) {
563
614
  const pr = (S.D.programs || []).find((p) => p && p.id === id) || { id, title: (P.get('label') || '').slice(0, 80) || id };
@@ -584,6 +635,7 @@ function select(id, o = {}) {
584
635
  if (!r) { S.phoneChat = false; if (S.ini) openTarget(iniTarget(S.ini)); else openTarget(homeTarget()); drawList(); return; }
585
636
  if (r.kind === 'ini') { goIni(r.ini); return; }
586
637
  if (r.kind === 'product') { goIni('product'); return; }
638
+ S.head = null;
587
639
  // a row with a conversation opens it; on a phone it opens over the list, with a back bar (HmPhone2)
588
640
  if (isPhone() && (r.kind === 'update' || (r.kind === 'need' && r.row) || r.kind === 'session' || r.needSession)) S.phoneChat = true;
589
641
  if (r.kind === 'update') { openTarget(updateTarget()); if (!o.keepViewer) openUpdateViewer(); }
@@ -600,18 +652,39 @@ function select(id, o = {}) {
600
652
  drawList();
601
653
  syncUrl();
602
654
  }
603
- async function goIni(id) {
604
- 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; }
605
661
  if (isPhone()) sheet(false);
606
662
  syncUrl();
607
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(); }
608
667
  await loadIni();
609
668
  if (S.ini !== id) return;
610
- drawList();
611
- if (id === 'product') { openTarget(updateTarget()); if (!VW.isOpen() && !isPhone()) openUpdateViewer(); }
612
- else openTarget(iniTarget(id));
669
+ drawList(); openTarget(iniTarget(id));
613
670
  }
614
- 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(); } });
615
688
  function syncUrl() {
616
689
  const q = new URLSearchParams(location.search);
617
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); });
@@ -620,7 +693,7 @@ function syncUrl() {
620
693
  if (r && r.kind === 'ptask') q.set('item', r.id); // a program task: pt:<program>:<key>, the link the program panel makes
621
694
  else if (r && r.key && r.kind !== 'session') q.set('open', r.key); else if (r && r.sid) q.set('session', r.sid);
622
695
  const s = q.toString();
623
- history.replaceState(null, '', location.pathname + (s ? '?' + s : ''));
696
+ history.replaceState(history.state, '', location.pathname + (s ? '?' + s : ''));
624
697
  }
625
698
 
626
699
  /* ── the one list's own views: a task, a mention, finished work, the weekly review (premium-uncovered-features) ── */
@@ -641,6 +714,7 @@ function openBoardTask(t) {
641
714
  },
642
715
  openRecord: (task) => import('./premium-vw-item.js').then((V) => V.openWorkItem({ kind: 'task', ini: task.ini, key: 'task:' + task.uid, title: task.title, ws: boardWs(), board: boardId() })).catch(() => toast('The record could not open.')),
643
716
  onChange: () => load(),
717
+ rename: taskRenameOf,
644
718
  }));
645
719
  }
646
720
  function openFinished(f) {
@@ -846,7 +920,7 @@ async function sendUpdate() {
846
920
 
847
921
  /* the overview of an initiative: stage moves and hold, Tasks, Core documents (no design yet: a minimal version) */
848
922
  function openOverview() {
849
- if (iniOverview()) return;
923
+ if (iniPage()) return;
850
924
  const id = S.ini; if (!id || id === 'product') return;
851
925
  let M = S.IM;
852
926
  let ask = null; // on-hold | cancelled while its reason is asked
@@ -1177,7 +1251,8 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1177
1251
  if ('hmDay' in d) { day(!S.day); return; }
1178
1252
  if ('hmDayx' in d) { day(false); return; }
1179
1253
  if ('hmFlt' in d) { filterMenu(b); return; }
1180
- 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; }
1181
1256
  if (d.hmKids) { // the chevron of an initiative: what sits under it shows or hides
1182
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); }
1183
1258
  keepKids(); drawList(); const f = $(`#hmList [data-hm-kids="${CSS.escape(d.hmKids)}"]`); if (f) f.focus(); return;
@@ -1201,14 +1276,6 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1201
1276
  if ('hmCal' in d) { openCalendar(); return; }
1202
1277
  if ('hmRec' in d) { MORE.openRecorder().then(() => drawList()); return; }
1203
1278
  if (d.hmRecopen) { openMeeting({ note: d.hmRecopen }); return; }
1204
- 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; }
1205
- if ('hmNewin' in d) { if (S.ini === 'product') { openTarget(updateTarget()); chat.focus(); } else newIn(S.ini); return; }
1206
- if ('hmDone' in d) { S.doneOpen = !S.doneOpen; drawList(); return; }
1207
- 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; }
1208
- if ('hmCta' in d) { cta(); return; }
1209
- if ('hmOv' in d) { if (S.ini === 'product') openUpdateViewer(); else openOverview(); return; }
1210
- if ('hmElse' in d) { const f = S.lay && S.lay.elsewhere && S.lay.elsewhere.first; goHome(); if (f) select(f.id); return; }
1211
- if ('hmPerson' in d) addPerson();
1212
1279
  };
1213
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); } });
1214
1281
  $('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
@@ -1272,8 +1339,15 @@ function cta() {
1272
1339
  }
1273
1340
 
1274
1341
  /* ── start ── */
1275
- mountIni({ S, VW, pmGet, pmPost, toast, load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT });
1276
- 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(); } });
1277
1351
  PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m) }); drawList();
1278
1352
  drawList(); drawTop();
1279
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); } }