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,1506 +0,0 @@
1
- /* pm/panel-tabs.js — panel 4: the tab bar, the panes, the scratchpad and the bottom bar.
2
- *
3
- * A port of the prototype's third column (template lines 844–997, derivation 1962–2126). Every
4
- * inline style below is the prototype's string, copied character for character; the interpolated
5
- * values are wrapped in their own `<span>` because that is what the prototype's runtime emits for
6
- * `{{ … }}` (verified against the reference render: `<span class="sc-interp">value</span>`), and a
7
- * text node where the design has an element moves the comparator's geometry.
8
- *
9
- * ── What this module owns ───────────────────────────────────────────────────────────────────
10
- * the tab bar · + session · split · the empty state · which pane hosts exist and where they sit
11
- * · the scratchpad · the bottom bar (scratchpad toggle, active-tab title, copy)
12
- * The BODY of a tab belongs to its own module — `mountDoc` (tab-doc.js), `mountTerm` (tab-term.js). This file never
13
- * renders a tab's contents.
14
- *
15
- * ── Why the pane hosts are cached ───────────────────────────────────────────────────────────
16
- * A term pane hosts a live xterm attached to a real PTY. Rebuilding that element on an unrelated
17
- * state change silently loses the terminal's grid — "the quiet PTY regression" the PRD names. So
18
- * one host element is created per tab id, kept for as long as the tab exists, and merely
19
- * re-ordered by `setChildren`. It is disposed only when the tab is actually closed.
20
- *
21
- * ── Scoping ────────────────────────────────────────────────────────────────────────────────
22
- * Tabs are per repository (prototype lines 1963–1966): a tab whose slug belongs to a repository is
23
- * visible only in that repository; a tab whose slug is not on any board (a SKILL.md, a decision
24
- * page, a doc opened with `slug:null`) is visible everywhere. That is a derivation, recomputed at
25
- * read time, never a stored flag — the `repo` field a tab carries is only the fallback for a slug
26
- * the board no longer knows about.
27
- */
28
-
29
- import { el, setChildren } from './dom.js';
30
- import { state, setState, FIXTURE, LEGACY_LAYOUT_FLAG } from './state.js';
31
- import { isMobile } from './mobile.js';
32
- import * as FX from './fixture.js';
33
- import { openTab, openTerm as openTermTab, openDoc as openDocTab } from './panel-initiatives.js';
34
- import { mountDoc, disposeDoc, docText } from './tab-doc.js';
35
- import { mountWeb, promptWeb } from './tab-web.js';
36
- import { newSessionBlock, openNewSession } from './panel-newsess.js';
37
- import { boardOf, currentProduct } from './board-read.js';
38
- import { field, button, iconButton, row, toast, ensureComponentsCss, SEL } from './primitives.js';
39
- import { COPY } from './frame-copy.js';
40
- import { COPY as PAL } from './palette-copy.js';
41
- import { askChoice } from './dialogs.js';
42
- import { icon, ensureSprite } from './icons.js';
43
-
44
- /* tab-term.js is loaded LAZILY and on purpose: it is another module's file, a static import of a
45
- * file that is not on disk yet takes the whole panel down with it, and an empty terminal pane is a
46
- * far smaller failure than a dead panel 4. When it lands, the panel repaints itself. */
47
- let termMod = null;
48
- let liveMod = null;
49
- let cockpitMod = null;
50
- /* Loaded lazily; a repaint is asked for only when a skill tab is already open (restored on reload) and waiting for it. */
51
- import('./panel-cockpit.js').then((m) => { cockpitMod = m; if ((state.tabs || []).some((t) => t.kind === 'view')) setState({}); }).catch(() => { cockpitMod = null; });
52
- import('./modes-live.js').then((m) => { liveMod = m; if ((state.tabs || []).some((t) => t.kind === 'skill' || t.kind === 'transcript')) setState({}); }).catch(() => { liveMod = null; });
53
- import('./tab-term.js')
54
- .then((m) => { termMod = m; setState({}); })
55
- .catch(() => { termMod = null; });
56
- /* pm-os-absorb Run 1 — panel-breakdown.js is loaded LAZILY for the same reason, and for one more: it is a 14-module graph
57
- * (primitives, icons, bd-*, item-sheet, handoff-box, keep-card, undo-hold), and a static import makes THIS module's
58
- * evaluation wait for all of it. Those fetches queue behind the server's synchronous boot reads (/api/initiative,
59
- * /api/library), so panel 4 — and with it tab-term.js and the terminal socket — came up after loadRepos instead of
60
- * beside it, and a reload's socket opened ~1.5 s late. A Breakdown tab restored on reload repaints when it lands. */
61
- let breakdownMod = null;
62
- import('./panel-breakdown.js')
63
- .then((m) => { breakdownMod = m; if ((state.tabs || []).some((t) => t.kind === 'breakdown')) setState({}); })
64
- .catch(() => { breakdownMod = null; });
65
-
66
- let reportTabMod = null;
67
- import('./report-tab.js')
68
- .then((m) => { reportTabMod = m; if ((state.tabs || []).some((t) => t.kind === 'report')) setState({}); })
69
- .catch(() => { reportTabMod = null; });
70
-
71
- /** `{{ expr }}` — one interpolated value in its own span, the way the prototype's runtime emits it. */
72
- /* A dock control's face: a lucide icon from the vendored sprite, then its word (C6: no Unicode glyph controls). */
73
- const iconLabel = (name, text) => (text ? [icon(name), el('span', null, text)] : [icon(name)]);
74
- const closeIcon = () => { ensureSprite(); return icon('x'); };
75
- const iv = (v) => el('span', null, v === null || v === undefined ? '' : String(v));
76
-
77
- /* ── the board, read exactly the way panels 2 and 3 read it (board-read.js) ─────────────────── */
78
-
79
- /** The selected initiative (prototype line 1397) — the slug `+ session` starts a session on. */
80
- function selSlug() {
81
- if (state.sel) return state.sel;
82
- const product = currentProduct();
83
- if (FIXTURE) return FX.defaultSlug(product);
84
- for (const g of (boardOf()[product] || [])) if (g.slugs && g.slugs.length) return g.slugs[0];
85
- return null;
86
- }
87
-
88
- /** slugProduct (lines 1963–1965) — which repository owns each initiative slug. */
89
- function slugProductOf() {
90
- const map = {};
91
- const board = boardOf();
92
- Object.keys(board).forEach((prod) => {
93
- (board[prod] || []).forEach((g) => (g.slugs || []).forEach((s) => { map[s] = prod; }));
94
- });
95
- Object.keys(state.addedInits || {}).forEach((key) => {
96
- const prod = key.split('|')[0];
97
- (state.addedInits[key] || []).forEach((s) => { map[s] = prod; });
98
- });
99
- return map;
100
- }
101
-
102
- /** The tabs visible in the current repository (line 1966). */
103
- function visibleTabs() {
104
- const product = currentProduct();
105
- const map = slugProductOf();
106
- return (state.tabs || []).filter((t) => {
107
- const sp = map[t.slug] !== undefined ? map[t.slug] : t.repo;
108
- /* `== null` on purpose: an unattributed-session tab carries `slug: null, repo: null`
109
- * (panel-initiatives openTerm), and a strict undefined check excluded it from EVERY
110
- * repository's bar — an open, PTY-attached tab with no visible chip and no close button. A
111
- * tab on no board is visible everywhere, whichever null-ish shape says so. */
112
- return sp == null || sp === product;
113
- });
114
- }
115
-
116
- /* ── the openers ───────────────────────────────────────────────────────────────────────────────
117
- * `openTab` / `openTerm` / `openDoc` have exactly ONE implementation, in panel-initiatives.js,
118
- * and are re-exported here so a caller can reach them from the panel that owns tabs. Their
119
- * argument order is the prototype's (`openDoc(slug, path, role)`, `openTerm(slug, sess)`), which
120
- * is what every existing call site in this repo passes.
121
- */
122
- export { openTab };
123
-
124
- /** openDoc (line 1400): focus the tab for `path`, opening it first if it is not already there. */
125
- export function openDoc(slug, path, role) {
126
- return openDocTab(slug, path, role);
127
- }
128
-
129
- /**
130
- * openTerm (line 1399). Two shapes:
131
- * openTerm(slug, sess) — attach a tab to a session that already exists;
132
- * openTerm(slug) — start a NEW session on that initiative and open it (the `+ session`
133
- * path), defaulting to the currently selected initiative.
134
- */
135
- export function openTerm(slug, sess) {
136
- if (sess === undefined) return newSession(typeof slug === 'string' ? slug : undefined);
137
- return openTermTab(slug, sess);
138
- }
139
-
140
- /** Close one tab (lines 1971–1974): the last remaining tab takes over, a dangling split is dropped. */
141
- export function closeTab(id) {
142
- setState((s) => {
143
- const rest = s.tabs.filter((t) => t.id !== id);
144
- return {
145
- tabs: rest,
146
- active: s.active === id ? (rest.length ? rest[rest.length - 1].id : null) : s.active,
147
- splitId: s.splitId === id ? null : s.splitId,
148
- };
149
- });
150
- }
151
-
152
- /**
153
- * The terminal tabs attached to ONE session, by tab id (initiative-surface-batch R1).
154
- *
155
- * A terminal tab carries the SERVER's session id (`sessionId`), which is the exact join. Read it BEFORE the
156
- * server is asked to end the session, not after: the moment the server drops the session it pushes the new
157
- * list, and a tab whose id is no longer listed re-joins by NAME (tab-term.js `resolveSessionId`) — so when two
158
- * sessions share a name the doomed tab quietly adopts its sibling and starts reporting the sibling's id, and a
159
- * lookup made after the answer finds nothing to close.
160
- */
161
- export function tabIdsOfSession(sessionId) {
162
- if (!sessionId) return [];
163
- return (state.tabs || []).filter((t) => t && t.kind === 'term' && t.sessionId === sessionId).map((t) => t.id);
164
- }
165
-
166
- /**
167
- * Close tabs by id. Called only after the server said the session is gone; closing a tab by hand still only
168
- * detaches. Another session's tab, and a tab that is not in `ids`, are untouched. Returns how many closed.
169
- */
170
- export function closeTabsById(ids) {
171
- const doomed = (state.tabs || []).filter((t) => t && (ids || []).includes(t.id)).map((t) => t.id);
172
- if (!doomed.length) return 0;
173
- setState((s) => {
174
- const rest = s.tabs.filter((t) => !doomed.includes(t.id));
175
- return {
176
- tabs: rest,
177
- active: doomed.includes(s.active) ? (rest.length ? rest[rest.length - 1].id : null) : s.active,
178
- splitId: doomed.includes(s.splitId) ? null : s.splitId,
179
- };
180
- });
181
- return doomed.length;
182
- }
183
-
184
- export const closeTabsOfSession = (sessionId) => closeTabsById(tabIdsOfSession(sessionId));
185
-
186
- /* The data layer's optional session-start hook. In fixture mode nothing is ever started; in real
187
- * mode the PTY is data.js's to create, and panel 4's part is only to show the tab for it. */
188
- let dataMod = null;
189
- /* The repaint matters: `syncPad` below cannot name a pad before this module exists, so the render
190
- * that lands it is the render that first loads the PM's staged text. */
191
- import('./data.js').then((m) => { dataMod = m; setState({}); }).catch(() => { dataMod = null; });
192
-
193
- /**
194
- * The next free `agent <n>`, counted against EVERY name the window can see — the server's live
195
- * sessions, the ones started in this window, and the tabs already open — not just this page's
196
- * counter.
197
- *
198
- * `startN` resets to 1 on every reload, and the name is what the terminal used to join on and what
199
- * the tab id is built from. So after a reload the first `+ session` proposed `agent 1`, which was
200
- * already running from before the reload: the click attached to that old session instead of
201
- * starting a new one, and a second click collided with its own tab id. Counting past what exists
202
- * is what makes `+ session` mean "a new one" again.
203
- */
204
- function nextSessionName() {
205
- let max = state.startN - 1;
206
- const bump = (name) => {
207
- const m = /^agent (\d+)$/.exec(String(name || ''));
208
- if (m) max = Math.max(max, Number(m[1]));
209
- };
210
- for (const s of (state.sessions || [])) bump(s && s.name);
211
- for (const k in (state.extraSess || {})) for (const s of (state.extraSess[k] || [])) bump(s && s.name);
212
- for (const t of (state.tabs || [])) if (t && t.kind === 'term') bump(t.sess);
213
- return { n: max + 1, name: 'agent ' + (max + 1) };
214
- }
215
-
216
- /* ── who is already in the tree this session would land in ───────────────────────────────────
217
- *
218
- * The workspace used to answer this AFTER the fact: it started the session, then wrote "2 sessions
219
- * already running in this working tree" into the new pane. That sentence is true and arrives one
220
- * step too late — the PM has already made the thing they might not have wanted, and the sentence
221
- * names a count they cannot act on. Worse, the answer they usually want is not "start another"
222
- * at all; it is "which of those is the one I was already working in?".
223
- *
224
- * So the same facts are computed BEFORE the spawn, from data the page already holds:
225
- * • the tree the new session would land in — data.js publishes it per registered workspace id
226
- * (`/api/workspaces` → `tree`), which is available even when that tree has no session yet;
227
- * • the live sessions in it — `state.sessions`, each row carrying the server's own `tree`,
228
- * `tree_role`, presented state and rendered label;
229
- * • what ending each one would cost — lib/tree-share's `endRisk`, the same module the server uses
230
- * for the pane advisory, so the two readings are one reading.
231
- *
232
- * Nothing is derived twice and nothing is guessed. When any input is missing — fixture mode, no
233
- * workspace selected, a folder with no git, the shared module not loaded — this answers "nobody",
234
- * and `+ session` behaves exactly as it always did. A chooser that appears on a bad guess would be
235
- * worse than no chooser.
236
- */
237
- function treePeersNow() {
238
- if (FIXTURE) return null;
239
- const TS = typeof window !== 'undefined' ? window.PMOSTreeShare : null;
240
- if (!TS) return null;
241
- const ws = state.wsId || null;
242
- const tree = ws && dataMod && typeof dataMod.treeOfWorkspace === 'function'
243
- ? dataMod.treeOfWorkspace(ws) : null;
244
- if (!tree) return null; // no git, or nothing selected — no index to share
245
- const rows = Array.isArray(state.sessions) ? state.sessions : [];
246
- // The map coTenants() keys on. Built from each row's OWN `tree`, which the server derived — the
247
- // client never runs git and must not pretend to. The target workspace is added explicitly so a
248
- // tree whose only registration has no session yet still resolves.
249
- const treeOfWs = new Map([[ws, tree]]);
250
- for (const r of rows) if (r && r.ws && !treeOfWs.has(r.ws)) treeOfWs.set(r.ws, r.tree || null);
251
- const mates = TS.coTenants(rows, treeOfWs, tree, null);
252
- if (!mates.length) return null;
253
- // The declared writer, read off the row the server already marked rather than recomputed.
254
- const held = rows.find((r) => r && r.tree === tree && r.tree_role === 'writer');
255
- return {
256
- tree,
257
- branch: (dataMod && typeof dataMod.branchOfWorkspace === 'function' && dataMod.branchOfWorkspace(ws)) || null,
258
- peers: mates.map((m) => TS.describeTenant(m, held ? held.id : null)),
259
- };
260
- }
261
-
262
- /**
263
- * `+ session` (line 2087): file a new session against the selected initiative and open its tab.
264
- * The session lands in `extraSess` — the prototype's own list of sessions started in this window —
265
- * and the terminal tab is opened in the callback, i.e. after the render that added it.
266
- *
267
- * `opts.force` skips the chooser. It is what the chooser's own "start another session here anyway"
268
- * calls, so the guard is asked exactly once per click and a PM who has already answered the
269
- * question is never asked it twice.
270
- */
271
- export function newSession(slug, opts) {
272
- const target = slug || selSlug();
273
- if (!target) return;
274
- if (!(opts && opts.force)) {
275
- const found = treePeersNow();
276
- if (found) { setState({ startPrompt: { slug: target, ...found }, endConfirm: null }); return; }
277
- }
278
- const { n, name } = nextSessionName();
279
- /* `spawn` is carried on the session and thence onto the tab: it is an INSTRUCTION to start a PTY,
280
- * and it is the only thing that authorises one. Without it the terminal resolves by name, which
281
- * is a question about what already exists, not a request for something new. */
282
- /* NO PROFILE, and stated rather than left to a slot. This control asks the PM nothing — that is
283
- * what makes it one click — so the only honest thing it can say about a profile is that none was
284
- * chosen, which the server reads as "no overlay" rather than as a client that forgot the field.
285
- *
286
- * It used to read `state.newSessProfile`, the slot the `⋯ options` pre-flight also wrote. Opening
287
- * that form wrote the server's remembered preference into it and every chip wrote the PM's choice
288
- * into it, and cancelling cleared neither — so a question the PM had abandoned came back as an
289
- * instruction on the next one-click start, travelled to the server on the tab, and was refused
290
- * whenever the descriptor could not be resolved. The click then opened a terminal and wrote the
291
- * refusal inside it, for a session that never existed. A profile is a per-session question, and
292
- * the control that asks it is the only one that may answer it. */
293
- const sess = { name, st: 'working', label: 'working', profile: null, spawn: true };
294
- setState((s) => ({
295
- startN: n + 1,
296
- startPrompt: null,
297
- endConfirm: null,
298
- extraSess: { ...s.extraSess, [target]: [...(s.extraSess[target] || []), sess] },
299
- }), () => openTermTab(target, sess));
300
- if (!FIXTURE && dataMod && typeof dataMod.startSession === 'function') {
301
- try { dataMod.startSession(target, sess); } catch { /* the tab still opens */ }
302
- }
303
- }
304
-
305
- /** Join a session that is already running instead of starting one: open its tab, start nothing. */
306
- export function joinSession(slug, peer) {
307
- if (!peer) return;
308
- setState({ startPrompt: null, endConfirm: null }, () => openTermTab(slug, {
309
- name: peer.name, st: peer.shown, profile: peer.profile || null,
310
- /* The SERVER's id, and NO `spawn`. Both halves matter and they are the exact difference
311
- * between joining and starting: `id` is the join, so the tab attaches to precisely the PTY the
312
- * PM pointed at rather than matching by a name that repeats across repositories; the absent
313
- * `spawn` is what withholds authorisation to create one. A peer described by
314
- * treeShare.describeTenant always carries its id, so this is never a name-match in practice. */
315
- id: peer.id || null,
316
- }));
317
- }
318
-
319
- /** Dismiss the chooser without starting or joining anything. */
320
- export function dismissStartPrompt() {
321
- setState({ startPrompt: null, endConfirm: null });
322
- }
323
-
324
- /** `⫽ split` / `⫽ unsplit` (lines 2088–2092). */
325
- export function toggleSplit() {
326
- setState((s) => {
327
- if (s.splitId) return { splitId: null };
328
- const other = s.tabs.find((t) => t.id !== s.active);
329
- return { splitId: other ? other.id : null };
330
- });
331
- }
332
-
333
- /* ── persistent chrome ─────────────────────────────────────────────────────────────────────── */
334
-
335
- const BAR_STYLE = 'display:flex;gap:2px;align-items:stretch;padding:6px 8px 0;border-bottom:1px solid var(--border);min-height:48px;min-width:0;overflow-x:auto';
336
- const CHIP_STYLE = 'flex:none;align-self:center;font:11px var(--mono);color:var(--muted-foreground);padding:5px 11px;min-height:30px;background:var(--secondary);border:1px solid var(--border);white-space:nowrap;margin-left:4px';
337
- const SPLIT_STYLE = 'flex:none;margin-left:auto;align-self:center;font:11px var(--mono);color:var(--muted-foreground);padding:5px 12px;min-height:30px;background:var(--secondary);border:1px solid var(--border);white-space:nowrap';
338
- const CHIP_HOVER = 'border-color:var(--ring)';
339
-
340
- /* The strip and the bottom bar are chrome: they follow the theme (PRD R27). Only the terminal itself stays dark (D41): its pane
341
- * paints --term-bg. `data-term-chrome` stays as a hook for the suites. */
342
- const tabBar = el('div', { 'data-tabs': 'bar', 'data-term-chrome': '', style: BAR_STYLE, onWheel: stripWheel });
343
-
344
- /* ── the cockpit's tab strip (workspace-cockpit-nav Run 4, planning/design/cockpit-mockup/WsA.dc.html) ─────────────────────────
345
- * On a desktop the strip is the mockup's: a 44px band whose tabs sit on its floor, the tab in front a card with rounded top corners,
346
- * the others plain, each a dot and a title in 12px mono, and `+ session` at the right end. A phone and `?layout=legacy` keep the
347
- * prototype's strip above. What the mockup does not draw is kept (R12): a tab's second line (its initiative and session) sits under
348
- * its title in the tab's own lower padding, so the title stays where the mockup puts it; a tab that is not in front keeps its close
349
- * control, in its right padding; the web, options and split controls sit to the left of `+ session`. */
350
- const cockpitLook = () => !LEGACY_LAYOUT_FLAG && !isMobile();
351
- const CK_BAR = 'flex:none;display:flex;align-items:flex-end;gap:4px;padding:0 10px;height:45px;border-bottom:1px solid var(--border);min-width:0;overflow-x:auto';
352
- /* ── the tabs as a vertical list (the PM's request after testing 0.48.0: the strip gets crowded with many tabs open) ─────────────
353
- * `state.tabsVertical` puts the open tabs in a column on the left of the panes, one row per tab with its title, its second line and
354
- * its close control, and the session controls under them. The choice is stored with the layout, so it survives a reload. It is a
355
- * cockpit (desktop) choice only: a phone and `?layout=legacy` keep the strip.
356
- *
357
- * NOTHING MOVES WHEN IT IS SWITCHED. The panes, the chooser, the scratchpad and the bottom bar live in one persistent column
358
- * (`tabsMain`) that is always the second child of the host; the switch only turns the host's flex direction and restyles the bar.
359
- * A live terminal is never re-parented by it. */
360
- const CK_VBAR = 'flex:none;width:224px;display:flex;flex-direction:column;align-items:stretch;gap:2px;padding:8px 6px;border-right:1px solid var(--border);min-height:0;overflow-y:auto;overflow-x:hidden';
361
- const tabsMain = el('div', { 'data-tabs': 'main', style: 'flex:1;min-height:0;min-width:0;display:flex;flex-direction:column' });
362
- const orientLabel = iv('');
363
- const orientIcon = el('span', null);
364
- const orientBtn = el('button', {
365
- onClick: () => setState({ tabsVertical: !state.tabsVertical }), 'data-tabs': 'orient',
366
- }, orientIcon, orientLabel);
367
- /* In the strip, a mouse wheel scrolls the tabs sideways: with many tabs open the strip is wider than the panel, and a wheel that
368
- * did nothing there left only the thin scrollbar. */
369
- function stripWheel(e) {
370
- if (state.tabsVertical || !e.deltaY || Math.abs(e.deltaX) > Math.abs(e.deltaY)) return;
371
- const bar = e.currentTarget;
372
- if (bar.scrollWidth <= bar.clientWidth) return;
373
- bar.scrollLeft += e.deltaY;
374
- e.preventDefault();
375
- }
376
-
377
- const CK_BTN = 'flex:none;margin:0 0 4px;height:30px;display:grid;place-items:center;font:500 12.5px var(--sans);line-height:normal;background:transparent;color:var(--foreground);border:1px solid var(--input);border-radius:8px;padding:0 12px;white-space:nowrap';
378
-
379
- const newSessionBtn = el('button', {
380
- onClick: () => newSession(), style: CHIP_STYLE, hover: CHIP_HOVER,
381
- 'aria-label': 'new session',
382
- }, ...iconLabel('plus', 'session'));
383
-
384
- /* overhaul-r5 (D69) — open a web page in a tab, by typing its address. Live mode only. */
385
- const newWebBtn = el('button', {
386
- onClick: () => promptWeb(), style: CHIP_STYLE, hover: CHIP_HOVER,
387
- title: 'open a web page in a tab (http/https; it loads only when you open it)', 'data-r5': 'new-web', 'aria-label': 'open a web page',
388
- }, ...iconLabel('globe', 'web'));
389
-
390
- /* `⋯ options` — the demoted composer, restored (workspace-session-preflight).
391
- *
392
- * `workspace-repo-first`'s accepted PRD says the six-question composer "remains reachable as *more
393
- * options* … it is demoted, not deleted". The four-panel rebuild deleted it, and start-policy.test
394
- * has been asserting in a comment that `spawnWithBranch` is "still reachable as more options" —
395
- * reachable from the server, by no client. This chip is the client half.
396
- *
397
- * `+ session` above is untouched: same handler, same text, same CHIP_STYLE, same co-tenancy
398
- * chooser. One click stays the primary path, which is what that PRD decided. */
399
- const newSessionOptsBtn = el('button', {
400
- onClick: () => openNewSession(selSlug()),
401
- style: CHIP_STYLE, hover: CHIP_HOVER,
402
- title: 'choose the branch, the agent and the profile before the session starts', 'aria-label': 'session options',
403
- }, ...iconLabel('ellipsis', 'options'));
404
-
405
- const splitLabel = iv('split');
406
- const splitBtn = el('button', {
407
- onClick: () => toggleSplit(), style: SPLIT_STYLE, hover: CHIP_HOVER,
408
- }, icon('columns-2'), splitLabel);
409
-
410
- const emptyState = el('div', {
411
- style: 'flex:1;display:grid;place-items:center;color:oklch(0.55 0.02 213);font-size:12.5px;padding:20px;text-align:center',
412
- }, "Nothing is open. Open an artifact, or press + session to start a session.");
413
-
414
- const panesRow = el('div', { 'data-tabs': 'panes', style: 'flex:1;display:flex;min-height:0;min-width:0;overflow:hidden' });
415
-
416
- /* ── the scratchpad (lines 983–991) ──────────────────────────────────────────────────────────
417
- * One textarea, created once. Its text is written back as a CHILD TEXT NODE as well as a value,
418
- * because that is what the prototype's runtime does and the comparator reads text nodes — but only
419
- * when the two differ, so a repaint mid-sentence never moves the PM's caret.
420
- *
421
- * ── ONE PAD PER SESSION ─────────────────────────────────────────────────────────────────────
422
- * The pad stages the next thing to type into a PARTICULAR agent, so it belongs to that agent's
423
- * session. The four-panel port shipped it as one in-memory string for the whole page, which meant
424
- * every terminal — in every repository, in every window — showed and overwrote the same buffer.
425
- *
426
- * The store is `state.scratchPads`, keyed by:
427
- * `sess:<server session id>` — a terminal tab bound to a live PTY. The id is the SERVER's, so two
428
- * sessions both called `agent 1` in two repositories are two pads.
429
- * `ws:<workspace id>` — everything else (a doc, nothing open): the repository pad.
430
- * That is exactly the key space `/api/scratchpad` already stores under — the endpoint has been
431
- * per-session all along, and it is the client half that went missing. `state.scratchText` remains
432
- * the text ON SCREEN, so the copy button, `⇥ send to terminal` and the fixture render are unchanged.
433
- *
434
- * FIXTURE MODE IS UNTOUCHED: no key, no fetch, one pad, the prototype's own placeholder. The offline
435
- * demo path must make no network call, and the comparator must see the design's string.
436
- */
437
- const SCRATCH_PLACEHOLDER = FIXTURE
438
- ? 'scratchpad — survives tab switches, dies with the page'
439
- : 'scratchpad — one pad per session, saved on this machine';
440
-
441
- /* workspace-cockpit-nav Run 3 (PRD R10) — the drawer takes the form of the cockpit board
442
- * `planning/design/cockpit-mockup/ViewFilesPad.dc.html`: a labelled header with a fold control, the pad
443
- * as a bordered field, and one row of buttons with a short note. The textarea stays a DIRECT child of
444
- * `scratchBlock` (the height ceiling and pm-tabs-test measure through `parentElement`), and every
445
- * behaviour below — the per-session pad, the autosave, the height handle — is unchanged. */
446
- const scratchTa = el('textarea', {
447
- placeholder: SCRATCH_PLACEHOLDER,
448
- 'data-scratch': 'text',
449
- style: 'height:96px;flex:none;width:100%;border:1px solid var(--input);border-radius:8px;background:var(--background);'
450
- + 'color:var(--foreground);padding:10px 12px;font:12.5px/1.55 var(--mono)',
451
- onInput: (e) => onScratchInput(e.target.value),
452
- });
453
-
454
- /* ── the drawer's height ────────────────────────────────────────────────────────────────────
455
- * 96px — four lines of the 12px mono face — was a literal in the style string above, and it was the
456
- * pad's only size. The pad's job (see the block comment above) is to stage the next thing to type
457
- * into a particular agent, and a staged instruction is routinely longer than four lines, so the PM
458
- * composed in a box that scrolled internally while a large empty pane sat above it.
459
- *
460
- * The handle is REAL MODE ONLY. The parity comparator renders the app at `?fixture=proto` against
461
- * the PM's own prototype and diffs text nodes, computed styles, geometry and pixels; the prototype
462
- * has no such control, so drawing one in fixture mode would be a difference the comparator is right
463
- * to report. This module already draws that line for the placeholder string, and for the same
464
- * reason.
465
- *
466
- * The clamps are the two ways this could damage the surface it sits in. `SCRATCH_MIN` keeps two
467
- * lines and the button row reachable — a drawer that can be dragged shut is a drawer with two
468
- * different closed states, one of which has no way back. The 70% ceiling keeps the pane above from
469
- * being driven to nothing, which matters more than it sounds: that pane is frequently a live PTY.
470
- *
471
- * NOTHING HERE TOUCHES THE PAD. Resizing does not read or write `state.scratchText`, does not call
472
- * `syncPad` or `flushPad`, and cannot change `state.scratchKey`. The height is a property of the
473
- * window, the text is a property of the session, and the two stores stay separate.
474
- */
475
- const SCRATCH_MIN = 56;
476
- const SCRATCH_DEFAULT = 96;
477
- const SCRATCH_MAX_FRACTION = 0.7;
478
- const SCRATCH_STEP = 16;
479
-
480
- /** The tallest the pad may be right now: 70% of panel 4, never below the minimum. */
481
- function scratchMax() {
482
- const host = scratchBlock && scratchBlock.parentElement;
483
- const h = host && host.clientHeight ? host.clientHeight : 0;
484
- // No host to measure (the drawer is not mounted yet) — fall back to the viewport, and to a plain
485
- // number if there is no window either, so this is safe to call from a test harness.
486
- const basis = h || (typeof window !== 'undefined' && window.innerHeight) || 600;
487
- return Math.max(SCRATCH_MIN, Math.round(basis * SCRATCH_MAX_FRACTION));
488
- }
489
-
490
- export function clampScratchH(v) {
491
- const n = Math.round(Number(v));
492
- if (!Number.isFinite(n)) return SCRATCH_DEFAULT;
493
- return Math.min(scratchMax(), Math.max(SCRATCH_MIN, n));
494
- }
495
-
496
- function setScratchH(v) {
497
- const h = clampScratchH(v);
498
- if (h === state.scratchH) return;
499
- setState({ scratchH: h });
500
- }
501
-
502
- let dragFrom = null; // {y, h} while the handle is held; null otherwise
503
-
504
- const scratchGrip = el('div', {
505
- tabindex: '0',
506
- role: 'separator',
507
- 'aria-orientation': 'horizontal',
508
- 'aria-label': 'resize the scratchpad — drag, or ↑ / ↓',
509
- title: 'drag to resize · ↑ / ↓ to nudge · double-click to reset',
510
- 'data-scratch': 'grip',
511
- // full width across the drawer's padding, on its top edge
512
- style: 'flex:none;height:7px;margin:-12px -18px 0;cursor:ns-resize;background:var(--sidebar);touch-action:none',
513
- hover: 'background:var(--border)',
514
- onPointerdown: (e) => {
515
- dragFrom = { y: e.clientY, h: state.scratchH || SCRATCH_DEFAULT };
516
- try { e.target.setPointerCapture(e.pointerId); } catch { /* not captured — the move still works */ }
517
- e.preventDefault();
518
- },
519
- // Up is taller: the drawer grows toward the top edge the PM is pulling, which is the direction
520
- // the handle itself moves. `clientY` decreases as the pointer rises, hence `from.y - clientY`.
521
- onPointermove: (e) => { if (dragFrom) setScratchH(dragFrom.h + (dragFrom.y - e.clientY)); },
522
- onPointerup: () => { dragFrom = null; },
523
- onPointercancel: () => { dragFrom = null; },
524
- onDblclick: () => setScratchH(SCRATCH_DEFAULT),
525
- onKeydown: (e) => {
526
- const h = state.scratchH || SCRATCH_DEFAULT;
527
- if (e.key === 'ArrowUp') { setScratchH(h + SCRATCH_STEP); e.preventDefault(); }
528
- else if (e.key === 'ArrowDown') { setScratchH(h - SCRATCH_STEP); e.preventDefault(); }
529
- else if (e.key === 'Home') { setScratchH(SCRATCH_DEFAULT); e.preventDefault(); }
530
- },
531
- });
532
-
533
- /* ── pad identity, loading and autosave ─────────────────────────────────────────────────────── */
534
-
535
- const padLoading = new Set(); // keys with a read in flight — one read per key, ever
536
- const padTyped = new Set(); // pads typed into since this page loaded: a late server read never overwrites them
537
- let padTimer = null;
538
- let padPending = null; // {key, text} not yet written
539
-
540
- /** The pad the ACTIVE tab stages against, or null when it cannot be named yet. */
541
- function padKey() {
542
- if (FIXTURE) return null;
543
- const act = activeTab();
544
- if (act && act.kind === 'term') {
545
- const id = (termMod && typeof termMod.sessionIdOf === 'function')
546
- ? termMod.sessionIdOf(act) : (act.sessionId || null);
547
- // A terminal whose session has not resolved yet has no pad of its own YET. Null holds the
548
- // drawer on whatever it was showing rather than flashing an empty pad and then SAVING it over
549
- // the real one the moment the session lands.
550
- return id ? 'sess:' + id : null;
551
- }
552
- return state.wsId ? 'ws:' + state.wsId : null;
553
- }
554
-
555
- /** Write the pending pad now. Called before leaving a pad, and when the page goes away. */
556
- function flushPad() {
557
- if (padTimer) { clearTimeout(padTimer); padTimer = null; }
558
- if (!padPending) return;
559
- const { key, text } = padPending;
560
- padPending = null;
561
- if (dataMod && typeof dataMod.saveScratchpad === 'function') {
562
- try { dataMod.saveScratchpad(key, text); } catch { /* the text stays in state either way */ }
563
- }
564
- }
565
-
566
- function schedulePadSave(key, text) {
567
- padPending = { key, text };
568
- if (padTimer) clearTimeout(padTimer);
569
- padTimer = setTimeout(flushPad, 500); // one write per pause, not one per keystroke
570
- }
571
-
572
- function onScratchInput(text) {
573
- if (FIXTURE) { setState({ scratchText: text }); return; }
574
- const key = state.scratchKey;
575
- setState((s) => ({
576
- scratchText: text,
577
- scratchPads: key ? { ...s.scratchPads, [key]: text } : s.scratchPads,
578
- }));
579
- if (key) { padTyped.add(key); schedulePadSave(key, text); }
580
- }
581
-
582
- /**
583
- * Bring the drawer onto the pad the active tab belongs to, reading it from the server the first
584
- * time that pad is seen. Called at the top of every render; a no-op unless the pad CHANGED.
585
- */
586
- function syncPad() {
587
- if (FIXTURE || !dataMod) return; // no data layer yet — retried on the next render
588
- const key = padKey();
589
- if (!key || key === state.scratchKey) return;
590
- flushPad(); // the pad being left is written before it is left
591
- if (Object.prototype.hasOwnProperty.call(state.scratchPads, key)) {
592
- setState({ scratchKey: key, scratchText: state.scratchPads[key] });
593
- return;
594
- }
595
- setState({ scratchKey: key, scratchText: '' });
596
- if (padLoading.has(key)) return;
597
- padLoading.add(key);
598
- const landed = (text) => {
599
- padLoading.delete(key);
600
- // text typed while the read was in flight is newer than what the read returns: it stays (and is the save in flight)
601
- if (padTyped.has(key)) return;
602
- setState((s) => ({
603
- scratchPads: { ...s.scratchPads, [key]: text },
604
- // …and onto the screen only if this is still the pad on screen. A PM who switched tabs while
605
- // the read was in flight must not have the arriving text land in the pad they moved to.
606
- ...(s.scratchKey === key ? { scratchText: text } : {}),
607
- }));
608
- };
609
- try { dataMod.loadScratchpad(key).then(landed, () => landed('')); }
610
- catch { padLoading.delete(key); }
611
- }
612
-
613
- /* A pad edited in the last half-second is still worth keeping when the tab is closed or the machine
614
- * sleeps. `pagehide` fires where `beforeunload` is unreliable (bfcache, mobile), and both are cheap. */
615
- if (typeof window !== 'undefined' && !FIXTURE) {
616
- window.addEventListener('pagehide', flushPad);
617
- window.addEventListener('beforeunload', flushPad);
618
- document.addEventListener('visibilitychange', () => { if (document.hidden) flushPad(); });
619
- }
620
-
621
- /* The board's two button forms, on the token system: `.btnp` (the one primary action) and `.btn`. */
622
- const PAD_BTN = 'flex:none;font:500 12.5px var(--sans);border-radius:8px;padding:0 12px;height:28px;'
623
- + 'display:inline-grid;place-items:center;white-space:nowrap;';
624
- const PAD_BTN_PRIMARY = PAD_BTN + 'background:var(--foreground);color:var(--background);border:0';
625
- const PAD_BTN_OUTLINE = PAD_BTN + 'background:transparent;color:var(--foreground);border:1px solid var(--input)';
626
- const PAD_BTN_OFF = PAD_BTN + 'background:transparent;color:var(--muted-foreground);border:1px solid var(--input)';
627
-
628
- const scratchCopyLabel = iv('⧉ copy');
629
- const scratchCopyBtn = el('button', {
630
- onClick: () => {
631
- copyToClipboard(state.scratchText);
632
- setState({ scratchCopied: true });
633
- setTimeout(() => setState({ scratchCopied: false }), 1200);
634
- },
635
- 'data-scratch': 'copy',
636
- style: PAD_BTN_OUTLINE,
637
- hover: 'background:var(--accent)',
638
- }, scratchCopyLabel);
639
-
640
- const scratchSendLabel = iv('open a terminal to send');
641
- const scratchSendBtn = el('button', {
642
- onClick: () => sendScratchToTerminal(),
643
- 'data-scratch': 'send',
644
- style: PAD_BTN_OFF,
645
- }, scratchSendLabel);
646
-
647
- /* Clear — the board's second button. It empties the pad through the same path as typing, so the
648
- * empty pad is saved for this session like any other edit. Disabled when there is nothing to clear. */
649
- const scratchClearBtn = el('button', {
650
- onClick: () => { if (state.scratchText) onScratchInput(''); },
651
- 'data-scratch': 'clear',
652
- style: PAD_BTN_OUTLINE,
653
- hover: 'background:var(--accent)',
654
- }, 'clear');
655
-
656
- const scratchHeadLabel = el('span', {
657
- 'data-scratch': 'label',
658
- style: 'font:500 10px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--muted-foreground)',
659
- }, 'scratchpad');
660
- const scratchFoldBtn = el('button', {
661
- onClick: () => setState({ scratchOpen: false }),
662
- 'data-scratch': 'fold', 'aria-label': 'close the scratchpad', title: 'Close the scratchpad. The text is kept.',
663
- style: 'flex:none;color:var(--muted-foreground);padding:0 4px', hover: 'color:var(--foreground)',
664
- }, '▾');
665
- const scratchNote = el('span', {
666
- 'data-scratch': 'note',
667
- style: 'min-width:0;color:var(--muted-foreground);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap',
668
- });
669
-
670
- const scratchBlock = el('div', {
671
- 'data-scratch': 'pad',
672
- style: 'display:flex;flex-direction:column;gap:8px;padding:12px 18px;border-top:1px solid var(--border);background:var(--sidebar)',
673
- },
674
- FIXTURE ? null : scratchGrip,
675
- el('div', { style: 'display:flex;align-items:center;justify-content:space-between' }, scratchHeadLabel, scratchFoldBtn),
676
- scratchTa,
677
- el('div', { style: 'display:flex;align-items:center;gap:8px;min-width:0' },
678
- scratchSendBtn, scratchCopyBtn, scratchClearBtn, scratchNote),
679
- );
680
-
681
- /* ── the scratchpad in the frame (workspace-tabs-declutter) ─────────────────────────────────────────────────────────
682
- * One header: the bottom bar's toggle names the pad and opens and closes it, so the drawer draws no label row and no ▾
683
- * of its own. Its three actions are primitives; Send is the one primary while a terminal is in front, and the note says
684
- * once what keeps the pad. The textarea stays a direct child of the drawer (the height clamp measures through it). */
685
- const padSendF = button({ label: 'send to terminal', variant: 'primary', size: 'sm', onClick: () => sendScratchToTerminal(), attrs: { 'data-scratch': 'send' } });
686
- const padCopyF = button({ label: 'copy', variant: 'ghost', size: 'sm', attrs: { 'data-scratch': 'copy' }, onClick: () => {
687
- copyToClipboard(state.scratchText);
688
- setState({ scratchCopied: true });
689
- setTimeout(() => setState({ scratchCopied: false }), 1200);
690
- } });
691
- const padClearF = button({ label: 'clear', variant: 'ghost', size: 'sm', onClick: () => { if (state.scratchText) onScratchInput(''); }, attrs: { 'data-scratch': 'clear' } });
692
- const padNoteF = el('span', { class: 'fr-pad__note', 'data-scratch': 'note' });
693
- const padRowF = el('div', { class: 'fr-pad__row' }, padSendF, padCopyF, padClearF, padNoteF);
694
- const padToggleF = button({ label: 'scratchpad', variant: 'ghost', size: 'sm', icon: 'chevron-down',
695
- onClick: () => setState((s) => ({ scratchOpen: !s.scratchOpen })), attrs: { 'data-scratch': 'toggle', class: 'fr-pad__toggle' } });
696
- const bottomCopyF = button({ label: 'copy', variant: 'ghost', size: 'sm', onClick: () => copyActive(), attrs: { 'data-tabs': 'copy' } });
697
-
698
- function paintFramePad(act) {
699
- const canSend = !!(act && act.kind === 'term');
700
- const text = state.scratchText || '';
701
- padSendF.disabled = !canSend || !text.trim();
702
- padSendF.title = canSend ? 'Type the pad into this session and press Enter' : 'Open a terminal to send the pad to it';
703
- padClearF.disabled = !text;
704
- padCopyF.disabled = !text;
705
- padCopyF.querySelector(SEL.btnLabel).textContent = state.scratchCopied ? 'copied' : 'copy';
706
- padNoteF.textContent = canSend ? 'Kept for this session.' : 'Kept for this repository.';
707
- setChildren(scratchBlock, [scratchGrip, scratchTa, padRowF]);
708
- scratchBlock.setAttribute('data-frame', '');
709
- }
710
-
711
- /**
712
- * Paint the scratchpad drawer and the bottom bar's scratchpad toggle for the active tab `act`.
713
- * renderTabs calls it on one line, so the scratchpad (3C) and the tab strip (3A) are separate hunks.
714
- */
715
- function renderScratch(act) {
716
- /* `defaultValue` IS the textarea's child text node — the rendered text lives in the DOM, not only
717
- * in a property, which is how the prototype's runtime leaves it. Writing it costs a typed-in box
718
- * nothing; `value` is written only when it differs, so the caret stays where the PM put it. */
719
- const scratchText = state.scratchText || '';
720
- if (scratchTa.defaultValue !== scratchText) scratchTa.defaultValue = scratchText;
721
- if (scratchTa.value !== scratchText) scratchTa.value = scratchText;
722
- /* The drawer's height, real mode only. The style ATTRIBUTE keeps the prototype's string; only the
723
- * resolved `height` property is written, so the fixture render — which never reaches here — stays
724
- * byte-identical to the design. Written on every paint rather than only on resize, because the
725
- * restored value has to land on the first one. */
726
- if (!FIXTURE) {
727
- const h = clampScratchH(state.scratchH || SCRATCH_DEFAULT) + 'px';
728
- if (scratchTa.style.height !== h) scratchTa.style.height = h;
729
- }
730
- scratchCopyLabel.textContent = state.scratchCopied ? 'copied ✓' : '⧉ copy';
731
- const canSend = !!(act && act.kind === 'term');
732
- scratchSendLabel.textContent = canSend ? '⇥ send to terminal' : 'open a terminal to send';
733
- scratchSendBtn.setAttribute('style', canSend ? PAD_BTN_PRIMARY : PAD_BTN_OFF);
734
- scratchClearBtn.disabled = !scratchText;
735
- scratchClearBtn.style.opacity = scratchText ? '' : '0.5';
736
- /* The header names whose pad this is, and the note says what keeps it and what Send does. Both are
737
- * read from the same facts `padKey` uses, so they cannot claim a pad the drawer is not showing. */
738
- scratchHeadLabel.textContent = FIXTURE ? 'scratchpad'
739
- : (canSend ? 'scratchpad · this session' : 'scratchpad · this repository');
740
- scratchNote.textContent = FIXTURE ? 'Kept until the page closes.'
741
- : (canSend ? 'Kept for this session. Send also presses Enter.' : 'Kept for this repository. Open a terminal to send.');
742
- scratchToggleLabel.textContent = state.scratchOpen ? '▼ scratchpad' : '▲ scratchpad';
743
- if (!FIXTURE && inFrame() && !isMobile()) paintFramePad(act);
744
- if (!FIXTURE) paintBottom(act);
745
- }
746
-
747
- /* ── the bottom bar (lines 992–996) ─────────────────────────────────────────────────────────── */
748
-
749
- const scratchToggleLabel = iv('▲ scratchpad');
750
- const colTitleLabel = iv('scratchpad');
751
- const copyLabel = iv('copy');
752
-
753
- const bottomBar = el('div', { 'data-tabs': 'bottom', 'data-term-chrome': '', class: 'lg-dock-bottom' },
754
- button({ label: scratchToggleLabel, variant: 'ghost', size: 'sm', onClick: () => setState((s) => ({ scratchOpen: !s.scratchOpen })) }),
755
- el('span', { class: 'lg-dock-bottom__title' }, colTitleLabel),
756
- button({ label: copyLabel, variant: 'outline', size: 'sm', onClick: () => copyActive() }),
757
- );
758
-
759
- /* pm-os-absorb Run 3 (R11) took the scratchpad toggle out of the bar, and with it the only way to the pad on a desktop.
760
- * 0.53.1 puts it back: paintBottom lays the bar out as the scratchpad toggle, the session's name and `copy`, or, on a
761
- * phone, the terminal's compose line (the same per-session pad). Fixture mode keeps the prototype's bar. */
762
- const [bottomToggle, bottomTitle, bottomCopy] = bottomBar.children;
763
- bottomToggle.setAttribute('data-scratch', 'toggle');
764
-
765
- /* The compose line: one message field and Send on the SAME per-session pad as the drawer (padKey), so the text is kept
766
- * on this machine and never crosses sessions. On a desktop ⌘K "Ask <session>" types to a session (pm/palette.js). */
767
- const composeInput = field({ label: PAL.compose.label, kind: 'textarea', hideLabel: true, placeholder: PAL.compose.placeholder,
768
- attrs: { class: 'pl-compose__input', 'data-compose': 'input', rows: 1, enterkeyhint: 'send' } });
769
- const composeSend = button({ label: PAL.compose.send, variant: 'primary', onClick: () => sendCompose(),
770
- attrs: { 'data-compose': 'send', 'aria-label': PAL.compose.sendLabel } });
771
- const composeLine = el('div', { class: 'pl-compose', 'data-compose': 'line' }, el('div', { class: 'pl-compose__field' }, composeInput), composeSend);
772
- // Send follows the field as it is typed, not only on the next render of the bar
773
- composeInput.control.addEventListener('input', () => { composeSend.disabled = !composeInput.control.value.trim(); onScratchInput(composeInput.control.value); });
774
- /* The keyboard's Send key is Enter (enterkeyhint 'send'), so it sends. Shift+Enter, and Enter while a composition is open, stay a newline. */
775
- composeInput.control.addEventListener('keydown', (e) => {
776
- if (e.key !== 'Enter' || e.shiftKey || e.isComposing) return;
777
- e.preventDefault();
778
- sendCompose();
779
- });
780
-
781
- /** Send the line to the session and clear it, only when the session took the text: otherwise the message stays and the PM is told. */
782
- function sendCompose() {
783
- const act = activeTab();
784
- if (!act || act.kind !== 'term' || !(state.scratchText || '').trim()) return;
785
- if (!sendScratchToTerminal({ strict: true })) { toast({ text: PAL.compose.failed(String(act.title || act.id)), tone: 'error' }); return; }
786
- onScratchInput('');
787
- }
788
-
789
- /** The bar in real mode: the scratchpad toggle, the title and copy; a phone's terminal gets the compose line instead. */
790
- function paintBottom(act) {
791
- const compose = isMobile() && !!act && act.kind === 'term';
792
- bottomTitle.textContent = act ? act.title : '';
793
- if (compose) {
794
- ensureComponentsCss();
795
- const text = state.scratchText || '';
796
- if (composeInput.control.value !== text) composeInput.control.value = text;
797
- composeSend.disabled = !text.trim();
798
- }
799
- if (!compose && inFrame() && !isMobile()) {
800
- /* The frame's bar: the scratchpad toggle (its chevron points the way the drawer will move), the tab in front, and a
801
- * copy that says what it copies. */
802
- const open = !!state.scratchOpen;
803
- padToggleF.setAttribute('aria-expanded', open ? 'true' : 'false');
804
- const ic = padToggleF.querySelector('[data-icon]');
805
- const want = open ? 'chevron-down' : 'chevron-right';
806
- if (ic && ic.getAttribute('data-icon') !== want) ic.replaceWith(icon(want));
807
- const what = act && act.kind === 'doc' ? 'copy document' : (act && act.kind === 'term' ? 'copy attach command' : null);
808
- if (what) bottomCopyF.querySelector(SEL.btnLabel).textContent = state.copied ? 'copied' : what;
809
- bottomTitle.textContent = act ? act.title : '';
810
- setChildren(bottomBar, [padToggleF, bottomTitle, what ? bottomCopyF : null]);
811
- bottomBar.hidden = false;
812
- return;
813
- }
814
- setChildren(bottomBar, compose ? [composeLine] : (act ? [bottomToggle, bottomTitle, bottomCopy] : [bottomToggle, bottomTitle]));
815
- // A phone draws no scratchpad drawer: its pad is the compose line of a terminal. With no terminal in front the bar would
816
- // offer a toggle that opens nothing, so on a phone it is shown for the compose line only.
817
- bottomBar.hidden = isMobile() && !compose;
818
- }
819
-
820
- /* ── clipboard + scratchpad actions (lines 2098–2118) ───────────────────────────────────────── */
821
-
822
- function copyToClipboard(txt) {
823
- try { if (navigator.clipboard) navigator.clipboard.writeText(txt); } catch { /* denied */ }
824
- }
825
-
826
- /** The active tab, or null when the active id belongs to another repository. */
827
- function activeTab() {
828
- return visibleTabs().find((t) => t.id === state.active) || null;
829
- }
830
-
831
- /** `⇥ send to terminal` (line 2104): one echoed prompt line per non-empty scratchpad line. Answers whether a real session took the text.
832
- * `strict` (the compose line) sends first and echoes nothing when the session did not take it. */
833
- function sendScratchToTerminal({ strict = false } = {}) {
834
- const act = activeTab();
835
- if (!act || act.kind !== 'term') return false;
836
- const v = (state.scratchText || '').trim();
837
- if (!v) return false;
838
- const lines = FX.scratchLines(v);
839
- /* A real PTY is not a scrollback list: when a terminal module is present it gets the same text
840
- * as keystrokes, so the paste lands in the shell rather than only in the transcript. */
841
- let sent = false;
842
- if (!FIXTURE && termMod && typeof termMod.sendToTerm === 'function') {
843
- try { sent = termMod.sendToTerm(act, v + '\n') === true; } catch { /* the transcript still shows it */ }
844
- }
845
- if (strict && !sent) return false;
846
- setState((s) => ({ termHist: { ...s.termHist, [act.id]: [...(s.termHist[act.id] || []), ...lines] } }));
847
- return sent;
848
- }
849
-
850
- /** `copy` (line 2111): the doc's text, or the attach command, or the scratchpad. */
851
- function copyActive() {
852
- const act = activeTab();
853
- let txt = '';
854
- if (act && act.kind === 'doc') txt = state.docEdits[act.path] ?? docText(act);
855
- else if (act && act.kind === 'term') txt = FX.termCopyText(act);
856
- else txt = state.scratchText;
857
- copyToClipboard(txt);
858
- setState({ copied: true });
859
- setTimeout(() => setState({ copied: false }), 1200);
860
- }
861
-
862
- /* ── the + session chooser ──────────────────────────────────────────────────────────────────
863
- *
864
- * Shown INSTEAD of a spawn when the working tree already has live sessions. It answers, in this
865
- * order, the three questions the old one-line notice left the PM holding:
866
- *
867
- * what is running? — every peer named, with the sidebar's own word for its state, the
868
- * agent's last words, and the writer claim where one is held.
869
- * is it safe to end? — one sentence per peer from lib/tree-share's `endRisk`, worded from the
870
- * EVIDENCE. Only `needs you` gets a plain "nothing is in flight"; quiet
871
- * and maybe-blocked say, in as many words, that the workspace cannot
872
- * tell — because a confident "safe" that discards a running turn is
873
- * exactly the false confidence this repo calls a watermelon.
874
- * can I just use it? — `open it`, which attaches a tab to that session and starts NOTHING.
875
- *
876
- * `end it` is the one destructive control on this surface and it is two clicks: the first arms it
877
- * and the button says what will happen, the second sends it. Nothing else here can lose work.
878
- *
879
- * Rebuilt on each render, deliberately: it holds no PTY and no caret, so there is nothing for a
880
- * persistent node to protect, and a chooser rebuilt from state cannot show a session that has
881
- * since exited.
882
- */
883
- const RISK_COLOR = {
884
- 'in-flight': 'var(--warning)',
885
- settled: 'var(--success)',
886
- unknown: 'var(--muted-foreground)',
887
- gone: 'var(--muted-foreground)',
888
- };
889
- const CH_BTN = 'flex:none;font-family:var(--mono);font-size:10.5px;padding:4px 10px;min-height:26px;'
890
- + 'background:oklch(1 0 0 / 6%);border:1px solid oklch(1 0 0 / 12%);color:oklch(0.85 0.01 214);white-space:nowrap';
891
-
892
- function peerRow(prompt, p) {
893
- const armed = state.endConfirm === p.id;
894
- const refusal = state.endRefusal && state.endRefusal.id === p.id ? state.endRefusal.why : null;
895
- const asked = state.endAsked === p.id;
896
- return el('div', {
897
- style: 'display:flex;gap:10px;align-items:flex-start;padding:8px 10px;border:1px solid oklch(1 0 0 / 10%);background:oklch(1 0 0 / 3%)',
898
- },
899
- el('span', { style: 'flex:none;font-size:9px;line-height:18px;color:' + RISK_COLOR[p.risk.level] }, '●'),
900
- el('div', { style: 'flex:1;min-width:0;display:flex;flex-direction:column;gap:2px' },
901
- el('div', { style: 'display:flex;gap:8px;align-items:baseline;flex-wrap:wrap' },
902
- el('span', { style: 'font-family:var(--mono);font-size:11.5px;color:oklch(0.95 0.01 214)' }, iv(p.name)),
903
- el('span', { style: 'font-family:var(--mono);font-size:10.5px;color:oklch(0.72 0.014 214)' }, iv(p.label)),
904
- p.agent ? el('span', { style: 'font-family:var(--mono);font-size:10px;color:oklch(0.55 0.02 213)' }, iv(p.agent)) : null,
905
- p.writer ? el('span', {
906
- style: 'font-family:var(--mono);font-size:9.5px;color:var(--brand);border:1px solid oklch(1 0 0 / 12%);padding:1px 5px',
907
- }, 'writer') : null,
908
- ),
909
- // The agent's own last words, when the workspace could read them. Absent rather than
910
- // substituted: a placeholder here would be a claim about a session nobody read.
911
- p.doing ? el('div', {
912
- style: 'font-family:var(--mono);font-size:10.5px;color:oklch(0.62 0.02 213);overflow:hidden;text-overflow:ellipsis;white-space:nowrap',
913
- }, iv(p.doing)) : null,
914
- p.modelLine ? el('div', { 'data-r12': 'model-line', style: 'font-family:var(--mono);font-size:10.5px;color:oklch(0.62 0.02 213)' }, iv(p.modelLine)) : null,
915
- el('div', { style: 'font-size:11px;color:' + RISK_COLOR[p.risk.level] + ';line-height:1.45' }, iv(p.risk.why)),
916
- /* WHY THE END DID NOT HAPPEN, in the row the PM was looking at. A refusal recorded in state
917
- * and rendered nowhere would be the same silence in a new place — the whole defect here was a
918
- * failure that looked like a success. */
919
- refusal ? el('div', {
920
- style: 'font-size:11px;color:var(--destructive);line-height:1.45',
921
- }, iv('not ended — ' + refusal)) : null,
922
- /* And the honest reading of a SENT end: asked, not done. The row leaves this list when the
923
- * server stops reporting the session, and that is the confirmation. */
924
- asked ? el('div', {
925
- style: 'font-size:11px;color:oklch(0.62 0.02 213);line-height:1.45',
926
- }, iv('asked it to end — this row disappears when the session actually stops')) : null,
927
- ),
928
- el('div', { style: 'flex:none;display:flex;gap:6px;align-items:center' },
929
- el('button', {
930
- onClick: () => joinSession(prompt.slug, p),
931
- style: CH_BTN + ';color:var(--brand)', hover: CHIP_HOVER,
932
- }, 'open it'),
933
- // D75 — switch a RUNNING Claude session's model, on a press: PMOS types the harness's own /model command into the pane.
934
- (p.agent === 'claude' && p.shown !== 'exited') ? el('button', {
935
- 'data-r12': 'switch-model', title: 'types /model into this pane; effort is not changed',
936
- onClick: async () => {
937
- const t = await askChoice({ title: 'Switch “' + p.name + '” model', label: 'Tier', value: 'balanced', confirmLabel: 'Switch', options: [{ value: 'fast', label: 'fast' }, { value: 'balanced', label: 'balanced' }, { value: 'deep', label: 'deep' }] });
938
- if (!t || !t.trim()) return;
939
- const out = await fetch('/api/session/model', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ id: p.id, tier: t.trim() }) })
940
- .then((r) => r.json()).catch((e) => ({ ok: false, error: String((e && e.message) || e) }));
941
- setState({ endRefusal: out && out.ok ? null : { id: p.id, why: 'model not switched — ' + ((out && out.error) || 'no answer') } });
942
- },
943
- style: CH_BTN, hover: CHIP_HOVER,
944
- }, 'switch model') : null,
945
- el('button', {
946
- onClick: () => {
947
- if (!armed) { setState({ endConfirm: p.id, endRefusal: null }); return; }
948
- /* THE ANSWER IS READ, NOT DISCARDED. This was an unconditional `setState({endConfirm:null})`
949
- * after a call whose return value was thrown away, so three separate paths — no module, a
950
- * `FIXTURE || !id` refusal, and a closed socket — disarmed the button on a request that
951
- * never left the page. The third is the one an ordinary PM meets: in a fresh window with
952
- * no terminal tab the chooser is populated over HTTP while this socket has never opened.
953
- *
954
- * The decision itself is in lib/tree-share so the BLOCKING suite can assert it; a rule
955
- * that lived here would only ever be tested by the browser suites, which CI runs under
956
- * `continue-on-error: true` — they report and never block. */
957
- const TS = typeof window !== 'undefined' ? window.PMOSTreeShare : null;
958
- const hasModule = !!(termMod && typeof termMod.killSession === 'function');
959
- const at = TS && typeof TS.endAttempt === 'function'
960
- ? TS.endAttempt({
961
- id: p.id,
962
- hasModule,
963
- socketOpen: !!(termMod && typeof termMod.socketOpen === 'function' && termMod.socketOpen()),
964
- fixture: FIXTURE,
965
- })
966
- /* The module that decides is the same module that built this row, so it cannot be
967
- * missing here. If it ever is, refuse — a destructive control has no safe default. */
968
- : { send: false, why: 'the workspace could not decide whether this could be sent, so it was not' };
969
- if (!at.send) {
970
- /* STAYS ARMED. Re-arming is the only signal the PM has that nothing happened, so a
971
- * refusal must not clear `endConfirm` — the disarm was itself the false report. */
972
- setState({ endRefusal: { id: p.id, why: at.why } });
973
- return;
974
- }
975
- termMod.killSession(p.id);
976
- /* `asked`, never `ended`. All this page knows is that a frame was written to a socket;
977
- * whether the session died is the server's to report, and the row leaving the list is
978
- * what says so. */
979
- setState({ endConfirm: null, endRefusal: null, endAsked: p.id });
980
- },
981
- style: CH_BTN + (armed ? ';color:var(--destructive);border-color:var(--destructive)' : ''),
982
- hover: CHIP_HOVER,
983
- }, iv(armed ? 'end “' + p.name + '” — click again' : 'end it')),
984
- ),
985
- );
986
- }
987
-
988
- function startPromptBlock() {
989
- const prompt = state.startPrompt;
990
- if (!prompt) return null;
991
- const peers = prompt.peers || [];
992
- const n = peers.length;
993
- return el('div', {
994
- style: 'flex:none;max-height:52vh;overflow-y:auto;display:flex;flex-direction:column;gap:8px;'
995
- + 'padding:12px 14px;border-bottom:1px solid oklch(1 0 0 / 10%);background:oklch(0.11 0.004 228.8)',
996
- },
997
- el('div', { style: 'display:flex;gap:8px;align-items:baseline;flex-wrap:wrap' },
998
- el('span', { style: 'font-size:12.5px;color:oklch(0.95 0.01 214)' },
999
- iv('⑂ ' + n + ' session' + (n === 1 ? '' : 's') + ' already running in this working tree')),
1000
- el('span', { style: 'font-family:var(--mono);font-size:10.5px;color:oklch(0.55 0.02 213);overflow-wrap:anywhere' },
1001
- iv(prompt.tree + (prompt.branch ? ' · ' + prompt.branch : ''))),
1002
- ),
1003
- el('div', { style: 'font-size:11.5px;color:oklch(0.72 0.014 214);line-height:1.5' },
1004
- iv('You would share one branch, one index and one set of files with '
1005
- + (n === 1 ? 'it' : 'them') + '. Open one instead, end one, or start another anyway.')),
1006
- peers.map((p) => peerRow(prompt, p)),
1007
- el('div', { style: 'display:flex;gap:6px;flex-wrap:wrap;padding-top:2px' },
1008
- el('button', {
1009
- onClick: () => newSession(prompt.slug, { force: true }),
1010
- style: CH_BTN, hover: CHIP_HOVER,
1011
- }, ...iconLabel('plus', 'start another session here anyway')),
1012
- el('button', { onClick: () => dismissStartPrompt(), style: CH_BTN, hover: CHIP_HOVER }, 'cancel'),
1013
- ),
1014
- // The limit, where the PM meets the feature — never only in a comment. PMOS hosts the terminal;
1015
- // it does not sit between an agent and the files, and no button above changes that.
1016
- el('div', { style: 'font-size:10.5px;color:oklch(0.52 0.02 213);line-height:1.5' },
1017
- 'Nothing here is enforced: PMOS hosts your agent’s terminal, it does not sit between it and '
1018
- + 'the files. To work in parallel for real, start on a new branch with its own folder (⑂).'),
1019
- );
1020
- }
1021
-
1022
- /* ── pane hosts ────────────────────────────────────────────────────────────────────────────── */
1023
-
1024
- /* `min-height:0` is load-bearing, not tidiness. A pane is a flex COLUMN whose body declares
1025
- * `flex:1;overflow-y:auto` — and a flex item's automatic minimum is its content, so without this
1026
- * the pane grows to fit a long document instead of letting the document scroll inside it, and the
1027
- * growth escapes upward until the whole page scrolls. See the chain documented in pm/app.js. */
1028
- const PANE_STYLE = 'flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;border-right:1px solid var(--border)';
1029
- const paneHosts = new Map(); // tab id -> the pane element, kept for the tab's whole life
1030
-
1031
- function paneFor(tab) {
1032
- let host = paneHosts.get(tab.id);
1033
- if (!host) { host = el('div', { style: PANE_STYLE }); paneHosts.set(tab.id, host); }
1034
- if (tab.kind === 'dest') {
1035
- // pm-os-absorb Runs 2–5: a destination as a tab until Run 3's frame. The registry arrives after boot (app.js
1036
- // imports it lazily and renders again), so until then the host stays empty.
1037
- const reg = window.pmApp && window.pmApp.registry;
1038
- if (reg && typeof reg.mountDestTab === 'function') reg.mountDestTab(host, tab);
1039
- return host;
1040
- }
1041
- if (tab.kind === 'term') {
1042
- if (termMod && typeof termMod.mountTerm === 'function') termMod.mountTerm(host, tab);
1043
- } else if (tab.kind === 'skill') {
1044
- if (liveMod && typeof liveMod.mountSkillTab === 'function') liveMod.mountSkillTab(host, tab);
1045
- } else if (tab.kind === 'transcript') {
1046
- if (liveMod && typeof liveMod.mountTranscriptTab === 'function') liveMod.mountTranscriptTab(host, tab);
1047
- } else if (tab.kind === 'view') {
1048
- if (cockpitMod && typeof cockpitMod.mountView === 'function') cockpitMod.mountView(host, tab);
1049
- } else if (tab.kind === 'web') {
1050
- mountWeb(host, tab); // overhaul-r5 — never falls through to an empty doc tab
1051
- } else if (tab.kind === 'report') {
1052
- if (reportTabMod && typeof reportTabMod.mountReportTab === 'function') reportTabMod.mountReportTab(host, tab);
1053
- } else if (tab.kind === 'breakdown') {
1054
- // pm-os-absorb Run 1 — an initiative's items (Tree, Board, item sheet); an empty pane until the module lands
1055
- if (breakdownMod && typeof breakdownMod.mountBreakdown === 'function') breakdownMod.mountBreakdown(host, tab);
1056
- } else {
1057
- mountDoc(host, tab);
1058
- }
1059
- return host;
1060
- }
1061
-
1062
- /** Drop the host of every tab that is no longer open, letting its module release what it holds. */
1063
- function reapClosedPanes() {
1064
- const live = new Set((state.tabs || []).map((t) => t.id));
1065
- for (const [id, host] of [...paneHosts]) {
1066
- if (live.has(id)) continue;
1067
- const tab = { id };
1068
- if (termMod && typeof termMod.disposeTerm === 'function') { try { termMod.disposeTerm(tab); } catch { /* ignore */ } }
1069
- try { disposeDoc(id); } catch { /* ignore */ }
1070
- try { if (window.pmApp && window.pmApp.registry) window.pmApp.registry.disposeDestTab(id); } catch { /* ignore */ }
1071
- if (host.parentNode) host.parentNode.removeChild(host);
1072
- paneHosts.delete(id);
1073
- const slot = offSlots.get(id);
1074
- if (slot) { if (slot.parentNode) slot.parentNode.removeChild(slot); offSlots.delete(id); }
1075
- }
1076
- }
1077
-
1078
- /* ── an open session whose tab is not the one on screen ───────────────────────────────────────
1079
- *
1080
- * `+ session` starts a REAL PTY, and a term tab is the only view of it. Until this existed a pane
1081
- * was built ONLY for the tab being displayed, which meant: start two sessions in a row and the
1082
- * first one had no terminal, was never bound to a session, and therefore never spawned a shell at
1083
- * all — the tab bar showed two sessions running and the server had one. Opening the tab later
1084
- * started it then, so the failure looked like a slow start rather than a session that was never
1085
- * begun. The same hole swallows a session the PM starts and then switches away from.
1086
- *
1087
- * So every open term tab is mounted, and the ones not on screen live in an OFF-SCREEN SLOT: a real
1088
- * box, the size of the pane they would occupy, parked far outside the viewport. Not `display:none`
1089
- * and not detached, because both measure zero and a terminal fitted to a zero box is the 1×1
1090
- * terminal this module's refit rules exist to prevent — the grid a hidden session's shell is
1091
- * drawing into has to be the grid it will still be drawing into when the PM looks at it.
1092
- *
1093
- * Real mode only. Fixture mode opens no socket, starts no PTY and must render the prototype's DOM
1094
- * exactly, so nothing is parked and nothing extra exists on the page.
1095
- */
1096
- const OFF_STAGE_STYLE = 'position:fixed;left:-100000px;top:0;width:0;height:0;pointer-events:none';
1097
- const offSlots = new Map(); // tab id -> the off-screen box its host is parked in
1098
- const lastPaneBox = { w: 720, h: 420 };
1099
- let offStage = null;
1100
-
1101
- function offSlotFor(id, w, h) {
1102
- if (!offStage) {
1103
- offStage = el('div', { style: OFF_STAGE_STYLE, 'aria-hidden': 'true' });
1104
- document.body.appendChild(offStage);
1105
- }
1106
- let slot = offSlots.get(id);
1107
- if (!slot) { slot = el('div', { style: 'display:flex' }); offSlots.set(id, slot); offStage.appendChild(slot); }
1108
- const want = 'display:flex;width:' + w + 'px;height:' + h + 'px';
1109
- if (slot.getAttribute('style') !== want) slot.setAttribute('style', want);
1110
- return slot;
1111
- }
1112
-
1113
- /**
1114
- * Keep every open term tab live. `shown` is the set of tab ids panel 4 is displaying — those hosts
1115
- * belong to the panes row and are left alone.
1116
- */
1117
- function keepSessionsLive(shown) {
1118
- if (FIXTURE || !termMod || typeof termMod.mountTerm !== 'function') return;
1119
- const parked = (state.tabs || []).filter((t) => t.kind === 'term' && !shown.has(t.id));
1120
- if (!parked.length) return;
1121
- /* The slot is the size of the box panel 4 gives ONE pane. Measured from the panes row, so a
1122
- * parked terminal is fitted to what it will actually get; when the row has no box yet (booting,
1123
- * or a phone showing another panel) the last known size stands in, and an 80×24 default only for
1124
- * the very first one — a stale-but-plausible grid beats a zero one. */
1125
- const box = panesRow.getBoundingClientRect();
1126
- if (box.width > 1 && box.height > 1) { lastPaneBox.w = Math.round(box.width); lastPaneBox.h = Math.round(box.height); }
1127
- for (const t of parked) {
1128
- const host = paneFor(t);
1129
- const slot = offSlotFor(t.id, lastPaneBox.w, lastPaneBox.h);
1130
- if (host.parentNode !== slot) slot.appendChild(host);
1131
- }
1132
- }
1133
-
1134
- /* ── the tab bar ───────────────────────────────────────────────────────────────────────────── */
1135
-
1136
- /* pm-os-absorb Run 3 (slice 3A): in the frame this panel is the agent dock. Its strip then carries the dock's own
1137
- * "+ Session" menu (new session, session with options, and the skills to start from) in place of the one-click chip, and a
1138
- * control that folds the dock to its rail. dock.js is loaded lazily, like the other siblings here, so panel 4 never waits
1139
- * for it; until it lands the strip shows the chip it always had. Outside the frame (fixture mode, ?layout=legacy) nothing
1140
- * here changes. */
1141
- let dockMod = null;
1142
- const inFrame = () => !!(window.pmApp && window.pmApp.frame && window.pmApp.frame.on);
1143
- import('./dock.js').then((m) => { dockMod = m; if (inFrame()) setState({}); }).catch(() => { dockMod = null; });
1144
- /* 0.55.1 — the dock lists SESSIONS grouped by initiative (dock-sessions.js), in the frame and live mode only. */
1145
- let dsMod = null;
1146
- if (!FIXTURE) import('./dock-sessions.js').then((m) => { dsMod = m; if (inFrame()) setState({}); }).catch(() => { dsMod = null; });
1147
- let dockParts = null;
1148
- let dockOrient = null;
1149
- let dockHead = null; // the side list's head: + Session and the dock's controls, one node across paints
1150
- function frameDock() {
1151
- if (!dockMod || !inFrame()) return null;
1152
- const repo = currentProduct();
1153
- const ws = repo && dataMod && typeof dataMod.wsOf === 'function' ? dataMod.wsOf(repo) : null;
1154
- if (!dockParts || dockParts.ws !== ws) {
1155
- dockParts = {
1156
- ws,
1157
- session: dockMod.sessionMenuButton({
1158
- ws,
1159
- open: () => (dsMod ? dsMod.openNewSessionSheet(currentProduct(), { initiative: null }) : newSession()),
1160
- }),
1161
- fold: dockParts ? dockParts.fold : dockMod.foldButton({ fold: () => window.pmApp.frame.foldDock() }),
1162
- size: dockParts ? dockParts.size : dockMod.dockSizeButton({
1163
- setSize: (sz) => window.pmApp.frame.setDockSize(sz),
1164
- getState: () => ({ size: window.pmApp.frame.dockSize, inFocus: !!window.pmApp.frame.dockMax }),
1165
- }),
1166
- };
1167
- }
1168
- if (isMobile()) return { session: dockParts.session, fold: null, size: null, orient: null };
1169
- dockMod.paintDockSize(dockParts.size, window.pmApp.frame.dockSize, !!window.pmApp.frame.dockMax);
1170
- // the tabs-on-top / tabs-at-side switch, icon only in the frame (0.55.1); drawn per paint because its icon follows the mode
1171
- // one element across paints, so the keyboard focus stays on it; only its icon and name follow the mode
1172
- const v = !!state.tabsVertical;
1173
- if (!dockOrient) {
1174
- dockOrient = iconButton({ icon: 'panel-left', ariaLabel: COPY.dock.sideTabs,
1175
- onClick: () => setState({ tabsVertical: !state.tabsVertical, dsEnding: null }), attrs: { 'data-tabs': 'orient' } });
1176
- }
1177
- const oname = v ? 'panel-top' : 'panel-left';
1178
- const cur = dockOrient.querySelector('[data-icon]');
1179
- if (!cur || cur.getAttribute('data-icon') !== oname) dockOrient.replaceChildren(icon(oname));
1180
- const olabel = v ? COPY.dock.topTabs : COPY.dock.sideTabs;
1181
- dockOrient.setAttribute('aria-label', olabel);
1182
- dockOrient.title = olabel;
1183
- return { session: dockParts.session, fold: dockParts.fold, size: dockParts.size, orient: dockOrient };
1184
- }
1185
-
1186
- /**
1187
- * overhaul-r1 R2.2/R2.3 — the line of work a tab is on, or null when it is the main tree (which
1188
- * shows nothing extra). A doc tab carries its tree from the search hit that opened it; a terminal
1189
- * tab is on whatever tree its session's workspace is. Live mode only; fixture tabs have neither.
1190
- */
1191
- export function tabBranch(t, includeMain) {
1192
- if (FIXTURE || !t || !dataMod) return null;
1193
- let ws = null;
1194
- if (t.kind === 'doc') ws = t.ws || null;
1195
- else if (t.kind === 'term' && t.sessionId) {
1196
- const s = (Array.isArray(state.sessions) ? state.sessions : []).find((x) => x && x.id === t.sessionId);
1197
- ws = s ? s.ws : null;
1198
- }
1199
- if (ws && dataMod.isLinkedTree(ws)) return (t.kind === 'doc' && t.branch) || dataMod.branchOfWs(ws) || 'detached';
1200
- if (!includeMain) return null;
1201
- // the status bar (R2.3) also names the MAIN tree's branch, but only where the repository has other
1202
- // lines of work — in a repository with one tree the branch answers no question anyone asked
1203
- const prod = t.repo || currentProduct();
1204
- const trees = prod && typeof dataMod.productTrees === 'function' ? dataMod.productTrees(prod) : [];
1205
- const main = trees.find((x) => x.main);
1206
- return trees.length > 1 && main ? main.branch : null;
1207
- }
1208
-
1209
- function cockpitTabNode(t, act, splitTab, vertical) {
1210
- const front = (act && act.id === t.id) || (splitTab && splitTab.id === t.id);
1211
- if (vertical) return cockpitTabRow(t, front);
1212
- const dotColor = FX.TAB_COLORS.dot[t.kind] || FX.TAB_COLORS.dot.doc;
1213
- const meta = t.kind === 'term'
1214
- ? ((!FIXTURE && t.sessionId) ? 'session ' + t.sessionId : 'session')
1215
- : (t.kind === 'view' ? 'view' : t.kind === 'web' ? 'web' : t.kind === 'skill' ? 'skill' : t.kind === 'transcript' ? 'conversation' : t.kind === 'report' ? 'report' : t.role);
1216
- const br = tabBranch(t);
1217
- return el('div', {
1218
- 'data-tab': t.id, 'data-tab-active': front ? '1' : '0',
1219
- // A tab may shrink to 96px when the strip is crowded; the title is clipped with an ellipsis and the full title is its tooltip.
1220
- style: 'position:relative;flex:0 1 auto;min-width:96px;display:flex;align-items:center;gap:8px;padding:0 14px;font:12px var(--mono);'
1221
- + (front ? 'height:37px;border:1px solid var(--border);border-bottom:0;border-radius:8px 8px 0 0;background:var(--card);color:var(--foreground)'
1222
- : 'height:36px;color:var(--muted-foreground)'),
1223
- },
1224
- el('button', {
1225
- onClick: () => setState({ active: t.id }),
1226
- title: t.title + (t.slug ? '\n' + t.slug + ' · ' + meta : ''),
1227
- style: 'display:flex;gap:8px;align-items:center;align-self:stretch;color:inherit;min-width:0',
1228
- },
1229
- el('span', { 'data-tab-dot': t.kind, style: 'width:8px;height:8px;border-radius:50%;display:inline-block;flex-shrink:0;background:' + dotColor + ';color:' + dotColor }),
1230
- el('span', { style: 'display:flex;flex-direction:column;min-width:0;align-items:flex-start' },
1231
- el('span', { style: 'max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap' }, iv(t.title)),
1232
- el('span', {
1233
- 'data-tab-sub': '',
1234
- // under the title, inside the tab's own width (the tab is its containing block), clipped to it
1235
- style: 'position:absolute;left:30px;right:14px;bottom:1px;font:9px var(--mono);line-height:10px;color:oklch(0.52 0.02 213);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left',
1236
- }, iv(t.slug), ' · ', iv(meta), br ? el('span', { 'data-r1': 'tab-branch' }, iv(' · ⑂ ' + br)) : null),
1237
- ),
1238
- ),
1239
- el('button', {
1240
- onClick: () => closeTab(t.id), 'data-tab-close': '', 'aria-label': 'close ' + t.title, title: 'close',
1241
- style: 'color:var(--muted-foreground)' + (front ? '' : ';position:absolute;right:3px;top:50%;transform:translateY(-50%)'),
1242
- hover: 'color:var(--foreground)',
1243
- }, closeIcon()),
1244
- );
1245
- }
1246
-
1247
- /** One tab as a row of the vertical list: the dot, the title over its second line, and the close control, all inside the row. */
1248
- function cockpitTabRow(t, front) {
1249
- const dotColor = FX.TAB_COLORS.dot[t.kind] || FX.TAB_COLORS.dot.doc;
1250
- const meta = t.kind === 'term'
1251
- ? ((!FIXTURE && t.sessionId) ? 'session ' + t.sessionId : 'session')
1252
- : (t.kind === 'view' ? 'view' : t.kind === 'web' ? 'web' : t.kind === 'skill' ? 'skill' : t.kind === 'transcript' ? 'conversation' : t.kind === 'report' ? 'report' : t.role);
1253
- const br = tabBranch(t);
1254
- return el('div', {
1255
- 'data-tab': t.id, 'data-tab-active': front ? '1' : '0', 'data-tab-row': '',
1256
- style: 'flex:none;display:flex;align-items:center;gap:6px;padding:5px 6px 5px 10px;border-radius:6px;font:12px var(--mono);border:1px solid '
1257
- + (front ? 'var(--border);background:var(--card);color:var(--foreground)' : 'transparent;color:var(--muted-foreground)'),
1258
- hover: front ? null : 'background:var(--accent)',
1259
- },
1260
- el('button', {
1261
- onClick: () => setState({ active: t.id }),
1262
- title: t.title + (t.slug ? '\n' + t.slug + ' · ' + meta : ''),
1263
- style: 'flex:1;min-width:0;display:flex;gap:8px;align-items:center;color:inherit;text-align:left',
1264
- },
1265
- el('span', { 'data-tab-dot': t.kind, style: 'width:8px;height:8px;border-radius:50%;display:inline-block;flex-shrink:0;background:' + dotColor + ';color:' + dotColor }),
1266
- el('span', { style: 'flex:1;min-width:0;display:flex;flex-direction:column;align-items:stretch' },
1267
- el('span', { style: 'overflow:hidden;text-overflow:ellipsis;white-space:nowrap' }, iv(t.title)),
1268
- el('span', {
1269
- 'data-tab-sub': '',
1270
- style: 'font:9.5px var(--mono);line-height:12px;color:oklch(0.52 0.02 213);overflow:hidden;text-overflow:ellipsis;white-space:nowrap',
1271
- }, iv(t.slug), ' · ', iv(meta), br ? el('span', { 'data-r1': 'tab-branch' }, iv(' · ⑂ ' + br)) : null),
1272
- ),
1273
- ),
1274
- el('button', {
1275
- onClick: () => closeTab(t.id), 'data-tab-close': '', 'aria-label': 'close ' + t.title, title: 'close',
1276
- style: 'flex:none;color:var(--muted-foreground);padding:0 4px', hover: 'color:var(--foreground)',
1277
- }, closeIcon()),
1278
- );
1279
- }
1280
-
1281
- /* ── a tab in the dock's side list (the frame, live mode) ─────────────────────────────────────────────────────────────
1282
- * The tabs that are not sessions (documents, views, web pages) sit under "Open" in the same row as a session: the
1283
- * design system's row, its title in the body face, a second line that says what it is (the document's role, or the kind
1284
- * of tab) and its line of work when that is not main, and one close control. The server's session id and the initiative
1285
- * slug stay in the tooltip; on screen they told two rows apart no better than the title did. */
1286
- const KIND_WORD = { term: 'Terminal', view: 'View', web: 'Web page', skill: 'Skill', transcript: 'Conversation', breakdown: 'Breakdown', dest: 'Page' };
1287
- function dockTabRow(t, front) {
1288
- const br = tabBranch(t);
1289
- const what = t.kind === 'doc' ? (t.role || 'Document') : (KIND_WORD[t.kind] || t.kind);
1290
- const r = row({
1291
- title: t.title, meta: [what, br ? '⑂ ' + br : null], compact: true, onOpen: () => setState({ active: t.id }),
1292
- openLabel: COPY.dock.openTab(t.title, what),
1293
- trail: [iconButton({ icon: 'x', ariaLabel: 'close ' + t.title, size: 'sm', onClick: () => closeTab(t.id), attrs: { 'data-tab-close': '', class: 'fr-ds-act' } })],
1294
- attrs: { class: 'fr-ds-row fr-ds-tab', 'data-tab': t.id, 'data-tab-active': front ? '1' : '0', 'data-tab-row': '', 'data-front': front ? 'true' : 'false',
1295
- 'data-kind': t.kind, title: t.title + (t.slug ? '\n' + t.slug : '') },
1296
- });
1297
- const meta = r.querySelector(SEL.rowMeta);
1298
- if (meta) {
1299
- meta.setAttribute('data-tab-sub', '');
1300
- // the branch keeps its hook for the suites (R2.2): it is the meta line's last part
1301
- if (br && meta.lastElementChild) meta.lastElementChild.setAttribute('data-r1', 'tab-branch');
1302
- }
1303
- return r;
1304
- }
1305
-
1306
- /* …and the same tab in the strip on top: a chip like a session's, with its own close control. The second line moves to the
1307
- * tooltip; the chip keeps the strip's floor and the 96px floor a crowded strip shrinks to. */
1308
- function dockTabChip(t, front) {
1309
- const br = tabBranch(t);
1310
- const what = t.kind === 'doc' ? (t.role || 'Document') : (KIND_WORD[t.kind] || t.kind);
1311
- return el('div', { class: 'fr-ds-tabchip', 'data-tab': t.id, 'data-tab-active': front ? '1' : '0', 'data-kind': t.kind },
1312
- button({ label: t.title, variant: front ? 'outline' : 'ghost', size: 'sm', onClick: () => setState({ active: t.id }),
1313
- attrs: { class: 'fr-ds-chip', 'aria-pressed': front ? 'true' : 'false', title: t.title + ' · ' + what + (br ? ' · ⑂ ' + br : '') } }),
1314
- iconButton({ icon: 'x', ariaLabel: 'close ' + t.title, size: 'sm', onClick: () => closeTab(t.id), attrs: { 'data-tab-close': '' } }));
1315
- }
1316
-
1317
- function tabNode(t, act, splitTab) {
1318
- const selected = (act && act.id === t.id) || (splitTab && splitTab.id === t.id);
1319
- const bg = selected ? FX.TAB_COLORS.activeBg : 'transparent';
1320
- const bc = selected ? FX.TAB_COLORS.activeBorder : FX.TAB_COLORS.idleBorder;
1321
- const color = act && act.id === t.id ? FX.TAB_COLORS.activeText : FX.TAB_COLORS.idleText;
1322
- const dotColor = FX.TAB_COLORS.dot[t.kind] || FX.TAB_COLORS.dot.doc;
1323
- /* A terminal's sub-line names the SESSION IT IS ON, not the word "session". After a reload the PM
1324
- * could not tell which session a re-opened tab had landed on, and the answer was on screen
1325
- * nowhere; the server's id is the one identifier that does not repeat across repositories. The
1326
- * fixture render keeps the design's literal — the comparator reads this text node. */
1327
- const meta = t.kind === 'term'
1328
- ? ((!FIXTURE && t.sessionId) ? 'session ' + t.sessionId : 'session')
1329
- : (t.kind === 'view' ? 'view' : t.kind === 'web' ? 'web' : t.kind === 'skill' ? 'skill' : t.kind === 'transcript' ? 'conversation' : t.kind === 'report' ? 'report' : t.role);
1330
-
1331
- return el('div', {
1332
- style: 'flex:none;display:flex;align-items:center;gap:8px;padding:0 10px;background:' + bg
1333
- + ';border:1px solid ' + bc + ';border-bottom:0',
1334
- },
1335
- el('button', {
1336
- onClick: () => setState({ active: t.id }),
1337
- style: 'display:flex;gap:7px;align-items:center;min-height:38px',
1338
- },
1339
- el('span', { style: 'font-size:9px;color:' + dotColor }, '●'),
1340
- el('span', { style: 'display:flex;flex-direction:column;min-width:0;align-items:flex-start' },
1341
- el('span', {
1342
- style: 'font-family:var(--mono);font-size:11.5px;color:' + color
1343
- + ';max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.3',
1344
- }, iv(t.title)),
1345
- el('span', {
1346
- style: 'font-family:var(--mono);font-size:9px;color:oklch(0.52 0.02 213);max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.2',
1347
- }, iv(t.slug), ' · ', iv(meta), tabBranch(t) ? el('span', { 'data-r1': 'tab-branch' }, iv(' · ⑂ ' + tabBranch(t))) : null),
1348
- ),
1349
- ),
1350
- el('button', {
1351
- onClick: () => closeTab(t.id), 'aria-label': 'close ' + t.title, title: 'close',
1352
- style: 'color:oklch(0.6 0.02 213);font-size:12px;padding:2px 3px;align-self:flex-start;margin-top:6px',
1353
- hover: 'color:oklch(0.987 0.002 197.1)',
1354
- }, closeIcon()),
1355
- );
1356
- }
1357
-
1358
- /* ── render ────────────────────────────────────────────────────────────────────────────────── */
1359
-
1360
- /**
1361
- * Paint panel 4 into `host` — the persistent panel container app.js owns. The children are the
1362
- * prototype's, in the prototype's order: tab bar · (empty state) · panes · (scratchpad) · bottom
1363
- * bar. The panes row renders even when nothing is open, exactly as the design does.
1364
- */
1365
- let lastFrontId = null;
1366
-
1367
- export function renderTabs(host) {
1368
- // Which pad the drawer is on is decided from the active tab, before anything is painted from it.
1369
- syncPad();
1370
- const visTabs = visibleTabs();
1371
- const act = visTabs.find((t) => t.id === state.active) || null;
1372
- const splitTab = state.splitId
1373
- ? (visTabs.find((t) => t.id === state.splitId && t.id !== (act && act.id)) || null)
1374
- : null;
1375
-
1376
- // ── tab bar ──
1377
- const canSplit = visTabs.length >= 2 || !!state.splitId;
1378
- splitLabel.textContent = state.splitId ? 'unsplit' : 'split';
1379
- const ck = cockpitLook();
1380
- ensureSprite(); // the dock controls draw lucide icons (C6); the sprite loads once
1381
- emptyState.textContent = 'Nothing is open. Open an artifact, or press + session to start a session.';
1382
- /* The tabs are drawn anew on every paint, so the bar is empty for a moment and its scroll would snap back to the start: a
1383
- * crowded strip (or a long list) scrolled by hand jumped back on the next repaint. The offset is kept across the redraw. */
1384
- const keepX = tabBar.scrollLeft, keepY = tabBar.scrollTop;
1385
- const vertical = ck && !!state.tabsVertical;
1386
- const fr = frameDock(); // the dock's own controls, in the frame only
1387
- host.style.flexDirection = vertical ? 'row' : 'column';
1388
- orientLabel.textContent = vertical ? 'tabs on top' : 'tabs at side';
1389
- const oi = vertical ? 'arrow-left-right' : 'arrow-up-down';
1390
- if (!orientIcon.firstChild || orientIcon.firstChild.getAttribute('data-icon') !== oi) orientIcon.replaceChildren(icon(oi));
1391
- orientBtn.title = vertical ? 'show the tabs as a strip above the panes' : 'show the tabs as a list at the left of the panes';
1392
- const ds = fr && dsMod ? currentProduct() : null; // the frame's session list (0.55.1); null = the tab list as before
1393
- const notListed = (listed) => visTabs.filter((t) => !(t.kind === 'term' && t.sessionId && listed.has(t.sessionId)));
1394
- if (vertical) {
1395
- tabBar.setAttribute('style', CK_VBAR);
1396
- const V_BTN = CK_BTN.replace('margin:0 0 4px', 'margin:0') + ';justify-content:start';
1397
- newSessionBtn.setAttribute('style', V_BTN + ';margin-bottom:6px');
1398
- for (const b of [newWebBtn, newSessionOptsBtn, splitBtn, orientBtn]) b.setAttribute('style', V_BTN);
1399
- setChildren(tabBar, [
1400
- fr ? fr.session : newSessionBtn,
1401
- ...visTabs.map((t) => cockpitTabNode(t, act, splitTab, true)),
1402
- el('div', { 'data-tabs': 'vcontrols', style: 'margin-top:auto;padding-top:8px;display:flex;flex-direction:column;gap:4px' },
1403
- FIXTURE ? null : newWebBtn,
1404
- !FIXTURE && state.webNotice ? el('span', { 'data-r5': 'notice', style: 'font-size:11px;color:var(--destructive);padding:0 6px' }, state.webNotice) : null,
1405
- newSessionOptsBtn,
1406
- canSplit ? splitBtn : null,
1407
- orientBtn,
1408
- fr ? fr.size : null,
1409
- fr ? fr.fold : null),
1410
- ]);
1411
- } else if (ck) {
1412
- tabBar.setAttribute('style', CK_BAR + ';scrollbar-width:thin');
1413
- newSessionBtn.setAttribute('style', CK_BTN + ';margin-left:0');
1414
- for (const b of [newWebBtn, newSessionOptsBtn, splitBtn, orientBtn]) b.setAttribute('style', CK_BTN);
1415
- const extras = [
1416
- FIXTURE ? null : newWebBtn,
1417
- !FIXTURE && state.webNotice ? el('span', { 'data-r5': 'notice', style: 'align-self:center;font-size:11px;color:var(--destructive);padding:0 6px' }, state.webNotice) : null,
1418
- newSessionOptsBtn,
1419
- canSplit ? splitBtn : null,
1420
- ].filter(Boolean);
1421
- extras[0].style.marginLeft = 'auto';
1422
- // The switch sits after `+ session`, so the strip still ends the mockup's way in the fixture, which does not draw it.
1423
- setChildren(tabBar, [...visTabs.map((t) => cockpitTabNode(t, act, splitTab)), ...extras, fr ? fr.session : newSessionBtn, FIXTURE ? null : orientBtn, fr ? fr.size : null, fr ? fr.fold : null]);
1424
- } else {
1425
- tabBar.setAttribute('style', BAR_STYLE);
1426
- newSessionBtn.setAttribute('style', CHIP_STYLE);
1427
- newWebBtn.setAttribute('style', CHIP_STYLE); newSessionOptsBtn.setAttribute('style', CHIP_STYLE); splitBtn.setAttribute('style', SPLIT_STYLE);
1428
- setChildren(tabBar, [
1429
- ...visTabs.map((t) => tabNode(t, act, splitTab)),
1430
- fr ? fr.session : newSessionBtn,
1431
- FIXTURE || fr ? null : newWebBtn,
1432
- !FIXTURE && state.webNotice ? el('span', { 'data-r5': 'notice', style: 'align-self:center;font-size:11px;color:var(--destructive);padding:0 6px' }, state.webNotice) : null,
1433
- fr ? null : newSessionOptsBtn,
1434
- canSplit && (!fr || state.splitId) ? splitBtn : null,
1435
- ]);
1436
- }
1437
-
1438
- /* 0.55.1 — in the frame the bar lists SESSIONS by initiative (dock-sessions.js); the tabs that are not sessions follow
1439
- * under "Open". The bar keeps the style the branch above gave it; only its children change. Web, options and split left
1440
- * the frame's dock (split stays only to undo one already made). */
1441
- if (ck && ds) {
1442
- const others = notListed(dsMod.listedSessionIds(ds));
1443
- // The dock's own controls (tabs on top, Focus, Minimize) sit beside + Session at the head of the list, held in view while
1444
- // the list scrolls: at the foot they were below every session, and a long list put them off screen.
1445
- setChildren(tabBar, vertical ? [
1446
- dockHead || (dockHead = el('div', { 'data-tabs': 'vcontrols', class: 'fr-ds-top' })),
1447
- ...dsMod.railNodes(ds, others.map((t) => dockTabRow(t, (act && act.id === t.id) || (splitTab && splitTab.id === t.id)))),
1448
- ] : [
1449
- ...dsMod.stripNodes(ds, others.map((t) => dockTabChip(t, (act && act.id === t.id) || (splitTab && splitTab.id === t.id)))),
1450
- state.splitId ? splitBtn : null, fr.orient, fr.size, fr.fold,
1451
- ]);
1452
- }
1453
-
1454
- if (ck && ds && vertical) setChildren(dockHead, [fr.session, state.splitId ? splitBtn : null, fr.orient, fr.size, fr.fold]);
1455
- if (tabBar.scrollLeft !== keepX) tabBar.scrollLeft = keepX;
1456
- if (tabBar.scrollTop !== keepY) tabBar.scrollTop = keepY;
1457
- // When the tab in front changes, the bar scrolls just enough to show it, so a tab opened at the far end of a crowded strip or a
1458
- // long list is seen. Only the bar's own offset is moved (not scrollIntoView, which would also scroll the panels around it).
1459
- // …and when the bar itself changed (the session list landed, or the orientation flipped): the tab may be off screen
1460
- const frontKey = act ? act.id + '|' + (ds ? 'ds' : '') + (vertical ? 'v' : 'h') : null;
1461
- if (ck && act && frontKey !== lastFrontId) {
1462
- const n = [...tabBar.querySelectorAll('[data-tab]')].find((x) => x.getAttribute('data-tab') === act.id);
1463
- if (n) {
1464
- const b = tabBar.getBoundingClientRect(), r = n.getBoundingClientRect();
1465
- if (vertical) {
1466
- if (r.top < b.top) tabBar.scrollTop -= b.top - r.top;
1467
- else if (r.bottom > b.bottom) tabBar.scrollTop += r.bottom - b.bottom;
1468
- } else if (r.left < b.left) tabBar.scrollLeft -= b.left - r.left;
1469
- else if (r.right > b.right) tabBar.scrollLeft += r.right - b.right;
1470
- }
1471
- }
1472
- lastFrontId = frontKey;
1473
-
1474
- // ── panes ──
1475
- reapClosedPanes();
1476
- const panes = [act ? paneFor(act) : null, splitTab ? paneFor(splitTab) : null].filter(Boolean);
1477
- setChildren(panesRow, panes);
1478
- // …and the sessions that are open but not on screen keep running, off screen (see above).
1479
- keepSessionsLive(new Set([act && act.id, splitTab && splitTab.id].filter(Boolean)));
1480
-
1481
- // ── scratchpad (renderScratch owns the drawer and the toggle label; 3C) ──
1482
- renderScratch(act);
1483
-
1484
- // ── bottom bar ──
1485
- colTitleLabel.textContent = act ? act.title : 'scratchpad';
1486
- copyLabel.textContent = state.copied ? 'copied ✓' : 'copy';
1487
-
1488
- setChildren(host, [tabBar, tabsMain]);
1489
- setChildren(tabsMain, [
1490
- // Above the panes and below the tab bar: the chooser is about the click that was just made in
1491
- // that bar, and putting it here leaves every open pane — and every live PTY — exactly where it
1492
- // was. Replacing the panes with it would re-parent a terminal, which is the quiet regression
1493
- // the persistent pane hosts exist to prevent.
1494
- startPromptBlock(),
1495
- // The pre-flight sits in the same slot and for the same reason: it is about the click just made
1496
- // in the bar above, and putting it here leaves every open pane — and every live PTY — exactly
1497
- // where it was. Replacing the panes with it would re-parent a terminal.
1498
- newSessionBlock(),
1499
- visTabs.length === 0 && !state.startPrompt && !state.newSess ? emptyState : null,
1500
- panesRow,
1501
- state.scratchOpen && (FIXTURE || !isMobile()) ? scratchBlock : null,
1502
- bottomBar,
1503
- ]);
1504
- }
1505
-
1506
- export default renderTabs;