create-pmos 0.399.0 → 0.401.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 (425) 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 +2 -2
  7. package/workspace/briefing-premium-board-test.js +3 -3
  8. package/workspace/briefing-premium-doc-edit-test.js +2 -8
  9. package/workspace/briefing-premium-sources-test.js +2 -0
  10. package/workspace/briefing-premium-test.js +6 -2
  11. package/workspace/briefing-premium-work-test.js +9 -4
  12. package/workspace/c3-capture-test.js +0 -17
  13. package/workspace/changelog.json +29 -0
  14. package/workspace/guide/briefing-premium.md +2 -2
  15. package/workspace/guide/home.md +24 -3
  16. package/workspace/guide/layout.md +2 -2
  17. package/workspace/guide/notes.md +2 -2
  18. package/workspace/guide/phone-companion.md +1 -1
  19. package/workspace/lib/core-docs.js +2 -2
  20. package/workspace/lib/route-modules.js +1 -9
  21. package/workspace/lib/routes-phone-day.js +18 -9
  22. package/workspace/lib/routes-slash.js +95 -0
  23. package/workspace/package-lock.json +2 -2
  24. package/workspace/package.json +1 -2
  25. package/workspace/premium-chat-goal-view-test.js +1 -1
  26. package/workspace/premium-chat-term-test.js +0 -10
  27. package/workspace/premium-menu-rows-test.js +1 -1
  28. package/workspace/premium-phone-card-test.js +8 -3
  29. package/workspace/premium-vw-cal-test.js +4 -1
  30. package/workspace/premium-vw-doc-test.js +1 -8
  31. package/workspace/premium-work-depth-test.js +2 -3
  32. package/workspace/public/capture.html +23 -0
  33. package/workspace/public/pm/c3-base.js +47 -0
  34. package/workspace/public/pm/c3-capture.js +1 -1
  35. package/workspace/public/pm/c3-ini-ui.js +1 -1
  36. package/workspace/public/pm/c3-sheet.js +1 -1
  37. package/workspace/public/pm/c3-toast.js +1 -1
  38. package/workspace/public/pm/console3.css +3 -0
  39. package/workspace/public/pm/cozy-home.css +21 -6
  40. package/workspace/public/pm/cozy-today.css +4 -3
  41. package/workspace/public/pm/cozy-viewer.js +4 -2
  42. package/workspace/public/pm/cozy.css +9 -0
  43. package/workspace/public/pm/goal-chat.js +5 -1
  44. package/workspace/public/pm/home-app.js +65 -33
  45. package/workspace/public/pm/home-chat.js +34 -29
  46. package/workspace/public/pm/home-data.js +10 -2
  47. package/workspace/public/pm/home-dictate.js +7 -4
  48. package/workspace/public/pm/home-ini.js +13 -3
  49. package/workspace/public/pm/home-list.js +18 -10
  50. package/workspace/public/pm/home-more.js +2 -2
  51. package/workspace/public/pm/home-phone-card.js +9 -4
  52. package/workspace/public/pm/home-review.js +2 -3
  53. package/workspace/public/pm/home-today.js +11 -8
  54. package/workspace/public/pm/home-work.js +13 -8
  55. package/workspace/public/pm/note-dock.js +1 -2
  56. package/workspace/public/pm/notes-links.js +1 -2
  57. package/workspace/public/pm/notes-task.js +3 -4
  58. package/workspace/public/pm/premium-board.js +1 -1
  59. package/workspace/public/pm/premium-initiative-head.js +3 -3
  60. package/workspace/public/pm/premium-vw-doc.css +20 -2
  61. package/workspace/public/pm/premium-vw-doc.js +22 -7
  62. package/workspace/public/pm/premium-vw-item.css +6 -0
  63. package/workspace/public/pm/view-notes.js +2 -2
  64. package/workspace/replaced-tests.json +435 -0
  65. package/workspace/run-tests.js +323 -28
  66. package/workspace/server.js +15 -10
  67. package/workspace/test-files.json +4 -140
  68. package/workspace/test-lists/base.json +1 -2
  69. package/workspace/test-lists/c3-desktop-light-load.json +1 -2
  70. package/workspace/test-lists/c3-initiative-boards.json +1 -2
  71. package/workspace/test-lists/c3-meeting-focus.json +2 -12
  72. package/workspace/test-lists/c3-work-agent.json +1 -2
  73. package/workspace/test-lists/calendar-tidy-up.json +1 -2
  74. package/workspace/test-lists/console3-reports.json +1 -2
  75. package/workspace/test-lists/docs-three-way-sync.json +1 -2
  76. package/workspace/test-lists/extension-capture.json +5 -0
  77. package/workspace/test-lists/jira-wbs.json +1 -2
  78. package/workspace/test-lists/legacy-cleanup-a.json +9 -0
  79. package/workspace/test-lists/meeting-material.json +1 -2
  80. package/workspace/test-lists/meeting-notes.json +2 -36
  81. package/workspace/test-lists/meeting-replay.json +1 -2
  82. package/workspace/test-lists/mm-capture.json +2 -12
  83. package/workspace/test-lists/my-work.json +2 -10
  84. package/workspace/test-lists/onboarding-firstrun.json +2 -12
  85. package/workspace/test-lists/people-directory.json +1 -2
  86. package/workspace/test-lists/run2-a.json +1 -2
  87. package/workspace/test-lists/run2-d.json +2 -19
  88. package/workspace/test-lists/run3-b.json +1 -2
  89. package/workspace/test-lists/run3-c.json +2 -12
  90. package/workspace/test-lists/run4-b.json +1 -2
  91. package/workspace/test-lists/run4-d.json +1 -5
  92. package/workspace/test-lists/run5-c.json +1 -11
  93. package/workspace/test-lists/run6.json +1 -5
  94. package/workspace/test-lists/workspace-launch-flags.json +2 -12
  95. package/workspace/test-lists/workspace-profile-detection.json +2 -10
  96. package/workspace/test-timings.json +242 -123
  97. package/workspace/c3-briefing-test.js +0 -136
  98. package/workspace/c3-core-docs-test.js +0 -170
  99. package/workspace/c3-driver-fixture.js +0 -64
  100. package/workspace/c3-driver-test.js +0 -169
  101. package/workspace/c3-foundation-test.js +0 -163
  102. package/workspace/c3-ib-items-test.js +0 -114
  103. package/workspace/c3-ib-more-test.js +0 -146
  104. package/workspace/c3-ib-triage-backlog-test.js +0 -128
  105. package/workspace/c3-ini-harness.js +0 -66
  106. package/workspace/c3-ini-life-test.js +0 -167
  107. package/workspace/c3-initiatives-test.js +0 -186
  108. package/workspace/c3-light-load-test.js +0 -112
  109. package/workspace/c3-one-home-test.js +0 -149
  110. package/workspace/c3-phone-test.js +0 -289
  111. package/workspace/c3-quiet-test.js +0 -157
  112. package/workspace/c3-report-design-real-test.js +0 -264
  113. package/workspace/c3-report-design-test.js +0 -442
  114. package/workspace/c3-report-setup-test.js +0 -192
  115. package/workspace/c3-report-structure-real-test.js +0 -248
  116. package/workspace/c3-report-structure-test.js +0 -397
  117. package/workspace/c3-reports-test.js +0 -288
  118. package/workspace/c3-scan-test.js +0 -517
  119. package/workspace/c3-sessions-panel-test.js +0 -365
  120. package/workspace/c3-settings-test.js +0 -204
  121. package/workspace/c3-updates-test.js +0 -131
  122. package/workspace/c3-work-test.js +0 -260
  123. package/workspace/cut-stub.js +0 -40
  124. package/workspace/first-paint-audit.js +0 -160
  125. package/workspace/lib/c3-full-console.js +0 -15
  126. package/workspace/lib/engine/derived/trust.js +0 -3
  127. package/workspace/lib/engine/plan-forecast.js +0 -342
  128. package/workspace/lib/engine/report-families.js +0 -175
  129. package/workspace/lib/engine/truth-table.js +0 -57
  130. package/workspace/lib/routes-c3-init.js +0 -54
  131. package/workspace/lib/routes-c3-life.js +0 -120
  132. package/workspace/lib/routes-c3-timeline.js +0 -192
  133. package/workspace/lib/routes-forecast.js +0 -86
  134. package/workspace/lib/routes-releases.js +0 -130
  135. package/workspace/lib/routes-report-facts.js +0 -85
  136. package/workspace/lib/routes-report-families.js +0 -33
  137. package/workspace/lib/routes-signals.js +0 -51
  138. package/workspace/lib/routes-timeline.js +0 -197
  139. package/workspace/public/c3.html +0 -35
  140. package/workspace/public/index.html +0 -156
  141. package/workspace/public/pm/app.js +0 -831
  142. package/workspace/public/pm/bd-board.js +0 -159
  143. package/workspace/public/pm/bd-drag.js +0 -59
  144. package/workspace/public/pm/bd-model.js +0 -152
  145. package/workspace/public/pm/bd-timeline.js +0 -233
  146. package/workspace/public/pm/bd-tree.js +0 -244
  147. package/workspace/public/pm/board-copy.js +0 -59
  148. package/workspace/public/pm/board-read.js +0 -38
  149. package/workspace/public/pm/branches-sheet.js +0 -56
  150. package/workspace/public/pm/breakdown-api.js +0 -58
  151. package/workspace/public/pm/breakdown-copy.js +0 -138
  152. package/workspace/public/pm/briefing-deck.js +0 -441
  153. package/workspace/public/pm/briefing-model.js +0 -251
  154. package/workspace/public/pm/c3-ambient.js +0 -100
  155. package/workspace/public/pm/c3-audience-link.js +0 -21
  156. package/workspace/public/pm/c3-audience.js +0 -46
  157. package/workspace/public/pm/c3-boot.js +0 -13
  158. package/workspace/public/pm/c3-breakdown.js +0 -240
  159. package/workspace/public/pm/c3-brief-data.js +0 -11
  160. package/workspace/public/pm/c3-brief-mentions.js +0 -137
  161. package/workspace/public/pm/c3-brief-needs.js +0 -288
  162. package/workspace/public/pm/c3-brief-pulse.js +0 -112
  163. package/workspace/public/pm/c3-brief-summary.js +0 -139
  164. package/workspace/public/pm/c3-brief-today.js +0 -79
  165. package/workspace/public/pm/c3-brief.js +0 -279
  166. package/workspace/public/pm/c3-cal-strategy.js +0 -529
  167. package/workspace/public/pm/c3-calendar.js +0 -965
  168. package/workspace/public/pm/c3-calpop.js +0 -111
  169. package/workspace/public/pm/c3-case.js +0 -196
  170. package/workspace/public/pm/c3-core-docs.css +0 -18
  171. package/workspace/public/pm/c3-core-docs.js +0 -236
  172. package/workspace/public/pm/c3-daypart.js +0 -176
  173. package/workspace/public/pm/c3-demo-boards.js +0 -764
  174. package/workspace/public/pm/c3-demo-brief-ix.js +0 -350
  175. package/workspace/public/pm/c3-demo-brief-page.js +0 -70
  176. package/workspace/public/pm/c3-demo-cal-ix.js +0 -74
  177. package/workspace/public/pm/c3-demo-cal2.js +0 -66
  178. package/workspace/public/pm/c3-demo-cal3.js +0 -173
  179. package/workspace/public/pm/c3-demo-cal4.js +0 -169
  180. package/workspace/public/pm/c3-demo-cal5.js +0 -52
  181. package/workspace/public/pm/c3-demo-coredocs.js +0 -221
  182. package/workspace/public/pm/c3-demo-data.js +0 -552
  183. package/workspace/public/pm/c3-demo-focus.js +0 -181
  184. package/workspace/public/pm/c3-demo-init.js +0 -430
  185. package/workspace/public/pm/c3-demo-life.js +0 -77
  186. package/workspace/public/pm/c3-demo-material.js +0 -58
  187. package/workspace/public/pm/c3-demo-misc2.js +0 -34
  188. package/workspace/public/pm/c3-demo-phone.js +0 -48
  189. package/workspace/public/pm/c3-demo-plan2.js +0 -30
  190. package/workspace/public/pm/c3-demo-rd.js +0 -432
  191. package/workspace/public/pm/c3-demo-rep-ix.js +0 -126
  192. package/workspace/public/pm/c3-demo-rep2.js +0 -130
  193. package/workspace/public/pm/c3-demo-rep3.js +0 -138
  194. package/workspace/public/pm/c3-demo-rs.js +0 -287
  195. package/workspace/public/pm/c3-demo-term.js +0 -153
  196. package/workspace/public/pm/c3-demo-time.js +0 -49
  197. package/workspace/public/pm/c3-demo-work-ix.js +0 -32
  198. package/workspace/public/pm/c3-demo.js +0 -131
  199. package/workspace/public/pm/c3-design-studio.js +0 -369
  200. package/workspace/public/pm/c3-doc-formats.js +0 -153
  201. package/workspace/public/pm/c3-doc-sheet.js +0 -1230
  202. package/workspace/public/pm/c3-dock.js +0 -206
  203. package/workspace/public/pm/c3-docs.js +0 -291
  204. package/workspace/public/pm/c3-driver-work.js +0 -110
  205. package/workspace/public/pm/c3-driver.css +0 -18
  206. package/workspace/public/pm/c3-driver.js +0 -298
  207. package/workspace/public/pm/c3-focus.css +0 -304
  208. package/workspace/public/pm/c3-focus.js +0 -983
  209. package/workspace/public/pm/c3-ib-docs.js +0 -92
  210. package/workspace/public/pm/c3-ib-initiatives.js +0 -201
  211. package/workspace/public/pm/c3-ib-items.js +0 -210
  212. package/workspace/public/pm/c3-ib-releases.js +0 -48
  213. package/workspace/public/pm/c3-ib-sprints.js +0 -201
  214. package/workspace/public/pm/c3-ib-triage.js +0 -177
  215. package/workspace/public/pm/c3-ii-tabs.js +0 -252
  216. package/workspace/public/pm/c3-ini-life.css +0 -34
  217. package/workspace/public/pm/c3-ini-life.js +0 -379
  218. package/workspace/public/pm/c3-ini-records.js +0 -197
  219. package/workspace/public/pm/c3-ini-timeline.js +0 -278
  220. package/workspace/public/pm/c3-ini-work.js +0 -139
  221. package/workspace/public/pm/c3-init-extras.js +0 -170
  222. package/workspace/public/pm/c3-initiatives.js +0 -852
  223. package/workspace/public/pm/c3-lifecycle-panels.js +0 -479
  224. package/workspace/public/pm/c3-look.js +0 -27
  225. package/workspace/public/pm/c3-material.css +0 -22
  226. package/workspace/public/pm/c3-material.js +0 -321
  227. package/workspace/public/pm/c3-md.js +0 -3
  228. package/workspace/public/pm/c3-misc-panels.js +0 -89
  229. package/workspace/public/pm/c3-new-session.js +0 -110
  230. package/workspace/public/pm/c3-notes.js +0 -751
  231. package/workspace/public/pm/c3-phone-boot.js +0 -47
  232. package/workspace/public/pm/c3-phone-detail.js +0 -97
  233. package/workspace/public/pm/c3-phone-model.js +0 -3
  234. package/workspace/public/pm/c3-phone.css +0 -66
  235. package/workspace/public/pm/c3-phone.js +0 -444
  236. package/workspace/public/pm/c3-plan-panels.js +0 -163
  237. package/workspace/public/pm/c3-plan.js +0 -193
  238. package/workspace/public/pm/c3-quiet.css +0 -113
  239. package/workspace/public/pm/c3-quiet.js +0 -177
  240. package/workspace/public/pm/c3-replay.css +0 -133
  241. package/workspace/public/pm/c3-replay.js +0 -429
  242. package/workspace/public/pm/c3-report-deck.css +0 -163
  243. package/workspace/public/pm/c3-report-deck.js +0 -598
  244. package/workspace/public/pm/c3-report-frame.css +0 -20
  245. package/workspace/public/pm/c3-report-print.css +0 -20
  246. package/workspace/public/pm/c3-report-setup.css +0 -67
  247. package/workspace/public/pm/c3-report-setup.js +0 -298
  248. package/workspace/public/pm/c3-report-store.js +0 -244
  249. package/workspace/public/pm/c3-report-structure.css +0 -44
  250. package/workspace/public/pm/c3-report-structure.js +0 -473
  251. package/workspace/public/pm/c3-reports.css +0 -68
  252. package/workspace/public/pm/c3-reports.js +0 -377
  253. package/workspace/public/pm/c3-roadmap.js +0 -249
  254. package/workspace/public/pm/c3-scan-api.js +0 -167
  255. package/workspace/public/pm/c3-scan-next.js +0 -248
  256. package/workspace/public/pm/c3-scan-setup.js +0 -313
  257. package/workspace/public/pm/c3-scan-words.js +0 -41
  258. package/workspace/public/pm/c3-scan.css +0 -74
  259. package/workspace/public/pm/c3-scan.js +0 -93
  260. package/workspace/public/pm/c3-session-chat.js +0 -103
  261. package/workspace/public/pm/c3-session-conv.js +0 -165
  262. package/workspace/public/pm/c3-session-term.js +0 -216
  263. package/workspace/public/pm/c3-settings.css +0 -85
  264. package/workspace/public/pm/c3-settings.js +0 -1045
  265. package/workspace/public/pm/c3-shell.js +0 -628
  266. package/workspace/public/pm/c3-signals.js +0 -196
  267. package/workspace/public/pm/c3-strategy-panels.js +0 -45
  268. package/workspace/public/pm/c3-swipe.js +0 -230
  269. package/workspace/public/pm/c3-terminal-data.js +0 -48
  270. package/workspace/public/pm/c3-terminal-edge.js +0 -91
  271. package/workspace/public/pm/c3-terminal-icons.js +0 -40
  272. package/workspace/public/pm/c3-terminal-results.js +0 -141
  273. package/workspace/public/pm/c3-terminal.js +0 -52
  274. package/workspace/public/pm/c3-tickets.js +0 -163
  275. package/workspace/public/pm/c3-timeline.js +0 -201
  276. package/workspace/public/pm/calendar-views.js +0 -1049
  277. package/workspace/public/pm/console3-lift.md +0 -220
  278. package/workspace/public/pm/cozy-home.js +0 -172
  279. package/workspace/public/pm/cozy-initiative.css +0 -138
  280. package/workspace/public/pm/cycle-review.js +0 -125
  281. package/workspace/public/pm/data.js +0 -1577
  282. package/workspace/public/pm/dest-board.js +0 -444
  283. package/workspace/public/pm/dest-docs.js +0 -530
  284. package/workspace/public/pm/dest-initiatives.js +0 -162
  285. package/workspace/public/pm/dest-mywork.js +0 -307
  286. package/workspace/public/pm/dest-notes.js +0 -537
  287. package/workspace/public/pm/dest-people.js +0 -449
  288. package/workspace/public/pm/dest-reports.js +0 -383
  289. package/workspace/public/pm/dest-settings.js +0 -601
  290. package/workspace/public/pm/dest-today.js +0 -267
  291. package/workspace/public/pm/display-word.js +0 -56
  292. package/workspace/public/pm/doc-editor.js +0 -473
  293. package/workspace/public/pm/doc-graph.js +0 -272
  294. package/workspace/public/pm/doc-health-panel.js +0 -110
  295. package/workspace/public/pm/doc-rail.js +0 -167
  296. package/workspace/public/pm/doc-remote.js +0 -180
  297. package/workspace/public/pm/dock-sessions.js +0 -472
  298. package/workspace/public/pm/dock.js +0 -216
  299. package/workspace/public/pm/fixture.js +0 -821
  300. package/workspace/public/pm/flag-picker.js +0 -104
  301. package/workspace/public/pm/frame-copy.js +0 -278
  302. package/workspace/public/pm/freshness-line.js +0 -149
  303. package/workspace/public/pm/handoff-box.js +0 -82
  304. package/workspace/public/pm/initiative-list.js +0 -235
  305. package/workspace/public/pm/initiative-sheet.js +0 -331
  306. package/workspace/public/pm/initiatives-api.js +0 -95
  307. package/workspace/public/pm/initiatives-copy.js +0 -287
  308. package/workspace/public/pm/initiatives-timeline-copy.js +0 -59
  309. package/workspace/public/pm/initiatives-timeline.js +0 -410
  310. package/workspace/public/pm/initiatives-ui.js +0 -291
  311. package/workspace/public/pm/item-sheet.js +0 -268
  312. package/workspace/public/pm/keep-card.js +0 -204
  313. package/workspace/public/pm/lifecycle-lens-model.js +0 -246
  314. package/workspace/public/pm/lifecycle-lens.js +0 -276
  315. package/workspace/public/pm/lifecycle.js +0 -111
  316. package/workspace/public/pm/mobile.css +0 -366
  317. package/workspace/public/pm/mobile.js +0 -581
  318. package/workspace/public/pm/modes-live.js +0 -453
  319. package/workspace/public/pm/modes.js +0 -147
  320. package/workspace/public/pm/my-work-card.js +0 -51
  321. package/workspace/public/pm/my-work-data.js +0 -36
  322. package/workspace/public/pm/new-initiative-sheet.js +0 -169
  323. package/workspace/public/pm/next-step-ui.js +0 -190
  324. package/workspace/public/pm/outbox-panel.js +0 -125
  325. package/workspace/public/pm/palette-copy.js +0 -55
  326. package/workspace/public/pm/palette.js +0 -343
  327. package/workspace/public/pm/panel-breakdown.js +0 -702
  328. package/workspace/public/pm/panel-cockpit.js +0 -425
  329. package/workspace/public/pm/panel-detail.js +0 -1513
  330. package/workspace/public/pm/panel-initiatives.js +0 -929
  331. package/workspace/public/pm/panel-newsess.js +0 -709
  332. package/workspace/public/pm/panel-repos.js +0 -741
  333. package/workspace/public/pm/panel-tabs.js +0 -1506
  334. package/workspace/public/pm/panel-trees.js +0 -204
  335. package/workspace/public/pm/people-link.js +0 -106
  336. package/workspace/public/pm/phone-deck.js +0 -167
  337. package/workspace/public/pm/pm-work-view.js +0 -1533
  338. package/workspace/public/pm/portfolio-report.js +0 -61
  339. package/workspace/public/pm/premium-acts.js +0 -280
  340. package/workspace/public/pm/premium-brief.js +0 -111
  341. package/workspace/public/pm/premium-chat.js +0 -22
  342. package/workspace/public/pm/premium-doc-sheet.js +0 -312
  343. package/workspace/public/pm/premium-initiative.js +0 -324
  344. package/workspace/public/pm/premium-insights.css +0 -228
  345. package/workspace/public/pm/premium-metric-tiles.js +0 -68
  346. package/workspace/public/pm/premium-report-brief.js +0 -132
  347. package/workspace/public/pm/premium-vw-rec.js +0 -67
  348. package/workspace/public/pm/premium-wide.css +0 -30
  349. package/workspace/public/pm/print.css +0 -44
  350. package/workspace/public/pm/provider-cards.js +0 -136
  351. package/workspace/public/pm/registry.js +0 -203
  352. package/workspace/public/pm/release-card.js +0 -110
  353. package/workspace/public/pm/releases-view.js +0 -248
  354. package/workspace/public/pm/report-families-view.js +0 -505
  355. package/workspace/public/pm/report-slides.js +0 -438
  356. package/workspace/public/pm/report-tab.js +0 -33
  357. package/workspace/public/pm/report-view.js +0 -337
  358. package/workspace/public/pm/reports-copy.js +0 -134
  359. package/workspace/public/pm/roadmap.js +0 -294
  360. package/workspace/public/pm/run-card.js +0 -260
  361. package/workspace/public/pm/sessions-panel.js +0 -219
  362. package/workspace/public/pm/sheet-jira.js +0 -353
  363. package/workspace/public/pm/shell-bell.js +0 -163
  364. package/workspace/public/pm/shell-model.js +0 -83
  365. package/workspace/public/pm/shell-phone.js +0 -124
  366. package/workspace/public/pm/shell-readaloud.js +0 -53
  367. package/workspace/public/pm/shell-recording.js +0 -274
  368. package/workspace/public/pm/shell-ticker.js +0 -90
  369. package/workspace/public/pm/sig-watch.js +0 -41
  370. package/workspace/public/pm/slide-confirm.js +0 -163
  371. package/workspace/public/pm/slides-copy.js +0 -52
  372. package/workspace/public/pm/status-banner.js +0 -95
  373. package/workspace/public/pm/tab-doc.js +0 -859
  374. package/workspace/public/pm/tab-gone.js +0 -21
  375. package/workspace/public/pm/tab-term.js +0 -1210
  376. package/workspace/public/pm/tab-web.js +0 -90
  377. package/workspace/public/pm/timeline-copy.js +0 -48
  378. package/workspace/public/pm/timeline-forecast-view.js +0 -164
  379. package/workspace/public/pm/today-agenda.js +0 -331
  380. package/workspace/public/pm/today-cards.js +0 -244
  381. package/workspace/public/pm/today-copy.js +0 -506
  382. package/workspace/public/pm/today-day.js +0 -1371
  383. package/workspace/public/pm/today-goals.js +0 -297
  384. package/workspace/public/pm/today-jobs.js +0 -84
  385. package/workspace/public/pm/today-mentions.js +0 -50
  386. package/workspace/public/pm/topbar.js +0 -202
  387. package/workspace/public/pm/triage-card.js +0 -60
  388. package/workspace/public/pm/undo-hold.js +0 -103
  389. package/workspace/public/pm/view-addrepo.js +0 -208
  390. package/workspace/public/pm/view-files.js +0 -197
  391. package/workspace/public/pm/view-livenotes.js +0 -399
  392. package/workspace/public/pm/view-today.js +0 -13
  393. package/workspace/public/pm/view-validate.js +0 -171
  394. package/workspace/public/pm/welcome.js +0 -391
  395. package/workspace/public/pm/work-place.js +0 -68
  396. package/workspace/public/pm/xlsx-read.js +0 -117
  397. package/workspace/public/welcome.html +0 -22
  398. package/workspace/test-lists/browser-suites-green.json +0 -5
  399. package/workspace/test-lists/c3-core-docs.json +0 -9
  400. package/workspace/test-lists/c3-doc-sheet-rich.json +0 -6
  401. package/workspace/test-lists/c3-doc-sheet-size.json +0 -6
  402. package/workspace/test-lists/c3-doc-sheet-v2.json +0 -6
  403. package/workspace/test-lists/c3-ib-items.json +0 -9
  404. package/workspace/test-lists/c3-ib-more.json +0 -9
  405. package/workspace/test-lists/c3-ib-triage-backlog.json +0 -9
  406. package/workspace/test-lists/c3-ini-life.json +0 -9
  407. package/workspace/test-lists/c3-meeting-board.json +0 -5
  408. package/workspace/test-lists/c3-meeting-card.json +0 -5
  409. package/workspace/test-lists/c3-notes-place.json +0 -5
  410. package/workspace/test-lists/c3-notes-series.json +0 -5
  411. package/workspace/test-lists/calendar-time-page.json +0 -5
  412. package/workspace/test-lists/calpop.json +0 -4
  413. package/workspace/test-lists/console3-briefing.json +0 -9
  414. package/workspace/test-lists/console3-foundation.json +0 -9
  415. package/workspace/test-lists/console3-work-page.json +0 -9
  416. package/workspace/test-lists/premium-brief-parity.json +0 -9
  417. package/workspace/test-lists/report-design-studio-ui.json +0 -5
  418. package/workspace/test-lists/report-structure-ui.json +0 -11
  419. package/workspace/test-lists/report-workspace-ui.json +0 -5
  420. package/workspace/test-lists/run3-a.json +0 -5
  421. package/workspace/test-lists/run3-d.json +0 -6
  422. package/workspace/test-lists/run4-c.json +0 -13
  423. package/workspace/test-lists/today-goals-jobs-ui.json +0 -5
  424. package/workspace/test-lists/today-mentions-cards.json +0 -5
  425. package/workspace/test-lists/workspace-tabs-declutter.json +0 -13
@@ -1,248 +0,0 @@
1
- /* pm/c3-scan-next.js — the "Proposed next steps (N)" panel of a Horizon scan document, and the way a scan document opens (initiative
2
- * horizon-scan-portfolio, PRD section 4; mockup 42-hscan.js X.panel).
3
- *
4
- * A scan report is a markdown file in the state folder (`<state>/reports/scan-<type>/<date>.md`) whose front matter says `source: scan:portfolio`
5
- * and `report: <record id>`. It opens in the EXISTING document sheet (c3-doc-sheet.js) by its path: GET /api/doc reads any file inside the
6
- * workspace root, and the state folder is inside it. This module adds the one thing the sheet does not know: the panel of proposals. It joins the
7
- * sheet through the `docAbove` list that c3-doc-sheet.js exports, so the sheet holds no scan code. The panel shows only for a document whose front
8
- * matter has `source: scan:*`. It sits under the sheet's header and tabs, collapsed, and scrolls with the text.
9
- *
10
- * Each proposal has a kind: create (title, board, lane, anchor, intent, starts in), research (question, depth, result) or attach
11
- * (initiative). Each has FROM (the finding in the document), EVIDENCE chips, Approve, Change first (the fields as a form, then
12
- * Approve with changes) and Dismiss (a one-line reason is required). Nothing acts without a press. Calls: c3-scan-api.js only.
13
- * openScanDoc(ws, report, { panel }) open a report in the document sheet; panel: true opens it with the proposals showing
14
- * proposalsPanel({ ws, path, text }) the panel node (the sheet's hook calls it)
15
- * goBoard(board, tab) open a board on the Initiatives tab
16
- * Undo takes back a dismissal, and a change made with Change first. Approve has no Undo: create made a real initiative and research started runs.
17
- * Pure parts (Node-testable): outOf, evidenceHref, shortRef, sumLine.
18
- */
19
- import { el } from './dom.js';
20
- import { icon, pbtn, lk, btn, chip, kv, put } from './c3-ini-ui.js';
21
- import { toast } from './c3-toast.js';
22
- import { docAbove } from './c3-doc-sheet.js';
23
- import { frontOf, getReport, getPortfolio, getBoards, loadChoices, postProposal, postStop, readOut, scanChanged, onScanChange } from './c3-scan-api.js';
24
-
25
- export const KIND_WORDS = { create: ['Create initiative', 'init'], research: ['Research more', 'search'], attach: ['Add to an existing initiative', 'plus'] };
26
- export const LANES = [['feature', 'Feature'], ['discovery', 'Discovery'], ['chore', 'Chore'], ['content', 'Content']];
27
- export const DEPTHS = [['quick', 'Quick', 'About 8 public pages, 5 minutes'], ['standard', 'Standard', 'About 20 public pages, 10 minutes'], ['deep', 'Deep', 'About 50 public pages, 30 minutes']];
28
- const EV_IC = { web: 'out', jira: 'org', note: 'doc', slack: 'mail', repo: 'repo' };
29
- const EV_T = { web: 'Public page', jira: 'Jira item', note: 'Note', slack: 'Slack thread', repo: 'Repository' };
30
- const isOpen = (p) => p.state === 'open' || p.state === 'running';
31
- const cap = (s) => (s ? s[0].toUpperCase() + s.slice(1) : '');
32
-
33
- /** What an approve press made, from the server's answer: { id, board, stage } (the initiative is an object in the answer: result.initiative.id). */
34
- export function outOf(r) {
35
- const o = readOut(r && r.result);
36
- return o ? { id: o.id, board: o.board, stage: o.stage } : { id: '', board: '', stage: '' };
37
- }
38
- /** The address a public-page evidence chip opens, or '' for a chip that opens nothing (a Jira key, a note, a path, or a scheme other than http). */
39
- export function evidenceHref(e) {
40
- const ref = String(e && e.ref || '').trim();
41
- if (!ref || (e && e.kind && e.kind !== 'web')) return '';
42
- if (/^https?:\/\//i.test(ref)) return ref;
43
- if (/^[a-z][a-z0-9+.-]*:/i.test(ref)) return '';
44
- return /^[\w-]+(\.[\w-]+)+(\/\S*)?$/.test(ref) ? 'https://' + ref : '';
45
- }
46
- export const shortRef = (ref) => String(ref || '').replace(/^https?:\/\/(www\.)?/i, '').replace(/\/$/, '');
47
- /** "1 create initiative, 1 research more, 1 add to an existing initiative", or "All handled." */
48
- export function sumLine(list) {
49
- const open = list.filter(isOpen);
50
- if (!open.length) return 'All handled.';
51
- return ['create', 'research', 'attach'].map((k) => [k, open.filter((p) => p.kind === k).length]).filter((x) => x[1]).map(([k, c]) => c + ' ' + KIND_WORDS[k][0].toLowerCase()).join(', ');
52
- }
53
-
54
- /* ── open a scan document ── */
55
- const WANT_PANEL = new Set();
56
- export async function openScanDoc(ws, r, o = {}) {
57
- if (!r || !r.path || r.written === false) { toast({ text: 'This report is not written yet. It opens when the scan ends.', tone: 'error' }); return; }
58
- if (o.panel) WANT_PANEL.add(r.path);
59
- const { openDocSheet } = await import('./c3-doc-sheet.js');
60
- return openDocSheet({ ws, doc: { path: r.path, name: r.title || r.path, ty: 'Report', v: '', st: 'current', ini: '', iniName: 'Portfolio' }, mode: 'read' });
61
- }
62
-
63
- /** Open a board on the Initiatives tab (the way the Briefing's old card did: the address, then the shell's own go). */
64
- export function goBoard(board, tab = 'initiatives') {
65
- try { const u = new URL(location.href); u.searchParams.set('init', 'board:' + encodeURIComponent(board) + ':' + tab); history.replaceState(history.state, '', u); } catch { /* no history */ }
66
- return import('./c3-brief.js').then((m) => { if (m.hooks && m.hooks.go) m.hooks.go({ action: 'goinit' }); try { window.dispatchEvent(new CustomEvent('pmos:ini-go', { detail: { board, tab } })); } catch { /* no events */ } });
67
- }
68
-
69
- /* ── the panel ── */
70
- export function proposalsPanel({ ws, path, text }) {
71
- const F = frontOf(text);
72
- const S = { list: [], loaded: false, err: '', open: WANT_PANEL.delete(path), busy: new Set(), ui: {}, boards: [], choices: null, reportId: F.report || '', timer: null, seen: new Map() };
73
- const root = el('section', { class: 'sc-next', 'aria-label': 'Proposed next steps', 'data-scan-next': '', hidden: true });
74
- const st = (id) => (S.ui[id] ||= { mode: 'view', draft: {}, why: '', bad: false });
75
- const name = (b) => (S.boards.find((x) => x.id === b) || { name: b || '' }).name;
76
-
77
- async function load() {
78
- let id = S.reportId;
79
- if (!id) { const d = await getPortfolio(ws); const r = d.reports.find((x) => x.path === path); id = r ? r.id : ''; S.reportId = id; }
80
- if (!id) { S.loaded = true; draw(); return; }
81
- const r = await getReport(ws, id);
82
- S.loaded = true; S.err = r.ok ? '' : r.error;
83
- if (r.ok) {
84
- for (const p of r.proposals) { const was = S.seen.get(p.id); if (was === 'running' && p.state === 'done' && p.kind === 'research') toast('Research finished. The follow-up document is in Documents, linked to this one.'); S.seen.set(p.id, p.state); }
85
- S.list = r.proposals;
86
- }
87
- draw();
88
- clearTimeout(S.timer);
89
- if (S.list.some((p) => p.state === 'running')) S.timer = setTimeout(() => { if (root.isConnected) load(); }, 2500);
90
- }
91
- // The form draws once the boards and anchors are in, so a redraw never replaces a field the PM is typing in.
92
- async function choices() { if (!S.choices) { try { S.choices = await loadChoices(ws); } catch { S.choices = { boards: [], anchors: [], initiatives: [] }; } } draw(); }
93
- async function press(p, body, after) {
94
- if (S.busy.has(p.id)) return null;
95
- S.busy.add(p.id); draw();
96
- const r = await postProposal(ws, { id: p.id, ...body });
97
- S.busy.delete(p.id);
98
- if (!r || r.ok === false) { toast({ text: 'That did not work: ' + ((r && r.error) || 'the workspace did not answer') + '.', tone: 'error', timeout: 6000 }); draw(); return null; }
99
- if (after) after(r);
100
- await load(); scanChanged();
101
- return r;
102
- }
103
- const undo = (p, what = 'dismissal') => press(p, { action: 'undo' }, () => toast(what === 'dismissal' ? 'Undone. The proposal waits for you again.' : 'Your changes are undone. The proposal is as the agent filed it.'));
104
- const valOf = (p, k) => { const d = st(p.id).draft; return k in d ? d[k] : p.fields[k]; };
105
- async function approve(p) {
106
- const u = st(p.id); const target = valOf(p, 'initiative');
107
- if (u.mode === 'change' && Object.keys(u.draft).length) {
108
- const c = await press(p, { action: 'change', fields: { ...u.draft } });
109
- if (!c) return;
110
- }
111
- u.mode = 'view'; u.draft = {};
112
- // Approve has no Undo: create makes a real initiative on the board and research starts runs. The toast says what happened.
113
- await press(p, { action: 'approve' }, (r) => {
114
- if (p.kind === 'create') { const o = outOf(r); const stage = o.stage || 'its first stage'; toast({ text: (o.id ? o.id + ' created' : 'Initiative created') + (o.board ? ' on ' + name(o.board) : '') + ' in ' + stage + ', with the report as evidence. The Initiative Driver starts on ' + stage + '.', timeout: 8000 }); }
115
- else if (p.kind === 'attach') toast({ text: 'Attached to ' + (target || 'the initiative') + ' as evidence. Nothing else changed.', timeout: 8000 });
116
- else toast('Research started. It reads public pages by topic only and sends nothing.');
117
- });
118
- }
119
- async function dismiss(p) {
120
- const u = st(p.id); const why = u.why.trim();
121
- if (!why) { u.bad = true; draw(); const f = root.querySelector('[data-scan-f="why"][data-id="' + p.id + '"]'); if (f) f.focus(); return; }
122
- u.mode = 'view'; u.bad = false;
123
- await press(p, { action: 'dismiss', why }, () => toast({ text: 'Dismissed. Counted as a correction. The scan will not raise this again.', onAction: () => undo(p), timeout: 8000 }));
124
- }
125
- function jump(p) {
126
- const sheet = root.closest('.sheet') || document;
127
- const rb = sheet.querySelector('[data-dmode="read"]');
128
- if (rb && rb.getAttribute('aria-pressed') !== 'true') rb.click();
129
- setTimeout(() => {
130
- const want = String(p.from || '').toLowerCase(); const head = want.split(':')[0].trim();
131
- const nodes = [...sheet.querySelectorAll('h1,h2,h3,h4,h5,li,p,td,th')].filter((n) => !root.contains(n));
132
- const hit = nodes.find((n) => want && n.textContent.toLowerCase().includes(want)) || nodes.find((n) => head && n.textContent.toLowerCase().includes(head));
133
- if (hit) { hit.scrollIntoView({ block: 'center' }); hit.classList.remove('flash'); void hit.offsetWidth; hit.classList.add('flash'); }
134
- }, 60);
135
- }
136
- async function openFollowUp(p) {
137
- const d = await getPortfolio(ws);
138
- const r = d.reports.find((x) => p.out && p.out.report && x.id === p.out.report) || d.reports.find((x) => x.parent === p.report) || d.reports.find((x) => x.parent && x.parent === S.reportId);
139
- if (r) openScanDoc(ws, r, { panel: true }); else toast({ text: 'The follow-up document is not in the list yet.', tone: 'error' });
140
- }
141
-
142
- /* ── drawing ── */
143
- const field = (label, ctl) => el('label', { class: 'sc-f' }, el('span', { class: 'dim mono' }, label), ctl);
144
- const opts = (list, cur) => { const l = list.map((o) => (Array.isArray(o) ? o : [o, o])); if (cur && !l.some((o) => String(o[0]) === String(cur))) l.unshift([cur, cur]); return l.map(([v, t]) => el('option', { value: v, selected: String(v) === String(cur) }, t)); };
145
- const input = (p, k, label, attrs) => el('input', { type: 'text', value: valOf(p, k) || '', 'aria-label': label, 'data-scan-f': k, 'data-id': p.id, oninput: (e) => { st(p.id).draft[k] = e.target.value; }, ...(attrs || {}) });
146
- const area = (p, k, label) => { const a = el('textarea', { rows: '2', 'aria-label': label, 'data-scan-f': k, 'data-id': p.id, oninput: (e) => { st(p.id).draft[k] = e.target.value; } }); a.value = valOf(p, k) || ''; return a; };
147
- const select = (p, k, label, list) => el('select', { 'aria-label': label, 'data-scan-f': k, 'data-id': p.id, onchange: (e) => { st(p.id).draft[k] = e.target.value; } }, ...opts(list, valOf(p, k)));
148
-
149
- function details(p) {
150
- const f = p.fields; const ch = st(p.id).mode === 'change'; const C = S.choices || { boards: [], anchors: [], initiatives: [] };
151
- if (ch && !S.choices) return el('div', { class: 'sc-form', 'data-scan-form': p.id, 'aria-busy': 'true' }, el('span', { class: 'dim' }, 'Reading the boards and anchors…'));
152
- if (p.kind === 'create') {
153
- if (!ch) return kv([['Title', f.title], ['Board', [name(f.board) || 'the agent will choose', ' ', el('span', { class: 'tag' }, p.changed ? 'changed by you' : 'chosen by the agent')]], ['Lane', cap(f.lane)], ['Anchor', f.anchor],
154
- ['Intent', f.intent], ['Starts in', "The first stage of the board's workflow, with this document as evidence"]], { 'data-scan-kv': 'create' });
155
- return el('div', { class: 'sc-form', 'data-scan-form': p.id },
156
- field('TITLE', input(p, 'title', 'Initiative title')),
157
- el('div', { class: 'sc-row' }, field('BOARD', select(p, 'board', 'Board', (C.boards.length ? C.boards : [{ id: f.board, name: name(f.board) }]).map((b) => [b.id, b.name + (b.id === f.board && !p.changed ? ' (agent choice)' : '')]))),
158
- field('LANE', select(p, 'lane', 'Lane', LANES))),
159
- field('ANCHOR (A KEY RESULT OR A HEALTH BUDGET)', C.anchors.length ? select(p, 'anchor', 'Anchor', C.anchors.map((a) => [a.value, a.label])) : input(p, 'anchor', 'Anchor', { placeholder: 'A key result or health:<id>' })),
160
- field('INTENT', area(p, 'intent', 'Intent')));
161
- }
162
- if (p.kind === 'research') {
163
- const dp = DEPTHS.find((x) => x[0] === valOf(p, 'depth')) || DEPTHS[1];
164
- if (!ch) return kv([['Question', f.question], ['Sources', 'Public pages on the topic. Nothing from the repository is sent.'], ['Depth', dp[1] + ': ' + dp[2]], ['Result', 'A new document in Documents, linked to this one']], { 'data-scan-kv': 'research' });
165
- return el('div', { class: 'sc-form', 'data-scan-form': p.id }, field('QUESTION', area(p, 'question', 'Research question')),
166
- field('DEPTH', select(p, 'depth', 'Depth', DEPTHS.map((x) => [x[0], x[1] + ': ' + x[2]]))), el('div', { class: 'dim sc-sm' }, 'Public pages on the topic. Nothing from the repository is sent.'));
167
- }
168
- if (!ch) return kv([['Attach to', f.initiative ? chip(icon('init', 'sm'), (C.initiatives.find((i) => i.id === f.initiative) ? f.initiative + ' ' + C.initiatives.find((i) => i.id === f.initiative).title : f.initiative)) : '—'], ['What it adds', p.why], ['Shown in', 'Evidence and research on that initiative']], { 'data-scan-kv': 'attach' });
169
- return el('div', { class: 'sc-form', 'data-scan-form': p.id }, field('ATTACH TO', C.initiatives.length ? select(p, 'initiative', 'Initiative', C.initiatives.map((i) => [i.id, i.id + ' ' + i.title])) : input(p, 'initiative', 'Initiative', { placeholder: 'An initiative id, e.g. IDPF-12' })),
170
- el('div', { class: 'dim sc-sm' }, p.why));
171
- }
172
- function acts(p) {
173
- const u = st(p.id); const busy = S.busy.has(p.id); const ch = u.mode === 'change';
174
- const verb = p.kind === 'research' ? 'Approve and start' : p.kind === 'attach' ? 'Approve and attach' : 'Approve';
175
- if (u.mode === 'dismiss') {
176
- const why = el('input', { type: 'text', value: u.why, placeholder: 'For example: we already decided this', 'aria-label': 'Reason for dismissing', 'data-scan-f': 'why', 'data-id': p.id, class: u.bad ? 'bad' : '',
177
- oninput: (e) => { u.why = e.target.value; u.bad = false; }, onkeydown: (e) => { if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); dismiss(p); } } });
178
- return el('div', { class: 'sc-form' }, field('WHY DO YOU DISMISS IT? ONE LINE', why),
179
- u.bad ? el('div', { class: 'fold w', role: 'alert', 'data-scan-need-why': '' }, icon('alert', 'sm'), 'Say why. The reason is kept and the scan will not raise this again.') : null,
180
- el('div', { class: 'dim sc-sm' }, 'A dismissal counts as a correction. The scan will not raise the same thing again.'),
181
- el('div', { class: 'chips2' }, pbtn('primary', 'Dismiss', 'x', { 'data-scan-act': 'dismiss-ok', 'data-id': p.id, disabled: busy, onclick: () => dismiss(p) }), pbtn('ghost', 'Cancel', null, { 'data-scan-act': 'cancel', 'data-id': p.id, onclick: () => { u.mode = 'view'; u.bad = false; draw(); } })));
182
- }
183
- return el('div', { class: 'chips2' }, pbtn('primary', ch ? 'Approve with changes' : verb, 'check', { 'data-scan-act': 'approve', 'data-id': p.id, disabled: busy, onclick: () => approve(p) }),
184
- p.changed ? pbtn('ghost', 'Undo my changes', null, { 'data-scan-act': 'undo-change', 'data-id': p.id, disabled: busy, onclick: () => { u.mode = 'view'; u.draft = {}; undo(p, 'change'); } }) : null,
185
- ch ? pbtn('outline', 'Cancel', null, { 'data-scan-act': 'cancel', 'data-id': p.id, onclick: () => { u.mode = 'view'; u.draft = {}; draw(); } })
186
- : pbtn('outline', 'Change first', 'edit', { 'data-scan-act': 'change', 'data-id': p.id, disabled: busy, onclick: () => { u.mode = 'change'; draw(); choices(); } }),
187
- pbtn('ghost', 'Dismiss', 'x', { 'data-scan-act': 'dismiss', 'data-id': p.id, disabled: busy, onclick: () => { u.mode = 'dismiss'; draw(); const f = root.querySelector('[data-scan-f="why"][data-id="' + p.id + '"]'); if (f) f.focus(); } }));
188
- }
189
- function result(p) {
190
- if (p.state === 'dismissed') return el('div', { class: 'fold', 'data-scan-result': 'dismissed' }, icon('x', 'sm'), ' Dismissed' + (p.reason ? ': ' + p.reason : '') + '. Counted as a correction. The scan will not raise this again. ', pbtn('ghost', 'Undo', null, { 'data-scan-act': 'undo', 'data-id': p.id, onclick: () => undo(p) }));
191
- if (p.kind === 'research') return el('div', { class: 'fold a', 'data-scan-result': 'research' }, icon('check', 'sm'), ' Research finished. ', pbtn('primary', 'Open the follow-up document', 'out', { 'data-scan-act': 'follow-up', 'data-id': p.id, onclick: () => openFollowUp(p) }));
192
- if (p.kind === 'attach') return el('div', { class: 'fold a', 'data-scan-result': 'attach' }, icon('check', 'sm'), ' Attached to ' + ((p.out && p.out.id) || valOf(p, 'initiative')) + ' as evidence.');
193
- const o = p.out || {};
194
- return el('div', { class: 'fold a', 'data-scan-result': 'create' }, icon('check', 'sm'), ' Created ' + (o.id || 'the initiative') + (o.board ? ' on ' + name(o.board) : '') + (o.stage ? ', in ' + o.stage + '. The Initiative Driver starts on ' + o.stage : '') + '. ',
195
- o.board ? pbtn('outline', 'Open in the board', 'out', { 'data-scan-act': 'go-board', 'data-id': p.id, onclick: () => goBoard(o.board) }) : null);
196
- }
197
- function runBox(p) {
198
- const steps = Array.isArray(p.steps) && p.steps.length ? p.steps : [{ label: 'Research is running', state: 'running' }];
199
- return el('div', { class: 'sc-run', role: 'status', 'aria-label': 'Research running', 'data-scan-run': p.id },
200
- el('ul', { class: 'chgl' }, ...steps.map((s) => el('li', null, icon(s.state === 'done' ? 'check' : s.state === 'failed' ? 'alert' : s.state === 'pending' || s.state === 'skipped' ? 'info' : 'clock', 'sm'), el('span', { class: s.state === 'pending' || s.state === 'skipped' ? 'dim' : '' }, s.label), el('span', { class: 'dim' }, s.state === 'done' ? 'done' : s.state === 'running' ? 'now' : s.state === 'failed' ? 'failed' : s.state === 'skipped' ? 'skipped' : '')))),
201
- el('div', { class: 'chips2' }, pbtn('outline', 'Stop', 'x', { 'data-scan-act': 'rstop', 'data-id': p.id, onclick: async () => { const r = await postStop(ws); if (r && r.ok === false) toast({ text: 'Stop did not work: ' + (r.error || 'no answer') + '.', tone: 'error' }); else toast('Research stopped. Nothing was written.'); await load(); scanChanged(); } }),
202
- el('span', { class: 'dim sc-sm' }, 'Reads public pages by topic only. Sends nothing.')));
203
- }
204
- function item(p) {
205
- const fin = p.state === 'done' || p.state === 'dismissed';
206
- const k = KIND_WORDS[p.kind];
207
- return el('li', { class: 'sc-p', 'data-scan-prop': p.id, 'data-scan-kind': p.kind, 'data-scan-state': p.state },
208
- el('div', { class: 'l1' }, el('span', { class: 'sc-ki' }, icon(k[1], 'sm')), el('b', null, p.title), el('span', { class: 'tag' + (p.kind === 'create' ? ' acc' : '') }, k[0])),
209
- p.why ? el('p', null, p.why) : null,
210
- p.from ? el('div', { class: 'chips' }, el('span', { class: 'dim mono sc-sm' }, 'FROM'), lk({ 'data-scan-act': 'jump', 'data-id': p.id, onclick: () => jump(p) }, icon('eye', 'sm'), p.from)) : null,
211
- p.evidence.length ? el('div', { class: 'chips' }, el('span', { class: 'dim mono sc-sm' }, 'EVIDENCE'), ...p.evidence.map(evChip)) : null,
212
- fin ? result(p) : p.state === 'running' ? runBox(p) : [details(p), acts(p)]);
213
- }
214
- function draw() {
215
- const l = S.list;
216
- root.hidden = !l.length;
217
- if (!l.length) { put(root); return; }
218
- const n = l.filter(isOpen).length;
219
- put(root,
220
- el('div', { class: 'hd' },
221
- btn({ class: 'sc-tg', 'data-scan-act': 'panel', 'aria-expanded': String(S.open), onclick: () => { S.open = !S.open; draw(); } }, icon('next', 'sm'), el('b', null, 'Proposed next steps (' + n + ')'), el('span', { class: 'dim' }, sumLine(l))),
222
- el('span', { class: 'tag acc' }, icon('spark', 'sm'), 'Nothing happens until you click')),
223
- S.open ? el('ul', { class: 'sc-pl' }, ...l.map(item)) : null,
224
- S.open ? el('div', { class: 'dim sc-sm' }, 'Approve, change or dismiss each one. A dismissal needs a reason and counts as a correction. The scan does not raise it again.') : null);
225
- }
226
-
227
- getBoards(ws).then((b) => { S.boards = b; draw(); });
228
- load();
229
- const off = onScanChange(() => { if (!root.isConnected) { off(); clearTimeout(S.timer); return; } load(); });
230
- return root;
231
- }
232
-
233
- function evChip(e) {
234
- const k = EV_IC[e.kind] ? e.kind : 'note';
235
- const inner = [icon(EV_IC[k], 'sm'), el('span', { class: 'mono' }, shortRef(e.ref))];
236
- const tip = (e.label ? e.label + '. ' : '') + EV_T[k];
237
- const href = evidenceHref(e);
238
- if (href) return el('a', { class: 'chip2 lk sc-link', href, target: '_blank', rel: 'noopener noreferrer', title: tip, 'data-scan-ev': k }, ...inner);
239
- return el('span', { class: 'chip2', title: tip, 'data-scan-ev': k }, ...inner);
240
- }
241
-
242
- /* ── the sheet's hook: a panel for a document that says `source: scan:*`, one node per open sheet ── */
243
- const NODES = new WeakMap();
244
- docAbove.push(({ ws, doc, text, key }) => {
245
- if (text == null || !/^scan:/.test(frontOf(text).source || '')) return null;
246
- if (!NODES.has(key)) NODES.set(key, proposalsPanel({ ws, path: doc.path, text }));
247
- return NODES.get(key);
248
- });
@@ -1,313 +0,0 @@
1
- /* pm/c3-scan-setup.js — the portfolio Horizon scan's own screens (initiative horizon-scan-portfolio, PRD sections 1 to 3; mockup 42-hscan.js).
2
- *
3
- * scanPortfolioSection({ ws, boardCount, showTab }) the "Horizon scan" section of Initiatives > Portfolio: the whole portfolio and its board
4
- * count, a primary Scan now that is always there, the Horizon scan setup button, the
5
- * latest scan's reports and the "Waiting for you: N proposals" line
6
- * scanPointer(ws) the one line in Board settings: "Horizon scan runs for the whole portfolio"
7
- * openScanSetup(ws, o) the setup sheet: last and next scan with Scan now, How often (Daily, Weekly, Off), the repository and the report
8
- * types, the watch list (kind and board chips; Keep, Edit, Remove, Add; Keep all on first use)
9
- * openScanPicker(ws, o) Scan now: what this scan reads and writes (items, repository, report types), then the running sheet
10
- * openScanRunning(ws, o) the steps of the scan that is running, with Stop
11
- * Reads and presses: c3-scan-api.js only. Each screen draws at once and fills itself from the server; every press posts, then reads again.
12
- * Every part that draws the scan listens to onScanChange, so a press on one screen updates the others. Nothing is sent outward.
13
- */
14
- import { el } from './dom.js';
15
- import { field } from './primitives.js';
16
- import { icon, pbtn, lk, btn, chip, st as stc, sect, plural, put, nrow, list, geo } from './c3-ini-ui.js';
17
- import { openSheet } from './c3-sheet.js';
18
- import { toast } from './c3-toast.js';
19
- import { TYPES, TYPE_KEYS, KINDS, typeName, getPortfolio, getBoards, getDismissed, postWatch, postSetting, postNow, postStop, scanNowWords, scanChanged, onScanChange } from './c3-scan-api.js';
20
- import { openScanDoc } from './c3-scan-next.js';
21
- import { pastLabel, nextLabel, scheduleLine, ensureScanCss, latestReports } from './c3-scan-words.js';
22
-
23
- export { latestReports };
24
-
25
- const KIND_ICON = { product: 'org', domain: 'report', approach: 'bolt' };
26
- const kindTag = (k) => el('span', { class: 'tag' + (k === 'product' ? ' acc' : '') }, k);
27
- const errText = (r, what) => what + ': ' + ((r && r.error) || 'the workspace did not answer') + '.';
28
- /** The proposals waiting: all of them (the server counts them), or those of one report (the report row says how many are open). */
29
- const waitingOf = (d, report) => (report ? ((d.reports.find((r) => r.id === report) || {}).open || 0) : d.waiting);
30
- /** Scan now may start: the server says so in `manual`. A scan already running is not a refusal here, since the button then opens the running sheet. */
31
- const blocked = (d) => !!d && !d.manual.ok && d.manual.why !== 'running';
32
- /** "2 of 3 manual scans left today", or the reason Scan now is off, in the server's words. */
33
- const leftLine = (d) => (d.manual.ok || d.manual.why === 'running' ? d.manual.left + ' of ' + d.manual.limit + ' manual scans left today.' : scanNowWords({ why: d.manual.why, error: d.manual.error, limit: d.manual.limit }));
34
- const SCHED_NOTE = scheduleLine;
35
-
36
- /** A check box with a title and a line of help, drawn by the field primitive. attrs go on the input. */
37
- function check(on, title, help, tag, attrs, onChange) {
38
- return field({ kind: 'check', value: on, onCommit: onChange, attrs, label: el('span', { class: 'sc-chkl' }, el('b', null, title), tag || null, help ? [el('br'), el('span', { class: 'dim sc-sm' }, help)] : null) });
39
- }
40
- const boardChip = (boards, id) => { const b = boards.find((x) => x.id === id); return chip(icon('cols', 'sm'), b ? b.name : id); };
41
-
42
- /* ══ the setup sheet ══ */
43
- export function openScanSetup(ws, o = {}) {
44
- ensureScanCss();
45
- const V = { d: null, boards: [], dismissed: [], err: '', busy: false, edit: null, editValue: '', addName: '', addKind: 'product', addWhy: '', addBoard: '', addErr: '' };
46
- const host = el('div', { class: 'sc-hs', 'data-scan-setup': '' });
47
- const head = pbtn('primary', 'Scan now', 'bolt', { 'data-scan-act': 'scan', 'data-scan-head': '', onclick: () => scanNow() });
48
- const ui = openSheet({ title: 'Horizon scan', icon: 'search', body: host, wide: true, dw: true, actions: [head], onClose: () => { off(); } });
49
- const off = onScanChange(() => load());
50
-
51
- async function load() {
52
- const [d, b] = await Promise.all([getPortfolio(ws), V.boards.length ? V.boards : getBoards(ws)]);
53
- V.boards = b;
54
- if (d.ok) { V.d = d; V.err = ''; V.dismissed = await getDismissed(ws, d.reports); } else V.err = errText(d, 'The horizon scan could not be read');
55
- draw();
56
- }
57
- async function press(fn, what, then) {
58
- if (V.busy) return null;
59
- V.busy = true; draw();
60
- const r = await fn();
61
- V.busy = false;
62
- if (!r || r.ok === false) { toast({ text: errText(r, what + ' did not work'), tone: 'error', timeout: 6000 }); await load(); return null; }
63
- if (then) then(r);
64
- scanChanged();
65
- return r;
66
- }
67
- const scanNow = () => { if (V.d && V.d.open) { openScanRunning(ws, o); toast('A scan is already running'); } else if (blocked(V.d)) toast({ text: leftLine(V.d), tone: 'error', timeout: 6000 }); else openScanPicker(ws, o); };
68
- const setCadence = (c) => { if (V.d && V.d.setting.cadence === c) return null; return press(() => postSetting(ws, { cadence: c }), 'The change', () => toast(c === 'off' ? 'Horizon scan is off. Scan now still works.' : 'Horizon scan: ' + scheduleLine(c).toLowerCase())); };
69
- const setRepo = (on) => press(() => postSetting(ws, { repo: on }), 'The change');
70
- const setType = (k, on) => { const cur = V.d.setting.types; return press(() => postSetting(ws, { types: TYPE_KEYS.filter((x) => (x === k ? on : cur.includes(x))) }), 'The change'); };
71
- const keep = (w) => press(() => postWatch(ws, { op: 'keep', id: w.id }), 'Keep');
72
- const keepAll = () => press(async () => { const rs = await Promise.all(V.d.items.filter((w) => w.state === 'suggested').map((w) => postWatch(ws, { op: 'keep', id: w.id }))); return rs.find((r) => !r || r.ok === false) || { ok: true }; }, 'Keep all', () => toast('Kept the watch list'));
73
- const remove = (w) => press(() => postWatch(ws, { op: 'remove', id: w.id }), 'Remove', () => toast({ text: 'Removed ' + w.name, onAction: () => press(() => postWatch(ws, { op: 'keep', id: w.id, restore: true }), 'Undo'), timeout: 7000 }));
74
- const save = async (w) => {
75
- const v = V.editValue.trim(); if (!v) return;
76
- V.edit = null;
77
- if (v !== w.name) await press(() => postWatch(ws, { op: 'edit', id: w.id, name: v }), 'Save');
78
- else if (w.state === 'new') await keep(w); else draw();
79
- };
80
- const add = async () => {
81
- const v = V.addName.trim();
82
- if (!v) { V.addErr = 'Write what to watch first.'; draw(); const i = host.querySelector('[data-scan-add-in]'); if (i) i.focus(); return; }
83
- V.addErr = '';
84
- const r = await press(() => postWatch(ws, { op: 'add', name: v, kind: V.addKind, why: V.addWhy.trim(), boards: V.addBoard ? [V.addBoard] : [] }), 'Add',
85
- () => { const b = V.addBoard; V.addName = ''; V.addWhy = ''; V.addBoard = ''; toast(b ? 'Added for ' + ((V.boards.find((x) => x.id === b) || {}).name || b) + '.' : 'Added for the whole portfolio.'); });
86
- if (!r) draw();
87
- };
88
-
89
- function item(w, deciding) {
90
- if (V.edit === w.id) {
91
- const inp = el('input', { type: 'text', 'data-scan-edit-in': '', value: V.editValue, 'aria-label': 'Watch list item name', maxlength: '80', autocomplete: 'off', oninput: (e) => { V.editValue = e.target.value; },
92
- onkeydown: (e) => { if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); save(w); } else if (e.key === 'Escape') { e.stopPropagation(); V.edit = null; draw(); } } });
93
- setTimeout(() => inp.focus(), 20);
94
- return el('li', { class: 'sc-it', 'data-scan-item': w.id, 'data-scan-state': 'edit' }, icon('eye', 'sm'), el('div', { class: 'sc-main' }, el('div', { class: 'form' }, inp),
95
- el('div', { class: 'sc-acts' }, pbtn('primary', 'Save', 'check', { 'data-scan-act': 'save', 'data-id': w.id, onclick: () => save(w) }), pbtn('ghost', 'Cancel', null, { 'data-scan-act': 'cancel', 'data-id': w.id, onclick: () => { V.edit = null; draw(); } }))));
96
- }
97
- const kept = w.state === 'kept';
98
- return el('li', { class: 'sc-it', 'data-scan-item': w.id, 'data-scan-state': w.state, 'data-scan-kind': w.kind }, icon(KIND_ICON[w.kind] || 'eye', 'sm'),
99
- el('div', { class: 'sc-main' },
100
- el('div', { class: 'sc-name' }, el('b', null, w.name), kindTag(w.kind), kept ? stc('ok', 'check', 'Kept') : null),
101
- (deciding || !kept || w.added) && w.why ? el('span', { class: 'dim sc-sm' }, w.why) : null,
102
- el('div', { class: 'chips' }, el('span', { class: 'dim mono sc-xs' }, 'BOARDS'), ...(w.boards.length ? w.boards.map((b) => boardChip(V.boards, b)) : [chip('none yet')]), el('span', { class: 'dim sc-sm' }, w.added ? 'added by you' : w.ini ? 'from ' + w.ini : 'suggested by the agent')),
103
- el('div', { class: 'sc-acts' }, !kept ? pbtn('outline', 'Keep', 'check', { 'data-scan-act': 'keep', 'data-id': w.id, disabled: V.busy, onclick: () => keep(w) }) : null,
104
- pbtn('ghost', 'Edit', 'edit', { 'data-scan-act': 'edit', 'data-id': w.id, disabled: V.busy, onclick: () => { V.edit = w.id; V.editValue = w.name; draw(); } }),
105
- pbtn('ghost', 'Remove', 'x', { 'data-scan-act': 'remove', 'data-id': w.id, disabled: V.busy, onclick: () => remove(w) }))));
106
- }
107
-
108
- function draw() {
109
- const d = V.d; const sy = host.parentElement ? host.parentElement.scrollTop : 0;
110
- if (!d) {
111
- put(host, V.err ? el('div', { class: 'fold w', role: 'alert', 'data-scan': 'error' }, icon('alert', 'sm'), V.err, ' ', pbtn('outline', 'Try again', null, { onclick: load }))
112
- : el('div', { class: 'dim', 'data-scan': 'loading' }, 'Reading the horizon scan'));
113
- return;
114
- }
115
- const { cadence, repo, types } = d.setting;
116
- const w = d.items; const n = w.length; const pend = w.filter((x) => x.state === 'suggested').length;
117
- head.disabled = blocked(d);
118
- const deciding = !d.last; const scanned = !!d.last;
119
- const mine = latestReports(d); const wait = waitingOf(d);
120
- const now = new Date();
121
- const lastLine = d.open ? 'A scan is running now.' : d.last ? (d.last.ok === false ? 'Last scan did not finish' + (d.last.reason ? ': ' + d.last.reason : '') + '. ' + pastLabel(d.last.at, now) + '.' : 'Last scan: ' + pastLabel(d.last.at, now) + '. ' + plural(mine.length, 'report') + ' written.') : 'Last scan: none yet.';
122
- const nextLine = cadence === 'off' ? 'Next scan: none while the scan is off. Scan now still works.'
123
- : d.next && (scanned || w.some((x) => x.state === 'kept')) ? 'Next scan ' + nextLabel(d.next, now) + '. The agent skips what you dismissed or already saw.' : 'The first scheduled scan runs after you decide on the watch list.';
124
- const status = sect({ ic: 'clock', title: 'Last scan and next scan', attrs: { 'data-scan': 'status' } },
125
- el('div', { class: 'sc-meta' }, el('span', { 'data-scan': 'schedule' }, el('b', null, SCHED_NOTE(cadence) + '.')),
126
- el('span', { class: 'dim', 'data-scan': 'last' }, lastLine, scanned && wait ? [' ', lk({ 'data-scan-act': 'reports', onclick: () => o.showTab ? o.showTab('rep', true) : null }, plural(wait, 'proposal') + ' waiting in Reports')] : null),
127
- el('span', { class: 'dim', 'data-scan': 'next' }, nextLine)),
128
- el('div', { class: 'chips2' }, pbtn('primary', 'Scan now', 'bolt', { 'data-scan-act': 'scan', disabled: blocked(d), onclick: scanNow }),
129
- scanned && mine.length ? pbtn('outline', 'Open the reports', 'doc', { 'data-scan-act': 'reports', onclick: () => mine[0] && openScanDoc(ws, mine[0], { panel: wait > 0 }) }) : null,
130
- el('span', { class: 'dim sc-sm', 'data-scan': 'manual', role: blocked(d) ? 'status' : null }, leftLine(d) + ' Scan now lets you choose what to scan.')));
131
- const freq = sect({ ic: 'cal', title: 'How often', attrs: { 'data-scan': 'freq' } },
132
- el('div', { class: 'chips2' }, el('div', { class: 'seg', role: 'group', 'aria-label': 'How often the agent scans' },
133
- ...[['daily', 'Daily'], ['weekly', 'Weekly'], ['off', 'Off']].map(([k, l]) => btn({ 'aria-pressed': String(cadence === k), 'data-scan-freq': k, disabled: V.busy, onclick: () => setCadence(k) }, l))), el('span', { class: 'dim sc-sm' }, 'Daily is the default.')),
134
- el('div', { class: 'dim sc-sm' }, 'One scan for the whole portfolio, not one per board. It costs one agent run.'));
135
- const fromAgent = w.some((x) => !x.added);
136
- const banner = deciding && n && fromAgent ? el('div', { class: 'fold a', role: 'status', 'data-scan': 'banner' }, icon('spark', 'sm'),
137
- ' The agent suggests ' + plural(n, 'thing') + ' to watch' + (V.boards.length ? (V.boards.length > 1 ? ', from the initiatives on all ' + V.boards.length + ' boards' : ', from the initiatives on the board') : '') + '. Keep, edit or remove each one.' + (pend ? ' ' + pend + ' still to decide.' : ' You decided on all of them.'),
138
- pend ? lk({ 'data-scan-act': 'keepall', onclick: keepAll }, 'Keep all') : null) : null;
139
- const kindSel = el('select', { 'data-scan-add-kind': '', 'aria-label': 'Kind', onchange: (e) => { V.addKind = e.target.value; } }, ...KINDS.map((k) => el('option', { value: k, selected: k === V.addKind }, k)));
140
- const boardSel = el('select', { 'data-scan-add-board': '', 'aria-label': 'Boards it relates to', onchange: (e) => { V.addBoard = e.target.value; } },
141
- el('option', { value: '', selected: !V.addBoard }, 'Whole portfolio'), ...V.boards.map((b) => el('option', { value: b.id, selected: b.id === V.addBoard }, b.name)));
142
- const whyIn = el('input', { type: 'text', 'data-scan-add-why': '', placeholder: 'Why watch it (optional)', 'aria-label': 'Why watch it', maxlength: '200', autocomplete: 'off', value: V.addWhy,
143
- oninput: (e) => { V.addWhy = e.target.value; }, onkeydown: (e) => { if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); add(); } } });
144
- const addIn = el('input', { type: 'text', 'data-scan-add-in': '', placeholder: 'Add something to watch', 'aria-label': 'Add to the watch list', maxlength: '80', autocomplete: 'off', value: V.addName,
145
- oninput: (e) => { V.addName = e.target.value; }, onkeydown: (e) => { if (e.key === 'Enter' && !e.isComposing) { e.preventDefault(); add(); } } });
146
- const watch = sect({ ic: 'eye', title: 'Watch list', count: n, attrs: { 'data-scan': 'watch' } }, banner,
147
- el('ul', { class: 'sc-list', 'data-scan': 'list' }, ...(n ? w.map((x) => item(x, deciding)) : [el('li', { class: 'dim', 'data-scan': 'empty' }, 'The watch list is empty. The web part of the scan has nothing to search for.')])),
148
- el('div', { class: 'sc-add' }, addIn, kindSel, boardSel, whyIn, pbtn('outline', 'Add', 'plus', { 'data-scan-act': 'add', disabled: V.busy, onclick: add })),
149
- V.addErr ? el('div', { class: 'fold w', role: 'alert', 'data-scan': 'add-error' }, icon('alert', 'sm'), V.addErr) : null);
150
- const src = sect({ ic: 'repo', title: 'Sources', attrs: { 'data-scan': 'sources' } },
151
- check(repo, 'Repository', 'Reads the initiatives on all boards, Jira themes, friction notes and delivery data. It stays on this machine.', null, { 'data-scan-repo': '' }, setRepo),
152
- el('div', { class: 'sc-web' }, icon('out', 'sm'), el('span', null, el('b', null, 'Web'), ' ', el('span', { class: 'tag' }, 'topics only'), el('br'), el('span', { class: 'dim sc-sm' }, 'Searches and reads public pages for the watch list topics. It never sees private repository content.'))));
153
- const typesS = sect({ ic: 'report', title: 'Report types', attrs: { 'data-scan': 'types' } },
154
- ...TYPES.map((t) => check(types.includes(t[0]), t[1], t[2], t[3] ? [' ', el('span', { class: 'tag warn' }, 'repository only')] : null, { 'data-scan-type': t[0] }, (on) => setType(t[0], on))),
155
- el('div', { class: 'fold' }, icon('plus', 'sm'), ' More report types come later.'));
156
- const dismissed = V.dismissed;
157
- const dis = dismissed.length ? sect({ ic: 'x', title: 'Dismissed', count: dismissed.length, attrs: { 'data-scan': 'dismissed' } },
158
- el('ul', { class: 'chgl' }, ...dismissed.map((p) => el('li', null, icon('x', 'sm'), el('span', null, el('b', null, p.title), el('br'), el('span', { class: 'dim sc-sm' }, p.reason)), el('span', { class: 'tag' }, 'not raised again'))))) : null;
159
- put(host, status, freq, watch, src, typesS, dis, el('div', { class: 'fold' }, icon('info', 'sm'), ' Nothing is sent outward. The agent proposes; you approve each step. A scan never creates an initiative by itself.'));
160
- if (host.parentElement) host.parentElement.scrollTop = sy;
161
- }
162
- draw(); load();
163
- return ui;
164
- }
165
-
166
- /* ══ Scan now: the picker ══ */
167
- export function openScanPicker(ws, o = {}) {
168
- ensureScanCss();
169
- const P = { d: null, items: {}, repo: true, types: {}, err: '', busy: false, boards: [] };
170
- const host = el('div', { class: 'sc-hs', 'data-scan-pick': '' });
171
- const ui = openSheet({ title: 'Scan now', icon: 'search', body: host, wide: true });
172
- Promise.all([getPortfolio(ws), getBoards(ws)]).then(([d, b]) => {
173
- P.d = d; P.boards = b; P.repo = d.setting.repo;
174
- d.items.filter((w) => w.state === 'kept').forEach((w) => { P.items[w.id] = true; });
175
- TYPES.forEach((t) => { P.types[t[0]] = d.setting.types.includes(t[0]); });
176
- draw();
177
- });
178
- async function start() {
179
- const w = P.d.items.filter((x) => x.state === 'kept' && P.items[x.id]);
180
- const sel = { items: w.map((x) => x.id), repo: P.repo, types: TYPES.map((t) => t[0]).filter((k) => P.types[k]) };
181
- P.busy = true; P.err = ''; draw();
182
- const r = await postNow(ws, sel);
183
- P.busy = false;
184
- if (!r || r.ok === false) { P.err = 'The scan did not start: ' + scanNowWords(r) + '.'; draw(); return; }
185
- scanChanged();
186
- openScanRunning(ws, { ...o, before: new Set(P.d.reports.map((x) => x.id)) });
187
- }
188
- function draw() {
189
- const d = P.d;
190
- if (!d) { put(host, el('div', { class: 'dim' }, 'Reading the horizon scan')); return; }
191
- const live = d.items.filter((w) => w.state === 'kept'); const held = d.items.length - live.length; const nI = live.filter((w) => P.items[w.id]).length; const nT = TYPES.filter((t) => P.types[t[0]]).length;
192
- const none = !nI && !P.repo; const webOnly = !none && !nI && P.repo && TYPES.some((t) => P.types[t[0]] && !t[3]);
193
- const items = sect({ ic: 'eye', title: 'Watch items', count: nI },
194
- el('ul', { class: 'sc-list' }, ...live.map((w) => el('li', { class: 'sc-it sc-pi' }, check(!!P.items[w.id], w.name, '', [' ', kindTag(w.kind)], { 'data-scan-pi': w.id }, (on) => { P.items[w.id] = on; draw(); }),
195
- el('div', { class: 'chips' }, ...w.boards.map((b) => boardChip(P.boards, b)))))),
196
- el('div', { class: 'chips2' }, lk({ 'data-scan-act': 'pall', onclick: () => { live.forEach((x) => { P.items[x.id] = true; }); draw(); } }, 'All'), lk({ 'data-scan-act': 'pnone', onclick: () => { live.forEach((x) => { P.items[x.id] = false; }); draw(); } }, 'None'),
197
- el('span', { class: 'dim sc-sm' }, nI + ' of ' + live.length + ' chosen. The web part sees these topics only.' + (held ? ' ' + plural(held, 'suggestion') + ' not kept yet, so not listed.' : ''))));
198
- const repo = sect({ ic: 'repo', title: 'Repository' }, check(P.repo, 'Read the repository', 'Initiatives on all boards, Jira themes, friction notes and delivery data.', null, { 'data-scan-prepo': '' }, (on) => { P.repo = on; draw(); }));
199
- const types = sect({ ic: 'report', title: 'Report types', count: nT }, ...TYPES.map((t) => check(!!P.types[t[0]], t[1], t[2], t[3] ? [' ', el('span', { class: 'tag warn' }, 'repository only')] : null, { 'data-scan-pt': t[0] }, (on) => { P.types[t[0]] = on; draw(); })));
200
- const warn = (t) => el('div', { class: 'fold w', role: 'alert' }, icon('alert', 'sm'), t);
201
- put(host, el('div', { class: 'fold' }, icon('info', 'sm'), ' Choose what this scan reads and writes. It does not change your schedule (' + SCHED_NOTE(d.setting.cadence).toLowerCase() + ').'),
202
- items, repo, types,
203
- blocked(d) ? warn(leftLine(d)) : null,
204
- none ? warn('Choose at least one watch item or the repository.') : null, webOnly ? warn('No watch item is chosen, so the web reports have nothing to search for. Only the Productivity report can run.') : null,
205
- nT === 0 ? warn('Choose at least one report type.') : null, P.err ? el('div', { class: 'fold w', role: 'alert', 'data-scan': 'start-error' }, icon('alert', 'sm'), P.err) : null,
206
- el('div', { class: 'chips2' }, pbtn('primary', P.busy ? 'Starting' : 'Start the scan', 'bolt', { 'data-scan-act': 'start', disabled: none || !nT || P.busy || blocked(d), onclick: start }), el('span', { class: 'dim sc-sm', 'data-scan': 'left' }, d.manual.left + ' of ' + d.manual.limit + ' manual scans left today.'), pbtn('ghost', 'Cancel', null, { 'data-scan-act': 'cancel', onclick: () => ui.close() })));
207
- }
208
- draw();
209
- return ui;
210
- }
211
-
212
- /* ══ the running sheet ══ */
213
- /** The steps of a scan are web, repo and reports; each is pending | running | done | failed | skipped. */
214
- const STEP_IC = (s) => (s === 'done' ? 'check' : s === 'failed' ? 'alert' : s === 'pending' || s === 'skipped' ? 'info' : 'clock');
215
- const STEP_WORD = { done: 'done', running: 'now', failed: 'failed', skipped: 'skipped', pending: '' };
216
- const settled = (s) => s.state === 'done' || s.state === 'failed' || s.state === 'skipped';
217
- export function openScanRunning(ws, o = {}) {
218
- ensureScanCss();
219
- const R = { d: null, stopped: false, before: o.before || null, seen: false, timer: null, closed: false, stepAt: 0, total: 0, steps: [] };
220
- const host = el('div', { class: 'sc-hs', 'data-scan-run': '' });
221
- const ui = openSheet({ title: 'Scan running', icon: 'search', body: host, wide: true, onClose: () => { R.closed = true; clearTimeout(R.timer); } });
222
- async function poll() {
223
- if (R.closed) return;
224
- const d = await getPortfolio(ws);
225
- if (R.closed) return;
226
- R.d = d;
227
- if (d.open) { R.seen = true; R.steps = d.open.steps; R.total = d.open.steps.length; R.stepAt = Math.max(0, d.open.steps.findIndex((s) => !settled(s))); }
228
- draw();
229
- if (d.open || !R.seen) R.timer = setTimeout(poll, 1500);
230
- if (!d.open && R.seen) scanChanged();
231
- }
232
- async function stop() {
233
- const r = await postStop(ws);
234
- if (!r || r.ok === false) { toast({ text: errText(r, 'Stop did not work'), tone: 'error', timeout: 6000 }); return; }
235
- R.stopped = true; clearTimeout(R.timer); toast('Scan stopped. What was already filed is kept'); scanChanged(); draw();
236
- }
237
- function draw() {
238
- const d = R.d;
239
- if (!d) { put(host, el('div', { class: 'dim' }, 'Reading the scan')); return; }
240
- if (R.stopped) { put(host, el('div', { class: 'fold w', role: 'status', 'data-scan': 'stopped' }, icon('x', 'sm'), ' Stopped at step ' + (R.stepAt + 1) + ' of ' + R.total + '. Nothing was sent. What was already filed is kept.'),
241
- el('div', { class: 'chips2' }, pbtn('primary', 'Scan now again', 'bolt', { 'data-scan-act': 'scan', onclick: () => openScanPicker(ws, o) }), pbtn('ghost', 'Close', null, { onclick: () => ui.close() }))); return; }
242
- if (d.open) {
243
- const steps = d.open.steps;
244
- put(host, el('div', { class: 'lh' }, el('span', { class: 'ki' }, icon('bolt')), el('div', { class: 'sc-lhm' }, el('b', null, 'Scanning the portfolio'), el('div', { class: 'dim' }, (d.open.stopping ? 'Stopping. ' : '') + 'Step ' + (R.stepAt + 1) + ' of ' + steps.length + '. You can close this sheet. The scan keeps running.'))),
245
- el('div', { class: 'hbr ini-t-acc', 'data-scan': 'progress', 'aria-label': 'Scan progress' }, el('div', { class: 'tk' }, geo(el('u'), { '--in-w': Math.max(6, Math.min(100, Math.round(R.stepAt / Math.max(1, steps.length) * 100))) + '%' }))),
246
- el('ul', { class: 'chgl sc-steps', 'data-scan': 'steps' }, ...steps.map((s, i) => el('li', { 'data-scan-step': s.id, 'data-scan-step-state': s.state }, icon(STEP_IC(s.state), 'sm'), el('span', { class: i > R.stepAt ? 'dim' : '' }, el('b', null, s.label)),
247
- el('span', { class: 'dim' }, STEP_WORD[s.state] || '')))),
248
- el('div', { class: 'chips2' }, pbtn('outline', 'Stop', 'x', { 'data-scan-act': 'stop', onclick: stop }), el('span', { class: 'dim sc-sm' }, 'Stopping keeps what was already filed. Nothing is sent.')));
249
- return;
250
- }
251
- if (!R.seen && !R.before) { put(host, el('div', { class: 'fold', 'data-scan': 'idle' }, icon('info', 'sm'), ' No scan is running now.'), el('div', { class: 'chips2' }, pbtn('primary', 'Scan now', 'bolt', { 'data-scan-act': 'scan', onclick: () => openScanPicker(ws, o) }), pbtn('ghost', 'Close', null, { onclick: () => ui.close() }))); return; }
252
- const fresh = d.reports.filter((r) => !r.parent && (!R.before || !R.before.has(r.id)));
253
- const wait = waitingOf(d);
254
- const failed = d.last && d.last.ok === false ? d.last : null;
255
- put(host, failed ? el('div', { class: 'fold w', role: 'alert', 'data-scan': 'failed' }, icon('alert', 'sm'), failed.stopped ? ' The scan was stopped.' : ' The scan did not finish' + (failed.reason ? ': ' + failed.reason : '') + '.') : null,
256
- el('div', { class: 'lh', 'data-scan': 'finished' }, el('span', { class: 'ki' }, icon('check')), el('div', { class: 'sc-lhm' }, el('b', null, fresh.length ? 'Scan finished: ' + plural(fresh.length, 'report') + ' written' : 'Scan finished: nothing new'),
257
- el('div', { class: 'dim' }, fresh.length ? plural(wait, 'proposal') + ' wait for you.' : 'The agent raised nothing twice.'))),
258
- fresh.length ? list(fresh.map((r) => nrow({ ic: 'search', title: r.title || typeName(r.type), onOpen: () => openScanDoc(ws, r, { panel: true }), attrs: { 'data-scan-report': r.id },
259
- chips: [waitingOf(d, r.id) ? el('span', { class: 'tag acc' }, plural(waitingOf(d, r.id), 'proposal')) : chip('No proposals')], right: [pbtn('outline', 'Open', 'out', { 'data-scan-act': 'opendoc', 'data-id': r.id, onclick: () => openScanDoc(ws, r, { panel: true }) })] }))) : null,
260
- el('div', { class: 'fold' }, icon('info', 'sm'), ' Nothing was sent. Public pages were read for topics only.'),
261
- el('div', { class: 'chips2' }, fresh.length && o.showTab ? pbtn('primary', 'Open Documents', 'doc', { 'data-scan-act': 'reports', onclick: () => { ui.close(); o.showTab('rep', true); } }) : null, pbtn('ghost', 'Close', null, { onclick: () => ui.close() })));
262
- }
263
- draw(); poll();
264
- return ui;
265
- }
266
-
267
- /* ══ the Portfolio section ══ */
268
- export function scanPortfolioSection({ ws, boardCount, showTab }) {
269
- ensureScanCss();
270
- const S = { d: null, err: '' };
271
- const body = el('div', { class: 'sc-pf' });
272
- const right = el('span', { class: 'dim mono sc-xs', 'data-scan': 'cadence' });
273
- const o = { showTab };
274
- const node = sect({ ic: 'search', title: 'Horizon scan', right, attrs: { 'data-scan-section': 'portfolio', 'data-c3pg': 'hs-portfolio', 'aria-label': 'Horizon scan' } }, body);
275
- const scanNow = () => { if (S.d && S.d.open) { openScanRunning(ws, o); toast('A scan is already running'); } else if (blocked(S.d)) toast({ text: leftLine(S.d), tone: 'error', timeout: 6000 }); else openScanPicker(ws, o); };
276
- async function load() { const d = await getPortfolio(ws); if (d.ok) { S.d = d; S.err = ''; } else S.err = errText(d, 'The horizon scan could not be read'); draw(); }
277
- function draw() {
278
- const d = S.d;
279
- const mine = d ? latestReports(d) : []; const wait = d ? waitingOf(d) : 0; const cad = d ? d.setting.cadence : 'daily';
280
- const now = new Date();
281
- const kept = d ? d.items.filter((w) => w.state === 'kept').length : 0;
282
- let state = 'Reading the horizon scan.';
283
- if (S.err && !d) state = S.err;
284
- else if (d) {
285
- state = !kept && !d.last ? (d.items.length ? 'The agent suggests ' + plural(d.items.length, 'thing') + ' to watch. Decide on the list, or run a scan now and choose what to scan.' : 'No watch list yet. Open the setup to add what to watch, or run a scan now and choose what to scan.')
286
- : cad === 'off' ? 'The scan is off. Scan now still works.'
287
- : (cad === 'daily' ? 'Daily' : 'Weekly') + '. ' + (d.last ? 'Last scan ' + pastLabel(d.last.at, now) + '. ' : '') + (d.next ? 'Next scan ' + nextLabel(d.next, now) + '.' : '');
288
- }
289
- right.textContent = d ? cad.toUpperCase() : '';
290
- const byDoc = d ? mine.filter((r) => waitingOf(d, r.id)) : [];
291
- put(body,
292
- el('div', { class: 'chips2' }, chip(icon('cols', 'sm'), 'Whole portfolio: ' + plural(boardCount == null ? 0 : boardCount, 'board')),
293
- d && mine.length ? chip(icon('doc', 'sm'), plural(mine.length, 'report') + ' from the last scan') : null),
294
- el('div', { class: 'dim sc-sm', 'data-scan': 'state', role: S.err && !d ? 'alert' : null }, state),
295
- d ? el('div', { class: 'dim sc-sm', 'data-scan': 'manual', role: blocked(d) ? 'status' : null }, leftLine(d)) : null,
296
- d && wait ? el('div', { class: 'fold a sc-strip', role: 'status', 'data-scan': 'waiting' }, icon('spark', 'sm'), el('b', null, 'Waiting for you: ' + plural(wait, 'proposal')), el('span', { class: 'dim' }, 'from the Horizon scan'),
297
- ...byDoc.map((r) => lk({ 'data-scan-act': 'opennext', 'data-id': r.id, onclick: () => openScanDoc(ws, r, { panel: true }) }, (r.title || typeName(r.type)).split(':')[0] + ' ' + waitingOf(d, r.id)))) : null,
298
- d && mine.length ? list(mine.map((r) => nrow({ ic: 'search', title: r.title || typeName(r.type), onOpen: () => openScanDoc(ws, r, { panel: waitingOf(d, r.id) > 0 }), attrs: { 'data-scan-report': r.id },
299
- chips: [waitingOf(d, r.id) ? el('span', { class: 'tag acc' }, plural(waitingOf(d, r.id), 'proposal')) : chip('No proposals waiting')] })), { 'data-scan': 'reports' }) : null,
300
- el('div', { class: 'chips2' }, pbtn('primary', 'Scan now', 'bolt', { 'data-scan-act': 'scan', disabled: blocked(d), onclick: scanNow }), pbtn('outline', 'Horizon scan setup', 'settings', { 'data-scan-act': 'setup', onclick: () => openScanSetup(ws, o) }),
301
- d && mine.length && showTab ? pbtn('ghost', 'Open the reports', 'doc', { 'data-scan-act': 'reports', onclick: () => showTab('rep', true) }) : null));
302
- }
303
- const off = onScanChange(() => { if (!node.isConnected) { off(); return; } load(); });
304
- draw(); load();
305
- return node;
306
- }
307
-
308
- /* ══ Board settings: the pointer ══ */
309
- export function scanPointer(ws) {
310
- ensureScanCss();
311
- return el('div', { class: 'sc-ptr', 'data-scan-ptr': '' }, icon('search', 'sm'), el('span', null, el('b', null, 'Horizon scan runs for the whole portfolio.'), ' ', el('span', { class: 'dim' }, 'It is not set per board.')),
312
- lk({ 'data-scan-act': 'setup', onclick: () => openScanSetup(ws) }, 'Open the Horizon scan setup'));
313
- }