create-pmos 0.398.0 → 0.400.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 (515) hide show
  1. package/package.json +30 -25
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +19 -15
  7. package/workspace/briefing-premium-board-test.js +82 -50
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +8 -10
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +48 -43
  18. package/workspace/briefing-premium-work-test.js +16 -11
  19. package/workspace/c3-capture-test.js +0 -17
  20. package/workspace/changelog.json +29 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  23. package/workspace/guide/briefing-premium.md +2 -2
  24. package/workspace/guide/home.md +58 -19
  25. package/workspace/guide/index.md +1 -1
  26. package/workspace/guide/layout.md +2 -2
  27. package/workspace/guide/notes.md +2 -2
  28. package/workspace/guide/phone-companion.md +1 -1
  29. package/workspace/lib/board-grill.js +63 -0
  30. package/workspace/lib/board-premium.js +36 -5
  31. package/workspace/lib/initiative-layout.js +77 -0
  32. package/workspace/lib/insights-premium.js +3 -2
  33. package/workspace/lib/insights-records.js +21 -7
  34. package/workspace/lib/meeting-points.js +52 -0
  35. package/workspace/lib/news-for-you.js +88 -0
  36. package/workspace/lib/notes-series.js +29 -6
  37. package/workspace/lib/report-confirm.js +48 -0
  38. package/workspace/lib/route-modules.js +9 -9
  39. package/workspace/lib/routes-board-docs.js +46 -0
  40. package/workspace/lib/routes-board-grill.js +90 -0
  41. package/workspace/lib/routes-home-review.js +108 -0
  42. package/workspace/lib/routes-initiative-layout.js +57 -0
  43. package/workspace/lib/routes-insights-premium.js +4 -1
  44. package/workspace/lib/routes-insights-records.js +8 -4
  45. package/workspace/lib/routes-meeting-points.js +37 -0
  46. package/workspace/lib/routes-news.js +57 -0
  47. package/workspace/lib/routes-notes.js +2 -1
  48. package/workspace/lib/routes-phone-day.js +18 -9
  49. package/workspace/lib/routes-report-confirm.js +31 -0
  50. package/workspace/lib/routes-search.js +38 -0
  51. package/workspace/lib/routes-slash.js +95 -0
  52. package/workspace/lib/search-index.js +176 -0
  53. package/workspace/package-lock.json +2 -2
  54. package/workspace/package.json +1 -2
  55. package/workspace/premium-board-actions-test.js +86 -50
  56. package/workspace/premium-briefing-depth-test.js +55 -54
  57. package/workspace/premium-chat-chart-tab-test.js +4 -2
  58. package/workspace/premium-chat-goal-view-test.js +1 -1
  59. package/workspace/premium-chat-report-tab-test.js +16 -2
  60. package/workspace/premium-chat-term-test.js +0 -10
  61. package/workspace/premium-core-doc-issue-test.js +15 -13
  62. package/workspace/premium-menu-rows-test.js +1 -1
  63. package/workspace/premium-phone-card-test.js +7 -5
  64. package/workspace/premium-report-read-test.js +55 -18
  65. package/workspace/premium-vw-backlog-test.js +2 -2
  66. package/workspace/premium-vw-cal-test.js +50 -35
  67. package/workspace/premium-vw-doc-test.js +10 -11
  68. package/workspace/premium-vw-item-test.js +1 -1
  69. package/workspace/premium-vw-jira-test.js +2 -2
  70. package/workspace/premium-vw-meet-test.js +37 -40
  71. package/workspace/premium-vw-notes-test.js +21 -19
  72. package/workspace/premium-vw-rec-test.js +11 -12
  73. package/workspace/premium-welcome-test.js +3 -3
  74. package/workspace/premium-work-depth-test.js +5 -6
  75. package/workspace/public/capture.html +23 -0
  76. package/workspace/public/pm/bd-acts.js +303 -225
  77. package/workspace/public/pm/bd-asks.js +261 -0
  78. package/workspace/public/pm/bd-pop.js +59 -0
  79. package/workspace/public/pm/bd-span.js +49 -13
  80. package/workspace/public/pm/bd-views.js +169 -0
  81. package/workspace/public/pm/c3-base.js +47 -0
  82. package/workspace/public/pm/c3-capture.js +1 -1
  83. package/workspace/public/pm/c3-ini-ui.js +1 -1
  84. package/workspace/public/pm/c3-sheet.js +1 -1
  85. package/workspace/public/pm/c3-toast.js +1 -1
  86. package/workspace/public/pm/console3.css +3 -0
  87. package/workspace/public/pm/cozy-board.css +301 -0
  88. package/workspace/public/pm/cozy-ev.css +228 -0
  89. package/workspace/public/pm/cozy-evmodel.js +106 -0
  90. package/workspace/public/pm/cozy-evui.js +47 -0
  91. package/workspace/public/pm/cozy-home.css +20 -5
  92. package/workspace/public/pm/cozy-insights.css +148 -10
  93. package/workspace/public/pm/cozy-nav.js +103 -39
  94. package/workspace/public/pm/cozy-news.js +140 -0
  95. package/workspace/public/pm/cozy-search.js +203 -0
  96. package/workspace/public/pm/cozy-settings.js +198 -0
  97. package/workspace/public/pm/cozy-sources.js +89 -0
  98. package/workspace/public/pm/cozy-today.css +220 -0
  99. package/workspace/public/pm/cozy-viewer.js +5 -2
  100. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  101. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  102. package/workspace/public/pm/cozy.css +9 -0
  103. package/workspace/public/pm/goal-chat.js +5 -1
  104. package/workspace/public/pm/home-adddoc.js +5 -5
  105. package/workspace/public/pm/home-app.js +365 -70
  106. package/workspace/public/pm/home-around.js +24 -126
  107. package/workspace/public/pm/home-chat.js +77 -18
  108. package/workspace/public/pm/home-data.js +9 -7
  109. package/workspace/public/pm/home-dictate.js +57 -0
  110. package/workspace/public/pm/home-draft.js +6 -6
  111. package/workspace/public/pm/home-ini-model.js +190 -0
  112. package/workspace/public/pm/home-ini.css +171 -0
  113. package/workspace/public/pm/home-ini.js +466 -0
  114. package/workspace/public/pm/home-list.js +289 -0
  115. package/workspace/public/pm/home-more.js +18 -135
  116. package/workspace/public/pm/home-phone-card.js +13 -8
  117. package/workspace/public/pm/home-review.js +103 -0
  118. package/workspace/public/pm/home-task.js +67 -0
  119. package/workspace/public/pm/home-today.js +148 -0
  120. package/workspace/public/pm/home-work.js +63 -28
  121. package/workspace/public/pm/note-dock.js +1 -2
  122. package/workspace/public/pm/notes-links.js +1 -2
  123. package/workspace/public/pm/notes-task.js +3 -4
  124. package/workspace/public/pm/premium-board.js +164 -40
  125. package/workspace/public/pm/premium-chart-tab.js +4 -5
  126. package/workspace/public/pm/premium-first.js +5 -7
  127. package/workspace/public/pm/premium-initiative-head.js +3 -3
  128. package/workspace/public/pm/premium-insights.js +499 -202
  129. package/workspace/public/pm/premium-mtg-present.js +138 -0
  130. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  131. package/workspace/public/pm/premium-report-read.js +216 -52
  132. package/workspace/public/pm/premium-report-tab.js +44 -19
  133. package/workspace/public/pm/premium-shell.js +7 -7
  134. package/workspace/public/pm/premium-vw-cal.js +150 -60
  135. package/workspace/public/pm/premium-vw-doc.css +20 -2
  136. package/workspace/public/pm/premium-vw-doc.js +22 -7
  137. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  138. package/workspace/public/pm/premium-vw-notes.js +61 -0
  139. package/workspace/public/pm/rp-parts.js +269 -0
  140. package/workspace/public/pm/view-notes.js +2 -2
  141. package/workspace/public/premium-board.html +4 -3
  142. package/workspace/public/premium-insights.html +10 -10
  143. package/workspace/public/premium.html +3 -1
  144. package/workspace/r/m1.png +0 -0
  145. package/workspace/r/m2.png +0 -0
  146. package/workspace/r/m3.png +0 -0
  147. package/workspace/r/nl.png +0 -0
  148. package/workspace/replaced-tests.json +435 -0
  149. package/workspace/run-tests.js +323 -28
  150. package/workspace/server.js +15 -10
  151. package/workspace/test-files.json +3 -140
  152. package/workspace/test-lists/base.json +1 -2
  153. package/workspace/test-lists/c3-desktop-light-load.json +1 -2
  154. package/workspace/test-lists/c3-initiative-boards.json +1 -2
  155. package/workspace/test-lists/c3-meeting-focus.json +2 -12
  156. package/workspace/test-lists/c3-work-agent.json +1 -2
  157. package/workspace/test-lists/calendar-tidy-up.json +1 -2
  158. package/workspace/test-lists/console3-reports.json +1 -2
  159. package/workspace/test-lists/docs-three-way-sync.json +1 -2
  160. package/workspace/test-lists/extension-capture.json +5 -0
  161. package/workspace/test-lists/initiative-layout.json +9 -0
  162. package/workspace/test-lists/jira-wbs.json +1 -2
  163. package/workspace/test-lists/legacy-cleanup-a.json +9 -0
  164. package/workspace/test-lists/meeting-material.json +1 -2
  165. package/workspace/test-lists/meeting-notes.json +2 -36
  166. package/workspace/test-lists/meeting-replay.json +1 -2
  167. package/workspace/test-lists/mm-capture.json +2 -12
  168. package/workspace/test-lists/my-work.json +2 -10
  169. package/workspace/test-lists/onboarding-firstrun.json +2 -12
  170. package/workspace/test-lists/people-directory.json +1 -2
  171. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  172. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  173. package/workspace/test-lists/run2-a.json +1 -2
  174. package/workspace/test-lists/run2-d.json +2 -19
  175. package/workspace/test-lists/run3-b.json +1 -2
  176. package/workspace/test-lists/run3-c.json +2 -12
  177. package/workspace/test-lists/run4-b.json +1 -2
  178. package/workspace/test-lists/run4-d.json +1 -5
  179. package/workspace/test-lists/run5-c.json +1 -11
  180. package/workspace/test-lists/run6.json +1 -5
  181. package/workspace/test-lists/uf-everywhere.json +15 -0
  182. package/workspace/test-lists/uf-home.json +9 -0
  183. package/workspace/test-lists/uncovered-board.json +9 -0
  184. package/workspace/test-lists/workspace-launch-flags.json +2 -12
  185. package/workspace/test-lists/workspace-profile-detection.json +2 -10
  186. package/workspace/test-timings.json +242 -123
  187. package/workspace/c3-briefing-test.js +0 -136
  188. package/workspace/c3-core-docs-test.js +0 -170
  189. package/workspace/c3-driver-fixture.js +0 -64
  190. package/workspace/c3-driver-test.js +0 -169
  191. package/workspace/c3-foundation-test.js +0 -163
  192. package/workspace/c3-ib-items-test.js +0 -114
  193. package/workspace/c3-ib-more-test.js +0 -146
  194. package/workspace/c3-ib-triage-backlog-test.js +0 -128
  195. package/workspace/c3-ini-harness.js +0 -66
  196. package/workspace/c3-ini-life-test.js +0 -167
  197. package/workspace/c3-initiatives-test.js +0 -186
  198. package/workspace/c3-light-load-test.js +0 -112
  199. package/workspace/c3-one-home-test.js +0 -149
  200. package/workspace/c3-phone-test.js +0 -289
  201. package/workspace/c3-quiet-test.js +0 -157
  202. package/workspace/c3-report-design-real-test.js +0 -264
  203. package/workspace/c3-report-design-test.js +0 -442
  204. package/workspace/c3-report-setup-test.js +0 -192
  205. package/workspace/c3-report-structure-real-test.js +0 -248
  206. package/workspace/c3-report-structure-test.js +0 -397
  207. package/workspace/c3-reports-test.js +0 -288
  208. package/workspace/c3-scan-test.js +0 -517
  209. package/workspace/c3-sessions-panel-test.js +0 -365
  210. package/workspace/c3-settings-test.js +0 -204
  211. package/workspace/c3-updates-test.js +0 -131
  212. package/workspace/c3-work-test.js +0 -260
  213. package/workspace/cut-stub.js +0 -40
  214. package/workspace/first-paint-audit.js +0 -160
  215. package/workspace/lib/c3-full-console.js +0 -15
  216. package/workspace/lib/engine/derived/trust.js +0 -3
  217. package/workspace/lib/engine/plan-forecast.js +0 -342
  218. package/workspace/lib/engine/report-families.js +0 -175
  219. package/workspace/lib/engine/truth-table.js +0 -57
  220. package/workspace/lib/routes-c3-init.js +0 -54
  221. package/workspace/lib/routes-c3-life.js +0 -120
  222. package/workspace/lib/routes-c3-timeline.js +0 -192
  223. package/workspace/lib/routes-forecast.js +0 -86
  224. package/workspace/lib/routes-releases.js +0 -130
  225. package/workspace/lib/routes-report-facts.js +0 -85
  226. package/workspace/lib/routes-report-families.js +0 -33
  227. package/workspace/lib/routes-signals.js +0 -51
  228. package/workspace/lib/routes-timeline.js +0 -197
  229. package/workspace/public/c3.html +0 -35
  230. package/workspace/public/index.html +0 -156
  231. package/workspace/public/pm/app.js +0 -831
  232. package/workspace/public/pm/bd-board.js +0 -159
  233. package/workspace/public/pm/bd-drag.js +0 -59
  234. package/workspace/public/pm/bd-model.js +0 -152
  235. package/workspace/public/pm/bd-timeline.js +0 -233
  236. package/workspace/public/pm/bd-tree.js +0 -244
  237. package/workspace/public/pm/board-copy.js +0 -59
  238. package/workspace/public/pm/board-read.js +0 -38
  239. package/workspace/public/pm/branches-sheet.js +0 -56
  240. package/workspace/public/pm/breakdown-api.js +0 -58
  241. package/workspace/public/pm/breakdown-copy.js +0 -138
  242. package/workspace/public/pm/briefing-deck.js +0 -441
  243. package/workspace/public/pm/briefing-model.js +0 -251
  244. package/workspace/public/pm/c3-ambient.js +0 -100
  245. package/workspace/public/pm/c3-audience-link.js +0 -21
  246. package/workspace/public/pm/c3-audience.js +0 -46
  247. package/workspace/public/pm/c3-boot.js +0 -13
  248. package/workspace/public/pm/c3-breakdown.js +0 -240
  249. package/workspace/public/pm/c3-brief-data.js +0 -11
  250. package/workspace/public/pm/c3-brief-mentions.js +0 -137
  251. package/workspace/public/pm/c3-brief-needs.js +0 -288
  252. package/workspace/public/pm/c3-brief-pulse.js +0 -112
  253. package/workspace/public/pm/c3-brief-summary.js +0 -139
  254. package/workspace/public/pm/c3-brief-today.js +0 -79
  255. package/workspace/public/pm/c3-brief.js +0 -279
  256. package/workspace/public/pm/c3-cal-strategy.js +0 -529
  257. package/workspace/public/pm/c3-calendar.js +0 -965
  258. package/workspace/public/pm/c3-calpop.js +0 -111
  259. package/workspace/public/pm/c3-case.js +0 -196
  260. package/workspace/public/pm/c3-core-docs.css +0 -18
  261. package/workspace/public/pm/c3-core-docs.js +0 -236
  262. package/workspace/public/pm/c3-daypart.js +0 -176
  263. package/workspace/public/pm/c3-demo-boards.js +0 -764
  264. package/workspace/public/pm/c3-demo-brief-ix.js +0 -350
  265. package/workspace/public/pm/c3-demo-brief-page.js +0 -70
  266. package/workspace/public/pm/c3-demo-cal-ix.js +0 -74
  267. package/workspace/public/pm/c3-demo-cal2.js +0 -66
  268. package/workspace/public/pm/c3-demo-cal3.js +0 -173
  269. package/workspace/public/pm/c3-demo-cal4.js +0 -169
  270. package/workspace/public/pm/c3-demo-cal5.js +0 -52
  271. package/workspace/public/pm/c3-demo-coredocs.js +0 -221
  272. package/workspace/public/pm/c3-demo-data.js +0 -552
  273. package/workspace/public/pm/c3-demo-focus.js +0 -181
  274. package/workspace/public/pm/c3-demo-init.js +0 -430
  275. package/workspace/public/pm/c3-demo-life.js +0 -77
  276. package/workspace/public/pm/c3-demo-material.js +0 -58
  277. package/workspace/public/pm/c3-demo-misc2.js +0 -34
  278. package/workspace/public/pm/c3-demo-phone.js +0 -48
  279. package/workspace/public/pm/c3-demo-plan2.js +0 -30
  280. package/workspace/public/pm/c3-demo-rd.js +0 -432
  281. package/workspace/public/pm/c3-demo-rep-ix.js +0 -126
  282. package/workspace/public/pm/c3-demo-rep2.js +0 -130
  283. package/workspace/public/pm/c3-demo-rep3.js +0 -138
  284. package/workspace/public/pm/c3-demo-rs.js +0 -287
  285. package/workspace/public/pm/c3-demo-term.js +0 -153
  286. package/workspace/public/pm/c3-demo-time.js +0 -49
  287. package/workspace/public/pm/c3-demo-work-ix.js +0 -32
  288. package/workspace/public/pm/c3-demo.js +0 -131
  289. package/workspace/public/pm/c3-design-studio.js +0 -369
  290. package/workspace/public/pm/c3-doc-formats.js +0 -153
  291. package/workspace/public/pm/c3-doc-sheet.js +0 -1230
  292. package/workspace/public/pm/c3-dock.js +0 -206
  293. package/workspace/public/pm/c3-docs.js +0 -291
  294. package/workspace/public/pm/c3-driver-work.js +0 -110
  295. package/workspace/public/pm/c3-driver.css +0 -18
  296. package/workspace/public/pm/c3-driver.js +0 -298
  297. package/workspace/public/pm/c3-focus.css +0 -304
  298. package/workspace/public/pm/c3-focus.js +0 -983
  299. package/workspace/public/pm/c3-ib-docs.js +0 -92
  300. package/workspace/public/pm/c3-ib-initiatives.js +0 -201
  301. package/workspace/public/pm/c3-ib-items.js +0 -210
  302. package/workspace/public/pm/c3-ib-releases.js +0 -48
  303. package/workspace/public/pm/c3-ib-sprints.js +0 -201
  304. package/workspace/public/pm/c3-ib-triage.js +0 -177
  305. package/workspace/public/pm/c3-ii-tabs.js +0 -252
  306. package/workspace/public/pm/c3-ini-life.css +0 -34
  307. package/workspace/public/pm/c3-ini-life.js +0 -379
  308. package/workspace/public/pm/c3-ini-records.js +0 -197
  309. package/workspace/public/pm/c3-ini-timeline.js +0 -278
  310. package/workspace/public/pm/c3-ini-work.js +0 -139
  311. package/workspace/public/pm/c3-init-extras.js +0 -170
  312. package/workspace/public/pm/c3-initiatives.js +0 -852
  313. package/workspace/public/pm/c3-lifecycle-panels.js +0 -479
  314. package/workspace/public/pm/c3-look.js +0 -27
  315. package/workspace/public/pm/c3-material.css +0 -22
  316. package/workspace/public/pm/c3-material.js +0 -321
  317. package/workspace/public/pm/c3-md.js +0 -3
  318. package/workspace/public/pm/c3-misc-panels.js +0 -89
  319. package/workspace/public/pm/c3-new-session.js +0 -110
  320. package/workspace/public/pm/c3-notes.js +0 -751
  321. package/workspace/public/pm/c3-phone-boot.js +0 -47
  322. package/workspace/public/pm/c3-phone-detail.js +0 -97
  323. package/workspace/public/pm/c3-phone-model.js +0 -3
  324. package/workspace/public/pm/c3-phone.css +0 -66
  325. package/workspace/public/pm/c3-phone.js +0 -444
  326. package/workspace/public/pm/c3-plan-panels.js +0 -163
  327. package/workspace/public/pm/c3-plan.js +0 -193
  328. package/workspace/public/pm/c3-quiet.css +0 -113
  329. package/workspace/public/pm/c3-quiet.js +0 -177
  330. package/workspace/public/pm/c3-replay.css +0 -133
  331. package/workspace/public/pm/c3-replay.js +0 -429
  332. package/workspace/public/pm/c3-report-deck.css +0 -163
  333. package/workspace/public/pm/c3-report-deck.js +0 -598
  334. package/workspace/public/pm/c3-report-frame.css +0 -20
  335. package/workspace/public/pm/c3-report-print.css +0 -20
  336. package/workspace/public/pm/c3-report-setup.css +0 -67
  337. package/workspace/public/pm/c3-report-setup.js +0 -298
  338. package/workspace/public/pm/c3-report-store.js +0 -244
  339. package/workspace/public/pm/c3-report-structure.css +0 -44
  340. package/workspace/public/pm/c3-report-structure.js +0 -473
  341. package/workspace/public/pm/c3-reports.css +0 -68
  342. package/workspace/public/pm/c3-reports.js +0 -377
  343. package/workspace/public/pm/c3-roadmap.js +0 -249
  344. package/workspace/public/pm/c3-scan-api.js +0 -167
  345. package/workspace/public/pm/c3-scan-next.js +0 -248
  346. package/workspace/public/pm/c3-scan-setup.js +0 -313
  347. package/workspace/public/pm/c3-scan-words.js +0 -41
  348. package/workspace/public/pm/c3-scan.css +0 -74
  349. package/workspace/public/pm/c3-scan.js +0 -93
  350. package/workspace/public/pm/c3-session-chat.js +0 -103
  351. package/workspace/public/pm/c3-session-conv.js +0 -165
  352. package/workspace/public/pm/c3-session-term.js +0 -216
  353. package/workspace/public/pm/c3-settings.css +0 -85
  354. package/workspace/public/pm/c3-settings.js +0 -1045
  355. package/workspace/public/pm/c3-shell.js +0 -628
  356. package/workspace/public/pm/c3-signals.js +0 -196
  357. package/workspace/public/pm/c3-strategy-panels.js +0 -45
  358. package/workspace/public/pm/c3-swipe.js +0 -230
  359. package/workspace/public/pm/c3-terminal-data.js +0 -48
  360. package/workspace/public/pm/c3-terminal-edge.js +0 -91
  361. package/workspace/public/pm/c3-terminal-icons.js +0 -40
  362. package/workspace/public/pm/c3-terminal-results.js +0 -141
  363. package/workspace/public/pm/c3-terminal.js +0 -52
  364. package/workspace/public/pm/c3-tickets.js +0 -163
  365. package/workspace/public/pm/c3-timeline.js +0 -201
  366. package/workspace/public/pm/calendar-views.js +0 -1049
  367. package/workspace/public/pm/console3-lift.md +0 -220
  368. package/workspace/public/pm/cozy-home.js +0 -172
  369. package/workspace/public/pm/cozy-initiative.css +0 -138
  370. package/workspace/public/pm/cycle-review.js +0 -125
  371. package/workspace/public/pm/data.js +0 -1577
  372. package/workspace/public/pm/dest-board.js +0 -444
  373. package/workspace/public/pm/dest-docs.js +0 -530
  374. package/workspace/public/pm/dest-initiatives.js +0 -162
  375. package/workspace/public/pm/dest-mywork.js +0 -307
  376. package/workspace/public/pm/dest-notes.js +0 -537
  377. package/workspace/public/pm/dest-people.js +0 -449
  378. package/workspace/public/pm/dest-reports.js +0 -383
  379. package/workspace/public/pm/dest-settings.js +0 -601
  380. package/workspace/public/pm/dest-today.js +0 -267
  381. package/workspace/public/pm/display-word.js +0 -56
  382. package/workspace/public/pm/doc-editor.js +0 -473
  383. package/workspace/public/pm/doc-graph.js +0 -272
  384. package/workspace/public/pm/doc-health-panel.js +0 -110
  385. package/workspace/public/pm/doc-rail.js +0 -167
  386. package/workspace/public/pm/doc-remote.js +0 -180
  387. package/workspace/public/pm/dock-sessions.js +0 -472
  388. package/workspace/public/pm/dock.js +0 -216
  389. package/workspace/public/pm/fixture.js +0 -821
  390. package/workspace/public/pm/flag-picker.js +0 -104
  391. package/workspace/public/pm/frame-copy.js +0 -278
  392. package/workspace/public/pm/freshness-line.js +0 -149
  393. package/workspace/public/pm/handoff-box.js +0 -82
  394. package/workspace/public/pm/initiative-list.js +0 -235
  395. package/workspace/public/pm/initiative-sheet.js +0 -331
  396. package/workspace/public/pm/initiatives-api.js +0 -95
  397. package/workspace/public/pm/initiatives-copy.js +0 -287
  398. package/workspace/public/pm/initiatives-timeline-copy.js +0 -59
  399. package/workspace/public/pm/initiatives-timeline.js +0 -410
  400. package/workspace/public/pm/initiatives-ui.js +0 -291
  401. package/workspace/public/pm/item-sheet.js +0 -268
  402. package/workspace/public/pm/keep-card.js +0 -204
  403. package/workspace/public/pm/lifecycle-lens-model.js +0 -246
  404. package/workspace/public/pm/lifecycle-lens.js +0 -276
  405. package/workspace/public/pm/lifecycle.js +0 -111
  406. package/workspace/public/pm/mobile.css +0 -366
  407. package/workspace/public/pm/mobile.js +0 -581
  408. package/workspace/public/pm/modes-live.js +0 -453
  409. package/workspace/public/pm/modes.js +0 -147
  410. package/workspace/public/pm/my-work-card.js +0 -51
  411. package/workspace/public/pm/my-work-data.js +0 -36
  412. package/workspace/public/pm/new-initiative-sheet.js +0 -169
  413. package/workspace/public/pm/next-step-ui.js +0 -190
  414. package/workspace/public/pm/outbox-panel.js +0 -125
  415. package/workspace/public/pm/palette-copy.js +0 -55
  416. package/workspace/public/pm/palette.js +0 -343
  417. package/workspace/public/pm/panel-breakdown.js +0 -702
  418. package/workspace/public/pm/panel-cockpit.js +0 -425
  419. package/workspace/public/pm/panel-detail.js +0 -1513
  420. package/workspace/public/pm/panel-initiatives.js +0 -929
  421. package/workspace/public/pm/panel-newsess.js +0 -709
  422. package/workspace/public/pm/panel-repos.js +0 -741
  423. package/workspace/public/pm/panel-tabs.js +0 -1506
  424. package/workspace/public/pm/panel-trees.js +0 -204
  425. package/workspace/public/pm/people-link.js +0 -106
  426. package/workspace/public/pm/phone-deck.js +0 -167
  427. package/workspace/public/pm/pm-work-view.js +0 -1533
  428. package/workspace/public/pm/portfolio-report.js +0 -61
  429. package/workspace/public/pm/premium-acts.js +0 -280
  430. package/workspace/public/pm/premium-brief.js +0 -111
  431. package/workspace/public/pm/premium-chat.js +0 -22
  432. package/workspace/public/pm/premium-doc-sheet.js +0 -312
  433. package/workspace/public/pm/premium-initiative.js +0 -324
  434. package/workspace/public/pm/premium-insights.css +0 -228
  435. package/workspace/public/pm/premium-metric-tiles.js +0 -68
  436. package/workspace/public/pm/premium-report-brief.js +0 -132
  437. package/workspace/public/pm/premium-vw-rec.js +0 -67
  438. package/workspace/public/pm/premium-wide.css +0 -30
  439. package/workspace/public/pm/print.css +0 -44
  440. package/workspace/public/pm/provider-cards.js +0 -136
  441. package/workspace/public/pm/registry.js +0 -203
  442. package/workspace/public/pm/release-card.js +0 -110
  443. package/workspace/public/pm/releases-view.js +0 -248
  444. package/workspace/public/pm/report-families-view.js +0 -505
  445. package/workspace/public/pm/report-slides.js +0 -438
  446. package/workspace/public/pm/report-tab.js +0 -33
  447. package/workspace/public/pm/report-view.js +0 -337
  448. package/workspace/public/pm/reports-copy.js +0 -134
  449. package/workspace/public/pm/roadmap.js +0 -294
  450. package/workspace/public/pm/run-card.js +0 -260
  451. package/workspace/public/pm/sessions-panel.js +0 -219
  452. package/workspace/public/pm/sheet-jira.js +0 -353
  453. package/workspace/public/pm/shell-bell.js +0 -163
  454. package/workspace/public/pm/shell-model.js +0 -83
  455. package/workspace/public/pm/shell-phone.js +0 -124
  456. package/workspace/public/pm/shell-readaloud.js +0 -53
  457. package/workspace/public/pm/shell-recording.js +0 -274
  458. package/workspace/public/pm/shell-ticker.js +0 -90
  459. package/workspace/public/pm/sig-watch.js +0 -41
  460. package/workspace/public/pm/slide-confirm.js +0 -163
  461. package/workspace/public/pm/slides-copy.js +0 -52
  462. package/workspace/public/pm/status-banner.js +0 -95
  463. package/workspace/public/pm/tab-doc.js +0 -859
  464. package/workspace/public/pm/tab-gone.js +0 -21
  465. package/workspace/public/pm/tab-term.js +0 -1210
  466. package/workspace/public/pm/tab-web.js +0 -90
  467. package/workspace/public/pm/timeline-copy.js +0 -48
  468. package/workspace/public/pm/timeline-forecast-view.js +0 -164
  469. package/workspace/public/pm/today-agenda.js +0 -331
  470. package/workspace/public/pm/today-cards.js +0 -244
  471. package/workspace/public/pm/today-copy.js +0 -506
  472. package/workspace/public/pm/today-day.js +0 -1371
  473. package/workspace/public/pm/today-goals.js +0 -297
  474. package/workspace/public/pm/today-jobs.js +0 -84
  475. package/workspace/public/pm/today-mentions.js +0 -50
  476. package/workspace/public/pm/topbar.js +0 -202
  477. package/workspace/public/pm/triage-card.js +0 -60
  478. package/workspace/public/pm/undo-hold.js +0 -103
  479. package/workspace/public/pm/view-addrepo.js +0 -208
  480. package/workspace/public/pm/view-files.js +0 -197
  481. package/workspace/public/pm/view-livenotes.js +0 -399
  482. package/workspace/public/pm/view-today.js +0 -13
  483. package/workspace/public/pm/view-validate.js +0 -171
  484. package/workspace/public/pm/welcome.js +0 -391
  485. package/workspace/public/pm/work-place.js +0 -68
  486. package/workspace/public/pm/xlsx-read.js +0 -117
  487. package/workspace/public/welcome.html +0 -22
  488. package/workspace/test-lists/browser-suites-green.json +0 -5
  489. package/workspace/test-lists/c3-core-docs.json +0 -9
  490. package/workspace/test-lists/c3-doc-sheet-rich.json +0 -6
  491. package/workspace/test-lists/c3-doc-sheet-size.json +0 -6
  492. package/workspace/test-lists/c3-doc-sheet-v2.json +0 -6
  493. package/workspace/test-lists/c3-ib-items.json +0 -9
  494. package/workspace/test-lists/c3-ib-more.json +0 -9
  495. package/workspace/test-lists/c3-ib-triage-backlog.json +0 -9
  496. package/workspace/test-lists/c3-ini-life.json +0 -9
  497. package/workspace/test-lists/c3-meeting-board.json +0 -5
  498. package/workspace/test-lists/c3-meeting-card.json +0 -5
  499. package/workspace/test-lists/c3-notes-place.json +0 -5
  500. package/workspace/test-lists/c3-notes-series.json +0 -5
  501. package/workspace/test-lists/calendar-time-page.json +0 -5
  502. package/workspace/test-lists/calpop.json +0 -4
  503. package/workspace/test-lists/console3-briefing.json +0 -9
  504. package/workspace/test-lists/console3-foundation.json +0 -9
  505. package/workspace/test-lists/console3-work-page.json +0 -9
  506. package/workspace/test-lists/premium-brief-parity.json +0 -9
  507. package/workspace/test-lists/report-design-studio-ui.json +0 -5
  508. package/workspace/test-lists/report-structure-ui.json +0 -11
  509. package/workspace/test-lists/report-workspace-ui.json +0 -5
  510. package/workspace/test-lists/run3-a.json +0 -5
  511. package/workspace/test-lists/run3-d.json +0 -6
  512. package/workspace/test-lists/run4-c.json +0 -13
  513. package/workspace/test-lists/today-goals-jobs-ui.json +0 -5
  514. package/workspace/test-lists/today-mentions-cards.json +0 -5
  515. package/workspace/test-lists/workspace-tabs-declutter.json +0 -13
@@ -1,1371 +0,0 @@
1
- /* pm/today-day.js — the day section at the top of Today (initiative today-goals, PRD G9 to G22).
2
- *
3
- * daySection({ ws, setState, openIni }) → the section node, or null in fixture mode
4
- * daySig(ws) → a string that changes whenever what the section shows changes
5
- *
6
- * One read feeds it: GET /api/proactive/day (the run, its stage, the fresh brief with its calendar, items and digests, the
7
- * goals' plan, the source settings and states, the daytime check). The section draws:
8
- * - a one-line top bar: the greeting, the four steps of "Prepare my day" (each selects its detail), the last and the
9
- * coming check with "Check now", Sources, and "Prepare my day";
10
- * - on the left, the calendar (with a line at the current time), the jobs (needs you, agent working, done), the goals
11
- * and the mentions with the watched channels, projects and spaces;
12
- * - on the right, the detail of what is selected: a meeting, a job, a goal, a mention, a step, the sources or a place.
13
- * A meeting's detail ends with its meeting notes: the summary and Open notes, or Take notes (pm/notes-links.js,
14
- * meeting-notes Run 4).
15
- * The presses go to the routes that own them: the goals route (add, done, drop, reopen, remove), /goals/plan (Prepare my
16
- * day), /day/decide (approve, revise, run again), /day/check (Check now) and the settings route (sources, levels, the
17
- * daytime check, websites). Nothing here sends anything outward: the agent sessions do that, after the PM approves.
18
- *
19
- * FIRST PAINT. Folded, the section is one control (its toggle), so Today keeps inside its control budget
20
- * (first-paint-today.test.js). It opens by itself on a day the PM pressed "Prepare my day", and it remembers the PM's own
21
- * choice in this browser.
22
- *
23
- * REFRESH. Like the goals before it, the read repeats every 30 seconds, and every 4 seconds while a run reads or works, a
24
- * check runs or a press is in flight. A read that changes nothing draws nothing.
25
- */
26
-
27
- import { el } from './dom.js';
28
- import { button, iconButton, badge, toast, row, tabs, field, menu, meter } from './primitives.js';
29
- import { pmGet, pmPost } from './http.js';
30
- import { FIXTURE, state } from './state.js';
31
- import { COPY } from './today-copy.js';
32
- import { goalRows, goalAdd, goalDetail, goalJobsBlock, jobsWithoutGoal, addGoal, goalsSig } from './today-goals.js';
33
- import { statusPill, whoActs, mark as whoMark, tag, tagged, originOf, goalPicker } from './today-jobs.js';
34
- import { hasCard, mentionCard } from './today-mentions.js';
35
- import { peopleLinks } from './people-link.js';
36
- import { agendaPanel, meetingDetail, memoryBlock, meetingFacts, keyItems, refreshAgenda, agendaSig, onAgenda } from './today-agenda.js';
37
- import { notesBlock, onNotes } from './notes-links.js';
38
-
39
- const D = COPY.day;
40
- const A = COPY.act;
41
- const SLOW_MS = 30000;
42
- const FAST_MS = 4000;
43
- const SCOPED = ['slack', 'jira', 'confluence'];
44
- const NARROW = 860; // below this width of the section the detail goes under the list (components.css @container td-day)
45
-
46
- /* ── per-viewer conveniences (never state that must persist): the fold and the new items already seen ── */
47
- const store = {
48
- get(k) { try { return localStorage.getItem(k); } catch { return null; } },
49
- set(k, v) { try { localStorage.setItem(k, v); } catch { /* private window: the default applies */ } },
50
- };
51
- // A new key: a fold stored by the old Today page must not hide the Agenda month.
52
- const OPEN_KEY = 'pmos.agenda.day.open';
53
- const SEEN_KEY = 'pmos.today.day.seen';
54
- const SECTION_KEY = 'pm.today.section';
55
- let seen = new Set();
56
- try { seen = new Set(JSON.parse(store.get(SEEN_KEY) || '[]')); } catch { seen = new Set(); }
57
-
58
- const cache = new Map(); // ws -> { data, error }
59
- const runs = new Map(); // ws -> the last "Prepare my day" press: { state: 'busy'|'started'|'running'|'failed', at, session, error }
60
- const ui = {
61
- open: (() => { const v = store.get(OPEN_KEY); return v === 'true' ? true : v === 'false' ? false : null; })(),
62
- section: (() => { const v = store.get(SECTION_KEY); return ['agenda', 'goals', 'jobs', 'mentions'].includes(v) ? v : 'agenda'; })(),
63
- sel: null, mtab: 'all', openSrc: null, showIgn: {}, showIgnDigests: false,
64
- revising: new Set(), notes: new Map(), siteDraft: '', placeDraft: {}, busy: new Set(), inflight: new Map(), scroll: false,
65
- // today-act-prepare: the folded groups the PM opened, the item whose hold form is open, and its draft
66
- cur: new Map(), groupsOpen: new Set(), holding: null, holdDraft: { who: '', when: 'h2' }, compose: new Map(), verdict: new Map(),
67
- };
68
- let rerender = () => {};
69
- let notesSub = null; // the redraw when the meeting notes list is read (pm/notes-links.js)
70
- let timer = null;
71
-
72
- /* ── the read ─────────────────────────────────────────────────────────────────────────────────────────────────── */
73
-
74
- const minuteOf = (v) => { const t = typeof v === 'number' ? v : Date.parse(v); return Number.isFinite(t) ? Math.floor(t / 60000) : null; };
75
- const dataSig = (d) => (d ? JSON.stringify({ ...d, now: minuteOf(d.now) }) : 'null');
76
-
77
- async function load(ws) {
78
- const q = ws ? '?ws=' + encodeURIComponent(ws) : '';
79
- let out = await pmGet('/api/proactive/day' + q);
80
- if (out && out.ok === false && out.status === 404) {
81
- // a workspace server from before the day run: show the goals from the older read, and say so
82
- const g = await pmGet('/api/proactive/goals' + q);
83
- out = g && g.ok ? { ok: true, legacy: true, today: g.today, now: null, run: null, stage: null, brief: null, plan: g.plan, max_goals: g.max_goals, settings: null, sources: [], check: null } : g;
84
- }
85
- const prev = cache.get(ws);
86
- const next = out && out.ok ? { data: out, error: null } : { data: prev ? prev.data : null, error: (out && out.error) || D.unreached };
87
- cache.set(ws, next);
88
- if (!prev || dataSig(prev.data) !== dataSig(next.data) || prev.error !== next.error) rerender();
89
- // the month follows the brief and the clock: it is read again with the day
90
- refreshAgenda();
91
- schedule();
92
- }
93
-
94
- function busyNow() {
95
- for (const [ws, c] of cache) {
96
- const d = c.data;
97
- if (d && (d.stage === 'reading' || d.stage === 'working' || (d.check && d.check.running))) return true;
98
- if (d && d.run && (d.run.tasks || []).some((t) => t.status === 'sending')) return true;
99
- const r = runs.get(ws);
100
- if (r && r.state === 'busy') return true;
101
- }
102
- return false;
103
- }
104
-
105
- function schedule() {
106
- if (typeof window === 'undefined') return;
107
- if (timer) clearTimeout(timer);
108
- timer = setTimeout(() => {
109
- timer = null;
110
- // a hidden Today reads at the slow pace only: the reads cost the server, and nobody looks
111
- if (!document.querySelector('[data-today="day"]') && !busyNow()) { schedule(); return; }
112
- for (const w of cache.keys()) load(w);
113
- }, busyNow() ? FAST_MS : SLOW_MS);
114
- }
115
-
116
- function ensure(ws) {
117
- if (!cache.has(ws)) { cache.set(ws, { data: null, error: null }); load(ws); }
118
- }
119
-
120
- /* ── the model: the read, joined once per draw ────────────────────────────────────────────────────────────────── */
121
-
122
- const pad = (n) => String(n).padStart(2, '0');
123
- const hhmm = (v) => { if (v === null || v === undefined || v === '') return ''; const d = new Date(typeof v === 'number' ? v : Date.parse(v)); return Number.isNaN(d.getTime()) ? String(v) : `${pad(d.getHours())}:${pad(d.getMinutes())}`; };
124
- const isUrl = (s) => typeof s === 'string' && s.length <= 500 && /^https?:\/\/\S+$/i.test(s);
125
- const srcName = (k) => D.srcName[k] || (k === 'derived' ? 'PMOS' : String(k || ''));
126
-
127
- function jobOf(item, task, worth) {
128
- // a job the PM gave to the agent (Have the agent draft it) has the task's kind: approve
129
- const kind = (task && task.kind) || (item && item.kind) || (item && item.owner === 'pm' ? 'you' : 'approve');
130
- const status = task ? task.status : kind === 'you' ? 'you' : 'notStarted';
131
- const group = worth ? 'worth' : ['you', 'review', 'failed'].includes(status) ? 'needs' : ['done', 'sent'].includes(status) ? 'done' : 'working';
132
- return {
133
- id: item ? item.id : task.item_id || task.id, item, task, kind, status, group, worth,
134
- // the id a link mark is kept under: the brief item, else the run task (PRD L1)
135
- linkId: item ? item.id : task.id,
136
- title: (item && item.title) || (task && task.title) || '', source: (item && item.source) || (task && task.source) || '',
137
- link: (item && isUrl(item.link) && item.link) || (task && isUrl(task.link) && task.link) || null,
138
- goal: (item && item.goal) || (task && task.goal) || null, isNew: !!(item && item.new),
139
- };
140
- }
141
-
142
- function deriveStage(run, brief) {
143
- if (!run) return null;
144
- if (!brief) return 'reading';
145
- const ts = run.tasks || [];
146
- if (ts.some((t) => ['waiting', 'working', 'sending'].includes(t.status))) return 'working';
147
- if (ts.some((t) => t.status === 'review')) return 'review';
148
- return 'done';
149
- }
150
-
151
- /* One day for every repository. `view` is { here: the repository Today was opened from (a workspace id), all: the
152
- * Show switch is on All repositories }. An item, a goal or a place carries a repository or none; with the switch on one
153
- * repository, the day keeps that repository's items and the ones with none. The calendar is never narrowed. */
154
- function model(d, view) {
155
- const today = d && d.today;
156
- const brief = d && d.brief && (!today || d.brief.date === today) ? d.brief : null;
157
- const plan = (d && d.plan) || null;
158
- // a goal with no repository of its own takes the one its initiative is in (goal_repos, from the server)
159
- const goalRepos = (d && d.goal_repos) || {};
160
- const goals = (plan ? plan.goals || [] : []).map((g) => (g.repo || !goalRepos[g.id] ? g : { ...g, repo: goalRepos[g.id] }));
161
- const goalNo = new Map(goals.map((g, i) => [g.id, i + 1]));
162
- const run = (d && d.run) || null;
163
- const tasks = run && Array.isArray(run.tasks) ? run.tasks : [];
164
- const byItem = new Map(tasks.map((t) => [t.item_id, t]));
165
- const used = new Set();
166
- const jobs = [];
167
- const add = (x, worth) => { const t = byItem.get(x.id) || null; if (t) used.add(t.id); jobs.push(jobOf(x, t, worth)); };
168
- for (const x of (brief && brief.priorities) || []) add(x, false);
169
- for (const x of (brief && brief.worth_asking) || []) add(x, true);
170
- for (const t of tasks) if (!used.has(t.id)) jobs.push(jobOf(null, t, false)); // an item a check took off: its task stays
171
- const now = d && d.now ? (typeof d.now === 'number' ? d.now : Date.parse(d.now)) : Date.now();
172
- const marks = (d && d.marks) || {};
173
- const events = ((brief && brief.calendar) || []).map((e, i) => {
174
- const s = Date.parse(e.start);
175
- const f = e.end ? Date.parse(e.end) : s + 30 * 60000;
176
- const mark = marks[e.id] || null;
177
- const checked = new Set((mark && mark.steps) || []);
178
- const before = ((e.steps && e.steps.before) || []).map((st) => ({ ...st, done: !!st.done || checked.has(String(st.t || '')) }));
179
- const ended = Number.isFinite(f) && f <= now;
180
- // a meeting needs prep when the brief gave a prep line or Before steps (the explainer's contradiction: Before steps
181
- // with no prep line read "Nothing to prepare" while the Agenda counted them as prep left)
182
- // the prep stays with the meeting once it ends (the PM, 2026-10-07): hadPrep keeps the detail, needsPrep drives the lists
183
- const hadPrep = !!e.prep || before.length > 0;
184
- const needsPrep = !ended && hadPrep;
185
- const st = mark && mark.state;
186
- const group = !needsPrep ? null : st === 'done' || st === 'dismissed' ? 'done' : st === 'snoozed' ? 'later' : 'needs';
187
- // the goal a meeting counts toward: the brief's own, else the goal the PM made from it (event_id), PRD A4
188
- const gid = (e.goal && goals.some((g) => g.id === e.goal) ? e.goal : null) || ((goals.find((g) => g.event_id && g.event_id === e.id) || {}).id) || null;
189
- return { ...e, id: e.id || 'ev-' + i, gid, s, f, time: hhmm(e.start), ended, mark, before, hadPrep, needsPrep, group };
190
- }).sort((a, b) => a.s - b.s);
191
- const settings = (d && d.settings) || null;
192
- const scopes = (settings && settings.scopes) || {};
193
- const level = (svc, name) => (scopes[svc] && scopes[svc][name]) || 'search';
194
- const digests = ((brief && Array.isArray(brief.digests)) ? brief.digests : []).map((g) => ({ ...g, id: g.source + '|' + g.name, level: level(g.source, g.name) }));
195
- const places = (brief && Array.isArray(brief.places)) ? brief.places : [];
196
- const placeRepos = (settings && settings.placeRepos) || {};
197
- const placeRepo = (svc, name) => (placeRepos[svc] && placeRepos[svc][name]) || null;
198
- const itemRepos = (d && d.item_repos) || {};
199
- const repos = (d && Array.isArray(d.repos)) ? d.repos : [];
200
- const repoName = (id) => { const r = repos.find((x) => x.id === id); return r ? r.name : id; };
201
- for (const j of jobs) j.repo = itemRepos[j.id] || null;
202
- // the goal of a job (initiative today-goals-jobs, PRD G4, L1): the plan puts a brief item under at most one open goal,
203
- // after the PM's link mark; a job the plan does not place keeps the PM's mark, else the goal it came with
204
- const stepGoal = new Map();
205
- for (const g of goals) for (const st of g.steps || []) if (st.item_id) stepGoal.set(st.item_id, g.id);
206
- for (const j of jobs) {
207
- const lk = marks[j.linkId];
208
- const linked = !!lk && lk.goal !== undefined;
209
- j.goal = (j.item && stepGoal.get(j.item.id)) || (linked ? lk.goal || null : j.goal);
210
- }
211
- // the PM's marks (today-act-prepare, PRD M1 to M6): a job the PM owns leaves Needs you when it is done, snoozed, held
212
- // or not the PM's; a snooze or hold whose time has passed comes back as open (the server reads it so)
213
- for (const j of jobs) {
214
- j.mark = marks[j.id] || null;
215
- const st = j.mark && j.mark.state;
216
- if (j.status === 'you' && st) j.group = { done: 'done', dismissed: 'done', snoozed: 'later', waiting: 'waiting' }[st] || j.group;
217
- }
218
- for (const g of digests) g.repo = placeRepo(g.source, g.name);
219
- const v = view || {};
220
- const narrow = !v.all && !!v.here;
221
- const inView = (r) => !narrow || !r || r === v.here;
222
- const shownJobs = jobs.filter((j) => inView(j.repo));
223
- const shownIds = new Set(shownJobs.map((j) => j.task && j.task.id).filter(Boolean));
224
- const shownTasks = narrow ? tasks.filter((t) => shownIds.has(t.id)) : tasks;
225
- return {
226
- d, brief, plan, goals: goals.filter((g) => inView(g.repo)), allGoals: goals, hiddenGoals: goals.filter((g) => !inView(g.repo)).length, goalNo, run, tasks: shownTasks, jobs: shownJobs, events, now, settings, scopes, level,
227
- digests: digests.filter((g) => inView(g.repo)), places, placeRepo, repos, repoName, here: v.here || null, narrow,
228
- stage: run ? (d.stage || deriveStage(run, brief)) : null,
229
- mentions: shownJobs.filter((j) => j.item && j.item.mention),
230
- sources: (d && Array.isArray(d.sources)) ? d.sources : [],
231
- check: (d && d.check) || null,
232
- readFailed: (d && d.read_failed) || null,
233
- free: plan && plan.time ? plan.time.free_minutes : null,
234
- maxGoals: (d && d.max_goals) || 7,
235
- preps: events.filter((e) => e.needsPrep),
236
- needs: shownJobs.filter((j) => j.group === 'needs').length + events.filter((e) => e.group === 'needs').length,
237
- done: shownJobs.filter((j) => j.group === 'done').length + events.filter((e) => e.group === 'done').length,
238
- };
239
- }
240
-
241
- const stepIndex = (stage) => ({ reading: 0, working: 2, review: 3, done: 4 }[stage] ?? -1);
242
-
243
- /* ── small parts ──────────────────────────────────────────────────────────────────────────────────────────────── */
244
-
245
- // a status word: the badge primitive. Health and attention read warning or destructive; everything else stays neutral.
246
- const TONE = { '': 'muted', ok: 'outline', info: 'outline', goal: 'outline', warn: 'warning', purple: 'warning', bad: 'destructive' };
247
- function pill(text, tone, attrs) {
248
- return badge({ text, tone: TONE[tone || ''] || 'muted', attrs });
249
- }
250
- /** The repository a row belongs to, as a small tag. A row with none (yours) carries no tag. */
251
- function repoTag(m, r) {
252
- return r ? badge({ text: m.repoName(r), tone: 'outline', attrs: { 'data-day-repo': r, title: COPY.day.repo.label } }) : null;
253
- }
254
- /** A picker of the repository: none, or one of the registered repositories. `onPick(id|null)`. */
255
- export function repoPicker(m, cur, onPick, attrs) {
256
- const sel = el('select', { class: 'td-day__repo', 'aria-label': COPY.day.repo.label, ...(attrs || {}) },
257
- el('option', { value: '' }, COPY.day.repo.none), ...m.repos.map((r) => el('option', { value: r.id }, r.name)),
258
- // a repository that is no longer registered stays shown, so the picker never hides what is stored
259
- cur && !m.repos.some((r) => r.id === cur) ? el('option', { value: cur }, cur) : null);
260
- sel.value = cur || '';
261
- sel.addEventListener('change', () => onPick(sel.value || null));
262
- return sel;
263
- }
264
- /** A link that opens outside the workspace, drawn as a small button. Only http and https addresses are drawn. */
265
- function extLink(label, href, attrs) {
266
- if (!isUrl(href)) return null;
267
- return el('a', { class: 'td-day__a', href, target: '_blank', rel: 'noopener noreferrer', ...(attrs || {}) }, label);
268
- }
269
- function panel(name, count, ...kids) {
270
- return el('section', { class: 'td-day__panel', 'aria-label': D.panels[name], 'data-day-panel': name },
271
- el('h2', { class: 'td-day__h2' }, D.panels[name], count ? el('span', null, count) : null), ...kids);
272
- }
273
- function note(text, attrs) { return el('p', { class: 'td-day__note', ...(attrs || {}) }, text); }
274
- function list(title, items, cls) {
275
- if (!items || !items.length) return null;
276
- return el('div', { class: 'td-day__phase' }, el('h4', null, title), el('ul', { class: 'td-day__chk' + (cls ? ' ' + cls : '') }, ...items.map((x) => el('li', null, x))));
277
- }
278
- function dl(pairs) {
279
- const kids = [];
280
- for (const [k, v] of pairs) if (v !== null && v !== undefined && v !== '') kids.push(el('dt', null, k), el('dd', null, v));
281
- return kids.length ? el('dl', { class: 'td-day__ctx' }, ...kids) : null;
282
- }
283
-
284
- function greet(now) {
285
- const h = new Date(now).getHours();
286
- return h < 12 ? D.hello.morning : h < 18 ? D.hello.afternoon : D.hello.evening;
287
- }
288
- function dateLabel(now) {
289
- try { return new Date(now).toLocaleDateString(undefined, { weekday: 'short', day: 'numeric', month: 'short' }); } catch { return ''; }
290
- }
291
-
292
- /* ── presses ──────────────────────────────────────────────────────────────────────────────────────────────────── */
293
-
294
- async function prepareDay(ws) {
295
- const cur = runs.get(ws);
296
- if (cur && cur.state === 'busy') return;
297
- runs.set(ws, { state: 'busy' });
298
- rerender(); schedule();
299
- const r = await pmPost('/api/proactive/goals/plan', { ws });
300
- const sid = r && (r.session || (r.result && r.result.sessionId));
301
- if (r && r.ok) {
302
- runs.set(ws, { state: r.running ? 'running' : 'started', at: Date.now(), session: sid ? { id: sid, name: 'morning-brief' } : null });
303
- ui.sel = { type: 'step', id: '0' };
304
- toast({ text: r.running ? D.runRunning : COPY.goals.started });
305
- } else {
306
- const error = (r && r.error) || D.unreached;
307
- runs.set(ws, { state: 'failed', at: Date.now(), error });
308
- toast({ text: D.runFailed(error), tone: 'destructive' });
309
- }
310
- rerender();
311
- load(ws);
312
- }
313
-
314
- async function openSession(session) {
315
- try { const m = await import('./handoff-box.js'); await m.openSessionTab(null, session); } catch (e) { console.error('[pm] could not open the session:', e); }
316
- }
317
-
318
- async function checkNow(ws) {
319
- ui.busy.add('check'); rerender();
320
- const r = await pmPost('/api/proactive/day/check', { ws });
321
- ui.busy.delete('check');
322
- toast(r && r.ok ? { text: D.checkStarted } : { text: D.checkRefused((r && r.error) || D.unreached), tone: 'destructive' });
323
- rerender();
324
- load(ws);
325
- }
326
-
327
- async function decide(ws, task, action, note) {
328
- const body = { task: task.id, action };
329
- if (note !== undefined) body.note = note;
330
- ui.busy.add(task.id); rerender();
331
- const r = await pmPost('/api/proactive/day/decide', body);
332
- ui.busy.delete(task.id);
333
- if (r && r.ok) { toast({ text: D.decided[action] }); ui.revising.delete(task.id); ui.notes.delete(task.id); }
334
- else toast({ text: D.refused((r && r.error) || D.unreached), tone: 'destructive' });
335
- rerender();
336
- load(ws);
337
- }
338
-
339
- /* The PM's marks (today-act-prepare, PRD M1 to M6). Every press but a step check says what it did, with Undo: the
340
- * answer carries the mark before the press, and Undo puts it back. */
341
- async function markPress(ws, id, op, said) {
342
- const key = 'mark:' + id;
343
- if (ui.busy.has(key)) return;
344
- ui.busy.add(key); rerender();
345
- const req = pmPost('/api/proactive/day/mark', { id, ...op });
346
- ui.inflight.set(key, req); // a step press made while this write is out waits for it (below) instead of being dropped as busy
347
- const r = await req;
348
- ui.inflight.delete(key);
349
- ui.busy.delete(key);
350
- if (r && r.ok) {
351
- if (op.action !== 'step') ui.holding = null;
352
- if (said) toast({ text: said, actionLabel: A.undo, onAction: () => undoMark(ws, id, r.prev) });
353
- } else toast({ text: (op.action === 'step' ? A.stepFailed : D.refused)((r && r.error) || D.unreached), tone: 'destructive' });
354
- rerender();
355
- load(ws);
356
- }
357
- async function undoMark(ws, id, prev) {
358
- const r = await pmPost('/api/proactive/day/mark', { id, action: 'restore', mark: prev === undefined ? null : prev });
359
- toast(r && r.ok ? { text: A.undone } : { text: D.refused((r && r.error) || D.unreached), tone: 'destructive' });
360
- load(ws);
361
- }
362
- /** "Have the agent draft it" (PRD C2): one briefed task for this job; the job then shows the draft to approve. */
363
- async function sendPress(ws, j, body, to) {
364
- const key = 'send:' + j.id;
365
- if (ui.busy.has(key)) return;
366
- ui.busy.add(key); rerender();
367
- const r = await pmPost('/api/proactive/day/send', { item: j.id, ws, ...body });
368
- ui.busy.delete(key);
369
- if (r && r.ok) { ui.compose.delete(j.id); ui.verdict.delete(j.id); toast({ text: A.sendStarted(to) }); } else toast({ text: D.refused((r && r.error) || D.unreached), tone: 'destructive' });
370
- rerender();
371
- load(ws);
372
- }
373
- async function draftPress(ws, j) {
374
- const key = 'draft:' + j.id;
375
- if (ui.busy.has(key)) return;
376
- ui.busy.add(key); rerender();
377
- const r = await pmPost('/api/proactive/day/draft', { item: j.id, ws });
378
- ui.busy.delete(key);
379
- toast(r && r.ok ? { text: A.draftStarted } : { text: D.refused((r && r.error) || D.unreached), tone: 'destructive' });
380
- rerender();
381
- load(ws);
382
- }
383
-
384
- async function setSettings(ws, patch) {
385
- const r = await pmPost('/api/proactive/settings', patch);
386
- if (!r || r.ok === false) { toast({ text: D.refused((r && r.error) || D.unreached), tone: 'destructive' }); return false; }
387
- await load(ws);
388
- return true;
389
- }
390
-
391
- function select(type, id) {
392
- ui.sel = type ? { type, id: String(id) } : null;
393
- if (type === 'job' && !seen.has(id)) { seen.add(id); store.set(SEEN_KEY, JSON.stringify([...seen].slice(-200))); }
394
- // Reveal the appropriate section when selecting an item
395
- if (type === 'job') { ui.section = 'jobs'; }
396
- else if (type === 'goal') { ui.section = 'goals'; }
397
- else if (type === 'mention' || type === 'channel') { ui.section = 'mentions'; }
398
- ui.scroll = true;
399
- rerender();
400
- }
401
-
402
- /* ── the top bar ──────────────────────────────────────────────────────────────────────────────────────────────── */
403
-
404
- function topBar(ctx) {
405
- const { m, ws } = ctx;
406
- const si = stepIndex(m.stage);
407
- const press = runs.get(ws);
408
- const busy = !!press && press.state === 'busy';
409
- const bs = m.run && m.run.brief_session;
410
- const reading = !!bs && !bs.ended_at && m.stage === 'reading' && !m.readFailed;
411
- // the four steps show as a small progress bar only while Prepare my day is running; otherwise the bar says when it last ran
412
- const inProgress = busy || reading || (!!m.run && m.stage === 'working');
413
- const steps = inProgress ? el('ol', { class: 'td-day__steps', 'aria-label': D.prepare }, ...D.steps.map((t, i) => {
414
- const st = si < 0 ? 'todo' : i < si || si === 4 ? 'done' : i === si ? 'now' : 'todo';
415
- return el('li', null, button({ label: [el('span', { class: 'td-day__seg', 'aria-hidden': 'true' })], variant: 'ghost', size: 'sm', onClick: () => select('step', i),
416
- attrs: { class: 'td-day__ts', 'data-step-state': st, 'data-day-step': String(i), 'data-day-sel': 'step:' + i, 'aria-current': ctx.cur('step', String(i)), 'aria-label': t + ': ' + D.stepHint[i], title: t + ': ' + D.stepHint[i] } }));
417
- })) : null;
418
- const working = m.tasks.filter((t) => t.status === 'working' || t.status === 'sending').length;
419
- const started = m.run && m.run.started_at ? hhmm(m.run.started_at) : '';
420
- const status = !m.run ? (busy ? D.starting : D.status.idle) : m.readFailed ? D.status.readFailed(m.readFailed.why) : m.stage === 'reading' ? D.status.reading : m.stage === 'working' ? D.status.working(working, m.needs)
421
- : D.status.last(started, m.needs);
422
- // S2: the status line (Last prepared), Check now, Settings and the way to the items with no repository are one menu
423
- const label = busy ? D.starting : reading ? D.stillReading : m.run ? D.again : D.prepare;
424
- const lines = [{ label: status, attrs: { 'data-day': 'status', 'aria-disabled': 'true' }, onSelect: () => {} }];
425
- if (m.tasks.length) {
426
- const c = { review: 0, done: 0, working: 0, failed: 0 };
427
- for (const t of m.tasks) {
428
- if (t.status === 'review') c.review++;
429
- else if (t.status === 'done' || t.status === 'sent') c.done++;
430
- else if (t.status === 'failed') c.failed++;
431
- else c.working++;
432
- }
433
- lines.push({ label: D.summary(c), attrs: { 'data-day': 'summary', 'aria-disabled': 'true' }, onSelect: () => {} });
434
- }
435
- if (m.run && m.check) {
436
- const every = m.settings && m.settings.dayCheck && typeof m.settings.dayCheck.every === 'number' ? m.settings.dayCheck.every : m.check.every;
437
- const running = !!m.check.running || ui.busy.has('check');
438
- lines.push({ label: every === 0 ? D.checkOff : running ? D.checking : D.checked(hhmm(m.check.last), hhmm(m.check.next)), attrs: { 'data-day': 'check', 'aria-disabled': 'true' }, onSelect: () => {} });
439
- if (every !== 0 && !running) lines.push({ label: D.checkNow, icon: 'refresh-cw', attrs: { 'data-day': 'check-now' }, onSelect: () => checkNow(ws) });
440
- }
441
- const items = [...lines, { sep: true },
442
- { label: D.sources, icon: 'settings', attrs: { 'data-day': 'sources', 'data-day-sel': 'sources:all' }, onSelect: () => select('sources', 'all') }];
443
- if (m.narrow) items.push({ label: D.menu.showAll, attrs: { 'data-day': 'show-all' }, onSelect: () => ctx.showAll() });
444
- const more = iconButton({ icon: 'ellipsis', ariaLabel: D.menu.label, size: 'sm', attrs: { 'data-day': 'bar-menu', 'aria-haspopup': 'menu', 'aria-current': ctx.cur('sources', 'all') },
445
- onClick: () => menu({ anchor: more, ariaLabel: D.menu.label, items }) });
446
- return el('header', { class: 'td-day__bar' },
447
- (() => { const when = dateLabel(m.now);
448
- return el('div', { class: 'td-day__hello', title: greet(m.now) + ' ' + when }, el('b', null, greet(m.now)), ' ', el('span', { class: 'td-day__dim' }, when)); })(),
449
- steps,
450
- el('span', { class: 'td-day__spacer', 'aria-hidden': 'true' }),
451
- button({ label, variant: 'primary', size: 'sm', disabled: busy || reading, attrs: { 'data-day': 'prepare', 'data-goals': 'prepare-day', title: D.prepareHint, 'aria-busy': busy ? 'true' : 'false' }, onClick: () => prepareDay(ws) }),
452
- more,
453
- iconButton({ icon: 'chevron-down', ariaLabel: D.fold, size: 'sm', expanded: true, attrs: { 'data-day': 'toggle' }, onClick: () => fold(false) }));
454
- }
455
-
456
- function runLine(ctx) {
457
- const r = runs.get(ctx.ws);
458
- if (!r || r.state === 'busy') return null;
459
- const text = r.state === 'failed' ? D.runFailed(r.error) : r.state === 'running' ? D.runRunning : D.runStarted(hhmm(r.at));
460
- return el('p', { class: 'td-day__run' + (r.state === 'failed' ? ' td-day__run--failed' : ''), 'data-day': 'run', 'data-goals': 'run', 'data-run': r.state,
461
- role: r.state === 'failed' ? 'alert' : 'status' }, text);
462
- }
463
-
464
- /* ── the left column ──────────────────────────────────────────────────────────────────────────────────────────── */
465
-
466
- /** A selectable row of a list: the row primitive. `lead` and `trail` are nodes or text; the row carries data-day-sel. */
467
- function rowBtn(ctx, type, id, { lead, title, meta, trail, dot }, mods) {
468
- const cur = ctx.cur(type, String(id));
469
- return el('li', null, row({
470
- title, meta: meta ? [meta] : null, onOpen: () => select(type, id),
471
- lead: [dot || null, lead !== undefined && lead !== null && lead !== '' ? el('span', { class: 'td-day__lead' }, lead) : null].filter(Boolean),
472
- trail: [trail || null].filter(Boolean),
473
- attrs: { class: 'td-day__r', 'data-day-sel': type + ':' + id, 'data-cur': cur, ...(mods || {}) },
474
- openAttrs: { 'aria-current': cur },
475
- }));
476
- }
477
-
478
- function eventChip(e) {
479
- if (e.ended) return e.notes && (e.notes.wispr || e.notes.mail) ? pill(D.pill.notes, 'ok') : pill(D.pill.ended, '');
480
- if (e.prep) return pill(D.pill.prepare, 'warn');
481
- if (e.steps && e.steps.before && e.steps.before.length) return pill(D.pill.ready, '');
482
- return null;
483
- }
484
-
485
- function calendar(ctx) {
486
- const { m } = ctx;
487
- if (!m.events.length) return panel('calendar', null, note(m.run && m.stage === 'reading' ? D.readingJobs : D.noCalendar));
488
- return panel('calendar', null, calendarRows(ctx));
489
- }
490
-
491
- /** Today's meetings from the brief, with a line at the current time: the agenda of today, and the calendar panel. */
492
- function calendarRows(ctx) {
493
- const { m } = ctx;
494
- if (!m.events.length) return null;
495
- const rows = [];
496
- let nowShown = false;
497
- const nowRow = () => el('li', { class: 'td-day__nowrow', 'data-day': 'now', 'aria-hidden': 'true' }, D.now(hhmm(m.now)));
498
- for (const e of m.events) {
499
- if (!nowShown && e.s > m.now) { rows.push(nowRow()); nowShown = true; }
500
- const n = e.gid ? m.goalNo.get(e.gid) : null;
501
- rows.push(rowBtn(ctx, 'event', e.id, { lead: e.time, title: e.title, meta: e.purpose || e.with || '',
502
- trail: el('span', { class: 'td-day__chips' }, n ? pill(D.pill.goal(n), 'goal') : null, eventChip(e)) },
503
- { 'data-past': e.ended ? 'true' : null, 'data-goal-tie': n ? 'true' : null }));
504
- }
505
- if (!nowShown) rows.push(nowRow());
506
- return el('ul', { class: 'td-day__rows', 'data-day-list': 'calendar' }, ...rows);
507
- }
508
-
509
- /* The Agenda month (G25 to G27): today-agenda.js draws it with the helpers of this section. An older workspace server
510
- * has no agenda route: then the day's calendar panel shows, as before. */
511
- function agenda(ctx) {
512
- const h = { panel, sel: ui.sel, todayRows: () => calendarRows(ctx), rowBtn: (type, id, parts, mods) => rowBtn(ctx, type, id, parts, mods) };
513
- return agendaPanel(ctx, h) || calendar(ctx);
514
- }
515
-
516
- function jobRow(ctx, j) {
517
- const n = j.goal ? ctx.m.goalNo.get(j.goal) : null;
518
- const sub = j.status === 'failed' && j.task && j.task.error ? j.task.error
519
- : [j.item && j.item.where, srcName(j.source)].filter(Boolean).join(' · ');
520
- const mine = j.status === 'you';
521
- const due = mine && j.item && j.item.due ? Date.parse(j.item.due) : NaN;
522
- const held = mine && j.mark && j.mark.state === 'waiting' ? `${A.hold.replace('…', '')} ${j.mark.on}` : sub;
523
- // J1: the row says who acts, in words and with a square (open for the PM, filled for the agent)
524
- const who = whoActs(j);
525
- const meta = [who.text, held].filter(Boolean).join(' · ');
526
- return rowBtn(ctx, 'job', j.id, { lead: mine ? verbChip(verbOf(j.item)) : n ? D.pill.goal(n) : '·', title: j.title, meta,
527
- trail: el('span', { class: 'td-day__chips' }, repoTag(ctx.m, j.repo), mine ? dueChip(ctx.m, j.mark, due, false) : statusPill(j)),
528
- dot: el('span', { class: 'td-day__marks2' }, whoMark(who.who), j.isNew && !seen.has(j.id) ? el('span', { class: 'td-day__newdot', 'data-day': 'new', role: 'img', 'aria-label': D.newItem }) : null) },
529
- { 'data-who': who.who });
530
- }
531
-
532
- /* What the repositories owe the PM outside today's jobs (outcome checks, report drafts, sessions) are jobs too: each one is a
533
- * row of Needs you, and pressing it shows its card, with the card's own buttons, in the detail column. The Agenda has no
534
- * separate section for them. */
535
- function owedItems(owed) {
536
- if (!owed || !owed.list) return [];
537
- return [...owed.list.children].filter((n) => n.getAttribute && n.getAttribute('data-today-id')).map((n) => {
538
- const cause = n.querySelector('[data-today-cause]');
539
- const ev = n.querySelector('.td-card__evidence');
540
- const text = ((cause || n).textContent || '').trim().replace(/\s+/g, ' ');
541
- return { id: n.getAttribute('data-today-id'), node: n, title: text, meta: ev ? ev.textContent.trim().replace(/\s+/g, ' ') : '' };
542
- });
543
- }
544
-
545
- /** A meeting to prepare for, as a row of the jobs (PRD D4): it selects the meeting. */
546
- function prepRow(ctx, e) {
547
- const total = e.before.length; const d = e.before.filter((x) => x.done).length;
548
- return rowBtn(ctx, 'event', e.id, { lead: verbChip('prepare'), title: e.title, meta: [total ? A.readiness(d, total) : null, e.with || null].filter(Boolean).join(' · '),
549
- trail: dueChip(ctx.m, e.mark, e.s, true) }, { 'data-day-prep': e.id });
550
- }
551
-
552
- function owedRow(ctx, o) {
553
- return rowBtn(ctx, 'owed', o.id, { lead: '·', title: o.title, meta: o.meta, trail: pill(A.chip.today, 'warn', { 'data-day-status': 'you' }) });
554
- }
555
-
556
- // Needs you holds only what the PM can do now (PRD D1): snoozed, held and done items fold into groups of their own.
557
- const JOB_GROUPS = ['needs', 'later', 'waiting', 'working', 'done', 'worth'];
558
- const FOLDED = new Set(['later', 'waiting', 'done']);
559
- function jobsPanel(ctx) {
560
- const { m } = ctx;
561
- const owed = ctx.owed;
562
- if (!m.jobs.length && !owed.length && !m.preps.length) return panel('jobs', null, note(m.run && m.stage === 'reading' ? D.readingJobs : D.noJobs, { 'data-day': 'no-jobs' }));
563
- const groups = JOB_GROUPS.map((g) => [g, m.jobs.filter((j) => j.group === g), m.preps.filter((e) => e.group === g)])
564
- .filter(([g, l, p]) => l.length || p.length || (g === 'needs' && owed.length));
565
- return panel('jobs', D.jobsCount(m.needs + owed.length, m.done), ...groups.map(([g, l, p]) => {
566
- const count = l.length + p.length + (g === 'needs' ? owed.length : 0);
567
- const label = A.groups[g] && g !== 'done' ? A.groups[g] : g === 'done' ? A.groups.done : D.groups[g];
568
- const foldable = FOLDED.has(g);
569
- const shut = foldable && !ui.groupsOpen.has(g);
570
- const head = foldable
571
- ? button({ label: `${label} · ${count}`, variant: 'ghost', size: 'sm', iconEnd: shut ? 'chevron-right' : 'chevron-down', attrs: { class: 'td-day__fold-head', 'aria-expanded': shut ? 'false' : 'true', 'data-day-fold': g },
572
- onClick: () => { if (shut) ui.groupsOpen.add(g); else ui.groupsOpen.delete(g); rerender(); } })
573
- : el('div', { class: 'td-day__gh' }, label, pill(String(count), ''));
574
- return el('div', { class: 'td-day__group', 'data-day-group': g }, head,
575
- shut ? null : el('ul', { class: 'td-day__rows', 'data-day-list': 'jobs-' + g }, ...p.map((e) => prepRow(ctx, e)), ...l.map((j) => jobRow(ctx, j)), ...(g === 'needs' ? owed.map((o) => owedRow(ctx, o)) : [])));
576
- }));
577
- }
578
-
579
- /* What waits for the PM outside today's jobs (the Today cards: outcome checks, reports, sessions). Today hands its list
580
- * in, so the cards keep their own controls and the open day shows one layout. */
581
- function goalsPanel(ctx) {
582
- const { m } = ctx;
583
- // a goal of another repository is not lost: the panel says how many the Show switch hides, with the way to them
584
- const hidden = m.hiddenGoals ? el('p', { class: 'td-day__note', 'data-day': 'goals-hidden' }, D.repo.hiddenGoals(m.hiddenGoals) + ' ',
585
- button({ label: D.repo.showAll, variant: 'ghost', size: 'sm', attrs: { 'data-day': 'show-all' }, onClick: () => ctx.showAll() })) : null;
586
- return panel('goals', D.goalsCount(m.allGoals.filter((g) => g.status === 'open').length, m.maxGoals), goalRows(ctx), hidden, goalAdd(ctx), jobsWithoutGoal(ctx));
587
- }
588
-
589
- function mentionStatus(j) {
590
- if (j.group === 'done') return pill(D.status2.handled, 'ok');
591
- if (j.status === 'you' && j.mark && j.mark.state) return dueChip({ now: Date.now() }, j.mark, NaN, false);
592
- if (j.status === 'you') return j.item && j.item.reply_needed ? pill(D.status2.replyNeeded, 'warn', { 'data-day-status': 'you' }) : verbChip(verbOf(j.item));
593
- return statusPill(j);
594
- }
595
-
596
- function digestRow(ctx, g) {
597
- const sub = D.digestLine(D.levelWord[g.level] || g.level, (g.decisions || []).length, (g.open || []).length);
598
- return rowBtn(ctx, 'channel', g.id, { lead: el('span', { class: 'td-day__chip' }, srcName(g.source)), title: g.name, meta: sub, trail: repoTag(ctx.m, g.repo) });
599
- }
600
-
601
- function mentionsPanel(ctx) {
602
- const { m } = ctx;
603
- const svcs = [...new Set(m.mentions.map((j) => j.source))];
604
- if (ui.mtab !== 'all' && !svcs.includes(ui.mtab)) ui.mtab = 'all';
605
- const need = m.mentions.filter((j) => j.group === 'needs').length;
606
- const mtabs = m.mentions.length ? tabs({ variant: 'line', role: 'tablist', ariaLabel: D.panels.mentions, value: ui.mtab, attrs: { 'data-day': 'mtabs' },
607
- items: ['all', ...svcs].map((v) => ({ id: v, label: v === 'all' ? D.all : srcName(v), count: v === 'all' ? m.mentions.length : m.mentions.filter((j) => j.source === v).length })),
608
- onChange: (v) => { ui.mtab = v; rerender(); } }) : null;
609
- const shown = m.mentions.filter((j) => ui.mtab === 'all' || j.source === ui.mtab);
610
- const rows = shown.length ? el('ul', { class: 'td-day__rows', 'data-day-list': 'mentions' }, ...shown.map((j) => {
611
- const it = j.item;
612
- // Slack, Confluence and Figma draw as a card of their own (PRD M1); the press, the link and the status are the row's
613
- if (hasCard(j.source)) return rowBtn(ctx, 'mention', j.id, { title: mentionCard(j, srcName(j.source)), trail: el('span', { class: 'td-day__chips' }, repoTag(ctx.m, j.repo), mentionStatus(j)) }, { 'data-mention-card': j.source });
614
- return rowBtn(ctx, 'mention', j.id, { lead: el('span', { class: 'td-day__chip' }, srcName(j.source)),
615
- title: it.about && it.ask ? `${it.about}: ${it.ask}` : it.ask || j.title, meta: D.fromWho(it.who, it.where) || it.why_now || '', trail: el('span', { class: 'td-day__chips' }, repoTag(ctx.m, j.repo), mentionStatus(j)) });
616
- })) : note(D.noMentions);
617
- const live = m.digests.filter((g) => g.level !== 'ignore');
618
- const ign = m.digests.filter((g) => g.level === 'ignore');
619
- const dig = m.digests.length ? el('div', { class: 'td-day__group', 'data-day-group': 'watched' },
620
- el('div', { class: 'td-day__gh' }, D.watched, pill(String(live.length), '')),
621
- live.length ? el('ul', { class: 'td-day__rows', 'data-day-list': 'digests' }, ...live.map((g) => digestRow(ctx, g))) : null,
622
- ign.length ? button({ label: ui.showIgnDigests ? D.hideIgnored : D.showIgnored(ign.length), variant: 'ghost', size: 'sm',
623
- attrs: { 'data-day': 'show-ignored', 'aria-expanded': ui.showIgnDigests ? 'true' : 'false' }, onClick: () => { ui.showIgnDigests = !ui.showIgnDigests; rerender(); } }) : null,
624
- ign.length && ui.showIgnDigests ? el('ul', { class: 'td-day__rows', 'data-day-list': 'ignored' }, ...ign.map((g) => digestRow(ctx, g))) : null) : null;
625
- return panel('mentions', m.mentions.length ? D.mentionsCount(m.mentions.length, need) : null, mtabs, rows, dig);
626
- }
627
-
628
- /* ── act and prepare (initiative today-act-prepare) ─────────────────────────────────────────────────────────────── */
629
-
630
- const MIN_MS = 60000;
631
- const clockAt = (ms, hh, mm) => { const d = new Date(ms); return new Date(d.getFullYear(), d.getMonth(), d.getDate(), hh, mm).getTime(); };
632
- const sameDay = (a, b) => new Date(a).toDateString() === new Date(b).toDateString();
633
- const verbOf = (it) => (it && A.verb[it.verb] ? it.verb : it && it.reply_needed ? 'reply' : 'do');
634
- function verbChip(verb) {
635
- return el('span', { class: 'td-day__verb', 'data-verb': verb, 'data-day': 'verb' }, A.verb[verb] || A.verb.do);
636
- }
637
- /** The chip at the end of a row the PM acts on: where its mark left it, else its due time, coloured by time left. */
638
- function dueChip(m, mark, due, prep) {
639
- const st = mark && mark.state;
640
- const at = (v) => hhmm(v);
641
- if (st === 'snoozed') return pill(A.back(at(mark.until)), '', { 'data-day-status': 'snoozed' });
642
- if (st === 'waiting') return pill(A.check(at(mark.until)), '', { 'data-day-status': 'waiting' });
643
- if (st === 'done') return pill(prep ? A.chip.ready : A.chip.done, 'ok', { 'data-day-status': 'marked-done' });
644
- if (st === 'dismissed') return pill(prep ? A.chip.skipped : A.chip.dismissed, '', { 'data-day-status': 'dismissed' });
645
- const status = prep ? 'prepare' : 'you';
646
- if (!Number.isFinite(due)) return pill(A.chip.today, 'warn', { 'data-day-status': status });
647
- const left = Math.round((due - m.now) / MIN_MS);
648
- return pill(prep ? A.at(at(due)) : A.by(at(due)), left < 60 ? 'bad' : left < 180 ? 'warn' : '', { 'data-day-status': status, title: A.left(left) });
649
- }
650
- /** The times a snooze can take, later today: [label, ms]. */
651
- function snoozeTimes(m, { due, start }) {
652
- const out = [];
653
- const add = (label, t) => { if (Number.isFinite(t) && t > m.now + 5 * MIN_MS && sameDay(t, m.now) && !out.some((x) => x[1] === t)) out.push([label, t]); };
654
- if (Number.isFinite(start)) { add(A.snoozeTo.m30, start - 30 * MIN_MS); add(A.snoozeTo.m15, start - 15 * MIN_MS); return out; }
655
- add(A.snoozeTo.hour, m.now + 60 * MIN_MS);
656
- if (Number.isFinite(due)) add(A.snoozeTo.due, due - 30 * MIN_MS);
657
- add(A.snoozeTo.later, clockAt(m.now, 16, 0));
658
- add(A.snoozeTo.end, clockAt(m.now, 17, 30));
659
- return out;
660
- }
661
- /** The banner of a marked item: what the mark is, and the press that undoes it. */
662
- function markBanner(ctx, id, mark, prep) {
663
- if (!mark) return null;
664
- if (mark.back) return note(A.state.back, { 'data-day': 'mark-back' });
665
- const st = mark.state;
666
- if (!st) return null;
667
- const text = st === 'snoozed' ? A.state.snoozed(hhmm(mark.until)) : st === 'waiting' ? A.state.waiting(mark.on, hhmm(mark.until))
668
- : st === 'done' ? (prep ? A.state.ready : A.state.done)(hhmm(mark.at)) : A.state.dismissed(A.why[mark.why] || mark.why);
669
- return el('div', { class: 'td-day__mark', 'data-day': 'mark', 'data-day-mark-state': st }, el('span', null, text),
670
- button({ label: st === 'done' ? A.reopen : A.bringBack, size: 'sm', attrs: { 'data-day-mark': 'reopen' }, onClick: () => markPress(ctx.ws, id, { action: 'reopen' }, A.did.reopen) }));
671
- }
672
- /** The steps the PM checks off. A step the brief already marked done stays done. A step that reads a source shows what
673
- * the source says under it (PRD X2), and a note step holds the PM's own note (PRD F3), so no other file needs opening. */
674
- function stepChecks(ctx, id, steps, { refs = [], mark = null, focus = false } = {}) {
675
- if (!steps.length) return null;
676
- const F = A.focus;
677
- // focus (the meeting detail, today-meeting-focus F2): only one step is open, the PM's own pick or else the first step left
678
- const want = focus ? ui.cur.get(id) : null;
679
- const cur = focus ? steps.find((x) => x.t === want) || steps.find((x) => !x.done) || null : null;
680
- return el('ul', { class: 'td-day__steps2', 'data-day': 'steps' }, ...steps.map((st) => {
681
- const isCur = !focus || (!!cur && st.t === cur.t);
682
- const f = field({ kind: 'check', label: st.t, value: !!st.done, attrs: { 'data-day-step': st.t, disabled: st.fixed ? true : null },
683
- onCommit: (v) => markPress(ctx.ws, id, { action: 'step', step: st.t, done: !!v }) });
684
- const r = Number.isInteger(st.ref) ? refs[st.ref] : null;
685
- const noteEl = st.note && isCur ? noteBox(ctx, id, mark) : null;
686
- let press = null;
687
- if (focus && isCur && !st.done) {
688
- press = button({ label: F.press[st.note ? 'note' : r ? 'read' : 'do'], variant: 'primary', size: 'sm', attrs: { 'data-day-step-press': st.t, onMousedown: (ev) => ev.preventDefault() }, onClick: async () => {
689
- // the box losing focus may have started saving the note already: wait for that write, or this press is dropped as busy
690
- const prior = ui.inflight.get('mark:' + id);
691
- if (prior) await prior.catch(() => null);
692
- // a note typed in the box is saved first, in this press, so the box losing focus does not redraw the card under the pointer
693
- const ta = noteEl && noteEl.querySelector('textarea');
694
- if (ta && ta.value !== ((mark && mark.note) || '')) await markPress(ctx.ws, id, { action: 'note', text: ta.value }, A.noteSaved);
695
- ui.cur.delete(id);
696
- await markPress(ctx.ws, id, { action: 'step', step: st.t, done: true });
697
- } });
698
- }
699
- const opener = focus && !isCur && (r || st.note)
700
- ? iconButton({ icon: 'chevron-down', ariaLabel: `${F.openStep}: ${st.t}`, size: 'sm', attrs: { 'data-day-step-open': st.t, class: 'td-day__stepopen' }, onClick: () => { ui.cur.set(id, st.t); rerender(); } }) : null;
701
- return el('li', { class: 'td-day__step2', 'data-done': st.done ? 'true' : 'false', 'data-cur': focus ? String(isCur) : null },
702
- el('div', { class: 'td-day__steprow' }, f, st.who ? el('span', { class: 'td-day__who' }, D.who[st.who] || st.who) : null, opener),
703
- r && isCur ? refBlock(r, { open: !st.done, step: true }) : null,
704
- noteEl,
705
- press ? el('div', { class: 'td-day__acts' }, press) : null);
706
- }));
707
- }
708
- /** One source in a few lines, in the card: what it says, and a small link to the source for when the PM wants more. */
709
- function refBlock(r, { open, step } = {}) {
710
- return el('details', { class: 'td-day__ref', 'data-day': 'ref', open: open ? true : null },
711
- el('summary', null, el('span', null, (step ? A.refRead : '') + r.label), r.source ? el('span', { class: 'td-day__src' }, srcName(r.source)) : null),
712
- el('ul', { class: 'td-day__reflines' }, ...(r.lines || []).map((l) => el('li', null, l))),
713
- isUrl(r.link) ? extLink(A.refOpen, r.link, { 'data-day-link': 'ref' }) : null);
714
- }
715
- /** The sources no step names, under one heading. */
716
- function refsBlock(refs, steps) {
717
- const named = new Set(steps.map((st) => st.ref).filter(Number.isInteger));
718
- const rest = refs.filter((_, i) => !named.has(i));
719
- return rest.length ? el('div', { class: 'td-day__phase', 'data-day': 'refs' }, el('h4', null, A.refsTitle), ...rest.map((r) => refBlock(r, { open: false }))) : null;
720
- }
721
- /** The conversation, as the brief read it: at most 4 messages, the last one first in weight. */
722
- function threadBlock(thread) {
723
- if (!Array.isArray(thread) || !thread.length) return null;
724
- return el('div', { class: 'td-day__phase td-day__thread', 'data-day': 'thread' }, el('h4', null, A.threadTitle),
725
- ...thread.map((x, i) => el('div', { class: 'td-day__msg' + (i === thread.length - 1 ? ' td-day__msg--last' : '') },
726
- el('div', { class: 'td-day__src' }, [x.who, x.at].filter(Boolean).join(' · ')), el('p', null, x.text))));
727
- }
728
- /** The PM's own note on a meeting, saved with its marks when the box loses focus. Nothing is sent. */
729
- function noteBox(ctx, id, mark) {
730
- const f = field({ label: A.noteTitle, kind: 'textarea', value: (mark && mark.note) || '', placeholder: A.noteHint, attrs: { maxlength: '1000', 'data-day-input': 'note' },
731
- onCommit: (v) => markPress(ctx.ws, id, { action: 'note', text: v }, A.noteSaved) });
732
- return el('div', { class: 'td-day__notebox', 'data-day': 'note' }, f, el('span', { class: 'td-day__dim' }, A.noteStays));
733
- }
734
- /** Where the PM's own answer goes, and the box to write it in (PRD F1, F2). The press is the approval: the agent posts
735
- * exactly this text, as the PM, to the place the item names. */
736
- function composer(ctx, j, verb) {
737
- const it = j.item || {};
738
- const sd = it.send || {};
739
- const to = sd.to || it.where || srcName(j.source);
740
- const review = !!sd.review;
741
- const busy = ui.busy.has('send:' + j.id);
742
- const f = field({ label: A.compose[verb] || A.compose.reply, kind: 'textarea', value: ui.compose.get(j.id) || '', placeholder: A.composeHint,
743
- attrs: { maxlength: '4000', rows: '4', 'data-day-input': 'compose' } });
744
- const ta = f.control;
745
- ta.addEventListener('input', () => { ui.compose.set(j.id, ta.value); });
746
- const chips = (sd.suggest || []).length ? el('div', { class: 'td-day__chipsrow', 'data-day': 'suggest' }, el('span', { class: 'td-day__dim' }, A.startFrom),
747
- ...sd.suggest.map((t, i) => button({ label: t.length > 60 ? t.slice(0, 57) + '…' : t, size: 'sm', variant: 'ghost', attrs: { 'data-day-suggest': String(i), title: t },
748
- onClick: () => { ta.value = t; ui.compose.set(j.id, t); ta.focus(); } }))) : null;
749
- const verdict = ui.verdict.get(j.id) || null;
750
- const toggle = review ? tabs({ variant: 'segmented', role: 'radiogroup', ariaLabel: A.verdictLabel, value: verdict, attrs: { 'data-day': 'verdict' },
751
- items: [{ id: 'approve', label: A.verdict.approve }, { id: 'changes', label: A.verdict.changes }], onChange: (k) => { ui.verdict.set(j.id, k); rerender(); } }) : null;
752
- const go = () => {
753
- const text = (ui.compose.get(j.id) || ta.value || '').trim();
754
- if (!text) { toast({ text: A.sendNeed, tone: 'destructive' }); return; }
755
- if (review && !verdict) { toast({ text: A.verdictNeed, tone: 'destructive' }); return; }
756
- sendPress(ctx.ws, j, { text, verdict: review ? verdict : undefined }, to);
757
- };
758
- return el('div', { class: 'td-day__compose', 'data-day': 'compose' }, f, chips, toggle,
759
- el('div', { class: 'td-day__acts' }, button({ label: tagged(review ? A.postReview(to) : A.sendTo(to), 'you'), variant: 'primary', size: 'sm', iconEnd: 'arrow-right', disabled: busy, attrs: { 'data-day-act': 'send' }, onClick: go })),
760
- el('span', { class: 'td-day__dim' }, A.sendNote));
761
- }
762
- /** The four presses of a job (Mark done, Snooze, Waiting on…, Not mine) or the three of a meeting (Mark ready, Remind
763
- * me, Skip prep). `strong` makes the first one the primary button: every step is checked. */
764
- function marksBar(ctx, { id, title, kind, due, start, strong }) {
765
- const { m, ws } = ctx;
766
- const prep = kind === 'event';
767
- const busy = ui.busy.has('mark:' + id);
768
- const st = (m.d && m.d.marks && m.d.marks[id] && m.d.marks[id].state) || null;
769
- const times = snoozeTimes(m, { due, start });
770
- const kids = [];
771
- if (st !== 'done') kids.push(button({ label: prep ? A.ready : tagged(A.done, 'you'), variant: strong ? 'primary' : 'outline', size: 'sm', icon: 'check', disabled: busy, attrs: { 'data-day-mark': 'done' },
772
- onClick: () => markPress(ws, id, { action: 'done' }, (prep ? A.did.ready : A.did.done)(title)) }));
773
- if (times.length) {
774
- const b = button({ label: prep ? A.remind : tagged(A.snooze, 'you'), size: 'sm', iconEnd: 'chevron-down', disabled: busy, attrs: { 'data-day-mark': 'snooze', 'aria-haspopup': 'menu' },
775
- onClick: () => menu({ anchor: b, ariaLabel: prep ? A.remind : A.snooze, items: times.map(([l, t]) => ({ label: `${l} · ${hhmm(t)}`, attrs: { 'data-day-snooze': hhmm(t) },
776
- onSelect: () => markPress(ws, id, { action: 'snooze', until: new Date(t).toISOString() }, A.did.snooze(hhmm(t))) })) }) });
777
- kids.push(b);
778
- }
779
- if (!prep) kids.push(button({ label: tagged(A.hold, 'you'), size: 'sm', disabled: busy, attrs: { 'data-day-mark': 'hold', 'aria-expanded': ui.holding === id ? 'true' : 'false' },
780
- onClick: () => { ui.holding = ui.holding === id ? null : id; ui.holdDraft = { who: '', when: 'h2' }; rerender(); } }));
781
- const reasons = prep ? ['nothing', 'elsewhere'] : ['no-action', 'someone-else', 'done-elsewhere'];
782
- if (st !== 'dismissed') {
783
- const nb = button({ label: prep ? A.skip : tagged(A.notMine, 'you'), size: 'sm', variant: 'ghost', iconEnd: 'chevron-down', disabled: busy, attrs: { 'data-day-mark': 'dismiss', 'aria-haspopup': 'menu' },
784
- onClick: () => menu({ anchor: nb, ariaLabel: prep ? A.skip : A.notMine, items: reasons.map((w) => ({ label: A.why[w], attrs: { 'data-day-why': w },
785
- onSelect: () => markPress(ws, id, { action: 'dismiss', why: w }, A.did.dismiss(A.why[w])) })) }) });
786
- kids.push(el('span', { class: 'td-day__grow', 'aria-hidden': 'true' }), nb);
787
- }
788
- return [el('div', { class: 'td-day__marks', 'data-day': 'marks', role: 'group', 'aria-label': title }, ...kids), ui.holding === id && !prep ? holdForm(ctx, id) : null];
789
- }
790
- function holdForm(ctx, id) {
791
- const { m } = ctx;
792
- const h2 = m.now + 120 * MIN_MS; const end = clockAt(m.now, 17, 30);
793
- const opts = [['h2', A.holdWhenOpts.h2, h2], ['end', A.holdWhenOpts.end, end]].filter(([, , t]) => t > m.now && sameDay(t, m.now));
794
- if (!opts.some((o) => o[0] === ui.holdDraft.when) && opts.length) ui.holdDraft.when = opts[0][0];
795
- const who = field({ label: A.holdWho, value: ui.holdDraft.who, placeholder: A.holdHint, attrs: { maxlength: '80', 'data-day-input': 'hold-who' } });
796
- who.control.addEventListener('input', () => { ui.holdDraft.who = who.control.value; });
797
- const go = () => {
798
- const v = (ui.holdDraft.who || '').trim();
799
- const o = opts.find((x) => x[0] === ui.holdDraft.when);
800
- if (!v || v.length > 80) { toast({ text: A.holdNeed, tone: 'destructive' }); return; }
801
- if (!o) return;
802
- markPress(ctx.ws, id, { action: 'hold', on: v, until: new Date(o[2]).toISOString() }, A.did.hold(v, hhmm(o[2])));
803
- };
804
- return el('div', { class: 'td-day__revise', 'data-day': 'hold' }, who,
805
- opts.length ? el('div', { class: 'td-day__ch' }, el('span', null, A.holdWhen), tabs({ variant: 'segmented', role: 'radiogroup', ariaLabel: A.holdWhen, value: ui.holdDraft.when,
806
- attrs: { 'data-day': 'hold-when' }, items: opts.map(([k, l, t]) => ({ id: k, label: `${l} (${hhmm(t)})` })), onChange: (k) => { ui.holdDraft.when = k; rerender(); } })) : null,
807
- el('div', { class: 'td-day__acts' }, button({ label: A.holdGo, variant: 'primary', size: 'sm', disabled: !opts.length, attrs: { 'data-day-act': 'hold-go' }, onClick: go }),
808
- button({ label: D.cancel, size: 'sm', variant: 'ghost', onClick: () => { ui.holding = null; rerender(); } })));
809
- }
810
- const open0 = (mark) => !mark || !mark.state;
811
- /** A link drawn as the primary button of a card. */
812
- function primaryLink(label, href, attrs) {
813
- return extLink(label, href, { class: 'td-day__a td-day__a--primary', ...(attrs || {}) });
814
- }
815
-
816
- /** The card of a job only the PM can do (PRD A1, C1, C2, M1, D3): the verb and one sentence, From and Why now, the
817
- * steps, the button that fits, the marks, and the rest of the context folded. */
818
- function actCard(ctx, j) {
819
- const { m } = ctx;
820
- const it = j.item || {};
821
- const mark = j.mark || null;
822
- const verb = verbOf(it);
823
- const todo = it.todo || it.how || it.ask || null;
824
- const checked = new Set((mark && mark.steps) || []);
825
- const steps = (Array.isArray(it.steps) ? it.steps : []).map((x) => (typeof x === 'string' ? { t: x } : x)).map((x) => ({ ...x, done: checked.has(x.t) }));
826
- const refs = Array.isArray(it.refs) ? it.refs : [];
827
- const canSend = open0(mark) && it.owner === 'pm' && isUrl(j.link) && (!!it.send || ['reply', 'review', 'decide', 'sign-off'].includes(verb));
828
- const due = it.due ? Date.parse(it.due) : NaN;
829
- const n = j.goal ? m.goalNo.get(j.goal) : null;
830
- const open = !mark || !mark.state;
831
- const allDone = steps.length > 0 && steps.every((x) => x.done);
832
- const reply = typeof it.reply_needed === 'boolean' ? (it.reply_needed ? D.yes : D.no) : null;
833
- const more = dl([[D.about, it.about || null], [D.ask, it.ask || null], [D.reply, reply], [D.how, todo === it.how ? null : it.how || null]]);
834
- return el('article', { class: 'td-day__job td-day__job--act', 'data-day-job': j.id, 'data-day-act-card': verb },
835
- el('div', { class: 'td-day__jobtop' }, el('span', { class: 'td-day__chips' }, verbChip(verb), el('span', { class: 'td-day__src' }, [srcName(j.source), n ? D.pill.goal(n) : null].filter(Boolean).join(' · '))),
836
- dueChip(m, mark, due, false)),
837
- el('h3', { class: 'td-day__acth' }, j.title),
838
- todo ? el('p', { class: 'td-day__todo', 'data-day': 'todo' }, todo) : null,
839
- markBanner(ctx, j.id, mark, false),
840
- dl([[D.where, A.from(it.who, it.where)], [D.why, it.why_now || null]]),
841
- threadBlock(it.thread),
842
- steps.length ? el('div', { class: 'td-day__phase' }, el('h4', null, A.howTitle(steps.filter((x) => x.done).length, steps.length)), stepChecks(ctx, j.id, steps, { refs })) : null,
843
- refsBlock(refs, steps),
844
- canSend ? composer(ctx, j, verb) : null,
845
- open ? el('div', { class: 'td-day__acts', 'data-day': 'cta' },
846
- (canSend ? extLink : primaryLink)(A.open[j.source] || A.openLink, j.link, { 'data-day-link': 'conversation' }),
847
- j.item && j.item.owner === 'pm' ? button({ label: tagged(A.draft, 'agent'), size: 'sm', disabled: ui.busy.has('draft:' + j.id), attrs: { 'data-day-act': 'draft' }, onClick: () => draftPress(ctx.ws, j) }) : null) : null,
848
- marksBar(ctx, { id: j.id, title: j.title, kind: 'item', due, strong: allDone }),
849
- more ? el('details', { class: 'td-day__fold', 'data-day': 'more' }, el('summary', null, A.more), more, note(A.readOnly)) : null);
850
- }
851
-
852
- /** Free minutes from now to the meeting's start, less the other meetings in between. */
853
- function freeBefore(m, e) {
854
- if (!Number.isFinite(e.s) || e.s <= m.now) return 0;
855
- let busy = 0;
856
- for (const o of m.events) {
857
- if (o.id === e.id) continue;
858
- const a = Math.max(o.s, m.now); const b = Math.min(o.f, e.s);
859
- if (b > a) busy += b - a;
860
- }
861
- return Math.max(0, Math.round((e.s - m.now - busy) / MIN_MS));
862
- }
863
-
864
- /** A meeting's prep (today-act-prepare A1, C1, M1, M6, D2; today-meeting-focus F1 to F3): the prep sentence, one line of how
865
- * ready the PM is, the Before steps with only the first open one expanded, and the one primary press that fits. The
866
- * other presses are in More. `fold` (the meeting has started) folds all of it under one line. */
867
- function prepBlock(ctx, e, { fold = false } = {}) {
868
- const { m } = ctx;
869
- const F = A.focus;
870
- const steps = e.before.map((st) => ({ t: String(st.t || ''), who: st.who, done: st.done, ref: st.ref, note: !!st.note, fixed: !!(e.steps && e.steps.before && e.steps.before.find((x) => x.t === st.t && x.done)) }));
871
- const refs = Array.isArray(e.refs) ? e.refs : [];
872
- const d = steps.filter((x) => x.done).length; const total = steps.length;
873
- const left = total - d;
874
- const free = freeBefore(m, e);
875
- const tight = !!left && free < left * 15;
876
- const open = !e.mark || !e.mark.state;
877
- const link = Array.isArray(e.links) ? e.links.find((l) => isUrl(l.url)) : null;
878
- const body = el('div', { class: 'td-day__prep', 'data-day': 'prep' },
879
- e.prep ? el('p', { class: 'td-day__todo', 'data-day': 'todo' }, e.prep) : null,
880
- markBanner(ctx, e.id, e.mark, true),
881
- total ? el('div', { class: 'td-day__ready', 'data-day': 'readiness' }, meter({ done: d, total, label: F.before(d, total, e.time) }),
882
- e.ended ? null : left ? el('span', { class: 'td-day__free', 'data-tight': String(tight), title: tight ? A.fit.short(left, free) : A.fit.time(left, free) }, F.free(free)) : el('span', { class: 'td-day__dim' }, A.fit.ok)) : null,
883
- stepChecks(ctx, e.id, steps, { refs, mark: e.mark, focus: true }),
884
- refsBlock(refs, steps),
885
- open && link && left && !e.ended ? el('div', { class: 'td-day__acts', 'data-day': 'cta' }, extLink((link.label || link.url) + ' ↗', link.url, { 'data-day-link': 'prep' })) : null,
886
- open && !left ? el('div', { class: 'td-day__acts', 'data-day': 'marks' }, button({ label: A.ready, variant: 'primary', size: 'sm', icon: 'check', disabled: ui.busy.has('mark:' + e.id), attrs: { 'data-day-mark': 'done' },
887
- onClick: () => markPress(ctx.ws, e.id, { action: 'done' }, A.did.ready(e.title)) })) : null);
888
- return fold ? el('details', { class: 'td-day__fold td-day__prepfold', 'data-day': 'prep-fold' }, el('summary', null, F.prepFold(d, total)), body) : body;
889
- }
890
-
891
- /** The presses that are rarely needed, in one menu (today-meeting-focus F4): Mark ready while steps are left, Remind me, Skip
892
- * prep, the key mark and, from `extra`, Add as a goal. Each press writes the same record, with the same toast and Undo, as before. */
893
- function moreMenu(ctx, e, extra) {
894
- const { m, ws } = ctx;
895
- const F = A.focus;
896
- const st = e.mark && e.mark.state;
897
- const items = [];
898
- if (e.hadPrep) {
899
- const left = e.before.filter((x) => !x.done).length;
900
- if (st !== 'done' && left > 0) items.push({ label: A.ready, attrs: { 'data-day-mark': 'done' }, onSelect: () => markPress(ws, e.id, { action: 'done' }, A.did.ready(e.title)) });
901
- for (const [l, t] of snoozeTimes(m, { start: e.s })) {
902
- items.push({ label: F.remindAt(l, hhmm(t)), attrs: { 'data-day-mark': 'snooze', 'data-day-snooze': hhmm(t) },
903
- onSelect: () => markPress(ws, e.id, { action: 'snooze', until: new Date(t).toISOString() }, A.did.snooze(hhmm(t))) });
904
- }
905
- if (st !== 'dismissed') for (const w of ['nothing', 'elsewhere']) items.push({ label: F.skipWhy(A.why[w]), attrs: { 'data-day-mark': 'dismiss', 'data-day-why': w },
906
- onSelect: () => markPress(ws, e.id, { action: 'dismiss', why: w }, A.did.dismiss(A.why[w])) });
907
- }
908
- const rest = [...keyItems(e.id), ...extra];
909
- if (items.length && rest.length) items.push({ sep: true });
910
- items.push(...rest);
911
- if (!items.length) return null;
912
- const b = button({ label: F.more, size: 'sm', variant: 'ghost', iconEnd: 'chevron-down', attrs: { 'data-day': 'more-menu', 'aria-haspopup': 'menu' },
913
- onClick: () => menu({ anchor: b, ariaLabel: F.more, items }) });
914
- return b;
915
- }
916
-
917
- /* ── the right column ─────────────────────────────────────────────────────────────────────────────────────────── */
918
-
919
- function dhead(kind, title) {
920
- return el('div', { class: 'td-day__dhead' }, el('span', { class: 'td-day__kind' }, kind), title ? el('h3', null, title) : null);
921
- }
922
- function relRow(ctx, type, id, label, lead, j) {
923
- return rowBtn(ctx, type, id, { lead: lead || '', title: label, trail: j ? statusPill(j) : null });
924
- }
925
-
926
- function stepItem(st) {
927
- const who = st && (st.who === 'pm' || st.who === 'agent') ? st.who : null;
928
- return el('span', { class: 'td-day__stepline' + (st && st.done ? ' td-day__stepline--done' : who === 'pm' ? ' td-day__stepline--you' : '') },
929
- String((st && st.t) || ''), who ? el('span', { class: 'td-day__who' }, D.who[who]) : null);
930
- }
931
-
932
- function eventDetail(ctx, e) {
933
- const { m } = ctx;
934
- const F = A.focus;
935
- const g = e.gid ? m.allGoals.find((x) => x.id === e.gid) || null : null;
936
- const n = g ? m.goalNo.get(g.id) : null;
937
- const ini = e.initiative && e.initiative.id ? e.initiative : null;
938
- const steps = e.steps || {};
939
- const notes = e.notes || {};
940
- const w = notes.wispr || null;
941
- const mail = notes.mail || null;
942
- const started = Number.isFinite(e.s) && e.s <= m.now && !e.ended;
943
- const facts = meetingFacts(e.id);
944
- const mailBlock = mail ? el('div', { class: 'td-day__notes', 'data-day': 'mail' }, el('div', { class: 'td-day__src' }, D.mail, ' · ', mail.from || '', ' ', isUrl(mail.link) ? el('a', { href: mail.link, target: '_blank', rel: 'noopener noreferrer' }, D.openLink) : null),
945
- el('p', null, el('b', null, (mail.subject || '') + '. '), mail.gist || '')) : null;
946
- const after = e.ended ? el('div', { class: 'td-day__notes', 'data-day': 'notes' }, el('h4', null, D.notesTitle),
947
- w ? [el('div', { class: 'td-day__src' }, D.wispr, ' ', isUrl(w.link) ? el('a', { href: w.link, target: '_blank', rel: 'noopener noreferrer' }, D.openLink) : null),
948
- w.summary ? el('p', null, w.summary) : null,
949
- list(D.decisions, (w.decisions || []).map(String), 'td-day__chk--ok'),
950
- list(D.actions, (w.actions || []).map((a) => (typeof a === 'string' ? a : stepItem(a))))] : note(D.noWispr),
951
- mailBlock || note(D.noMail)) : null;
952
- const tie = g ? el('p', { class: 'td-day__goalline', 'data-day': 'tie' }, D.countsToward(n, g.text)) : null;
953
- const addGoalItem = !g && m.allGoals.length < m.maxGoals
954
- ? [{ label: D.addAsGoal, attrs: { 'data-day-act': 'add-goal' }, onSelect: async () => { if (await addGoal(ctx, e.title, ini ? ini.id : null, { event_id: e.id })) toast({ text: D.goalAdded }); } }] : [];
955
- // the one line under the title: the time, how many people join, and a star for a key meeting (F5)
956
- const meta = [`${e.time}${e.end ? '–' + hhmm(e.end) : ''}`, facts && facts.people ? F.people(facts.people) : null, facts && facts.key ? F.key : null].filter(Boolean).join(' · ');
957
- const duringAfter = [list(D.phases.during, (steps.during || []).map(stepItem)), list(D.phases.after, (steps.after || []).map(stepItem))];
958
- const links = Array.isArray(e.links) && e.links.length ? el('div', { class: 'td-day__acts', 'data-day': 'links' }, ...e.links.map((l) => extLink((l.label || l.url) + ' ↗', l.url))) : null;
959
- const details = [
960
- e.with ? peopleLinks(ctx.ws, e.with, { 'data-day': 'people' }) : null,
961
- memoryBlock(e.id, { compact: true }),
962
- ini ? el('div', { class: 'td-day__ini', 'data-day': 'initiative' }, el('span', null, D.initiative + ': ', el('b', { class: 'td-day__mono' }, ini.id), ini.why ? el('span', { class: 'td-day__dim' }, ' (' + D.suggested(ini.why) + ')') : null),
963
- ctx.openIni ? button({ label: D.openInitiative, size: 'sm', variant: 'ghost', attrs: { 'data-day-act': 'open-initiative' }, onClick: () => ctx.openIni(ini.id) }) : null) : null,
964
- tie,
965
- duringAfter,
966
- e.ended ? null : mailBlock,
967
- links,
968
- ];
969
- const more = moreMenu(ctx, e, addGoalItem);
970
- return [
971
- el('div', { class: 'td-day__dhead' }, el('span', { class: 'td-day__kind td-day__meta', 'data-day': 'meta' }, meta), el('h3', null, e.title)),
972
- e.ended ? el('p', { class: 'td-day__ended', 'data-day': 'ended', role: 'status' }, pill(D.pill.ended, ''), ' ', A.endedAt(hhmm(e.end || e.f))) : null,
973
- e.purpose ? el('p', { class: 'td-day__purpose', 'data-day': 'purpose' }, e.purpose) : null,
974
- started ? notesBlock(e, { ws: ctx.ws, initiative: ini, mode: 'live', liveText: F.live }) : null,
975
- e.hadPrep ? prepBlock(ctx, e, { fold: started }) : null,
976
- g ? goalJobsBlock(ctx, g, n) : null,
977
- after,
978
- started ? null : notesBlock(e, { ws: ctx.ws, initiative: ini, mode: 'quiet' }),
979
- el('div', { class: 'td-day__foot', 'data-day': 'foot' },
980
- el('details', { class: 'td-day__fold td-day__details', 'data-day': 'details' }, el('summary', null, F.details), ...details),
981
- more),
982
- ];
983
- }
984
-
985
- function jobCard(ctx, j) {
986
- if (j.status === 'you') return actCard(ctx, j);
987
- const { m, ws } = ctx;
988
- const t = j.task;
989
- const it = j.item || {};
990
- const n = j.goal ? m.goalNo.get(j.goal) : null;
991
- const busy = t && ui.busy.has(t.id);
992
- const revs = t && Array.isArray(t.revisions) ? t.revisions.length : 0;
993
- const statusNote = { notStarted: D.notTask, waiting: D.waitingNote, working: D.workingNote, sending: D.sendingNote }[j.status]
994
- || (j.status === 'done' && j.kind === 'auto' ? D.autoNote : null);
995
- // J5: a finished job shows its result (the run's summary and draft) inside the job; there is no separate Result section
996
- const finished = !!t && (j.status === 'done' || j.status === 'sent');
997
- const draft = t && t.draft ? el('div', { class: 'td-day__draftbox', 'data-day': finished ? 'result' : 'draft' }, el('h4', null, finished ? D.result : D.draft),
998
- t.draft.summary ? el('p', null, t.draft.summary) : null,
999
- t.draft.body ? el('pre', { class: 'td-day__draft' }, t.draft.body) : null) : null;
1000
- const acts = [];
1001
- const canRevise = t && (j.status === 'review' || j.status === 'done') ;
1002
- if (t && j.status === 'review' && j.kind === 'approve') acts.push(button({ label: tagged(D.approve, 'you'), variant: 'primary', size: 'sm', disabled: busy, attrs: { 'data-day-act': 'approve' }, onClick: () => decide(ws, t, 'approve') }));
1003
- if (t && j.kind === 'auto' && (j.status === 'review' || (j.status === 'done' && !t.decided))) acts.push(button({ label: tagged(D.approveAuto, 'you'), size: 'sm', disabled: busy, attrs: { 'data-day-act': 'approve' }, onClick: () => decide(ws, t, 'approve') }));
1004
- if (canRevise && !ui.revising.has(t.id)) acts.push(button({ label: tagged(D.revise, 'agent'), size: 'sm', disabled: busy, attrs: { 'data-day-act': 'revise' }, onClick: () => { ui.revising.add(t.id); rerender(); } }));
1005
- if (t && j.status === 'failed') acts.push(button({ label: tagged(D.retry, 'agent'), variant: 'primary', size: 'sm', disabled: busy, attrs: { 'data-day-act': 'retry' }, onClick: () => decide(ws, t, 'retry') }));
1006
- acts.push(extLink(D.openConversation, j.link, { 'data-day-link': 'conversation' }));
1007
- if (t && t.draft) acts.push(extLink(D.openDraft, t.draft.link, { 'data-day-link': 'draft' }));
1008
- if (t && t.sent) acts.push(extLink(D.openSent, t.sent.link, { 'data-day-link': 'sent' }));
1009
- let form = null;
1010
- if (t && ui.revising.has(t.id) && canRevise) {
1011
- const f = field({ label: D.noteLabel, kind: 'textarea', value: ui.notes.get(t.id) || '', placeholder: D.noteHint, hideLabel: true, attrs: { maxlength: '500', 'data-day-input': 'note-' + t.id } });
1012
- const ta = f.control;
1013
- ta.addEventListener('input', () => { ui.notes.set(t.id, ta.value); });
1014
- form = el('div', { class: 'td-day__revise', 'data-day': 'revise' }, f, el('div', { class: 'td-day__acts' },
1015
- button({ label: tagged(D.sendNote, 'agent'), variant: 'primary', size: 'sm', disabled: busy, attrs: { 'data-day-act': 'send-note' }, onClick: () => {
1016
- const v = (ui.notes.get(t.id) || '').trim();
1017
- if (!v || v.length > 500) { toast({ text: D.noteNeeded, tone: 'destructive' }); return; }
1018
- decide(ws, t, 'revise', v);
1019
- } }),
1020
- button({ label: D.cancel, size: 'sm', variant: 'ghost', attrs: { 'data-day-act': 'cancel' }, onClick: () => { ui.revising.delete(t.id); rerender(); } })));
1021
- }
1022
- const reply = typeof it.reply_needed === 'boolean' ? (it.reply_needed ? D.yes : D.no) : null;
1023
- return el('article', { class: 'td-day__job', 'data-day-job': j.id },
1024
- el('div', { class: 'td-day__jobtop' }, el('span', { class: 'td-day__jobtitle' }, j.title), statusPill(j)),
1025
- el('span', { class: 'td-day__src' }, [srcName(j.source), it.where, n ? D.pill.goal(n) : null].filter(Boolean).join(' · ')),
1026
- dl([[D.where, D.fromWho(it.who, null)], [D.about, it.about || null], [D.why, it.why_now || null], [D.ask, it.ask || null], [D.reply, reply], [D.how, it.how || null]]),
1027
- statusNote ? note(statusNote) : null,
1028
- t && j.status === 'failed' && t.error ? el('p', { class: 'td-day__run td-day__run--failed', role: 'alert' }, D.failedWhy(t.error)) : null,
1029
- j.status === 'sent' && t && ((t.sent && t.sent.at) || (t.decided && t.decided.at)) ? note(D.sentAt(hhmm((t.sent && t.sent.at) || t.decided.at))) : null,
1030
- draft,
1031
- revs ? note(D.revisions(revs)) : null,
1032
- el('div', { class: 'td-day__acts' }, ...acts.filter(Boolean)),
1033
- form);
1034
- }
1035
-
1036
- /** The goal of a job is the PM's link mark (PRD L1). The press says what it did, with Undo, like the other marks. */
1037
- function linkPress(ctx, linkId, goalId) {
1038
- const g = goalId ? ctx.m.allGoals.find((x) => x.id === goalId) : null;
1039
- return markPress(ctx.ws, linkId, { action: 'link', goal: goalId }, g ? D.linked(g.text) : D.unlinked);
1040
- }
1041
-
1042
- /** What a job says about itself (PRD J1, J3, J4): who acts, where it came from, its goal and, with a session, the way to it. */
1043
- function jobMeta(ctx, j) {
1044
- const { m } = ctx;
1045
- const who = whoActs(j);
1046
- const t = j.task;
1047
- const sid = t && (t.session_id || t.stalled_session);
1048
- const known = sid ? (state.sessions || []).find((x) => x && x.id === sid) : null;
1049
- const name = (known && known.name) || 'day-task';
1050
- const origin = originOf(j);
1051
- const pick = goalPicker(m, j.goal, (g) => linkPress(ctx, j.linkId, g), { attrs: { 'data-day-job-goal': j.id } });
1052
- return el('div', { class: 'td-day__jobmeta', 'data-day': 'jobmeta' },
1053
- el('p', { class: 'td-day__who2', 'data-day': 'who', 'data-who': who.who }, whoMark(who.who), el('span', null, who.text)),
1054
- dl([[D.origin.label, el('span', { 'data-day': 'origin', 'data-origin': origin }, D.origin[origin])], [D.goalCtl.label, pick]]),
1055
- sid ? el('div', { class: 'td-day__acts' }, button({ label: tagged(D.openSessionOf(name), 'you'), size: 'sm', variant: 'ghost', attrs: { 'data-day-act': 'session' },
1056
- onClick: () => openSession({ id: sid, name }) })) : null);
1057
- }
1058
-
1059
- function jobDetail(ctx, j) {
1060
- const { m } = ctx;
1061
- const n = j.goal ? m.goalNo.get(j.goal) : null;
1062
- const meets = m.events.filter((e) => e.gid && e.gid === j.goal);
1063
- const mention = j.item && j.item.mention;
1064
- return [
1065
- dhead(n ? D.kind.jobGoal(n) : D.kind.job, null),
1066
- j.repo ? el('div', { class: 'td-day__acts' }, repoTag(m, j.repo)) : null,
1067
- jobCard(ctx, j),
1068
- jobMeta(ctx, j),
1069
- meets.length || mention ? el('div', { class: 'td-day__rel' }, el('h4', null, D.related), el('ul', { class: 'td-day__rows' },
1070
- ...meets.map((e) => relRow(ctx, 'event', e.id, e.title, e.time)),
1071
- mention ? relRow(ctx, 'mention', j.id, j.item.ask || j.title, srcName(j.source)) : null)) : null,
1072
- ];
1073
- }
1074
-
1075
- function mentionDetail(ctx, j) {
1076
- const it = j.item;
1077
- const reply = typeof it.reply_needed === 'boolean' ? (it.reply_needed ? D.yes : D.no) : null;
1078
- return [
1079
- dhead(D.kind.mention(srcName(j.source)), it.about || j.title),
1080
- hasCard(j.source) ? el('div', { class: 'td-day__mcbox', 'data-day': 'mention-card' }, mentionCard(j, srcName(j.source))) : null,
1081
- dl([[D.where, D.fromWho(it.who, it.where)], [D.ask, it.ask || it.why_now || null], [D.reply, reply]]),
1082
- el('div', { class: 'td-day__acts' }, extLink(D.openIn(srcName(j.source)), j.link, { 'data-day-link': 'conversation' }), mentionStatus(j)),
1083
- el('div', { class: 'td-day__rel' }, el('h4', null, D.theJob), el('ul', { class: 'td-day__rows' }, relRow(ctx, 'job', j.id, j.title, '', j))),
1084
- ];
1085
- }
1086
-
1087
- function levelSeg(ctx, svc, name) {
1088
- const cur = ctx.m.level(svc, name);
1089
- return tabs({ variant: 'segmented', role: 'radiogroup', ariaLabel: name, value: cur, attrs: { 'data-day-levels': svc + ':' + name },
1090
- items: ['watch', 'search', 'ignore'].map((l) => ({ id: l, label: D.levels[l] })), onChange: (l) => { if (l !== cur) setLevel(ctx, svc, name, l); } });
1091
- }
1092
- function setLevel(ctx, svc, name, lvl) {
1093
- const scopes = { ...(ctx.m.scopes || {}) };
1094
- scopes[svc] = { ...(scopes[svc] || {}), [name]: lvl };
1095
- return setSettings(ctx.ws, { scopes });
1096
- }
1097
-
1098
- function setPlaceRepo(ctx, svc, name, repo) {
1099
- return setSettings(ctx.ws, { placeRepos: { [svc]: { [name]: repo } } });
1100
- }
1101
-
1102
- function channelDetail(ctx, id) {
1103
- const g = ctx.m.digests.find((x) => x.id === id);
1104
- if (!g) return null;
1105
- const sec = (t, l) => list(t, (l || []).map(String), 'td-day__chk--ok');
1106
- return [
1107
- dhead(D.kind.place(srcName(g.source), D.place[g.source] || '', D.levelWord[g.level] || g.level), g.name),
1108
- sec(D.decisions, g.decisions), sec(D.open, g.open), sec(D.forGoals, g.goals),
1109
- el('div', { class: 'td-day__ch' }, el('span', null, D.changeLevel), levelSeg(ctx, g.source, g.name)),
1110
- el('div', { class: 'td-day__ch' }, el('span', null, D.repo.label), repoPicker(ctx.m, g.repo, (r) => setPlaceRepo(ctx, g.source, g.name, r), { 'data-day-place-repo': g.source + ':' + g.name })),
1111
- note(D.levelHelp),
1112
- el('div', { class: 'td-day__acts' }, extLink(D.openIn(srcName(g.source)), g.link, { 'data-day-link': 'place' }),
1113
- button({ label: D.manageSources, size: 'sm', variant: 'ghost', onClick: () => select('sources', 'all') })),
1114
- ];
1115
- }
1116
-
1117
- function stepDetail(ctx, i) {
1118
- const { m } = ctx;
1119
- const si = stepIndex(m.stage);
1120
- const head = dhead(D.stepOf(i + 1), D.stepTitle[i]);
1121
- if (!m.run) return [head, note(D.readNone)];
1122
- if (i > si && si !== 4) return [head, note(D.notYet)];
1123
- const jobRows = (l) => (l.length ? el('ul', { class: 'td-day__rows' }, ...l.map((j) => relRow(ctx, 'job', j.id, j.title, '', j))) : null);
1124
- if (i === 0) {
1125
- const bs = m.run.brief_session;
1126
- const items = m.brief ? (m.brief.priorities || []).length + (m.brief.worth_asking || []).length : 0;
1127
- return [head, el('p', m.readFailed ? { class: 'td-day__warn', 'data-day': 'read-failed' } : null,
1128
- m.brief ? D.readDone(m.events.length, items) : m.readFailed ? D.readFailed(m.readFailed.why) : D.readNow),
1129
- el('ul', { class: 'td-day__chk' }, ...m.sources.map((s) => el('li', { class: s.on && s.state === 'read' ? 'td-day__ok' : '' }, el('span', { class: s.on ? '' : 'td-day__dim' }, `${srcName(s.k)}: ${srcLine(s)}`)))),
1130
- el('div', { class: 'td-day__acts' }, button({ label: D.manageSources, size: 'sm', onClick: () => select('sources', 'all') }),
1131
- bs && bs.id ? button({ label: D.openSession, size: 'sm', variant: 'ghost', attrs: { 'data-day-act': 'session' }, onClick: () => openSession({ id: bs.id, name: 'morning-brief' }) }) : null)];
1132
- }
1133
- if (i === 1) {
1134
- const live = m.jobs.filter((j) => !j.worth);
1135
- return [head, el('p', null, D.madeJobs(live.length, live.filter((j) => j.kind === 'you').length, live.filter((j) => j.kind !== 'you').length)),
1136
- m.goals.length ? el('ul', { class: 'td-day__rows' }, ...m.goals.map((g) => relRow(ctx, 'goal', g.id, g.text, String(m.goalNo.get(g.id))))) : null];
1137
- }
1138
- if (i === 2) {
1139
- const ts = m.jobs.filter((j) => j.task);
1140
- const c = (s) => m.tasks.filter((t) => s.includes(t.status)).length;
1141
- return [head, el('p', null, D.agentsLine(c(['working', 'sending']), c(['waiting']), c(['done', 'sent']))), jobRows(ts)];
1142
- }
1143
- const need = m.jobs.filter((j) => j.group === 'needs');
1144
- return [head, el('p', null, D.approveLine(need.length)), jobRows(need)];
1145
- }
1146
-
1147
- function srcLine(s) {
1148
- if (!s.on) return D.srcState.off;
1149
- if (s.state === 'read') return typeof s.got === 'number' ? D.gave(s.got) : D.srcState.read;
1150
- return D.srcState[s.state] || D.srcState.none;
1151
- }
1152
-
1153
- function placeControls(ctx, svc) {
1154
- const { m } = ctx;
1155
- // every place the last read found you in, then any you set a level for or that has a digest
1156
- const names = [...new Set([...m.places.filter((x) => x.source === svc).map((x) => x.name), ...Object.keys(m.scopes[svc] || {}),
1157
- ...m.digests.filter((g) => g.source === svc).map((g) => g.name)])];
1158
- const row = (name) => el('div', { class: 'td-day__ch', 'data-day-place': svc + ':' + name }, el('span', null, name),
1159
- el('span', { class: 'td-day__chips' }, repoPicker(m, m.placeRepo(svc, name), (r) => setPlaceRepo(ctx, svc, name, r), { 'data-day-place-repo': svc + ':' + name }), levelSeg(ctx, svc, name)));
1160
- const live = names.filter((x) => m.level(svc, x) !== 'ignore');
1161
- const ign = names.filter((x) => m.level(svc, x) === 'ignore');
1162
- const input = field({ label: D.placeAdd[svc], value: '', placeholder: D.placeHint, hideLabel: true, attrs: { maxlength: '120', 'data-day-input': 'place-' + svc },
1163
- onCommit: async (raw) => {
1164
- const v = String(raw || '').trim();
1165
- if (!v) return;
1166
- ui.placeDraft[svc] = '';
1167
- if (!(await setLevel(ctx, svc, v, 'watch'))) ui.placeDraft[svc] = v;
1168
- } });
1169
- // made empty and filled after, so Enter still commits text a rebuild put back
1170
- input.control.value = ui.placeDraft[svc] || '';
1171
- input.control.addEventListener('input', () => { ui.placeDraft[svc] = input.control.value; });
1172
- return [
1173
- note(D.readNote[svc]),
1174
- m.places.some((x) => x.source === svc) ? null : note(D.noPlaces[svc]),
1175
- ...live.map(row),
1176
- ign.length ? button({ label: ui.showIgn[svc] ? D.hideIgnored : D.showIgnored(ign.length), variant: 'ghost', size: 'sm',
1177
- attrs: { 'data-day-ignored': svc, 'aria-expanded': ui.showIgn[svc] ? 'true' : 'false' }, onClick: () => { ui.showIgn[svc] = !ui.showIgn[svc]; rerender(); } }) : null,
1178
- ui.showIgn[svc] ? ign.map(row) : null,
1179
- input,
1180
- note(D.levelHelp),
1181
- note(D.repo.placeHint),
1182
- ];
1183
- }
1184
-
1185
- function siteControls(ctx) {
1186
- const sites = (ctx.m.settings && Array.isArray(ctx.m.settings.websites)) ? ctx.m.settings.websites : [];
1187
- const input = field({ label: D.siteAdd, value: '', placeholder: D.siteHint, hideLabel: true, attrs: { maxlength: '500', 'data-day-input': 'site' },
1188
- onCommit: async (raw) => {
1189
- const v = String(raw || '').trim();
1190
- if (!v) return;
1191
- if (!isUrl(v)) { toast({ text: D.siteBad, tone: 'destructive' }); return; }
1192
- if (sites.length >= 10) { toast({ text: D.siteFull, tone: 'destructive' }); return; }
1193
- ui.siteDraft = '';
1194
- if (!(await setSettings(ctx.ws, { websites: [...sites.filter((x) => x !== v), v] }))) ui.siteDraft = v;
1195
- } });
1196
- input.control.value = ui.siteDraft;
1197
- input.control.addEventListener('input', () => { ui.siteDraft = input.control.value; });
1198
- return [
1199
- el('h4', null, D.sites),
1200
- sites.length ? el('ul', { class: 'td-day__sites', 'data-day': 'sites' }, ...sites.map((u) => el('li', null, el('span', { class: 'td-day__mono' }, u),
1201
- button({ label: D.remove, size: 'sm', variant: 'ghost', attrs: { 'data-day-site-remove': u }, onClick: () => setSettings(ctx.ws, { websites: sites.filter((x) => x !== u) }) })))) : null,
1202
- sites.length < 10 ? input : note(D.siteFull),
1203
- ];
1204
- }
1205
-
1206
- function sourcesDetail(ctx) {
1207
- const { m, ws } = ctx;
1208
- if (!m.settings) return [dhead(D.kind.settings, D.sources), note(m.d && m.d.legacy ? D.oldServer : D.noSources)];
1209
- const dc = m.settings.dayCheck || { every: 60, start: '09:00', end: '18:00' };
1210
- const log = m.check && Array.isArray(m.check.log) ? m.check.log.slice(-4).reverse() : [];
1211
- const box = el('div', { class: 'td-day__notes', 'data-day': 'day-check' }, el('h4', null, D.dayCheck),
1212
- el('div', { class: 'td-day__ch' }, el('span', null, D.every), tabs({ variant: 'segmented', role: 'radiogroup', ariaLabel: D.every, value: String(dc.every), attrs: { 'data-day': 'every' },
1213
- items: D.everyOpts.map(([v, l]) => ({ id: String(v), label: l })), onChange: (v) => { if (Number(v) !== dc.every) setSettings(ws, { dayCheck: { ...dc, every: Number(v) } }); } })),
1214
- el('div', { class: 'td-day__ch' }, el('span', null, D.hours), el('span', { class: 'td-day__mono' }, `${dc.start}–${dc.end}`)),
1215
- el('div', { class: 'td-day__ch' }, el('span', null, D.beforeMeeting), el('span', { class: 'td-day__dim' }, D.beforeMeetingWhat)),
1216
- el('div', { class: 'td-day__ch' }, el('span', null, D.afterMeeting), el('span', { class: 'td-day__dim' }, D.afterMeetingWhat)),
1217
- note(D.checkHelp),
1218
- log.length ? el('div', { class: 'td-day__log', 'data-day': 'check-log' }, ...log.map((x) => el('div', null, x.found === null || x.found === undefined ? D.checkRunning(hhmm(x.at)) : D.checkLog(hhmm(x.at), x.found || 0, x.resolved || 0)))) : null);
1219
- const rows = m.sources.map((s) => {
1220
- const name = srcName(s.k);
1221
- const open = ui.openSrc === s.k;
1222
- const more = !open ? null : el('div', { class: 'td-day__more' }, note(D.srcWhat[s.k] || ''),
1223
- SCOPED.includes(s.k) ? placeControls(ctx, s.k) : null,
1224
- s.k === 'website' ? siteControls(ctx) : null);
1225
- return el('div', { class: 'td-day__sr', 'data-day-source': s.k },
1226
- el('span', { class: 'td-day__ic', 'aria-hidden': 'true' }, name.slice(0, 2)),
1227
- button({ label: name, variant: 'ghost', size: 'sm', iconEnd: open ? 'chevron-down' : 'chevron-right', attrs: { 'aria-expanded': open ? 'true' : 'false', 'data-day-osrc': s.k }, onClick: () => { ui.openSrc = open ? null : s.k; rerender(); } }),
1228
- el('span', { class: 'td-day__st' }, srcLine(s)),
1229
- field({ kind: 'check', label: D.read, value: !!s.on, attrs: { 'aria-label': D.readSwitch(name), 'data-day-src': s.k },
1230
- onCommit: (v) => setSettings(ws, { briefSources: { [s.k]: !!v } }) }),
1231
- more);
1232
- });
1233
- return [dhead(D.kind.settings, D.sources), note(D.sourcesIntro), box, el('div', { class: 'td-day__slist' }, ...rows)];
1234
- }
1235
-
1236
- function defaultSel(m, owed) {
1237
- const j = m.jobs.find((x) => x.group === 'needs');
1238
- if (j) return { type: 'job', id: j.id };
1239
- if (owed && owed.length) return { type: 'owed', id: owed[0].id };
1240
- const e = m.events.find((x) => !x.ended);
1241
- if (e) return { type: 'event', id: e.id };
1242
- return { type: 'step', id: String(Math.max(0, Math.min(3, stepIndex(m.stage)))) };
1243
- }
1244
-
1245
- function detail(ctx) {
1246
- const { m } = ctx;
1247
- let sel = ctx.sel;
1248
- let kids = null;
1249
- const find = (s) => {
1250
- if (s.type === 'event') { const e = m.events.find((x) => x.id === s.id); return e ? eventDetail(ctx, e) : null; }
1251
- if (s.type === 'job') { const j = m.jobs.find((x) => x.id === s.id); return j ? jobDetail(ctx, j) : null; }
1252
- if (s.type === 'mention') { const j = m.mentions.find((x) => x.id === s.id); return j ? mentionDetail(ctx, j) : null; }
1253
- if (s.type === 'goal') return goalDetail(ctx, s.id, (type, id, label, lead, j) => relRow(ctx, type, id, label, lead, j));
1254
- if (s.type === 'channel') return channelDetail(ctx, s.id);
1255
- if (s.type === 'step') return stepDetail(ctx, Math.max(0, Math.min(3, Number(s.id) || 0)));
1256
- if (s.type === 'sources') return sourcesDetail(ctx);
1257
- if (s.type === 'meeting') return meetingDetail(ctx, s.id, { dhead });
1258
- if (s.type === 'owed') { const o = ctx.owed.find((x) => x.id === s.id); if (o) o.node.hidden = false; return o ? [dhead(D.groups.needs), el('div', { class: 'td-day__owed', 'data-day': 'owed' }, o.node)] : null; }
1259
- return null;
1260
- };
1261
- kids = find(sel);
1262
- if (!kids) { sel = defaultSel(m, ctx.owed); kids = find(sel); }
1263
- return el('aside', { class: 'td-day__detail', 'aria-label': D.panels.detail, 'data-day': 'detail', 'data-day-detail': sel.type, 'data-day-detail-id': sel.id }, kids);
1264
- }
1265
-
1266
- /* ── the section ──────────────────────────────────────────────────────────────────────────────────────────────── */
1267
-
1268
- /* The phone's view of Today (pm/phone-deck.js): Day opens the section and Cards folds it, without touching the fold the
1269
- * PM chose on a desktop. null is no phone override. */
1270
- let forced = null;
1271
- export function setDayForced(open) { forced = open === null || open === undefined ? null : !!open; }
1272
-
1273
- /** Is today's day prepared, and is a press in flight? For the phone's first card on Today. */
1274
- export function dayState(ws) {
1275
- const c = cache.get(ws) || {};
1276
- const m = model(c.data, { here: null, all: false });
1277
- const press = runs.get(ws);
1278
- return { known: !!c.data, prepared: !!m.run, busy: !!press && press.state === 'busy' };
1279
- }
1280
- /** Press "Prepare my day" for `ws`, the same press as the day section's own button. */
1281
- export function pressPrepare(ws) { return prepareDay(ws); }
1282
-
1283
- function fold(open) {
1284
- ui.open = open;
1285
- store.set(OPEN_KEY, open ? 'true' : 'false');
1286
- rerender();
1287
- }
1288
-
1289
- /** Render the section selector tabs. */
1290
- function sectionSelector(ctx) {
1291
- const { m } = ctx;
1292
- const openGoals = m.allGoals.filter((g) => g.status === 'open').length;
1293
- const items = [
1294
- { id: 'agenda', icon: 'calendar', label: D.sections.agenda, count: null },
1295
- { id: 'goals', icon: 'target', label: D.sections.goals, count: openGoals },
1296
- { id: 'jobs', icon: 'list-checks', label: D.sections.jobs, count: m.jobs.length },
1297
- { id: 'mentions', icon: 'text-quote', label: D.sections.mentions, count: m.mentions.length },
1298
- ];
1299
- return tabs({ variant: 'segmented', role: 'tablist', ariaLabel: D.sections.label, value: ui.section, full: true, attrs: { 'data-day': 'section-tabs' },
1300
- items,
1301
- onChange: (v) => { ui.section = v; store.set(SECTION_KEY, v); rerender(); } });
1302
- }
1303
-
1304
- /** Render the chosen section's content. */
1305
- function sectionContent(ctx) {
1306
- const { m } = ctx;
1307
- switch (ui.section) {
1308
- case 'agenda':
1309
- return agenda(ctx);
1310
- case 'goals':
1311
- return goalsPanel(ctx);
1312
- case 'jobs':
1313
- return jobsPanel(ctx);
1314
- case 'mentions':
1315
- return mentionsPanel(ctx);
1316
- default:
1317
- return agenda(ctx);
1318
- }
1319
- }
1320
-
1321
- /** The section. `ws` is the repository the day run belongs to; `openIni(id)` opens an initiative of it. */
1322
- export function daySection({ ws, setState, openIni, owed, here, all } = {}) {
1323
- if (FIXTURE) return null;
1324
- // like Today's own feeds, a read that lands re-renders only while the section is on the page: a hidden Today must not
1325
- // cause a whole-page render under whatever the PM is doing elsewhere
1326
- if (setState) rerender = () => { if (document.querySelector('[data-today="day"]')) setState({}); };
1327
- onAgenda(() => rerender());
1328
- if (!notesSub) notesSub = onNotes(() => rerender());
1329
- ensure(ws);
1330
- const c = cache.get(ws) || {};
1331
- const m = model(c.data, { here: here || null, all: !!all });
1332
- const open = forced !== null ? forced : ui.open !== null ? ui.open : true;
1333
- if (!open) {
1334
- return el('section', { class: 'td-day', 'data-today': 'day', 'data-open': 'false', 'aria-label': D.title },
1335
- button({ label: D.toggle(m.needs), variant: 'ghost', iconEnd: 'chevron-right', attrs: { 'data-day': 'toggle', 'aria-expanded': 'false' }, onClick: () => fold(true) }));
1336
- }
1337
- const sel = ui.sel;
1338
- const ctx = {
1339
- ws, m, sel, openIni, reload: () => load(ws), rerender: () => rerender(), select, repoPicker, mark: (id, op, said) => markPress(ws, id, op, said),
1340
- showAll: () => { if (setState) setState({ todayScope: 'all' }); },
1341
- cur: (type, id) => { const s = sel || defaultSel(m, ctx.owed); return s.type === type && s.id === String(id) ? 'true' : 'false'; },
1342
- owed: owedItems(owed),
1343
- };
1344
- ctx.sel = sel || defaultSel(m, ctx.owed);
1345
- // the open day takes what the repositories owe into its jobs: dest-today draws no second list under it
1346
- if (owed) owed.taken = true;
1347
- if (ui.scroll) {
1348
- ui.scroll = false;
1349
- // on a narrow screen the detail is under the list: bring it into view once it is on the page
1350
- requestAnimationFrame(() => requestAnimationFrame(() => {
1351
- const box = document.querySelector('[data-today="day"] .td-day__cols');
1352
- const d = document.querySelector('[data-today="day"] [data-day="detail"]');
1353
- if (box && d && box.clientWidth < NARROW) d.scrollIntoView({ behavior: 'smooth', block: 'start' });
1354
- }));
1355
- }
1356
- return el('section', { class: 'td-day', 'data-today': 'day', 'data-open': 'true', 'aria-label': D.title },
1357
- topBar(ctx),
1358
- runLine(ctx),
1359
- m.narrow && m.repos.length > 1 ? note(D.repo.only(m.repoName(m.here)), { 'data-day': 'repo-view' }) : null,
1360
- c.error ? el('p', { class: 'td-day__run td-day__run--failed', role: 'status', 'data-day': 'error' }, D.refused(c.error)) : null,
1361
- m.d && m.d.legacy ? note(D.oldServer) : null,
1362
- el('div', { class: 'td-day__cols' },
1363
- el('div', { class: 'td-day__left' }, sectionSelector(ctx), sectionContent(ctx)),
1364
- detail(ctx)));
1365
- }
1366
-
1367
- export function daySig(ws) {
1368
- const c = cache.get(ws) || {};
1369
- return JSON.stringify([forced, ui.open, ui.section, ui.sel, ui.mtab, ui.openSrc, ui.showIgn, ui.showIgnDigests, [...ui.revising], [...ui.busy], [...ui.groupsOpen], [...ui.cur], ui.holding, ui.holdDraft.when, [...ui.verdict], c.error, runs.get(ws) || null, [...seen].length])
1370
- + dataSig(c.data) + goalsSig() + agendaSig();
1371
- }