@assistant-ui/react 0.14.24 → 0.14.27
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/README.md +1 -1
- package/dist/augmentations.d.ts.map +1 -1
- package/dist/client/ExternalThread.d.ts +6 -4
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +2 -1
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/client/InMemoryThreadList.d.ts +0 -1
- package/dist/client/InMemoryThreadList.d.ts.map +1 -1
- package/dist/client/InMemoryThreadList.js +4 -1
- package/dist/client/InMemoryThreadList.js.map +1 -1
- package/dist/client/SingleThreadList.d.ts +0 -1
- package/dist/client/SingleThreadList.d.ts.map +1 -1
- package/dist/context/ReadonlyStore.d.ts +0 -1
- package/dist/context/ReadonlyStore.d.ts.map +1 -1
- package/dist/context/providers/MessageProvider.d.ts +0 -1
- package/dist/context/providers/MessageProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadViewportProvider.d.ts +0 -1
- package/dist/context/providers/ThreadViewportProvider.d.ts.map +1 -1
- package/dist/context/react/ThreadViewportContext.d.ts +15 -16
- package/dist/context/react/ThreadViewportContext.d.ts.map +1 -1
- package/dist/context/react/utils/createContextHook.d.ts +0 -1
- package/dist/context/react/utils/createContextHook.d.ts.map +1 -1
- package/dist/context/react/utils/createContextStoreHook.d.ts +2 -3
- package/dist/context/react/utils/createContextStoreHook.d.ts.map +1 -1
- package/dist/context/react/utils/createStateHookForRuntime.d.ts +0 -1
- package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +1 -1
- package/dist/context/react/utils/ensureBinding.d.ts.map +1 -1
- package/dist/context/react/utils/useRuntimeState.d.ts +0 -1
- package/dist/context/react/utils/useRuntimeState.d.ts.map +1 -1
- package/dist/context/stores/ThreadViewport.d.ts +25 -15
- package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
- package/dist/devtools/DevToolsHooks.d.ts +0 -1
- package/dist/devtools/DevToolsHooks.d.ts.map +1 -1
- package/dist/hooks/useMessageQuote.d.ts +0 -1
- package/dist/hooks/useMessageQuote.d.ts.map +1 -1
- package/dist/hooks/useMessageTiming.d.ts +0 -1
- package/dist/hooks/useMessageTiming.d.ts.map +1 -1
- package/dist/hooks/useToolCallElapsed.d.ts.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/internal.d.ts +0 -2
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts +0 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.d.ts +11 -2
- package/dist/legacy-runtime/cloud/auiV0.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.js +31 -2
- package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts +1 -5
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts +0 -1
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +0 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts +0 -1
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/MessageContext.d.ts +0 -1
- package/dist/legacy-runtime/hooks/MessageContext.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +0 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts +0 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +0 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts +1 -4
- package/dist/legacy-runtime/runtime-cores/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useLatestRef.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.d.ts +12 -7
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +29 -7
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.d.ts +0 -1
- package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js +32 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js.map +1 -1
- package/dist/mcp-apps/app-frame.d.ts +1 -12
- package/dist/mcp-apps/app-frame.d.ts.map +1 -1
- package/dist/mcp-apps/app-frame.js +1 -1
- package/dist/mcp-apps/app-frame.js.map +1 -1
- package/dist/mcp-apps/bridge.d.ts +0 -1
- package/dist/mcp-apps/bridge.d.ts.map +1 -1
- package/dist/mcp-apps/bridge.js +4 -3
- package/dist/mcp-apps/bridge.js.map +1 -1
- package/dist/mcp-apps/types.d.ts +10 -7
- package/dist/mcp-apps/types.d.ts.map +1 -1
- package/dist/mcp-apps/types.js.map +1 -1
- package/dist/mcp-apps/utils.d.ts +0 -1
- package/dist/mcp-apps/utils.d.ts.map +1 -1
- package/dist/model-context/frame/useAssistantFrameHost.d.ts +1 -6
- package/dist/model-context/frame/useAssistantFrameHost.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.d.ts +0 -1
- package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts +1 -4
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts +0 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts +1 -5
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts +0 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts +0 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarInteractionContext.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts +0 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.d.ts +0 -1
- package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts +0 -1
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts +0 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts +1 -6
- package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts.map +1 -1
- package/dist/primitives/actionBar.d.ts +0 -2
- package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts +0 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts +0 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts +0 -1
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts +0 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts +0 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/scope.d.ts +0 -1
- package/dist/primitives/actionBarMore/scope.d.ts.map +1 -1
- package/dist/primitives/actionBarMore.d.ts +0 -2
- package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts +6 -4
- package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.js +2 -2
- package/dist/primitives/assistantModal/AssistantModalAnchor.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts +4 -2
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +2 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts +0 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts +6 -4
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.js +2 -2
- package/dist/primitives/assistantModal/AssistantModalTrigger.js.map +1 -1
- package/dist/primitives/assistantModal/popoverRenderPrimitives.d.ts +14 -0
- package/dist/primitives/assistantModal/popoverRenderPrimitives.d.ts.map +1 -0
- package/dist/primitives/assistantModal/popoverRenderPrimitives.js +10 -0
- package/dist/primitives/assistantModal/popoverRenderPrimitives.js.map +1 -0
- package/dist/primitives/assistantModal/scope.d.ts +0 -1
- package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
- package/dist/primitives/assistantModal.d.ts +0 -2
- package/dist/primitives/attachment/AttachmentName.d.ts +0 -1
- package/dist/primitives/attachment/AttachmentName.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.d.ts +0 -1
- package/dist/primitives/attachment/AttachmentRemove.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.d.ts +0 -1
- package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.d.ts +0 -1
- package/dist/primitives/attachment/AttachmentThumb.d.ts.map +1 -1
- package/dist/primitives/attachment.d.ts +0 -2
- package/dist/primitives/branchPicker/BranchPickerCount.d.ts +0 -1
- package/dist/primitives/branchPicker/BranchPickerCount.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts +0 -1
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.d.ts +0 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +0 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +0 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
- package/dist/primitives/branchPicker.d.ts +0 -2
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts +0 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts +0 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts.map +1 -1
- package/dist/primitives/chainOfThought.d.ts +0 -2
- package/dist/primitives/composer/ComposerAddAttachment.d.ts +5 -6
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts +0 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts +0 -1
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCompactContext.d.ts +9 -0
- package/dist/primitives/composer/ComposerCompactContext.d.ts.map +1 -0
- package/dist/primitives/composer/ComposerCompactContext.js +11 -0
- package/dist/primitives/composer/ComposerCompactContext.js.map +1 -0
- package/dist/primitives/composer/ComposerDictate.d.ts +0 -1
- package/dist/primitives/composer/ComposerDictate.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts +0 -1
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +0 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +17 -2
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInputPluginContext.d.ts +4 -3
- package/dist/primitives/composer/ComposerInputPluginContext.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerQuote.d.ts +0 -1
- package/dist/primitives/composer/ComposerQuote.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts +22 -3
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +63 -30
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.d.ts +0 -1
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.d.ts +0 -1
- package/dist/primitives/composer/ComposerStopDictation.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts +10 -5
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts +5 -3
- package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js +3 -2
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.d.ts +0 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts +0 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts +3 -2
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts +0 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts +10 -6
- package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts +8 -5
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/index.d.ts +0 -1
- package/dist/primitives/composer/trigger/index.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts +5 -2
- package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts +7 -4
- package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts +13 -7
- package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts +7 -4
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/useComposerInputState.d.ts.map +1 -1
- package/dist/primitives/composer.d.ts +0 -2
- package/dist/primitives/dropdownMenuRenderPrimitives.d.ts +0 -1
- package/dist/primitives/dropdownMenuRenderPrimitives.d.ts.map +1 -1
- package/dist/primitives/error/ErrorMessage.d.ts +0 -1
- package/dist/primitives/error/ErrorMessage.d.ts.map +1 -1
- package/dist/primitives/error/ErrorRoot.d.ts +0 -1
- package/dist/primitives/error/ErrorRoot.d.ts.map +1 -1
- package/dist/primitives/error.d.ts +0 -2
- package/dist/primitives/message/MessageError.d.ts +0 -1
- package/dist/primitives/message/MessageError.d.ts.map +1 -1
- package/dist/primitives/message/MessageIf.d.ts +0 -1
- package/dist/primitives/message/MessageIf.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts +0 -1
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts +25 -12
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessageRoot.d.ts +0 -1
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/message.d.ts +0 -2
- package/dist/primitives/messagePart/MessagePartImage.d.ts +0 -1
- package/dist/primitives/messagePart/MessagePartImage.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.d.ts +2 -1
- package/dist/primitives/messagePart/MessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.d.ts +0 -1
- package/dist/primitives/messagePart/useMessagePartData.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.d.ts +0 -1
- package/dist/primitives/messagePart/useMessagePartFile.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.d.ts +0 -1
- package/dist/primitives/messagePart/useMessagePartImage.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts +0 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.d.ts +0 -1
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart.d.ts +0 -2
- package/dist/primitives/queueItem/QueueItemRemove.d.ts +0 -1
- package/dist/primitives/queueItem/QueueItemRemove.d.ts.map +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.d.ts +0 -1
- package/dist/primitives/queueItem/QueueItemSteer.d.ts.map +1 -1
- package/dist/primitives/queueItem/QueueItemText.d.ts +0 -1
- package/dist/primitives/queueItem/QueueItemText.d.ts.map +1 -1
- package/dist/primitives/queueItem.d.ts +0 -2
- package/dist/primitives/reasoning/useScrollLock.d.ts +0 -1
- package/dist/primitives/reasoning/useScrollLock.d.ts.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts +0 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts +0 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +2 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
- package/dist/primitives/selectionToolbar.d.ts +0 -2
- package/dist/primitives/suggestion/SuggestionDescription.d.ts +0 -1
- package/dist/primitives/suggestion/SuggestionDescription.d.ts.map +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.d.ts +0 -1
- package/dist/primitives/suggestion/SuggestionTitle.d.ts.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.d.ts +1 -5
- package/dist/primitives/suggestion/SuggestionTrigger.d.ts.map +1 -1
- package/dist/primitives/suggestion.d.ts +0 -2
- package/dist/primitives/thread/ThreadEmpty.d.ts +0 -1
- package/dist/primitives/thread/ThreadEmpty.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadIf.d.ts +0 -1
- package/dist/primitives/thread/ThreadIf.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts +0 -1
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts +1 -4
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.d.ts +13 -14
- package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts +0 -1
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.d.ts +0 -1
- package/dist/primitives/thread/ThreadViewportFooter.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/computeTopAnchorSlack.d.ts +2 -11
- package/dist/primitives/thread/topAnchor/computeTopAnchorSlack.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/createReserveObservers.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts +1 -4
- package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorUtils.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts +1 -7
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread.d.ts +0 -2
- package/dist/primitives/threadList/ThreadListLoadMore.d.ts +0 -1
- package/dist/primitives/threadList/ThreadListLoadMore.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.d.ts +0 -1
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.d.ts +0 -1
- package/dist/primitives/threadList/ThreadListRoot.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.js +10 -3
- package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
- package/dist/primitives/threadList.d.ts +0 -2
- package/dist/primitives/threadListFocusGroup.d.ts +25 -0
- package/dist/primitives/threadListFocusGroup.d.ts.map +1 -0
- package/dist/primitives/threadListFocusGroup.js +15 -0
- package/dist/primitives/threadListFocusGroup.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +0 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +0 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts +0 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +45 -27
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts +0 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +26 -2
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +0 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem.d.ts +0 -2
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts +0 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +63 -38
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts +0 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts +20 -4
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js +95 -14
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts +0 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts +0 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +38 -21
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
- package/dist/primitives/threadListItemMore/scope.d.ts +0 -1
- package/dist/primitives/threadListItemMore/scope.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore.d.ts +0 -2
- package/dist/sandbox-host/SandboxHost.d.ts +1 -10
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -1
- package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
- package/dist/unstable/useComposerInput.d.ts +2 -2
- package/dist/unstable/useComposerInput.d.ts.map +1 -1
- package/dist/unstable/useComposerInputHistory.d.ts +2 -2
- package/dist/unstable/useComposerInputHistory.d.ts.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.d.ts +4 -3
- package/dist/unstable/useLiveCompletionAdapter.d.ts.map +1 -1
- package/dist/unstable/useMentionAdapter.d.ts +19 -10
- package/dist/unstable/useMentionAdapter.d.ts.map +1 -1
- package/dist/unstable/useMessageStallDetection.d.ts +3 -1
- package/dist/unstable/useMessageStallDetection.d.ts.map +1 -1
- package/dist/unstable/useSlashCommandAdapter.d.ts +6 -4
- package/dist/unstable/useSlashCommandAdapter.d.ts.map +1 -1
- package/dist/utils/Primitive.d.ts +0 -1
- package/dist/utils/Primitive.d.ts.map +1 -1
- package/dist/utils/RequireAtLeastOne.d.ts +1 -1
- package/dist/utils/RequireAtLeastOne.d.ts.map +1 -1
- package/dist/utils/createActionButton.d.ts +0 -1
- package/dist/utils/createActionButton.d.ts.map +1 -1
- package/dist/utils/getSelectionMessageId.d.ts.map +1 -1
- package/dist/utils/getSelectionMessageId.js +32 -7
- package/dist/utils/getSelectionMessageId.js.map +1 -1
- package/dist/utils/hooks/useManagedRef.d.ts.map +1 -1
- package/dist/utils/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/utils/hooks/useMediaQuery.js +2 -2
- package/dist/utils/hooks/useMediaQuery.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.d.ts.map +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.d.ts.map +1 -1
- package/dist/utils/hooks/useSizeHandle.d.ts +0 -1
- package/dist/utils/hooks/useSizeHandle.d.ts.map +1 -1
- package/dist/utils/smooth/SmoothContext.d.ts +71 -72
- package/dist/utils/smooth/SmoothContext.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.d.ts +4 -1
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +7 -1
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.d.ts.map +1 -1
- package/package.json +19 -17
- package/src/index.ts +3 -0
- package/src/legacy-runtime/cloud/auiV0.ts +72 -3
- package/src/mcp-apps/McpAppRenderer.test.tsx +141 -0
- package/src/mcp-apps/McpAppRenderer.tsx +48 -10
- package/src/mcp-apps/McpAppsRemoteHost.test.ts +126 -0
- package/src/mcp-apps/McpAppsRemoteHost.ts +40 -1
- package/src/mcp-apps/app-frame.tsx +3 -1
- package/src/mcp-apps/bridge.ts +1 -1
- package/src/mcp-apps/types.ts +16 -8
- package/src/primitives/assistantModal/AssistantModalAnchor.tsx +6 -8
- package/src/primitives/assistantModal/AssistantModalContent.tsx +5 -5
- package/src/primitives/assistantModal/AssistantModalTrigger.test.tsx +80 -0
- package/src/primitives/assistantModal/AssistantModalTrigger.tsx +6 -8
- package/src/primitives/assistantModal/popoverRenderPrimitives.ts +6 -0
- package/src/primitives/composer/ComposerCompactContext.tsx +13 -0
- package/src/primitives/composer/ComposerInput.tsx +35 -0
- package/src/primitives/composer/ComposerRoot.test.tsx +161 -0
- package/src/primitives/composer/ComposerRoot.tsx +37 -7
- package/src/primitives/messagePart/MessagePartText.tsx +1 -0
- package/src/primitives/threadList/ThreadListRoot.tsx +8 -1
- package/src/primitives/threadListFocusGroup.ts +24 -0
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +53 -5
- package/src/primitives/threadListItem/ThreadListItemTrigger.tsx +45 -0
- package/src/primitives/threadListItem/ThreadListKeyboardNav.test.tsx +141 -0
- package/src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx +22 -1
- package/src/primitives/threadListItemMore/ThreadListItemMoreRoot.tsx +64 -3
- package/src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx +29 -2
- package/src/tests/LocalThreadRuntimeCore.test.ts +4 -1
- package/src/tests/auiV0Encode.test.ts +134 -1
- package/src/tests/generative-ui.test.tsx +21 -1
- package/src/utils/getSelectionMessageId.test.ts +175 -0
- package/src/utils/getSelectionMessageId.ts +57 -6
- package/src/utils/hooks/useMediaQuery.ts +3 -2
- package/src/utils/smooth/useSmooth.test.tsx +26 -0
- package/src/utils/smooth/useSmooth.ts +7 -1
- package/dist/utils/json/is-json-equal.d.ts +0 -5
- package/dist/utils/json/is-json-equal.d.ts.map +0 -1
- package/dist/utils/json/is-json-equal.js +0 -26
- package/dist/utils/json/is-json-equal.js.map +0 -1
- package/dist/utils/json/is-json.d.ts +0 -10
- package/dist/utils/json/is-json.d.ts.map +0 -1
- package/dist/utils/json/is-json.js +0 -22
- package/dist/utils/json/is-json.js.map +0 -1
- package/src/primitives/threadListItem/ThreadListItemTrigger.ts +0 -23
- package/src/utils/json/is-json-equal.ts +0 -48
- package/src/utils/json/is-json.ts +0 -58
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { createTapRoot, useResource } from "@assistant-ui/tap";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { McpAppsRemoteHost } from "./McpAppsRemoteHost";
|
|
4
|
+
|
|
5
|
+
const mount = (fetch: typeof globalThis.fetch) =>
|
|
6
|
+
createTapRoot(function Root() {
|
|
7
|
+
return useResource(
|
|
8
|
+
McpAppsRemoteHost({
|
|
9
|
+
url: "/api/mcp-apps",
|
|
10
|
+
fetch,
|
|
11
|
+
}),
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe("McpAppsRemoteHost", () => {
|
|
16
|
+
it("posts the requested method and params to the host route", async () => {
|
|
17
|
+
const fetch = vi.fn(async () =>
|
|
18
|
+
Response.json({ content: [{ type: "text", text: "ok" }] }),
|
|
19
|
+
) as unknown as typeof globalThis.fetch;
|
|
20
|
+
const root = mount(fetch);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
await expect(
|
|
24
|
+
root.getValue().callTool({
|
|
25
|
+
name: "search",
|
|
26
|
+
arguments: { query: "docs" },
|
|
27
|
+
}),
|
|
28
|
+
).resolves.toEqual({ content: [{ type: "text", text: "ok" }] });
|
|
29
|
+
|
|
30
|
+
expect(fetch).toHaveBeenCalledWith("/api/mcp-apps", {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: { "content-type": "application/json" },
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
method: "tools/call",
|
|
35
|
+
params: { name: "search", arguments: { query: "docs" } },
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
} finally {
|
|
39
|
+
root.unmount();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("posts serverId params verbatim for tool calls and resource loads", async () => {
|
|
44
|
+
const fetch = vi.fn(async () =>
|
|
45
|
+
Response.json({ content: [{ type: "text", text: "ok" }] }),
|
|
46
|
+
) as unknown as typeof globalThis.fetch;
|
|
47
|
+
const root = mount(fetch);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await root.getValue().callTool({
|
|
51
|
+
name: "search",
|
|
52
|
+
arguments: { query: "docs" },
|
|
53
|
+
serverId: "search-server",
|
|
54
|
+
});
|
|
55
|
+
await root.getValue().loadResource({
|
|
56
|
+
uri: "ui://example/search",
|
|
57
|
+
serverId: "search-server",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(fetch).toHaveBeenNthCalledWith(1, "/api/mcp-apps", {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: { "content-type": "application/json" },
|
|
63
|
+
body: JSON.stringify({
|
|
64
|
+
method: "tools/call",
|
|
65
|
+
params: {
|
|
66
|
+
name: "search",
|
|
67
|
+
arguments: { query: "docs" },
|
|
68
|
+
serverId: "search-server",
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
expect(fetch).toHaveBeenNthCalledWith(2, "/api/mcp-apps", {
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: { "content-type": "application/json" },
|
|
75
|
+
body: JSON.stringify({
|
|
76
|
+
method: "mcp-apps/read-resource",
|
|
77
|
+
params: {
|
|
78
|
+
uri: "ui://example/search",
|
|
79
|
+
serverId: "search-server",
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
} finally {
|
|
84
|
+
root.unmount();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("includes method, url, status, and text body in host request errors", async () => {
|
|
89
|
+
const fetch = vi.fn(
|
|
90
|
+
async () =>
|
|
91
|
+
new Response("Missing tool name", {
|
|
92
|
+
status: 500,
|
|
93
|
+
statusText: "Internal Server Error",
|
|
94
|
+
}),
|
|
95
|
+
) as unknown as typeof globalThis.fetch;
|
|
96
|
+
const root = mount(fetch);
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
await expect(
|
|
100
|
+
root.getValue().callTool({ name: "search" }),
|
|
101
|
+
).rejects.toThrow(
|
|
102
|
+
'MCP App host request "tools/call" to "/api/mcp-apps" failed with 500 Internal Server Error: Missing tool name',
|
|
103
|
+
);
|
|
104
|
+
} finally {
|
|
105
|
+
root.unmount();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("uses JSON error messages from failed host responses", async () => {
|
|
110
|
+
const fetch = vi.fn(async () =>
|
|
111
|
+
Response.json(
|
|
112
|
+
{ error: { message: "resources/list is not supported" } },
|
|
113
|
+
{ status: 400, statusText: "Bad Request" },
|
|
114
|
+
),
|
|
115
|
+
) as unknown as typeof globalThis.fetch;
|
|
116
|
+
const root = mount(fetch);
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
await expect(root.getValue().listResources()).rejects.toThrow(
|
|
120
|
+
'MCP App host request "resources/list" to "/api/mcp-apps" failed with 400 Bad Request: resources/list is not supported',
|
|
121
|
+
);
|
|
122
|
+
} finally {
|
|
123
|
+
root.unmount();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -6,6 +6,39 @@ import type {
|
|
|
6
6
|
McpAppsRemoteHostOptions,
|
|
7
7
|
} from "./types";
|
|
8
8
|
|
|
9
|
+
const truncateBody = (body: string) =>
|
|
10
|
+
body.length > 500 ? `${body.slice(0, 500)}...` : body;
|
|
11
|
+
|
|
12
|
+
const extractErrorBody = (body: string): string | undefined => {
|
|
13
|
+
const trimmed = body.trim();
|
|
14
|
+
if (!trimmed) return undefined;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(trimmed) as unknown;
|
|
18
|
+
if (parsed && typeof parsed === "object") {
|
|
19
|
+
const record = parsed as Record<string, unknown>;
|
|
20
|
+
if (typeof record.message === "string") return record.message;
|
|
21
|
+
if (typeof record.error === "string") return record.error;
|
|
22
|
+
if (record.error && typeof record.error === "object") {
|
|
23
|
+
const error = record.error as Record<string, unknown>;
|
|
24
|
+
if (typeof error.message === "string") return error.message;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
return truncateBody(trimmed);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return truncateBody(trimmed);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const readErrorBody = async (res: Response): Promise<string | undefined> => {
|
|
35
|
+
try {
|
|
36
|
+
return extractErrorBody(await res.text());
|
|
37
|
+
} catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
9
42
|
async function postToHost(
|
|
10
43
|
options: McpAppsRemoteHostOptions,
|
|
11
44
|
method: string,
|
|
@@ -22,7 +55,13 @@ async function postToHost(
|
|
|
22
55
|
body: JSON.stringify({ method, params }),
|
|
23
56
|
});
|
|
24
57
|
if (!res.ok) {
|
|
25
|
-
|
|
58
|
+
const status = res.statusText
|
|
59
|
+
? `${res.status} ${res.statusText}`
|
|
60
|
+
: `${res.status}`;
|
|
61
|
+
const body = await readErrorBody(res);
|
|
62
|
+
throw new Error(
|
|
63
|
+
`MCP App host request "${method}" to "${options.url}" failed with ${status}${body ? `: ${body}` : ""}`,
|
|
64
|
+
);
|
|
26
65
|
}
|
|
27
66
|
return res.json();
|
|
28
67
|
}
|
|
@@ -246,7 +246,9 @@ export function McpAppFrame({
|
|
|
246
246
|
return (
|
|
247
247
|
<SandboxHost
|
|
248
248
|
content={{ html: resource.html }}
|
|
249
|
-
contentKey={
|
|
249
|
+
contentKey={
|
|
250
|
+
app.serverId ? `${app.serverId} ${resource.uri}` : resource.uri
|
|
251
|
+
}
|
|
250
252
|
sandbox={{ ...sandbox, product: sandbox?.product ?? DEFAULT_PRODUCT }}
|
|
251
253
|
maxHeight={maxHeight}
|
|
252
254
|
createBridge={createBridge}
|
package/src/mcp-apps/bridge.ts
CHANGED
package/src/mcp-apps/types.ts
CHANGED
|
@@ -51,19 +51,27 @@ export type McpAppHostInfo = {
|
|
|
51
51
|
* `McpAppsRemoteHost`.
|
|
52
52
|
*/
|
|
53
53
|
export type McpAppsHost = {
|
|
54
|
-
loadResource: (params: {
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
loadResource: (params: {
|
|
55
|
+
uri: string;
|
|
56
|
+
serverId?: string;
|
|
57
|
+
}) => Promise<McpAppResource>;
|
|
58
|
+
callTool: (
|
|
59
|
+
params: McpAppToolCallParams & { serverId?: string },
|
|
60
|
+
) => Promise<unknown>;
|
|
61
|
+
readResource: (params: {
|
|
62
|
+
uri: string;
|
|
63
|
+
serverId?: string;
|
|
64
|
+
}) => Promise<unknown>;
|
|
57
65
|
listResources: (params?: unknown) => Promise<unknown>;
|
|
58
66
|
};
|
|
59
67
|
|
|
60
68
|
/**
|
|
61
69
|
* Options for `McpAppsRemoteHost`. The host POSTs `{ method, params }` to
|
|
62
|
-
* `url` and expects JSON responses. Method names sent:
|
|
63
|
-
* - `mcp-apps/read-resource` (`{ uri }`) → `McpAppResource`
|
|
64
|
-
* - `tools/call` (`{ name, arguments? }`) → tool result
|
|
65
|
-
* - `resources/read` (`{ uri }`) → resource read result
|
|
66
|
-
* - `resources/list` (`params?`) → list result
|
|
70
|
+
* `url` and expects JSON responses. Params may carry `serverId` for host-side routing. Method names sent:
|
|
71
|
+
* - `mcp-apps/read-resource` (`{ uri, serverId? }`) → `McpAppResource`
|
|
72
|
+
* - `tools/call` (`{ name, arguments?, serverId? }`) → tool result
|
|
73
|
+
* - `resources/read` (`{ uri, serverId? }`) → resource read result
|
|
74
|
+
* - `resources/list` (`{ serverId?, ...params }?`) → list result
|
|
67
75
|
*/
|
|
68
76
|
export type McpAppsRemoteHostOptions = {
|
|
69
77
|
url: string;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "react";
|
|
8
|
-
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
3
|
+
import { type ComponentRef, forwardRef } from "react";
|
|
4
|
+
import type { Popover as PopoverPrimitive } from "radix-ui";
|
|
5
|
+
import type { WithRenderPropProps } from "../../utils/Primitive";
|
|
6
|
+
import { PopoverRenderAnchor } from "./popoverRenderPrimitives";
|
|
9
7
|
import { type ScopedProps, usePopoverScope } from "./scope";
|
|
10
8
|
|
|
11
9
|
export namespace AssistantModalPrimitiveAnchor {
|
|
12
10
|
export type Element = ComponentRef<typeof PopoverPrimitive.Anchor>;
|
|
13
|
-
export type Props =
|
|
11
|
+
export type Props = WithRenderPropProps<typeof PopoverPrimitive.Anchor>;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export const AssistantModalPrimitiveAnchor = forwardRef<
|
|
@@ -26,7 +24,7 @@ export const AssistantModalPrimitiveAnchor = forwardRef<
|
|
|
26
24
|
) => {
|
|
27
25
|
const scope = usePopoverScope(__scopeAssistantModal);
|
|
28
26
|
|
|
29
|
-
return <
|
|
27
|
+
return <PopoverRenderAnchor {...scope} {...rest} ref={ref} />;
|
|
30
28
|
},
|
|
31
29
|
);
|
|
32
30
|
AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
forwardRef,
|
|
7
7
|
} from "react";
|
|
8
8
|
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
9
|
-
import { type ScopedProps, usePopoverScope } from "./scope";
|
|
10
9
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
10
|
+
import type { WithRenderPropProps } from "../../utils/Primitive";
|
|
11
|
+
import { PopoverRenderContent } from "./popoverRenderPrimitives";
|
|
12
|
+
import { type ScopedProps, usePopoverScope } from "./scope";
|
|
11
13
|
|
|
12
14
|
export namespace AssistantModalPrimitiveContent {
|
|
13
15
|
export type Element = ComponentRef<typeof PopoverPrimitive.Content>;
|
|
14
|
-
export type Props =
|
|
15
|
-
typeof PopoverPrimitive.Content
|
|
16
|
-
> & {
|
|
16
|
+
export type Props = WithRenderPropProps<typeof PopoverPrimitive.Content> & {
|
|
17
17
|
portalProps?:
|
|
18
18
|
| ComponentPropsWithoutRef<typeof PopoverPrimitive.Portal>
|
|
19
19
|
| undefined;
|
|
@@ -41,7 +41,7 @@ export const AssistantModalPrimitiveContent = forwardRef<
|
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<PopoverPrimitive.Portal {...scope} {...portalProps}>
|
|
44
|
-
<
|
|
44
|
+
<PopoverRenderContent
|
|
45
45
|
{...scope}
|
|
46
46
|
{...props}
|
|
47
47
|
ref={forwardedRef}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { AssistantModalPrimitiveAnchor } from "./AssistantModalAnchor";
|
|
4
|
+
import { AssistantModalPrimitiveContent } from "./AssistantModalContent";
|
|
5
|
+
import { AssistantModalPrimitiveRoot } from "./AssistantModalRoot";
|
|
6
|
+
import { AssistantModalPrimitiveTrigger } from "./AssistantModalTrigger";
|
|
7
|
+
|
|
8
|
+
vi.mock("@assistant-ui/store", async (importOriginal) => {
|
|
9
|
+
const actual = await importOriginal<typeof import("@assistant-ui/store")>();
|
|
10
|
+
return {
|
|
11
|
+
...actual,
|
|
12
|
+
useAui: () => ({
|
|
13
|
+
on: () => () => {},
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("AssistantModalPrimitive render props", () => {
|
|
19
|
+
it("Trigger render matches asChild", () => {
|
|
20
|
+
const renderHtml = renderToStaticMarkup(
|
|
21
|
+
<AssistantModalPrimitiveRoot open>
|
|
22
|
+
<AssistantModalPrimitiveTrigger
|
|
23
|
+
render={<button type="button" className="trigger" />}
|
|
24
|
+
>
|
|
25
|
+
Open
|
|
26
|
+
</AssistantModalPrimitiveTrigger>
|
|
27
|
+
</AssistantModalPrimitiveRoot>,
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const asChildHtml = renderToStaticMarkup(
|
|
31
|
+
<AssistantModalPrimitiveRoot open>
|
|
32
|
+
<AssistantModalPrimitiveTrigger asChild>
|
|
33
|
+
<button type="button" className="trigger">
|
|
34
|
+
Open
|
|
35
|
+
</button>
|
|
36
|
+
</AssistantModalPrimitiveTrigger>
|
|
37
|
+
</AssistantModalPrimitiveRoot>,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(renderHtml).toBe(asChildHtml);
|
|
41
|
+
expect(renderHtml).toContain('class="trigger"');
|
|
42
|
+
expect(renderHtml).toContain("Open");
|
|
43
|
+
expect(renderHtml).toContain('type="button"');
|
|
44
|
+
expect(renderHtml).toMatch(/aria-haspopup|aria-expanded|data-state/);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("Anchor render matches asChild", () => {
|
|
48
|
+
const renderHtml = renderToStaticMarkup(
|
|
49
|
+
<AssistantModalPrimitiveRoot open>
|
|
50
|
+
<AssistantModalPrimitiveAnchor render={<div className="anchor" />}>
|
|
51
|
+
Anchor
|
|
52
|
+
</AssistantModalPrimitiveAnchor>
|
|
53
|
+
</AssistantModalPrimitiveRoot>,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const asChildHtml = renderToStaticMarkup(
|
|
57
|
+
<AssistantModalPrimitiveRoot open>
|
|
58
|
+
<AssistantModalPrimitiveAnchor asChild>
|
|
59
|
+
<div className="anchor">Anchor</div>
|
|
60
|
+
</AssistantModalPrimitiveAnchor>
|
|
61
|
+
</AssistantModalPrimitiveRoot>,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(renderHtml).toBe(asChildHtml);
|
|
65
|
+
expect(renderHtml).toContain('class="anchor"');
|
|
66
|
+
expect(renderHtml).toContain("Anchor");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("accepts render on Trigger, Anchor, and Content", () => {
|
|
70
|
+
const tree = (
|
|
71
|
+
<AssistantModalPrimitiveRoot open>
|
|
72
|
+
<AssistantModalPrimitiveTrigger render={<button type="button" />} />
|
|
73
|
+
<AssistantModalPrimitiveAnchor render={<div />} />
|
|
74
|
+
<AssistantModalPrimitiveContent render={<div />} />
|
|
75
|
+
</AssistantModalPrimitiveRoot>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
expect(tree).toBeTruthy();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "react";
|
|
6
|
-
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
1
|
+
import { type ComponentRef, forwardRef } from "react";
|
|
2
|
+
import type { Popover as PopoverPrimitive } from "radix-ui";
|
|
3
|
+
import type { WithRenderPropProps } from "../../utils/Primitive";
|
|
4
|
+
import { PopoverRenderTrigger } from "./popoverRenderPrimitives";
|
|
7
5
|
import { type ScopedProps, usePopoverScope } from "./scope";
|
|
8
6
|
|
|
9
7
|
export namespace AssistantModalPrimitiveTrigger {
|
|
10
8
|
export type Element = ComponentRef<typeof PopoverPrimitive.Trigger>;
|
|
11
|
-
export type Props =
|
|
9
|
+
export type Props = WithRenderPropProps<typeof PopoverPrimitive.Trigger>;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
export const AssistantModalPrimitiveTrigger = forwardRef<
|
|
@@ -24,7 +22,7 @@ export const AssistantModalPrimitiveTrigger = forwardRef<
|
|
|
24
22
|
) => {
|
|
25
23
|
const scope = usePopoverScope(__scopeAssistantModal);
|
|
26
24
|
|
|
27
|
-
return <
|
|
25
|
+
return <PopoverRenderTrigger {...scope} {...rest} ref={ref} />;
|
|
28
26
|
},
|
|
29
27
|
);
|
|
30
28
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
2
|
+
import { withRenderProp } from "../../utils/Primitive";
|
|
3
|
+
|
|
4
|
+
export const PopoverRenderTrigger = withRenderProp(PopoverPrimitive.Trigger);
|
|
5
|
+
export const PopoverRenderAnchor = withRenderProp(PopoverPrimitive.Anchor);
|
|
6
|
+
export const PopoverRenderContent = withRenderProp(PopoverPrimitive.Content);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
|
|
5
|
+
export type ComposerCompactContextValue = {
|
|
6
|
+
setMultiline: (multiline: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const ComposerCompactContext =
|
|
10
|
+
createContext<ComposerCompactContextValue | null>(null);
|
|
11
|
+
|
|
12
|
+
export const useComposerCompactContextOptional = () =>
|
|
13
|
+
useContext(ComposerCompactContext);
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "react";
|
|
18
18
|
import TextareaAutosize, {
|
|
19
19
|
type TextareaAutosizeProps,
|
|
20
|
+
type TextareaHeightChangeMeta,
|
|
20
21
|
} from "react-textarea-autosize";
|
|
21
22
|
import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
|
|
22
23
|
import { useOnScrollToBottom } from "../../utils/hooks/useOnScrollToBottom";
|
|
@@ -24,6 +25,7 @@ import { useMediaQuery } from "../../utils/hooks/useMediaQuery";
|
|
|
24
25
|
import { useAui } from "@assistant-ui/store";
|
|
25
26
|
import { flushTapSync } from "@assistant-ui/tap";
|
|
26
27
|
import { useComposerInputPluginRegistryOptional } from "./ComposerInputPluginContext";
|
|
28
|
+
import { useComposerCompactContextOptional } from "./ComposerCompactContext";
|
|
27
29
|
import {
|
|
28
30
|
useComposerInputDisabled,
|
|
29
31
|
useComposerInputValue,
|
|
@@ -165,12 +167,14 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
165
167
|
unstable_focusOnThreadSwitched = true,
|
|
166
168
|
unstable_insertNewlineOnTouchEnter = false,
|
|
167
169
|
addAttachmentOnPaste = true,
|
|
170
|
+
onHeightChange,
|
|
168
171
|
...rest
|
|
169
172
|
},
|
|
170
173
|
forwardedRef,
|
|
171
174
|
) => {
|
|
172
175
|
const aui = useAui();
|
|
173
176
|
const pluginRegistry = useComposerInputPluginRegistryOptional();
|
|
177
|
+
const compactContext = useComposerCompactContextOptional();
|
|
174
178
|
|
|
175
179
|
const declaredSubmitMode =
|
|
176
180
|
submitMode ?? (submitOnEnter === false ? "none" : "enter");
|
|
@@ -278,6 +282,28 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
278
282
|
}
|
|
279
283
|
};
|
|
280
284
|
|
|
285
|
+
const handleHeightChange = (
|
|
286
|
+
height: number,
|
|
287
|
+
meta: TextareaHeightChangeMeta,
|
|
288
|
+
) => {
|
|
289
|
+
onHeightChange?.(height, meta);
|
|
290
|
+
if (!compactContext) return;
|
|
291
|
+
const el = textareaRef.current;
|
|
292
|
+
if (!el || el.value === "") return;
|
|
293
|
+
const cs = getComputedStyle(el);
|
|
294
|
+
const contentHeight =
|
|
295
|
+
cs.boxSizing === "border-box"
|
|
296
|
+
? height -
|
|
297
|
+
parseFloat(cs.paddingTop) -
|
|
298
|
+
parseFloat(cs.paddingBottom) -
|
|
299
|
+
parseFloat(cs.borderTopWidth) -
|
|
300
|
+
parseFloat(cs.borderBottomWidth)
|
|
301
|
+
: height;
|
|
302
|
+
if (Math.round(contentHeight / meta.rowHeight) > 1) {
|
|
303
|
+
compactContext.setMultiline(true);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
281
307
|
const autoFocusEnabled = autoFocus && !isDisabled;
|
|
282
308
|
const focus = useCallback(() => {
|
|
283
309
|
const textarea = textareaRef.current;
|
|
@@ -318,6 +344,10 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
318
344
|
return aui.on("threadListItem.switchedTo", focus);
|
|
319
345
|
}, [unstable_focusOnThreadSwitched, focus, aui]);
|
|
320
346
|
|
|
347
|
+
useEffect(() => {
|
|
348
|
+
if (value === "") compactContext?.setMultiline(false);
|
|
349
|
+
}, [value, compactContext]);
|
|
350
|
+
|
|
321
351
|
const ariaComboboxProps = useTriggerPopoverAriaProps();
|
|
322
352
|
|
|
323
353
|
const inputProps = {
|
|
@@ -391,6 +421,11 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
391
421
|
},
|
|
392
422
|
),
|
|
393
423
|
onPaste: composeEventHandlers(onPaste, handlePaste),
|
|
424
|
+
...(compactContext
|
|
425
|
+
? { onHeightChange: handleHeightChange }
|
|
426
|
+
: onHeightChange !== undefined
|
|
427
|
+
? { onHeightChange }
|
|
428
|
+
: {}),
|
|
394
429
|
};
|
|
395
430
|
|
|
396
431
|
if (render && isValidElement(render)) {
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vitest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import { act } from "react";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { createRoot } from "react-dom/client";
|
|
7
|
+
import type { Root } from "react-dom/client";
|
|
8
|
+
import type * as AssistantStore from "@assistant-ui/store";
|
|
9
|
+
import type * as ComposerSendModule from "./ComposerSend";
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
11
|
+
import { useComposerCompactContextOptional } from "./ComposerCompactContext";
|
|
12
|
+
import type { ComposerCompactContextValue } from "./ComposerCompactContext";
|
|
13
|
+
import { ComposerPrimitiveRoot } from "./ComposerRoot";
|
|
14
|
+
|
|
15
|
+
type StoreState = {
|
|
16
|
+
composer: {
|
|
17
|
+
attachments: object[];
|
|
18
|
+
quote: object | undefined;
|
|
19
|
+
queue: object[];
|
|
20
|
+
dictation: object | undefined;
|
|
21
|
+
text: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const { storeState } = vi.hoisted((): { storeState: StoreState } => ({
|
|
26
|
+
storeState: {
|
|
27
|
+
composer: {
|
|
28
|
+
attachments: [],
|
|
29
|
+
quote: undefined,
|
|
30
|
+
queue: [],
|
|
31
|
+
dictation: undefined,
|
|
32
|
+
text: "",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
(globalThis as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;
|
|
38
|
+
|
|
39
|
+
vi.mock("@assistant-ui/store", async (importOriginal) => {
|
|
40
|
+
const actual = await importOriginal<typeof AssistantStore>();
|
|
41
|
+
return {
|
|
42
|
+
...actual,
|
|
43
|
+
useAuiState: <T,>(selector: (state: StoreState) => T) =>
|
|
44
|
+
selector(storeState),
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
vi.mock("./ComposerSend", async (importOriginal) => ({
|
|
49
|
+
...(await importOriginal<typeof ComposerSendModule>()),
|
|
50
|
+
useComposerSend: () => vi.fn(),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const resetStoreState = () => {
|
|
54
|
+
storeState.composer.attachments = [];
|
|
55
|
+
storeState.composer.quote = undefined;
|
|
56
|
+
storeState.composer.queue = [];
|
|
57
|
+
storeState.composer.dictation = undefined;
|
|
58
|
+
storeState.composer.text = "";
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
describe("ComposerPrimitiveRoot", () => {
|
|
62
|
+
let container: HTMLDivElement;
|
|
63
|
+
let root: Root;
|
|
64
|
+
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
resetStoreState();
|
|
67
|
+
container = document.createElement("div");
|
|
68
|
+
document.body.appendChild(container);
|
|
69
|
+
root = createRoot(container);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
afterEach(async () => {
|
|
73
|
+
await act(async () => {
|
|
74
|
+
root.unmount();
|
|
75
|
+
});
|
|
76
|
+
container.remove();
|
|
77
|
+
vi.restoreAllMocks();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const mount = async (props: {
|
|
81
|
+
compact?: boolean | undefined;
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
}) => {
|
|
84
|
+
await act(async () => {
|
|
85
|
+
root.render(
|
|
86
|
+
<ComposerPrimitiveRoot data-testid="composer-root" {...props} />,
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
const form = container.querySelector("form");
|
|
90
|
+
expect(form).not.toBeNull();
|
|
91
|
+
return form as HTMLFormElement;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
it("does not mark the form compact when compact is not enabled", async () => {
|
|
95
|
+
const form = await mount({});
|
|
96
|
+
|
|
97
|
+
expect(form.hasAttribute("data-compact")).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("provides no compact context when compact is not enabled", async () => {
|
|
101
|
+
let compactContext: ComposerCompactContextValue | null = null;
|
|
102
|
+
const Probe = () => {
|
|
103
|
+
compactContext = useComposerCompactContextOptional();
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
await mount({ children: <Probe /> });
|
|
108
|
+
|
|
109
|
+
expect(compactContext).toBeNull();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("starts compact on the first render when compact is enabled and composer state is pristine", async () => {
|
|
113
|
+
const form = await mount({ compact: true });
|
|
114
|
+
|
|
115
|
+
expect(form.hasAttribute("data-compact")).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it.each([
|
|
119
|
+
["attachments are present", { attachments: [{}] }],
|
|
120
|
+
["a quote is present", { quote: {} }],
|
|
121
|
+
["queued messages are present", { queue: [{}] }],
|
|
122
|
+
["dictation is active", { dictation: {} }],
|
|
123
|
+
["text contains an explicit newline", { text: "a\nb" }],
|
|
124
|
+
] as const)(
|
|
125
|
+
"does not mark the form compact when %s",
|
|
126
|
+
async (_name, composerPatch) => {
|
|
127
|
+
Object.assign(storeState.composer, composerPatch);
|
|
128
|
+
|
|
129
|
+
const form = await mount({ compact: true });
|
|
130
|
+
|
|
131
|
+
expect(form.hasAttribute("data-compact")).toBe(false);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
it("updates compact mode when the compact context multiline latch changes", async () => {
|
|
136
|
+
let compactContext: ComposerCompactContextValue | null = null;
|
|
137
|
+
const Probe = () => {
|
|
138
|
+
compactContext = useComposerCompactContextOptional();
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const form = await mount({
|
|
143
|
+
compact: true,
|
|
144
|
+
children: <Probe />,
|
|
145
|
+
});
|
|
146
|
+
const context = compactContext;
|
|
147
|
+
expect(context).not.toBeNull();
|
|
148
|
+
if (!context) throw new Error("Composer compact context was not provided");
|
|
149
|
+
expect(form.hasAttribute("data-compact")).toBe(true);
|
|
150
|
+
|
|
151
|
+
await act(async () => {
|
|
152
|
+
context.setMultiline(true);
|
|
153
|
+
});
|
|
154
|
+
expect(form.hasAttribute("data-compact")).toBe(false);
|
|
155
|
+
|
|
156
|
+
await act(async () => {
|
|
157
|
+
context.setMultiline(false);
|
|
158
|
+
});
|
|
159
|
+
expect(form.hasAttribute("data-compact")).toBe(true);
|
|
160
|
+
});
|
|
161
|
+
});
|