@assistant-ui/react 0.15.30 → 0.15.32
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/dist/_virtual/_rolldown/runtime.js +1 -2
- package/dist/adapters/OpenAIRealtimeVoiceAdapter.js +1 -2
- package/dist/assistant-transport.js +1 -2
- package/dist/cloud-renderer/CloudRendererHost.d.ts.map +1 -1
- package/dist/cloud-renderer/CloudRendererHost.js +2 -4
- package/dist/cloud-renderer/CloudRendererHost.js.map +1 -1
- package/dist/context/ReadonlyStore.js +1 -2
- package/dist/context/providers/AttachmentByIndexProvider.js +1 -2
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js +1 -2
- package/dist/context/providers/MessageByIndexProvider.js +1 -2
- package/dist/context/providers/MessageProvider.js +1 -2
- package/dist/context/providers/PartByIndexProvider.js +1 -2
- package/dist/context/providers/SuggestionByIndexProvider.js +1 -2
- package/dist/context/providers/TextMessagePartProvider.js +1 -2
- package/dist/context/providers/ThreadListItemProvider.js +1 -2
- package/dist/context/providers/ThreadViewportProvider.js +1 -2
- package/dist/context/react/ThreadViewportContext.js +1 -2
- package/dist/context/react/utils/createContextHook.js +1 -2
- package/dist/context/react/utils/createContextStoreHook.js +1 -2
- package/dist/context/stores/ThreadViewport.js +1 -2
- package/dist/devtools/DevToolsHooks.js +1 -2
- package/dist/hooks/useMessageQuote.js +1 -2
- package/dist/hooks/useMessageTiming.js +1 -2
- package/dist/hooks/useToolCallElapsed.js +1 -2
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -9
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -3
- package/dist/internal.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -2
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +3 -3
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/mcp-apps/McpAppsRemoteHost.js +1 -2
- package/dist/mcp-apps/app-frame.js +1 -2
- package/dist/mcp-apps/bridge.js +1 -2
- package/dist/mcp-apps/csp.js +1 -2
- package/dist/mcp-apps/types.js +1 -2
- package/dist/mcp-apps/utils.js +1 -2
- package/dist/model-context/frame/useAssistantFrameHost.js +1 -2
- package/dist/model-context/makeAssistantVisible.js +1 -2
- package/dist/primitives/actionBar/ActionBarCopy.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +1 -2
- package/dist/primitives/actionBar/ActionBarEdit.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +1 -2
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +1 -2
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +1 -2
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +1 -2
- package/dist/primitives/actionBar/ActionBarInteractionContext.js +1 -2
- package/dist/primitives/actionBar/ActionBarReload.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js +1 -2
- package/dist/primitives/actionBar/ActionBarRoot.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js +1 -2
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +1 -2
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +1 -2
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +1 -2
- package/dist/primitives/actionBar.js +1 -2
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js +1 -2
- package/dist/primitives/actionBarMore/ActionBarMoreItem.js +1 -2
- package/dist/primitives/actionBarMore/ActionBarMoreRoot.js +1 -2
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js +1 -2
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js +1 -2
- package/dist/primitives/actionBarMore/scope.js +1 -2
- package/dist/primitives/actionBarMore.js +1 -2
- package/dist/primitives/assistantModal/AssistantModalAnchor.js +1 -2
- package/dist/primitives/assistantModal/AssistantModalContent.js +1 -2
- package/dist/primitives/assistantModal/AssistantModalRoot.js +1 -2
- package/dist/primitives/assistantModal/AssistantModalTrigger.js +1 -2
- package/dist/primitives/assistantModal/popoverRenderPrimitives.js +1 -2
- package/dist/primitives/assistantModal/scope.js +1 -2
- package/dist/primitives/assistantModal.js +1 -2
- package/dist/primitives/attachment/AttachmentName.js +1 -2
- package/dist/primitives/attachment/AttachmentRemove.d.ts +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +1 -2
- package/dist/primitives/attachment/AttachmentRoot.d.ts +1 -1
- package/dist/primitives/attachment/AttachmentRoot.js +1 -2
- package/dist/primitives/attachment/AttachmentThumb.d.ts +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +1 -2
- package/dist/primitives/attachment.js +1 -2
- package/dist/primitives/branchPicker/BranchPickerCount.js +1 -2
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +1 -2
- package/dist/primitives/branchPicker/BranchPickerNumber.js +1 -2
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +1 -2
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js +1 -2
- package/dist/primitives/branchPicker.js +1 -2
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts +6 -5
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +57 -20
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js +1 -2
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.js +1 -2
- package/dist/primitives/chainOfThought.js +1 -2
- package/dist/primitives/composer/ComposerAddAttachment.d.ts +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +1 -2
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +1 -2
- package/dist/primitives/composer/ComposerAttachments.js +1 -2
- package/dist/primitives/composer/ComposerCancel.d.ts +1 -1
- package/dist/primitives/composer/ComposerCancel.js +1 -2
- package/dist/primitives/composer/ComposerCompactContext.js +1 -2
- package/dist/primitives/composer/ComposerDictate.d.ts +1 -1
- package/dist/primitives/composer/ComposerDictate.js +1 -2
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js +1 -2
- package/dist/primitives/composer/ComposerIf.js +1 -2
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +4 -5
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInputPluginContext.js +1 -2
- package/dist/primitives/composer/ComposerQueue.js +1 -2
- package/dist/primitives/composer/ComposerQuote.d.ts +3 -3
- package/dist/primitives/composer/ComposerQuote.js +1 -2
- package/dist/primitives/composer/ComposerResume.d.ts +1 -1
- package/dist/primitives/composer/ComposerResume.js +1 -2
- package/dist/primitives/composer/ComposerRoot.d.ts +1 -1
- package/dist/primitives/composer/ComposerRoot.js +1 -2
- package/dist/primitives/composer/ComposerSend.d.ts +1 -1
- package/dist/primitives/composer/ComposerSend.js +1 -2
- package/dist/primitives/composer/ComposerStopDictation.d.ts +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js +1 -2
- package/dist/primitives/composer/composerInputSelector.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopoverAction.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopoverBack.d.ts +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts +2 -2
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts +2 -2
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopoverResource.js +1 -2
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js +1 -2
- package/dist/primitives/composer/trigger/detectTrigger.js +1 -2
- package/dist/primitives/composer/trigger/index.d.ts +1 -1
- package/dist/primitives/composer/trigger/index.js +1 -2
- package/dist/primitives/composer/trigger/matchesTriggerItemQuery.js +1 -2
- package/dist/primitives/composer/trigger/triggerDetectionResource.js +1 -2
- package/dist/primitives/composer/trigger/triggerKeyboardResource.js +1 -2
- package/dist/primitives/composer/trigger/triggerNavigationResource.js +1 -2
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js +3 -4
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/composer/useComposerCancelWithFocus.js +1 -2
- package/dist/primitives/composer/useComposerInputState.js +1 -2
- package/dist/primitives/composer.js +1 -2
- package/dist/primitives/dropdownMenuRenderPrimitives.js +1 -2
- package/dist/primitives/error/ErrorMessage.d.ts +1 -1
- package/dist/primitives/error/ErrorMessage.js +1 -2
- package/dist/primitives/error/ErrorRoot.d.ts +1 -1
- package/dist/primitives/error/ErrorRoot.js +1 -2
- package/dist/primitives/error.js +1 -2
- package/dist/primitives/message/MessageAttachments.js +1 -2
- package/dist/primitives/message/MessageError.js +1 -2
- package/dist/primitives/message/MessageIf.js +1 -2
- package/dist/primitives/message/MessageParts.js +1 -2
- package/dist/primitives/message/MessagePartsGrouped.js +1 -2
- package/dist/primitives/message/MessageRoot.d.ts +1 -1
- package/dist/primitives/message/MessageRoot.js +1 -2
- package/dist/primitives/message.js +1 -2
- package/dist/primitives/messagePart/MessagePartImage.d.ts +1 -1
- package/dist/primitives/messagePart/MessagePartImage.js +1 -2
- package/dist/primitives/messagePart/MessagePartInProgress.js +1 -2
- package/dist/primitives/messagePart/MessagePartText.d.ts +1 -1
- package/dist/primitives/messagePart/MessagePartText.js +1 -2
- package/dist/primitives/messagePart/useMessagePartData.js +1 -2
- package/dist/primitives/messagePart/useMessagePartFile.js +1 -2
- package/dist/primitives/messagePart/useMessagePartImage.js +1 -2
- package/dist/primitives/messagePart/useMessagePartReasoning.js +1 -2
- package/dist/primitives/messagePart/useMessagePartSource.js +1 -2
- package/dist/primitives/messagePart/useMessagePartText.js +1 -2
- package/dist/primitives/messagePart.js +1 -2
- package/dist/primitives/queueItem/QueueItemRemove.d.ts +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js +1 -2
- package/dist/primitives/queueItem/QueueItemSteer.d.ts +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js +1 -2
- package/dist/primitives/queueItem/QueueItemText.d.ts +1 -1
- package/dist/primitives/queueItem/QueueItemText.js +1 -2
- package/dist/primitives/queueItem.js +1 -2
- package/dist/primitives/reasoning/useScrollLock.d.ts.map +1 -1
- package/dist/primitives/reasoning/useScrollLock.js +41 -25
- package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +1 -2
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +1 -2
- package/dist/primitives/selectionToolbar.js +1 -2
- package/dist/primitives/suggestion/SuggestionDescription.d.ts +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js +1 -2
- package/dist/primitives/suggestion/SuggestionTitle.d.ts +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js +1 -2
- package/dist/primitives/suggestion/SuggestionTrigger.d.ts +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +1 -2
- package/dist/primitives/suggestion.js +1 -2
- package/dist/primitives/thread/ThreadEmpty.js +1 -2
- package/dist/primitives/thread/ThreadIf.js +1 -2
- package/dist/primitives/thread/ThreadLoadEarlier.d.ts +1 -1
- package/dist/primitives/thread/ThreadLoadEarlier.js +1 -2
- package/dist/primitives/thread/ThreadMessages.js +1 -2
- package/dist/primitives/thread/ThreadRoot.d.ts +1 -1
- package/dist/primitives/thread/ThreadRoot.js +1 -2
- package/dist/primitives/thread/ThreadRootElementContext.js +1 -2
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js +1 -2
- package/dist/primitives/thread/ThreadSuggestion.d.ts +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +1 -2
- package/dist/primitives/thread/ThreadSuggestions.js +1 -2
- package/dist/primitives/thread/ThreadViewport.d.ts +1 -1
- package/dist/primitives/thread/ThreadViewport.js +1 -2
- package/dist/primitives/thread/ThreadViewportFooter.d.ts +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.js +1 -2
- package/dist/primitives/thread/topAnchor/computeTopAnchorSlack.js +1 -2
- package/dist/primitives/thread/topAnchor/createReserveObservers.js +1 -2
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js +1 -2
- package/dist/primitives/thread/topAnchor/topAnchorTurn.js +1 -2
- package/dist/primitives/thread/topAnchor/topAnchorUtils.js +1 -2
- package/dist/primitives/thread/topAnchor/useTopAnchorReserve.js +1 -2
- package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +7 -5
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/thread.js +1 -2
- package/dist/primitives/threadList/ThreadListItems.js +1 -2
- package/dist/primitives/threadList/ThreadListLoadMore.d.ts +1 -1
- package/dist/primitives/threadList/ThreadListLoadMore.js +1 -2
- package/dist/primitives/threadList/ThreadListNew.d.ts +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +1 -2
- package/dist/primitives/threadList/ThreadListRoot.d.ts +1 -1
- package/dist/primitives/threadList/ThreadListRoot.js +1 -2
- package/dist/primitives/threadList.js +1 -2
- package/dist/primitives/threadListFocusGroup.d.ts +1 -1
- package/dist/primitives/threadListFocusGroup.d.ts.map +1 -1
- package/dist/primitives/threadListFocusGroup.js +1 -2
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +1 -2
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +1 -2
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +2 -3
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js +1 -2
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +1 -2
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +2 -2
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +3 -4
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/dist/primitives/threadListItem.js +1 -2
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +1 -2
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js +1 -2
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js +1 -2
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js +1 -2
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +1 -2
- package/dist/primitives/threadListItemMore/scope.js +1 -2
- package/dist/primitives/threadListItemMore.js +1 -2
- package/dist/sandbox-host/SandboxHost.js +1 -2
- package/dist/unstable/useComposerInput.js +2 -3
- package/dist/unstable/useComposerInput.js.map +1 -1
- package/dist/unstable/useComposerInputHistory.d.ts.map +1 -1
- package/dist/unstable/useComposerInputHistory.js +3 -4
- package/dist/unstable/useComposerInputHistory.js.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.d.ts.map +1 -1
- package/dist/unstable/useLiveCompletionAdapter.js +4 -4
- package/dist/unstable/useLiveCompletionAdapter.js.map +1 -1
- package/dist/unstable/useMentionAdapter.js +1 -2
- package/dist/unstable/useMessageStallDetection.js +1 -2
- package/dist/unstable/useModelContextSnapshot.js +1 -2
- package/dist/unstable/useSlashCommandAdapter.js +1 -2
- package/dist/unstable/webmcp/WebMcpRegistrationResource.js +1 -2
- package/dist/unstable/webmcp/convertTools.js +1 -2
- package/dist/unstable/webmcp/useWebMcpProvider.js +1 -2
- package/dist/unstable/webmcp/webmcp-host.js +1 -2
- package/dist/utils/Primitive.d.ts +17 -17
- package/dist/utils/Primitive.js +1 -2
- package/dist/utils/createActionButton.d.ts +1 -1
- package/dist/utils/createActionButton.js +1 -2
- package/dist/utils/getSelectionMessageId.js +1 -2
- package/dist/utils/hooks/useManagedRef.js +1 -2
- package/dist/utils/hooks/useMediaQuery.js +1 -2
- package/dist/utils/hooks/useOnScrollToBottom.js +1 -2
- package/dist/utils/hooks/useSizeHandle.js +1 -2
- package/dist/utils/isCompositionKey.js +1 -2
- package/dist/utils/smooth/SmoothContext.js +1 -2
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +11 -4
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useIsomorphicLayoutEffect.js +0 -1
- package/package.json +13 -13
- package/src/adapters/OpenAIRealtimeVoiceAdapter.test.ts +14 -1
- package/src/cloud-renderer/CloudRendererHost.tsx +4 -2
- package/src/index.ts +9 -8
- package/src/internal.ts +1 -1
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +1 -1
- package/src/mcp-apps/McpAppRenderer.composer.test.tsx +111 -0
- package/src/mcp-apps/McpAppRenderer.test.tsx +24 -23
- package/src/mcp-apps/McpAppRenderer.tsx +9 -1
- package/src/primitives/actionBar/ActionBarCopy.test.tsx +57 -0
- package/src/primitives/actionBar/ActionBarExportMarkdown.test.tsx +24 -5
- package/src/primitives/assistantModal/AssistantModalRoot.test.tsx +1 -1
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.test.tsx +91 -0
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx +54 -0
- package/src/primitives/composer/ComposerInput.focus-on-run-start.test.tsx +1 -1
- package/src/primitives/composer/ComposerInput.test.tsx +1 -0
- package/src/primitives/composer/ComposerInput.text-change.test.tsx +68 -0
- package/src/primitives/composer/ComposerInput.thread-scope.test.tsx +82 -0
- package/src/primitives/composer/ComposerInput.tsx +4 -3
- package/src/primitives/composer/trigger/triggerSelectionResource.test.ts +6 -4
- package/src/primitives/composer/trigger/triggerSelectionResource.ts +2 -0
- package/src/primitives/reasoning/useScrollLock.test.tsx +71 -2
- package/src/primitives/reasoning/useScrollLock.ts +78 -51
- package/src/primitives/thread/ThreadRoot.test.tsx +1 -1
- package/src/primitives/thread/ThreadViewport.thread-scope.test.tsx +51 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +8 -2
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +4 -1
- package/src/primitives/threadListItem/ThreadListItemUnarchive.test.tsx +52 -0
- package/src/primitives/threadListItem/ThreadListItemUnarchive.ts +2 -2
- package/src/primitives/threadListItem/ThreadListKeyboardNav.test.tsx +25 -0
- package/src/tests/DataRenderers.test.tsx +1 -1
- package/src/tests/MessageParts.loading.test.tsx +1 -1
- package/src/tests/RemoteThreadListRuntime.adapterProvider.test.tsx +1 -1
- package/src/tests/RemoteThreadListRuntime.deferredProvider.test.tsx +4 -2
- package/src/tests/RemoteThreadListRuntime.reloadMainThread.test.tsx +4 -2
- package/src/tests/generative-ui.primitive.test.tsx +1 -1
- package/src/tests/local-runtime-queue.test.tsx +2 -2
- package/src/tests/messagePartSwitchRace.test.tsx +2 -2
- package/src/tests/messagePartTypeMismatch.test.tsx +1 -1
- package/src/tests/threadListItemIsRunning.test.tsx +5 -3
- package/src/tests/toolCallTiming.test.tsx +1 -1
- package/src/unstable/useComposerInput.test.tsx +1 -1
- package/src/unstable/useComposerInput.ts +1 -1
- package/src/unstable/useComposerInputHistory.test.tsx +10 -7
- package/src/unstable/useComposerInputHistory.thread-scope.test.tsx +123 -0
- package/src/unstable/useComposerInputHistory.ts +3 -2
- package/src/unstable/useLiveCompletionAdapter.test.tsx +44 -0
- package/src/unstable/useLiveCompletionAdapter.ts +3 -2
- package/src/unstable/webmcp/convertTools.test.ts +11 -1
- package/src/utils/hooks/useMediaQuery.test.tsx +35 -0
- package/src/utils/smooth/useSmooth.test.tsx +150 -14
- package/src/utils/smooth/useSmooth.ts +16 -2
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts +0 -2
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +0 -1
- package/dist/context/providers/ChainOfThoughtPartByIndexProvider.js +0 -3
- package/dist/legacy-runtime/RuntimeAdapter.d.ts +0 -2
- package/dist/legacy-runtime/RuntimeAdapter.d.ts.map +0 -1
- package/dist/legacy-runtime/RuntimeAdapter.js +0 -2
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts +0 -2
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +0 -1
- package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.js +0 -3
- package/dist/legacy-runtime/runtime/AssistantRuntime.d.ts +0 -3
- package/dist/legacy-runtime/runtime/AssistantRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/AssistantRuntime.js +0 -2
- package/dist/legacy-runtime/runtime/AttachmentRuntime.d.ts +0 -3
- package/dist/legacy-runtime/runtime/AttachmentRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/AttachmentRuntime.js +0 -2
- package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts +0 -4
- package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/ComposerRuntime.js +0 -2
- package/dist/legacy-runtime/runtime/RuntimeBindings.d.ts +0 -3
- package/dist/legacy-runtime/runtime/RuntimeBindings.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/RuntimeBindings.js +0 -0
- package/dist/legacy-runtime/runtime/RuntimePathTypes.d.ts +0 -2
- package/dist/legacy-runtime/runtime/RuntimePathTypes.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/RuntimePathTypes.js +0 -0
- package/dist/legacy-runtime/runtime/ThreadListItemRuntime.d.ts +0 -5
- package/dist/legacy-runtime/runtime/ThreadListItemRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/ThreadListItemRuntime.js +0 -2
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts +0 -4
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/ThreadRuntime.js +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.js +0 -3
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.js +0 -3
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/core/AssistantRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/core/AssistantRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/AssistantRuntimeCore.js +0 -0
- package/dist/legacy-runtime/runtime-cores/core/BaseAssistantRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/core/BaseAssistantRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/BaseAssistantRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.js +0 -0
- package/dist/legacy-runtime/runtime-cores/core/ThreadListRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/core/ThreadListRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/ThreadListRuntimeCore.js +0 -0
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.js +0 -0
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.js +0 -0
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadListRuntimeCore.d.ts +0 -3
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadListRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageConverter.d.ts +0 -3
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageConverter.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageConverter.js +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.d.ts +0 -3
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.js +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/auto-status.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/auto-status.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/auto-status.js +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js +0 -3
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.js +0 -3
- package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.js +0 -3
- package/dist/legacy-runtime/runtime-cores/local/ChatModelAdapter.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/local/ChatModelAdapter.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/ChatModelAdapter.js +0 -0
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts +0 -4
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js +0 -2
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadListRuntimeCore.d.ts +0 -3
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadListRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadListRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js +0 -2
- package/dist/legacy-runtime/runtime-cores/local/shouldContinue.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/local/shouldContinue.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/shouldContinue.js +0 -2
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js +0 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/BaseSubscribable.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/BaseSubscribable.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/BaseSubscribable.js +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/OptimisticState.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/OptimisticState.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/OptimisticState.js +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js +0 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +0 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js +0 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.js +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.js +0 -0
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js +0 -3
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.d.ts +0 -4
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.js +0 -3
- package/dist/utils/hooks/useOnResizeContent.d.ts +0 -2
- package/dist/utils/hooks/useOnResizeContent.d.ts.map +0 -1
- package/dist/utils/hooks/useOnResizeContent.js +0 -21
- package/dist/utils/hooks/useOnResizeContent.js.map +0 -1
- package/src/context/providers/ChainOfThoughtPartByIndexProvider.tsx +0 -3
- package/src/legacy-runtime/RuntimeAdapter.ts +0 -1
- package/src/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.ts +0 -3
- package/src/legacy-runtime/runtime/AssistantRuntime.ts +0 -2
- package/src/legacy-runtime/runtime/AttachmentRuntime.ts +0 -7
- package/src/legacy-runtime/runtime/ComposerRuntime.ts +0 -20
- package/src/legacy-runtime/runtime/RuntimeBindings.ts +0 -12
- package/src/legacy-runtime/runtime/RuntimePathTypes.ts +0 -8
- package/src/legacy-runtime/runtime/ThreadListItemRuntime.ts +0 -10
- package/src/legacy-runtime/runtime/ThreadRuntime.ts +0 -14
- package/src/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.tsx +0 -7
- package/src/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.ts +0 -3
- package/src/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/core/AssistantRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/core/BaseAssistantRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.ts +0 -6
- package/src/legacy-runtime/runtime-cores/core/ThreadListRuntimeCore.ts +0 -4
- package/src/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.ts +0 -13
- package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.ts +0 -6
- package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadListRuntimeCore.ts +0 -2
- package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.ts +0 -4
- package/src/legacy-runtime/runtime-cores/external-store/ThreadMessageConverter.ts +0 -2
- package/src/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.ts +0 -2
- package/src/legacy-runtime/runtime-cores/external-store/auto-status.ts +0 -1
- package/src/legacy-runtime/runtime-cores/external-store/createMessageConverter.ts +0 -2
- package/src/legacy-runtime/runtime-cores/external-store/external-message-converter.ts +0 -7
- package/src/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.ts +0 -3
- package/src/legacy-runtime/runtime-cores/local/ChatModelAdapter.ts +0 -7
- package/src/legacy-runtime/runtime-cores/local/LocalRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.ts +0 -3
- package/src/legacy-runtime/runtime-cores/local/LocalThreadListRuntimeCore.ts +0 -2
- package/src/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.ts +0 -1
- package/src/legacy-runtime/runtime-cores/local/shouldContinue.ts +0 -1
- package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.ts +0 -3
- package/src/legacy-runtime/runtime-cores/remote-thread-list/BaseSubscribable.ts +0 -1
- package/src/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.ts +0 -1
- package/src/legacy-runtime/runtime-cores/remote-thread-list/OptimisticState.ts +0 -1
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +0 -3
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +0 -3
- package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +0 -3
- package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.ts +0 -1
- package/src/legacy-runtime/runtime-cores/remote-thread-list/types.ts +0 -7
- package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.ts +0 -3
- package/src/legacy-runtime/runtime-cores/utils/MessageRepository.ts +0 -3
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.ts +0 -49
- package/src/utils/hooks/useOnResizeContent.ts +0 -15
|
@@ -17,10 +17,12 @@ import {
|
|
|
17
17
|
type AssistantClient,
|
|
18
18
|
} from "@assistant-ui/store";
|
|
19
19
|
import { resource } from "@assistant-ui/tap";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
ReadonlyThreadProvider,
|
|
22
|
+
useExternalStoreRuntime,
|
|
23
|
+
} from "@assistant-ui/core/react";
|
|
21
24
|
import type { ThreadMessage } from "@assistant-ui/core";
|
|
22
25
|
import { AssistantRuntimeProvider } from "../legacy-runtime/AssistantRuntimeProvider";
|
|
23
|
-
import { useExternalStoreRuntime } from "../legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime";
|
|
24
26
|
|
|
25
27
|
const CHANNEL = "assistant-ui/cloud-renderer";
|
|
26
28
|
|
package/src/index.ts
CHANGED
|
@@ -60,7 +60,7 @@ export {
|
|
|
60
60
|
SimpleTextAttachmentAdapter,
|
|
61
61
|
CompositeAttachmentAdapter,
|
|
62
62
|
} from "@assistant-ui/core";
|
|
63
|
-
export { CloudFileAttachmentAdapter } from "
|
|
63
|
+
export { CloudFileAttachmentAdapter } from "@assistant-ui/core/react";
|
|
64
64
|
|
|
65
65
|
// --- adapters/voice ---
|
|
66
66
|
export type { RealtimeVoiceAdapter } from "@assistant-ui/core";
|
|
@@ -164,7 +164,7 @@ export {
|
|
|
164
164
|
type ExternalThreadQueueAdapter,
|
|
165
165
|
type ExternalThreadBranchAdapter,
|
|
166
166
|
} from "@assistant-ui/core";
|
|
167
|
-
export { useExternalStoreRuntime } from "
|
|
167
|
+
export { useExternalStoreRuntime } from "@assistant-ui/core/react";
|
|
168
168
|
export { useExternalStoreSharedOptions } from "@assistant-ui/core/react";
|
|
169
169
|
export {
|
|
170
170
|
useExternalMessageConverter,
|
|
@@ -174,11 +174,11 @@ export {
|
|
|
174
174
|
createExternalMessageConversionCache as unstable_createExternalMessageConversionCache,
|
|
175
175
|
/** @deprecated Experimental since 2026-09-15. Not scheduled for removal; the API may change in any release. */
|
|
176
176
|
type ExternalMessageConversionCache as Unstable_ExternalMessageConversionCache,
|
|
177
|
-
} from "
|
|
177
|
+
} from "@assistant-ui/core/react";
|
|
178
178
|
export {
|
|
179
179
|
/** @deprecated Experimental since 2025-02-02. Not scheduled for removal; the API may change in any release. */
|
|
180
180
|
createMessageConverter as unstable_createMessageConverter,
|
|
181
|
-
} from "
|
|
181
|
+
} from "@assistant-ui/core/react";
|
|
182
182
|
|
|
183
183
|
// --- local ---
|
|
184
184
|
export type {
|
|
@@ -188,12 +188,12 @@ export type {
|
|
|
188
188
|
ChatModelRunUpdate,
|
|
189
189
|
LocalRuntimeOptionsBase,
|
|
190
190
|
} from "@assistant-ui/core";
|
|
191
|
-
export { useLocalRuntime } from "
|
|
192
|
-
export type { LocalRuntimeOptions } from "
|
|
191
|
+
export { useLocalRuntime } from "@assistant-ui/core/react";
|
|
192
|
+
export type { LocalRuntimeOptions } from "@assistant-ui/core/react";
|
|
193
193
|
|
|
194
194
|
// --- remote-thread-list ---
|
|
195
|
-
export { useRemoteThreadListRuntime } from "
|
|
196
|
-
export { useCloudThreadListAdapter } from "
|
|
195
|
+
export { useRemoteThreadListRuntime } from "@assistant-ui/core/react";
|
|
196
|
+
export { useCloudThreadListAdapter } from "@assistant-ui/core/react";
|
|
197
197
|
export type {
|
|
198
198
|
RemoteThreadListAdapter,
|
|
199
199
|
RemoteThreadListProviderComponent,
|
|
@@ -303,6 +303,7 @@ export type {
|
|
|
303
303
|
QueueItemMethods,
|
|
304
304
|
} from "@assistant-ui/core/store";
|
|
305
305
|
export type { ComposerSendOptions } from "@assistant-ui/core/store";
|
|
306
|
+
export type { ComposerTextOrigin } from "@assistant-ui/core";
|
|
306
307
|
|
|
307
308
|
export { makeAssistantVisible } from "./model-context/makeAssistantVisible";
|
|
308
309
|
|
package/src/internal.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type {
|
|
|
20
20
|
} from "@assistant-ui/core/internal";
|
|
21
21
|
|
|
22
22
|
// React-specific (stay in react)
|
|
23
|
-
export { splitLocalRuntimeOptions } from "
|
|
23
|
+
export { splitLocalRuntimeOptions } from "@assistant-ui/core/react";
|
|
24
24
|
export type { ToolExecutionStatus } from "@assistant-ui/core";
|
|
25
25
|
|
|
26
26
|
export { useSmooth } from "./utils/smooth/useSmooth";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type AuiConfig,
|
|
7
7
|
useAui,
|
|
8
8
|
} from "@assistant-ui/store";
|
|
9
|
-
import type { AssistantRuntime } from "
|
|
9
|
+
import type { AssistantRuntime } from "@assistant-ui/core";
|
|
10
10
|
import { AssistantProviderBase } from "@assistant-ui/core/react";
|
|
11
11
|
import { ThreadPrimitiveViewportProvider } from "../context/providers/ThreadViewportProvider";
|
|
12
12
|
import { DevToolsProviderApi } from "../devtools/DevToolsHooks";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, render, waitFor } from "@testing-library/react";
|
|
3
|
+
import { resource, useResource } from "@assistant-ui/tap";
|
|
4
|
+
import {
|
|
5
|
+
AssistantRuntimeProvider,
|
|
6
|
+
MessageByIndexProvider,
|
|
7
|
+
useExternalStoreRuntime,
|
|
8
|
+
type ToolCallMessagePartProps,
|
|
9
|
+
} from "@assistant-ui/core/react";
|
|
10
|
+
import type { ThreadMessageLike } from "@assistant-ui/core";
|
|
11
|
+
import { expect, it, vi } from "vitest";
|
|
12
|
+
import type { AssistantRuntime } from "../index";
|
|
13
|
+
import type { McpAppBridgeHandlers, McpAppsHost } from "./types";
|
|
14
|
+
|
|
15
|
+
const { framePropsMock } = vi.hoisted(() => ({ framePropsMock: vi.fn() }));
|
|
16
|
+
|
|
17
|
+
vi.mock("./app-frame", () => ({
|
|
18
|
+
McpAppFrame: (props: unknown) => {
|
|
19
|
+
framePropsMock(props);
|
|
20
|
+
return null;
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
import { McpAppRenderer } from "./McpAppRenderer";
|
|
25
|
+
|
|
26
|
+
const Host = resource(({ host }: { host: McpAppsHost }) => host);
|
|
27
|
+
|
|
28
|
+
const host: McpAppsHost = {
|
|
29
|
+
loadResource: vi.fn(async ({ uri }) => ({
|
|
30
|
+
uri,
|
|
31
|
+
mimeType: "text/html;profile=mcp-app" as const,
|
|
32
|
+
html: "",
|
|
33
|
+
})),
|
|
34
|
+
callTool: vi.fn(),
|
|
35
|
+
readResource: vi.fn(),
|
|
36
|
+
listResources: vi.fn(),
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const part: ToolCallMessagePartProps = {
|
|
40
|
+
type: "tool-call",
|
|
41
|
+
toolCallId: "call-1",
|
|
42
|
+
toolName: "search",
|
|
43
|
+
args: {},
|
|
44
|
+
argsText: "{}",
|
|
45
|
+
status: { type: "complete" },
|
|
46
|
+
mcp: { app: { resourceUri: "ui://example/search" } },
|
|
47
|
+
addResult: vi.fn(),
|
|
48
|
+
resume: vi.fn(),
|
|
49
|
+
respondToApproval: vi.fn(),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const messages: ThreadMessageLike[] = [
|
|
53
|
+
{ role: "assistant", content: "Here is the app" },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const AppPart = () => {
|
|
57
|
+
const renderer = useResource(McpAppRenderer({ host: Host({ host }) }));
|
|
58
|
+
const Renderer = renderer.render;
|
|
59
|
+
return <Renderer {...part} />;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
let runtime!: AssistantRuntime;
|
|
63
|
+
|
|
64
|
+
const App = () => {
|
|
65
|
+
runtime = useExternalStoreRuntime({
|
|
66
|
+
messages,
|
|
67
|
+
convertMessage: (message: ThreadMessageLike) => message,
|
|
68
|
+
onNew: async () => {},
|
|
69
|
+
});
|
|
70
|
+
return (
|
|
71
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
72
|
+
<MessageByIndexProvider index={0}>
|
|
73
|
+
<AppPart />
|
|
74
|
+
</MessageByIndexProvider>
|
|
75
|
+
</AssistantRuntimeProvider>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const renderApp = async () => {
|
|
80
|
+
framePropsMock.mockClear();
|
|
81
|
+
render(<App />);
|
|
82
|
+
await waitFor(() => expect(framePropsMock).toHaveBeenCalled());
|
|
83
|
+
const handlers = framePropsMock.mock.lastCall?.[0]
|
|
84
|
+
.handlers as McpAppBridgeHandlers;
|
|
85
|
+
return handlers;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
it("fills the thread composer from an MCP App message inside a message", async () => {
|
|
89
|
+
const handlers = await renderApp();
|
|
90
|
+
|
|
91
|
+
let result: unknown;
|
|
92
|
+
act(() => {
|
|
93
|
+
result = handlers.sendMessage?.({ text: "Open Grade 5 Math" });
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(result).toEqual({ ok: true });
|
|
97
|
+
expect(runtime.thread.composer.getState().text).toBe("Open Grade 5 Math");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("keeps the user's draft when an MCP App message arrives", async () => {
|
|
101
|
+
const handlers = await renderApp();
|
|
102
|
+
act(() => runtime.thread.composer.setText("Show my classes"));
|
|
103
|
+
|
|
104
|
+
act(() => {
|
|
105
|
+
handlers.sendMessage?.({ text: "Open Grade 5 Math" });
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(runtime.thread.composer.getState().text).toBe(
|
|
109
|
+
"Show my classes Open Grade 5 Math",
|
|
110
|
+
);
|
|
111
|
+
});
|
|
@@ -16,15 +16,22 @@ import type {
|
|
|
16
16
|
McpAppsRemoteHostOptions,
|
|
17
17
|
} from "./types";
|
|
18
18
|
|
|
19
|
-
const { appendMock, framePropsMock } = vi.hoisted(() => ({
|
|
19
|
+
const { appendMock, setTextMock, framePropsMock } = vi.hoisted(() => ({
|
|
20
20
|
appendMock: vi.fn(),
|
|
21
|
+
setTextMock: vi.fn(),
|
|
21
22
|
framePropsMock: vi.fn(),
|
|
22
23
|
}));
|
|
23
24
|
|
|
24
25
|
vi.mock("@assistant-ui/store", async (importOriginal) => ({
|
|
25
26
|
...(await importOriginal()),
|
|
26
27
|
useAui: () => ({
|
|
27
|
-
thread: {
|
|
28
|
+
thread: {
|
|
29
|
+
append: appendMock,
|
|
30
|
+
composer: () => ({
|
|
31
|
+
setText: setTextMock,
|
|
32
|
+
getState: () => ({ text: "" }),
|
|
33
|
+
}),
|
|
34
|
+
},
|
|
28
35
|
}),
|
|
29
36
|
}));
|
|
30
37
|
|
|
@@ -190,6 +197,7 @@ function RemoteHarness({
|
|
|
190
197
|
describe("McpAppRenderer", () => {
|
|
191
198
|
beforeEach(() => {
|
|
192
199
|
appendMock.mockReset();
|
|
200
|
+
setTextMock.mockReset();
|
|
193
201
|
framePropsMock.mockReset();
|
|
194
202
|
});
|
|
195
203
|
|
|
@@ -676,7 +684,7 @@ describe("McpAppRenderer", () => {
|
|
|
676
684
|
expect(listResources).toHaveBeenCalledWith(params);
|
|
677
685
|
});
|
|
678
686
|
|
|
679
|
-
it("
|
|
687
|
+
it("puts MCP Apps text content in the composer without appending", async () => {
|
|
680
688
|
render(<Harness host={loadingHost()} />);
|
|
681
689
|
await waitFor(() => expect(framePropsMock).toHaveBeenCalled());
|
|
682
690
|
const handlers = framePropsMock.mock.lastCall?.[0]
|
|
@@ -692,19 +700,13 @@ describe("McpAppRenderer", () => {
|
|
|
692
700
|
],
|
|
693
701
|
}),
|
|
694
702
|
).toEqual({ ok: true });
|
|
695
|
-
expect(
|
|
696
|
-
|
|
697
|
-
{ type: "text", text: "Open Grade 5 Math" },
|
|
698
|
-
{ type: "text", text: "Period 4" },
|
|
699
|
-
],
|
|
700
|
-
});
|
|
703
|
+
expect(setTextMock).toHaveBeenCalledWith("Open Grade 5 Math\nPeriod 4");
|
|
704
|
+
expect(appendMock).not.toHaveBeenCalled();
|
|
701
705
|
|
|
702
706
|
expect(handlers.sendMessage?.({ text: "typed instead" })).toEqual({
|
|
703
707
|
ok: true,
|
|
704
708
|
});
|
|
705
|
-
expect(
|
|
706
|
-
content: [{ type: "text", text: "typed instead" }],
|
|
707
|
-
});
|
|
709
|
+
expect(setTextMock).toHaveBeenLastCalledWith("typed instead");
|
|
708
710
|
|
|
709
711
|
expect(
|
|
710
712
|
handlers.sendMessage?.({
|
|
@@ -722,7 +724,8 @@ describe("McpAppRenderer", () => {
|
|
|
722
724
|
ok: false,
|
|
723
725
|
reason: "unrecognised params shape",
|
|
724
726
|
});
|
|
725
|
-
expect(
|
|
727
|
+
expect(setTextMock).toHaveBeenCalledTimes(2);
|
|
728
|
+
expect(appendMock).not.toHaveBeenCalled();
|
|
726
729
|
});
|
|
727
730
|
|
|
728
731
|
it("extracts sparse message content without traversing holes", async () => {
|
|
@@ -755,9 +758,8 @@ describe("McpAppRenderer", () => {
|
|
|
755
758
|
}
|
|
756
759
|
|
|
757
760
|
expect(visitedHole).not.toHaveBeenCalled();
|
|
758
|
-
expect(
|
|
759
|
-
|
|
760
|
-
});
|
|
761
|
+
expect(setTextMock).toHaveBeenCalledExactlyOnceWith("sparse prompt");
|
|
762
|
+
expect(appendMock).not.toHaveBeenCalled();
|
|
761
763
|
});
|
|
762
764
|
|
|
763
765
|
it("ignores non-index message content properties after structured clone", async () => {
|
|
@@ -781,13 +783,10 @@ describe("McpAppRenderer", () => {
|
|
|
781
783
|
).toEqual({ ok: true });
|
|
782
784
|
}
|
|
783
785
|
|
|
784
|
-
expect(
|
|
785
|
-
expect(
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
expect(appendMock).toHaveBeenNthCalledWith(2, {
|
|
789
|
-
content: [{ type: "text", text: "message text" }],
|
|
790
|
-
});
|
|
786
|
+
expect(setTextMock).toHaveBeenCalledTimes(2);
|
|
787
|
+
expect(setTextMock).toHaveBeenNthCalledWith(1, "message text");
|
|
788
|
+
expect(setTextMock).toHaveBeenNthCalledWith(2, "message text");
|
|
789
|
+
expect(appendMock).not.toHaveBeenCalled();
|
|
791
790
|
});
|
|
792
791
|
|
|
793
792
|
it("uses caller UI handlers and keeps data-plane handlers on the host", async () => {
|
|
@@ -838,6 +837,8 @@ describe("McpAppRenderer", () => {
|
|
|
838
837
|
expect(updateModelContext).toHaveBeenCalledWith({ text: "context" });
|
|
839
838
|
expect(openLink).toHaveBeenCalledWith({ url: "https://example.com" });
|
|
840
839
|
expect(sendMessage).toHaveBeenCalledWith({ text: "hello" });
|
|
840
|
+
expect(setTextMock).not.toHaveBeenCalled();
|
|
841
|
+
expect(appendMock).not.toHaveBeenCalled();
|
|
841
842
|
expect(onInitialized).toHaveBeenCalledOnce();
|
|
842
843
|
expect(host.callTool).toHaveBeenCalledWith({ name: "search" });
|
|
843
844
|
expect(host.readResource).toHaveBeenCalledWith({ uri: "ui://resource" });
|
|
@@ -277,7 +277,15 @@ function InlineRenderer({
|
|
|
277
277
|
if ("reason" in result) {
|
|
278
278
|
return { isError: true, ok: false, reason: result.reason };
|
|
279
279
|
}
|
|
280
|
-
aui.thread.
|
|
280
|
+
const composer = aui.thread.composer();
|
|
281
|
+
composer.setText(
|
|
282
|
+
[
|
|
283
|
+
composer.getState().text,
|
|
284
|
+
result.content.map((part) => part.text).join("\n"),
|
|
285
|
+
]
|
|
286
|
+
.filter((part) => part.trim())
|
|
287
|
+
.join(" "),
|
|
288
|
+
);
|
|
281
289
|
return { ok: true };
|
|
282
290
|
}),
|
|
283
291
|
callTool: (params) =>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
act,
|
|
5
|
+
cleanup,
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
screen,
|
|
9
|
+
waitFor,
|
|
10
|
+
} from "@testing-library/react";
|
|
11
|
+
import { afterEach, expect, it, vi } from "vitest";
|
|
12
|
+
import type { ChatModelAdapter, ThreadMessageLike } from "@assistant-ui/core";
|
|
13
|
+
import {
|
|
14
|
+
AssistantRuntimeProvider,
|
|
15
|
+
useLocalRuntime,
|
|
16
|
+
} from "@assistant-ui/core/react";
|
|
17
|
+
import { ThreadPrimitiveMessages } from "../thread/ThreadMessages";
|
|
18
|
+
import { ActionBarPrimitiveCopy } from "./ActionBarCopy";
|
|
19
|
+
|
|
20
|
+
const model: ChatModelAdapter = { async *run() {} };
|
|
21
|
+
const initialMessages: ThreadMessageLike[] = [
|
|
22
|
+
{
|
|
23
|
+
role: "assistant",
|
|
24
|
+
content: [{ type: "text", text: "Message to copy." }],
|
|
25
|
+
status: { type: "complete", reason: "stop" },
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
const Message = () => (
|
|
29
|
+
<ActionBarPrimitiveCopy>Copy message</ActionBarPrimitiveCopy>
|
|
30
|
+
);
|
|
31
|
+
const Example = () => {
|
|
32
|
+
const runtime = useLocalRuntime(model, { initialMessages });
|
|
33
|
+
return (
|
|
34
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
35
|
+
<ThreadPrimitiveMessages components={{ Message }} />
|
|
36
|
+
</AssistantRuntimeProvider>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
cleanup();
|
|
42
|
+
vi.unstubAllGlobals();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("copies the scoped message through the browser clipboard", async () => {
|
|
46
|
+
const writeText = vi.fn().mockResolvedValue(undefined);
|
|
47
|
+
vi.stubGlobal("navigator", { ...navigator, clipboard: { writeText } });
|
|
48
|
+
render(<Example />);
|
|
49
|
+
const button = screen.getByRole("button", { name: "Copy message" });
|
|
50
|
+
|
|
51
|
+
await act(async () => {
|
|
52
|
+
fireEvent.click(button);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(writeText).toHaveBeenCalledExactlyOnceWith("Message to copy.");
|
|
56
|
+
await waitFor(() => expect(button.getAttribute("data-copied")).toBe("true"));
|
|
57
|
+
});
|
|
@@ -41,16 +41,24 @@ describe("ActionBarPrimitiveExportMarkdown", () => {
|
|
|
41
41
|
vi.restoreAllMocks();
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
it("
|
|
44
|
+
it("downloads the message as Markdown through an attached anchor", async () => {
|
|
45
45
|
const createObjectURL = vi
|
|
46
46
|
.spyOn(URL, "createObjectURL")
|
|
47
47
|
.mockReturnValue("blob:export");
|
|
48
48
|
vi.spyOn(URL, "revokeObjectURL").mockImplementation(() => {});
|
|
49
|
-
const
|
|
49
|
+
const downloads: {
|
|
50
|
+
isConnected: boolean;
|
|
51
|
+
href: string;
|
|
52
|
+
download: string;
|
|
53
|
+
}[] = [];
|
|
50
54
|
vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(function (
|
|
51
55
|
this: HTMLAnchorElement,
|
|
52
56
|
) {
|
|
53
|
-
|
|
57
|
+
downloads.push({
|
|
58
|
+
isConnected: this.isConnected,
|
|
59
|
+
href: this.href,
|
|
60
|
+
download: this.download,
|
|
61
|
+
});
|
|
54
62
|
});
|
|
55
63
|
|
|
56
64
|
await act(async () => {
|
|
@@ -65,9 +73,20 @@ describe("ActionBarPrimitiveExportMarkdown", () => {
|
|
|
65
73
|
container.querySelector("button")!.click();
|
|
66
74
|
});
|
|
67
75
|
|
|
68
|
-
expect(createObjectURL).
|
|
76
|
+
expect(createObjectURL).toHaveBeenCalledOnce();
|
|
77
|
+
const blob = createObjectURL.mock.calls[0]![0] as Blob;
|
|
78
|
+
expect(blob.type).toBe("text/markdown");
|
|
79
|
+
const content = await new Promise<string>((resolve, reject) => {
|
|
80
|
+
const reader = new FileReader();
|
|
81
|
+
reader.onload = () => resolve(reader.result as string);
|
|
82
|
+
reader.onerror = () => reject(reader.error);
|
|
83
|
+
reader.readAsText(blob);
|
|
84
|
+
});
|
|
85
|
+
expect(content).toBe("# Exported message");
|
|
69
86
|
// Firefox ignores a programmatic click on a detached anchor.
|
|
70
|
-
expect(
|
|
87
|
+
expect(downloads).toEqual([
|
|
88
|
+
{ isConnected: true, href: "blob:export", download: "message.md" },
|
|
89
|
+
]);
|
|
71
90
|
expect(document.querySelector('a[download="message.md"]')).toBeNull();
|
|
72
91
|
});
|
|
73
92
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { useState } from "react";
|
|
11
11
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
12
12
|
import { AssistantRuntimeProvider } from "../../context";
|
|
13
|
-
import { useLocalRuntime } from "
|
|
13
|
+
import { useLocalRuntime } from "@assistant-ui/core/react";
|
|
14
14
|
import { AssistantModalPrimitiveContent } from "./AssistantModalContent";
|
|
15
15
|
import { AssistantModalPrimitiveRoot } from "./AssistantModalRoot";
|
|
16
16
|
import { AssistantModalPrimitiveTrigger } from "./AssistantModalTrigger";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { createRef, type MouseEvent, type Ref } from "react";
|
|
3
|
+
import { cleanup, fireEvent, render, waitFor } from "@testing-library/react";
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { AuiProvider, useAui, useAuiState } from "@assistant-ui/store";
|
|
6
|
+
import { ChainOfThoughtClient } from "@assistant-ui/core/store";
|
|
7
|
+
import { ChainOfThoughtPrimitiveAccordionTrigger } from "./ChainOfThoughtAccordionTrigger";
|
|
8
|
+
|
|
9
|
+
afterEach(cleanup);
|
|
10
|
+
|
|
11
|
+
const Content = () => {
|
|
12
|
+
const collapsed = useAuiState((s) => s.chainOfThought.collapsed);
|
|
13
|
+
return (
|
|
14
|
+
<div data-testid="reasoning" hidden={collapsed}>
|
|
15
|
+
Reasoning details
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const App = ({
|
|
21
|
+
triggerRef,
|
|
22
|
+
...props
|
|
23
|
+
}: ChainOfThoughtPrimitiveAccordionTrigger.Props & {
|
|
24
|
+
triggerRef?: Ref<HTMLButtonElement>;
|
|
25
|
+
}) => {
|
|
26
|
+
const aui = useAui({
|
|
27
|
+
chainOfThought: ChainOfThoughtClient({
|
|
28
|
+
parts: [
|
|
29
|
+
{
|
|
30
|
+
type: "reasoning",
|
|
31
|
+
text: "Reasoning details",
|
|
32
|
+
status: { type: "complete" },
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
getMessagePart: () => {
|
|
36
|
+
throw new Error("Part lookup is not used by the toggle");
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
return (
|
|
41
|
+
<AuiProvider value={aui}>
|
|
42
|
+
<ChainOfThoughtPrimitiveAccordionTrigger {...props} ref={triggerRef} />
|
|
43
|
+
<Content />
|
|
44
|
+
</AuiProvider>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
describe("ChainOfThoughtPrimitiveAccordionTrigger", () => {
|
|
49
|
+
it.each(["button", "render", "asChild"] as const)(
|
|
50
|
+
"exposes expansion and forwards the ref with %s",
|
|
51
|
+
async (mode) => {
|
|
52
|
+
const ref = createRef<HTMLButtonElement>();
|
|
53
|
+
const { getByRole, getByTestId } = render(
|
|
54
|
+
<App
|
|
55
|
+
triggerRef={ref}
|
|
56
|
+
{...(mode === "render" ? { render: <button /> } : {})}
|
|
57
|
+
{...(mode === "asChild" ? { asChild: true } : {})}
|
|
58
|
+
>
|
|
59
|
+
{mode === "asChild" ? <button>Thinking</button> : "Thinking"}
|
|
60
|
+
</App>,
|
|
61
|
+
);
|
|
62
|
+
const button = getByRole("button", { name: "Thinking" });
|
|
63
|
+
const content = getByTestId("reasoning");
|
|
64
|
+
expect(ref.current).toBe(button);
|
|
65
|
+
expect(content.hidden).toBe(true);
|
|
66
|
+
expect(button.getAttribute("aria-expanded")).toBe("false");
|
|
67
|
+
fireEvent.click(button);
|
|
68
|
+
await waitFor(() => expect(content.hidden).toBe(false));
|
|
69
|
+
expect(button.getAttribute("aria-expanded")).toBe("true");
|
|
70
|
+
fireEvent.click(button);
|
|
71
|
+
await waitFor(() => expect(content.hidden).toBe(true));
|
|
72
|
+
expect(button.getAttribute("aria-expanded")).toBe("false");
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
it("lets the caller veto expansion", () => {
|
|
77
|
+
const onClick = vi.fn((event: MouseEvent) => event.preventDefault());
|
|
78
|
+
const { getByRole, getByTestId } = render(
|
|
79
|
+
<App onClick={onClick}>Thinking</App>,
|
|
80
|
+
);
|
|
81
|
+
fireEvent.click(getByRole("button"));
|
|
82
|
+
expect(onClick).toHaveBeenCalledOnce();
|
|
83
|
+
expect(getByTestId("reasoning").hidden).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("does not expand a disabled trigger", () => {
|
|
87
|
+
const { getByRole, getByTestId } = render(<App disabled>Thinking</App>);
|
|
88
|
+
fireEvent.click(getByRole("button"));
|
|
89
|
+
expect(getByTestId("reasoning").hidden).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ActionButtonElement } from "../../utils/createActionButton";
|
|
4
|
+
import { type ComponentPropsWithoutRef, forwardRef, useCallback } from "react";
|
|
5
|
+
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
6
|
+
import { composeEventHandlers } from "radix-ui/internal";
|
|
7
|
+
import { Primitive } from "../../utils/Primitive";
|
|
8
|
+
|
|
9
|
+
export namespace ChainOfThoughtPrimitiveAccordionTrigger {
|
|
10
|
+
export type Element = ActionButtonElement;
|
|
11
|
+
/**
|
|
12
|
+
* Props for the ChainOfThoughtPrimitive.AccordionTrigger component.
|
|
13
|
+
* Inherits all button element props and action button functionality.
|
|
14
|
+
*/
|
|
15
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A button component that toggles the collapsed state of the chain of thought accordion.
|
|
20
|
+
*
|
|
21
|
+
* This component automatically handles the toggle functionality, expanding or collapsing
|
|
22
|
+
* the chain of thought parts when clicked.
|
|
23
|
+
* Exposes the current disclosure state through `aria-expanded`.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <ChainOfThoughtPrimitive.AccordionTrigger>
|
|
28
|
+
* Toggle Reasoning
|
|
29
|
+
* </ChainOfThoughtPrimitive.AccordionTrigger>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const ChainOfThoughtPrimitiveAccordionTrigger = forwardRef<
|
|
33
|
+
ChainOfThoughtPrimitiveAccordionTrigger.Element,
|
|
34
|
+
ChainOfThoughtPrimitiveAccordionTrigger.Props
|
|
35
|
+
>(({ onClick, ...props }, ref) => {
|
|
36
|
+
const aui = useAui();
|
|
37
|
+
const collapsed = useAuiState((s) => s.chainOfThought.collapsed);
|
|
38
|
+
const toggle = useCallback(() => {
|
|
39
|
+
aui.chainOfThought.setCollapsed(!collapsed);
|
|
40
|
+
}, [aui, collapsed]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Primitive.button
|
|
44
|
+
type="button"
|
|
45
|
+
{...props}
|
|
46
|
+
ref={ref}
|
|
47
|
+
aria-expanded={!collapsed}
|
|
48
|
+
onClick={composeEventHandlers(onClick, toggle)}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
ChainOfThoughtPrimitiveAccordionTrigger.displayName =
|
|
54
|
+
"ChainOfThoughtPrimitive.AccordionTrigger";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { AssistantRuntimeProvider } from "../../context";
|
|
6
|
-
import { useLocalRuntime } from "
|
|
6
|
+
import { useLocalRuntime } from "@assistant-ui/core/react";
|
|
7
7
|
import { ThreadPrimitiveRoot } from "../thread/ThreadRoot";
|
|
8
8
|
import { ComposerPrimitiveInput } from "./ComposerInput";
|
|
9
9
|
import { ComposerPrimitiveRoot } from "./ComposerRoot";
|