@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
@@ -0,0 +1,219 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The board's pure view logic, and the request a card dispatches.
8
+ *
9
+ * These are the rules a reader would otherwise have to infer from a render: which
10
+ * stage a hidden lane keeps, which lens a fresh board opens on, and exactly what
11
+ * a Start-work request carries. Each one is a silent bug when wrong — a hidden
12
+ * lane that loses cards, a lens that hides the board, a spawn with the stage
13
+ * prompt in the wrong place.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+
18
+ import type { Card, CardSummary, ResolvedAgent, Stage } from '../protocol';
19
+ import { defaultBoard } from '../store/board';
20
+ import { resolveAgent } from '../store/resolve';
21
+ import { followUpBody, modelCommands, startWorkBody, startWork } from './start-work';
22
+ import { defaultLens, lensCards, lensCounts } from './use-board';
23
+ import { visibleStages, unplacedCards } from './index';
24
+ import { originLabel, isOverridden } from './CardSheet';
25
+ import { priorityLabel, promptPreview, workspaceLabel } from './CardTile';
26
+
27
+ function summary(overrides: Partial<CardSummary> = {}): CardSummary {
28
+ return {
29
+ schema: 2,
30
+ id: 'k-aaaaaa',
31
+ title: 'A card',
32
+ status: 'open',
33
+ priority: 2,
34
+ workspace: '/w/alpha',
35
+ sessionId: null,
36
+ createdAt: '2026-01-01T00:00:00.000Z',
37
+ updatedAt: '2026-01-01T00:00:00.000Z',
38
+ movedAt: null,
39
+ hasPrompt: true,
40
+ imageCount: 0,
41
+ ...overrides,
42
+ };
43
+ }
44
+
45
+ function card(overrides: Partial<Card> = {}): Card {
46
+ return {
47
+ schema: 2,
48
+ id: 'k-aaaaaa',
49
+ title: 'A card',
50
+ status: 'in_progress',
51
+ priority: 1,
52
+ workspace: '/w/alpha',
53
+ task: { prompt: 'Fix the portal.', images: [] },
54
+ sessionId: null,
55
+ createdAt: '2026-01-01T00:00:00.000Z',
56
+ updatedAt: '2026-01-01T00:00:00.000Z',
57
+ movedAt: null,
58
+ ...overrides,
59
+ };
60
+ }
61
+
62
+ describe('lenses', () => {
63
+ const cards = [summary(), summary({ id: 'k-bbbbbb', workspace: '/w/beta' }), summary({ id: 'k-cccccc', workspace: null })];
64
+
65
+ test('a workspace is open → that lens; none → everything', () => {
66
+ expect(defaultLens('/w/alpha')).toBe('workspace');
67
+ expect(defaultLens(null)).toBe('all');
68
+ });
69
+
70
+ test('a lens filters and never moves', () => {
71
+ expect(lensCards(cards, 'all', '/w/alpha')).toHaveLength(3);
72
+ expect(lensCards(cards, 'workspace', '/w/alpha').map((entry) => entry.id)).toEqual(['k-aaaaaa']);
73
+ expect(lensCards(cards, 'unfiled', '/w/alpha').map((entry) => entry.id)).toEqual(['k-cccccc']);
74
+ // No workspace open means the workspace lens is empty, not "everything".
75
+ expect(lensCards(cards, 'workspace', null)).toEqual([]);
76
+ });
77
+
78
+ test('the counts let a chip say what is elsewhere', () => {
79
+ expect(lensCounts(cards, '/w/alpha')).toEqual({ all: 3, workspace: 1, unfiled: 1 });
80
+ expect(lensCounts(cards, null)).toEqual({ all: 3, workspace: 0, unfiled: 1 });
81
+ });
82
+ });
83
+
84
+ describe('stages drawn', () => {
85
+ const stages: Stage[] = defaultBoard('2026-01-01T00:00:00.000Z').stages;
86
+
87
+ test('a hidden stage with cards still renders', () => {
88
+ // Hiding quiets a lane; it must never make a card disappear.
89
+ const withReview = [...stages];
90
+ const drawn = visibleStages(withReview, [summary({ status: 'review' })]);
91
+ expect(drawn.map((stage) => stage.id)).toContain('review');
92
+ });
93
+
94
+ test('a hidden empty stage does not', () => {
95
+ expect(visibleStages(stages, [summary()]).map((stage) => stage.id)).not.toContain('review');
96
+ });
97
+
98
+ test('a card whose status matches no stage is Unplaced, not dropped', () => {
99
+ const orphans = unplacedCards(stages, [summary({ status: 'doing' })]);
100
+ expect(orphans.map((entry) => entry.status)).toEqual(['doing']);
101
+ });
102
+ });
103
+
104
+ describe('card face', () => {
105
+ test('priority clamps into P0..P4', () => {
106
+ expect(priorityLabel(0)).toBe('P0');
107
+ expect(priorityLabel(9)).toBe('P4');
108
+ expect(priorityLabel(-1)).toBe('P0');
109
+ });
110
+
111
+ test('the prompt preview says whether there is one, and how many images', () => {
112
+ expect(promptPreview(summary({ hasPrompt: false }))).toBe('no prompt');
113
+ expect(promptPreview(summary({ hasPrompt: true }))).toBe('prompt');
114
+ expect(promptPreview(summary({ hasPrompt: true, imageCount: 2 }))).toBe('prompt · 2 images');
115
+ });
116
+
117
+ test('a workspace reads as its last segment, and null reads as unfiled', () => {
118
+ expect(workspaceLabel('/Users/x/projects/kabmo')).toBe('kabmo');
119
+ expect(workspaceLabel('C:\\work\\alpha')).toBe('alpha');
120
+ expect(workspaceLabel(null)).toBe('unfiled');
121
+ });
122
+ });
123
+
124
+ describe('origin labels', () => {
125
+ const stage: Stage = { id: 'in_progress', label: 'In Progress', hidden: false, session: true };
126
+
127
+ test('each level names itself, so an override is visible before it is made', () => {
128
+ expect(originLabel('card', stage)).toBe('this card');
129
+ expect(originLabel('stage', stage)).toBe('stage: In Progress');
130
+ expect(originLabel('defaults', stage)).toBe('board default');
131
+ expect(originLabel('host', stage)).toBe('host default');
132
+ });
133
+
134
+ test('only a card-level value is an override', () => {
135
+ expect(isOverridden('card')).toBe(true);
136
+ expect(isOverridden('stage')).toBe(false);
137
+ });
138
+ });
139
+
140
+ describe('start work', () => {
141
+ const board = defaultBoard('2026-01-01T00:00:00.000Z');
142
+ const stage = board.stages.find((entry) => entry.id === 'in_progress');
143
+
144
+ test('omp gets the stage prompt as a system prompt and the task as the message', () => {
145
+ const resolved: ResolvedAgent = { ...resolveAgent(card(), stage, board), prompt: 'Work it.' };
146
+ const body = startWorkBody(card(), resolved);
147
+ expect(body.harness).toBe('omp-rpc');
148
+ expect(body.systemPrompt).toBe('Work it.');
149
+ expect(body.message).toBe('Fix the portal.');
150
+ expect(body.cwd).toBe('/w/alpha');
151
+ expect(body.accessMode).toBe('always-ask');
152
+ });
153
+
154
+ test('ACP gets both in the message, because session/new has no field for one', () => {
155
+ // The delivery is derived from the HARNESS, so the stage has to be the one
156
+ // that names an ACP agent — spreading `harness` alone would keep omp's
157
+ // `appended` delivery and quietly test the wrong branch.
158
+ const acpStage: Stage = { ...stage!, agent: { harness: 'claude', prompt: 'Review it.' } };
159
+ const resolved = resolveAgent(card(), acpStage, board);
160
+ expect(resolved.promptDelivery).toBe('prepended');
161
+ const body = startWorkBody(card(), resolved);
162
+ expect(body.systemPrompt).toBeUndefined();
163
+ expect(body.message).toContain('<stage_instructions>');
164
+ expect(body.message).toContain('Review it.');
165
+ expect(body.message.endsWith('Fix the portal.')).toBe(true);
166
+ });
167
+
168
+ test('a card with no workspace is refused before any request is built', () => {
169
+ expect(() => startWorkBody(card({ workspace: null }), resolveAgent(card(), stage, board))).toThrow(/workspace/i);
170
+ });
171
+
172
+ test('a refusal from the route is surfaced verbatim', async () => {
173
+ const resolved = resolveAgent(card(), stage, board);
174
+ const refused = await startWork(card(), resolved, async () => ({ error: 'Mock mode runs no agent process', code: 'mock_mode' }));
175
+ expect(refused).toEqual({ ok: false, error: 'Mock mode runs no agent process' });
176
+ });
177
+
178
+ test('an empty prompt never reaches the route', async () => {
179
+ const resolved = resolveAgent(card(), stage, board);
180
+ let called = false;
181
+ const refused = await startWork(card({ task: { prompt: ' ', images: [] } }), resolved, async () => {
182
+ called = true;
183
+ return { success: true, sessionId: 'x' };
184
+ });
185
+ expect(called).toBe(false);
186
+ expect(refused.ok).toBe(false);
187
+ });
188
+
189
+ test('the answered session id is what links the card', async () => {
190
+ const resolved = resolveAgent(card(), stage, board);
191
+ const started = await startWork(card(), resolved, async () => ({ success: true, sessionId: 'sess-42' }));
192
+ expect(started).toEqual({ ok: true, sessionId: 'sess-42' });
193
+ });
194
+
195
+ test('images ride the request in the shape the route takes', () => {
196
+ const resolved = resolveAgent(card(), stage, board);
197
+ const withImage = card({ task: { prompt: 'Look.', images: [{ name: 'a.png', mimeType: 'image/png', dataBase64: 'AAAA' }] } });
198
+ expect(startWorkBody(withImage, resolved).images).toEqual([{ data: 'AAAA', mimeType: 'image/png' }]);
199
+ });
200
+
201
+ test('a follow-up always prepends, because a live session cannot take a flag', () => {
202
+ const resolved: ResolvedAgent = { ...resolveAgent(card(), stage, board), prompt: 'Rules.' };
203
+ const body = followUpBody(card(), resolved) as { message: string };
204
+ expect(body.message).toContain('<stage_instructions>');
205
+ });
206
+
207
+ test('the model commands are separate verbs, model first', () => {
208
+ const resolved: ResolvedAgent = {
209
+ ...resolveAgent(card(), stage, board),
210
+ model: { provider: 'p', modelId: 'm' },
211
+ thinking: 'high',
212
+ };
213
+ expect(modelCommands(resolved)).toEqual([
214
+ { type: 'set_model', provider: 'p', modelId: 'm' },
215
+ { type: 'set_thinking_level', level: 'high' },
216
+ ]);
217
+ expect(modelCommands({ ...resolved, model: null, thinking: null })).toEqual([]);
218
+ });
219
+ });
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Starting work on a card: one call to the route the composer itself uses.
8
+ *
9
+ * `POST /api/agent/new` already does everything a chat's first send does — it
10
+ * resolves the model when the request names none (project default, then the
11
+ * persisted pick), applies `set_model`/`set_thinking_level`, spawns omp or an
12
+ * ACP harness, and runs the first prompt. So the board is not a second spawn
13
+ * path: it fills the request from `resolveAgent` and then records the session id
14
+ * the route answers with.
15
+ *
16
+ * That answer is why there is no pending-session heuristic here. `openNew()`
17
+ * returns nothing and the real id arrives later; this route returns it now, so
18
+ * the card is linked on the same response.
19
+ */
20
+
21
+ import type { Card, ResolvedAgent } from '../protocol';
22
+ import { dispatchText } from '../store/resolve';
23
+
24
+ /** What the route takes, built from a card and its resolved agent. */
25
+ export interface StartWorkBody {
26
+ type: 'prompt';
27
+ cwd: string;
28
+ harness: string;
29
+ message: string;
30
+ accessMode: string;
31
+ systemPrompt?: string;
32
+ provider?: string;
33
+ modelId?: string;
34
+ thinkingLevel?: string;
35
+ skills?: string[];
36
+ images?: { data: string; mimeType: string }[];
37
+ }
38
+
39
+ /**
40
+ * The request a card dispatches.
41
+ *
42
+ * `cwd` is the card's workspace. A card with none cannot be started — the
43
+ * alternative is a chat born in the server's own directory, which is a project
44
+ * nobody chose — so the caller refuses before building this.
45
+ */
46
+ export function startWorkBody(card: Card, resolved: ResolvedAgent): StartWorkBody {
47
+ if (!card.workspace) {
48
+ throw new Error('Pick a workspace for this card before starting work.');
49
+ }
50
+ const { systemPrompt, message } = dispatchText(resolved, card.task.prompt);
51
+ return {
52
+ type: 'prompt',
53
+ cwd: card.workspace,
54
+ harness: resolved.harness,
55
+ message,
56
+ accessMode: resolved.access,
57
+ ...(systemPrompt ? { systemPrompt } : {}),
58
+ ...(resolved.model ? { provider: resolved.model.provider, modelId: resolved.model.modelId } : {}),
59
+ ...(resolved.thinking ? { thinkingLevel: resolved.thinking } : {}),
60
+ ...(resolved.skills.length ? { skills: resolved.skills } : {}),
61
+ ...(card.task.images.length
62
+ ? { images: card.task.images.map((image) => ({ data: image.dataBase64, mimeType: image.mimeType })) }
63
+ : {}),
64
+ };
65
+ }
66
+
67
+ /** What the route answers. */
68
+ interface StartWorkAnswer {
69
+ success?: boolean;
70
+ sessionId?: string;
71
+ error?: string;
72
+ code?: string;
73
+ }
74
+
75
+ export type StartWorkOutcome = { ok: true; sessionId: string } | { ok: false; error: string };
76
+
77
+ /**
78
+ * Spawn the chat for a card.
79
+ *
80
+ * A refusal keeps the sentence the server wrote — `mock_mode`, a missing cwd, an
81
+ * over-long system prompt — because each names something the board cannot
82
+ * reconstruct, and a generic "could not start" would hide which.
83
+ */
84
+ export async function startWork(
85
+ card: Card,
86
+ resolved: ResolvedAgent,
87
+ post: (body: StartWorkBody) => Promise<StartWorkAnswer>,
88
+ ): Promise<StartWorkOutcome> {
89
+ let body: StartWorkBody;
90
+ try {
91
+ body = startWorkBody(card, resolved);
92
+ } catch (cause) {
93
+ return { ok: false, error: cause instanceof Error ? cause.message : String(cause) };
94
+ }
95
+ if (!body.message.trim()) return { ok: false, error: 'This card has no prompt to send.' };
96
+ const answer = await post(body);
97
+ if (answer.success === true && answer.sessionId) return { ok: true, sessionId: answer.sessionId };
98
+ return { ok: false, error: answer.error ?? 'The chat could not be started.' };
99
+ }
100
+
101
+ /**
102
+ * Continue a card's existing session.
103
+ *
104
+ * The stage prompt is PREPENDED here, because a live session's spawn flags are
105
+ * already fixed — the same sentence the card sheet shows.
106
+ */
107
+ export function followUpBody(card: Card, resolved: ResolvedAgent): Record<string, unknown> {
108
+ const { message } = dispatchText({ ...resolved, promptDelivery: 'prepended' }, card.task.prompt);
109
+ return {
110
+ type: 'prompt',
111
+ message,
112
+ ...(card.task.images.length
113
+ ? { images: card.task.images.map((image) => ({ data: image.dataBase64, mimeType: image.mimeType })) }
114
+ : {}),
115
+ };
116
+ }
117
+
118
+ /**
119
+ * The commands a follow-up applies before its prompt.
120
+ *
121
+ * Two commands, not one: `set_model` and `set_thinking_level` are separate RPC
122
+ * verbs, and the queue's delivery applies them in this order for the same
123
+ * reason — a thinking level is only meaningful against the model it will run on.
124
+ */
125
+ export function modelCommands(resolved: ResolvedAgent): Record<string, unknown>[] {
126
+ const commands: Record<string, unknown>[] = [];
127
+ if (resolved.model) {
128
+ commands.push({ type: 'set_model', provider: resolved.model.provider, modelId: resolved.model.modelId });
129
+ }
130
+ if (resolved.thinking) commands.push({ type: 'set_thinking_level', level: resolved.thinking });
131
+ return commands;
132
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The board's client state: one read, one invalidation topic, one lens.
8
+ *
9
+ * The snapshot comes from `openBoard` and is re-read when the plugin's own topic
10
+ * moves. The topic carries a REVISION, never the board, because two writers exist
11
+ * — this panel and the MCP child an agent talks to — and the only thing the
12
+ * panel can cheaply learn from another process is "something changed".
13
+ *
14
+ * The lens is per SESSION state (`useSessionState`), not component state: a
15
+ * plugin panel is unmounted whenever another view is on screen, so a lens kept in
16
+ * `useState` would reset every time the user glanced at Files.
17
+ */
18
+
19
+ import { useCallback, useEffect, useMemo, useState } from 'preact/hooks';
20
+ import { useRpc, useRealtime, useSessionState, usePanelInfo } from '@kabmo-labs/kabmo-ui';
21
+
22
+ import type { BoardRead, BoardSignal, CardSummary } from '../protocol';
23
+
24
+ /** The three lenses a board can show. `null` is the global bucket. */
25
+ export type Lens = 'all' | 'workspace' | 'unfiled';
26
+
27
+ /** Which cards the current lens keeps. */
28
+ export function lensCards(cards: readonly CardSummary[], lens: Lens, workspace: string | null): CardSummary[] {
29
+ if (lens === 'workspace') return workspace ? cards.filter((card) => card.workspace === workspace) : [];
30
+ if (lens === 'unfiled') return cards.filter((card) => card.workspace === null);
31
+ return [...cards];
32
+ }
33
+
34
+ /** The lens a board opens on: this workspace when one is open, else everything. */
35
+ export function defaultLens(workspace: string | null): Lens {
36
+ return workspace ? 'workspace' : 'all';
37
+ }
38
+
39
+ /** How many cards each lens holds, so the chips can say "9 elsewhere". */
40
+ export function lensCounts(cards: readonly CardSummary[], workspace: string | null): Record<Lens, number> {
41
+ return {
42
+ all: cards.length,
43
+ workspace: workspace ? cards.filter((card) => card.workspace === workspace).length : 0,
44
+ unfiled: cards.filter((card) => card.workspace === null).length,
45
+ };
46
+ }
47
+
48
+ export interface BoardState {
49
+ /** The board, or `{ exists: false }` when there is none yet. */
50
+ snapshot: BoardRead | null;
51
+ cards: CardSummary[];
52
+ lens: Lens;
53
+ setLens: (lens: Lens) => void;
54
+ counts: Record<Lens, number>;
55
+ isLoading: boolean;
56
+ /** A read refusal, or the server's sentence when the board cannot be read. */
57
+ error: string | null;
58
+ /** True while the plugin topic says the value may be behind. */
59
+ stale: boolean;
60
+ reload: () => void;
61
+ createBoard: () => Promise<void>;
62
+ /** A write that answers the fresh snapshot, so the panel does not wait for the topic. */
63
+ refreshAfter: <T>(work: () => Promise<T>) => Promise<T>;
64
+ }
65
+
66
+ /** Read the board, follow its topic, and keep the lens. */
67
+ export function useBoard(): BoardState {
68
+ const { workspacePath } = usePanelInfo();
69
+ const rpc = useRpc<Record<string, never>, BoardRead>('openBoard');
70
+ const init = useRpc<Record<string, never>, BoardRead>('initBoard');
71
+ const signal = useRealtime<BoardSignal>();
72
+ const [snapshot, setSnapshot] = useState<BoardRead | null>(null);
73
+ const [error, setError] = useState<string | null>(null);
74
+ const [isLoading, setIsLoading] = useState(true);
75
+ const [storedLens, setStoredLens] = useSessionState<Lens | null>('kanban.lens', null);
76
+
77
+ // A workspace is open → that lens; none → everything. A stored choice wins
78
+ // only while it still names something, so a lens picked in one workspace does
79
+ // not hide the board in a session that has no workspace at all.
80
+ const lens: Lens = storedLens ?? defaultLens(workspacePath);
81
+ const setLens = useCallback((next: Lens) => setStoredLens(next), [setStoredLens]);
82
+
83
+ const read = useCallback(async () => {
84
+ const outcome = await rpc.call({});
85
+ if (outcome.ok) {
86
+ // Absence is a value (`exists: false`), so this branch is the only place
87
+ // the panel decides between the board and the Create screen.
88
+ setSnapshot(outcome.value as BoardRead);
89
+ setError(null);
90
+ } else {
91
+ setError(outcome.error.message);
92
+ }
93
+ setIsLoading(false);
94
+ }, [rpc]);
95
+
96
+ useEffect(() => {
97
+ void read();
98
+ // `read` is stable per method id; a mount is the only trigger here.
99
+ // eslint-disable-next-line react-hooks/exhaustive-deps
100
+ }, []);
101
+
102
+ // The topic moves for THIS panel's writes and for an agent's (the watcher).
103
+ useEffect(() => {
104
+ if (!signal.value) return;
105
+ void read();
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ }, [signal.value?.revision]);
108
+
109
+ const createBoard = useCallback(async () => {
110
+ const outcome = await init.call({});
111
+ if (outcome.ok) {
112
+ setSnapshot(outcome.value as BoardRead);
113
+ setError(null);
114
+ } else {
115
+ setError(outcome.error.message);
116
+ }
117
+ }, [init]);
118
+
119
+ const refreshAfter = useCallback(
120
+ async <T,>(work: () => Promise<T>): Promise<T> => {
121
+ const value = await work();
122
+ await read();
123
+ return value;
124
+ },
125
+ [read],
126
+ );
127
+
128
+ const boardCards = snapshot?.exists ? snapshot.cards : [];
129
+ const cards = useMemo(() => lensCards(boardCards, lens, workspacePath), [boardCards, lens, workspacePath]);
130
+ const counts = useMemo(
131
+ () => lensCounts(boardCards, workspacePath),
132
+ [boardCards, workspacePath],
133
+ );
134
+
135
+ return {
136
+ snapshot,
137
+ cards,
138
+ lens,
139
+ setLens,
140
+ counts,
141
+ isLoading,
142
+ error,
143
+ stale: signal.stale,
144
+ reload: () => void read(),
145
+ createBoard,
146
+ refreshAfter,
147
+ };
148
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * One card's detail, read on demand.
8
+ *
9
+ * The board's snapshot is deliberately slim (no prompt, no images), so opening a
10
+ * card is its own read. That keeps a 500-card board cheap and still gives the
11
+ * sheet everything it needs — including the stage the card belongs to and the
12
+ * agent that stage resolves to.
13
+ */
14
+
15
+ import { useCallback, useState } from 'preact/hooks';
16
+ import { useRpc } from '@kabmo-labs/kabmo-ui';
17
+
18
+ import type { Card, ResolvedAgent, Stage } from '../protocol';
19
+
20
+ /** What `readCard` answers. */
21
+ export interface CardDetailAnswer {
22
+ card: Card;
23
+ board: { stages: Stage[]; defaults: Record<string, unknown> };
24
+ stage: Stage | null;
25
+ agent: ResolvedAgent;
26
+ }
27
+
28
+ /** The card on screen, and the read that fetched it. */
29
+ export function useCardDetail(): {
30
+ card: Card | null;
31
+ agent: ResolvedAgent | null;
32
+ error: string | null;
33
+ load: (id: string) => Promise<void>;
34
+ clear: () => void;
35
+ } {
36
+ const rpc = useRpc<{ id: string }, CardDetailAnswer>('readCard');
37
+ const [card, setCard] = useState<Card | null>(null);
38
+ const [agent, setAgent] = useState<ResolvedAgent | null>(null);
39
+ const [error, setError] = useState<string | null>(null);
40
+
41
+ const load = useCallback(
42
+ async (id: string) => {
43
+ const outcome = await rpc.call({ id });
44
+ if (outcome.ok) {
45
+ const answer = outcome.value as CardDetailAnswer;
46
+ setCard(answer.card);
47
+ setAgent(answer.agent);
48
+ setError(null);
49
+ } else {
50
+ // The card vanished under us (an agent deleted it): say so and close.
51
+ setCard(null);
52
+ setAgent(null);
53
+ setError(outcome.error.message);
54
+ }
55
+ },
56
+ [rpc],
57
+ );
58
+
59
+ return {
60
+ card,
61
+ agent,
62
+ error,
63
+ load,
64
+ clear: () => {
65
+ setCard(null);
66
+ setAgent(null);
67
+ setError(null);
68
+ },
69
+ };
70
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The board's writes, in one place so the panel never builds a call by hand.
8
+ *
9
+ * Two kinds of write live here and they are deliberately different:
10
+ *
11
+ * - **Board writes** go through the plugin's own RPC, which takes the file lock
12
+ * and answers the fresh snapshot.
13
+ * - **Starting work** goes to `/api/agent/new`, the route the chat composer
14
+ * itself uses. The board does not spawn anything: it fills the request from
15
+ * `resolveAgent` and links the session id the route answers with.
16
+ *
17
+ * A refusal is returned, never thrown: the sheet shows the server's own sentence
18
+ * ("This card changed on disk", "Pick a workspace") instead of a stack trace.
19
+ */
20
+
21
+ import { useCallback } from 'preact/hooks';
22
+ import { useRpc } from '@kabmo-labs/kabmo-ui';
23
+
24
+ import type { Card, ResolvedAgent, Stage } from '../protocol';
25
+ import { startWork, type StartWorkBody, type StartWorkOutcome } from './start-work';
26
+
27
+ /** What a write answers. */
28
+ export type WriteOutcome<T> = { ok: true; value: T } | { ok: false; error: string };
29
+
30
+ /** The answer `moveCard` gives, which carries the Start-work hint. */
31
+ export interface MoveAnswer {
32
+ card: Card;
33
+ next?: 'start_work_required';
34
+ revision: number;
35
+ }
36
+
37
+ /** The POST the panel makes to spawn a chat. */
38
+ async function postStartWork(body: StartWorkBody): Promise<Record<string, unknown>> {
39
+ const response = await fetch('/api/agent/new', {
40
+ method: 'POST',
41
+ headers: { 'content-type': 'application/json' },
42
+ credentials: 'same-origin',
43
+ body: JSON.stringify(body),
44
+ });
45
+ return (await response.json().catch(() => ({}))) as Record<string, unknown>;
46
+ }
47
+
48
+ /** The RPC methods the panel calls, with the outcome flattened to one shape. */
49
+ export function useWrites(onChanged: () => void) {
50
+ const create = useRpc('createCard');
51
+ const update = useRpc('updateCard');
52
+ const move = useRpc('moveCard');
53
+ const remove = useRpc('deleteCard');
54
+ const link = useRpc('linkSession');
55
+ const claim = useRpc('claimCard');
56
+ const stages = useRpc('saveStages');
57
+ const defaults = useRpc('saveDefaults');
58
+
59
+ const settle = useCallback(
60
+ async <T,>(outcome: { ok: boolean; value?: unknown; error?: { message: string } }): Promise<WriteOutcome<T>> => {
61
+ if (outcome.ok) {
62
+ onChanged();
63
+ return { ok: true, value: outcome.value as T };
64
+ }
65
+ return { ok: false, error: outcome.error?.message ?? 'The board refused that write.' };
66
+ },
67
+ [onChanged],
68
+ );
69
+
70
+ return {
71
+ createCard: useCallback(
72
+ async (input: { title: string; status?: string; workspace?: string | null; priority?: number }) =>
73
+ settle<{ card: Card }>(await create.call(input)),
74
+ [create, settle],
75
+ ),
76
+ updateCard: useCallback(
77
+ async (id: string, patch: Record<string, unknown>, baseUpdatedAt?: string) =>
78
+ settle<{ card: Card }>(await update.call({ id, patch, baseUpdatedAt })),
79
+ [settle, update],
80
+ ),
81
+ moveCard: useCallback(
82
+ async (id: string, status: string, baseUpdatedAt?: string) =>
83
+ settle<MoveAnswer>(await move.call({ id, status, baseUpdatedAt })),
84
+ [move, settle],
85
+ ),
86
+ deleteCard: useCallback(async (id: string) => settle<unknown>(await remove.call({ id })), [remove, settle]),
87
+ linkSession: useCallback(
88
+ async (id: string, sessionId: string | null) => settle<{ card: Card }>(await link.call({ id, sessionId })),
89
+ [link, settle],
90
+ ),
91
+ claimCard: useCallback(
92
+ async (id: string, sessionId?: string) => settle<{ card: Card }>(await claim.call({ id, sessionId })),
93
+ [claim, settle],
94
+ ),
95
+ saveStages: useCallback(
96
+ async (next: Stage[]) => settle<{ board: { stages: Stage[] } }>(await stages.call({ stages: next })),
97
+ [settle, stages],
98
+ ),
99
+ saveDefaults: useCallback(
100
+ async (next: Record<string, unknown>) => settle<{ board: unknown }>(await defaults.call({ defaults: next })),
101
+ [defaults, settle],
102
+ ),
103
+ /**
104
+ * Start the card's chat, then link it.
105
+ *
106
+ * The link is a SECOND write and it is deliberate: the spawn already
107
+ * happened, so a failed link must not read as a failed start. The sentence
108
+ * names which half landed.
109
+ */
110
+ startWork: useCallback(
111
+ async (card: Card, resolved: ResolvedAgent): Promise<StartWorkOutcome> => {
112
+ const started = await startWork(card, resolved, postStartWork);
113
+ if (!started.ok) return started;
114
+ const linked = await settle<{ card: Card }>(await claim.call({ id: card.id, sessionId: started.sessionId }));
115
+ if (!linked.ok) {
116
+ return { ok: false, error: `The chat started (${started.sessionId.slice(0, 8)}…) but the card was not linked: ${linked.error}` };
117
+ }
118
+ return started;
119
+ },
120
+ [claim, settle],
121
+ ),
122
+ };
123
+ }