@kabmo-labs/kabmo 0.32.0 → 0.33.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 (303) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +537 -530
  3. package/dist/client/static/js/{CsvGrid-amafmq3z.js → CsvGrid-fncjbg6j.js} +2 -2
  4. package/dist/client/static/js/{DocxView-851ps9t0.js → DocxView-c9v2vr3r.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-kw1vy3r2.js → DrawioView-vxjksm12.js} +2 -2
  6. package/dist/client/static/js/ImageView-a3g5k226.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-hnjfwsjh.js +2 -0
  8. package/dist/client/static/js/Modal-qtftcp2t.js +38 -0
  9. package/dist/client/static/js/{PdfView-f5jkm0rs.js → PdfView-ksaes53y.js} +1 -1
  10. package/dist/client/static/js/SessionsView-30vcr95v.js +1 -0
  11. package/dist/client/static/js/{SheetView-23zxy30b.js → SheetView-vc484scg.js} +23 -23
  12. package/dist/client/static/js/{SvgPreview-c341y50e.js → SvgPreview-tph89jet.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-2dc3mpk6.js → abnfDiagram-O67JEVCF-xbar278c.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-7jmrr5ja.js → architectureDiagram-NJMV4G6O-s171n2z6.js} +3 -3
  16. package/dist/client/static/js/{astro-sjtf954j.js → astro-80bs6hvg.js} +1 -1
  17. package/dist/client/static/js/bash-b3rwyg5p.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-jrk2m0ea.js → blockDiagram-BEXU5L5S-gzx6rv9n.js} +3 -3
  19. package/dist/client/static/js/c-wkgxb1t1.js +1 -0
  20. package/dist/client/static/js/{c4Diagram-YGBWAQC7-48cyncjd.js → c4Diagram-YGBWAQC7-7f00skch.js} +2 -2
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-gm7jt1cd.js → classDiagram-v2-NBCMYWYE-j79v95nc.js} +4 -4
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-g0g3z0xp.js → cose-bilkent-JH36ORCC-5fkn7ee5.js} +1 -1
  23. package/dist/client/static/js/cpp-y0t6mynx.js +1 -0
  24. package/dist/client/static/js/css-6vj0d308.js +1 -0
  25. package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +1 -0
  26. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-6vjde6am.js → cynefinDiagram-VND7K2PF-cfs1yvrd.js} +1 -1
  27. package/dist/client/static/js/{dagre-6A5THRUB-q6k8bx1j.js → dagre-6A5THRUB-44bgc48p.js} +2 -2
  28. package/dist/client/static/js/{diagram-22UHCM2B-87cmze2n.js → diagram-22UHCM2B-a4g4x83k.js} +19 -19
  29. package/dist/client/static/js/{diagram-3UASUU5V-1ejbr2p4.js → diagram-3UASUU5V-gm4rg5na.js} +1 -1
  30. package/dist/client/static/js/{diagram-ATOU4E4O-vaw1r6k2.js → diagram-ATOU4E4O-a95y41vk.js} +3 -3
  31. package/dist/client/static/js/{diagram-CDSNMT55-gxm9zv7d.js → diagram-CDSNMT55-t3j93mmc.js} +5 -5
  32. package/dist/client/static/js/{diagram-MLGK6HIB-x010xswm.js → diagram-MLGK6HIB-c2wdez02.js} +1 -1
  33. package/dist/client/static/js/{diagram-MPIPVDR6-qtcq7e6c.js → diagram-MPIPVDR6-gya9jhs5.js} +2 -2
  34. package/dist/client/static/js/{dockerfile-k5xbramm.js → dockerfile-a7q6174s.js} +1 -1
  35. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-nwwbasfh.js → ebnfDiagram-ZINNZB2B-jjhkza6t.js} +1 -1
  36. package/dist/client/static/js/{elk-276RUBZZ-xcp7thax.js → elk-276RUBZZ-f7re45mw.js} +1 -1
  37. package/dist/client/static/js/{erDiagram-OPXOYQCR-xj1tp716.js → erDiagram-OPXOYQCR-tpm9g5te.js} +6 -6
  38. package/dist/client/static/js/{erlang-rz1g9mxy.js → erlang-qt876zrq.js} +1 -1
  39. package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +1 -0
  40. package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +1 -0
  41. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-f7q96bea.js → ganttDiagram-FUAMR5RP-fz43n12d.js} +4 -4
  42. package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +1 -0
  43. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-1rydkyq9.js → gitGraphDiagram-X574FWY7-f61hgbn6.js} +9 -9
  44. package/dist/client/static/js/graphql-n43pd5fs.js +1 -0
  45. package/dist/client/static/js/{index-0g25yrc0.js → index-03h3bkcf.js} +1 -1
  46. package/dist/client/static/js/{index-8m3q2zpb.js → index-0e40xskg.js} +1 -1
  47. package/dist/client/static/js/{index-w5131mtt.js → index-0n5wwe60.js} +2 -2
  48. package/dist/client/static/js/{index-ynqnbvn2.js → index-0tf0arsp.js} +3 -3
  49. package/dist/client/static/js/{index-0a1ekhqf.js → index-14vndmcr.js} +2 -2
  50. package/dist/client/static/js/index-1a0zkj8h.js +2 -0
  51. package/dist/client/static/js/{index-zca66d5d.js → index-1xqs14fr.js} +3 -3
  52. package/dist/client/static/js/{index-73xfkyea.js → index-1y9r4frb.js} +2 -2
  53. package/dist/client/static/js/{index-0n9c85ke.js → index-2svnq5gg.js} +2 -2
  54. package/dist/client/static/js/{index-pe9j88d4.js → index-2x5f66t6.js} +2 -2
  55. package/dist/client/static/js/{index-ggaqh9rt.js → index-354mqqra.js} +2 -2
  56. package/dist/client/static/js/{index-2t2tnc3x.js → index-3rcjx70v.js} +1 -1
  57. package/dist/client/static/js/{index-9nbxb421.js → index-3zc1b0dv.js} +2 -2
  58. package/dist/client/static/js/{index-14wppnkx.js → index-5tgq7aqx.js} +2 -2
  59. package/dist/client/static/js/{index-vrbcj11n.js → index-76zb4m0n.js} +2 -2
  60. package/dist/client/static/js/{index-x64kqgen.js → index-7y6rpsrp.js} +2 -2
  61. package/dist/client/static/js/{index-2n5wy1sh.js → index-8239j2v1.js} +1 -1
  62. package/dist/client/static/js/{index-pkyrkkbt.js → index-9fjt5anh.js} +2 -2
  63. package/dist/client/static/js/{index-m6wwc5h6.js → index-9t82sx0w.js} +2 -2
  64. package/dist/client/static/js/{index-hkq0y3pn.js → index-9y3gjdj7.js} +2 -2
  65. package/dist/client/static/js/{index-hyry1n8x.js → index-ahv9y42z.js} +2 -2
  66. package/dist/client/static/js/{index-f519m6s3.js → index-ajs3jj6j.js} +1 -1
  67. package/dist/client/static/js/index-apvkd37e.js +4 -0
  68. package/dist/client/static/js/index-at6bhjyf.js +1 -0
  69. package/dist/client/static/js/index-bkye8mz4.js +2 -0
  70. package/dist/client/static/js/{index-e7a3fkvv.js → index-d495kfm0.js} +1 -1
  71. package/dist/client/static/js/{index-hhm62nfj.js → index-dbe6afkf.js} +2 -2
  72. package/dist/client/static/js/{index-c20a46ww.js → index-djmg1d7h.js} +2 -2
  73. package/dist/client/static/js/{index-fc2j6bq2.js → index-e4p4cd3r.js} +2 -2
  74. package/dist/client/static/js/{index-f63y3mjj.js → index-eyzeya95.js} +5 -5
  75. package/dist/client/static/js/{index-123e8tqq.js → index-gcs49f3p.js} +1 -1
  76. package/dist/client/static/js/{index-c8jzx6b0.js → index-gs6f0qwa.js} +2 -2
  77. package/dist/client/static/js/{index-6sdctwv2.js → index-hf52f59k.js} +2 -2
  78. package/dist/client/static/js/{index-3anc30zh.js → index-j0r5hj0j.js} +2 -2
  79. package/dist/client/static/js/{index-31jrebvn.js → index-js7t1vb1.js} +18 -18
  80. package/dist/client/static/js/{index-xa7nrnda.js → index-km2zb6wk.js} +2 -2
  81. package/dist/client/static/js/{index-yvcpdk5f.js → index-m73za75e.js} +1 -1
  82. package/dist/client/static/js/{index-e6rar25v.js → index-pbe4yed4.js} +2 -2
  83. package/dist/client/static/js/{index-xpf2ra60.js → index-pxv2nw9w.js} +1 -1
  84. package/dist/client/static/js/{index-deex10rz.js → index-q2w6s8n7.js} +5 -5
  85. package/dist/client/static/js/{index-22jaxtz1.js → index-qckv9nte.js} +2 -2
  86. package/dist/client/static/js/{index-e26rd868.js → index-qsm2z36d.js} +2 -2
  87. package/dist/client/static/js/{index-5zd1jx9r.js → index-rg8jpbsw.js} +2 -2
  88. package/dist/client/static/js/{index-gvwqjpcr.js → index-rytaa8ca.js} +2 -2
  89. package/dist/client/static/js/{index-fmxn1rzs.js → index-sdtye3jy.js} +2 -2
  90. package/dist/client/static/js/index-sffjtm5w.js +12 -0
  91. package/dist/client/static/js/{index-tr8754r0.js → index-trm9x02n.js} +45 -45
  92. package/dist/client/static/js/{index-cwaz6geq.js → index-vtbbfwx0.js} +2 -2
  93. package/dist/client/static/js/{index-vmvcse63.js → index-vw4brsdx.js} +1 -1
  94. package/dist/client/static/js/{index-qmh0h87h.js → index-vw5k8csz.js} +55 -55
  95. package/dist/client/static/js/{index-52bgxh6f.js → index-w0fwb80e.js} +1 -1
  96. package/dist/client/static/js/{index-s9vp6p70.js → index-x07kp3jz.js} +2 -2
  97. package/dist/client/static/js/{index-8a3tmm1h.js → index-xj9649ac.js} +7 -7
  98. package/dist/client/static/js/{index-w4re5r8w.js → index-ypx3qmhq.js} +2 -2
  99. package/dist/client/static/js/{index-y139vc12.js → index-zt75xpq0.js} +193 -193
  100. package/dist/client/static/js/{index-nsrnyqcm.js → index-zvfvqvn9.js} +2 -2
  101. package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +1 -0
  102. package/dist/client/static/js/{infoDiagram-VRGFBTTK-ptg07tp2.js → infoDiagram-VRGFBTTK-1qj804sn.js} +1 -1
  103. package/dist/client/static/js/ini-j5dyq6gm.js +1 -0
  104. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-bdk2dkf5.js → ishikawaDiagram-OU5B5YK6-4j4qsnzw.js} +3 -3
  105. package/dist/client/static/js/java-g4dgwbfd.js +1 -0
  106. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kez0ha4c.js → journeyDiagram-ZHPQQLJL-j0brnfft.js} +4 -4
  107. package/dist/client/static/js/json-j5q8nt57.js +1 -0
  108. package/dist/client/static/js/jsx-7t5ecz9s.js +1 -0
  109. package/dist/client/static/js/{julia-nmr85k8z.js → julia-4ghmfy3e.js} +1 -1
  110. package/dist/client/static/js/{kanban-definition-PNTS6WVX-dhzp3qg5.js → kanban-definition-PNTS6WVX-qqc22br0.js} +3 -3
  111. package/dist/client/static/js/lua-1g6w30de.js +1 -0
  112. package/dist/client/static/js/markdown-afx21x8c.js +1 -0
  113. package/dist/client/static/js/{mermaid.core-h7wttbss.js → mermaid.core-vv3wbe65.js} +7 -7
  114. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-tq5dd1em.js → mindmap-definition-NLK3R4M7-y5b2z8zp.js} +4 -4
  115. package/dist/client/static/js/one-dark-pro-hm3f56n1.js +1 -0
  116. package/dist/client/static/js/one-light-xrz49rct.js +1 -0
  117. package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +1 -0
  118. package/dist/client/static/js/{pegDiagram-GJSIUBJH-e5hrdfzv.js → pegDiagram-GJSIUBJH-0be07mqs.js} +1 -1
  119. package/dist/client/static/js/{perl-prxcva8r.js → perl-sd00t4b4.js} +1 -1
  120. package/dist/client/static/js/{php-m9kcctzs.js → php-2zfyqa61.js} +1 -1
  121. package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +1 -0
  122. package/dist/client/static/js/{pieDiagram-5QR66LMP-axvbvnz8.js → pieDiagram-5QR66LMP-544w86jk.js} +2 -2
  123. package/dist/client/static/js/properties-thd83wey.js +1 -0
  124. package/dist/client/static/js/python-264ns4xw.js +1 -0
  125. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-wtn28cfm.js → quadrantDiagram-O4NWA36T-p09e7z5s.js} +4 -4
  126. package/dist/client/static/js/r-qw82kkv9.js +1 -0
  127. package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +1 -0
  128. package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +1 -0
  129. package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +1 -0
  130. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +1 -0
  131. package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +1 -0
  132. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-avjkq945.js → railroadDiagram-XR7U4H2S-de830ed2.js} +1 -1
  133. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bntx7r6q.js → requirementDiagram-PLB6GJNP-b47d74p1.js} +4 -4
  134. package/dist/client/static/js/{ruby-t06c0e7g.js → ruby-v9qaqhby.js} +1 -1
  135. package/dist/client/static/js/{rust-6gqjxyf0.js → rust-fkt0qyrs.js} +1 -1
  136. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-ps8nkdm2.js → sankeyDiagram-IPEJSGJF-6ezc2fpj.js} +5 -5
  137. package/dist/client/static/js/{sass-gsbyn3wh.js → sass-9bxped7y.js} +1 -1
  138. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3ckf1q6z.js → sequenceDiagram-PO4LG4MO-by5zqj6w.js} +18 -18
  139. package/dist/client/static/js/{sizeCapture-INFHLROL-akvcr1x7.js → sizeCapture-INFHLROL-q85r06j6.js} +1 -1
  140. package/dist/client/static/js/sql-g8wcshpc.js +1 -0
  141. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-c82914fz.js → stateDiagram-v2-GCMORJYK-ep5pyexs.js} +3 -3
  142. package/dist/client/static/js/{svelte-j54gfrvq.js → svelte-mwtx07d9.js} +1 -1
  143. package/dist/client/static/js/{swimlanes-2SLR337P-scgdefh4.js → swimlanes-2SLR337P-95fcqkh8.js} +1 -1
  144. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xs2en5dv.js +8 -0
  145. package/dist/client/static/js/{timeline-definition-EJHVYXUP-z2ha1rhq.js → timeline-definition-EJHVYXUP-461e615g.js} +2 -2
  146. package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +1 -0
  147. package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +1 -0
  148. package/dist/client/static/js/tsx-nm94hed6.js +1 -0
  149. package/dist/client/static/js/typescript-0s2t05jj.js +1 -0
  150. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-3wdmrfmk.js → usecaseDiagram-POWQR4AR-ftqfnvhg.js} +38 -38
  151. package/dist/client/static/js/{vennDiagram-UO4OBE2U-7m5tatzv.js → vennDiagram-UO4OBE2U-7t96h6ez.js} +7 -7
  152. package/dist/client/static/js/{vue-y8bb5f3h.js → vue-j8vb9d7r.js} +1 -1
  153. package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +1 -0
  154. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-55ps9s4z.js → wardleyDiagram-VNRHLVJA-0de8w8c6.js} +4 -4
  155. package/dist/client/static/js/xml-dz51p1m3.js +1 -0
  156. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8bsjtm4t.js → xychartDiagram-PMCCYNJV-dez9phkf.js} +5 -5
  157. package/dist/client/static/js/yaml-2cfkd30t.js +1 -0
  158. package/package.json +1 -1
  159. package/src/client/components/common/context-usage-button/McpSection.test.tsx +98 -0
  160. package/src/client/components/common/context-usage-button/McpSection.tsx +12 -5
  161. package/src/client/components/common/context-usage-button/SessionStats.tsx +80 -0
  162. package/src/client/components/common/context-usage-button/index.test.tsx +26 -0
  163. package/src/client/components/common/context-usage-button/index.tsx +36 -28
  164. package/src/client/components/common/harness-glyph/brands.ts +8 -0
  165. package/src/client/components/common/session-actions-menu/index.tsx +6 -1
  166. package/src/client/components/layout/session-sidebar/SessionsView.tsx +20 -33
  167. package/src/client/components/mobile/LayoutWrapper.tsx +28 -29
  168. package/src/client/components/mobile/mobile-right-sidebar/FullDiff.tsx +9 -2
  169. package/src/client/components/mobile/worktree-session.ts +4 -1
  170. package/src/client/components/settings/apply-side-effects.test.ts +11 -0
  171. package/src/client/components/settings/apply-side-effects.ts +7 -0
  172. package/src/client/components/settings/categories/ChatSettings.test.tsx +1 -1
  173. package/src/client/components/settings/categories/ChatSettings.tsx +2 -0
  174. package/src/client/components/settings/categories/NotificationSettings.tsx +1 -1
  175. package/src/client/components/settings/categories/chat-settings/ChangedFilesSection.tsx +79 -0
  176. package/src/client/components/settings/categories/chat-settings/groups.ts +4 -3
  177. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +101 -0
  178. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +16 -15
  179. package/src/client/components/workspace/chat-timeline/MessageList.tsx +33 -1
  180. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +21 -1
  181. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +13 -0
  182. package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +11 -0
  183. package/src/client/components/workspace/chat-timeline/index.tsx +1 -1
  184. package/src/client/components/workspace/diff-panel/Toolbar.tsx +17 -51
  185. package/src/client/components/workspace/diff-panel/index.tsx +23 -4
  186. package/src/client/components/workspace/diff-panel/toolbar-git-actions.tsx +94 -0
  187. package/src/client/components/workspace/editor/Body.tsx +2 -0
  188. package/src/client/data/settings/omp-schema.json +73 -3
  189. package/src/client/hooks/chat/btw/mode.ts +5 -1
  190. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +9 -3
  191. package/src/client/hooks/chat/timeline/changed-files-setting.test.ts +31 -0
  192. package/src/client/hooks/chat/timeline/changed-files-setting.ts +60 -0
  193. package/src/client/hooks/chat/timeline/new-chat.ts +4 -1
  194. package/src/client/hooks/chat/timeline/pending-dispatch.ts +6 -10
  195. package/src/client/hooks/chat/timeline/session-changes.ts +51 -0
  196. package/src/client/hooks/chat/waiting/dispatch.ts +4 -1
  197. package/src/client/hooks/ui/notification-events.test.ts +3 -0
  198. package/src/client/hooks/ui/notification-events.ts +3 -1
  199. package/src/client/hooks/ui/notification-sound.ts +13 -6
  200. package/src/client/hooks/ui/ui-sounds.test.ts +15 -0
  201. package/src/client/hooks/workspace/batch-delete-run.ts +5 -1
  202. package/src/client/hooks/workspace/diff-file.ts +11 -4
  203. package/src/client/hooks/workspace/file-tabs.ts +13 -4
  204. package/src/client/hooks/workspace/journal-diff.ts +97 -0
  205. package/src/client/hooks/workspace/session-delete.ts +5 -1
  206. package/src/client/lib/notifications/native-banner-sound.test.ts +93 -0
  207. package/src/client/lib/notifications/native-banner-sound.ts +46 -0
  208. package/src/client/lib/notifications/os.test.ts +14 -5
  209. package/src/client/lib/notifications/os.ts +8 -0
  210. package/src/client/lib/router/branch-params.test.ts +62 -0
  211. package/src/client/lib/router/branch-params.ts +48 -0
  212. package/src/server/lib/assets/shell-settings.server.test.ts +35 -0
  213. package/src/server/lib/assets/shell-settings.server.ts +33 -0
  214. package/src/server/lib/harness/launch-table.ts +10 -0
  215. package/src/server/lib/omp/session/changes.test.ts +138 -0
  216. package/src/server/lib/omp/session/changes.ts +220 -0
  217. package/src/server/lib/omp/session/session-discovery.test.ts +4 -4
  218. package/src/server/lib/omp/session/sidebar-activity.server.test.ts +6 -2
  219. package/src/server/lib/omp/session/subagent-presence-scan.ts +54 -0
  220. package/src/server/lib/omp/session/subagent-presence-store.test.ts +1 -1
  221. package/src/server/lib/omp/session/subagent-presence.test.ts +115 -0
  222. package/src/server/lib/omp/session/subagent-presence.ts +12 -3
  223. package/src/server/lib/omp/session/telemetry/compute.ts +68 -0
  224. package/src/server/lib/omp/session/telemetry.test.ts +81 -0
  225. package/src/server/lib/realtime/topics/peer-relay.server.test.ts +1 -11
  226. package/src/server/plugins/ssr.ts +20 -8
  227. package/src/server/routes/sessions/changes.test.ts +90 -0
  228. package/src/server/routes/sessions/changes.ts +55 -0
  229. package/src/server/routes/sessions/index.ts +6 -0
  230. package/src/shared/lib/chat/duration.ts +34 -0
  231. package/src/shared/lib/chat/timeline/changed-files.test.ts +121 -0
  232. package/src/shared/lib/chat/timeline/changed-files.ts +71 -0
  233. package/src/shared/lib/chat/timeline/fork-anchor.test.ts +3 -0
  234. package/src/shared/lib/format/duration.test.ts +31 -0
  235. package/src/shared/lib/format/duration.ts +27 -0
  236. package/src/shared/lib/fs/unified-diff.test.ts +53 -0
  237. package/src/shared/lib/fs/unified-diff.ts +127 -0
  238. package/src/shared/lib/harness/brand-color.ts +3 -0
  239. package/src/shared/lib/harness/catalog.test.ts +13 -0
  240. package/src/shared/lib/harness/catalog.ts +8 -1
  241. package/src/shared/lib/harness/fork.ts +4 -2
  242. package/src/shared/lib/harness/mcp-facts.ts +3 -0
  243. package/src/shared/lib/harness/provider-facts.ts +14 -0
  244. package/src/shared/lib/harness/updates.ts +5 -0
  245. package/src/shared/lib/icons/tint-hues.generated.ts +27 -27
  246. package/src/shared/lib/omp/config/schema.test.ts +4 -2
  247. package/src/shared/lib/settings/defaults.ts +1 -0
  248. package/src/shared/lib/workspace/file-tab-id.ts +9 -0
  249. package/src/shared/types/context.ts +18 -0
  250. package/src/shared/types/fs.ts +21 -0
  251. package/src/shared/types/index.ts +1 -0
  252. package/src/shared/types/omp/session.ts +6 -0
  253. package/src/shared/types/session-changes.ts +58 -0
  254. package/src/shared/types/settings/state.ts +8 -0
  255. package/src/test-support/peer-harness.ts +13 -5
  256. package/dist/client/static/js/ImageView-ksx9bbct.js +0 -1
  257. package/dist/client/static/js/LayoutWrapper-9ftz050x.js +0 -2
  258. package/dist/client/static/js/Modal-f8x3j3be.js +0 -38
  259. package/dist/client/static/js/SessionsView-wzdf1cp6.js +0 -1
  260. package/dist/client/static/js/architecture-7GRP2DOG-4wsd6vk0.js +0 -1
  261. package/dist/client/static/js/bash-h6pkqvth.js +0 -1
  262. package/dist/client/static/js/c-thbdzmwv.js +0 -1
  263. package/dist/client/static/js/cpp-r1za1kke.js +0 -1
  264. package/dist/client/static/js/css-qsv4vvke.js +0 -1
  265. package/dist/client/static/js/cynefin-OW5HDTMX-eycwde8c.js +0 -1
  266. package/dist/client/static/js/eventmodeling-NTZA5JFV-srqbnmey.js +0 -1
  267. package/dist/client/static/js/flowDiagram-KWPJA3E3-yj98317w.js +0 -1
  268. package/dist/client/static/js/gitGraph-4MIJSDKK-5jcrvn94.js +0 -1
  269. package/dist/client/static/js/graphql-275pg7ya.js +0 -1
  270. package/dist/client/static/js/index-b08zd4eq.js +0 -1
  271. package/dist/client/static/js/index-g0pkzanm.js +0 -2
  272. package/dist/client/static/js/index-ga2xdef3.js +0 -2
  273. package/dist/client/static/js/index-r416e9dt.js +0 -12
  274. package/dist/client/static/js/index-xzfsaqyz.js +0 -4
  275. package/dist/client/static/js/info-A6RAGUB7-mbt0ryx5.js +0 -1
  276. package/dist/client/static/js/ini-jqdrx98c.js +0 -1
  277. package/dist/client/static/js/java-70zqqrkr.js +0 -1
  278. package/dist/client/static/js/json-kxk8gfet.js +0 -1
  279. package/dist/client/static/js/jsx-h1035eqk.js +0 -1
  280. package/dist/client/static/js/lua-j2356waf.js +0 -1
  281. package/dist/client/static/js/markdown-ffw6rgk6.js +0 -1
  282. package/dist/client/static/js/one-dark-pro-8acf6cn2.js +0 -1
  283. package/dist/client/static/js/one-light-ysc1knem.js +0 -1
  284. package/dist/client/static/js/packet-AYTQ26CC-a5yw789s.js +0 -1
  285. package/dist/client/static/js/pie-WAS4IAKB-x0y4v4r2.js +0 -1
  286. package/dist/client/static/js/properties-55mrarxr.js +0 -1
  287. package/dist/client/static/js/python-dhypc3j4.js +0 -1
  288. package/dist/client/static/js/r-6b8dt1wp.js +0 -1
  289. package/dist/client/static/js/radar-RG4KPBEZ-trrc3ta1.js +0 -1
  290. package/dist/client/static/js/railroad-74A4TZTK-dxgvx21w.js +0 -1
  291. package/dist/client/static/js/railroad-abnf-HS5TGJTU-rbgkd8sk.js +0 -1
  292. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-exgw7j47.js +0 -1
  293. package/dist/client/static/js/railroad-peg-WCYAUIDC-28tpamzk.js +0 -1
  294. package/dist/client/static/js/sql-9dq913c8.js +0 -1
  295. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-0x2ashav.js +0 -8
  296. package/dist/client/static/js/treeView-Q6P3EWNA-1a00b6kc.js +0 -1
  297. package/dist/client/static/js/treemap-WGGIJYW6-2q4f2f7m.js +0 -1
  298. package/dist/client/static/js/tsx-wh5xgm7f.js +0 -1
  299. package/dist/client/static/js/typescript-ge85req5.js +0 -1
  300. package/dist/client/static/js/wardley-WFR3VGLG-x9v91the.js +0 -1
  301. package/dist/client/static/js/xml-7bgz40qa.js +0 -1
  302. package/dist/client/static/js/yaml-4ht9416k.js +0 -1
  303. package/src/client/components/layout/session-sidebar/new-session-context.test.ts +0 -55
@@ -1,11 +1,20 @@
1
1
  import { formatNewSessionTitle } from '@/shared/lib/omp/session/default-title';
2
2
  import { contentProfile } from '@/shared/lib/omp/session/telemetry-blocks';
3
+ import { toEpochMs } from '@/shared/lib/omp/session/timestamps';
4
+ import { isRecord } from '@/shared/lib/util/guards';
3
5
  import type { RawMessageItem, SessionContextTelemetry } from '@/shared/types/context';
4
6
  import type { OmpMessageEntry, OmpUsage } from '@/shared/types/omp/session';
5
7
  import { CONTEXT_LIMIT, buildInfo, contextAnchorTokens, emptyTelemetry, formatCost, formatTs, textOf, tokensOf } from '@/server/lib/omp/session/telemetry/format';
6
8
  import { loadModelsWithCache } from '@/server/lib/models/registry.server';
7
9
  import { scanSessionEntries } from '@/server/lib/omp/session/telemetry/scan';
8
10
 
11
+ /**
12
+ * Below this a request's tokens/second is noise: a cached or instant response
13
+ * divides by almost nothing and reports an absurd rate. Same floor omp's own
14
+ * usage row applies (`pi-tui/overlays/usage-row.ts`).
15
+ */
16
+ const MIN_RATE_DURATION_MS = 100;
17
+
9
18
  /**
10
19
  * Compute real `SessionContextTelemetry` for a session file (all-zero on
11
20
  * unreadable/empty). `rawLimit` caps materialized raw items (0 = none): the
@@ -56,6 +65,17 @@ export async function computeRealSessionTelemetry(
56
65
  let messagesCount = 0;
57
66
  const rawMessages: RawMessageItem[] = [];
58
67
  let cwd = '';
68
+ // Timing: `duration`/`ttft` are per assistant message; a tool call's span runs
69
+ // from its `tool_execution_start` entry to its `toolResult` timestamp. The
70
+ // join is the same one the chat reload path performs (messages-map.ts), so a
71
+ // call states one duration whichever surface reads it.
72
+ let llmDurationMs = 0;
73
+ let toolDurationMs = 0;
74
+ let ttftSum = 0;
75
+ let ttftCount = 0;
76
+ let lastOutputTokens = 0;
77
+ let lastDurationMs: number | undefined;
78
+ const toolStarts = new Map<string, number>();
59
79
 
60
80
  await scanSessionEntries(filePath, (entry, index) => {
61
81
  // Modern session files start with a fixed-width title slot line, so the
@@ -72,6 +92,17 @@ export async function computeRealSessionTelemetry(
72
92
  return;
73
93
  }
74
94
  if (entry.type === 'compaction' && typeof entry.shortSummary === 'string' && !shortSummary) shortSummary = entry.shortSummary;
95
+ // omp records each call's begin as its own `custom` entry; the result entry
96
+ // carries no duration. The map is exact by call id and costs one entry.
97
+ if (entry.type === 'custom' && entry.customType === 'tool_execution_start') {
98
+ const data = isRecord(entry.data) ? entry.data : undefined;
99
+ const callId = typeof data?.toolCallId === 'string' ? data.toolCallId : undefined;
100
+ if (callId) {
101
+ const startedAt = toEpochMs(data?.startedAt) ?? toEpochMs(entry.timestamp);
102
+ if (startedAt !== undefined) toolStarts.set(callId, startedAt);
103
+ }
104
+ return;
105
+ }
75
106
  if (entry.type !== 'message' || !entry.message) return;
76
107
 
77
108
  const msg = entry.message;
@@ -81,6 +112,17 @@ export async function computeRealSessionTelemetry(
81
112
  const info = buildInfo(entry, msg, cwd, index);
82
113
  const tokens = tokensOf(msg.usage);
83
114
 
115
+ // A result closes the span its `tool_execution_start` opened. A call still
116
+ // running when the file was read has no result and adds nothing.
117
+ if (role === 'toolResult') {
118
+ const callId = typeof msg.toolCallId === 'string' ? msg.toolCallId : undefined;
119
+ const startedAt = callId ? toolStarts.get(callId) : undefined;
120
+ const endedAt = toEpochMs(msg.timestamp) ?? toEpochMs(entry.timestamp);
121
+ if (startedAt !== undefined && endedAt !== undefined && endedAt >= startedAt) {
122
+ toolDurationMs += endedAt - startedAt;
123
+ }
124
+ }
125
+
84
126
  toolChars += profile.toolChars;
85
127
 
86
128
  if (role === 'user') {
@@ -93,6 +135,16 @@ export async function computeRealSessionTelemetry(
93
135
  if (msg.usage) lastAsstUsage = msg.usage;
94
136
  const anchor = contextAnchorTokens(msg);
95
137
  if (anchor !== undefined) contextAnchor = anchor;
138
+ const duration = typeof msg.duration === 'number' && Number.isFinite(msg.duration) ? msg.duration : undefined;
139
+ if (duration !== undefined && duration > 0) {
140
+ llmDurationMs += duration;
141
+ lastDurationMs = duration;
142
+ lastOutputTokens = tokens.output;
143
+ }
144
+ if (typeof msg.ttft === 'number' && Number.isFinite(msg.ttft) && msg.ttft > 0) {
145
+ ttftSum += msg.ttft;
146
+ ttftCount += 1;
147
+ }
96
148
  }
97
149
 
98
150
  if (msg.usage) {
@@ -177,6 +229,15 @@ export async function computeRealSessionTelemetry(
177
229
  const cacheHitPercent = lastAsstUsage && lastTokens.input + lastTokens.output + lastTokens.cacheRead > 0 ? Number(((lastTokens.cacheRead / (lastTokens.input + lastTokens.output + lastTokens.cacheRead)) * 100).toFixed(1)) : 0;
178
230
  const cacheHitAverage = cacheAvgInput + cacheAvgCacheRead > 0 ? Number(((cacheAvgCacheRead / (cacheAvgInput + cacheAvgCacheRead)) * 100).toFixed(1)) : 0;
179
231
 
232
+ // Output tokens per second, over the whole request duration — the same
233
+ // arithmetic omp's usage row prints, so the popover and the TUI agree.
234
+ const lastTps = lastDurationMs !== undefined && lastDurationMs > MIN_RATE_DURATION_MS && lastOutputTokens > 0
235
+ ? (lastOutputTokens / lastDurationMs) * 1000
236
+ : undefined;
237
+ const avgTps = llmDurationMs > MIN_RATE_DURATION_MS && sumOutput > 0
238
+ ? (sumOutput / llmDurationMs) * 1000
239
+ : undefined;
240
+
180
241
  return {
181
242
  sessionId,
182
243
  sessionTitle: effectiveTitle || shortSummary || firstUserText
@@ -192,6 +253,13 @@ export async function computeRealSessionTelemetry(
192
253
  assistantCount,
193
254
  totalCost,
194
255
  costFormatted: formatCost(totalCost),
256
+ timing: {
257
+ llmMs: Math.round(llmDurationMs),
258
+ toolMs: Math.round(toolDurationMs),
259
+ ...(ttftCount > 0 ? { ttftAvgMs: Math.round(ttftSum / ttftCount) } : {}),
260
+ ...(lastTps !== undefined ? { lastTps } : {}),
261
+ ...(avgTps !== undefined ? { avgTps } : {}),
262
+ },
195
263
  cacheHitAverage,
196
264
  costBreakdown: { input: costInput, output: costOutput, cacheRead: costCacheRead, cacheWrite: costCacheWrite, total: totalCost },
197
265
  lastMessage: {
@@ -185,3 +185,84 @@ describe('computeRealSessionTelemetry raw items', () => {
185
185
  expect(telemetry.rawMessages[0]?.id).toBe('u1');
186
186
  });
187
187
  });
188
+
189
+ describe('computeRealSessionTelemetry timing', () => {
190
+ /** The call's begin clock: a `custom` entry, the only start omp writes. */
191
+ function toolStart(callId: string, at: string): Record<string, unknown> {
192
+ return {
193
+ type: 'custom',
194
+ customType: 'tool_execution_start',
195
+ timestamp: at,
196
+ data: { toolCallId: callId, toolName: 'bash', startedAt: at },
197
+ };
198
+ }
199
+
200
+ function toolResult(callId: string, at: string): Record<string, unknown> {
201
+ return {
202
+ type: 'message',
203
+ id: `r-${callId}`,
204
+ timestamp: at,
205
+ message: {
206
+ role: 'toolResult',
207
+ toolCallId: callId,
208
+ toolName: 'bash',
209
+ content: [{ type: 'text', text: 'ok' }],
210
+ },
211
+ };
212
+ }
213
+
214
+ test('sums LLM time, tool spans, TTFT and tokens/second', async () => {
215
+ const file = await writeSession([
216
+ header,
217
+ userMessage('u1', 'go'),
218
+ assistantMessage('a1', { duration: 2000, ttft: 500, usage: { input: 10, output: 100 } }),
219
+ toolStart('c1', '2026-09-16T02:32:00.000Z'),
220
+ toolResult('c1', '2026-09-16T02:32:01.500Z'),
221
+ assistantMessage('a2', { duration: 3000, ttft: 1000, usage: { input: 20, output: 150 } }),
222
+ ]);
223
+
224
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
225
+ expect(timing).toEqual({
226
+ llmMs: 5000,
227
+ toolMs: 1500,
228
+ ttftAvgMs: 750,
229
+ // last = 150 output / 3000 ms; avg = 250 output / 5000 ms — both 50/s.
230
+ lastTps: 50,
231
+ avgTps: 50,
232
+ });
233
+ });
234
+
235
+ test('reports no rate when the request is too short to mean anything', async () => {
236
+ const file = await writeSession([
237
+ header,
238
+ userMessage('u1', 'go'),
239
+ assistantMessage('a1', { duration: 80, usage: { input: 10, output: 5 } }),
240
+ ]);
241
+
242
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
243
+ // 80 ms is below the 100 ms floor: the span is real, the rate is not.
244
+ expect(timing).toEqual({ llmMs: 80, toolMs: 0 });
245
+ });
246
+
247
+ test('a tool call with no result contributes no time', async () => {
248
+ const file = await writeSession([
249
+ header,
250
+ userMessage('u1', 'go'),
251
+ toolStart('c1', '2026-09-16T02:32:00.000Z'),
252
+ ]);
253
+
254
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
255
+ expect(timing?.toolMs).toBe(0);
256
+ });
257
+
258
+ test('legacy messages without timing leave the rates unmeasured', async () => {
259
+ const file = await writeSession([
260
+ header,
261
+ userMessage('u1', 'go'),
262
+ assistantMessage('a1', { usage: { input: 10, output: 5 } }),
263
+ ]);
264
+
265
+ const { timing } = await computeRealSessionTelemetry(file, 'ses_telemetry');
266
+ expect(timing).toEqual({ llmMs: 0, toolMs: 0 });
267
+ });
268
+ });
@@ -206,17 +206,7 @@ describe('peer session relay', () => {
206
206
 
207
207
  try {
208
208
  const value = (await sessionDescriptor(sessionId).resolve(topic)) as { running?: boolean };
209
- const { resolveSessionOwnership } = await import('@/server/lib/omp/session/ownership.server');
210
- const { listInstanceRecords } = await import('@/server/lib/lifecycle/instance');
211
- const { processParentPid } = await import('@/server/lib/lifecycle/identity');
212
- const diag = JSON.stringify({
213
- holder,
214
- parentNow: processParentPid(holder.pid),
215
- records: listInstanceRecords(),
216
- ownership: await resolveSessionOwnership(sessionId),
217
- calls: ownerCalls,
218
- });
219
- expect(ownerCalls, diag).toEqual([`/api/agent/${sessionId}`]);
209
+ expect(ownerCalls, JSON.stringify({ holder })).toEqual([`/api/agent/${sessionId}`]);
220
210
  expect(value.running).toBe(true);
221
211
  } finally {
222
212
  ownerServer.stop(true);
@@ -23,6 +23,7 @@ import { readSettingsBlob } from '@/shared/lib/settings/keys';
23
23
  import { resolveTheme } from '@/shared/lib/theme/catalog';
24
24
  import { FIRST_FRAME_STYLE_ELEMENT_ID } from '@/shared/lib/theme/first-frame';
25
25
  import { applyShellDocumentFacts } from '@/server/lib/assets/shell-attributes.server';
26
+ import { splitShellSettings } from '@/server/lib/assets/shell-settings.server';
26
27
  import { SURFACE_STYLE_SETTING_KEY } from '@/shared/lib/theme/surface-style';
27
28
  import { ICON_STYLE_SETTING_KEY } from '@/shared/lib/theme/icon-style';
28
29
  import { windowChromeColor } from '@/shared/lib/theme/chrome';
@@ -169,7 +170,10 @@ export const ssrRoutes = new Elysia({ name: 'ssr' }).get('*', async ({ request }
169
170
  if (pathname === THEMED_MANIFEST_ROUTE) {
170
171
  const source = await manifestSource();
171
172
  if (!source) return new Response('Not found', { status: 404 });
172
- const manifestSettings = isAuthenticatedRequest(request) ? await readSettings() : {};
173
+ // The manifest's colours are presentation, so they follow the stored theme
174
+ // for an unauthenticated visitor too — the login screen is what that
175
+ // visitor sees, and the install's splash must not disagree with it.
176
+ const manifestSettings = await readSettings();
173
177
  return new Response(themedManifest(source, resolveTheme(storedThemeId(manifestSettings))), {
174
178
  headers: { 'content-type': 'application/manifest+json; charset=utf-8', 'cache-control': 'no-store' },
175
179
  });
@@ -182,13 +186,21 @@ export const ssrRoutes = new Elysia({ name: 'ssr' }).get('*', async ({ request }
182
186
  const asset = await tryServeStatic(pathname, request);
183
187
  if (asset) return asset;
184
188
  // An unauthenticated visitor still gets the shell — it IS the login screen —
185
- // but not the settings map. `appSettings` carries the provider registry, the
186
- // theme and every stored preference, and publishing it to whoever can reach
187
- // the port would hand out exactly what the password protects. The client
188
- // answers "is auth required" from `/api/auth/state` and renders the login
189
- // screen without it.
189
+ // but not the settings map. `appSettings` carries the provider registry and
190
+ // every stored preference, and publishing it to whoever can reach the port
191
+ // would hand out exactly what the password protects. The client answers "is
192
+ // auth required" from `/api/auth/state` and renders the login screen without
193
+ // it.
194
+ //
195
+ // The stored settings are still READ for both audiences: the palette, the
196
+ // surface material and the icon tone are presentation, and the login screen
197
+ // has to paint the theme the install chose. Only the published map is gated
198
+ // (`splitShellSettings`).
190
199
  const authenticated = isAuthenticatedRequest(request);
191
- const settings = authenticated ? await readSettings() : {};
200
+ const { presentation: settings, published: publishedSettings } = splitShellSettings(
201
+ await readSettings(),
202
+ authenticated,
203
+ );
192
204
  // Both blobs, legacy beneath: an install that predates the rename still has
193
205
  // its theme in the old row, and the SSR shell is what paints the first frame.
194
206
  // Resolved through the catalog: an id this build no longer ships (a
@@ -221,7 +233,7 @@ export const ssrRoutes = new Elysia({ name: 'ssr' }).get('*', async ({ request }
221
233
  // questions: "this browser has a session" versus "there is a session to have".
222
234
  // A Kabmo running open answers `authenticated: true` for every visitor, so
223
235
  // the navbar cannot use it to decide whether a sign-out control applies.
224
- const bootstrap = JSON.stringify({ initialIsMobile, shellVersion: androidVersion, iosShellVersion: iosVersion, isAndroid, authenticated, authEnabled: isAuthEnabled(), production: !DEV_ASSETS_ENABLED, appSettings: settings }).replace(/</g, '\\u003c');
236
+ const bootstrap = JSON.stringify({ initialIsMobile, shellVersion: androidVersion, iosShellVersion: iosVersion, isAndroid, authenticated, authEnabled: isAuthEnabled(), production: !DEV_ASSETS_ENABLED, appSettings: publishedSettings }).replace(/</g, '\\u003c');
225
237
  // The template's own `<meta name="theme-color">` is REWRITTEN, not joined by
226
238
  // a second tag: with both present Chrome reads the first one, so an appended
227
239
  // tag would leave a dark theme painting light browser chrome.
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The two journal routes' guards: a missing or unsafe session id, a diff read
8
+ * without its range, and a path with no record in the range. The data itself is
9
+ * covered by `changes.test.ts`; this file pins the HTTP answers a stale click
10
+ * or a crafted id receives.
11
+ */
12
+
13
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
14
+ import * as fsp from 'node:fs/promises';
15
+ import * as os from 'node:os';
16
+ import * as path from 'node:path';
17
+ import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
18
+ import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
19
+ import { getSessionChangeDiff, getSessionChanges } from '@/server/routes/sessions/changes';
20
+
21
+ const SESSION_ID = '01a0cc50-fd62-7417-899c-e24ff8c8608c';
22
+ const CWD = '/tmp/project';
23
+ let agentDir = '';
24
+ let journalDir = '';
25
+
26
+ function args(sessionId: string | undefined, query = ''): LoaderFunctionArgs {
27
+ return {
28
+ params: sessionId === undefined ? {} : { sessionId },
29
+ request: new Request(`http://localhost/api/sessions/${sessionId ?? ''}/changes${query}`),
30
+ context: {},
31
+ } as unknown as LoaderFunctionArgs;
32
+ }
33
+
34
+ beforeAll(async () => {
35
+ agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'omp-changes-route-'));
36
+ process.env.PI_CODING_AGENT_DIR = agentDir;
37
+ const cwdDir = path.join(agentDir, 'sessions', '-tmp-project');
38
+ await fsp.mkdir(cwdDir, { recursive: true });
39
+ const sessionFile = path.join(cwdDir, `2026-01-01T00-00-00-000Z_${SESSION_ID}.jsonl`);
40
+ await fsp.writeFile(
41
+ sessionFile,
42
+ `${JSON.stringify({ type: 'session', version: 3, id: SESSION_ID, timestamp: '2026-01-01T00:00:00.000Z', cwd: CWD })}\n`,
43
+ );
44
+ journalDir = sessionFile.slice(0, -'.jsonl'.length);
45
+ await fsp.mkdir(path.join(journalDir, 'blobs'), { recursive: true });
46
+ const after = 'a1';
47
+ await fsp.writeFile(path.join(journalDir, 'blobs', after), Bun.gzipSync(Buffer.from('one\n', 'utf8')));
48
+ await fsp.writeFile(
49
+ path.join(journalDir, 'changes.jsonl'),
50
+ `${JSON.stringify({ type: 'change', at: 1000, agent: 'Main', tool: 'write', path: `${CWD}/a.ts`, before: null, after })}\n`,
51
+ );
52
+ clearSessionFileCaches();
53
+ });
54
+
55
+ afterAll(async () => {
56
+ delete process.env.PI_CODING_AGENT_DIR;
57
+ clearSessionFileCaches();
58
+ await fsp.rm(agentDir, { recursive: true, force: true });
59
+ });
60
+
61
+ describe('getSessionChanges', () => {
62
+ test('answers the records for a real session', async () => {
63
+ const response = (await getSessionChanges(args(SESSION_ID))) as Response;
64
+ expect(response.status).toBe(200);
65
+ const body = (await response.json()) as { records: Array<{ displayPath: string }> };
66
+ expect(body.records.map((record) => record.displayPath)).toEqual(['a.ts']);
67
+ });
68
+
69
+ test('a missing id is a 400, an unsafe id a 404', async () => {
70
+ expect(((await getSessionChanges(args(undefined))) as Response).status).toBe(400);
71
+ expect(((await getSessionChanges(args('../escape'))) as Response).status).toBe(404);
72
+ });
73
+ });
74
+
75
+ describe('getSessionChangeDiff', () => {
76
+ test('answers the net change for a path in range', async () => {
77
+ const query = `?path=${encodeURIComponent(`${CWD}/a.ts`)}&from=1000&to=1000`;
78
+ const response = (await getSessionChangeDiff(args(SESSION_ID, query))) as Response;
79
+ expect(response.status).toBe(200);
80
+ const body = (await response.json()) as { status: string; newContent: string };
81
+ expect(body.status).toBe('added');
82
+ expect(body.newContent).toBe('one\n');
83
+ });
84
+
85
+ test('a missing range is a 400, an unknown path a 404', async () => {
86
+ expect(((await getSessionChangeDiff(args(SESSION_ID, '?path=x'))) as Response).status).toBe(400);
87
+ const query = `?path=${encodeURIComponent(`${CWD}/nope.ts`)}&from=1&to=2`;
88
+ expect(((await getSessionChangeDiff(args(SESSION_ID, query))) as Response).status).toBe(404);
89
+ });
90
+ });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The chat's per-run file list, read from the session's agent change journal.
8
+ *
9
+ * GET /api/sessions/:sessionId/changes
10
+ * Every `change` record, oldest first, with a display path. No blob
11
+ * content: the client buckets records into runs and only asks for a diff
12
+ * when a file is clicked.
13
+ *
14
+ * GET /api/sessions/:sessionId/changes/diff?path=<abs>&from=<ms>&to=<ms>
15
+ * The net change of one path inside one run window: the first record's
16
+ * `before` and the last record's `after`, plus a unified patch.
17
+ *
18
+ * A session with no journal (older omp, or no artifacts directory) answers an
19
+ * empty list — a normal state, not an error. The diff read answers 404 when the
20
+ * path has no record in the range, so a stale click reports the real problem.
21
+ */
22
+
23
+ import { json } from '@/server/lib/remix-compat';
24
+ import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
25
+ import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
26
+ import { readSessionChangeDiff, readSessionChangeIndex } from '@/server/lib/omp/session/changes';
27
+
28
+ /** GET /api/sessions/:sessionId/changes */
29
+ export async function getSessionChanges({ params }: LoaderFunctionArgs) {
30
+ const sessionId = params.sessionId;
31
+ if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
32
+ if (!isSinglePathSegment(sessionId)) return json({ error: 'Session not found' }, { status: 404 });
33
+ return json({ sessionId, records: await readSessionChangeIndex(sessionId) });
34
+ }
35
+
36
+ /** GET /api/sessions/:sessionId/changes/diff */
37
+ export async function getSessionChangeDiff({ params, request }: LoaderFunctionArgs) {
38
+ const sessionId = params.sessionId;
39
+ if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
40
+ if (!isSinglePathSegment(sessionId)) return json({ error: 'Session not found' }, { status: 404 });
41
+
42
+ const url = new URL(request.url);
43
+ const file = url.searchParams.get('path');
44
+ const fromRaw = url.searchParams.get('from');
45
+ const toRaw = url.searchParams.get('to');
46
+ const from = fromRaw === null ? Number.NaN : Number(fromRaw);
47
+ const to = toRaw === null ? Number.NaN : Number(toRaw);
48
+ if (!file || !Number.isFinite(from) || !Number.isFinite(to)) {
49
+ return json({ error: 'path, from and to are required' }, { status: 400 });
50
+ }
51
+
52
+ const diff = await readSessionChangeDiff(sessionId, file, from, to);
53
+ if (!diff) return json({ error: 'No change for that path in the range' }, { status: 404 });
54
+ return json({ success: true, ...diff });
55
+ }
@@ -21,6 +21,7 @@ import { getSessionRelations, updateSessionParent } from '@/server/routes/sessio
21
21
  import { forkSessionRoute } from '@/server/routes/sessions/fork';
22
22
  import { getSessionAnswer } from '@/server/routes/sessions/answer';
23
23
  import { getSessionMcp, probeSessionMcp, setSessionMcp } from '@/server/routes/sessions/mcp';
24
+ import { getSessionChangeDiff, getSessionChanges } from '@/server/routes/sessions/changes';
24
25
 
25
26
  export const sessionsBindings: HandlerBinding[] = [
26
27
  ...bindingsFor(sessionsList, '/api/sessions/list'),
@@ -42,6 +43,11 @@ export const sessionsBindings: HandlerBinding[] = [
42
43
  { method: 'POST', path: '/api/sessions/:sessionId/parent', handler: updateSessionParent },
43
44
  { method: 'POST', path: '/api/sessions/:sessionId/fork', handler: forkSessionRoute },
44
45
  { method: 'GET', path: '/api/sessions/:sessionId/answer', handler: getSessionAnswer },
46
+ // The agent's own change journal: the per-run file list and one file's net
47
+ // diff. Static suffixes under the same `:sessionId` position, so the
48
+ // parameter name must stay `sessionId`.
49
+ { method: 'GET', path: '/api/sessions/:sessionId/changes', handler: getSessionChanges },
50
+ { method: 'GET', path: '/api/sessions/:sessionId/changes/diff', handler: getSessionChangeDiff },
45
51
  // The MCP list this session has, and the per-session switch. A static suffix
46
52
  // under the same `:sessionId` position, so the parameter name must stay
47
53
  // `sessionId` (Elysia requires one name per position).
@@ -80,3 +80,37 @@ export function responseRunDurationMs(
80
80
  if (start === null || end <= start) return null;
81
81
  return end - start;
82
82
  }
83
+
84
+ /**
85
+ * Wall-clock window of one run: the opening row's start to the owner row's end.
86
+ *
87
+ * The change journal records epoch-ms write times and nothing that names a
88
+ * message, so this window is what buckets a write into the run that made it.
89
+ * `null` when either end is unmeasurable — a caller then shows no file list
90
+ * rather than guessing.
91
+ */
92
+ export function runWindowMs(
93
+ messages: TimedMessage[],
94
+ runStartIndex: number,
95
+ ownerIndex: number,
96
+ ): { start: number; end: number } | null {
97
+ // A session file can start mid-run: the first run then has no user row
98
+ // (`runStartIndex` is -1), and falling back to the OWNER row's start would
99
+ // begin the window at the last assistant message — after every write the run
100
+ // made. Walk forward from the first row instead.
101
+ const start = runStartIndex >= 0
102
+ ? (msgStartMs(messages[runStartIndex]) ?? msgStartMs(messages[ownerIndex]))
103
+ : firstStartMs(messages, ownerIndex);
104
+ const end = msgEndMs(messages[ownerIndex]);
105
+ if (start === null || end === null || end < start) return null;
106
+ return { start, end };
107
+ }
108
+
109
+ /** First measurable start at or before `lastIndex`, scanning from the top. */
110
+ function firstStartMs(messages: TimedMessage[], lastIndex: number): number | null {
111
+ for (let index = 0; index <= lastIndex; index++) {
112
+ const start = msgStartMs(messages[index]);
113
+ if (start !== null) return start;
114
+ }
115
+ return null;
116
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Bucketing the change journal into runs. The journal has no message id, so the
8
+ * run window is the whole contract: a write one millisecond outside it belongs
9
+ * to another run, and a file written twice must show the NET change, not the
10
+ * last write's pair.
11
+ */
12
+
13
+ import { describe, expect, test } from 'bun:test';
14
+ import { bucketChangesByRun } from '@/shared/lib/chat/timeline/changed-files';
15
+ import type { RunFooterSlot } from '@/shared/lib/chat/timeline/run-footer';
16
+ import type { ChatMessageData, SessionChangeRecord } from '@/shared/types';
17
+
18
+ function message(overrides: Partial<ChatMessageData>): ChatMessageData {
19
+ return { id: 'm', role: 'ai', content: '', ...overrides };
20
+ }
21
+
22
+ function footer(ownerIndex: number, runStartIndex: number): RunFooterSlot {
23
+ return {
24
+ msg: message({ id: `owner-${ownerIndex}` }),
25
+ ownerIndex,
26
+ durationMs: null,
27
+ runStartIndex,
28
+ runUserId: `user-${runStartIndex}`,
29
+ answerText: '',
30
+ };
31
+ }
32
+
33
+ function record(overrides: Partial<SessionChangeRecord>): SessionChangeRecord {
34
+ return {
35
+ at: 0,
36
+ agent: 'Main',
37
+ tool: 'edit',
38
+ path: '/repo/a.ts',
39
+ displayPath: 'a.ts',
40
+ before: 'b1',
41
+ after: 'b2',
42
+ ...overrides,
43
+ };
44
+ }
45
+
46
+ describe('bucketChangesByRun', () => {
47
+ const messages: ChatMessageData[] = [
48
+ message({ id: 'u1', role: 'user', startedAt: 1000 }),
49
+ message({ id: 'a1', role: 'ai', startedAt: 1100, completedAt: 2000 }),
50
+ message({ id: 'u2', role: 'user', startedAt: 3000 }),
51
+ message({ id: 'a2', role: 'ai', startedAt: 3100, completedAt: 4000 }),
52
+ ];
53
+ const footers = [null, footer(1, 0), null, footer(3, 2)];
54
+
55
+ test('a write belongs to the run whose window contains it', () => {
56
+ const buckets = bucketChangesByRun(messages, footers, [
57
+ record({ at: 1500, path: '/repo/a.ts', displayPath: 'a.ts' }),
58
+ record({ at: 3500, path: '/repo/b.ts', displayPath: 'b.ts' }),
59
+ ]);
60
+ expect(buckets.get(1)?.map((file) => file.displayPath)).toEqual(['a.ts']);
61
+ expect(buckets.get(3)?.map((file) => file.displayPath)).toEqual(['b.ts']);
62
+ });
63
+
64
+ test('a write outside every window is dropped', () => {
65
+ const buckets = bucketChangesByRun(messages, footers, [record({ at: 2500 })]);
66
+ expect(buckets.size).toBe(0);
67
+ });
68
+
69
+ test('a file written twice shows the net change', () => {
70
+ const buckets = bucketChangesByRun(messages, footers, [
71
+ record({ at: 1200, before: 'b1', after: 'b2' }),
72
+ record({ at: 1300, before: 'b2', after: 'b3' }),
73
+ ]);
74
+ expect(buckets.get(1)).toEqual([
75
+ { path: '/repo/a.ts', displayPath: 'a.ts', status: 'modified', agent: 'Main' },
76
+ ]);
77
+ });
78
+
79
+ test('created and deleted in one run is not a change', () => {
80
+ const buckets = bucketChangesByRun(messages, footers, [
81
+ record({ at: 1200, before: null, after: 'b2' }),
82
+ record({ at: 1300, before: 'b2', after: null }),
83
+ ]);
84
+ expect(buckets.size).toBe(0);
85
+ });
86
+
87
+ test('written back to the same blob is not a change', () => {
88
+ const buckets = bucketChangesByRun(messages, footers, [
89
+ record({ at: 1200, before: 'b1', after: 'b2' }),
90
+ record({ at: 1300, before: 'b2', after: 'b1' }),
91
+ ]);
92
+ expect(buckets.size).toBe(0);
93
+ });
94
+
95
+ test('added and deleted statuses come from the first before and last after', () => {
96
+ const buckets = bucketChangesByRun(messages, footers, [
97
+ record({ at: 1200, path: '/repo/new.ts', displayPath: 'new.ts', before: null, after: 'b2' }),
98
+ record({ at: 1300, path: '/repo/gone.ts', displayPath: 'gone.ts', before: 'b1', after: null }),
99
+ ]);
100
+ expect(buckets.get(1)?.map((file) => file.status)).toEqual(['deleted', 'added']);
101
+ });
102
+
103
+ test('a subagent write keeps its agent id', () => {
104
+ const buckets = bucketChangesByRun(messages, footers, [
105
+ record({ at: 1200, agent: 'AuthLoader' }),
106
+ ]);
107
+ expect(buckets.get(1)?.[0]?.agent).toBe('AuthLoader');
108
+ });
109
+
110
+ test('a session that starts mid-run uses the first row as the window start', () => {
111
+ // The first run has no user row (`runStartIndex` is -1). Falling back to
112
+ // the OWNER row's start would begin the window at the last assistant
113
+ // message, after every write the run made.
114
+ const midRun: ChatMessageData[] = [
115
+ message({ id: 'a0', role: 'ai', startedAt: 1000, completedAt: 1200 }),
116
+ message({ id: 'a1', role: 'ai', startedAt: 1300, completedAt: 2000 }),
117
+ ];
118
+ const buckets = bucketChangesByRun(midRun, [null, footer(1, -1)], [record({ at: 1500 })]);
119
+ expect(buckets.get(1)?.length).toBe(1);
120
+ });
121
+ });