@copilotkit/vue 1.57.1

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 (437) hide show
  1. package/AGENTS.md +50 -0
  2. package/CHANGELOG.md +13 -0
  3. package/PARITY.md +434 -0
  4. package/README.md +396 -0
  5. package/dist/components/copilot-provider/CopilotKit.vue.d.ts +20 -0
  6. package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -0
  7. package/dist/components/copilot-provider/index.d.ts +3 -0
  8. package/dist/components/copilot-provider/index.d.ts.map +1 -0
  9. package/dist/components/copilot-provider/types.d.ts +22 -0
  10. package/dist/components/copilot-provider/types.d.ts.map +1 -0
  11. package/dist/hooks/index.d.ts +7 -0
  12. package/dist/hooks/index.d.ts.map +1 -0
  13. package/dist/hooks/use-copilot-action.d.ts +27 -0
  14. package/dist/hooks/use-copilot-action.d.ts.map +1 -0
  15. package/dist/hooks/use-copilot-readable.d.ts +20 -0
  16. package/dist/hooks/use-copilot-readable.d.ts.map +1 -0
  17. package/dist/hooks/use-frontend-tool.d.ts +21 -0
  18. package/dist/hooks/use-frontend-tool.d.ts.map +1 -0
  19. package/dist/index.cjs +2 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +10 -0
  22. package/dist/index.d.mts +10 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.mjs +252 -0
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/styles.css +2 -0
  28. package/dist/use-render-activity-message-BRL1Rpl-.cjs +85 -0
  29. package/dist/use-render-activity-message-BRL1Rpl-.cjs.map +1 -0
  30. package/dist/use-render-activity-message-CqtxiFSs.js +8927 -0
  31. package/dist/use-render-activity-message-CqtxiFSs.js.map +1 -0
  32. package/dist/v2/components/A2UIMessageRenderer.d.ts +9 -0
  33. package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -0
  34. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +16 -0
  35. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -0
  36. package/dist/v2/components/CopilotKitInspector.vue.d.ts +7 -0
  37. package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -0
  38. package/dist/v2/components/InlineFeatureWarning.vue.d.ts +6 -0
  39. package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -0
  40. package/dist/v2/components/LicenseWarningBanner.vue.d.ts +18 -0
  41. package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -0
  42. package/dist/v2/components/MCPAppsActivityRenderer.d.ts +88 -0
  43. package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -0
  44. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +154 -0
  45. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -0
  46. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +19 -0
  47. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -0
  48. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +16 -0
  49. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -0
  50. package/dist/v2/components/a2ui/VueSurface.d.ts +62 -0
  51. package/dist/v2/components/a2ui/VueSurface.d.ts.map +1 -0
  52. package/dist/v2/components/a2ui/adapter.d.ts +38 -0
  53. package/dist/v2/components/a2ui/adapter.d.ts.map +1 -0
  54. package/dist/v2/components/a2ui/catalog.d.ts +29 -0
  55. package/dist/v2/components/a2ui/catalog.d.ts.map +1 -0
  56. package/dist/v2/components/a2ui/index.d.ts +5 -0
  57. package/dist/v2/components/a2ui/index.d.ts.map +1 -0
  58. package/dist/v2/components/a2ui/utils.d.ts +18 -0
  59. package/dist/v2/components/a2ui/utils.d.ts.map +1 -0
  60. package/dist/v2/components/a2ui.d.ts +12 -0
  61. package/dist/v2/components/a2ui.d.ts.map +1 -0
  62. package/dist/v2/components/chat/CopilotChat.vue.d.ts +50 -0
  63. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -0
  64. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +164 -0
  65. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -0
  66. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts +12 -0
  67. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -0
  68. package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts +7 -0
  69. package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -0
  70. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +12 -0
  71. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -0
  72. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +290 -0
  73. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -0
  74. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +72 -0
  75. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -0
  76. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts +65 -0
  77. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -0
  78. package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts +27 -0
  79. package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -0
  80. package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts +26 -0
  81. package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -0
  82. package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts +17 -0
  83. package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -0
  84. package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts +5 -0
  85. package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts.map +1 -0
  86. package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts +5 -0
  87. package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts.map +1 -0
  88. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +21 -0
  89. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -0
  90. package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts +34 -0
  91. package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -0
  92. package/dist/v2/components/chat/CopilotChatView.vue.d.ts +106 -0
  93. package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -0
  94. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts +15 -0
  95. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -0
  96. package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts +5 -0
  97. package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -0
  98. package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts +5 -0
  99. package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -0
  100. package/dist/v2/components/chat/CopilotPopup.vue.d.ts +50 -0
  101. package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -0
  102. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +55 -0
  103. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -0
  104. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +55 -0
  105. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -0
  106. package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts +28 -0
  107. package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -0
  108. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +48 -0
  109. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -0
  110. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +62 -0
  111. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -0
  112. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +53 -0
  113. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -0
  114. package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts +28 -0
  115. package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -0
  116. package/dist/v2/components/chat/audioRecorder.d.ts +11 -0
  117. package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -0
  118. package/dist/v2/components/chat/index.d.ts +682 -0
  119. package/dist/v2/components/chat/index.d.ts.map +1 -0
  120. package/dist/v2/components/chat/last-user-message-context.d.ts +29 -0
  121. package/dist/v2/components/chat/last-user-message-context.d.ts.map +1 -0
  122. package/dist/v2/components/chat/normalize-auto-scroll.d.ts +3 -0
  123. package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +1 -0
  124. package/dist/v2/components/chat/types.d.ts +380 -0
  125. package/dist/v2/components/chat/types.d.ts.map +1 -0
  126. package/dist/v2/components/icons/index.d.ts +2 -0
  127. package/dist/v2/components/icons/index.d.ts.map +1 -0
  128. package/dist/v2/components/index.d.ts +8 -0
  129. package/dist/v2/components/index.d.ts.map +1 -0
  130. package/dist/v2/hooks/index.d.ts +24 -0
  131. package/dist/v2/hooks/index.d.ts.map +1 -0
  132. package/dist/v2/hooks/use-agent-context.d.ts +24 -0
  133. package/dist/v2/hooks/use-agent-context.d.ts.map +1 -0
  134. package/dist/v2/hooks/use-agent.d.ts +53 -0
  135. package/dist/v2/hooks/use-agent.d.ts.map +1 -0
  136. package/dist/v2/hooks/use-attachments.d.ts +21 -0
  137. package/dist/v2/hooks/use-attachments.d.ts.map +1 -0
  138. package/dist/v2/hooks/use-capabilities.d.ts +16 -0
  139. package/dist/v2/hooks/use-capabilities.d.ts.map +1 -0
  140. package/dist/v2/hooks/use-component.d.ts +13 -0
  141. package/dist/v2/hooks/use-component.d.ts.map +1 -0
  142. package/dist/v2/hooks/use-configure-suggestions.d.ts +24 -0
  143. package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -0
  144. package/dist/v2/hooks/use-default-render-tool.d.ts +14 -0
  145. package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -0
  146. package/dist/v2/hooks/use-frontend-tool.d.ts +19 -0
  147. package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -0
  148. package/dist/v2/hooks/use-human-in-the-loop.d.ts +19 -0
  149. package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -0
  150. package/dist/v2/hooks/use-interrupt.d.ts +36 -0
  151. package/dist/v2/hooks/use-interrupt.d.ts.map +1 -0
  152. package/dist/v2/hooks/use-katex-styles.d.ts +22 -0
  153. package/dist/v2/hooks/use-katex-styles.d.ts.map +1 -0
  154. package/dist/v2/hooks/use-keyboard-height.d.ts +33 -0
  155. package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -0
  156. package/dist/v2/hooks/use-pin-to-send.d.ts +28 -0
  157. package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -0
  158. package/dist/v2/hooks/use-render-activity-message.d.ts +21 -0
  159. package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -0
  160. package/dist/v2/hooks/use-render-custom-messages.d.ts +27 -0
  161. package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -0
  162. package/dist/v2/hooks/use-render-tool.d.ts +36 -0
  163. package/dist/v2/hooks/use-render-tool.d.ts.map +1 -0
  164. package/dist/v2/hooks/use-suggestions.d.ts +26 -0
  165. package/dist/v2/hooks/use-suggestions.d.ts.map +1 -0
  166. package/dist/v2/hooks/use-threads.d.ts +42 -0
  167. package/dist/v2/hooks/use-threads.d.ts.map +1 -0
  168. package/dist/v2/index.cjs +2 -0
  169. package/dist/v2/index.cjs.map +1 -0
  170. package/dist/v2/index.d.cts +9 -0
  171. package/dist/v2/index.d.mts +9 -0
  172. package/dist/v2/index.d.ts +9 -0
  173. package/dist/v2/index.d.ts.map +1 -0
  174. package/dist/v2/index.mjs +75 -0
  175. package/dist/v2/index.mjs.map +1 -0
  176. package/dist/v2/lib/processPartialHtml.d.ts +3 -0
  177. package/dist/v2/lib/processPartialHtml.d.ts.map +1 -0
  178. package/dist/v2/lib/shallow-stable.d.ts +7 -0
  179. package/dist/v2/lib/shallow-stable.d.ts.map +1 -0
  180. package/dist/v2/lib/transcription-client.d.ts +19 -0
  181. package/dist/v2/lib/transcription-client.d.ts.map +1 -0
  182. package/dist/v2/lib/vue-core.d.ts +47 -0
  183. package/dist/v2/lib/vue-core.d.ts.map +1 -0
  184. package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts +15 -0
  185. package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts.map +1 -0
  186. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts +17 -0
  187. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -0
  188. package/dist/v2/providers/CopilotKitProvider.types.d.ts +61 -0
  189. package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -0
  190. package/dist/v2/providers/CopilotKitProvider.vue.d.ts +37 -0
  191. package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -0
  192. package/dist/v2/providers/SandboxFunctionsContext.d.ts +4 -0
  193. package/dist/v2/providers/SandboxFunctionsContext.d.ts.map +1 -0
  194. package/dist/v2/providers/index.d.ts +13 -0
  195. package/dist/v2/providers/index.d.ts.map +1 -0
  196. package/dist/v2/providers/keys.d.ts +17 -0
  197. package/dist/v2/providers/keys.d.ts.map +1 -0
  198. package/dist/v2/providers/license-context.d.ts +7 -0
  199. package/dist/v2/providers/license-context.d.ts.map +1 -0
  200. package/dist/v2/providers/types.d.ts +38 -0
  201. package/dist/v2/providers/types.d.ts.map +1 -0
  202. package/dist/v2/providers/useCopilotChatConfiguration.d.ts +4 -0
  203. package/dist/v2/providers/useCopilotChatConfiguration.d.ts.map +1 -0
  204. package/dist/v2/providers/useCopilotKit.d.ts +2 -0
  205. package/dist/v2/providers/useCopilotKit.d.ts.map +1 -0
  206. package/dist/v2/providers/useLicenseContext.d.ts +14 -0
  207. package/dist/v2/providers/useLicenseContext.d.ts.map +1 -0
  208. package/dist/v2/types/a2ui.d.ts +5 -0
  209. package/dist/v2/types/a2ui.d.ts.map +1 -0
  210. package/dist/v2/types/defineToolCallRenderer.d.ts +15 -0
  211. package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -0
  212. package/dist/v2/types/frontend-tool.d.ts +6 -0
  213. package/dist/v2/types/frontend-tool.d.ts.map +1 -0
  214. package/dist/v2/types/human-in-the-loop.d.ts +29 -0
  215. package/dist/v2/types/human-in-the-loop.d.ts.map +1 -0
  216. package/dist/v2/types/index.d.ts +10 -0
  217. package/dist/v2/types/index.d.ts.map +1 -0
  218. package/dist/v2/types/interrupt.d.ts +14 -0
  219. package/dist/v2/types/interrupt.d.ts.map +1 -0
  220. package/dist/v2/types/sandbox-function.d.ts +8 -0
  221. package/dist/v2/types/sandbox-function.d.ts.map +1 -0
  222. package/dist/v2/types/vue-activity-message-renderer.d.ts +18 -0
  223. package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -0
  224. package/dist/v2/types/vue-custom-message-renderer.d.ts +19 -0
  225. package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -0
  226. package/dist/v2/types/vue-tool-call-renderer.d.ts +37 -0
  227. package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -0
  228. package/env.d.ts +7 -0
  229. package/eslint.config.mjs +42 -0
  230. package/package.json +130 -0
  231. package/scripts/scope-preflight.mjs +100 -0
  232. package/src/components/copilot-provider/CopilotKit.vue +18 -0
  233. package/src/components/copilot-provider/index.ts +2 -0
  234. package/src/components/copilot-provider/types.ts +24 -0
  235. package/src/hooks/index.ts +9 -0
  236. package/src/hooks/use-copilot-action.ts +168 -0
  237. package/src/hooks/use-copilot-readable.ts +75 -0
  238. package/src/hooks/use-frontend-tool.ts +76 -0
  239. package/src/index.ts +12 -0
  240. package/src/styles/globals.css +314 -0
  241. package/src/v2/__tests__/exports.test.ts +35 -0
  242. package/src/v2/__tests__/mocks/web-inspector.ts +5 -0
  243. package/src/v2/__tests__/setup.ts +141 -0
  244. package/src/v2/__tests__/utils/agents.ts +391 -0
  245. package/src/v2/__tests__/utils/mount.ts +83 -0
  246. package/src/v2/__tests__/utils/test-helpers.ts +712 -0
  247. package/src/v2/components/A2UIMessageRenderer.ts +125 -0
  248. package/src/v2/components/A2UISurfaceActivityRenderer.vue +186 -0
  249. package/src/v2/components/CopilotKitInspector.vue +42 -0
  250. package/src/v2/components/InlineFeatureWarning.vue +35 -0
  251. package/src/v2/components/LicenseWarningBanner.vue +196 -0
  252. package/src/v2/components/MCPAppsActivityRenderer.ts +778 -0
  253. package/src/v2/components/OpenGenerativeUIRenderer.ts +550 -0
  254. package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +271 -0
  255. package/src/v2/components/__tests__/CopilotKitInspector.test.ts +57 -0
  256. package/src/v2/components/__tests__/MCPAppsActivityRenderer.e2e.test.ts +851 -0
  257. package/src/v2/components/__tests__/MCPAppsActivityRenderer.test.ts +237 -0
  258. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +516 -0
  259. package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +295 -0
  260. package/src/v2/components/a2ui/A2UICatalogContext.ts +190 -0
  261. package/src/v2/components/a2ui/VueSurface.ts +144 -0
  262. package/src/v2/components/a2ui/adapter.ts +156 -0
  263. package/src/v2/components/a2ui/catalog.ts +858 -0
  264. package/src/v2/components/a2ui/index.ts +7 -0
  265. package/src/v2/components/a2ui/utils.ts +67 -0
  266. package/src/v2/components/a2ui.ts +30 -0
  267. package/src/v2/components/chat/CopilotChat.vue +777 -0
  268. package/src/v2/components/chat/CopilotChatAssistantMessage.vue +891 -0
  269. package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +411 -0
  270. package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +87 -0
  271. package/src/v2/components/chat/CopilotChatAudioRecorder.vue +269 -0
  272. package/src/v2/components/chat/CopilotChatInput.vue +1271 -0
  273. package/src/v2/components/chat/CopilotChatMessageView.vue +476 -0
  274. package/src/v2/components/chat/CopilotChatReasoningMessage.vue +247 -0
  275. package/src/v2/components/chat/CopilotChatSuggestionPill.vue +56 -0
  276. package/src/v2/components/chat/CopilotChatSuggestionView.vue +93 -0
  277. package/src/v2/components/chat/CopilotChatToggleButton.vue +145 -0
  278. package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +17 -0
  279. package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +18 -0
  280. package/src/v2/components/chat/CopilotChatToolCallsView.vue +161 -0
  281. package/src/v2/components/chat/CopilotChatUserMessage.vue +322 -0
  282. package/src/v2/components/chat/CopilotChatView.vue +740 -0
  283. package/src/v2/components/chat/CopilotModalHeader.vue +73 -0
  284. package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +38 -0
  285. package/src/v2/components/chat/CopilotModalHeaderTitle.ts +22 -0
  286. package/src/v2/components/chat/CopilotPopup.vue +182 -0
  287. package/src/v2/components/chat/CopilotPopupView.vue +168 -0
  288. package/src/v2/components/chat/CopilotPopupViewInternal.vue +453 -0
  289. package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +140 -0
  290. package/src/v2/components/chat/CopilotSidebar.vue +178 -0
  291. package/src/v2/components/chat/CopilotSidebarView.vue +172 -0
  292. package/src/v2/components/chat/CopilotSidebarViewInternal.vue +366 -0
  293. package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +142 -0
  294. package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.ts +237 -0
  295. package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.ts +1240 -0
  296. package/src/v2/components/chat/__tests__/CopilotChat.licenseWarning.test.ts +138 -0
  297. package/src/v2/components/chat/__tests__/CopilotChat.onError.test.ts +85 -0
  298. package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.ts +141 -0
  299. package/src/v2/components/chat/__tests__/CopilotChat.test.ts +652 -0
  300. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +683 -0
  301. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +768 -0
  302. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +1108 -0
  303. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.ts +87 -0
  304. package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +277 -0
  305. package/src/v2/components/chat/__tests__/CopilotChatAttachmentRenderer.test.ts +124 -0
  306. package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.ts +230 -0
  307. package/src/v2/components/chat/__tests__/CopilotChatInput.bottomAnchored.test.ts +83 -0
  308. package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +1139 -0
  309. package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +1051 -0
  310. package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.ts +141 -0
  311. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +494 -0
  312. package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.ts +181 -0
  313. package/src/v2/components/chat/__tests__/CopilotChatReasoningMessage.test.ts +73 -0
  314. package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +73 -0
  315. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +674 -0
  316. package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.test.ts +91 -0
  317. package/src/v2/components/chat/__tests__/CopilotChatToggleButton.test.ts +93 -0
  318. package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.test.ts +382 -0
  319. package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.ts +1019 -0
  320. package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.ts +516 -0
  321. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.ts +701 -0
  322. package/src/v2/components/chat/__tests__/CopilotChatUserMessage.test.ts +337 -0
  323. package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.ts +135 -0
  324. package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +278 -0
  325. package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.ts +1082 -0
  326. package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.ts +166 -0
  327. package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.ts +1145 -0
  328. package/src/v2/components/chat/__tests__/CopilotChatView.test.ts +374 -0
  329. package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +636 -0
  330. package/src/v2/components/chat/__tests__/CopilotModalHeader.test.ts +112 -0
  331. package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +58 -0
  332. package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +725 -0
  333. package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +112 -0
  334. package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +58 -0
  335. package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.ts +603 -0
  336. package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +214 -0
  337. package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.ts +394 -0
  338. package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.ts +82 -0
  339. package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +39 -0
  340. package/src/v2/components/chat/audioRecorder.ts +15 -0
  341. package/src/v2/components/chat/index.ts +52 -0
  342. package/src/v2/components/chat/last-user-message-context.ts +39 -0
  343. package/src/v2/components/chat/normalize-auto-scroll.ts +17 -0
  344. package/src/v2/components/chat/types.ts +481 -0
  345. package/src/v2/components/icons/__tests__/icons.test.ts +86 -0
  346. package/src/v2/components/icons/index.ts +22 -0
  347. package/src/v2/components/index.ts +7 -0
  348. package/src/v2/hooks/__tests__/standard-schema-types.test.ts +149 -0
  349. package/src/v2/hooks/__tests__/standard-schema.test.ts +315 -0
  350. package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.ts +144 -0
  351. package/src/v2/hooks/__tests__/use-agent-context.test.ts +271 -0
  352. package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +64 -0
  353. package/src/v2/hooks/__tests__/use-agent-stability.test.ts +268 -0
  354. package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.ts +433 -0
  355. package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +747 -0
  356. package/src/v2/hooks/__tests__/use-agent.e2e.test.ts +187 -0
  357. package/src/v2/hooks/__tests__/use-agent.test.ts +126 -0
  358. package/src/v2/hooks/__tests__/use-attachments.test.ts +181 -0
  359. package/src/v2/hooks/__tests__/use-component.test.ts +145 -0
  360. package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.ts +527 -0
  361. package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +399 -0
  362. package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +214 -0
  363. package/src/v2/hooks/__tests__/use-frontend-tool-available.test.ts +220 -0
  364. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +2320 -0
  365. package/src/v2/hooks/__tests__/use-frontend-tool.test.ts +648 -0
  366. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +1379 -0
  367. package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +282 -0
  368. package/src/v2/hooks/__tests__/use-interrupt.test.ts +345 -0
  369. package/src/v2/hooks/__tests__/use-katex-styles.test.ts +69 -0
  370. package/src/v2/hooks/__tests__/use-keyboard-height.test.ts +199 -0
  371. package/src/v2/hooks/__tests__/use-pin-to-send.test.ts +363 -0
  372. package/src/v2/hooks/__tests__/use-render-tool.test.ts +329 -0
  373. package/src/v2/hooks/__tests__/use-suggestions.e2e.test.ts +397 -0
  374. package/src/v2/hooks/__tests__/use-suggestions.test.ts +198 -0
  375. package/src/v2/hooks/__tests__/use-threads.test.ts +1041 -0
  376. package/src/v2/hooks/__tests__/zod-regression.test.ts +339 -0
  377. package/src/v2/hooks/index.ts +29 -0
  378. package/src/v2/hooks/use-agent-context.ts +55 -0
  379. package/src/v2/hooks/use-agent.ts +345 -0
  380. package/src/v2/hooks/use-attachments.ts +261 -0
  381. package/src/v2/hooks/use-capabilities.ts +30 -0
  382. package/src/v2/hooks/use-component.ts +46 -0
  383. package/src/v2/hooks/use-configure-suggestions.ts +252 -0
  384. package/src/v2/hooks/use-default-render-tool.ts +130 -0
  385. package/src/v2/hooks/use-frontend-tool.ts +68 -0
  386. package/src/v2/hooks/use-human-in-the-loop.ts +90 -0
  387. package/src/v2/hooks/use-interrupt.ts +257 -0
  388. package/src/v2/hooks/use-katex-styles.ts +44 -0
  389. package/src/v2/hooks/use-keyboard-height.ts +87 -0
  390. package/src/v2/hooks/use-pin-to-send.ts +160 -0
  391. package/src/v2/hooks/use-render-activity-message.ts +92 -0
  392. package/src/v2/hooks/use-render-custom-messages.ts +129 -0
  393. package/src/v2/hooks/use-render-tool.ts +128 -0
  394. package/src/v2/hooks/use-suggestions.ts +98 -0
  395. package/src/v2/hooks/use-threads.ts +208 -0
  396. package/src/v2/index.ts +11 -0
  397. package/src/v2/lib/__tests__/processPartialHtml.test.ts +84 -0
  398. package/src/v2/lib/__tests__/transcription-client.test.ts +65 -0
  399. package/src/v2/lib/processPartialHtml.ts +21 -0
  400. package/src/v2/lib/shallow-stable.ts +54 -0
  401. package/src/v2/lib/transcription-client.ts +151 -0
  402. package/src/v2/lib/vue-core.ts +161 -0
  403. package/src/v2/providers/CopilotChatConfigurationProvider.types.ts +15 -0
  404. package/src/v2/providers/CopilotChatConfigurationProvider.vue +95 -0
  405. package/src/v2/providers/CopilotKitProvider.types.ts +66 -0
  406. package/src/v2/providers/CopilotKitProvider.vue +653 -0
  407. package/src/v2/providers/SandboxFunctionsContext.ts +11 -0
  408. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +309 -0
  409. package/src/v2/providers/__tests__/CopilotKitProvider.debug.test.ts +295 -0
  410. package/src/v2/providers/__tests__/CopilotKitProvider.license.test.ts +110 -0
  411. package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.ts +67 -0
  412. package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.ts +901 -0
  413. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +141 -0
  414. package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.ts +871 -0
  415. package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +603 -0
  416. package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.ts +104 -0
  417. package/src/v2/providers/index.ts +21 -0
  418. package/src/v2/providers/keys.ts +25 -0
  419. package/src/v2/providers/license-context.ts +16 -0
  420. package/src/v2/providers/types.ts +40 -0
  421. package/src/v2/providers/useCopilotChatConfiguration.ts +11 -0
  422. package/src/v2/providers/useCopilotKit.ts +11 -0
  423. package/src/v2/providers/useLicenseContext.ts +21 -0
  424. package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +157 -0
  425. package/src/v2/types/a2ui.ts +5 -0
  426. package/src/v2/types/defineToolCallRenderer.ts +32 -0
  427. package/src/v2/types/frontend-tool.ts +8 -0
  428. package/src/v2/types/human-in-the-loop.ts +38 -0
  429. package/src/v2/types/index.ts +9 -0
  430. package/src/v2/types/interrupt.ts +15 -0
  431. package/src/v2/types/sandbox-function.ts +8 -0
  432. package/src/v2/types/vue-activity-message-renderer.ts +22 -0
  433. package/src/v2/types/vue-custom-message-renderer.ts +24 -0
  434. package/src/v2/types/vue-tool-call-renderer.ts +44 -0
  435. package/tsconfig.json +27 -0
  436. package/vite.config.ts +49 -0
  437. package/vitest.config.ts +23 -0
@@ -0,0 +1,1041 @@
1
+ import { mount } from "@vue/test-utils";
2
+ import { defineComponent, h, nextTick, ref } from "vue";
3
+ import type { Ref } from "vue";
4
+ import { describe, expect, it, beforeEach, vi } from "vitest";
5
+ import { useCopilotKit } from "../../providers/useCopilotKit";
6
+
7
+ type ThreadRecord = {
8
+ id: string;
9
+ organizationId: string;
10
+ agentId: string;
11
+ createdById: string;
12
+ name: string | null;
13
+ archived: boolean;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ lastRunAt?: string;
17
+ };
18
+
19
+ type ThreadState = {
20
+ threads: ThreadRecord[];
21
+ isLoading: boolean;
22
+ error: Error | null;
23
+ hasNextPage: boolean;
24
+ isFetchingNextPage: boolean;
25
+ context: {
26
+ runtimeUrl: string;
27
+ headers: Record<string, string>;
28
+ wsUrl?: string;
29
+ agentId: string;
30
+ includeArchived?: boolean;
31
+ limit?: number;
32
+ } | null;
33
+ };
34
+
35
+ const select = <T>(selector: (state: ThreadState) => T) => selector;
36
+
37
+ vi.mock("../../providers/useCopilotKit", () => ({
38
+ useCopilotKit: vi.fn(),
39
+ }));
40
+
41
+ const mockUseCopilotKit = useCopilotKit as ReturnType<typeof vi.fn>;
42
+ const threadMocks = vi.hoisted(() => ({
43
+ sockets: [] as any[],
44
+ dispatchedContexts: [] as Array<ThreadState["context"]>,
45
+ }));
46
+
47
+ function compareThreadsByActivity(left: ThreadRecord, right: ThreadRecord) {
48
+ const leftKey = left.lastRunAt ?? left.updatedAt ?? left.createdAt;
49
+ const rightKey = right.lastRunAt ?? right.updatedAt ?? right.createdAt;
50
+ return rightKey.localeCompare(leftKey);
51
+ }
52
+
53
+ vi.mock("@copilotkit/core", () => {
54
+ class MockChannel {
55
+ topic: string;
56
+ left = false;
57
+ private readonly store: MockThreadStore;
58
+
59
+ constructor(topic: string, store: MockThreadStore) {
60
+ this.topic = topic;
61
+ this.store = store;
62
+ }
63
+
64
+ leave(): void {
65
+ this.left = true;
66
+ }
67
+
68
+ serverPush(event: string, payload: any): void {
69
+ if (event !== "thread_metadata") return;
70
+ this.store.applyMetadata(payload);
71
+ }
72
+ }
73
+
74
+ class MockSocket {
75
+ connected = true;
76
+ disconnected = false;
77
+ channels: MockChannel[] = [];
78
+ private consecutiveErrors = 0;
79
+
80
+ constructor(public readonly store: MockThreadStore) {
81
+ threadMocks.sockets.push(this);
82
+ }
83
+
84
+ addChannel(channel: MockChannel): void {
85
+ this.channels.push(channel);
86
+ }
87
+
88
+ disconnect(): void {
89
+ this.disconnected = true;
90
+ }
91
+
92
+ triggerError(): void {
93
+ this.consecutiveErrors += 1;
94
+ if (this.consecutiveErrors >= 5) {
95
+ for (const channel of this.channels) {
96
+ channel.leave();
97
+ }
98
+ this.disconnect();
99
+ }
100
+ }
101
+ }
102
+
103
+ class MockThreadStore {
104
+ private state: ThreadState = {
105
+ threads: [],
106
+ isLoading: false,
107
+ error: null,
108
+ hasNextPage: false,
109
+ isFetchingNextPage: false,
110
+ context: null,
111
+ };
112
+ private listeners = new Set<() => void>();
113
+ private socket: MockSocket | null = null;
114
+
115
+ start(): void {}
116
+
117
+ stop(): void {
118
+ this.state = {
119
+ threads: [],
120
+ isLoading: false,
121
+ error: null,
122
+ hasNextPage: false,
123
+ isFetchingNextPage: false,
124
+ context: null,
125
+ };
126
+ if (this.socket) {
127
+ for (const channel of this.socket.channels) {
128
+ channel.leave();
129
+ }
130
+ this.socket.disconnect();
131
+ }
132
+ this.notify();
133
+ }
134
+
135
+ setContext(context: ThreadState["context"]): void {
136
+ threadMocks.dispatchedContexts.push(context);
137
+ this.state.context = context;
138
+ if (!context) {
139
+ this.state.threads = [];
140
+ this.state.isLoading = false;
141
+ this.state.error = null;
142
+ this.notify();
143
+ return;
144
+ }
145
+
146
+ this.state.threads = [];
147
+ this.state.isLoading = true;
148
+ this.state.error = null;
149
+ this.state.hasNextPage = false;
150
+ this.state.isFetchingNextPage = false;
151
+ this.notify();
152
+ void this.fetchThreads(context);
153
+ }
154
+
155
+ private async fetchThreads(context: NonNullable<ThreadState["context"]>) {
156
+ try {
157
+ const query = new URLSearchParams({ agentId: context.agentId });
158
+ if (context.includeArchived !== undefined) {
159
+ query.set("includeArchived", String(context.includeArchived));
160
+ }
161
+ if (context.limit !== undefined) {
162
+ query.set("limit", String(context.limit));
163
+ }
164
+ const listResponse = await fetchMock(
165
+ `${context.runtimeUrl}/threads?${query}`,
166
+ {
167
+ method: "GET",
168
+ headers: context.headers,
169
+ },
170
+ );
171
+ if (!listResponse.ok) {
172
+ this.state.error = new Error(String(listResponse.status));
173
+ this.state.isLoading = false;
174
+ this.state.threads = [];
175
+ this.state.hasNextPage = false;
176
+ this.notify();
177
+ return;
178
+ }
179
+
180
+ const listData = await listResponse.json();
181
+ this.state.threads = [...listData.threads].sort(
182
+ compareThreadsByActivity,
183
+ );
184
+ this.state.hasNextPage = typeof listData.nextCursor === "string";
185
+ this.state.isLoading = false;
186
+ this.state.error = null;
187
+ this.notify();
188
+
189
+ await fetchMock(`${context.runtimeUrl}/threads/subscribe`, {
190
+ method: "POST",
191
+ headers: context.headers,
192
+ body: JSON.stringify({
193
+ agentId: context.agentId,
194
+ }),
195
+ });
196
+
197
+ const joinCode =
198
+ typeof listData.joinCode === "string" ? listData.joinCode : "unknown";
199
+ this.socket = new MockSocket(this);
200
+ this.socket.addChannel(new MockChannel(`user_meta:${joinCode}`, this));
201
+ } catch (error) {
202
+ this.state.error = error as Error;
203
+ this.state.isLoading = false;
204
+ this.state.threads = [];
205
+ this.notify();
206
+ }
207
+ }
208
+
209
+ applyMetadata(payload: any): void {
210
+ if (!this.state.context) {
211
+ return;
212
+ }
213
+
214
+ if (payload.operation === "deleted") {
215
+ this.state.threads = this.state.threads.filter(
216
+ (thread) => thread.id !== payload.deleted.id,
217
+ );
218
+ } else {
219
+ const thread = payload.thread as ThreadRecord;
220
+ const existingIndex = this.state.threads.findIndex(
221
+ (item) => item.id === thread.id,
222
+ );
223
+ if (existingIndex === -1) {
224
+ this.state.threads = [...this.state.threads, thread];
225
+ } else {
226
+ const next = [...this.state.threads];
227
+ next[existingIndex] = thread;
228
+ this.state.threads = next;
229
+ }
230
+ this.state.threads.sort(compareThreadsByActivity);
231
+ }
232
+ this.notify();
233
+ }
234
+
235
+ async renameThread(threadId: string, name: string): Promise<void> {
236
+ const context = this.requireContext();
237
+ await fetchMock(`${context.runtimeUrl}/threads/${threadId}`, {
238
+ method: "PATCH",
239
+ headers: context.headers,
240
+ body: JSON.stringify({
241
+ agentId: context.agentId,
242
+ name,
243
+ }),
244
+ });
245
+ }
246
+
247
+ async archiveThread(threadId: string): Promise<void> {
248
+ const context = this.requireContext();
249
+ await fetchMock(`${context.runtimeUrl}/threads/${threadId}/archive`, {
250
+ method: "POST",
251
+ headers: context.headers,
252
+ body: JSON.stringify({
253
+ agentId: context.agentId,
254
+ }),
255
+ });
256
+ }
257
+
258
+ async deleteThread(threadId: string): Promise<void> {
259
+ const context = this.requireContext();
260
+ await fetchMock(`${context.runtimeUrl}/threads/${threadId}`, {
261
+ method: "DELETE",
262
+ headers: context.headers,
263
+ body: JSON.stringify({
264
+ agentId: context.agentId,
265
+ }),
266
+ });
267
+ }
268
+
269
+ fetchNextPage(): void {
270
+ this.state.isFetchingNextPage = true;
271
+ this.notify();
272
+ this.state.isFetchingNextPage = false;
273
+ this.notify();
274
+ }
275
+
276
+ private requireContext() {
277
+ if (!this.state.context) {
278
+ throw new Error("Missing thread context");
279
+ }
280
+ return this.state.context;
281
+ }
282
+
283
+ getState(): ThreadState {
284
+ return this.state;
285
+ }
286
+
287
+ select<T>(selector: (state: ThreadState) => T) {
288
+ return {
289
+ subscribe: (callback: () => void) => {
290
+ const listener = () => {
291
+ selector(this.state);
292
+ callback();
293
+ };
294
+ this.listeners.add(listener);
295
+ return {
296
+ unsubscribe: () => this.listeners.delete(listener),
297
+ };
298
+ },
299
+ };
300
+ }
301
+
302
+ private notify(): void {
303
+ for (const listener of this.listeners) {
304
+ listener();
305
+ }
306
+ }
307
+ }
308
+
309
+ return {
310
+ CopilotKitCoreRuntimeConnectionStatus: {
311
+ Disconnected: "disconnected",
312
+ Connecting: "connecting",
313
+ Connected: "connected",
314
+ Error: "error",
315
+ },
316
+ ɵcreateThreadStore: () => new MockThreadStore(),
317
+ ɵselectThreads: select((state) => state.threads),
318
+ ɵselectThreadsIsLoading: select((state) => state.isLoading),
319
+ ɵselectThreadsError: select((state) => state.error),
320
+ ɵselectHasNextPage: select((state) => state.hasNextPage),
321
+ ɵselectIsFetchingNextPage: select((state) => state.isFetchingNextPage),
322
+ };
323
+ });
324
+
325
+ const fetchMock = vi.fn();
326
+ globalThis.fetch = fetchMock;
327
+
328
+ const { CopilotKitCoreRuntimeConnectionStatus } =
329
+ await import("@copilotkit/core");
330
+
331
+ function getMockSockets(): any[] {
332
+ return threadMocks.sockets;
333
+ }
334
+
335
+ function getDispatchedContexts(): Array<ThreadState["context"]> {
336
+ return threadMocks.dispatchedContexts;
337
+ }
338
+
339
+ function setupCopilotKit(
340
+ runtimeUrl: string | undefined = "http://localhost:4000",
341
+ runtimeConnectionStatus: CopilotKitCoreRuntimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Connected,
342
+ ) {
343
+ const copilotkit = ref<{
344
+ runtimeUrl: string | undefined;
345
+ runtimeConnectionStatus: CopilotKitCoreRuntimeConnectionStatus;
346
+ headers: Record<string, string>;
347
+ intelligence: { wsUrl?: string } | undefined;
348
+ }>({
349
+ runtimeUrl,
350
+ runtimeConnectionStatus,
351
+ headers: { Authorization: "Bearer test-token" },
352
+ intelligence: {
353
+ wsUrl: "ws://localhost:4000/client",
354
+ },
355
+ });
356
+ mockUseCopilotKit.mockReturnValue({ copilotkit });
357
+ return copilotkit;
358
+ }
359
+
360
+ function jsonResponse(body: unknown, status = 200) {
361
+ return Promise.resolve({
362
+ ok: status >= 200 && status < 300,
363
+ status,
364
+ json: () => Promise.resolve(body),
365
+ text: () => Promise.resolve(JSON.stringify(body)),
366
+ });
367
+ }
368
+
369
+ const defaultInput = { agentId: "agent-1" };
370
+
371
+ const sampleThreads = [
372
+ {
373
+ id: "t-1",
374
+ organizationId: "org-1",
375
+ agentId: "agent-1",
376
+ createdById: "user-1",
377
+ name: "Thread One",
378
+ archived: false,
379
+ createdAt: "2026-01-01T00:00:00Z",
380
+ updatedAt: "2026-01-01T00:00:00Z",
381
+ },
382
+ {
383
+ id: "t-2",
384
+ organizationId: "org-1",
385
+ agentId: "agent-1",
386
+ createdById: "user-1",
387
+ name: "Thread Two",
388
+ archived: false,
389
+ createdAt: "2026-01-02T00:00:00Z",
390
+ updatedAt: "2026-01-02T00:00:00Z",
391
+ },
392
+ ];
393
+
394
+ const { useThreads } = await import("../use-threads");
395
+ type UseThreadsResult = ReturnType<typeof useThreads>;
396
+
397
+ function mountHook(
398
+ input: {
399
+ agentId: string | Ref<string>;
400
+ includeArchived?: boolean | Ref<boolean | undefined>;
401
+ limit?: number | Ref<number | undefined>;
402
+ } = defaultInput,
403
+ ) {
404
+ let result: UseThreadsResult | undefined;
405
+
406
+ const Harness = defineComponent({
407
+ setup() {
408
+ result = useThreads(input);
409
+ return () => h("div");
410
+ },
411
+ });
412
+
413
+ const wrapper = mount(Harness);
414
+
415
+ return {
416
+ wrapper,
417
+ getResult: () => {
418
+ if (!result) {
419
+ throw new Error("useThreads result not initialized");
420
+ }
421
+ return result;
422
+ },
423
+ };
424
+ }
425
+
426
+ describe("useThreads", () => {
427
+ beforeEach(() => {
428
+ threadMocks.sockets.splice(0);
429
+ threadMocks.dispatchedContexts.splice(0);
430
+ fetchMock.mockReset();
431
+ setupCopilotKit();
432
+ });
433
+
434
+ it("fetches threads and subscribes to the user metadata channel", async () => {
435
+ fetchMock
436
+ .mockReturnValueOnce(
437
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
438
+ )
439
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
440
+
441
+ const { getResult } = mountHook();
442
+
443
+ await vi.waitFor(() => {
444
+ expect(getResult().isLoading.value).toBe(false);
445
+ });
446
+
447
+ expect(getResult().threads.value.map((thread) => thread.id)).toEqual([
448
+ "t-2",
449
+ "t-1",
450
+ ]);
451
+ expect(getResult().error.value).toBeNull();
452
+ expect(fetchMock).toHaveBeenCalledWith(
453
+ expect.stringContaining("/threads?agentId=agent-1"),
454
+ expect.objectContaining({ method: "GET" }),
455
+ );
456
+ expect(fetchMock).toHaveBeenCalledWith(
457
+ expect.stringContaining("/threads/subscribe"),
458
+ expect.objectContaining({ method: "POST" }),
459
+ );
460
+
461
+ const socket = getMockSockets()[0];
462
+ expect(socket.connected).toBe(true);
463
+ expect(socket.channels[0].topic).toBe("user_meta:jc-1");
464
+ });
465
+
466
+ it("stores fetch failures in error state", async () => {
467
+ fetchMock.mockReturnValue(jsonResponse({}, 500));
468
+
469
+ const { getResult } = mountHook();
470
+
471
+ await vi.waitFor(() => {
472
+ expect(getResult().isLoading.value).toBe(false);
473
+ });
474
+
475
+ expect(getResult().error.value?.message).toContain("500");
476
+ expect(getResult().threads.value).toEqual([]);
477
+ });
478
+
479
+ it("does not fetch when runtimeUrl is not configured", async () => {
480
+ setupCopilotKit("");
481
+
482
+ const { getResult } = mountHook();
483
+
484
+ await nextTick();
485
+
486
+ expect(fetchMock).not.toHaveBeenCalled();
487
+ expect(getResult().isLoading.value).toBe(false);
488
+ expect(getResult().error.value?.message).toBe(
489
+ "Runtime URL is not configured",
490
+ );
491
+ });
492
+
493
+ it("updates local state directly from realtime metadata events", async () => {
494
+ fetchMock
495
+ .mockReturnValueOnce(
496
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
497
+ )
498
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
499
+
500
+ const { getResult } = mountHook();
501
+
502
+ await vi.waitFor(() => {
503
+ expect(getResult().isLoading.value).toBe(false);
504
+ });
505
+
506
+ const channel = getMockSockets()[0].channels[0];
507
+ channel.serverPush("thread_metadata", {
508
+ operation: "updated",
509
+ threadId: "t-1",
510
+ userId: "user-1",
511
+ organizationId: "org-1",
512
+ occurredAt: "2026-01-03T00:00:00Z",
513
+ thread: {
514
+ ...sampleThreads[0],
515
+ name: "Renamed Thread",
516
+ updatedAt: "2026-01-03T00:00:00Z",
517
+ },
518
+ });
519
+
520
+ await vi.waitFor(() => {
521
+ expect(getResult().threads.value[0].name).toBe("Renamed Thread");
522
+ });
523
+ });
524
+
525
+ it("applies realtime metadata without client-side user filtering", async () => {
526
+ fetchMock
527
+ .mockReturnValueOnce(
528
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
529
+ )
530
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
531
+
532
+ const { getResult } = mountHook();
533
+
534
+ await vi.waitFor(() => {
535
+ expect(getResult().isLoading.value).toBe(false);
536
+ });
537
+
538
+ getMockSockets()[0].channels[0].serverPush("thread_metadata", {
539
+ operation: "deleted",
540
+ threadId: "t-2",
541
+ userId: "user-2",
542
+ organizationId: "org-1",
543
+ occurredAt: "2026-01-03T00:00:00Z",
544
+ deleted: { id: "t-2" },
545
+ });
546
+
547
+ await vi.waitFor(() => {
548
+ expect(getResult().threads.value).toHaveLength(1);
549
+ });
550
+ });
551
+
552
+ it("renames a thread through the runtime contract", async () => {
553
+ fetchMock
554
+ .mockReturnValueOnce(
555
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
556
+ )
557
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }))
558
+ .mockReturnValueOnce(jsonResponse({}));
559
+
560
+ const { getResult } = mountHook();
561
+
562
+ await vi.waitFor(() => {
563
+ expect(getResult().isLoading.value).toBe(false);
564
+ });
565
+
566
+ await getResult().renameThread("t-1", "Renamed");
567
+
568
+ const [url, options] = fetchMock.mock.calls[2];
569
+ expect(url).toContain("/threads/t-1");
570
+ expect(options.method).toBe("PATCH");
571
+ expect(JSON.parse(options.body)).toMatchObject({
572
+ agentId: "agent-1",
573
+ name: "Renamed",
574
+ });
575
+ });
576
+
577
+ it("archives and deletes threads through the runtime contract", async () => {
578
+ fetchMock
579
+ .mockReturnValueOnce(
580
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
581
+ )
582
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }))
583
+ .mockReturnValueOnce(jsonResponse({}))
584
+ .mockReturnValueOnce(jsonResponse({}));
585
+
586
+ const { getResult } = mountHook();
587
+
588
+ await vi.waitFor(() => {
589
+ expect(getResult().isLoading.value).toBe(false);
590
+ });
591
+
592
+ await getResult().archiveThread("t-2");
593
+ await getResult().deleteThread("t-1");
594
+
595
+ expect(fetchMock.mock.calls[2][0]).toContain("/threads/t-2/archive");
596
+ expect(fetchMock.mock.calls[2][1].method).toBe("POST");
597
+ expect(JSON.parse(fetchMock.mock.calls[2][1].body)).toMatchObject({
598
+ agentId: "agent-1",
599
+ });
600
+
601
+ expect(fetchMock.mock.calls[3][0]).toContain("/threads/t-1");
602
+ expect(fetchMock.mock.calls[3][1].method).toBe("DELETE");
603
+ expect(JSON.parse(fetchMock.mock.calls[3][1].body)).toMatchObject({
604
+ agentId: "agent-1",
605
+ });
606
+ });
607
+
608
+ it("exposes thread-scoped pagination properties", async () => {
609
+ fetchMock
610
+ .mockReturnValueOnce(
611
+ jsonResponse({
612
+ threads: sampleThreads,
613
+ joinCode: "jc-1",
614
+ nextCursor: "cursor-abc",
615
+ }),
616
+ )
617
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
618
+
619
+ const { getResult } = mountHook();
620
+
621
+ await vi.waitFor(() => {
622
+ expect(getResult().isLoading.value).toBe(false);
623
+ });
624
+
625
+ expect(getResult()).toHaveProperty("hasMoreThreads");
626
+ expect(getResult()).toHaveProperty("isFetchingMoreThreads");
627
+ expect(getResult()).toHaveProperty("fetchMoreThreads");
628
+ expect(getResult()).not.toHaveProperty("hasNextPage");
629
+ expect(getResult()).not.toHaveProperty("isFetchingNextPage");
630
+ expect(getResult()).not.toHaveProperty("fetchNextPage");
631
+
632
+ expect(getResult().hasMoreThreads.value).toBe(true);
633
+ expect(getResult().isFetchingMoreThreads.value).toBe(false);
634
+ expect(typeof getResult().fetchMoreThreads).toBe("function");
635
+ });
636
+
637
+ it("does not expose organizationId or createdById on threads", async () => {
638
+ fetchMock
639
+ .mockReturnValueOnce(
640
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
641
+ )
642
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
643
+
644
+ const { getResult } = mountHook();
645
+
646
+ await vi.waitFor(() => {
647
+ expect(getResult().isLoading.value).toBe(false);
648
+ });
649
+
650
+ for (const thread of getResult().threads.value) {
651
+ expect(thread).not.toHaveProperty("organizationId");
652
+ expect(thread).not.toHaveProperty("createdById");
653
+ expect(thread).toHaveProperty("id");
654
+ expect(thread).toHaveProperty("agentId");
655
+ expect(thread).toHaveProperty("name");
656
+ expect(thread).toHaveProperty("archived");
657
+ expect(thread).toHaveProperty("createdAt");
658
+ expect(thread).toHaveProperty("updatedAt");
659
+ }
660
+ });
661
+
662
+ it("tears down sockets after repeated connection failures", async () => {
663
+ fetchMock
664
+ .mockReturnValueOnce(
665
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
666
+ )
667
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
668
+
669
+ mountHook();
670
+
671
+ await vi.waitFor(() => {
672
+ expect(getMockSockets().length).toBe(1);
673
+ });
674
+
675
+ const socket = getMockSockets()[0];
676
+ const channel = socket.channels[0];
677
+
678
+ for (let index = 0; index < 5; index += 1) {
679
+ socket.triggerError();
680
+ }
681
+
682
+ expect(channel.left).toBe(true);
683
+ expect(socket.disconnected).toBe(true);
684
+ });
685
+
686
+ it("tears down the active socket on unmount", async () => {
687
+ fetchMock
688
+ .mockReturnValueOnce(
689
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
690
+ )
691
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
692
+
693
+ const { wrapper } = mountHook();
694
+
695
+ await vi.waitFor(() => {
696
+ expect(getMockSockets().length).toBe(1);
697
+ });
698
+
699
+ const socket = getMockSockets()[0];
700
+ const channel = socket.channels[0];
701
+
702
+ wrapper.unmount();
703
+
704
+ expect(channel.left).toBe(true);
705
+ expect(socket.disconnected).toBe(true);
706
+ });
707
+
708
+ describe("Vue-specific reactive semantics", () => {
709
+ it("reacts to reactive input changes", async () => {
710
+ const copilotkit = setupCopilotKit();
711
+ const agentId = ref("agent-1");
712
+
713
+ fetchMock
714
+ .mockReturnValueOnce(jsonResponse({ threads: sampleThreads }))
715
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }))
716
+ .mockReturnValueOnce(
717
+ jsonResponse({
718
+ threads: [
719
+ {
720
+ ...sampleThreads[0],
721
+ id: "t-3",
722
+ agentId: "agent-2",
723
+ createdById: "user-2",
724
+ },
725
+ ],
726
+ }),
727
+ )
728
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-2" }));
729
+
730
+ const { getResult } = mountHook({ agentId });
731
+
732
+ await vi.waitFor(() => {
733
+ expect(getResult().isLoading.value).toBe(false);
734
+ });
735
+
736
+ agentId.value = "agent-2";
737
+ copilotkit.value = {
738
+ ...copilotkit.value,
739
+ headers: { Authorization: "Bearer updated" },
740
+ };
741
+
742
+ await vi.waitFor(() => {
743
+ expect(fetchMock).toHaveBeenCalledWith(
744
+ expect.stringContaining("/threads?agentId=agent-2"),
745
+ expect.objectContaining({ method: "GET" }),
746
+ );
747
+ });
748
+
749
+ await vi.waitFor(() => {
750
+ expect(getResult().threads.value[0]?.id).toBe("t-3");
751
+ });
752
+ });
753
+
754
+ it("reacts to in-place header mutations", async () => {
755
+ const copilotkit = setupCopilotKit();
756
+
757
+ fetchMock
758
+ .mockReturnValueOnce(jsonResponse({ threads: sampleThreads }))
759
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }))
760
+ .mockReturnValueOnce(
761
+ jsonResponse({
762
+ threads: [
763
+ {
764
+ ...sampleThreads[0],
765
+ id: "t-4",
766
+ },
767
+ ],
768
+ }),
769
+ )
770
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-2" }));
771
+
772
+ const { getResult } = mountHook();
773
+
774
+ await vi.waitFor(() => {
775
+ expect(getResult().isLoading.value).toBe(false);
776
+ });
777
+
778
+ copilotkit.value.headers.Authorization = "Bearer mutated";
779
+
780
+ await vi.waitFor(() => {
781
+ expect(fetchMock).toHaveBeenCalledWith(
782
+ expect.stringContaining("/threads?agentId=agent-1"),
783
+ expect.objectContaining({
784
+ method: "GET",
785
+ headers: { Authorization: "Bearer mutated" },
786
+ }),
787
+ );
788
+ });
789
+
790
+ expect(getResult().threads.value[0].id).toBe("t-4");
791
+ });
792
+
793
+ it("reacts to includeArchived and limit changes", async () => {
794
+ const includeArchived = ref(false);
795
+ const limit = ref(10);
796
+
797
+ fetchMock
798
+ .mockReturnValueOnce(jsonResponse({ threads: sampleThreads }))
799
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }))
800
+ .mockReturnValueOnce(jsonResponse({ threads: sampleThreads }))
801
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-2" }));
802
+
803
+ mountHook({ agentId: "agent-1", includeArchived, limit });
804
+
805
+ await vi.waitFor(() => {
806
+ expect(fetchMock).toHaveBeenCalledWith(
807
+ expect.stringContaining(
808
+ "/threads?agentId=agent-1&includeArchived=false&limit=10",
809
+ ),
810
+ expect.objectContaining({ method: "GET" }),
811
+ );
812
+ });
813
+
814
+ includeArchived.value = true;
815
+ limit.value = 5;
816
+
817
+ await vi.waitFor(() => {
818
+ expect(fetchMock).toHaveBeenCalledWith(
819
+ expect.stringContaining(
820
+ "/threads?agentId=agent-1&includeArchived=true&limit=5",
821
+ ),
822
+ expect.objectContaining({ method: "GET" }),
823
+ );
824
+ });
825
+ });
826
+ });
827
+
828
+ describe("Connected-gate", () => {
829
+ it("waits for runtimeConnectionStatus=Connected before fetching /threads", async () => {
830
+ // Start in Connecting — hook should hold off on dispatching any request
831
+ // so the initial list fetch includes wsUrl and avoids a redundant second
832
+ // call once /info resolves.
833
+ const copilotkit = setupCopilotKit(
834
+ "http://localhost:4000",
835
+ CopilotKitCoreRuntimeConnectionStatus.Connecting,
836
+ );
837
+ copilotkit.value = {
838
+ ...copilotkit.value,
839
+ intelligence: undefined,
840
+ };
841
+
842
+ fetchMock
843
+ .mockReturnValueOnce(
844
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
845
+ )
846
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
847
+
848
+ const { getResult } = mountHook();
849
+
850
+ await new Promise((resolve) => setTimeout(resolve, 20));
851
+ expect(fetchMock).not.toHaveBeenCalled();
852
+
853
+ // While waiting for Connected, the hook must surface isLoading=true so
854
+ // consumers don't render an empty-state flash before the first fetch
855
+ // is even dispatched. The store's own isLoading is false at this
856
+ // point (no setContext call yet), so the hook synthesizes it.
857
+ expect(getResult().isLoading.value).toBe(true);
858
+ expect(getResult().threads.value).toEqual([]);
859
+
860
+ // Flip to Connected with wsUrl populated. The watcher now dispatches
861
+ // exactly one list fetch (+ one subscribe after it lands).
862
+ copilotkit.value = {
863
+ ...copilotkit.value,
864
+ runtimeConnectionStatus:
865
+ CopilotKitCoreRuntimeConnectionStatus.Connected,
866
+ intelligence: { wsUrl: "ws://localhost:4000/client" },
867
+ };
868
+
869
+ await vi.waitFor(() => {
870
+ expect(fetchMock).toHaveBeenCalledWith(
871
+ expect.stringContaining("/threads?agentId=agent-1"),
872
+ expect.objectContaining({ method: "GET" }),
873
+ );
874
+ });
875
+
876
+ const listCalls = fetchMock.mock.calls.filter(
877
+ ([url]) => typeof url === "string" && /\/threads\?agentId=/.test(url),
878
+ );
879
+ expect(listCalls).toHaveLength(1);
880
+
881
+ // The dispatched context must carry wsUrl, otherwise the store would
882
+ // re-fetch once /info eventually populates it.
883
+ const nonNullContexts = getDispatchedContexts().filter(
884
+ (context) => context !== null,
885
+ );
886
+ expect(nonNullContexts).toHaveLength(1);
887
+ expect(nonNullContexts[0]).toMatchObject({
888
+ runtimeUrl: "http://localhost:4000",
889
+ wsUrl: "ws://localhost:4000/client",
890
+ agentId: "agent-1",
891
+ });
892
+
893
+ await vi.waitFor(() => {
894
+ expect(getResult().isLoading.value).toBe(false);
895
+ });
896
+ });
897
+
898
+ it("does not re-dispatch context across transient Disconnected states", async () => {
899
+ const copilotkit = setupCopilotKit();
900
+
901
+ fetchMock
902
+ .mockReturnValueOnce(
903
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
904
+ )
905
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
906
+
907
+ const { getResult } = mountHook();
908
+
909
+ await vi.waitFor(() => {
910
+ expect(getResult().isLoading.value).toBe(false);
911
+ });
912
+
913
+ const baselineContexts = getDispatchedContexts().filter(
914
+ (context) => context !== null,
915
+ ).length;
916
+
917
+ copilotkit.value = {
918
+ ...copilotkit.value,
919
+ runtimeConnectionStatus:
920
+ CopilotKitCoreRuntimeConnectionStatus.Disconnected,
921
+ };
922
+
923
+ await new Promise((resolve) => setTimeout(resolve, 20));
924
+
925
+ const afterTransient = getDispatchedContexts().filter(
926
+ (context) => context !== null,
927
+ ).length;
928
+ expect(afterTransient).toBe(baselineContexts);
929
+ });
930
+
931
+ it("clears the store when runtimeUrl is removed even before Connected", async () => {
932
+ const copilotkit = setupCopilotKit();
933
+
934
+ fetchMock
935
+ .mockReturnValueOnce(
936
+ jsonResponse({ threads: sampleThreads, joinCode: "jc-1" }),
937
+ )
938
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
939
+
940
+ const { getResult } = mountHook();
941
+
942
+ await vi.waitFor(() => {
943
+ expect(getResult().isLoading.value).toBe(false);
944
+ });
945
+
946
+ copilotkit.value = {
947
+ ...copilotkit.value,
948
+ runtimeUrl: undefined,
949
+ };
950
+
951
+ await vi.waitFor(() => {
952
+ expect(getResult().error.value?.message).toBe(
953
+ "Runtime URL is not configured",
954
+ );
955
+ });
956
+
957
+ const lastDispatched = getDispatchedContexts().at(-1);
958
+ expect(lastDispatched).toBeNull();
959
+ });
960
+ });
961
+
962
+ describe("lastRunAt", () => {
963
+ it("exposes lastRunAt on threads when present", async () => {
964
+ const threadsWithLastRun = [
965
+ {
966
+ ...sampleThreads[0],
967
+ lastRunAt: "2026-02-01T00:00:00Z",
968
+ },
969
+ sampleThreads[1],
970
+ ];
971
+
972
+ fetchMock
973
+ .mockReturnValueOnce(
974
+ jsonResponse({ threads: threadsWithLastRun, joinCode: "jc-1" }),
975
+ )
976
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
977
+
978
+ const { getResult } = mountHook();
979
+
980
+ await vi.waitFor(() => {
981
+ expect(getResult().isLoading.value).toBe(false);
982
+ });
983
+
984
+ const byId = Object.fromEntries(
985
+ getResult().threads.value.map((thread) => [thread.id, thread]),
986
+ );
987
+ expect(byId["t-1"].lastRunAt).toBe("2026-02-01T00:00:00Z");
988
+ expect(byId["t-2"]).not.toHaveProperty("lastRunAt");
989
+ });
990
+
991
+ it("orders threads by lastRunAt with fallback to updatedAt then createdAt", async () => {
992
+ const mixed = [
993
+ {
994
+ ...sampleThreads[0],
995
+ id: "u-only",
996
+ lastRunAt: undefined,
997
+ createdAt: "2026-01-01T00:00:00Z",
998
+ updatedAt: "2026-01-05T00:00:00Z",
999
+ },
1000
+ {
1001
+ ...sampleThreads[0],
1002
+ id: "lr-new",
1003
+ createdAt: "2026-01-01T00:00:00Z",
1004
+ updatedAt: "2026-01-01T00:00:00Z",
1005
+ lastRunAt: "2026-02-01T00:00:00Z",
1006
+ },
1007
+ {
1008
+ ...sampleThreads[0],
1009
+ id: "lr-old",
1010
+ createdAt: "2026-01-01T00:00:00Z",
1011
+ updatedAt: "2026-01-10T00:00:00Z",
1012
+ lastRunAt: "2026-01-15T00:00:00Z",
1013
+ },
1014
+ {
1015
+ ...sampleThreads[0],
1016
+ id: "c-only",
1017
+ lastRunAt: undefined,
1018
+ createdAt: "2026-01-03T00:00:00Z",
1019
+ updatedAt: undefined as unknown as string,
1020
+ },
1021
+ ];
1022
+
1023
+ fetchMock
1024
+ .mockReturnValueOnce(jsonResponse({ threads: mixed, joinCode: "jc-1" }))
1025
+ .mockReturnValueOnce(jsonResponse({ joinToken: "jt-1" }));
1026
+
1027
+ const { getResult } = mountHook();
1028
+
1029
+ await vi.waitFor(() => {
1030
+ expect(getResult().isLoading.value).toBe(false);
1031
+ });
1032
+
1033
+ expect(getResult().threads.value.map((thread) => thread.id)).toEqual([
1034
+ "lr-new",
1035
+ "lr-old",
1036
+ "u-only",
1037
+ "c-only",
1038
+ ]);
1039
+ });
1040
+ });
1041
+ });