@kabmo-labs/kabmo 0.38.2 → 0.39.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 (508) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +565 -537
  3. package/dist/client/static/js/{CsvGrid-4dpsfdrf.js → CsvGrid-kfcp4sd6.js} +2 -2
  4. package/dist/client/static/js/{DocxView-crdgc0jd.js → DocxView-atff5w38.js} +4 -4
  5. package/dist/client/static/js/DrawioView-yfnq4c99.js +5 -0
  6. package/dist/client/static/js/ImageView-nreh25s0.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-0x1q1q5z.js +2 -0
  8. package/dist/client/static/js/Modal-2xqd3sss.js +38 -0
  9. package/dist/client/static/js/{PdfView-72c123a9.js → PdfView-mk8paxt1.js} +1 -1
  10. package/dist/client/static/js/SessionsView-ner25qxn.js +1 -0
  11. package/dist/client/static/js/{SheetView-8xh69wgk.js → SheetView-s6n3fawm.js} +31 -31
  12. package/dist/client/static/js/{SvgPreview-z3fm87h6.js → SvgPreview-8bxvz3ez.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-25r2p3vh.js → abnfDiagram-O67JEVCF-tvvz9fha.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-y0zb4vqa.js +1 -0
  15. package/dist/client/static/js/architectureDiagram-NJMV4G6O-bybv3wg4.js +36 -0
  16. package/dist/client/static/js/{astro-p3f5p9p2.js → astro-4ybhkc9b.js} +1 -1
  17. package/dist/client/static/js/bash-k6p3y3pr.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-vzamgz9s.js → blockDiagram-BEXU5L5S-h3fs79x6.js} +8 -8
  19. package/dist/client/static/js/c-ve09y19q.js +1 -0
  20. package/dist/client/static/js/{c4Diagram-YGBWAQC7-jejafgn0.js → c4Diagram-YGBWAQC7-h8p3h54v.js} +5 -5
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-qfa6mj0q.js → classDiagram-v2-NBCMYWYE-q645r4q6.js} +6 -6
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-9vzdgmk1.js → cose-bilkent-JH36ORCC-p4mm1zcv.js} +1 -1
  23. package/dist/client/static/js/cpp-vhqp7bcy.js +1 -0
  24. package/dist/client/static/js/css-77mvf0ca.js +1 -0
  25. package/dist/client/static/js/css-tys2rrny.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-nt1ed192.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-a3k3w1t5.js → cynefinDiagram-VND7K2PF-v2hbc3aq.js} +1 -1
  28. package/dist/client/static/js/{dagre-6A5THRUB-gf04dvxj.js → dagre-6A5THRUB-4edpda33.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-a9e0a684.js → diagram-22UHCM2B-b6gp813w.js} +19 -19
  30. package/dist/client/static/js/{diagram-3UASUU5V-fb73gfjd.js → diagram-3UASUU5V-s1f3b0ng.js} +1 -1
  31. package/dist/client/static/js/{diagram-ATOU4E4O-yb9n3t30.js → diagram-ATOU4E4O-ga06kjp5.js} +3 -3
  32. package/dist/client/static/js/{diagram-CDSNMT55-adhbhw28.js → diagram-CDSNMT55-wdbmv4td.js} +5 -5
  33. package/dist/client/static/js/{diagram-MLGK6HIB-v4yxyb8r.js → diagram-MLGK6HIB-fkntefcq.js} +2 -2
  34. package/dist/client/static/js/{diagram-MPIPVDR6-94ttsqy2.js → diagram-MPIPVDR6-k2zh7edp.js} +3 -3
  35. package/dist/client/static/js/{dockerfile-mrranatf.js → dockerfile-srcym0bs.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jj4f3pyq.js → ebnfDiagram-ZINNZB2B-4vc4vz9c.js} +1 -1
  37. package/dist/client/static/js/{elixir-jwphgp8j.js → elixir-v9bbxsgg.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-mtnkhyte.js → elk-276RUBZZ-g2ppf1by.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-18qdkhm5.js → erDiagram-OPXOYQCR-rmnwkb5q.js} +9 -9
  40. package/dist/client/static/js/{erlang-6m6tpt72.js → erlang-55r0skxa.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-v4edaxx7.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-jvrvhb9d.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-vz28h061.js → ganttDiagram-FUAMR5RP-ptfvae64.js} +5 -5
  44. package/dist/client/static/js/gitGraph-4MIJSDKK-adzhec96.js +1 -0
  45. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-cgq3r4rz.js → gitGraphDiagram-X574FWY7-ne9n3cyf.js} +14 -14
  46. package/dist/client/static/js/graphql-g97hycb3.js +1 -0
  47. package/dist/client/static/js/html-2syect3n.js +1 -0
  48. package/dist/client/static/js/{index-3az1w5f8.js → index-0j518hqm.js} +2 -2
  49. package/dist/client/static/js/index-1jeyjqkh.js +2 -0
  50. package/dist/client/static/js/{index-t5t71dhp.js → index-1sgad84m.js} +2 -2
  51. package/dist/client/static/js/{index-z72wf7q4.js → index-270y5r9k.js} +2 -2
  52. package/dist/client/static/js/{index-sa9cp6km.js → index-2rs03vfy.js} +2 -2
  53. package/dist/client/static/js/index-3fw3sd10.js +474 -0
  54. package/dist/client/static/js/{index-xya34x4v.js → index-442mbhwb.js} +2 -2
  55. package/dist/client/static/js/{index-95t1hwr8.js → index-4pehdq5h.js} +2 -2
  56. package/dist/client/static/js/{index-dt7e1328.js → index-4wtr5wjp.js} +2 -2
  57. package/dist/client/static/js/{index-gr6jng0x.js → index-4wvtar0v.js} +2 -2
  58. package/dist/client/static/js/{index-zdbvm01f.js → index-56w8m083.js} +2 -2
  59. package/dist/client/static/js/index-5a4w58r2.js +1 -0
  60. package/dist/client/static/js/{index-4hsxaa87.js → index-5kvvb0zm.js} +2 -2
  61. package/dist/client/static/js/{index-5v9v41ap.js → index-61qjr1k0.js} +98 -98
  62. package/dist/client/static/js/{index-6k3e5dph.js → index-72289dgx.js} +2 -2
  63. package/dist/client/static/js/{index-gbdvr4rt.js → index-7h5n5rz4.js} +2 -2
  64. package/dist/client/static/js/{index-y5y7smet.js → index-7z63xr1s.js} +1 -1
  65. package/dist/client/static/js/index-878d61js.js +1 -0
  66. package/dist/client/static/js/{index-fghst0kd.js → index-8egjccbq.js} +34 -34
  67. package/dist/client/static/js/index-8qgwj6m8.js +1 -0
  68. package/dist/client/static/js/{index-kf9t3mzv.js → index-8w2tx2k9.js} +2 -2
  69. package/dist/client/static/js/{index-x07kp3jz.js → index-9d6x1f3t.js} +2 -2
  70. package/dist/client/static/js/{index-vb6t44dw.js → index-9gepbvdt.js} +2 -2
  71. package/dist/client/static/js/index-a7qccdq2.js +1 -0
  72. package/dist/client/static/js/{index-7fdp9c7m.js → index-b08hx4tw.js} +2 -2
  73. package/dist/client/static/js/{index-nd4p98mc.js → index-c1be3rva.js} +2 -2
  74. package/dist/client/static/js/{index-3zc1b0dv.js → index-c36pag9y.js} +2 -2
  75. package/dist/client/static/js/{index-qkscve6n.js → index-cfnxda13.js} +2 -2
  76. package/dist/client/static/js/index-cst843zs.css +1 -0
  77. package/dist/client/static/js/{index-6j9h1fa7.js → index-dmd26a1y.js} +1 -1
  78. package/dist/client/static/js/{index-1y9r4frb.js → index-drjtwfp5.js} +2 -2
  79. package/dist/client/static/js/index-dt22v9ns.js +2 -0
  80. package/dist/client/static/js/{index-h7pn9qw6.js → index-enmh3w27.js} +2 -2
  81. package/dist/client/static/js/{index-ray2czf6.js → index-fjnkzk12.js} +4 -4
  82. package/dist/client/static/js/index-gvkc9e32.js +1 -0
  83. package/dist/client/static/js/{index-d146s9g3.js → index-hh05xd1d.js} +2 -2
  84. package/dist/client/static/js/{index-qxb8k6py.js → index-jkph8wqq.js} +3 -3
  85. package/dist/client/static/js/index-k3c3n69j.js +12 -0
  86. package/dist/client/static/js/{index-dr7nhha9.js → index-k5a6r25s.js} +2 -2
  87. package/dist/client/static/js/{index-we2ezmn7.js → index-k61tdd4a.js} +2 -2
  88. package/dist/client/static/js/{index-8acv5b77.js → index-k7sdsmgv.js} +2 -2
  89. package/dist/client/static/js/{index-s16h2nmv.js → index-m3r0j562.js} +6 -6
  90. package/dist/client/static/js/{index-njqpkcvw.js → index-mdxnhndy.js} +2 -2
  91. package/dist/client/static/js/index-me7m3516.js +9 -0
  92. package/dist/client/static/js/index-mmsszqvn.js +1 -0
  93. package/dist/client/static/js/index-ntx3bbmb.js +1 -0
  94. package/dist/client/static/js/index-p89z1qmj.js +1 -0
  95. package/dist/client/static/js/{index-fqhpxzyb.js → index-pr7gk5eq.js} +13 -13
  96. package/dist/client/static/js/index-pzqsp5jw.js +4 -0
  97. package/dist/client/static/js/{index-qn4pkjfh.js → index-q0bph5x0.js} +2 -2
  98. package/dist/client/static/js/{index-gbfg0anm.js → index-qsrw5c67.js} +2 -2
  99. package/dist/client/static/js/{index-ashpbfqv.js → index-rj81xrvw.js} +2 -2
  100. package/dist/client/static/js/{index-b9b2nwdd.js → index-t6gznaxm.js} +2 -2
  101. package/dist/client/static/js/{index-12p63902.js → index-v8vjh5jj.js} +2 -2
  102. package/dist/client/static/js/{index-naz3px72.js → index-xdqsqhnn.js} +9 -9
  103. package/dist/client/static/js/{index-9wd9y6m0.js → index-xrp2zv8z.js} +2 -2
  104. package/dist/client/static/js/{index-ajtd1q1h.js → index-y2prm0xm.js} +2 -2
  105. package/dist/client/static/js/{index-y3hdv561.js → index-y3qxrs90.js} +2 -2
  106. package/dist/client/static/js/index-ymp2wqtc.js +3 -0
  107. package/dist/client/static/js/index-ywpdhntc.js +1 -0
  108. package/dist/client/static/js/info-A6RAGUB7-2ye26vqn.js +1 -0
  109. package/dist/client/static/js/{infoDiagram-VRGFBTTK-jjwckbr9.js → infoDiagram-VRGFBTTK-ctfwcm3n.js} +2 -2
  110. package/dist/client/static/js/ini-7ffv28px.js +1 -0
  111. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-qzk5gejf.js → ishikawaDiagram-OU5B5YK6-b0b0pn4y.js} +3 -3
  112. package/dist/client/static/js/java-4x5yky4a.js +1 -0
  113. package/dist/client/static/js/javascript-4kw2j9t3.js +1 -0
  114. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-maccpg3q.js → journeyDiagram-ZHPQQLJL-kdq12drs.js} +5 -5
  115. package/dist/client/static/js/json-h3kwpty2.js +1 -0
  116. package/dist/client/static/js/jsx-jk20f0dr.js +1 -0
  117. package/dist/client/static/js/{julia-237yk557.js → julia-jhe2vd4f.js} +1 -1
  118. package/dist/client/static/js/{kanban-definition-PNTS6WVX-xv2azgws.js → kanban-definition-PNTS6WVX-65x6xn2q.js} +6 -6
  119. package/dist/client/static/js/lua-k02dpxq8.js +1 -0
  120. package/dist/client/static/js/markdown-fhhg7ms6.js +1 -0
  121. package/dist/client/static/js/{mermaid.core-e4ys760s.js → mermaid.core-0fq63jpa.js} +8 -8
  122. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-b779wz81.js → mindmap-definition-NLK3R4M7-p86myex3.js} +6 -6
  123. package/dist/client/static/js/one-dark-pro-c4q810z4.js +1 -0
  124. package/dist/client/static/js/one-light-czk9dzya.js +1 -0
  125. package/dist/client/static/js/packet-AYTQ26CC-b0j3te0q.js +1 -0
  126. package/dist/client/static/js/{pegDiagram-GJSIUBJH-8sgdmhnw.js → pegDiagram-GJSIUBJH-p2hkk9xb.js} +1 -1
  127. package/dist/client/static/js/{perl-dvz4y1tb.js → perl-qhj6tk7k.js} +1 -1
  128. package/dist/client/static/js/{php-n6y7dzhm.js → php-arycc4w7.js} +1 -1
  129. package/dist/client/static/js/pie-WAS4IAKB-28qq62fn.js +1 -0
  130. package/dist/client/static/js/pieDiagram-5QR66LMP-bza19wkx.js +39 -0
  131. package/dist/client/static/js/properties-qhvcxc13.js +1 -0
  132. package/dist/client/static/js/python-3qsrs510.js +1 -0
  133. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-47dpygk5.js → quadrantDiagram-O4NWA36T-bxqec9w1.js} +6 -6
  134. package/dist/client/static/js/r-z2ng7mza.js +1 -0
  135. package/dist/client/static/js/radar-RG4KPBEZ-fyrcbpyd.js +1 -0
  136. package/dist/client/static/js/railroad-74A4TZTK-9s62qncd.js +1 -0
  137. package/dist/client/static/js/railroad-abnf-HS5TGJTU-f7yjmhrk.js +1 -0
  138. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-sfrw8gkz.js +1 -0
  139. package/dist/client/static/js/railroad-peg-WCYAUIDC-4mm4cern.js +1 -0
  140. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-wv0bvwve.js → railroadDiagram-XR7U4H2S-1g3hx3sm.js} +1 -1
  141. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-w3r8r837.js → requirementDiagram-PLB6GJNP-qbjjm48v.js} +13 -13
  142. package/dist/client/static/js/{ruby-7zye3g0e.js → ruby-fb6zzevm.js} +1 -1
  143. package/dist/client/static/js/{rust-42c4h7e4.js → rust-jatm47v6.js} +1 -1
  144. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t55rjgad.js → sankeyDiagram-IPEJSGJF-t2ythbh7.js} +6 -6
  145. package/dist/client/static/js/{sass-m0h9yzfb.js → sass-fzs6a0kr.js} +1 -1
  146. package/dist/client/static/js/{scss-2pwwfkvn.js → scss-gdb52d0c.js} +1 -1
  147. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-yfwjwy37.js → sequenceDiagram-PO4LG4MO-mqsfek2j.js} +21 -21
  148. package/dist/client/static/js/{sizeCapture-INFHLROL-nq6hy7ce.js → sizeCapture-INFHLROL-xj67pgds.js} +1 -1
  149. package/dist/client/static/js/sql-ypk53ntb.js +1 -0
  150. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-4xy0atqh.js → stateDiagram-v2-GCMORJYK-gj4fezak.js} +3 -3
  151. package/dist/client/static/js/{svelte-x8f8c8hq.js → svelte-8s3k6qjd.js} +1 -1
  152. package/dist/client/static/js/{swimlanes-2SLR337P-np47cy1q.js → swimlanes-2SLR337P-pgtdd1pk.js} +1 -1
  153. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-zk37paj9.js +8 -0
  154. package/dist/client/static/js/{timeline-definition-EJHVYXUP-rb0gnm35.js → timeline-definition-EJHVYXUP-q013vdd1.js} +7 -7
  155. package/dist/client/static/js/treeView-Q6P3EWNA-a5vgg4gz.js +1 -0
  156. package/dist/client/static/js/treemap-WGGIJYW6-ctqhajgg.js +1 -0
  157. package/dist/client/static/js/tsx-zy7hb2hw.js +1 -0
  158. package/dist/client/static/js/typescript-2hr53c8j.js +1 -0
  159. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-gatkznan.js → usecaseDiagram-POWQR4AR-7swsbqnq.js} +51 -51
  160. package/dist/client/static/js/{vennDiagram-UO4OBE2U-r3f5xjjq.js → vennDiagram-UO4OBE2U-9dygxdxf.js} +5 -5
  161. package/dist/client/static/js/{vue-myjjd0gd.js → vue-k3f3chre.js} +1 -1
  162. package/dist/client/static/js/wardley-WFR3VGLG-ns7e0fqf.js +1 -0
  163. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-tpass65t.js → wardleyDiagram-VNRHLVJA-aaaa9kj3.js} +4 -4
  164. package/dist/client/static/js/xml-p4742r9b.js +1 -0
  165. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8xkh67cw.js → xychartDiagram-PMCCYNJV-tamf39gx.js} +6 -6
  166. package/dist/client/static/js/yaml-qbckg671.js +1 -0
  167. package/marketplace/plugins/command-runner/README.md +5 -0
  168. package/marketplace/plugins/command-runner/package.json +2 -2
  169. package/marketplace/plugins/command-runner/src/panel/Output.test.tsx +177 -0
  170. package/marketplace/plugins/command-runner/src/panel/Output.tsx +53 -2
  171. package/package.json +3 -1
  172. package/public/tray-monochrome-dark.png +0 -0
  173. package/public/tray-monochrome-light.png +0 -0
  174. package/src/client/App.tsx +4 -0
  175. package/src/client/components/common/NotificationPermissionDialog.test.tsx +166 -0
  176. package/src/client/components/common/NotificationPermissionDialog.tsx +167 -0
  177. package/src/client/components/common/batch-selection/BatchDeleteModal.test.tsx +97 -0
  178. package/src/client/components/common/batch-selection/BatchDeleteModal.tsx +24 -1
  179. package/src/client/components/common/context-usage-button/SessionStats.tsx +4 -8
  180. package/src/client/components/common/context-usage-button/TokenTotals.tsx +51 -0
  181. package/src/client/components/common/context-usage-button/index.test.tsx +26 -3
  182. package/src/client/components/common/context-usage-button/index.tsx +2 -0
  183. package/src/client/components/common/diagram-viewer/index.tsx +11 -235
  184. package/src/client/components/common/fullscreen-viewer/fullscreen-viewer.test.tsx +108 -0
  185. package/src/client/components/common/fullscreen-viewer/index.tsx +326 -0
  186. package/src/client/components/common/header-button/index.test.tsx +97 -0
  187. package/src/client/components/common/header-button/index.tsx +67 -0
  188. package/src/client/components/common/header-controls/index.test.tsx +17 -1
  189. package/src/client/components/common/header-controls/index.tsx +18 -8
  190. package/src/client/components/common/image-viewer/fullscreen.tsx +64 -0
  191. package/src/client/components/common/progress-bar/index.tsx +53 -0
  192. package/src/client/components/common/session-actions-menu/MenuItem.tsx +36 -0
  193. package/src/client/components/common/session-actions-menu/index.test.tsx +79 -0
  194. package/src/client/components/common/session-actions-menu/index.tsx +62 -69
  195. package/src/client/components/common/session-delete-modal/index.tsx +5 -0
  196. package/src/client/components/common/session-row/TimeCell.tsx +22 -6
  197. package/src/client/components/common/session-row/TrailingSlot.tsx +3 -3
  198. package/src/client/components/common/session-row/index.tsx +6 -3
  199. package/src/client/components/common/session-row/row-state.ts +18 -0
  200. package/src/client/components/common/session-row/session-row.test.tsx +24 -0
  201. package/src/client/components/common/session-row/time-cell.test.tsx +110 -0
  202. package/src/client/components/layout/ActivityBar.test.ts +10 -116
  203. package/src/client/components/layout/ActivityBar.tsx +138 -134
  204. package/src/client/components/layout/ActivityBarDrag.test.ts +334 -0
  205. package/src/client/components/layout/LeftActivityBar.test.ts +30 -5
  206. package/src/client/components/layout/LeftDock.tsx +19 -1
  207. package/src/client/components/layout/PanelButton.tsx +93 -0
  208. package/src/client/components/layout/{PanelVisibilityMenu.tsx → VisibilityMenu.tsx} +37 -18
  209. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +30 -1
  210. package/src/client/components/layout/desktop-layout/PanelSuspense.tsx +30 -0
  211. package/src/client/components/layout/desktop-layout/ResizeHandle.tsx +24 -3
  212. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +62 -6
  213. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +28 -19
  214. package/src/client/components/layout/desktop-layout/index.tsx +7 -5
  215. package/src/client/components/layout/desktop-layout/resizer/index.tsx +17 -4
  216. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +4 -2
  217. package/src/client/components/layout/session-sidebar/Footer.test.tsx +76 -0
  218. package/src/client/components/layout/session-sidebar/Footer.tsx +13 -9
  219. package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -0
  220. package/src/client/components/layout/session-sidebar/SessionItem.test.ts +21 -0
  221. package/src/client/components/layout/session-sidebar/SessionItem.tsx +7 -4
  222. package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
  223. package/src/client/components/layout/session-sidebar/SessionsView.tsx +1 -0
  224. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +3 -1
  225. package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
  226. package/src/client/components/layout/session-sidebar/search-results.test.tsx +127 -0
  227. package/src/client/components/mobile/mobile-session-sidebar/Dialogs.tsx +1 -0
  228. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +31 -0
  229. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +8 -4
  230. package/src/client/components/mobile/mobile-session-sidebar/use-dock.test.ts +41 -0
  231. package/src/client/components/mobile/mobile-session-sidebar/use-dock.ts +4 -1
  232. package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +2 -0
  233. package/src/client/components/mobile/panel-chips.test.tsx +18 -11
  234. package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
  235. package/src/client/components/settings/categories/HarnessSettings.tsx +3 -1
  236. package/src/client/components/settings/categories/NotificationSettings.test.tsx +56 -2
  237. package/src/client/components/settings/categories/NotificationSettings.tsx +46 -6
  238. package/src/client/components/settings/categories/appearance-settings/TrayIconSection.test.tsx +81 -0
  239. package/src/client/components/settings/categories/appearance-settings/TrayIconSection.tsx +118 -0
  240. package/src/client/components/settings/categories/harness-settings/HarnessCard.import.test.tsx +124 -0
  241. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +21 -2
  242. package/src/client/components/settings/categories/harness-settings/HarnessImportControls.tsx +143 -0
  243. package/src/client/components/settings/categories/notification-settings/PermissionNotice.tsx +50 -0
  244. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +1 -1
  245. package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.test.tsx +107 -0
  246. package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.tsx +49 -24
  247. package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +3 -0
  248. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +4 -0
  249. package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -1
  250. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +6 -10
  251. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +45 -38
  252. package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +20 -18
  253. package/src/client/components/settings/categories/plugin-settings/PaneHeader.tsx +40 -0
  254. package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +6 -9
  255. package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +1 -25
  256. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.test.ts +9 -1
  257. package/src/client/components/workspace/chat-timeline/MessageItem.gutter.test.ts +4 -0
  258. package/src/client/components/workspace/chat-timeline/chat-input/expansion.test.ts +22 -2
  259. package/src/client/components/workspace/chat-timeline/chat-input/expansion.ts +15 -2
  260. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-parts.tsx +6 -11
  261. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolScreenshots.test.tsx +9 -0
  262. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolScreenshots.tsx +9 -18
  263. package/src/client/components/workspace/context-panel/index.tsx +18 -19
  264. package/src/client/components/workspace/editor/SplitColumn.tsx +5 -1
  265. package/src/client/components/workspace/file-explorer/Toolbar.tsx +40 -28
  266. package/src/client/components/workspace/git-panel/RepoHeader.tsx +27 -25
  267. package/src/client/components/workspace/git-panel/commit-modal/CommitActions.tsx +28 -77
  268. package/src/client/components/workspace/git-panel/commit-modal/CommitDiffViewer.tsx +15 -15
  269. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.test.ts +79 -5
  270. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.tsx +66 -45
  271. package/src/client/components/workspace/git-panel/commit-modal/GraphCanvas.tsx +1 -7
  272. package/src/client/components/workspace/git-panel/commit-modal/Header.test.tsx +90 -0
  273. package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +28 -18
  274. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +24 -7
  275. package/src/client/components/workspace/git-panel/commit-modal.test.ts +16 -0
  276. package/src/client/components/workspace/panel-header/index.test.tsx +80 -0
  277. package/src/client/components/workspace/panel-header/index.tsx +46 -0
  278. package/src/client/components/workspace/plan-panel/index.tsx +24 -22
  279. package/src/client/components/workspace/plugin-panel/catalog.tsx +21 -13
  280. package/src/client/components/workspace/search-panel/Body.tsx +42 -37
  281. package/src/client/components/workspace/terminal-panel/Header.tsx +37 -38
  282. package/src/client/components/workspace/terminal-panel/fonts.test.ts +40 -0
  283. package/src/client/components/workspace/terminal-panel/fonts.ts +27 -0
  284. package/src/client/components/workspace/terminal-panel/mount.ts +2 -5
  285. package/src/client/components/workspace/todo-panel/index.tsx +28 -26
  286. package/src/client/components/workspace/usage-panel/index.test.tsx +91 -0
  287. package/src/client/components/workspace/usage-panel/index.tsx +31 -55
  288. package/src/client/components/workspace/wiki-panel/index.tsx +47 -46
  289. package/src/client/data/context-data/index.ts +16 -0
  290. package/src/client/data/settings/omp-schema.json +201 -151
  291. package/src/client/hooks/chat/composer/auto-grow.ts +13 -3
  292. package/src/client/hooks/chat/omp/session-sidebar-controller.folder-open.test.ts +140 -0
  293. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +33 -203
  294. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +8 -6
  295. package/src/client/hooks/chat/timeline/jump-landing.ts +27 -9
  296. package/src/client/hooks/chat/timeline/jump-rail.ts +1 -0
  297. package/src/client/hooks/chat/timeline/reader-input.ts +39 -0
  298. package/src/client/hooks/chat/timeline/restore-history.ts +55 -0
  299. package/src/client/hooks/chat/timeline/row-window.test.ts +36 -3
  300. package/src/client/hooks/chat/timeline/row-window.ts +12 -3
  301. package/src/client/hooks/chat/timeline/scroll-geometry.ts +95 -0
  302. package/src/client/hooks/chat/timeline/scroll-probe.test-util.ts +17 -4
  303. package/src/client/hooks/chat/timeline/scroll.test.ts +53 -0
  304. package/src/client/hooks/chat/timeline/scroll.ts +30 -70
  305. package/src/client/hooks/chat/timeline/session-load.test.ts +25 -0
  306. package/src/client/hooks/chat/timeline/session-load.ts +8 -1
  307. package/src/client/hooks/chat/timeline/session-shapes.ts +3 -0
  308. package/src/client/hooks/models/use-harnesses-controller.ts +8 -1
  309. package/src/client/hooks/models/use-harnesses.ts +68 -1
  310. package/src/client/hooks/ui/navbar-controls.test.ts +50 -0
  311. package/src/client/hooks/ui/navbar-controls.ts +118 -0
  312. package/src/client/hooks/ui/pointer-hover.test.ts +94 -0
  313. package/src/client/hooks/ui/pointer-hover.ts +62 -0
  314. package/src/client/hooks/ui/ui-sounds.test.ts +4 -0
  315. package/src/client/hooks/workspace/batch-archive.ts +19 -3
  316. package/src/client/hooks/workspace/batch-delete-run.ts +15 -3
  317. package/src/client/hooks/workspace/batch-delete.test.ts +112 -0
  318. package/src/client/hooks/workspace/batch-delete.ts +51 -5
  319. package/src/client/hooks/workspace/left-dock.ts +14 -0
  320. package/src/client/hooks/workspace/panel-drop-target.test.tsx +119 -0
  321. package/src/client/hooks/workspace/panel-drop-target.ts +76 -0
  322. package/src/client/hooks/workspace/panel-menu-items.ts +57 -0
  323. package/src/client/hooks/workspace/panel-reorder.ts +5 -2
  324. package/src/client/lib/browser/download.ts +12 -1
  325. package/src/client/lib/notifications/active.ts +26 -0
  326. package/src/client/lib/notifications/native-banner-sound.test.ts +34 -1
  327. package/src/client/lib/notifications/native-banner-sound.ts +7 -0
  328. package/src/client/lib/notifications/os.test.ts +53 -0
  329. package/src/client/lib/notifications/os.ts +129 -5
  330. package/src/client/lib/session-export.test.ts +72 -0
  331. package/src/client/lib/session-export.ts +60 -0
  332. package/src/client/lib/ui/control-plate.test.ts +29 -0
  333. package/src/client/lib/ui/control-plate.ts +42 -0
  334. package/src/client/main.tsx +7 -0
  335. package/src/client/tailwind.css +18 -7
  336. package/src/server/lib/changes/attach.test.ts +3 -1
  337. package/src/server/lib/changes/capture-bash.server.ts +15 -1
  338. package/src/server/lib/changes/capture.server.ts +2 -0
  339. package/src/server/lib/changes/capture.test.ts +40 -0
  340. package/src/server/lib/changes/journal-read.server.ts +204 -0
  341. package/src/server/lib/changes/reader.server.ts +28 -184
  342. package/src/server/lib/changes/reader.test.ts +40 -0
  343. package/src/server/lib/changes/scan.server.ts +86 -12
  344. package/src/server/lib/changes/scan.test.ts +56 -0
  345. package/src/server/lib/changes/sessions.server.ts +15 -0
  346. package/src/server/lib/changes/temp-path.test.ts +45 -0
  347. package/src/server/lib/changes/temp-path.ts +102 -0
  348. package/src/server/lib/db/schema.ts +9 -0
  349. package/src/server/lib/harness/acp/client.ts +12 -6
  350. package/src/server/lib/harness/acp/frames-replay.test.ts +55 -0
  351. package/src/server/lib/harness/acp/frames.ts +45 -3
  352. package/src/server/lib/harness/acp/protocol.ts +29 -0
  353. package/src/server/lib/harness/acp/replay-transcript.test.ts +47 -0
  354. package/src/server/lib/harness/acp/replay-transcript.ts +55 -0
  355. package/src/server/lib/harness/acp/replay.ts +78 -0
  356. package/src/server/lib/harness/acp/session-config.ts +36 -1
  357. package/src/server/lib/harness/acp/session-handshake.ts +32 -8
  358. package/src/server/lib/harness/acp/session-observers.test.ts +2 -2
  359. package/src/server/lib/harness/acp/session-options.ts +9 -0
  360. package/src/server/lib/harness/acp/session-start.ts +62 -0
  361. package/src/server/lib/harness/acp/session.test-util.ts +2 -0
  362. package/src/server/lib/harness/acp/session.ts +33 -37
  363. package/src/server/lib/harness/acp/v2.test.ts +44 -0
  364. package/src/server/lib/harness/acp/v2.ts +38 -0
  365. package/src/server/lib/harness/acp/verbs.test.ts +37 -1
  366. package/src/server/lib/harness/acp/verbs.ts +52 -6
  367. package/src/server/lib/harness/auto-import.server.test.ts +92 -0
  368. package/src/server/lib/harness/auto-import.server.ts +209 -0
  369. package/src/server/lib/harness/auto-probe.server.ts +9 -3
  370. package/src/server/lib/harness/codex/transcript.server.test.ts +67 -0
  371. package/src/server/lib/harness/codex/transcript.server.ts +222 -0
  372. package/src/server/lib/harness/schema.server.ts +15 -7
  373. package/src/server/lib/harness/session-delete.server.test.ts +156 -0
  374. package/src/server/lib/harness/session-delete.server.ts +198 -0
  375. package/src/server/lib/harness/session-import.server.ts +177 -0
  376. package/src/server/lib/harness/session-store.server.test.ts +85 -0
  377. package/src/server/lib/harness/session-store.server.ts +70 -3
  378. package/src/server/lib/harness/session-transcript.server.test.ts +183 -0
  379. package/src/server/lib/harness/session-transcript.server.ts +301 -0
  380. package/src/server/lib/harness/session.ts +4 -2
  381. package/src/server/lib/harness/spawn.server.ts +9 -0
  382. package/src/server/lib/lifecycle/after-listen.ts +11 -5
  383. package/src/server/lib/model-roles/mock.server.test.ts +35 -0
  384. package/src/server/lib/model-roles/mock.server.ts +1 -1
  385. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +15 -4
  386. package/src/server/lib/omp/session/delete-flow.server.ts +62 -9
  387. package/src/server/lib/omp/session/delete.server.ts +6 -0
  388. package/src/server/lib/omp/session/sidebar-data.harness.test.ts +86 -1
  389. package/src/server/lib/omp/session/sidebar-data.server.ts +41 -70
  390. package/src/server/lib/omp/session/sidebar-status.server.ts +82 -0
  391. package/src/server/lib/omp/session/telemetry/compute.ts +18 -0
  392. package/src/server/lib/omp/session/telemetry.test.ts +21 -0
  393. package/src/server/lib/realtime/topics/catalog.server.ts +2 -1
  394. package/src/server/lib/realtime/topics.server.ts +2 -1
  395. package/src/server/lib/sessions/deleted-sessions.server.test.ts +49 -0
  396. package/src/server/lib/sessions/deleted-sessions.server.ts +45 -0
  397. package/src/server/lib/tray/config.ts +19 -4
  398. package/src/server/lib/tray/host/darwin.js +6 -1
  399. package/src/server/lib/tray/host/linux.js +2 -1
  400. package/src/server/lib/tray/host/win32.ps1 +7 -1
  401. package/src/server/lib/tray/runtime.server.ts +81 -3
  402. package/src/server/lib/tray/tray.test.ts +20 -0
  403. package/src/server/routes/agent/command.ts +4 -0
  404. package/src/server/routes/agent/harness-command.ts +77 -3
  405. package/src/server/routes/agent/restore.ts +50 -0
  406. package/src/server/routes/chat/imported.ts +32 -0
  407. package/src/server/routes/chat/session.ts +33 -21
  408. package/src/server/routes/chat/window.ts +25 -0
  409. package/src/server/routes/folders/batch-delete.ts +3 -4
  410. package/src/server/routes/harness/root.ts +17 -1
  411. package/src/server/routes/harness/session-actions.ts +60 -0
  412. package/src/server/routes/harness/session-import.test.ts +81 -0
  413. package/src/server/routes/sessions/batch-archive.ts +5 -4
  414. package/src/server/routes/sessions/batch-delete.ts +23 -12
  415. package/src/server/routes/sessions/delete-acp.test.ts +70 -0
  416. package/src/server/routes/sessions/export.test.ts +83 -0
  417. package/src/server/routes/sessions/export.ts +59 -0
  418. package/src/server/routes/sessions/index.ts +4 -0
  419. package/src/server/routes/sessions/list.ts +5 -0
  420. package/src/server/routes/settings/root.ts +13 -0
  421. package/src/shared/lib/chat/export-markdown.test.ts +110 -0
  422. package/src/shared/lib/chat/export-markdown.ts +141 -0
  423. package/src/shared/lib/omp/config/schema-releases.test.ts +193 -0
  424. package/src/shared/lib/omp/config/schema.test.ts +0 -117
  425. package/src/shared/lib/realtime/connection.ts +4 -0
  426. package/src/shared/lib/sessions/batch-limits.test.ts +51 -0
  427. package/src/shared/lib/sessions/batch-limits.ts +42 -0
  428. package/src/shared/lib/settings/defaults.ts +2 -0
  429. package/src/shared/lib/theme/tray-icon-style.test.ts +43 -0
  430. package/src/shared/lib/theme/tray-icon-style.ts +69 -0
  431. package/src/shared/lib/workspace/left-dock-width.ts +23 -3
  432. package/src/shared/lib/workspace/left-dock.test.ts +38 -10
  433. package/src/shared/lib/workspace/left-dock.ts +39 -14
  434. package/src/shared/lib/workspace/panel-drag.test.ts +52 -0
  435. package/src/shared/lib/workspace/panel-drag.ts +34 -0
  436. package/src/shared/lib/workspace/panel-open.test.ts +7 -1
  437. package/src/shared/lib/workspace/session-state/store.ts +0 -1
  438. package/src/shared/types/context.ts +20 -0
  439. package/src/shared/types/harness.ts +26 -0
  440. package/src/shared/types/settings/state.ts +9 -0
  441. package/src/test-support/fake-acp-delete.ts +63 -0
  442. package/src/test-support/sidebar-controller-harness.test-util.ts +121 -0
  443. package/dist/client/static/js/DrawioView-1ts9y0yk.js +0 -5
  444. package/dist/client/static/js/ImageView-w2hyp129.js +0 -1
  445. package/dist/client/static/js/LayoutWrapper-pdvfkncm.js +0 -2
  446. package/dist/client/static/js/Modal-2sx1tgqr.js +0 -38
  447. package/dist/client/static/js/SessionsView-a8921ysr.js +0 -1
  448. package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +0 -1
  449. package/dist/client/static/js/architectureDiagram-NJMV4G6O-z3n19xwk.js +0 -36
  450. package/dist/client/static/js/bash-b3rwyg5p.js +0 -1
  451. package/dist/client/static/js/c-jkdstn33.js +0 -1
  452. package/dist/client/static/js/cpp-9d3xdpe3.js +0 -1
  453. package/dist/client/static/js/css-r3wja1ze.js +0 -1
  454. package/dist/client/static/js/css-sebxkh5f.js +0 -1
  455. package/dist/client/static/js/cynefin-OW5HDTMX-w2f2vev7.js +0 -1
  456. package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +0 -1
  457. package/dist/client/static/js/flowDiagram-KWPJA3E3-zmz4grtx.js +0 -1
  458. package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +0 -1
  459. package/dist/client/static/js/graphql-p4cskvad.js +0 -1
  460. package/dist/client/static/js/html-f26r6vv5.js +0 -1
  461. package/dist/client/static/js/index-1c7294vk.js +0 -1
  462. package/dist/client/static/js/index-2mx9ej4k.css +0 -1
  463. package/dist/client/static/js/index-2xb54jt3.js +0 -4
  464. package/dist/client/static/js/index-6d5qj0kb.js +0 -1
  465. package/dist/client/static/js/index-6k2x281j.js +0 -12
  466. package/dist/client/static/js/index-6rt7gs1j.js +0 -1
  467. package/dist/client/static/js/index-737w2mqf.js +0 -1
  468. package/dist/client/static/js/index-a5ptb956.js +0 -3
  469. package/dist/client/static/js/index-aa6qdgmv.js +0 -1
  470. package/dist/client/static/js/index-arvqarv3.js +0 -7
  471. package/dist/client/static/js/index-bgcp21ed.js +0 -1
  472. package/dist/client/static/js/index-d8kjsgpt.js +0 -474
  473. package/dist/client/static/js/index-enxfdvdq.js +0 -1
  474. package/dist/client/static/js/index-hp8kfk9z.js +0 -1
  475. package/dist/client/static/js/index-r83kr4s5.js +0 -2
  476. package/dist/client/static/js/index-rtd9frp1.js +0 -2
  477. package/dist/client/static/js/index-s910y31q.js +0 -1
  478. package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +0 -1
  479. package/dist/client/static/js/ini-cg0a5wm3.js +0 -1
  480. package/dist/client/static/js/java-vcck089n.js +0 -1
  481. package/dist/client/static/js/javascript-nyf39d5r.js +0 -1
  482. package/dist/client/static/js/json-j5q8nt57.js +0 -1
  483. package/dist/client/static/js/jsx-ht9zyzwa.js +0 -1
  484. package/dist/client/static/js/lua-86fjqj8v.js +0 -1
  485. package/dist/client/static/js/markdown-gwmsh53r.js +0 -1
  486. package/dist/client/static/js/one-dark-pro-kckm8epj.js +0 -1
  487. package/dist/client/static/js/one-light-0v7rg9a7.js +0 -1
  488. package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +0 -1
  489. package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +0 -1
  490. package/dist/client/static/js/pieDiagram-5QR66LMP-nz6n95d6.js +0 -39
  491. package/dist/client/static/js/properties-mzvvbqg5.js +0 -1
  492. package/dist/client/static/js/python-3w64wsyd.js +0 -1
  493. package/dist/client/static/js/r-32re2zwb.js +0 -1
  494. package/dist/client/static/js/radar-RG4KPBEZ-m3tsyfv0.js +0 -1
  495. package/dist/client/static/js/railroad-74A4TZTK-5p202a4q.js +0 -1
  496. package/dist/client/static/js/railroad-abnf-HS5TGJTU-hj0y9tgn.js +0 -1
  497. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-8c5dct8f.js +0 -1
  498. package/dist/client/static/js/railroad-peg-WCYAUIDC-3tx8z65q.js +0 -1
  499. package/dist/client/static/js/sql-0e9mnrda.js +0 -1
  500. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-56rk9kxv.js +0 -8
  501. package/dist/client/static/js/treeView-Q6P3EWNA-mf0rb2yv.js +0 -1
  502. package/dist/client/static/js/treemap-WGGIJYW6-0x5gf06b.js +0 -1
  503. package/dist/client/static/js/tsx-nm94hed6.js +0 -1
  504. package/dist/client/static/js/typescript-5nmrzgkj.js +0 -1
  505. package/dist/client/static/js/wardley-WFR3VGLG-x7ej8dms.js +0 -1
  506. package/dist/client/static/js/xml-3dd1pter.js +0 -1
  507. package/dist/client/static/js/yaml-yssayv8a.js +0 -1
  508. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +0 -229
@@ -54,6 +54,8 @@ export async function computeRealSessionTelemetry(
54
54
  let sumOutput = 0;
55
55
  let sumCacheRead = 0;
56
56
  let sumCacheWrite = 0;
57
+ let sumTotal = 0;
58
+ let sumReasoning = 0;
57
59
  // Cache-hit average only counts warmed calls — any assistant call that read
58
60
  // zero cache tokens (cold request) is excluded, not just the very first one.
59
61
  let cacheAvgInput = 0;
@@ -153,6 +155,8 @@ export async function computeRealSessionTelemetry(
153
155
  sumOutput += tokens.output;
154
156
  sumCacheRead += tokens.cacheRead;
155
157
  sumCacheWrite += tokens.cacheWrite;
158
+ sumTotal += tokens.total;
159
+ sumReasoning += tokens.reasoning;
156
160
  if (msg.role === 'assistant' && tokens.cacheRead > 0) {
157
161
  cacheAvgInput += tokens.input;
158
162
  cacheAvgCacheRead += tokens.cacheRead;
@@ -262,6 +266,20 @@ export async function computeRealSessionTelemetry(
262
266
  },
263
267
  cacheHitAverage,
264
268
  costBreakdown: { input: costInput, output: costOutput, cacheRead: costCacheRead, cacheWrite: costCacheWrite, total: totalCost },
269
+ // Only when a call actually reported usage: a transcript with messages but
270
+ // no usage has no measured totals, and zeros would read as "nothing ran".
271
+ ...(hasUsage
272
+ ? {
273
+ totals: {
274
+ total: sumTotal,
275
+ input: sumInput,
276
+ cacheRead: sumCacheRead,
277
+ cacheWrite: sumCacheWrite,
278
+ output: sumOutput,
279
+ reasoning: sumReasoning,
280
+ },
281
+ }
282
+ : {}),
265
283
  lastMessage: {
266
284
  input: lastTokens.input,
267
285
  output: lastTokens.output,
@@ -150,6 +150,27 @@ describe('computeRealSessionTelemetry context anchor', () => {
150
150
  expect(telemetry.distribution.otherTokens).toBe(350);
151
151
  expect(telemetry.totalCost).toBeCloseTo(0.03, 5);
152
152
  expect(telemetry.contextUsed).toBe(2200);
153
+ // Session-wide totals, summed over both calls: the provider's own
154
+ // processed count plus the four parts the popover splits out.
155
+ expect(telemetry.totals).toEqual({
156
+ total: 3700,
157
+ input: 3000,
158
+ cacheRead: 350,
159
+ cacheWrite: 50,
160
+ output: 300,
161
+ reasoning: 0,
162
+ });
163
+ });
164
+
165
+ test('omits totals when no call reported usage', async () => {
166
+ const file = await writeSession([
167
+ header,
168
+ userMessage('u1', 'no usage here'),
169
+ assistantMessage('a1', {}),
170
+ ]);
171
+
172
+ const telemetry = await computeRealSessionTelemetry(file, 'ses_telemetry');
173
+ expect(telemetry.totals).toBeUndefined();
153
174
  });
154
175
  });
155
176
 
@@ -33,7 +33,8 @@ import {
33
33
  import type { SidebarActivityPayload, SidebarPayload, SidebarStatusPayload } from '@/shared/types/realtime';
34
34
  import { isValidPluginId } from '@/shared/lib/plugins/protocol';
35
35
  import type { TopicDescriptor } from '@/server/lib/realtime/hub.types';
36
- import { loadSidebarStatus, loadSidebarStructure } from '@/server/lib/omp/session/sidebar-data.server';
36
+ import { loadSidebarStructure } from '@/server/lib/omp/session/sidebar-data.server';
37
+ import { loadSidebarStatus } from '@/server/lib/omp/session/sidebar-status.server';
37
38
  import { loadSidebarActivity } from '@/server/lib/omp/session/sidebar-activity.server';
38
39
  import { sessionDescriptor } from '@/server/lib/realtime/topics/session.server';
39
40
  import { btwDescriptor } from '@/server/lib/realtime/topics/btw.server';
@@ -29,7 +29,8 @@ import {
29
29
  import { getRealtimeHub, registerTopics, type TopicDescriptor } from '@/server/lib/realtime/hub.server';
30
30
  import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
31
31
  import { invalidateOmpSidebarData } from '@/server/lib/omp/session/reader';
32
- import { loadSidebarStatus, loadSidebarStructure } from '@/server/lib/omp/session/sidebar-data.server';
32
+ import { loadSidebarStructure } from '@/server/lib/omp/session/sidebar-data.server';
33
+ import { loadSidebarStatus } from '@/server/lib/omp/session/sidebar-status.server';
33
34
  import { loadSidebarActivity } from '@/server/lib/omp/session/sidebar-activity.server';
34
35
  import { EXACT_TOPICS, descriptorFor, isKnownTopicName } from '@/server/lib/realtime/topics/catalog.server';
35
36
 
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The deleted-session tombstone.
8
+ *
9
+ * The bug this pins: deleting an imported chat removed Kabmo's rows, the agent
10
+ * kept its copy, and the next import put the chat back. The tombstone is the
11
+ * durable answer — the delete writes the id, and the import and the sidebar
12
+ * skip it.
13
+ */
14
+
15
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
16
+ import { getDb } from '@/server/db.server';
17
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
18
+ import { loadDeletedSessionIds, markSessionDeleted } from '@/server/lib/sessions/deleted-sessions.server';
19
+
20
+ beforeEach(async () => {
21
+ await isolateDb();
22
+ });
23
+
24
+ afterEach(async () => {
25
+ await releaseDb();
26
+ });
27
+
28
+ describe('deleted session tombstones', () => {
29
+ test('a marked id is loaded, and marking twice is a no-op', async () => {
30
+ await markSessionDeleted('ses_gone');
31
+ await markSessionDeleted('ses_gone');
32
+ expect([...(await loadDeletedSessionIds())]).toEqual(['ses_gone']);
33
+ });
34
+
35
+ test('an empty id is not written', async () => {
36
+ await markSessionDeleted('');
37
+ expect((await loadDeletedSessionIds()).size).toBe(0);
38
+ });
39
+
40
+ test('the tombstone outlives the rows it was written with', async () => {
41
+ const db = await getDb();
42
+ await db.run('INSERT INTO harness_sessions (session_id, harness, agent_session_id, cwd, created_at, updated_at) VALUES (?, ?, ?, ?, 1, 1)', [
43
+ 'ses_gone', 'opencode', '', '/tmp/project',
44
+ ]);
45
+ await markSessionDeleted('ses_gone');
46
+ await db.run('DELETE FROM harness_sessions WHERE session_id = ?', ['ses_gone']);
47
+ expect((await loadDeletedSessionIds()).has('ses_gone')).toBe(true);
48
+ });
49
+ });
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The tombstone a deleted session leaves behind.
8
+ *
9
+ * Deleting a chat removes Kabmo's rows and asks the agent to drop its own copy.
10
+ * That is not enough for an IMPORTED chat: the agent's store is the source the
11
+ * import copies from, and an agent that keeps the conversation (or a delete
12
+ * that only removed Kabmo's rows) puts the chat back on the next pass. The
13
+ * reported defect is exactly that — delete an imported row, watch it return.
14
+ *
15
+ * `deleted_sessions` is the durable answer: the delete writes the id, and both
16
+ * the import and the sidebar skip it. It is a TOMBSTONE, not a cache: it
17
+ * outlives the process, a reload and a second instance, because the agent's
18
+ * store does.
19
+ *
20
+ * The table is keyed by session id alone. A session id is unique across the
21
+ * harnesses Kabmo records, and the id is what the import and the scan both
22
+ * carry.
23
+ */
24
+
25
+ import { getDb } from '@/server/db.server';
26
+
27
+ /** Tombstone one deleted session. Idempotent: a repeated delete is a no-op. */
28
+ export async function markSessionDeleted(sessionId: string): Promise<void> {
29
+ if (!sessionId) return;
30
+ const db = await getDb();
31
+ await db.run('INSERT OR IGNORE INTO deleted_sessions (session_id) VALUES (?)', [sessionId]);
32
+ }
33
+
34
+ /**
35
+ * Every tombstoned session id, for one import or sidebar pass.
36
+ *
37
+ * A Set rather than a per-row query: the import walks hundreds of rows and the
38
+ * sidebar assembles every folder, so one read is the difference between one
39
+ * query and one per session.
40
+ */
41
+ export async function loadDeletedSessionIds(): Promise<Set<string>> {
42
+ const db = await getDb();
43
+ const rows = (await db.all('SELECT session_id FROM deleted_sessions')) as { session_id: string }[];
44
+ return new Set(rows.map((row) => row.session_id));
45
+ }
@@ -16,6 +16,7 @@
16
16
  import fs from 'node:fs';
17
17
 
18
18
  import { getDataDir } from '@/server/lib/lifecycle/paths';
19
+ import type { TrayIconStyle } from '@/shared/lib/theme/tray-icon-style';
19
20
 
20
21
  /** The tray's own name, shown in the menu and the tooltip. */
21
22
  export const TRAY_LABEL = 'Kabmo';
@@ -53,6 +54,16 @@ export interface TrayConfig {
53
54
  cli: string;
54
55
  /** Packaged icon; falls back to the title when it does not load. */
55
56
  icon: string;
57
+ /**
58
+ * Which icon the host draws (`color` | `monochrome`). The host is a separate
59
+ * process and cannot read the page, so the choice travels in the config.
60
+ */
61
+ iconStyle: TrayIconStyle;
62
+ /**
63
+ * The greyscale plate for the active theme's variant: the green plate and
64
+ * the cream strokes swap luminance, and the orange arm is the middle grey.
65
+ */
66
+ iconMono: string;
56
67
  logFile: string;
57
68
  dataDir: string;
58
69
  pidFile: string;
@@ -76,7 +87,7 @@ export function trayUrl(port: number, host: string, tls: boolean): string {
76
87
  }
77
88
 
78
89
  /** Resolve `..`/symlinks; fall back to the input when it does not exist. */
79
- function canonicalize(value: string): string {
90
+ export function canonicalizeTrayPath(value: string): string {
80
91
  try {
81
92
  return fs.realpathSync(value);
82
93
  } catch {
@@ -85,7 +96,7 @@ function canonicalize(value: string): string {
85
96
  }
86
97
 
87
98
  /** Build the config for a server on `port`. */
88
- export function buildTrayConfig({ pkgRoot, port, host, tls, dataDir, bun, icon, pidFile, loginInstalled }: {
99
+ export function buildTrayConfig({ pkgRoot, port, host, tls, dataDir, bun, icon, iconStyle, iconMono, pidFile, loginInstalled }: {
89
100
  pkgRoot: string;
90
101
  port: number;
91
102
  host: string;
@@ -93,6 +104,8 @@ export function buildTrayConfig({ pkgRoot, port, host, tls, dataDir, bun, icon,
93
104
  dataDir: string;
94
105
  bun: string;
95
106
  icon: string;
107
+ iconStyle: TrayIconStyle;
108
+ iconMono: string;
96
109
  pidFile: string;
97
110
  loginInstalled: boolean;
98
111
  }): TrayConfig {
@@ -108,8 +121,10 @@ export function buildTrayConfig({ pkgRoot, port, host, tls, dataDir, bun, icon,
108
121
  // segment, so a path assembled from a `..`-bearing root would carry it into
109
122
  // a login entry's argv, where it is interpreted much later. Measured: a
110
123
  // generated LaunchAgent held `<pkg>/src/cli/../../src/cli/kabmo.js`.
111
- cli: canonicalize(`${pkgRoot}/src/cli/kabmo.js`),
112
- icon: canonicalize(icon),
124
+ cli: canonicalizeTrayPath(`${pkgRoot}/src/cli/kabmo.js`),
125
+ icon: canonicalizeTrayPath(icon),
126
+ iconStyle,
127
+ iconMono: canonicalizeTrayPath(iconMono),
113
128
  logFile: `${dataDir}/logs/kabmo-${port}.log`,
114
129
  dataDir,
115
130
  pidFile,
@@ -142,9 +142,14 @@ function run(argv) {
142
142
 
143
143
  // The bundled icon when it loads; the name otherwise, so a missing asset
144
144
  // leaves a visible tray rather than an invisible zero-width item.
145
+ //
146
+ // Monochrome is the grey plate with the K knocked out, drawn AS-IS: the user
147
+ // asked for grey, and a template image would be repainted in the menu bar's
148
+ // own ink (black or white) instead.
145
149
  let drew = false;
150
+ const iconPath = config.iconStyle === 'monochrome' ? config.iconMono : config.icon;
146
151
  try {
147
- const image = $.NSImage.alloc.initWithContentsOfFile($.NSString.alloc.initWithUTF8String(config.icon));
152
+ const image = $.NSImage.alloc.initWithContentsOfFile($.NSString.alloc.initWithUTF8String(iconPath));
148
153
  if (image && image.size && image.size.width > 0) {
149
154
  image.setSize($.NSMakeSize(18, 18));
150
155
  statusItem.setImage(image);
@@ -117,12 +117,13 @@ async function main() {
117
117
  );
118
118
  }
119
119
 
120
+ const iconPath = config.iconStyle === 'monochrome' ? config.iconMono : config.icon;
120
121
  const proc = Bun.spawn({
121
122
  cmd: [
122
123
  client.bin,
123
124
  '--notification',
124
125
  '--listen',
125
- `--image=${config.icon}`,
126
+ `--image=${iconPath}`,
126
127
  `--text=${config.label} · ${config.url}`,
127
128
  `--menu=${menuPayload(buildMenuModel(config))}`,
128
129
  '--no-middle',
@@ -35,7 +35,13 @@ function Invoke-Cli([string[]]$extra) {
35
35
  }
36
36
 
37
37
  $notify = New-Object System.Windows.Forms.NotifyIcon
38
- $notify.Icon = New-Object System.Drawing.Icon($config.icon)
38
+ # The shipped assets are PNGs, and `System.Drawing.Icon` only reads .ico files —
39
+ # constructing it from a PNG throws. A Bitmap plus `GetHicon()` is the documented
40
+ # way to turn a PNG into a NotifyIcon icon. Monochrome uses the glyph tinted for
41
+ # the active theme's variant; colour uses the app icon.
42
+ $iconPath = if ($config.iconStyle -eq 'monochrome') { $config.iconMono } else { $config.icon }
43
+ $iconBitmap = [System.Drawing.Bitmap]::FromFile($iconPath)
44
+ $notify.Icon = [System.Drawing.Icon]::FromHandle($iconBitmap.GetHicon())
39
45
  $notify.Text = "$($config.label) - $($config.url)"
40
46
  $notify.Visible = $true
41
47
 
@@ -29,9 +29,19 @@
29
29
  import { getDataDir } from '@/server/lib/lifecycle/paths';
30
30
  import { resolveBunBin } from '@/server/lib/lifecycle/bun';
31
31
  import { packageDir } from '@/server/lib/fs/package-root';
32
+ import { getDb } from '@/server/db.server';
33
+ import { readAllSettingsJson } from '@/server/lib/db/settings-store';
34
+ import { readSettingsBlob } from '@/shared/lib/settings/keys';
35
+ import { resolveTheme } from '@/shared/lib/theme/catalog';
36
+ import {
37
+ resolveTrayIconStyle,
38
+ TRAY_ICON_STYLE_SETTING_KEY,
39
+ type TrayIconStyle,
40
+ } from '@/shared/lib/theme/tray-icon-style';
32
41
  import { isAutostartInstalled } from '@/server/lib/tray/autostart';
33
42
  import {
34
43
  buildTrayConfig,
44
+ canonicalizeTrayPath,
35
45
  getTrayConfigPath,
36
46
  writeTrayConfig,
37
47
  type TrayConfig,
@@ -45,6 +55,37 @@ interface TrayRuntime {
45
55
  config: TrayConfig;
46
56
  }
47
57
 
58
+ /** The two facts the tray icon needs from the stored settings. */
59
+ export interface TrayAppearance {
60
+ iconStyle: TrayIconStyle;
61
+ /** Absolute path to the greyscale plate for the active theme's variant. */
62
+ iconMono: string;
63
+ }
64
+
65
+ /**
66
+ * Read the tray's appearance from `app_settings`.
67
+ *
68
+ * A failed read is the shipped default (colour, light glyph) rather than a
69
+ * thrown error: the tray is a convenience over the console, and a database
70
+ * hiccup must not stop the server from raising its icon.
71
+ */
72
+ export async function readTrayAppearance(pkgRoot: string): Promise<TrayAppearance> {
73
+ let settings: Record<string, unknown> = {};
74
+ try {
75
+ const db = await getDb();
76
+ settings = await readAllSettingsJson(db);
77
+ } catch {
78
+ // Fall through to the defaults below.
79
+ }
80
+ const blob = readSettingsBlob(settings);
81
+ const theme = typeof blob.theme === 'string' ? blob.theme : undefined;
82
+ const variant = resolveTheme(theme).variant;
83
+ return {
84
+ iconStyle: resolveTrayIconStyle(blob[TRAY_ICON_STYLE_SETTING_KEY]),
85
+ iconMono: canonicalizeTrayPath(`${packageDir(pkgRoot)}/public/tray-monochrome-${variant}.png`),
86
+ };
87
+ }
88
+
48
89
  /**
49
90
  * The running host, anchored on `globalThis` for the reason the database handle
50
91
  * is: `bun --hot` re-evaluates a changed module in place, so a module-level
@@ -63,11 +104,12 @@ export function isTrayRunning(): boolean {
63
104
  }
64
105
 
65
106
  /** Resolve every path a host needs and write the config document for `port`. */
66
- export function writeTrayConfigFor({ port, host, tls, pkgRoot }: {
107
+ export function writeTrayConfigFor({ port, host, tls, pkgRoot, appearance }: {
67
108
  port: number;
68
109
  host: string;
69
110
  tls: boolean;
70
111
  pkgRoot: string;
112
+ appearance: TrayAppearance;
71
113
  }): TrayConfig {
72
114
  const config = buildTrayConfig({
73
115
  pkgRoot,
@@ -77,6 +119,8 @@ export function writeTrayConfigFor({ port, host, tls, pkgRoot }: {
77
119
  dataDir: getDataDir(),
78
120
  bun: resolveBunBin(),
79
121
  icon: `${packageDir(pkgRoot)}/public/icon-192x192.png`,
122
+ iconStyle: appearance.iconStyle,
123
+ iconMono: appearance.iconMono,
80
124
  pidFile: `${getDataDir()}/tray/host/tray-${port}.pid`,
81
125
  loginInstalled: isAutostartInstalled(),
82
126
  });
@@ -95,11 +139,12 @@ export function writeTrayConfigFor({ port, host, tls, pkgRoot }: {
95
139
  * on Linux, a JXA error) writes its reason into the server's own log instead of
96
140
  * vanishing. A host that starts successfully prints nothing.
97
141
  */
98
- export function ensureTray({ port, host, tls, pkgRoot, platform = process.platform }: {
142
+ export function ensureTray({ port, host, tls, pkgRoot, appearance, platform = process.platform }: {
99
143
  port: number;
100
144
  host: string;
101
145
  tls: boolean;
102
146
  pkgRoot: string;
147
+ appearance: TrayAppearance;
103
148
  platform?: NodeJS.Platform;
104
149
  }): { started: boolean; reason?: string } {
105
150
  if (isTrayRunning()) return { started: false, reason: 'already running' };
@@ -108,7 +153,7 @@ export function ensureTray({ port, host, tls, pkgRoot, platform = process.platfo
108
153
  if (!hostScript.available()) return { started: false, reason: hostScript.unavailableReason };
109
154
 
110
155
  try {
111
- const config = writeTrayConfigFor({ port, host, tls, pkgRoot });
156
+ const config = writeTrayConfigFor({ port, host, tls, pkgRoot, appearance });
112
157
  installHostScript(platform);
113
158
  const child = Bun.spawn({
114
159
  cmd: hostScript.interpreter(getTrayConfigPath(port)),
@@ -130,3 +175,36 @@ export function ensureTray({ port, host, tls, pkgRoot, platform = process.platfo
130
175
  return { started: false, reason: error instanceof Error ? error.message : String(error) };
131
176
  }
132
177
  }
178
+
179
+ /**
180
+ * Re-apply the stored appearance to a RUNNING tray.
181
+ *
182
+ * The host is a separate process that reads its config once, so a settings edit
183
+ * cannot reach it any other way. The old child is stopped and a new one started
184
+ * with the same listener facts; when nothing moved this is a no-op, which is
185
+ * what makes it safe to call after every settings write.
186
+ */
187
+ export async function refreshTrayIcon({ pkgRoot }: { pkgRoot: string }): Promise<{ updated: boolean; reason?: string }> {
188
+ const runtime = slot().current;
189
+ if (!runtime) return { updated: false, reason: 'not running' };
190
+
191
+ const appearance = await readTrayAppearance(pkgRoot);
192
+ if (appearance.iconStyle === runtime.config.iconStyle && appearance.iconMono === runtime.config.iconMono) {
193
+ return { updated: false, reason: 'unchanged' };
194
+ }
195
+
196
+ try {
197
+ runtime.child.kill();
198
+ } catch {
199
+ // The host is already gone; starting the replacement is all that is left.
200
+ }
201
+ slot().current = null;
202
+ const result = ensureTray({
203
+ port: runtime.config.port,
204
+ host: runtime.config.host,
205
+ tls: runtime.config.tls,
206
+ pkgRoot,
207
+ appearance,
208
+ });
209
+ return { updated: result.started, reason: result.reason };
210
+ }
@@ -107,6 +107,8 @@ describe('buildTrayConfig', () => {
107
107
  dataDir: '/data',
108
108
  bun: '/bun',
109
109
  icon: join(process.cwd(), 'public', 'icon-192x192.png'),
110
+ iconStyle: 'color',
111
+ iconMono: join(process.cwd(), 'public', 'tray-monochrome-light.png'),
110
112
  pidFile: '/data/tray/host/tray-3999.pid',
111
113
  loginInstalled: false,
112
114
  });
@@ -116,6 +118,24 @@ describe('buildTrayConfig', () => {
116
118
  expect(config.logFile).toBe('/data/logs/kabmo-3999.log');
117
119
  expect(config.loginInstalled).toBe(false);
118
120
  });
121
+
122
+ test('carries the icon style and the monochrome glyph the host draws', () => {
123
+ const config = buildTrayConfig({
124
+ pkgRoot: process.cwd(),
125
+ port: 3999,
126
+ host: '127.0.0.1',
127
+ tls: false,
128
+ dataDir: '/data',
129
+ bun: '/bun',
130
+ icon: join(process.cwd(), 'public', 'icon-192x192.png'),
131
+ iconStyle: 'monochrome',
132
+ iconMono: join(process.cwd(), 'public', 'tray-monochrome-dark.png'),
133
+ pidFile: '/data/tray/host/tray-3999.pid',
134
+ loginInstalled: false,
135
+ });
136
+ expect(config.iconStyle).toBe('monochrome');
137
+ expect(config.iconMono).toContain('tray-monochrome-dark.png');
138
+ });
119
139
  });
120
140
 
121
141
  describe('linux host menu', () => {
@@ -15,6 +15,7 @@ import { mintAgentEnvironment, rememberAgentToken } from '@/server/lib/sessions/
15
15
  import { resetGoalDriverState } from '@/server/lib/omp/session/goal-driver.server';
16
16
  import { forwardToPeer, isPeerRelayed, peerOriginForSession } from '@/server/lib/omp/rpc/peer-proxy.server';
17
17
  import { applyHarnessMode, resumeRecordedHarnessSession } from '@/server/routes/agent/harness-command';
18
+ import { restoreChatResponse } from '@/server/routes/agent/restore';
18
19
  import { asHarnessSession } from '@/server/lib/harness/registry';
19
20
  import { asOmpSession, getLiveSession } from '@/server/lib/omp/rpc/session-registry';
20
21
  import { recordPrompt } from '@/server/lib/chat/prompt-history.server';
@@ -54,6 +55,9 @@ export async function sendCommand({ params, request }: ActionFunctionArgs) {
54
55
  // default. omp has no RPC to change the mode after spawn.
55
56
  const explicitMode = isApprovalMode(body.accessMode) ? body.accessMode : null;
56
57
 
58
+ // RESTORE: an imported chat's history lives in the agent, not in Kabmo.
59
+ if (body.type === 'restore') return restoreChatResponse(sessionId, explicitMode);
60
+
57
61
  // A command that moves the conversation is refused while a side question is
58
62
  // in flight on this session — the question's snapshot describes the
59
63
  // transcript this command would replace (omp blocks the same operations).
@@ -14,9 +14,13 @@
14
14
  */
15
15
 
16
16
  import { freshProbe } from '@/server/lib/harness/probe-cache.server';
17
- import { startAcpSession } from '@/server/lib/harness/spawn.server';
17
+ import { startAcpSession, takeAcpReplayEvents } from '@/server/lib/harness/spawn.server';
18
18
  import { mintAgentEnvironment, rememberAgentToken } from '@/server/lib/sessions/agent-token.server';
19
- import { knownHarness, loadHarnessSession, repointHarnessSession } from '@/server/lib/harness/session-store.server';
19
+ import {
20
+ knownHarness, loadHarnessSession, loadHarnessSessionTitle, repointHarnessSession,
21
+ } from '@/server/lib/harness/session-store.server';
22
+ import { transcriptFromReplay } from '@/server/lib/harness/acp/replay-transcript';
23
+ import { getDb } from '@/server/db.server';
20
24
  import { selectValues } from '@/server/lib/harness/launch';
21
25
  import { harnessOfSession } from '@/server/lib/omp/rpc/session-registry';
22
26
  import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
@@ -64,7 +68,10 @@ export async function resumeRecordedHarnessSession(
64
68
 
65
69
  const label = harnessDescriptor(harness)?.label ?? harness;
66
70
  const probe = await freshProbe(harness);
67
- if (probe && !probe.capabilities.loadSession && !probe.capabilities.resumeSession) {
71
+ // A BLOCKED probe is not evidence about capabilities: it was measured in a
72
+ // different auth state (`codex` answered "Authentication required" before the
73
+ // user logged in). Refusing on it locked a chat that could already resume.
74
+ if (probe && !probe.capabilities.blocked && !probe.capabilities.loadSession && !probe.capabilities.resumeSession) {
68
75
  throw new Error(`${label} cannot restore this chat: it supports neither session/load nor session/resume.`);
69
76
  }
70
77
  const { token, env } = mintAgentEnvironment();
@@ -93,6 +100,73 @@ export async function resumeRecordedHarnessSession(
93
100
  return session;
94
101
  }
95
102
 
103
+ /**
104
+ * Replay an IMPORTED chat's retained history into Kabmo's own transcript.
105
+ *
106
+ * The sidebar shows an imported row because `harness_sessions` lists it, but
107
+ * the agent holds the conversation: Kabmo never received those turns, so the
108
+ * open tab would be empty. A v2 agent replays its history when
109
+ * `session/resume` carries `replayFrom`; the frames are collected before the
110
+ * session is usable and reduced to the rows the timeline reads. Persisting the
111
+ * result is the point of the exercise — every later open is an ordinary read.
112
+ *
113
+ * Only an `origin = 'imported'` row is eligible: a chat Kabmo spawned already
114
+ * has its transcript (the client wrote every turn), and replaying it would
115
+ * duplicate the conversation.
116
+ */
117
+ export async function restoreRecordedHarnessSession(
118
+ sessionId: string,
119
+ accessMode: ApprovalMode | null,
120
+ ): Promise<{ session: HarnessSession; harness: string; messages: number } | null> {
121
+ const record = await loadHarnessSession(sessionId);
122
+ const harness = knownHarness(record?.harness, HARNESS_IDS);
123
+ if (!record || record.origin !== 'imported' || !harness || harness === 'omp-rpc' || !record.cwd) return null;
124
+
125
+ const db = await getDb();
126
+ const existing = (await db.get('SELECT messages FROM chat_sessions WHERE session_id = ?', [sessionId])) as {
127
+ messages?: string;
128
+ } | null;
129
+ if (existing?.messages) {
130
+ try {
131
+ const parsed: unknown = JSON.parse(existing.messages);
132
+ if (Array.isArray(parsed) && parsed.length > 0) return null;
133
+ } catch {
134
+ // A corrupt local copy is not a transcript: replay and replace it.
135
+ }
136
+ }
137
+
138
+ const probe = await freshProbe(harness);
139
+ const label = harnessDescriptor(harness)?.label ?? harness;
140
+ if (probe && !probe.capabilities.blocked && !probe.capabilities.loadSession && !probe.capabilities.resumeSession) {
141
+ throw new Error(`${label} cannot replay this chat: it supports neither session/load nor session/resume.`);
142
+ }
143
+ const { token, env } = mintAgentEnvironment();
144
+ const { session, realSessionId } = await startAcpSession({
145
+ harness,
146
+ sessionId,
147
+ resumeAgentSessionId: record.agentSessionId || sessionId,
148
+ cwd: record.cwd,
149
+ accessMode,
150
+ env,
151
+ replay: true,
152
+ });
153
+ await rememberAgentToken(sessionId, token).catch((cause: unknown) => {
154
+ console.error(`[sessions] could not record the agent token for ${sessionId}:`, cause);
155
+ });
156
+ await repointHarnessSession(sessionId, realSessionId).catch(() => {});
157
+ if (realSessionId !== sessionId) emitRealtimeSignal('sidebar-structure');
158
+
159
+ const messages = transcriptFromReplay(takeAcpReplayEvents(session));
160
+ if (messages.length > 0) {
161
+ const title = (await loadHarnessSessionTitle(sessionId).catch(() => '')) || `Session ${sessionId}`;
162
+ await db.run(
163
+ 'INSERT OR REPLACE INTO chat_sessions (session_id, title, messages, updated_at) VALUES (?, ?, ?, CURRENT_TIMESTAMP)',
164
+ [sessionId, title, JSON.stringify(messages)],
165
+ );
166
+ }
167
+ return { session, harness, messages: messages.length };
168
+ }
169
+
96
170
  /**
97
171
  * Answer a mode command on a harness that has no `/kabmo-mode` extension.
98
172
  *
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `POST /api/agent/:id { type: 'restore' }` — copy an imported chat's history in.
8
+ *
9
+ * The command exists because opening a discovered chat is not opening a file:
10
+ * the agent holds the transcript, and only a resume with `replayFrom` can hand
11
+ * it over. Split from `command.ts` so the dispatcher keeps one branch per line
12
+ * and the rules read as a sentence:
13
+ *
14
+ * - a LIVE session has nothing to replay (its frames already reached Kabmo);
15
+ * - an unrecorded id is refused by name, never guessed at;
16
+ * - a failure is the agent's own words, because an empty timeline is
17
+ * indistinguishable from a lost conversation.
18
+ */
19
+
20
+ import { json } from '@/server/lib/remix-compat';
21
+ import { getLiveSession, harnessOfSession } from '@/server/lib/omp/rpc/session-registry';
22
+ import { loadPersistedAccessMode } from '@/shared/lib/omp/config/access-mode.server';
23
+ import { restoreRecordedHarnessSession } from '@/server/routes/agent/harness-command';
24
+ import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
25
+
26
+ export async function restoreChatResponse(
27
+ sessionId: string,
28
+ explicitMode: ApprovalMode | null,
29
+ ): Promise<Response> {
30
+ const live = getLiveSession(sessionId);
31
+ if (live?.isAlive()) {
32
+ return json({ success: true, data: { restored: false, harness: harnessOfSession(live), messages: 0 } });
33
+ }
34
+ const accessMode = explicitMode ?? await loadPersistedAccessMode();
35
+ try {
36
+ const restored = await restoreRecordedHarnessSession(sessionId, accessMode);
37
+ if (!restored) {
38
+ return json(
39
+ { error: 'This chat has no imported history to replay', code: 'restore_unavailable' },
40
+ { status: 404 },
41
+ );
42
+ }
43
+ return json({ success: true, data: { restored: true, harness: restored.harness, messages: restored.messages } });
44
+ } catch (cause) {
45
+ return json(
46
+ { error: cause instanceof Error ? cause.message : 'Could not replay this chat', code: 'restore_failed' },
47
+ { status: 400 },
48
+ );
49
+ }
50
+ }