@copilotkit/vue 2.0.0-rc.1 → 2.0.0-rc.10
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/PARITY.md +13 -12
- package/README.md +1 -2
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts +3 -1
- package/dist/components/copilot-provider/CopilotKit.vue.d.ts.map +1 -1
- package/dist/hooks/use-copilot-action.d.ts.map +1 -1
- package/dist/hooks/use-frontend-tool.d.ts +1 -1
- package/dist/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/hooks/zod-parameters.d.ts +14 -0
- package/dist/hooks/zod-parameters.d.ts.map +1 -0
- package/dist/index.cjs +1 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +384 -14275
- package/dist/index.mjs.map +1 -1
- package/dist/use-render-activity-message-CTR_ziWV.js +18097 -0
- package/dist/use-render-activity-message-CTR_ziWV.js.map +1 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs +92 -0
- package/dist/use-render-activity-message-Dky9_GRG.cjs.map +1 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts +7 -0
- package/dist/v2/components/A2UIMessageRenderer.d.ts.map +1 -1
- package/dist/v2/components/A2UISurfaceActivityRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/LicenseWarningBanner.vue.d.ts.map +1 -1
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts +13 -45
- package/dist/v2/components/OpenGenerativeUIRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts +11 -2
- package/dist/v2/components/a2ui/A2UIBuiltInToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts +1 -1
- package/dist/v2/components/a2ui/A2UICatalogContext.d.ts.map +1 -1
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts +144 -0
- package/dist/v2/components/a2ui/A2UIRecoveryStates.d.ts.map +1 -0
- package/dist/v2/components/a2ui.d.ts +3 -7
- package/dist/v2/components/a2ui.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts +3 -1
- package/dist/v2/components/chat/CopilotChatAssistantMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts +16 -0
- package/dist/v2/components/chat/CopilotChatAssistantToolbarButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatAttachmentQueue.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAttachmentRenderer.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatAudioRecorder.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatFeedbackCommentPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts +21 -232
- package/dist/v2/components/chat/CopilotChatInput.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts +12 -0
- package/dist/v2/components/chat/CopilotChatInspectorButton.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts +22 -0
- package/dist/v2/components/chat/CopilotChatLightbox.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts +20 -0
- package/dist/v2/components/chat/CopilotChatMessageView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatReasoningMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionPill.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatSuggestionView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToggleButton.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts +32 -0
- package/dist/v2/components/chat/CopilotChatToolCallGroup.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotChatToolCallItem.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts +11 -1
- package/dist/v2/components/chat/CopilotChatToolCallsView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatUserMessage.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts +5 -0
- package/dist/v2/components/chat/CopilotChatWorkSummary.vue.d.ts.map +1 -0
- package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderCloseButton.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotModalHeaderTitle.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +1 -0
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +2 -0
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarWelcomeScreen.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/StreamingMarkdownDefault.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts +0 -1
- package/dist/v2/components/chat/copilotChatToolCallItemRender.d.ts.map +1 -1
- package/dist/v2/components/chat/index.d.ts +17 -1
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/inspector-shortcuts.d.ts +12 -0
- package/dist/v2/components/chat/inspector-shortcuts.d.ts.map +1 -0
- package/dist/v2/components/chat/message-feedback.d.ts +89 -0
- package/dist/v2/components/chat/message-feedback.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts +39 -0
- package/dist/v2/components/chat/tool-call-capture.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts +22 -0
- package/dist/v2/components/chat/tool-call-display-context.d.ts.map +1 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts +131 -0
- package/dist/v2/components/chat/tool-call-group-parts.d.ts.map +1 -0
- package/dist/v2/components/chat/turn-work.d.ts +33 -0
- package/dist/v2/components/chat/turn-work.d.ts.map +1 -0
- package/dist/v2/components/chat/types.d.ts +104 -5
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/components/chat/use-chat-labels.d.ts +8 -0
- package/dist/v2/components/chat/use-chat-labels.d.ts.map +1 -0
- package/dist/v2/components/chat/use-lightbox.d.ts +18 -0
- package/dist/v2/components/chat/use-lightbox.d.ts.map +1 -0
- package/dist/v2/components/icons/index.d.ts +968 -1
- package/dist/v2/components/icons/index.d.ts.map +1 -1
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts +55 -0
- package/dist/v2/components/ui/CopilotDropdownMenuContent.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts +40 -0
- package/dist/v2/components/ui/CopilotPopover.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts +37 -0
- package/dist/v2/components/ui/CopilotTooltip.vue.d.ts.map +1 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts +14 -0
- package/dist/v2/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/v2/components/ui/floating.d.ts +84 -0
- package/dist/v2/components/ui/floating.d.ts.map +1 -0
- package/dist/v2/components/ui/presence.d.ts +9 -0
- package/dist/v2/components/ui/presence.d.ts.map +1 -0
- package/dist/v2/components/ui/use-id.d.ts +9 -0
- package/dist/v2/components/ui/use-id.d.ts.map +1 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts +6 -0
- package/dist/v2/hooks/use-default-render-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-frontend-tool.d.ts +5 -0
- package/dist/v2/hooks/use-frontend-tool.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-activity-message.d.ts +13 -9
- package/dist/v2/hooks/use-render-activity-message.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-custom-messages.d.ts +5 -7
- package/dist/v2/hooks/use-render-custom-messages.d.ts.map +1 -1
- package/dist/v2/hooks/use-render-tool.d.ts +4 -0
- package/dist/v2/hooks/use-render-tool.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.d.cts +3 -0
- package/dist/v2/index.d.mts +3 -0
- package/dist/v2/index.d.ts +3 -0
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/index.mjs +197 -197
- package/dist/v2/index.mjs.map +1 -1
- package/dist/v2/lib/message-feedback.d.ts +33 -0
- package/dist/v2/lib/message-feedback.d.ts.map +1 -0
- package/dist/v2/lib/processPartialHtml.d.ts +1 -2
- package/dist/v2/lib/processPartialHtml.d.ts.map +1 -1
- package/dist/v2/lib/vue-core.d.ts +0 -1
- package/dist/v2/lib/vue-core.d.ts.map +1 -1
- package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.types.d.ts +56 -6
- package/dist/v2/providers/CopilotKitProvider.types.d.ts.map +1 -1
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts +6 -2
- package/dist/v2/providers/CopilotKitProvider.vue.d.ts.map +1 -1
- package/dist/v2/providers/index.d.ts +1 -1
- package/dist/v2/providers/index.d.ts.map +1 -1
- package/dist/v2/providers/keys.d.ts +8 -0
- package/dist/v2/providers/keys.d.ts.map +1 -1
- package/dist/v2/providers/types.d.ts +3 -37
- package/dist/v2/providers/types.d.ts.map +1 -1
- package/dist/v2/styles/CopilotKitStyles.d.ts +18 -0
- package/dist/v2/styles/CopilotKitStyles.d.ts.map +1 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts +2 -0
- package/dist/v2/types/defineToolCallRenderer.d.ts.map +1 -1
- package/dist/v2/types/human-in-the-loop.d.ts +8 -29
- package/dist/v2/types/human-in-the-loop.d.ts.map +1 -1
- package/dist/v2/types/interrupt.d.ts +1 -22
- package/dist/v2/types/interrupt.d.ts.map +1 -1
- package/dist/v2/types/vue-activity-message-renderer.d.ts +16 -15
- package/dist/v2/types/vue-activity-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-custom-message-renderer.d.ts +7 -16
- package/dist/v2/types/vue-custom-message-renderer.d.ts.map +1 -1
- package/dist/v2/types/vue-tool-call-renderer.d.ts +16 -28
- package/dist/v2/types/vue-tool-call-renderer.d.ts.map +1 -1
- package/package.json +14 -27
- package/src/__tests__/build-entries.test.ts +27 -0
- package/src/components/copilot-provider/CopilotKit.vue +4 -1
- package/src/hooks/__tests__/zod-parameters.test.ts +520 -0
- package/src/hooks/use-copilot-action.ts +2 -1
- package/src/hooks/use-frontend-tool.ts +3 -6
- package/src/hooks/zod-parameters.ts +162 -0
- package/src/v2/__tests__/exports.test.ts +4 -2
- package/src/v2/components/A2UIMessageRenderer.ts +56 -68
- package/src/v2/components/A2UISurfaceActivityRenderer.vue +11 -23
- package/src/v2/components/LicenseWarningBanner.vue +31 -15
- package/src/v2/components/OpenGenerativeUIRenderer.ts +51 -373
- package/src/v2/components/__tests__/A2UIBasicCatalogColors.test.ts +8 -9
- package/src/v2/components/__tests__/A2UICatalogContext.test.ts +1 -1
- package/src/v2/components/__tests__/A2UIMessageRenderer.test.ts +63 -36
- package/src/v2/components/__tests__/LicenseWarningBanner.test.ts +20 -0
- package/src/v2/components/__tests__/OpenGenerativeUIRenderer.test.ts +55 -6
- package/src/v2/components/a2ui/A2UIBuiltInToolCallRenderer.ts +15 -258
- package/src/v2/components/a2ui/A2UICatalogContext.ts +10 -102
- package/src/v2/components/a2ui/A2UIRecoveryStates.ts +444 -0
- package/src/v2/components/a2ui/__tests__/A2UIRecoveryStates.test.ts +175 -0
- package/src/v2/components/a2ui.ts +1 -1
- package/src/v2/components/chat/CopilotChat.vue +26 -40
- package/src/v2/components/chat/CopilotChatAssistantMessage.vue +267 -67
- package/src/v2/components/chat/CopilotChatAssistantToolbarButton.vue +46 -0
- package/src/v2/components/chat/CopilotChatAttachmentQueue.vue +150 -173
- package/src/v2/components/chat/CopilotChatAttachmentRenderer.vue +77 -20
- package/src/v2/components/chat/CopilotChatAudioRecorder.vue +2 -2
- package/src/v2/components/chat/CopilotChatFeedbackCommentPopover.vue +240 -0
- package/src/v2/components/chat/CopilotChatInput.vue +250 -191
- package/src/v2/components/chat/CopilotChatInspectorButton.vue +331 -0
- package/src/v2/components/chat/CopilotChatLightbox.vue +105 -0
- package/src/v2/components/chat/CopilotChatMessageView.vue +262 -87
- package/src/v2/components/chat/CopilotChatReasoningMessage.vue +52 -35
- package/src/v2/components/chat/CopilotChatSuggestionPill.vue +5 -14
- package/src/v2/components/chat/CopilotChatSuggestionView.vue +1 -4
- package/src/v2/components/chat/CopilotChatToggleButton.vue +3 -9
- package/src/v2/components/chat/CopilotChatToggleButtonCloseIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToggleButtonOpenIcon.ts +1 -1
- package/src/v2/components/chat/CopilotChatToolCallGroup.vue +353 -0
- package/src/v2/components/chat/CopilotChatToolCallItem.vue +24 -14
- package/src/v2/components/chat/CopilotChatToolCallsView.vue +194 -21
- package/src/v2/components/chat/CopilotChatUserMessage.vue +105 -42
- package/src/v2/components/chat/CopilotChatView.vue +37 -42
- package/src/v2/components/chat/CopilotChatWorkSummary.vue +111 -0
- package/src/v2/components/chat/CopilotModalHeader.vue +10 -8
- package/src/v2/components/chat/CopilotModalHeaderCloseButton.ts +7 -6
- package/src/v2/components/chat/CopilotModalHeaderTitle.ts +1 -4
- package/src/v2/components/chat/CopilotPopup.vue +3 -0
- package/src/v2/components/chat/CopilotPopupView.vue +1 -0
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +9 -19
- package/src/v2/components/chat/CopilotPopupWelcomeScreen.vue +5 -8
- package/src/v2/components/chat/CopilotSidebar.vue +5 -0
- package/src/v2/components/chat/CopilotSidebarView.vue +2 -0
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +24 -17
- package/src/v2/components/chat/CopilotSidebarWelcomeScreen.vue +7 -10
- package/src/v2/components/chat/StreamingMarkdownDefault.vue +3 -5
- package/src/v2/components/chat/__tests__/CopilotChat.labels.test.ts +19 -4
- package/src/v2/components/chat/__tests__/CopilotChatActivityRendering.e2e.test.ts +26 -9
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.inspector.test.ts +269 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.learningFeedback.test.ts +760 -0
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.slots.e2e.test.ts +3 -5
- package/src/v2/components/chat/__tests__/CopilotChatAssistantMessage.test.ts +2 -2
- package/src/v2/components/chat/__tests__/CopilotChatInput.addMenu.test.ts +328 -0
- package/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.ts +6 -3
- package/src/v2/components/chat/__tests__/CopilotChatInput.test.ts +55 -14
- package/src/v2/components/chat/__tests__/CopilotChatLightbox.test.ts +160 -0
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.test.ts +247 -403
- package/src/v2/components/chat/__tests__/CopilotChatMessageView.toolCallDisplay.test.ts +637 -0
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionPill.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotChatSuggestionView.slots.e2e.test.ts +3 -1
- package/src/v2/components/chat/__tests__/CopilotChatToolCallsView.learning.test.ts +75 -0
- package/src/v2/components/chat/__tests__/CopilotChatUserMessage.attachments.test.ts +143 -0
- package/src/v2/components/chat/__tests__/CopilotChatView.inputOverlay.test.ts +5 -4
- package/src/v2/components/chat/__tests__/CopilotChatView.rootWidth.test.ts +7 -33
- package/src/v2/components/chat/__tests__/CopilotModalHeader.slots.e2e.test.ts +1 -1
- package/src/v2/components/chat/__tests__/CopilotPopupView.slots.e2e.test.ts +3 -3
- package/src/v2/components/chat/__tests__/CopilotSidebarView.position.test.ts +126 -0
- package/src/v2/components/chat/__tests__/messageFeedbackDefaults.test.ts +33 -0
- package/src/v2/components/chat/__tests__/modalChatDisplayProps.test.ts +44 -0
- package/src/v2/components/chat/copilotChatToolCallItemRender.ts +3 -19
- package/src/v2/components/chat/index.ts +2 -1
- package/src/v2/components/chat/inspector-shortcuts.ts +34 -0
- package/src/v2/components/chat/message-feedback.ts +291 -0
- package/src/v2/components/chat/tool-call-capture.ts +55 -0
- package/src/v2/components/chat/tool-call-display-context.ts +28 -0
- package/src/v2/components/chat/tool-call-group-parts.ts +251 -0
- package/src/v2/components/chat/turn-work.ts +52 -0
- package/src/v2/components/chat/types.ts +114 -4
- package/src/v2/components/chat/use-chat-labels.ts +16 -0
- package/src/v2/components/chat/use-lightbox.ts +64 -0
- package/src/v2/components/icons/__tests__/icons.test.ts +72 -68
- package/src/v2/components/icons/index.ts +109 -23
- package/src/v2/components/ui/CopilotDropdownMenuContent.vue +465 -0
- package/src/v2/components/ui/CopilotPopover.vue +138 -0
- package/src/v2/components/ui/CopilotTooltip.vue +237 -0
- package/src/v2/components/ui/__tests__/CopilotTooltip.test.ts +168 -0
- package/src/v2/components/ui/dropdown-menu.ts +15 -0
- package/src/v2/components/ui/floating.ts +321 -0
- package/src/v2/components/ui/presence.ts +54 -0
- package/src/v2/components/ui/use-id.ts +16 -0
- package/src/v2/hooks/__tests__/use-frontend-tool.e2e.test.ts +62 -1
- package/src/v2/hooks/__tests__/use-render-activity-message.test.ts +105 -0
- package/src/v2/hooks/__tests__/use-render-tool.test.ts +3 -6
- package/src/v2/hooks/__tests__/zod-regression.test.ts +5 -4
- package/src/v2/hooks/use-default-render-tool.ts +123 -62
- package/src/v2/hooks/use-frontend-tool.ts +10 -10
- package/src/v2/hooks/use-render-activity-message.ts +27 -48
- package/src/v2/hooks/use-render-custom-messages.ts +14 -35
- package/src/v2/hooks/use-render-tool.ts +8 -0
- package/src/v2/index.ts +3 -0
- package/src/v2/lib/__tests__/message-feedback.test.ts +152 -0
- package/src/v2/lib/message-feedback.ts +120 -0
- package/src/v2/lib/processPartialHtml.ts +6 -21
- package/src/v2/lib/vue-core.ts +3 -5
- package/src/v2/providers/CopilotChatConfigurationProvider.vue +29 -2
- package/src/v2/providers/CopilotKitProvider.types.ts +57 -5
- package/src/v2/providers/CopilotKitProvider.vue +177 -114
- package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.openThread.test.ts +69 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.a2ui.test.ts +1 -1
- package/src/v2/providers/__tests__/CopilotKitProvider.headersAtSendTime.test.ts +3 -3
- package/src/v2/providers/__tests__/CopilotKitProvider.learning.test.ts +536 -0
- package/src/v2/providers/__tests__/CopilotKitProvider.test.ts +17 -33
- package/src/v2/providers/index.ts +4 -1
- package/src/v2/providers/keys.ts +12 -0
- package/src/v2/providers/types.ts +3 -38
- package/src/v2/styles/CopilotKitStyles.ts +95 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.client.test.ts +149 -0
- package/src/v2/styles/__tests__/CopilotKitStyles.ssr.test.ts +71 -0
- package/src/v2/types/__tests__/defineToolCallRenderer.test.ts +28 -33
- package/src/v2/types/defineToolCallRenderer.ts +9 -4
- package/src/v2/types/human-in-the-loop.ts +8 -32
- package/src/v2/types/interrupt.ts +7 -31
- package/src/v2/types/vue-activity-message-renderer.ts +24 -15
- package/src/v2/types/vue-custom-message-renderer.ts +12 -16
- package/src/v2/types/vue-tool-call-renderer.ts +23 -31
- package/vite.config.ts +5 -5
- package/dist/styles.css +0 -2
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts +0 -9
- package/dist/v2/components/chat/BasicMarkdown.vue.d.ts.map +0 -1
- package/dist/v2/lib/transcription-client.d.ts +0 -19
- package/dist/v2/lib/transcription-client.d.ts.map +0 -1
- package/scripts/scope-preflight.mjs +0 -100
- package/src/styles/globals.css +0 -233
- package/src/v2/components/chat/BasicMarkdown.vue +0 -158
- package/src/v2/components/chat/__tests__/BasicMarkdown.test.ts +0 -69
- package/src/v2/lib/__tests__/processPartialHtml.test.ts +0 -84
- package/src/v2/lib/__tests__/transcription-client.test.ts +0 -67
- package/src/v2/lib/transcription-client.ts +0 -151
|
@@ -36,6 +36,7 @@ const props = withDefaults(
|
|
|
36
36
|
{
|
|
37
37
|
messages: () => [],
|
|
38
38
|
autoScroll: true,
|
|
39
|
+
messageFeedback: true,
|
|
39
40
|
isRunning: false,
|
|
40
41
|
suggestions: () => [],
|
|
41
42
|
suggestionLoadingIndexes: () => [],
|
|
@@ -44,6 +45,7 @@ const props = withDefaults(
|
|
|
44
45
|
inputMode: "input",
|
|
45
46
|
inputToolsMenu: () => [],
|
|
46
47
|
width: undefined,
|
|
48
|
+
position: "right",
|
|
47
49
|
onFinishTranscribeWithAudio: undefined,
|
|
48
50
|
},
|
|
49
51
|
);
|
|
@@ -98,12 +100,9 @@ const headerTitle = computed(
|
|
|
98
100
|
CopilotChatDefaultLabels.modalHeaderTitle,
|
|
99
101
|
);
|
|
100
102
|
const asideClass = computed(() => [
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
"cpk
|
|
104
|
-
isSidebarOpen.value
|
|
105
|
-
? "cpk:translate-x-0"
|
|
106
|
-
: "cpk:translate-x-full cpk:pointer-events-none",
|
|
103
|
+
"copilotKitSidebar copilotKitWindow cpk-sidebar-view",
|
|
104
|
+
// Slides off its edge when closed.
|
|
105
|
+
!isSidebarOpen.value && "cpk-sidebar-view-closed",
|
|
107
106
|
attrs.class,
|
|
108
107
|
]);
|
|
109
108
|
const asideAttrs = computed(() => {
|
|
@@ -118,16 +117,19 @@ const asideStyle = computed(
|
|
|
118
117
|
paddingBottom: "env(safe-area-inset-bottom)",
|
|
119
118
|
}) as Record<string, string>,
|
|
120
119
|
);
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
// The page makes room on the docked edge (desktop only).
|
|
121
|
+
const bodyMarginStyle = computed(() => {
|
|
122
|
+
const margin =
|
|
123
|
+
props.position === "left" ? "margin-inline-start" : "margin-inline-end";
|
|
124
|
+
return `
|
|
123
125
|
@media (min-width: 768px) {
|
|
124
126
|
body {
|
|
125
|
-
margin
|
|
126
|
-
transition: margin
|
|
127
|
+
${margin}: ${widthToMargin(resolvedSidebarWidth.value)};
|
|
128
|
+
transition: ${margin} ${SIDEBAR_TRANSITION_MS}ms ease;
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
);
|
|
131
|
+
`;
|
|
132
|
+
});
|
|
131
133
|
|
|
132
134
|
function widthToCss(width: number | string): string {
|
|
133
135
|
return typeof width === "number" ? `${width}px` : width;
|
|
@@ -268,13 +270,18 @@ onBeforeUnmount(() => {
|
|
|
268
270
|
:open="openSidebar"
|
|
269
271
|
:close="closeSidebar"
|
|
270
272
|
>
|
|
271
|
-
<CopilotChatToggleButton
|
|
273
|
+
<CopilotChatToggleButton
|
|
274
|
+
:class="
|
|
275
|
+
position === 'left' ? 'cpk-sidebar-view-toggle-button-left' : undefined
|
|
276
|
+
"
|
|
277
|
+
/>
|
|
272
278
|
</slot>
|
|
273
279
|
|
|
274
280
|
<aside
|
|
275
281
|
ref="sidebarRef"
|
|
276
282
|
data-copilotkit
|
|
277
283
|
data-copilot-sidebar
|
|
284
|
+
:data-position="position"
|
|
278
285
|
:class="asideClass"
|
|
279
286
|
:style="asideStyle"
|
|
280
287
|
:aria-label="
|
|
@@ -284,9 +291,7 @@ onBeforeUnmount(() => {
|
|
|
284
291
|
role="complementary"
|
|
285
292
|
v-bind="asideAttrs"
|
|
286
293
|
>
|
|
287
|
-
<div
|
|
288
|
-
class="cpk:flex cpk:h-full cpk:w-full cpk:flex-col cpk:overflow-hidden"
|
|
289
|
-
>
|
|
294
|
+
<div class="cpk-sidebar-view-panel">
|
|
290
295
|
<slot
|
|
291
296
|
name="header"
|
|
292
297
|
:title="headerTitle"
|
|
@@ -296,7 +301,7 @@ onBeforeUnmount(() => {
|
|
|
296
301
|
<CopilotModalHeader :title="headerTitle" />
|
|
297
302
|
</slot>
|
|
298
303
|
|
|
299
|
-
<div class="cpk
|
|
304
|
+
<div class="cpk-sidebar-view-chat" data-sidebar-chat>
|
|
300
305
|
<CopilotChatView
|
|
301
306
|
:messages="messages"
|
|
302
307
|
:auto-scroll="autoScroll"
|
|
@@ -307,6 +312,8 @@ onBeforeUnmount(() => {
|
|
|
307
312
|
:input-value="inputValue"
|
|
308
313
|
:input-mode="inputMode"
|
|
309
314
|
:input-tools-menu="inputToolsMenu"
|
|
315
|
+
:tool-call-display="toolCallDisplay"
|
|
316
|
+
:message-feedback="messageFeedback"
|
|
310
317
|
:on-finish-transcribe-with-audio="onFinishTranscribeWithAudio"
|
|
311
318
|
v-bind="chatViewEventProps"
|
|
312
319
|
>
|
|
@@ -127,26 +127,23 @@ const inputEventProps = computed(() => {
|
|
|
127
127
|
<slot name="layout" v-bind="layoutSlotProps">
|
|
128
128
|
<div
|
|
129
129
|
data-copilotkit
|
|
130
|
-
class="cpk
|
|
130
|
+
class="cpk-sidebar-view-welcome-screen"
|
|
131
131
|
data-testid="copilot-sidebar-welcome-screen"
|
|
132
132
|
>
|
|
133
|
-
<div
|
|
134
|
-
class="cpk:flex-1 cpk:flex cpk:flex-col cpk:items-center cpk:justify-center cpk:px-4"
|
|
135
|
-
>
|
|
133
|
+
<div class="cpk-sidebar-view-welcome-screen-message">
|
|
136
134
|
<slot name="welcome-message">
|
|
137
|
-
<h1
|
|
138
|
-
class="cpk:text-xl cpk:sm:text-2xl cpk:font-medium cpk:text-foreground cpk:text-center"
|
|
139
|
-
>
|
|
135
|
+
<h1 class="cpk-chat-view-welcome-message">
|
|
140
136
|
{{ labels.welcomeMessageText }}
|
|
141
137
|
</h1>
|
|
142
138
|
</slot>
|
|
143
139
|
</div>
|
|
144
140
|
|
|
145
|
-
<div class="cpk
|
|
146
|
-
<div class="cpk
|
|
147
|
-
<div class="cpk
|
|
141
|
+
<div class="cpk-sidebar-view-welcome-screen-footer">
|
|
142
|
+
<div class="cpk-sidebar-view-welcome-screen-content">
|
|
143
|
+
<div class="cpk-sidebar-view-welcome-screen-suggestions">
|
|
148
144
|
<slot name="suggestion-view" v-bind="suggestionViewSlotProps">
|
|
149
145
|
<CopilotChatSuggestionView
|
|
146
|
+
class="cpk-chat-view-suggestion-view"
|
|
150
147
|
:suggestions="suggestions"
|
|
151
148
|
:loading-indexes="loadingIndexes"
|
|
152
149
|
@select-suggestion="onSelectSuggestion"
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, h, watchEffect } from "vue";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type VueStreamingMarkdownNodeRenderer,
|
|
6
|
-
} from "@copilotkit/markdown-renderer/vue";
|
|
3
|
+
import { StreamingMarkdownRenderer } from "@copilotkit/markdown-renderer/vue";
|
|
4
|
+
import type { VueStreamingMarkdownNodeRenderer } from "@copilotkit/markdown-renderer/vue";
|
|
7
5
|
import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown-renderer";
|
|
8
6
|
import type { StreamingMarkdownParserOptions } from "@copilotkit/markdown-renderer";
|
|
9
7
|
import type { DefaultMarkdownRendererProps } from "../../providers/markdown-renderer";
|
|
@@ -29,7 +27,7 @@ const defaultCodeBlockRenderer: VueStreamingMarkdownNodeRenderer = (
|
|
|
29
27
|
{
|
|
30
28
|
"data-streaming-markdown-node": "code-block",
|
|
31
29
|
"data-node-open": String(!node.closed),
|
|
32
|
-
class: "cpk
|
|
30
|
+
class: "cpk-markdown-code-block",
|
|
33
31
|
},
|
|
34
32
|
[h("code", { "data-code-info": node.info ?? undefined }, node.text)],
|
|
35
33
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { defineComponent, nextTick, onMounted } from "vue";
|
|
3
3
|
import { fireEvent, render, screen } from "@testing-library/vue";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ReasoningMessage } from "@ag-ui/core";
|
|
5
5
|
import type { Attachment } from "@copilotkit/shared";
|
|
6
6
|
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
7
7
|
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
@@ -16,6 +16,8 @@ import { CopilotModalHeader, CopilotSidebarView } from "../index";
|
|
|
16
16
|
// hard-coded English.
|
|
17
17
|
const germanLabels: Partial<Record<keyof CopilotChatLabels, string>> = {
|
|
18
18
|
reasoningMessageThinkingLabel: "Denkt nach…",
|
|
19
|
+
reasoningMessageThoughtForLabel: "Gedacht für {duration}",
|
|
20
|
+
reasoningMessageDurationFewSeconds: "ein paar Sekunden",
|
|
19
21
|
chatInputSlashMenuLabel: "Befehle",
|
|
20
22
|
chatInputSlashMenuEmptyText: "Keine Befehle gefunden",
|
|
21
23
|
attachmentRemoveButtonLabel: "Anhang entfernen",
|
|
@@ -26,11 +28,11 @@ const germanLabels: Partial<Record<keyof CopilotChatLabels, string>> = {
|
|
|
26
28
|
sidebarLabel: "Chat-Seitenleiste",
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
const reasoning = {
|
|
31
|
+
const reasoning: ReasoningMessage = {
|
|
30
32
|
id: "reasoning-1",
|
|
31
33
|
role: "reasoning",
|
|
32
34
|
content: "",
|
|
33
|
-
}
|
|
35
|
+
};
|
|
34
36
|
|
|
35
37
|
const video: Attachment = {
|
|
36
38
|
id: "clip",
|
|
@@ -66,7 +68,7 @@ function renderWithLabels(template: string) {
|
|
|
66
68
|
return {
|
|
67
69
|
labels: germanLabels,
|
|
68
70
|
reasoning,
|
|
69
|
-
reasoningMessages: [reasoning]
|
|
71
|
+
reasoningMessages: [reasoning],
|
|
70
72
|
attachments: [video],
|
|
71
73
|
toolsMenu: [{ label: "Say hi", action: vi.fn() }],
|
|
72
74
|
};
|
|
@@ -112,6 +114,19 @@ describe("chat strings from labels", () => {
|
|
|
112
114
|
expect(screen.queryByText("Thinking…")).toBeNull();
|
|
113
115
|
});
|
|
114
116
|
|
|
117
|
+
it("uses the configured duration labels once the model is done", () => {
|
|
118
|
+
renderWithLabels(`
|
|
119
|
+
<CopilotChatReasoningMessage
|
|
120
|
+
:message="reasoning"
|
|
121
|
+
:messages="reasoningMessages"
|
|
122
|
+
:is-running="false"
|
|
123
|
+
/>
|
|
124
|
+
`);
|
|
125
|
+
|
|
126
|
+
expect(screen.getByText("Gedacht für ein paar Sekunden")).toBeDefined();
|
|
127
|
+
expect(screen.queryByText(/Thought for/)).toBeNull();
|
|
128
|
+
});
|
|
129
|
+
|
|
115
130
|
it("passes the elapsed reasoning time to a custom header", async () => {
|
|
116
131
|
vi.useFakeTimers();
|
|
117
132
|
renderWithLabels(`
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "@testing-library/vue";
|
|
8
8
|
import { defineComponent, ref, toRaw } from "vue";
|
|
9
9
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
10
|
+
import type * as CoreModule from "@copilotkit/core";
|
|
10
11
|
import type { AbstractAgent } from "@ag-ui/client";
|
|
11
12
|
import { EventType } from "@ag-ui/client";
|
|
12
13
|
import type { A2UITheme as Theme } from "../../../types";
|
|
@@ -160,11 +161,25 @@ vi.mock("phoenix", () => ({
|
|
|
160
161
|
Socket: MockPhoenixSocket,
|
|
161
162
|
}));
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
// Run the real core controller against a fake websandbox
|
|
165
|
+
vi.mock("@copilotkit/core", async (importOriginal) => {
|
|
166
|
+
const actual = await importOriginal<typeof CoreModule>();
|
|
167
|
+
class TestOpenGenerativeUIController
|
|
168
|
+
extends actual.ɵOpenGenerativeUIController
|
|
169
|
+
{
|
|
170
|
+
constructor() {
|
|
171
|
+
super({
|
|
172
|
+
loadWebsandbox: async () => ({
|
|
173
|
+
create: (...args) => mockWebsandboxCreate(...args),
|
|
174
|
+
}),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
...actual,
|
|
180
|
+
ɵOpenGenerativeUIController: TestOpenGenerativeUIController,
|
|
181
|
+
};
|
|
182
|
+
});
|
|
168
183
|
|
|
169
184
|
function jsonResponse(body: unknown, status = 200): Response {
|
|
170
185
|
return {
|
|
@@ -667,13 +682,15 @@ describe("CopilotChat activity message rendering", () => {
|
|
|
667
682
|
|
|
668
683
|
renderOpenGenerativeUIChat();
|
|
669
684
|
|
|
685
|
+
// The restored chat can remount the activity while it reconnects, so wait
|
|
686
|
+
// until exactly one sandbox, the restored one, is alive.
|
|
670
687
|
await waitFor(() => {
|
|
671
|
-
|
|
688
|
+
const created = mockWebsandboxCreate.mock.calls.length;
|
|
689
|
+
expect(created).toBeGreaterThanOrEqual(2);
|
|
690
|
+
expect(mockWebsandboxDestroy).toHaveBeenCalledTimes(created - 1);
|
|
672
691
|
});
|
|
673
|
-
expect(mockWebsandboxCreate.mock.calls
|
|
692
|
+
expect(mockWebsandboxCreate.mock.calls.at(-1)?.[1]).toMatchObject({
|
|
674
693
|
frameContent: restoredHtml,
|
|
675
694
|
});
|
|
676
|
-
|
|
677
|
-
expect(mockWebsandboxDestroy).toHaveBeenCalledTimes(1);
|
|
678
695
|
});
|
|
679
696
|
});
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { computed, defineComponent, h, nextTick, provide } from "vue";
|
|
3
|
+
import type { Component } from "vue";
|
|
4
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/vue";
|
|
5
|
+
import type { AssistantMessage } from "@ag-ui/core";
|
|
6
|
+
import CopilotChatAssistantMessage from "../CopilotChatAssistantMessage.vue";
|
|
7
|
+
import CopilotChatConfigurationProvider from "../../../providers/CopilotChatConfigurationProvider.vue";
|
|
8
|
+
import CopilotKitProvider from "../../../providers/CopilotKitProvider.vue";
|
|
9
|
+
import { InspectorKey } from "../../../providers/keys";
|
|
10
|
+
import { ɵresetInspectorShortcuts } from "../inspector-shortcuts";
|
|
11
|
+
|
|
12
|
+
const THREAD_ID = "thread-inspector";
|
|
13
|
+
const message: AssistantMessage = {
|
|
14
|
+
id: "message-1",
|
|
15
|
+
role: "assistant",
|
|
16
|
+
content: "Inspect me",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function renderMessage({
|
|
20
|
+
enabled = true,
|
|
21
|
+
openInspector = vi.fn(),
|
|
22
|
+
slots = {},
|
|
23
|
+
before,
|
|
24
|
+
}: {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
openInspector?: ReturnType<typeof vi.fn>;
|
|
27
|
+
slots?: Record<string, unknown>;
|
|
28
|
+
before?: () => unknown;
|
|
29
|
+
} = {}) {
|
|
30
|
+
const InspectorContext = defineComponent({
|
|
31
|
+
setup(_, { slots: children }) {
|
|
32
|
+
provide(InspectorKey, {
|
|
33
|
+
isInspectorEnabled: computed(() => enabled),
|
|
34
|
+
openInspector,
|
|
35
|
+
});
|
|
36
|
+
return () => children.default?.();
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const Harness = defineComponent({
|
|
40
|
+
setup() {
|
|
41
|
+
return () =>
|
|
42
|
+
h(CopilotKitProvider, null, {
|
|
43
|
+
default: () =>
|
|
44
|
+
h(InspectorContext, null, {
|
|
45
|
+
default: () =>
|
|
46
|
+
h(
|
|
47
|
+
CopilotChatConfigurationProvider,
|
|
48
|
+
{ threadId: THREAD_ID },
|
|
49
|
+
{
|
|
50
|
+
default: () => [
|
|
51
|
+
before?.(),
|
|
52
|
+
h(
|
|
53
|
+
CopilotChatAssistantMessage as Component,
|
|
54
|
+
{ message },
|
|
55
|
+
slots,
|
|
56
|
+
),
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
),
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
render(Harness);
|
|
65
|
+
return { openInspector };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const expectedRequest = {
|
|
69
|
+
messageId: message.id,
|
|
70
|
+
threadId: THREAD_ID,
|
|
71
|
+
agentId: "default",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
describe("CopilotChatAssistantMessage Inspector button", () => {
|
|
75
|
+
afterEach(() => {
|
|
76
|
+
ɵresetInspectorShortcuts();
|
|
77
|
+
document.body.innerHTML = "";
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("renders no Inspector button while the Inspector is off", () => {
|
|
81
|
+
renderMessage({ enabled: false });
|
|
82
|
+
|
|
83
|
+
expect(
|
|
84
|
+
screen.queryByRole("button", { name: /copilotkit inspector/i }),
|
|
85
|
+
).toBeNull();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("renders the local Inspector button and opens it from the toolbar", async () => {
|
|
89
|
+
const { openInspector } = renderMessage();
|
|
90
|
+
|
|
91
|
+
const inspectorButton = screen.getByRole("button", {
|
|
92
|
+
name: "CopilotKit Inspector (local only)",
|
|
93
|
+
});
|
|
94
|
+
const inspectorIcon = screen.getByTestId("copilot-inspector-icon");
|
|
95
|
+
expect(inspectorIcon.classList.contains("lucide-wrench")).toBe(true);
|
|
96
|
+
expect(inspectorButton.textContent).toBe("");
|
|
97
|
+
expect(inspectorButton.getAttribute("aria-haspopup")).toBe("menu");
|
|
98
|
+
expect(inspectorButton.getAttribute("aria-expanded")).toBe("false");
|
|
99
|
+
expect(screen.queryByRole("menu")).toBeNull();
|
|
100
|
+
|
|
101
|
+
await fireEvent.pointerEnter(inspectorButton, { pointerType: "mouse" });
|
|
102
|
+
const item = await screen.findByRole("menuitem", {
|
|
103
|
+
name: "View in Inspector Open this message in the Inspector",
|
|
104
|
+
});
|
|
105
|
+
expect(inspectorButton.getAttribute("aria-expanded")).toBe("true");
|
|
106
|
+
expect(screen.getByRole("menu").classList).toContain(
|
|
107
|
+
"cpk-inspector-button-menu",
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
await fireEvent.click(item);
|
|
111
|
+
|
|
112
|
+
expect(openInspector).toHaveBeenCalledWith(expectedRequest);
|
|
113
|
+
await waitFor(() => expect(screen.queryByRole("menu")).toBeNull());
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it.each(["click", "hover then click", "Enter", " "])(
|
|
117
|
+
"opens Inspector directly on %s",
|
|
118
|
+
async (interaction) => {
|
|
119
|
+
const { openInspector } = renderMessage();
|
|
120
|
+
const trigger = screen.getByTestId("copilot-inspector-button");
|
|
121
|
+
if (interaction === "hover then click") {
|
|
122
|
+
await fireEvent.pointerEnter(trigger, { pointerType: "mouse" });
|
|
123
|
+
expect(screen.getByRole("menu")).toBeDefined();
|
|
124
|
+
}
|
|
125
|
+
if (interaction.includes("click")) {
|
|
126
|
+
await fireEvent.pointerDown(trigger, { button: 0 });
|
|
127
|
+
if (interaction === "click") {
|
|
128
|
+
expect(screen.queryByRole("menu")).toBeNull();
|
|
129
|
+
}
|
|
130
|
+
await fireEvent.click(trigger);
|
|
131
|
+
} else {
|
|
132
|
+
await fireEvent.keyDown(trigger, { key: interaction });
|
|
133
|
+
}
|
|
134
|
+
expect(openInspector).toHaveBeenCalledExactlyOnceWith(expectedRequest);
|
|
135
|
+
await waitFor(() => expect(screen.queryByRole("menu")).toBeNull());
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
it.each(["hover", "keyboard"])(
|
|
140
|
+
"preserves the appropriate focus when opening by %s",
|
|
141
|
+
async (interaction) => {
|
|
142
|
+
renderMessage({
|
|
143
|
+
before: () => h("textarea", { "aria-label": "Chat input" }),
|
|
144
|
+
});
|
|
145
|
+
const input = screen.getByRole("textbox", { name: "Chat input" });
|
|
146
|
+
input.focus();
|
|
147
|
+
const trigger = screen.getByTestId("copilot-inspector-button");
|
|
148
|
+
if (interaction === "hover") {
|
|
149
|
+
await fireEvent.pointerEnter(trigger, { pointerType: "mouse" });
|
|
150
|
+
} else {
|
|
151
|
+
trigger.focus();
|
|
152
|
+
await fireEvent.keyDown(trigger, { key: "ArrowDown" });
|
|
153
|
+
}
|
|
154
|
+
const menu = await screen.findByRole("menu");
|
|
155
|
+
if (interaction === "hover") {
|
|
156
|
+
expect(document.activeElement).toBe(input);
|
|
157
|
+
} else {
|
|
158
|
+
await waitFor(() =>
|
|
159
|
+
expect(menu.contains(document.activeElement)).toBe(true),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
it("Escape closes a keyboard-opened menu and returns focus to the button", async () => {
|
|
166
|
+
renderMessage();
|
|
167
|
+
const trigger = screen.getByTestId("copilot-inspector-button");
|
|
168
|
+
trigger.focus();
|
|
169
|
+
await fireEvent.keyDown(trigger, { key: "ArrowDown" });
|
|
170
|
+
const menu = await screen.findByRole("menu");
|
|
171
|
+
await waitFor(() =>
|
|
172
|
+
expect(menu.contains(document.activeElement)).toBe(true),
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
await fireEvent.keyDown(document.activeElement!, { key: "Escape" });
|
|
176
|
+
|
|
177
|
+
await waitFor(() => expect(screen.queryByRole("menu")).toBeNull());
|
|
178
|
+
expect(document.activeElement).toBe(trigger);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("dismisses the hover menu when the pointer leaves", async () => {
|
|
182
|
+
renderMessage();
|
|
183
|
+
const trigger = screen.getByTestId("copilot-inspector-button");
|
|
184
|
+
await fireEvent.pointerEnter(trigger, { pointerType: "mouse" });
|
|
185
|
+
const menu = await screen.findByRole("menu");
|
|
186
|
+
await fireEvent.pointerLeave(trigger, { pointerType: "mouse" });
|
|
187
|
+
await fireEvent.pointerEnter(menu, { pointerType: "mouse" });
|
|
188
|
+
await new Promise((resolve) => setTimeout(resolve, 220));
|
|
189
|
+
expect(screen.getByRole("menu")).toBeDefined();
|
|
190
|
+
await fireEvent.pointerLeave(menu, { pointerType: "mouse" });
|
|
191
|
+
await waitFor(() => expect(screen.queryByRole("menu")).toBeNull());
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("hides the shortcut until the page reloads", async () => {
|
|
195
|
+
renderMessage();
|
|
196
|
+
await fireEvent.pointerEnter(
|
|
197
|
+
screen.getByTestId("copilot-inspector-button"),
|
|
198
|
+
{ pointerType: "mouse" },
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
await fireEvent.click(
|
|
202
|
+
await screen.findByRole("menuitem", {
|
|
203
|
+
name: "Hide this icon Until you reload this page",
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
206
|
+
await nextTick();
|
|
207
|
+
|
|
208
|
+
expect(screen.queryByTestId("copilot-inspector-button")).toBeNull();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("replaces the default Inspector button with the inspector-button slot", async () => {
|
|
212
|
+
const { openInspector } = renderMessage({
|
|
213
|
+
slots: {
|
|
214
|
+
"inspector-button": ({ onInspect }: { onInspect: () => void }) =>
|
|
215
|
+
h("button", { type: "button", onClick: onInspect }, "Custom inspect"),
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
expect(screen.queryByTestId("copilot-inspector-button")).toBeNull();
|
|
220
|
+
await fireEvent.click(
|
|
221
|
+
screen.getByRole("button", { name: "Custom inspect" }),
|
|
222
|
+
);
|
|
223
|
+
expect(openInspector).toHaveBeenCalledExactlyOnceWith(expectedRequest);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("does not render the inspector-button slot while the Inspector is off", () => {
|
|
227
|
+
renderMessage({
|
|
228
|
+
enabled: false,
|
|
229
|
+
slots: {
|
|
230
|
+
"inspector-button": () => h("button", "Custom inspect"),
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
expect(screen.queryByRole("button", { name: "Custom inspect" })).toBeNull();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
describe("CopilotChatAssistantMessage toolbar tooltips", () => {
|
|
239
|
+
afterEach(() => {
|
|
240
|
+
document.body.innerHTML = "";
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it("shows each toolbar label as a tooltip instead of a title", async () => {
|
|
244
|
+
render(
|
|
245
|
+
defineComponent({
|
|
246
|
+
setup: () => () =>
|
|
247
|
+
h(CopilotKitProvider, null, {
|
|
248
|
+
default: () =>
|
|
249
|
+
h(CopilotChatAssistantMessage as Component, {
|
|
250
|
+
message,
|
|
251
|
+
onRegenerate: () => {},
|
|
252
|
+
}),
|
|
253
|
+
}),
|
|
254
|
+
}),
|
|
255
|
+
);
|
|
256
|
+
const copy = screen.getByTestId("copilot-copy-button");
|
|
257
|
+
expect(copy.hasAttribute("title")).toBe(false);
|
|
258
|
+
|
|
259
|
+
await fireEvent.focus(copy);
|
|
260
|
+
const tooltip = screen.getByRole("tooltip");
|
|
261
|
+
expect(tooltip.textContent).toBe("Copy");
|
|
262
|
+
expect(tooltip.getAttribute("data-side")).toBe("bottom");
|
|
263
|
+
expect(copy.getAttribute("aria-describedby")).toBe(tooltip.id);
|
|
264
|
+
await fireEvent.blur(copy);
|
|
265
|
+
|
|
266
|
+
await fireEvent.focus(screen.getByRole("button", { name: "Regenerate" }));
|
|
267
|
+
expect(screen.getByRole("tooltip").textContent).toBe("Regenerate");
|
|
268
|
+
});
|
|
269
|
+
});
|