create-pmos 0.426.0 → 0.428.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 (78) hide show
  1. package/package.json +25 -25
  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/board-programs-test.js +16 -2
  7. package/workspace/briefing-premium-board-test.js +25 -20
  8. package/workspace/briefing-premium-test.js +2 -1
  9. package/workspace/changelog.json +24 -0
  10. package/workspace/guide/briefing-premium.md +4 -2
  11. package/workspace/guide/claude-proposes.md +3 -1
  12. package/workspace/guide/home.md +32 -7
  13. package/workspace/guide/programs.md +1 -0
  14. package/workspace/home-other-product-test.js +12 -2
  15. package/workspace/lib/context-use.js +54 -0
  16. package/workspace/lib/routes-live.js +3 -1
  17. package/workspace/lib/routes-meeting-material.js +22 -1
  18. package/workspace/lib/settings-store.js +14 -0
  19. package/workspace/lib/transcript-read.js +9 -2
  20. package/workspace/milestone-pins-test.js +13 -0
  21. package/workspace/milestone-suggest-test.js +10 -4
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/premium-board-actions-test.js +40 -13
  25. package/workspace/premium-rec-tab-test.js +8 -0
  26. package/workspace/premium-vw-item-test.js +7 -3
  27. package/workspace/premium-vw-jira-test.js +2 -1
  28. package/workspace/program-charter-test.js +1 -1
  29. package/workspace/program-leave-test.js +2 -2
  30. package/workspace/program-order-test.js +3 -2
  31. package/workspace/program-panel-test.js +2 -1
  32. package/workspace/public/pm/bd-acts.js +20 -26
  33. package/workspace/public/pm/bd-ini-panel.js +90 -32
  34. package/workspace/public/pm/bd-pin-card.js +4 -1
  35. package/workspace/public/pm/bd-span.js +22 -12
  36. package/workspace/public/pm/cozy-home.css +7 -0
  37. package/workspace/public/pm/cozy-live-pill.css +1 -0
  38. package/workspace/public/pm/cozy-live-pill.js +2 -1
  39. package/workspace/public/pm/cozy-rec-tab.js +12 -3
  40. package/workspace/public/pm/cozy-today.css +3 -0
  41. package/workspace/public/pm/cozy-viewer.js +157 -23
  42. package/workspace/public/pm/cozy-vw-shell.css +13 -0
  43. package/workspace/public/pm/cozy.css +6 -0
  44. package/workspace/public/pm/ctx-wedge.js +45 -0
  45. package/workspace/public/pm/hi-pop.css +82 -0
  46. package/workspace/public/pm/hi-pop.js +65 -0
  47. package/workspace/public/pm/home-app.js +70 -28
  48. package/workspace/public/pm/home-chat.js +7 -2
  49. package/workspace/public/pm/home-data.js +2 -1
  50. package/workspace/public/pm/home-ini.css +6 -76
  51. package/workspace/public/pm/home-ini.js +50 -68
  52. package/workspace/public/pm/home-list.js +29 -3
  53. package/workspace/public/pm/home-today.js +26 -9
  54. package/workspace/public/pm/ini-more.js +67 -0
  55. package/workspace/public/pm/ini-view-model.js +3 -2
  56. package/workspace/public/pm/ini-view.css +3 -1
  57. package/workspace/public/pm/ini-view.js +7 -5
  58. package/workspace/public/pm/live-model.js +1 -1
  59. package/workspace/public/pm/order-model.js +85 -0
  60. package/workspace/public/pm/premium-board.js +57 -11
  61. package/workspace/public/pm/premium-insights.js +11 -1
  62. package/workspace/public/pm/premium-vw-item.js +3 -1
  63. package/workspace/public/pm/premium-vw-jira.js +2 -0
  64. package/workspace/public/pm/prog-order.js +15 -2
  65. package/workspace/public/pm/sort-order.css +17 -0
  66. package/workspace/public/pm/sort-order.js +108 -0
  67. package/workspace/public/pm/tk-view.js +3 -2
  68. package/workspace/public/pm/wf-page.js +1 -1
  69. package/workspace/public/premium-board.html +1 -0
  70. package/workspace/server.js +28 -0
  71. package/workspace/sort-order-test.js +201 -0
  72. package/workspace/stage-card-test.js +1 -0
  73. package/workspace/task-card-test.js +1 -1
  74. package/workspace/test-lists/batch13-context-use.json +5 -0
  75. package/workspace/test-lists/sort-order.json +6 -0
  76. package/workspace/test-lists/viewer-trail.json +5 -0
  77. package/workspace/tk-tasks-test.js +5 -3
  78. package/workspace/viewer-trail-test.js +145 -0
@@ -44,6 +44,8 @@ import { mountRecRow, clockOf as recClock } from './home-rec-row.js';
44
44
  import { mountSesName } from './home-ses-name.js'; // session names A: tap the session's name to rename it (canvas XmsNames)
45
45
  import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
46
46
  import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other, LpA4Phone)
47
+ import * as CW from './ctx-wedge.js'; // how full a session's context is, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
48
+ import * as SO from './sort-order.js'; // the sort button and ONE order with the Board (batch 14 item 8, canvas SoAHomePhone)
47
49
  import * as PO from './prog-order.js'; // a program's order on Home: the grip, hold-then-drag on a phone, ✦ Claude's order from the dates (canvas RoAPhone)
48
50
  import * as LPV from './loose-props.js'; // Claude's clean-up of "Not in an initiative": the ✦ on its header and the Viewer (batch 13 item 3)
49
51
  import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
@@ -159,7 +161,7 @@ async function load() {
159
161
  const [brief, board, ses, desk, today, sch, work, day, rev, progs, , pick] = await Promise.all([
160
162
  getRetry('/api/briefing-premium' + wsQ()), getRetry('/api/board-premium' + wsQ() + boardQ(WS ? '&' : '?')), pmGet('/api/sessions'), pmGet('/api/home-desk' + wsQ()),
161
163
  pmGet('/api/brief-page' + wsQ()), pmGet('/api/schedules' + wsQ()), pmGet('/api/my-work-premium' + wsQ()), pmGet('/api/phone-day'), pmGet('/api/home-review' + wsQ()),
162
- pmGet('/api/programs'), MEN.load(menCtx()), PP.readPick(),
164
+ pmGet('/api/programs'), MEN.load(menCtx()), PP.readPick(), SO.load(),
163
165
  ]);
164
166
  const D = S.D;
165
167
  D.brief = brief && brief.ok && brief.model ? brief.model : null;
@@ -172,6 +174,7 @@ async function load() {
172
174
  D.phoneDay = day && day.ok ? day : null; // what finished today, the recap and tomorrow (the end-of-day card, the Done filter)
173
175
  D.review = rev && rev.ok ? rev : null; // this week's review (GET /api/home-review)
174
176
  D.programs = progs && progs.ok ? progs.programs : []; // programs above initiatives, across products (GET /api/programs)
177
+ D.order = SO.layout(); // the PM's sort and own order, shared with the Board (batch 14 item 8)
175
178
  D.pick = pick || D.pick || null; // the one product pick (the chip): which products are on Home and read
176
179
  if (D.pick && WS) D.pick = { ...D.pick, products: D.pick.products.map((p) => ({ ...p, on: p.ws === WS })) }; // ?ws= is a one-off view of that product
177
180
  D.now = Date.now();
@@ -291,13 +294,16 @@ function homeListHtml() {
291
294
  pick: S.D.pick, tones: pickTones(), review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
292
295
  });
293
296
  }
294
- /** Your day (XvAPhDay, was the HvAOpen sheet): "Good morning" opens it in the Viewer, shell A. Full screen on a phone, beside the chat on a
295
- * desktop; on a phone the moment card (TfPhone) is its Now section, and the calendar is under ⋯. */
297
+ /** Your day (XvAPhDay, was the HvAOpen sheet), a phone only: "Good morning" opens it in the Viewer, full screen; the moment card (TfPhone) is
298
+ * its Now section, and the calendar is under ⋯. On a desktop "Good morning" opens the calendar (batch 14 item 4). */
296
299
  function dayHtml() { return ''; }
297
300
  function day(on) {
298
301
  S.day = !!on;
299
302
  if (!on) { const c = VW.current(); if (c && c.id === 'day') VW.close(); return; }
300
303
  if (!S.M) return;
304
+ // a desktop has no Your day any more (batch 14 item 4): the greeting opens the calendar in the Viewer; the list already holds every next step.
305
+ // A phone keeps Your day: its moment card (TfPhone) lives there
306
+ if (!isPhone()) { S.day = false; openCalendar(); return; }
301
307
  const Y = YD.dayModel(S.M, S.D, L.reviewModel(S.D, NOW()), NOW());
302
308
  const ph = isPhone() && PHC;
303
309
  const P = YD.dayParts(Y, { moment: !!ph });
@@ -488,7 +494,7 @@ function drawTop() {
488
494
  // is back + that name only, no second line (XmsNames, XcbOptions)
489
495
  const ses = cur.ses ? S.D.sessions.find((x) => x.id === cur.ses) : null;
490
496
  const title = ses ? H.nameOf(ses) : cur.title;
491
- const th = ses && isPhone() ? SN.titleHtml(ses.id, title) : esc(title || '');
497
+ const th = ses && isPhone() ? SN.titleHtml(ses.id, title) + CW.wedgeHtml(ses.ctx) : esc(title || ''); // its context pie after the name (XctxA2Phones)
492
498
  const tb = $('#hmTopTitle'); if (tb.__h !== th) { tb.__h = th; tb.innerHTML = th; }
493
499
  $('#hmTopSub').textContent = '';
494
500
  $('#hmNeedsN').textContent = !S.ready ? 'Reading' : n ? n + (n === 1 ? ' next step' : ' next steps') : 'Today';
@@ -516,6 +522,10 @@ const chat = mountChat($('#hmChat'), {
516
522
  unqueue: (sid, at) => { pmPost('/api/home-desk/queue-drop', { session: sid, at }); if (S.D.desk && S.D.desk.queued && S.D.desk.queued[sid]) S.D.desk.queued[sid] = S.D.desk.queued[sid].filter((x) => x.at !== at); },
517
523
  onScope: (b) => menu(b, scopeItems(), 'Where this goes'),
518
524
  suggestLink: (t, first) => suggestLink(t, first),
525
+ // Claude's ✦ Compact in the chat's offer chip (batch 13 item 8): only when the link chip has nothing to say
526
+ compactOffer: (sid) => { const s = S.D.sessions.find((x) => x.id === sid); const w = s && CW.compactOffer(s.ctx, !!(s.close_ok && s.close_ok.safe), sid); return w ? { text: w, pct: s.ctx.pct } : null; },
527
+ compact: (sid) => compact(sid),
528
+ dismissCompact: (sid, pct) => CW.hideOffer(sid, pct),
519
529
  linkTo: (sid, ini) => link(sid, ini),
520
530
  dismissLink: (sid) => { try { localStorage.setItem('cz-linksug-x:' + sid, '1'); } catch { /* a private window: it shows again next time */ } },
521
531
  onLink: (b, t) => menu(b, H.boardRows(S.D).map((r) => ({ label: r.title, sub: r.stage, go: () => link(t.sid, r.id) })), 'Link it to an initiative'),
@@ -538,7 +548,7 @@ function chatHead(t) {
538
548
  if (t.prog) return { row: r, title: t.title, scope: t.prog.title, prog: true };
539
549
  const title = r && r.kind !== 'ini' ? r.name : t.title;
540
550
  // session names A: an open session's name is the rename press (or the field while it is renamed)
541
- if (t.ses) { const s = S.D.sessions.find((x) => x.id === t.ses); if (s) return { ...chatHeadOf(t, r, H.nameOf(s)), titleHtml: SN.titleHtml(s.id, H.nameOf(s), 'hm-chb') }; }
551
+ if (t.ses) { const s = S.D.sessions.find((x) => x.id === t.ses); if (s) return { ...chatHeadOf(t, r, H.nameOf(s)), titleHtml: SN.titleHtml(s.id, H.nameOf(s), 'hm-chb'), ctx: s.ctx || null }; }
542
552
  return chatHeadOf(t, r, title);
543
553
  }
544
554
  function chatHeadOf(t, r, title) {
@@ -689,12 +699,24 @@ function productTarget() {
689
699
  context: 'Product ' + name + '. ' + C.of + (C.items.length ? ': ' + C.items.map((x) => x.label).join('; ') : '') + '.', also: null };
690
700
  }
691
701
  /** 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. */
702
+ /** Tap the product's name in its page's header to rename it (batch 14 item 9, the rename press RnA* agreed for programs, initiatives and
703
+ * tasks): POST /api/workspaces/rename keeps the PM's name for the repository (its id does not move), so Home, the Board and the pick
704
+ * show it. Undo puts the old name back. A product with no workspace id has no press. */
705
+ const productRename = (ws, name, vid) => (ws ? { value: name, max: 80, save: async (t) => {
706
+ let r = null; try { r = await pmPost('/api/workspaces/rename', { id: ws, name: t }); } catch { r = null; }
707
+ if (!r || !r.ok) return { ok: false, error: (r && r.error) || 'The name could not be saved.' };
708
+ toastUndo('Renamed', async () => { let u = null; try { u = await pmPost('/api/workspaces/rename', { id: ws, name }); } catch { u = null; } if (u && u.ok) { VW.retitle(vid, name); load(); } return u && u.ok ? { ok: true } : { ok: false, error: 'The old name could not be put back.' }; });
709
+ load();
710
+ return { ok: true, title: t };
711
+ } } : null);
712
+ /** The name Home shows for the board's own product: its group's name (the PM's name for the repository wins), else the board's. */
713
+ const ownProductName = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return (g && g.name) || H.productName(S.D); };
692
714
  const productKey = () => { const g = ((S.M && S.M.groups) || []).find((x) => x.kind === 'product' && x.primary); return g ? g.key : null; };
693
715
  /** 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
694
716
  * metrics review. A press opens that one; ← comes back to the page. */
695
717
  function openProductPage() {
696
- const name = H.productName(S.D);
697
- VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart',
718
+ const name = ownProductName();
719
+ VW.open({ id: 'product', kind: 'Product', title: name, icon: 'chart', rename: productRename(boardWs(), name, 'product'),
698
720
  render: (b) => {
699
721
  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);
700
722
  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>';
@@ -813,11 +835,12 @@ async function goIni(id, o = {}) {
813
835
  S.ini = id; S.sel = null; S.head = id === 'product' ? productKey() : null; S.doneOpen = false; S.stepsMore = false;
814
836
  if (was !== id) { S.IM = null; S.IMid = null; }
815
837
  if (isPhone()) sheet(false);
816
- syncUrl();
817
838
  drawList();
818
- if (id === 'product') { openTarget(productTarget()); if (o.page !== false) { pushPage(); openProductPage(); } return; }
839
+ // the address follows the page, so the entry before it (the trail's start, batch 14 item 7) keeps Home's own address
840
+ if (id === 'product') { openTarget(productTarget()); if (o.page !== false) { pushPage(); openProductPage(); } syncUrl(); return; }
819
841
  openTarget(iniTarget(id));
820
842
  if (o.page !== false) { pushPage(); iniPage(); }
843
+ syncUrl();
821
844
  await loadIni();
822
845
  if (S.ini !== id) return;
823
846
  drawList(); openTarget(iniTarget(id));
@@ -836,7 +859,7 @@ function goOtherProduct(g) {
836
859
  openTarget(t);
837
860
  pushPage();
838
861
  const own = '/premium.html?ws=' + encodeURIComponent(ws) + '&ini=product';
839
- VW.open({ id: 'product:' + ws, kind: 'Product', title: name, icon: 'chart',
862
+ VW.open({ id: 'product:' + ws, kind: 'Product', title: name, icon: 'chart', rename: productRename(ws, name, 'product:' + ws),
840
863
  render: (b) => {
841
864
  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>';
842
865
  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>`
@@ -857,12 +880,11 @@ function goProgram(id) {
857
880
  programPanel().then(() => { if (S.head === 'g:' + id) document.dispatchEvent(new CustomEvent('bd:program', { detail: { id } })); }).catch(() => toast('The program could not open.'));
858
881
  }
859
882
  function goHome() { S.ini = null; S.sel = null; S.IM = null; S.head = null; S.phoneChat = false; syncUrl(); drawList(); openTarget(homeTarget()); }
860
- /* 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
861
- * was. Close (×, Escape) takes the entry off too, so Back never stops at a page that is already closed. */
862
- let pushed = false;
863
- function pushPage() { if (pushed) return; pushed = true; history.pushState({ hmVw: 1 }, '', location.href); }
864
- addEventListener('popstate', () => { if (!pushed) return; pushed = false; if (VW.isOpen()) VW.close(); goHome(); });
865
- VW.onChange((d) => { if (!d.open && pushed) { pushed = false; history.back(); } });
883
+ /* The browser's Back closes the page a name opened (HbC). The Viewer keeps the one trail and its history entries (batch 14 item 7): Back
884
+ * at the trail's first item closes it, and Home is then as it was. Close (×, Escape) takes the entries off and keeps the initiative's chat. */
885
+ let paged = false;
886
+ function pushPage() { paged = true; }
887
+ VW.onChange((d) => { if (!d.open && paged) { paged = false; if (d.via === 'history') goHome(); } }); // × keeps the initiative's chat
866
888
  function syncUrl() {
867
889
  const q = new URLSearchParams(location.search);
868
890
  ['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); });
@@ -871,7 +893,7 @@ function syncUrl() {
871
893
  if (r && r.kind === 'ptask') q.set('item', r.id); // a program task: pt:<program>:<key>, the link the program panel makes
872
894
  else if (r && r.key && r.kind !== 'session') q.set('open', r.key); else if (r && r.sid) q.set('session', r.sid);
873
895
  const s = q.toString();
874
- history.replaceState(history.state, '', location.pathname + (s ? '?' + s : ''));
896
+ VW.replaceUrl(location.pathname + (s ? '?' + s : '')); // after the history settles, so it lands on the entry Home shows
875
897
  }
876
898
 
877
899
  /* ── the one list's own views: a task, a mention, finished work, the weekly review (premium-uncovered-features) ── */
@@ -915,7 +937,7 @@ function openReviewVw() {
915
937
  },
916
938
  }));
917
939
  }
918
- /* New → A task: the PM names the initiative first. An initiative's task is added in its page's Tasks field, the cursor in it (XtaA4NewTask);
940
+ /* New → Task: in the open initiative, else the PM names the initiative. An initiative's task is added in its page's Tasks field, the cursor in it (XtaA4NewTask);
919
941
  * "Not in an initiative" opens the capture box in the list, on the PM's own list (POST /api/pm-items/add). The box is not on Home otherwise. */
920
942
  async function addTaskIn(id) {
921
943
  if (!id) { S.cap = true; drawList(); const i = $('#hmCap'); if (i) i.focus(); return; }
@@ -1316,21 +1338,32 @@ function recLive() {
1316
1338
  }
1317
1339
 
1318
1340
  /* ── New, end, kids ── */
1341
+ /* New (batch 14 item 10, canvas PmA*): four kinds, an icon and one word each, the Board's New in the same look. Each lands where the PM is:
1342
+ * the open initiative, else the open product's chat, else Home (a task asks where, "Not in an initiative" first; a chat is loose, linked
1343
+ * later). The place shows on the right, quiet. Quick ask and "Next step of an initiative" went: Home's chat box is always there, and the
1344
+ * list's rows already open where a next step waits. Initiative opens the Board's New initiative panel (?new=initiative), in that product. */
1345
+ const NEW_ICON = { task: 'M5 5h14v14H5zM9 12l2 2 4-4', ini: 'M12 4a8 8 0 1 0 0 16a8 8 0 1 0 0-16M12 9a3 3 0 1 0 0 6a3 3 0 1 0 0-6' };
1319
1346
  function newItems() {
1320
1347
  const here = S.ini && S.ini !== 'product' ? S.ini : null;
1321
1348
  const inis = H.boardRows(S.D);
1322
1349
  const cur = chat.current(), prod = !here && cur && /^chat:product/.test(cur.key || '') && cur.newChat ? cur : null; // a product's chat is open: its own new session
1350
+ const where = here ? iniTitle(here) : prod ? prod.about : '';
1351
+ const pickTask = (b) => menu(b, [{ label: 'Not in an initiative', icon: NEW_ICON.task, go: () => addTaskIn(null) }, { sep: true }]
1352
+ .concat(inis.filter(H.OPEN).map((r) => ({ label: r.title, sub: r.stage, go: () => addTaskIn(r.id) }))), 'Task in');
1353
+ const ws = here ? iniWsOf(here) : prod ? prod.ws : boardWs();
1323
1354
  return [
1324
- { label: 'A task', sub: 'Choose its initiative first', go: (b) => menu(b, inis.filter(H.OPEN).map((r) => ({ label: r.title, sub: r.stage, go: () => addTaskIn(r.id) }))
1325
- .concat([{ sep: true }, { label: 'Not in an initiative', sub: 'Your own list', go: () => addTaskIn(null) }]), 'Under which initiative') },
1326
- { label: 'Next step of an initiative', sub: 'Open where it waits', go: (b) => menu(b, inis.map((r) => ({ label: r.title, sub: r.stage, go: () => goIni(r.id) })), 'Which initiative') },
1327
- prod ? { label: 'New session in ' + prod.about, sub: 'A fresh chat with its own history', go: () => prod.newChat() }
1328
- : { label: here ? 'New session in ' + iniTitle(here) : 'New session in an initiative', sub: 'A fresh chat with its own history', go: (b) => (here ? newIn(here) : menu(b, inis.map((r) => ({ label: r.title, sub: r.stage, go: () => newIn(r.id) })), 'In which initiative')) },
1329
- { label: 'Quick ask', sub: 'Your own chat, about all work', go: () => { goHome(); chat.focus(); } },
1330
- { label: 'Something unrelated', sub: 'A loose chat; link it later', go: () => newLoose() },
1331
- { label: 'Record a note now', sub: 'A conversation that is not on the calendar', go: () => MORE.openRecorder().then(() => drawList()) },
1355
+ { label: 'Task', icon: NEW_ICON.task, k: here ? where : '', go: (b) => (here ? addTaskIn(here) : pickTask(b)) },
1356
+ { label: 'Chat', icon: TD.P.chat, k: where, go: () => (here ? newIn(here) : prod ? prod.newChat() : newLoose()) },
1357
+ { label: 'Recording', icon: TD.P.mic, go: () => MORE.openRecorder().then(() => drawList()) },
1358
+ { sep: true },
1359
+ { label: 'Initiative', icon: NEW_ICON.ini, k: prod ? where : '', go: () => { location.href = '/premium-board.html?new=initiative' + (ws ? '&ws=' + encodeURIComponent(ws) : ''); } },
1332
1360
  ];
1333
1361
  }
1362
+ /** The initiative's conversation with a question typed in the box, not sent (the ⋯ menu's Change the plan dates, as the Board's ?ask=&q=). */
1363
+ function askIn(id, q) {
1364
+ S.phoneChat = isPhone(); openTarget(iniTarget(id));
1365
+ setTimeout(() => { const ta = $('#hmIn'); if (ta) { ta.value = q; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); ta.setSelectionRange(q.length, q.length); } }, 0);
1366
+ }
1334
1367
  function newIn(id) {
1335
1368
  const used = new Set(S.D.sessions.map((s) => H.keyOfSession(s)).filter(Boolean));
1336
1369
  let n = 2; while (used.has('init:' + id + ':' + n)) n++;
@@ -1457,6 +1490,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1457
1490
  if (d.hmSes) { sesPill(d.hmSes === S.ses ? null : d.hmSes); return; } // an initiative's pill: what sits in it, under it (a sheet on a phone)
1458
1491
  if ('hmSesx' in d) { sesPill(null); return; }
1459
1492
  if (d.hmSesnew) { sesPill(null, false); newIn(d.hmSesnew); return; }
1493
+ if (d.hmCompact) { compact(d.hmCompact); return; } // ✓ on Claude's ✦ Compact (batch 13 item 8): the pill's list stays open
1460
1494
  if (S.ses && !b.closest('.hv-spp, .hv-sps')) sesPill(null, false); // a press anywhere else in the list closes it
1461
1495
  if (d.hmSel) { if (S.ses) sesPill(null, false); if (S.day) S.day = false; select(d.hmSel); return; }
1462
1496
  if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
@@ -1483,7 +1517,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1483
1517
  if (d.hmEnd) { endRow(d.hmEnd); return; }
1484
1518
  if (d.hmGroup) { if (S.shut.has(d.hmGroup)) S.shut.delete(d.hmGroup); else S.shut.add(d.hmGroup); store.set('pmos.home.shut', JSON.stringify([...S.shut])); drawList(); return; }
1485
1519
  if ('hmAllneeds' in d) { S.allNeeds = !S.allNeeds; drawList(); return; }
1486
- if ('hmNew' in d) { menu(b, newItems(), 'What is it for?'); return; }
1520
+ if ('hmNew' in d) { menu(b, newItems(), 'New'); return; }
1487
1521
  if ('hmFold' in d) { S.folded = true; store.set('pmos.home.fold', '1'); drawList(); return; }
1488
1522
  if ('hmMeet' in d) { const m = H.meetLineOf(S.D.today); if (m) openMeeting(m.meeting); return; }
1489
1523
  if ('hmCal' in d) { openCalendar(); return; }
@@ -1492,6 +1526,13 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1492
1526
  if (d.hmRecopen) { if (!(ownTab() && bring(tabUrl(d.hmRecopen, { ws: WS || '' })))) openMeeting({ note: d.hmRecopen }); return; }
1493
1527
  };
1494
1528
  $('#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); } });
1529
+ /** Claude's ✦ Compact, accepted (batch 13 item 8): type /compact into that session. Its pie shrinks after the session's next reply. */
1530
+ async function compact(sid) {
1531
+ const s = S.D.sessions.find((x) => x.id === sid);
1532
+ const r = await pmPost('/api/session/compact', { id: sid });
1533
+ if (r && r.ok && s && s.ctx) { CW.hideOffer(sid, s.ctx.pct); drawList(); } // the ✦ stays away until the session's next reply moves the pie
1534
+ toast(r && r.ok ? 'Compacting “' + (s ? H.nameOf(s) : 'the session') + '”. Its context shrinks when it answers.' : (r && r.error) || 'Nothing was typed.');
1535
+ }
1495
1536
  /** Open (id) or close (null) the list behind an initiative's pill (batch 12 item 6). Closing gives the focus back to the pill, unless the
1496
1537
  * press that closed it goes somewhere else (back false). */
1497
1538
  function sesPill(id, back = true) {
@@ -1573,7 +1614,7 @@ function cta() {
1573
1614
  mountIni({ S, VW, pmGet, pmPost, toast, rowOf: (id) => iniRowOf(id), 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,
1574
1615
  // the initiative's page (HbCDesk): its card, its header and its ⋯
1575
1616
  openBoardTask: (t) => openBoardTask(t),
1576
- cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), smItems: (id, openList) => smItems(id, openList), smPress: (id, act) => SM.press(smCtx(id), act), goIni: (id) => goIni(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1617
+ cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), askIn: (id, q) => askIn(id, q), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), smItems: (id, openList) => smItems(id, openList), smPress: (id, act) => SM.press(smCtx(id), act), goIni: (id) => goIni(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1577
1618
  foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1578
1619
  /* 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.
1579
1620
  * 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. */
@@ -1582,6 +1623,7 @@ const programPanel = () => progPanel || (progPanel = import('./bd-prog-panel.js'
1582
1623
  PO.mount({ programs: () => S.D.programs || [], stateOf: (p) => (((S.M && S.M.groups) || []).find((g) => g.kind === 'program' && g.program.id === p.id) || {}).st || null,
1583
1624
  saved: (p) => { const L2 = S.D.programs || [], i = L2.findIndex((x) => x.id === p.id); if (i >= 0) L2[i] = { ...L2[i], ...p }; drawList(); },
1584
1625
  say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)), openIni: (id) => goIni(id) });
1626
+ SO.mount({ redraw: () => { S.D.order = SO.layout(); drawList(); }, say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) });
1585
1627
  mountNav('home', document, { more: () => moreMenu, settings: () => MORE.openSettings(), here: () => { if (VW.isOpen()) VW.close(); goHome(); } });
1586
1628
  // the Live pill (batch 6 item 2): on Home a row opens in place, the session's chat (with its Viewer page) or the meeting; the open one is tinted
1587
1629
  mountLivePill(document, {
@@ -159,8 +159,11 @@ export function mountChat(el, host) {
159
159
  // A loose chat that reads like one initiative gets one quiet chip at its top: "Looks like <initiative> · Link it ×" (XvALinkSuggest).
160
160
  function drawSug() {
161
161
  const t = C.t, g = t && t.scope && t.scope.loose && t.sid && host.suggestLink ? host.suggestLink(t, firstUser()) : null;
162
- sug.hidden = !g; C.sug = g;
163
- put(sug, g ? `<span class="hm-sugc">Looks like <b>${esc(g.title)}</b><button type="button" class="hm-sugl" data-hm-sug="link">Link it</button><button type="button" class="hm-sugx" data-hm-sug="x" aria-label="Not this one" title="Not this one">${SVG(XX, 13)}</button></span>` : '');
162
+ // with nothing to link, the same chip carries Claude's ✦ Compact from 70% on the PM's turn (batch 13 item 8, XctxA1Desk): ✓ types /compact
163
+ const cp = !g && sid() && host.compactOffer ? host.compactOffer(sid()) : null;
164
+ sug.hidden = !g && !cp; C.sug = g; C.cpt = cp;
165
+ put(sug, g ? `<span class="hm-sugc">Looks like <b>${esc(g.title)}</b><button type="button" class="hm-sugl" data-hm-sug="link">Link it</button><button type="button" class="hm-sugx" data-hm-sug="x" aria-label="Not this one" title="Not this one">${SVG(XX, 13)}</button></span>`
166
+ : cp ? `<span class="hm-sugc cpt"><i class="hm-sugs" aria-hidden="true">✦</i><span class="hm-sugw">${esc(cp.text)}</span><button type="button" class="hm-sugx ok" data-hm-cpt="ok" aria-label="Compact this session" title="Compact (types /compact)">${SVG(OK, 13)}</button><button type="button" class="hm-sugx" data-hm-cpt="x" aria-label="Not now" title="Not now">${SVG(XX, 13)}</button></span>` : '');
164
167
  }
165
168
  function draw() {
166
169
  const t = C.t; if (!t) return;
@@ -438,6 +441,8 @@ export function mountChat(el, host) {
438
441
  return;
439
442
  }
440
443
  const b = e.target.closest('button, [data-file], [data-att], [data-ctx]'); if (!b || !el.contains(b)) return;
444
+ // ✓ types /compact (and hides the ✦ until the pie moves); ✕ hides it until the session is 10 points fuller
445
+ if (b.dataset.hmCpt && C.cpt) { if (b.dataset.hmCpt === 'ok') host.compact(sid()); else host.dismissCompact(sid(), C.cpt.pct); C.cpt = null; sug.hidden = true; put(sug, ''); return; }
441
446
  if (b.dataset.hmSug && C.sug) { const g = C.sug; if (b.dataset.hmSug === 'link') host.linkTo(C.t.sid, g.id); else { host.dismissLink(C.t.sid); drawSug(); } return; }
442
447
  const d = b.dataset;
443
448
  const ic = b.closest('.hm-icard'), card = C.t && C.t.intro && C.t.intro.card;
@@ -73,7 +73,8 @@ export function sessionRow(s, roles) {
73
73
  const name = nameOf(s);
74
74
  return { id: 's:' + s.id, kind: 'session', sid: s.id, key: keyOfSession(s), ini: iniOfSession(s), name, state: st, initial: role.initial, role,
75
75
  hint: role.name, icon: 'chat', created: s.created || '', prog: s.progress && s.progress.n > 0 ? s.progress : null,
76
- ...(s.close_ok && st === 'quiet' ? { close: s.close_ok } : {}) }; // idle 30 min: { safe, say } (batch 13 item 7, lib/idle-close.js) // the state is the dot beside the row, not a word (testing fixes)
76
+ ...(s.close_ok && st === 'quiet' ? { close: s.close_ok } : {}), // idle 30 min: { safe, say } (batch 13 item 7, lib/idle-close.js)
77
+ ctx: s.ctx || null }; // how full its context is, and Claude's ✦ Compact (batch 13 item 8; pm/ctx-wedge.js) // the state is the dot beside the row, not a word (testing fixes)
77
78
  }
78
79
  /** The sessions as Home reads them. A session PMOS started (a skill, a background job) reads 'needs' as soon as its prompt is done:
79
80
  * its turn ending asks nothing of the PM, so it is a finished run, quiet, and never a row that waits on the PM (testing fixes).
@@ -16,19 +16,7 @@
16
16
  .hi-mvb { display: flex; align-items: center; gap: 6px; }
17
17
  .hi-mvb .cz-ms { margin-right: 2px; }
18
18
 
19
- /* buttons, as the canvas draws them */
20
- .hi-btn { height: 36px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13.5px; font-weight: 700; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); white-space: nowrap; cursor: pointer; }
21
- .hi-btn svg { flex: none; }
22
- .hi-btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
23
- .hi-btn.dark { background: var(--cz-ink); border-color: transparent; color: var(--cz-card); }
24
- .hi-btn.ghost { border-color: transparent; background: transparent; color: var(--cz-ink2); }
25
- .hi-btn.ghost:hover { background: var(--cz-well); }
26
- .hi-btn:disabled { opacity: .45; cursor: default; }
27
19
  .hi-self { align-self: flex-start; }
28
- .hi-ib { width: 32px; height: 32px; border-radius: 999px; display: inline-grid; place-items: center; flex: none; padding: 0; border: 0; background: none; color: var(--cz-ink2); cursor: pointer; }
29
- .hi-ib:hover { background: var(--cz-well2); }
30
- .hi-ib.solid { background: var(--cz-ink); color: var(--cz-card); }
31
- .hi-ib.sm { width: 28px; height: 28px; }
32
20
 
33
21
  /* ── the list column groups (InTasks, InDocs) ── */
34
22
  .hi-g .hm-gh .hi-n { margin-left: auto; font-weight: 700; font-size: 12px; color: var(--cz-ink3); }
@@ -48,47 +36,6 @@
48
36
  .hi-chk.off { cursor: default; border-style: dashed; }
49
37
  .hi-chk.off.on { border-style: solid; opacity: .6; }
50
38
 
51
- /* ── the popovers: Move anyway, Back, the menus ── */
52
- .hi-pop { position: fixed; z-index: 90; left: var(--hi-x, 24px); top: var(--hi-y, 24px); width: 360px; max-width: calc(100vw - 24px); box-sizing: border-box; background: var(--cz-card); color: var(--cz-ink); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 10px; font-family: var(--cz-sans); font-size: 14px; box-shadow: 0 24px 60px -24px rgba(42,46,53,.45), 0 0 0 1px var(--cz-hair); }
53
- .hi-pop.menu { width: 290px; padding: 8px; gap: 2px; }
54
- .hi-pop.sheet { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-width: none; border-radius: 28px 28px 0 0; padding: 10px 16px 28px; box-shadow: 0 -20px 50px -20px rgba(42,46,53,.35); }
55
- .hi-pop.sheet .hi-btn { height: 48px; justify-content: center; }
56
- .hi-pop.sheet .hi-acts { flex-direction: column; align-items: stretch; }
57
- .hi-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--cz-c-d9dce1); align-self: center; margin-bottom: 4px; }
58
- .hi-scrim { position: fixed; inset: 0; z-index: 89; background: rgba(42,46,53,.18); }
59
- .hi-pop p { margin: 0; }
60
- .hi-h3 { font-size: 15px; font-weight: 800; }
61
- .hi-lbl { margin: 0; font-size: 12px; font-weight: 800; color: var(--cz-ink3); }
62
- .hi-small { margin: 0; font-size: 12.5px; color: var(--cz-ink3); }
63
- .hi-warn { background: var(--cz-riskbg); color: var(--cz-risk); border-radius: 14px; padding: 12px 14px; font-size: 12.5px; }
64
- .hi-field { display: flex; flex-direction: column; gap: 6px; }
65
- .hi-field > span { font-size: 12.5px; font-weight: 800; color: var(--cz-ink2); }
66
- .hi-field em { font-style: normal; font-weight: 600; color: var(--cz-ink3); }
67
- .hi-field input, .hi-field textarea { box-sizing: border-box; width: 100%; border: 0; border-radius: 14px; background: var(--cz-well); color: var(--cz-ink); font: inherit; font-size: 14px; padding: 10px 14px; outline: 0; }
68
- .hi-field input { height: 42px; }
69
- .hi-field textarea { min-height: 56px; resize: vertical; }
70
- .hi-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
71
- .hi-chips { display: flex; flex-wrap: wrap; gap: 6px; }
72
- .hi-chips .cz-chip[aria-pressed="true"] { background: var(--cz-bluebg); border-color: transparent; color: var(--cz-blueink); }
73
- .hi-cks { display: flex; flex-direction: column; gap: 4px; }
74
- .hi-pop:not(.sheet) .hi-cks { display: none; } /* the card shows the items; the phone's sheet repeats them (InPhone) */
75
- .hi-ck { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cz-ink2); padding: 2px 0; }
76
- .hi-ck i { width: 16px; height: 16px; border-radius: 5px; border: 2px solid var(--cz-c-c5c9d0); box-sizing: border-box; display: inline-grid; place-items: center; flex: none; color: var(--cz-card); }
77
- .hi-ck.on i { background: var(--cz-ink); border-color: var(--cz-ink); }
78
- .hi-mlbl { margin: 0; font-size: 12px; font-weight: 800; color: var(--cz-ink3); padding: 8px 12px 4px; }
79
- .hi-hr { height: 1px; background: var(--cz-hair); margin: 4px 0; }
80
- .hi-mi { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 12px; font: inherit; font-size: 14px; font-weight: 600; color: var(--cz-ink); width: 100%; border: 0; background: none; cursor: pointer; text-align: left; }
81
- .hi-mi:hover, .hi-mi.on { background: var(--cz-well); }
82
- .hi-mi span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
83
- .hi-mi em { font-style: normal; margin-left: auto; font-size: 12px; color: var(--cz-ink3); font-weight: 600; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
84
- .hi-mi:disabled { opacity: .45; cursor: default; }
85
- .hi-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
86
-
87
- /* the toast with Undo: info, so it does not move */
88
- .hi-toast { position: fixed; z-index: 95; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--cz-ink); color: var(--cz-card); font-family: var(--cz-sans); font-size: 13px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); max-width: calc(100vw - 32px); }
89
- .hi-toast[hidden] { display: none; }
90
- .hi-toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
91
- .hi-toast button { height: 32px; padding: 0 12px; border-radius: 999px; border: 0; background: rgba(255,255,255,.14); color: inherit; font: inherit; font-weight: 700; cursor: pointer; flex: none; }
92
39
 
93
40
  /* ── the Viewer: Tasks, Documents, Stage (InTasks, InDocs) ── */
94
41
  .hi-v { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 24px; font-size: 14px; color: var(--cz-ink); }
@@ -148,6 +95,12 @@ button.hi-pill { cursor: pointer; }
148
95
  @media (max-width: 760px) {
149
96
  /* every target in the Viewer is at least 44 px (the phone floor); a check box keeps its 18 px look inside a 44 px press */
150
97
  .hi-v button, .hi-v input, .hi-pop button, .hi-pop input { min-height: 44px; }
98
+ /* a task row's check box and its dates keep their size inside the 44 px floor (batch 14 item 6: the box stretched tall and the dates fell a line) */
99
+ .hi-v .iv-cb { min-height: 0; position: relative; }
100
+ .hi-v .iv-car, .hi-v .iv-tr .iv-tt { min-height: 0; }
101
+ .hi-v .iv-cb::after { content: ""; position: absolute; inset: -13px; }
102
+ .hi-v .iv-dc { min-height: 22px; position: relative; }
103
+ .hi-v .iv-dc::after { content: ""; position: absolute; left: 0; right: 0; top: -11px; bottom: -11px; }
151
104
  .hi-v .cz-seg button { height: 44px; }
152
105
  .hi-v .hi-ib, .hi-pop .hi-ib { width: 44px; height: 44px; }
153
106
  .hi-trow { min-height: 52px; padding: 0 2px; gap: 6px; }
@@ -190,29 +143,6 @@ button.hi-pill { cursor: pointer; }
190
143
  .hm-br .hm-wf { margin-left: auto; display: inline-flex; align-items: center; padding: 3px; border: 0; border-radius: 9px; background: none; cursor: pointer; color: inherit; }
191
144
  .hm-br .hm-wf:hover, .hm-br .hm-wf[aria-expanded="true"] { background: var(--cz-well); }
192
145
  .hm-br .hm-wf + .st { margin-left: 0; }
193
- .hi-pop.wide:not(.sheet) { width: 560px; }
194
- .hi-pop.menu .hi-mi .wfi { margin-left: -2px; }
195
- .hi-wfpad { padding: 4px 12px 6px; }
196
- .hi-wfchain { line-height: 1.5; }
197
- .hi-mut { color: var(--cz-ink3); }
198
- .hi-wfh { display: flex; align-items: center; gap: 8px; }
199
- .hi-wfh .hi-h3 { flex: 1; min-width: 0; }
200
- .hi-wfrows { display: flex; flex-direction: column; }
201
- .hi-wfrow { display: grid; grid-template-columns: minmax(0, 130px) 14px minmax(0, 130px) minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--cz-hair); font-size: 13.5px; }
202
- .hi-wfrow:first-child { border-top: 0; }
203
- .hi-wfrow span { min-width: 0; }
204
- .hi-wfrow em { display: block; font-style: normal; font-size: 12px; color: var(--cz-ink3); }
205
- .hi-wfland { display: flex; align-items: center; gap: 8px; }
206
- .hi-wfland span { flex: 1; }
207
- .hi-wfland select { font: inherit; font-size: 13px; font-weight: 700; color: var(--cz-ink); background: var(--cz-well); border: 0; border-radius: 10px; padding: 6px 10px; max-width: 60%; }
208
- .hi-end { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--cz-well); font-size: 13px; }
209
- .hi-end p { margin: 0; flex: 1; min-width: 0; color: var(--cz-ink2); }
210
- .hi-endi { display: inline-flex; color: var(--cz-ink3); }
211
- @media (max-width: 760px) {
212
- .hi-wfrow { grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); }
213
- .hi-wfrow > .hi-small { grid-column: 1 / -1; }
214
- .hi-end { flex-wrap: wrap; }
215
- }
216
146
 
217
147
  /* ── stage card D: the stage as a live step list (canvas XscD, XscDDesk); the list itself is cozy-steps.css ── */
218
148
  .hm-card.hm-sc { padding: 0; background: transparent; box-shadow: none; }
@@ -27,6 +27,8 @@
27
27
  * page; the phone keeps the Documents | Stage switch. */
28
28
  import * as MD from './home-ini-model.js';
29
29
  import * as WF from './ini-wf.js';
30
+ import { openPop, closePop, undoToast, popEl, ensureCss as ensurePopCss } from './hi-pop.js';
31
+ import { iniMore, iniText, pageHref } from './ini-more.js'; // the one initiative ⋯ menu, the same on the Board (batch 14 item 5) // the popovers and the toast with Undo, shared with the Board
30
32
  import * as SC from './home-stage-card.js';
31
33
  import { viewHtml, wireView } from './ini-view.js'; // the one initiative view, the Board's panel's own renderer
32
34
  import { ensureCss as ensureStepsCss } from './cozy-steps.js'; // stage card D: the card's last node and the move sheet's words // D99: the initiative's own workflow (Change picker, switch, Won't do, Archive)
@@ -39,7 +41,7 @@ const I = {
39
41
  };
40
42
  const PHONE = 760;
41
43
  const isPhone = () => innerWidth <= PHONE;
42
- const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'page', doc: { by: 'stage', filter: 'all', more: new Set() }, pop: null, toastT: 0 };
44
+ const X = { ctx: null, L: new Map(), reading: new Set(), tried: new Set(), view: 'page', doc: { by: 'stage', filter: 'all', more: new Set() } };
43
45
 
44
46
  /* ── reading the layout record ── */
45
47
  const curM = () => { const S = X.ctx && X.ctx.S; return S && S.ini && S.ini !== 'product' && S.IMid === S.ini ? S.IM : null; };
@@ -104,15 +106,6 @@ async function doMove(id, M, to, why, o = {}) {
104
106
  await X.ctx.load();
105
107
  return true;
106
108
  }
107
- function undoToast(text, undo) {
108
- let el = document.getElementById('hiToast');
109
- if (!el) { el = document.createElement('div'); el.id = 'hiToast'; el.className = 'hi-toast'; el.setAttribute('role', 'status'); el.setAttribute('aria-live', 'polite'); document.body.appendChild(el); }
110
- el.innerHTML = `<span>${esc(text)}</span><button type="button" data-hi-undo>Undo</button>`;
111
- el.hidden = false; el.classList.add('on');
112
- el.querySelector('[data-hi-undo]').onclick = () => { hide(); undo(); };
113
- const hide = () => { el.classList.remove('on'); el.hidden = true; };
114
- clearTimeout(X.toastT); X.toastT = setTimeout(hide, 9000);
115
- }
116
109
  function autoCheck(id, M, mv) {
117
110
  const L = Lof(id);
118
111
  if (!L.read || !mv.autoReady) return;
@@ -122,42 +115,7 @@ function autoCheck(id, M, mv) {
122
115
  doMove(id, M, mv.next, MD.whyOf('auto'), { auto: true });
123
116
  }
124
117
 
125
- /* ── the popovers: Move anyway, Back, and the small menus ── */
126
- function closePop() {
127
- if (!X.pop) return;
128
- const a = X.pop.anchor; X.pop.el.remove(); if (X.pop.scrim) X.pop.scrim.remove(); X.pop = null;
129
- if (a && a.isConnected) { a.setAttribute('aria-expanded', 'false'); try { a.focus(); } catch { /* gone */ } }
130
- }
131
- function openPop(anchor, kind, html, onClick, o = {}) {
132
- closePop();
133
- const el = document.createElement('div');
134
- const sheet = isPhone() && !o.menu;
135
- el.className = 'cz hi-pop' + (sheet ? ' sheet' : '') + (o.menu ? ' menu' : '') + (o.wide ? ' wide' : '');
136
- el.setAttribute('role', o.role || (o.menu ? 'menu' : 'dialog')); el.setAttribute('aria-label', o.label || ''); el.setAttribute('data-esc-layer', '');
137
- el.innerHTML = (sheet ? '<div class="hi-grab" aria-hidden="true"></div>' : '') + html;
138
- let scrim = null;
139
- if (sheet) { scrim = document.createElement('div'); scrim.className = 'hi-scrim'; scrim.onclick = closePop; document.body.appendChild(scrim); }
140
- document.body.appendChild(el);
141
- if (!sheet) { // under the button that opened it, kept inside the window: run-time geometry, set as two custom properties
142
- const r = anchor.getBoundingClientRect(), w = el.offsetWidth, hh = el.offsetHeight;
143
- const col = !o.menu && anchor.closest('#hmList'); // a dialog from the list column opens beside the column (InStage), not over it
144
- let x, y;
145
- if (col) { const c = col.getBoundingClientRect(); x = c.right + 12; y = Math.min(innerHeight - hh - 12, Math.max(12, r.top - 60)); }
146
- else { x = r.left + w > innerWidth - 12 ? r.right - w : r.left; y = r.bottom + 8 + hh > innerHeight - 12 ? r.top - hh - 8 : r.bottom + 8; }
147
- x = Math.max(12, Math.min(innerWidth - w - 12, x)); y = Math.max(12, y);
148
- el.style.setProperty('--hi-x', Math.round(x) + 'px'); el.style.setProperty('--hi-y', Math.round(y) + 'px');
149
- }
150
- anchor.setAttribute('aria-expanded', 'true');
151
- X.pop = { el, scrim, anchor, kind };
152
- el.addEventListener('click', (e) => { const b = e.target.closest('button'); if (b && !b.disabled) onClick(b, el); });
153
- el.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); closePop(); } });
154
- const f = el.querySelector((sheet && o.sheetFocus) || o.focus || 'input, textarea, button:not([disabled])'); if (f) setTimeout(() => f.focus(), 0);
155
- return el;
156
- }
157
- // Escape closes the popover first: on window in the capture phase, so Home's own Escape (the phone's list sheet, the Viewer) waits for the next press
158
- if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && X.pop) { e.stopPropagation(); e.preventDefault(); closePop(); } }, true);
159
- if (typeof document !== 'undefined') document.addEventListener('mousedown', (e) => { if (X.pop && !X.pop.el.contains(e.target) && !(X.pop.anchor && X.pop.anchor.contains(e.target)) && !(X.pop.scrim && X.pop.scrim === e.target)) closePop(); }, true);
160
-
118
+ /* ── the popovers: Move anyway, Back, and the small menus (the kit is pm/hi-pop.js, shared with the Board) ── */
161
119
  function popMove(anchor, id, M, mv) {
162
120
  const title = X.ctx.iniTitle(id);
163
121
  const ck = mv.items.map((x) => `<span class="hi-ck${x.done ? ' on' : ''}"><i aria-hidden="true">${x.done ? SVG(I.check, 10, 3.5) : ''}</i>${esc(x.label)}</span>`).join('');
@@ -226,7 +184,7 @@ function menu(anchor, items, label) {
226
184
  function ask(anchor, label, value, go, o = {}) { // one line of words, inline (no browser prompt)
227
185
  openPop(anchor, 'ask', `<label class="hi-field"><span>${esc(label)}</span><input id="hiAsk" maxlength="${o.max || 40}" autocomplete="off" value="${esc(value || '')}"></label><div class="hi-acts"><button type="button" class="hi-btn dark" data-hi-go>Save</button><button type="button" class="hi-btn ghost" data-hi-x>Cancel</button></div>`,
228
186
  (b, el) => { if ('hiX' in b.dataset) { closePop(); return; } if ('hiGo' in b.dataset) { const v = el.querySelector('#hiAsk').value.trim(); if (!v) return; closePop(); go(v); } }, { label });
229
- const i = X.pop.el.querySelector('#hiAsk');
187
+ const i = popEl().querySelector('#hiAsk');
230
188
  i.addEventListener('keydown', (e) => { if (e.key === 'Enter') { e.preventDefault(); const v = i.value.trim(); if (v) { closePop(); go(v); } } });
231
189
  }
232
190
 
@@ -366,29 +324,52 @@ async function setDates(id, uid, patch) {
366
324
  if (k || (r.from && ('start' in r.from || 'due' in r.from))) undoToast('Dates saved: ' + (k ? k.title : uid + ', kept in PMOS') + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
367
325
  else C.toast('Dates saved.');
368
326
  }
369
- /** ⋯ of the page (HbCMore): change it, look at it elsewhere, then stop it, red and last. */
327
+ /** ⋯ of the page: the ONE initiative menu (pm/ini-more.js, feedback batch 14 item 5), the same words and order as the Board's panel.
328
+ * This page says which items apply and what each press does; the menu decides the order. */
370
329
  function pageMore(id) {
371
330
  const M = curM(); if (!M) return [];
372
- const mv = mvOf(id, M), out = [], row = rowOf(id), self = !!(M.acts && M.acts.self);
373
- // D99 (WfAWontDo): Change workflow and Rename first; the PMOS-self board keeps its derived ladder, so it has no workflow to change
374
- if (!self && !row.ended) out.push({ label: 'Change workflow', note: (row.wf || {}).name || 'Product feature', on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) });
375
- if (X.ctx.renameIni) out.push({ label: 'Rename', on: () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } });
376
- if (!mv.why) out.push({ label: 'Moves on by itself', note: mv.auto ? 'On' : 'Off', on: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) });
377
- if (mv.canBack) out.push({ label: 'Move back a stage', note: mv.prev, on: (b) => popBack(b || document.querySelector('#czViewer [data-cz-vw="more"]'), id, M, mv) });
378
- if ((M.acts.stages || []).length && !M.acts.self) out.push({ label: 'Move to a stage', on: () => iniOverview('stage', { back: true }) });
379
- out.push({ label: 'Add a stakeholder', on: () => X.ctx.addPerson() });
380
- // P7: an initiative in no program can become one; one in a program can move out of it or to another (batch 11 item 2, canvas LpA1More)
381
- const pm = X.ctx.moveItems ? X.ctx.moveItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], 'Move to another program')) : [];
382
- if (X.ctx.turnProgram && !pm.length) out.push({ label: 'Turn into a program', on: () => X.ctx.turnProgram(id) });
383
- // split it into a new initiative, or merge it into another, above the program moves (batch 11 item 14, canvas XsmA1Menu)
384
- const sm = X.ctx.smItems && !row.ended ? X.ctx.smItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], label)) : [];
385
- if (sm.length || pm.length) out.push({ sep: true }, ...sm, ...pm);
386
- out.push({ sep: true }, { label: 'Open on the Board', on: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); } },
387
- { label: 'The record', on: async () => (X.ctx.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }) });
388
- // Won't do and Archive hold from any stage (wfRules); Won't do comes back to Triage. Cancel stays red and last (HbCMore)
389
- if (!self) out.push({ sep: true }, row.ended ? { label: 'Back to Triage', on: () => WF.backToTriage(wfUi(), id) } : { label: 'Won’t do', on: (b) => WF.openWontDo(b || moreBtn(), wfUi(), id) }, { label: 'Archive', on: () => WF.archive(wfUi(), id) });
390
- if (!M.acts.life && !row.ended) out.push({ sep: true }, { label: 'Put on hold', on: () => { iniOverview('stage', { back: true, ask: 'on-hold' }); } }, { label: 'Cancel the initiative', danger: true, on: () => { iniOverview('stage', { back: true, ask: 'cancelled' }); } });
391
- return out;
331
+ const C = X.ctx, mv = mvOf(id, M), row = rowOf(id), self = !!(M.acts && M.acts.self), B = (C.S.D && C.S.D.board) || {};
332
+ const openList = (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], label);
333
+ const copy = (t, said) => navigator.clipboard.writeText(t).then(() => C.toast(said), () => C.toast('This browser did not allow the copy.'));
334
+ const ask = (q) => { if (C.askIn) C.askIn(id, q); };
335
+ return iniMore({
336
+ // D99 (WfAWontDo): the PMOS-self board keeps its derived ladder, so it has no workflow to change
337
+ wf: !self && !row.ended ? { name: (row.wf || {}).name, on: (b) => WF.openPicker(b || moreBtn(), wfUi(), id) } : null,
338
+ rename: C.renameIni ? () => { const t = document.querySelector('#czViewer [data-cz-vw-rn]'); if (t) t.click(); } : null,
339
+ auto: !mv.why ? { on: mv.auto, press: () => (ownWf(row) ? autoPress(id, M, !mv.auto) : press(id, M, { kind: 'auto', on: !mv.auto })) } : null,
340
+ back: mv.canBack ? { prev: mv.prev, on: (b) => popBack(b || moreBtn(), id, M, mv) } : null,
341
+ toStage: (M.acts.stages || []).length && !self ? () => iniOverview('stage', { back: true }) : null,
342
+ dates: C.askIn ? () => ask('Propose new start and end dates for ' + C.iniTitle(id)) : null,
343
+ person: () => C.addPerson(),
344
+ // split or merge, then the program moves (batch 11 items 2 and 14)
345
+ sm: C.smItems && !row.ended ? C.smItems(id, openList) : [],
346
+ pm: C.moveItems ? C.moveItems(id, (b, label, rows) => menu(b || moreBtn(), [{ head: label }, ...rows], 'Move to another program')) : [],
347
+ turnProgram: C.turnProgram ? () => C.turnProgram(id) : null,
348
+ jira: B.jira ? () => readJira(M) : null,
349
+ board: () => { location.href = '/premium-board.html?focus=' + encodeURIComponent(id) + (M.board.ws ? '&ws=' + encodeURIComponent(M.board.ws) : '') + (M.board.id ? '&board=' + encodeURIComponent(M.board.id) : ''); },
350
+ record: async () => (C.VW.drill(), await import('./premium-vw-item.js')).openWorkItem({ kind: 'initiative', id, title: M.title, ...bw(M) }),
351
+ link: () => copy(new URL(pageHref(id, M.board.ws, M.board.id), location.href).href, 'Link copied.'),
352
+ text: () => copy(iniText(C.iniTitle(id), C.view ? C.view(id) : null, (row.track && row.track.tickets) || []), 'Copied as text.'),
353
+ ended: !!row.ended,
354
+ wontDo: !self ? (b) => WF.openWontDo(b || moreBtn(), wfUi(), id) : null,
355
+ backToTriage: !self ? () => WF.backToTriage(wfUi(), id) : null,
356
+ archive: !self ? () => WF.archive(wfUi(), id) : null,
357
+ hold: !M.acts.life && !row.ended ? () => iniOverview('stage', { back: true, ask: 'on-hold' }) : null,
358
+ resume: M.acts.life === 'hold' && !row.ended ? () => resume(id, M) : null,
359
+ cancel: !M.acts.life && !row.ended ? () => iniOverview('stage', { back: true, ask: 'cancelled' }) : null,
360
+ });
361
+ }
362
+ /** Resume an initiative on hold (POST /api/lifecycle, the Stage view's Resume and the Board's). */
363
+ async function resume(id, M) {
364
+ const r = await X.ctx.pmPost('/api/lifecycle', { ws: M.board.ws, initiative_id: id, state: 'active', reason: 'resumed' });
365
+ if (!r || r.ok === false) { X.ctx.toast((r && r.error) || 'Nothing was changed.'); return; }
366
+ X.ctx.toast('Resumed · ' + X.ctx.iniTitle(id) + '.'); await X.ctx.load(); redrawView();
367
+ }
368
+ /** Read Jira again (the Board's press): the initiative's product reads its Jira source again; the page reads the Board after it lands. */
369
+ async function readJira(M) {
370
+ const r = await X.ctx.pmPost('/api/sources/refresh', { ws: M.board.ws, source: 'jira' });
371
+ X.ctx.toast(r && r.ok ? 'Reading Jira again. The page shows it when the read lands.' : 'Jira was not read again: ' + ((r && r.error) || 'the server did not answer') + '.');
372
+ if (r && r.ok) setTimeout(() => X.ctx.load(), 4000);
392
373
  }
393
374
  const moreBtn = () => document.querySelector('#czViewer [data-cz-vw="more"]') || document.body;
394
375
  /** Moves on by itself for this one initiative, on a workflow of the library (POST /api/boards/ini-auto): the stage sets the default. */
@@ -627,6 +608,7 @@ function pagePress(t, id, M) {
627
608
  export function mountIni(ctx) {
628
609
  X.ctx = ctx;
629
610
  if (typeof document === 'undefined') return X;
611
+ ensurePopCss(); // before home-ini.css, so its phone rules win
630
612
  if (!document.querySelector('link[data-hi-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./home-ini.css', import.meta.url).href; l.dataset.hiCss = ''; document.head.appendChild(l); }
631
613
  ensureStepsCss(); // the stage card's step list (cozy-steps.css), before the first draw
632
614
  if (!document.querySelector('link[data-tk-css]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./tk-tasks.css', import.meta.url).href; l.dataset.tkCss = ''; document.head.appendChild(l); }