@kabmo-labs/kabmo 0.41.0 → 0.42.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 (305) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +533 -518
  3. package/dist/client/static/js/{CsvGrid-60njj97j.js → CsvGrid-20k047ht.js} +2 -2
  4. package/dist/client/static/js/{DocxView-rsv0j46a.js → DocxView-qpvhfcmg.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-n2g5df3a.js → DrawioView-178skky8.js} +2 -2
  6. package/dist/client/static/js/ImageView-460th5qa.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-5cv0dty8.js +2 -0
  8. package/dist/client/static/js/Modal-wks6p4r5.js +38 -0
  9. package/dist/client/static/js/{PdfView-1r7a0qkp.js → PdfView-y51g03nr.js} +1 -1
  10. package/dist/client/static/js/SessionsView-rsmvn7ks.js +1 -0
  11. package/dist/client/static/js/{SheetView-bt5pp042.js → SheetView-z7yvb05v.js} +25 -25
  12. package/dist/client/static/js/{SvgPreview-vfmqgmrx.js → SvgPreview-yehgzhem.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-8k5hk1yx.js → abnfDiagram-O67JEVCF-6zxpcy8b.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +1 -0
  15. package/dist/client/static/js/architectureDiagram-NJMV4G6O-m98sgh3c.js +36 -0
  16. package/dist/client/static/js/{astro-0rh34hha.js → astro-nn7xg0we.js} +1 -1
  17. package/dist/client/static/js/bash-fjzhxy10.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-04sbtdth.js → blockDiagram-BEXU5L5S-cp7rervg.js} +5 -5
  19. package/dist/client/static/js/c-wqtyezvw.js +1 -0
  20. package/dist/client/static/js/c4Diagram-YGBWAQC7-t31recqm.js +38 -0
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-18cc0bsb.js → classDiagram-v2-NBCMYWYE-fy8x3dkx.js} +5 -5
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-dk683zvp.js → cose-bilkent-JH36ORCC-va7ybm9e.js} +1 -1
  23. package/dist/client/static/js/cpp-y0nzwner.js +1 -0
  24. package/dist/client/static/js/css-a13jmmnc.js +1 -0
  25. package/dist/client/static/js/css-n2waj098.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-m2sx8d8s.js → cynefinDiagram-VND7K2PF-4k0k429c.js} +2 -2
  28. package/dist/client/static/js/{dagre-6A5THRUB-qf3pr59p.js → dagre-6A5THRUB-ykdhxq6t.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-twnz23mt.js → diagram-22UHCM2B-5nvwx7b6.js} +8 -8
  30. package/dist/client/static/js/{diagram-3UASUU5V-417bas6t.js → diagram-3UASUU5V-hc7zsjgw.js} +1 -1
  31. package/dist/client/static/js/diagram-ATOU4E4O-97ae07y7.js +3 -0
  32. package/dist/client/static/js/diagram-CDSNMT55-b56nnbbs.js +30 -0
  33. package/dist/client/static/js/{diagram-MLGK6HIB-7a0h1hs3.js → diagram-MLGK6HIB-37rygr9k.js} +1 -1
  34. package/dist/client/static/js/{diagram-MPIPVDR6-w75bftmd.js → diagram-MPIPVDR6-wv3vhhfk.js} +2 -2
  35. package/dist/client/static/js/{dockerfile-g5qbaeq3.js → dockerfile-0efb1z6e.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-vdzm3tsv.js → ebnfDiagram-ZINNZB2B-13fv7vxg.js} +1 -1
  37. package/dist/client/static/js/{elixir-gpez1k9m.js → elixir-mabagxwa.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-2fsbb484.js → elk-276RUBZZ-xam60ktz.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-vnkztq7d.js → erDiagram-OPXOYQCR-24ctv2ee.js} +6 -6
  40. package/dist/client/static/js/{erlang-jqqa3ehb.js → erlang-zwy7cqdk.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-pbvcch52.js → ganttDiagram-FUAMR5RP-766a8fqw.js} +2 -2
  44. package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +1 -0
  45. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-dkvktvzr.js → gitGraphDiagram-X574FWY7-fmwjkgh6.js} +2 -2
  46. package/dist/client/static/js/graphql-gvb7e2eb.js +1 -0
  47. package/dist/client/static/js/html-bwyt0ayy.js +1 -0
  48. package/dist/client/static/js/{index-rc8wrs2a.js → index-03pyvmcz.js} +2 -2
  49. package/dist/client/static/js/index-13dr1t1r.js +314 -0
  50. package/dist/client/static/js/{index-rebnv57p.js → index-13xbwcbz.js} +2 -2
  51. package/dist/client/static/js/{index-pbsm2vw7.js → index-1c0pnsjd.js} +2 -2
  52. package/dist/client/static/js/index-1rxa9zxp.js +1 -0
  53. package/dist/client/static/js/{index-c6kx7s6a.js → index-2hpy58d0.js} +2 -2
  54. package/dist/client/static/js/{index-f8pq132s.js → index-2x9eqztp.js} +1 -1
  55. package/dist/client/static/js/{index-pn91shfp.js → index-4cncqz8j.js} +2 -2
  56. package/dist/client/static/js/index-4j8rgr4p.js +1 -0
  57. package/dist/client/static/js/{index-x2kb1kx5.js → index-4mstdh41.js} +3 -3
  58. package/dist/client/static/js/index-4z4ax55k.js +12 -0
  59. package/dist/client/static/js/{index-55hq7tnj.js → index-6ge6gk9w.js} +1 -1
  60. package/dist/client/static/js/{index-re1xz433.js → index-7t63akyt.js} +1 -1
  61. package/dist/client/static/js/{index-zye9309h.js → index-8b3t2y77.js} +2 -2
  62. package/dist/client/static/js/index-8hgm0abr.js +474 -0
  63. package/dist/client/static/js/index-8jqawh3r.js +2 -0
  64. package/dist/client/static/js/index-95en3p3g.js +9 -0
  65. package/dist/client/static/js/{index-rdqn92tc.js → index-97qst4k9.js} +2 -2
  66. package/dist/client/static/js/{index-xfa5hswh.js → index-9vdbnvmk.js} +1 -1
  67. package/dist/client/static/js/{index-zfykeg7x.js → index-a9t9gdew.js} +9 -9
  68. package/dist/client/static/js/{index-ds6a2cx7.js → index-b4y5g48d.js} +5 -5
  69. package/dist/client/static/js/{index-hz177dr2.js → index-czagykbq.js} +2 -2
  70. package/dist/client/static/js/{index-yq9vnd1y.js → index-dfqmwm7j.js} +2 -2
  71. package/dist/client/static/js/{index-tgper3yy.js → index-dydwcp3n.js} +2 -2
  72. package/dist/client/static/js/{index-0c6vpk89.js → index-e1yz59fa.js} +2 -2
  73. package/dist/client/static/js/{index-ce4vytm6.js → index-e6any867.js} +2 -2
  74. package/dist/client/static/js/{index-j5ram1ve.js → index-ejdnjh5c.js} +2 -2
  75. package/dist/client/static/js/index-f4vr1c6e.css +1 -0
  76. package/dist/client/static/js/{index-cytks03p.js → index-feffxxss.js} +2 -2
  77. package/dist/client/static/js/{index-6fx2t6y7.js → index-grczkttn.js} +12 -12
  78. package/dist/client/static/js/{index-s78n0dtv.js → index-hga3e13s.js} +2 -2
  79. package/dist/client/static/js/{index-ajjq0b8y.js → index-hw14rhen.js} +2 -2
  80. package/dist/client/static/js/index-hzwr5fm9.js +4 -0
  81. package/dist/client/static/js/{index-sj4y8kj2.js → index-j17h4z6f.js} +2 -2
  82. package/dist/client/static/js/{index-a4ed3mks.js → index-ka2rc2cr.js} +5 -5
  83. package/dist/client/static/js/{index-djv15k5s.js → index-ktbrmp29.js} +2 -2
  84. package/dist/client/static/js/{index-3rymer2w.js → index-nbexks3x.js} +1 -1
  85. package/dist/client/static/js/{index-ngk9h0v9.js → index-nh29fkk9.js} +2 -2
  86. package/dist/client/static/js/{index-gn92c6hp.js → index-p0ez6hqd.js} +2 -2
  87. package/dist/client/static/js/{index-e7yf273s.js → index-pkes9492.js} +2 -2
  88. package/dist/client/static/js/{index-fg965t62.js → index-pysqpc5n.js} +2 -2
  89. package/dist/client/static/js/index-qj34r6d0.js +1 -0
  90. package/dist/client/static/js/{index-ntcqyqd5.js → index-qx6x4z0y.js} +2 -2
  91. package/dist/client/static/js/{index-agdbjh5k.js → index-r8cc80w5.js} +2 -2
  92. package/dist/client/static/js/{index-9dnkfpx4.js → index-rab39785.js} +2 -2
  93. package/dist/client/static/js/{index-haaz8t7e.js → index-sk9ej289.js} +2 -2
  94. package/dist/client/static/js/{index-9fnzcg2x.js → index-sq3r1xhf.js} +2 -2
  95. package/dist/client/static/js/{index-pfbyfab5.js → index-sx809d6d.js} +2 -2
  96. package/dist/client/static/js/{index-7w3gqw2b.js → index-sz3mxjvy.js} +1 -1
  97. package/dist/client/static/js/{index-4jk8ngjg.js → index-tqycj126.js} +2 -2
  98. package/dist/client/static/js/{index-0xaz2eyv.js → index-vcn1kcpy.js} +3 -3
  99. package/dist/client/static/js/{index-2z9wrb46.js → index-x7f5ysch.js} +2 -2
  100. package/dist/client/static/js/index-xe5cqwnf.js +1 -0
  101. package/dist/client/static/js/index-xxe52zrm.js +2 -0
  102. package/dist/client/static/js/{index-amawahyh.js → index-yvxa7hd8.js} +2 -2
  103. package/dist/client/static/js/{index-e6qjfcz9.js → index-z6kpc98a.js} +1 -1
  104. package/dist/client/static/js/{index-yzg9mbsv.js → index-zjydzxhm.js} +1 -1
  105. package/dist/client/static/js/{index-ne131hmw.js → index-zvazj4va.js} +2 -2
  106. package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +1 -0
  107. package/dist/client/static/js/{infoDiagram-VRGFBTTK-mh6yks62.js → infoDiagram-VRGFBTTK-tqytmzp1.js} +1 -1
  108. package/dist/client/static/js/ini-2gvjwh83.js +1 -0
  109. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-hnfqppnv.js → ishikawaDiagram-OU5B5YK6-rp77ff6m.js} +1 -1
  110. package/dist/client/static/js/java-1xwcq79s.js +1 -0
  111. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-s4nv1f3q.js → journeyDiagram-ZHPQQLJL-c7bxrhf1.js} +2 -2
  112. package/dist/client/static/js/json-4pqjabgq.js +1 -0
  113. package/dist/client/static/js/jsx-wcsss15s.js +1 -0
  114. package/dist/client/static/js/{julia-yre4bxb9.js → julia-2eekpjq8.js} +1 -1
  115. package/dist/client/static/js/{kanban-definition-PNTS6WVX-t8kbfefp.js → kanban-definition-PNTS6WVX-j2pxewqq.js} +5 -5
  116. package/dist/client/static/js/lua-h7vjcn0h.js +1 -0
  117. package/dist/client/static/js/markdown-f30jjjh9.js +1 -0
  118. package/dist/client/static/js/{mermaid.core-0784021p.js → mermaid.core-cqqe1krg.js} +6 -6
  119. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-swkkze8c.js → mindmap-definition-NLK3R4M7-s03k32p9.js} +5 -5
  120. package/dist/client/static/js/one-dark-pro-9tt0a020.js +1 -0
  121. package/dist/client/static/js/one-light-5fg4r0ra.js +1 -0
  122. package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +1 -0
  123. package/dist/client/static/js/{pegDiagram-GJSIUBJH-jqayzh7z.js → pegDiagram-GJSIUBJH-dfg2j0zc.js} +1 -1
  124. package/dist/client/static/js/{perl-weeskn1v.js → perl-5vxax0nr.js} +1 -1
  125. package/dist/client/static/js/{php-vf3045p9.js → php-hgrgdq63.js} +1 -1
  126. package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +1 -0
  127. package/dist/client/static/js/{pieDiagram-5QR66LMP-w03a65ky.js → pieDiagram-5QR66LMP-pshd1j79.js} +1 -1
  128. package/dist/client/static/js/properties-ymexza6q.js +1 -0
  129. package/dist/client/static/js/python-31ycwa66.js +1 -0
  130. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-2j7sfa9s.js → quadrantDiagram-O4NWA36T-cvvvmtk2.js} +4 -4
  131. package/dist/client/static/js/r-t2nne4xp.js +1 -0
  132. package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +1 -0
  133. package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +1 -0
  134. package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +1 -0
  135. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +1 -0
  136. package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +1 -0
  137. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-jtkkgy34.js → railroadDiagram-XR7U4H2S-h53p3sha.js} +1 -1
  138. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-t85ckjdb.js → requirementDiagram-PLB6GJNP-bdv2fkxd.js} +4 -4
  139. package/dist/client/static/js/{ruby-1a2ryzy6.js → ruby-8pxcn21w.js} +1 -1
  140. package/dist/client/static/js/{rust-736r0f0v.js → rust-j80dxgjg.js} +1 -1
  141. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-5pfkw8ne.js → sankeyDiagram-IPEJSGJF-xqnnvmhy.js} +2 -2
  142. package/dist/client/static/js/{sass-tq4vw7hd.js → sass-bm32bb5k.js} +1 -1
  143. package/dist/client/static/js/{scss-x7ddw6gb.js → scss-e2dndbfa.js} +1 -1
  144. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-55vs9zv5.js → sequenceDiagram-PO4LG4MO-3p67305f.js} +10 -10
  145. package/dist/client/static/js/{sizeCapture-INFHLROL-pzqqd7f4.js → sizeCapture-INFHLROL-f87525h7.js} +1 -1
  146. package/dist/client/static/js/sql-bwnasywx.js +1 -0
  147. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-6nhrph8n.js → stateDiagram-v2-GCMORJYK-e5st1fy3.js} +6 -6
  148. package/dist/client/static/js/{svelte-0hv6pak2.js → svelte-ztkaww47.js} +1 -1
  149. package/dist/client/static/js/{swimlanes-2SLR337P-6tcnxfbv.js → swimlanes-2SLR337P-ceghkbez.js} +1 -1
  150. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-vc8hvfya.js +8 -0
  151. package/dist/client/static/js/{timeline-definition-EJHVYXUP-1dz46nt5.js → timeline-definition-EJHVYXUP-f7evs443.js} +2 -2
  152. package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +1 -0
  153. package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +1 -0
  154. package/dist/client/static/js/tsx-zfy727zs.js +1 -0
  155. package/dist/client/static/js/typescript-p3syh43m.js +1 -0
  156. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-b3jfveq6.js → usecaseDiagram-POWQR4AR-0gpn21p7.js} +27 -27
  157. package/dist/client/static/js/{vennDiagram-UO4OBE2U-dnc3jqvp.js → vennDiagram-UO4OBE2U-4spzy428.js} +1 -1
  158. package/dist/client/static/js/{vue-zccj3qa5.js → vue-xm1dxpmy.js} +1 -1
  159. package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +1 -0
  160. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-466m8400.js → wardleyDiagram-VNRHLVJA-745xr2pa.js} +4 -4
  161. package/dist/client/static/js/xml-4enq788a.js +1 -0
  162. package/dist/client/static/js/xychartDiagram-PMCCYNJV-7dr9qwx5.js +7 -0
  163. package/dist/client/static/js/yaml-pjtt3jsc.js +1 -0
  164. package/package.json +1 -1
  165. package/src/client/components/common/batch-selection/folder-state.ts +2 -2
  166. package/src/client/components/common/server-control/Panel.tsx +16 -5
  167. package/src/client/components/common/server-control/index.test.tsx +63 -9
  168. package/src/client/components/common/session-row/TrailingSlot.tsx +8 -0
  169. package/src/client/components/common/session-row/index.tsx +16 -9
  170. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -1
  171. package/src/client/components/layout/session-sidebar/ClassicView.tsx +13 -0
  172. package/src/client/components/layout/session-sidebar/HarnessFilter.tsx +175 -0
  173. package/src/client/components/layout/session-sidebar/SessionList.tsx +9 -1
  174. package/src/client/components/layout/session-sidebar/SessionsView.tsx +6 -0
  175. package/src/client/components/layout/session-sidebar/harness-filter.test.tsx +173 -0
  176. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +63 -18
  177. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +1 -1
  178. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +21 -12
  179. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -1
  180. package/src/client/components/layout/session-sidebar/modern/index.tsx +11 -2
  181. package/src/client/components/layout/session-sidebar/modern/search-field.test.tsx +96 -0
  182. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +3 -0
  183. package/src/client/components/layout/session-sidebar/variant-props.ts +7 -0
  184. package/src/client/components/mobile/SessionSidebar.tsx +14 -25
  185. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +19 -0
  186. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -1
  187. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +1 -1
  188. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.image.test.ts +147 -0
  189. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +51 -83
  190. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +44 -63
  191. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ReadDirectory.tsx +72 -0
  192. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ReadImage.tsx +51 -0
  193. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/read-test-util.ts +91 -0
  194. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.test.ts +80 -62
  195. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.tsx +15 -33
  196. package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +1 -1
  197. package/src/client/components/workspace/terminal-panel/copy.test.ts +179 -0
  198. package/src/client/components/workspace/terminal-panel/copy.ts +76 -0
  199. package/src/client/components/workspace/terminal-panel/mount.ts +13 -0
  200. package/src/client/data/settings/omp-schema.json +39 -18
  201. package/src/client/hooks/chat/omp/pending-child.test.ts +1 -1
  202. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +61 -0
  203. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +37 -39
  204. package/src/client/hooks/chat/omp/sidebar-filter.ts +62 -0
  205. package/src/client/hooks/chat/timeline/session-changes.test.ts +85 -0
  206. package/src/client/hooks/chat/timeline/session-changes.ts +8 -5
  207. package/src/client/hooks/shell/servers.ts +60 -2
  208. package/src/client/hooks/ui/updates/mobile-flow.ts +56 -0
  209. package/src/client/tailwind.css +58 -0
  210. package/src/server/lib/harness/acp/commands.test.ts +1 -0
  211. package/src/server/lib/harness/acp/commands.ts +12 -4
  212. package/src/server/lib/harness/acp/replay-transcript.ts +32 -13
  213. package/src/server/lib/harness/acp/session-transcript.server.test.ts +162 -0
  214. package/src/server/lib/harness/acp/session-transcript.server.ts +350 -0
  215. package/src/server/lib/harness/acp/session.ts +6 -1
  216. package/src/server/lib/harness/schema.server.ts +18 -0
  217. package/src/server/lib/harness/spawn.server.ts +14 -1
  218. package/src/server/lib/models/provider-icon-fetch.ts +2 -2
  219. package/src/server/lib/models/provider-icon-parse.test.ts +0 -12
  220. package/src/server/lib/models/provider-icon-parse.ts +0 -8
  221. package/src/server/lib/omp/rpc/frame-fold.test.ts +16 -1
  222. package/src/server/lib/omp/rpc/frame-fold.ts +17 -4
  223. package/src/server/lib/omp/session/blobs.server.test.ts +34 -0
  224. package/src/server/lib/omp/session/blobs.server.ts +8 -3
  225. package/src/server/lib/omp/session/delete.server.ts +4 -0
  226. package/src/server/lib/omp/session/sidebar-activity.server.test.ts +2 -1
  227. package/src/server/routes/agent/harness-command.test.ts +71 -0
  228. package/src/server/routes/agent/harness-command.ts +27 -13
  229. package/src/server/routes/chat/imported.ts +5 -2
  230. package/src/server/routes/chat/live-meta.ts +42 -0
  231. package/src/server/routes/chat/session.test.ts +110 -0
  232. package/src/server/routes/chat/session.ts +31 -34
  233. package/src/shared/lib/chat/transcript-rows.ts +22 -0
  234. package/src/shared/lib/fs/file-kind.test.ts +46 -3
  235. package/src/shared/lib/fs/file-kind.ts +40 -9
  236. package/src/shared/lib/omp/config/schema-releases.test.ts +29 -0
  237. package/src/shared/lib/workspace/harness-filter.test.ts +89 -0
  238. package/src/shared/lib/workspace/harness-filter.ts +75 -0
  239. package/src/{client/lib → shared/lib/workspace}/session-tree.test.ts +1 -1
  240. package/src/shared/lib/workspace/session-visibility.test.ts +71 -0
  241. package/src/shared/lib/workspace/session-visibility.ts +48 -23
  242. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +64 -23
  243. package/src/shared/lib/workspace/sidebar-filter-row.ts +89 -31
  244. package/dist/client/static/js/ImageView-t330jx6y.js +0 -1
  245. package/dist/client/static/js/LayoutWrapper-qp6nsw65.js +0 -2
  246. package/dist/client/static/js/Modal-sbya4ahp.js +0 -38
  247. package/dist/client/static/js/SessionsView-yqs5m8tj.js +0 -1
  248. package/dist/client/static/js/architecture-7GRP2DOG-1wqga929.js +0 -1
  249. package/dist/client/static/js/architectureDiagram-NJMV4G6O-7jcb7fgy.js +0 -36
  250. package/dist/client/static/js/bash-vv2ysp0a.js +0 -1
  251. package/dist/client/static/js/c-67jyc7sg.js +0 -1
  252. package/dist/client/static/js/c4Diagram-YGBWAQC7-vwac9za0.js +0 -38
  253. package/dist/client/static/js/cpp-crfbnwv8.js +0 -1
  254. package/dist/client/static/js/css-2re5mbea.js +0 -1
  255. package/dist/client/static/js/css-983fbv00.js +0 -1
  256. package/dist/client/static/js/cynefin-OW5HDTMX-j2dpdgkh.js +0 -1
  257. package/dist/client/static/js/diagram-ATOU4E4O-n63cpdnx.js +0 -3
  258. package/dist/client/static/js/diagram-CDSNMT55-v86p14dd.js +0 -30
  259. package/dist/client/static/js/eventmodeling-NTZA5JFV-xjvjawd3.js +0 -1
  260. package/dist/client/static/js/flowDiagram-KWPJA3E3-j21f2bfg.js +0 -1
  261. package/dist/client/static/js/gitGraph-4MIJSDKK-r0zbk95f.js +0 -1
  262. package/dist/client/static/js/graphql-npbd9fdx.js +0 -1
  263. package/dist/client/static/js/html-1cpe2xc8.js +0 -1
  264. package/dist/client/static/js/index-1sw00wm0.js +0 -2
  265. package/dist/client/static/js/index-7fwppdkn.js +0 -1
  266. package/dist/client/static/js/index-ae91g8ka.js +0 -9
  267. package/dist/client/static/js/index-b6cyn4hr.js +0 -314
  268. package/dist/client/static/js/index-efn233xp.js +0 -4
  269. package/dist/client/static/js/index-esx3zwnt.js +0 -1
  270. package/dist/client/static/js/index-fbbp5cwj.js +0 -2
  271. package/dist/client/static/js/index-g1cggqgx.js +0 -12
  272. package/dist/client/static/js/index-ghsdzs4m.js +0 -1
  273. package/dist/client/static/js/index-gs7ytgdw.js +0 -474
  274. package/dist/client/static/js/index-jqs23cc7.css +0 -1
  275. package/dist/client/static/js/index-qjsy6p86.js +0 -1
  276. package/dist/client/static/js/info-A6RAGUB7-a8xap43w.js +0 -1
  277. package/dist/client/static/js/ini-df5bw23e.js +0 -1
  278. package/dist/client/static/js/java-8j33rj1p.js +0 -1
  279. package/dist/client/static/js/json-g5ggnd94.js +0 -1
  280. package/dist/client/static/js/jsx-f6p72qpc.js +0 -1
  281. package/dist/client/static/js/lua-bahx6qze.js +0 -1
  282. package/dist/client/static/js/markdown-9dhg1fax.js +0 -1
  283. package/dist/client/static/js/one-dark-pro-h5tmw145.js +0 -1
  284. package/dist/client/static/js/one-light-x7vj1pxr.js +0 -1
  285. package/dist/client/static/js/packet-AYTQ26CC-b5bvg6v1.js +0 -1
  286. package/dist/client/static/js/pie-WAS4IAKB-77ee73zg.js +0 -1
  287. package/dist/client/static/js/properties-49mfnee4.js +0 -1
  288. package/dist/client/static/js/python-qb69wp1s.js +0 -1
  289. package/dist/client/static/js/r-s3mf2tch.js +0 -1
  290. package/dist/client/static/js/radar-RG4KPBEZ-cp79xtvb.js +0 -1
  291. package/dist/client/static/js/railroad-74A4TZTK-dcpgqhcb.js +0 -1
  292. package/dist/client/static/js/railroad-abnf-HS5TGJTU-qasqv686.js +0 -1
  293. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e46908rd.js +0 -1
  294. package/dist/client/static/js/railroad-peg-WCYAUIDC-7009t6bk.js +0 -1
  295. package/dist/client/static/js/sql-aczp05f2.js +0 -1
  296. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-7xrkrkpa.js +0 -8
  297. package/dist/client/static/js/treeView-Q6P3EWNA-tpn62q8j.js +0 -1
  298. package/dist/client/static/js/treemap-WGGIJYW6-w910f1g4.js +0 -1
  299. package/dist/client/static/js/tsx-s1shkfg9.js +0 -1
  300. package/dist/client/static/js/typescript-htx9v6bf.js +0 -1
  301. package/dist/client/static/js/wardley-WFR3VGLG-pt9tq808.js +0 -1
  302. package/dist/client/static/js/xml-wr1dxav5.js +0 -1
  303. package/dist/client/static/js/xychartDiagram-PMCCYNJV-kryrpqp1.js +0 -7
  304. package/dist/client/static/js/yaml-0y9fdskg.js +0 -1
  305. /package/src/{client/lib → shared/lib/workspace}/session-tree.ts +0 -0
@@ -0,0 +1,350 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The transcript an ACP session writes for itself.
8
+ *
9
+ * A chat Kabmo spawns SERVER-SIDE — an orchestration worker, a CLI child — has
10
+ * no tab, and the client is the only writer of `chat_sessions` for an ACP chat.
11
+ * The agent holds the conversation, but `session/load` is the only way to read
12
+ * it back and that needs a dead process. So the frames the driver already
13
+ * receives are folded here, as they stream, into the rows the timeline reads.
14
+ *
15
+ * The store is `acp_transcripts`, NOT `chat_sessions`: a tab that IS open keeps
16
+ * writing the richer row (attachment chips, notice rows) and must not be
17
+ * overwritten by this fallback. The loader prefers `chat_sessions` and reads
18
+ * this table only when that row is empty.
19
+ *
20
+ * The fold is deliberately the same one the reload path uses
21
+ * (`chatMessageFromEvent`), so a recorded row and a replayed row agree.
22
+ */
23
+
24
+ import { getDb } from '@/server/db.server';
25
+ import { chatMessageFromEvent } from '@/server/lib/harness/acp/replay-transcript';
26
+ import { hasAssistantRow } from '@/shared/lib/chat/transcript-rows';
27
+ import {
28
+ pairToolOutputs,
29
+ putToolResult,
30
+ recordToolResult,
31
+ resultDetails,
32
+ type ToolResultHost,
33
+ type ToolResultRecord,
34
+ } from '@/shared/lib/chat/omp/tool-results';
35
+ import { toolResultText } from '@/shared/lib/omp/session/mapper';
36
+ import { extractToolImages } from '@/shared/lib/omp/session/tool-images';
37
+ import type { ChatMessageData } from '@/shared/types/chat';
38
+ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
39
+
40
+ /** One write per burst. A turn emits a frame per chunk; the row is the unit. */
41
+ const FLUSH_DEBOUNCE_MS = 250;
42
+ /** The display attachments an image-only prompt carries. */
43
+ function imageAttachments(images: unknown): ChatMessageData['attachments'] {
44
+ if (!Array.isArray(images)) return undefined;
45
+ const rows = images.flatMap((image) => {
46
+ if (!image || typeof image !== 'object') return [];
47
+ const record = image as { data?: unknown; mimeType?: unknown };
48
+ if (typeof record.data !== 'string' || typeof record.mimeType !== 'string') return [];
49
+ return [{
50
+ name: 'image',
51
+ preview: `data:${record.mimeType};base64,${record.data}`,
52
+ type: record.mimeType,
53
+ }];
54
+ });
55
+ return rows.length > 0 ? rows : undefined;
56
+ }
57
+
58
+ /** The newest row's clock, for deciding which copy is ahead. */
59
+ function lastRowTime(rows: readonly ChatMessageData[]): number {
60
+ let newest = 0;
61
+ for (const row of rows) {
62
+ const time = typeof row.startedAt === 'number'
63
+ ? row.startedAt
64
+ : row.date
65
+ ? Date.parse(row.date)
66
+ : 0;
67
+ if (Number.isFinite(time) && time > newest) newest = time;
68
+ }
69
+ return newest;
70
+ }
71
+
72
+ /** The client-written row, when it exists. */
73
+ async function loadStoredMessages(sessionId: string): Promise<ChatMessageData[]> {
74
+ const db = await getDb();
75
+ const row = await db.get<{ messages: string }>(
76
+ 'SELECT messages FROM chat_sessions WHERE session_id = ?',
77
+ [sessionId],
78
+ );
79
+ if (!row?.messages) return [];
80
+ try {
81
+ const parsed: unknown = JSON.parse(row.messages);
82
+ return Array.isArray(parsed) ? (parsed as ChatMessageData[]) : [];
83
+ } catch {
84
+ return [];
85
+ }
86
+ }
87
+
88
+ /**
89
+ * The recorded rows over the client's row, keeping what only the client has.
90
+ *
91
+ * A tab's copy carries attachment chips and notice rows this fold does not
92
+ * build; replacing it wholesale would drop them. Rows are matched by message
93
+ * id, and a user turn by its text (the composer's optimistic id is local to the
94
+ * tab, so the same prompt has two ids).
95
+ */
96
+ function mergeTranscripts(
97
+ recorded: readonly ChatMessageData[],
98
+ stored: readonly ChatMessageData[],
99
+ ): ChatMessageData[] {
100
+ if (stored.length === 0) return [...recorded];
101
+ const merged = [...stored];
102
+ const indexById = new Map(merged.map((row, index) => [row.id, index]));
103
+ const userIdByText = new Map<string, string>();
104
+ for (const row of merged) {
105
+ if (row.role === 'user' && row.content.trim()) userIdByText.set(row.content.trim(), row.id);
106
+ }
107
+ for (const row of recorded) {
108
+ const existing = indexById.get(row.id);
109
+ if (existing !== undefined) {
110
+ merged[existing] = row;
111
+ continue;
112
+ }
113
+ if (row.role === 'user' && userIdByText.has(row.content.trim())) continue;
114
+ indexById.set(row.id, merged.length);
115
+ merged.push(row);
116
+ if (row.role === 'user' && row.content.trim()) userIdByText.set(row.content.trim(), row.id);
117
+ }
118
+ return merged;
119
+ }
120
+
121
+ /**
122
+ * Fold one session's frames into transcript rows and persist them.
123
+ *
124
+ * One instance per live ACP session. `recordPrompt` is called by the driver
125
+ * (the agent never echoes a live user turn), `record` by `emit`, and `flush`
126
+ * on the turn's end and on process exit.
127
+ */
128
+ export class AcpTranscriptRecorder {
129
+ private readonly rows: ChatMessageData[] = [];
130
+ private readonly indexById = new Map<string, number>();
131
+ private readonly toolResultsRef = { current: new Map<string, ToolResultRecord>() };
132
+ private readonly lastToolMessageRef = { current: null as ChatMessageData | null };
133
+ private readonly host: ToolResultHost = {
134
+ toolResultsRef: this.toolResultsRef,
135
+ lastToolMessageRef: this.lastToolMessageRef,
136
+ };
137
+ private timer: ReturnType<typeof setTimeout> | undefined;
138
+ private dirty = false;
139
+ private promptSeq = 0;
140
+ private disposed = false;
141
+
142
+ constructor(private readonly sessionId: () => string) {}
143
+
144
+ /**
145
+ * Load the rows a previous process recorded for this session.
146
+ *
147
+ * A resumed chat keeps its id, and the recorder starts empty in a new
148
+ * process; without this the first flush would replace the whole conversation
149
+ * with the new turn. Called once, before the first prompt.
150
+ */
151
+ async hydrate(): Promise<void> {
152
+ const recorded = await loadAcpTranscript(this.sessionId());
153
+ const stored = await loadStoredMessages(this.sessionId());
154
+ // The client's row is richer (attachment chips, notices); the recorder's
155
+ // may be ahead (a turn no tab wrote). Take whichever is newer, so the
156
+ // recorder's next flush is a superset of both.
157
+ const base = lastRowTime(stored) > lastRowTime(recorded) ? stored : recorded;
158
+ for (const row of base) this.upsert(row);
159
+ this.dirty = false;
160
+ }
161
+
162
+ /** Record the user turn. The ACP mapper drops live `user_message` frames as
163
+ * receipts for a bubble the composer drew, so this is the only copy. */
164
+ recordPrompt(text: string, images?: unknown): void {
165
+ if (this.disposed) return;
166
+ const content = text.trim();
167
+ if (!content) return;
168
+ const attachments = imageAttachments(images);
169
+ this.upsert({
170
+ id: `prompt-${++this.promptSeq}-${Date.now()}`,
171
+ role: 'user',
172
+ content,
173
+ startedAt: Date.now(),
174
+ ...(attachments ? { attachments } : {}),
175
+ });
176
+ this.schedule();
177
+ }
178
+
179
+ /** Fold one agent frame. Unknown frames are ignored, never guessed at. */
180
+ record(event: AgentEvent): void {
181
+ if (this.disposed) return;
182
+ switch (event.type) {
183
+ case 'user_turn':
184
+ this.recordPrompt(String(event.message ?? ''), event.images);
185
+ return;
186
+ case 'message_start':
187
+ case 'message_update':
188
+ case 'message_end': {
189
+ const message = event.message;
190
+ if (!message || typeof message !== 'object' || Array.isArray(message)) return;
191
+ const record = message as Record<string, unknown>;
192
+ if (record.role === 'toolResult') {
193
+ recordToolResult(record, this.host);
194
+ this.repaint(typeof record.toolCallId === 'string' ? record.toolCallId : undefined);
195
+ return;
196
+ }
197
+ const row = chatMessageFromEvent(event);
198
+ if (!row) return;
199
+ this.upsert(pairToolOutputs(row, this.host));
200
+ if (event.type === 'message_end') this.schedule();
201
+ return;
202
+ }
203
+ case 'tool_execution_start': {
204
+ const callId = typeof event.toolCallId === 'string' ? event.toolCallId : undefined;
205
+ if (!callId) return;
206
+ putToolResult(this.host, callId, { output: '', startedAt: Date.now(), pending: true });
207
+ this.repaint(callId);
208
+ return;
209
+ }
210
+ case 'tool_execution_update': {
211
+ const callId = typeof event.toolCallId === 'string' ? event.toolCallId : undefined;
212
+ if (!callId) return;
213
+ const stored = this.toolResultsRef.current.get(callId);
214
+ const output = typeof event.output === 'string' && event.output.length > 0
215
+ ? event.output
216
+ : toolResultText(event.partialResult);
217
+ const details = resultDetails(event) ?? stored?.details;
218
+ putToolResult(this.host, callId, {
219
+ output: output || stored?.output || '',
220
+ ...(details ? { details } : {}),
221
+ pending: true,
222
+ });
223
+ this.repaint(callId);
224
+ return;
225
+ }
226
+ case 'tool_execution_end': {
227
+ const callId = typeof event.toolCallId === 'string' ? event.toolCallId : undefined;
228
+ if (!callId) return;
229
+ const startedAt = this.toolResultsRef.current.get(callId)?.startedAt;
230
+ const images = extractToolImages(event.result);
231
+ putToolResult(this.host, callId, {
232
+ output: typeof event.output === 'string' && event.output.length > 0
233
+ ? event.output
234
+ : toolResultText(event.result),
235
+ isError: event.isError === true,
236
+ details: resultDetails(event),
237
+ pending: false,
238
+ ...(startedAt !== undefined ? { durationMs: Math.max(0, Date.now() - startedAt) } : {}),
239
+ ...(images.length > 0 ? { images } : {}),
240
+ });
241
+ this.repaint(callId);
242
+ return;
243
+ }
244
+ case 'agent_end':
245
+ void this.flush();
246
+ return;
247
+ default:
248
+ return;
249
+ }
250
+ }
251
+
252
+ /** Persist the rows so far. A no-op when nothing changed. */
253
+ async flush(): Promise<void> {
254
+ if (!this.dirty || this.disposed) return;
255
+ const sessionId = this.sessionId();
256
+ if (!sessionId) return;
257
+ this.dirty = false;
258
+ const stored = await loadStoredMessages(sessionId);
259
+ const rows = mergeTranscripts(this.rows, stored);
260
+ try {
261
+ const db = await getDb();
262
+ await db.run(
263
+ `INSERT INTO acp_transcripts (session_id, messages, updated_at)
264
+ VALUES (?, ?, ?)
265
+ ON CONFLICT(session_id) DO UPDATE SET
266
+ messages = excluded.messages,
267
+ updated_at = excluded.updated_at`,
268
+ [sessionId, JSON.stringify(rows), Date.now()],
269
+ );
270
+ // A turn no tab wrote would otherwise be invisible: the loader prefers
271
+ // `chat_sessions` when it holds an answer. Write it only when this copy is
272
+ // AHEAD, so an open tab's newer (and richer) row is never replaced.
273
+ if (!hasAssistantRow(stored) || lastRowTime(rows) > lastRowTime(stored)) {
274
+ const titleRow = await db.get<{ title: string }>(
275
+ 'SELECT title FROM chat_sessions WHERE session_id = ?',
276
+ [sessionId],
277
+ );
278
+ await db.run(
279
+ `INSERT INTO chat_sessions (session_id, title, messages, updated_at)
280
+ VALUES (?, ?, ?, CURRENT_TIMESTAMP)
281
+ ON CONFLICT(session_id) DO UPDATE SET
282
+ messages = excluded.messages,
283
+ updated_at = CURRENT_TIMESTAMP`,
284
+ [sessionId, titleRow?.title || `Session ${sessionId}`, JSON.stringify(rows)],
285
+ );
286
+ }
287
+ } catch (error) {
288
+ // A failed write is not a lost turn: the next frame retries, and the
289
+ // restore path can replay the agent's own history.
290
+ this.dirty = true;
291
+ console.error('[harness] could not record the ACP transcript:', error);
292
+ }
293
+ }
294
+
295
+ /** Flush the last rows and stop the timer (process exit). */
296
+ dispose(): void {
297
+ if (this.timer !== undefined) clearTimeout(this.timer);
298
+ this.timer = undefined;
299
+ void this.flush();
300
+ this.disposed = true;
301
+ }
302
+
303
+ private upsert(row: ChatMessageData): void {
304
+ const existing = this.indexById.get(row.id);
305
+ if (existing !== undefined) {
306
+ this.rows[existing] = row;
307
+ } else {
308
+ this.indexById.set(row.id, this.rows.length);
309
+ this.rows.push(row);
310
+ }
311
+ this.dirty = true;
312
+ }
313
+
314
+ /** Re-pair the row that owns a call after its result changed. */
315
+ private repaint(callId: string | undefined): void {
316
+ if (!callId) return;
317
+ for (let index = this.rows.length - 1; index >= 0; index -= 1) {
318
+ const row = this.rows[index];
319
+ if (!row.toolCalls?.some((call) => call.id === callId)) continue;
320
+ this.rows[index] = pairToolOutputs(row, this.host);
321
+ this.dirty = true;
322
+ return;
323
+ }
324
+ }
325
+
326
+ private schedule(): void {
327
+ if (this.timer !== undefined) return;
328
+ this.timer = setTimeout(() => {
329
+ this.timer = undefined;
330
+ void this.flush();
331
+ }, FLUSH_DEBOUNCE_MS);
332
+ this.timer.unref?.();
333
+ }
334
+ }
335
+
336
+ /** The recorded rows for a session, or empty when it has none. */
337
+ export async function loadAcpTranscript(sessionId: string): Promise<ChatMessageData[]> {
338
+ const db = await getDb();
339
+ const row = await db.get<{ messages: string }>(
340
+ 'SELECT messages FROM acp_transcripts WHERE session_id = ?',
341
+ [sessionId],
342
+ );
343
+ if (!row?.messages) return [];
344
+ try {
345
+ const parsed: unknown = JSON.parse(row.messages);
346
+ return Array.isArray(parsed) ? (parsed as ChatMessageData[]) : [];
347
+ } catch {
348
+ return [];
349
+ }
350
+ }
@@ -198,6 +198,8 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
198
198
  return this.proc.steer(this.sessionId, blocks, queue);
199
199
  }
200
200
 
201
+ /** Record a mid-turn user message; the ACP mapper drops live user frames. */
202
+ recordUserTurn(message: string, images: unknown): void { this.emit({ type: 'user_turn', message, images }); }
201
203
  /**
202
204
  * The durable run marker (`session_stream_state`), the row the sidebar's
203
205
  * spinner and a reattaching tab's "still running" answer read. A field so a
@@ -281,7 +283,10 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
281
283
  this.background.stop();
282
284
  this.promptCount += 1;
283
285
  this.usage.beginTurn();
284
- return beginAcpTurn(this, this.turns, message, images);
286
+ const ack = beginAcpTurn(this, this.turns, message, images);
287
+ // Only a delivered turn is recorded: a refusal must not leave a user row.
288
+ this.emit({ type: 'user_turn', message, images });
289
+ return ack;
285
290
  }
286
291
 
287
292
  private onNotification(method: string, params: Record<string, unknown>): void {
@@ -141,6 +141,23 @@ const CUSTOM_HARNESSES_SQL = `
141
141
  );
142
142
  `;
143
143
 
144
+ /**
145
+ * The transcript an ACP session records for itself.
146
+ *
147
+ * A chat Kabmo spawns server-side (an orchestration worker, a CLI child) has no
148
+ * tab, and the client is the only writer of `chat_sessions` for an ACP chat.
149
+ * The driver folds the frames it already receives into this table, and the
150
+ * loader reads it only when `chat_sessions` is empty — so an open tab's richer
151
+ * row (attachment chips, notices) is never overwritten by the fallback.
152
+ */
153
+ const ACP_TRANSCRIPTS_SQL = `
154
+ CREATE TABLE IF NOT EXISTS acp_transcripts (
155
+ session_id TEXT PRIMARY KEY,
156
+ messages TEXT NOT NULL,
157
+ updated_at INTEGER NOT NULL
158
+ );
159
+ `;
160
+
144
161
  /** Idempotent: created on every database open, like every other feature table. */
145
162
  export async function ensureHarnessSchema(db: DbClient): Promise<void> {
146
163
  await db.exec(HARNESS_SESSIONS_SQL);
@@ -148,6 +165,7 @@ export async function ensureHarnessSchema(db: DbClient): Promise<void> {
148
165
  await db.exec(HARNESS_PROBES_SQL);
149
166
  await db.exec(HARNESS_GOAL_STATE_SQL);
150
167
  await db.exec(HARNESS_USAGE_STATE_SQL);
168
+ await db.exec(ACP_TRANSCRIPTS_SQL);
151
169
  for (const migration of HARNESS_SESSIONS_MIGRATIONS) {
152
170
  try {
153
171
  await db.exec(migration);
@@ -21,6 +21,7 @@
21
21
  */
22
22
 
23
23
  import { AcpSession } from '@/server/lib/harness/acp/session';
24
+ import { AcpTranscriptRecorder } from '@/server/lib/harness/acp/session-transcript.server';
24
25
  import { claimPrewarmedAcpSession } from '@/server/lib/harness/acp/prewarm.server';
25
26
  import { rememberAgentToken } from '@/server/lib/sessions/agent-token.server';
26
27
  import { loadHarnessConfig, resolveLaunch } from '@/server/lib/harness/config.server';
@@ -219,6 +220,15 @@ export async function startAcpSession(
219
220
  const { session, realSessionId } = await openAcpSession(
220
221
  warm ? { ...request, process: warm.process } : request,
221
222
  );
223
+ // The transcript this session writes for itself. A restore replays the
224
+ // agent's history and persists it itself, so it is the one session that must
225
+ // not record. The listener is attached before the first prompt, which is what
226
+ // makes a server-spawned child's timeline non-empty.
227
+ const recorder = request.replay ? null : new AcpTranscriptRecorder(() => realSessionId);
228
+ if (recorder) {
229
+ await recorder.hydrate();
230
+ session.onEvent((event) => recorder.record(event));
231
+ }
222
232
  if (warm) {
223
233
  // The process's environment already carries the credential minted at
224
234
  // prewarm; recording a different one here would authenticate its callbacks
@@ -233,7 +243,10 @@ export async function startAcpSession(
233
243
  // `onDestroy` is a single slot, so a second registration would silently
234
244
  // replace the registry cleanup and leave a dead session answering for its id.
235
245
  const pid = session.pid;
236
- registerAcpSession(session, request.sessionId, pid ? () => removeHarnessLease(pid) : undefined);
246
+ registerAcpSession(session, request.sessionId, () => {
247
+ if (pid) removeHarnessLease(pid);
248
+ recorder?.dispose();
249
+ });
237
250
  // Record the ownership BEFORE the first frame is forwarded: the sidebar reads
238
251
  // this table, not the live registry, so a row written late would draw the row
239
252
  // as `omp` until the next folder load. A failed write must not kill a live
@@ -23,8 +23,8 @@
23
23
  * stranger.
24
24
  */
25
25
 
26
- import { getImageMimeFromBytes } from '@/shared/lib/fs/file-kind';
27
- import { looksLikeSvg, pickIconHrefs, providerIconOrigins } from '@/server/lib/models/provider-icon-parse';
26
+ import { getImageMimeFromBytes, looksLikeSvg } from '@/shared/lib/fs/file-kind';
27
+ import { pickIconHrefs, providerIconOrigins } from '@/server/lib/models/provider-icon-parse';
28
28
 
29
29
  /** Per-request ceiling. A favicon slower than this is not worth the wait. */
30
30
  const FETCH_TIMEOUT_MS = 4_000;
@@ -13,7 +13,6 @@
13
13
 
14
14
  import { describe, expect, test } from 'bun:test';
15
15
  import {
16
- looksLikeSvg,
17
16
  pickIconHrefs,
18
17
  providerBaseOrigin,
19
18
  providerIconOrigins,
@@ -160,14 +159,3 @@ describe('pickIconHrefs', () => {
160
159
  expect(urls[0]).toBe('https://kenari.id/i7.png');
161
160
  });
162
161
  });
163
-
164
- describe('looksLikeSvg', () => {
165
- test('recognises a document and one behind a prolog', () => {
166
- expect(looksLikeSvg(new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg"/>'))).toBe(true);
167
- expect(looksLikeSvg(new TextEncoder().encode('<?xml version="1.0"?>\n<svg/>'))).toBe(true);
168
- });
169
-
170
- test('a PNG is not an SVG', () => {
171
- expect(looksLikeSvg(new Uint8Array([0x89, 0x50, 0x4e, 0x47]))).toBe(false);
172
- });
173
- });
@@ -202,11 +202,3 @@ export function pickIconHrefs(html: string, origin: string, limit = 4): string[]
202
202
  }
203
203
  return urls.slice(0, limit);
204
204
  }
205
-
206
- /** True when the bytes are an SVG document (which no magic-byte table catches). */
207
- export function looksLikeSvg(bytes: Uint8Array): boolean {
208
- // Decode only the head: an SVG's first tag is within the first few hundred
209
- // bytes even with a prolog and a long `<style>`.
210
- const head = new TextDecoder().decode(bytes.subarray(0, 2048)).trimStart();
211
- return head.startsWith('<svg') || (head.startsWith('<?xml') && head.includes('<svg'));
212
- }
@@ -237,10 +237,25 @@ describe('a non-invoking prompt_result never reaches the client mid-run', () =>
237
237
  expect(foldSessionFrame(host, { type: 'prompt_result', agentInvoked: false }).suppressForward).toBe(true);
238
238
  });
239
239
 
240
+ test('suppresses it in the dispatch window, before agent_start', () => {
241
+ // Measured on a fresh session (omp 18.22.2): the client's plan-review
242
+ // `republish` reaches the child 43 ms after the prompt and omp answers it
243
+ // `agentInvoked:false` ~160 ms BEFORE `agent_start`. `streaming` is still
244
+ // false there, so the frame was forwarded, the client settled the optimistic
245
+ // turn, and the user echo appended a second bubble (57 of 58 first prompts
246
+ // rendered twice). The dispatch window is part of the run.
247
+ const host = makeHost({ sessionId: 's1', promptRunning: true, streaming: false });
248
+ const result = foldSessionFrame(host, { type: 'prompt_result', agentInvoked: false });
249
+
250
+ expect(result.suppressForward).toBe(true);
251
+ // The dispatch it arrived under still owns the turn slot.
252
+ expect(host.promptRunning).toBe(true);
253
+ });
254
+
240
255
  test('still forwards the operator’s own builtin result when no turn runs', () => {
241
256
  // The case the frame exists for: a `/usage` the operator typed must settle
242
257
  // the optimistic turn, even inside a rename window.
243
- const host = makeHost({ sessionId: 's1', promptRunning: true, autoTitleWindowUntil: Date.now() + 60_000 });
258
+ const host = makeHost({ sessionId: 's1', promptRunning: false, autoTitleWindowUntil: Date.now() + 60_000 });
244
259
  const result = foldSessionFrame(host, { type: 'prompt_result', agentInvoked: false });
245
260
 
246
261
  expect(result.suppressForward).toBe(false);
@@ -115,19 +115,32 @@ function handleToolExecutionEnd(host: SessionFrameHost): void {
115
115
  * 20 s run, and the first prompt was stored twice in Kabmo's copy of the
116
116
  * conversation.
117
117
  *
118
- * The RUN is the attribution, and it covers every sender: while the operator's
119
- * turn is streaming, a prompt that opened no turn cannot be the settle of the
120
- * turn they are watching. The auto-title request window is not sufficient on its
118
+ * The RUN is the attribution, and it covers every sender: while a run is in
119
+ * flight, a prompt that opened no turn cannot be the settle of the turn the
120
+ * operator is watching. The auto-title request window is not sufficient on its
121
121
  * own — it is armed around the `/rename`, and omp answers it in the same tick
122
122
  * (~3 ms), so a frame that won that race reached the client regardless (the leak
123
123
  * this replaces). Its flags are left alone too, exactly as the dispatcher leaves
124
124
  * a non-owning command's (see `session-commands.ts`): the live run owns them.
125
125
  *
126
+ * `streaming` alone is too narrow, and that is the second leak: it flips at
127
+ * `agent_start`, so the window between the prompt's DISPATCH and its first frame
128
+ * was open. A background command answered there — measured on a fresh session
129
+ * (omp 18.22.2): the plan-review `republish` the client fires on spawn adoption
130
+ * (`usePlanReview`) reached the child 43 ms after the prompt and omp answered it
131
+ * `agentInvoked:false` 160 ms before `agent_start`. The frame was forwarded, the
132
+ * client settled the optimistic turn, and the user echo that followed appended a
133
+ * second bubble — 57 of 58 first prompts rendered twice. `promptRunning` is set
134
+ * before the prompt is written and cleared only by a settle, so it covers the
135
+ * whole run; the dispatcher's own decline path (`session-commands.ts`, the
136
+ * `ack.agentInvoked === false` branch) still emits its own frame, so a prompt
137
+ * that genuinely opened no turn is still settled.
138
+ *
126
139
  * A builtin the operator typed while the agent is IDLE still passes through
127
140
  * untouched — the case this frame exists for.
128
141
  */
129
142
  function handlePromptResult(host: SessionFrameHost, event: AgentEvent): boolean {
130
- if (event.agentInvoked === false && host.streaming) return true;
143
+ if (event.agentInvoked === false && (host.promptRunning || host.streaming)) return true;
131
144
  host.promptRunning = false;
132
145
  host.awaitingAgentStart = false;
133
146
  host.awaitingAgentStartDeadline = 0;
@@ -118,6 +118,40 @@ describe('readBlobImage', () => {
118
118
  expect(image?.bytes).toEqual(JPEG_BYTES);
119
119
  });
120
120
 
121
+ test('a WEBP blob is labelled from its RIFF/WEBP tag', async () => {
122
+ // A `read` of a `.webp` answers with an image block, and omp externalizes it
123
+ // to the store; the tag at offset 8 is the only evidence left once the
124
+ // sibling link is pruned.
125
+ const hash = 'e'.repeat(64);
126
+ const webpBytes = Buffer.from([0x52, 0x49, 0x46, 0x46, 0x20, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50]);
127
+ await fsp.writeFile(path.join(getBlobStoreDir(), hash), webpBytes);
128
+ const image = await readBlobImage(hash);
129
+ expect(image?.mimeType).toBe('image/webp');
130
+ expect(image?.bytes).toEqual(webpBytes);
131
+ });
132
+
133
+ test('an SVG blob is labelled from its own text', async () => {
134
+ // No magic table catches an SVG; it used to answer
135
+ // `application/octet-stream`, which no browser paints.
136
+ const hash = 'f'.repeat(64);
137
+ const svgBytes = Buffer.from('<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"/>');
138
+ await fsp.writeFile(path.join(getBlobStoreDir(), hash), svgBytes);
139
+ const image = await readBlobImage(hash);
140
+ expect(image?.mimeType).toBe('image/svg+xml');
141
+ expect(image?.bytes).toEqual(svgBytes);
142
+ });
143
+
144
+ test('an SVG whose head the text check rejects still answers from its link', async () => {
145
+ // A document that opens with a comment or a doctype is not recognised from
146
+ // the first tag; the hardlink omp writes beside the blob is the fallback.
147
+ const hash = '9'.repeat(64);
148
+ const svgBytes = Buffer.from('<!-- exported --><svg xmlns="http://www.w3.org/2000/svg"/>');
149
+ await fsp.writeFile(path.join(getBlobStoreDir(), hash), svgBytes);
150
+ await fsp.writeFile(path.join(getBlobStoreDir(), `${hash}.svg`), svgBytes);
151
+ const image = await readBlobImage(hash);
152
+ expect(image?.mimeType).toBe('image/svg+xml');
153
+ });
154
+
121
155
  test('a missing blob yields null', async () => {
122
156
  expect(await readBlobImage('d'.repeat(64))).toBeNull();
123
157
  });
@@ -28,7 +28,7 @@ import * as fsp from 'node:fs/promises';
28
28
  import { existsSync } from 'node:fs';
29
29
  import * as path from 'node:path';
30
30
  import { getAgentDir } from '@/server/lib/omp/core/paths';
31
- import { getImageMimeFromBytes, getImageMimeType } from '@/shared/lib/fs/file-kind';
31
+ import { getImageMimeFromBytes, getPaintableImageMimeType } from '@/shared/lib/fs/file-kind';
32
32
 
33
33
  const BLOB_PREFIX = 'blob:sha256:';
34
34
 
@@ -77,7 +77,7 @@ export async function readBlobRef(ref: string): Promise<Buffer | null> {
77
77
  }
78
78
 
79
79
  /** Extensions omp writes onto a blob's hardlink beside it (`mimeToExtension`). */
80
- const BLOB_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'bmp', 'tiff', 'ico'];
80
+ const BLOB_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'bmp', 'tiff', 'ico', 'svg'];
81
81
 
82
82
  /**
83
83
  * A blob's bytes plus the content type to serve them with, or null when the
@@ -89,6 +89,11 @@ const BLOB_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'bmp
89
89
  * has the bytes, and a wrong `content-type` makes a browser download the image
90
90
  * instead of painting it. `image/jpeg` is the honest answer for a `.png` that
91
91
  * omp converted on read (measured: a 96×96 PNG read came back as a JPEG blob).
92
+ *
93
+ * An SVG has no magic signature, which is why the sniff reads its head as text
94
+ * (`looksLikeSvg`); `svg` is also in the link list, for a document that opens
95
+ * with a comment or a doctype the head check does not accept. Without either,
96
+ * an SVG blob was labelled `application/octet-stream` and painted nothing.
92
97
  */
93
98
  export async function readBlobImage(hash: string): Promise<{ bytes: Buffer; mimeType: string } | null> {
94
99
  const bytes = await readBlob(hash);
@@ -100,7 +105,7 @@ export async function readBlobImage(hash: string): Promise<{ bytes: Buffer; mime
100
105
  const dir = getBlobStoreDir();
101
106
  for (const ext of BLOB_IMAGE_EXTENSIONS) {
102
107
  if (!existsSync(path.join(dir, `${hash}.${ext}`))) continue;
103
- const byExtension = getImageMimeType(`x.${ext}`);
108
+ const byExtension = getPaintableImageMimeType(`x.${ext}`);
104
109
  if (byExtension) return { bytes, mimeType: byExtension };
105
110
  }
106
111
 
@@ -70,6 +70,10 @@ const SESSION_ROW_DELETES: readonly (readonly [string, string])[] = [
70
70
  ['queued_messages', 'session_id'],
71
71
  ['prompt_history', 'session_id'],
72
72
  ['chat_sessions', 'session_id'],
73
+ // The server-side recorder's fallback for a chat no tab ever wrote. It is a
74
+ // second copy of the same conversation, so a delete that left it behind would
75
+ // resurrect the transcript on the next open.
76
+ ['acp_transcripts', 'session_id'],
73
77
  ['files', 'session_id'],
74
78
  // An ACP chat has no transcript for the scan to lose: `harness_sessions` IS
75
79
  // its row, so leaving it behind both refused the delete as "not found" (nothing
@@ -26,6 +26,7 @@
26
26
 
27
27
  import { afterAll, afterEach, describe, expect, test } from 'bun:test';
28
28
  import fs from 'fs';
29
+ import * as os from 'os';
29
30
  import * as path from 'path';
30
31
 
31
32
  import { loadSidebarActivity } from '@/server/lib/omp/session/sidebar-activity.server';
@@ -43,7 +44,7 @@ const previousAgentDir = process.env.PI_CODING_AGENT_DIR;
43
44
  * path, so they are cleared before and after.
44
45
  */
45
46
  function useAgentDir(): string {
46
- const dir = fs.mkdtempSync(path.join(fs.realpathSync('/tmp'), 'kabmo-activity-'));
47
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-activity-'));
47
48
  tempDirs.push(dir);
48
49
  process.env.PI_CODING_AGENT_DIR = dir;
49
50
  clearSessionFileCaches();