@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,1145 @@
1
+ import { render, screen, fireEvent } from "@testing-library/vue";
2
+ import { defineComponent } from "vue";
3
+ import { describe, it, expect, vi } from "vitest";
4
+ import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
5
+ import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
6
+ import CopilotChatView from "../CopilotChatView.vue";
7
+ import CopilotChatMessageView from "../CopilotChatMessageView.vue";
8
+ import CopilotChatInput from "../CopilotChatInput.vue";
9
+ import CopilotChatSuggestionView from "../CopilotChatSuggestionView.vue";
10
+ import CopilotChatAssistantMessage from "../CopilotChatAssistantMessage.vue";
11
+ import CopilotChatUserMessage from "../CopilotChatUserMessage.vue";
12
+
13
+ const sampleMessages = [
14
+ { id: "1", role: "user" as const, content: "Hello" },
15
+ { id: "2", role: "assistant" as const, content: "Hi there!" },
16
+ ];
17
+
18
+ const sampleSuggestions = [
19
+ { title: "Test", message: "Test message", isLoading: false },
20
+ { title: "Another", message: "Another message", isLoading: false },
21
+ ];
22
+
23
+ function renderInWrapper(component: ReturnType<typeof defineComponent>) {
24
+ const Host = defineComponent({
25
+ components: {
26
+ CopilotKitProvider,
27
+ CopilotChatConfigurationProvider,
28
+ UnderTest: component,
29
+ },
30
+ template: `
31
+ <CopilotKitProvider>
32
+ <CopilotChatConfigurationProvider thread-id="test-thread">
33
+ <div style="height: 400px;">
34
+ <UnderTest />
35
+ </div>
36
+ </CopilotChatConfigurationProvider>
37
+ </CopilotKitProvider>
38
+ `,
39
+ });
40
+
41
+ return render(Host);
42
+ }
43
+
44
+ describe("CopilotChatView Slot System E2E Tests", () => {
45
+ describe("1. Tailwind Class Slot Override", () => {
46
+ describe("messageView slot", () => {
47
+ it("should apply tailwind class string to messageView", () => {
48
+ const Host = defineComponent({
49
+ components: { CopilotChatView },
50
+ setup() {
51
+ return { sampleMessages };
52
+ },
53
+ template: `
54
+ <CopilotChatView :messages="sampleMessages">
55
+ <template #message-view="{ messages }">
56
+ <div data-testid="message-view" class="bg-red-500 text-white p-4">{{ messages.length }}</div>
57
+ </template>
58
+ </CopilotChatView>
59
+ `,
60
+ });
61
+
62
+ renderInWrapper(Host);
63
+ const messageView = screen.getByTestId("message-view");
64
+ expect(messageView.classList.contains("bg-red-500")).toBe(true);
65
+ expect(messageView.classList.contains("text-white")).toBe(true);
66
+ expect(messageView.classList.contains("p-4")).toBe(true);
67
+ });
68
+
69
+ it("should override default className with tailwind string", () => {
70
+ const Host = defineComponent({
71
+ components: { CopilotChatView },
72
+ setup() {
73
+ return { sampleMessages };
74
+ },
75
+ template: `
76
+ <CopilotChatView :messages="sampleMessages">
77
+ <template #message-view>
78
+ <div class="custom-override-class">override</div>
79
+ </template>
80
+ </CopilotChatView>
81
+ `,
82
+ });
83
+ const { container } = renderInWrapper(Host);
84
+ expect(container.querySelector(".custom-override-class")).toBeDefined();
85
+ });
86
+ });
87
+
88
+ describe("scrollView slot", () => {
89
+ it("should apply tailwind class string to scrollView", () => {
90
+ const Host = defineComponent({
91
+ components: { CopilotChatView },
92
+ setup() {
93
+ return { sampleMessages };
94
+ },
95
+ template: `
96
+ <CopilotChatView :messages="sampleMessages">
97
+ <template #scroll-view="{ messages }">
98
+ <div data-testid="scroll-view" class="overflow-y-auto bg-gray-100">{{ messages.length }}</div>
99
+ </template>
100
+ </CopilotChatView>
101
+ `,
102
+ });
103
+ renderInWrapper(Host);
104
+ const scrollView = screen.getByTestId("scroll-view");
105
+ expect(scrollView.classList.contains("overflow-y-auto")).toBe(true);
106
+ expect(scrollView.classList.contains("bg-gray-100")).toBe(true);
107
+ });
108
+ });
109
+
110
+ describe("scrollToBottomButton slot (nested under scrollView)", () => {
111
+ it("should apply tailwind class string to scrollToBottomButton via scrollView", () => {
112
+ const Host = defineComponent({
113
+ components: { CopilotChatView },
114
+ setup() {
115
+ return { sampleMessages };
116
+ },
117
+ template: `
118
+ <CopilotChatView :messages="sampleMessages">
119
+ <template #scroll-to-bottom-button="{ onClick }">
120
+ <button data-testid="scroll-bottom-btn" class="bg-blue-500 rounded-full" @click="onClick">down</button>
121
+ </template>
122
+ </CopilotChatView>
123
+ `,
124
+ });
125
+ renderInWrapper(Host);
126
+ const button = screen.queryByTestId("scroll-bottom-btn");
127
+ if (button) {
128
+ expect(button.classList.contains("rounded-full")).toBe(true);
129
+ }
130
+ });
131
+ });
132
+
133
+ describe("input slot", () => {
134
+ it("should apply tailwind class string to input", () => {
135
+ const Host = defineComponent({
136
+ components: { CopilotChatView, CopilotChatInput },
137
+ setup() {
138
+ return { sampleMessages };
139
+ },
140
+ template: `
141
+ <CopilotChatView :messages="sampleMessages">
142
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
143
+ <CopilotChatInput
144
+ data-testid="input-slot"
145
+ class="border-2 border-purple-500"
146
+ :model-value="modelValue"
147
+ @update:model-value="onUpdateModelValue"
148
+ @submit-message="onSubmitMessage"
149
+ />
150
+ </template>
151
+ </CopilotChatView>
152
+ `,
153
+ });
154
+ renderInWrapper(Host);
155
+ expect(
156
+ screen
157
+ .getByTestId("input-slot")
158
+ .classList.contains("border-purple-500"),
159
+ ).toBe(true);
160
+ });
161
+ });
162
+
163
+ describe("feather slot (via scrollView)", () => {
164
+ it("should apply tailwind class string to feather via scrollView", () => {
165
+ const Host = defineComponent({
166
+ components: { CopilotChatView },
167
+ setup() {
168
+ return { sampleMessages };
169
+ },
170
+ template: `
171
+ <CopilotChatView :messages="sampleMessages">
172
+ <template #feather>
173
+ <div data-testid="feather-slot" class="text-green-500 font-bold">feather</div>
174
+ </template>
175
+ </CopilotChatView>
176
+ `,
177
+ });
178
+ renderInWrapper(Host);
179
+ const feather = screen.getByTestId("feather-slot");
180
+ expect(feather.classList.contains("text-green-500")).toBe(true);
181
+ expect(feather.classList.contains("font-bold")).toBe(true);
182
+ });
183
+ });
184
+
185
+ describe("suggestionView slot", () => {
186
+ it("should apply tailwind class string to suggestionView", () => {
187
+ const Host = defineComponent({
188
+ components: { CopilotChatView, CopilotChatSuggestionView },
189
+ setup() {
190
+ return { sampleMessages, sampleSuggestions };
191
+ },
192
+ template: `
193
+ <CopilotChatView :messages="sampleMessages" :suggestions="sampleSuggestions">
194
+ <template #suggestion-view="{ suggestions, loadingIndexes, onSelectSuggestion }">
195
+ <CopilotChatSuggestionView
196
+ data-testid="suggestion-view"
197
+ class="flex gap-2 bg-indigo-50"
198
+ :suggestions="suggestions"
199
+ :loading-indexes="loadingIndexes"
200
+ @select-suggestion="(s, i) => onSelectSuggestion(s, i)"
201
+ />
202
+ </template>
203
+ </CopilotChatView>
204
+ `,
205
+ });
206
+ renderInWrapper(Host);
207
+ expect(
208
+ screen
209
+ .getByTestId("suggestion-view")
210
+ .classList.contains("bg-indigo-50"),
211
+ ).toBe(true);
212
+ });
213
+ });
214
+
215
+ describe("className vs tailwind string precedence", () => {
216
+ it("tailwind string should completely replace className (not merge)", () => {
217
+ const Host = defineComponent({
218
+ components: { CopilotChatView, CopilotChatInput },
219
+ setup() {
220
+ return { sampleMessages };
221
+ },
222
+ template: `
223
+ <CopilotChatView :messages="sampleMessages">
224
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
225
+ <CopilotChatInput class="only-this-class" :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage" />
226
+ </template>
227
+ </CopilotChatView>
228
+ `,
229
+ });
230
+ const { container } = renderInWrapper(Host);
231
+ expect(container.querySelector(".only-this-class")).toBeDefined();
232
+ });
233
+ });
234
+
235
+ describe("non-tailwind inline styles should still work", () => {
236
+ it("should accept style prop alongside className override", () => {
237
+ const Host = defineComponent({
238
+ components: { CopilotChatView, CopilotChatInput },
239
+ setup() {
240
+ return { sampleMessages };
241
+ },
242
+ template: `
243
+ <CopilotChatView :messages="sampleMessages">
244
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
245
+ <div data-testid="custom-input" style="background-color: rgb(255, 0, 0);">
246
+ <CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage" />
247
+ </div>
248
+ </template>
249
+ </CopilotChatView>
250
+ `,
251
+ });
252
+ renderInWrapper(Host);
253
+ const customInput = screen.getByTestId("custom-input");
254
+ expect(customInput.style.backgroundColor).toBe("rgb(255, 0, 0)");
255
+ });
256
+ });
257
+ });
258
+
259
+ describe("2. Properties Slot Override", () => {
260
+ describe("scrollToBottomButton props (nested under scrollView)", () => {
261
+ it("should pass onClick handler to scrollToBottomButton via scrollView", async () => {
262
+ const handleClick = vi.fn();
263
+ const Host = defineComponent({
264
+ components: { CopilotChatView },
265
+ setup() {
266
+ return { sampleMessages, handleClick };
267
+ },
268
+ template: `
269
+ <CopilotChatView :messages="sampleMessages">
270
+ <template #scroll-to-bottom-button="{ onClick }">
271
+ <button data-testid="scroll-button" @click="handleClick(); onClick()">scroll</button>
272
+ </template>
273
+ </CopilotChatView>
274
+ `,
275
+ });
276
+ renderInWrapper(Host);
277
+ const btn = screen.queryByTestId("scroll-button");
278
+ if (btn) {
279
+ await fireEvent.click(btn);
280
+ expect(handleClick).toHaveBeenCalled();
281
+ }
282
+ });
283
+
284
+ it("should pass disabled prop to scrollToBottomButton via scrollView", () => {
285
+ const Host = defineComponent({
286
+ components: { CopilotChatView },
287
+ setup() {
288
+ return { sampleMessages };
289
+ },
290
+ template: `
291
+ <CopilotChatView :messages="sampleMessages">
292
+ <template #scroll-to-bottom-button>
293
+ <button data-testid="scroll-button-disabled" disabled>scroll</button>
294
+ </template>
295
+ </CopilotChatView>
296
+ `,
297
+ });
298
+ renderInWrapper(Host);
299
+ const btn = screen.queryByTestId("scroll-button-disabled");
300
+ if (btn) {
301
+ expect(btn.hasAttribute("disabled")).toBe(true);
302
+ }
303
+ });
304
+ });
305
+
306
+ describe("input props", () => {
307
+ it("should pass onFocus handler to input", async () => {
308
+ const handleFocus = vi.fn();
309
+ const Host = defineComponent({
310
+ components: { CopilotChatView, CopilotChatInput },
311
+ setup() {
312
+ return { sampleMessages, handleFocus };
313
+ },
314
+ template: `
315
+ <CopilotChatView :messages="sampleMessages">
316
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
317
+ <CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
318
+ <template #text-area="{ value, onInput, onKeydown }">
319
+ <textarea data-testid="focus-input" :value="value" @focus="handleFocus" @input="onInput" @keydown="onKeydown" />
320
+ </template>
321
+ </CopilotChatInput>
322
+ </template>
323
+ </CopilotChatView>
324
+ `,
325
+ });
326
+ renderInWrapper(Host);
327
+ await fireEvent.focus(screen.getByTestId("focus-input"));
328
+ expect(handleFocus).toHaveBeenCalled();
329
+ });
330
+
331
+ it("should pass autoFocus prop to input", () => {
332
+ const Host = defineComponent({
333
+ components: { CopilotChatView, CopilotChatInput },
334
+ setup() {
335
+ return { sampleMessages };
336
+ },
337
+ template: `
338
+ <CopilotChatView :messages="sampleMessages">
339
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
340
+ <CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
341
+ <template #text-area="{ value, onInput, onKeydown }">
342
+ <textarea data-testid="autofocus-input" autofocus :value="value" @input="onInput" @keydown="onKeydown" />
343
+ </template>
344
+ </CopilotChatInput>
345
+ </template>
346
+ </CopilotChatView>
347
+ `,
348
+ });
349
+ renderInWrapper(Host);
350
+ expect(
351
+ screen.getByTestId("autofocus-input").hasAttribute("autofocus"),
352
+ ).toBe(true);
353
+ });
354
+ });
355
+
356
+ describe("messageView props", () => {
357
+ it("should pass isRunning prop to messageView", () => {
358
+ const Host = defineComponent({
359
+ components: { CopilotChatView },
360
+ setup() {
361
+ return { sampleMessages };
362
+ },
363
+ template: `
364
+ <CopilotChatView :messages="sampleMessages" :is-running="true">
365
+ <template #message-view="{ isRunning }">
366
+ <div data-testid="running-state">{{ isRunning ? "running" : "idle" }}</div>
367
+ </template>
368
+ </CopilotChatView>
369
+ `,
370
+ });
371
+ renderInWrapper(Host);
372
+ expect(screen.getByTestId("running-state").textContent).toBe("running");
373
+ });
374
+ });
375
+ });
376
+
377
+ describe("3. Custom Component Slot Override", () => {
378
+ describe("messageView custom component", () => {
379
+ it("should render custom messageView component", () => {
380
+ const Host = defineComponent({
381
+ components: { CopilotChatView },
382
+ setup() {
383
+ return { sampleMessages };
384
+ },
385
+ template: `
386
+ <CopilotChatView :messages="sampleMessages">
387
+ <template #message-view>
388
+ <div data-testid="custom-message-view">Custom message view component</div>
389
+ </template>
390
+ </CopilotChatView>
391
+ `,
392
+ });
393
+ renderInWrapper(Host);
394
+ expect(screen.getByTestId("custom-message-view")).toBeDefined();
395
+ });
396
+
397
+ it("custom messageView should receive all props including messages", () => {
398
+ const Host = defineComponent({
399
+ components: { CopilotChatView },
400
+ setup() {
401
+ return { sampleMessages };
402
+ },
403
+ template: `
404
+ <CopilotChatView :messages="sampleMessages">
405
+ <template #message-view="{ messages }">
406
+ <div data-testid="custom-message-count">{{ messages.length }}</div>
407
+ </template>
408
+ </CopilotChatView>
409
+ `,
410
+ });
411
+ renderInWrapper(Host);
412
+ expect(screen.getByTestId("custom-message-count").textContent).toBe(
413
+ "2",
414
+ );
415
+ });
416
+ });
417
+
418
+ describe("input custom component", () => {
419
+ it("should render custom input component", () => {
420
+ const Host = defineComponent({
421
+ components: { CopilotChatView },
422
+ setup() {
423
+ return { sampleMessages };
424
+ },
425
+ template: `
426
+ <CopilotChatView :messages="sampleMessages">
427
+ <template #input>
428
+ <div data-testid="custom-input-component">Custom input</div>
429
+ </template>
430
+ </CopilotChatView>
431
+ `,
432
+ });
433
+ renderInWrapper(Host);
434
+ expect(screen.getByTestId("custom-input-component")).toBeDefined();
435
+ });
436
+
437
+ it("custom input should receive onSubmitMessage callback", async () => {
438
+ const onSubmitMessage = vi.fn();
439
+ const Host = defineComponent({
440
+ components: { CopilotChatView },
441
+ setup() {
442
+ return { sampleMessages, onSubmitMessage };
443
+ },
444
+ template: `
445
+ <CopilotChatView :messages="sampleMessages" @submit-message="onSubmitMessage">
446
+ <template #input="{ onSubmitMessage }">
447
+ <button data-testid="custom-input-submit" @click="onSubmitMessage('hello')">Submit</button>
448
+ </template>
449
+ </CopilotChatView>
450
+ `,
451
+ });
452
+ renderInWrapper(Host);
453
+ await fireEvent.click(screen.getByTestId("custom-input-submit"));
454
+ expect(onSubmitMessage).toHaveBeenCalledWith("hello");
455
+ });
456
+ });
457
+
458
+ describe("scrollView custom component", () => {
459
+ it("should render custom scrollView component", () => {
460
+ const Host = defineComponent({
461
+ components: { CopilotChatView },
462
+ setup() {
463
+ return { sampleMessages };
464
+ },
465
+ template: `
466
+ <CopilotChatView :messages="sampleMessages">
467
+ <template #scroll-view>
468
+ <div data-testid="custom-scroll-view-component">Scroll view</div>
469
+ </template>
470
+ </CopilotChatView>
471
+ `,
472
+ });
473
+ renderInWrapper(Host);
474
+ expect(
475
+ screen.getByTestId("custom-scroll-view-component"),
476
+ ).toBeDefined();
477
+ });
478
+ });
479
+
480
+ describe("suggestionView custom component", () => {
481
+ it("should render custom suggestionView component", () => {
482
+ const Host = defineComponent({
483
+ components: { CopilotChatView },
484
+ setup() {
485
+ return { sampleMessages, sampleSuggestions };
486
+ },
487
+ template: `
488
+ <CopilotChatView :messages="sampleMessages" :suggestions="sampleSuggestions">
489
+ <template #suggestion-view>
490
+ <div data-testid="custom-suggestion-component">Suggestion view</div>
491
+ </template>
492
+ </CopilotChatView>
493
+ `,
494
+ });
495
+ renderInWrapper(Host);
496
+ expect(screen.getByTestId("custom-suggestion-component")).toBeDefined();
497
+ });
498
+ });
499
+
500
+ describe("feather custom component (via scrollView)", () => {
501
+ it("should render custom feather component via scrollView", () => {
502
+ const Host = defineComponent({
503
+ components: { CopilotChatView },
504
+ setup() {
505
+ return { sampleMessages };
506
+ },
507
+ template: `
508
+ <CopilotChatView :messages="sampleMessages">
509
+ <template #feather>
510
+ <div data-testid="custom-feather-component">Feather</div>
511
+ </template>
512
+ </CopilotChatView>
513
+ `,
514
+ });
515
+ renderInWrapper(Host);
516
+ expect(screen.getByTestId("custom-feather-component")).toBeDefined();
517
+ });
518
+ });
519
+
520
+ describe("scrollToBottomButton custom component (nested under scrollView)", () => {
521
+ it("should render custom scrollToBottomButton component via scrollView", () => {
522
+ const Host = defineComponent({
523
+ components: { CopilotChatView },
524
+ setup() {
525
+ return { sampleMessages };
526
+ },
527
+ template: `
528
+ <CopilotChatView :messages="sampleMessages">
529
+ <template #scroll-to-bottom-button>
530
+ <button data-testid="custom-scroll-bottom-component">Down</button>
531
+ </template>
532
+ </CopilotChatView>
533
+ `,
534
+ });
535
+ renderInWrapper(Host);
536
+ const button = screen.queryByTestId("custom-scroll-bottom-component");
537
+ if (button) {
538
+ expect(button.textContent).toBe("Down");
539
+ }
540
+ });
541
+ });
542
+ });
543
+
544
+ describe("4. Recursive Subcomponent Drill-Down", () => {
545
+ describe("messageView -> assistantMessage drill-down", () => {
546
+ it("should allow customizing assistantMessage within messageView", () => {
547
+ const Host = defineComponent({
548
+ components: {
549
+ CopilotChatView,
550
+ CopilotChatMessageView,
551
+ CopilotChatAssistantMessage,
552
+ },
553
+ setup() {
554
+ return { sampleMessages };
555
+ },
556
+ template: `
557
+ <CopilotChatView :messages="sampleMessages">
558
+ <template #message-view="{ messages, isRunning }">
559
+ <CopilotChatMessageView :messages="messages" :is-running="isRunning">
560
+ <template #assistant-message="{ message, messages, isRunning }">
561
+ <CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
562
+ <template #message-renderer="{ content }">
563
+ <div data-testid="assistant-custom">{{ content }}</div>
564
+ </template>
565
+ </CopilotChatAssistantMessage>
566
+ </template>
567
+ </CopilotChatMessageView>
568
+ </template>
569
+ </CopilotChatView>
570
+ `,
571
+ });
572
+ renderInWrapper(Host);
573
+ expect(screen.getByTestId("assistant-custom")).toBeDefined();
574
+ });
575
+ });
576
+
577
+ describe("messageView -> userMessage drill-down", () => {
578
+ it("should allow customizing userMessage within messageView", () => {
579
+ const Host = defineComponent({
580
+ components: {
581
+ CopilotChatView,
582
+ CopilotChatMessageView,
583
+ CopilotChatUserMessage,
584
+ },
585
+ setup() {
586
+ return { sampleMessages };
587
+ },
588
+ template: `
589
+ <CopilotChatView :messages="sampleMessages">
590
+ <template #message-view="{ messages, isRunning }">
591
+ <CopilotChatMessageView :messages="messages" :is-running="isRunning">
592
+ <template #user-message="{ message }">
593
+ <CopilotChatUserMessage :message="message">
594
+ <template #message-renderer="{ content }">
595
+ <div data-testid="user-custom">{{ content }}</div>
596
+ </template>
597
+ </CopilotChatUserMessage>
598
+ </template>
599
+ </CopilotChatMessageView>
600
+ </template>
601
+ </CopilotChatView>
602
+ `,
603
+ });
604
+ renderInWrapper(Host);
605
+ expect(screen.getByTestId("user-custom")).toBeDefined();
606
+ });
607
+ });
608
+
609
+ describe("messageView -> cursor drill-down", () => {
610
+ it("should allow customizing cursor within messageView", () => {
611
+ const Host = defineComponent({
612
+ components: { CopilotChatView, CopilotChatMessageView },
613
+ setup() {
614
+ return { sampleMessages };
615
+ },
616
+ template: `
617
+ <CopilotChatView :messages="sampleMessages" :is-running="true">
618
+ <template #message-view="{ messages, isRunning }">
619
+ <CopilotChatMessageView :messages="messages" :is-running="isRunning">
620
+ <template #cursor>
621
+ <div data-testid="custom-cursor">cursor</div>
622
+ </template>
623
+ </CopilotChatMessageView>
624
+ </template>
625
+ </CopilotChatView>
626
+ `,
627
+ });
628
+ renderInWrapper(Host);
629
+ expect(screen.getByTestId("custom-cursor")).toBeDefined();
630
+ });
631
+ });
632
+
633
+ describe("input -> textArea drill-down", () => {
634
+ it("should allow customizing textArea within input", () => {
635
+ const Host = defineComponent({
636
+ components: { CopilotChatView, CopilotChatInput },
637
+ setup() {
638
+ return { sampleMessages };
639
+ },
640
+ template: `
641
+ <CopilotChatView :messages="sampleMessages">
642
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
643
+ <CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
644
+ <template #text-area="{ value, onInput, onKeydown }">
645
+ <textarea data-testid="custom-text-area-drill" :value="value" @input="onInput" @keydown="onKeydown" />
646
+ </template>
647
+ </CopilotChatInput>
648
+ </template>
649
+ </CopilotChatView>
650
+ `,
651
+ });
652
+ renderInWrapper(Host);
653
+ expect(screen.getByTestId("custom-text-area-drill")).toBeDefined();
654
+ });
655
+ });
656
+
657
+ describe("input -> sendButton drill-down", () => {
658
+ it("should allow customizing sendButton within input", () => {
659
+ const Host = defineComponent({
660
+ components: { CopilotChatView, CopilotChatInput },
661
+ setup() {
662
+ return { sampleMessages };
663
+ },
664
+ template: `
665
+ <CopilotChatView :messages="sampleMessages">
666
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
667
+ <CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
668
+ <template #send-button="{ onClick }">
669
+ <button data-testid="custom-send-drill" @click="onClick">Send</button>
670
+ </template>
671
+ </CopilotChatInput>
672
+ </template>
673
+ </CopilotChatView>
674
+ `,
675
+ });
676
+ renderInWrapper(Host);
677
+ expect(screen.getByTestId("custom-send-drill")).toBeDefined();
678
+ });
679
+ });
680
+
681
+ describe("input -> addMenuButton drill-down", () => {
682
+ it("should allow customizing addMenuButton within input", () => {
683
+ const toolsMenu = [{ label: "Tool", action: vi.fn() }];
684
+ const Host = defineComponent({
685
+ components: { CopilotChatView, CopilotChatInput },
686
+ setup() {
687
+ return { sampleMessages, toolsMenu };
688
+ },
689
+ template: `
690
+ <CopilotChatView :messages="sampleMessages" :input-tools-menu="toolsMenu">
691
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage, inputToolsMenu }">
692
+ <CopilotChatInput :model-value="modelValue" :tools-menu="inputToolsMenu" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
693
+ <template #add-menu-button="{ toggleMenu }">
694
+ <button data-testid="custom-add-drill" @click="toggleMenu">Add</button>
695
+ </template>
696
+ </CopilotChatInput>
697
+ </template>
698
+ </CopilotChatView>
699
+ `,
700
+ });
701
+ renderInWrapper(Host);
702
+ expect(screen.getByTestId("custom-add-drill")).toBeDefined();
703
+ });
704
+ });
705
+
706
+ describe("suggestionView -> suggestion drill-down", () => {
707
+ it("should allow customizing suggestion pill within suggestionView", () => {
708
+ const Host = defineComponent({
709
+ components: { CopilotChatView, CopilotChatSuggestionView },
710
+ setup() {
711
+ return { sampleMessages, sampleSuggestions };
712
+ },
713
+ template: `
714
+ <CopilotChatView :messages="sampleMessages" :suggestions="sampleSuggestions">
715
+ <template #suggestion-view="{ suggestions, loadingIndexes }">
716
+ <CopilotChatSuggestionView :suggestions="suggestions" :loading-indexes="loadingIndexes">
717
+ <template #suggestion="{ suggestion, index }">
718
+ <button :data-testid="'custom-pill-' + index">{{ suggestion.title }}</button>
719
+ </template>
720
+ </CopilotChatSuggestionView>
721
+ </template>
722
+ </CopilotChatView>
723
+ `,
724
+ });
725
+ renderInWrapper(Host);
726
+ expect(screen.getByTestId("custom-pill-0")).toBeDefined();
727
+ });
728
+ });
729
+
730
+ describe("suggestionView -> container drill-down", () => {
731
+ it("should allow customizing container within suggestionView", () => {
732
+ const Host = defineComponent({
733
+ components: { CopilotChatView, CopilotChatSuggestionView },
734
+ setup() {
735
+ return { sampleMessages, sampleSuggestions };
736
+ },
737
+ template: `
738
+ <CopilotChatView :messages="sampleMessages" :suggestions="sampleSuggestions">
739
+ <template #suggestion-view="{ suggestions, loadingIndexes, onSelectSuggestion }">
740
+ <CopilotChatSuggestionView :suggestions="suggestions" :loading-indexes="loadingIndexes" @select-suggestion="(s, i) => onSelectSuggestion(s, i)">
741
+ <template #container="{ suggestions }">
742
+ <div data-testid="custom-suggestion-container">{{ suggestions.length }}</div>
743
+ </template>
744
+ </CopilotChatSuggestionView>
745
+ </template>
746
+ </CopilotChatView>
747
+ `,
748
+ });
749
+ renderInWrapper(Host);
750
+ expect(screen.getByTestId("custom-suggestion-container")).toBeDefined();
751
+ });
752
+ });
753
+
754
+ describe("multiple nested overrides simultaneously", () => {
755
+ it("should allow overriding multiple nested slots at once", () => {
756
+ const Host = defineComponent({
757
+ components: {
758
+ CopilotChatView,
759
+ CopilotChatMessageView,
760
+ CopilotChatAssistantMessage,
761
+ CopilotChatInput,
762
+ CopilotChatSuggestionView,
763
+ },
764
+ setup() {
765
+ return { sampleMessages, sampleSuggestions };
766
+ },
767
+ template: `
768
+ <CopilotChatView :messages="sampleMessages" :suggestions="sampleSuggestions">
769
+ <template #message-view="{ messages, isRunning }">
770
+ <CopilotChatMessageView :messages="messages" :is-running="isRunning">
771
+ <template #assistant-message="{ message, messages, isRunning }">
772
+ <CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
773
+ <template #message-renderer><div data-testid="multi-assistant">assistant</div></template>
774
+ </CopilotChatAssistantMessage>
775
+ </template>
776
+ </CopilotChatMessageView>
777
+ </template>
778
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
779
+ <CopilotChatInput :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage">
780
+ <template #send-button><button data-testid="multi-send">send</button></template>
781
+ </CopilotChatInput>
782
+ </template>
783
+ <template #suggestion-view="{ suggestions, loadingIndexes }">
784
+ <CopilotChatSuggestionView :suggestions="suggestions" :loading-indexes="loadingIndexes">
785
+ <template #suggestion="{ index }"><button :data-testid="'multi-pill-' + index">pill</button></template>
786
+ </CopilotChatSuggestionView>
787
+ </template>
788
+ </CopilotChatView>
789
+ `,
790
+ });
791
+ renderInWrapper(Host);
792
+ expect(screen.getByTestId("multi-assistant")).toBeDefined();
793
+ expect(screen.getByTestId("multi-send")).toBeDefined();
794
+ expect(screen.getByTestId("multi-pill-0")).toBeDefined();
795
+ });
796
+ });
797
+
798
+ describe("three-level deep nesting", () => {
799
+ it("should support messageView -> assistantMessage -> toolbar drill-down", () => {
800
+ const Host = defineComponent({
801
+ components: {
802
+ CopilotChatView,
803
+ CopilotChatMessageView,
804
+ CopilotChatAssistantMessage,
805
+ },
806
+ setup() {
807
+ return { sampleMessages };
808
+ },
809
+ template: `
810
+ <CopilotChatView :messages="sampleMessages">
811
+ <template #message-view="{ messages, isRunning }">
812
+ <CopilotChatMessageView :messages="messages" :is-running="isRunning">
813
+ <template #assistant-message="{ message, messages, isRunning }">
814
+ <CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
815
+ <template #toolbar><div data-testid="deep-toolbar">toolbar</div></template>
816
+ </CopilotChatAssistantMessage>
817
+ </template>
818
+ </CopilotChatMessageView>
819
+ </template>
820
+ </CopilotChatView>
821
+ `,
822
+ });
823
+ renderInWrapper(Host);
824
+ expect(screen.getByTestId("deep-toolbar")).toBeDefined();
825
+ });
826
+
827
+ it("should support messageView -> assistantMessage -> copyButton drill-down", () => {
828
+ const Host = defineComponent({
829
+ components: {
830
+ CopilotChatView,
831
+ CopilotChatMessageView,
832
+ CopilotChatAssistantMessage,
833
+ },
834
+ setup() {
835
+ return { sampleMessages };
836
+ },
837
+ template: `
838
+ <CopilotChatView :messages="sampleMessages">
839
+ <template #message-view="{ messages, isRunning }">
840
+ <CopilotChatMessageView :messages="messages" :is-running="isRunning">
841
+ <template #assistant-message="{ message, messages, isRunning }">
842
+ <CopilotChatAssistantMessage :message="message" :messages="messages" :is-running="isRunning">
843
+ <template #copy-button><button data-testid="deep-copy">copy</button></template>
844
+ </CopilotChatAssistantMessage>
845
+ </template>
846
+ </CopilotChatMessageView>
847
+ </template>
848
+ </CopilotChatView>
849
+ `,
850
+ });
851
+ renderInWrapper(Host);
852
+ expect(screen.getByTestId("deep-copy")).toBeDefined();
853
+ });
854
+
855
+ it("should support messageView -> userMessage -> editButton drill-down", () => {
856
+ const Host = defineComponent({
857
+ components: {
858
+ CopilotChatView,
859
+ CopilotChatMessageView,
860
+ CopilotChatUserMessage,
861
+ },
862
+ setup() {
863
+ return { sampleMessages };
864
+ },
865
+ template: `
866
+ <CopilotChatView :messages="sampleMessages">
867
+ <template #message-view="{ messages, isRunning }">
868
+ <CopilotChatMessageView :messages="messages" :is-running="isRunning">
869
+ <template #user-message="{ message }">
870
+ <CopilotChatUserMessage :message="message">
871
+ <template #edit-button>
872
+ <button data-testid="custom-edit-btn">✏️ Edit</button>
873
+ </template>
874
+ </CopilotChatUserMessage>
875
+ </template>
876
+ </CopilotChatMessageView>
877
+ </template>
878
+ </CopilotChatView>
879
+ `,
880
+ });
881
+ renderInWrapper(Host);
882
+ const editBtn = screen.queryByTestId("custom-edit-btn");
883
+ if (editBtn) {
884
+ expect(editBtn.textContent).toContain("Edit");
885
+ }
886
+ });
887
+ });
888
+ });
889
+
890
+ describe("5. className Override with Tailwind", () => {
891
+ describe("className prop override", () => {
892
+ it("should allow className prop in object slot to override defaults", () => {
893
+ const Host = defineComponent({
894
+ components: { CopilotChatView },
895
+ setup() {
896
+ return { sampleMessages };
897
+ },
898
+ template: `
899
+ <CopilotChatView :messages="sampleMessages">
900
+ <template #message-view>
901
+ <div class="class-override-a">A</div>
902
+ </template>
903
+ </CopilotChatView>
904
+ `,
905
+ });
906
+ const { container } = renderInWrapper(Host);
907
+ expect(container.querySelector(".class-override-a")).toBeDefined();
908
+ });
909
+
910
+ it("should merge className with other props in object slot", () => {
911
+ const Host = defineComponent({
912
+ components: { CopilotChatView },
913
+ setup() {
914
+ return { sampleMessages };
915
+ },
916
+ template: `
917
+ <CopilotChatView :messages="sampleMessages">
918
+ <template #message-view>
919
+ <div class="class-override-b" data-testid="class-override-b">B</div>
920
+ </template>
921
+ </CopilotChatView>
922
+ `,
923
+ });
924
+ renderInWrapper(Host);
925
+ expect(
926
+ screen
927
+ .getByTestId("class-override-b")
928
+ .classList.contains("class-override-b"),
929
+ ).toBe(true);
930
+ });
931
+ });
932
+
933
+ describe("string slot vs className prop equivalence", () => {
934
+ it("string slot should behave same as className prop", () => {
935
+ const Host = defineComponent({
936
+ components: { CopilotChatView, CopilotChatInput },
937
+ setup() {
938
+ return { sampleMessages };
939
+ },
940
+ template: `
941
+ <CopilotChatView :messages="sampleMessages">
942
+ <template #input="{ modelValue, onUpdateModelValue, onSubmitMessage }">
943
+ <CopilotChatInput class="equivalence-class" :model-value="modelValue" @update:model-value="onUpdateModelValue" @submit-message="onSubmitMessage" />
944
+ </template>
945
+ </CopilotChatView>
946
+ `,
947
+ });
948
+ const { container } = renderInWrapper(Host);
949
+ expect(container.querySelector(".equivalence-class")).toBeDefined();
950
+ });
951
+ });
952
+
953
+ describe("tailwind utility class merging", () => {
954
+ it("should properly apply tailwind utilities like flex, grid, etc.", () => {
955
+ const Host = defineComponent({
956
+ components: { CopilotChatView },
957
+ setup() {
958
+ return { sampleMessages };
959
+ },
960
+ template: `
961
+ <CopilotChatView :messages="sampleMessages">
962
+ <template #message-view>
963
+ <div class="flex grid gap-2">x</div>
964
+ </template>
965
+ </CopilotChatView>
966
+ `,
967
+ });
968
+ const { container } = renderInWrapper(Host);
969
+ expect(container.querySelector(".flex.grid.gap-2")).toBeDefined();
970
+ });
971
+
972
+ it("should apply responsive tailwind classes", () => {
973
+ const Host = defineComponent({
974
+ components: { CopilotChatView },
975
+ setup() {
976
+ return { sampleMessages };
977
+ },
978
+ template: `
979
+ <CopilotChatView :messages="sampleMessages">
980
+ <template #message-view>
981
+ <div class="sm:px-4 md:px-6">x</div>
982
+ </template>
983
+ </CopilotChatView>
984
+ `,
985
+ });
986
+ const { container } = renderInWrapper(Host);
987
+ expect(container.querySelector(".sm\\:px-4")).toBeDefined();
988
+ });
989
+
990
+ it("should apply dark mode tailwind classes", () => {
991
+ const Host = defineComponent({
992
+ components: { CopilotChatView },
993
+ setup() {
994
+ return { sampleMessages };
995
+ },
996
+ template: `
997
+ <CopilotChatView :messages="sampleMessages">
998
+ <template #message-view>
999
+ <div class="dark:bg-zinc-900">x</div>
1000
+ </template>
1001
+ </CopilotChatView>
1002
+ `,
1003
+ });
1004
+ const { container } = renderInWrapper(Host);
1005
+ expect(container.querySelector(".dark\\:bg-zinc-900")).toBeDefined();
1006
+ });
1007
+ });
1008
+
1009
+ describe("user className should override pre-set className", () => {
1010
+ it("object slot className should take precedence over defaults", () => {
1011
+ const Host = defineComponent({
1012
+ components: { CopilotChatView },
1013
+ setup() {
1014
+ return { sampleMessages };
1015
+ },
1016
+ template: `
1017
+ <CopilotChatView :messages="sampleMessages">
1018
+ <template #message-view>
1019
+ <div class="override-precedence">x</div>
1020
+ </template>
1021
+ </CopilotChatView>
1022
+ `,
1023
+ });
1024
+ const { container } = renderInWrapper(Host);
1025
+ expect(container.querySelector(".override-precedence")).toBeDefined();
1026
+ });
1027
+ });
1028
+ });
1029
+
1030
+ describe("6. Children Render Function (Composition Pattern)", () => {
1031
+ it("should support children render function for full control", () => {
1032
+ const Host = defineComponent({
1033
+ components: { CopilotChatView },
1034
+ setup() {
1035
+ return { sampleMessages };
1036
+ },
1037
+ template: `
1038
+ <CopilotChatView :messages="sampleMessages">
1039
+ <template #scroll-view="{ messages }">
1040
+ <div data-testid="full-control-view">count: {{ messages.length }}</div>
1041
+ </template>
1042
+ </CopilotChatView>
1043
+ `,
1044
+ });
1045
+ renderInWrapper(Host);
1046
+ expect(screen.getByTestId("full-control-view")).toBeDefined();
1047
+ });
1048
+
1049
+ it("children render function should receive all slot elements", () => {
1050
+ const Host = defineComponent({
1051
+ components: { CopilotChatView },
1052
+ setup() {
1053
+ return { sampleMessages, sampleSuggestions };
1054
+ },
1055
+ template: `
1056
+ <CopilotChatView :messages="sampleMessages" :suggestions="sampleSuggestions">
1057
+ <template #scroll-view="{ messages, suggestions, onSelectSuggestion, onScroll, scrollToBottom }">
1058
+ <div data-testid="slot-elements-check">
1059
+ {{ messages.length }}-{{ suggestions.length }}-{{ typeof onSelectSuggestion }}-{{ typeof onScroll }}-{{ typeof scrollToBottom }}
1060
+ </div>
1061
+ </template>
1062
+ </CopilotChatView>
1063
+ `,
1064
+ });
1065
+ renderInWrapper(Host);
1066
+ const text = screen.getByTestId("slot-elements-check").textContent ?? "";
1067
+ expect(text.includes("function")).toBe(true);
1068
+ });
1069
+ });
1070
+
1071
+ describe("mobile keyboard height integration", () => {
1072
+ it("forwards visualViewport-driven keyboardHeight into the input transform", async () => {
1073
+ const originalVisualViewport = window.visualViewport;
1074
+ const originalInnerHeight = window.innerHeight;
1075
+ const listeners = new Map<string, ((event: Event) => void)[]>();
1076
+ const mockVisualViewport = {
1077
+ height: 800,
1078
+ addEventListener: vi.fn(
1079
+ (type: string, listener: (event: Event) => void) => {
1080
+ const bucket = listeners.get(type) ?? [];
1081
+ bucket.push(listener);
1082
+ listeners.set(type, bucket);
1083
+ },
1084
+ ),
1085
+ removeEventListener: vi.fn(),
1086
+ };
1087
+
1088
+ Object.defineProperty(window, "visualViewport", {
1089
+ value: mockVisualViewport,
1090
+ writable: true,
1091
+ configurable: true,
1092
+ });
1093
+ Object.defineProperty(window, "innerHeight", {
1094
+ value: 800,
1095
+ writable: true,
1096
+ configurable: true,
1097
+ });
1098
+
1099
+ try {
1100
+ const Host = defineComponent({
1101
+ components: { CopilotChatView },
1102
+ setup() {
1103
+ return { sampleMessages };
1104
+ },
1105
+ template: `
1106
+ <CopilotChatView :messages="sampleMessages" />
1107
+ `,
1108
+ });
1109
+
1110
+ const { container } = renderInWrapper(Host);
1111
+
1112
+ // Simulate the on-screen keyboard opening (visual viewport shrinks
1113
+ // by 300px, well above the 150px isKeyboardOpen threshold).
1114
+ mockVisualViewport.height = 500;
1115
+ (listeners.get("resize") ?? []).forEach((listener) =>
1116
+ listener(new Event("resize")),
1117
+ );
1118
+ await new Promise((resolve) => setTimeout(resolve, 0));
1119
+
1120
+ const inputContainer = container.querySelector(
1121
+ "[data-testid='copilot-input-overlay']",
1122
+ ) as HTMLElement | null;
1123
+ expect(inputContainer).not.toBeNull();
1124
+ // The input's absolute positioning wrapper inside the chat view
1125
+ // should now carry the `translateY(-300px)` transform driven by
1126
+ // useKeyboardHeight via effectiveKeyboardHeight.
1127
+ const translatedWrapper = inputContainer!.querySelector(
1128
+ '[style*="translateY(-300px)"]',
1129
+ );
1130
+ expect(translatedWrapper).not.toBeNull();
1131
+ } finally {
1132
+ Object.defineProperty(window, "visualViewport", {
1133
+ value: originalVisualViewport,
1134
+ writable: true,
1135
+ configurable: true,
1136
+ });
1137
+ Object.defineProperty(window, "innerHeight", {
1138
+ value: originalInnerHeight,
1139
+ writable: true,
1140
+ configurable: true,
1141
+ });
1142
+ }
1143
+ });
1144
+ });
1145
+ });