@assistant-ui/react 0.14.26 → 0.14.28
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 +4 -3
- 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/AssistantRuntimeProvider.js.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 +12 -13
- 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/model-context/makeAssistantVisible.js +7 -1
- package/dist/model-context/makeAssistantVisible.js.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/ActionBarRoot.js.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/ActionBarMoreContent.js.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/AttachmentThumb.js.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/BranchPickerRoot.js.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/ComposerAttachmentDropzone.js.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/ComposerDictationTranscript.js.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/ComposerQuote.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts +27 -3
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +109 -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/TriggerPopover.js.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/TriggerPopoverCategories.js.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/TriggerPopoverItems.js.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/TriggerPopoverRootContext.js.map +1 -1
- package/dist/primitives/composer/trigger/detectTrigger.d.ts +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/ErrorMessage.js.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/MessageParts.js.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/MessagePartsGrouped.js.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 +0 -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 +3 -3
- package/dist/primitives/messagePart/useMessagePartData.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js +3 -2
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.d.ts +5 -5
- package/dist/primitives/messagePart/useMessagePartFile.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.js +11 -3
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.d.ts +5 -5
- package/dist/primitives/messagePart/useMessagePartImage.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.js +10 -3
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts +5 -5
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.js +10 -3
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.d.ts +6 -4
- package/dist/primitives/messagePart/useMessagePartSource.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.js +12 -3
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.d.ts +6 -6
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.js +10 -3
- package/dist/primitives/messagePart/useMessagePartText.js.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/QueueItemText.js.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/SuggestionDescription.js.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/SuggestionTitle.js.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/ThreadViewport.js +53 -19
- package/dist/primitives/thread/ThreadViewport.js.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 +4 -0
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js +14 -1
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts +14 -5
- package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.js +14 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.js.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/useThreadViewportAutoScroll.js +2 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.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.map +1 -1
- package/dist/primitives/threadList.d.ts +0 -2
- package/dist/primitives/threadListFocusGroup.d.ts +0 -1
- package/dist/primitives/threadListFocusGroup.d.ts.map +1 -1
- 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.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.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.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 +0 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts.map +1 -1
- 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/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/tests/setup.d.ts +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/Primitive.js.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/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 +0 -1
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.d.ts +2 -2
- package/dist/utils/useToolArgsFieldStatus.d.ts.map +1 -1
- package/package.json +23 -23
- package/src/client/ExternalThread.ts +2 -1
- 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/model-context/makeAssistantVisible.test.tsx +146 -0
- package/src/model-context/makeAssistantVisible.tsx +18 -1
- 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 +382 -0
- package/src/primitives/composer/ComposerRoot.tsx +86 -7
- package/src/primitives/messagePart/useMessagePartData.ts +3 -2
- package/src/primitives/messagePart/useMessagePartFile.ts +19 -7
- package/src/primitives/messagePart/useMessagePartImage.ts +18 -7
- package/src/primitives/messagePart/useMessagePartReasoning.ts +15 -6
- package/src/primitives/messagePart/useMessagePartSource.ts +20 -7
- package/src/primitives/messagePart/useMessagePartText.ts +15 -5
- package/src/primitives/thread/ThreadViewport.tsx +15 -0
- package/src/primitives/thread/topAnchor/mountTopAnchorReserve.test.ts +243 -0
- package/src/primitives/thread/topAnchor/mountTopAnchorReserve.ts +28 -7
- package/src/primitives/thread/topAnchor/topAnchorTurn.test.ts +69 -0
- package/src/primitives/thread/topAnchor/topAnchorTurn.ts +29 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +86 -1
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +6 -1
- package/src/tests/BaseComposerRuntimeCore.test.ts +12 -3
- package/src/tests/LocalThreadRuntimeCore.test.ts +4 -1
- package/src/tests/auiV0Encode.test.ts +134 -1
- package/src/tests/external-thread-attachments.test.tsx +81 -0
- package/src/tests/messagePartSwitchRace.test.tsx +158 -0
- package/src/tests/messagePartTypeMismatch.test.tsx +146 -0
- package/src/utils/getSelectionMessageId.test.ts +175 -0
- package/src/utils/getSelectionMessageId.ts +57 -6
- 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/utils/json/is-json-equal.ts +0 -48
- package/src/utils/json/is-json.ts +0 -58
|
@@ -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,382 @@
|
|
|
1
|
+
/** @vitest-environment jsdom */
|
|
2
|
+
import { act } from "react";
|
|
3
|
+
import type { MouseEvent, ReactNode } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { createRoot } from "react-dom/client";
|
|
6
|
+
import type { Root } from "react-dom/client";
|
|
7
|
+
import type * as AssistantStore from "@assistant-ui/store";
|
|
8
|
+
import type * as ComposerSendModule from "./ComposerSend";
|
|
9
|
+
import { fireEvent, render } from "@testing-library/react";
|
|
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 click-to-focus", () => {
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
resetStoreState();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const setupComposer = (props?: ComposerPrimitiveRoot.Props) => {
|
|
67
|
+
const { getByTestId } = render(
|
|
68
|
+
<ComposerPrimitiveRoot {...props}>
|
|
69
|
+
<div data-testid="blank-space">
|
|
70
|
+
<textarea data-testid="composer-input" />
|
|
71
|
+
</div>
|
|
72
|
+
</ComposerPrimitiveRoot>,
|
|
73
|
+
);
|
|
74
|
+
return {
|
|
75
|
+
blankSpace: getByTestId("blank-space"),
|
|
76
|
+
textarea: getByTestId("composer-input"),
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
it("focuses the textarea when primary-button mousedown starts on blank form space", () => {
|
|
81
|
+
const { blankSpace, textarea } = setupComposer();
|
|
82
|
+
|
|
83
|
+
fireEvent.mouseDown(blankSpace, { button: 0 });
|
|
84
|
+
|
|
85
|
+
expect(document.activeElement).toBe(textarea);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("does not move focus to the textarea when mousedown starts on an interactive child", () => {
|
|
89
|
+
const { getByTestId } = render(
|
|
90
|
+
<ComposerPrimitiveRoot>
|
|
91
|
+
<button data-testid="interactive-child" type="button">
|
|
92
|
+
Action
|
|
93
|
+
</button>
|
|
94
|
+
<textarea data-testid="composer-input" />
|
|
95
|
+
</ComposerPrimitiveRoot>,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const notPrevented = fireEvent.mouseDown(getByTestId("interactive-child"), {
|
|
99
|
+
button: 0,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(notPrevented).toBe(true);
|
|
103
|
+
expect(document.activeElement).not.toBe(getByTestId("composer-input"));
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("does not steal focus from a role-based widget carrying a tabindex", () => {
|
|
107
|
+
const { getByTestId } = render(
|
|
108
|
+
<ComposerPrimitiveRoot>
|
|
109
|
+
<div role="slider" tabIndex={0} data-testid="widget" />
|
|
110
|
+
<textarea data-testid="composer-input" />
|
|
111
|
+
</ComposerPrimitiveRoot>,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const notPrevented = fireEvent.mouseDown(getByTestId("widget"), {
|
|
115
|
+
button: 0,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(notPrevented).toBe(true);
|
|
119
|
+
expect(document.activeElement).not.toBe(getByTestId("composer-input"));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("does not steal focus from a roving-tabindex child with tabindex=-1", () => {
|
|
123
|
+
const { getByTestId } = render(
|
|
124
|
+
<ComposerPrimitiveRoot>
|
|
125
|
+
<span tabIndex={-1} data-testid="roving-item">
|
|
126
|
+
Item
|
|
127
|
+
</span>
|
|
128
|
+
<textarea data-testid="composer-input" />
|
|
129
|
+
</ComposerPrimitiveRoot>,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const notPrevented = fireEvent.mouseDown(getByTestId("roving-item"), {
|
|
133
|
+
button: 0,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(notPrevented).toBe(true);
|
|
137
|
+
expect(document.activeElement).not.toBe(getByTestId("composer-input"));
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("does not move focus to the textarea on non-primary mousedown", () => {
|
|
141
|
+
const { blankSpace, textarea } = setupComposer();
|
|
142
|
+
|
|
143
|
+
const notPrevented = fireEvent.mouseDown(blankSpace, { button: 2 });
|
|
144
|
+
|
|
145
|
+
expect(notPrevented).toBe(true);
|
|
146
|
+
expect(document.activeElement).not.toBe(textarea);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("focuses a contenteditable composer target when primary-button mousedown starts on blank form space", () => {
|
|
150
|
+
const { getByTestId } = render(
|
|
151
|
+
<ComposerPrimitiveRoot>
|
|
152
|
+
<div data-testid="blank-space">
|
|
153
|
+
<div contentEditable data-testid="composer-input" tabIndex={0} />
|
|
154
|
+
</div>
|
|
155
|
+
</ComposerPrimitiveRoot>,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
fireEvent.mouseDown(getByTestId("blank-space"), { button: 0 });
|
|
159
|
+
|
|
160
|
+
expect(document.activeElement).toBe(getByTestId("composer-input"));
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("still focuses the textarea when the form is hosted inside a tabindex=-1 wrapper", () => {
|
|
164
|
+
const { getByTestId } = render(
|
|
165
|
+
<div tabIndex={-1}>
|
|
166
|
+
<ComposerPrimitiveRoot>
|
|
167
|
+
<div data-testid="blank-space">
|
|
168
|
+
<textarea data-testid="composer-input" />
|
|
169
|
+
</div>
|
|
170
|
+
</ComposerPrimitiveRoot>
|
|
171
|
+
</div>,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
fireEvent.mouseDown(getByTestId("blank-space"), { button: 0 });
|
|
175
|
+
|
|
176
|
+
expect(document.activeElement).toBe(getByTestId("composer-input"));
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("ignores mousedown on portaled descendants rendered outside the form's DOM", () => {
|
|
180
|
+
const { getByTestId } = render(
|
|
181
|
+
<ComposerPrimitiveRoot>
|
|
182
|
+
{createPortal(<div data-testid="portal-blank" />, document.body)}
|
|
183
|
+
<textarea data-testid="composer-input" />
|
|
184
|
+
</ComposerPrimitiveRoot>,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const notPrevented = fireEvent.mouseDown(getByTestId("portal-blank"), {
|
|
188
|
+
button: 0,
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
expect(notPrevented).toBe(true);
|
|
192
|
+
expect(document.activeElement).not.toBe(getByTestId("composer-input"));
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("keeps the mousedown default when the only textarea is disabled", () => {
|
|
196
|
+
const { getByTestId } = render(
|
|
197
|
+
<ComposerPrimitiveRoot>
|
|
198
|
+
<div data-testid="blank-space">
|
|
199
|
+
<textarea disabled data-testid="composer-input" />
|
|
200
|
+
</div>
|
|
201
|
+
</ComposerPrimitiveRoot>,
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const notPrevented = fireEvent.mouseDown(getByTestId("blank-space"), {
|
|
205
|
+
button: 0,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
expect(notPrevented).toBe(true);
|
|
209
|
+
expect(document.activeElement).not.toBe(getByTestId("composer-input"));
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("skips a disabled textarea and focuses the next composer input", () => {
|
|
213
|
+
const { getByTestId } = render(
|
|
214
|
+
<ComposerPrimitiveRoot>
|
|
215
|
+
<div data-testid="blank-space">
|
|
216
|
+
<textarea disabled data-testid="disabled-input" />
|
|
217
|
+
<div contentEditable data-testid="composer-input" tabIndex={0} />
|
|
218
|
+
</div>
|
|
219
|
+
</ComposerPrimitiveRoot>,
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
fireEvent.mouseDown(getByTestId("blank-space"), { button: 0 });
|
|
223
|
+
|
|
224
|
+
expect(document.activeElement).toBe(getByTestId("composer-input"));
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it("keeps the mousedown default when the form contains no composer input", () => {
|
|
228
|
+
const { getByTestId } = render(
|
|
229
|
+
<ComposerPrimitiveRoot>
|
|
230
|
+
<div data-testid="blank-space" />
|
|
231
|
+
</ComposerPrimitiveRoot>,
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
const notPrevented = fireEvent.mouseDown(getByTestId("blank-space"), {
|
|
235
|
+
button: 0,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
expect(notPrevented).toBe(true);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("lets descendants keep native mousedown defaults via stopPropagation", () => {
|
|
242
|
+
const { getByTestId } = render(
|
|
243
|
+
<ComposerPrimitiveRoot>
|
|
244
|
+
<div data-testid="selectable" onMouseDown={(e) => e.stopPropagation()}>
|
|
245
|
+
Selectable content
|
|
246
|
+
</div>
|
|
247
|
+
<textarea data-testid="composer-input" />
|
|
248
|
+
</ComposerPrimitiveRoot>,
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
const notPrevented = fireEvent.mouseDown(getByTestId("selectable"), {
|
|
252
|
+
button: 0,
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
expect(notPrevented).toBe(true);
|
|
256
|
+
expect(document.activeElement).not.toBe(getByTestId("composer-input"));
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("lets consumer onMouseDown prevent the default focus behavior", () => {
|
|
260
|
+
const onMouseDown = vi.fn((event: MouseEvent<HTMLFormElement>) => {
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
});
|
|
263
|
+
const { blankSpace, textarea } = setupComposer({ onMouseDown });
|
|
264
|
+
|
|
265
|
+
fireEvent.mouseDown(blankSpace, { button: 0 });
|
|
266
|
+
|
|
267
|
+
expect(onMouseDown).toHaveBeenCalledTimes(1);
|
|
268
|
+
expect(document.activeElement).not.toBe(textarea);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("runs consumer onMouseDown and preserves default focus behavior when it does not prevent default", () => {
|
|
272
|
+
const onMouseDown = vi.fn();
|
|
273
|
+
const { blankSpace, textarea } = setupComposer({ onMouseDown });
|
|
274
|
+
|
|
275
|
+
fireEvent.mouseDown(blankSpace, { button: 0 });
|
|
276
|
+
|
|
277
|
+
expect(onMouseDown).toHaveBeenCalledTimes(1);
|
|
278
|
+
expect(document.activeElement).toBe(textarea);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
describe("ComposerPrimitiveRoot compact mode", () => {
|
|
283
|
+
let container: HTMLDivElement;
|
|
284
|
+
let root: Root;
|
|
285
|
+
|
|
286
|
+
beforeEach(() => {
|
|
287
|
+
resetStoreState();
|
|
288
|
+
container = document.createElement("div");
|
|
289
|
+
document.body.appendChild(container);
|
|
290
|
+
root = createRoot(container);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
afterEach(async () => {
|
|
294
|
+
await act(async () => {
|
|
295
|
+
root.unmount();
|
|
296
|
+
});
|
|
297
|
+
container.remove();
|
|
298
|
+
vi.restoreAllMocks();
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
const mount = async (props: {
|
|
302
|
+
compact?: boolean | undefined;
|
|
303
|
+
children?: ReactNode;
|
|
304
|
+
}) => {
|
|
305
|
+
await act(async () => {
|
|
306
|
+
root.render(
|
|
307
|
+
<ComposerPrimitiveRoot data-testid="composer-root" {...props} />,
|
|
308
|
+
);
|
|
309
|
+
});
|
|
310
|
+
const form = container.querySelector("form");
|
|
311
|
+
expect(form).not.toBeNull();
|
|
312
|
+
return form as HTMLFormElement;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
it("does not mark the form compact when compact is not enabled", async () => {
|
|
316
|
+
const form = await mount({});
|
|
317
|
+
|
|
318
|
+
expect(form.hasAttribute("data-compact")).toBe(false);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("provides no compact context when compact is not enabled", async () => {
|
|
322
|
+
let compactContext: ComposerCompactContextValue | null = null;
|
|
323
|
+
const Probe = () => {
|
|
324
|
+
compactContext = useComposerCompactContextOptional();
|
|
325
|
+
return null;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
await mount({ children: <Probe /> });
|
|
329
|
+
|
|
330
|
+
expect(compactContext).toBeNull();
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it("starts compact on the first render when compact is enabled and composer state is pristine", async () => {
|
|
334
|
+
const form = await mount({ compact: true });
|
|
335
|
+
|
|
336
|
+
expect(form.hasAttribute("data-compact")).toBe(true);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it.each([
|
|
340
|
+
["attachments are present", { attachments: [{}] }],
|
|
341
|
+
["a quote is present", { quote: {} }],
|
|
342
|
+
["queued messages are present", { queue: [{}] }],
|
|
343
|
+
["dictation is active", { dictation: {} }],
|
|
344
|
+
["text contains an explicit newline", { text: "a\nb" }],
|
|
345
|
+
] as const)(
|
|
346
|
+
"does not mark the form compact when %s",
|
|
347
|
+
async (_name, composerPatch) => {
|
|
348
|
+
Object.assign(storeState.composer, composerPatch);
|
|
349
|
+
|
|
350
|
+
const form = await mount({ compact: true });
|
|
351
|
+
|
|
352
|
+
expect(form.hasAttribute("data-compact")).toBe(false);
|
|
353
|
+
},
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
it("updates compact mode when the compact context multiline latch changes", async () => {
|
|
357
|
+
let compactContext: ComposerCompactContextValue | null = null;
|
|
358
|
+
const Probe = () => {
|
|
359
|
+
compactContext = useComposerCompactContextOptional();
|
|
360
|
+
return null;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const form = await mount({
|
|
364
|
+
compact: true,
|
|
365
|
+
children: <Probe />,
|
|
366
|
+
});
|
|
367
|
+
const context = compactContext;
|
|
368
|
+
expect(context).not.toBeNull();
|
|
369
|
+
if (!context) throw new Error("Composer compact context was not provided");
|
|
370
|
+
expect(form.hasAttribute("data-compact")).toBe(true);
|
|
371
|
+
|
|
372
|
+
await act(async () => {
|
|
373
|
+
context.setMultiline(true);
|
|
374
|
+
});
|
|
375
|
+
expect(form.hasAttribute("data-compact")).toBe(false);
|
|
376
|
+
|
|
377
|
+
await act(async () => {
|
|
378
|
+
context.setMultiline(false);
|
|
379
|
+
});
|
|
380
|
+
expect(form.hasAttribute("data-compact")).toBe(true);
|
|
381
|
+
});
|
|
382
|
+
});
|
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
4
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
4
5
|
import { Primitive } from "../../utils/Primitive";
|
|
5
6
|
import {
|
|
6
7
|
type ComponentRef,
|
|
7
8
|
type FormEvent,
|
|
8
9
|
forwardRef,
|
|
9
10
|
type ComponentPropsWithoutRef,
|
|
11
|
+
type MouseEvent,
|
|
12
|
+
useMemo,
|
|
13
|
+
useState,
|
|
10
14
|
} from "react";
|
|
11
15
|
import { useComposerSend } from "./ComposerSend";
|
|
16
|
+
import { ComposerCompactContext } from "./ComposerCompactContext";
|
|
17
|
+
|
|
18
|
+
const CONTENT_EDITABLE_SELECTOR =
|
|
19
|
+
"[contenteditable]:not([contenteditable='false'])";
|
|
20
|
+
|
|
21
|
+
const COMPOSER_INPUT_SELECTOR = `textarea:not(:disabled), ${CONTENT_EDITABLE_SELECTOR}`;
|
|
22
|
+
|
|
23
|
+
// Keeps tabindex="-1": roving-tabindex widgets click-focus items at -1.
|
|
24
|
+
const INTERACTIVE_ELEMENT_SELECTOR = [
|
|
25
|
+
"a",
|
|
26
|
+
"audio[controls]",
|
|
27
|
+
"button",
|
|
28
|
+
"details",
|
|
29
|
+
"embed",
|
|
30
|
+
"iframe",
|
|
31
|
+
"input",
|
|
32
|
+
"label",
|
|
33
|
+
"select",
|
|
34
|
+
"summary",
|
|
35
|
+
"textarea",
|
|
36
|
+
"video[controls]",
|
|
37
|
+
CONTENT_EDITABLE_SELECTOR,
|
|
38
|
+
"[tabindex]",
|
|
39
|
+
].join(", ");
|
|
12
40
|
|
|
13
41
|
export namespace ComposerPrimitiveRoot {
|
|
14
42
|
export type Element = ComponentRef<typeof Primitive.form>;
|
|
@@ -16,7 +44,17 @@ export namespace ComposerPrimitiveRoot {
|
|
|
16
44
|
* Props for the ComposerPrimitive.Root component.
|
|
17
45
|
* Accepts all standard form element props.
|
|
18
46
|
*/
|
|
19
|
-
export type Props = ComponentPropsWithoutRef<typeof Primitive.form
|
|
47
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.form> & {
|
|
48
|
+
/**
|
|
49
|
+
* Opt the composer into compact mode. While the input holds at most a single
|
|
50
|
+
* line of text and there are no attachments, quote, queued messages, or
|
|
51
|
+
* active dictation, the root renders a `data-compact` attribute so styles
|
|
52
|
+
* can collapse the composer into a single row. It expands automatically
|
|
53
|
+
* when any of those conditions stop holding.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
compact?: boolean | undefined;
|
|
57
|
+
};
|
|
20
58
|
}
|
|
21
59
|
|
|
22
60
|
/**
|
|
@@ -26,6 +64,11 @@ export namespace ComposerPrimitiveRoot {
|
|
|
26
64
|
* is submitted (e.g., via Enter key or submit button). It automatically prevents the
|
|
27
65
|
* default form submission and triggers the composer's send functionality.
|
|
28
66
|
*
|
|
67
|
+
* Clicking blank form space focuses the composer input (the first textarea or
|
|
68
|
+
* contenteditable inside the form). Text selection cannot start from blank
|
|
69
|
+
* areas; descendants that need native mousedown defaults can call
|
|
70
|
+
* `stopPropagation()` in their own `onMouseDown`.
|
|
71
|
+
*
|
|
29
72
|
* @example
|
|
30
73
|
* ```tsx
|
|
31
74
|
* <ComposerPrimitive.Root>
|
|
@@ -37,9 +80,22 @@ export namespace ComposerPrimitiveRoot {
|
|
|
37
80
|
export const ComposerPrimitiveRoot = forwardRef<
|
|
38
81
|
ComposerPrimitiveRoot.Element,
|
|
39
82
|
ComposerPrimitiveRoot.Props
|
|
40
|
-
>(({ onSubmit, ...rest }, forwardedRef) => {
|
|
83
|
+
>(({ onSubmit, onMouseDown, compact, ...rest }, forwardedRef) => {
|
|
41
84
|
const send = useComposerSend();
|
|
42
85
|
|
|
86
|
+
const [multiline, setMultiline] = useState(false);
|
|
87
|
+
const compactContext = useMemo(() => ({ setMultiline }), []);
|
|
88
|
+
const stateAllowsCompact = useAuiState((s) =>
|
|
89
|
+
compact
|
|
90
|
+
? s.composer.attachments.length === 0 &&
|
|
91
|
+
s.composer.quote == null &&
|
|
92
|
+
s.composer.queue.length === 0 &&
|
|
93
|
+
s.composer.dictation == null &&
|
|
94
|
+
!s.composer.text.includes("\n")
|
|
95
|
+
: false,
|
|
96
|
+
);
|
|
97
|
+
const isCompact = stateAllowsCompact && !multiline;
|
|
98
|
+
|
|
43
99
|
const handleSubmit = (e: FormEvent) => {
|
|
44
100
|
e.preventDefault();
|
|
45
101
|
|
|
@@ -47,12 +103,35 @@ export const ComposerPrimitiveRoot = forwardRef<
|
|
|
47
103
|
send();
|
|
48
104
|
};
|
|
49
105
|
|
|
106
|
+
const handleMouseDown = (e: MouseEvent<HTMLFormElement>) => {
|
|
107
|
+
if (e.button !== 0) return;
|
|
108
|
+
const target = e.target;
|
|
109
|
+
// Portaled descendants (e.g. a dialog overlay) propagate mousedown through
|
|
110
|
+
// the React tree while their DOM nodes live outside the form.
|
|
111
|
+
if (!(target instanceof Element) || !e.currentTarget.contains(target))
|
|
112
|
+
return;
|
|
113
|
+
// Bound the ancestor walk to the form: hosts like AssistantModal render
|
|
114
|
+
// the composer inside a wrapper carrying tabindex="-1" (Radix FocusScope).
|
|
115
|
+
const interactive = target.closest(INTERACTIVE_ELEMENT_SELECTOR);
|
|
116
|
+
if (interactive && e.currentTarget.contains(interactive)) return;
|
|
117
|
+
const input = e.currentTarget.querySelector<HTMLElement>(
|
|
118
|
+
COMPOSER_INPUT_SELECTOR,
|
|
119
|
+
);
|
|
120
|
+
if (!input) return;
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
input.focus();
|
|
123
|
+
};
|
|
124
|
+
|
|
50
125
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
126
|
+
<ComposerCompactContext.Provider value={compact ? compactContext : null}>
|
|
127
|
+
<Primitive.form
|
|
128
|
+
{...rest}
|
|
129
|
+
data-compact={isCompact ? "" : undefined}
|
|
130
|
+
ref={forwardedRef}
|
|
131
|
+
onSubmit={composeEventHandlers(onSubmit, handleSubmit)}
|
|
132
|
+
onMouseDown={composeEventHandlers(onMouseDown, handleMouseDown)}
|
|
133
|
+
/>
|
|
134
|
+
</ComposerCompactContext.Provider>
|
|
56
135
|
);
|
|
57
136
|
});
|
|
58
137
|
|
|
@@ -5,8 +5,9 @@ import { useAuiState } from "@assistant-ui/store";
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
8
|
-
* Return `null` for optional rendering
|
|
9
|
-
*
|
|
8
|
+
* Return `null` for optional rendering. Do not throw inside the selector:
|
|
9
|
+
* selectors run inside `useSyncExternalStore`'s `getSnapshot`, so a transient
|
|
10
|
+
* part mismatch during thread switches can unmount the React root.
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```tsx
|