@cueloop/client 0.1.0-alpha.11 → 0.1.0-alpha.110

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 (360) hide show
  1. package/native/build-pty.sh +51 -0
  2. package/native/build.sh +82 -0
  3. package/native/darwin-arm64/libcuelooppty.dylib +0 -0
  4. package/native/darwin-arm64/libcueloopvt.dylib +0 -0
  5. package/native/src/pty.zig +193 -0
  6. package/native/src/shim.zig +114 -0
  7. package/package.json +42 -34
  8. package/src/annotations/annotation-palette.ts +63 -0
  9. package/src/annotations/components/AnnotationCards.stories.tsx +86 -0
  10. package/src/annotations/components/AnnotationCards.test.tsx +42 -0
  11. package/src/annotations/components/AnnotationCards.tsx +383 -0
  12. package/src/annotations/components/DiscussionMarkerRail.stories.tsx +54 -0
  13. package/src/annotations/components/DiscussionMarkerRail.tsx +189 -0
  14. package/src/annotations/discussions.ts +78 -0
  15. package/src/annotations/thread-selection.test.ts +210 -0
  16. package/src/annotations/thread-selection.ts +248 -0
  17. package/src/annotations/use-annotation-surface.tsx +1378 -0
  18. package/src/app/App.appearance.test.tsx +53 -0
  19. package/src/{App.autoclose.test.tsx → app/App.autoclose.test.tsx} +77 -51
  20. package/src/app/App.deleted-scroll.test.tsx +190 -0
  21. package/src/app/App.diff.test.tsx +313 -0
  22. package/src/app/App.export.test.tsx +105 -0
  23. package/src/app/App.focus.test.ts +89 -0
  24. package/src/app/App.harness-settings.test.tsx +77 -0
  25. package/src/app/App.identity.test.tsx +84 -0
  26. package/src/app/App.plan-render.test.tsx +211 -0
  27. package/src/app/App.plan-review.test.tsx +429 -0
  28. package/src/app/App.prototype-markdown.test.tsx +129 -0
  29. package/src/app/App.prototype.test.tsx +176 -0
  30. package/src/app/App.readonly.test.tsx +274 -0
  31. package/src/app/App.regression.test.tsx +99 -0
  32. package/src/app/App.rendering.test.tsx +134 -0
  33. package/src/app/App.share-dialog.test.tsx +177 -0
  34. package/src/app/App.submit-confirm.test.tsx +267 -0
  35. package/src/app/App.test.tsx +497 -0
  36. package/src/app/App.thread-agent.test.ts +20 -0
  37. package/src/app/App.toast.test.tsx +124 -0
  38. package/src/app/App.tsx +1758 -0
  39. package/src/app/App.visual.test.tsx +60 -0
  40. package/src/app/App.walk.test.tsx +300 -0
  41. package/src/app/App.workbench.test.tsx +1152 -0
  42. package/src/app/app-key-state.ts +61 -0
  43. package/src/app/app-screens.tsx +607 -0
  44. package/src/app/app-view-model.ts +178 -0
  45. package/src/app/components/AppHeader.stories.tsx +50 -0
  46. package/src/app/components/AppHeader.tsx +81 -0
  47. package/src/app/components/AppShell.brand.test.tsx +58 -0
  48. package/src/app/components/AppShell.extensions.test.tsx +191 -0
  49. package/src/app/components/AppShell.stories.tsx +89 -0
  50. package/src/app/components/AppShell.tsx +358 -0
  51. package/src/app/components/AppShell.zoom.test.tsx +149 -0
  52. package/src/app/components/Breadcrumb.stories.tsx +19 -0
  53. package/src/app/components/Breadcrumb.tsx +45 -0
  54. package/src/app/components/MenuBar.stories.tsx +28 -0
  55. package/src/app/components/MenuBar.tsx +44 -0
  56. package/src/app/components/PaneGrid.stories.tsx +84 -0
  57. package/src/app/components/PaneGrid.tsx +128 -0
  58. package/src/app/components/PanelColumn.stories.tsx +25 -0
  59. package/src/app/components/PanelColumn.tsx +93 -0
  60. package/src/app/components/ShellHeader.stories.tsx +50 -0
  61. package/src/app/components/ShellHeader.tsx +137 -0
  62. package/src/app/components/WorkspacePanels.stories.tsx +36 -0
  63. package/src/app/components/WorkspacePanels.tsx +121 -0
  64. package/src/app/components/pages/Workspace.stories.tsx +181 -0
  65. package/src/app/intent-dispatch.test.ts +729 -0
  66. package/src/app/intent-dispatch.ts +713 -0
  67. package/src/app/launch-layout.test.ts +78 -0
  68. package/src/app/launch-layout.ts +57 -0
  69. package/src/app/ready-signal.test.ts +85 -0
  70. package/src/app/ready-signal.ts +54 -0
  71. package/src/app/run.ts +111 -0
  72. package/src/{serve.test.ts → app/serve.test.ts} +28 -12
  73. package/src/app/serve.ts +111 -0
  74. package/src/app/version.ts +5 -0
  75. package/src/appearance/components/theme-context.stories.tsx +46 -0
  76. package/src/appearance/components/theme-context.tsx +37 -0
  77. package/src/appearance/theme-presets.test.ts +51 -0
  78. package/src/appearance/theme-presets.ts +219 -0
  79. package/src/appearance/theme.ts +112 -0
  80. package/src/appearance/visual/contrast.test.ts +35 -0
  81. package/src/appearance/visual/contrast.ts +33 -0
  82. package/src/diff/components/AnnotatableFileView.stories.tsx +42 -0
  83. package/src/diff/components/AnnotatableFileView.test.tsx +160 -0
  84. package/src/diff/components/AnnotatableFileView.tsx +142 -0
  85. package/src/diff/components/BareWorkbenchFileView.stories.tsx +27 -0
  86. package/src/diff/components/BareWorkbenchFileView.tsx +63 -0
  87. package/src/diff/components/DiffContentView.scroll.test.tsx +443 -0
  88. package/src/diff/components/DiffContentView.split.test.tsx +140 -0
  89. package/src/diff/components/DiffContentView.stories.tsx +80 -0
  90. package/src/diff/components/DiffContentView.syntax.test.tsx +85 -0
  91. package/src/diff/components/DiffContentView.tsx +1080 -0
  92. package/src/diff/components/WalkWizard.stories.tsx +100 -0
  93. package/src/diff/components/WalkWizard.tsx +146 -0
  94. package/src/diff/components/diff-content-view-layout.test.ts +198 -0
  95. package/src/diff/components/diff-content-view-layout.ts +87 -0
  96. package/src/diff/diff-fold.test.ts +78 -0
  97. package/src/diff/diff-fold.ts +130 -0
  98. package/src/diff/diff-hunk-curate.test.ts +315 -0
  99. package/src/diff/diff-hunk-curate.ts +155 -0
  100. package/src/diff/diff-intraline.test.ts +239 -0
  101. package/src/diff/diff-intraline.ts +244 -0
  102. package/src/diff/diff-syntax.test.ts +125 -0
  103. package/src/diff/diff-syntax.ts +194 -0
  104. package/src/diff/split-diff.test.ts +110 -0
  105. package/src/diff/split-diff.ts +150 -0
  106. package/src/diff/view-diff.test.ts +325 -0
  107. package/src/diff/view-diff.ts +540 -0
  108. package/src/diff/walk.test.ts +121 -0
  109. package/src/diff/walk.ts +76 -0
  110. package/src/index.ts +32 -2
  111. package/src/integrations/attribution.test.ts +31 -0
  112. package/src/integrations/attribution.ts +44 -0
  113. package/src/integrations/client-extension-registry.test.tsx +61 -0
  114. package/src/integrations/client-extension-registry.ts +163 -0
  115. package/src/integrations/clipboard.test.ts +23 -0
  116. package/src/integrations/clipboard.ts +34 -0
  117. package/src/integrations/components/ExtensionZone.stories.tsx +28 -0
  118. package/src/integrations/components/ExtensionZone.tsx +145 -0
  119. package/src/integrations/components/ShareDialog.agent.test.tsx +52 -0
  120. package/src/integrations/components/ShareDialog.stories.tsx +121 -0
  121. package/src/integrations/components/ShareDialog.tsx +602 -0
  122. package/src/integrations/components/share-dialog-store.ts +59 -0
  123. package/src/integrations/editor.test.ts +149 -0
  124. package/src/integrations/editor.ts +163 -0
  125. package/src/integrations/github-identity.test.ts +59 -0
  126. package/src/integrations/github-identity.ts +42 -0
  127. package/src/integrations/herdr.test.ts +43 -0
  128. package/src/integrations/herdr.ts +40 -0
  129. package/src/integrations/integrations.test.ts +41 -0
  130. package/src/integrations/integrations.ts +32 -0
  131. package/src/integrations/pasted-image.test.ts +67 -0
  132. package/src/integrations/pasted-image.ts +62 -0
  133. package/src/integrations/share.ts +283 -0
  134. package/src/keyboard/components/CompletionOverlay.stories.tsx +37 -0
  135. package/src/keyboard/components/CompletionOverlay.tsx +75 -0
  136. package/src/keyboard/components/HandleChipsInput.stories.tsx +24 -0
  137. package/src/keyboard/components/HandleChipsInput.test.tsx +35 -0
  138. package/src/keyboard/components/HandleChipsInput.tsx +147 -0
  139. package/src/keyboard/components/KeybindsDialog.stories.tsx +31 -0
  140. package/src/keyboard/components/KeybindsDialog.tsx +103 -0
  141. package/src/keyboard/components/NavModeHint.stories.tsx +40 -0
  142. package/src/keyboard/components/NavModeHint.tsx +31 -0
  143. package/src/keyboard/components/SlashComposer.stories.tsx +37 -0
  144. package/src/keyboard/components/SlashComposer.tsx +90 -0
  145. package/src/keyboard/key-bindings.test.ts +156 -0
  146. package/src/keyboard/key-bindings.ts +462 -0
  147. package/src/keyboard/keymap.test.ts +611 -0
  148. package/src/keyboard/keymap.ts +446 -0
  149. package/src/keyboard/skills.test.ts +74 -0
  150. package/src/keyboard/skills.ts +77 -0
  151. package/src/keyboard/slash-palette.test.ts +103 -0
  152. package/src/keyboard/slash-palette.ts +137 -0
  153. package/src/keyboard/thread-chords.test.ts +79 -0
  154. package/src/keyboard/thread-chords.ts +168 -0
  155. package/src/keyboard/use-shared-keyboard.ts +56 -0
  156. package/src/markdown/__snapshots__/view-plan.regression.test.ts.snap +100 -0
  157. package/src/markdown/components/MarkdownGridBlock.stories.tsx +33 -0
  158. package/src/markdown/components/MarkdownGridBlock.tsx +72 -0
  159. package/src/markdown/components/MarkdownThreadEditor.stories.tsx +15 -0
  160. package/src/markdown/components/MarkdownThreadEditor.test.tsx +98 -0
  161. package/src/markdown/components/MarkdownThreadEditor.tsx +165 -0
  162. package/src/markdown/components/ThreadView.selection.test.tsx +954 -0
  163. package/src/markdown/components/ThreadView.slash.test.tsx +146 -0
  164. package/src/markdown/components/ThreadView.stories.tsx +26 -0
  165. package/src/markdown/components/ThreadView.tsx +577 -0
  166. package/src/markdown/mark-runs.ts +125 -0
  167. package/src/markdown/markdown-editor-syntax-style.ts +66 -0
  168. package/src/markdown/markdown-grid.test.ts +101 -0
  169. package/src/markdown/markdown-grid.ts +209 -0
  170. package/src/markdown/markdown-highlight.test.ts +61 -0
  171. package/src/markdown/markdown-highlight.ts +125 -0
  172. package/src/markdown/thread-code-syntax.ts +48 -0
  173. package/src/markdown/use-thread-body-editing.tsx +54 -0
  174. package/src/markdown/view-plan.regression.test.ts +60 -0
  175. package/src/markdown/view-plan.test.ts +545 -0
  176. package/src/markdown/view-plan.ts +1061 -0
  177. package/src/performance/otlp-trace.test.ts +119 -0
  178. package/src/performance/otlp-trace.ts +134 -0
  179. package/src/performance/perf-report.ts +19 -0
  180. package/src/performance/perf-timings.test.ts +18 -0
  181. package/src/performance/perf-timings.ts +40 -0
  182. package/src/prototype/components/PrototypeContentView.stories.tsx +19 -0
  183. package/src/prototype/components/PrototypeContentView.tsx +459 -0
  184. package/src/prototype/prototype-browser.test.ts +81 -0
  185. package/src/prototype/prototype-browser.ts +332 -0
  186. package/src/prototype/prototype-pixels.tsx +35 -0
  187. package/src/settings/components/SettingsDialog.stories.tsx +117 -0
  188. package/src/settings/components/SettingsDialog.tsx +186 -0
  189. package/src/settings/components/SettingsRows.stories.tsx +18 -0
  190. package/src/settings/components/SettingsRows.tsx +112 -0
  191. package/src/settings/components/quick-actions-editor.stories.tsx +58 -0
  192. package/src/settings/components/quick-actions-editor.test.tsx +120 -0
  193. package/src/settings/components/quick-actions-editor.tsx +222 -0
  194. package/src/settings/config-identity.test.ts +78 -0
  195. package/src/settings/config.test.ts +754 -0
  196. package/src/settings/config.ts +718 -0
  197. package/src/settings/use-settings-dialog.test.tsx +172 -0
  198. package/src/settings/use-settings-dialog.tsx +465 -0
  199. package/src/settings/use-thread-harness-setting.test.tsx +87 -0
  200. package/src/settings/use-thread-harness-setting.ts +86 -0
  201. package/src/stories/__snapshots__/stories.test.tsx.snap +2358 -0
  202. package/src/stories/stories-app.tsx +196 -0
  203. package/src/stories/stories.test.tsx +78 -0
  204. package/src/stories/story-fixtures.ts +102 -0
  205. package/src/stories/story-tree.test.ts +108 -0
  206. package/src/stories/story.ts +160 -0
  207. package/src/terminal/ansi-screen.test.ts +28 -0
  208. package/src/terminal/ansi-screen.ts +77 -0
  209. package/src/terminal/components/AnsiScreen.stories.tsx +12 -0
  210. package/src/terminal/components/AnsiScreen.tsx +28 -0
  211. package/src/terminal/components/terminal-pane.test.tsx +40 -0
  212. package/src/terminal/components/terminal-pane.ts +208 -0
  213. package/src/terminal/ghostty-terminal.test.ts +85 -0
  214. package/src/terminal/ghostty-terminal.ts +207 -0
  215. package/src/terminal/kitty-image.test.ts +66 -0
  216. package/src/terminal/kitty-image.ts +140 -0
  217. package/src/terminal/pty.test.ts +81 -0
  218. package/src/terminal/pty.ts +255 -0
  219. package/src/testing/test-support.test.ts +266 -0
  220. package/src/testing/test-support.ts +424 -0
  221. package/src/thread/agent-continuation.test.ts +34 -0
  222. package/src/thread/agent-continuation.ts +13 -0
  223. package/src/thread/agent-transcript.test.ts +161 -0
  224. package/src/thread/agent-transcript.ts +344 -0
  225. package/src/thread/components/AgentConfigControls.stories.tsx +39 -0
  226. package/src/thread/components/AgentConfigControls.test.tsx +153 -0
  227. package/src/thread/components/AgentConfigControls.tsx +121 -0
  228. package/src/thread/components/AgentThreadPane.stories.tsx +105 -0
  229. package/src/thread/components/AgentThreadPane.test.tsx +1248 -0
  230. package/src/thread/components/AgentThreadPane.tsx +458 -0
  231. package/src/thread/components/ThreadFooter.stories.tsx +30 -0
  232. package/src/thread/components/ThreadFooter.test.tsx +49 -0
  233. package/src/thread/components/ThreadFooter.tsx +77 -0
  234. package/src/thread/components/ThreadTree.stories.tsx +46 -0
  235. package/src/thread/components/ThreadTree.test.tsx +41 -0
  236. package/src/thread/components/ThreadTree.tsx +268 -0
  237. package/src/thread/components/thread-tree.test.ts +138 -0
  238. package/src/thread/components/thread-tree.ts +112 -0
  239. package/src/thread/thread-controller.curate.test.ts +504 -0
  240. package/src/thread/thread-controller.derivation.test.ts +62 -0
  241. package/src/thread/thread-controller.live-diff.test.ts +357 -0
  242. package/src/thread/thread-controller.optimistic.test.ts +69 -0
  243. package/src/thread/thread-controller.share.test.ts +618 -0
  244. package/src/thread/thread-controller.switch-cache.test.ts +174 -0
  245. package/src/thread/thread-controller.tree.test.ts +263 -0
  246. package/src/thread/thread-controller.ts +2151 -0
  247. package/src/thread/tree-view.test.ts +128 -0
  248. package/src/thread/tree-view.ts +150 -0
  249. package/src/thread/use-thread-agent.test.tsx +209 -0
  250. package/src/thread/use-thread-agent.ts +122 -0
  251. package/src/ui/components/CodeBlock.stories.tsx +42 -0
  252. package/src/ui/components/CodeBlock.tsx +82 -0
  253. package/src/ui/components/ConfirmCard.stories.tsx +37 -0
  254. package/src/ui/components/ConfirmCard.tsx +151 -0
  255. package/src/ui/components/ConfirmDialog.stories.tsx +21 -0
  256. package/src/ui/components/ConfirmDialog.tsx +72 -0
  257. package/src/ui/components/OverlayScrollbar.stories.tsx +33 -0
  258. package/src/ui/components/OverlayScrollbar.test.tsx +142 -0
  259. package/src/ui/components/OverlayScrollbar.tsx +134 -0
  260. package/src/ui/components/PromptDialog.stories.tsx +36 -0
  261. package/src/ui/components/PromptDialog.test.tsx +65 -0
  262. package/src/ui/components/PromptDialog.tsx +101 -0
  263. package/src/ui/components/RootOverlay.stories.tsx +45 -0
  264. package/src/ui/components/RootOverlay.tsx +50 -0
  265. package/src/ui/components/ScrollArea.stories.tsx +20 -0
  266. package/src/ui/components/ScrollArea.tsx +63 -0
  267. package/src/ui/components/Toast.stories.tsx +19 -0
  268. package/src/ui/components/Toast.tsx +54 -0
  269. package/src/ui/components/Tooltip.stories.tsx +26 -0
  270. package/src/ui/components/Tooltip.tsx +93 -0
  271. package/src/ui/components/menu-control.stories.tsx +35 -0
  272. package/src/ui/components/menu-control.tsx +43 -0
  273. package/src/ui/components/primitives/Button.stories.tsx +32 -0
  274. package/src/ui/components/primitives/Button.tsx +58 -0
  275. package/src/ui/components/primitives/Card.stories.tsx +25 -0
  276. package/src/ui/components/primitives/Card.tsx +62 -0
  277. package/src/ui/components/primitives/Dialog.stories.tsx +24 -0
  278. package/src/ui/components/primitives/Dialog.test.tsx +38 -0
  279. package/src/ui/components/primitives/Dialog.tsx +69 -0
  280. package/src/ui/components/primitives/DialogActions.stories.tsx +20 -0
  281. package/src/ui/components/primitives/DialogActions.tsx +39 -0
  282. package/src/ui/components/primitives/IconButton.stories.tsx +36 -0
  283. package/src/ui/components/primitives/IconButton.tsx +58 -0
  284. package/src/ui/components/primitives/StatusBar.stories.tsx +11 -0
  285. package/src/ui/components/primitives/StatusBar.tsx +23 -0
  286. package/src/ui/components/primitives/Switch.stories.tsx +17 -0
  287. package/src/ui/components/primitives/Switch.tsx +32 -0
  288. package/src/ui/components/primitives/Tabs.stories.tsx +29 -0
  289. package/src/ui/components/primitives/Tabs.tsx +102 -0
  290. package/src/ui/components/primitives/Toolbar.stories.tsx +17 -0
  291. package/src/ui/components/primitives/Toolbar.tsx +14 -0
  292. package/src/ui/components/primitives/Tree.stories.tsx +124 -0
  293. package/src/ui/components/primitives/Tree.tsx +137 -0
  294. package/src/ui/components/primitives/frame.test.ts +12 -0
  295. package/src/ui/components/primitives/frame.ts +17 -0
  296. package/src/ui/components/primitives/icons.ts +61 -0
  297. package/src/ui/components/primitives/tree-model.test.ts +99 -0
  298. package/src/ui/components/primitives/tree-model.ts +144 -0
  299. package/src/ui/components/syntax-highlight.ts +154 -0
  300. package/src/ui/components/truncate-text.ts +7 -0
  301. package/src/ui/components/truncate-title.test.ts +31 -0
  302. package/src/ui/components/truncate-title.ts +16 -0
  303. package/src/ui/use-frame-measure.ts +88 -0
  304. package/src/ui/use-terminal-virtualizer.ts +286 -0
  305. package/src/workbench/components/ChangesColumn.stories.tsx +44 -0
  306. package/src/workbench/components/ChangesColumn.tsx +210 -0
  307. package/src/workbench/components/ChangesFileTree.test.tsx +184 -0
  308. package/src/workbench/components/EditorGrid.split.test.tsx +119 -0
  309. package/src/workbench/components/EditorGrid.stories.tsx +86 -0
  310. package/src/workbench/components/EditorGrid.tabs.test.tsx +118 -0
  311. package/src/workbench/components/EditorGrid.tsx +552 -0
  312. package/src/workbench/components/EditorGrid.zoom.test.tsx +132 -0
  313. package/src/workbench/components/FileContentsView.stories.tsx +16 -0
  314. package/src/workbench/components/FileContentsView.test.tsx +29 -0
  315. package/src/workbench/components/FileContentsView.tsx +104 -0
  316. package/src/workbench/components/GridTabContent.actions.test.tsx +151 -0
  317. package/src/workbench/components/GridTabContent.stories.tsx +59 -0
  318. package/src/workbench/components/GridTabContent.tsx +195 -0
  319. package/src/workbench/components/ProjectTreeView.stories.tsx +25 -0
  320. package/src/workbench/components/ProjectTreeView.test.tsx +239 -0
  321. package/src/workbench/components/ProjectTreeView.tsx +159 -0
  322. package/src/workbench/components/TreePane.stories.tsx +106 -0
  323. package/src/workbench/components/TreePane.tsx +157 -0
  324. package/src/workbench/components/WelcomePlayground.stories.tsx +12 -0
  325. package/src/workbench/components/WelcomePlayground.test.tsx +83 -0
  326. package/src/workbench/components/WelcomePlayground.tsx +138 -0
  327. package/src/workbench/components/editor-grid.test.ts +184 -0
  328. package/src/workbench/components/editor-grid.ts +284 -0
  329. package/src/workbench/components/file-tree.test.ts +60 -0
  330. package/src/workbench/components/file-tree.ts +114 -0
  331. package/src/workbench/use-changes-workbench.ts +210 -0
  332. package/src/workbench/use-remember-layout.ts +33 -0
  333. package/src/workbench/use-repo-changes.ts +93 -0
  334. package/src/workbench/workbench-snapshot.test.ts +99 -0
  335. package/src/workbench/workbench-snapshot.ts +59 -0
  336. package/src/App.diff.test.tsx +0 -99
  337. package/src/App.export.test.tsx +0 -88
  338. package/src/App.plan-review.test.tsx +0 -259
  339. package/src/App.readonly.test.tsx +0 -148
  340. package/src/App.rendering.test.tsx +0 -108
  341. package/src/App.submit-confirm.test.tsx +0 -183
  342. package/src/App.test.tsx +0 -218
  343. package/src/App.tsx +0 -1249
  344. package/src/config.test.ts +0 -116
  345. package/src/config.ts +0 -150
  346. package/src/editor.ts +0 -34
  347. package/src/herdr.test.ts +0 -68
  348. package/src/herdr.ts +0 -34
  349. package/src/keymap.test.ts +0 -270
  350. package/src/keymap.ts +0 -173
  351. package/src/run.ts +0 -30
  352. package/src/serve.ts +0 -75
  353. package/src/session-controller.ts +0 -398
  354. package/src/syntax.test.ts +0 -41
  355. package/src/syntax.ts +0 -88
  356. package/src/theme.ts +0 -46
  357. package/src/view-diff.test.ts +0 -55
  358. package/src/view-diff.ts +0 -86
  359. package/src/view.test.ts +0 -157
  360. package/src/view.ts +0 -364
@@ -0,0 +1,34 @@
1
+ import { expect, test } from "bun:test";
2
+ import { agentContinuation, type AgentContinuation } from "./agent-continuation";
3
+ import type { ThreadAgentState } from "@cueloop/schema";
4
+
5
+ const state: ThreadAgentState = {
6
+ threadId: "thread",
7
+ phase: { kind: "idle" },
8
+ messages: [],
9
+ comments: [],
10
+ tools: [],
11
+ };
12
+
13
+ test("only a completed reply in an idle conversation offers continuation", () => {
14
+ expect(agentContinuation(state)).toEqual({ kind: "waiting" });
15
+ const message = {
16
+ id: "answer",
17
+ role: "agent" as const,
18
+ text: "Done",
19
+ complete: true,
20
+ revision: 1,
21
+ };
22
+ const completed: AgentContinuation = agentContinuation({ ...state, messages: [message] });
23
+
24
+ expect(completed.kind).toBe("ready");
25
+
26
+ if (completed.kind === "ready") expect(completed.replyId).toBe("answer");
27
+
28
+ expect(agentContinuation({ ...state, phase: { kind: "running" }, messages: [message] })).toEqual({
29
+ kind: "waiting",
30
+ });
31
+ expect(agentContinuation({ ...state, messages: [{ ...message, complete: false }] })).toEqual({
32
+ kind: "waiting",
33
+ });
34
+ });
@@ -0,0 +1,13 @@
1
+ import type { ThreadAgentState } from "@cueloop/schema";
2
+
3
+ /** Chat continuation names a completed reply only when the harness has returned to idle. */
4
+ export type AgentContinuation = { kind: "waiting" } | { kind: "ready"; replyId: string };
5
+
6
+ /** Streaming replies cannot request the next prompt's focus. */
7
+ export function agentContinuation(state: ThreadAgentState): AgentContinuation {
8
+ const reply = state.messages.findLast((message) => message.role === "agent");
9
+
10
+ if (state.phase.kind !== "idle" || !reply?.complete) return { kind: "waiting" };
11
+
12
+ return { kind: "ready", replyId: reply.id };
13
+ }
@@ -0,0 +1,161 @@
1
+ import { expect, test } from "bun:test";
2
+ import { SCHEMA_VERSION, type Thread, type ThreadAgentState } from "@cueloop/schema";
3
+ import {
4
+ projectAgentTranscript,
5
+ projectThreadConversation,
6
+ commentOnAgentSpan,
7
+ agentToolFilePath,
8
+ } from "./agent-transcript";
9
+
10
+ import { buildDisplay, marksByDisplay } from "../markdown/view-plan";
11
+
12
+ const thread: Thread = {
13
+ schemaVersion: SCHEMA_VERSION,
14
+ id: "thread",
15
+ workspace: { repoRoot: "/tmp", branch: "main" },
16
+ artifact: { type: "plan", content: "Original artifact", meta: {} },
17
+ annotations: [],
18
+ revisions: [],
19
+ status: "pending",
20
+ message: null,
21
+ createdAt: "2026-10-04",
22
+ };
23
+ const state: ThreadAgentState = {
24
+ threadId: "thread",
25
+ phase: { kind: "idle" },
26
+ tools: [],
27
+ comments: [],
28
+ messages: [
29
+ { id: "question", role: "user", text: "Why?", complete: true, revision: 1 },
30
+ { id: "answer-1", role: "agent", text: "Same quote.", complete: true, revision: 1 },
31
+ { id: "answer-2", role: "agent", text: "Same quote.", complete: true, revision: 1 },
32
+ ],
33
+ };
34
+
35
+ test("repeated quotes bind to the chosen answer instead of an earlier message", () => {
36
+ const comment = commentOnAgentSpan(
37
+ thread,
38
+ state,
39
+ { start: { blockIndex: 5, char: 0 }, end: { blockIndex: 5, char: 4 } },
40
+ "Explain",
41
+ "note",
42
+ );
43
+ const projected = projectAgentTranscript(thread, { ...state, comments: [comment] });
44
+
45
+ expect(comment.messageId).toBe("answer-2");
46
+ expect(comment.anchor.quote).toBe("Same");
47
+ expect(projected.marks.has(5)).toBe(true);
48
+ expect(projected.marks.has(3)).toBe(false);
49
+ expect(thread.artifact.content).toBe("Original artifact");
50
+ });
51
+
52
+ test("a question, a cross-message selection, or a changing answer cannot accept feedback", () => {
53
+ const span = { start: { blockIndex: 1, char: 0 }, end: { blockIndex: 1, char: 3 } };
54
+
55
+ expect(() => commentOnAgentSpan(thread, state, span, "note", "id")).toThrow();
56
+ expect(() =>
57
+ commentOnAgentSpan(
58
+ thread,
59
+ state,
60
+ { ...span, start: { blockIndex: 3, char: 0 }, end: { blockIndex: 5, char: 4 } },
61
+ "note",
62
+ "id",
63
+ ),
64
+ ).toThrow();
65
+ expect(() =>
66
+ commentOnAgentSpan(
67
+ thread,
68
+ { ...state, messages: state.messages.map((message) => ({ ...message, complete: false })) },
69
+ { ...span, start: { blockIndex: 3, char: 0 }, end: { blockIndex: 3, char: 4 } },
70
+ "note",
71
+ "id",
72
+ ),
73
+ ).toThrow();
74
+ });
75
+
76
+ test("tool locations open the correct repository file from a subdirectory cwd", () => {
77
+ const nested: Thread = {
78
+ ...thread,
79
+ workspace: { repoRoot: "/repo", branch: "main" },
80
+ artifact: { ...thread.artifact, meta: { cwd: "/repo/packages/client" } },
81
+ };
82
+
83
+ expect(agentToolFilePath(nested, "/repo/packages/client/src/App.tsx")).toBe(
84
+ "packages/client/src/App.tsx",
85
+ );
86
+ expect(agentToolFilePath(nested, "src/App.tsx")).toBe("packages/client/src/App.tsx");
87
+ expect(agentToolFilePath(nested, "../../README.md")).toBe("README.md");
88
+ expect(agentToolFilePath(nested, "/outside/README.md")).toBeUndefined();
89
+ expect(agentToolFilePath(nested, "../../../outside.ts")).toBeUndefined();
90
+ });
91
+
92
+ test("editable artifact and agent comments stay inline until accepted for invocation", () => {
93
+ const comment = commentOnAgentSpan(
94
+ thread,
95
+ state,
96
+ { start: { blockIndex: 3, char: 0 }, end: { blockIndex: 3, char: 4 } },
97
+ "Explain the answer",
98
+ "agent-note",
99
+ );
100
+ const artifactNote = {
101
+ id: "artifact-note",
102
+ kind: "comment" as const,
103
+ body: "Explain the artifact",
104
+ createdAt: thread.createdAt,
105
+ anchor: { quote: "Original", prefix: "", suffix: " artifact", blockIndex: 0, start: 0, end: 8 },
106
+ };
107
+ const annotated = { ...thread, annotations: [artifactNote] };
108
+ const pending = { ...state, comments: [comment] };
109
+ const display = buildDisplay(thread.artifact.content);
110
+ const marks = marksByDisplay(annotated.annotations, display);
111
+ const inline = projectThreadConversation(annotated, pending, display, marks);
112
+
113
+ expect(inline.mirrors.size).toBe(0);
114
+ expect(inline.session.annotations.some((entry) => entry.id === artifactNote.id)).toBe(true);
115
+ expect(inline.session.annotations.some((entry) => entry.id === comment.id)).toBe(true);
116
+ const submitted = projectThreadConversation(
117
+ annotated,
118
+ {
119
+ ...pending,
120
+ submissions: [
121
+ {
122
+ id: "accepted",
123
+ commentId: artifactNote.id,
124
+ prompt: artifactNote.body,
125
+ quote: artifactNote.anchor.quote,
126
+ status: "queued",
127
+ },
128
+ ],
129
+ },
130
+ display,
131
+ marks,
132
+ );
133
+
134
+ expect(submitted.mirrors.size).toBe(1);
135
+ expect(submitted.mirrors.get("mirror:accepted")?.commentId).toBe(artifactNote.id);
136
+ });
137
+
138
+ test.each([undefined, "plain-prompt"])(
139
+ "accepted bottom prompts remain user messages without synthetic comment mirrors (%s)",
140
+ (commentId) => {
141
+ const emptyThread = { ...thread, artifact: { ...thread.artifact, content: "" } };
142
+ const projected = projectThreadConversation(
143
+ emptyThread,
144
+ {
145
+ ...state,
146
+ messages: [],
147
+ submissions: [
148
+ { id: "plain-prompt", commentId, prompt: "Hello from the prompt", status: "completed" },
149
+ ],
150
+ },
151
+ [],
152
+ new Map(),
153
+ );
154
+
155
+ expect(projected.mirrors.size).toBe(0);
156
+ expect(projected.session.annotations).toEqual([]);
157
+ expect(projected.display.some((block) => block.work?.text === "Hello from the prompt")).toBe(
158
+ true,
159
+ );
160
+ },
161
+ );
@@ -0,0 +1,344 @@
1
+ import { resolve, relative, isAbsolute } from "node:path";
2
+ import {
3
+ makeAnchor,
4
+ parseBlocks,
5
+ type AgentComment,
6
+ type Thread,
7
+ type ThreadAgentState,
8
+ } from "@cueloop/schema";
9
+ import {
10
+ buildDisplay,
11
+ marksByDisplay,
12
+ renderedSpanToWork,
13
+ type DisplayBlock,
14
+ type Mark,
15
+ } from "../markdown/view-plan";
16
+ import type { TextSpan } from "../annotations/thread-selection";
17
+
18
+ /** One parsed agent transcript owns both display blocks and message selection coordinates. */
19
+ export function projectAgentTranscript(thread: Thread, state: ThreadAgentState) {
20
+ const display: DisplayBlock[] = [];
21
+ const offsets = new Map<string, number>();
22
+ const sources: { messageId: string; blockIndex: number }[] = [];
23
+ const annotations = state.comments.map((comment) => ({
24
+ ...comment,
25
+ kind: "comment",
26
+ createdAt: thread.createdAt,
27
+ }));
28
+
29
+ for (const message of state.messages) {
30
+ display.push(
31
+ ...buildDisplay(`## ${message.role === "user" ? "You" : (state.harness?.label ?? "Agent")}`),
32
+ );
33
+ sources.push({ messageId: "", blockIndex: -1 });
34
+ offsets.set(message.id, display.length);
35
+ const blocks = buildDisplay(message.text);
36
+
37
+ display.push(...blocks);
38
+ sources.push(...blocks.map((_, blockIndex) => ({ messageId: message.id, blockIndex })));
39
+
40
+ if (message.role === "user") {
41
+ const tools = state.tools.filter((tool) => tool.turnId === message.id);
42
+
43
+ if (tools.length) {
44
+ display.push(
45
+ ...buildDisplay(
46
+ `${tools.length} tool ${tools.length === 1 ? "call" : "calls"} · ${tools.filter((tool) => tool.kind === "read").length} reads · ${tools.filter((tool) => tool.kind === "execute").length} commands`,
47
+ ),
48
+ );
49
+ sources.push({ messageId: "", blockIndex: -1 });
50
+ }
51
+ }
52
+ }
53
+ const marks = new Map<number, Mark[]>();
54
+
55
+ for (const message of state.messages) {
56
+ const local = annotations.filter((annotation) => annotation.messageId === message.id);
57
+ const offset = offsets.get(message.id)!;
58
+
59
+ for (const [index, values] of marksByDisplay(local, buildDisplay(message.text)))
60
+ marks.set(
61
+ index + offset,
62
+ values.map((mark) => ({
63
+ ...mark,
64
+ span: mark.span
65
+ ? {
66
+ start: { ...mark.span.start, blockIndex: mark.span.start.blockIndex + offset },
67
+ end: { ...mark.span.end, blockIndex: mark.span.end.blockIndex + offset },
68
+ }
69
+ : undefined,
70
+ })),
71
+ );
72
+ }
73
+ const session: Thread = {
74
+ ...thread,
75
+ history: undefined,
76
+ workingCopy: undefined,
77
+ textCuts: undefined,
78
+ artifact: { type: "plan", content: "", meta: {} },
79
+ annotations,
80
+ status: "pending",
81
+ message: null,
82
+ };
83
+
84
+ return { display, marks, session, sources };
85
+ }
86
+
87
+ /** Agent feedback cannot span messages or bind to an unfinished answer. */
88
+ export function commentOnAgentSpan(
89
+ thread: Thread,
90
+ state: ThreadAgentState,
91
+ span: TextSpan,
92
+ body: string,
93
+ id: string,
94
+ ): AgentComment {
95
+ const projection = projectAgentTranscript(thread, state);
96
+ const start = projection.sources[span.start.blockIndex];
97
+ const end = projection.sources[span.end.blockIndex];
98
+ const message = state.messages.find((message) => message.id === start?.messageId);
99
+
100
+ if (
101
+ !message ||
102
+ !start ||
103
+ !end ||
104
+ start.messageId !== end.messageId ||
105
+ message.role !== "agent" ||
106
+ !message.complete
107
+ ) {
108
+ throw new Error("Agent comment requires a selection within one completed answer");
109
+ }
110
+
111
+ const range = renderedSpanToWork(
112
+ buildDisplay(message.text),
113
+ start.blockIndex,
114
+ end.blockIndex,
115
+ span.start.char,
116
+ span.end.char,
117
+ );
118
+
119
+ return {
120
+ id,
121
+ messageId: message.id,
122
+ anchor: makeAnchor(
123
+ parseBlocks(message.text),
124
+ start.blockIndex,
125
+ range.start,
126
+ range.end,
127
+ end.blockIndex,
128
+ ),
129
+ body,
130
+ sent: false,
131
+ };
132
+ }
133
+
134
+ /** Tool locations use the agent cwd; the file reader uses the repository root. */
135
+ export function agentToolFilePath(thread: Thread, path: string): string | undefined {
136
+ const root = thread.workspace.repoRoot;
137
+ const absolute = resolve(thread.artifact.meta.cwd ?? root, path);
138
+ const local = relative(root, absolute);
139
+
140
+ if (!local || local === ".." || local.startsWith("../") || isAbsolute(local)) return undefined;
141
+
142
+ return local;
143
+ }
144
+
145
+ /** The artifact, mirrored discussions, answers, and tail share one navigation projection. */
146
+ export function projectThreadConversation(
147
+ thread: Thread,
148
+ state: ThreadAgentState,
149
+ artifactDisplay: DisplayBlock[],
150
+ artifactMarks: Map<number, Mark[]>,
151
+ showActivity = state.phase.kind !== "idle",
152
+ ) {
153
+ const display = [...artifactDisplay];
154
+ const marks = new Map(artifactMarks);
155
+ const annotations = [...thread.annotations];
156
+ const sources: (
157
+ | { kind: "artifact" }
158
+ | { kind: "message"; messageId: string; blockIndex: number }
159
+ | { kind: "mirror"; commentId?: string }
160
+ | { kind: "tail" }
161
+ | { kind: "activity" }
162
+ )[] = artifactDisplay.map(() => ({ kind: "artifact" }));
163
+ const mirrors = new Map<string, { commentId?: string; submissionId?: string }>();
164
+ const destinations = new Map<string, number>();
165
+ const mirror = (
166
+ id: string,
167
+ body: string,
168
+ quote: string,
169
+ commentId?: string,
170
+ submissionId?: string,
171
+ ): void => {
172
+ const blocks: DisplayBlock[] = buildDisplay(quote);
173
+
174
+ if (!blocks.length)
175
+ blocks.push({
176
+ type: "same",
177
+ kind: "p",
178
+ work: { kind: "p", text: "", lineStart: 0, lineEnd: 0 },
179
+ });
180
+
181
+ const offset = display.length;
182
+ const annotation = {
183
+ id: `mirror:${id}`,
184
+ kind: "comment",
185
+ body,
186
+ createdAt: thread.createdAt,
187
+ anchor: {
188
+ quote,
189
+ prefix: "",
190
+ suffix: "",
191
+ blockIndex: 0,
192
+ start: 0,
193
+ end: (blocks[0]?.work ?? blocks[0]?.base)?.text.length ?? 0,
194
+ },
195
+ };
196
+
197
+ display.push(...blocks);
198
+ sources.push(...blocks.map(() => ({ kind: "mirror" as const, commentId })));
199
+ annotations.push(annotation);
200
+ const mirrorAnnotations = [annotation];
201
+
202
+ if (commentId) {
203
+ const replies = [...thread.annotations, ...state.comments].filter(
204
+ (entry) => entry.replyTo === commentId,
205
+ );
206
+
207
+ for (const reply of replies) {
208
+ const replica = {
209
+ ...annotation,
210
+ id: `${annotation.id}:${reply.id}`,
211
+ body: reply.body,
212
+ author: reply.author,
213
+ replyTo: annotation.id,
214
+ };
215
+
216
+ annotations.push(replica);
217
+ mirrorAnnotations.push(replica);
218
+ mirrors.set(replica.id, { commentId: reply.id });
219
+ }
220
+ }
221
+
222
+ const localMarks = quote.trim()
223
+ ? marksByDisplay(mirrorAnnotations, blocks)
224
+ : new Map<number, Mark[]>([
225
+ [
226
+ 0,
227
+ mirrorAnnotations.map((entry) => ({
228
+ start: 0,
229
+ end: 0,
230
+ role: "mark-comment",
231
+ annotationId: entry.id,
232
+ span: { start: { blockIndex: 0, char: 0 }, end: { blockIndex: 0, char: 0 } },
233
+ })),
234
+ ],
235
+ ]);
236
+
237
+ for (const [index, values] of localMarks) {
238
+ marks.set(
239
+ index + offset,
240
+ values.map((mark) => ({
241
+ ...mark,
242
+ span: mark.span
243
+ ? {
244
+ start: { ...mark.span.start, blockIndex: mark.span.start.blockIndex + offset },
245
+ end: { ...mark.span.end, blockIndex: mark.span.end.blockIndex + offset },
246
+ }
247
+ : undefined,
248
+ })),
249
+ );
250
+ }
251
+ mirrors.set(annotation.id, { commentId, submissionId });
252
+
253
+ if (submissionId) destinations.set(submissionId, offset);
254
+ };
255
+ const message = (entry: ThreadAgentState["messages"][number]): void => {
256
+ const projection = projectAgentTranscript(thread, {
257
+ ...state,
258
+ messages: [entry],
259
+ tools: [],
260
+ comments: state.comments.filter((comment) => comment.messageId === entry.id),
261
+ });
262
+ const offset = display.length;
263
+
264
+ display.push(...projection.display.slice(1));
265
+ sources.push(
266
+ ...projection.sources.slice(1).map((source) => ({ kind: "message" as const, ...source })),
267
+ );
268
+ annotations.push(...projection.session.annotations);
269
+ for (const [index, values] of projection.marks) {
270
+ marks.set(
271
+ index - 1 + offset,
272
+ values.map((mark) => ({
273
+ ...mark,
274
+ span: mark.span
275
+ ? {
276
+ start: { ...mark.span.start, blockIndex: mark.span.start.blockIndex + offset - 1 },
277
+ end: { ...mark.span.end, blockIndex: mark.span.end.blockIndex + offset - 1 },
278
+ }
279
+ : undefined,
280
+ })),
281
+ );
282
+ }
283
+ };
284
+
285
+ if (state.submissions?.length) {
286
+ for (const submission of state.submissions) {
287
+ // A prompt may use its submission ID as a discussion root; that is not an inline comment.
288
+ if (submission.commentId && submission.commentId !== submission.id) {
289
+ mirror(
290
+ submission.id,
291
+ submission.prompt,
292
+ submission.quote ?? " ",
293
+ submission.commentId,
294
+ submission.id,
295
+ );
296
+ } else {
297
+ destinations.set(submission.id, display.length);
298
+ message({
299
+ id: submission.id,
300
+ role: "user",
301
+ text: submission.prompt,
302
+ complete: true,
303
+ revision: 1,
304
+ });
305
+ }
306
+
307
+ for (const entry of state.messages.filter(
308
+ (entry) => entry.role === "agent" && entry.submissionId === submission.id,
309
+ ))
310
+ message(entry);
311
+ }
312
+ } else for (const entry of state.messages) message(entry);
313
+
314
+ const activityIndex = showActivity ? display.length : -1;
315
+
316
+ if (showActivity) {
317
+ display.push({
318
+ type: "same",
319
+ kind: "p",
320
+ work: { kind: "p", text: "", lineStart: 0, lineEnd: 0 },
321
+ });
322
+ sources.push({ kind: "activity" });
323
+ }
324
+
325
+ const tailIndex = display.length;
326
+
327
+ display.push({
328
+ type: "same",
329
+ kind: "p",
330
+ work: { kind: "p", text: "", lineStart: 0, lineEnd: 0 },
331
+ });
332
+ sources.push({ kind: "tail" });
333
+
334
+ return {
335
+ display,
336
+ marks,
337
+ sources,
338
+ mirrors,
339
+ destinations,
340
+ activityIndex,
341
+ tailIndex,
342
+ session: { ...thread, annotations },
343
+ };
344
+ }
@@ -0,0 +1,39 @@
1
+ import React from "react";
2
+ import { DARK } from "../../appearance/theme";
3
+ import type { Story, StoryMeta } from "../../stories/story";
4
+ import { AgentConfigControls } from "./AgentConfigControls";
5
+
6
+ export const meta: StoryMeta = { title: "Chrome/AgentConfigControls" };
7
+
8
+ export const Choices: Story = {
9
+ size: { width: 40, height: 2 },
10
+ expectedColors: [DARK.textMuted],
11
+ render: () => (
12
+ <AgentConfigControls
13
+ theme={DARK}
14
+ onConfigure={() => {}}
15
+ state={{
16
+ threadId: "thread",
17
+ phase: { kind: "idle" },
18
+ messages: [],
19
+ tools: [],
20
+ comments: [],
21
+ configOptions: [
22
+ {
23
+ id: "model",
24
+ name: "Model",
25
+ currentValue: "test",
26
+ options: [{ value: "test", name: "Test model" }],
27
+ },
28
+ {
29
+ id: "effort",
30
+ name: "Reasoning",
31
+ category: "thought_level",
32
+ currentValue: "medium",
33
+ options: [{ value: "medium", name: "Medium" }],
34
+ },
35
+ ],
36
+ }}
37
+ />
38
+ ),
39
+ };