@copilotkit/vue 2.0.0-rc.2 → 2.0.0-rc.21

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 (335) hide show
  1. package/PARITY.md +3 -3
  2. package/dist/hooks/use-copilot-action.d.ts.map +1 -1
  3. package/dist/hooks/use-frontend-tool.d.ts +1 -1
  4. package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
  5. package/dist/hooks/zod-parameters.d.ts +14 -0
  6. package/dist/hooks/zod-parameters.d.ts.map +1 -0
  7. package/dist/index.cjs +1 -73
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.mjs +365 -16920
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/use-render-activity-message-BAhbpSDh.js +16200 -0
  12. package/dist/use-render-activity-message-BAhbpSDh.js.map +1 -0
  13. package/dist/use-render-activity-message-DJ6q1qHV.cjs +114 -0
  14. package/dist/use-render-activity-message-DJ6q1qHV.cjs.map +1 -0
  15. package/dist/v2/components/A2UIMessageRenderer.d.ts +14 -0
  16. package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
  17. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +10 -3
  18. package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
  19. package/dist/v2/components/CopilotKitInspector.vue.d.ts +5 -1
  20. package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -1
  21. package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -1
  22. package/dist/v2/components/LicenseWarningBanner.vue.d.ts +2 -2
  23. package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
  24. package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -1
  25. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -59
  26. package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
  27. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +0 -5
  28. package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
  29. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +10 -15
  30. package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
  31. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +14 -130
  32. package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -1
  33. package/dist/v2/components/a2ui/catalog.d.ts.map +1 -1
  34. package/dist/v2/components/a2ui/utils.d.ts +3 -15
  35. package/dist/v2/components/a2ui/utils.d.ts.map +1 -1
  36. package/dist/v2/components/a2ui.d.ts +9 -8
  37. package/dist/v2/components/a2ui.d.ts.map +1 -1
  38. package/dist/v2/components/chat/CopilotChat.vue.d.ts +2 -2
  39. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
  40. package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
  41. package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
  42. package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
  43. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +4 -8
  44. package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
  45. package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +1 -1
  46. package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -1
  47. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +6 -270
  48. package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
  49. package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -1
  50. package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -1
  51. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +1 -1
  52. package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
  53. package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
  54. package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +1 -1
  55. package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -1
  56. package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
  57. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +1 -1
  58. package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
  59. package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
  60. package/dist/v2/components/chat/CopilotChatView.vue.d.ts +3 -3
  61. package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
  62. package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -1
  63. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
  64. package/dist/v2/components/chat/CopilotPopup.vue.d.ts +8 -3
  65. package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
  66. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +5 -3
  67. package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
  68. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +5 -3
  69. package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
  70. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +8 -3
  71. package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
  72. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +6 -4
  73. package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
  74. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +6 -4
  75. package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
  76. package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -1
  77. package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts +1 -0
  78. package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
  79. package/dist/v2/components/chat/audioRecorder.d.ts +3 -4
  80. package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -1
  81. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +3 -3
  82. package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
  83. package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
  84. package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
  85. package/dist/v2/components/chat/index.d.ts +34 -31
  86. package/dist/v2/components/chat/index.d.ts.map +1 -1
  87. package/dist/v2/components/chat/inspector-shortcuts.d.ts +2 -1
  88. package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -1
  89. package/dist/v2/components/chat/message-feedback.d.ts +18 -49
  90. package/dist/v2/components/chat/message-feedback.d.ts.map +1 -1
  91. package/dist/v2/components/chat/tool-call-display-context.d.ts +4 -19
  92. package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -1
  93. package/dist/v2/components/chat/tool-call-group-parts.d.ts +7 -20
  94. package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -1
  95. package/dist/v2/components/chat/turn-work.d.ts +0 -2
  96. package/dist/v2/components/chat/turn-work.d.ts.map +1 -1
  97. package/dist/v2/components/chat/types.d.ts +9 -4
  98. package/dist/v2/components/chat/types.d.ts.map +1 -1
  99. package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
  100. package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
  101. package/dist/v2/components/chat/use-copy-feedback.d.ts +11 -0
  102. package/dist/v2/components/chat/use-copy-feedback.d.ts.map +1 -0
  103. package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -1
  104. package/dist/v2/components/icons/index.d.ts +968 -1
  105. package/dist/v2/components/icons/index.d.ts.map +1 -1
  106. package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +1 -1
  107. package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -1
  108. package/dist/v2/hooks/use-agent-context.d.ts +2 -3
  109. package/dist/v2/hooks/use-agent-context.d.ts.map +1 -1
  110. package/dist/v2/hooks/use-agent.d.ts +4 -1
  111. package/dist/v2/hooks/use-agent.d.ts.map +1 -1
  112. package/dist/v2/hooks/use-attachments.d.ts +7 -0
  113. package/dist/v2/hooks/use-attachments.d.ts.map +1 -1
  114. package/dist/v2/hooks/use-capabilities.d.ts.map +1 -1
  115. package/dist/v2/hooks/use-component.d.ts +1 -0
  116. package/dist/v2/hooks/use-component.d.ts.map +1 -1
  117. package/dist/v2/hooks/use-configure-suggestions.d.ts +4 -9
  118. package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -1
  119. package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
  120. package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
  121. package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
  122. package/dist/v2/hooks/use-human-in-the-loop.d.ts +2 -1
  123. package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -1
  124. package/dist/v2/hooks/use-interrupt.d.ts +0 -1
  125. package/dist/v2/hooks/use-interrupt.d.ts.map +1 -1
  126. package/dist/v2/hooks/use-keyboard-height.d.ts +1 -1
  127. package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -1
  128. package/dist/v2/hooks/use-pin-to-send.d.ts +4 -12
  129. package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -1
  130. package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
  131. package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
  132. package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
  133. package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
  134. package/dist/v2/hooks/use-suggestions.d.ts.map +1 -1
  135. package/dist/v2/hooks/use-threads.d.ts +0 -8
  136. package/dist/v2/hooks/use-threads.d.ts.map +1 -1
  137. package/dist/v2/index.cjs +1 -1
  138. package/dist/v2/index.mjs +197 -200
  139. package/dist/v2/index.mjs.map +1 -1
  140. package/dist/v2/lib/processPartialHtml.d.ts +1 -2
  141. package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
  142. package/dist/v2/lib/shallow-stable.d.ts.map +1 -1
  143. package/dist/v2/lib/vue-core.d.ts +12 -12
  144. package/dist/v2/lib/vue-core.d.ts.map +1 -1
  145. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
  146. package/dist/v2/providers/CopilotKitProvider.types.d.ts +9 -129
  147. package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
  148. package/dist/v2/providers/CopilotKitProvider.vue.d.ts +9 -10
  149. package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
  150. package/dist/v2/providers/chat-configuration-store-key.d.ts +8 -0
  151. package/dist/v2/providers/chat-configuration-store-key.d.ts.map +1 -0
  152. package/dist/v2/providers/markdown-renderer.d.ts +4 -2
  153. package/dist/v2/providers/markdown-renderer.d.ts.map +1 -1
  154. package/dist/v2/providers/types.d.ts +3 -46
  155. package/dist/v2/providers/types.d.ts.map +1 -1
  156. package/dist/v2/providers/use-inspector-thread-override.d.ts +5 -0
  157. package/dist/v2/providers/use-inspector-thread-override.d.ts.map +1 -1
  158. package/dist/v2/types/human-in-the-loop.d.ts +8 -29
  159. package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
  160. package/dist/v2/types/interrupt.d.ts +1 -22
  161. package/dist/v2/types/interrupt.d.ts.map +1 -1
  162. package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
  163. package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
  164. package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
  165. package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
  166. package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -35
  167. package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
  168. package/package.json +10 -11
  169. package/src/__tests__/build-entries.test.ts +27 -0
  170. package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
  171. package/src/hooks/use-copilot-action.ts +2 -1
  172. package/src/hooks/use-frontend-tool.ts +3 -6
  173. package/src/hooks/zod-parameters.ts +162 -0
  174. package/src/v2/__tests__/exports.test.ts +10 -0
  175. package/src/v2/__tests__/mocks/web-inspector.ts +6 -0
  176. package/src/v2/__tests__/utils/test-helpers.ts +34 -4
  177. package/src/v2/components/A2UIMessageRenderer.ts +98 -68
  178. package/src/v2/components/A2UISurfaceActivityRenderer.vue +68 -103
  179. package/src/v2/components/CopilotKitInspector.vue +104 -51
  180. package/src/v2/components/InlineFeatureWarning.vue +20 -21
  181. package/src/v2/components/LicenseWarningBanner.vue +27 -135
  182. package/src/v2/components/MCPAppsActivityRenderer.ts +75 -201
  183. package/src/v2/components/OpenGenerativeUIRenderer.ts +122 -446
  184. package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +171 -8
  185. package/src/v2/components/__tests__/CopilotKitInspector.test.ts +42 -0
  186. package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +60 -0
  187. package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +64 -8
  188. package/src/v2/components/__tests__/OpenGenerativeUIToolRenderer.test.ts +38 -0
  189. package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +2 -7
  190. package/src/v2/components/a2ui/A2UICatalogContext.ts +27 -185
  191. package/src/v2/components/a2ui/A2UIRecoveryStates.ts +127 -327
  192. package/src/v2/components/a2ui/catalog.ts +3 -3
  193. package/src/v2/components/a2ui/utils.ts +13 -65
  194. package/src/v2/components/a2ui.ts +15 -22
  195. package/src/v2/components/chat/CopilotChat.vue +147 -356
  196. package/src/v2/components/chat/CopilotChatAssistantMessage.vue +19 -43
  197. package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +36 -55
  198. package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +14 -6
  199. package/src/v2/components/chat/CopilotChatAudioRecorder.vue +19 -246
  200. package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +2 -2
  201. package/src/v2/components/chat/CopilotChatInput.vue +108 -436
  202. package/src/v2/components/chat/CopilotChatInspectorButton.vue +45 -108
  203. package/src/v2/components/chat/CopilotChatLightbox.vue +10 -31
  204. package/src/v2/components/chat/CopilotChatMessageView.vue +82 -210
  205. package/src/v2/components/chat/CopilotChatReasoningMessage.vue +7 -15
  206. package/src/v2/components/chat/CopilotChatToolCallGroup.vue +63 -71
  207. package/src/v2/components/chat/CopilotChatToolCallItem.vue +8 -6
  208. package/src/v2/components/chat/CopilotChatToolCallsView.vue +31 -32
  209. package/src/v2/components/chat/CopilotChatUserMessage.vue +24 -112
  210. package/src/v2/components/chat/CopilotChatView.vue +33 -28
  211. package/src/v2/components/chat/CopilotChatWorkSummary.vue +26 -36
  212. package/src/v2/components/chat/CopilotModalHeader.vue +11 -23
  213. package/src/v2/components/chat/CopilotPopup.vue +23 -25
  214. package/src/v2/components/chat/CopilotPopupView.vue +10 -39
  215. package/src/v2/components/chat/CopilotPopupViewInternal.vue +35 -131
  216. package/src/v2/components/chat/CopilotSidebar.vue +23 -25
  217. package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
  218. package/src/v2/components/chat/CopilotSidebarViewInternal.vue +38 -59
  219. package/src/v2/components/chat/CopilotThreadsDrawer.vue +37 -102
  220. package/src/v2/components/chat/StreamingMarkdownDefault.vue +15 -28
  221. package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
  222. package/src/v2/components/chat/__tests__/CopilotChat.test.ts +12 -10
  223. package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
  224. package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +5 -5
  225. package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +28 -0
  226. package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +89 -1
  227. package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
  228. package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +1 -99
  229. package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
  230. package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +19 -0
  231. package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
  232. package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +32 -8
  233. package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +2 -1
  234. package/src/v2/components/chat/__tests__/StreamingMarkdownDefault.test.ts +54 -0
  235. package/src/v2/components/chat/audioRecorder.ts +4 -7
  236. package/src/v2/components/chat/copilotChatToolCallItemRender.ts +24 -89
  237. package/src/v2/components/chat/forwarded-slots.ts +17 -0
  238. package/src/v2/components/chat/index.ts +0 -1
  239. package/src/v2/components/chat/inspector-shortcuts.ts +10 -16
  240. package/src/v2/components/chat/message-feedback.ts +62 -197
  241. package/src/v2/components/chat/tool-call-display-context.ts +6 -22
  242. package/src/v2/components/chat/tool-call-group-parts.ts +47 -108
  243. package/src/v2/components/chat/turn-work.ts +0 -9
  244. package/src/v2/components/chat/types.ts +12 -4
  245. package/src/v2/components/chat/use-chat-labels.ts +16 -0
  246. package/src/v2/components/chat/use-copy-feedback.ts +21 -0
  247. package/src/v2/components/chat/use-lightbox.ts +15 -33
  248. package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
  249. package/src/v2/components/icons/index.ts +109 -27
  250. package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +5 -3
  251. package/src/v2/hooks/__tests__/use-agent-stability.test.ts +25 -4
  252. package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +5 -1
  253. package/src/v2/hooks/__tests__/use-agent.test.ts +6 -3
  254. package/src/v2/hooks/__tests__/use-component.test.ts +21 -0
  255. package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +30 -1
  256. package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +10 -10
  257. package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +66 -1
  258. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +6 -1
  259. package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +187 -12
  260. package/src/v2/hooks/__tests__/use-interrupt.test.ts +97 -0
  261. package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +106 -0
  262. package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
  263. package/src/v2/hooks/__tests__/use-threads.test.ts +48 -6
  264. package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
  265. package/src/v2/hooks/use-agent-context.ts +4 -10
  266. package/src/v2/hooks/use-agent.ts +86 -290
  267. package/src/v2/hooks/use-attachments.ts +48 -168
  268. package/src/v2/hooks/use-capabilities.ts +2 -7
  269. package/src/v2/hooks/use-component.ts +7 -4
  270. package/src/v2/hooks/use-configure-suggestions.ts +28 -218
  271. package/src/v2/hooks/use-default-render-tool.ts +34 -94
  272. package/src/v2/hooks/use-frontend-tool.ts +10 -10
  273. package/src/v2/hooks/use-human-in-the-loop.ts +11 -80
  274. package/src/v2/hooks/use-interrupt.ts +29 -308
  275. package/src/v2/hooks/use-keyboard-height.ts +17 -40
  276. package/src/v2/hooks/use-pin-to-send.ts +15 -99
  277. package/src/v2/hooks/use-render-activity-message.ts +31 -55
  278. package/src/v2/hooks/use-render-custom-messages.ts +24 -88
  279. package/src/v2/hooks/use-suggestions.ts +9 -33
  280. package/src/v2/hooks/use-threads.ts +43 -273
  281. package/src/v2/lib/__tests__/shallow-stable.test.ts +54 -0
  282. package/src/v2/lib/__tests__/vue-core-renderers.test.ts +42 -0
  283. package/src/v2/lib/processPartialHtml.ts +6 -21
  284. package/src/v2/lib/shallow-stable.ts +2 -16
  285. package/src/v2/lib/vue-core.ts +69 -78
  286. package/src/v2/providers/CopilotChatConfigurationProvider.vue +48 -186
  287. package/src/v2/providers/CopilotKitProvider.types.ts +12 -132
  288. package/src/v2/providers/CopilotKitProvider.vue +237 -510
  289. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +22 -2
  290. package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +20 -2
  291. package/src/v2/providers/__tests__/CopilotKitProvider.config.test.ts +124 -0
  292. package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
  293. package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +3 -1
  294. package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +4 -1
  295. package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +53 -26
  296. package/src/v2/providers/chat-configuration-store-key.ts +9 -0
  297. package/src/v2/providers/markdown-renderer.ts +8 -2
  298. package/src/v2/providers/types.ts +3 -49
  299. package/src/v2/providers/use-inspector-thread-override.ts +22 -80
  300. package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
  301. package/src/v2/types/defineToolCallRenderer.ts +5 -4
  302. package/src/v2/types/human-in-the-loop.ts +8 -32
  303. package/src/v2/types/interrupt.ts +7 -31
  304. package/src/v2/types/vue-activity-message-renderer.ts +24 -15
  305. package/src/v2/types/vue-custom-message-renderer.ts +12 -16
  306. package/src/v2/types/vue-tool-call-renderer.ts +23 -38
  307. package/tsconfig.json +0 -1
  308. package/vite.config.ts +8 -5
  309. package/vitest.config.ts +12 -7
  310. package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
  311. package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
  312. package/dist/v2/components/chat/normalize-auto-scroll.d.ts +0 -3
  313. package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +0 -1
  314. package/dist/v2/components/chat/tool-call-layout.d.ts +0 -115
  315. package/dist/v2/components/chat/tool-call-layout.d.ts.map +0 -1
  316. package/dist/v2/lib/is-mobile-viewport.d.ts +0 -15
  317. package/dist/v2/lib/is-mobile-viewport.d.ts.map +0 -1
  318. package/dist/v2/lib/message-feedback.d.ts +0 -33
  319. package/dist/v2/lib/message-feedback.d.ts.map +0 -1
  320. package/dist/v2/lib/transcription-client.d.ts +0 -19
  321. package/dist/v2/lib/transcription-client.d.ts.map +0 -1
  322. package/src/v2/components/__tests__/A2UICatalogContext.test.ts +0 -63
  323. package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +0 -175
  324. package/src/v2/components/chat/BasicMarkdown.vue +0 -160
  325. package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
  326. package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +0 -39
  327. package/src/v2/components/chat/normalize-auto-scroll.ts +0 -17
  328. package/src/v2/components/chat/tool-call-layout.ts +0 -304
  329. package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +0 -48
  330. package/src/v2/lib/__tests__/message-feedback.test.ts +0 -152
  331. package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
  332. package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
  333. package/src/v2/lib/is-mobile-viewport.ts +0 -23
  334. package/src/v2/lib/message-feedback.ts +0 -120
  335. package/src/v2/lib/transcription-client.ts +0 -151
@@ -5,11 +5,20 @@ import {
5
5
  onBeforeUnmount,
6
6
  onMounted,
7
7
  ref,
8
+ shallowRef,
8
9
  useAttrs,
9
10
  watch,
10
11
  } from "vue";
11
- import { useCopilotChatConfiguration } from "../../providers/useCopilotChatConfiguration";
12
- import { CopilotChatDefaultLabels } from "../../providers/types";
12
+ import {
13
+ ɵclampSlashIndex,
14
+ ɵcomposerButtonState,
15
+ ɵcreateComposerAutosize,
16
+ ɵfilterCommands,
17
+ ɵflattenCommandItems,
18
+ ɵparseSlashQuery,
19
+ ɵresolveComposerKey,
20
+ ɵresolveSlashKey,
21
+ } from "@copilotkit/core";
13
22
  import {
14
23
  IconArrowUp,
15
24
  IconCheck,
@@ -29,6 +38,7 @@ import type {
29
38
  import { useCopilotId } from "../ui/use-id";
30
39
  import type { CopilotChatAudioRecorderRef } from "./audioRecorder";
31
40
  import type { CopilotChatInputMode, ToolsMenuItem } from "./types";
41
+ import { useChatLabels } from "./use-chat-labels";
32
42
 
33
43
  defineOptions({ inheritAttrs: false });
34
44
 
@@ -107,7 +117,6 @@ const emit = defineEmits<{
107
117
  }>();
108
118
 
109
119
  const attrs = useAttrs();
110
- const config = useCopilotChatConfiguration();
111
120
  const shellRef = ref<HTMLElement | null>(null);
112
121
  const textareaRef = ref<HTMLTextAreaElement | null>(null);
113
122
  const gridRef = ref<HTMLElement | null>(null);
@@ -117,7 +126,20 @@ const slashMenuRef = ref<HTMLElement | null>(null);
117
126
  const audioRecorderRef = ref<CopilotChatAudioRecorderRef | null>(null);
118
127
  const localValue = ref(props.modelValue ?? "");
119
128
  const isComposing = ref(false);
120
- const layout = ref<"compact" | "expanded">("compact");
129
+ // Sizes the text box and picks the compact or expanded layout.
130
+ const autosize = ɵcreateComposerAutosize({
131
+ getElements: () => ({
132
+ textarea: textareaRef.value,
133
+ grid: gridRef.value,
134
+ start: addButtonContainerRef.value,
135
+ actions: actionsContainerRef.value,
136
+ }),
137
+ maxRows: props.maxRows,
138
+ });
139
+ const layout = shallowRef(autosize.getSnapshot());
140
+ autosize.subscribe(() => {
141
+ layout.value = autosize.getSnapshot();
142
+ });
121
143
  const commandQuery = ref<string | null>(null);
122
144
  const slashHighlightIndex = ref(0);
123
145
  const previousCommandQuery = ref<string | null>(null);
@@ -128,36 +150,18 @@ const addMenuInitialFocus = ref<"first" | "last" | "content">("content");
128
150
  const addMenuAnchor = ref<HTMLElement | null>(null);
129
151
  const addMenuId = useCopilotId("cpk-add-menu");
130
152
  const addMenuTriggerId = `${addMenuId}-trigger`;
131
- const measurements = ref({
132
- singleLineHeight: 0,
133
- maxHeight: 0,
134
- paddingLeft: 0,
135
- paddingRight: 0,
136
- });
137
- const resizeEvaluationRafRef = ref<number | null>(null);
138
- const ignoreResizeRef = ref(false);
139
- const measurementCanvasRef = ref<HTMLCanvasElement | null>(null);
140
- const containerCacheRef = ref<{
141
- compactWidth: number;
142
- } | null>(null);
143
- const didWarnMissingFontRef = ref(false);
144
- const didWarnMissingCanvasContextRef = ref(false);
145
- let resizeObserver: ResizeObserver | null = null;
146
153
 
147
154
  const isControlled = computed(() => props.modelValue !== undefined);
148
155
  const inputValue = computed(() =>
149
156
  isControlled.value ? (props.modelValue ?? "") : localValue.value,
150
157
  );
151
- const labels = computed(() => config.value?.labels ?? CopilotChatDefaultLabels);
158
+ const labels = useChatLabels();
152
159
  const resolvedPlaceholder = computed(
153
160
  () => props.placeholder ?? labels.value.chatInputPlaceholder,
154
161
  );
155
162
  const isExpanded = computed(
156
163
  () => props.mode === "input" && layout.value === "expanded",
157
164
  );
158
- const isProcessing = computed(
159
- () => props.mode !== "transcribe" && props.isRunning,
160
- );
161
165
  const shouldShowDisclaimer = computed(
162
166
  () => props.showDisclaimer ?? props.positioning === "absolute",
163
167
  );
@@ -177,16 +181,20 @@ const hasFinishTranscribeAction = computed(
177
181
  typeof props.onFinishTranscribe === "function" ||
178
182
  typeof props.onFinishTranscribeWithAudio === "function",
179
183
  );
180
- const canSend = computed(
181
- () =>
182
- props.mode === "input" &&
183
- !props.disabled &&
184
- hasSubmitAction.value &&
185
- inputValue.value.trim().length > 0,
186
- );
187
- const sendDisabled = computed(() =>
188
- isProcessing.value ? !hasStopAction.value : !canSend.value,
184
+ const composerInput = computed(() => ({
185
+ mode: props.mode,
186
+ isRunning: props.isRunning,
187
+ value: inputValue.value,
188
+ canSubmit: hasSubmitAction.value,
189
+ canStop: hasStopAction.value,
190
+ disabled: props.disabled,
191
+ }));
192
+ const composerButton = computed(() =>
193
+ ɵcomposerButtonState(composerInput.value),
189
194
  );
195
+ const isProcessing = computed(() => composerButton.value.isProcessing);
196
+ const sendDisabled = computed(() => composerButton.value.disabled);
197
+ const showsStop = computed(() => composerButton.value.action === "stop");
190
198
 
191
199
  const containerClass = computed(() => [
192
200
  "cpk-chat-input",
@@ -251,35 +259,7 @@ function normalizeMenuItems() {
251
259
  const menuItems = computed(() => normalizeMenuItems());
252
260
  const hasMenuItems = computed(() => menuItems.value.length > 0);
253
261
 
254
- function flattenMenuForCommands(items: MenuEntry[]) {
255
- const seen = new Set<string>();
256
- const commands: ToolsMenuItem[] = [];
257
-
258
- const walk = (entryList: MenuEntry[]) => {
259
- for (const entry of entryList) {
260
- if (entry === "-") {
261
- continue;
262
- }
263
-
264
- if (isMenuGroup(entry) && entry.items.length > 0) {
265
- walk(entry.items);
266
- continue;
267
- }
268
-
269
- if (!entry.action || seen.has(entry.label)) {
270
- continue;
271
- }
272
-
273
- seen.add(entry.label);
274
- commands.push(entry);
275
- }
276
- };
277
-
278
- walk(items);
279
- return commands;
280
- }
281
-
282
- const commandItems = computed(() => flattenMenuForCommands(menuItems.value));
262
+ const commandItems = computed(() => ɵflattenCommandItems(menuItems.value));
283
263
 
284
264
  function flattenMenuDisplay(items: MenuEntry[], depth = 0, prefix = "root") {
285
265
  const entries: MenuDisplayEntry[] = [];
@@ -314,32 +294,9 @@ function flattenMenuDisplay(items: MenuEntry[], depth = 0, prefix = "root") {
314
294
 
315
295
  const menuDisplayItems = computed(() => flattenMenuDisplay(menuItems.value));
316
296
 
317
- const filteredCommands = computed(() => {
318
- if (commandQuery.value === null || commandItems.value.length === 0) {
319
- return [] as ToolsMenuItem[];
320
- }
321
-
322
- const normalized = commandQuery.value.trim().toLowerCase();
323
- if (normalized.length === 0) {
324
- return commandItems.value;
325
- }
326
-
327
- const startsWith: ToolsMenuItem[] = [];
328
- const contains: ToolsMenuItem[] = [];
329
-
330
- for (const command of commandItems.value) {
331
- const label = command.label.toLowerCase();
332
- if (label.startsWith(normalized)) {
333
- startsWith.push(command);
334
- continue;
335
- }
336
- if (label.includes(normalized)) {
337
- contains.push(command);
338
- }
339
- }
340
-
341
- return [...startsWith, ...contains];
342
- });
297
+ const filteredCommands = computed(() =>
298
+ ɵfilterCommands(commandItems.value, commandQuery.value),
299
+ );
343
300
 
344
301
  const slashMenuVisible = computed(
345
302
  () => commandQuery.value !== null && commandItems.value.length > 0,
@@ -357,18 +314,7 @@ function clearInputValue() {
357
314
  }
358
315
 
359
316
  function updateSlashState(value: string) {
360
- if (commandItems.value.length === 0) {
361
- commandQuery.value = null;
362
- return;
363
- }
364
-
365
- if (value.startsWith("/")) {
366
- const firstLine = value.split(/\r?\n/, 1)[0] ?? "";
367
- commandQuery.value = firstLine.slice(1);
368
- return;
369
- }
370
-
371
- commandQuery.value = null;
317
+ commandQuery.value = ɵparseSlashQuery(value, commandItems.value.length > 0);
372
318
  }
373
319
 
374
320
  function runCommand(command: ToolsMenuItem) {
@@ -408,14 +354,16 @@ function handleInput(event: Event) {
408
354
  updateSlashState(nextValue);
409
355
  }
410
356
 
357
+ // The button stops a run whatever the input holds. Enter differs: see
358
+ // handleKeydown.
411
359
  function handleSendButtonClick() {
412
- if (isProcessing.value) {
413
- if (hasStopAction.value) {
414
- emit("stop");
415
- }
360
+ if (showsStop.value) {
361
+ emit("stop");
416
362
  return;
417
363
  }
418
- submit();
364
+ if (!isProcessing.value) {
365
+ submit();
366
+ }
419
367
  }
420
368
 
421
369
  function handleKeydown(event: KeyboardEvent) {
@@ -427,61 +375,43 @@ function handleKeydown(event: KeyboardEvent) {
427
375
  return;
428
376
  }
429
377
 
430
- if (commandQuery.value !== null && props.mode === "input") {
431
- if (event.key === "ArrowDown") {
432
- if (filteredCommands.value.length > 0) {
433
- event.preventDefault();
434
- slashHighlightIndex.value =
435
- slashHighlightIndex.value < 0
436
- ? 0
437
- : (slashHighlightIndex.value + 1) % filteredCommands.value.length;
438
- }
378
+ const slash = ɵresolveSlashKey(event, {
379
+ query: props.mode === "input" ? commandQuery.value : null,
380
+ commands: filteredCommands.value,
381
+ highlightIndex: slashHighlightIndex.value,
382
+ });
383
+ if (slash.type !== "none") event.preventDefault();
384
+ switch (slash.type) {
385
+ case "highlight":
386
+ slashHighlightIndex.value = slash.index;
439
387
  return;
440
- }
441
-
442
- if (event.key === "ArrowUp") {
443
- if (filteredCommands.value.length > 0) {
444
- event.preventDefault();
445
- if (slashHighlightIndex.value < 0) {
446
- slashHighlightIndex.value = filteredCommands.value.length - 1;
447
- } else {
448
- slashHighlightIndex.value =
449
- slashHighlightIndex.value <= 0
450
- ? filteredCommands.value.length - 1
451
- : slashHighlightIndex.value - 1;
452
- }
453
- }
388
+ case "run":
389
+ runCommand(slash.command);
454
390
  return;
455
- }
456
-
457
- if (event.key === "Enter") {
458
- const selected =
459
- slashHighlightIndex.value >= 0
460
- ? filteredCommands.value[slashHighlightIndex.value]
461
- : undefined;
462
- if (selected) {
463
- event.preventDefault();
464
- runCommand(selected);
465
- return;
466
- }
467
- }
468
-
469
- if (event.key === "Escape") {
470
- event.preventDefault();
391
+ case "close":
471
392
  commandQuery.value = null;
472
393
  return;
473
- }
394
+ case "none":
395
+ break;
474
396
  }
475
397
 
476
- if (event.key === "Enter" && !event.shiftKey && props.mode === "input") {
398
+ if (props.mode !== "input") {
399
+ return;
400
+ }
401
+
402
+ // Enter with text sends, also while a run is going. Enter in an empty input
403
+ // stops the run. Read the textarea: a controlled modelValue can lag a tick.
404
+ const action = ɵresolveComposerKey(event, {
405
+ ...composerInput.value,
406
+ value: textareaRef.value?.value ?? inputValue.value,
407
+ });
408
+ if (event.key === "Enter" && !event.shiftKey) {
477
409
  event.preventDefault();
478
- if (isProcessing.value) {
479
- if (hasStopAction.value) {
480
- emit("stop");
481
- }
482
- return;
483
- }
410
+ }
411
+ if (action === "send") {
484
412
  submit();
413
+ } else if (action === "stop") {
414
+ emit("stop");
485
415
  }
486
416
  }
487
417
 
@@ -593,240 +523,6 @@ function handleContainerClick(event: MouseEvent) {
593
523
  textareaRef.value?.focus();
594
524
  }
595
525
 
596
- function ensureMeasurements() {
597
- const textarea = textareaRef.value;
598
- if (!textarea || isComposing.value) {
599
- return;
600
- }
601
-
602
- const previousValue = textarea.value;
603
- const previousHeight = textarea.style.height;
604
- textarea.style.height = "auto";
605
-
606
- const computedStyle = window.getComputedStyle(textarea);
607
- const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0;
608
- const paddingRight = parseFloat(computedStyle.paddingRight) || 0;
609
- const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
610
- const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
611
-
612
- textarea.value = "";
613
- const singleLineHeight = textarea.scrollHeight;
614
- textarea.value = previousValue;
615
-
616
- const contentHeight = singleLineHeight - paddingTop - paddingBottom;
617
- const maxHeight = contentHeight * props.maxRows + paddingTop + paddingBottom;
618
-
619
- measurements.value = {
620
- singleLineHeight,
621
- maxHeight,
622
- paddingLeft,
623
- paddingRight,
624
- };
625
-
626
- textarea.style.height = previousHeight;
627
- textarea.style.maxHeight = `${maxHeight}px`;
628
- }
629
-
630
- function adjustTextareaHeight() {
631
- const textarea = textareaRef.value;
632
- if (!textarea) {
633
- return 0;
634
- }
635
-
636
- if (measurements.value.singleLineHeight === 0) {
637
- ensureMeasurements();
638
- }
639
-
640
- const { maxHeight } = measurements.value;
641
- if (maxHeight) {
642
- textarea.style.maxHeight = `${maxHeight}px`;
643
- }
644
-
645
- textarea.style.height = "auto";
646
- const scrollHeight = textarea.scrollHeight;
647
- textarea.style.height = `${maxHeight ? Math.min(scrollHeight, maxHeight) : scrollHeight}px`;
648
- return scrollHeight;
649
- }
650
-
651
- function updateLayout(nextLayout: "compact" | "expanded") {
652
- if (layout.value === nextLayout) {
653
- return;
654
- }
655
- ignoreResizeRef.value = true;
656
- layout.value = nextLayout;
657
- }
658
-
659
- function resolveTextareaFont(textarea: HTMLTextAreaElement): string | null {
660
- const textareaStyles = window.getComputedStyle(textarea);
661
- if (textareaStyles.font?.trim()) {
662
- return textareaStyles.font;
663
- }
664
-
665
- if (textareaStyles.fontSize && textareaStyles.fontFamily) {
666
- const fallbackFont =
667
- `${textareaStyles.fontStyle} ${textareaStyles.fontVariant} ` +
668
- `${textareaStyles.fontWeight} ${textareaStyles.fontSize}/${textareaStyles.lineHeight} ` +
669
- `${textareaStyles.fontFamily}`;
670
- if (fallbackFont.trim()) {
671
- return fallbackFont;
672
- }
673
- }
674
-
675
- if (process.env.NODE_ENV !== "production" && !didWarnMissingFontRef.value) {
676
- didWarnMissingFontRef.value = true;
677
- console.warn(
678
- "[CopilotChatInput] Could not resolve textarea font for layout measurement. " +
679
- "Text-width-based expansion will be skipped until the next container resize.",
680
- );
681
- }
682
- return null;
683
- }
684
-
685
- function updateContainerCache() {
686
- const grid = gridRef.value;
687
- const addContainer = addButtonContainerRef.value;
688
- const actionsContainer = actionsContainerRef.value;
689
- if (!grid || !addContainer || !actionsContainer) {
690
- containerCacheRef.value = null;
691
- return null;
692
- }
693
-
694
- const gridStyles = window.getComputedStyle(grid);
695
- const paddingLeft = parseFloat(gridStyles.paddingLeft) || 0;
696
- const paddingRight = parseFloat(gridStyles.paddingRight) || 0;
697
- const columnGap = parseFloat(gridStyles.columnGap) || 0;
698
- const gridAvailableWidth = grid.clientWidth - paddingLeft - paddingRight;
699
- if (gridAvailableWidth <= 0) {
700
- containerCacheRef.value = null;
701
- return null;
702
- }
703
-
704
- const addWidth = addContainer.getBoundingClientRect().width;
705
- const actionsWidth = actionsContainer.getBoundingClientRect().width;
706
- const compactWidth = Math.max(
707
- gridAvailableWidth - addWidth - actionsWidth - columnGap * 2,
708
- 0,
709
- );
710
- if (compactWidth <= 0) {
711
- containerCacheRef.value = null;
712
- return null;
713
- }
714
-
715
- const cache = { compactWidth };
716
- containerCacheRef.value = cache;
717
- return cache;
718
- }
719
-
720
- function evaluateLayout() {
721
- if (props.mode !== "input") {
722
- updateLayout("compact");
723
- return;
724
- }
725
-
726
- if (
727
- typeof window.matchMedia === "function" &&
728
- window.matchMedia("(max-width: 767px)").matches
729
- ) {
730
- ensureMeasurements();
731
- adjustTextareaHeight();
732
- updateLayout("expanded");
733
- return;
734
- }
735
-
736
- const textarea = textareaRef.value;
737
- if (
738
- !textarea ||
739
- !gridRef.value ||
740
- !addButtonContainerRef.value ||
741
- !actionsContainerRef.value
742
- ) {
743
- return;
744
- }
745
-
746
- if (measurements.value.singleLineHeight === 0) {
747
- ensureMeasurements();
748
- }
749
-
750
- const scrollHeight = adjustTextareaHeight();
751
- const baseline = measurements.value.singleLineHeight;
752
- const hasExplicitBreak = inputValue.value.includes("\n");
753
- const renderedMultiline = baseline > 0 ? scrollHeight > baseline + 1 : false;
754
- let shouldExpand = hasExplicitBreak || renderedMultiline;
755
-
756
- if (!shouldExpand) {
757
- const cache = containerCacheRef.value ?? updateContainerCache();
758
- if (cache && cache.compactWidth > 0) {
759
- const compactInnerWidth = Math.max(
760
- cache.compactWidth -
761
- measurements.value.paddingLeft -
762
- measurements.value.paddingRight,
763
- 0,
764
- );
765
-
766
- if (compactInnerWidth > 0) {
767
- const canvas =
768
- measurementCanvasRef.value ?? document.createElement("canvas");
769
- if (!measurementCanvasRef.value) {
770
- measurementCanvasRef.value = canvas;
771
- }
772
-
773
- const context = canvas.getContext("2d");
774
- if (context) {
775
- const resolvedFont = resolveTextareaFont(textarea);
776
- if (resolvedFont) {
777
- context.font = resolvedFont;
778
- const lines =
779
- inputValue.value.length > 0 ? inputValue.value.split("\n") : [""];
780
- let longestLine = 0;
781
- for (const line of lines) {
782
- const width = context.measureText(line || " ").width;
783
- if (width > longestLine) {
784
- longestLine = width;
785
- }
786
- }
787
- if (longestLine > compactInnerWidth) {
788
- shouldExpand = true;
789
- }
790
- }
791
- } else if (
792
- process.env.NODE_ENV !== "production" &&
793
- !didWarnMissingCanvasContextRef.value
794
- ) {
795
- didWarnMissingCanvasContextRef.value = true;
796
- console.warn(
797
- "[CopilotChatInput] canvas.getContext('2d') returned null. " +
798
- "Text-width-based expansion will be skipped.",
799
- );
800
- }
801
- }
802
- }
803
- }
804
-
805
- updateLayout(shouldExpand ? "expanded" : "compact");
806
- }
807
-
808
- function scheduleLayoutEvaluation(invalidateCache: boolean) {
809
- if (ignoreResizeRef.value) {
810
- ignoreResizeRef.value = false;
811
- return;
812
- }
813
-
814
- if (invalidateCache) {
815
- containerCacheRef.value = null;
816
- didWarnMissingFontRef.value = false;
817
- didWarnMissingCanvasContextRef.value = false;
818
- }
819
-
820
- if (resizeEvaluationRafRef.value !== null) {
821
- cancelAnimationFrame(resizeEvaluationRafRef.value);
822
- }
823
-
824
- resizeEvaluationRafRef.value = requestAnimationFrame(() => {
825
- resizeEvaluationRafRef.value = null;
826
- evaluateLayout();
827
- });
828
- }
829
-
830
526
  watch(
831
527
  () => props.modelValue,
832
528
  (next) => {
@@ -838,13 +534,25 @@ watch(
838
534
 
839
535
  watch(inputValue, (value) => {
840
536
  updateSlashState(value);
841
- evaluateLayout();
842
537
  });
843
538
 
539
+ watch(
540
+ [inputValue, () => props.mode],
541
+ ([value, mode]) => {
542
+ autosize.evaluate(value, mode);
543
+ },
544
+ { flush: "post" },
545
+ );
546
+
547
+ watch(
548
+ () => props.maxRows,
549
+ (maxRows) => {
550
+ autosize.setMaxRows(maxRows);
551
+ },
552
+ );
553
+
844
554
  watch(commandItems, () => {
845
- if (commandItems.value.length === 0) {
846
- commandQuery.value = null;
847
- }
555
+ updateSlashState(inputValue.value);
848
556
  });
849
557
 
850
558
  watch(
@@ -866,20 +574,13 @@ watch(
866
574
  watch(
867
575
  [commandQuery, filteredCommands],
868
576
  () => {
869
- if (commandQuery.value === null) {
870
- slashHighlightIndex.value = 0;
871
- return;
872
- }
873
- if (filteredCommands.value.length === 0) {
874
- slashHighlightIndex.value = -1;
875
- return;
876
- }
877
- if (
878
- slashHighlightIndex.value < 0 ||
879
- slashHighlightIndex.value >= filteredCommands.value.length
880
- ) {
881
- slashHighlightIndex.value = 0;
882
- }
577
+ slashHighlightIndex.value =
578
+ commandQuery.value === null
579
+ ? 0
580
+ : ɵclampSlashIndex(
581
+ slashHighlightIndex.value,
582
+ filteredCommands.value.length,
583
+ );
883
584
  },
884
585
  { immediate: true },
885
586
  );
@@ -888,7 +589,6 @@ watch(
888
589
  () => props.mode,
889
590
  async (mode) => {
890
591
  if (mode !== "input") {
891
- layout.value = "compact";
892
592
  commandQuery.value = null;
893
593
  closeAddMenu();
894
594
  }
@@ -960,39 +660,11 @@ onMounted(() => {
960
660
  textareaRef.value?.focus();
961
661
  }
962
662
 
963
- evaluateLayout();
964
-
965
- if (typeof ResizeObserver !== "undefined") {
966
- const containerTargets = new Set<HTMLElement>();
967
- if (gridRef.value) containerTargets.add(gridRef.value);
968
- if (addButtonContainerRef.value)
969
- containerTargets.add(addButtonContainerRef.value);
970
- if (actionsContainerRef.value)
971
- containerTargets.add(actionsContainerRef.value);
972
-
973
- resizeObserver = new ResizeObserver((entries) => {
974
- const shouldInvalidate = entries.some((entry) =>
975
- containerTargets.has(entry.target as HTMLElement),
976
- );
977
- scheduleLayoutEvaluation(shouldInvalidate);
978
- });
979
-
980
- if (gridRef.value) resizeObserver.observe(gridRef.value);
981
- if (addButtonContainerRef.value)
982
- resizeObserver.observe(addButtonContainerRef.value);
983
- if (actionsContainerRef.value)
984
- resizeObserver.observe(actionsContainerRef.value);
985
- if (textareaRef.value) resizeObserver.observe(textareaRef.value);
986
- }
663
+ autosize.evaluate(inputValue.value, props.mode);
987
664
  });
988
665
 
989
666
  onBeforeUnmount(() => {
990
- resizeObserver?.disconnect();
991
- resizeObserver = null;
992
- if (resizeEvaluationRafRef.value !== null) {
993
- cancelAnimationFrame(resizeEvaluationRafRef.value);
994
- resizeEvaluationRafRef.value = null;
995
- }
667
+ autosize.dispose();
996
668
  });
997
669
  </script>
998
670
 
@@ -1295,7 +967,7 @@ onBeforeUnmount(() => {
1295
967
  type="button"
1296
968
  data-testid="copilot-chat-input-send"
1297
969
  :aria-label="
1298
- isProcessing && hasStopAction
970
+ showsStop
1299
971
  ? labels.chatInputToolbarStopButtonLabel
1300
972
  : labels.chatInputToolbarSendButtonLabel
1301
973
  "
@@ -1304,7 +976,7 @@ onBeforeUnmount(() => {
1304
976
  @click="handleSendButtonClick"
1305
977
  >
1306
978
  <IconSquare
1307
- v-if="isProcessing && hasStopAction"
979
+ v-if="showsStop"
1308
980
  class="cpk-chat-input-stop-icon"
1309
981
  />
1310
982
  <IconArrowUp v-else class="cpk-chat-input-send-icon" />