@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.
- package/AGENTS.md +50 -0
- package/CHANGELOG.md +13 -0
- package/PARITY.md +434 -0
- package/README.md +396 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +20 -0
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -0
- package/dist/components/copilot-provider/index.d.ts +3 -0
- package/dist/components/copilot-provider/index.d.ts.map +1 -0
- package/dist/components/copilot-provider/types.d.ts +22 -0
- package/dist/components/copilot-provider/types.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-copilot-action.d.ts +27 -0
- package/dist/hooks/use-copilot-action.d.ts.map +1 -0
- package/dist/hooks/use-copilot-readable.d.ts +20 -0
- package/dist/hooks/use-copilot-readable.d.ts.map +1 -0
- package/dist/hooks/use-frontend-tool.d.ts +21 -0
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +252 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs +85 -0
- package/dist/use-render-activity-message-BRL1Rpl-.cjs.map +1 -0
- package/dist/use-render-activity-message-CqtxiFSs.js +8927 -0
- package/dist/use-render-activity-message-CqtxiFSs.js.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +9 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts +16 -0
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts +7 -0
- package/dist/v2/components/CopilotKitInspector.vue.d.ts.map +1 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts +6 -0
- package/dist/v2/components/InlineFeatureWarning.vue.d.ts.map +1 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts +18 -0
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts +88 -0
- package/dist/v2/components/MCPAppsActivityRenderer.d.ts.map +1 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +154 -0
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +19 -0
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +16 -0
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts +62 -0
- package/dist/v2/components/a2ui/VueSurface.d.ts.map +1 -0
- package/dist/v2/components/a2ui/adapter.d.ts +38 -0
- package/dist/v2/components/a2ui/adapter.d.ts.map +1 -0
- package/dist/v2/components/a2ui/catalog.d.ts +29 -0
- package/dist/v2/components/a2ui/catalog.d.ts.map +1 -0
- package/dist/v2/components/a2ui/index.d.ts +5 -0
- package/dist/v2/components/a2ui/index.d.ts.map +1 -0
- package/dist/v2/components/a2ui/utils.d.ts +18 -0
- package/dist/v2/components/a2ui/utils.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +12 -0
- package/dist/v2/components/a2ui.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +164 -0
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts +7 -0
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +290 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +72 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts +65 -0
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts +27 -0
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts +26 -0
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts +17 -0
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonCloseIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatToggleButtonOpenIcon.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +21 -0
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts +34 -0
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +106 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts +15 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts +5 -0
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +50 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +55 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +48 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +62 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +53 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts +28 -0
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/audioRecorder.d.ts +11 -0
- package/dist/v2/components/chat/audioRecorder.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +682 -0
- package/dist/v2/components/chat/index.d.ts.map +1 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts +29 -0
- package/dist/v2/components/chat/last-user-message-context.d.ts.map +1 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts +3 -0
- package/dist/v2/components/chat/normalize-auto-scroll.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +380 -0
- package/dist/v2/components/chat/types.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +2 -0
- package/dist/v2/components/icons/index.d.ts.map +1 -0
- package/dist/v2/components/index.d.ts +8 -0
- package/dist/v2/components/index.d.ts.map +1 -0
- package/dist/v2/hooks/index.d.ts +24 -0
- package/dist/v2/hooks/index.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent-context.d.ts +24 -0
- package/dist/v2/hooks/use-agent-context.d.ts.map +1 -0
- package/dist/v2/hooks/use-agent.d.ts +53 -0
- package/dist/v2/hooks/use-agent.d.ts.map +1 -0
- package/dist/v2/hooks/use-attachments.d.ts +21 -0
- package/dist/v2/hooks/use-attachments.d.ts.map +1 -0
- package/dist/v2/hooks/use-capabilities.d.ts +16 -0
- package/dist/v2/hooks/use-capabilities.d.ts.map +1 -0
- package/dist/v2/hooks/use-component.d.ts +13 -0
- package/dist/v2/hooks/use-component.d.ts.map +1 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts +24 -0
- package/dist/v2/hooks/use-configure-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +14 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts +19 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts +19 -0
- package/dist/v2/hooks/use-human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/hooks/use-interrupt.d.ts +36 -0
- package/dist/v2/hooks/use-interrupt.d.ts.map +1 -0
- package/dist/v2/hooks/use-katex-styles.d.ts +22 -0
- package/dist/v2/hooks/use-katex-styles.d.ts.map +1 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts +33 -0
- package/dist/v2/hooks/use-keyboard-height.d.ts.map +1 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts +28 -0
- package/dist/v2/hooks/use-pin-to-send.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts +21 -0
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts +27 -0
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -0
- package/dist/v2/hooks/use-render-tool.d.ts +36 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -0
- package/dist/v2/hooks/use-suggestions.d.ts +26 -0
- package/dist/v2/hooks/use-suggestions.d.ts.map +1 -0
- package/dist/v2/hooks/use-threads.d.ts +42 -0
- package/dist/v2/hooks/use-threads.d.ts.map +1 -0
- package/dist/v2/index.cjs +2 -0
- package/dist/v2/index.cjs.map +1 -0
- package/dist/v2/index.d.cts +9 -0
- package/dist/v2/index.d.mts +9 -0
- package/dist/v2/index.d.ts +9 -0
- package/dist/v2/index.d.ts.map +1 -0
- package/dist/v2/index.mjs +75 -0
- package/dist/v2/index.mjs.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +3 -0
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -0
- package/dist/v2/lib/shallow-stable.d.ts +7 -0
- package/dist/v2/lib/shallow-stable.d.ts.map +1 -0
- package/dist/v2/lib/transcription-client.d.ts +19 -0
- package/dist/v2/lib/transcription-client.d.ts.map +1 -0
- package/dist/v2/lib/vue-core.d.ts +47 -0
- package/dist/v2/lib/vue-core.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts +15 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts +17 -0
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +61 -0
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +37 -0
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts +4 -0
- package/dist/v2/providers/SandboxFunctionsContext.d.ts.map +1 -0
- package/dist/v2/providers/index.d.ts +13 -0
- package/dist/v2/providers/index.d.ts.map +1 -0
- package/dist/v2/providers/keys.d.ts +17 -0
- package/dist/v2/providers/keys.d.ts.map +1 -0
- package/dist/v2/providers/license-context.d.ts +7 -0
- package/dist/v2/providers/license-context.d.ts.map +1 -0
- package/dist/v2/providers/types.d.ts +38 -0
- package/dist/v2/providers/types.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts +4 -0
- package/dist/v2/providers/useCopilotChatConfiguration.d.ts.map +1 -0
- package/dist/v2/providers/useCopilotKit.d.ts +2 -0
- package/dist/v2/providers/useCopilotKit.d.ts.map +1 -0
- package/dist/v2/providers/useLicenseContext.d.ts +14 -0
- package/dist/v2/providers/useLicenseContext.d.ts.map +1 -0
- package/dist/v2/types/a2ui.d.ts +5 -0
- package/dist/v2/types/a2ui.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +15 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -0
- package/dist/v2/types/frontend-tool.d.ts +6 -0
- package/dist/v2/types/frontend-tool.d.ts.map +1 -0
- package/dist/v2/types/human-in-the-loop.d.ts +29 -0
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -0
- package/dist/v2/types/index.d.ts +10 -0
- package/dist/v2/types/index.d.ts.map +1 -0
- package/dist/v2/types/interrupt.d.ts +14 -0
- package/dist/v2/types/interrupt.d.ts.map +1 -0
- package/dist/v2/types/sandbox-function.d.ts +8 -0
- package/dist/v2/types/sandbox-function.d.ts.map +1 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts +18 -0
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts +19 -0
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts +37 -0
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -0
- package/env.d.ts +7 -0
- package/eslint.config.mjs +42 -0
- package/package.json +130 -0
- package/scripts/scope-preflight.mjs +100 -0
- package/src/components/copilot-provider/CopilotKit.vue +18 -0
- package/src/components/copilot-provider/index.ts +2 -0
- package/src/components/copilot-provider/types.ts +24 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/use-copilot-action.ts +168 -0
- package/src/hooks/use-copilot-readable.ts +75 -0
- package/src/hooks/use-frontend-tool.ts +76 -0
- package/src/index.ts +12 -0
- package/src/styles/globals.css +314 -0
- package/src/v2/__tests__/exports.test.ts +35 -0
- package/src/v2/__tests__/mocks/web-inspector.ts +5 -0
- package/src/v2/__tests__/setup.ts +141 -0
- package/src/v2/__tests__/utils/agents.ts +391 -0
- package/src/v2/__tests__/utils/mount.ts +83 -0
- package/src/v2/__tests__/utils/test-helpers.ts +712 -0
- package/src/v2/components/A2UIMessageRenderer.ts +125 -0
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +186 -0
- package/src/v2/components/CopilotKitInspector.vue +42 -0
- package/src/v2/components/InlineFeatureWarning.vue +35 -0
- package/src/v2/components/LicenseWarningBanner.vue +196 -0
- package/src/v2/components/MCPAppsActivityRenderer.ts +778 -0
- package/src/v2/components/OpenGenerativeUIRenderer.ts +550 -0
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +271 -0
- package/src/v2/components/__tests__/CopilotKitInspector.test.ts +57 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.e2e.test.ts +851 -0
- package/src/v2/components/__tests__/MCPAppsActivityRenderer.test.ts +237 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +516 -0
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +295 -0
- package/src/v2/components/a2ui/A2UICatalogContext.ts +190 -0
- package/src/v2/components/a2ui/VueSurface.ts +144 -0
- package/src/v2/components/a2ui/adapter.ts +156 -0
- package/src/v2/components/a2ui/catalog.ts +858 -0
- package/src/v2/components/a2ui/index.ts +7 -0
- package/src/v2/components/a2ui/utils.ts +67 -0
- package/src/v2/components/a2ui.ts +30 -0
- package/src/v2/components/chat/CopilotChat.vue +777 -0
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +891 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +411 -0
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +87 -0
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +269 -0
- package/src/v2/components/chat/CopilotChatInput.vue +1271 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +476 -0
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +247 -0
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +56 -0
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +93 -0
- package/src/v2/components/chat/CopilotChatToggleButton.vue +145 -0
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +17 -0
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +18 -0
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +161 -0
- package/src/v2/components/chat/CopilotChatUserMessage.vue +322 -0
- package/src/v2/components/chat/CopilotChatView.vue +740 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +73 -0
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +38 -0
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +22 -0
- package/src/v2/components/chat/CopilotPopup.vue +182 -0
- package/src/v2/components/chat/CopilotPopupView.vue +168 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +453 -0
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +140 -0
- package/src/v2/components/chat/CopilotSidebar.vue +178 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +172 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +366 -0
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +142 -0
- package/src/v2/components/chat/__tests__/CopilotChat.attachments.test.ts +237 -0
- package/src/v2/components/chat/__tests__/CopilotChat.e2e.test.ts +1240 -0
- package/src/v2/components/chat/__tests__/CopilotChat.licenseWarning.test.ts +138 -0
- package/src/v2/components/chat/__tests__/CopilotChat.onError.test.ts +85 -0
- package/src/v2/components/chat/__tests__/CopilotChat.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChat.test.ts +652 -0
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +683 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +768 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +1108 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.thumbs.test.ts +87 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentQueue.test.ts +277 -0
- package/src/v2/components/chat/__tests__/CopilotChatAttachmentRenderer.test.ts +124 -0
- package/src/v2/components/chat/__tests__/CopilotChatCopyButton.clipboard.test.ts +230 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.bottomAnchored.test.ts +83 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +1139 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +1051 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.slots.e2e.test.ts +141 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +494 -0
- package/src/v2/components/chat/__tests__/CopilotChatPropsRerender.e2e.test.ts +181 -0
- package/src/v2/components/chat/__tests__/CopilotChatReasoningMessage.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +73 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +674 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.test.ts +91 -0
- package/src/v2/components/chat/__tests__/CopilotChatToggleButton.test.ts +93 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.test.ts +382 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRendering.e2e.test.ts +1019 -0
- package/src/v2/components/chat/__tests__/CopilotChatToolRerenders.e2e.test.ts +516 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.slots.e2e.test.ts +701 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.test.ts +337 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.connectingGate.test.ts +135 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +278 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.onClick.e2e.test.ts +1082 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.pinToSend.test.ts +166 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.slots.e2e.test.ts +1145 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.test.ts +374 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +636 -0
- package/src/v2/components/chat/__tests__/CopilotModalHeader.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +725 -0
- package/src/v2/components/chat/__tests__/CopilotPopupView.test.ts +112 -0
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +58 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.slots.e2e.test.ts +603 -0
- package/src/v2/components/chat/__tests__/CopilotSidebarView.test.ts +214 -0
- package/src/v2/components/chat/__tests__/MCPAppsUiMessage.e2e.test.ts +394 -0
- package/src/v2/components/chat/__tests__/copilot-chat-throttle.test.ts +82 -0
- package/src/v2/components/chat/__tests__/normalize-auto-scroll.test.ts +39 -0
- package/src/v2/components/chat/audioRecorder.ts +15 -0
- package/src/v2/components/chat/index.ts +52 -0
- package/src/v2/components/chat/last-user-message-context.ts +39 -0
- package/src/v2/components/chat/normalize-auto-scroll.ts +17 -0
- package/src/v2/components/chat/types.ts +481 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +86 -0
- package/src/v2/components/icons/index.ts +22 -0
- package/src/v2/components/index.ts +7 -0
- package/src/v2/hooks/__tests__/standard-schema-types.test.ts +149 -0
- package/src/v2/hooks/__tests__/standard-schema.test.ts +315 -0
- package/src/v2/hooks/__tests__/use-agent-context-timing.e2e.test.ts +144 -0
- package/src/v2/hooks/__tests__/use-agent-context.test.ts +271 -0
- package/src/v2/hooks/__tests__/use-agent-error-state.test.ts +64 -0
- package/src/v2/hooks/__tests__/use-agent-stability.test.ts +268 -0
- package/src/v2/hooks/__tests__/use-agent-thread-isolation.test.ts +433 -0
- package/src/v2/hooks/__tests__/use-agent-throttle.test.ts +747 -0
- package/src/v2/hooks/__tests__/use-agent.e2e.test.ts +187 -0
- package/src/v2/hooks/__tests__/use-agent.test.ts +126 -0
- package/src/v2/hooks/__tests__/use-attachments.test.ts +181 -0
- package/src/v2/hooks/__tests__/use-component.test.ts +145 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.e2e.test.ts +527 -0
- package/src/v2/hooks/__tests__/use-configure-suggestions.test.ts +399 -0
- package/src/v2/hooks/__tests__/use-default-render-tool.test.ts +214 -0
- package/src/v2/hooks/__tests__/use-frontend-tool-available.test.ts +220 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +2320 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.test.ts +648 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +1379 -0
- package/src/v2/hooks/__tests__/use-human-in-the-loop.test.ts +282 -0
- package/src/v2/hooks/__tests__/use-interrupt.test.ts +345 -0
- package/src/v2/hooks/__tests__/use-katex-styles.test.ts +69 -0
- package/src/v2/hooks/__tests__/use-keyboard-height.test.ts +199 -0
- package/src/v2/hooks/__tests__/use-pin-to-send.test.ts +363 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +329 -0
- package/src/v2/hooks/__tests__/use-suggestions.e2e.test.ts +397 -0
- package/src/v2/hooks/__tests__/use-suggestions.test.ts +198 -0
- package/src/v2/hooks/__tests__/use-threads.test.ts +1041 -0
- package/src/v2/hooks/__tests__/zod-regression.test.ts +339 -0
- package/src/v2/hooks/index.ts +29 -0
- package/src/v2/hooks/use-agent-context.ts +55 -0
- package/src/v2/hooks/use-agent.ts +345 -0
- package/src/v2/hooks/use-attachments.ts +261 -0
- package/src/v2/hooks/use-capabilities.ts +30 -0
- package/src/v2/hooks/use-component.ts +46 -0
- package/src/v2/hooks/use-configure-suggestions.ts +252 -0
- package/src/v2/hooks/use-default-render-tool.ts +130 -0
- package/src/v2/hooks/use-frontend-tool.ts +68 -0
- package/src/v2/hooks/use-human-in-the-loop.ts +90 -0
- package/src/v2/hooks/use-interrupt.ts +257 -0
- package/src/v2/hooks/use-katex-styles.ts +44 -0
- package/src/v2/hooks/use-keyboard-height.ts +87 -0
- package/src/v2/hooks/use-pin-to-send.ts +160 -0
- package/src/v2/hooks/use-render-activity-message.ts +92 -0
- package/src/v2/hooks/use-render-custom-messages.ts +129 -0
- package/src/v2/hooks/use-render-tool.ts +128 -0
- package/src/v2/hooks/use-suggestions.ts +98 -0
- package/src/v2/hooks/use-threads.ts +208 -0
- package/src/v2/index.ts +11 -0
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +84 -0
- package/src/v2/lib/__tests__/transcription-client.test.ts +65 -0
- package/src/v2/lib/processPartialHtml.ts +21 -0
- package/src/v2/lib/shallow-stable.ts +54 -0
- package/src/v2/lib/transcription-client.ts +151 -0
- package/src/v2/lib/vue-core.ts +161 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.types.ts +15 -0
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +95 -0
- package/src/v2/providers/CopilotKitProvider.types.ts +66 -0
- package/src/v2/providers/CopilotKitProvider.vue +653 -0
- package/src/v2/providers/SandboxFunctionsContext.ts +11 -0
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +309 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.debug.test.ts +295 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.license.test.ts +110 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.onError.test.ts +67 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.renderCustomMessages.e2e.test.ts +901 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.sandboxFunctions.test.ts +141 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.stability.test.ts +871 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +603 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.ts +104 -0
- package/src/v2/providers/index.ts +21 -0
- package/src/v2/providers/keys.ts +25 -0
- package/src/v2/providers/license-context.ts +16 -0
- package/src/v2/providers/types.ts +40 -0
- package/src/v2/providers/useCopilotChatConfiguration.ts +11 -0
- package/src/v2/providers/useCopilotKit.ts +11 -0
- package/src/v2/providers/useLicenseContext.ts +21 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +157 -0
- package/src/v2/types/a2ui.ts +5 -0
- package/src/v2/types/defineToolCallRenderer.ts +32 -0
- package/src/v2/types/frontend-tool.ts +8 -0
- package/src/v2/types/human-in-the-loop.ts +38 -0
- package/src/v2/types/index.ts +9 -0
- package/src/v2/types/interrupt.ts +15 -0
- package/src/v2/types/sandbox-function.ts +8 -0
- package/src/v2/types/vue-activity-message-renderer.ts +22 -0
- package/src/v2/types/vue-custom-message-renderer.ts +24 -0
- package/src/v2/types/vue-tool-call-renderer.ts +44 -0
- package/tsconfig.json +27 -0
- package/vite.config.ts +49 -0
- package/vitest.config.ts +23 -0
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from "@testing-library/vue";
|
|
2
|
+
import { defineComponent } from "vue";
|
|
3
|
+
import { describe, it, expect, vi } from "vitest";
|
|
4
|
+
import type { Suggestion } from "@copilotkit/core";
|
|
5
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
6
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
7
|
+
import CopilotChatSuggestionView from "../CopilotChatSuggestionView.vue";
|
|
8
|
+
|
|
9
|
+
const TestWrapper = defineComponent({
|
|
10
|
+
components: {
|
|
11
|
+
CopilotKitProvider,
|
|
12
|
+
CopilotChatConfigurationProvider,
|
|
13
|
+
},
|
|
14
|
+
template: `
|
|
15
|
+
<CopilotKitProvider>
|
|
16
|
+
<CopilotChatConfigurationProvider thread-id="test-thread">
|
|
17
|
+
<slot />
|
|
18
|
+
</CopilotChatConfigurationProvider>
|
|
19
|
+
</CopilotKitProvider>
|
|
20
|
+
`,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function renderInWrapper(component: ReturnType<typeof defineComponent>) {
|
|
24
|
+
return render(component, {
|
|
25
|
+
global: {
|
|
26
|
+
components: {
|
|
27
|
+
TestWrapper,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
wrapper: TestWrapper,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const createSuggestions = (): Suggestion[] => [
|
|
35
|
+
{ title: "Suggestion 1", message: "Message 1", isLoading: false },
|
|
36
|
+
{ title: "Suggestion 2", message: "Message 2", isLoading: false },
|
|
37
|
+
{ title: "Suggestion 3", message: "Message 3", isLoading: false },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
describe("CopilotChatSuggestionView Slot System E2E Tests", () => {
|
|
41
|
+
describe("1. Tailwind Class Slot Override", () => {
|
|
42
|
+
describe("container slot", () => {
|
|
43
|
+
it("should apply tailwind class string to container", () => {
|
|
44
|
+
const Host = defineComponent({
|
|
45
|
+
components: { CopilotChatSuggestionView },
|
|
46
|
+
setup() {
|
|
47
|
+
return { suggestions: createSuggestions() };
|
|
48
|
+
},
|
|
49
|
+
template: `
|
|
50
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
51
|
+
<template #container="{ suggestions, onSelectSuggestion }">
|
|
52
|
+
<div data-testid="custom-container" class="flex gap-4 bg-blue-50 p-4">
|
|
53
|
+
<button
|
|
54
|
+
v-for="(suggestion, index) in suggestions"
|
|
55
|
+
:key="suggestion.title"
|
|
56
|
+
type="button"
|
|
57
|
+
@click="onSelectSuggestion(suggestion, index)"
|
|
58
|
+
>
|
|
59
|
+
{{ suggestion.title }}
|
|
60
|
+
</button>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
</CopilotChatSuggestionView>
|
|
64
|
+
`,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
renderInWrapper(Host);
|
|
68
|
+
const containerEl = screen.getByTestId("custom-container");
|
|
69
|
+
expect(containerEl.classList.contains("gap-4")).toBe(true);
|
|
70
|
+
expect(containerEl.classList.contains("bg-blue-50")).toBe(true);
|
|
71
|
+
expect(containerEl.classList.contains("p-4")).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should merge container classes with default flex-wrap", () => {
|
|
75
|
+
const Host = defineComponent({
|
|
76
|
+
components: { CopilotChatSuggestionView },
|
|
77
|
+
setup() {
|
|
78
|
+
return { suggestions: createSuggestions() };
|
|
79
|
+
},
|
|
80
|
+
template: `
|
|
81
|
+
<CopilotChatSuggestionView
|
|
82
|
+
:suggestions="suggestions"
|
|
83
|
+
class="custom-container-class"
|
|
84
|
+
/>
|
|
85
|
+
`,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
renderInWrapper(Host);
|
|
89
|
+
const containerEl = document.querySelector(".custom-container-class");
|
|
90
|
+
expect(containerEl).toBeTruthy();
|
|
91
|
+
expect(containerEl?.classList.contains("cpk:flex-wrap")).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("suggestion slot", () => {
|
|
96
|
+
it("should apply tailwind class string to all suggestion pills", () => {
|
|
97
|
+
const Host = defineComponent({
|
|
98
|
+
components: { CopilotChatSuggestionView },
|
|
99
|
+
setup() {
|
|
100
|
+
return { suggestions: createSuggestions() };
|
|
101
|
+
},
|
|
102
|
+
template: `
|
|
103
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
104
|
+
<template #suggestion="{ suggestion, onSelect }">
|
|
105
|
+
<button
|
|
106
|
+
class="bg-green-100 hover:bg-green-200 rounded-full"
|
|
107
|
+
type="button"
|
|
108
|
+
@click="onSelect"
|
|
109
|
+
>
|
|
110
|
+
{{ suggestion.title }}
|
|
111
|
+
</button>
|
|
112
|
+
</template>
|
|
113
|
+
</CopilotChatSuggestionView>
|
|
114
|
+
`,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
renderInWrapper(Host);
|
|
118
|
+
const pills = document.querySelectorAll(".bg-green-100");
|
|
119
|
+
expect(pills.length).toBe(3);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe("2. Property Passing (onClick, disabled, etc.)", () => {
|
|
125
|
+
describe("container slot", () => {
|
|
126
|
+
it("should pass custom props to container", () => {
|
|
127
|
+
const Host = defineComponent({
|
|
128
|
+
components: { CopilotChatSuggestionView },
|
|
129
|
+
setup() {
|
|
130
|
+
return { suggestions: createSuggestions() };
|
|
131
|
+
},
|
|
132
|
+
template: `
|
|
133
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
134
|
+
<template #container="{ suggestions, onSelectSuggestion }">
|
|
135
|
+
<div data-testid="custom-container">
|
|
136
|
+
<button
|
|
137
|
+
v-for="(suggestion, index) in suggestions"
|
|
138
|
+
:key="suggestion.title"
|
|
139
|
+
type="button"
|
|
140
|
+
@click="onSelectSuggestion(suggestion, index)"
|
|
141
|
+
>
|
|
142
|
+
{{ suggestion.title }}
|
|
143
|
+
</button>
|
|
144
|
+
</div>
|
|
145
|
+
</template>
|
|
146
|
+
</CopilotChatSuggestionView>
|
|
147
|
+
`,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
renderInWrapper(Host);
|
|
151
|
+
expect(screen.getByTestId("custom-container")).toBeDefined();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("should pass custom onClick to container", async () => {
|
|
155
|
+
const onClick = vi.fn();
|
|
156
|
+
const Host = defineComponent({
|
|
157
|
+
components: { CopilotChatSuggestionView },
|
|
158
|
+
setup() {
|
|
159
|
+
return { suggestions: createSuggestions(), onClick };
|
|
160
|
+
},
|
|
161
|
+
template: `
|
|
162
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
163
|
+
<template #container="{ suggestions, onSelectSuggestion }">
|
|
164
|
+
<div data-testid="clickable-container" @click="onClick">
|
|
165
|
+
<button
|
|
166
|
+
v-for="(suggestion, index) in suggestions"
|
|
167
|
+
:key="suggestion.title"
|
|
168
|
+
type="button"
|
|
169
|
+
@click.stop="onSelectSuggestion(suggestion, index)"
|
|
170
|
+
>
|
|
171
|
+
{{ suggestion.title }}
|
|
172
|
+
</button>
|
|
173
|
+
</div>
|
|
174
|
+
</template>
|
|
175
|
+
</CopilotChatSuggestionView>
|
|
176
|
+
`,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
renderInWrapper(Host);
|
|
180
|
+
await fireEvent.click(screen.getByTestId("clickable-container"));
|
|
181
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("suggestion slot", () => {
|
|
186
|
+
it("should apply custom type to suggestion buttons", () => {
|
|
187
|
+
const Host = defineComponent({
|
|
188
|
+
components: { CopilotChatSuggestionView },
|
|
189
|
+
setup() {
|
|
190
|
+
return { suggestions: createSuggestions() };
|
|
191
|
+
},
|
|
192
|
+
template: `
|
|
193
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
194
|
+
<template #suggestion="{ suggestion, onSelect }">
|
|
195
|
+
<button type="submit" @click="onSelect">
|
|
196
|
+
{{ suggestion.title }}
|
|
197
|
+
</button>
|
|
198
|
+
</template>
|
|
199
|
+
</CopilotChatSuggestionView>
|
|
200
|
+
`,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
renderInWrapper(Host);
|
|
204
|
+
const buttons = document.querySelectorAll('button[type="submit"]');
|
|
205
|
+
expect(buttons.length).toBe(3);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("should apply disabled state to all suggestion pills", () => {
|
|
209
|
+
const Host = defineComponent({
|
|
210
|
+
components: { CopilotChatSuggestionView },
|
|
211
|
+
setup() {
|
|
212
|
+
return { suggestions: createSuggestions() };
|
|
213
|
+
},
|
|
214
|
+
template: `
|
|
215
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
216
|
+
<template #suggestion="{ suggestion, onSelect }">
|
|
217
|
+
<button disabled type="button" @click="onSelect">
|
|
218
|
+
{{ suggestion.title }}
|
|
219
|
+
</button>
|
|
220
|
+
</template>
|
|
221
|
+
</CopilotChatSuggestionView>
|
|
222
|
+
`,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
renderInWrapper(Host);
|
|
226
|
+
const buttons = document.querySelectorAll("button[disabled]");
|
|
227
|
+
expect(buttons.length).toBe(3);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
describe("onSelectSuggestion callback", () => {
|
|
232
|
+
it("should call onSelectSuggestion when suggestion is clicked", async () => {
|
|
233
|
+
const onSelectSuggestion = vi.fn();
|
|
234
|
+
const Host = defineComponent({
|
|
235
|
+
components: { CopilotChatSuggestionView },
|
|
236
|
+
setup() {
|
|
237
|
+
return { suggestions: createSuggestions(), onSelectSuggestion };
|
|
238
|
+
},
|
|
239
|
+
template: `
|
|
240
|
+
<CopilotChatSuggestionView
|
|
241
|
+
:suggestions="suggestions"
|
|
242
|
+
@select-suggestion="onSelectSuggestion"
|
|
243
|
+
/>
|
|
244
|
+
`,
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
renderInWrapper(Host);
|
|
248
|
+
await fireEvent.click(screen.getByText("Suggestion 1"));
|
|
249
|
+
expect(onSelectSuggestion).toHaveBeenCalledWith(
|
|
250
|
+
createSuggestions()[0],
|
|
251
|
+
0,
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("should call onSelectSuggestion with correct index for each suggestion", async () => {
|
|
256
|
+
const suggestions = createSuggestions();
|
|
257
|
+
const onSelectSuggestion = vi.fn();
|
|
258
|
+
const Host = defineComponent({
|
|
259
|
+
components: { CopilotChatSuggestionView },
|
|
260
|
+
setup() {
|
|
261
|
+
return { suggestions, onSelectSuggestion };
|
|
262
|
+
},
|
|
263
|
+
template: `
|
|
264
|
+
<CopilotChatSuggestionView
|
|
265
|
+
:suggestions="suggestions"
|
|
266
|
+
@select-suggestion="onSelectSuggestion"
|
|
267
|
+
/>
|
|
268
|
+
`,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
renderInWrapper(Host);
|
|
272
|
+
await fireEvent.click(screen.getByText("Suggestion 2"));
|
|
273
|
+
await fireEvent.click(screen.getByText("Suggestion 3"));
|
|
274
|
+
expect(onSelectSuggestion).toHaveBeenCalledWith(suggestions[1], 1);
|
|
275
|
+
expect(onSelectSuggestion).toHaveBeenCalledWith(suggestions[2], 2);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
describe("3. Custom Component Receiving Sub-components", () => {
|
|
281
|
+
it("should allow custom component for container", () => {
|
|
282
|
+
const CustomContainer = defineComponent({
|
|
283
|
+
template: `
|
|
284
|
+
<div data-testid="custom-container-component">
|
|
285
|
+
<span>Suggestions:</span>
|
|
286
|
+
<slot />
|
|
287
|
+
</div>
|
|
288
|
+
`,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const Host = defineComponent({
|
|
292
|
+
components: { CopilotChatSuggestionView, CustomContainer },
|
|
293
|
+
setup() {
|
|
294
|
+
return { suggestions: createSuggestions() };
|
|
295
|
+
},
|
|
296
|
+
template: `
|
|
297
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
298
|
+
<template #container="{ suggestions, onSelectSuggestion }">
|
|
299
|
+
<CustomContainer>
|
|
300
|
+
<button
|
|
301
|
+
v-for="(suggestion, index) in suggestions"
|
|
302
|
+
:key="suggestion.title"
|
|
303
|
+
type="button"
|
|
304
|
+
@click="onSelectSuggestion(suggestion, index)"
|
|
305
|
+
>
|
|
306
|
+
{{ suggestion.title }}
|
|
307
|
+
</button>
|
|
308
|
+
</CustomContainer>
|
|
309
|
+
</template>
|
|
310
|
+
</CopilotChatSuggestionView>
|
|
311
|
+
`,
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
renderInWrapper(Host);
|
|
315
|
+
const custom = screen.getByTestId("custom-container-component");
|
|
316
|
+
expect(custom.textContent).toContain("Suggestions:");
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it("should allow custom component for suggestion pills", () => {
|
|
320
|
+
const CustomSuggestionPill = defineComponent({
|
|
321
|
+
props: {
|
|
322
|
+
title: { type: String, required: true },
|
|
323
|
+
},
|
|
324
|
+
emits: ["select"],
|
|
325
|
+
template: `
|
|
326
|
+
<button data-testid="custom-pill" @click="$emit('select')">[{{ title }}]</button>
|
|
327
|
+
`,
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const Host = defineComponent({
|
|
331
|
+
components: { CopilotChatSuggestionView, CustomSuggestionPill },
|
|
332
|
+
setup() {
|
|
333
|
+
return { suggestions: createSuggestions() };
|
|
334
|
+
},
|
|
335
|
+
template: `
|
|
336
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
337
|
+
<template #suggestion="{ suggestion, onSelect }">
|
|
338
|
+
<CustomSuggestionPill
|
|
339
|
+
:title="suggestion.title"
|
|
340
|
+
@select="onSelect"
|
|
341
|
+
/>
|
|
342
|
+
</template>
|
|
343
|
+
</CopilotChatSuggestionView>
|
|
344
|
+
`,
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
renderInWrapper(Host);
|
|
348
|
+
const customPills = screen.getAllByTestId("custom-pill");
|
|
349
|
+
expect(customPills).toHaveLength(3);
|
|
350
|
+
expect(customPills[0]?.textContent).toBe("[Suggestion 1]");
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it("should pass isLoading to custom suggestion component", () => {
|
|
354
|
+
const suggestions: Suggestion[] = [
|
|
355
|
+
{ title: "Suggestion 1", message: "Message 1", isLoading: true },
|
|
356
|
+
{ title: "Suggestion 2", message: "Message 2", isLoading: false },
|
|
357
|
+
];
|
|
358
|
+
|
|
359
|
+
const Host = defineComponent({
|
|
360
|
+
components: { CopilotChatSuggestionView },
|
|
361
|
+
setup() {
|
|
362
|
+
return { suggestions };
|
|
363
|
+
},
|
|
364
|
+
template: `
|
|
365
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
366
|
+
<template #suggestion="{ suggestion, isLoading }">
|
|
367
|
+
<button data-testid="custom-pill" :data-loading="String(isLoading)">
|
|
368
|
+
{{ isLoading ? "Loading..." : suggestion.title }}
|
|
369
|
+
</button>
|
|
370
|
+
</template>
|
|
371
|
+
</CopilotChatSuggestionView>
|
|
372
|
+
`,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
renderInWrapper(Host);
|
|
376
|
+
const pills = screen.getAllByTestId("custom-pill");
|
|
377
|
+
expect(pills[0]?.getAttribute("data-loading")).toBe("true");
|
|
378
|
+
expect(pills[0]?.textContent).toBe("Loading...");
|
|
379
|
+
expect(pills[1]?.getAttribute("data-loading")).toBe("false");
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
describe("4. Children Render Function for Drill-down", () => {
|
|
384
|
+
it("should provide bound container and suggestion via children render function", () => {
|
|
385
|
+
const Host = defineComponent({
|
|
386
|
+
components: { CopilotChatSuggestionView },
|
|
387
|
+
setup() {
|
|
388
|
+
return { suggestions: createSuggestions() };
|
|
389
|
+
},
|
|
390
|
+
template: `
|
|
391
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
392
|
+
<template #layout="{ suggestions, onSelectSuggestion }">
|
|
393
|
+
<div data-testid="children-render">
|
|
394
|
+
<div data-testid="received-container">{{ typeof onSelectSuggestion }}</div>
|
|
395
|
+
<div data-testid="received-suggestion">{{ suggestions.length }}</div>
|
|
396
|
+
</div>
|
|
397
|
+
</template>
|
|
398
|
+
</CopilotChatSuggestionView>
|
|
399
|
+
`,
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
renderInWrapper(Host);
|
|
403
|
+
expect(screen.getByTestId("children-render")).toBeDefined();
|
|
404
|
+
expect(screen.getByTestId("received-container").textContent).toBe(
|
|
405
|
+
"function",
|
|
406
|
+
);
|
|
407
|
+
expect(screen.getByTestId("received-suggestion").textContent).toBe("3");
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it("should pass suggestions array through children render function", () => {
|
|
411
|
+
const Host = defineComponent({
|
|
412
|
+
components: { CopilotChatSuggestionView },
|
|
413
|
+
setup() {
|
|
414
|
+
return { suggestions: createSuggestions() };
|
|
415
|
+
},
|
|
416
|
+
template: `
|
|
417
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
418
|
+
<template #layout="{ suggestions }">
|
|
419
|
+
<div data-testid="suggestion-count">{{ suggestions.length }}</div>
|
|
420
|
+
</template>
|
|
421
|
+
</CopilotChatSuggestionView>
|
|
422
|
+
`,
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
renderInWrapper(Host);
|
|
426
|
+
expect(screen.getByTestId("suggestion-count").textContent).toBe("3");
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it("should pass loadingIndexes through children render function", () => {
|
|
430
|
+
const Host = defineComponent({
|
|
431
|
+
components: { CopilotChatSuggestionView },
|
|
432
|
+
setup() {
|
|
433
|
+
return {
|
|
434
|
+
suggestions: createSuggestions(),
|
|
435
|
+
loadingIndexes: [0, 2],
|
|
436
|
+
};
|
|
437
|
+
},
|
|
438
|
+
template: `
|
|
439
|
+
<CopilotChatSuggestionView :suggestions="suggestions" :loading-indexes="loadingIndexes">
|
|
440
|
+
<template #layout="{ loadingIndexes }">
|
|
441
|
+
<div data-testid="loading-indexes">{{ loadingIndexes.join(",") }}</div>
|
|
442
|
+
</template>
|
|
443
|
+
</CopilotChatSuggestionView>
|
|
444
|
+
`,
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
renderInWrapper(Host);
|
|
448
|
+
expect(screen.getByTestId("loading-indexes").textContent).toBe("0,2");
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
it("should allow custom layout via children render function", () => {
|
|
452
|
+
const Host = defineComponent({
|
|
453
|
+
components: { CopilotChatSuggestionView },
|
|
454
|
+
setup() {
|
|
455
|
+
return { suggestions: createSuggestions() };
|
|
456
|
+
},
|
|
457
|
+
template: `
|
|
458
|
+
<CopilotChatSuggestionView :suggestions="suggestions">
|
|
459
|
+
<template #layout="{ suggestions }">
|
|
460
|
+
<div data-testid="custom-layout">
|
|
461
|
+
<h3>Quick Actions</h3>
|
|
462
|
+
<p>Total: {{ suggestions.length }}</p>
|
|
463
|
+
</div>
|
|
464
|
+
</template>
|
|
465
|
+
</CopilotChatSuggestionView>
|
|
466
|
+
`,
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
renderInWrapper(Host);
|
|
470
|
+
const customLayout = screen.getByTestId("custom-layout");
|
|
471
|
+
expect(customLayout.textContent).toContain("Quick Actions");
|
|
472
|
+
expect(customLayout.textContent).toContain("Total: 3");
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
describe("5. className Override with Tailwind Strings", () => {
|
|
477
|
+
it("should apply className to container", () => {
|
|
478
|
+
const Host = defineComponent({
|
|
479
|
+
components: { CopilotChatSuggestionView },
|
|
480
|
+
setup() {
|
|
481
|
+
return { suggestions: createSuggestions() };
|
|
482
|
+
},
|
|
483
|
+
template: `
|
|
484
|
+
<CopilotChatSuggestionView
|
|
485
|
+
:suggestions="suggestions"
|
|
486
|
+
class="custom-root-class mt-4"
|
|
487
|
+
/>
|
|
488
|
+
`,
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
renderInWrapper(Host);
|
|
492
|
+
const containerEl = document.querySelector(".custom-root-class");
|
|
493
|
+
expect(containerEl).toBeTruthy();
|
|
494
|
+
expect(containerEl?.classList.contains("mt-4")).toBe(true);
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
it("should merge className with container slot class", () => {
|
|
498
|
+
const Host = defineComponent({
|
|
499
|
+
components: { CopilotChatSuggestionView },
|
|
500
|
+
setup() {
|
|
501
|
+
return { suggestions: createSuggestions() };
|
|
502
|
+
},
|
|
503
|
+
template: `
|
|
504
|
+
<CopilotChatSuggestionView :suggestions="suggestions" class="root-class">
|
|
505
|
+
<template #container="{ suggestions, onSelectSuggestion, containerClass, containerAttrs }">
|
|
506
|
+
<div
|
|
507
|
+
class="container-class"
|
|
508
|
+
:class="containerClass"
|
|
509
|
+
v-bind="containerAttrs"
|
|
510
|
+
data-testid="container-class"
|
|
511
|
+
>
|
|
512
|
+
<button
|
|
513
|
+
v-for="(suggestion, index) in suggestions"
|
|
514
|
+
:key="suggestion.title"
|
|
515
|
+
type="button"
|
|
516
|
+
@click="onSelectSuggestion(suggestion, index)"
|
|
517
|
+
>
|
|
518
|
+
{{ suggestion.title }}
|
|
519
|
+
</button>
|
|
520
|
+
</div>
|
|
521
|
+
</template>
|
|
522
|
+
</CopilotChatSuggestionView>
|
|
523
|
+
`,
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
renderInWrapper(Host);
|
|
527
|
+
const containerEl = screen.getByTestId("container-class");
|
|
528
|
+
expect(containerEl.classList.contains("container-class")).toBe(true);
|
|
529
|
+
expect(containerEl.classList.contains("root-class")).toBe(true);
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
it("should allow overriding default pointer-events-none", () => {
|
|
533
|
+
const Host = defineComponent({
|
|
534
|
+
components: { CopilotChatSuggestionView },
|
|
535
|
+
setup() {
|
|
536
|
+
return { suggestions: createSuggestions() };
|
|
537
|
+
},
|
|
538
|
+
template: `
|
|
539
|
+
<CopilotChatSuggestionView
|
|
540
|
+
:suggestions="suggestions"
|
|
541
|
+
class="pointer-events-auto"
|
|
542
|
+
/>
|
|
543
|
+
`,
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
renderInWrapper(Host);
|
|
547
|
+
const containerEl = document.querySelector(".pointer-events-auto");
|
|
548
|
+
expect(containerEl).toBeTruthy();
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
describe("6. Integration and Loading State Tests", () => {
|
|
553
|
+
it("should correctly render all slots with mixed customization", () => {
|
|
554
|
+
const onSelectSuggestion = vi.fn();
|
|
555
|
+
const Host = defineComponent({
|
|
556
|
+
components: { CopilotChatSuggestionView },
|
|
557
|
+
setup() {
|
|
558
|
+
return {
|
|
559
|
+
suggestions: createSuggestions(),
|
|
560
|
+
onSelectSuggestion,
|
|
561
|
+
};
|
|
562
|
+
},
|
|
563
|
+
template: `
|
|
564
|
+
<CopilotChatSuggestionView
|
|
565
|
+
:suggestions="suggestions"
|
|
566
|
+
class="container-style"
|
|
567
|
+
@select-suggestion="onSelectSuggestion"
|
|
568
|
+
>
|
|
569
|
+
<template #suggestion="{ suggestion, onSelect }">
|
|
570
|
+
<button class="suggestion-style" type="button" @click="onSelect">
|
|
571
|
+
{{ suggestion.title }}
|
|
572
|
+
</button>
|
|
573
|
+
</template>
|
|
574
|
+
</CopilotChatSuggestionView>
|
|
575
|
+
`,
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
renderInWrapper(Host);
|
|
579
|
+
expect(document.querySelector(".container-style")).toBeTruthy();
|
|
580
|
+
expect(document.querySelectorAll(".suggestion-style")).toHaveLength(3);
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
it("should show loading state for specific indexes", () => {
|
|
584
|
+
const Host = defineComponent({
|
|
585
|
+
components: { CopilotChatSuggestionView },
|
|
586
|
+
setup() {
|
|
587
|
+
return {
|
|
588
|
+
suggestions: createSuggestions(),
|
|
589
|
+
loadingIndexes: [1],
|
|
590
|
+
};
|
|
591
|
+
},
|
|
592
|
+
template: `
|
|
593
|
+
<CopilotChatSuggestionView
|
|
594
|
+
:suggestions="suggestions"
|
|
595
|
+
:loading-indexes="loadingIndexes"
|
|
596
|
+
/>
|
|
597
|
+
`,
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
renderInWrapper(Host);
|
|
601
|
+
const buttons = screen.getAllByRole("button");
|
|
602
|
+
expect(buttons[1]?.hasAttribute("disabled")).toBe(true);
|
|
603
|
+
});
|
|
604
|
+
|
|
605
|
+
it("should handle empty suggestions array", () => {
|
|
606
|
+
const Host = defineComponent({
|
|
607
|
+
components: { CopilotChatSuggestionView },
|
|
608
|
+
template: `
|
|
609
|
+
<CopilotChatSuggestionView :suggestions="[]" />
|
|
610
|
+
`,
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
renderInWrapper(Host);
|
|
614
|
+
const buttons = document.querySelectorAll("button");
|
|
615
|
+
expect(buttons).toHaveLength(0);
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it("should handle single suggestion", () => {
|
|
619
|
+
const Host = defineComponent({
|
|
620
|
+
components: { CopilotChatSuggestionView },
|
|
621
|
+
setup() {
|
|
622
|
+
return {
|
|
623
|
+
suggestions: [
|
|
624
|
+
{
|
|
625
|
+
title: "Only One",
|
|
626
|
+
message: "Single message",
|
|
627
|
+
isLoading: false,
|
|
628
|
+
},
|
|
629
|
+
] as Suggestion[],
|
|
630
|
+
};
|
|
631
|
+
},
|
|
632
|
+
template: `
|
|
633
|
+
<CopilotChatSuggestionView :suggestions="suggestions" />
|
|
634
|
+
`,
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
renderInWrapper(Host);
|
|
638
|
+
expect(screen.getByText("Only One")).toBeDefined();
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
it("should work with property objects and class strings mixed", () => {
|
|
642
|
+
const onClick = vi.fn();
|
|
643
|
+
const Host = defineComponent({
|
|
644
|
+
components: { CopilotChatSuggestionView },
|
|
645
|
+
setup() {
|
|
646
|
+
return {
|
|
647
|
+
suggestions: createSuggestions(),
|
|
648
|
+
onClick,
|
|
649
|
+
};
|
|
650
|
+
},
|
|
651
|
+
template: `
|
|
652
|
+
<CopilotChatSuggestionView
|
|
653
|
+
:suggestions="suggestions"
|
|
654
|
+
class="flex gap-2"
|
|
655
|
+
data-testid="mixed-container"
|
|
656
|
+
@click="onClick"
|
|
657
|
+
>
|
|
658
|
+
<template #suggestion="{ suggestion, onSelect }">
|
|
659
|
+
<button class="pill-style" type="button" @click.stop="onSelect">
|
|
660
|
+
{{ suggestion.title }}
|
|
661
|
+
</button>
|
|
662
|
+
</template>
|
|
663
|
+
</CopilotChatSuggestionView>
|
|
664
|
+
`,
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
renderInWrapper(Host);
|
|
668
|
+
const container = screen.getByTestId("mixed-container");
|
|
669
|
+
expect(container.classList.contains("flex")).toBe(true);
|
|
670
|
+
expect(container.classList.contains("gap-2")).toBe(true);
|
|
671
|
+
expect(document.querySelectorAll(".pill-style")).toHaveLength(3);
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
});
|