@stigmer/react 3.0.9-dev.20260615153829 → 3.1.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 (439) hide show
  1. package/execution/ApprovalCard.d.ts +47 -3
  2. package/execution/ApprovalCard.d.ts.map +1 -1
  3. package/execution/ApprovalCard.js +138 -70
  4. package/execution/ApprovalCard.js.map +1 -1
  5. package/execution/ApprovalContext.d.ts +72 -0
  6. package/execution/ApprovalContext.d.ts.map +1 -0
  7. package/execution/ApprovalContext.js +41 -0
  8. package/execution/ApprovalContext.js.map +1 -0
  9. package/execution/ArtifactCard.d.ts.map +1 -1
  10. package/execution/ArtifactCard.js +3 -1
  11. package/execution/ArtifactCard.js.map +1 -1
  12. package/execution/ArtifactPreviewModal.d.ts.map +1 -1
  13. package/execution/ArtifactPreviewModal.js +5 -3
  14. package/execution/ArtifactPreviewModal.js.map +1 -1
  15. package/execution/EmptyChangeNotice.d.ts +38 -0
  16. package/execution/EmptyChangeNotice.d.ts.map +1 -0
  17. package/execution/EmptyChangeNotice.js +27 -0
  18. package/execution/EmptyChangeNotice.js.map +1 -0
  19. package/execution/FileChangesView.d.ts +81 -0
  20. package/execution/FileChangesView.d.ts.map +1 -0
  21. package/execution/FileChangesView.js +164 -0
  22. package/execution/FileChangesView.js.map +1 -0
  23. package/execution/FilePathLink.d.ts +24 -4
  24. package/execution/FilePathLink.d.ts.map +1 -1
  25. package/execution/FilePathLink.js +31 -9
  26. package/execution/FilePathLink.js.map +1 -1
  27. package/execution/FileReviewCard.d.ts +111 -0
  28. package/execution/FileReviewCard.d.ts.map +1 -0
  29. package/execution/FileReviewCard.js +558 -0
  30. package/execution/FileReviewCard.js.map +1 -0
  31. package/execution/FileReviewContext.d.ts +35 -0
  32. package/execution/FileReviewContext.d.ts.map +1 -0
  33. package/execution/FileReviewContext.js +23 -0
  34. package/execution/FileReviewContext.js.map +1 -0
  35. package/execution/FileReviewDock.d.ts +73 -0
  36. package/execution/FileReviewDock.d.ts.map +1 -0
  37. package/execution/FileReviewDock.js +65 -0
  38. package/execution/FileReviewDock.js.map +1 -0
  39. package/execution/McpToolDetail.d.ts.map +1 -1
  40. package/execution/McpToolDetail.js +38 -5
  41. package/execution/McpToolDetail.js.map +1 -1
  42. package/execution/MessageThread.d.ts +42 -3
  43. package/execution/MessageThread.d.ts.map +1 -1
  44. package/execution/MessageThread.js +263 -18
  45. package/execution/MessageThread.js.map +1 -1
  46. package/execution/PlanArtifactCard.d.ts.map +1 -1
  47. package/execution/PlanArtifactCard.js +3 -1
  48. package/execution/PlanArtifactCard.js.map +1 -1
  49. package/execution/PlanCompletionCard.d.ts +1 -1
  50. package/execution/PlanCompletionCard.js +1 -1
  51. package/execution/ResultView.d.ts +19 -1
  52. package/execution/ResultView.d.ts.map +1 -1
  53. package/execution/ResultView.js +141 -40
  54. package/execution/ResultView.js.map +1 -1
  55. package/execution/SubAgentSection.d.ts.map +1 -1
  56. package/execution/SubAgentSection.js +45 -6
  57. package/execution/SubAgentSection.js.map +1 -1
  58. package/execution/TerminalSession.d.ts +34 -0
  59. package/execution/TerminalSession.d.ts.map +1 -0
  60. package/execution/TerminalSession.js +34 -0
  61. package/execution/TerminalSession.js.map +1 -0
  62. package/execution/TodoCard.d.ts +53 -0
  63. package/execution/TodoCard.d.ts.map +1 -0
  64. package/execution/TodoCard.js +77 -0
  65. package/execution/TodoCard.js.map +1 -0
  66. package/execution/ToolArgsView.d.ts +7 -1
  67. package/execution/ToolArgsView.d.ts.map +1 -1
  68. package/execution/ToolArgsView.js +10 -9
  69. package/execution/ToolArgsView.js.map +1 -1
  70. package/execution/ToolCallDetail.d.ts +10 -1
  71. package/execution/ToolCallDetail.d.ts.map +1 -1
  72. package/execution/ToolCallDetail.js +66 -19
  73. package/execution/ToolCallDetail.js.map +1 -1
  74. package/execution/ToolCallGroup.d.ts +28 -18
  75. package/execution/ToolCallGroup.d.ts.map +1 -1
  76. package/execution/ToolCallGroup.js +39 -148
  77. package/execution/ToolCallGroup.js.map +1 -1
  78. package/execution/ToolCallItem.d.ts +36 -8
  79. package/execution/ToolCallItem.d.ts.map +1 -1
  80. package/execution/ToolCallItem.js +140 -21
  81. package/execution/ToolCallItem.js.map +1 -1
  82. package/execution/ToolRunGroup.d.ts +48 -0
  83. package/execution/ToolRunGroup.d.ts.map +1 -0
  84. package/execution/ToolRunGroup.js +168 -0
  85. package/execution/ToolRunGroup.js.map +1 -0
  86. package/execution/approval-provenance.d.ts +2 -0
  87. package/execution/approval-provenance.d.ts.map +1 -0
  88. package/execution/approval-provenance.js +6 -0
  89. package/execution/approval-provenance.js.map +1 -0
  90. package/execution/artifact-utils.d.ts +0 -10
  91. package/execution/artifact-utils.d.ts.map +1 -1
  92. package/execution/artifact-utils.js +0 -17
  93. package/execution/artifact-utils.js.map +1 -1
  94. package/execution/execution-phases.d.ts +1 -6
  95. package/execution/execution-phases.d.ts.map +1 -1
  96. package/execution/execution-phases.js +4 -14
  97. package/execution/execution-phases.js.map +1 -1
  98. package/execution/file-path-resolver.d.ts +28 -0
  99. package/execution/file-path-resolver.d.ts.map +1 -1
  100. package/execution/file-path-resolver.js +24 -0
  101. package/execution/file-path-resolver.js.map +1 -1
  102. package/execution/file-review-status.d.ts +127 -0
  103. package/execution/file-review-status.d.ts.map +1 -0
  104. package/execution/file-review-status.js +135 -0
  105. package/execution/file-review-status.js.map +1 -0
  106. package/execution/index.d.ts +39 -5
  107. package/execution/index.d.ts.map +1 -1
  108. package/execution/index.js +23 -3
  109. package/execution/index.js.map +1 -1
  110. package/execution/segment-tool-calls.d.ts +46 -0
  111. package/execution/segment-tool-calls.d.ts.map +1 -0
  112. package/execution/segment-tool-calls.js +71 -0
  113. package/execution/segment-tool-calls.js.map +1 -0
  114. package/execution/tool-categories.d.ts +62 -1
  115. package/execution/tool-categories.d.ts.map +1 -1
  116. package/execution/tool-categories.js +96 -2
  117. package/execution/tool-categories.js.map +1 -1
  118. package/execution/tool-presenter.d.ts +38 -2
  119. package/execution/tool-presenter.d.ts.map +1 -1
  120. package/execution/tool-presenter.js +23 -1
  121. package/execution/tool-presenter.js.map +1 -1
  122. package/execution/tool-rendering-primitives.d.ts.map +1 -1
  123. package/execution/tool-rendering-primitives.js +3 -2
  124. package/execution/tool-rendering-primitives.js.map +1 -1
  125. package/execution/useArtifactDownload.d.ts +44 -0
  126. package/execution/useArtifactDownload.d.ts.map +1 -0
  127. package/execution/useArtifactDownload.js +80 -0
  128. package/execution/useArtifactDownload.js.map +1 -0
  129. package/execution/useArtifactDownloadUrl.d.ts +67 -0
  130. package/execution/useArtifactDownloadUrl.d.ts.map +1 -0
  131. package/execution/useArtifactDownloadUrl.js +59 -0
  132. package/execution/useArtifactDownloadUrl.js.map +1 -0
  133. package/execution/useFileChangeContent.d.ts +61 -0
  134. package/execution/useFileChangeContent.d.ts.map +1 -0
  135. package/execution/useFileChangeContent.js +89 -0
  136. package/execution/useFileChangeContent.js.map +1 -0
  137. package/execution/useFileReview.d.ts +89 -0
  138. package/execution/useFileReview.d.ts.map +1 -0
  139. package/execution/useFileReview.js +106 -0
  140. package/execution/useFileReview.js.map +1 -0
  141. package/execution/useSubmitApproval.d.ts +17 -2
  142. package/execution/useSubmitApproval.d.ts.map +1 -1
  143. package/execution/useSubmitApproval.js +27 -23
  144. package/execution/useSubmitApproval.js.map +1 -1
  145. package/execution/useToolOutputContent.d.ts +44 -0
  146. package/execution/useToolOutputContent.d.ts.map +1 -0
  147. package/execution/useToolOutputContent.js +31 -0
  148. package/execution/useToolOutputContent.js.map +1 -0
  149. package/index.d.ts +6 -6
  150. package/index.d.ts.map +1 -1
  151. package/index.js +3 -3
  152. package/index.js.map +1 -1
  153. package/internal/ApprovalPeekBar.d.ts +23 -0
  154. package/internal/ApprovalPeekBar.d.ts.map +1 -0
  155. package/internal/ApprovalPeekBar.js +25 -0
  156. package/internal/ApprovalPeekBar.js.map +1 -0
  157. package/internal/BoundedContent.d.ts +49 -0
  158. package/internal/BoundedContent.d.ts.map +1 -0
  159. package/internal/BoundedContent.js +50 -0
  160. package/internal/BoundedContent.js.map +1 -0
  161. package/internal/DecisionButton.d.ts +47 -0
  162. package/internal/DecisionButton.d.ts.map +1 -0
  163. package/internal/DecisionButton.js +42 -0
  164. package/internal/DecisionButton.js.map +1 -0
  165. package/internal/InCardDecisionError.d.ts +31 -0
  166. package/internal/InCardDecisionError.d.ts.map +1 -0
  167. package/internal/InCardDecisionError.js +23 -0
  168. package/internal/InCardDecisionError.js.map +1 -0
  169. package/internal/RevealToggle.d.ts +36 -0
  170. package/internal/RevealToggle.d.ts.map +1 -0
  171. package/internal/RevealToggle.js +32 -0
  172. package/internal/RevealToggle.js.map +1 -0
  173. package/internal/VirtualizedThread.d.ts +7 -1
  174. package/internal/VirtualizedThread.d.ts.map +1 -1
  175. package/internal/VirtualizedThread.js +7 -3
  176. package/internal/VirtualizedThread.js.map +1 -1
  177. package/internal/code-highlight.d.ts +24 -0
  178. package/internal/code-highlight.d.ts.map +1 -0
  179. package/internal/code-highlight.js +115 -0
  180. package/internal/code-highlight.js.map +1 -0
  181. package/internal/markdown-components.d.ts.map +1 -1
  182. package/internal/markdown-components.js +13 -2
  183. package/internal/markdown-components.js.map +1 -1
  184. package/internal/useAutoDisclosure.d.ts +34 -0
  185. package/internal/useAutoDisclosure.d.ts.map +1 -0
  186. package/internal/useAutoDisclosure.js +53 -0
  187. package/internal/useAutoDisclosure.js.map +1 -0
  188. package/internal/useElapsedSince.d.ts +30 -0
  189. package/internal/useElapsedSince.d.ts.map +1 -0
  190. package/internal/useElapsedSince.js +70 -0
  191. package/internal/useElapsedSince.js.map +1 -0
  192. package/internal/useIsOverflowing.d.ts +30 -0
  193. package/internal/useIsOverflowing.d.ts.map +1 -0
  194. package/internal/useIsOverflowing.js +47 -0
  195. package/internal/useIsOverflowing.js.map +1 -0
  196. package/internal/useIsTextTruncated.d.ts +24 -0
  197. package/internal/useIsTextTruncated.d.ts.map +1 -0
  198. package/internal/useIsTextTruncated.js +41 -0
  199. package/internal/useIsTextTruncated.js.map +1 -0
  200. package/internal/useKeyedSubmission.d.ts +49 -0
  201. package/internal/useKeyedSubmission.d.ts.map +1 -0
  202. package/internal/useKeyedSubmission.js +67 -0
  203. package/internal/useKeyedSubmission.js.map +1 -0
  204. package/package.json +7 -4
  205. package/session/SessionViewer.d.ts +2 -2
  206. package/session/SessionViewer.d.ts.map +1 -1
  207. package/session/SessionViewer.js +10 -4
  208. package/session/SessionViewer.js.map +1 -1
  209. package/session/index.d.ts +2 -0
  210. package/session/index.d.ts.map +1 -1
  211. package/session/index.js +1 -0
  212. package/session/index.js.map +1 -1
  213. package/session/inspector/ChangesTab.d.ts +8 -5
  214. package/session/inspector/ChangesTab.d.ts.map +1 -1
  215. package/session/inspector/ChangesTab.js +11 -8
  216. package/session/inspector/ChangesTab.js.map +1 -1
  217. package/session/inspector/SessionInspector.d.ts +4 -4
  218. package/session/inspector/SessionInspector.d.ts.map +1 -1
  219. package/session/inspector/SessionInspector.js +4 -4
  220. package/session/inspector/SessionInspector.js.map +1 -1
  221. package/session/inspector/index.d.ts +0 -2
  222. package/session/inspector/index.d.ts.map +1 -1
  223. package/session/inspector/index.js +0 -1
  224. package/session/inspector/index.js.map +1 -1
  225. package/session/inspector/useSessionInspector.d.ts +8 -4
  226. package/session/inspector/useSessionInspector.d.ts.map +1 -1
  227. package/session/inspector/useSessionInspector.js +27 -20
  228. package/session/inspector/useSessionInspector.js.map +1 -1
  229. package/session/useSessionConversation.d.ts +37 -3
  230. package/session/useSessionConversation.d.ts.map +1 -1
  231. package/session/useSessionConversation.js +18 -2
  232. package/session/useSessionConversation.js.map +1 -1
  233. package/session/useSessionFileChanges.d.ts +74 -0
  234. package/session/useSessionFileChanges.d.ts.map +1 -0
  235. package/session/useSessionFileChanges.js +178 -0
  236. package/session/useSessionFileChanges.js.map +1 -0
  237. package/src/__tests__/styles-border-layer-invariant.test.ts +105 -0
  238. package/src/execution/ApprovalCard.tsx +368 -230
  239. package/src/execution/ApprovalContext.ts +109 -0
  240. package/src/execution/ArtifactCard.tsx +10 -6
  241. package/src/execution/ArtifactPreviewModal.tsx +12 -6
  242. package/src/execution/EmptyChangeNotice.tsx +62 -0
  243. package/src/execution/FileChangesView.tsx +383 -0
  244. package/src/execution/FilePathLink.tsx +65 -12
  245. package/src/execution/FileReviewCard.tsx +1118 -0
  246. package/src/execution/FileReviewContext.ts +53 -0
  247. package/src/execution/FileReviewDock.tsx +157 -0
  248. package/src/execution/McpToolDetail.tsx +98 -32
  249. package/src/execution/MessageThread.tsx +374 -9
  250. package/src/execution/PlanArtifactCard.tsx +9 -6
  251. package/src/execution/PlanCompletionCard.tsx +1 -1
  252. package/src/execution/ResultView.tsx +333 -162
  253. package/src/execution/SubAgentSection.tsx +58 -11
  254. package/src/execution/TerminalSession.tsx +91 -0
  255. package/src/execution/TodoCard.tsx +186 -0
  256. package/src/execution/ToolArgsView.tsx +28 -17
  257. package/src/execution/ToolCallDetail.tsx +137 -26
  258. package/src/execution/ToolCallGroup.tsx +68 -296
  259. package/src/execution/ToolCallItem.tsx +265 -67
  260. package/src/execution/ToolRunGroup.tsx +302 -0
  261. package/src/execution/__tests__/ApprovalCard.test.tsx +395 -5
  262. package/src/execution/__tests__/ArtifactContentRenderer.test.tsx +15 -0
  263. package/src/execution/__tests__/ArtifactPreviewModal.test.tsx +0 -1
  264. package/src/execution/__tests__/EmptyChangeNotice.test.tsx +24 -0
  265. package/src/execution/__tests__/FileChangesView.test.tsx +296 -0
  266. package/src/execution/__tests__/FilePathLink.test.tsx +92 -0
  267. package/src/execution/__tests__/FileReviewCard.test.tsx +1044 -0
  268. package/src/execution/__tests__/FileReviewDock.test.tsx +134 -0
  269. package/src/execution/__tests__/McpToolDetail.test.tsx +79 -0
  270. package/src/execution/__tests__/MessageThread.test.tsx +324 -0
  271. package/src/execution/__tests__/PlanArtifactCard.test.tsx +37 -16
  272. package/src/execution/__tests__/ResultView.test.tsx +280 -2
  273. package/src/execution/__tests__/SubAgentSection.test.tsx +180 -0
  274. package/src/execution/__tests__/TerminalSession.test.tsx +72 -0
  275. package/src/execution/__tests__/TodoCard.test.tsx +102 -0
  276. package/src/execution/__tests__/ToolArgsView.test.tsx +48 -0
  277. package/src/execution/__tests__/ToolCallDetail.test.tsx +195 -0
  278. package/src/execution/__tests__/ToolCallGroup.test.tsx +132 -0
  279. package/src/execution/__tests__/ToolCallItem.test.tsx +521 -0
  280. package/src/execution/__tests__/ToolRunGroup.test.tsx +137 -0
  281. package/src/execution/__tests__/blanked-narration.test.tsx +149 -0
  282. package/src/execution/__tests__/buildThreadItems-approvals.test.ts +304 -0
  283. package/src/execution/__tests__/buildThreadItems-file-review.test.ts +331 -0
  284. package/src/execution/__tests__/file-path-resolver.test.ts +44 -0
  285. package/src/execution/__tests__/file-review-status.test.ts +343 -0
  286. package/src/execution/__tests__/message-entry.test.tsx +16 -0
  287. package/src/execution/__tests__/segment-tool-calls.test.ts +124 -0
  288. package/src/execution/__tests__/subagent-file-review-badge.test.tsx +273 -0
  289. package/src/execution/__tests__/thread-keys.test.ts +195 -0
  290. package/src/execution/__tests__/tool-presenter.test.tsx +95 -0
  291. package/src/execution/__tests__/useArtifactDownload.test.tsx +67 -0
  292. package/src/execution/__tests__/useArtifactDownloadUrl.test.tsx +51 -0
  293. package/src/execution/__tests__/useFileChangeContent.test.tsx +240 -0
  294. package/src/execution/__tests__/useFileReview.test.tsx +236 -0
  295. package/src/execution/__tests__/useSubmitApproval.test.tsx +165 -0
  296. package/src/execution/__tests__/useToolOutputContent.test.tsx +82 -0
  297. package/src/execution/approval-provenance.ts +8 -0
  298. package/src/execution/artifact-utils.ts +0 -18
  299. package/src/execution/execution-phases.ts +4 -16
  300. package/src/execution/file-path-resolver.ts +38 -0
  301. package/src/execution/file-review-status.ts +219 -0
  302. package/src/execution/index.ts +84 -4
  303. package/src/execution/segment-tool-calls.ts +101 -0
  304. package/src/execution/tool-categories.ts +128 -1
  305. package/src/execution/tool-presenter.ts +58 -3
  306. package/src/execution/tool-rendering-primitives.tsx +11 -14
  307. package/src/execution/useArtifactDownload.ts +109 -0
  308. package/src/execution/useArtifactDownloadUrl.ts +116 -0
  309. package/src/execution/useFileChangeContent.ts +149 -0
  310. package/src/execution/useFileReview.ts +197 -0
  311. package/src/execution/useSubmitApproval.ts +49 -27
  312. package/src/execution/useToolOutputContent.ts +70 -0
  313. package/src/index.ts +60 -1
  314. package/src/internal/ApprovalPeekBar.tsx +73 -0
  315. package/src/internal/BoundedContent.tsx +97 -0
  316. package/src/internal/DecisionButton.tsx +127 -0
  317. package/src/internal/InCardDecisionError.tsx +47 -0
  318. package/src/internal/RevealToggle.tsx +91 -0
  319. package/src/internal/VirtualizedThread.tsx +28 -2
  320. package/src/internal/__tests__/ApprovalPeekBar.test.tsx +34 -0
  321. package/src/internal/__tests__/BoundedContent.test.tsx +92 -0
  322. package/src/internal/__tests__/DecisionButton.test.tsx +107 -0
  323. package/src/internal/__tests__/RevealToggle.test.tsx +61 -0
  324. package/src/internal/__tests__/code-highlight.test.tsx +59 -0
  325. package/src/internal/__tests__/markdown-components.test.tsx +68 -2
  326. package/src/internal/__tests__/useAutoDisclosure.test.ts +74 -0
  327. package/src/internal/__tests__/useElapsedSince.test.tsx +68 -0
  328. package/src/internal/__tests__/useIsOverflowing.test.ts +36 -0
  329. package/src/internal/__tests__/useKeyedSubmission.test.tsx +126 -0
  330. package/src/internal/code-highlight.tsx +120 -0
  331. package/src/internal/markdown-components.tsx +20 -3
  332. package/src/internal/useAutoDisclosure.ts +58 -0
  333. package/src/internal/useElapsedSince.ts +72 -0
  334. package/src/internal/useIsOverflowing.ts +61 -0
  335. package/src/internal/useIsTextTruncated.ts +55 -0
  336. package/src/internal/useKeyedSubmission.ts +101 -0
  337. package/src/session/SessionViewer.tsx +21 -4
  338. package/src/session/__tests__/SessionViewer-fileReviewDock.test.tsx +198 -0
  339. package/src/session/__tests__/audienceWiring.test.tsx +4 -0
  340. package/src/session/__tests__/useSessionFileChanges.test.ts +303 -0
  341. package/src/session/index.ts +3 -0
  342. package/src/session/inspector/ChangesTab.tsx +20 -17
  343. package/src/session/inspector/SessionInspector.tsx +12 -10
  344. package/src/session/inspector/__tests__/ArtifactsTab.test.tsx +0 -1
  345. package/src/session/inspector/__tests__/ChangesTab.test.tsx +38 -0
  346. package/src/session/inspector/__tests__/useSessionInspector.test.ts +46 -61
  347. package/src/session/inspector/index.ts +0 -3
  348. package/src/session/inspector/useSessionInspector.ts +27 -20
  349. package/src/session/useSessionConversation.ts +80 -3
  350. package/src/session/useSessionFileChanges.ts +207 -0
  351. package/src/styles.css +123 -10
  352. package/src/version-history/DiffViewer.tsx +10 -7
  353. package/src/version-history/UnifiedDiffView.tsx +66 -0
  354. package/src/version-history/__tests__/DiffViewer.test.tsx +57 -0
  355. package/src/version-history/__tests__/UnifiedDiffView.test.tsx +50 -0
  356. package/src/version-history/__tests__/computeDiff.test.ts +35 -0
  357. package/src/version-history/__tests__/parseUnifiedDiff.test.ts +82 -0
  358. package/src/version-history/computeDiff.ts +6 -37
  359. package/src/version-history/diff-hunks.ts +63 -0
  360. package/src/version-history/index.ts +1 -0
  361. package/src/version-history/parseUnifiedDiff.ts +34 -0
  362. package/src/workflow/WorkflowExecutionApprovalCard.tsx +49 -24
  363. package/src/workflow/WorkflowExecutionTimeline.tsx +15 -4
  364. package/src/workflow/WorkflowExecutionTimelineEvent.tsx +8 -3
  365. package/src/workflow/WorkflowExecutionViewer.tsx +72 -28
  366. package/src/workflow/WorkflowFileReviewList.tsx +152 -0
  367. package/src/workflow/WorkflowTaskApprovalCard.tsx +37 -85
  368. package/src/workflow/__tests__/ExecutionInspector.test.tsx +30 -2
  369. package/src/workflow/__tests__/WorkflowExecutionApprovalCard.test.tsx +129 -0
  370. package/src/workflow/__tests__/WorkflowFileReviewList.test.tsx +129 -0
  371. package/src/workflow/__tests__/WorkflowTaskApprovalCard.test.tsx +43 -11
  372. package/src/workflow/__tests__/useWorkflowExecutionActions.test.tsx +276 -0
  373. package/src/workflow/execution-inspector/ExecutionInspector.tsx +42 -18
  374. package/src/workflow/index.ts +5 -0
  375. package/src/workflow/useWorkflowExecutionActions.ts +177 -29
  376. package/styles.css +1 -1
  377. package/version-history/DiffViewer.d.ts.map +1 -1
  378. package/version-history/DiffViewer.js +9 -3
  379. package/version-history/DiffViewer.js.map +1 -1
  380. package/version-history/UnifiedDiffView.d.ts +29 -0
  381. package/version-history/UnifiedDiffView.d.ts.map +1 -0
  382. package/version-history/UnifiedDiffView.js +36 -0
  383. package/version-history/UnifiedDiffView.js.map +1 -0
  384. package/version-history/computeDiff.d.ts +3 -1
  385. package/version-history/computeDiff.d.ts.map +1 -1
  386. package/version-history/computeDiff.js +5 -35
  387. package/version-history/computeDiff.js.map +1 -1
  388. package/version-history/diff-hunks.d.ts +21 -0
  389. package/version-history/diff-hunks.d.ts.map +1 -0
  390. package/version-history/diff-hunks.js +58 -0
  391. package/version-history/diff-hunks.js.map +1 -0
  392. package/version-history/index.d.ts +1 -0
  393. package/version-history/index.d.ts.map +1 -1
  394. package/version-history/index.js +1 -0
  395. package/version-history/index.js.map +1 -1
  396. package/version-history/parseUnifiedDiff.d.ts +22 -0
  397. package/version-history/parseUnifiedDiff.d.ts.map +1 -0
  398. package/version-history/parseUnifiedDiff.js +34 -0
  399. package/version-history/parseUnifiedDiff.js.map +1 -0
  400. package/workflow/WorkflowExecutionApprovalCard.d.ts +8 -1
  401. package/workflow/WorkflowExecutionApprovalCard.d.ts.map +1 -1
  402. package/workflow/WorkflowExecutionApprovalCard.js +17 -3
  403. package/workflow/WorkflowExecutionApprovalCard.js.map +1 -1
  404. package/workflow/WorkflowExecutionTimeline.d.ts +11 -2
  405. package/workflow/WorkflowExecutionTimeline.d.ts.map +1 -1
  406. package/workflow/WorkflowExecutionTimeline.js +2 -2
  407. package/workflow/WorkflowExecutionTimeline.js.map +1 -1
  408. package/workflow/WorkflowExecutionTimelineEvent.d.ts +4 -1
  409. package/workflow/WorkflowExecutionTimelineEvent.d.ts.map +1 -1
  410. package/workflow/WorkflowExecutionTimelineEvent.js +2 -2
  411. package/workflow/WorkflowExecutionTimelineEvent.js.map +1 -1
  412. package/workflow/WorkflowExecutionViewer.d.ts.map +1 -1
  413. package/workflow/WorkflowExecutionViewer.js +18 -10
  414. package/workflow/WorkflowExecutionViewer.js.map +1 -1
  415. package/workflow/WorkflowFileReviewList.d.ts +46 -0
  416. package/workflow/WorkflowFileReviewList.d.ts.map +1 -0
  417. package/workflow/WorkflowFileReviewList.js +48 -0
  418. package/workflow/WorkflowFileReviewList.js.map +1 -0
  419. package/workflow/WorkflowTaskApprovalCard.d.ts +8 -1
  420. package/workflow/WorkflowTaskApprovalCard.d.ts.map +1 -1
  421. package/workflow/WorkflowTaskApprovalCard.js +12 -19
  422. package/workflow/WorkflowTaskApprovalCard.js.map +1 -1
  423. package/workflow/execution-inspector/ExecutionInspector.d.ts +21 -4
  424. package/workflow/execution-inspector/ExecutionInspector.d.ts.map +1 -1
  425. package/workflow/execution-inspector/ExecutionInspector.js +6 -3
  426. package/workflow/execution-inspector/ExecutionInspector.js.map +1 -1
  427. package/workflow/index.d.ts +1 -0
  428. package/workflow/index.d.ts.map +1 -1
  429. package/workflow/index.js +1 -0
  430. package/workflow/index.js.map +1 -1
  431. package/workflow/useWorkflowExecutionActions.d.ts +62 -4
  432. package/workflow/useWorkflowExecutionActions.d.ts.map +1 -1
  433. package/workflow/useWorkflowExecutionActions.js +94 -18
  434. package/workflow/useWorkflowExecutionActions.js.map +1 -1
  435. package/session/inspector/PlanTab.d.ts +0 -15
  436. package/session/inspector/PlanTab.d.ts.map +0 -1
  437. package/session/inspector/PlanTab.js +0 -19
  438. package/session/inspector/PlanTab.js.map +0 -1
  439. package/src/session/inspector/PlanTab.tsx +0 -31
@@ -0,0 +1,343 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { create } from "@bufbuild/protobuf";
3
+ import {
4
+ FileContentSchema,
5
+ ToolCallOutputRefSchema,
6
+ } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
7
+ import type { FileContent } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
8
+ import {
9
+ CapturedFileChangeSchema,
10
+ FileChangeSetSchema,
11
+ FileDecisionSchema,
12
+ type FileDecision,
13
+ } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
14
+ import {
15
+ DiffCompleteness,
16
+ FileChangeKind,
17
+ FileChangeSetStatus,
18
+ FileDecisionAction,
19
+ FileDecisionScope,
20
+ FileReviewBlockReason,
21
+ } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
22
+ import {
23
+ changeForRowPath,
24
+ changeSetReviewability,
25
+ deriveEffectiveVerdicts,
26
+ fileReviewability,
27
+ fileReviewRowState,
28
+ } from "../file-review-status";
29
+
30
+ /** Inline text side (the git substrate's shape). */
31
+ function inline(value: string, isBinary = false): FileContent {
32
+ return create(FileContentSchema, { body: { case: "inline", value }, isBinary });
33
+ }
34
+
35
+ /** Offloaded blob-ref side (large/CAS bodies), carrying its own is_binary. */
36
+ function ref(isBinary: boolean): FileContent {
37
+ return create(FileContentSchema, {
38
+ body: {
39
+ case: "ref",
40
+ value: create(ToolCallOutputRefSchema, {
41
+ storageKey: "artifacts/x/filereview/c.after.txt",
42
+ sizeBytes: 1_048_576n,
43
+ contentHash: "sha256:deadbeef",
44
+ }),
45
+ },
46
+ isBinary,
47
+ });
48
+ }
49
+
50
+ function change(opts: {
51
+ kind?: FileChangeKind;
52
+ diffComplete: boolean;
53
+ before?: FileContent;
54
+ after?: FileContent;
55
+ blockedReason?: FileReviewBlockReason;
56
+ }) {
57
+ const fc = create(CapturedFileChangeSchema, {
58
+ id: "cs:0:p",
59
+ pathBefore: "p",
60
+ pathAfter: "p",
61
+ kind: opts.kind ?? FileChangeKind.MODIFY,
62
+ diffComplete: opts.diffComplete,
63
+ blockedReason: opts.blockedReason ?? FileReviewBlockReason.UNSPECIFIED,
64
+ });
65
+ if (opts.before) fc.before = opts.before;
66
+ if (opts.after) fc.after = opts.after;
67
+ return fc;
68
+ }
69
+
70
+ describe("fileReviewability", () => {
71
+ it("classifies a complete text diff as reviewable", () => {
72
+ expect(
73
+ fileReviewability(
74
+ change({ diffComplete: true, before: inline("old\n"), after: inline("new\n") }),
75
+ ),
76
+ ).toEqual({ kind: "reviewable" });
77
+ });
78
+
79
+ it("stays reviewable when complete even if a side is (incongruously) flagged binary — diff_complete wins", () => {
80
+ // diff_complete is the authoritative signal; a complete change is reviewable.
81
+ expect(
82
+ fileReviewability(
83
+ change({ diffComplete: true, before: inline("a", true), after: inline("b", true) }),
84
+ ),
85
+ ).toEqual({ kind: "reviewable" });
86
+ });
87
+
88
+ it("classifies an incomplete change with a binary before side as binary", () => {
89
+ expect(
90
+ fileReviewability(
91
+ change({ diffComplete: false, before: inline("\u0000\u0001", true), after: inline("\u0000", true) }),
92
+ ),
93
+ ).toEqual({ kind: "binary" });
94
+ });
95
+
96
+ it("classifies an incomplete change with only an after binary side as binary", () => {
97
+ expect(
98
+ fileReviewability(change({ diffComplete: false, after: inline("\u0000", true) })),
99
+ ).toEqual({ kind: "binary" });
100
+ });
101
+
102
+ it("classifies a binary side that was offloaded to a ref as binary (offload preserves is_binary)", () => {
103
+ expect(
104
+ fileReviewability(change({ diffComplete: false, after: ref(true) })),
105
+ ).toEqual({ kind: "binary" });
106
+ });
107
+
108
+ it("prefers binary over a stray blocked_reason (is_binary is the authoritative binary signal)", () => {
109
+ // Defensive: even if a reason were somehow set on a binary change, the wire
110
+ // proves binary via is_binary, which the classifier resolves first.
111
+ expect(
112
+ fileReviewability(
113
+ change({
114
+ diffComplete: false,
115
+ after: inline("\u0000", true),
116
+ blockedReason: FileReviewBlockReason.SIZE_ELIDED,
117
+ }),
118
+ ),
119
+ ).toEqual({ kind: "binary" });
120
+ });
121
+
122
+ it("classifies a secret-withheld change as unavailable with reason 'secret' (doc 15)", () => {
123
+ // The secret gate authors the change content-less, diff_complete=false, and
124
+ // records SECRET_WITHHELD so the UI can say *why*.
125
+ expect(
126
+ fileReviewability(
127
+ change({ diffComplete: false, blockedReason: FileReviewBlockReason.SECRET_WITHHELD }),
128
+ ),
129
+ ).toEqual({ kind: "unavailable", reason: "secret" });
130
+ });
131
+
132
+ it("classifies a size-elided change as unavailable with reason 'size' — distinct from secret (doc 15)", () => {
133
+ // The size backstop drops the inline bodies, sets diff_complete=false, and
134
+ // records SIZE_ELIDED. Once byte-identical to the secret case; now honestly
135
+ // distinguished by the recorded reason.
136
+ expect(
137
+ fileReviewability(
138
+ change({ diffComplete: false, blockedReason: FileReviewBlockReason.SIZE_ELIDED }),
139
+ ),
140
+ ).toEqual({ kind: "unavailable", reason: "size" });
141
+ });
142
+
143
+ it("classifies a content-less change with no recorded reason as unavailable/'unknown'", () => {
144
+ // Historical rows (pre doc 15) and any future/unmapped cause fall back to the
145
+ // defensive generic bucket rather than fabricating a specific cause.
146
+ expect(fileReviewability(change({ diffComplete: false }))).toEqual({
147
+ kind: "unavailable",
148
+ reason: "unknown",
149
+ });
150
+ });
151
+
152
+ it("maps the generic UNREVIEWABLE reason to 'unknown'", () => {
153
+ expect(
154
+ fileReviewability(
155
+ change({ diffComplete: false, blockedReason: FileReviewBlockReason.UNREVIEWABLE }),
156
+ ),
157
+ ).toEqual({ kind: "unavailable", reason: "unknown" });
158
+ });
159
+
160
+ it("does not misread a one-sided binary ADD as unavailable", () => {
161
+ expect(
162
+ fileReviewability(
163
+ change({ kind: FileChangeKind.ADD, diffComplete: false, after: inline("\u0000", true) }),
164
+ ),
165
+ ).toEqual({ kind: "binary" });
166
+ });
167
+
168
+ it("does not misread a one-sided binary DELETE as unavailable", () => {
169
+ expect(
170
+ fileReviewability(
171
+ change({ kind: FileChangeKind.DELETE, diffComplete: false, before: inline("\u0000", true) }),
172
+ ),
173
+ ).toEqual({ kind: "binary" });
174
+ });
175
+ });
176
+
177
+ describe("changeSetReviewability", () => {
178
+ function set(completeness: DiffCompleteness) {
179
+ return create(FileChangeSetSchema, { id: "cs", diffCompleteness: completeness });
180
+ }
181
+
182
+ it("maps the server rollup to the set-level verdict", () => {
183
+ expect(changeSetReviewability(set(DiffCompleteness.COMPLETE))).toBe("complete");
184
+ expect(changeSetReviewability(set(DiffCompleteness.BINARY_SUMMARY_ONLY))).toBe("binary-only");
185
+ expect(changeSetReviewability(set(DiffCompleteness.PARTIAL_BLOCKED))).toBe("blocked");
186
+ });
187
+
188
+ it("treats UNSPECIFIED as blocked (fail-closed)", () => {
189
+ expect(changeSetReviewability(set(DiffCompleteness.UNSPECIFIED))).toBe("blocked");
190
+ });
191
+ });
192
+
193
+ // ---------------------------------------------------------------------------
194
+ // Effective verdicts + the stamped row's badge state
195
+ // ---------------------------------------------------------------------------
196
+
197
+ function fileChange(id: string, path: string) {
198
+ return create(CapturedFileChangeSchema, {
199
+ id,
200
+ pathBefore: path,
201
+ pathAfter: path,
202
+ kind: FileChangeKind.MODIFY,
203
+ diffComplete: true,
204
+ });
205
+ }
206
+
207
+ function decision(opts: {
208
+ scope: FileDecisionScope;
209
+ action: FileDecisionAction;
210
+ fileChangeId?: string;
211
+ }): FileDecision {
212
+ return create(FileDecisionSchema, {
213
+ changeSetId: "cs:0",
214
+ scope: opts.scope,
215
+ action: opts.action,
216
+ fileChangeId: opts.fileChangeId ?? "",
217
+ });
218
+ }
219
+
220
+ function reviewSet(opts: {
221
+ status: FileChangeSetStatus;
222
+ changes?: ReturnType<typeof fileChange>[];
223
+ decisions?: FileDecision[];
224
+ }) {
225
+ return create(FileChangeSetSchema, {
226
+ id: "cs:0",
227
+ status: opts.status,
228
+ changes: opts.changes ?? [fileChange("cs:0:a.ts", "a.ts")],
229
+ decisions: opts.decisions ?? [],
230
+ });
231
+ }
232
+
233
+ describe("deriveEffectiveVerdicts", () => {
234
+ it("applies a CHANGE_SET decision to every file (a settled 'Keep all')", () => {
235
+ const set = reviewSet({
236
+ status: FileChangeSetStatus.RECONCILED,
237
+ changes: [fileChange("f1", "a.ts"), fileChange("f2", "b.ts")],
238
+ decisions: [decision({ scope: FileDecisionScope.CHANGE_SET, action: FileDecisionAction.APPROVE })],
239
+ });
240
+ const verdicts = deriveEffectiveVerdicts(set);
241
+ expect(verdicts.get("f1")).toBe(FileDecisionAction.APPROVE);
242
+ expect(verdicts.get("f2")).toBe(FileDecisionAction.APPROVE);
243
+ });
244
+
245
+ it("lets a FILE decision override the CHANGE_SET baseline (most-specific-wins)", () => {
246
+ const set = reviewSet({
247
+ status: FileChangeSetStatus.RECONCILED,
248
+ changes: [fileChange("f1", "a.ts"), fileChange("f2", "b.ts")],
249
+ decisions: [
250
+ decision({ scope: FileDecisionScope.FILE, action: FileDecisionAction.REJECT, fileChangeId: "f2" }),
251
+ decision({ scope: FileDecisionScope.CHANGE_SET, action: FileDecisionAction.APPROVE }),
252
+ ],
253
+ });
254
+ const verdicts = deriveEffectiveVerdicts(set);
255
+ expect(verdicts.get("f1")).toBe(FileDecisionAction.APPROVE);
256
+ // FILE beats CHANGE_SET regardless of ledger order.
257
+ expect(verdicts.get("f2")).toBe(FileDecisionAction.REJECT);
258
+ });
259
+
260
+ it("leaves an undecided file absent (a set terminated mid-review)", () => {
261
+ const set = reviewSet({
262
+ status: FileChangeSetStatus.DECIDED,
263
+ changes: [fileChange("f1", "a.ts"), fileChange("f2", "b.ts")],
264
+ decisions: [decision({ scope: FileDecisionScope.FILE, action: FileDecisionAction.APPROVE, fileChangeId: "f1" })],
265
+ });
266
+ const verdicts = deriveEffectiveVerdicts(set);
267
+ expect(verdicts.get("f1")).toBe(FileDecisionAction.APPROVE);
268
+ expect(verdicts.has("f2")).toBe(false);
269
+ });
270
+ });
271
+
272
+ describe("changeForRowPath", () => {
273
+ const set = reviewSet({
274
+ status: FileChangeSetStatus.AWAITING_REVIEW,
275
+ changes: [fileChange("f1", "src/a.ts")],
276
+ });
277
+
278
+ it("matches an exact workspace-relative path", () => {
279
+ expect(changeForRowPath(set, "src/a.ts")?.id).toBe("f1");
280
+ });
281
+
282
+ it("matches an absolute row path by /-boundary suffix", () => {
283
+ expect(changeForRowPath(set, "/home/user/ws/src/a.ts")?.id).toBe("f1");
284
+ // A partial-segment overlap is NOT a match.
285
+ expect(changeForRowPath(set, "othersrc/a.ts")).toBeNull();
286
+ });
287
+
288
+ it("returns null for an unknown or empty path", () => {
289
+ expect(changeForRowPath(set, "src/b.ts")).toBeNull();
290
+ expect(changeForRowPath(set, "")).toBeNull();
291
+ });
292
+ });
293
+
294
+ describe("fileReviewRowState", () => {
295
+ it("returns null with no set (not yet projected / unknown id)", () => {
296
+ expect(fileReviewRowState(undefined, "a.ts")).toBeNull();
297
+ });
298
+
299
+ it("reads AWAITING_REVIEW as pending regardless of path", () => {
300
+ const set = reviewSet({ status: FileChangeSetStatus.AWAITING_REVIEW });
301
+ expect(fileReviewRowState(set, "a.ts")).toBe("pending");
302
+ expect(fileReviewRowState(set, null)).toBe("pending");
303
+ });
304
+
305
+ it("reads FAILED as failed", () => {
306
+ expect(
307
+ fileReviewRowState(reviewSet({ status: FileChangeSetStatus.FAILED }), "a.ts"),
308
+ ).toBe("failed");
309
+ });
310
+
311
+ it("resolves a decided file's verdict by row path (kept / discarded)", () => {
312
+ const set = reviewSet({
313
+ status: FileChangeSetStatus.RECONCILED,
314
+ changes: [fileChange("f1", "a.ts"), fileChange("f2", "b.ts")],
315
+ decisions: [
316
+ decision({ scope: FileDecisionScope.FILE, action: FileDecisionAction.APPROVE, fileChangeId: "f1" }),
317
+ decision({ scope: FileDecisionScope.FILE, action: FileDecisionAction.REJECT, fileChangeId: "f2" }),
318
+ ],
319
+ });
320
+ expect(fileReviewRowState(set, "a.ts")).toBe("kept");
321
+ expect(fileReviewRowState(set, "/abs/ws/b.ts")).toBe("discarded");
322
+ });
323
+
324
+ it("degrades to null — never a wrong badge — for a file absent from the set or with no verdict", () => {
325
+ const set = reviewSet({
326
+ status: FileChangeSetStatus.DECIDED,
327
+ changes: [fileChange("f1", "a.ts")],
328
+ decisions: [],
329
+ });
330
+ // Superseded/reverted within the turn: the row's file is not in the set.
331
+ expect(fileReviewRowState(set, "gone.ts")).toBeNull();
332
+ // In the set but never decided (terminated mid-review).
333
+ expect(fileReviewRowState(set, "a.ts")).toBeNull();
334
+ // No usable path on the row.
335
+ expect(fileReviewRowState(set, null)).toBeNull();
336
+ });
337
+
338
+ it("returns null for a CAPTURING set (no reviewable state yet)", () => {
339
+ expect(
340
+ fileReviewRowState(reviewSet({ status: FileChangeSetStatus.CAPTURING }), "a.ts"),
341
+ ).toBeNull();
342
+ });
343
+ });
@@ -153,6 +153,22 @@ describe("MessageEntry — AI messages (Streamdown)", () => {
153
153
  const article = queryArticle(container, "AI response");
154
154
  expect(article!.querySelector("pre")).not.toBeNull();
155
155
  });
156
+
157
+ it("syntax-highlights fenced code in the chat stream (Streamdown path)", () => {
158
+ const msg = makeMessage(
159
+ MessageType.MESSAGE_AI,
160
+ "```go\nfunc main() {}\n```",
161
+ );
162
+ const { container } = render(<MessageEntry message={msg} />);
163
+
164
+ const article = queryArticle(container, "AI response");
165
+ // Streamdown routes fenced code through the shared MARKDOWN_COMPONENTS.code
166
+ // override, so chat highlights identically to the artifact viewer.
167
+ expect(article!.querySelector("code.hljs")).not.toBeNull();
168
+ expect(
169
+ article!.querySelectorAll('span[class*="hljs-"]').length,
170
+ ).toBeGreaterThan(0);
171
+ });
156
172
  });
157
173
 
158
174
  // ---------------------------------------------------------------------------
@@ -0,0 +1,124 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { create, type JsonObject } from "@bufbuild/protobuf";
3
+ import {
4
+ ToolCallSchema,
5
+ type ToolCall,
6
+ } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
7
+ import { segmentToolCalls } from "../segment-tool-calls";
8
+ import { registerToolPresenter } from "../tool-presenter";
9
+ import { ToolKind } from "@stigmer/sdk";
10
+
11
+ function tc(name: string, id: string, args?: Record<string, unknown>): ToolCall {
12
+ return create(ToolCallSchema, {
13
+ id,
14
+ name,
15
+ args: (args ?? { path: `/x/${id}`, pattern: "p", command: "ls" }) as JsonObject,
16
+ });
17
+ }
18
+
19
+ describe("segmentToolCalls", () => {
20
+ it("folds a run of >= 2 consecutive same-category groupable calls", () => {
21
+ const calls = [tc("Read", "r1"), tc("Read", "r2"), tc("Read", "r3")];
22
+ const segments = segmentToolCalls(calls);
23
+
24
+ expect(segments).toHaveLength(1);
25
+ const [seg] = segments;
26
+ expect(seg.kind).toBe("run");
27
+ if (seg.kind === "run") {
28
+ expect(seg.category).toBe("read");
29
+ expect(seg.toolCalls).toHaveLength(3);
30
+ // Slice preserves the original references (structural-sharing friendly).
31
+ expect(seg.toolCalls[0]).toBe(calls[0]);
32
+ }
33
+ });
34
+
35
+ it("leaves a lone groupable call as a row (no one-item chip)", () => {
36
+ const calls = [tc("Read", "r1")];
37
+ const segments = segmentToolCalls(calls);
38
+
39
+ expect(segments).toHaveLength(1);
40
+ expect(segments[0].kind).toBe("row");
41
+ });
42
+
43
+ it("never folds high-signal categories (shell, edit)", () => {
44
+ const calls = [
45
+ tc("Shell", "s1", { command: "echo a" }),
46
+ tc("Shell", "s2", { command: "echo b" }),
47
+ tc("StrReplace", "e1", { path: "/a.ts", old_string: "a", new_string: "b" }),
48
+ ];
49
+ const segments = segmentToolCalls(calls);
50
+
51
+ expect(segments).toHaveLength(3);
52
+ expect(segments.every((s) => s.kind === "row")).toBe(true);
53
+ });
54
+
55
+ it("preserves chronology — interleaved categories stay separate rows", () => {
56
+ // read, search, read: three runs of length 1, so three rows in order.
57
+ const calls = [tc("Read", "r1"), tc("Grep", "g1"), tc("Read", "r2")];
58
+ const segments = segmentToolCalls(calls);
59
+
60
+ expect(segments.map((s) => s.kind)).toEqual(["row", "row", "row"]);
61
+ });
62
+
63
+ it("splits adjacent runs of different groupable categories", () => {
64
+ // read, read, search, search -> two chips, in order.
65
+ const calls = [
66
+ tc("Read", "r1"),
67
+ tc("Read", "r2"),
68
+ tc("Grep", "g1"),
69
+ tc("Grep", "g2"),
70
+ ];
71
+ const segments = segmentToolCalls(calls);
72
+
73
+ expect(segments).toHaveLength(2);
74
+ expect(segments[0].kind).toBe("run");
75
+ expect(segments[1].kind).toBe("run");
76
+ if (segments[0].kind === "run") expect(segments[0].category).toBe("read");
77
+ if (segments[1].kind === "run") expect(segments[1].category).toBe("search");
78
+ });
79
+
80
+ it("folds a run that is bounded by high-signal rows on both sides", () => {
81
+ const calls = [
82
+ tc("Shell", "s1", { command: "echo a" }),
83
+ tc("Read", "r1"),
84
+ tc("Read", "r2"),
85
+ tc("Shell", "s2", { command: "echo b" }),
86
+ ];
87
+ const segments = segmentToolCalls(calls);
88
+
89
+ expect(segments.map((s) => s.kind)).toEqual(["row", "run", "row"]);
90
+ });
91
+
92
+ it("emits stable, distinct keys per segment", () => {
93
+ const calls = [tc("Read", "r1"), tc("Read", "r2"), tc("Shell", "s1")];
94
+ const segments = segmentToolCalls(calls);
95
+ const keys = segments.map((s) => s.key);
96
+
97
+ expect(new Set(keys).size).toBe(keys.length);
98
+ // Run key is derived from its category + first call id; stable across runs.
99
+ expect(segmentToolCalls(calls).map((s) => s.key)).toEqual(keys);
100
+ });
101
+
102
+ it("returns an empty list for no tool calls", () => {
103
+ expect(segmentToolCalls([])).toEqual([]);
104
+ });
105
+
106
+ it("honours a registry runGroupable override", () => {
107
+ // Force shell to fold; two adjacent shells then become one run chip.
108
+ const dispose = registerToolPresenter(ToolKind.SHELL, {
109
+ runGroupable: () => true,
110
+ });
111
+ try {
112
+ const calls = [
113
+ tc("Shell", "s1", { command: "echo a" }),
114
+ tc("Shell", "s2", { command: "echo b" }),
115
+ ];
116
+ const segments = segmentToolCalls(calls);
117
+ expect(segments).toHaveLength(1);
118
+ expect(segments[0].kind).toBe("run");
119
+ if (segments[0].kind === "run") expect(segments[0].category).toBe("shell");
120
+ } finally {
121
+ dispose();
122
+ }
123
+ });
124
+ });