@kabmo-labs/kabmo 0.42.0 → 0.42.2

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 (195) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +592 -593
  3. package/dist/client/static/js/{CsvGrid-20k047ht.js → CsvGrid-g6rek8y9.js} +1 -1
  4. package/dist/client/static/js/{DocxView-qpvhfcmg.js → DocxView-41t9ryws.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-178skky8.js → DrawioView-mfxhfz1h.js} +1 -1
  6. package/dist/client/static/js/{ImageView-460th5qa.js → ImageView-bxqw3t4k.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-5cv0dty8.js → LayoutWrapper-zt14rv9m.js} +2 -2
  8. package/dist/client/static/js/{Modal-wks6p4r5.js → Modal-cm35g20x.js} +10 -10
  9. package/dist/client/static/js/{PdfView-y51g03nr.js → PdfView-bek8k888.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-rsmvn7ks.js → SessionsView-gn53zyn7.js} +1 -1
  11. package/dist/client/static/js/{SheetView-z7yvb05v.js → SheetView-vezssf6b.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-yehgzhem.js → SvgPreview-f1qaw73k.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-6zxpcy8b.js → abnfDiagram-O67JEVCF-4qn94h52.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-m98sgh3c.js → architectureDiagram-NJMV4G6O-tbewzdya.js} +3 -3
  16. package/dist/client/static/js/{blockDiagram-BEXU5L5S-cp7rervg.js → blockDiagram-BEXU5L5S-njgnwckz.js} +2 -2
  17. package/dist/client/static/js/{c4Diagram-YGBWAQC7-t31recqm.js → c4Diagram-YGBWAQC7-f58pcvbk.js} +1 -1
  18. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fy8x3dkx.js → classDiagram-v2-NBCMYWYE-52g73vyw.js} +3 -3
  19. package/dist/client/static/js/{cose-bilkent-JH36ORCC-va7ybm9e.js → cose-bilkent-JH36ORCC-ptdnshzh.js} +1 -1
  20. package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +1 -0
  21. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-4k0k429c.js → cynefinDiagram-VND7K2PF-qabfdkzr.js} +1 -1
  22. package/dist/client/static/js/{dagre-6A5THRUB-ykdhxq6t.js → dagre-6A5THRUB-kyf5jetf.js} +2 -2
  23. package/dist/client/static/js/{diagram-22UHCM2B-5nvwx7b6.js → diagram-22UHCM2B-bxrsjtv9.js} +4 -4
  24. package/dist/client/static/js/{diagram-3UASUU5V-hc7zsjgw.js → diagram-3UASUU5V-0f41s00j.js} +1 -1
  25. package/dist/client/static/js/{diagram-ATOU4E4O-97ae07y7.js → diagram-ATOU4E4O-0z1zx9h1.js} +1 -1
  26. package/dist/client/static/js/{diagram-CDSNMT55-b56nnbbs.js → diagram-CDSNMT55-znrmr6bk.js} +3 -3
  27. package/dist/client/static/js/{diagram-MLGK6HIB-37rygr9k.js → diagram-MLGK6HIB-jfe2jhk0.js} +1 -1
  28. package/dist/client/static/js/{diagram-MPIPVDR6-wv3vhhfk.js → diagram-MPIPVDR6-2kaawmwa.js} +1 -1
  29. package/dist/client/static/js/{dockerfile-0efb1z6e.js → dockerfile-12exatm9.js} +1 -1
  30. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-13fv7vxg.js → ebnfDiagram-ZINNZB2B-s5n37rfp.js} +1 -1
  31. package/dist/client/static/js/{elixir-mabagxwa.js → elixir-szk51ehr.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-xam60ktz.js → elk-276RUBZZ-433rd9fp.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-24ctv2ee.js → erDiagram-OPXOYQCR-key6ah0b.js} +2 -2
  34. package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
  35. package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +1 -0
  36. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-766a8fqw.js → ganttDiagram-FUAMR5RP-4efkhmca.js} +2 -2
  37. package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +1 -0
  38. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fmwjkgh6.js → gitGraphDiagram-X574FWY7-ac376y2k.js} +1 -1
  39. package/dist/client/static/js/html-tbz83eke.js +1 -0
  40. package/dist/client/static/js/{index-13xbwcbz.js → index-02543wk3.js} +1 -1
  41. package/dist/client/static/js/{index-sx809d6d.js → index-0e9nkc0g.js} +1 -1
  42. package/dist/client/static/js/{index-1c0pnsjd.js → index-0gbj4270.js} +1 -1
  43. package/dist/client/static/js/{index-z6kpc98a.js → index-0pabfaac.js} +1 -1
  44. package/dist/client/static/js/{index-4mstdh41.js → index-1t5ybx9v.js} +1 -1
  45. package/dist/client/static/js/{index-9vdbnvmk.js → index-1y3rzw6b.js} +1 -1
  46. package/dist/client/static/js/{index-qj34r6d0.js → index-38xv8h4t.js} +1 -1
  47. package/dist/client/static/js/{index-4j8rgr4p.js → index-50mdqev0.js} +1 -1
  48. package/dist/client/static/js/{index-zvazj4va.js → index-5jnvz9hw.js} +1 -1
  49. package/dist/client/static/js/{index-97qst4k9.js → index-77t0nvt1.js} +1 -1
  50. package/dist/client/static/js/{index-x7f5ysch.js → index-7a2efrbj.js} +1 -1
  51. package/dist/client/static/js/{index-yvxa7hd8.js → index-82vk27q1.js} +1 -1
  52. package/dist/client/static/js/{index-nbexks3x.js → index-8k7vjp8b.js} +1 -1
  53. package/dist/client/static/js/{index-sq3r1xhf.js → index-8kbp24xg.js} +1 -1
  54. package/dist/client/static/js/{index-zjydzxhm.js → index-b0v6gwym.js} +2 -2
  55. package/dist/client/static/js/{index-grczkttn.js → index-b42t14wk.js} +7 -7
  56. package/dist/client/static/js/{index-13dr1t1r.js → index-cz50ha6x.js} +23 -23
  57. package/dist/client/static/js/{index-8jqawh3r.js → index-dtj73vs1.js} +1 -1
  58. package/dist/client/static/js/{index-7t63akyt.js → index-dzmar8jr.js} +1 -1
  59. package/dist/client/static/js/{index-2x9eqztp.js → index-f33c4paw.js} +1 -1
  60. package/dist/client/static/js/{index-xxe52zrm.js → index-fb6pw9xb.js} +1 -1
  61. package/dist/client/static/js/{index-6ge6gk9w.js → index-gp57dx2v.js} +1 -1
  62. package/dist/client/static/js/{index-2hpy58d0.js → index-gsxebrq9.js} +2 -2
  63. package/dist/client/static/js/{index-czagykbq.js → index-pxtff3ez.js} +2 -2
  64. package/dist/client/static/js/{index-8hgm0abr.js → index-pzvr1699.js} +187 -183
  65. package/dist/client/static/js/{index-dydwcp3n.js → index-r9db1gsf.js} +1 -1
  66. package/dist/client/static/js/{index-b4y5g48d.js → index-raca8tsh.js} +1 -1
  67. package/dist/client/static/js/{index-95en3p3g.js → index-rf29f3fq.js} +4 -4
  68. package/dist/client/static/js/{index-sz3mxjvy.js → index-s4gv0rpk.js} +1 -1
  69. package/dist/client/static/js/{index-a9t9gdew.js → index-v3f7we4n.js} +4 -4
  70. package/dist/client/static/js/{index-ejdnjh5c.js → index-yjmm73jm.js} +1 -1
  71. package/dist/client/static/js/{index-1rxa9zxp.js → index-ykfd2fyj.js} +1 -1
  72. package/dist/client/static/js/{index-4z4ax55k.js → index-yzda8j2d.js} +6 -6
  73. package/dist/client/static/js/{index-vcn1kcpy.js → index-z78bzryw.js} +3 -3
  74. package/dist/client/static/js/{index-tqycj126.js → index-zndbhb9w.js} +1 -1
  75. package/dist/client/static/js/{index-ka2rc2cr.js → index-zs73zwjz.js} +3 -3
  76. package/dist/client/static/js/{index-xe5cqwnf.js → index-zs7sjv6x.js} +1 -1
  77. package/dist/client/static/js/{index-hzwr5fm9.js → index-zw621xez.js} +3 -3
  78. package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
  79. package/dist/client/static/js/{infoDiagram-VRGFBTTK-tqytmzp1.js → infoDiagram-VRGFBTTK-4e7ej63f.js} +2 -2
  80. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rp77ff6m.js → ishikawaDiagram-OU5B5YK6-k3yet1ec.js} +2 -2
  81. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-c7bxrhf1.js → journeyDiagram-ZHPQQLJL-qe352kyd.js} +2 -2
  82. package/dist/client/static/js/{kanban-definition-PNTS6WVX-j2pxewqq.js → kanban-definition-PNTS6WVX-58hag75n.js} +4 -4
  83. package/dist/client/static/js/{mermaid.core-cqqe1krg.js → mermaid.core-6e89h6vm.js} +2 -2
  84. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-s03k32p9.js → mindmap-definition-NLK3R4M7-ncsam2fm.js} +1 -1
  85. package/dist/client/static/js/one-dark-pro-qmyne0tn.js +1 -0
  86. package/dist/client/static/js/one-light-dj0ecjcj.js +1 -0
  87. package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +1 -0
  88. package/dist/client/static/js/{pegDiagram-GJSIUBJH-dfg2j0zc.js → pegDiagram-GJSIUBJH-b5ckc39d.js} +1 -1
  89. package/dist/client/static/js/{perl-5vxax0nr.js → perl-dtn1fccw.js} +1 -1
  90. package/dist/client/static/js/{php-hgrgdq63.js → php-7av78hch.js} +1 -1
  91. package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +1 -0
  92. package/dist/client/static/js/{pieDiagram-5QR66LMP-pshd1j79.js → pieDiagram-5QR66LMP-s4d47ve8.js} +2 -2
  93. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-cvvvmtk2.js → quadrantDiagram-O4NWA36T-zm0ekvjz.js} +1 -1
  94. package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +1 -0
  95. package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +1 -0
  96. package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +1 -0
  97. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +1 -0
  98. package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +1 -0
  99. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-h53p3sha.js → railroadDiagram-XR7U4H2S-52vdqf53.js} +1 -1
  100. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bdv2fkxd.js → requirementDiagram-PLB6GJNP-7kf8bmk9.js} +1 -1
  101. package/dist/client/static/js/{ruby-8pxcn21w.js → ruby-s2bqr910.js} +1 -1
  102. package/dist/client/static/js/{rust-j80dxgjg.js → rust-q98kssv3.js} +1 -1
  103. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-xqnnvmhy.js → sankeyDiagram-IPEJSGJF-bcb9f54a.js} +1 -1
  104. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3p67305f.js → sequenceDiagram-PO4LG4MO-76ywvj7g.js} +3 -3
  105. package/dist/client/static/js/{sizeCapture-INFHLROL-f87525h7.js → sizeCapture-INFHLROL-p9bsf5dc.js} +1 -1
  106. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-e5st1fy3.js → stateDiagram-v2-GCMORJYK-1ecfb3fs.js} +1 -1
  107. package/dist/client/static/js/{swimlanes-2SLR337P-ceghkbez.js → swimlanes-2SLR337P-2pyjr946.js} +1 -1
  108. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-vc8hvfya.js → swimlanesDiagram-TC7HE7FX-qr5hdxm4.js} +1 -1
  109. package/dist/client/static/js/{timeline-definition-EJHVYXUP-f7evs443.js → timeline-definition-EJHVYXUP-4csxwmn2.js} +3 -3
  110. package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +1 -0
  111. package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +1 -0
  112. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0gpn21p7.js → usecaseDiagram-POWQR4AR-0p1jnbsn.js} +7 -7
  113. package/dist/client/static/js/{vennDiagram-UO4OBE2U-4spzy428.js → vennDiagram-UO4OBE2U-y1hgdet4.js} +2 -2
  114. package/dist/client/static/js/{vue-xm1dxpmy.js → vue-cbqm4bed.js} +1 -1
  115. package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +1 -0
  116. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-745xr2pa.js → wardleyDiagram-VNRHLVJA-p578yrgm.js} +2 -2
  117. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7dr9qwx5.js → xychartDiagram-PMCCYNJV-b08b4ah0.js} +3 -3
  118. package/package.json +1 -1
  119. package/src/cli/lib/commands/session.js +12 -1
  120. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -123
  121. package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +214 -0
  122. package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +126 -0
  123. package/src/client/components/workspace/chat-timeline/UserTurn.tsx +183 -0
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +3 -3
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions.tsx +45 -0
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +14 -4
  127. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +2 -12
  128. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +42 -38
  129. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +25 -21
  130. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +41 -29
  131. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +47 -43
  132. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/parity.test.tsx +136 -0
  133. package/src/client/hooks/chat/timeline/composer-modes.ts +10 -7
  134. package/src/client/hooks/chat/timeline/plan-review-republish.test.ts +121 -0
  135. package/src/client/hooks/chat/timeline/plan-review.ts +12 -3
  136. package/src/server/lib/harness/acp/acp-audit.server.ts +1 -1
  137. package/src/server/lib/harness/acp/session-exit.ts +39 -5
  138. package/src/server/lib/harness/acp/session-turns.ts +67 -12
  139. package/src/server/lib/harness/acp/session.test.ts +61 -0
  140. package/src/server/lib/harness/acp/session.ts +15 -25
  141. package/src/server/lib/harness/acp/turn-outcome.server.test.ts +97 -0
  142. package/src/server/lib/harness/acp/turn-outcome.server.ts +71 -0
  143. package/src/server/lib/harness/acp/turn-silence.ts +52 -0
  144. package/src/server/lib/harness/acp/turn.test.ts +85 -3
  145. package/src/server/lib/harness/acp/turn.ts +62 -4
  146. package/src/server/lib/lifecycle/after-listen.ts +10 -0
  147. package/src/server/lib/omp/rpc/frame-fold-contract.ts +21 -0
  148. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +4 -0
  149. package/src/server/lib/omp/rpc/frame-fold.ts +25 -2
  150. package/src/server/lib/omp/rpc/manager.ts +9 -8
  151. package/src/server/lib/omp/rpc/retry-saga.ts +54 -0
  152. package/src/server/lib/omp/rpc/run-settle.server.ts +38 -5
  153. package/src/server/lib/omp/rpc/run-settle.test.ts +5 -2
  154. package/src/server/lib/omp/rpc/session-commands-dialog.test.ts +6 -20
  155. package/src/server/lib/omp/rpc/session-commands-mapping.test.ts +131 -0
  156. package/src/server/lib/omp/rpc/session-commands.test.ts +95 -116
  157. package/src/server/lib/omp/rpc/session-commands.ts +38 -17
  158. package/src/server/lib/omp/rpc/terminal-settle.test.ts +223 -0
  159. package/src/server/lib/omp/rpc/terminal-settle.ts +127 -29
  160. package/src/server/lib/omp/session/scan.ts +15 -2
  161. package/src/server/lib/omp/session/session-discovery.test.ts +21 -0
  162. package/src/server/lib/sessions/notify.server.test.ts +11 -3
  163. package/src/server/lib/sessions/notify.server.ts +67 -42
  164. package/src/server/lib/sessions/spawn.server.test.ts +5 -1
  165. package/src/server/lib/sessions/spawn.server.ts +8 -3
  166. package/src/server/routes/sessions/answer.test.ts +62 -0
  167. package/src/server/routes/sessions/answer.ts +13 -2
  168. package/src/shared/lib/chat/composer/delegation.ts +11 -7
  169. package/src/shared/lib/chat/export-markdown.ts +19 -0
  170. package/src/shared/lib/chat/orchestration/notice.test.ts +118 -0
  171. package/src/shared/lib/chat/orchestration/notice.ts +183 -0
  172. package/src/shared/lib/chat/timeline/omp-callbacks.ts +6 -1
  173. package/src/shared/lib/chat/timeline/tool-render-mode.ts +3 -3
  174. package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
  175. package/src/shared/lib/omp/session/operator-title.test.ts +21 -0
  176. package/src/shared/lib/omp/session/operator-title.ts +28 -0
  177. package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +0 -1
  178. package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +0 -1
  179. package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +0 -1
  180. package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +0 -1
  181. package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +0 -1
  182. package/dist/client/static/js/html-bwyt0ayy.js +0 -1
  183. package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +0 -1
  184. package/dist/client/static/js/one-dark-pro-9tt0a020.js +0 -1
  185. package/dist/client/static/js/one-light-5fg4r0ra.js +0 -1
  186. package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +0 -1
  187. package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +0 -1
  188. package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +0 -1
  189. package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +0 -1
  190. package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +0 -1
  191. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +0 -1
  192. package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +0 -1
  193. package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +0 -1
  194. package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +0 -1
  195. package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +0 -1
@@ -0,0 +1,223 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * What a child tells its coordinator when a run ends — and, more importantly,
8
+ * when it does not.
9
+ *
10
+ * Three failures are pinned here, all measured on a real orchestration run:
11
+ *
12
+ * - a worker whose provider answered `400 The model … is currently
13
+ * unavailable` reached its coordinator as the bare sentence "The run ended
14
+ * with error", because the failure was read from a nested `error` field omp
15
+ * never writes (it uses flat `errorMessage`/`errorStatus`);
16
+ * - the reason was ALSO lost whenever the terminal frame was compacted, which
17
+ * omp does to every frame over 1 MiB by dropping what `message_end` already
18
+ * delivered — the failed assistant message is always among them;
19
+ * - a retry saga reported per attempt, so a coordinator was told its worker
20
+ * had failed while omp was still retrying that worker.
21
+ *
22
+ * The fold is driven with real frames (the shapes omp emits) and the notice is
23
+ * read back through the shared parser, so the text a coordinator receives is
24
+ * what is asserted — not an internal field. `settleTerminalRun` returns its
25
+ * write, so nothing here waits on a clock.
26
+ */
27
+
28
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
29
+ import { mkdtempSync } from 'node:fs';
30
+ import { tmpdir } from 'node:os';
31
+ import { join } from 'node:path';
32
+
33
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
34
+ import { getDb } from '@/server/db.server';
35
+ import { ensureSessionRelationsSchema } from '@/server/lib/sessions/schema.server';
36
+ import { createSessionRelation } from '@/server/lib/sessions/relations.server';
37
+ import { cancelNoticeTimer, materializeNotice } from '@/server/lib/sessions/notify.server';
38
+ import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
39
+ import { makeHost } from '@/server/lib/omp/rpc/frame-fold-host.test-util';
40
+ import {
41
+ noteRefusedPrompt,
42
+ noteRunEndedWithoutFrame,
43
+ settleTerminalRun,
44
+ } from '@/server/lib/omp/rpc/terminal-settle';
45
+ import {
46
+ parseChildOutcomeNotice,
47
+ parseOrchestrationBlock,
48
+ type ChildOutcomeEntry,
49
+ } from '@/shared/lib/chat/orchestration/notice';
50
+ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
51
+
52
+ const PARENT = 'parent-1';
53
+ const CHILD = 'child-1';
54
+ const previousAgentDir = Bun.env.PI_CODING_AGENT_DIR;
55
+
56
+ beforeEach(async () => {
57
+ // An empty agent dir: the notice reads the child's title from its session
58
+ // file, and a suite must never scan the developer's real ~/.omp tree.
59
+ Bun.env.PI_CODING_AGENT_DIR = mkdtempSync(join(tmpdir(), 'kabmo-settle-agent-'));
60
+ await isolateDb();
61
+ await ensureSessionRelationsSchema(await getDb());
62
+ await createSessionRelation({ sessionId: CHILD, parentSessionId: PARENT });
63
+ });
64
+
65
+ afterEach(async () => {
66
+ cancelNoticeTimer(PARENT);
67
+ if (previousAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
68
+ else Bun.env.PI_CODING_AGENT_DIR = previousAgentDir;
69
+ await releaseDb();
70
+ });
71
+
72
+ function host() {
73
+ return makeHost({ sessionId: CHILD });
74
+ }
75
+
76
+ function fold(target: ReturnType<typeof host>, event: AgentEvent): void {
77
+ foldSessionFrame(target, event);
78
+ }
79
+
80
+ /** The notice body, parsed the way the timeline parses it. */
81
+ async function outcomeOf(parent: string): Promise<ChildOutcomeEntry[]> {
82
+ const text = await materializeNotice(parent);
83
+ if (text === null) return [];
84
+ const block = parseOrchestrationBlock(text);
85
+ return parseChildOutcomeNotice(block?.body ?? '');
86
+ }
87
+
88
+ const FAILED_TURN = {
89
+ type: 'message_end',
90
+ message: {
91
+ role: 'assistant',
92
+ stopReason: 'error',
93
+ errorStatus: 400,
94
+ errorMessage: 'The model agnes-2-5-flash:free is currently unavailable.',
95
+ content: [],
96
+ },
97
+ } as AgentEvent;
98
+
99
+ const GOOD_TURN = {
100
+ type: 'message_end',
101
+ message: { role: 'assistant', stopReason: 'stop', content: [{ type: 'text', text: 'all done' }] },
102
+ } as AgentEvent;
103
+
104
+ describe('a failed run reports the provider’s own words', () => {
105
+ test('the reason survives a compacted terminal frame', async () => {
106
+ const target = host();
107
+ fold(target, { type: 'agent_start' });
108
+ fold(target, FAILED_TURN);
109
+ // omp drops the messages it already delivered: the terminal frame is empty.
110
+ await settleTerminalRun(target, []);
111
+
112
+ const [entry] = await outcomeOf(PARENT);
113
+ expect(entry?.status).toBe('failed');
114
+ expect(entry?.failure).toContain('400 The model agnes-2-5-flash:free is currently unavailable.');
115
+ });
116
+
117
+ test('a reason that only the terminal frame carries is still read', async () => {
118
+ const target = host();
119
+ fold(target, { type: 'agent_start' });
120
+ await settleTerminalRun(target, [
121
+ { role: 'assistant', stopReason: 'error', errorMessage: 'quota exhausted' },
122
+ ]);
123
+
124
+ const [entry] = await outcomeOf(PARENT);
125
+ expect(entry?.failure).toContain('quota exhausted');
126
+ });
127
+ });
128
+
129
+ describe('a retry saga reports once, at its end', () => {
130
+ test('nothing is reported while omp is still retrying', () => {
131
+ const target = host();
132
+ fold(target, { type: 'agent_start' });
133
+ fold(target, FAILED_TURN);
134
+ fold(target, { type: 'auto_retry_start', attempt: 1, maxAttempts: 3, delayMs: 2_000 });
135
+ // The attempt's own non-terminal end: the run is NOT over.
136
+ fold(target, { type: 'agent_end', isTerminal: false, messages: [] });
137
+
138
+ expect(target.retrySagaOpen).toBe(true);
139
+ expect(target.runOutcomeReported).toBe(false);
140
+ });
141
+
142
+ test('a retry that recovers reports a completed run, not the failed attempt', async () => {
143
+ const target = host();
144
+ fold(target, { type: 'agent_start' });
145
+ fold(target, FAILED_TURN);
146
+ fold(target, { type: 'auto_retry_start', attempt: 1, maxAttempts: 3, delayMs: 1_000 });
147
+ fold(target, { type: 'agent_start' });
148
+ fold(target, GOOD_TURN);
149
+ fold(target, { type: 'auto_retry_end', success: true, attempt: 1 });
150
+ await settleTerminalRun(target, [
151
+ { role: 'assistant', stopReason: 'stop', content: [{ type: 'text', text: 'all done' }] },
152
+ ]);
153
+
154
+ const [entry] = await outcomeOf(PARENT);
155
+ expect(entry?.status).toBe('completed');
156
+ expect(entry?.output).toBe('all done');
157
+ expect(entry?.failure).toBeUndefined();
158
+ });
159
+
160
+ test('a spent retry budget reports the budget, not a generic failure', async () => {
161
+ const target = host();
162
+ fold(target, { type: 'agent_start' });
163
+ fold(target, FAILED_TURN);
164
+ fold(target, { type: 'auto_retry_start', attempt: 3, maxAttempts: 3, delayMs: 1_000 });
165
+ fold(target, {
166
+ type: 'auto_retry_end',
167
+ success: false,
168
+ attempt: 3,
169
+ finalError: 'Retry budget exhausted after 3 retries: 429 rate limited',
170
+ });
171
+ await settleTerminalRun(target, []);
172
+
173
+ const [entry] = await outcomeOf(PARENT);
174
+ expect(entry?.status).toBe('failed');
175
+ expect(entry?.failure).toContain('Retry budget exhausted after 3 retries');
176
+ });
177
+ });
178
+
179
+ describe('one outcome per run', () => {
180
+ test('a second settle cannot rewrite a reported outcome', async () => {
181
+ const target = host();
182
+ fold(target, { type: 'agent_start' });
183
+ fold(target, GOOD_TURN);
184
+ await settleTerminalRun(target, []);
185
+ // The process exits after the run already settled: nothing new to say.
186
+ await noteRunEndedWithoutFrame(target, 'failed', 'the process died');
187
+
188
+ const [entry] = await outcomeOf(PARENT);
189
+ expect(entry?.status).toBe('completed');
190
+ });
191
+
192
+ test('a run that ends without a frame is reported as interrupted, once', async () => {
193
+ const target = host();
194
+ fold(target, { type: 'agent_start' });
195
+ await noteRunEndedWithoutFrame(target, 'interrupted', 'the run stopped reporting progress');
196
+ await noteRunEndedWithoutFrame(target, 'interrupted', 'the run stopped reporting progress');
197
+
198
+ const entries = await outcomeOf(PARENT);
199
+ expect(entries).toHaveLength(1);
200
+ expect(entries[0]?.status).toBe('interrupted');
201
+ expect(entries[0]?.failure).toContain('stopped reporting progress');
202
+ });
203
+ });
204
+
205
+ describe('a refused prompt', () => {
206
+ test('a busy refusal is not an outcome — the run is still going', async () => {
207
+ await noteRefusedPrompt(
208
+ { type: 'response', success: false, command: 'prompt', error: 'Agent is already processing a turn' },
209
+ CHILD,
210
+ );
211
+ expect(await materializeNotice(PARENT)).toBeNull();
212
+ });
213
+
214
+ test('a real refusal is reported with its reason', async () => {
215
+ await noteRefusedPrompt(
216
+ { type: 'response', success: false, command: 'prompt', error: 'Session not found' },
217
+ CHILD,
218
+ );
219
+ const [entry] = await outcomeOf(PARENT);
220
+ expect(entry?.status).toBe('failed');
221
+ expect(entry?.failure).toBe('Session not found');
222
+ });
223
+ });
@@ -25,6 +25,16 @@
25
25
  * - **The badge is written from this frame alone.** `turn_end` fires for every
26
26
  * turn of a multi-turn run and carries no `isTerminal`, so it cannot say the
27
27
  * run is over; `agent_end` is the only frame that knows.
28
+ *
29
+ * The CHILD OUTCOME is reported from here too, and it obeys one rule the rest
30
+ * of the settle does not: a run reports ONCE, at the moment it is genuinely
31
+ * over. omp retries a transient provider failure by itself and keeps the run
32
+ * open across the attempts (`agent_end {isTerminal:false}` between them, no
33
+ * terminal end until the saga resolves), so a coordinator that saw an outcome
34
+ * per attempt would be told a worker failed while that worker was still
35
+ * working. `runOutcomeReported` is the latch that makes a second settle — a
36
+ * synthesized one after lost frames, or the process exit — a no-op, and
37
+ * `auto_retry_*` is what names the reason instead of guessing it.
28
38
  */
29
39
 
30
40
  import {
@@ -38,11 +48,26 @@ import { driveGoalAfterTurn, lastAssistantText } from '@/server/lib/omp/session/
38
48
  import { noteChildOutcome } from '@/server/lib/sessions/notify.server';
39
49
  import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
40
50
  import { publishSidebarStructure } from '@/server/lib/realtime/topics.server';
51
+ import { AGENT_BUSY_REFUSAL_RE } from '@/server/lib/omp/rpc/constants';
52
+ import { deriveTurnError, turnStoppedAbnormally } from '@/shared/lib/omp/session/turn-error';
53
+ import type { ChildOutcomeNotice } from '@/server/lib/sessions/notify.server';
41
54
 
42
55
  /** The wrapper surface a terminal settle touches. */
43
56
  export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
44
57
  /** Abort verdict captured from `message_end` — see `SessionFrameHost.runAborted`. */
45
58
  runAborted: boolean;
59
+ /** The provider failure the run's last settled assistant message carried, in
60
+ * omp's own words. Captured at `message_end` because the terminal frame is
61
+ * compacted (see `endedAborted`). */
62
+ runFailure: string | null;
63
+ /** True between `auto_retry_start` and `auto_retry_end`: omp is inside a
64
+ * retry saga and the run is NOT over. */
65
+ retrySagaOpen: boolean;
66
+ /** The reason the last retry saga closed with, when it closed as a failure. */
67
+ retryFinalError: string | null;
68
+ /** Set once this RUN has told its coordinator how it ended. Cleared at
69
+ * `agent_start`, so a queued follow-up run reports its own outcome. */
70
+ runOutcomeReported: boolean;
46
71
  }
47
72
 
48
73
  /**
@@ -58,11 +83,8 @@ export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
58
83
  * `message_end` (keeping only `messageCount`), and the aborted assistant message
59
84
  * is always among them — measured on 18.16.0, `message_end`
60
85
  * (`role: "assistant"`, `stopReason: "aborted"`) arrives before `agent_end`.
61
- * Reading only the frame therefore reports a stopped run as finished, and the
62
- * settle then titles the session, audits the goal and releases the queue for a
63
- * turn the operator cancelled. 12.7% of the runs in this workstation's own
64
- * session store (494 of 3901) exceed the 1 MiB frame ceiling, so the trimmed
65
- * case is routine, not exotic.
86
+ * 12.7% of the runs in this workstation's own session store (494 of 3901) exceed
87
+ * the 1 MiB frame ceiling, so the trimmed case is routine, not exotic.
66
88
  */
67
89
  function endedAborted(host: TerminalSettleHost, messages: unknown): boolean {
68
90
  if (host.runAborted) return true;
@@ -75,25 +97,58 @@ function endedAborted(host: TerminalSettleHost, messages: unknown): boolean {
75
97
  );
76
98
  }
77
99
 
78
- const FAILED_STOP_REASONS: Readonly<Record<string, true>> = { error: true, failed: true, failure: true };
100
+ /**
101
+ * The failure one assistant message names, or null when it did not fail.
102
+ *
103
+ * omp records the reason as FLAT fields on the message (`stopReason` /
104
+ * `errorStatus` / `errorId` / `errorMessage`) — there is no nested `error`
105
+ * object. Reading one (the shape this replaced) is why a worker whose provider
106
+ * answered "400 The model … is currently unavailable" reported to its
107
+ * coordinator as the bare sentence "The run ended with error": the reason was
108
+ * in the transcript the whole time. `deriveTurnError` is the shared read both
109
+ * render paths already use, so the notice and the timeline cannot disagree.
110
+ */
111
+ export function assistantFailure(record: Record<string, unknown>): string | null {
112
+ if (record.role !== 'assistant') return null;
113
+ if (!turnStoppedAbnormally(record)) return null;
114
+ const error = deriveTurnError(record);
115
+ const message = error?.message?.trim();
116
+ if (message) {
117
+ const status = error?.status;
118
+ // Providers usually repeat the status in their own text ("400 The model …"),
119
+ // so prefixing unconditionally printed "400 400 The model …".
120
+ if (status === undefined || message.startsWith(String(status))) return message;
121
+ return `${status} ${message}`;
122
+ }
123
+ const stop = error?.stopReason;
124
+ return stop ? `The turn ended with ${stop}.` : 'The turn ended with an error.';
125
+ }
79
126
 
80
127
  /** The failure a terminal frame reports, or null for a normal stop.
81
128
  *
82
- * Conservative on purpose: only an assistant message's own `error` text or an
83
- * explicit failure stop reason counts. A tool error is not a failed run. */
129
+ * Conservative on purpose: only an assistant message's own error does. A tool
130
+ * error is not a failed run. */
84
131
  function endedFailure(messages: unknown): string | null {
85
132
  if (!Array.isArray(messages)) return null;
86
133
  for (const entry of messages) {
87
134
  if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;
88
- const record = entry as Record<string, unknown>;
89
- const error = typeof record.error === 'string' ? record.error.trim() : '';
90
- if (record.role === 'assistant' && error) return error;
91
- const stop = typeof record.stopReason === 'string' ? record.stopReason : '';
92
- if (FAILED_STOP_REASONS[stop] === true) return `The run ended with ${stop}`;
135
+ const failure = assistantFailure(entry as Record<string, unknown>);
136
+ if (failure) return failure;
93
137
  }
94
138
  return null;
95
139
  }
96
140
 
141
+ /** The one reason the run did not finish normally, from the most reliable
142
+ * source that has one. */
143
+ function runFailureOf(host: TerminalSettleHost, messages: unknown): string | null {
144
+ return host.retryFinalError
145
+ ?? host.runFailure
146
+ ?? endedFailure(messages)
147
+ // A terminal end while a saga is still open: omp gave up without closing it
148
+ // (or closed it with no reason). Silence would be read as success.
149
+ ?? (host.retrySagaOpen ? 'The run ended while omp was still retrying a provider error.' : null);
150
+ }
151
+
97
152
  /**
98
153
  * Write the terminal stream badge from the ending turn's own stopReason.
99
154
  *
@@ -102,7 +157,12 @@ function endedFailure(messages: unknown): string | null {
102
157
  * Re-check the current row and only upgrade `stream` rows, so a `finish`
103
158
  * written here can never clobber a newer run's live `stream`/`abort`.
104
159
  */
105
- async function markEndStatus(sessionId: string, host: TerminalSettleHost, messages: unknown): Promise<void> {
160
+ async function markEndStatus(
161
+ sessionId: string,
162
+ host: TerminalSettleHost,
163
+ messages: unknown,
164
+ failure: string | null,
165
+ ): Promise<void> {
106
166
  if (!sessionId) return;
107
167
  const current = await loadStreamStatuses();
108
168
  if (current[sessionId] !== 'stream') return;
@@ -110,7 +170,7 @@ async function markEndStatus(sessionId: string, host: TerminalSettleHost, messag
110
170
  await markStreamStatus(sessionId, 'abort');
111
171
  return;
112
172
  }
113
- await markStreamStatus(sessionId, 'finish', undefined, endedFailure(messages));
173
+ await markStreamStatus(sessionId, 'finish', undefined, failure);
114
174
  }
115
175
 
116
176
  /**
@@ -118,31 +178,68 @@ async function markEndStatus(sessionId: string, host: TerminalSettleHost, messag
118
178
  *
119
179
  * A refused prompt opens no turn, so no `agent_end` will ever settle it. The
120
180
  * check lives here because this module already owns the outcome vocabulary.
181
+ *
182
+ * A refusal for BUSY is not an outcome: the session is streaming (often
183
+ * mid-retry), nothing was delivered, and Kabmo's queue re-sends. Reporting it
184
+ * told a coordinator its worker had failed while the worker was still running.
121
185
  */
122
186
  export function noteRefusedPrompt(
123
187
  event: { type?: string; success?: unknown; command?: unknown; error?: unknown },
124
188
  sessionId: string,
125
- ): void {
126
- if (event.type !== 'response' || event.success !== false || event.command !== 'prompt' || !sessionId) return;
127
- void noteChildOutcome({
128
- sessionId,
129
- status: 'failed',
130
- failure: typeof event.error === 'string' ? event.error : 'Prompt failed',
131
- }).catch((error: unknown) => {
189
+ ): Promise<void> {
190
+ if (event.type !== 'response' || event.success !== false || event.command !== 'prompt' || !sessionId) {
191
+ return Promise.resolve();
192
+ }
193
+ const failure = typeof event.error === 'string' ? event.error : 'Prompt failed';
194
+ if (AGENT_BUSY_REFUSAL_RE.test(failure)) return Promise.resolve();
195
+ return noteChildOutcome({ sessionId, status: 'failed', failure }).catch((error: unknown) => {
132
196
  console.error('[sessions] could not record a refused prompt:', error);
133
197
  });
134
198
  }
135
199
 
136
- /** Run the side effects a terminal run end owns. */
137
- export function settleTerminalRun(host: TerminalSettleHost, messages: unknown): void {
200
+ /**
201
+ * Report a run that ended WITHOUT a terminal frame.
202
+ *
203
+ * Two paths reach this: omp answered `get_state` with `isSettled` after its
204
+ * frame stream stopped (`run-settle.server.ts`), and the omp process exited
205
+ * mid-run. Neither can produce the frame that normally carries the outcome, so
206
+ * without this a coordinator is never told — the worker simply goes quiet, and
207
+ * "no news" is indistinguishable from "still retrying".
208
+ *
209
+ * Never a success: nothing here observed the run finish, and claiming one is
210
+ * the false completion this exists to remove.
211
+ */
212
+ export function noteRunEndedWithoutFrame(
213
+ host: { sessionId: string; runOutcomeReported: boolean },
214
+ status: Extract<ChildOutcomeNotice['status'], 'failed' | 'interrupted'>,
215
+ failure: string,
216
+ ): Promise<void> {
217
+ if (!host.sessionId || host.runOutcomeReported) return Promise.resolve();
218
+ host.runOutcomeReported = true;
219
+ return noteChildOutcome({ sessionId: host.sessionId, status, failure }).catch((error: unknown) => {
220
+ console.error('[sessions] could not record a child outcome:', error);
221
+ });
222
+ }
223
+
224
+ /**
225
+ * Run the side effects a terminal run end owns.
226
+ *
227
+ * Returns the outcome write, so a caller that must observe it (a test, or a
228
+ * shutdown path that wants the row durable) can await it. The frame fold
229
+ * deliberately does not: a settle must never block the frame stream.
230
+ */
231
+ export function settleTerminalRun(host: TerminalSettleHost, messages: unknown): Promise<void> {
138
232
  const aborted = endedAborted(host, messages);
139
- const failure = aborted ? null : endedFailure(messages);
140
- if (host.sessionId) void markEndStatus(host.sessionId, host, messages);
233
+ const failure = aborted ? null : runFailureOf(host, messages);
234
+ if (host.sessionId) void markEndStatus(host.sessionId, host, messages, failure);
141
235
  // Delegation is reported here, not from the route: this frame is the only
142
236
  // moment that knows a run genuinely ended, and a synthetic `run-settle`
143
- // reconcile must report the same outcome as a real `agent_end`.
144
- if (host.sessionId) {
145
- void noteChildOutcome({
237
+ // reconcile must report the same outcome as a real `agent_end`. Exactly once
238
+ // per run — see the module header.
239
+ let reported: Promise<void> = Promise.resolve();
240
+ if (host.sessionId && !host.runOutcomeReported) {
241
+ host.runOutcomeReported = true;
242
+ reported = noteChildOutcome({
146
243
  sessionId: host.sessionId,
147
244
  status: aborted ? 'interrupted' : failure ? 'failed' : 'completed',
148
245
  output: aborted ? null : lastAssistantText(messages),
@@ -175,4 +272,5 @@ export function settleTerminalRun(host: TerminalSettleHost, messages: unknown):
175
272
  // The final answer appended after the last tool call; the sidebar's ordering
176
273
  // and time-ago labels catch up on it the same way.
177
274
  publishSidebarStructure();
275
+ return reported;
178
276
  }
@@ -19,7 +19,7 @@
19
19
 
20
20
  import { readLastEntryTimestamp, readTextPrefix, SESSION_LIST_PREFIX_BYTES } from '@/server/lib/omp/session/file-scan';
21
21
  import { countMessageMarkers, parseJsonlLenient, parseSessionListHeader } from '@/shared/lib/omp/session/jsonl';
22
- import { firstOperatorTitleFromPrefix, operatorTitleFromEntry } from '@/shared/lib/omp/session/operator-title';
22
+ import { countSkillPromptMarkers, firstOperatorTitleFromPrefix, operatorTitleFromEntry, SKILL_PROMPT_CUSTOM_TYPE } from '@/shared/lib/omp/session/operator-title';
23
23
 
24
24
  export const SESSION_TITLE_SLOT_BYTES = 256;
25
25
 
@@ -76,6 +76,7 @@ export async function scanSessionInfo(filePath: string): Promise<OmpSessionInfo
76
76
  type?: string;
77
77
  message?: { role?: string; content?: unknown };
78
78
  shortSummary?: string;
79
+ customType?: string;
79
80
  };
80
81
  if (entry.type === 'compaction' && typeof entry.shortSummary === 'string') {
81
82
  shortSummary = entry.shortSummary;
@@ -83,6 +84,14 @@ export async function scanSessionInfo(filePath: string): Promise<OmpSessionInfo
83
84
  if (entry.type === 'message' && entry.message) {
84
85
  parsedMessageCount++;
85
86
  }
87
+ // A `/skill:` turn is a real message in omp's transcript (a
88
+ // `custom_message`, not a `message`). Counting only `message` entries
89
+ // reported `messageCount: 0` for a chat opened with `/skill:<name>`, and
90
+ // the sidebar drops `messageCount === 0` files as header-only — measured:
91
+ // 8 real chats in one project missing from the list.
92
+ if (entry.type === 'custom_message' && entry.customType === SKILL_PROMPT_CUSTOM_TYPE) {
93
+ parsedMessageCount++;
94
+ }
86
95
  // The operator's opening turn, by the ONE rule every surface shares — a
87
96
  // `user` message OR a `/skill:` custom entry. A skill turn carries no
88
97
  // `role` field, so a scan that looked only for `role: "user"` reported
@@ -99,6 +108,10 @@ export async function scanSessionInfo(filePath: string): Promise<OmpSessionInfo
99
108
  // raw-text pass below is the only chance — it is what keeps this reader in
100
109
  // agreement with the header instead of guessing a placeholder.
101
110
  firstMessage ||= firstOperatorTitleFromPrefix(prefix) ?? '';
111
+ // Same reason for the COUNT: a skill entry cut by the window is not a
112
+ // parsed entry, so the raw marker is the only evidence the chat has a turn
113
+ // at all. Without it the row is filtered out as header-only.
114
+ const rawMessageCount = countMessageMarkers(prefix) + countSkillPromptMarkers(prefix);
102
115
  return {
103
116
  path: filePath,
104
117
  id: header.id,
@@ -109,7 +122,7 @@ export async function scanSessionInfo(filePath: string): Promise<OmpSessionInfo
109
122
  modified: lastEntryAt ?? mtime,
110
123
  fileMtime: mtime,
111
124
  fileMtimeMs: mtimeMs,
112
- messageCount: Math.max(parsedMessageCount, countMessageMarkers(prefix)),
125
+ messageCount: Math.max(parsedMessageCount, rawMessageCount),
113
126
  size,
114
127
  firstMessage: firstMessage || '(no messages)',
115
128
  };
@@ -193,6 +193,27 @@ describe('scanSessionInfo', () => {
193
193
  expect((await scanSessionInfo(file))?.firstMessage).toBe('(no messages)');
194
194
  });
195
195
 
196
+ test('a session opened with /skill: counts as a chat even when the skill body fills the window', async () => {
197
+ // The reported shape: the opening turn is a `custom_message` whose expanded
198
+ // SKILL.md runs past the 4 KiB prefix, so no `message` entry is in the
199
+ // window at all. Counting only `message` entries reported 0, and the
200
+ // sidebar drops `messageCount === 0` files as header-only — the row
201
+ // vanished (8 real chats in one project, 0.8–8.6 MB each).
202
+ const body = '# antislop-ui\n' + 'skill instructions\n'.repeat(400);
203
+ const file = writeSessionFile(join(tempDir('scan'), 'proj', 'skill.jsonl'), [
204
+ header('skill-id'),
205
+ {
206
+ type: 'custom_message',
207
+ customType: 'skill-prompt',
208
+ content: `[IMPORTANT: User invoked the "antislop-ui" skill; follow its instructions. Full skill below.]\n\n${body}`,
209
+ attribution: 'user',
210
+ },
211
+ ]);
212
+ const info = await scanSessionInfo(file);
213
+ expect(info?.messageCount).toBe(1);
214
+ expect(info?.firstMessage).toBe('/skill:antislop-ui');
215
+ });
216
+
196
217
  test('a missing file yields undefined instead of throwing', async () => {
197
218
  expect(await scanSessionInfo(join(tempDir('scan'), 'gone.jsonl'))).toBeUndefined();
198
219
  });
@@ -25,6 +25,10 @@ import {
25
25
  noteChildOutcome,
26
26
  } from '@/server/lib/sessions/notify.server';
27
27
  import { listQueue } from '@/server/lib/queue/store.server';
28
+ import {
29
+ parseChildOutcomeNotice,
30
+ parseOrchestrationBlock,
31
+ } from '@/shared/lib/chat/orchestration/notice';
28
32
 
29
33
  const parents = new Set<string>();
30
34
 
@@ -57,9 +61,13 @@ describe('child outcome notices', () => {
57
61
  await noteChildOutcome({ sessionId: 'c2', status: 'completed', output: 'second done' });
58
62
 
59
63
  const text = await materializeNotice('p');
60
- expect(text).toContain('Child session updates');
61
- expect(text).toContain('c1');
62
- expect(text).toContain('c2');
64
+ expect(text).not.toBeNull();
65
+ // The body is the shared envelope, so the coordinator's message and the
66
+ // timeline card are built from the same text.
67
+ const block = parseOrchestrationBlock(text ?? '');
68
+ const entries = parseChildOutcomeNotice(block?.body ?? '');
69
+ expect(entries.map((entry) => entry.sessionId)).toEqual(['c1', 'c2']);
70
+ expect(entries[0]?.output).toBe('first done');
63
71
  expect(await listQueue('p')).toHaveLength(1);
64
72
  });
65
73