@kabmo-labs/kabmo 0.46.0 → 0.47.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 (301) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +439 -435
  3. package/dist/client/static/js/{CsvGrid-br4j001k.js → CsvGrid-vfgttmym.js} +2 -2
  4. package/dist/client/static/js/{DocxView-kmtkbmmw.js → DocxView-dc41t6rp.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-3df0g3jr.js → DrawioView-wpwr38d9.js} +2 -2
  6. package/dist/client/static/js/HtmlPreview-23n7t5cs.js +1 -0
  7. package/dist/client/static/js/ImageView-mvjb3qh1.js +1 -0
  8. package/dist/client/static/js/LayoutWrapper-eenx0hp2.js +2 -0
  9. package/dist/client/static/js/{Modal-tmxhxd6q.js → Modal-dsqhas10.js} +13 -13
  10. package/dist/client/static/js/{PdfView-p5z7c7eg.js → PdfView-cpvsbfk0.js} +1 -1
  11. package/dist/client/static/js/{SessionsView-t06h6zfx.js → SessionsView-s0crtcm8.js} +1 -1
  12. package/dist/client/static/js/{SheetView-agw459v2.js → SheetView-n6mst0hq.js} +13 -13
  13. package/dist/client/static/js/{SvgPreview-b9rfy1h6.js → SvgPreview-g2aqq812.js} +1 -1
  14. package/dist/client/static/js/{abnfDiagram-O67JEVCF-wbnhzcnj.js → abnfDiagram-O67JEVCF-3vac8sq4.js} +1 -1
  15. package/dist/client/static/js/architecture-7GRP2DOG-b5w9mnn5.js +1 -0
  16. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-t2sgevea.js → architectureDiagram-NJMV4G6O-1nh4htz2.js} +3 -3
  17. package/dist/client/static/js/{astro-hyj5wege.js → astro-63zcysj7.js} +1 -1
  18. package/dist/client/static/js/bash-hv3167gh.js +1 -0
  19. package/dist/client/static/js/{blockDiagram-BEXU5L5S-v2nzp54a.js → blockDiagram-BEXU5L5S-62z6kaar.js} +2 -2
  20. package/dist/client/static/js/{c4Diagram-YGBWAQC7-7h03146b.js → c4Diagram-YGBWAQC7-rts5zgx4.js} +3 -3
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-m57e9kp1.js → classDiagram-v2-NBCMYWYE-tnpww186.js} +1 -1
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-c4tnh4mg.js → cose-bilkent-JH36ORCC-8vsjbzwa.js} +1 -1
  23. package/dist/client/static/js/cpp-v2mqp8j7.js +1 -0
  24. package/dist/client/static/js/css-x7gyc3ta.js +1 -0
  25. package/dist/client/static/js/cynefin-OW5HDTMX-kdj8rjc1.js +1 -0
  26. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-mjf6njey.js → cynefinDiagram-VND7K2PF-005gc8km.js} +1 -1
  27. package/dist/client/static/js/{dagre-6A5THRUB-6yma9ch3.js → dagre-6A5THRUB-41zsteyd.js} +2 -2
  28. package/dist/client/static/js/{diagram-22UHCM2B-1q4ce2gb.js → diagram-22UHCM2B-prsm18a1.js} +3 -3
  29. package/dist/client/static/js/{diagram-3UASUU5V-0ttps29p.js → diagram-3UASUU5V-5nx9wf04.js} +1 -1
  30. package/dist/client/static/js/{diagram-ATOU4E4O-1mzexgv1.js → diagram-ATOU4E4O-k3d4z3aq.js} +3 -3
  31. package/dist/client/static/js/{diagram-CDSNMT55-4ae89t23.js → diagram-CDSNMT55-x2c5x5j2.js} +2 -2
  32. package/dist/client/static/js/{diagram-MLGK6HIB-057jaqvh.js → diagram-MLGK6HIB-nvr76jqh.js} +1 -1
  33. package/dist/client/static/js/{diagram-MPIPVDR6-p6yyq5sx.js → diagram-MPIPVDR6-v1jpzp9p.js} +1 -1
  34. package/dist/client/static/js/{dockerfile-00hqsk9c.js → dockerfile-vz6va73h.js} +1 -1
  35. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-bsk7dvm4.js → ebnfDiagram-ZINNZB2B-0v4tqr9v.js} +1 -1
  36. package/dist/client/static/js/{elk-276RUBZZ-dsq91er5.js → elk-276RUBZZ-qfn4r7xj.js} +1 -1
  37. package/dist/client/static/js/{erDiagram-OPXOYQCR-p7p13mbh.js → erDiagram-OPXOYQCR-cd667n9f.js} +4 -4
  38. package/dist/client/static/js/{erlang-814e8qy5.js → erlang-vk66vt7q.js} +1 -1
  39. package/dist/client/static/js/eventmodeling-NTZA5JFV-m57b7ytw.js +1 -0
  40. package/dist/client/static/js/flowDiagram-KWPJA3E3-fasj2gxy.js +1 -0
  41. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-bwgnttyk.js → ganttDiagram-FUAMR5RP-ps0h3drm.js} +1 -1
  42. package/dist/client/static/js/gitGraph-4MIJSDKK-wvzsc4ph.js +1 -0
  43. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ca0gj5am.js → gitGraphDiagram-X574FWY7-fts23jer.js} +2 -2
  44. package/dist/client/static/js/graphql-a4gbqpj9.js +1 -0
  45. package/dist/client/static/js/{index-y2z8nsvw.js → index-0dkc6z8e.js} +2 -2
  46. package/dist/client/static/js/{index-eqhjs1yv.js → index-1d8bxjsz.js} +4 -4
  47. package/dist/client/static/js/{index-kty4ncsr.js → index-1whzs9kb.js} +2 -2
  48. package/dist/client/static/js/{index-qfxn7yh5.js → index-396r53n0.js} +2 -2
  49. package/dist/client/static/js/{index-qn200x1b.js → index-39d8zbkx.js} +6 -6
  50. package/dist/client/static/js/{index-dn7hg4em.js → index-3nsrnyqr.js} +2 -2
  51. package/dist/client/static/js/{index-jkay7aw7.js → index-4jzsr1ky.js} +2 -2
  52. package/dist/client/static/js/{index-064vdkrs.js → index-4wnzs76g.js} +1 -1
  53. package/dist/client/static/js/{index-16sd19f0.js → index-4x9p7hf9.js} +2 -2
  54. package/dist/client/static/js/{index-zq0qxb17.js → index-52nd4hgm.js} +1 -1
  55. package/dist/client/static/js/{index-8pksqzwq.js → index-54mkp2r2.js} +1 -1
  56. package/dist/client/static/js/{index-abs635a1.js → index-56rtb871.js} +25 -25
  57. package/dist/client/static/js/{index-dxvtjn6a.js → index-5f4b44ay.js} +2 -2
  58. package/dist/client/static/js/{index-95kese1h.js → index-6009v8jf.js} +1 -1
  59. package/dist/client/static/js/{index-29npynva.js → index-62jgcgfd.js} +5 -5
  60. package/dist/client/static/js/{index-nw5mvcaj.js → index-64p1dncg.js} +2 -2
  61. package/dist/client/static/js/{index-fj5rsp5v.js → index-6d6hxwb5.js} +2 -2
  62. package/dist/client/static/js/{index-19x11s5w.js → index-70g527sb.js} +2 -2
  63. package/dist/client/static/js/{index-9d3n04vb.js → index-7zeah164.js} +2 -2
  64. package/dist/client/static/js/{index-5h8y54t6.js → index-7zedprz3.js} +1 -1
  65. package/dist/client/static/js/{index-g7s0wsag.js → index-9ab6xaxd.js} +2 -2
  66. package/dist/client/static/js/index-9vqkyj58.js +3 -0
  67. package/dist/client/static/js/{index-x1fqhhpp.js → index-9xsf8162.js} +35 -35
  68. package/dist/client/static/js/{index-j718pxb3.js → index-a4h5np9r.js} +2 -2
  69. package/dist/client/static/js/{index-bjv5ga2e.js → index-an2wv33f.js} +2 -2
  70. package/dist/client/static/js/{index-64sqfr4a.js → index-c5hjht5e.js} +2 -2
  71. package/dist/client/static/js/{index-aagt3382.js → index-c63qyysm.js} +1 -1
  72. package/dist/client/static/js/{index-red856x6.js → index-ccgzzydx.js} +1 -1
  73. package/dist/client/static/js/{index-ex5dtdx2.js → index-cra9mgkq.js} +4 -4
  74. package/dist/client/static/js/index-cvyqp8nz.css +1 -0
  75. package/dist/client/static/js/index-d2xtbabt.js +2 -0
  76. package/dist/client/static/js/{index-7055hdx1.js → index-dxkefysk.js} +1 -1
  77. package/dist/client/static/js/index-dxp2yvy7.js +2 -0
  78. package/dist/client/static/js/{index-vjmg7kn5.js → index-dyc886cc.js} +1 -1
  79. package/dist/client/static/js/{index-5wz0y88c.js → index-dzeyd153.js} +2 -2
  80. package/dist/client/static/js/{index-qf3y3ahx.js → index-e5j5gc4h.js} +2 -2
  81. package/dist/client/static/js/{index-2ks0m8ss.js → index-evmcc5qh.js} +2 -2
  82. package/dist/client/static/js/{index-f7te27n5.js → index-f2ahkev0.js} +5 -5
  83. package/dist/client/static/js/{index-5gf52a6d.js → index-fjex1y0t.js} +2 -2
  84. package/dist/client/static/js/{index-bafe7hmd.js → index-fxd8dfj4.js} +2 -2
  85. package/dist/client/static/js/{index-trvqvb1v.js → index-g4kkapka.js} +2 -2
  86. package/dist/client/static/js/{index-561gkvve.js → index-gzkzwgzv.js} +2 -2
  87. package/dist/client/static/js/{index-twsbv1yn.js → index-n1yr4khe.js} +1 -1
  88. package/dist/client/static/js/{index-d23eacf2.js → index-nkahe229.js} +2 -2
  89. package/dist/client/static/js/{index-3bf7r7z4.js → index-p6s3fz6b.js} +11 -11
  90. package/dist/client/static/js/{index-hnb66d3s.js → index-q4ke39rh.js} +2 -2
  91. package/dist/client/static/js/index-qtd0e38d.js +1 -0
  92. package/dist/client/static/js/{index-ncpwteyt.js → index-tqgj7rd9.js} +2 -2
  93. package/dist/client/static/js/{index-wbws16ag.js → index-x0xspam4.js} +2 -2
  94. package/dist/client/static/js/{index-amys498v.js → index-x2v1zmth.js} +186 -186
  95. package/dist/client/static/js/{index-pwe6chtp.js → index-x9hfvbz6.js} +1 -1
  96. package/dist/client/static/js/{index-dr5hca5b.js → index-xk1cqjkn.js} +3 -3
  97. package/dist/client/static/js/{index-k5zfzgez.js → index-y6ke70e6.js} +2 -2
  98. package/dist/client/static/js/{index-zedt16w7.js → index-zhjjpvcc.js} +1 -1
  99. package/dist/client/static/js/info-A6RAGUB7-ym2xevn8.js +1 -0
  100. package/dist/client/static/js/{infoDiagram-VRGFBTTK-7q58qdf1.js → infoDiagram-VRGFBTTK-88qbtpq5.js} +1 -1
  101. package/dist/client/static/js/ini-80p6sp79.js +1 -0
  102. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-9jmeszag.js → ishikawaDiagram-OU5B5YK6-s8bagk00.js} +1 -1
  103. package/dist/client/static/js/java-mm2b3s9b.js +1 -0
  104. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-0d7xe845.js → journeyDiagram-ZHPQQLJL-hz8z0b9x.js} +2 -2
  105. package/dist/client/static/js/json-fzy76fkw.js +1 -0
  106. package/dist/client/static/js/jsx-c7v2f8s7.js +1 -0
  107. package/dist/client/static/js/{julia-yv2j8qd0.js → julia-dm0j9apa.js} +1 -1
  108. package/dist/client/static/js/{kanban-definition-PNTS6WVX-7p83rwdn.js → kanban-definition-PNTS6WVX-sjjnjb51.js} +1 -1
  109. package/dist/client/static/js/lua-ppfdxrmv.js +1 -0
  110. package/dist/client/static/js/markdown-xed7y3ds.js +1 -0
  111. package/dist/client/static/js/{mermaid.core-hwhzw0wv.js → mermaid.core-zvwygxbh.js} +7 -7
  112. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hy0rtr7t.js → mindmap-definition-NLK3R4M7-kgj8enan.js} +2 -2
  113. package/dist/client/static/js/one-dark-pro-mq6sn6a2.js +1 -0
  114. package/dist/client/static/js/one-light-pt6t6vax.js +1 -0
  115. package/dist/client/static/js/packet-AYTQ26CC-01vcsy6x.js +1 -0
  116. package/dist/client/static/js/{pegDiagram-GJSIUBJH-kd8t53tx.js → pegDiagram-GJSIUBJH-gxzw1qwa.js} +1 -1
  117. package/dist/client/static/js/{perl-917pjq5a.js → perl-4jcm2jxv.js} +1 -1
  118. package/dist/client/static/js/{php-hwz75qzt.js → php-q32mec74.js} +1 -1
  119. package/dist/client/static/js/pie-WAS4IAKB-053gzkmh.js +1 -0
  120. package/dist/client/static/js/{pieDiagram-5QR66LMP-h3x03f80.js → pieDiagram-5QR66LMP-pdqwyqcm.js} +1 -1
  121. package/dist/client/static/js/properties-8ysbq2n2.js +1 -0
  122. package/dist/client/static/js/python-4ysexc8s.js +1 -0
  123. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-y2b1ncbg.js → quadrantDiagram-O4NWA36T-yx2t364p.js} +1 -1
  124. package/dist/client/static/js/r-hrsw5arc.js +1 -0
  125. package/dist/client/static/js/radar-RG4KPBEZ-bkpby8am.js +1 -0
  126. package/dist/client/static/js/railroad-74A4TZTK-67bxrjgw.js +1 -0
  127. package/dist/client/static/js/railroad-abnf-HS5TGJTU-xj9ymacg.js +1 -0
  128. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-2xxpbnf6.js +1 -0
  129. package/dist/client/static/js/railroad-peg-WCYAUIDC-78w88znz.js +1 -0
  130. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-x188rcxf.js → railroadDiagram-XR7U4H2S-800fdzkr.js} +1 -1
  131. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-g5e9fk17.js → requirementDiagram-PLB6GJNP-vc5rpgtm.js} +1 -1
  132. package/dist/client/static/js/{ruby-er7ayhte.js → ruby-npmpb290.js} +1 -1
  133. package/dist/client/static/js/{rust-1v8xbxn9.js → rust-waks43wh.js} +1 -1
  134. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-y9ht91gf.js → sankeyDiagram-IPEJSGJF-ccjk8zgn.js} +2 -2
  135. package/dist/client/static/js/{sass-n47tt136.js → sass-502a4r7y.js} +1 -1
  136. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-pp8s63rt.js → sequenceDiagram-PO4LG4MO-c0tk7gfn.js} +6 -6
  137. package/dist/client/static/js/{sizeCapture-INFHLROL-k6dhfxex.js → sizeCapture-INFHLROL-fma9p1vy.js} +1 -1
  138. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-y3akpsm4.js → stateDiagram-v2-GCMORJYK-d8f24b7j.js} +2 -2
  139. package/dist/client/static/js/{svelte-2pmz35vx.js → svelte-c15d0421.js} +1 -1
  140. package/dist/client/static/js/{swimlanes-2SLR337P-89081dr3.js → swimlanes-2SLR337P-sdt7qy36.js} +1 -1
  141. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-rz309qrx.js +8 -0
  142. package/dist/client/static/js/{timeline-definition-EJHVYXUP-tz6r8g3q.js → timeline-definition-EJHVYXUP-rv8qyr8b.js} +2 -2
  143. package/dist/client/static/js/treeView-Q6P3EWNA-g2bkjr4z.js +1 -0
  144. package/dist/client/static/js/treemap-WGGIJYW6-pj7yw9rw.js +1 -0
  145. package/dist/client/static/js/tsx-xjp2ds8g.js +1 -0
  146. package/dist/client/static/js/typescript-yg97da8h.js +1 -0
  147. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-yq2y1b09.js → usecaseDiagram-POWQR4AR-w6ew1red.js} +2 -2
  148. package/dist/client/static/js/{vennDiagram-UO4OBE2U-qdmjf6x3.js → vennDiagram-UO4OBE2U-p9axw7ch.js} +1 -1
  149. package/dist/client/static/js/{vue-d5gpjfgn.js → vue-xpemy62d.js} +1 -1
  150. package/dist/client/static/js/wardley-WFR3VGLG-c7ekf8r2.js +1 -0
  151. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-3n2sm7rj.js → wardleyDiagram-VNRHLVJA-5ewc8s4p.js} +1 -1
  152. package/dist/client/static/js/xml-nrb23phz.js +1 -0
  153. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-d7n2av2t.js → xychartDiagram-PMCCYNJV-7n4gn7k6.js} +2 -2
  154. package/dist/client/static/js/yaml-sqs6pjpx.js +1 -0
  155. package/marketplace/marketplace.json +34 -7
  156. package/marketplace/plugins/kanban/README.md +143 -0
  157. package/marketplace/plugins/kanban/icon.svg +5 -0
  158. package/marketplace/plugins/kanban/package.json +30 -0
  159. package/marketplace/plugins/kanban/src/app.tsx +34 -0
  160. package/marketplace/plugins/kanban/src/mcp-tools.ts +296 -0
  161. package/marketplace/plugins/kanban/src/mcp.test.ts +199 -0
  162. package/marketplace/plugins/kanban/src/mcp.ts +148 -0
  163. package/marketplace/plugins/kanban/src/panel/CardSheet.tsx +319 -0
  164. package/marketplace/plugins/kanban/src/panel/CardTile.tsx +97 -0
  165. package/marketplace/plugins/kanban/src/panel/StageColumn.tsx +116 -0
  166. package/marketplace/plugins/kanban/src/panel/StageSheet.tsx +249 -0
  167. package/marketplace/plugins/kanban/src/panel/catalogs.ts +114 -0
  168. package/marketplace/plugins/kanban/src/panel/index.tsx +327 -0
  169. package/marketplace/plugins/kanban/src/panel/panel.test.ts +219 -0
  170. package/marketplace/plugins/kanban/src/panel/start-work.ts +132 -0
  171. package/marketplace/plugins/kanban/src/panel/use-board.ts +148 -0
  172. package/marketplace/plugins/kanban/src/panel/use-card-detail.ts +70 -0
  173. package/marketplace/plugins/kanban/src/panel/use-writes.ts +123 -0
  174. package/marketplace/plugins/kanban/src/protocol.ts +180 -0
  175. package/marketplace/plugins/kanban/src/server.test.ts +113 -0
  176. package/marketplace/plugins/kanban/src/server.ts +227 -0
  177. package/marketplace/plugins/kanban/src/store/board.test.ts +311 -0
  178. package/marketplace/plugins/kanban/src/store/board.ts +147 -0
  179. package/marketplace/plugins/kanban/src/store/cards.ts +228 -0
  180. package/marketplace/plugins/kanban/src/store/fs.ts +159 -0
  181. package/marketplace/plugins/kanban/src/store/ops.ts +245 -0
  182. package/marketplace/plugins/kanban/src/store/resolve.test.ts +82 -0
  183. package/marketplace/plugins/kanban/src/store/resolve.ts +135 -0
  184. package/marketplace/plugins/kanban/tsconfig.json +26 -0
  185. package/package.json +2 -2
  186. package/src/client/components/common/file-icon/index.tsx +1 -1
  187. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +14 -4
  188. package/src/client/components/layout/desktop-layout/RightColumn.test.tsx +204 -0
  189. package/src/client/components/layout/desktop-layout/RightColumn.tsx +37 -16
  190. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +34 -7
  191. package/src/client/components/layout/desktop-layout/index.tsx +17 -22
  192. package/src/client/components/mobile/RightSidebar.tsx +10 -8
  193. package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +2 -0
  194. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +11 -3
  195. package/src/client/components/mobile/mobile-session-sidebar/use-drawer-tabs.ts +2 -1
  196. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.test.tsx +21 -0
  197. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +8 -4
  198. package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +8 -2
  199. package/src/client/components/settings/categories/appearance-settings/ThemeGrid.tsx +15 -4
  200. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +11 -0
  201. package/src/client/components/workspace/chat-timeline/MessageList.tsx +29 -21
  202. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +21 -0
  203. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +7 -1
  204. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +3 -1
  205. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +1 -1
  206. package/src/client/components/workspace/editor/FilePane.tsx +4 -2
  207. package/src/client/components/workspace/editor/Tabs.tsx +7 -1
  208. package/src/client/components/workspace/editor/Toolbar.tsx +7 -1
  209. package/src/client/components/workspace/editor/chrome-rows.test.tsx +126 -0
  210. package/src/client/components/workspace/editor/viewers/HtmlPreview.test.tsx +94 -0
  211. package/src/client/components/workspace/editor/viewers/HtmlPreview.tsx +71 -0
  212. package/src/client/components/workspace/editor/viewers/bytes.ts +1 -1
  213. package/src/client/components/workspace/editor/viewers/dispatch.tsx +18 -2
  214. package/src/client/components/workspace/editor/viewers/viewers.test.ts +14 -1
  215. package/src/client/components/workspace/panel-header/index.test.tsx +2 -1
  216. package/src/client/components/workspace/panel-header/index.tsx +6 -4
  217. package/src/client/hooks/chat/timeline/row-measure.ts +75 -0
  218. package/src/client/hooks/chat/timeline/row-window.test.ts +41 -21
  219. package/src/client/hooks/chat/timeline/row-window.ts +6 -24
  220. package/src/client/hooks/editor/resolve-viewer.ts +1 -1
  221. package/src/client/hooks/editor/use-editor-drop.ts +14 -0
  222. package/src/client/hooks/editor/use-editor-tab-state.ts +5 -4
  223. package/src/client/hooks/ui/media-query.ts +27 -0
  224. package/src/client/hooks/workspace/file-tabs.ts +10 -0
  225. package/src/client/hooks/workspace/panel-tabs-reveal.test.tsx +20 -17
  226. package/src/client/hooks/workspace/panel-tabs-reveal.ts +29 -17
  227. package/src/client/hooks/workspace/panel-tabs.ts +3 -2
  228. package/src/client/hooks/workspace/right-panel-presence.test.ts +152 -0
  229. package/src/client/hooks/workspace/right-panel-presence.ts +119 -0
  230. package/src/client/hooks/workspace/session-state/index.test.tsx +145 -0
  231. package/src/client/hooks/workspace/session-state/index.ts +28 -16
  232. package/src/client/lib/router/search-params.test.ts +83 -0
  233. package/src/client/lib/router/search-params.ts +14 -3
  234. package/src/server/lib/mcp/session-mcp.test.ts +64 -1
  235. package/src/server/lib/mcp/session-overlay.server.ts +7 -4
  236. package/src/server/lib/omp/rpc/constants.test.ts +31 -0
  237. package/src/server/lib/omp/rpc/constants.ts +19 -0
  238. package/src/server/lib/omp/rpc/session-new.ts +78 -0
  239. package/src/server/lib/omp/rpc/session-registry.ts +22 -49
  240. package/src/server/lib/omp/rpc/spawn-mcp.ts +8 -1
  241. package/src/server/lib/omp/session/blobs.server.ts +2 -1
  242. package/src/server/lib/plugins/e2e.test.ts +71 -2
  243. package/src/server/lib/plugins/loader.server.ts +20 -1
  244. package/src/server/lib/plugins/module-import.server.ts +45 -0
  245. package/src/server/routes/agent/new-prompt.test.ts +81 -0
  246. package/src/server/routes/agent/new.ts +78 -4
  247. package/src/server/routes/fs/raw.test.ts +12 -0
  248. package/src/server/routes/fs/raw.ts +2 -6
  249. package/src/server/routes/wiki/asset.ts +1 -1
  250. package/src/shared/lib/fs/document-kind.test.ts +39 -2
  251. package/src/shared/lib/fs/document-kind.ts +49 -1
  252. package/src/shared/lib/fs/file-kind.test.ts +30 -3
  253. package/src/shared/lib/fs/file-kind.ts +7 -104
  254. package/src/shared/lib/fs/mime.ts +159 -0
  255. package/src/shared/lib/workspace/sidebar-width.test.ts +34 -0
  256. package/src/shared/lib/workspace/sidebar-width.ts +33 -0
  257. package/src/shared/lib/workspace/workspace-panel-widths.test.ts +124 -0
  258. package/src/shared/lib/workspace/workspace-panel-widths.ts +115 -18
  259. package/dist/client/static/js/ImageView-2r8p5z3y.js +0 -1
  260. package/dist/client/static/js/LayoutWrapper-rq3d2a4e.js +0 -2
  261. package/dist/client/static/js/architecture-7GRP2DOG-pvb4d65d.js +0 -1
  262. package/dist/client/static/js/bash-8d8z8zrg.js +0 -1
  263. package/dist/client/static/js/cpp-620mvjkk.js +0 -1
  264. package/dist/client/static/js/css-bt76kxbq.js +0 -1
  265. package/dist/client/static/js/cynefin-OW5HDTMX-gmx4vean.js +0 -1
  266. package/dist/client/static/js/eventmodeling-NTZA5JFV-vrnheyh7.js +0 -1
  267. package/dist/client/static/js/flowDiagram-KWPJA3E3-7b4w6phx.js +0 -1
  268. package/dist/client/static/js/gitGraph-4MIJSDKK-n6wnc8st.js +0 -1
  269. package/dist/client/static/js/graphql-j1a6zp7m.js +0 -1
  270. package/dist/client/static/js/index-3qnjdjg2.js +0 -1
  271. package/dist/client/static/js/index-4bqssvt6.js +0 -2
  272. package/dist/client/static/js/index-dpy3ewrn.css +0 -1
  273. package/dist/client/static/js/index-gq5w5w8x.js +0 -2
  274. package/dist/client/static/js/index-ta6gpcpw.js +0 -3
  275. package/dist/client/static/js/info-A6RAGUB7-1xtdxjz2.js +0 -1
  276. package/dist/client/static/js/ini-5f4zqtqr.js +0 -1
  277. package/dist/client/static/js/java-jj41mty3.js +0 -1
  278. package/dist/client/static/js/json-rnh2h17x.js +0 -1
  279. package/dist/client/static/js/jsx-4gecrt29.js +0 -1
  280. package/dist/client/static/js/lua-zszaw2f7.js +0 -1
  281. package/dist/client/static/js/markdown-nm6gw4v4.js +0 -1
  282. package/dist/client/static/js/one-dark-pro-4b8er03c.js +0 -1
  283. package/dist/client/static/js/one-light-e6r3vsz4.js +0 -1
  284. package/dist/client/static/js/packet-AYTQ26CC-zm1r82x5.js +0 -1
  285. package/dist/client/static/js/pie-WAS4IAKB-sqa7321j.js +0 -1
  286. package/dist/client/static/js/properties-rkptax7r.js +0 -1
  287. package/dist/client/static/js/python-qf1se1mj.js +0 -1
  288. package/dist/client/static/js/r-ms0cygq2.js +0 -1
  289. package/dist/client/static/js/radar-RG4KPBEZ-z3z82syp.js +0 -1
  290. package/dist/client/static/js/railroad-74A4TZTK-z6swcqq2.js +0 -1
  291. package/dist/client/static/js/railroad-abnf-HS5TGJTU-33km6py4.js +0 -1
  292. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-1zbf1xmq.js +0 -1
  293. package/dist/client/static/js/railroad-peg-WCYAUIDC-wte1xzzy.js +0 -1
  294. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-3q2a15wc.js +0 -8
  295. package/dist/client/static/js/treeView-Q6P3EWNA-pvgx6n22.js +0 -1
  296. package/dist/client/static/js/treemap-WGGIJYW6-3n9zm628.js +0 -1
  297. package/dist/client/static/js/tsx-gx7td06z.js +0 -1
  298. package/dist/client/static/js/typescript-1a808spn.js +0 -1
  299. package/dist/client/static/js/wardley-WFR3VGLG-7m07ewc4.js +0 -1
  300. package/dist/client/static/js/xml-3117mxd9.js +0 -1
  301. package/dist/client/static/js/yaml-dmvh8vyt.js +0 -1
@@ -4,7 +4,8 @@
4
4
  */
5
5
 
6
6
  /**
7
- * A tab-style panel that is REVEALED shows a view, not its catalog.
7
+ * A tab-style panel that is REVEALED shows the view its session had, not its
8
+ * catalog — but a session that never picked a view keeps the catalog.
8
9
  *
9
10
  * A panel can be put away whole — the navbar's right-side toggle, the sidebar's
10
11
  * expand control, `⌥⌘J`, `⌘B`, and on a phone the same two header controls — and
@@ -17,8 +18,8 @@
17
18
  * opened `Resources` as a tab. Two clicks that both say "show me the panel" gave
18
19
  * two different answers, and the second one looked broken.
19
20
  *
20
- * So the rule is stated once, for every column and drawer, and it is a GESTURE,
21
- * not a state:
21
+ * So the rule is stated once, for every column and drawer, and it is a GESTURE
22
+ * over a STORED selection:
22
23
  *
23
24
  * - **Only a reveal counts.** Keying it on "the panel is open and on its home
24
25
  * page" would fight the `+` control: pressing it to browse the catalog would be
@@ -27,8 +28,12 @@
27
28
  * open — revealing it is enough.
28
29
  * - **A home page the user CHOSE is left alone.** Closing the last tab (or
29
30
  * pressing `+`) is an answer, not an absence: reopening the closed tab on the
30
- * next toggle is the defect this rule was extended for. Only a column that has
31
- * never held a tab is brought back on its view.
31
+ * next toggle is the defect this rule was extended for.
32
+ * - **A view the session never picked is not opened.** The resolved selection
33
+ * falls back to `files`, and that fallback is not a request: a fresh chat whose
34
+ * right drawer was opened from the header showed a `Files` tab on BOTH layouts
35
+ * — the reported defect — because the default was indistinguishable from the
36
+ * user's pick. With no stored view the catalog is the answer.
32
37
  * - **A view the panel cannot draw is not opened.** The stored selection can name
33
38
  * a panel that is switched off, uninstalled, or whose bundle has not loaded;
34
39
  * `open` would write an id `visiblePanelTabs` filters straight back out, which
@@ -53,12 +58,16 @@ export interface RevealTabInput {
53
58
  home: boolean;
54
59
  /**
55
60
  * The catalog is up because the user ASKED for it — `+`, or closing the last
56
- * tab. A reveal leaves that alone; only a column that never held a tab is
57
- * brought back on its view.
61
+ * tab. A reveal leaves that alone.
58
62
  */
59
63
  chosenHome: boolean;
60
- /** The view the panel would show — its stored selection. */
61
- view: string;
64
+ /**
65
+ * The view this SESSION stored, or `null` when it never picked one.
66
+ *
67
+ * The resolved fallback (`files`) is deliberately not accepted here: treating
68
+ * it as a pick is what opened the file explorer in every new chat.
69
+ */
70
+ storedView: string | null;
62
71
  /** Every id this panel could draw right now. */
63
72
  known: ReadonlySet<string>;
64
73
  /** Only the tab style has a home page to leave. */
@@ -66,14 +75,14 @@ export interface RevealTabInput {
66
75
  }
67
76
 
68
77
  /** The id a reveal must open, or `null` when there is nothing to do. */
69
- export function revealTabId({ revealed, home, chosenHome, view, known, enabled }: RevealTabInput): string | null {
78
+ export function revealTabId({ revealed, home, chosenHome, storedView, known, enabled }: RevealTabInput): string | null {
70
79
  if (!enabled || !revealed) return null;
71
80
  if (!home) return null;
72
81
  // Closing the last tab IS the answer. Reopening it on the next toggle is the
73
82
  // reported defect: the tab came back after the user had closed it.
74
83
  if (chosenHome) return null;
75
- if (!view || !known.has(view)) return null;
76
- return view;
84
+ if (!storedView || !known.has(storedView)) return null;
85
+ return storedView;
77
86
  }
78
87
 
79
88
  /**
@@ -127,8 +136,11 @@ export interface RevealPanelTabOptions {
127
136
  enabled: boolean;
128
137
  /** A reveal gesture landed on this render — see `useRevealEdge`. */
129
138
  revealed: boolean;
130
- /** The view to show when the strip has nothing on screen. */
131
- view: string;
139
+ /**
140
+ * The view THIS SESSION stored, or `null` when it never picked one. Not the
141
+ * resolved fallback: see `RevealTabInput.storedView`.
142
+ */
143
+ storedView: string | null;
132
144
  /** The panel's strip is showing its catalog. */
133
145
  home: boolean;
134
146
  /** The catalog was ASKED for (see `RevealTabInput.chosenHome`). */
@@ -153,10 +165,10 @@ export interface RevealPanelTabOptions {
153
165
  * `enabled` flag is what keeps rail panels out of it, where there is no home page
154
166
  * and the stored selection is already on screen.
155
167
  */
156
- export function useRevealPanelTab({ enabled, revealed, view, home, chosenHome, openTab, known }: RevealPanelTabOptions): void {
168
+ export function useRevealPanelTab({ enabled, revealed, storedView, home, chosenHome, openTab, known }: RevealPanelTabOptions): void {
157
169
  useEffect(() => {
158
170
  if (!openTab) return;
159
- const id = revealTabId({ revealed, home, chosenHome, view, known, enabled });
171
+ const id = revealTabId({ revealed, home, chosenHome, storedView, known, enabled });
160
172
  if (id !== null) openTab(id);
161
- }, [enabled, revealed, home, chosenHome, view, known, openTab]);
173
+ }, [enabled, revealed, home, chosenHome, storedView, known, openTab]);
162
174
  }
@@ -86,8 +86,9 @@ interface ColumnTabs {
86
86
  * differ from the rail's default (which opens `Files`). A rail has to show
87
87
  * something — a column with no view is a column of buttons over nothing — while
88
88
  * a strip's empty state is its catalog, which is a real answer. So the stored
89
- * `layout.activeRightPanel` (`files`) does NOT seed a tab; only an explicit
90
- * request does (`useRightOpenRequest`).
89
+ * `layout.activeRightPanel` (`files`) does NOT seed a tab by itself: only an
90
+ * explicit request (`useRightOpenRequest`), or a reveal of a session that had
91
+ * already picked a view (`panel-tabs-reveal`), opens one.
91
92
  */
92
93
  const EMPTY: ColumnTabs = { tabs: [], active: null, home: false };
93
94
 
@@ -0,0 +1,152 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `useRightPanelPresence` — the side's toggle, and the refusal that answers it.
8
+ *
9
+ * The panel is the only part of the side that can be refused (the editor column
10
+ * keeps its width whenever it is open), so the toggle has to read PRESENCE
11
+ * rather than its own `hidden` flag, and a click that could only flip a flag the
12
+ * layout is ignoring must be answered out loud. Three behaviours, each a bug
13
+ * that shipped before this hook existed:
14
+ *
15
+ * - a load that starts narrow does not warn — the panel was never on screen, and
16
+ * a toast on every 900px load is noise;
17
+ * - a crossing AFTER the load does warn, once, naming what would make it fit;
18
+ * - a click on a side with nothing on screen is answered even though no crossing
19
+ * happened.
20
+ *
21
+ * The settle window is a clock read (`Date.now()`), so time is driven with
22
+ * `setSystemTime` rather than by sleeping through it.
23
+ */
24
+
25
+ import { afterAll, afterEach, beforeEach, describe, expect, setSystemTime, test } from 'bun:test';
26
+ import { Window } from 'happy-dom';
27
+ import { h, render } from 'preact';
28
+ import { act } from 'preact/test-utils';
29
+ import {
30
+ useRightPanelPresence,
31
+ type RightPanelPresence,
32
+ } from '@/client/hooks/workspace/right-panel-presence';
33
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
34
+
35
+ interface ProbeProps {
36
+ showEditor: boolean;
37
+ sideShown: boolean;
38
+ toggleSide: () => void;
39
+ pushToast: (message: string, tone?: 'success' | 'error' | 'warning') => void;
40
+ expose: (value: RightPanelPresence) => void;
41
+ }
42
+
43
+ let toasts: string[] = [];
44
+ let toggles = 0;
45
+ let container: HTMLElement;
46
+ /** Past the hook's 1500ms settle window, without waiting for it. */
47
+ const AFTER_SETTLE = 5_000;
48
+
49
+ beforeEach(() => {
50
+ installDomGlobals(new Window({ url: 'http://localhost' }));
51
+ setSystemTime(new Date('2026-01-01T00:00:00Z'));
52
+ toasts = [];
53
+ toggles = 0;
54
+ container = document.createElement('div');
55
+ document.body.appendChild(container);
56
+ });
57
+
58
+ afterEach(() => {
59
+ render(null, container);
60
+ container.remove();
61
+ restoreDomGlobals();
62
+ setSystemTime();
63
+ });
64
+
65
+ afterAll(() => {
66
+ restoreDomGlobals();
67
+ setSystemTime();
68
+ });
69
+
70
+ function Probe({ showEditor, sideShown, toggleSide, pushToast, expose }: ProbeProps) {
71
+ expose(useRightPanelPresence({ showEditor, sideShown, toggleSide, pushToast }));
72
+ return null;
73
+ }
74
+
75
+ const BASE = { showEditor: true, sideShown: true, toggleSide: () => { toggles += 1; } };
76
+
77
+ function mount() {
78
+ let current: RightPanelPresence | null = null;
79
+ const draw = async (next: Omit<ProbeProps, 'expose' | 'pushToast'>) => {
80
+ await act(async () => {
81
+ render(
82
+ h(Probe, {
83
+ ...next,
84
+ pushToast: (message: string) => toasts.push(message),
85
+ expose: (value) => {
86
+ current = value;
87
+ },
88
+ }),
89
+ container,
90
+ );
91
+ });
92
+ };
93
+ return {
94
+ draw,
95
+ get: () => current!,
96
+ /** Move the clock past the settle window, so a report counts as a crossing. */
97
+ passSettleWindow: () => setSystemTime(new Date(Date.now() + AFTER_SETTLE)),
98
+ };
99
+ }
100
+
101
+ describe('useRightPanelPresence', () => {
102
+ test('a load that starts narrow does not warn about the panel it never drew', async () => {
103
+ const probe = mount();
104
+ await probe.draw(BASE);
105
+ await act(async () => probe.get().report(true));
106
+
107
+ expect(toasts).toEqual([]);
108
+ expect(probe.get().suppressed).toBe(true);
109
+ // The editor column is still on screen, so the side reads visible.
110
+ expect(probe.get().sideVisible).toBe(true);
111
+ });
112
+
113
+ test('a crossing after the settle window warns once, and stops repeating', async () => {
114
+ const probe = mount();
115
+ await probe.draw(BASE);
116
+ probe.passSettleWindow();
117
+
118
+ await act(async () => probe.get().report(true));
119
+ await act(async () => probe.get().report(true));
120
+ expect(toasts).toHaveLength(1);
121
+ expect(toasts[0]).toContain('right panel needs more room');
122
+
123
+ // Coming back and losing it again is a second crossing, so it may speak.
124
+ await act(async () => probe.get().report(false));
125
+ await act(async () => probe.get().report(true));
126
+ expect(toasts).toHaveLength(2);
127
+ });
128
+
129
+ test('a click on a side with nothing on screen is refused out loud', async () => {
130
+ const probe = mount();
131
+ await probe.draw({ ...BASE, showEditor: false });
132
+ probe.passSettleWindow();
133
+ await act(async () => probe.get().report(true));
134
+
135
+ // Nothing of the side is on screen: the editor is closed and the panel is
136
+ // suppressed, so the toggle must explain instead of flipping a dead flag.
137
+ expect(probe.get().sideVisible).toBe(false);
138
+ await act(async () => probe.get().toggle());
139
+ expect(toggles).toBe(0);
140
+ expect(toasts).toHaveLength(1);
141
+ });
142
+
143
+ test('a click with something on screen still toggles', async () => {
144
+ const probe = mount();
145
+ await probe.draw(BASE);
146
+ probe.passSettleWindow();
147
+ await act(async () => probe.get().toggle());
148
+
149
+ expect(toggles).toBe(1);
150
+ expect(toasts).toEqual([]);
151
+ });
152
+ });
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The right side of the workspace: is anything of it on screen, and what happens
8
+ * when the panel it was asked to show cannot fit.
9
+ *
10
+ * Two facts, one owner, because they are the same question asked twice. The
11
+ * editor column keeps its width even while the right panel is suppressed, so
12
+ * "the side is on" means "the editor, the panel, or both" — and a toggle that
13
+ * reads its own `hidden` flag instead would either claim a side is on screen
14
+ * when nothing is, or hide a visible column on the next click.
15
+ *
16
+ * `WorkspacePanels` is the only place that measures the group, so it is the only
17
+ * place that can answer whether the panel fits; the answer travels up here
18
+ * because the control that asked (the navbar's toggle, the `⌥⌘J` chord) is the
19
+ * layout's. A panel that silently fails to appear is the defect: the flag the
20
+ * click flipped stays true, so the next click looks like it does nothing.
21
+ *
22
+ * Three ways the refusal is announced, and each is once:
23
+ *
24
+ * - **The FIRST suppression of a load is silent.** A window that is narrow from
25
+ * the start never had the panel on screen, so nothing was lost; a warning
26
+ * toast on every load at 900px is noise, not information.
27
+ * - **The panel DISAPPEARING is announced** — a resize, or an editor column the
28
+ * user just opened — because the message names what would make it fit.
29
+ * - **A click on a side that has nothing on screen is answered on demand**: the
30
+ * crossing rule cannot see it, since the suppression was already true.
31
+ */
32
+
33
+ import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
34
+ import type { ToastTone } from '@/shared/lib/ui/toast-duration';
35
+
36
+ const REFUSAL =
37
+ 'The right panel needs more room: widen the window, close the editor column, or pick the phone layout.';
38
+
39
+ /**
40
+ * How long after mount a suppression is still the LOAD settling rather than the
41
+ * panel being taken away.
42
+ *
43
+ * A session restores its stored layout in several passes — the panel widths, the
44
+ * editor's tab list, the right side's own flags — so a 900px window draws the
45
+ * panel for a frame and then drops it. That is not a loss the user can see, and
46
+ * warning about it put a toast on every narrow-window load. A crossing after
47
+ * this window is a real one: a resize, or an editor column the user opened.
48
+ */
49
+ const SETTLE_MS = 1500;
50
+
51
+ export interface RightPanelPresenceArgs {
52
+ pushToast: (message: string, tone?: ToastTone) => void;
53
+ /** The editor column is on screen and holds its width. */
54
+ showEditor: boolean;
55
+ /** The side is not put away (`!rightSide.hidden`). */
56
+ sideShown: boolean;
57
+ /** The side's own switch, used when a click has something to do. */
58
+ toggleSide: () => void;
59
+ }
60
+
61
+ export interface RightPanelPresence {
62
+ /** The panel is asked for and there is no room for it. */
63
+ suppressed: boolean;
64
+ /** Something of the side — the editor, the panel, or both — is on screen. */
65
+ sideVisible: boolean;
66
+ /**
67
+ * Handed to `WorkspacePanels`; it reports the fit decision every render, and
68
+ * `null` until the group has been measured.
69
+ *
70
+ * The `null` is what makes "the first suppression of a load is silent"
71
+ * possible: the resolver answers "fits" before it has an area, so without it
72
+ * the first measured frame looked like a panel being taken away and warned on
73
+ * every load at a narrow window.
74
+ */
75
+ report: (suppressed: boolean | null) => void;
76
+ /** The navbar's control and the chord: reads `sideVisible`, refuses out loud. */
77
+ toggle: () => void;
78
+ }
79
+
80
+ export function useRightPanelPresence({
81
+ pushToast,
82
+ showEditor,
83
+ sideShown,
84
+ toggleSide,
85
+ }: RightPanelPresenceArgs): RightPanelPresence {
86
+ const [suppressed, setSuppressed] = useState<boolean | null>(null);
87
+ const announced = useRef(false);
88
+ const mountedAt = useRef(Date.now());
89
+
90
+ const announce = useCallback(() => {
91
+ if (announced.current) return;
92
+ if (Date.now() - mountedAt.current < SETTLE_MS) return;
93
+ announced.current = true;
94
+ pushToast(REFUSAL, 'warning');
95
+ }, [pushToast]);
96
+
97
+ useEffect(() => {
98
+ if (suppressed !== true) {
99
+ // A panel that came back clears the "already said so" mark, so losing it
100
+ // again is a new crossing the user may need to hear about.
101
+ if (suppressed === false) announced.current = false;
102
+ return;
103
+ }
104
+ announce();
105
+ }, [suppressed, announce]);
106
+
107
+ const report = useCallback((next: boolean | null) => setSuppressed(next), []);
108
+ const sideVisible = showEditor || suppressed !== true;
109
+
110
+ const toggle = useCallback(() => {
111
+ if (sideShown && !sideVisible) {
112
+ announce();
113
+ return;
114
+ }
115
+ toggleSide();
116
+ }, [announce, sideShown, sideVisible, toggleSide]);
117
+
118
+ return { suppressed: suppressed === true, sideVisible, report, toggle };
119
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * A per-session slot is never painted under another session's id.
8
+ *
9
+ * The reported defect: a fresh chat opened with the `Files` right-panel tab
10
+ * already in its strip, on both the phone and the desktop. The strip mirrors its
11
+ * selection into `layout.activeRightPanel`, and a switch renders once before the
12
+ * new session's blob lands — with the OLD session's local copy still in the
13
+ * hook. That commit wrote the old strip into the new session, where the (empty)
14
+ * blob then merged under it.
15
+ *
16
+ * So the claim is about the RENDER, not the store: after a switch, no commit may
17
+ * expose the previous session's value under the new id.
18
+ */
19
+
20
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
21
+ import { Window } from 'happy-dom';
22
+ import { h, render } from 'preact';
23
+ import { act } from 'preact/test-utils';
24
+ import { SessionStateProvider } from '@/client/components/common/session-state-provider/index';
25
+ import { useSessionState } from '@/client/hooks/workspace/session-state';
26
+ import { useSessionStateContext } from '@/client/hooks/workspace/session-state/context';
27
+ import {
28
+ getSessionState,
29
+ hydrateSession,
30
+ resetSessionStateStore,
31
+ } from '@/shared/lib/workspace/session-state/store';
32
+
33
+ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'HTMLInputElement', 'Event', 'MouseEvent', 'KeyboardEvent'] as const;
34
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
35
+ const nativeFetch = Bun.fetch;
36
+
37
+ let container: HTMLElement;
38
+ /** Every commit's `(session, value)`, so a stale one cannot hide behind the last. */
39
+ let renders: Array<{ session: string; panel: string }> = [];
40
+
41
+ function Probe() {
42
+ const { sessionId } = useSessionStateContext();
43
+ const [panel] = useSessionState<string>('layout.activeRightPanel', 'files');
44
+ renders.push({ session: sessionId, panel });
45
+ return h('div', null, panel);
46
+ }
47
+
48
+ beforeAll(() => {
49
+ const win = new Window({ url: 'http://localhost' });
50
+ const target = globalThis as unknown as Record<string, unknown>;
51
+ for (const key of DOM_GLOBALS) {
52
+ if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
53
+ target[key] = (win as unknown as Record<string, unknown>)[key];
54
+ }
55
+ // Answer with the SESSION's own entry, so a load landing mid-test cannot
56
+ // adopt an empty blob over the value `hydrateSession` seeded.
57
+ target.fetch = async (input: unknown, init?: { method?: string }) => {
58
+ const method = init?.method ?? 'GET';
59
+ const sessionId = String(input).split('/sessions/')[1]?.split('/')[0] ?? 'x';
60
+ if (method === 'POST') return new Response(JSON.stringify({ success: true }), { status: 200 });
61
+ return new Response(
62
+ JSON.stringify({ sessionId, state: { ...(getSessionState(sessionId) ?? {}) } }),
63
+ { status: 200 },
64
+ );
65
+ };
66
+ });
67
+
68
+ afterAll(() => {
69
+ const target = globalThis as unknown as Record<string, unknown>;
70
+ for (const key of DOM_GLOBALS) {
71
+ if (nativeGlobals[key] === undefined) delete target[key];
72
+ else target[key] = nativeGlobals[key];
73
+ }
74
+ target.fetch = nativeFetch;
75
+ });
76
+
77
+ beforeEach(() => {
78
+ resetSessionStateStore();
79
+ renders = [];
80
+ container = document.createElement('div');
81
+ document.body.appendChild(container);
82
+ });
83
+
84
+ afterEach(() => {
85
+ render(null, container);
86
+ container.remove();
87
+ });
88
+
89
+ /** Render the provider on a session id and drain the load's promise chain. */
90
+ async function show(sessionId: string) {
91
+ await act(async () => {
92
+ render(h(SessionStateProvider, { sessionId, children: h(Probe, null) }), container);
93
+ });
94
+ for (let i = 0; i < 20; i += 1) await act(async () => {});
95
+ }
96
+
97
+ describe('useSessionState across a session switch', () => {
98
+ test('the previous session value is never rendered under the new id', async () => {
99
+ hydrateSession('s-prev', { 'layout.activeRightPanel': 'git' });
100
+ await show('s-prev');
101
+ expect(renders.at(-1)).toEqual({ session: 's-prev', panel: 'git' });
102
+
103
+ renders = [];
104
+ await show('s-fresh');
105
+
106
+ // The switch commit itself used to carry `git` — the old chat's pick — and
107
+ // every mirror-on-render then wrote it into the fresh session.
108
+ expect(renders.filter((r) => r.session === 's-fresh' && r.panel !== 'files')).toEqual([]);
109
+ expect(renders.at(-1)).toEqual({ session: 's-fresh', panel: 'files' });
110
+ });
111
+
112
+ test('a session with its own stored value shows that value, not the previous one', async () => {
113
+ hydrateSession('s-prev', { 'layout.activeRightPanel': 'git' });
114
+ hydrateSession('s-owns', { 'layout.activeRightPanel': 'todo' });
115
+ await show('s-prev');
116
+
117
+ renders = [];
118
+ await show('s-owns');
119
+ expect(renders.at(-1)).toEqual({ session: 's-owns', panel: 'todo' });
120
+ });
121
+
122
+ test('a write during the switch persists under the new id', async () => {
123
+ hydrateSession('s-prev', { 'layout.activeRightPanel': 'git' });
124
+ hydrateSession('s-write', {});
125
+ await show('s-prev');
126
+
127
+ function Writer() {
128
+ const [, setPanel] = useSessionState<string>('layout.activeRightPanel', 'files');
129
+ return h('button', { onClick: () => setPanel('terminal') }, 'pick');
130
+ }
131
+
132
+ await act(async () => {
133
+ render(
134
+ h(SessionStateProvider, { sessionId: 's-write', children: h(Writer, null) }),
135
+ container,
136
+ );
137
+ });
138
+ for (let i = 0; i < 20; i += 1) await act(async () => {});
139
+ (container.querySelector('button') as HTMLButtonElement).click();
140
+ await act(async () => {});
141
+
142
+ expect(getSessionState('s-write')?.['layout.activeRightPanel']).toBe('terminal');
143
+ expect(getSessionState('s-prev')?.['layout.activeRightPanel']).toBe('git');
144
+ });
145
+ });
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef, useState } from 'preact/hooks';
1
+ import { useEffect, useState } from 'preact/hooks';
2
2
  import { getSessionValue, hydrateSession, setSessionKey } from '@/shared/lib/workspace/session-state/store';
3
3
  import { subscribeSessionKey, subscribeSessionReplaced } from '@/shared/lib/workspace/session-state/listeners';
4
4
  import { useSessionStateContext } from '@/client/hooks/workspace/session-state/context';
@@ -23,21 +23,35 @@ type LoadedState = Record<string, unknown>;
23
23
  * move across an adoption (it was already true), so without the second
24
24
  * subscription a pending chat's opened panels and picked view were reset to
25
25
  * their defaults at the exact moment the spawn renamed the session.
26
+ *
27
+ * The local copy is KEYED by the session it was read for. A session switch
28
+ * happens one commit before the restore effect can run, and an unkeyed copy
29
+ * made that commit render the PREVIOUS chat's value under the NEW session id.
30
+ * Every reader that mirrors the value back into the store then persisted the
31
+ * old chat's state as the new one's — measured: opening a new chat while a
32
+ * right-panel tab strip was in `tabs` mode reopened `Files` in it, on both
33
+ * layouts, because the strip's selection was mirrored into the fresh session
34
+ * before its (empty) blob landed. A copy that belongs to another session is
35
+ * not a value this session may show; the store or the fallback is.
26
36
  */
27
37
  export function useSessionState<T>(key: string, fallback: T): [T, (value: T | ((prev: T) => T)) => void, boolean] {
28
38
  const { sessionId, ready } = useSessionStateContext();
29
39
  const stored = getSessionValue<T>(sessionId, key);
30
- const [local, setLocal] = useState<T>(stored === undefined ? fallback : stored);
31
- const sessionIdRef = useRef(sessionId);
40
+ const [local, setLocal] = useState<{ sessionId: string; value: T }>(() => ({
41
+ sessionId,
42
+ value: stored === undefined ? fallback : stored,
43
+ }));
44
+
45
+ // The copy belongs to another session: read this session's own value instead
46
+ // of carrying the previous chat's over. The restore effect below adopts it.
47
+ const current =
48
+ local.sessionId === sessionId ? local.value : stored === undefined ? fallback : stored;
32
49
 
33
50
  // Restore the stored value (or reset to fallback) on session change/load.
34
51
  useEffect(() => {
35
- if (sessionIdRef.current !== sessionId) {
36
- sessionIdRef.current = sessionId;
37
- }
38
52
  if (!ready) return;
39
53
  const next = getSessionValue<T>(sessionId, key);
40
- setLocal(next === undefined ? fallback : next);
54
+ setLocal({ sessionId, value: next === undefined ? fallback : next });
41
55
  // `key` and `fallback` are stable per call site; session/ready drive restore.
42
56
  // eslint-disable-next-line react-hooks/exhaustive-deps
43
57
  }, [sessionId, ready, key]);
@@ -48,7 +62,7 @@ export function useSessionState<T>(key: string, fallback: T): [T, (value: T | ((
48
62
  () =>
49
63
  subscribeSessionReplaced(sessionId, () => {
50
64
  const next = getSessionValue<T>(sessionId, key);
51
- setLocal(next === undefined ? fallback : next);
65
+ setLocal({ sessionId, value: next === undefined ? fallback : next });
52
66
  }),
53
67
  // `key` and `fallback` are stable per call site.
54
68
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -56,17 +70,15 @@ export function useSessionState<T>(key: string, fallback: T): [T, (value: T | ((
56
70
  );
57
71
 
58
72
  const setValue = (value: T | ((prev: T) => T)) => {
59
- const resolved = typeof value === 'function' ? (value as (prev: T) => T)(getSessionValue<T>(sessionId, key) ?? local) : value;
60
- setLocal(resolved);
73
+ const resolved =
74
+ typeof value === 'function'
75
+ ? (value as (prev: T) => T)(getSessionValue<T>(sessionId, key) ?? current)
76
+ : value;
77
+ setLocal({ sessionId, value: resolved });
61
78
  setSessionKey(sessionId, key, resolved);
62
79
  };
63
80
 
64
- // While the blob loads, surface the live in-memory value so a panel never
65
- // renders stale fallback over a fresher local write.
66
- if (!ready && stored !== undefined && stored !== local) {
67
- return [stored, setValue, ready];
68
- }
69
- return [local, setValue, ready];
81
+ return [current, setValue, ready];
70
82
  }
71
83
 
72
84
  export const useSessionUiState = useSessionState;