create-pmos 0.610.0 → 0.612.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 (164) hide show
  1. package/package.json +135 -27
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/board-columns-test.js +2 -1
  8. package/workspace/board-deliveries-test.js +2 -1
  9. package/workspace/board-programs-test.js +7 -3
  10. package/workspace/board-publish-ui-test.js +2 -1
  11. package/workspace/board-shared-ui-test.js +2 -1
  12. package/workspace/board-workflows-test.js +2 -1
  13. package/workspace/briefing-premium-board-test.js +3 -2
  14. package/workspace/briefing-premium-calendar-2-test.js +3 -2
  15. package/workspace/briefing-premium-calendar-3-test.js +1 -1
  16. package/workspace/briefing-premium-calendar-test.js +1 -1
  17. package/workspace/briefing-premium-doc-edit-test.js +2 -1
  18. package/workspace/briefing-premium-insights-test.js +4 -3
  19. package/workspace/briefing-premium-test.js +3 -2
  20. package/workspace/calm-timeline-test.js +2 -1
  21. package/workspace/changelog.json +134 -0
  22. package/workspace/core-docs-workflow-test.js +2 -1
  23. package/workspace/ev-everywhere-test.js +3 -2
  24. package/workspace/guide/home.md +2 -2
  25. package/workspace/guide/index.md +4 -0
  26. package/workspace/guide/layout.md +97 -3
  27. package/workspace/guide/programs.md +16 -2
  28. package/workspace/guide/routine.md +65 -0
  29. package/workspace/guide/scheduled-tasks-and-cli.md +1 -1
  30. package/workspace/guide/settings-and-switches.md +2 -2
  31. package/workspace/impact-screens-test.js +3 -1
  32. package/workspace/ini-workflow-test.js +2 -1
  33. package/workspace/lib/board-premium.js +12 -4
  34. package/workspace/lib/classic-board.js +15 -0
  35. package/workspace/lib/cos-chat.js +1 -0
  36. package/workspace/lib/doc-library.js +43 -12
  37. package/workspace/lib/doc-path.js +30 -0
  38. package/workspace/lib/engine/boards.js +4 -2
  39. package/workspace/lib/events-place.js +368 -0
  40. package/workspace/lib/events-stated.js +129 -0
  41. package/workspace/lib/initiative-chat.js +1 -0
  42. package/workspace/lib/insights-premium.js +13 -1
  43. package/workspace/lib/library-find.js +162 -0
  44. package/workspace/lib/library-items.js +250 -0
  45. package/workspace/lib/notes.js +9 -1
  46. package/workspace/lib/plan-items.js +17 -3
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-artefacts.js +5 -2
  49. package/workspace/lib/routes-boards.js +6 -2
  50. package/workspace/lib/routes-doc-sheet.js +1 -0
  51. package/workspace/lib/routes-events-place.js +203 -0
  52. package/workspace/lib/routes-library.js +155 -0
  53. package/workspace/lib/routes-pop-work.js +39 -0
  54. package/workspace/lib/routes-report-setups.js +32 -1
  55. package/workspace/lib/routes-today-log.js +48 -0
  56. package/workspace/lib/routine-reports.js +84 -0
  57. package/workspace/lib/status-when.js +36 -0
  58. package/workspace/lib/task-items.js +5 -3
  59. package/workspace/lib/today-log.js +131 -0
  60. package/workspace/live-pill-round-test.js +10 -7
  61. package/workspace/metric-drafts-ui-test.js +3 -1
  62. package/workspace/milestone-pins-test.js +2 -1
  63. package/workspace/milestone-suggest-test.js +3 -1
  64. package/workspace/package-lock.json +2 -2
  65. package/workspace/package.json +1 -1
  66. package/workspace/panels-test.js +2 -1
  67. package/workspace/premium-board-actions-test.js +3 -1
  68. package/workspace/premium-rec-tab-test.js +2 -1
  69. package/workspace/premium-vw-backlog-test.js +3 -1
  70. package/workspace/premium-vw-item-test.js +3 -1
  71. package/workspace/premium-vw-jira-test.js +3 -1
  72. package/workspace/premium-vw-meet-test.js +2 -1
  73. package/workspace/premium-vw-notes-test.js +3 -2
  74. package/workspace/product-lane-test.js +2 -1
  75. package/workspace/program-charter-test.js +3 -1
  76. package/workspace/program-leave-test.js +2 -1
  77. package/workspace/program-order-test.js +2 -1
  78. package/workspace/program-panel-test.js +3 -1
  79. package/workspace/public/pm/artefact-kind.js +87 -0
  80. package/workspace/public/pm/bd-ini-panel.js +77 -12
  81. package/workspace/public/pm/bd-prog-panel.js +55 -8
  82. package/workspace/public/pm/bd-span.js +5 -0
  83. package/workspace/public/pm/bd-work.css +192 -0
  84. package/workspace/public/pm/bd-work.js +483 -0
  85. package/workspace/public/pm/cozy-bar.css +11 -0
  86. package/workspace/public/pm/cozy-bar.js +99 -0
  87. package/workspace/public/pm/cozy-day-pick.css +27 -0
  88. package/workspace/public/pm/cozy-day-pick.js +97 -0
  89. package/workspace/public/pm/cozy-ev.css +2 -5
  90. package/workspace/public/pm/cozy-events-view.js +274 -0
  91. package/workspace/public/pm/cozy-events.css +179 -0
  92. package/workspace/public/pm/cozy-events.js +278 -0
  93. package/workspace/public/pm/cozy-evmodel.js +1 -1
  94. package/workspace/public/pm/cozy-goals.css +172 -0
  95. package/workspace/public/pm/cozy-library.css +125 -0
  96. package/workspace/public/pm/cozy-live-pill.js +1 -0
  97. package/workspace/public/pm/cozy-nav.js +6 -7
  98. package/workspace/public/pm/cozy-pick.css +3 -0
  99. package/workspace/public/pm/cozy-pop-work.css +224 -0
  100. package/workspace/public/pm/cozy-pop-work.js +668 -0
  101. package/workspace/public/pm/cozy-popup.css +11 -2
  102. package/workspace/public/pm/cozy-popup.js +67 -9
  103. package/workspace/public/pm/cozy-routine-job.js +203 -0
  104. package/workspace/public/pm/cozy-routine-model.js +219 -0
  105. package/workspace/public/pm/cozy-routine-pop.js +318 -0
  106. package/workspace/public/pm/cozy-routine.css +155 -0
  107. package/workspace/public/pm/cozy-routine.js +335 -0
  108. package/workspace/public/pm/cozy-schedwork.js +6 -5
  109. package/workspace/public/pm/cozy-settings.js +1 -5
  110. package/workspace/public/pm/cozy-status-when.js +48 -0
  111. package/workspace/public/pm/cozy-today-app.js +236 -0
  112. package/workspace/public/pm/cozy-today-model.js +176 -0
  113. package/workspace/public/pm/cozy-today-page.css +100 -0
  114. package/workspace/public/pm/cozy-today-view.js +76 -0
  115. package/workspace/public/pm/cozy-viewer.js +19 -8
  116. package/workspace/public/pm/cozy-vw-mtg.css +39 -0
  117. package/workspace/public/pm/goals-model.js +205 -0
  118. package/workspace/public/pm/goals-open.js +124 -0
  119. package/workspace/public/pm/home-app.js +18 -3
  120. package/workspace/public/pm/home-chat.js +4 -2
  121. package/workspace/public/pm/home-ini.js +43 -10
  122. package/workspace/public/pm/ini-edit.js +3 -1
  123. package/workspace/public/pm/ini-view-model.js +1 -1
  124. package/workspace/public/pm/library-model.js +197 -0
  125. package/workspace/public/pm/library-open.js +37 -0
  126. package/workspace/public/pm/page-chat.js +12 -2
  127. package/workspace/public/pm/pop-work-model.js +493 -0
  128. package/workspace/public/pm/premium-board.js +204 -17
  129. package/workspace/public/pm/premium-goals.js +213 -0
  130. package/workspace/public/pm/premium-library.js +436 -0
  131. package/workspace/public/pm/premium-shell.js +1 -1
  132. package/workspace/public/pm/premium-vw-mtg.js +79 -1
  133. package/workspace/public/pm/scope-chip.js +204 -0
  134. package/workspace/public/premium-board.html +1 -0
  135. package/workspace/public/premium-events.html +44 -0
  136. package/workspace/public/premium-goals.html +37 -0
  137. package/workspace/public/premium-library.html +39 -0
  138. package/workspace/public/premium-routine.html +33 -0
  139. package/workspace/public/today.html +50 -0
  140. package/workspace/ready-dash-ui-test.js +3 -1
  141. package/workspace/rename-test.js +2 -1
  142. package/workspace/run-tests.js +4 -1
  143. package/workspace/server.js +4 -2
  144. package/workspace/sort-order-test.js +2 -1
  145. package/workspace/split-merge-ui-test.js +3 -1
  146. package/workspace/stage-card-tasks-test.js +3 -1
  147. package/workspace/stage-card-test.js +2 -1
  148. package/workspace/task-delete-test.js +2 -1
  149. package/workspace/task-links-test.js +2 -1
  150. package/workspace/task-milestones-test.js +4 -2
  151. package/workspace/task-plans-test.js +3 -1
  152. package/workspace/task-press-test.js +3 -1
  153. package/workspace/task-views-test.js +3 -1
  154. package/workspace/test-lists/doc-path.json +9 -0
  155. package/workspace/test-lists/events-place.json +11 -0
  156. package/workspace/test-lists/goals-place.json +9 -0
  157. package/workspace/test-lists/library-place.json +9 -0
  158. package/workspace/test-lists/pop-work.json +9 -0
  159. package/workspace/test-lists/routine-place.json +9 -0
  160. package/workspace/test-lists/status-when.json +9 -0
  161. package/workspace/test-lists/today-log.json +9 -0
  162. package/workspace/test-lists/work-view.json +9 -0
  163. package/workspace/timeline-holds-test.js +3 -1
  164. package/workspace/tk-tasks-test.js +2 -1
@@ -25,6 +25,7 @@ import { mountPanels } from './cozy-panels.js';
25
25
  import { ownTab, bring, tabUrl } from './rec-tab-core.js';
26
26
  import * as VW from './cozy-viewer.js';
27
27
  import * as POP from './cozy-popup.js'; // the one popup: an initiative and Ask PMOS side by side (slice 2 of the six-place navigation)
28
+ import { mountToday } from './cozy-today-app.js'; // Today on a desk (slice 5): today.html is this page with data-today
28
29
  import * as SV from './small-vw.js'; // the small Viewers: a stakeholder, its form, a routine (batch 18 item 2-C)
29
30
  import { pmGet, pmPost, pmHeaders } from './http.js';
30
31
  import * as ST from './story.js';
@@ -89,6 +90,10 @@ const BOARD = P.get('board') || ''; // the Board's expand link names its board
89
90
  const boardQ = (pre = '?') => (BOARD ? pre + 'board=' + encodeURIComponent(BOARD) : '');
90
91
  const PHONE = 760;
91
92
  const isPhone = () => innerWidth <= PHONE;
93
+ /* Today (slice 5 of the six-place navigation): today.html is this page with data-today. On a desk it draws Today's log and agenda in place of
94
+ * the list and the chat column (pm/cozy-today-app.js); a phone keeps Home. TDY is set once the page's presses are defined (below). */
95
+ const TD_PAGE = document.body.hasAttribute('data-today');
96
+ let TDY = null;
92
97
  if (navigator.maxTouchPoints > 0) wireSettle(window); // a touch screen only: on a desktop the page does not scroll and the nudge is not needed
93
98
  const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
94
99
  /** The Everything chip's globe (chief-of-staff C1, board CsA). */
@@ -280,7 +285,8 @@ async function openGrillNews(id) {
280
285
  function otherProducts(D) {
281
286
  const av = (D.brief && D.brief.products && D.brief.products.available) || [];
282
287
  const own = ((D.board && D.board.board) || {}).ws || WS;
283
- return av.filter((a) => a.on && a.ws && a.ws !== own).slice(0, 4);
288
+ // Today reads every product (slice 5 of the six-place navigation): the product pick is Work's and Goals', not Today's
289
+ return av.filter((a) => (a.on || (TD_PAGE && !isPhone())) && a.ws && a.ws !== own).slice(0, 4);
284
290
  }
285
291
  async function loadIni() {
286
292
  const id = S.ini;
@@ -438,7 +444,7 @@ async function readMove() {
438
444
  const auto = await Promise.all(L.map((ws) => pmGet('/api/autonomy' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
439
445
  // C3: the Lab's findings that fit no initiative are a row here (its section on Intelligence is gone)
440
446
  const labs = await Promise.all(PR.map((p, i) => { const b = (p.model.board && p.model.board.id) || ''; const q = [L[i] ? 'ws=' + encodeURIComponent(L[i]) : '', b ? 'board=' + encodeURIComponent(b) : ''].filter(Boolean).join('&');
441
- return pmGet('/api/lab' + (q ? '?' + q : '')).then((r) => (r && r.ok && r.lab && (r.lab.loose || []).length ? { ws: L[i], board: b, n: r.lab.loose.length, say: r.lab.say || '' } : null)).catch(() => null); }));
447
+ return pmGet('/api/lab' + (q ? '?' + q : '')).then((r) => (r && r.ok && r.lab && (r.lab.loose || []).length ? { ws: L[i], board: b, n: r.lab.loose.length, say: r.lab.say || '', items: r.lab.loose.map((f) => ({ id: f.id, title: f.title, why: f.why || '' })) } : null)).catch(() => null); }));
442
448
  L.forEach((ws, i) => {
443
449
  const r = got[i], A = auto[i] && auto[i].ok ? auto[i] : null; if (!r || !r.ok) return;
444
450
  const done = A ? (A.done || []).map((d) => ({ ref: d.ref, ini: d.ini || '', said: d.title || 'done', at: d.at, via: 'autonomy', reason: d.reason || '', way: d.way || '' }))
@@ -906,6 +912,7 @@ function drawList() {
906
912
  document.body.classList.toggle('hm-plist', isPhone() && !S.phoneChat); // a phone: the list is the page until a row opens its conversation (HmPhone)
907
913
  drawRailCard();
908
914
  drawRecTop();
915
+ if (TDY) TDY.draw(); // Today on a desk (today.html): the log and the agenda, from the same reads
909
916
  }
910
917
  /** The list's own fold (batch 20 item 6): kept on this computer, the one thing that folds or unfolds the list. With a Viewer open it is the rail. */
911
918
  function setFold(on) {
@@ -2388,6 +2395,13 @@ mountPanels({
2388
2395
  return false;
2389
2396
  },
2390
2397
  });
2398
+ if (TD_PAGE) TDY = mountToday({ S, VW, POP, pmGet, pmPost, toast, toastUndo, isPhone, now: NOW,
2399
+ rank: () => { S.topRank = rankMove({ ...rankIn(), calls: YD.callsOf((S.M && S.M.move) || []), now: NOW() }); return S.topRank; },
2400
+ rows: () => new Map(allRows().map((r) => [r.id, r])), titleOf: (id) => (iniRowOf(id) ? iniTitle(id) : String(id || '').replace(/[-_]+/g, ' ').replace(/^./, (c) => c.toUpperCase())), hasIni: (id) => !!(id && iniRowOf(id)), boardWs, boardId,
2401
+ goIni: (id) => goIni(id), select: (id) => select(id), movePress: (b) => movePress(b), openFinished, openReviewVw, openMeeting: (m) => openMeeting(m), openCalendar,
2402
+ openInbox: () => MORE.openInbox(searchGo, ''), reload: () => load(), review: () => L.reviewModel(S.D, NOW()), meetings: () => H.todayOf(S.D),
2403
+ news: () => (S.news && S.news.ok ? S.news.count || 0 : 0), chatNow: () => (chat.current ? chat.current() : null),
2404
+ openLab: (f) => import('./cozy-lab-ins.js').then((LB) => LB.openLab({ where: () => ({ ws: f.ws, board: f.board }), iniHref: (id) => '/premium-initiative.html?' + (f.ws ? 'ws=' + encodeURIComponent(f.ws) + '&' : '') + 'id=' + encodeURIComponent(id), toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) })) });
2391
2405
  PHC = mountPhoneCard({ pmGet, pmPost, toast, ws: () => WS || null, openMeeting: (m) => openMeeting(m), skip: ['meeting'] }); drawList();
2392
2406
  drawList(); drawTop();
2393
2407
  { // a conversation the address names opens at once, before the lists are read, so nothing typed or attached lands in the Home chat
@@ -2434,7 +2448,7 @@ load().then(() => {
2434
2448
  else if (about) { openTarget({ ...homeTarget(), key: about, title: (P.get('label') || '').slice(0, 80) || about }); discussed(about, P.get('vid'), P.get('label')); }
2435
2449
  else if (P.get('view') === 'metrics') openMetrics(P.get('ws') || ''); // ?view=metrics: an old link lands on Intelligence › Delivery trends
2436
2450
  else if (S.ini) goIni(S.ini);
2437
- else if (!isPhone() && !blockOpen && !say && !VW.isOpen()) { const first = H.needsOf(S.D)[0]; if (first) select(first.id); } // a card the PM opened while Home was reading stays
2451
+ else if (!isPhone() && !blockOpen && !say && !VW.isOpen() && !TD_PAGE) { const first = H.needsOf(S.D)[0]; if (first) select(first.id); } // Today opens nothing by itself // a card the PM opened while Home was reading stays
2438
2452
  if (blockOpen) {
2439
2453
  const b = { kind: blockOpen[1], id: blockOpen[2] };
2440
2454
  (b.kind === 'report' ? import('./premium-report-tab.js').then((M) => M.openReportTab(b)) : import('./premium-chart-tab.js').then((M) => M.openChartTab(b))).catch(() => toast('That view could not open.'));
@@ -2450,6 +2464,7 @@ load().then(() => {
2450
2464
  const u = new URL(location.href); ['settings', 'new', 'wf', 'stage'].forEach((k) => u.searchParams.delete(k)); history.replaceState(history.state, '', u.pathname + u.search + u.hash);
2451
2465
  }
2452
2466
  if (/^(prop|men|pulse|scan|rep|src)$/.test(P.get('around') || '')) MORE.openAround(P.get('around')); // ?around=<row>: that Around you view (home-around.js)
2467
+ if (TDY) { TDY.read(); readNews(); } // Today's own marks and entries, and the quiet New for you line
2453
2468
  // the Viewer opens now or not at all: the held column goes either way, and the next open holds it only if it opened (SpJ)
2454
2469
  setTimeout(() => { if (!isPhone()) store.set(VW_HELD, VW.isOpen() ? '1' : null); LS.holdViewer($('.hm-vw'), false); }, 0);
2455
2470
  poll();
@@ -159,8 +159,10 @@ export function mountChat(el, host) {
159
159
  }
160
160
  if (it.t === 'worked') {
161
161
  const id = 'w' + i, on = C.open.has(id);
162
- const what = toolLine(it.tools).replace(/^Used /, '');
163
- return `<div class="hm-worked"><button type="button" class="hm-wk" data-hm-wk="${id}" aria-expanded="${on}">${SVG(CHEV, 12, 2.4)}<span>Worked${it.took ? ' ' + esc(it.took) : ''}${what ? ' · ' + esc(what) : ''}</span></button>`
162
+ // the tool steps of one answer fold into one grey line, "5 steps" (popup round 3 point 9); the press opens them
163
+ const n = it.calls.length || Object.values(it.tools || {}).reduce((k, v) => k + (Number(v) || 0), 0);
164
+ const what = n ? n + (n === 1 ? ' step' : ' steps') : 'Worked' + (it.took ? ' ' + it.took : '');
165
+ return `<div class="hm-worked"><button type="button" class="hm-wk" data-hm-wk="${id}" aria-expanded="${on}" title="${esc(toolLine(it.tools) + (it.took ? ' · ' + it.took : ''))}">${SVG(CHEV, 12, 2.4)}<span>${esc(what)}</span></button>`
164
166
  + (on ? `<ol class="hm-calls">${it.calls.slice(0, 40).map((c) => `<li><b>${esc(c.tool.split(/__|\//).pop())}</b><code>${esc(c.target || '')}</code></li>`).join('')}</ol>` : '') + '</div>'
165
167
  + (it.ask ? askHtmlOf(it, R) : '');
166
168
  }
@@ -34,7 +34,10 @@ import * as SC from './home-stage-card.js';
34
34
  import { viewHtml, wireView } from './ini-view.js'; // the one initiative view, the Board's panel's own renderer
35
35
  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)
36
36
  import * as DB from './dash-view.js'; // the ready-made Dashboard view (batch 17 item 1)
37
- import * as TL from './ini-tail.js'; // under Linked, as the Board draws it (UI grill U1): drafted tickets, the PRD drift, Your impact
37
+ import * as TL from './ini-tail.js';
38
+ import * as PW from './cozy-pop-work.js'; // what the popup shows for work (slice 3 of the six-place navigation): in the popup, in place of the old page
39
+ import * as PP from './ini-props.js'; // everything PMOS suggests, as a drill-in (the popup's ⋯) // under Linked, as the Board draws it (UI grill U1): drafted tickets, the PRD drift, Your impact
40
+ import * as SWN from './cozy-status-when.js'; // the day a status move really happened, in the toast (round 3 point 18)
38
41
 
39
42
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
40
43
  const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
@@ -259,9 +262,32 @@ function holdPop(anchor, id) {
259
262
  }, { label: 'On hold', sheetFocus: '#hiBack' });
260
263
  }
261
264
  /** The one view's presses on Home's page. */
265
+ /** In the popup: what pm/cozy-pop-work.js shows for work, from the same view model and the page's own read. */
266
+ function popOpts(id, M) {
267
+ const v = X.ctx.view(id) || {};
268
+ return { today: v.today, docs: M ? MD.docRows(M) : [], product: (M && M.board && (M.board.name || M.board.ws)) || rowOf(id).ws || '', program: (v.summary && v.summary.program) || null, ws: (M && M.board && M.board.ws) || rowOf(id).ws || '', board: (M && M.board && M.board.id) || '', id };
269
+ }
270
+ function popHtml(id, M) {
271
+ X.ctx.head(id);
272
+ const v = X.ctx.view(id);
273
+ if (!v) return `<div class="hi-v hi-page" data-hi-v="page"><p class="hi-small" role="status">The initiative could not be read.</p></div>`;
274
+ return PW.html({ ...rowOf(id), id }, v, popOpts(id, M)) + '<p class="hi-small" role="status" id="ovMsg"></p>';
275
+ }
276
+ /** The popup's own presses: every part of the old page as a drill-in (so nothing is lost), and everything PMOS suggests. */
277
+ function popExtra(id) {
278
+ const C = X.ctx, H = { where: () => { const M = curM(); return M ? bw(M) : {}; }, reload: async () => { await C.load(); redrawView(); }, toast: (m, u) => (u ? undoToast(m, u) : C.toast(m)) };
279
+ return {
280
+ allParts: () => {
281
+ C.VW.drill();
282
+ C.VW.open({ kind: X.ctx.kindOf(id), title: C.iniTitle(id), icon: 'goal', id: 'all:' + id, back: true,
283
+ render: (b) => { b.dataset.pwAll = '1'; const M = curM(); b.innerHTML = M ? pageHtml(id, M) : ''; wire(b, id); wirePage(b, id); } });
284
+ },
285
+ props: () => { const v = X.ctx.view(id); if (v) PP.open(v, H); },
286
+ };
287
+ }
262
288
  function wirePage(b, id) {
263
289
  const C = X.ctx, say = (m) => C.toast(m);
264
- wireView(b, {
290
+ const H = {
265
291
  redraw: () => redrawView(),
266
292
  // Claude's split or merge card (batch 11 item 14): ✕ Not now, ✎ Change it first, ✓ as suggested; the merged summary's link opens the one that stays
267
293
  sm: (act) => { if (C.smPress) C.smPress(id, act); },
@@ -274,7 +300,7 @@ function wirePage(b, id) {
274
300
  check: async (uid, btn) => {
275
301
  await setState(id, uid, btn.getAttribute('aria-pressed') === 'true' ? 'To do' : 'Done');
276
302
  },
277
- status: (uid, state) => setState(id, uid, state),
303
+ status: (uid, state, w) => setState(id, uid, state, w),
278
304
  dates: (uid, patch) => setDates(id, uid, patch),
279
305
  milestone: (uid, on) => setDates(id, uid, { milestone: !!on }), // the ◇ in the status picker (batch 11 item 3)
280
306
  remove: (uid) => removeTask(id, uid), // the trash in the status picker (batch 11 item 16)
@@ -320,7 +346,13 @@ function wirePage(b, id) {
320
346
  stagePick: (btn) => stageChip(btn, id),
321
347
  planDates: () => { if (C.askIn) C.askIn(id, 'Propose new start and end dates for ' + C.iniTitle(id)); },
322
348
  jira: () => { const M = curM(); if (M) readJira(M); },
323
- });
349
+ };
350
+ if (PW.on(b)) {
351
+ PW.wire(b, { ...H, ...popExtra(id), redraw: () => { b.__pg = null; if (b.dataset.pwAll) return; redrawView(); } },
352
+ { r: () => ({ ...rowOf(id), id }), v: () => X.ctx.view(id), o: () => popOpts(id, curM()) });
353
+ return;
354
+ }
355
+ wireView(b, H);
324
356
  }
325
357
  /** A task of the initiative as the one view reads it: the board row's (status, start, end), else the page's own read (state, start, end). */
326
358
  function taskAt(id, uid) {
@@ -330,14 +362,15 @@ function taskAt(id, uid) {
330
362
  }
331
363
  /** The quick status (the box, its caret, a Kanban drag): POST /api/boards/tasks/state, Undo puts the old state back. A breakdown item set
332
364
  * to Won't do is withdrawn, which the ledger cannot undo, so that toast has no Undo. */
333
- async function setState(id, uid, state) {
365
+ async function setState(id, uid, state, w) {
334
366
  const M = curM(); if (!M) return;
335
- const k = taskAt(id, uid), C = X.ctx, body = { ...bw(M), task: uid };
336
- const r = await C.pmPost('/api/boards/tasks/state', { ...body, state });
367
+ const k = taskAt(id, uid), C = X.ctx, body = { ...bw(M), task: uid }, happened = (w && w.happened) || null;
368
+ const r = await C.pmPost('/api/boards/tasks/state', { ...body, state, ...(happened ? { happened } : {}) });
337
369
  if (!r || r.ok === false) { C.toast((r && r.error) || 'Nothing was changed.'); return; }
338
370
  await C.load(); redrawView();
339
371
  const was = k && k.status;
340
- if (was && was !== state && !(k.item && state === "Won't do")) undoToast(state + ': ' + k.title + '.', async () => { const u = await C.pmPost('/api/boards/tasks/state', { ...body, state: was }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
372
+ // the day it really happened is said beside the title (round 3 point 18): "Done on 14 Nov, noted today."
373
+ if (was && was !== state && !(k.item && state === "Won't do")) undoToast(happened ? SWN.whenWords(state, happened).replace(/\.$/, '') + ': ' + k.title + '.' : state + ': ' + k.title + '.', async () => { const u = await C.pmPost('/api/boards/tasks/state', { ...body, state: was }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
341
374
  else C.toast(state + (k ? ': ' + k.title : '') + '.');
342
375
  }
343
376
  /** The status picker's trash (batch 11 item 16): POST /api/boards/tasks/delete, a Board task or a breakdown item; Undo restores it. */
@@ -461,7 +494,7 @@ export function iniPage(o = {}) {
461
494
  let rename = X.ctx.renameIni ? X.ctx.renameIni(id, '') : null;
462
495
  if (rename) rename = { ...rename, value: X.ctx.iniTitle(id) };
463
496
  const dh = dashFor(id);
464
- BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => pageMore(id), rename, pop: o.pop || undefined,
497
+ BODY = VW.open({ id: 'ov:' + id, kind: X.ctx.kindOf(id), title: X.ctx.iniTitle(id), icon: 'goal', wrap: true, more: () => (PW.on(BODY) ? PW.moreItems(null, popExtra(id)) : []).concat(pageMore(id)), rename, pop: o.pop || undefined,
465
498
  discuss: () => X.ctx.newIn(id), discussHome: true, // the one view (OvViewers): Discuss starts a new session about it, where + New session was
466
499
  // the kind of work (batch 29 item 11, KdV1-3): its glyph stands before Discuss; a tap opens the three kinds
467
500
  presses: [WK.pressOf(kindNow(id))].concat(dh ? dh.presses() : []), onPress: (a, btn) => {
@@ -542,7 +575,7 @@ function draw(b) {
542
575
  const v = X.view;
543
576
  if (v !== 'page') b.__pg = null;
544
577
  if (v === 'page' && dashFor(id) && dashFor(id).shows()) { b.__pg = null; b.innerHTML = dashFor(id).html(() => ''); return; }
545
- if (v === 'page') { const h = pageHtml(id, M); if (b.__pg !== h || !b.firstChild) { b.__pg = h; b.innerHTML = h; } return; }
578
+ if (v === 'page') { const h = PW.on(b) ? popHtml(id, M) : pageHtml(id, M); if (b.__pg !== h || !b.firstChild) { b.__pg = h; b.innerHTML = h; } return; }
546
579
  // Documents is shell A (XvADocs): no tabs, the summary card and folding groups straight in the body
547
580
  if (v === 'docs') { b.innerHTML = docsView(id, M) + '<p class="hi-small" role="status" id="ovMsg"></p>'; return; }
548
581
  // the phone keeps the Documents | Stage switch (PgTkList); in shell A on a desktop the other view sits under ⋯ (XvATasks)
@@ -17,6 +17,8 @@
17
17
  * wire(body) once per body: the name field (Enter or blur saves, Esc closes), the add field (Enter adds and stays open),
18
18
  * a press outside the open row closes it, and the drag (StA10Drag): a grip on hover on a desktop, a long press
19
19
  * on the title on a phone; the target stage lights up and a blue line shows where the task lands
20
+ * milestone(H, x, on) a task made a milestone (one date: the due day, else the start) or a task again, through H.dates; the
21
+ * host's toast carries Undo. The popup for work (pm/cozy-pop-work.js) calls the same, so there is one way
20
22
  * writes(h) the host's handlers with the writes this file needs, where the host has none: h.rename(uid, title),
21
23
  * h.move(uid, { to, from, ids, name }) (a stage, and the order inside it), each with Undo in the toast,
22
24
  * h.jiraMove({ key, to, from, fromRaw }) (a Jira ticket's status, moved in Jira: pm/jira-move.js)
@@ -290,7 +292,7 @@ function moreMenu(b, uid, id, v, H) {
290
292
  }
291
293
  /** A milestone has one date (StA4Milestone): turning ◇ on keeps the due day (or the start, when it has no due day) and clears the start; the
292
294
  * host's Undo puts both back. */
293
- function milestone(H, x, on) {
295
+ export function milestone(H, x, on) {
294
296
  if (!H.dates) return;
295
297
  const p = { milestone: on };
296
298
  if (on && x.start) { p.start = ''; if (!x.end) p.due = x.start; }
@@ -136,7 +136,7 @@ function rowOf(k0, today, J = null) {
136
136
  // the List's meta draws the dates as their own press (batch 9 item 5b): days is the dates alone, lateText what follows them
137
137
  return { uid: k.uid, title: k.title, status: k.status || 'To do', closed, done: k.status === 'Done', wont: k.status === "Won't do", prog: k.status === 'In progress', late, due,
138
138
  days, lateText: late ? plural(between(d, today), 'day', 'days') + ' late' : '', item: !!k.item, ms: !!k.milestone, // ms: the ◇ flag (batch 11 item 3)
139
- start: k.start || '', end: k.end || '', owner: who, av: initials(k.owner),
139
+ start: k.start || '', end: k.end || '', since: k.since || '', owner: who, av: initials(k.owner),
140
140
  // the open row's date chips (batch 18 item 16): each day alone; rank: the PM's order inside its stage (a task-order line)
141
141
  startText: k.start ? dateY(k.start, today) : '', dueText: d ? dateY(k.end, today) : '', rank: Number.isFinite(k.rank) ? k.rank : null,
142
142
  sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid && !k.draft && !J, order: k.order,
@@ -0,0 +1,197 @@
1
+ /* pm/library-model.js — the Library's catalogue, PURE (initiative library-place; slice 7 of the six-place navigation, Library round 2).
2
+ *
3
+ * A library keeps a catalogue, not a list by date: one record per item with the same fields, shelves where related items stand together,
4
+ * editions under one record, what is new, and a search on the record and the content. This module is that catalogue over the items of
5
+ * GET /api/library-items (lib/library-items.js ITEM).
6
+ *
7
+ * COLUMNS Name, Kind, Product, About, By, State, Updated
8
+ * FAMILIES · GROUPS · STATES the Kind chip's families, the Group by choices, the State chip's states
9
+ * aboutText(item) → "Program › Initiative"; the initiative leaves when it repeats the Name, and nothing when all of it does
10
+ * stateText(row) → "Final", "Draft · v3"
11
+ * passes(item, f) → whether the filters keep a row. f: { kinds: ['f:<family>' | 'k:<kind>'], states: [state], scope: (tokens) => bool }
12
+ * matches(item, q) → whether the words find the row by its record (name, kind, product, about, by, state)
13
+ * counts(items, f) → { families: {key: n}, kinds: {kind: n}, states: {state: n} }: each chip's counts under the other filters
14
+ * view(items, o) → { groups: [{ key, label, level, n, folded, rows }], shown, hidden }
15
+ * o: { q, f, group: 'new'|'work'|'kind'|'product', open: Set of keys the PM unfolded, shut: Set of keys the PM folded, now }
16
+ * A row: { x, older: [item] } (editions of one document fold under the newest, "v3 · 2 older"), or { checks: [item], key, about }
17
+ * (grouped by New, the gate records of one initiative fold into one "Checks · 3" row; a Kind filter that asks for them shows them singly)
18
+ * Grouped by Work, each program is a shelf and each initiative a shelf inside it; the items stand in the order of the work
19
+ * (brief, PRD, design, prototype, done test, meeting notes), one row per kind with the other files of that kind folded under the
20
+ * newest ("2 earlier"), and a shelf folds.
21
+ * hiddenText(n) → "418 hidden by the filters"
22
+ * groupOf(iso, now) · dayText(iso, now) · noteOf(q, group)
23
+ */
24
+
25
+ export const COLUMNS = ['Name', 'Kind', 'Product', 'About', 'By', 'State', 'Updated'];
26
+ export const FAMILIES = [['plans', 'Plans and specs'], ['briefs', 'Briefs'], ['meetings', 'Meeting notes'], ['protos', 'Prototypes and designs'], ['checks', 'Checks'], ['links', 'Links']];
27
+ export const GROUPS = [['new', 'New'], ['work', 'Work'], ['kind', 'Kind'], ['product', 'Product']];
28
+ export const STATES = ['Draft', 'Final', 'Issued'];
29
+ const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
30
+ const DAY = 864e5;
31
+
32
+ const bare = (s) => String(s || '').toLowerCase().replace(/…$/, '').replace(/[^a-z0-9]+/g, ' ').trim();
33
+ const repeats = (a, name) => { const A = bare(a), N = bare(name); return !A || A === N || (A.length >= 4 && N.startsWith(A)); };
34
+ export function aboutText(x) {
35
+ const a = (x && x.about) || {};
36
+ const ini = repeats(a.title, x && x.name) ? '' : a.title || '';
37
+ const prog = a.programTitle && !repeats(a.programTitle, x && x.name) ? a.programTitle : '';
38
+ return [prog, ini].filter(Boolean).join(' › ');
39
+ }
40
+ export function stateText(r) {
41
+ const x = r && (r.x || r);
42
+ if (!x || !x.state) return '';
43
+ // the edition: the version the item says, else its place among the editions folded under it (other files of its kind are not editions)
44
+ const v = x.v || (r.older && r.older.length && r.older.every((o) => o.ed && o.ed === x.ed) ? r.older.length + 1 : null);
45
+ return x.state + (v && v > 1 ? ' · v' + v : '');
46
+ }
47
+ export const noteOf = (q, group) => (q ? '' : group === 'work'
48
+ ? 'Each program and initiative is a shelf; inside, the work stands in its order. Press a shelf to fold it.'
49
+ : 'Everything that was made, the newest first. Press a row to open it in the popup, with the chat beside it. Reports are in Routine.');
50
+
51
+ /* ── filters ── */
52
+ const kindOn = (x, kinds) => !kinds || !kinds.length || kinds.includes('f:' + x.family) || kinds.includes('k:' + x.kindText);
53
+ const stateOn = (x, states) => !states || !states.length || states.includes(x.state);
54
+ export function passes(x, f = {}) {
55
+ return !!x && kindOn(x, f.kinds) && stateOn(x, f.states) && (!f.scope || f.scope(x.scope || []));
56
+ }
57
+ const norm = (s) => String(s || '').toLowerCase();
58
+ export function matches(x, q) {
59
+ const words = norm(q).split(/\s+/).filter(Boolean);
60
+ if (!words.length) return true;
61
+ const a = x.about || {};
62
+ const hay = norm([x.name, x.sub, x.kindText, x.state, x.by, x.came, x.product, a.title, a.programTitle].join(' '));
63
+ return words.every((w) => hay.includes(w));
64
+ }
65
+ export function counts(items, f = {}) {
66
+ const families = {}, kinds = {}, states = {};
67
+ for (const x of items || []) {
68
+ if (passes(x, { ...f, kinds: null })) { families[x.family] = (families[x.family] || 0) + 1; kinds[x.kindText] = (kinds[x.kindText] || 0) + 1; }
69
+ if (x.state && passes(x, { ...f, states: null })) states[x.state] = (states[x.state] || 0) + 1;
70
+ }
71
+ return { families, kinds, states };
72
+ }
73
+ /** Does the Kind filter ask for gate records (the Checks family, or one of its kinds)? */
74
+ const asksChecks = (kinds, items) => !!kinds && kinds.some((k) => k === 'f:checks' || (k.startsWith('k:') && (items || []).some((x) => x.gate && 'k:' + x.kindText === k)));
75
+
76
+ /* ── dates ── */
77
+ const t = (iso) => { const n = Date.parse(String(iso || '').length === 10 ? iso + 'T12:00:00' : iso); return Number.isFinite(n) ? n : null; };
78
+ export function groupOf(iso, now = Date.now()) {
79
+ const at = t(iso);
80
+ if (at == null) return 'Older';
81
+ const n = new Date(now), start = new Date(n.getFullYear(), n.getMonth(), n.getDate()).getTime();
82
+ if (at >= start - 6 * DAY) return 'This week';
83
+ const d = new Date(at);
84
+ if (d.getFullYear() === n.getFullYear() && d.getMonth() === n.getMonth()) return 'Earlier in ' + MONTHS[n.getMonth()];
85
+ return 'Older';
86
+ }
87
+ export function dayText(iso, now = Date.now()) {
88
+ const at = t(iso); if (at == null) return '';
89
+ const d = new Date(at), y = new Date(now).getFullYear();
90
+ return d.getDate() + ' ' + MONTHS[d.getMonth()].slice(0, 3) + (d.getFullYear() !== y ? ' ' + d.getFullYear() : '');
91
+ }
92
+ export const when = (x) => (x && (x.kind === 'meeting' && x.held ? x.held : x.updated)) || null;
93
+ const newest = (a, b) => (t(when(b)) || 0) - (t(when(a)) || 0) || String(a.name).localeCompare(String(b.name));
94
+
95
+ /* the order of the work inside a shelf (round 2, point 3) */
96
+ const WORK_ORDER = ['Anchor', 'Strategic brief', 'Design brief', 'Content brief', 'Spike brief', 'Pre-read', 'Prototype brief', 'Prototype', 'PRD', 'User stories',
97
+ 'Spec', 'API spec', 'Design', 'Risk list', 'Done test', 'Rubric', 'Eval', 'Retro', 'Minutes', 'Meeting notes', 'Update note', 'Report'];
98
+ const workRank = (x) => { const i = WORK_ORDER.indexOf(x.kind === 'proto' ? 'Prototype' : x.kindText); return i < 0 ? WORK_ORDER.length - 0.5 : i; };
99
+
100
+ /** Fold the editions of one document under its newest (the highest version, else the newest date). */
101
+ function editions(list) {
102
+ const by = new Map(), out = [];
103
+ for (const x of list) {
104
+ if (!x.ed) { out.push({ x, older: [] }); continue; }
105
+ let r = by.get(x.ed);
106
+ if (!r) { r = { x, older: [] }; by.set(x.ed, r); out.push(r); continue; }
107
+ const better = (x.v || 0) > (r.x.v || 0) || ((x.v || 0) === (r.x.v || 0) && newest(x, r.x) < 0);
108
+ if (better) { r.older.push(r.x); r.x = x; } else r.older.push(x);
109
+ }
110
+ for (const r of out) r.older.sort((a, b) => (b.v || 0) - (a.v || 0) || newest(a, b));
111
+ return out;
112
+ }
113
+ /** One row per Kind: the newest (the highest version, else the newest date) stands, the other files of that kind fold under it. */
114
+ export function perKind(rows) {
115
+ const by = new Map(), out = [];
116
+ for (const r of rows) {
117
+ const k = r.x.kindText || '';
118
+ const h = by.get(k);
119
+ if (!h) { const n = { x: r.x, older: r.older.slice() }; by.set(k, n); out.push(n); continue; }
120
+ const better = (r.x.v || 0) > (h.x.v || 0) || ((r.x.v || 0) === (h.x.v || 0) && newest(r.x, h.x) < 0);
121
+ if (better) { h.older.push(h.x, ...r.older); h.x = r.x; } else h.older.push(r.x, ...r.older);
122
+ }
123
+ for (const r of out) r.older.sort((a, b) => (b.v || 0) - (a.v || 0) || newest(a, b));
124
+ return out;
125
+ }
126
+ const iniKey = (x) => (x.about && x.about.ws && x.about.ini ? x.about.ws + '|' + x.about.ini : '');
127
+
128
+ export function view(items, { q = '', f = {}, group = 'new', open = new Set(), shut = new Set(), now = Date.now() } = {}) {
129
+ const all = items || [];
130
+ const base = all.filter((x) => matches(x, q));
131
+ const kept = base.filter((x) => passes(x, f));
132
+ const hidden = base.length - kept.length;
133
+ const single = !!String(q).trim() || asksChecks(f.kinds, all) || group !== 'new';
134
+ let rows = editions(kept.slice().sort(newest));
135
+ // grouped by New, an initiative's gate records stand as one "Checks · N" row at the date of the newest
136
+ if (!single) {
137
+ const checks = new Map(), out = [];
138
+ for (const r of rows) {
139
+ const k = r.x.gate ? iniKey(r.x) : '';
140
+ if (!k) { out.push(r); continue; }
141
+ let c = checks.get(k);
142
+ if (!c) { c = { checks: [], key: 'checks:' + k, about: r.x.about, x: null }; checks.set(k, c); out.push(c); }
143
+ c.checks.push(r.x, ...r.older);
144
+ }
145
+ // one gate record alone stands as itself: a fold of one hides nothing
146
+ rows = out.map((r) => (r.checks && r.checks.length === 1 ? { x: r.checks[0], older: [] } : r));
147
+ }
148
+ const at = (r) => (r.checks ? when(r.checks[0]) : when(r.x));
149
+ const groups = [];
150
+ const add = (key, label, level, list, foldable) => {
151
+ const folded = foldable ? (open.has(key) ? false : shut.has(key) ? true : level === 2 && groups.filter((g) => g.level === 2).length >= 3) : false;
152
+ groups.push({ key, label, level, n: list.reduce((s, r) => s + (r.checks ? r.checks.length : 1 + r.older.length), 0), folded, rows: list });
153
+ };
154
+ if (group === 'work') {
155
+ // program › initiative shelves, the most recently touched first; work with no program stands after, then what is not linked to work
156
+ const shelves = new Map();
157
+ for (const r of rows) {
158
+ const a = r.x.about || {};
159
+ const k = a.ini ? 'w:' + a.ws + '|' + a.ini : 'w:none';
160
+ let s = shelves.get(k);
161
+ if (!s) { s = { key: k, prog: a.program || '', progTitle: a.programTitle || '', label: a.ini ? a.title || a.ini : 'Not linked to work', list: [] }; shelves.set(k, s); }
162
+ s.list.push(r);
163
+ }
164
+ const S = [...shelves.values()];
165
+ // one initiative's shelf holds one row per kind (popup round 3, point 16i): the newest stands, the rest fold under it ("2 earlier")
166
+ for (const s of S) if (s.key !== 'w:none') s.list = perKind(s.list);
167
+ for (const s of S) { s.list.sort((a, b) => workRank(a.x) - workRank(b.x) || newest(a.x, b.x)); s.at = Math.max(...s.list.map((r) => t(at(r)) || 0)); }
168
+ const progs = new Map();
169
+ for (const s of S) {
170
+ const pk = s.key === 'w:none' ? '~none' : s.prog ? 'g:' + s.prog : '~solo';
171
+ if (!progs.has(pk)) progs.set(pk, { key: pk, label: s.progTitle || (pk === '~solo' ? 'Not in a program' : ''), list: [], at: 0 });
172
+ const p = progs.get(pk); p.list.push(s); p.at = Math.max(p.at, s.at);
173
+ }
174
+ const P = [...progs.values()].sort((a, b) => (a.key[0] === '~') - (b.key[0] === '~') || (a.key === '~none') - (b.key === '~none') || b.at - a.at);
175
+ for (const p of P) {
176
+ p.list.sort((a, b) => b.at - a.at);
177
+ if (p.label) groups.push({ key: p.key, label: p.label, level: 1, n: p.list.reduce((n, s) => n + s.list.reduce((m, r) => m + 1 + r.older.length, 0), 0), folded: false, rows: [] });
178
+ for (const s of p.list) add(s.key, s.label, 2, s.list, true);
179
+ }
180
+ } else if (group === 'kind' || group === 'product') {
181
+ const by = new Map();
182
+ for (const r of rows) {
183
+ const k = group === 'kind' ? r.x.family || 'plans' : r.x.product || '';
184
+ if (!by.has(k)) by.set(k, []);
185
+ by.get(k).push(r);
186
+ }
187
+ const order = group === 'kind' ? FAMILIES.map(([k]) => k).filter((k) => by.has(k)) : [...by.keys()].sort((a, b) => (!a) - (!b) || a.localeCompare(b));
188
+ for (const k of order) add('k:' + k, group === 'kind' ? (FAMILIES.find(([f]) => f === k) || [k, k])[1] : k || 'No product', 1, by.get(k), false);
189
+ } else {
190
+ const by = new Map();
191
+ for (const r of rows) { const g = groupOf(at(r), now); if (!by.has(g)) by.set(g, []); by.get(g).push(r); }
192
+ for (const g of [...by.keys()].sort((a, b) => rankNew(a) - rankNew(b))) add('n:' + g, g, 1, by.get(g), false);
193
+ }
194
+ return { groups, shown: kept.length, hidden };
195
+ }
196
+ const rankNew = (g) => (g === 'This week' ? 0 : g === 'Older' ? 2 : 1);
197
+ export const hiddenText = (n) => (n > 0 ? n + ' hidden by the filters' : '');
@@ -0,0 +1,37 @@
1
+ /* pm/library-open.js — open one thing that was made, in the one popup (initiative library-place, slice 7 of the six-place navigation).
2
+ * The thing is on the left, in the Viewer that already draws it; the chat on the right is about it (cozy-popup.js openWork → popNext).
3
+ *
4
+ * openItem(item, { from }?) item = GET /api/library-items ITEM (lib/library-items.js); the Library page passes from: 'Library'
5
+ * doc the document as its page (premium-vw-doc.js openDocPage)
6
+ * meeting the meeting notes card: who was there, the summary, decisions and tasks (premium-vw-open.js openMeeting)
7
+ * proto the design canvas of the prototype round (cozy-lab.js openCompare, which draws cozy-proto.js)
8
+ * link a new browser tab; nothing opens in PMOS
9
+ * aboutOf(item, from) → { id, kind, title, ws, from?, kindChip } what the chat beside it is about; from ('Library') and kindChip are
10
+ * what the popup's header draws: ←, "Library › name" and the small kind chip (cozy-viewer.js reads them from popNext)
11
+ * Slice 3's Artefacts table opens its rows with the same openItem. On a phone the Viewer opens as it does today (no popup). */
12
+ import * as POP from './cozy-popup.js';
13
+
14
+ const KIND = { doc: 'document', link: 'link', meeting: 'meeting', proto: 'prototype' };
15
+ const CHIP = { link: 'Link', meeting: 'Meeting notes', proto: 'Prototype' };
16
+ export const aboutOf = (x, from) => ({ id: String(x.id || '').replace(/[^A-Za-z0-9._:-]+/g, '-').slice(0, 100), kind: KIND[x.kind] || 'document', title: x.name || '', ws: (x.about && x.about.ws) || undefined,
17
+ ...(from ? { from } : {}), kindChip: CHIP[x.kind] || x.kindText || 'Document' });
18
+
19
+ export function openItem(x, { from } = {}) {
20
+ if (!x || !x.open) return false;
21
+ const o = x.open;
22
+ if (o.url) { try { window.open(o.url, '_blank', 'noopener,noreferrer'); } catch { /* a blocked window: nothing opens */ } return true; }
23
+ const go = async () => {
24
+ if (o.doc) {
25
+ const M = await import('./premium-vw-doc.js');
26
+ M.openDocPage({ path: o.doc.path, title: x.name }, { ws: () => o.doc.ws || '', ini: (x.about && x.about.ini) || undefined });
27
+ } else if (o.note) {
28
+ await import('./premium-vw-open.js');
29
+ window.czViews.openMeeting({ note: o.note }, { ws: o.ws || '' });
30
+ } else if (o.proto) {
31
+ const LC = await import('./cozy-lab.js');
32
+ LC.openCompare({ where: { ws: o.proto.ws, board: o.proto.board || '' }, id: o.proto.id });
33
+ }
34
+ };
35
+ POP.openWork({ about: aboutOf(x, from), open: () => { go().catch((e) => console.error(e)); } });
36
+ return true;
37
+ }
@@ -60,7 +60,11 @@ function host() {
60
60
  roles: () => [], seen: () => null, markSeen: () => {}, session: () => null, queued: () => [],
61
61
  touch: (sid) => { if (sid) pmPost('/api/session/touch', { id: sid }).then(() => document.dispatchEvent(new CustomEvent('cz:live'))).catch(() => {}); },
62
62
  // × on the "You are on …" chip drops the page: the chat reads Everything again (C5)
63
- onScope: () => { if (Q.t && Q.t.cos && Q.t.here) { Q.t = cosTarget('', Q.t.ws); Q.chat.open(Q.t); } },
63
+ // × on the popup's "About …" chip (board 23): the chat is about nothing in particular, so it is the chat over everything
64
+ onScope: () => {
65
+ const c = (Q.chat && Q.chat.current && Q.chat.current()) || Q.t;
66
+ if (c && ((c.cos && c.here) || c.popAbout)) { Q.t = cosTarget('', c.ws); Q.chat.open(Q.t); }
67
+ },
64
68
  onTo: () => {}, onLink: () => {},
65
69
  workItem: () => toast('Make a work-item from Home, in the initiative’s own chat.'),
66
70
  viewerClosed: () => false, reopenViewer: () => {}, desk: () => true, head: () => '',
@@ -77,11 +81,17 @@ const shownAt = () => VW.panels.list().find((p) => p.open && p.item && p.item.id
77
81
  const GLOBE = 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18';
78
82
  const PIN = 'M4 5h16v14H4z';
79
83
  /** The chief-of-staff chat's target (lib/cos-chat.js): Home's own conversation; the chip says where the PM is, and context carries it. */
84
+ /** The popup's chat about a thing (board 23): the chip reads "In: <thing> ×", the one form every chat uses, and the chat starts with two plain grey lines. */
85
+ export function popTarget(it, ws) {
86
+ const T = targetOf(it, ws);
87
+ return { ...T, popAbout: true, scope: { text: 'In: ' + T.title, icon: PIN, drop: true }, placeholder: 'Ask or tell PMOS', empty: COS_EMPTY };
88
+ }
89
+ const COS_EMPTY = 'Ask anything about your work. I read it with PMOS and say where each answer came from.';
80
90
  export function cosTarget(here, ws) {
81
91
  const h = String(here || '').replace(/\s+/g, ' ').trim().slice(0, 80);
82
92
  return { key: 'chat:main', ws: ws || undefined, title: 'Ask PMOS', about: 'Ask PMOS', role: CLAUDE, rich: false, cos: true, here: h,
83
93
  scope: h ? { text: 'You are on ' + h, icon: PIN, drop: true } : { text: 'Everything', icon: GLOBE }, context: h || undefined,
84
- placeholder: 'Ask or tell PMOS', empty: 'Ask anything about your work. I read it with PMOS and say where each answer came from.' };
94
+ placeholder: 'Ask or tell PMOS', empty: COS_EMPTY };
85
95
  }
86
96
  /** The chief-of-staff chat over this page (the menu's chat icon). here: "Board · Atlas"; × on the chip drops it. On a desk it opens in the
87
97
  * one popup (cozy-popup.js, slice 2 of the six-place navigation) with the list of sessions beside it; a phone keeps the chat's sheet. */