create-pmos 0.396.0 → 0.398.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 (177) hide show
  1. package/package.json +25 -25
  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/scripts/nine-stages.js +49 -20
  6. package/payload/state/discoveries.md +1 -1
  7. package/payload/state/log.md +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +103 -74
  9. package/workspace/briefing-premium-board-test.js +316 -154
  10. package/workspace/briefing-premium-calendar-2-test.js +135 -195
  11. package/workspace/briefing-premium-calendar-3-test.js +143 -413
  12. package/workspace/briefing-premium-calendar-test.js +86 -185
  13. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  14. package/workspace/briefing-premium-initiative-test.js +166 -294
  15. package/workspace/briefing-premium-insights-test.js +351 -214
  16. package/workspace/briefing-premium-metrics-test.js +53 -118
  17. package/workspace/briefing-premium-products-test.js +40 -27
  18. package/workspace/briefing-premium-sources-test.js +91 -52
  19. package/workspace/briefing-premium-test.js +150 -633
  20. package/workspace/briefing-premium-work-test.js +88 -269
  21. package/workspace/changelog.json +24 -0
  22. package/workspace/fixtures/board-premium-facts.js +2 -1
  23. package/workspace/fixtures/board-premium-jira.js +28 -0
  24. package/workspace/fixtures/board-premium-trail.js +32 -0
  25. package/workspace/fixtures/initiative-premium-facts.js +2 -1
  26. package/workspace/fixtures/initiatives-api/list.json +30 -42
  27. package/workspace/fixtures/initiatives-api/roadmap.json +40 -56
  28. package/workspace/fixtures/initiatives-api/sheet.json +10 -14
  29. package/workspace/fixtures/insights-premium-facts.js +11 -2
  30. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  31. package/workspace/guide/briefing-premium.md +3 -1
  32. package/workspace/guide/home.md +47 -0
  33. package/workspace/guide/index.md +2 -0
  34. package/workspace/guide/lifecycle.md +51 -0
  35. package/workspace/home-shot.js +38 -0
  36. package/workspace/lib/agent-roles.js +71 -0
  37. package/workspace/lib/board-premium.js +160 -3
  38. package/workspace/lib/board-trail.js +223 -0
  39. package/workspace/lib/engine/boards.js +15 -14
  40. package/workspace/lib/engine/nine-stages.js +49 -20
  41. package/workspace/lib/engine/signals/detectors.js +13 -11
  42. package/workspace/lib/home-work-item.js +58 -0
  43. package/workspace/lib/insights-goals.js +196 -0
  44. package/workspace/lib/insights-premium.js +126 -1
  45. package/workspace/lib/insights-records.js +101 -0
  46. package/workspace/lib/jira-tickets.js +1 -1
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-board-premium.js +3 -2
  49. package/workspace/lib/routes-board-trail.js +33 -0
  50. package/workspace/lib/routes-home-desk.js +176 -0
  51. package/workspace/lib/routes-initiatives.js +1 -1
  52. package/workspace/lib/routes-insights-premium.js +19 -3
  53. package/workspace/lib/routes-insights-records.js +129 -0
  54. package/workspace/lib/routes-notes.js +1 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/transcript-steps.js +123 -0
  57. package/workspace/lib/vendor/scripts/nine-stages.js +49 -20
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-agreed-viewer-shots.js +76 -0
  63. package/workspace/premium-board-actions-test.js +85 -73
  64. package/workspace/premium-briefing-depth-test.js +66 -53
  65. package/workspace/premium-chat-attach-test.js +54 -63
  66. package/workspace/premium-chat-chart-tab-test.js +35 -36
  67. package/workspace/premium-chat-context-test.js +22 -19
  68. package/workspace/premium-chat-goal-view-test.js +28 -26
  69. package/workspace/premium-chat-notes-test.js +29 -33
  70. package/workspace/premium-chat-report-tab-test.js +35 -25
  71. package/workspace/premium-chat-term-test.js +16 -14
  72. package/workspace/premium-chat-viewer-test.js +60 -53
  73. package/workspace/premium-core-doc-issue-test.js +50 -41
  74. package/workspace/premium-html-viewer-test.js +17 -18
  75. package/workspace/premium-phone-card-test.js +8 -2
  76. package/workspace/premium-phone-room-test.js +42 -31
  77. package/workspace/premium-report-read-test.js +115 -197
  78. package/workspace/premium-viewer-download-test.js +19 -22
  79. package/workspace/premium-viewer-flicker-test.js +11 -16
  80. package/workspace/premium-viewer-share-test.js +6 -9
  81. package/workspace/premium-viewer-test.js +41 -60
  82. package/workspace/premium-vw-backlog-test.js +53 -31
  83. package/workspace/premium-vw-cal-test.js +82 -123
  84. package/workspace/premium-vw-copy-test.js +17 -33
  85. package/workspace/premium-vw-doc-test.js +12 -11
  86. package/workspace/premium-vw-item-test.js +50 -48
  87. package/workspace/premium-vw-jira-test.js +55 -26
  88. package/workspace/premium-vw-meet-test.js +118 -187
  89. package/workspace/premium-vw-notes-test.js +85 -107
  90. package/workspace/premium-vw-rec-test.js +72 -193
  91. package/workspace/premium-vw-slides-test.js +46 -50
  92. package/workspace/premium-welcome-test.js +3 -2
  93. package/workspace/premium-work-depth-test.js +63 -51
  94. package/workspace/public/pm/bd-acts.js +305 -0
  95. package/workspace/public/pm/bd-span.js +224 -0
  96. package/workspace/public/pm/bd-stages.js +47 -0
  97. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  98. package/workspace/public/pm/c3-md.js +3 -395
  99. package/workspace/public/pm/c3-phone-detail.js +1 -1
  100. package/workspace/public/pm/c3-phone-model.js +3 -68
  101. package/workspace/public/pm/chat-term.js +3 -3
  102. package/workspace/public/pm/cozy-board.css +640 -0
  103. package/workspace/public/pm/cozy-home.css +580 -0
  104. package/workspace/public/pm/cozy-home.js +172 -0
  105. package/workspace/public/pm/cozy-initiative.css +138 -0
  106. package/workspace/public/pm/cozy-insights.css +421 -0
  107. package/workspace/public/pm/cozy-md.js +396 -0
  108. package/workspace/public/pm/cozy-nav.js +65 -0
  109. package/workspace/public/pm/cozy-placeholder.js +26 -0
  110. package/workspace/public/pm/cozy-viewer.css +143 -0
  111. package/workspace/public/pm/cozy-viewer.js +144 -0
  112. package/workspace/public/pm/cozy-vw.css +485 -0
  113. package/workspace/public/pm/cozy.css +254 -0
  114. package/workspace/public/pm/home-adddoc.js +48 -0
  115. package/workspace/public/pm/home-app.js +905 -0
  116. package/workspace/public/pm/home-around.js +515 -0
  117. package/workspace/public/pm/home-chat.js +459 -0
  118. package/workspace/public/pm/home-data.js +312 -0
  119. package/workspace/public/pm/home-draft.js +68 -0
  120. package/workspace/public/pm/home-more.js +249 -0
  121. package/workspace/public/pm/home-phone-card.js +109 -0
  122. package/workspace/public/pm/home-work.js +519 -0
  123. package/workspace/public/pm/lifecycle-lens-model.js +45 -27
  124. package/workspace/public/pm/lifecycle-lens.js +22 -11
  125. package/workspace/public/pm/phone-moment.js +69 -0
  126. package/workspace/public/pm/pm-work-view.js +1 -1
  127. package/workspace/public/pm/premium-attach.js +4 -0
  128. package/workspace/public/pm/premium-board.js +544 -253
  129. package/workspace/public/pm/premium-brief.js +1 -1
  130. package/workspace/public/pm/premium-chart-tab.js +110 -62
  131. package/workspace/public/pm/premium-chat.js +17 -10
  132. package/workspace/public/pm/premium-deck.js +3 -3
  133. package/workspace/public/pm/premium-first.js +25 -21
  134. package/workspace/public/pm/premium-initiative-head.js +138 -0
  135. package/workspace/public/pm/premium-initiative.js +28 -4
  136. package/workspace/public/pm/premium-insights.js +950 -440
  137. package/workspace/public/pm/premium-meeting.js +61 -549
  138. package/workspace/public/pm/premium-notes.js +1 -1
  139. package/workspace/public/pm/premium-report-frame.css +20 -0
  140. package/workspace/public/pm/premium-report-read.js +509 -480
  141. package/workspace/public/pm/premium-report-tab.js +87 -63
  142. package/workspace/public/pm/premium-shell.js +107 -124
  143. package/workspace/public/pm/premium-viewer.js +27 -1
  144. package/workspace/public/pm/premium-vw-cal.js +187 -48
  145. package/workspace/public/pm/premium-vw-doc.css +6 -0
  146. package/workspace/public/pm/premium-vw-doc.js +40 -2
  147. package/workspace/public/pm/premium-vw-file.js +2 -2
  148. package/workspace/public/pm/premium-vw-jira-model.js +22 -5
  149. package/workspace/public/pm/premium-vw-jira.css +11 -0
  150. package/workspace/public/pm/premium-vw-jira.js +11 -4
  151. package/workspace/public/pm/premium-vw-meet.js +6 -83
  152. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  153. package/workspace/public/pm/premium-vw-notes.js +56 -69
  154. package/workspace/public/pm/premium-vw-open.js +35 -0
  155. package/workspace/public/pm/premium-vw-page.js +16 -0
  156. package/workspace/public/pm/premium-vw-rec.js +11 -215
  157. package/workspace/public/pm/premium-vw-slides.css +5 -0
  158. package/workspace/public/pm/premium-vw-slides.js +44 -8
  159. package/workspace/public/pm/term-view.js +22 -0
  160. package/workspace/public/premium-board.html +57 -64
  161. package/workspace/public/premium-chat.html +7 -33
  162. package/workspace/public/premium-initiative.html +8 -41
  163. package/workspace/public/premium-insights.html +63 -62
  164. package/workspace/public/premium-viewer.html +20 -0
  165. package/workspace/public/premium-work.html +6 -72
  166. package/workspace/public/premium.html +21 -66
  167. package/workspace/public/vendor/nunito-var.woff2 +0 -0
  168. package/workspace/server.js +25 -3
  169. package/workspace/test-files.json +1 -0
  170. package/workspace/test-lists/home-libs.json +9 -0
  171. package/workspace/test-lists/premium-agreed-viewer.json +9 -0
  172. package/workspace/test-lists/premium-report-read.json +1 -1
  173. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  174. package/workspace/test-lists/premium-vw-notes.json +1 -1
  175. package/workspace/third-party/README.md +1 -0
  176. package/workspace/public/pm/premium-work.js +0 -719
  177. package/workspace/public/pm/premium.js +0 -1133
@@ -1,11 +1,9 @@
1
1
  /* pm/premium-shell.js — what the premium Briefing and My work pages share: the theme, the toast, the standard dialog and the read-only agent's conversation (initiatives briefing-premium and my-work-premium). */
2
2
  import { pmGet, pmPost } from './http.js';
3
- import { recChipView, STOP_LINE } from './premium-meeting.js';
4
3
  import { vwReset, vwOn, vwCount, vwOpen, vwStyle } from './premium-viewer.js';
5
4
  import { openChatFile, openWebLink } from './premium-vw-file.js';
6
5
  import { turnsOf } from './chat-context.js';
7
6
  import { chipsHtml, itemOf, openCtx } from './premium-vw-ctx.js';
8
- import { chipActs, openLive, openFocus, mountRecord, HL_LINE } from './premium-vw-rec.js';
9
7
  import { lineItems, behindOf, whenRead } from './freshness-words.js';
10
8
  import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches } from './goal-chat.js';
11
9
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
@@ -13,13 +11,33 @@ import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
13
11
  import { askCardHtml, answerText } from './chat-ask.js';
14
12
  import { termTarget, TERM_ICON } from './chat-term.js';
15
13
  import { openReportTab } from './premium-report-tab.js';
14
+ import { placeholder as czPlaceholderView } from './cozy-viewer.js'; // the Agreed design's Viewer; imported first, so its Escape runs before the dialog's
16
15
  import { openChartTab } from './premium-chart-tab.js';
17
16
  /** A pmos-report block opens the Report tab, or the Chart tab for a chart or a dashboard (premium-reports-from-chat, slice C). */
18
17
  export const openBlockTab = (b) => (b && b.kind === 'report' ? openReportTab(b) : openChartTab(b));
19
18
  import { mountNotes, openNotes, flushNotes, syncNotes } from './premium-notes.js';
20
19
  import { attachMarkup, attachRowMarkup, mountAttach, attachNames, clearAttach, syncAttach, dropFiles, splitFiles, filesHtml, openAttachment } from './premium-attach.js';
21
- import { railModel, railHtml, teaser, menuCount, loudestRow, factsOf, titleOf, endAsks, DOT, WORD } from './session-rail.js';
22
- export const $ = (s, r = document) => r.querySelector(s);
20
+ import { railModel, railHtml, teaser, loudestRow, factsOf, titleOf, endAsks, DOT, WORD } from './session-rail.js';
21
+ /* premium-agreed-design (Home): a page without the old dialog (Home has none) can still import this module. Its top-level wiring then binds to a
22
+ * detached copy of the dialog's parts that is never put in the page, so nothing old shows and nothing throws. A page with #dlg is unchanged. */
23
+ const DETACHED = typeof document !== 'undefined' && !document.getElementById('dlg') ? (() => {
24
+ const d = document.createElement('div');
25
+ d.innerHTML = '<div class="veil" id="veil"></div><div class="dlg" id="dlg" data-mode="split"><p id="dEye"></p><h2 id="dTitle"></h2><p id="dSub"></p>'
26
+ + '<div class="dtools"><button id="dPane"></button><button id="dExpand"><svg><path id="dExpP"/></svg></button><button id="dClose"></button></div><div id="dTabs"></div>'
27
+ + '<div id="dGrid"><section id="dBody"></section><section id="dOut"><div class="otop"><span id="oLab"></span></div><div class="obody" id="oMain"></div><button id="tabGo"></button></section></div></div>'
28
+ + '<div id="toast"></div>';
29
+ return d;
30
+ })() : null;
31
+ export const $ = (s, r = document) => r.querySelector(s) || (DETACHED && r === document ? DETACHED.querySelector(s) : null);
32
+ /* Home (initiative premium-agreed-design, H2): on a desktop the chat is docked beside Home's list, as the middle and right panes, instead of a
33
+ * popup. It is the Chat page's held-open dialog (chatpg) placed right of the list; on a phone, and on every other page, the dialog stays a popup. */
34
+ if (document.body.classList.contains('cz-home') && innerWidth >= 1000) document.body.classList.add('chatpg', 'cz-dock');
35
+ export const homeDock = () => document.body.classList.contains('cz-dock');
36
+ /* The Agreed design has one way between places, the floating place menu (cozy-nav.js). The old five-place rail (Briefing, My work, Chat,
37
+ * Board, Insights) and the old dock are no longer wired: the rail leaves the page, and the dock stays hidden and inert until the pages stop
38
+ * writing their counts into it (premium-agreed-design, shared foundation). */
39
+ document.querySelectorAll('nav.rail').forEach((n) => n.remove());
40
+ { const d = document.getElementById('dock'); if (d) { d.hidden = true; d.inert = true; } }
23
41
  export const $$ = (s, r = document) => [...r.querySelectorAll(s)];
24
42
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
25
43
  export const RM = matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -38,35 +56,38 @@ export function flip() {
38
56
  theme(next); store.set(THEME_KEY, next); tbTheme();
39
57
  }
40
58
  { const t = new URLSearchParams(location.search).get('theme') || store.get(THEME_KEY); theme(t); }
41
- /* ── the top bar (initiative premium-topbar): where you are on the left; the Sources chip, the bell and one menu on the right. Chat is
42
- * the rail's middle place (premium-chat-rail). The menu holds what left the bar: Search, Console, Theme, Settings, and on Board how an initiative opens. Every item keeps
43
- * the id the pages and the code below wire, so a press does what it did as a round button. ── */
59
+ /* ── the top bar: one ⋯ menu (premium-agreed-design). The design draws no Sources chip, no bell, no mic and no help button, and leaves the menu's
60
+ * contents to be designed (only Insights names them: Sources, Export, About these numbers). So each item opens the Viewer on its placeholder, and
61
+ * Theme stays a plain switch. Nothing in the menu leads to the console. The ids moreBtn, moreMenu, modeRow and settingsBtn stay: pages add their
62
+ * own items before #settingsBtn and anchor their popovers on #moreBtn. ── */
44
63
  const MORE = '<svg class="i" viewBox="0 0 24 24"><circle cx="6" cy="12" r="1.3"/><circle cx="12" cy="12" r="1.3"/><circle cx="18" cy="12" r="1.3"/></svg>';
45
64
  const TH = [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']];
65
+ /** The ⋯ menu's items that open a placeholder: [id, label, icon]. Insights adds what its own design names. Pure, for a unit test. */
66
+ export const moreItems = (path = location.pathname) => (/premium-insights/.test(path)
67
+ ? [['srcItem', 'Sources', 'source'], ['tbExport', 'Export', 'export'], ['tbAbout', 'About these numbers', 'info']]
68
+ : [['srcItem', 'Sources', 'source']]);
46
69
  function tbMount() {
47
70
  const t = $('.tools-top'); if (!t || $('#tbMore')) return;
48
- t.insertAdjacentHTML('beforeend', `<button type="button" class="schip" id="srcChip" aria-haspopup="dialog" title="When each source was last read"><i class="sdot" id="srcDot" aria-hidden="true"></i>Sources</button>`
49
- + `<span class="mwrap" id="tbMore"><button type="button" class="glass round" id="moreBtn" aria-haspopup="menu" aria-expanded="false" aria-controls="moreMenu" aria-label="More" title="More">${MORE}<i class="mdot" id="moreDot" hidden></i></button>`
71
+ const items = moreItems();
72
+ t.insertAdjacentHTML('beforeend', `<span class="mwrap" id="tbMore"><button type="button" class="glass round" id="moreBtn" aria-haspopup="menu" aria-expanded="false" aria-controls="moreMenu" aria-label="More" title="More">${MORE}</button>`
50
73
  + '<div class="crmenu tbmenu" id="moreMenu" role="menu" aria-label="More" hidden>'
51
- + '<button role="menuitem" id="pvSearch" aria-haspopup="dialog">Search<em>Ctrl K</em></button>'
52
- + '<button role="menuitem" id="srcItem" class="tbm-src" aria-haspopup="dialog">Sources</button>'
53
- + '<a role="menuitem" id="toConsole" href="/console.html" aria-label="Open the console">Console</a>'
74
+ + items.map(([id, label]) => `<button role="menuitem" id="${id}" aria-haspopup="dialog">${esc(label)}</button>`).join('')
54
75
  + '<div class="tbrow" id="modeRow" hidden><span>Open initiatives</span></div>'
55
76
  + `<div class="tbrow" role="group" aria-label="Theme"><span>Theme</span><span class="tbseg" id="tbTheme">${TH.map(([k, w]) => `<button role="menuitemradio" data-th="${k}" aria-checked="false">${w}</button>`).join('')}</span></div>`
56
- + '<button role="menuitem" id="settingsBtn" aria-haspopup="dialog">Settings<em class="updpill" id="updPill" hidden></em></button></div></span>');
77
+ + '<button role="menuitem" id="settingsBtn" aria-haspopup="dialog">Settings</button></div></span>');
57
78
  const ms = $('#modeSeg'); if (ms) { $('#modeRow').appendChild(ms); $('#modeRow').hidden = false; }
58
79
  tbTheme();
59
80
  const btn = $('#moreBtn'), menu = $('#moreMenu');
60
- const items = () => $$('#moreMenu [role^="menuitem"]').filter((x) => x.offsetParent !== null || x.closest('.tbseg'));
81
+ const live = () => $$('#moreMenu [role^="menuitem"]').filter((x) => x.offsetParent !== null || x.closest('.tbseg'));
61
82
  const close = (back) => { if (menu.hidden) return; menu.hidden = true; btn.setAttribute('aria-expanded', 'false'); if (back) btn.focus(); };
62
83
  btn.onclick = (e) => {
63
84
  e.stopPropagation();
64
85
  if (!menu.hidden) { close(); return; }
65
86
  menu.hidden = false; btn.setAttribute('aria-expanded', 'true');
66
87
  if ($('#modeSeg', menu)) pillOf($('#modeSeg', menu));
67
- const f = items()[0]; if (f) f.focus();
88
+ const f = live()[0]; if (f) f.focus();
68
89
  };
69
- // capture: the menu closes and focus goes back to its button before the item's own press runs, so a dialog it opens returns focus there
90
+ // capture: the menu closes and focus goes back to its button before the item's own press runs, so a view it opens returns focus there
70
91
  menu.addEventListener('click', (e) => {
71
92
  const th = e.target.closest('[data-th]');
72
93
  if (th) { const v = th.dataset.th; theme(v === 'auto' ? null : v); store.set(THEME_KEY, v === 'auto' ? '' : v); tbTheme(); return; }
@@ -77,10 +98,10 @@ function tbMount() {
77
98
  menu.addEventListener('keydown', (e) => {
78
99
  if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(true); return; }
79
100
  if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
80
- const L = items(), i = L.indexOf(document.activeElement); if (!L.length) return;
101
+ const L = live(), i = L.indexOf(document.activeElement); if (!L.length) return;
81
102
  e.preventDefault(); L[(i + (e.key === 'ArrowDown' ? 1 : L.length - 1) + (i < 0 ? 1 : 0)) % L.length].focus();
82
103
  });
83
- $('#srcChip').onclick = () => openSources(); $('#srcItem').onclick = () => openSources();
104
+ items.forEach(([id, label, icon]) => { $('#' + id).onclick = () => czPlaceholderView(label, { icon }); });
84
105
  tbReadSrc();
85
106
  setInterval(() => { if (!document.hidden) tbReadSrc(); }, 300000);
86
107
  }
@@ -88,9 +109,8 @@ function tbTheme() {
88
109
  const cur = document.documentElement.dataset.theme || 'auto';
89
110
  $$('#tbTheme [data-th]').forEach((b) => b.setAttribute('aria-checked', String(b.dataset.th === cur)));
90
111
  }
91
- let ABOUT = null;
92
- /** The page the rail's Chat brings along (premium-chat-page): the conversation key of this page and its name. The Chat page opens that conversation. */
93
- export function chatAbout(key, label) { ABOUT = key ? { key, label: label || '' } : null; }
112
+ /** The page's own conversation (premium-chat-page). The rail's Chat that carried it is gone; the pages still name it, and nothing reads it now. */
113
+ export function chatAbout(key, label) { return key ? { key, label: label || '' } : null; }
94
114
  /** On the Chat page the dialog is the page: it never closes, Escape does nothing, and the rail stays live. */
95
115
  const chatPage = () => document.body.classList.contains('chatpg');
96
116
 
@@ -255,16 +275,17 @@ export function openChatPage(key, label) {
255
275
  ? 'Talk to Claude about ' + label + '. It works in a real Claude Code session: it can read, change files, run commands and take slash commands.'
256
276
  : 'Talk to Claude. It works in a real Claude Code session: it can read, change files, run commands and take slash commands. Pick another session from the list.';
257
277
  openDlg({ eye: label ? 'Chat · ' + label : 'Chat', title: label ? 'Ask about ' + label : 'Chat', say, stream: turnA(ptx(say)), noteKey: key, pane: `<article class="paper doc"><p class="note">${esc(label ? 'This conversation is about ' + label + '. Files Claude opens show here.' : 'Files Claude opens show here.')}</p></article>`, paneEmpty: true, label: label || 'Chat', sessions: true });
258
- $$('.rail').forEach((x) => { x.inert = false; }); document.documentElement.style.overflow = '';
259
- $('#veil').classList.remove('on');
278
+ if (chatPage()) { // the held-open chat (desktop Home) leaves the page live; on a phone Home's chat is a popup and keeps openDlg's veil and inert page
279
+ document.documentElement.style.overflow = '';
280
+ $('#veil').classList.remove('on');
281
+ }
260
282
  $('#askIn').placeholder = label ? 'Message Claude about ' + label : 'Message Claude, or type /';
261
283
  if (desk()) setFull(true); else setTab('chat');
262
284
  vwShutPane(); // premium-chat-viewer V1: the conversation has the room until something opens in the viewer
263
285
  loadThread(key);
264
286
  }
265
- tbMount(); // the top bar first: the menu holds the Settings, Sessions, Console and Search items the code below wires
266
- { const t2 = $('#theme2'); if (t2) t2.onclick = flip; }
267
- { const b = $('#settingsBtn'); if (b) b.onclick = () => openSettings(); } // hoisted: the function below is declared, not assigned
287
+ tbMount(); // the top bar first: the menu holds the Settings item the code below reads
288
+ { const b = $('#settingsBtn'); if (b) b.onclick = () => czPlaceholderView('Settings', { icon: 'gear' }); } // Settings has no design yet (premium-agreed-design)
268
289
 
269
290
  /* ── toast ──────────────────────────────────────────────────────────────────────────────────────────────── */
270
291
  let tt = null;
@@ -311,7 +332,7 @@ export function openDlg(o) {
311
332
  if (S.ctx) markSeen(S.key, S.ctx);
312
333
  park(); // a page's own control lent to the dialog (the Briefing's product picker) goes home before the pane is replaced
313
334
  const ae = document.activeElement; if (ae && ae !== document.body) lastFocus = ae;
314
- $$('.rail,main.stage,#dock').forEach((x) => { x.inert = true; });
335
+ $$('main.stage').forEach((x) => { x.inert = true; });
315
336
  $('#dlg').inert = false; document.documentElement.style.overflow = 'hidden';
316
337
  $('#dEye').textContent = o.eye; $('#dTitle').textContent = o.title; $('#dSub').textContent = o.sub || ''; $('#dSub').hidden = !o.sub;
317
338
  $('#oMain').innerHTML = o.pane || `<article class="paper doc">${o.html}</article>`; $('#oLab').textContent = o.label || 'Detail';
@@ -327,8 +348,17 @@ export function openDlg(o) {
327
348
  $('#veil').classList.add('on'); $('#dlg').classList.add('on');
328
349
  $$('#dGrid .pane').forEach((p) => { p.scrollTop = 0; });
329
350
  railOnOpen(o);
351
+ if (homeDock()) dockOpen(o);
330
352
  setTimeout(() => $('#dlg').focus(), 60);
331
353
  }
354
+ /* Home on a desktop: the dialog is the docked chat. The list stays live beside it, nothing is veiled, and the Viewer shows when the row has a
355
+ * detail to show; a placeholder note leaves it folded, and the icon at the chat's top right opens it again. */
356
+ function dockOpen(o) {
357
+ $('#dlg').setAttribute('aria-modal', 'false'); // docked, the list beside it stays live: a modal flag would hide the list from a screen reader
358
+ $('#veil').classList.remove('on'); $$('main.stage').forEach((x) => { x.inert = false; }); document.documentElement.style.overflow = '';
359
+ setFull(true);
360
+ if (o.paneEmpty || o.sessions) vwShutPane(); else vwOpenPane(true);
361
+ }
332
362
  /* The compact head clamps a long title; a press on it shows the whole title and sub line, a second press clamps them again. */
333
363
  $('#dTitle').addEventListener('click', () => { const g = $('#dlg'); if (g.classList.contains('cmp') && innerWidth < 1000) g.classList.toggle('tfull'); });
334
364
  /* A compact dialog on a phone: once the detail scrolls, the head keeps only the title and the tools, so the detail gets the screen.
@@ -349,12 +379,17 @@ export function setFocus(f) {
349
379
  }
350
380
  $('#dFocus').onclick = () => setFocus(!$('#dlg').classList.contains('focus'));
351
381
  export function closeDlg() {
382
+ if (homeDock()) { // Home: closing a row's conversation goes back to your own chat, and the focus goes back to the row that opened it
383
+ const back = lastFocus;
384
+ openChatPage('chat:main', '');
385
+ if (back && back.isConnected && !$('#dlg').contains(back)) setTimeout(() => { try { back.focus(); } catch { /* gone */ } }, 80); // after openDlg's own focus at 60 ms
386
+ return;
387
+ }
352
388
  if (chatPage()) return;
353
389
  clearTimeout(threadTimer); S.key = null; syncTerm(null); flushNotes(); railOnClose();
354
390
  park();
355
- $('#veil').classList.remove('on'); $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; });
391
+ $('#veil').classList.remove('on'); $$('main.stage').forEach((x) => { x.inert = false; });
356
392
  $('#dlg').inert = true; document.documentElement.style.overflow = ''; $('#dlg').classList.remove('on');
357
- $('#dock').inert = !document.body.classList.contains('docked');
358
393
  if (lastFocus) { try { lastFocus.focus(); } catch { /* gone */ } }
359
394
  }
360
395
  export function pillOf(s) { const o = $('button[aria-pressed="true"]', s), p = $('.pill', s); requestAnimationFrame(() => { if (!o || !p) return; p.style.left = o.offsetLeft + 'px'; p.style.width = o.offsetWidth + 'px'; }); }
@@ -380,6 +415,7 @@ function syncTerm(t = null) {
380
415
  }
381
416
  $('#dTerm').onclick = async () => {
382
417
  const t = S.term; if (!t) return;
418
+ if (t.term) { import('./term-view.js').then((M) => M.openTermView(t.term, { title: ($('#dTitle') || {}).textContent || t.term })); return; }
383
419
  if (t.href) { window.open(t.href, '_blank', 'noopener'); return; }
384
420
  try { await navigator.clipboard.writeText(t.copy); toast('Copied. Paste it in Terminal on the computer PMOS runs on.'); }
385
421
  catch { toast('Copy did not work here. The command: ' + t.copy); }
@@ -392,12 +428,15 @@ $('#dTabs').addEventListener('click', (e) => { const b = e.target.closest('[data
392
428
  addEventListener('keydown', (e) => {
393
429
  if (e.key !== 'Escape' || !$('#dlg').classList.contains('on')) return;
394
430
  if (chatPage() && $('#dlg').classList.contains('vw-layer') && !document.querySelector('[data-esc-layer]')) { vwBack(); return; }
395
- if (document.querySelector('[data-esc-layer]') || chatPage()) return; // a layer open over the dialog (a viewer menu, Present) closes itself first
431
+ if (document.querySelector('[data-esc-layer]')) return; // a layer open over the dialog (a viewer menu, Present) closes itself first
432
+ if (homeDock()) { if (S.key !== 'chat:main') closeDlg(); return; } // Home: Escape takes a row's chat back to your own chat, which stays open
433
+ if (chatPage()) return;
396
434
  if ($('#dlg').classList.contains('full')) { setFull(false); e.stopImmediatePropagation(); return; }
397
435
  closeDlg();
398
436
  }, true);
399
437
  (() => {
400
438
  const g = $('#dlg .grab'); let y0 = null, dy = 0;
439
+ if (!g) return; // a page with no dialog (the DETACHED stub has no grab handle)
401
440
  g.addEventListener('pointerdown', (e) => { y0 = e.clientY; dy = 0; try { g.setPointerCapture(e.pointerId); } catch { /* none */ } });
402
441
  g.addEventListener('pointermove', (e) => { if (y0 == null) return; dy = Math.max(0, e.clientY - y0); $('#dlg').style.transition = 'none'; $('#dlg').style.transform = `translateY(${dy}px)`; });
403
442
  const end = () => { if (y0 == null) return; const d = dy; y0 = null; dy = 0; $('#dlg').style.transition = ''; $('#dlg').style.transform = ''; if (d > 90) closeDlg(); };
@@ -549,7 +588,7 @@ function ctxPeek(it) {
549
588
  const f = $('#askF'); if (!f) return;
550
589
  if (!b) { f.insertAdjacentHTML('beforebegin', '<button type="button" class="ctxpeek" id="ctxPeek" hidden></button>'); b = $('#ctxPeek'); }
551
590
  b.innerHTML = `<span>${esc(it.sub)} · <b>${esc(it.title)}</b></span><em>View</em>`; b.hidden = false;
552
- b.onclick = () => { ctxPeek(null); if (it.kind === 'goal') openGoal(); else if (it.kind === 'report') openBlockTab(it.block); else openCtx(it, ctxWhere()); };
591
+ b.onclick = () => { ctxPeek(null); if (it.kind === 'goal') openGoal(); else if (it.kind === 'report') openBlockTab(it.block); else openCtx(it, ctxWhere()); if (!desk()) setTab('out'); }; // View shows it: a phone popup (Home's chat) brings its Detail tab forward
553
592
  CTX.peekTimer = setTimeout(() => ctxPeek(null), 15000);
554
593
  }
555
594
  $('#dBody').addEventListener('click', (e) => {
@@ -742,17 +781,13 @@ $('#dBody').addEventListener('submit', async (e) => {
742
781
  if (await sendText(key, text, files)) { inp.value = ''; inp.placeholder = 'Message Claude, or type /'; clearAttach(); drawSlash(); growAsk(); }
743
782
  });
744
783
 
745
- /* ── the hero folds into the dock on scroll ─────────────────────────────────────────────────────────────── */
784
+ /* ── on scroll: a card's head sticks while its card is on screen. The old hero no longer folds into a dock (premium-agreed-design). ── */
746
785
  let tick = false;
747
786
  export function onScroll() {
748
787
  if (tick) return; tick = true;
749
788
  requestAnimationFrame(() => {
750
789
  tick = false;
751
- const y = scrollY, h = $('.hero').offsetHeight, p = Math.max(0, Math.min(1, y / (h * 0.55))), big = $('.brief');
752
- if (!RM) { big.style.transform = `translateY(${-p * 30}px) scale(${1 - p * 0.12})`; big.style.opacity = 1 - p * 0.9; }
753
- document.body.classList.toggle('docked', p > 0.62);
754
- if (!$('#dlg').classList.contains('on')) $('#dock').inert = p <= 0.62;
755
- $$('.ch').forEach((c) => c.classList.toggle('stuck', c.getBoundingClientRect().top <= 61 && c.closest('.card').getBoundingClientRect().bottom > 140));
790
+ $$('.ch').forEach((c) => { const k = c.closest('.card, .cz-grp'); if (k) c.classList.toggle('stuck', c.getBoundingClientRect().top <= 61 && k.getBoundingClientRect().bottom > 140); });
756
791
  });
757
792
  }
758
793
  addEventListener('scroll', onScroll, { passive: true }); addEventListener('resize', onScroll);
@@ -773,64 +808,11 @@ if (window.visualViewport) {
773
808
  visualViewport.addEventListener('resize', () => { const shut = visualViewport.height >= innerHeight - 1; if (kb && shut) settleFixed(); kb = !shut; });
774
809
  }
775
810
 
776
- /* ── the rail: Briefing, My work, Board and Insights are premium pages ── */
777
- const GO = { brief: '/premium.html', work: '/premium-work.html', chat: '/premium-chat.html', init: '/premium-board.html', rep: '/premium-insights.html' };
778
- /* ── the recording chip: while a note records or is paused, every premium page says so and can stop it (initiative briefing-premium-calendar, slice 3) ───────────────
779
- * It reads GET /api/notes. Only the Briefing holds a recorder; the other pages show what the server holds, and Stop there ends the meeting through POST /api/notes/stop. */
780
- function mountRecChip(here) {
781
- const c = document.createElement('div'); c.className = 'recchip glass'; c.id = 'recChip'; c.hidden = true; c.setAttribute('role', 'status'); document.body.appendChild(c);
782
- let rows = [], ask = false, msg = '';
783
- const holding = () => (window.__premiumHolding && window.__premiumHolding.id) || null;
784
- const draw = () => {
785
- const v = recChipView(rows, { holdingId: holding(), here });
786
- if (!v) { c.hidden = true; c.innerHTML = ''; ask = false; return; }
787
- c.hidden = false; c.dataset.mode = v.mode;
788
- if (ask) { c.innerHTML = `<span>Stop “${esc(v.title)}” for good? ${esc(STOP_LINE)}</span><button data-r="no">Cancel</button>${v.held ? '<button data-r="pause">Pause instead</button>' : ''}<button data-r="stopgo">Stop for good</button>`; return; }
789
- const L = { hl: 'Highlight', pause: 'Pause', fv: 'Focus', open: 'Open', resume: 'Resume', stop: 'Stop' }; // the presses premium-vw-rec.js gives this page
790
- c.innerHTML = `<i${v.mode === 'paused' ? ' class="paused"' : ''}></i><span>${esc(msg || v.text)}</span>${chipActs(v, here).map((a) => `<button data-r="${a}"${a === 'hl' ? ` title="${esc(HL_LINE)}"` : ''}>${L[a]}</button>`).join('')}`;
791
- };
792
- const read = async () => { const r = await pmGet('/api/notes'); if (r && r.ok === true && Array.isArray(r.notes)) rows = r.notes; draw(); };
793
- c.addEventListener('click', async (e) => {
794
- const b = e.target.closest('button'); if (!b) return;
795
- const v = recChipView(rows, { holdingId: holding(), here }); if (!v) return;
796
- const act = b.dataset.r; msg = '';
797
- const d = { openDlg, toast, pmGet, pmPost };
798
- if (act === 'open') { if (here === 'brief' && window.__premiumRec) openLive(v.id, d); else location.assign('/premium.html?meeting=' + encodeURIComponent(v.id)); return; }
799
- if (act === 'fv') { openFocus(v.id, d); return; }
800
- if (act === 'stop') { ask = true; draw(); const g = c.querySelector('[data-r="no"]'); if (g) g.focus(); return; }
801
- if (act === 'no') { ask = false; draw(); return; }
802
- b.disabled = true;
803
- if (act === 'hl') { const r = window.__premiumRec ? await window.__premiumRec.highlight() : { ok: false }; msg = r.ok ? 'Highlighting the last 30 seconds and the next ones.' : (r.error || 'The highlight was not started.'); draw(); setTimeout(() => { msg = ''; draw(); }, 6000); return; }
804
- if (act === 'pause') { ask = false; const r = window.__premiumRec ? await window.__premiumRec.pause() : { ok: false }; msg = r.ok ? '' : (r.error || 'It was not paused.'); }
805
- else if (act === 'resume') { const r = window.__premiumRec ? await window.__premiumRec.resume(v.id) : { ok: false }; msg = r.ok ? '' : (r.error || 'It was not resumed.'); }
806
- else if (act === 'stopgo') {
807
- ask = false;
808
- const r = window.__premiumRec ? await window.__premiumRec.stop(v.id) : await pmPost('/api/notes/stop', { id: v.id });
809
- if (r && r.ok === true) toast('Stopped for good. The final notes are written now.'); else msg = (r && r.error) || 'The meeting was not stopped.';
810
- }
811
- await read();
812
- });
813
- addEventListener('premium-rec', read);
814
- read(); setInterval(read, 20000);
815
- mountRecord(here, { openDlg, toast, pmGet, pmPost });
816
- }
817
- export function wireRail(here) {
818
- mountRecChip(here);
819
- const rail = $('.rail');
820
- // premium-chat-rail: five places with Chat in the middle. The phone bar slides by whole places (--pi); the desktop rail's Chat is taller, so
821
- // the indicator there is placed at the current place's own top (--py).
822
- const cur = $(`.rail [data-go="${here}"]`), all = $$('.rail .pl');
823
- rail.style.setProperty('--pi', String(all.indexOf(cur)));
824
- const place = () => { if (cur) rail.style.setProperty('--py', (cur.offsetTop - all[0].offsetTop) + 'px'); };
825
- place(); addEventListener('resize', place);
826
- $$('.rail [data-go]').forEach((b) => { b.onclick = () => { if (b.dataset.go !== here) location.assign(b.dataset.go === 'chat' ? chatHref() : GO[b.dataset.go]); }; });
827
- }
828
- /** The Chat page's address: the workspace the PM is in, and the page they came from as the conversation it opens (premium-chat-page). */
829
- function chatHref() {
830
- const q = new URLSearchParams(), ws = new URLSearchParams(location.search).get('ws');
831
- if (ws) q.set('ws', ws);
832
- if (ABOUT) { q.set('about', ABOUT.key); if (ABOUT.label) q.set('label', ABOUT.label); }
833
- const s = q.toString(); return GO.chat + (s ? '?' + s : '');
811
+ /* ── a page's start (premium-agreed-design): the old rail, the floating record chip (#recChip) and the round mic (#recCtl) are gone; the place
812
+ * menu (cozy-nav.js) moves between places, and recording shows in the Viewer's recording bar and Home's meeting line. Recording starts from
813
+ * the Viewer (window.czViews.newNote, or a meeting's Record), so a page start draws no recorder; an old page's mic is taken out. ── */
814
+ export function wireRail() {
815
+ const mic = document.getElementById('recCtl'); if (mic) mic.remove();
834
816
  }
835
817
 
836
818
  /* ── the crumb: where you are and a menu to switch board or initiative. Its Chat moved to the rail (premium-chat-rail) ──────────── */
@@ -900,12 +882,12 @@ export function openAddDoc(o) {
900
882
  };
901
883
  }
902
884
 
903
- /* ── Search (Ctrl K or "/") and the bell, in the header of every premium page (initiative premium-search-bell). Reads only; a press goes to a page. ── */
885
+ /* ── Search (Ctrl K or "/") and the agent inbox (initiative premium-search-bell). Reads only; a press goes to a page.
886
+ * The Agreed design draws no bell, so none is drawn: the inbox is still read (its count, its toast and the panel premium.js opens). ── */
904
887
  const SRCH = '<svg class="i" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg>';
905
- const BELL = '<svg class="i" viewBox="0 0 24 24"><path d="M6 16V11a6 6 0 0 1 12 0v5l2 2H4z"/><path d="M10 20a2 2 0 0 0 4 0"/></svg>';
906
888
  const IC = (d) => `<svg class="i" viewBox="0 0 24 24"><path d="${d}"/></svg>`;
907
889
  const GL = { place: IC('M4 5h16v14H4zM4 10h16'), ini: IC('M12 3l9 9-9 9-9-9z'), doc: IC('M6 3h9l4 4v14H6zM14 3v5h5'), ses: IC('M5 4l14 8-14 8z'), need: IC('M12 4v10M12 18v2') };
908
- const PLACES = [['Briefing', '/premium.html'], ['My work', '/premium-work.html'], ['Board', '/premium-board.html'], ['Insights', '/premium-insights.html']];
890
+ const PLACES = [['Home', '/premium.html'], ['Board', '/premium-board.html'], ['Insights', '/premium-insights.html']];
909
891
  const PV_WS = new URLSearchParams(location.search).get('ws');
910
892
  const pvQ = (sep) => (PV_WS ? sep + 'ws=' + encodeURIComponent(PV_WS) : '');
911
893
  async function pvGet(u) { try { const r = await fetch(u, { credentials: 'same-origin' }); return { status: r.status, j: await r.json() }; } catch { return { status: 0, j: null }; } }
@@ -914,10 +896,9 @@ const pvOv = { kind: null, back: null, at: 0, list: [], pal: null, need: null };
914
896
  * first read never toasts), shown the new ids the open panel shows (closing the panel marks them seen), toastAt the last toast (at most one per 15 min). */
915
897
  const IB = { r: null, ids: null, shown: [], toastAt: 0 };
916
898
  function pvMount() {
917
- const a = $('#tbMore'); if (!a || $('#pvBell')) return;
918
- a.insertAdjacentHTML('beforebegin', `<button class="glass round pv-hp" id="pvBell" aria-haspopup="dialog" aria-label="Needs you" title="Needs you">${BELL}<span class="pv-bdg" id="pvBdg" hidden></span></button>`);
899
+ if (!$('#tbMore') || $('#pvOv')) return;
919
900
  document.body.insertAdjacentHTML('beforeend', '<div class="pv-scrim" id="pvScrim"></div><div class="pv-ov" id="pvOv" role="dialog" aria-modal="true" hidden inert></div>');
920
- $('#pvSearch').onclick = () => pvOpen('pal'); $('#pvBell').onclick = () => pvOpen('bell'); $('#pvScrim').onclick = pvClose;
901
+ $('#pvScrim').onclick = pvClose;
921
902
  pvNeeds(); ibRead();
922
903
  setInterval(() => { if (!document.hidden) ibRead(); }, 60000);
923
904
  document.addEventListener('visibilitychange', () => { if (!document.hidden) ibRead(); });
@@ -926,21 +907,24 @@ export function pvClose() {
926
907
  if (!pvOv.kind) return;
927
908
  if (pvOv.kind === 'bell' && IB.shown.length) { const ids = IB.shown.slice(0, 100); IB.shown = []; pmPost('/api/inbox/seen', { ids }).then(ibRead); } // seen is not done: they move to Still waiting
928
909
  pvOv.kind = null; $('#pvOv').hidden = true; $('#pvOv').inert = true; $('#pvScrim').classList.remove('on');
929
- $$('.rail,main.stage,#dock').forEach((x) => { x.inert = false; }); $('#dock').inert = !document.body.classList.contains('docked'); document.documentElement.style.overflow = '';
910
+ $$('main.stage').forEach((x) => { x.inert = false; }); document.documentElement.style.overflow = '';
911
+ if (homeDock()) $('#dlg').inert = false;
930
912
  if (pvOv.back) { try { pvOv.back.focus(); } catch { /* gone */ } }
931
913
  }
932
914
  export const pvOpenBell = () => pvOpen('bell');
933
915
  function pvOpen(kind) {
934
916
  if (pvOv.kind === kind) { pvClose(); return; }
935
917
  if (pvOv.kind) pvClose();
936
- const ae = document.activeElement; pvOv.back = ae && ae !== document.body ? ae : $(kind === 'pal' ? '#moreBtn' : '#pvBell');
918
+ const ae = document.activeElement; pvOv.back = ae && ae !== document.body ? ae : $('#moreBtn');
937
919
  pvOv.kind = kind; pvOv.at = 0;
938
- $$('.rail,main.stage,#dock').forEach((x) => { x.inert = true; }); document.documentElement.style.overflow = 'hidden';
920
+ $$('main.stage').forEach((x) => { x.inert = true; }); document.documentElement.style.overflow = 'hidden';
921
+ if (homeDock()) $('#dlg').inert = true;
939
922
  const o = $('#pvOv'); o.className = 'pv-ov ' + kind; o.setAttribute('aria-label', kind === 'pal' ? 'Search' : 'Needs you'); o.hidden = false; o.inert = false; $('#pvScrim').classList.add('on');
940
923
  if (kind === 'pal') { o.innerHTML = '<div class="pv-pin">' + SRCH + '<input id="pvQ" type="text" placeholder="Search places, initiatives, documents and sessions" aria-label="Search" autocomplete="off" role="combobox" aria-expanded="true" aria-controls="pvList"><kbd>Esc</kbd></div><div id="pvList" role="listbox" aria-label="Results"></div><p class="pv-note">Ctrl K or / opens this from any page. Arrow keys move, Enter opens.</p>'; $('#pvQ').focus(); pvPal(); }
941
924
  else { o.innerHTML = '<div class="pv-hd"><h2>Needs you</h2><small id="pvN"></small><button type="button" class="ib-all" id="ibAll" hidden>Mark all seen</button></div><div id="pvList" class="pv-lst"></div>'; pvBellDraw(); pvNeeds(); ibRead(); }
942
925
  }
943
- const pvGo = (it) => { pvClose(); if (it.go) location.assign(it.go); };
926
+ /* A session opens in Home's chat: in place on Home, or Home opens on it (?session=<id>, read at the end of this file). Never the console. */
927
+ const pvGo = (it) => { pvClose(); if (it.sid && pvOnBriefing()) { openSessionAt(it.sid); return; } if (it.go) location.assign(it.go); };
944
928
  const pvRow = (it, i, sel) => `<button type="button" class="pv-row" role="option" id="pvo${i}" data-i="${i}" aria-selected="${sel}"><span class="gl">${GL[it.gl]}</span><span><b>${esc(it.t)}</b>${it.s ? `<small>${esc(it.s)}</small>` : ''}</span></button>`;
945
929
  async function pvPal() {
946
930
  if (!pvOv.pal) {
@@ -948,7 +932,7 @@ async function pvPal() {
948
932
  const miss = [];
949
933
  const ini = b.j && b.j.ok && Array.isArray(b.j.rows) ? b.j.rows.map((r) => ({ g: 'Initiatives', gl: 'ini', t: r.title || r.id, s: [r.lane, r.stage].filter(Boolean).join(' · '), go: '/premium-initiative.html?id=' + encodeURIComponent(r.id) + (b.j.ws ? '&ws=' + encodeURIComponent(b.j.ws) + '&board=' + encodeURIComponent(b.j.board) : '') })) : (miss.push('initiatives'), []);
950
934
  const docs = d.j && d.j.ok && Array.isArray(d.j.docs) ? d.j.docs.map((x) => ({ g: 'Documents', gl: 'doc', t: x.title || x.key, s: d.j.scope && d.j.scope.name ? d.j.scope.name : 'Board', go: '/premium-board.html' + pvQ('?') })) : (miss.push('documents'), []);
951
- const ses = s.j && Array.isArray(s.j.sessions) ? s.j.sessions.filter((x) => !x.automatic).map((x) => ({ g: 'Sessions', gl: 'ses', t: x.name || x.id, s: [x.cwd && x.cwd !== '.' ? x.cwd : '', x.state].filter(Boolean).join(' · '), go: '/console.html' })) : (miss.push('sessions'), []);
935
+ const ses = s.j && Array.isArray(s.j.sessions) ? s.j.sessions.filter((x) => !x.automatic).map((x) => ({ g: 'Sessions', gl: 'ses', t: x.name || x.id, s: [x.cwd && x.cwd !== '.' ? x.cwd : '', x.state].filter(Boolean).join(' · '), sid: x.id, go: '/premium.html?' + ['session=' + encodeURIComponent(x.id), PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&') })) : (miss.push('sessions'), []);
952
936
  pvOv.pal = { items: [...PLACES.map(([t, go]) => ({ g: 'Places', gl: 'place', t, s: 'Place', go })), ...ini, ...docs, ...ses], miss };
953
937
  }
954
938
  if (pvOv.kind === 'pal') pvPalDraw();
@@ -978,7 +962,7 @@ const IB_GL = { 'work-draft': IC('M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM1
978
962
  const ibAgo = (ms) => { if (ms == null) return ''; const m = Math.round((Date.now() - ms) / 60000); return m < 1 ? 'just now' : m < 60 ? m + ' min ago' : m < 1440 ? Math.round(m / 60) + ' h ago' : Math.round(m / 1440) + (Math.round(m / 1440) === 1 ? ' day ago' : ' days ago'); };
979
963
  const ibOld = (ms) => { if (ms == null) return ''; const d = Math.floor((Date.now() - ms) / 86400000); return d < 1 ? 'oldest is from today' : 'oldest is ' + d + (d === 1 ? ' day old' : ' days old'); };
980
964
  /** The deep link of an inbox item or bundle: the Briefing opens it (premium.js openParam); a My work item (item:<id>) opens its dialog on My work. */
981
- export const ibHref = (open, pws) => /^item:/.test(open) ? '/premium-work.html?' + ['item=' + encodeURIComponent(open.slice(5)), PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&') : '/premium.html?' + ['open=' + encodeURIComponent(open), pws ? 'pws=' + encodeURIComponent(pws) : '', PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&');
965
+ export const ibHref = (open, pws) => /^item:/.test(open) ? '/premium.html?' + ['item=' + encodeURIComponent(open.slice(5)), PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&') : '/premium.html?' + ['open=' + encodeURIComponent(open), pws ? 'pws=' + encodeURIComponent(pws) : '', PV_WS ? 'ws=' + encodeURIComponent(PV_WS) : ''].filter(Boolean).join('&');
982
966
  /** The last inbox answer, for the Briefing's count line: { count, newCount, oldest } or null. */
983
967
  export const ibState = () => IB.r;
984
968
  async function ibRead() {
@@ -1044,8 +1028,9 @@ addEventListener('keydown', (e) => {
1044
1028
  else if ((e.ctrlKey || e.metaKey) && (e.key === 'k' || e.key === 'K')) { e.preventDefault(); pvClose(); }
1045
1029
  return;
1046
1030
  }
1047
- if ($('#dlg').classList.contains('on') || !$('#pvSearch')) return;
1031
+ if (!$('#pvOv') || ($('#dlg').classList.contains('on') && !homeDock())) return; // Home's docked chat is always open: Ctrl K still searches
1048
1032
  if ((e.ctrlKey || e.metaKey) && !e.altKey && (e.key === 'k' || e.key === 'K')) { e.preventDefault(); pvOpen('pal'); return; }
1033
+ if ($('#dlg').classList.contains('on')) return;
1049
1034
  const t = document.activeElement;
1050
1035
  if (e.key === '/' && !e.ctrlKey && !e.metaKey && !e.altKey && !(t && t.matches && t.matches('input,textarea,select,[contenteditable="true"]'))) { e.preventDefault(); pvOpen('pal'); }
1051
1036
  }, true);
@@ -1178,7 +1163,7 @@ export async function openSettings() {
1178
1163
  <div class="two" style="margin-top:10px"><label><input id="stP" maxlength="500" placeholder="Folder path of a repository" aria-label="Folder path of a repository"></label><button type="button" class="cta" id="stAdd">Add repository</button></div></div>
1179
1164
  <div><span class="label">Connectors</span><p class="note" style="margin:0 0 8px">Every connector your Claude session has. Your sessions can use all of them; a switch chooses only what PMOS reads on its own, such as the sources of the Briefing. PMOS keeps no passwords or keys.</p>${srcRows}${connRows}</div>
1180
1165
  <p class="note" id="stM" role="status" style="margin:0;min-height:1.2em">${esc(M.err)}</p>
1181
- <p class="note" style="margin:0">Everything else runs on a default. <a href="/console.html?tab=settings">More settings in the console</a>.</p></div></article>`;
1166
+ <p class="note" style="margin:0">Everything else runs on a default.</p></div></article>`;
1182
1167
  };
1183
1168
  openDlg({ eye: 'Settings · real data', title: 'Settings', say: 'Updates and what each kit changed, then two choices: which repositories PMOS works in, and which sources the Briefing reads.', stream: turnA(ptx('Updates and what each published kit changed, copied from its merged pull requests. Then two choices: which repositories PMOS works in, and which sources the Briefing reads. Each press saves that one record and changes nothing else.')), noteKey: popKey('settings'), pane: '<article class="paper doc"></article>', label: 'Settings' });
1184
1169
  setMode('detail'); draw();
@@ -1258,6 +1243,7 @@ const railShowing = () => $('#dlg').classList.contains('on') && $('#dlg').classL
1258
1243
  function railMount() {
1259
1244
  const g = $('#dGrid'); if (!g || $('#sRail')) return;
1260
1245
  g.insertAdjacentHTML('afterbegin', `<aside class="srl" id="sRail" aria-label="Sessions"><div class="srl-hd"><b>Sessions</b><button type="button" class="srl-fold" id="srlFold" aria-label="Fold the list" title="Fold the list"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M9 4v16"/></svg></button></div><div class="srl-list" id="srlList"></div><div class="srl-lg" aria-hidden="true"><span><i class="sdot2 ready"></i>Ready</span><span><i class="sdot2 run"></i>Running</span><span><i class="sdot2 blk"></i>Maybe blocked</span></div></aside>`);
1246
+ { const home = homeDock() && $('#hSessions'); if (home) home.appendChild($('#sRail')); } // Home: the session list is a group of the list on the left
1261
1247
  $('#dlg .dtools').insertAdjacentHTML('afterbegin', '<button type="button" class="stease" id="sTease" aria-haspopup="true" hidden><i class="sdot2" aria-hidden="true"></i><span>Sessions</span><em></em></button>');
1262
1248
  const ot = $('#dOut .otop'); if (ot) ot.insertAdjacentHTML('afterbegin', '<button type="button" class="vfold" id="vFold" aria-label="Fold the viewer" title="Fold the viewer"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M15 4v16"/></svg></button>');
1263
1249
  $('#srlFold').onclick = () => { if (R.autoMin) { R.autoMin = false; railLayout(); return; } R.railMin = !R.railMin; store.set('pmos.srl.rail', R.railMin ? 'min' : 'open'); railLayout(); }; // a list the viewer folded opens again; the PM's own fold is remembered
@@ -1358,8 +1344,10 @@ function railDraw() {
1358
1344
  t.hidden = !tz || !t.dataset.on || $('#dlg').classList.contains('full');
1359
1345
  if (tz) { $('i', t).className = 'sdot2 ' + tz.dot; $('em', t).textContent = tz.text; t.setAttribute('aria-label', 'Sessions, ' + tz.text + '. Switch between sessions'); t.title = 'Switch between sessions'; t.setAttribute('aria-expanded', String($('#dlg').classList.contains('srl-open'))); }
1360
1346
  }
1361
- sessBadge(menuCount(R.rows));
1347
+ document.dispatchEvent(new CustomEvent('pmos:sessions', { detail: m })); // Home's list counts them and finds an initiative's own sessions
1362
1348
  }
1349
+ /** Home: open one session from the list's own rows (an initiative's sessions). */
1350
+ export function openSessionRow(id) { if (R.model && R.model.rows.some((x) => x.id === id)) pickSession(id); }
1363
1351
  async function railRead() {
1364
1352
  const [s, g] = await Promise.all([pmGet('/api/sessions').catch(() => null), pmGet('/api/briefing-premium/goals').catch(() => null)]);
1365
1353
  if (s && Array.isArray(s.sessions)) R.rows = s.sessions;
@@ -1373,7 +1361,7 @@ function railOnOpen(o) {
1373
1361
  railMount(); clearTimeout(R.sidTimer); S.sid = null; R.ask = null; R.slow = null; R.err = '';
1374
1362
  $('#dlg').classList.remove('srl-open');
1375
1363
  const t = $('#sTease'); if (t) { if (o.noteKey || o.sessions) t.dataset.on = '1'; else delete t.dataset.on; }
1376
- $('#dlg').classList.toggle('srl-on', !!(o.noteKey || o.sessions)); // only a dialog with a conversation gets the list
1364
+ $('#dlg').classList.toggle('srl-on', !!(o.noteKey || o.sessions) || homeDock()); // only a dialog with a conversation gets the list
1377
1365
  R.sel = o.noteKey ? ((R.rows.find((x) => x.origin === 'chat:' + o.noteKey && x.shown !== 'exited') || {}).id || null) : null;
1378
1366
  railLayout(); railDraw(); railRead().then(() => { if (o.noteKey && !R.sel) { R.sel = (R.rows.find((x) => x.origin === 'chat:' + o.noteKey && x.shown !== 'exited') || {}).id || null; railDraw(); } });
1379
1367
  railTick();
@@ -1423,7 +1411,7 @@ function cardDraw(r) {
1423
1411
  ${R.ask ? `<div class="ssc" role="group" aria-label="Confirm stop"><p><b>Stop “${esc(r.name)}”?</b> ${what} Files it already wrote stay where they are.</p><div class="ssx"><button type="button" class="cta bad" data-yes="1">Stop</button><button type="button" class="cta alt" data-no="1">Keep running</button></div></div>`
1424
1412
  : R.slow ? `<div class="ssc" role="group" aria-label="Still running"><p><b>Asked “${esc(r.name)}” to end.</b> It has not exited yet. Press Stop again to remove it.</p><div class="ssx"><button type="button" class="cta bad" data-yes="1">Stop again</button><button type="button" class="cta alt" data-no="1">Keep running</button></div></div>`
1425
1413
  : `<div class="ssx"><button type="button" class="cta alt" data-stop="1"${R.busy ? ' disabled' : ''}>${R.busy ? 'Ending…' : 'Stop'}</button></div>`}
1426
- <p class="note" role="status">${esc(R.err)}</p><p class="note">Its terminal is in the console. <a href="/console.html">Open the console</a>.</p></article>`;
1414
+ <p class="note" role="status">${esc(R.err)}</p></article>`;
1427
1415
  }
1428
1416
  $('#oMain').addEventListener('click', async (e) => {
1429
1417
  const card = e.target.closest('.scard'); if (!card || R.busy) return;
@@ -1448,18 +1436,6 @@ $('#oMain').addEventListener('click', async (e) => {
1448
1436
  cardDraw(r);
1449
1437
  }
1450
1438
  });
1451
- /* The rail's Chat carries the count the ⋯ menu's Sessions used to: a dot when a session is Ready or Maybe blocked (premium-chat-rail C5). */
1452
- function sessBadge(n) {
1453
- const a = $('.rail [data-go="chat"]'); if (!a) return;
1454
- const d = $('.cdot', a); if (d) d.hidden = !n;
1455
- a.setAttribute('aria-label', n ? 'Chat, ' + n + (n === 1 ? ' session needs you' : ' sessions need you') : 'Chat');
1456
- }
1457
- {
1458
- if ($('.rail [data-go="chat"]')) {
1459
- const poll = async () => { if (document.hidden || railShowing()) return; const s = await pmGet('/api/sessions').catch(() => null); if (s && Array.isArray(s.sessions)) { R.rows = s.sessions; sessBadge(menuCount(R.rows)); } };
1460
- poll(); setInterval(poll, BADGE_POLL);
1461
- }
1462
- }
1463
1439
  /** The session list on its own (the rail's Chat on a page with no conversation): the chat panel, full screen with the list (the list itself on a phone), on the session that needs you most. */
1464
1440
  export async function openSessions() {
1465
1441
  openDlg({ eye: 'Sessions', title: 'Sessions', say: 'Pick a session from the list.', stream: turnA(ptx('Pick a session from the list. A dot shows its state: Ready, Running or Maybe blocked.')), noteKey: null, sessions: true, pane: '<article class="paper doc"><p class="note">Pick a session from the list.</p></article>', label: 'Session' });
@@ -1470,3 +1446,10 @@ export async function openSessions() {
1470
1446
  const top = loudestRow(R.model);
1471
1447
  if (top && desk()) pickSession(top.id);
1472
1448
  }
1449
+ /** Open one session in Home's chat: the session list opens on it (a desktop docks it beside the list; a phone shows the chat). */
1450
+ async function openSessionAt(id) {
1451
+ await openSessions();
1452
+ if (R.model && R.model.rows.some((x) => x.id === id)) pickSession(id); else toast('That session is not running any more.');
1453
+ }
1454
+ /* Home opened from a search result elsewhere: ?session=<id>. It waits one turn, so Home's own chat (premium-chat.js) opens first. */
1455
+ { const sid = new URLSearchParams(location.search).get('session'); if (sid && pvOnBriefing()) setTimeout(() => openSessionAt(sid), 0); }
@@ -9,6 +9,7 @@
9
9
  * premium-chat-viewer: #oMain with data-empty="1" holds only a placeholder note, so its tab is not drawn and closing the last other tab empties
10
10
  * the viewer. vwOn(fn) hears fn('open', id), fn('show', id) and fn('empty'): the Chat page opens and closes its viewer on them. Tabs that do not
11
11
  * fit fold, oldest first, into a "+N" button that lists them; the current tab always shows. */
12
+ import { open as czOpen, current as czCurrent, close as czClose } from './cozy-viewer.js';
12
13
  const MAX = 4;
13
14
  const IC = {
14
15
  doc: 'M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h5', cal: 'M3.5 5h17v15h-17zM3.5 10h17M8 3v4M16 3v4', notes: 'M6 3h9l4 4v14H6zM14 3v5h5M9 12h7M9 16h5',
@@ -77,7 +78,25 @@ if (typeof ResizeObserver !== 'undefined') {
77
78
  setTimeout(watch, 0);
78
79
  vwOn(() => watch());
79
80
  }
80
- function pane(id) { return id === 'main' ? q('#oMain') : document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(id)}"]`); }
81
+ function pane(id) { return id === 'main' ? q('#oMain') : document.querySelector(`.obody.vw[data-vw="${CSS.escape(id)}"]`); }
82
+ /* A page with no dialog (Home in the Agreed design): a view opens in the cozy Viewer card (cozy-viewer.js) instead of a tab of #dOut, one at a time.
83
+ * The view draws into the same .obody.vw element, so its own code does not change. */
84
+ const CZ_ICON = { tk: 'jira', list: 'list', goal: 'goal', mic: 'mic', cal: 'cal', notes: 'notes', doc: 'doc' };
85
+ let czLast = null;
86
+ /** Opens again the last item the cozy Viewer showed through vwOpen (Home's "Open the Viewer" button). False when there is none. */
87
+ export function vwReopen() { if (!czLast) return false; czVw(czLast); return true; }
88
+ function czVw(it) {
89
+ let el = null; czLast = it;
90
+ czOpen({ id: 'vw:' + it.id, kind: it.kind || it.title || 'Item', title: it.name || it.title || 'Item', icon: CZ_ICON[it.icon] || 'doc', url: it.url || '',
91
+ render: (body) => {
92
+ el = document.createElement('div'); el.className = 'obody vw'; el.dataset.vw = it.id; el.setAttribute('role', 'region'); body.append(el);
93
+ if (it.render) it.render(el); else el.innerHTML = it.html || '';
94
+ if (it.wire) it.wire(el);
95
+ },
96
+ onClose: () => emit('empty') });
97
+ emit('open', it.id);
98
+ return el;
99
+ }
81
100
  export function vwShow(id) {
82
101
  if (id !== 'main' && !V.items.some((x) => x.id === id)) id = 'main';
83
102
  if (id === 'main' && !mainReal() && V.items.length) id = V.items[V.items.length - 1].id; // the placeholder is never a tab of its own
@@ -90,6 +109,7 @@ export function vwShow(id) {
90
109
  }
91
110
  export function vwOpen(it) {
92
111
  if (!it || !it.id) return null;
112
+ if (typeof document !== 'undefined' && !document.getElementById('dOut')) return czVw(it);
93
113
  const was = V.items.find((x) => x.id === it.id);
94
114
  if (was) { Object.assign(was, it); fill(was); vwShow(it.id); emit('open', it.id); return pane(it.id); }
95
115
  if (V.items.length >= MAX) vwClose(V.items[0].id, true);
@@ -105,6 +125,7 @@ function fill(rec) {
105
125
  if (rec.wire) rec.wire(el);
106
126
  }
107
127
  export function vwClose(id, quiet) {
128
+ if (typeof document !== 'undefined' && !document.getElementById('dOut')) { const c = czCurrent(); if (c && c.id === 'vw:' + id) czClose(); return; }
108
129
  const i = V.items.findIndex((x) => x.id === id); if (i < 0) return;
109
130
  V.items.splice(i, 1); const p = pane(id); if (p) p.remove();
110
131
  if (quiet) return;
@@ -146,4 +167,9 @@ export function vwConfirm(el, o) {
146
167
  el.prepend(c); const f = c.querySelector('[data-a="1"]'); if (f) f.focus();
147
168
  });
148
169
  }
170
+ /* The Agreed design (initiative premium-agreed-design): the dialog and the Viewer take the cozy look on a page whose body has class cz.
171
+ * The sheet is inert elsewhere, so it is loaded on every page that imports the viewer. */
172
+ if (typeof document !== 'undefined' && document.head && !document.querySelector('link[href="/pm/cozy-viewer.css"]')) {
173
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = '/pm/cozy-viewer.css'; document.head.append(l);
174
+ }
149
175
  if (typeof window !== 'undefined') window.__premiumViewer = { vwOpen, vwClose, vwShow, vwReset, vwState, vwStyle, vwConfirm, vwCount };