@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
|
@@ -21,17 +21,13 @@ import { flushResourcesSync } from "@assistant-ui/tap";
|
|
|
21
21
|
|
|
22
22
|
export namespace ComposerPrimitiveInput {
|
|
23
23
|
export type Element = HTMLTextAreaElement;
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
type BaseProps = {
|
|
25
26
|
/**
|
|
26
27
|
* Whether to render as a child component using Slot.
|
|
27
28
|
* When true, the component will merge its props with its child.
|
|
28
29
|
*/
|
|
29
30
|
asChild?: boolean | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Whether to submit the message when Enter is pressed (without Shift).
|
|
32
|
-
* @default true
|
|
33
|
-
*/
|
|
34
|
-
submitOnEnter?: boolean | undefined;
|
|
35
31
|
/**
|
|
36
32
|
* Whether to cancel message composition when Escape is pressed.
|
|
37
33
|
* @default true
|
|
@@ -58,6 +54,34 @@ export namespace ComposerPrimitiveInput {
|
|
|
58
54
|
*/
|
|
59
55
|
addAttachmentOnPaste?: boolean | undefined;
|
|
60
56
|
};
|
|
57
|
+
|
|
58
|
+
type SubmitModeProps =
|
|
59
|
+
| {
|
|
60
|
+
/**
|
|
61
|
+
* Controls how the Enter key submits messages.
|
|
62
|
+
* - "enter": Plain Enter submits (Shift+Enter for newline)
|
|
63
|
+
* - "ctrlEnter": Ctrl/Cmd+Enter submits (plain Enter for newline)
|
|
64
|
+
* - "none": Keyboard submission disabled
|
|
65
|
+
* @default "enter"
|
|
66
|
+
*/
|
|
67
|
+
submitMode?: "enter" | "ctrlEnter" | "none" | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Use `submitMode` instead
|
|
70
|
+
* @ignore
|
|
71
|
+
*/
|
|
72
|
+
submitOnEnter?: never;
|
|
73
|
+
}
|
|
74
|
+
| {
|
|
75
|
+
submitMode?: never;
|
|
76
|
+
/**
|
|
77
|
+
* Whether to submit the message when Enter is pressed (without Shift).
|
|
78
|
+
* @default true
|
|
79
|
+
* @deprecated Use `submitMode` instead. Will be removed in a future version.
|
|
80
|
+
*/
|
|
81
|
+
submitOnEnter?: boolean | undefined;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type Props = TextareaAutosizeProps & BaseProps & SubmitModeProps;
|
|
61
85
|
}
|
|
62
86
|
|
|
63
87
|
/**
|
|
@@ -69,10 +93,16 @@ export namespace ComposerPrimitiveInput {
|
|
|
69
93
|
*
|
|
70
94
|
* @example
|
|
71
95
|
* ```tsx
|
|
96
|
+
* // Ctrl/Cmd+Enter to submit (plain Enter inserts newline)
|
|
97
|
+
* <ComposerPrimitive.Input
|
|
98
|
+
* placeholder="Type your message..."
|
|
99
|
+
* submitMode="ctrlEnter"
|
|
100
|
+
* />
|
|
101
|
+
*
|
|
102
|
+
* // Old API (deprecated, still supported)
|
|
72
103
|
* <ComposerPrimitive.Input
|
|
73
104
|
* placeholder="Type your message..."
|
|
74
105
|
* submitOnEnter={true}
|
|
75
|
-
* addAttachmentOnPaste={true}
|
|
76
106
|
* />
|
|
77
107
|
* ```
|
|
78
108
|
*/
|
|
@@ -88,7 +118,8 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
88
118
|
onChange,
|
|
89
119
|
onKeyDown,
|
|
90
120
|
onPaste,
|
|
91
|
-
submitOnEnter
|
|
121
|
+
submitOnEnter,
|
|
122
|
+
submitMode,
|
|
92
123
|
cancelOnEscape = true,
|
|
93
124
|
unstable_focusOnRunStart = true,
|
|
94
125
|
unstable_focusOnScrollToBottom = true,
|
|
@@ -100,17 +131,19 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
100
131
|
) => {
|
|
101
132
|
const aui = useAui();
|
|
102
133
|
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
134
|
+
const effectiveSubmitMode =
|
|
135
|
+
submitMode ?? (submitOnEnter === false ? "none" : "enter");
|
|
136
|
+
|
|
137
|
+
const value = useAuiState((s) => {
|
|
138
|
+
if (!s.composer.isEditing) return "";
|
|
139
|
+
return s.composer.text;
|
|
106
140
|
});
|
|
107
141
|
|
|
108
142
|
const Component = asChild ? Slot : TextareaAutosize;
|
|
109
143
|
|
|
110
144
|
const isDisabled =
|
|
111
145
|
useAuiState(
|
|
112
|
-
(
|
|
113
|
-
thread.isDisabled || composer.dictation?.inputDisabled,
|
|
146
|
+
(s) => s.thread.isDisabled || s.composer.dictation?.inputDisabled,
|
|
114
147
|
) || disabledProp;
|
|
115
148
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
116
149
|
const ref = useComposedRefs(forwardedRef, textareaRef);
|
|
@@ -129,17 +162,24 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
129
162
|
});
|
|
130
163
|
|
|
131
164
|
const handleKeyPress = (e: KeyboardEvent) => {
|
|
132
|
-
if (isDisabled
|
|
165
|
+
if (isDisabled) return;
|
|
133
166
|
|
|
134
167
|
// ignore IME composition events
|
|
135
168
|
if (e.nativeEvent.isComposing) return;
|
|
136
169
|
|
|
137
|
-
if (e.key === "Enter" && e.shiftKey
|
|
170
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
138
171
|
const isRunning = aui.thread().getState().isRunning;
|
|
172
|
+
if (isRunning) return;
|
|
139
173
|
|
|
140
|
-
|
|
141
|
-
|
|
174
|
+
let shouldSubmit = false;
|
|
175
|
+
if (effectiveSubmitMode === "ctrlEnter") {
|
|
176
|
+
shouldSubmit = e.ctrlKey || e.metaKey;
|
|
177
|
+
} else if (effectiveSubmitMode === "enter") {
|
|
178
|
+
shouldSubmit = true;
|
|
179
|
+
}
|
|
142
180
|
|
|
181
|
+
if (shouldSubmit) {
|
|
182
|
+
e.preventDefault();
|
|
143
183
|
textareaRef.current?.closest("form")?.requestSubmit();
|
|
144
184
|
}
|
|
145
185
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import {
|
|
5
|
+
type ComponentRef,
|
|
6
|
+
type ComponentPropsWithoutRef,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useCallback,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
11
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
12
|
+
|
|
13
|
+
// ---- Root ----
|
|
14
|
+
|
|
15
|
+
export namespace ComposerPrimitiveQuote {
|
|
16
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
|
17
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Renders a container for the quoted text preview in the composer.
|
|
22
|
+
* Only renders when a quote is set.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <ComposerPrimitive.Quote>
|
|
27
|
+
* <ComposerPrimitive.QuoteText />
|
|
28
|
+
* <ComposerPrimitive.QuoteDismiss>×</ComposerPrimitive.QuoteDismiss>
|
|
29
|
+
* </ComposerPrimitive.Quote>
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const ComposerPrimitiveQuote = forwardRef<
|
|
33
|
+
ComposerPrimitiveQuote.Element,
|
|
34
|
+
ComposerPrimitiveQuote.Props
|
|
35
|
+
>((props, forwardedRef) => {
|
|
36
|
+
const quote = useAuiState((s) => s.composer.quote);
|
|
37
|
+
if (!quote) return null;
|
|
38
|
+
|
|
39
|
+
return <Primitive.div {...props} ref={forwardedRef} />;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
ComposerPrimitiveQuote.displayName = "ComposerPrimitive.Quote";
|
|
43
|
+
|
|
44
|
+
// ---- QuoteText ----
|
|
45
|
+
|
|
46
|
+
export namespace ComposerPrimitiveQuoteText {
|
|
47
|
+
export type Element = ComponentRef<typeof Primitive.span>;
|
|
48
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Renders the quoted text content.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <ComposerPrimitive.QuoteText />
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export const ComposerPrimitiveQuoteText = forwardRef<
|
|
60
|
+
ComposerPrimitiveQuoteText.Element,
|
|
61
|
+
ComposerPrimitiveQuoteText.Props
|
|
62
|
+
>(({ children, ...props }, forwardedRef) => {
|
|
63
|
+
const text = useAuiState((s) => s.composer.quote?.text);
|
|
64
|
+
if (!text) return null;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Primitive.span {...props} ref={forwardedRef}>
|
|
68
|
+
{children ?? text}
|
|
69
|
+
</Primitive.span>
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
ComposerPrimitiveQuoteText.displayName = "ComposerPrimitive.QuoteText";
|
|
74
|
+
|
|
75
|
+
// ---- QuoteDismiss ----
|
|
76
|
+
|
|
77
|
+
export namespace ComposerPrimitiveQuoteDismiss {
|
|
78
|
+
export type Element = ComponentRef<typeof Primitive.button>;
|
|
79
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A button that clears the current quote from the composer.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* <ComposerPrimitive.QuoteDismiss>×</ComposerPrimitive.QuoteDismiss>
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export const ComposerPrimitiveQuoteDismiss = forwardRef<
|
|
91
|
+
ComposerPrimitiveQuoteDismiss.Element,
|
|
92
|
+
ComposerPrimitiveQuoteDismiss.Props
|
|
93
|
+
>(({ onClick, ...props }, forwardedRef) => {
|
|
94
|
+
const aui = useAui();
|
|
95
|
+
const handleDismiss = useCallback(() => {
|
|
96
|
+
aui.composer().setQuote(undefined);
|
|
97
|
+
}, [aui]);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Primitive.button
|
|
101
|
+
type="button"
|
|
102
|
+
{...props}
|
|
103
|
+
ref={forwardedRef}
|
|
104
|
+
onClick={composeEventHandlers(onClick, handleDismiss)}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
ComposerPrimitiveQuoteDismiss.displayName = "ComposerPrimitive.QuoteDismiss";
|
|
@@ -11,7 +11,7 @@ import { useAuiState } from "@assistant-ui/store";
|
|
|
11
11
|
|
|
12
12
|
const useComposerStopDictation = () => {
|
|
13
13
|
const aui = useAui();
|
|
14
|
-
const isDictating = useAuiState((
|
|
14
|
+
const isDictating = useAuiState((s) => s.composer.dictation != null);
|
|
15
15
|
|
|
16
16
|
const callback = useCallback(() => {
|
|
17
17
|
aui.composer().stopDictation();
|
|
@@ -10,3 +10,6 @@ export { ComposerPrimitiveDictate as Dictate } from "./ComposerDictate";
|
|
|
10
10
|
export { ComposerPrimitiveStopDictation as StopDictation } from "./ComposerStopDictation";
|
|
11
11
|
export { ComposerPrimitiveDictationTranscript as DictationTranscript } from "./ComposerDictationTranscript";
|
|
12
12
|
export { ComposerPrimitiveIf as If } from "./ComposerIf";
|
|
13
|
+
export { ComposerPrimitiveQuote as Quote } from "./ComposerQuote";
|
|
14
|
+
export { ComposerPrimitiveQuoteText as QuoteText } from "./ComposerQuote";
|
|
15
|
+
export { ComposerPrimitiveQuoteDismiss as QuoteDismiss } from "./ComposerQuote";
|
|
@@ -13,10 +13,10 @@ export const ErrorPrimitiveMessage = forwardRef<
|
|
|
13
13
|
ErrorPrimitiveMessage.Element,
|
|
14
14
|
ErrorPrimitiveMessage.Props
|
|
15
15
|
>(({ children, ...props }, forwardRef) => {
|
|
16
|
-
const error = useAuiState((
|
|
17
|
-
return message.status?.type === "incomplete" &&
|
|
18
|
-
message.status.reason === "error"
|
|
19
|
-
? message.status.error
|
|
16
|
+
const error = useAuiState((s) => {
|
|
17
|
+
return s.message.status?.type === "incomplete" &&
|
|
18
|
+
s.message.status.reason === "error"
|
|
19
|
+
? s.message.status.error
|
|
20
20
|
: undefined;
|
|
21
21
|
});
|
|
22
22
|
|
package/src/primitives/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * as SuggestionPrimitive from "./suggestion";
|
|
|
13
13
|
export * as ThreadListPrimitive from "./threadList";
|
|
14
14
|
export * as ThreadListItemPrimitive from "./threadListItem";
|
|
15
15
|
export * as ThreadListItemMorePrimitive from "./threadListItemMore";
|
|
16
|
+
export * as SelectionToolbarPrimitive from "./selectionToolbar";
|
|
16
17
|
|
|
17
18
|
export { useMessagePartText } from "./messagePart/useMessagePartText";
|
|
18
19
|
export { useMessagePartReasoning } from "./messagePart/useMessagePartReasoning";
|
|
@@ -22,3 +23,4 @@ export { useMessagePartImage } from "./messagePart/useMessagePartImage";
|
|
|
22
23
|
export { useMessagePartData } from "./messagePart/useMessagePartData";
|
|
23
24
|
export { useThreadViewportAutoScroll } from "./thread/useThreadViewportAutoScroll";
|
|
24
25
|
export { useScrollLock } from "./reasoning";
|
|
26
|
+
export { useMessageQuote } from "../hooks/useMessageQuote";
|
|
@@ -39,7 +39,7 @@ const getComponent = (
|
|
|
39
39
|
const AttachmentComponent: FC<{
|
|
40
40
|
components: MessagePrimitiveAttachments.Props["components"];
|
|
41
41
|
}> = ({ components }) => {
|
|
42
|
-
const attachment = useAuiState((
|
|
42
|
+
const attachment = useAuiState((s) => s.attachment);
|
|
43
43
|
if (!attachment) return null;
|
|
44
44
|
|
|
45
45
|
const Component = getComponent(components, attachment as CompleteAttachment);
|
|
@@ -94,9 +94,9 @@ MessagePrimitiveAttachmentByIndex.displayName =
|
|
|
94
94
|
export const MessagePrimitiveAttachments: FC<
|
|
95
95
|
MessagePrimitiveAttachments.Props
|
|
96
96
|
> = ({ components }) => {
|
|
97
|
-
const attachmentsCount = useAuiState((
|
|
98
|
-
if (message.role !== "user") return 0;
|
|
99
|
-
return message.attachments.length;
|
|
97
|
+
const attachmentsCount = useAuiState((s) => {
|
|
98
|
+
if (s.message.role !== "user") return 0;
|
|
99
|
+
return s.message.attachments.length;
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
const attachmentElements = useMemo(() => {
|
|
@@ -5,9 +5,9 @@ import { useAuiState } from "@assistant-ui/store";
|
|
|
5
5
|
|
|
6
6
|
export const MessagePrimitiveError: FC<PropsWithChildren> = ({ children }) => {
|
|
7
7
|
const hasError = useAuiState(
|
|
8
|
-
(
|
|
9
|
-
message.status?.type === "incomplete" &&
|
|
10
|
-
message.status.reason === "error",
|
|
8
|
+
(s) =>
|
|
9
|
+
s.message.status?.type === "incomplete" &&
|
|
10
|
+
s.message.status.reason === "error",
|
|
11
11
|
);
|
|
12
12
|
return hasError ? children : null;
|
|
13
13
|
};
|
|
@@ -20,7 +20,7 @@ type MessageIfFilters = {
|
|
|
20
20
|
type UseMessageIfProps = RequireAtLeastOne<MessageIfFilters>;
|
|
21
21
|
|
|
22
22
|
const useMessageIf = (props: UseMessageIfProps) => {
|
|
23
|
-
return useAuiState((
|
|
23
|
+
return useAuiState((s) => {
|
|
24
24
|
const {
|
|
25
25
|
role,
|
|
26
26
|
attachments,
|
|
@@ -30,7 +30,7 @@ const useMessageIf = (props: UseMessageIfProps) => {
|
|
|
30
30
|
speech,
|
|
31
31
|
isCopied,
|
|
32
32
|
isHovering,
|
|
33
|
-
} = message;
|
|
33
|
+
} = s.message;
|
|
34
34
|
|
|
35
35
|
if (props.hasBranches === true && branchCount < 2) return false;
|
|
36
36
|
|
|
@@ -64,7 +64,7 @@ const useMessageIf = (props: UseMessageIfProps) => {
|
|
|
64
64
|
|
|
65
65
|
if (
|
|
66
66
|
props.submittedFeedback !== undefined &&
|
|
67
|
-
(message.metadata.submittedFeedback?.type ?? null) !==
|
|
67
|
+
(s.message.metadata.submittedFeedback?.type ?? null) !==
|
|
68
68
|
props.submittedFeedback
|
|
69
69
|
)
|
|
70
70
|
return false;
|