@assistant-ui/react 0.12.8 → 0.12.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +10 -0
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/client/NoOpComposerClient.d.ts.map +1 -1
- package/dist/client/NoOpComposerClient.js +4 -0
- package/dist/client/NoOpComposerClient.js.map +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js +1 -1
- package/dist/context/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
- package/dist/context/react/utils/ensureBinding.js +1 -1
- package/dist/context/react/utils/ensureBinding.js.map +1 -1
- package/dist/hooks/useMessageQuote.d.ts +17 -0
- package/dist/hooks/useMessageQuote.d.ts.map +1 -0
- package/dist/hooks/useMessageQuote.js +20 -0
- package/dist/hooks/useMessageQuote.js.map +1 -0
- 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/legacy-runtime/client/ComposerRuntimeClient.d.ts.map +1 -1
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js +2 -0
- package/dist/legacy-runtime/client/ComposerRuntimeClient.js.map +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/AssistantContext.js +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.js +1 -1
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts +6 -6
- package/dist/legacy-runtime/hooks/ComposerContext.js +4 -4
- package/dist/legacy-runtime/hooks/MessageContext.d.ts +5 -5
- package/dist/legacy-runtime/hooks/MessageContext.js +5 -5
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.js +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts +5 -5
- package/dist/legacy-runtime/hooks/ThreadContext.js +4 -4
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js +1 -1
- package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts +12 -0
- package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime/ComposerRuntime.js +9 -0
- package/dist/legacy-runtime/runtime/ComposerRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts +2 -0
- package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +5 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +36 -26
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js +7 -7
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts +4 -0
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js +16 -2
- package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts +3 -0
- package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js +4 -0
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +7 -6
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +4 -3
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +4 -3
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +5 -5
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/attachment/AttachmentName.js +1 -1
- package/dist/primitives/attachment/AttachmentName.js.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js +2 -2
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +3 -3
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerNumber.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +3 -3
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts +3 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js +5 -7
- package/dist/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachments.js +1 -1
- package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +1 -1
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerDictate.js +3 -3
- package/dist/primitives/composer/ComposerDictate.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerIf.js +4 -4
- package/dist/primitives/composer/ComposerIf.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts +35 -45
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +25 -9
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.d.ts +52 -0
- package/dist/primitives/composer/ComposerQuote.d.ts.map +1 -0
- package/dist/primitives/composer/ComposerQuote.js +57 -0
- package/dist/primitives/composer/ComposerQuote.js.map +1 -0
- package/dist/primitives/composer/ComposerStopDictation.js +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/composer/index.d.ts +3 -0
- package/dist/primitives/composer/index.d.ts.map +1 -1
- package/dist/primitives/composer/index.js +3 -0
- package/dist/primitives/composer/index.js.map +1 -1
- package/dist/primitives/error/ErrorMessage.js +4 -4
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +2 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/message/MessageAttachments.js +4 -4
- package/dist/primitives/message/MessageAttachments.js.map +1 -1
- package/dist/primitives/message/MessageError.js +2 -2
- package/dist/primitives/message/MessageError.js.map +1 -1
- package/dist/primitives/message/MessageIf.js +3 -3
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts +140 -133
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js +7 -7
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +5 -5
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/message/MessageRoot.js +6 -5
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js +1 -1
- package/dist/primitives/messagePart/MessagePartInProgress.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js +3 -3
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.js +3 -3
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.js +3 -3
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.js +3 -3
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.js +3 -3
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.js +3 -3
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts +24 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts.map +1 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +37 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts +31 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts.map +1 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +85 -0
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -0
- package/dist/primitives/selectionToolbar/index.d.ts +3 -0
- package/dist/primitives/selectionToolbar/index.d.ts.map +1 -0
- package/dist/primitives/selectionToolbar/index.js +3 -0
- package/dist/primitives/selectionToolbar/index.js.map +1 -0
- package/dist/primitives/suggestion/SuggestionDescription.js +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.d.ts.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +6 -3
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +1 -1
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.js +7 -7
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadMessages.js +3 -3
- package/dist/primitives/thread/ThreadMessages.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +5 -2
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestions.js +1 -1
- package/dist/primitives/thread/ThreadSuggestions.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportSlack.js +4 -4
- package/dist/primitives/thread/ThreadViewportSlack.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +1 -1
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +1 -1
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
- package/dist/types/QuoteTypes.d.ts +5 -0
- package/dist/types/QuoteTypes.d.ts.map +1 -0
- package/dist/types/QuoteTypes.js +2 -0
- package/dist/types/QuoteTypes.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/scopes/composer.d.ts +10 -0
- package/dist/types/scopes/composer.d.ts.map +1 -1
- package/dist/utils/getSelectionMessageId.d.ts +2 -0
- package/dist/utils/getSelectionMessageId.d.ts.map +1 -0
- package/dist/utils/getSelectionMessageId.js +21 -0
- package/dist/utils/getSelectionMessageId.js.map +1 -0
- package/dist/utils/smooth/useSmooth.js +1 -1
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/dist/utils/useToolArgsFieldStatus.js +5 -5
- package/dist/utils/useToolArgsFieldStatus.js.map +1 -1
- package/package.json +7 -7
- package/src/client/ExternalThread.ts +12 -0
- package/src/client/NoOpComposerClient.tsx +4 -0
- package/src/context/providers/ChainOfThoughtByIndicesProvider.tsx +3 -2
- package/src/context/react/utils/ensureBinding.ts +1 -1
- package/src/hooks/useMessageQuote.ts +27 -0
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +1 -4
- package/src/legacy-runtime/client/ComposerRuntimeClient.ts +2 -0
- package/src/legacy-runtime/hooks/AssistantContext.ts +1 -1
- package/src/legacy-runtime/hooks/AttachmentContext.ts +1 -1
- package/src/legacy-runtime/hooks/ComposerContext.ts +6 -6
- package/src/legacy-runtime/hooks/MessageContext.ts +5 -5
- package/src/legacy-runtime/hooks/MessagePartContext.ts +1 -1
- package/src/legacy-runtime/hooks/ThreadContext.ts +5 -5
- package/src/legacy-runtime/hooks/ThreadListItemContext.ts +1 -1
- package/src/legacy-runtime/runtime/ComposerRuntime.ts +22 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +5 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.tsx +41 -31
- package/src/legacy-runtime/runtime-cores/assistant-transport/useToolInvocations.ts +8 -8
- package/src/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.tsx +21 -2
- package/src/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.tsx +4 -0
- package/src/legacy-runtime/runtime-cores/external-store/createMessageConverter.tsx +2 -2
- package/src/legacy-runtime/runtime-cores/local/useLocalRuntime.tsx +1 -3
- package/src/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.tsx +6 -0
- package/src/primitives/actionBar/ActionBarCopy.tsx +7 -6
- package/src/primitives/actionBar/ActionBarEdit.tsx +1 -1
- package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +4 -3
- package/src/primitives/actionBar/ActionBarSpeak.tsx +4 -3
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +1 -1
- package/src/primitives/actionBar/useActionBarFloatStatus.tsx +5 -5
- package/src/primitives/attachment/AttachmentName.tsx +1 -1
- package/src/primitives/attachment/AttachmentThumb.tsx +2 -2
- package/src/primitives/branchPicker/BranchPickerCount.tsx +1 -1
- package/src/primitives/branchPicker/BranchPickerNext.tsx +3 -3
- package/src/primitives/branchPicker/BranchPickerNumber.tsx +1 -1
- package/src/primitives/branchPicker/BranchPickerPrevious.tsx +3 -3
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx +1 -3
- package/src/primitives/chainOfThought/ChainOfThoughtParts.tsx +19 -11
- package/src/primitives/composer/ComposerAddAttachment.tsx +1 -1
- package/src/primitives/composer/ComposerAttachments.tsx +1 -1
- package/src/primitives/composer/ComposerCancel.tsx +1 -1
- package/src/primitives/composer/ComposerDictate.tsx +4 -4
- package/src/primitives/composer/ComposerDictationTranscript.tsx +1 -3
- package/src/primitives/composer/ComposerIf.tsx +4 -4
- package/src/primitives/composer/ComposerInput.tsx +57 -17
- package/src/primitives/composer/ComposerQuote.tsx +109 -0
- package/src/primitives/composer/ComposerStopDictation.tsx +1 -1
- package/src/primitives/composer/index.ts +3 -0
- package/src/primitives/error/ErrorMessage.tsx +4 -4
- package/src/primitives/index.ts +2 -0
- package/src/primitives/message/MessageAttachments.tsx +4 -4
- package/src/primitives/message/MessageError.tsx +3 -3
- package/src/primitives/message/MessageIf.tsx +3 -3
- package/src/primitives/message/MessageParts.tsx +156 -148
- package/src/primitives/message/MessagePartsGrouped.tsx +5 -5
- package/src/primitives/message/MessageRoot.tsx +6 -5
- package/src/primitives/messagePart/MessagePartInProgress.tsx +1 -3
- package/src/primitives/messagePart/useMessagePartData.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartFile.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartImage.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartReasoning.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartSource.tsx +3 -3
- package/src/primitives/messagePart/useMessagePartText.tsx +4 -3
- package/src/primitives/selectionToolbar/SelectionToolbarQuote.tsx +62 -0
- package/src/primitives/selectionToolbar/SelectionToolbarRoot.tsx +131 -0
- package/src/primitives/selectionToolbar/index.ts +8 -0
- package/src/primitives/suggestion/SuggestionDescription.tsx +1 -1
- package/src/primitives/suggestion/SuggestionTitle.tsx +1 -1
- package/src/primitives/suggestion/SuggestionTrigger.tsx +6 -3
- package/src/primitives/thread/ThreadEmpty.tsx +1 -1
- package/src/primitives/thread/ThreadIf.tsx +8 -8
- package/src/primitives/thread/ThreadMessages.tsx +3 -3
- package/src/primitives/thread/ThreadSuggestion.tsx +5 -2
- package/src/primitives/thread/ThreadSuggestions.tsx +1 -1
- package/src/primitives/thread/ThreadViewportSlack.tsx +5 -5
- package/src/primitives/threadList/ThreadListItems.tsx +2 -2
- package/src/primitives/threadList/ThreadListNew.tsx +1 -1
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +1 -1
- package/src/primitives/threadListItem/ThreadListItemTitle.tsx +1 -1
- package/src/types/QuoteTypes.ts +4 -0
- package/src/types/index.ts +2 -0
- package/src/types/scopes/composer.ts +12 -0
- package/src/utils/getSelectionMessageId.ts +20 -0
- package/src/utils/smooth/useSmooth.tsx +1 -1
- package/src/utils/useToolArgsFieldStatus.tsx +5 -5
- package/src/primitives/chainOfThought/CHAIN_OF_THOUGHT.spec.md +0 -68
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import {
|
|
5
|
+
type ComponentPropsWithoutRef,
|
|
6
|
+
type ComponentRef,
|
|
7
|
+
createContext,
|
|
8
|
+
forwardRef,
|
|
9
|
+
useContext,
|
|
10
|
+
useEffect,
|
|
11
|
+
useState,
|
|
12
|
+
} from "react";
|
|
13
|
+
import { createPortal } from "react-dom";
|
|
14
|
+
import { getSelectionMessageId } from "../../utils/getSelectionMessageId";
|
|
15
|
+
|
|
16
|
+
type SelectionInfo = {
|
|
17
|
+
text: string;
|
|
18
|
+
messageId: string;
|
|
19
|
+
rect: DOMRect;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const SelectionToolbarContext = createContext<SelectionInfo | null>(null);
|
|
23
|
+
|
|
24
|
+
export const useSelectionToolbarInfo = () =>
|
|
25
|
+
useContext(SelectionToolbarContext);
|
|
26
|
+
|
|
27
|
+
export namespace SelectionToolbarPrimitiveRoot {
|
|
28
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
|
29
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A floating toolbar that appears when text is selected within a message.
|
|
34
|
+
*
|
|
35
|
+
* Listens for mouse and keyboard selection events, validates that the
|
|
36
|
+
* selection is within a single message, and renders a positioned portal
|
|
37
|
+
* near the selection. Prevents mousedown from clearing the selection.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <SelectionToolbarPrimitive.Root>
|
|
42
|
+
* <SelectionToolbarPrimitive.Quote>Quote</SelectionToolbarPrimitive.Quote>
|
|
43
|
+
* </SelectionToolbarPrimitive.Root>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export const SelectionToolbarPrimitiveRoot = forwardRef<
|
|
47
|
+
SelectionToolbarPrimitiveRoot.Element,
|
|
48
|
+
SelectionToolbarPrimitiveRoot.Props
|
|
49
|
+
>(({ onMouseDown, style, ...props }, forwardedRef) => {
|
|
50
|
+
const [info, setInfo] = useState<SelectionInfo | null>(null);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const checkSelection = () => {
|
|
54
|
+
requestAnimationFrame(() => {
|
|
55
|
+
const sel = window.getSelection();
|
|
56
|
+
if (!sel || sel.isCollapsed) {
|
|
57
|
+
setInfo(null);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const text = sel.toString().trim();
|
|
62
|
+
if (!text) {
|
|
63
|
+
setInfo(null);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const messageId = getSelectionMessageId(sel);
|
|
68
|
+
if (!messageId) {
|
|
69
|
+
setInfo(null);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const range = sel.getRangeAt(0);
|
|
74
|
+
const rect = range.getBoundingClientRect();
|
|
75
|
+
setInfo({ text, messageId, rect });
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const handleSelectionCollapse = () => {
|
|
80
|
+
const sel = window.getSelection();
|
|
81
|
+
if (!sel || sel.isCollapsed) {
|
|
82
|
+
setInfo(null);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleScroll = () => {
|
|
87
|
+
setInfo(null);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
document.addEventListener("mouseup", checkSelection);
|
|
91
|
+
document.addEventListener("keyup", checkSelection);
|
|
92
|
+
document.addEventListener("selectionchange", handleSelectionCollapse);
|
|
93
|
+
document.addEventListener("scroll", handleScroll, true);
|
|
94
|
+
|
|
95
|
+
return () => {
|
|
96
|
+
document.removeEventListener("mouseup", checkSelection);
|
|
97
|
+
document.removeEventListener("keyup", checkSelection);
|
|
98
|
+
document.removeEventListener("selectionchange", handleSelectionCollapse);
|
|
99
|
+
document.removeEventListener("scroll", handleScroll, true);
|
|
100
|
+
};
|
|
101
|
+
}, []);
|
|
102
|
+
|
|
103
|
+
if (!info) return null;
|
|
104
|
+
|
|
105
|
+
const positionStyle: React.CSSProperties = {
|
|
106
|
+
position: "fixed",
|
|
107
|
+
top: `${info.rect.top - 8}px`,
|
|
108
|
+
left: `${info.rect.left + info.rect.width / 2}px`,
|
|
109
|
+
transform: "translate(-50%, -100%)",
|
|
110
|
+
zIndex: 50,
|
|
111
|
+
...style,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return createPortal(
|
|
115
|
+
<SelectionToolbarContext.Provider value={info}>
|
|
116
|
+
<Primitive.div
|
|
117
|
+
{...props}
|
|
118
|
+
ref={forwardedRef}
|
|
119
|
+
style={positionStyle}
|
|
120
|
+
onMouseDown={(e) => {
|
|
121
|
+
// Prevent mousedown from clearing the text selection
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
onMouseDown?.(e);
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
</SelectionToolbarContext.Provider>,
|
|
127
|
+
document.body,
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
SelectionToolbarPrimitiveRoot.displayName = "SelectionToolbarPrimitive.Root";
|
|
@@ -21,7 +21,7 @@ export const SuggestionPrimitiveDescription = forwardRef<
|
|
|
21
21
|
SuggestionPrimitiveDescription.Element,
|
|
22
22
|
SuggestionPrimitiveDescription.Props
|
|
23
23
|
>((props, ref) => {
|
|
24
|
-
const label = useAuiState((
|
|
24
|
+
const label = useAuiState((s) => s.suggestion.label);
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<Primitive.span {...props} ref={ref}>
|
|
@@ -21,7 +21,7 @@ export const SuggestionPrimitiveTitle = forwardRef<
|
|
|
21
21
|
SuggestionPrimitiveTitle.Element,
|
|
22
22
|
SuggestionPrimitiveTitle.Props
|
|
23
23
|
>((props, ref) => {
|
|
24
|
-
const title = useAuiState((
|
|
24
|
+
const title = useAuiState((s) => s.suggestion.title);
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<Primitive.span {...props} ref={ref}>
|
|
@@ -28,8 +28,8 @@ const useSuggestionTrigger = ({
|
|
|
28
28
|
clearComposer?: boolean | undefined;
|
|
29
29
|
}) => {
|
|
30
30
|
const aui = useAui();
|
|
31
|
-
const disabled = useAuiState((
|
|
32
|
-
const prompt = useAuiState((
|
|
31
|
+
const disabled = useAuiState((s) => s.thread.isDisabled);
|
|
32
|
+
const prompt = useAuiState((s) => s.suggestion.prompt);
|
|
33
33
|
|
|
34
34
|
const resolvedSend = send ?? false;
|
|
35
35
|
|
|
@@ -37,7 +37,10 @@ const useSuggestionTrigger = ({
|
|
|
37
37
|
const isRunning = aui.thread().getState().isRunning;
|
|
38
38
|
|
|
39
39
|
if (resolvedSend && !isRunning) {
|
|
40
|
-
aui.thread().append(
|
|
40
|
+
aui.thread().append({
|
|
41
|
+
content: [{ type: "text", text: prompt }],
|
|
42
|
+
runConfig: aui.composer().getState().runConfig,
|
|
43
|
+
});
|
|
41
44
|
if (clearComposer) {
|
|
42
45
|
aui.composer().setText("");
|
|
43
46
|
}
|
|
@@ -11,7 +11,7 @@ export const ThreadPrimitiveEmpty: FC<ThreadPrimitiveEmpty.Props> = ({
|
|
|
11
11
|
children,
|
|
12
12
|
}) => {
|
|
13
13
|
const empty = useAuiState(
|
|
14
|
-
(
|
|
14
|
+
(s) => s.thread.messages.length === 0 && !s.thread.isLoading,
|
|
15
15
|
);
|
|
16
16
|
return empty ? children : null;
|
|
17
17
|
};
|
|
@@ -13,14 +13,14 @@ type ThreadIfFilters = {
|
|
|
13
13
|
type UseThreadIfProps = RequireAtLeastOne<ThreadIfFilters>;
|
|
14
14
|
|
|
15
15
|
const useThreadIf = (props: UseThreadIfProps) => {
|
|
16
|
-
return useAuiState((
|
|
17
|
-
if (props.empty === true && !thread.isEmpty) return false;
|
|
18
|
-
if (props.empty === false && thread.isEmpty) return false;
|
|
19
|
-
|
|
20
|
-
if (props.running === true && !thread.isRunning) return false;
|
|
21
|
-
if (props.running === false && thread.isRunning) return false;
|
|
22
|
-
if (props.disabled === true && !thread.isDisabled) return false;
|
|
23
|
-
if (props.disabled === false && thread.isDisabled) return false;
|
|
16
|
+
return useAuiState((s) => {
|
|
17
|
+
if (props.empty === true && !s.thread.isEmpty) return false;
|
|
18
|
+
if (props.empty === false && s.thread.isEmpty) return false;
|
|
19
|
+
|
|
20
|
+
if (props.running === true && !s.thread.isRunning) return false;
|
|
21
|
+
if (props.running === false && s.thread.isRunning) return false;
|
|
22
|
+
if (props.disabled === true && !s.thread.isDisabled) return false;
|
|
23
|
+
if (props.disabled === false && s.thread.isDisabled) return false;
|
|
24
24
|
|
|
25
25
|
return true;
|
|
26
26
|
});
|
|
@@ -129,8 +129,8 @@ type ThreadMessageComponentProps = {
|
|
|
129
129
|
const ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({
|
|
130
130
|
components,
|
|
131
131
|
}) => {
|
|
132
|
-
const role = useAuiState((
|
|
133
|
-
const isEditing = useAuiState((
|
|
132
|
+
const role = useAuiState((s) => s.message.role);
|
|
133
|
+
const isEditing = useAuiState((s) => s.message.composer.isEditing);
|
|
134
134
|
const Component = getComponent(components, role, isEditing);
|
|
135
135
|
|
|
136
136
|
return <Component />;
|
|
@@ -196,7 +196,7 @@ ThreadPrimitiveMessageByIndex.displayName = "ThreadPrimitive.MessageByIndex";
|
|
|
196
196
|
export const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({
|
|
197
197
|
components,
|
|
198
198
|
}) => {
|
|
199
|
-
const messagesLength = useAuiState((
|
|
199
|
+
const messagesLength = useAuiState((s) => s.thread.messages.length);
|
|
200
200
|
|
|
201
201
|
const messageElements = useMemo(() => {
|
|
202
202
|
if (messagesLength === 0) return null;
|
|
@@ -40,7 +40,7 @@ const useThreadSuggestion = ({
|
|
|
40
40
|
method?: "replace";
|
|
41
41
|
}) => {
|
|
42
42
|
const aui = useAui();
|
|
43
|
-
const disabled = useAuiState((
|
|
43
|
+
const disabled = useAuiState((s) => s.thread.isDisabled);
|
|
44
44
|
|
|
45
45
|
// ========== Deprecation Mapping ==========
|
|
46
46
|
const resolvedSend = send ?? autoSend ?? false;
|
|
@@ -50,7 +50,10 @@ const useThreadSuggestion = ({
|
|
|
50
50
|
const isRunning = aui.thread().getState().isRunning;
|
|
51
51
|
|
|
52
52
|
if (resolvedSend && !isRunning) {
|
|
53
|
-
aui.thread().append(
|
|
53
|
+
aui.thread().append({
|
|
54
|
+
content: [{ type: "text", text: prompt }],
|
|
55
|
+
runConfig: aui.composer().getState().runConfig,
|
|
56
|
+
});
|
|
54
57
|
if (clearComposer) {
|
|
55
58
|
aui.composer().setText("");
|
|
56
59
|
}
|
|
@@ -84,7 +84,7 @@ export const ThreadPrimitiveSuggestionsImpl: FC<
|
|
|
84
84
|
ThreadPrimitiveSuggestions.Props
|
|
85
85
|
> = ({ components }) => {
|
|
86
86
|
const suggestionsLength = useAuiState(
|
|
87
|
-
(
|
|
87
|
+
(s) => s.suggestions.suggestions.length,
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
const suggestionElements = useMemo(() => {
|
|
@@ -59,11 +59,11 @@ export const ThreadPrimitiveViewportSlack: FC<ThreadViewportSlackProps> = ({
|
|
|
59
59
|
}) => {
|
|
60
60
|
const shouldApplySlack = useAuiState(
|
|
61
61
|
// only add slack to the last assistant message following a user message (valid turn)
|
|
62
|
-
(
|
|
63
|
-
message.isLast &&
|
|
64
|
-
message.role === "assistant" &&
|
|
65
|
-
message.index >= 1 &&
|
|
66
|
-
thread.messages.at(message.index - 1)?.role === "user",
|
|
62
|
+
(s) =>
|
|
63
|
+
s.message.isLast &&
|
|
64
|
+
s.message.role === "assistant" &&
|
|
65
|
+
s.message.index >= 1 &&
|
|
66
|
+
s.thread.messages.at(s.message.index - 1)?.role === "user",
|
|
67
67
|
);
|
|
68
68
|
const threadViewportStore = useThreadViewportStore({ optional: true });
|
|
69
69
|
const isNested = useContext(SlackNestingContext);
|
|
@@ -60,8 +60,8 @@ export const ThreadListPrimitiveItems: FC<ThreadListPrimitiveItems.Props> = ({
|
|
|
60
60
|
archived = false,
|
|
61
61
|
components,
|
|
62
62
|
}) => {
|
|
63
|
-
const contentLength = useAuiState((
|
|
64
|
-
archived ? threads.archivedThreadIds.length : threads.threadIds.length,
|
|
63
|
+
const contentLength = useAuiState((s) =>
|
|
64
|
+
archived ? s.threads.archivedThreadIds.length : s.threads.threadIds.length,
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
const listElements = useMemo(() => {
|
|
@@ -19,7 +19,7 @@ export const ThreadListPrimitiveNew = forwardRef<
|
|
|
19
19
|
ThreadListPrimitiveNew.Props
|
|
20
20
|
>(({ onClick, disabled, ...props }, forwardedRef) => {
|
|
21
21
|
const isMain = useAuiState(
|
|
22
|
-
(
|
|
22
|
+
(s) => s.threads.newThreadId === s.threads.mainThreadId,
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
const aui = useAui();
|
|
@@ -16,7 +16,7 @@ export const ThreadListItemPrimitiveRoot = forwardRef<
|
|
|
16
16
|
ThreadListItemPrimitiveRoot.Props
|
|
17
17
|
>((props, ref) => {
|
|
18
18
|
const isMain = useAuiState(
|
|
19
|
-
(
|
|
19
|
+
(s) => s.threads.mainThreadId === s.threadListItem.id,
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
return (
|
|
@@ -12,7 +12,7 @@ export namespace ThreadListItemPrimitiveTitle {
|
|
|
12
12
|
export const ThreadListItemPrimitiveTitle: FC<
|
|
13
13
|
ThreadListItemPrimitiveTitle.Props
|
|
14
14
|
> = ({ fallback }) => {
|
|
15
|
-
const title = useAuiState((
|
|
15
|
+
const title = useAuiState((s) => s.threadListItem.title);
|
|
16
16
|
return <>{title || fallback}</>;
|
|
17
17
|
};
|
|
18
18
|
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Attachment } from "../AttachmentTypes";
|
|
2
2
|
import type { MessageRole, RunConfig } from "../AssistantTypes";
|
|
3
|
+
import type { QuoteInfo } from "../QuoteTypes";
|
|
3
4
|
import type { ComposerRuntime } from "../../legacy-runtime/runtime";
|
|
4
5
|
import type { AttachmentMethods } from "./attachment";
|
|
5
6
|
import { DictationState } from "../../legacy-runtime/runtime-cores";
|
|
@@ -20,6 +21,12 @@ export type ComposerState = {
|
|
|
20
21
|
* Undefined when dictation is not active.
|
|
21
22
|
*/
|
|
22
23
|
readonly dictation: DictationState | undefined;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The currently quoted text, if any.
|
|
27
|
+
* Undefined when no quote is set.
|
|
28
|
+
*/
|
|
29
|
+
readonly quote: QuoteInfo | undefined;
|
|
23
30
|
};
|
|
24
31
|
|
|
25
32
|
export type ComposerMethods = {
|
|
@@ -46,6 +53,11 @@ export type ComposerMethods = {
|
|
|
46
53
|
*/
|
|
47
54
|
stopDictation(): void;
|
|
48
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Set a quote for the next message. Pass undefined to clear.
|
|
58
|
+
*/
|
|
59
|
+
setQuote(quote: QuoteInfo | undefined): void;
|
|
60
|
+
|
|
49
61
|
/** @internal */
|
|
50
62
|
__internal_getRuntime?(): ComposerRuntime;
|
|
51
63
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const findMessageId = (node: Node | null): string | null => {
|
|
2
|
+
let el = node instanceof HTMLElement ? node : (node?.parentElement ?? null);
|
|
3
|
+
while (el) {
|
|
4
|
+
const id = el.getAttribute("data-message-id");
|
|
5
|
+
if (id) return id;
|
|
6
|
+
el = el.parentElement;
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const getSelectionMessageId = (selection: Selection): string | null => {
|
|
12
|
+
const { anchorNode, focusNode } = selection;
|
|
13
|
+
if (!anchorNode || !focusNode) return null;
|
|
14
|
+
|
|
15
|
+
const anchorId = findMessageId(anchorNode);
|
|
16
|
+
const focusId = findMessageId(focusNode);
|
|
17
|
+
|
|
18
|
+
if (!anchorId || anchorId !== focusId) return null;
|
|
19
|
+
return anchorId;
|
|
20
|
+
};
|
|
@@ -75,7 +75,7 @@ export const useSmooth = (
|
|
|
75
75
|
smooth: boolean = false,
|
|
76
76
|
): MessagePartState & (TextMessagePart | ReasoningMessagePart) => {
|
|
77
77
|
const { text } = state;
|
|
78
|
-
const id = useAuiState((
|
|
78
|
+
const id = useAuiState((s) => s.message.id);
|
|
79
79
|
|
|
80
80
|
const idRef = useRef(id);
|
|
81
81
|
const [displayedText, setDisplayedText] = useState(text);
|
|
@@ -4,15 +4,15 @@ import { useAuiState } from "@assistant-ui/store";
|
|
|
4
4
|
const COMPLETE_STATUS = { type: "complete" };
|
|
5
5
|
|
|
6
6
|
export const useToolArgsFieldStatus = (fieldPath: (string | number)[]) => {
|
|
7
|
-
return useAuiState((
|
|
8
|
-
if (part.type !== "tool-call")
|
|
7
|
+
return useAuiState((s) => {
|
|
8
|
+
if (s.part.type !== "tool-call")
|
|
9
9
|
throw new Error(
|
|
10
10
|
"useToolArgsFieldStatus can only be used inside tool-call message parts",
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
const state = getPartialJsonObjectFieldState(part.args, fieldPath);
|
|
14
|
-
if (state === "complete" || part.status?.type === "requires-action")
|
|
13
|
+
const state = getPartialJsonObjectFieldState(s.part.args, fieldPath);
|
|
14
|
+
if (state === "complete" || s.part.status?.type === "requires-action")
|
|
15
15
|
return COMPLETE_STATUS;
|
|
16
|
-
return part.status;
|
|
16
|
+
return s.part.status;
|
|
17
17
|
});
|
|
18
18
|
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
ChainOfThought Primitive
|
|
2
|
-
|
|
3
|
-
Overview
|
|
4
|
-
|
|
5
|
-
- Groups consecutive reasoning and tool-call message parts into a collapsible "chain of thought" section.
|
|
6
|
-
- Built on the part-scope mechanism shared with `MessagePrimitiveParts`, using `Derived` for part resolution.
|
|
7
|
-
- Each part within the chain of thought gets its own part scope via `ChainOfThoughtPartByIndexProvider`.
|
|
8
|
-
- Rendering is delegated to the shared `MessagePartComponent`, supporting the same component configuration as `MessagePrimitiveParts`.
|
|
9
|
-
|
|
10
|
-
Architecture
|
|
11
|
-
|
|
12
|
-
ChainOfThoughtState
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
type ChainOfThoughtState = {
|
|
16
|
-
readonly startIndex: number; // index of the first CoT part in the parent message
|
|
17
|
-
readonly parts: readonly ChainOfThoughtPart[];
|
|
18
|
-
readonly collapsed: boolean;
|
|
19
|
-
readonly status: MessagePartStatus | ToolCallMessagePartStatus;
|
|
20
|
-
};
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
ChainOfThoughtMethods
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
type ChainOfThoughtMethods = {
|
|
27
|
-
getState(): ChainOfThoughtState;
|
|
28
|
-
setCollapsed(collapsed: boolean): void;
|
|
29
|
-
part(selector: { index: number }): PartMethods;
|
|
30
|
-
};
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
- `part({ index })` delegates to the parent message's `part()` at offset `startIndex + index`.
|
|
34
|
-
|
|
35
|
-
ChainOfThoughtClient
|
|
36
|
-
|
|
37
|
-
- Resource params: `{ startIndex, parts, getMessagePart }`.
|
|
38
|
-
- `getMessagePart` is a callback that resolves to the parent message's `part()` method.
|
|
39
|
-
- The `part` method implementation: `({ index }) => getMessagePart({ index: startIndex + index })`.
|
|
40
|
-
|
|
41
|
-
Providers
|
|
42
|
-
|
|
43
|
-
ChainOfThoughtByIndicesProvider
|
|
44
|
-
|
|
45
|
-
- Wraps a range of message parts (startIndex..endIndex) into a chain of thought scope.
|
|
46
|
-
- Reads parts from the parent message state, passes `startIndex` and `getMessagePart` to `ChainOfThoughtClient`.
|
|
47
|
-
- Used internally by `MessagePrimitiveParts` when `ChainOfThought` component is configured.
|
|
48
|
-
|
|
49
|
-
ChainOfThoughtPartByIndexProvider
|
|
50
|
-
|
|
51
|
-
- Follows the same pattern as `PartByIndexProvider`.
|
|
52
|
-
- Reads `startIndex` from chain of thought state.
|
|
53
|
-
- Creates a `Derived` part scope: `source: "message"`, `query: { type: "index", index: startIndex + index }`.
|
|
54
|
-
- Delegates `get` to `aui.chainOfThought().part({ index })`.
|
|
55
|
-
|
|
56
|
-
Rendering (ChainOfThoughtPrimitiveParts)
|
|
57
|
-
|
|
58
|
-
- Accepts `components` prop with the same type as `MessagePrimitiveParts.Props["components"]`.
|
|
59
|
-
- Reads `collapsed` and `parts.length` from chain of thought state.
|
|
60
|
-
- When collapsed, renders nothing.
|
|
61
|
-
- When expanded, renders each part via `ChainOfThoughtPartByIndexProvider` + `MessagePartComponent`.
|
|
62
|
-
- `MessagePartComponent` is the shared rendering component exported from `MessageParts.tsx`.
|
|
63
|
-
|
|
64
|
-
Integration with MessagePrimitiveParts
|
|
65
|
-
|
|
66
|
-
- When `components.ChainOfThought` is set, `MessagePrimitiveParts` groups consecutive tool-call and reasoning parts into `chainOfThoughtGroup` ranges.
|
|
67
|
-
- Each group is wrapped in `ChainOfThoughtByIndicesProvider`, which sets up the chain of thought scope.
|
|
68
|
-
- The user's `ChainOfThought` component renders inside that scope and can use `ChainOfThoughtPrimitive.Parts` to render individual parts through the part-scope mechanism.
|