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,1210 +0,0 @@
1
- /* pm/tab-term.js — the body of a `term` tab. ONE component, TWO modes.
2
- *
3
- * ── fixture mode (`?fixture=proto`) ──────────────────────────────────────────────────────────
4
- * The prototype's faux terminal, ported line for line from template lines 928–939 and derivation
5
- * lines 1981–2006: the five attach lines, the transcript in `termHist[tab.id]`, the working prompt
6
- * with the blinking `pmblink` caret, and the fake shell's command table (which lives in
7
- * fixture.js — `termBaseLines` / `fauxShellReply` / `termEcho` — so there is exactly one copy of
8
- * it). Every inline style below is the prototype's string, character for character, and each
9
- * interpolated value sits in its own `<span>` because that is what the prototype's runtime emits
10
- * (`<span class="sc-interp">…</span>`) and the comparator reads text nodes, not properties.
11
- * Fixture mode opens no socket and touches no PTY: it is the offline demo path and the only render
12
- * the comparator ever sees.
13
- *
14
- * ── real mode (everything else) ─────────────────────────────────────────────────────────────
15
- * A LIVE xterm.js terminal on the existing WebSocket/node-pty path — the same protocol the retired
16
- * public/app.js spoke, preserved frame for frame:
17
- *
18
- * out: attach{id} · input{id,data} · resize{id,cols,rows} · detach{id} · new{name,agent,ws}
19
- * in : hello{sessions} · sessions{sessions} · attached{id,buf,…} · data{id,data} · created{id}
20
- *
21
- * Three properties of that path are load-bearing and are the reason this file is written the way
22
- * it is:
23
- *
24
- * 1. A SESSION SURVIVES DETACH AND RELOAD. The PTY lives in the server; the browser holds a view
25
- * of it. Closing a tab sends `detach`, never `kill`. Reconnecting re-`attach`es and the
26
- * server replays its ring buffer, so scrollback comes back with the page.
27
- * 2. A TERMINAL IS NEVER REBUILT BY NAVIGATION. One xterm per tab id, kept for the tab's whole
28
- * life. panel-tabs.js caches the pane host for the same reason; `mountTerm` is therefore
29
- * idempotent — called on every render, it builds once and re-fits thereafter.
30
- * 3. IT MUST BE RE-FITTED. A terminal that attaches and is never re-fitted keeps a stale grid:
31
- * output wraps at the wrong column and a full-screen TUI paints into a box that is not there.
32
- * It is invisible in a screenshot of an empty terminal, which is why the PRD names it "the
33
- * quiet PTY regression". Refit is explicit here — ONE exported `refitVisible()` — and it is
34
- * driven from every event that can change a terminal's box: a render (tab shown, split
35
- * toggled, a panel collapsed), a ResizeObserver on the pane, window resize, tab visibility,
36
- * and `document.fonts.ready` (xterm measures its cell from the face resolved at construction,
37
- * so the first real metrics arrive after the woff2 lands).
38
- *
39
- * The xterm palette is the DESIGN's: `--term-bg` for the background — dark in both themes, D41 —
40
- * and IBM Plex Mono at the design's 12.5px. Its LINE HEIGHT is not the design's 1.65: that number
41
- * is a CSS line-height and xterm's option of the same name is not one, so it is converted rather
42
- * than copied — see TERM_LINE_HEIGHT. xterm's colour parser does not understand
43
- * `oklch()`, so the token is resolved to a concrete sRGB value at runtime (canvas round-trip, with
44
- * the pre-computed hex as the fallback) rather than handed to xterm as written.
45
- */
46
-
47
- import { el, setChildren } from './dom.js';
48
- import { state, setState, subscribe, FIXTURE } from './state.js';
49
- import * as FX from './fixture.js';
50
- import { goneTermTabIds } from './tab-gone.js';
51
- import { pageNonce } from './http.js'; // R25: a session started with an initiative binds only with the nonce
52
-
53
- /* ── the design's terminal colours ───────────────────────────────────────────────────────────
54
- * `--term-bg` is oklch(0.148 0.004 228.8) in BOTH themes. Resolved through a canvas at runtime so
55
- * the value xterm gets is whatever the stylesheet actually says; TERM_BG_FALLBACK is that same
56
- * oklch converted offline, for a browser that will not do the conversion for us. The ANSI ramp is
57
- * the workspace's own, unchanged — it is the palette agent CLIs have been rendering against.
58
- */
59
- const TERM_BG_FALLBACK = '#090b0c';
60
- const ANSI = {
61
- foreground: '#c4ccce', cursor: '#47cf79', cursorAccent: '#090b0c',
62
- selectionBackground: 'rgba(43,127,255,.3)',
63
- black: '#090b0c', red: '#ff6467', green: '#47cf79', yellow: '#f4b93c',
64
- blue: '#2b7fff', magenta: '#b48df4', cyan: '#53d1d0', white: '#d2d9db',
65
- brightBlack: '#6f7d81', brightRed: '#ff6467', brightGreen: '#81e8a0', brightYellow: '#f4b93c',
66
- brightBlue: '#2b7fff', brightMagenta: '#b48df4', brightCyan: '#53d1d0', brightWhite: '#f9fbfb',
67
- };
68
-
69
- /** Resolve a CSS colour value (possibly `oklch(…)`, possibly a `var()`) to something xterm parses. */
70
- function resolveColor(value, fallback) {
71
- let spec = value;
72
- try {
73
- const probe = document.createElement('span');
74
- probe.style.cssText = 'position:absolute;left:-9999px;top:-9999px;visibility:hidden';
75
- probe.style.color = value;
76
- document.body.appendChild(probe);
77
- spec = getComputedStyle(probe).color || value;
78
- probe.remove();
79
- } catch { /* keep the literal */ }
80
- if (/^rgba?\(/.test(spec) || /^#/.test(spec)) return spec;
81
- try {
82
- const c = document.createElement('canvas');
83
- c.width = c.height = 1;
84
- const ctx = c.getContext('2d');
85
- ctx.fillStyle = '#000000';
86
- ctx.fillStyle = spec; // an unparsable value leaves the previous one
87
- ctx.fillRect(0, 0, 1, 1);
88
- const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
89
- const hex = '#' + [r, g, b].map((n) => n.toString(16).padStart(2, '0')).join('');
90
- if (hex !== '#000000') return hex;
91
- } catch { /* fall through */ }
92
- return fallback;
93
- }
94
-
95
- /** The xterm theme, read off the live token layer (app.js:165–179 in the retired client). */
96
- function xtheme() {
97
- let bg = TERM_BG_FALLBACK;
98
- try {
99
- const raw = getComputedStyle(document.documentElement).getPropertyValue('--term-bg').trim();
100
- if (raw) bg = resolveColor(raw, TERM_BG_FALLBACK);
101
- } catch { /* the fallback IS the design's value */ }
102
- return { ...ANSI, background: bg, cursorAccent: bg };
103
- }
104
-
105
- /* ── module state ──────────────────────────────────────────────────────────────────────────── */
106
-
107
- /** tab id → the mounted pane. Fixture panes and real panes are both keyed here. */
108
- const panes = new Map();
109
-
110
- const XTERM = () => (typeof window !== 'undefined' ? window.Terminal : null);
111
- const FIT = () => (typeof window !== 'undefined' && window.FitAddon ? window.FitAddon.FitAddon : null);
112
- const LINKS = () => (typeof window !== 'undefined' && window.WebLinksAddon ? window.WebLinksAddon.WebLinksAddon : null);
113
-
114
- /* ── the socket ────────────────────────────────────────────────────────────────────────────────
115
- * Opened LAZILY, and never in fixture mode: the fixture render must make no network call at all,
116
- * which is what lets the comparator and no-network.test.js trust a fixture run. One socket for the
117
- * page, shared by every terminal, reconnecting on a fixed 1.2s delay with the attach set cleared —
118
- * so every visible terminal re-attaches and replays its ring buffer, exactly as before.
119
- */
120
- const SOCK = {
121
- ws: null, open: false, tries: 0,
122
- sessions: [], // the server's session list, module-local on purpose (see below)
123
- listed: false, // THIS connection's `hello` has arrived, so `sessions` is current — see bind()
124
- attached: new Set(), // session ids this connection has attached
125
- spawning: new Map(), // tab id → true, while a `new` is in flight
126
- spawnQueue: [], // the SAME requests, in order — `created` carries no correlation id
127
- timer: null,
128
- };
129
-
130
- /* ── what rides on spawnQueue, and why it is two kinds ─────────────────────────────────────────
131
- * The queue itself is unchanged in MECHANISM: `created` carries no correlation id, the server
132
- * answers `new` in receipt order, so first-in-first-out IS the correlation and two simultaneous
133
- * starts cannot be handed each other's shell. What changed is what a slot holds.
134
- *
135
- * {kind:'pane', tabId} — the original behaviour: a pane already exists and is waiting for
136
- * its session. Still used by bind()'s fallback spawn (see below).
137
- * {kind:'ask', msg, resolve} — NOBODY is waiting on screen. The answer resolves a promise, and
138
- * the caller decides whether a tab is opened at all.
139
- *
140
- * The second kind is the whole of workspace-session-preflight's R1. Before it, a refusal arrived
141
- * after the tab, the pane and the xterm had all been built, so `{t:'error'}` could only be written
142
- * INSIDE a terminal belonging to a session the server had just declined to start.
143
- *
144
- * ── WHY A SLOT ALSO CARRIES ITS MESSAGE, AND WHETHER IT WAS SENT ──────────────────────────────
145
- * An `ask` is queued BEFORE it is on the wire, because on the first use of the pre-flight there is
146
- * no wire yet: `connect()` opens a WebSocket and the handshake is asynchronous, so the socket that
147
- * the very first press opens is still in readyState 0 when that press would have sent. The first
148
- * implementation called `send()` synchronously and reported the false refusal "not connected to the
149
- * workspace server — nothing was started" — which made the feature dead on first use in a fresh
150
- * window, and alive on the second press only because the failed press had left a socket behind.
151
- *
152
- * So a slot holds the message it still owes the server, and `flushAsks()` puts it on the wire the
153
- * moment there is one — from `requestSpawn` when the socket is already up, and from `ws.onopen`
154
- * when it is not. This is the idiom the module already used for panes: bind() answers a cold socket
155
- * with "connecting to the workspace server…" and is re-run from `onopen`.
156
- *
157
- * The FIFO correlation is unchanged in meaning but is now stated exactly: `created`/`error` belong
158
- * to the oldest request THAT WAS ACTUALLY SENT (takeSent). A queued-but-unsent slot cannot absorb
159
- * the answer to somebody else's message, because the server has never heard of it. What actually
160
- * enforces the correlation is that queue order and WIRE order are the same thing — which is why
161
- * `ws.onopen` flushes the asks before it re-binds the panes, and why takeSent is a floor rather
162
- * than the mechanism. See its own note.
163
- */
164
- const SPAWN_TIMEOUT_MS = 15000;
165
-
166
- /** Resolve an `ask` slot exactly once, and stop its timer. */
167
- function settleAsk(req, out) {
168
- if (!req || req.settled) return;
169
- req.settled = true;
170
- if (req.timer) { clearTimeout(req.timer); req.timer = null; }
171
- try { req.resolve(out); } catch { /* a caller that threw is not this module's to repair */ }
172
- }
173
-
174
- /** Fail every outstanding `ask`. A dropped promise is the same swallow this module is removing. */
175
- function failAllAsks(error) {
176
- for (const req of SOCK.spawnQueue) if (req && req.kind === 'ask') settleAsk(req, { ok: false, error });
177
- }
178
-
179
- /**
180
- * Put every queued `ask` that is not yet on the wire onto it, in queue order — and stop at the
181
- * first one the socket will not take, so the queue's order stays the order the server received.
182
- * Called from `requestSpawn` (the socket may already be up) and from `ws.onopen` (it has just come
183
- * up). Sending in queue order is what keeps FIFO the correlation `created` relies on.
184
- */
185
- function flushAsks() {
186
- for (const req of SOCK.spawnQueue) {
187
- if (!req || req.kind !== 'ask' || req.sent || req.settled) continue;
188
- if (!send(req.msg)) return;
189
- req.sent = true;
190
- }
191
- }
192
-
193
- /**
194
- * The oldest request the server has actually been sent. `consume` removes it (an answer that ends
195
- * the request) or leaves it (a `notice`, which is followed by a `created` for the same request).
196
- *
197
- * It is a search rather than a `shift` because the head of the queue may now be an `ask` that is
198
- * waiting for the socket to open: the server cannot be answering a message it was never sent, and
199
- * handing that slot somebody else's `created` would attach a pre-flight to the wrong PTY.
200
- *
201
- * SAID PLAINLY, BECAUSE THE SUITE CANNOT SHOW IT: no call site reaches that state today. `bind()`
202
- * only queues while the socket is open, `flushAsks` runs before the re-bind, and both are removed
203
- * again when a send is refused — so replacing this with a plain `shift()` passes every assertion in
204
- * pm-term-test.js (checked, not assumed). What keeps the correlation honest in practice is the
205
- * ORDER in `ws.onopen`, and that IS asserted — the race test one page down goes red when the panes
206
- * are re-bound first. This is a floor under an invariant, not behaviour anybody can observe.
207
- */
208
- function takeSent(consume) {
209
- const i = SOCK.spawnQueue.findIndex((r) => r && r.sent);
210
- if (i < 0) return null;
211
- const req = SOCK.spawnQueue[i];
212
- if (consume) SOCK.spawnQueue.splice(i, 1);
213
- return req;
214
- }
215
-
216
- /**
217
- * Ask the server to START a session, and answer what it said. NOTHING is opened here — no tab, no
218
- * pane, no terminal. That is the caller's to do, and only on `{ok:true}`.
219
- *
220
- * Resolves `{ok:true, id, notice}` on `created`, or `{ok:false, error}` on any of the four ways a
221
- * request can end without one:
222
- * · the server refused it (`{t:'error'}` — an unreadable profile, a failed worktree, a failed
223
- * checkout, all of which spawnWithBranch decides BEFORE spawnSession is reached);
224
- * · the socket closed with the request still outstanding;
225
- * · the socket never came up at all;
226
- * · nothing came back within SPAWN_TIMEOUT_MS.
227
- * It always settles. A promise that hangs is a form that hangs, which is the same failure in a
228
- * different costume.
229
- *
230
- * A COLD SOCKET IS NOT A REFUSAL. `connect()` returns before the WebSocket handshake completes, so
231
- * on the first press in a window with no terminal open there is nothing to send on yet. The message
232
- * is therefore QUEUED and flushed from `ws.onopen`; only the timeout and a socket that actually
233
- * closed can end it without an answer. Reporting "not connected" synchronously is what made this
234
- * control fail every first press in a fresh window.
235
- */
236
- export function requestSpawn(opts) {
237
- const o = opts || {};
238
- if (FIXTURE) {
239
- return Promise.resolve({ ok: false, error: 'fixture mode starts no sessions' });
240
- }
241
- connect();
242
- return new Promise((resolve) => {
243
- const req = {
244
- kind: 'ask', resolve, notice: null, settled: false, timer: null, sent: false,
245
- /* `start: true` (0.55.1, the dock's new-session sheet) sends the one-click `start` message instead: the server's
246
- * start policy then picks the tree — the initiative's own branch, made the first time, or the main tree when
247
- * there is no initiative — and nothing about branches is decided here. */
248
- msg: o.start ? {
249
- t: 'start', name: o.name, agent: o.agent || 'shell', ws: o.ws,
250
- ...(o.initiative ? { initiative: o.initiative } : {}),
251
- profile: o.profile === undefined ? null : o.profile,
252
- ...(o.skill ? { skill: o.skill } : {}),
253
- ...(o.workType ? { workType: o.workType } : {}),
254
- ...(o.tier ? { tier: o.tier } : {}),
255
- ...(Array.isArray(o.flags) && o.flags.length ? { flags: o.flags } : {}),
256
- } : {
257
- t: 'new',
258
- ...(o.skill ? { skill: o.skill } : {}),
259
- ...(o.workType ? { workType: o.workType } : {}),
260
- name: o.name,
261
- agent: o.agent || 'shell',
262
- ws: o.ws,
263
- // The initiative the session is FOR, when the caller knows it (workspace-branch-sessions R8):
264
- // the `⋯ options` path used to drop it, so a session started with a branch carried none.
265
- ...(o.initiative ? { initiative: o.initiative } : {}),
266
- /* Sent even when the PM chose nothing, and that is deliberate on two of them. `isolate` has
267
- * a server-side default (`server.js` liveSessionCount) whose own comment says the client
268
- * should state what the PM actually saw; `profile: null` is a DELIBERATE "no profile",
269
- * which the server distinguishes from a client that forgot the field. */
270
- branch: o.branch || null,
271
- createBranch: !!o.createBranch,
272
- isolate: o.isolate === undefined ? null : o.isolate,
273
- profile: o.profile === undefined ? null : o.profile,
274
- // D75 — a tier the PM picked (fast | balanced | deep). Absent = "auto": the server routes by policy, or asks for nothing.
275
- ...(o.tier ? { tier: o.tier } : {}),
276
- // workspace-launch-flags — `[{flag, value?}]`, checked by the server against the generated claude flag list.
277
- ...(Array.isArray(o.flags) && o.flags.length ? { flags: o.flags } : {}),
278
- },
279
- };
280
- SOCK.spawnQueue.push(req);
281
- /* Armed BEFORE the flush, and armed whether or not the message goes out now: a request waiting
282
- * for a socket that never opens must end in a sentence, not in a form that spins for ever.
283
- *
284
- * Only an UNSENT ask leaves the queue here — the server never heard it, so no answer is coming.
285
- * A SENT one keeps its slot, settled: the queue's ORDER is the correlation, and removing a slot
286
- * the server will still answer (spawnWithBranch can legitimately outlive this timer on a large
287
- * repo) would hand its late `created` to the next request in line — a different click's PTY.
288
- * The `created` handler detaches the session a dead slot's answer names. */
289
- req.timer = setTimeout(() => {
290
- if (!req.sent) SOCK.spawnQueue = SOCK.spawnQueue.filter((x) => x !== req);
291
- settleAsk(req, {
292
- ok: false,
293
- error: req.sent
294
- ? 'the workspace server did not answer — nothing was started'
295
- : 'could not reach the workspace server — nothing was started',
296
- });
297
- }, SPAWN_TIMEOUT_MS);
298
- flushAsks();
299
- });
300
- }
301
-
302
- /* The session heartbeat arrives about every 2s. It is deliberately NOT pushed through setState:
303
- * a state change repaints all four panels, and repainting the window twice a second to redraw
304
- * nothing would destroy text selection, scroll position and any in-flight edit. Nothing in this
305
- * pane is rendered from the session list — it only decides which PTY a terminal is bound to — so
306
- * the list stays here and the panels keep their own reads. */
307
-
308
- function connect() {
309
- if (FIXTURE || SOCK.ws) return;
310
- let ws;
311
- try {
312
- const proto = location.protocol === 'https:' ? 'wss' : 'ws';
313
- const n = pageNonce();
314
- ws = new WebSocket(`${proto}://${location.host}/` + (n ? '?pmos-nonce=' + encodeURIComponent(n) : ''));
315
- } catch { return; }
316
- SOCK.ws = ws;
317
- ws.onopen = () => {
318
- SOCK.open = true; SOCK.tries = 0;
319
- /* The asks FIRST, and the order is the point: a pre-flight that pressed `start session` before
320
- * this socket existed has been waiting here, and binding the panes first would put a pane's
321
- * fallback `new` ahead of it on the wire while the queue still said otherwise. Flushing first
322
- * keeps queue order and wire order the same thing, which is what makes FIFO a correlation. */
323
- flushAsks();
324
- for (const rec of panes.values()) if (rec.kind === 'real') bind(rec);
325
- };
326
- ws.onclose = () => {
327
- SOCK.open = false; SOCK.listed = false; SOCK.ws = null; SOCK.attached.clear();
328
- /* An in-flight `new` is abandoned rather than retried: the server may well have started the
329
- * session before the socket dropped, and the reconnect's `hello` will find it by name. Retrying
330
- * blind is how a PM ends up with two shells and one tab.
331
- *
332
- * An `ask` is not merely abandoned, it is ANSWERED. Dropping the promise would leave the
333
- * pre-flight spinning on a question that can no longer be answered — the same swallow this
334
- * module is removing, one layer up. The wording is careful: the session may in fact exist, so
335
- * it says what PMOS knows (this window did not start one) and not more. */
336
- failAllAsks('the connection to the workspace server was lost — this window started nothing');
337
- SOCK.spawning.clear(); SOCK.spawnQueue = [];
338
- for (const rec of panes.values()) {
339
- if (rec.kind !== 'real') continue;
340
- rec.attachedId = null;
341
- rec.sentCols = null; rec.sentRows = null; // the next connection has stated no grid yet
342
- note(rec, 'pmos: connection to the workspace server lost — retrying');
343
- }
344
- clearTimeout(SOCK.timer);
345
- SOCK.timer = setTimeout(connect, 1200);
346
- };
347
- ws.onerror = () => { /* onclose does the retrying */ };
348
- ws.onmessage = (ev) => {
349
- let m; try { m = JSON.parse(ev.data); } catch { return; }
350
- handle(m);
351
- };
352
- }
353
-
354
- function send(obj) {
355
- if (SOCK.ws && SOCK.ws.readyState === 1) { SOCK.ws.send(JSON.stringify(obj)); return true; }
356
- return false;
357
- }
358
-
359
- function handle(m) {
360
- if (m.t === 'hello' || m.t === 'sessions') {
361
- SOCK.sessions = Array.isArray(m.sessions) ? m.sessions : [];
362
- SOCK.listed = true;
363
- if (m.t === 'hello' && Array.isArray(m.workspaces)) SOCK.workspaces = m.workspaces;
364
- if (m.t === 'hello' && m.home) SOCK.home = m.home;
365
- /* A tab restored from the browser may name a session the server has since removed (an automatic one that finished or
366
- * went idle). Close it: it would otherwise return on every reload as an "Open" row over an empty pane. A session the
367
- * data layer still lists also keeps its tab, so a tab is never closed on the socket's word alone. */
368
- const gone = goneTermTabIds(state.tabs, [...SOCK.sessions, ...(Array.isArray(state.sessions) ? state.sessions : [])], { starting: (t) => SOCK.spawning.get(t.id) });
369
- if (gone.length) {
370
- setState((s) => {
371
- const rest = (s.tabs || []).filter((t) => !gone.includes(t.id));
372
- return {
373
- tabs: rest,
374
- active: gone.includes(s.active) ? (rest.length ? rest[rest.length - 1].id : null) : s.active,
375
- splitId: gone.includes(s.splitId) ? null : s.splitId,
376
- };
377
- });
378
- }
379
- for (const rec of panes.values()) if (rec.kind === 'real') bind(rec);
380
- return;
381
- }
382
- if (m.t === 'attached') {
383
- const rec = recFor(m.id);
384
- if (!rec) return;
385
- rec.attachedId = m.id;
386
- rec.noted = null;
387
- try { rec.term.reset(); } catch { /* a disposed terminal */ }
388
- if (m.buf) { try { rec.term.write(m.buf); } catch { /* ignore */ } }
389
- /* THE PTY DOES NOT KNOW HOW WIDE THIS BROWSER IS. `attached` carries the SERVER's cols/rows —
390
- * 80×24 for a session nobody ever resized — and the server never adopts the client's grid on
391
- * attach. The only thing that ever told it was xterm's `onResize`, which fires when a fit
392
- * CHANGES the grid; the first fit runs while the socket is still connecting, so `sessionId` was
393
- * null and the message was dropped, and every later fit measured the same box and changed
394
- * nothing, so it never fired again. Result: a 200-column window rendering a shell that believes
395
- * it has 80, wrapping a third of the way across — "the terminal only shows a small portion".
396
- * The grid is therefore PUSHED here, unconditionally, the moment there is a session to push it
397
- * to. `sent*` is cleared first so a re-attach after a reconnect re-states it. */
398
- rec.sentCols = null; rec.sentRows = null;
399
- syncSize(rec, true);
400
- refitVisible();
401
- return;
402
- }
403
- if (m.t === 'size') {
404
- /* ANOTHER SCREEN RESIZED THIS SESSION. A session has one PTY and one grid, and the last screen
405
- * to state a grid wins. Without this, a pane never learned it had lost: its `sent*` still said
406
- * its own grid, so it never stated it again, and the agent went on drawing for the other
407
- * screen's grid inside this one — Claude Code's whole frame drawn twice, one under the other.
408
- * The pane records the grid the PTY really has and YIELDS: it does not take the size back on
409
- * its own (two open screens would then trade the size on every render), only when the person
410
- * types into it, focuses it, or its own grid changes. See syncSize. */
411
- for (const rec of panes.values()) {
412
- if (rec.kind !== 'real' || rec.sessionId !== m.id || rec.attachedId !== m.id) continue;
413
- rec.sentCols = m.cols; rec.sentRows = m.rows;
414
- rec.yielded = !!rec.term && (rec.term.cols !== m.cols || rec.term.rows !== m.rows);
415
- }
416
- return;
417
- }
418
- if (m.t === 'data') {
419
- const rec = recFor(m.id);
420
- if (rec) { try { rec.term.write(m.data); } catch { /* ignore */ } }
421
- return;
422
- }
423
- if (m.t === 'created') {
424
- // `created` carries no correlation id, so the oldest request THAT WAS SENT takes it. The server
425
- // answers `new` in the order it received them, which makes the queue the correlation — matching
426
- // by iteration order over the pane map would hand two simultaneous starts each other's shell.
427
- // "That was sent" is the whole guard: a queued ask still waiting for the socket to open has not
428
- // been asked for anything, so it cannot be the thing being answered.
429
- const req = takeSent(true);
430
- if (!req) return;
431
- if (req.kind === 'ask') {
432
- // A slot the timeout already settled has no caller left: the form reported the failure and
433
- // moved on, so the session this answer names is unowned — detach it rather than leak a
434
- // running PTY nobody asked for. Consuming the slot (above) is what keeps the NEXT answer
435
- // correlated with the next request.
436
- if (req.settled) { send({ t: 'detach', id: m.id }); return; }
437
- // Nobody is on screen waiting for this. Hand the caller the id and whatever non-fatal truth
438
- // arrived just before it; the caller opens the tab, and the tab carries the id so bind()
439
- // ATTACHES rather than starting a second session for the same click.
440
- settleAsk(req, { ok: true, id: m.id, notice: req.notice || null });
441
- return;
442
- }
443
- const id = req.tabId;
444
- SOCK.spawning.delete(id);
445
- const rec = panes.get(id);
446
- if (!rec) { send({ t: 'detach', id: m.id }); return; } // the tab closed while we waited
447
- rec.sessionId = m.id;
448
- rec.sentCols = null; rec.sentRows = null;
449
- rememberSession(rec.tab, m.id);
450
- attach(rec);
451
- return;
452
- }
453
- if (m.t === 'error' || m.t === 'notice') {
454
- /* An `error` CONSUMES its slot — the request is over. A `notice` only PEEKS, because the server
455
- * sends `notice` and then `created` for the same request and the slot has to survive to take
456
- * the `created`. That asymmetry predates this change and is preserved exactly. */
457
- const req = takeSent(!!m.error);
458
- if (!req) return;
459
- if (req.kind === 'ask') {
460
- // THE POINT OF THE WHOLE INITIATIVE. A refusal resolves the promise and opens nothing: no
461
- // tab, no pane, no xterm, no extraSess row. It used to be written as a dimmed line inside a
462
- // terminal the click had already built, for a session the server had just declined to start.
463
- if (m.error) settleAsk(req, { ok: false, error: m.error });
464
- else req.notice = m.notice; // held, and shown by whoever ends up owning the pane
465
- return;
466
- }
467
- const line = m.error ? 'pmos: ' + m.error : 'pmos: ' + m.notice;
468
- if (m.error) SOCK.spawning.delete(req.tabId);
469
- const rec = panes.get(req.tabId);
470
- if (rec) note(rec, line, true);
471
- return;
472
- }
473
- if (m.t === 'branch') {
474
- /* The picker must not go stale. The server broadcasts this after a worktree is added, after a
475
- * checkout and after a worktree is removed — so a branch the PM checked out in a terminal, or
476
- * one this very spawn created, changes what the open pre-flight should be offering. The
477
- * retired single-file client acted on exactly this (app.js:294); the four-panel port dropped
478
- * every one of the three broadcasts on the floor.
479
- *
480
- * Written to state unconditionally rather than only when a form is open: `branchInfo` is a
481
- * cache of the server's last word about a workspace, and a reader that is not open ignores it.
482
- * The `ws` is carried so a reader can tell whether the news is about the repository it is
483
- * asking about. */
484
- setState({ branchInfo: { ...m, at: Date.now() }, treesPush: Date.now() });
485
- return;
486
- }
487
- /* A tree was registered, removed or renamed. Panel 1 re-reads the tree list on `treesPush`
488
- * (panel-repos.js); without this the new folder appeared only after a reload. */
489
- if (m.t === 'workspaces') { setState({ treesPush: Date.now() }); return; }
490
- }
491
-
492
- const recFor = (sessionId) => {
493
- for (const rec of panes.values()) if (rec.kind === 'real' && rec.sessionId === sessionId) return rec;
494
- return null;
495
- };
496
-
497
- /* ── binding a tab to a real session ───────────────────────────────────────────────────────────
498
- * `sessionId` on the tab is the ONLY exact join, and it is the one that is used whenever it exists:
499
- * it is the server's own id, the data layer puts it on every tab opened from a listed session, and
500
- * `rememberSession` writes it back (and so into localStorage) the first time a tab resolves. The
501
- * name join below is the fallback for a tab that predates all of that.
502
- *
503
- * THE NAME JOIN IS SCOPED TO THE TAB'S OWN WORKSPACE, and no longer falls back to "a session with
504
- * this name anywhere". Session names are not unique across repositories — every `+ session` in
505
- * every repo produces `agent 1` — so the unscoped fallback quietly attached a tab in one repository
506
- * to a PTY running in another, and the PM was shown another repo's shell under their own repo's
507
- * initiative. A name that resolves nowhere in this workspace is now reported as not found, which is
508
- * the true answer.
509
- */
510
- function resolveSessionId(tab) {
511
- const pool = SOCK.sessions.length ? SOCK.sessions
512
- : (Array.isArray(state.sessions) ? state.sessions : []);
513
- if (tab.sessionId) {
514
- // A restored tab names a session from a previous run of this window — or of this SERVER. Trust
515
- // it while nothing is known (the socket has not said `hello` yet), but once there is a list,
516
- // an id that is not in it is a session that no longer exists: fall through rather than
517
- // `attach`ing to it, which the server answers with silence and the PM reads as a dead pane.
518
- if (!pool.length || pool.some((s) => s && s.id === tab.sessionId)) return tab.sessionId;
519
- }
520
- if (tab.spawn) return null; // a `+ session` tab must START one, never adopt one
521
- const name = tab.sess;
522
- if (!name) return null;
523
- const byId = pool.find((s) => s && s.id === name);
524
- if (byId) return byId.id;
525
- const ws = wsForTab(tab);
526
- const inWs = pool.find((s) => s && s.name === name && (!ws || s.ws === ws));
527
- if (inWs) return inWs.id;
528
- // No cross-workspace fallback. See the note above: it is how a repository showed another's shell.
529
- if (ws) return null;
530
- const anywhere = pool.find((s) => s && s.name === name);
531
- return anywhere ? anywhere.id : null;
532
- }
533
-
534
- /** The workspace a new session should start in: the selected repository when the server knows it. */
535
- function workspaceId() {
536
- const known = Array.isArray(SOCK.workspaces) ? SOCK.workspaces.map((w) => w.id) : [];
537
- // `state.wsId` FIRST — it is the workspace id the data layer published for the selected
538
- // repository. `state.product` is the repository's NAME, and reading a name as an id was only ever
539
- // harmless because it fails over to SOCK.home, which is right when exactly one repo is
540
- // registered. With two, a terminal would be spawned in the home tree while the PM was looking at
541
- // the other repository's board — a PTY in the wrong working tree, reported as if it were in the
542
- // right one. Kept as a fallback so a fixture render with no data layer still resolves.
543
- if (state.wsId && (!known.length || known.includes(state.wsId))) return state.wsId;
544
- if (state.product && known.includes(state.product)) return state.product;
545
- if (SOCK.home) return SOCK.home;
546
- return known.length ? known[0] : null;
547
- }
548
-
549
- /**
550
- * The workspace THIS TAB belongs to — which is not always the selected one. Every open terminal is
551
- * kept live, including the ones belonging to a repository the PM is not currently looking at (see
552
- * panel-tabs.js `keepSessionsLive`), so scoping a parked tab's name join by the SELECTED repository
553
- * would scope it by the wrong repo entirely. `state.productWs` is the data layer's product-name →
554
- * workspace-id map; a tab whose repository is not in it falls back to the selected workspace, which
555
- * is right for the tab on screen and is all a fixture render has.
556
- */
557
- function wsForTab(tab) {
558
- const map = state.productWs;
559
- if (tab && tab.repo && map && typeof map === 'object' && map[tab.repo]) return map[tab.repo];
560
- return workspaceId();
561
- }
562
-
563
- /**
564
- * Does this tab carry an instruction to START a session? Only then may a terminal spawn a PTY on
565
- * its own: a tab opened against a session the board listed must attach to that session or say it is
566
- * gone — silently starting a second shell with the same name would be a lie about what the PM is
567
- * looking at.
568
- *
569
- * The flag is set by `+ session` and travels ON THE TAB. It used to be inferred by looking the
570
- * tab's session NAME up in `state.extraSess`, which is a different question wearing the same
571
- * clothes: after a reload `extraSess` is empty and `startN` is back at 1, so a fresh `+ session`
572
- * produced the name `agent 1`, the name join found the `agent 1` still running from before the
573
- * reload, and the click ATTACHED to an old session instead of starting a new one. The PM asked for
574
- * a session and got someone else's.
575
- */
576
- function wantsSpawn(tab) {
577
- if (tab && tab.spawn) return true;
578
- const list = (state.extraSess || {})[tab.slug];
579
- return Array.isArray(list) && list.some((s) => s && s.name === tab.sess);
580
- }
581
-
582
- /**
583
- * Record the session a tab actually landed on, on the tab record itself — so it is written to
584
- * localStorage and a reload re-attaches to exactly this PTY rather than re-running the name join.
585
- * "I don't know which session it has reloaded" is that join being re-run against a list that has
586
- * moved on; an id does not have that failure mode.
587
- */
588
- function rememberSession(tab, sessionId) {
589
- if (!tab || !sessionId) return;
590
- // The guard is checked BEFORE the mutation, and on the tab record itself. `rec.tab` is very often
591
- // the same object that sits in `state.tabs`, so mutating first and then comparing would always
592
- // find them equal and the repaint that shows the id on the tab would never be scheduled.
593
- if (tab.sessionId === sessionId && tab.spawn === false) return;
594
- tab.sessionId = sessionId;
595
- tab.spawn = false;
596
- setState((s) => {
597
- const i = (s.tabs || []).findIndex((t) => t.id === tab.id);
598
- if (i < 0) return null;
599
- const next = [...s.tabs];
600
- next[i] = { ...next[i], sessionId, spawn: false };
601
- return { tabs: next };
602
- });
603
- }
604
-
605
- function bind(rec) {
606
- if (rec.kind !== 'real' || !rec.term) return;
607
- const id = resolveSessionId(rec.tab);
608
- if (id) {
609
- if (rec.sessionId !== id) {
610
- rec.sessionId = id; rec.attachedId = null; rec.sentCols = null; rec.sentRows = null;
611
- }
612
- rememberSession(rec.tab, id);
613
- attach(rec);
614
- return;
615
- }
616
- if (!SOCK.open) { note(rec, 'pmos: connecting to the workspace server…'); return; }
617
- /* NOT BEFORE THE LIST. `onopen` fires one frame before `hello`, and on a fresh page the pool is then empty (or
618
- * `state.sessions`, which the 4 s poll may not have filled yet), so every name join below answers "not found". A tab
619
- * that may spawn then starts a SECOND session under a name that is running — the reload case pm-term-test.js
620
- * asserts. Starting a session or saying one is gone is decided only against the list this connection sent; `hello`
621
- * is the very next frame and re-binds every pane. An id that IS known attached above, without waiting. */
622
- if (!SOCK.listed) return;
623
- if (SOCK.spawning.get(rec.tab.id)) return;
624
- if (wantsSpawn(rec.tab)) {
625
- /* THE FALLBACK SPAWN — no longer the PM's path, and no longer pretending to be.
626
- *
627
- * Since workspace-session-preflight, a session the PM started through a control that ASKS
628
- * arrives here already carrying `sessionId`, so `resolveSessionId` returns above and this is
629
- * never reached for it. What still reaches it is a session record with `spawn:true` and no id:
630
- * a test seed (pm-term-test.js, ui-test.js both write `extraSess` directly), and a tab whose
631
- * server-side session vanished between the click and the render.
632
- *
633
- * It is kept rather than removed, and that is an honest weakness worth stating: the defect is
634
- * closed because every PM path goes through a control that asks, NOT by construction. A future
635
- * call site that writes `extraSess` directly re-opens it. See the PRD's R5.
636
- *
637
- * WHAT IT MAY SEND IS EXACTLY WHAT A TAB CARRIES — `agent` and `profile`, and nothing else.
638
- * An earlier draft of this line also sent `branch`, `createBranch` and `isolate` off the tab
639
- * record, under a comment claiming a seed could name them. Nothing sets any of the three
640
- * (`openTerm` in panel-initiatives.js is the only builder of a term tab) and none of them is in
641
- * `TAB_FIELDS` (state.js), so all three were `undefined` on every tab that has ever existed:
642
- * three nulls dressed as a feature, and a claim in a comment that no code path could satisfy.
643
- *
644
- * They are also the three that must NOT be here even if a tab did carry one. This path exists
645
- * to re-open a view whose session went missing — a reload, a server restart — and a restored
646
- * tab that re-ran a checkout each time would move the PM's working tree behind their back,
647
- * repeatedly, for a decision they made once. A branch is a question, and the control that asks
648
- * it is the pre-flight; its answer reaches the server through `requestSpawn`, never through a
649
- * tab record.
650
- *
651
- * `profile` stays because it is genuinely a tab's own: `openTerm` sets it from the session the
652
- * PM clicked and `TAB_FIELDS` persists it, so a vanished session is restarted under the
653
- * environment it claimed rather than under a different one. `agent` is honoured when a caller
654
- * puts one on the tab and defaults to `shell` otherwise, which is the only honest default for
655
- * a tab that cannot say what the PM meant. */
656
- const t = rec.tab;
657
- SOCK.spawning.set(t.id, true);
658
- /* `sent: true` from birth: this slot is only ever pushed when the socket is up (the guard a few
659
- * lines above), and it is removed again if `send` refuses it. An `ask` is the kind that can sit
660
- * in the queue unsent, waiting for `onopen`. */
661
- const req = { kind: 'pane', tabId: t.id, sent: true };
662
- SOCK.spawnQueue.push(req);
663
- note(rec, 'pmos: starting a session…', true);
664
- /* `initiative` is the ONE field this message was missing (workspace-session-attribution R2).
665
- * `+ session` is clicked on an initiative row, `openTerm` puts that row's id on the tab as
666
- * `slug`, and `state.js` persists it — so the answer to "what is this session for?" has been
667
- * sitting on `rec.tab` at the moment of every spawn, while the message named three other fields.
668
- * Without it the server could only infer the initiative from the git branch, which is why a
669
- * session on `main` or on `claude/*` was invisible to the board.
670
- *
671
- * A tab with no slug sends nothing extra and the session is unattributed. That is the honest
672
- * outcome, not a failure: the server never refuses a spawn over a label. */
673
- const ok = send({
674
- t: 'new', name: t.sess, agent: t.agent || 'shell', ws: wsForTab(t),
675
- initiative: t.slug || null,
676
- profile: t.profile === undefined ? null : t.profile,
677
- });
678
- if (!ok) {
679
- SOCK.spawning.delete(t.id);
680
- SOCK.spawnQueue = SOCK.spawnQueue.filter((x) => x !== req);
681
- }
682
- return;
683
- }
684
- /* Say WHICH session was looked for and why it could not be found. A tab restored from a previous
685
- * run names an id; one opened from the board names a name. Both are worth printing — "nothing was
686
- * attached" without the identity is exactly the report that left the PM unable to tell which
687
- * session a reloaded tab had landed on. */
688
- note(rec, rec.tab.sessionId
689
- ? 'pmos: session ' + rec.tab.sessionId + ' ("' + (rec.tab.sess || '?')
690
- + '") is no longer running — nothing was attached'
691
- : 'pmos: no live session named "' + rec.tab.sess + '" in this repository — nothing was attached');
692
- }
693
-
694
- function attach(rec) {
695
- if (!rec.sessionId || !SOCK.open) return;
696
- if (rec.attachedId === rec.sessionId && SOCK.attached.has(rec.sessionId)) return;
697
- if (send({ t: 'attach', id: rec.sessionId })) SOCK.attached.add(rec.sessionId);
698
- }
699
-
700
- /**
701
- * Tell the PTY the grid this browser is actually rendering. Sent whenever the pane is attached and
702
- * the terminal's cols/rows differ from what this connection last stated — which covers the attach
703
- * itself, every refit that moves the grid, and a reconnect (where `sent*` is cleared).
704
- *
705
- * Idempotent by design: `sent*` makes a re-render cost nothing, and the guard is on what was SENT
706
- * rather than on what xterm reports, because the server holds the authoritative copy and a resize
707
- * this connection never sent is a resize the shell never heard.
708
- */
709
- function syncSize(rec, claim) {
710
- if (!rec || rec.kind !== 'real' || !rec.term) return;
711
- if (!rec.sessionId || rec.attachedId !== rec.sessionId) return;
712
- // A pane that another screen resized waits until the person uses it (`claim`). See `size`.
713
- if (claim) rec.yielded = false; else if (rec.yielded) return;
714
- const cols = rec.term.cols, rows = rec.term.rows;
715
- if (!cols || !rows) return;
716
- if (rec.sentCols === cols && rec.sentRows === rows) return;
717
- if (send({ t: 'resize', id: rec.sessionId, cols, rows })) { rec.sentCols = cols; rec.sentRows = rows; }
718
- }
719
-
720
- /**
721
- * State a grid that a refit changed, once the box stops moving. A phone's soft keyboard and a
722
- * rotation move the box several times in a few hundred milliseconds, and every grid the PTY hears
723
- * makes the agent redraw its whole frame. Typing still sends at once: `onData` calls syncSize
724
- * before the keystroke, which states the latest grid and makes the queued call a no-op.
725
- */
726
- const SIZE_SETTLE_MS = 120;
727
- function queueSize(rec) {
728
- clearTimeout(rec.sizeTimer);
729
- rec.sizeTimer = setTimeout(() => { rec.sizeTimer = null; syncSize(rec, true); }, SIZE_SETTLE_MS);
730
- }
731
-
732
- /** Write a status line into the terminal itself — once per distinct message, dimmed. */
733
- function note(rec, line, force) {
734
- if (!rec.term) return;
735
- if (!force && rec.noted === line) return;
736
- rec.noted = line;
737
- try { rec.term.write('\x1b[2m' + line + '\x1b[0m\r\n'); } catch { /* disposed */ }
738
- }
739
-
740
- /* ── refit ─────────────────────────────────────────────────────────────────────────────────────
741
- * The single entry point. Coalesced into one animation frame so the six triggers below cost one
742
- * measure per frame rather than six. A pane that is not in the document, or has no box yet, is
743
- * skipped — fitting a zero-sized element is how a terminal ends up 1×1 and stays there.
744
- */
745
- let refitQueued = false;
746
-
747
- export function refitVisible() {
748
- if (refitQueued) return;
749
- refitQueued = true;
750
- const run = () => {
751
- refitQueued = false;
752
- for (const rec of panes.values()) {
753
- if (rec.kind !== 'real' || !rec.fit || !rec.host) continue;
754
- if (!rec.host.isConnected) continue;
755
- if (!rec.host.offsetWidth || !rec.host.offsetHeight) continue;
756
- try { rec.fit.fit(); } catch { /* a terminal mid-teardown */ }
757
- // …and state the resulting grid to the PTY. `fit()` only fires xterm's `onResize` when the
758
- // grid MOVES, so a pane that was measured before it had a session would otherwise never tell
759
- // the shell how wide it is. See the `attached` handler. A grid change the fit just queued
760
- // (see queueSize) goes out when the box settles, not here.
761
- if (!rec.sizeTimer) syncSize(rec);
762
- }
763
- };
764
- if (typeof requestAnimationFrame === 'function') requestAnimationFrame(run);
765
- else setTimeout(run, 16);
766
- }
767
-
768
- /* Every event that can change a terminal's box. `subscribe` covers the three the PRD names —
769
- * a tab being shown, the split toggling, a panel collapsing — because each of them is a state
770
- * change, and the shell's render has already run by the time this subscriber does. */
771
- if (typeof window !== 'undefined') {
772
- subscribe(() => refitVisible());
773
- window.addEventListener('resize', () => refitVisible());
774
- document.addEventListener('visibilitychange', () => { if (!document.hidden) refitVisible(); });
775
- if (document.fonts && document.fonts.ready) document.fonts.ready.then(() => refitVisible()).catch(() => {});
776
- }
777
-
778
- /* ── fixture pane ──────────────────────────────────────────────────────────────────────────── */
779
-
780
- /* ── one terminal row ────────────────────────────────────────────────────────────────────────
781
- * TWO pane kinds, TWO different meanings for the same number, and that is the whole of the defect
782
- * this constant exists to keep fixed.
783
- *
784
- * FAUX SHELL (fixture) — SCROLL_STYLE below. `line-height:1.65` is CSS: a unitless multiplier on
785
- * the FONT SIZE. One line box is 12.5 × 1.65 = 20.625px. That is the PM's prototype, ported
786
- * character for character (planning/design/four-panel/prototype-original.html:929), and it is
787
- * also the value design-parity.js compares. It was never wrong; leave it alone.
788
- *
789
- * LIVE TERMINAL (real) — the xterm options. `lineHeight` there is xterm's OWN option, and its
790
- * renderer computes `cell.height = floor(char.height × lineHeight)` where `char.height` is the
791
- * font's MEASURED glyph box — 16px for IBM Plex Mono at 12.5px, already carrying the leading the
792
- * typeface ships with. So xterm's number adds leading ON TOP OF leading where CSS's replaces it.
793
- *
794
- * Passing the design's CSS 1.65 straight into xterm therefore rendered floor(1.65 × 16) = 26px
795
- * rows against a 20.625px reference — 26% looser than the design, 13.5px of empty space around a
796
- * 12.5px glyph — and the header comment at the top of this file recorded the belief that the two
797
- * agreed. Measured in Chromium against the served woff2: 1.0 → 16px, 1.2 → 19px, 1.3 → 20px,
798
- * 1.65 → 26px. 1.3 is the ratio that reproduces the design's line box through xterm's formula.
799
- *
800
- * It is not paint-only: addon-fit divides the pane height by the cell height to pick `rows`, and
801
- * syncSize() sends that to the PTY. At 26px a 565px pane told the shell it had 21 rows; at 20px it
802
- * tells it 28. The row height IS how much terminal the agent CLI gets to draw into.
803
- */
804
- const TERM_LINE_HEIGHT = 1.3;
805
- const SCROLL_STYLE = 'flex:1;min-height:0;overflow-y:auto;padding:14px 16px;font-family:var(--mono);font-size:12.5px;line-height:1.65;color:#c4ccce';
806
- const LINE_STYLE = (c) => 'color:' + c + ';white-space:pre-wrap;overflow-wrap:anywhere';
807
- const PROMPT_ROW_STYLE = 'display:flex;gap:8px;align-items:baseline';
808
- const PROMPT_STYLE = 'color:#47cf79;flex:none';
809
- const INPUT_STYLE = 'flex:1;min-width:0;font-family:var(--mono);font-size:12.5px;color:#f9fbfb;caret-color:#47cf79';
810
- const CARET_STYLE = 'width:8px;height:15px;background:#47cf79;animation:pmblink 1.1s step-end infinite;flex:none;align-self:center';
811
-
812
- /** The fake shell (lines 1993–2006). The command table itself lives in fixture.js. */
813
- function fauxKey(tab, e) {
814
- if (e.key !== 'Enter') return;
815
- const v = e.target.value.trim();
816
- if (!v) return;
817
- e.target.value = '';
818
- const reply = FX.fauxShellReply(v, tab);
819
- setState((s) => ({
820
- termHist: {
821
- ...s.termHist,
822
- [tab.id]: v === 'clear' ? [] : [
823
- ...(s.termHist[tab.id] || []),
824
- FX.termEcho(v),
825
- ...(reply ? [{ t: reply, c: FX.TERM_COLORS.text }] : []),
826
- ],
827
- },
828
- }));
829
- }
830
-
831
- function buildFixture(tab) {
832
- const input = el('input', { style: INPUT_STYLE, onKeyDown: (e) => fauxKey(rec.tab, e) });
833
- const promptRow = el('div', { style: PROMPT_ROW_STYLE },
834
- el('span', { style: PROMPT_STYLE }, 'root@vm:~/pmos$'),
835
- input,
836
- el('span', { style: CARET_STYLE }),
837
- );
838
- const scroll = el('div', { style: SCROLL_STYLE });
839
- const rec = { kind: 'fixture', tab, scroll, promptRow, input, lines: [] };
840
- return rec;
841
- }
842
-
843
- /**
844
- * Paint the transcript: the five attach lines, then whatever the session has said since. Line
845
- * nodes are REUSED rather than rebuilt — the prompt input sits in the same subtree and a rebuilt
846
- * ancestor is a lost caret.
847
- */
848
- function paintFixture(rec) {
849
- const tab = rec.tab;
850
- const lines = [...FX.termBaseLines(tab), ...((state.termHist || {})[tab.id] || [])];
851
- while (rec.lines.length > lines.length) rec.lines.pop();
852
- lines.forEach((ln, i) => {
853
- let node = rec.lines[i];
854
- if (!node) {
855
- const value = el('span', null, ln.t);
856
- node = el('div', { style: LINE_STYLE(ln.c) }, value);
857
- node._value = value;
858
- rec.lines[i] = node;
859
- return;
860
- }
861
- const want = LINE_STYLE(ln.c);
862
- if (node.getAttribute('style') !== want) node.setAttribute('style', want);
863
- if (node._value.textContent !== ln.t) node._value.textContent = ln.t;
864
- });
865
- setChildren(rec.scroll, [...rec.lines, rec.promptRow]);
866
- }
867
-
868
- /* ── real pane ─────────────────────────────────────────────────────────────────────────────── */
869
-
870
- /* The CSS contract a live terminal needs, and the reason for each half of it:
871
- * WRAP — `flex:1;min-height:0;position:relative;overflow:hidden`. It is the box the fit addon
872
- * measures, and it must be sized by the PANEL, never by the terminal inside it.
873
- * INNER — `position:absolute;inset:0`. Taking the terminal OUT OF FLOW is what breaks the loop:
874
- * in flow, the xterm's rendered height feeds the pane's automatic min-height, which
875
- * feeds the next fit, which adds rows — a terminal that grows a few thousand rows tall
876
- * on its own. Measured, not theorised: without `inset:0` this pane fit to 209 rows in a
877
- * 900px window.
878
- */
879
- const WRAP_STYLE = 'flex:1;min-height:0;position:relative;overflow:hidden;background:var(--term-bg)';
880
- const INNER_STYLE = 'position:absolute;inset:0;padding:14px 16px';
881
- const DEAD_STYLE = SCROLL_STYLE;
882
-
883
- /** The honest pane for a real-mode browser with no xterm on the page. */
884
- function buildDead(tab) {
885
- const scroll = el('div', { style: DEAD_STYLE },
886
- el('div', { style: LINE_STYLE(FX.TERM_COLORS.dim) },
887
- el('span', null, 'pmos: the terminal engine did not load — /vendor/xterm.js was not served, '
888
- + 'so nothing was attached. Run `npm install` in workspace/ and reload.')),
889
- );
890
- return { kind: 'dead', tab, scroll };
891
- }
892
-
893
- function buildReal(tab) {
894
- const Terminal = XTERM();
895
- if (!Terminal) return buildDead(tab);
896
- const inner = el('div', { style: INNER_STYLE });
897
- const host = el('div', { style: WRAP_STYLE }, inner);
898
- const term = new Terminal({
899
- fontFamily: '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
900
- fontSize: 12.5,
901
- // NOT the design's 1.65 — and that is the whole point. See TERM_LINE_HEIGHT above: xterm's
902
- // `lineHeight` multiplies the font's MEASURED box, where the design's CSS number multiplies the
903
- // font size. Handing the CSS number to xterm is what made a row 26px instead of 20.6px.
904
- lineHeight: TERM_LINE_HEIGHT,
905
- theme: xtheme(),
906
- cursorBlink: true,
907
- scrollback: 5000,
908
- allowProposedApi: true,
909
- });
910
- const Fit = FIT();
911
- let fit = null;
912
- if (Fit) { fit = new Fit(); term.loadAddon(fit); }
913
- const Links = LINKS();
914
- if (Links) { try { term.loadAddon(new Links()); } catch { /* optional */ } }
915
- term.open(inner);
916
- // xterm sizes itself to its container only if the element it created fills it.
917
- const xel = inner.querySelector('.xterm');
918
- if (xel) { xel.style.height = '100%'; xel.style.width = '100%'; }
919
-
920
- // ⌘K belongs to the shell's search, not to the PTY. Returning false stops xterm consuming the
921
- // key; the event still bubbles to app.js's window listener, which is where the palette lives.
922
- term.attachCustomKeyEventHandler((e) => !((e.metaKey || e.ctrlKey) && (e.key === 'k' || e.key === 'K')));
923
-
924
- const rec = {
925
- kind: 'real', tab, host, term, fit, sessionId: null, attachedId: null, noted: null, ro: null, sizeTimer: null,
926
- };
927
- // Typing, focusing or re-sizing THIS pane takes the session's grid back from another screen, and
928
- // the grid goes out before the keystroke so the agent answers it at this pane's size.
929
- term.onData((d) => { if (rec.sessionId) { syncSize(rec, true); send({ t: 'input', id: rec.sessionId, data: d }); } });
930
- term.onResize(() => queueSize(rec));
931
- host.addEventListener('focusin', () => syncSize(rec, true));
932
- if (typeof ResizeObserver === 'function') {
933
- rec.ro = new ResizeObserver(() => refitVisible());
934
- try { rec.ro.observe(host); } catch { /* ignore */ }
935
- }
936
- touchScroll(rec);
937
- return rec;
938
- }
939
-
940
- /* ── a swipe scrolls ───────────────────────────────────────────────────────────────────────────
941
- * xterm scrolls on a touch drag only while no program has asked for the mouse. A program that has
942
- * (Claude Code, tmux, an editor) gets nothing from a swipe, because xterm ignores touch then and a
943
- * touch is not a wheel. On an iPhone or iPad a swipe was therefore dead in exactly the sessions
944
- * that matter. A vertical drag on the pane is turned into wheel events instead, and xterm does with
945
- * them what it does with a mouse wheel: it scrolls its own scrollback, or it reports the wheel to
946
- * the program that asked for the mouse, or it sends arrow keys in a full-screen program that did
947
- * not. The finger's speed carries on for a moment after it lifts, as a native scroll does. A tap
948
- * is left alone, so it still focuses the terminal and raises the keyboard. */
949
- const TOUCH_SLOP = 6; // px a finger moves before a touch is a swipe rather than a tap
950
- const MOMENTUM_DECAY = 0.95; // the carried speed kept per frame after the finger lifts
951
-
952
- function touchScroll(rec) {
953
- const { host, term } = rec;
954
- let t = null; // the swipe in progress: { x, y, lastY, lastT, v, swiping }
955
- let glide = 0; // the momentum frame, if one is queued
956
-
957
- const wheel = (dy, x, y) => {
958
- const target = (term.element && term.element.querySelector('.xterm-screen')) || term.element;
959
- if (!target || !dy) return;
960
- target.dispatchEvent(new WheelEvent('wheel', {
961
- deltaY: dy, deltaMode: 0, clientX: x, clientY: y, bubbles: true, cancelable: true,
962
- }));
963
- };
964
- const stopGlide = () => { if (glide) { cancelAnimationFrame(glide); glide = 0; } };
965
-
966
- host.addEventListener('touchstart', (e) => {
967
- stopGlide();
968
- if (e.touches.length !== 1) { t = null; return; }
969
- const p = e.touches[0];
970
- t = { x: p.clientX, y: p.clientY, lastY: p.clientY, lastT: e.timeStamp, v: 0, swiping: false };
971
- }, { capture: true, passive: true });
972
-
973
- host.addEventListener('touchmove', (e) => {
974
- if (!t || e.touches.length !== 1) return;
975
- const p = e.touches[0];
976
- if (!t.swiping) {
977
- const dx = p.clientX - t.x, dy = p.clientY - t.y;
978
- if (Math.abs(dy) < TOUCH_SLOP || Math.abs(dy) < Math.abs(dx)) return;
979
- t.swiping = true;
980
- }
981
- // Ours from here: xterm's own touch handling and the page's scroll do not also see it.
982
- e.preventDefault();
983
- e.stopPropagation();
984
- const dy = t.lastY - p.clientY; // finger up = content up = wheel down
985
- const dt = Math.max(1, e.timeStamp - t.lastT);
986
- t.v = 0.8 * (dy / dt) + 0.2 * t.v;
987
- t.lastY = p.clientY; t.lastT = e.timeStamp;
988
- wheel(dy, p.clientX, p.clientY);
989
- }, { capture: true, passive: false });
990
-
991
- const end = () => {
992
- if (!t || !t.swiping) { t = null; return; }
993
- let v = t.v * 16; // px per frame
994
- const x = t.x, y = t.lastY;
995
- t = null;
996
- const step = () => {
997
- v *= MOMENTUM_DECAY;
998
- if (Math.abs(v) < 0.5) { glide = 0; return; }
999
- wheel(v, x, y);
1000
- glide = requestAnimationFrame(step);
1001
- };
1002
- if (Math.abs(v) >= 0.5) glide = requestAnimationFrame(step);
1003
- };
1004
- host.addEventListener('touchend', end, { capture: true, passive: true });
1005
- host.addEventListener('touchcancel', end, { capture: true, passive: true });
1006
- }
1007
-
1008
- /* ── the exported surface ──────────────────────────────────────────────────────────────────── */
1009
-
1010
- /**
1011
- * Mount (or re-show) the terminal body of `tab` inside `host` — the pane element panel-tabs.js
1012
- * keeps for this tab's whole life. Idempotent: the first call builds, every later call re-paints
1013
- * the fixture transcript or re-fits the live terminal. It never rebuilds an xterm.
1014
- */
1015
- export function mountTerm(host, tab) {
1016
- if (!host || !tab) return;
1017
- let rec = panes.get(tab.id);
1018
- if (!rec) {
1019
- rec = FIXTURE ? buildFixture(tab) : buildReal(tab);
1020
- panes.set(tab.id, rec);
1021
- if (rec.kind === 'real') connect();
1022
- }
1023
- rec.tab = tab; // the record is re-derived every render; the pane is not
1024
-
1025
- if (rec.kind === 'fixture') {
1026
- paintFixture(rec);
1027
- setChildren(host, [rec.scroll]);
1028
- return;
1029
- }
1030
- if (rec.kind === 'dead') { setChildren(host, [rec.scroll]); return; }
1031
-
1032
- setChildren(host, [rec.host]);
1033
- bind(rec);
1034
- refitVisible(); // the tab was just shown — this is the fit that must happen
1035
- }
1036
-
1037
- /**
1038
- * Release the terminal of a tab that has been CLOSED. The PTY is not killed: it is detached, so
1039
- * the session keeps running on the server and re-opening the tab (or reloading the page) picks it
1040
- * back up with its scrollback. Killing a session is the sidebar's explicit action, never a
1041
- * side effect of closing a view of it.
1042
- */
1043
- export function disposeTerm(tab) {
1044
- const id = tab && (tab.id || tab);
1045
- const rec = panes.get(id);
1046
- if (!rec) return;
1047
- panes.delete(id);
1048
- SOCK.spawning.delete(id);
1049
- /* The queue entry STAYS: the server is still going to answer that `new`, and dropping the slot
1050
- * would let the next tab's `created` be handed the session this one asked for. `created` finds no
1051
- * pane for the id and detaches from the orphan instead. */
1052
- if (rec.kind !== 'real') return;
1053
- if (rec.ro) { try { rec.ro.disconnect(); } catch { /* ignore */ } }
1054
- clearTimeout(rec.sizeTimer);
1055
- if (rec.sessionId) {
1056
- send({ t: 'detach', id: rec.sessionId });
1057
- SOCK.attached.delete(rec.sessionId);
1058
- }
1059
- if (rec.host && rec.host.parentNode) rec.host.parentNode.removeChild(rec.host);
1060
- /* DISPOSE ONE FRAME LATER, NOT NOW. `attached` calls `term.reset()`, and xterm 5's Viewport.reset()
1061
- * queues a requestAnimationFrame that reads the renderer's dimensions — a callback dispose() does
1062
- * not cancel. A tab closed inside that frame (a fast close, or a `tabs` replace that drops a
1063
- * terminal whose session has just attached) disposed the renderer first, and the queued callback
1064
- * then threw "Cannot read properties of undefined (reading 'dimensions')" as an uncaught page
1065
- * error, about half the runs of pm-term-test.js. Queued after it, this dispose runs after every
1066
- * callback xterm has already queued, against a renderer that still exists. The pane is already
1067
- * out of the document and out of `panes`, so nothing can draw into it or re-attach it meanwhile. */
1068
- const term = rec.term;
1069
- const later = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : (f) => setTimeout(f, 0);
1070
- later(() => { try { term.dispose(); } catch { /* already gone */ } });
1071
- }
1072
-
1073
- /**
1074
- * Write text to a terminal as if it had been typed — the scratchpad's `⇥ send to terminal`.
1075
- * In fixture mode the transcript is panel-tabs.js's to append (it already did); here there is a
1076
- * PTY, and text that only appeared in a transcript would be text the shell never received.
1077
- */
1078
- export function sendToTerm(tab, data) {
1079
- const rec = panes.get(tab && (tab.id || tab));
1080
- if (!rec || rec.kind !== 'real' || !rec.sessionId) return false;
1081
- return send({ t: 'input', id: rec.sessionId, data });
1082
- }
1083
-
1084
- /**
1085
- * Type a message into a running session, by id, and press Enter — for console3, which shows a session without a pane.
1086
- *
1087
- * The same socket and `input` frame the terminal's own keys use (the socket carries this page's launch nonce), so it is
1088
- * exactly as safe as typing into the terminal. The Enter goes in its own frame a moment later: an agent's screen reads
1089
- * text and Enter that arrive together as a paste, and a pasted Enter is a new line, not a send. Resolves false when the
1090
- * socket did not open, so a caller can say "not sent".
1091
- */
1092
- export async function typeIntoSession(id, text) {
1093
- if (FIXTURE || !id || !text) return false;
1094
- connect();
1095
- for (let i = 0; i < 50 && !socketOpen(); i++) await new Promise((r) => setTimeout(r, 100));
1096
- if (!send({ t: 'input', id, data: text })) return false;
1097
- await new Promise((r) => setTimeout(r, 150));
1098
- return send({ t: 'input', id, data: '\r' });
1099
- }
1100
-
1101
- /** Keys typed into a session as they are, with no Enter after them: a menu choice ('1') or Esc ('\x1b') for a running agent.
1102
- * The same frame and socket as typeIntoSession. Returns false when nothing was sent. */
1103
- export async function pressKeys(id, data) {
1104
- if (FIXTURE || !id || !data) return false;
1105
- connect();
1106
- for (let i = 0; i < 50 && !socketOpen(); i++) await new Promise((r) => setTimeout(r, 100));
1107
- return send({ t: 'input', id, data });
1108
- }
1109
-
1110
- /**
1111
- * End a running session, by id — the `+ session` chooser's one destructive action.
1112
- *
1113
- * The wire message already existed (`t:'kill'`); what did not exist anywhere in the four-panel
1114
- * surface was a way to reach it, which is why "is it safe to end this?" had no answer the PM could
1115
- * act on. This is a bare send: the CONFIRMATION lives in the chooser, next to the reading of what
1116
- * ending it would cost, because that is the only place the PM is looking at both at once.
1117
- *
1118
- * Returns false when the socket is not up, so a caller can say "not sent" rather than imply a kill
1119
- * that never left the page.
1120
- */
1121
- export function killSession(id) {
1122
- if (FIXTURE || !id) return false;
1123
- return send({ t: 'kill', id });
1124
- }
1125
-
1126
- /**
1127
- * Is the terminal socket open right now?
1128
- *
1129
- * Exported so a caller can decide BEFORE acting rather than discover afterwards. `killSession`
1130
- * already returned `false` on a closed socket and its own docstring said a caller should use that
1131
- * to say "not sent" — the chooser discarded it, and a destructive control disarmed on a request
1132
- * that never left the page. The pre-flight is what lets the chooser refuse and SAY WHY, and the
1133
- * reason has to be distinguishable from "the module is not loaded", which the return value alone
1134
- * cannot express.
1135
- *
1136
- * The readiness constant is `1` (`OPEN`) and nothing else: `CONNECTING` is not open, and a frame
1137
- * written to a `CLOSING` socket is a frame nobody receives.
1138
- */
1139
- export function socketOpen() {
1140
- return !!(SOCK.ws && SOCK.ws.readyState === 1);
1141
- }
1142
-
1143
- /**
1144
- * Write a status line into a tab's terminal, by tab id — for a caller that holds a fact about a
1145
- * session but not the pane showing it.
1146
- *
1147
- * The pre-flight is the caller. `spawnWithBranch` answers an accepted start with a `notice` — a
1148
- * worktree's path, "not a git repository, so no branch was applied" — and that notice arrives
1149
- * BEFORE the pane it belongs to exists, because the pane is now built from the acceptance. Without
1150
- * this the server's deliberate non-fatal truth would be dropped precisely because the request
1151
- * succeeded, which is the same swallow as the one this initiative removes, in the happy path.
1152
- *
1153
- * The pane may not be mounted on the very next frame, so the write is retried a few times and then
1154
- * given up on quietly — a status line is worth trying for, not worth a timer that never stops.
1155
- */
1156
- export function noteOnTab(tabId, line, tries) {
1157
- const rec = panes.get(tabId);
1158
- if (rec && rec.term) { note(rec, line, true); return true; }
1159
- const left = tries === undefined ? 20 : tries;
1160
- if (left <= 0) return false;
1161
- setTimeout(() => noteOnTab(tabId, line, left - 1), 100);
1162
- return false;
1163
- }
1164
-
1165
- /**
1166
- * The SERVER's session id this tab is bound to, or null. The scratchpad reads it: a pad belongs to
1167
- * the session, and the session's identity is this id — not the tab id (which survives a session
1168
- * being replaced) and not the session name (which repeats across repositories).
1169
- */
1170
- export function sessionIdOf(tab) {
1171
- const rec = panes.get(tab && (tab.id || tab));
1172
- if (rec && rec.kind === 'real' && rec.sessionId) return rec.sessionId;
1173
- return (tab && tab.sessionId) || null;
1174
- }
1175
-
1176
- /** Focus the terminal of a tab, if it is live. */
1177
- export function focusTerm(tab) {
1178
- const rec = panes.get(tab && (tab.id || tab));
1179
- if (rec && rec.kind === 'real') { try { rec.term.focus(); } catch { /* ignore */ } }
1180
- }
1181
-
1182
- /* A read-only window into this module for the browser suite: cell geometry after a tab switch and
1183
- * a split is the assertion that guards the quiet PTY regression, and it cannot be read from the
1184
- * DOM alone. */
1185
- export function termProbe() {
1186
- const out = {};
1187
- for (const [id, rec] of panes) {
1188
- out[id] = rec.kind === 'real'
1189
- ? { kind: 'real', cols: rec.term.cols, rows: rec.term.rows, sessionId: rec.sessionId,
1190
- attached: rec.attachedId === rec.sessionId && !!rec.sessionId,
1191
- width: rec.host.offsetWidth, height: rec.host.offsetHeight }
1192
- : { kind: rec.kind, lines: rec.lines ? rec.lines.length : 0 };
1193
- }
1194
- return out;
1195
- }
1196
-
1197
- /**
1198
- * The message entry point, exposed for the browser suite ONLY.
1199
- *
1200
- * `handle` is what `ws.onmessage` calls after `JSON.parse`, so feeding it a frame exercises the
1201
- * exact path a real broadcast takes — nothing is stubbed and no branch is special-cased for a
1202
- * test. It exists because the `{t:'branch'}` claim cannot honestly be asserted any other way: the
1203
- * only way to make the server broadcast one is to check a branch out, and the server under test in
1204
- * pm-term-test.js is serving the repository the suite is running in.
1205
- */
1206
- export function __handleForTest(m) { return handle(m); }
1207
-
1208
- if (typeof window !== 'undefined') window.pmTerm = { refitVisible, termProbe, panes, requestSpawn };
1209
-
1210
- export default mountTerm;