@assistant-ui/react 0.14.27 → 0.14.29
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 +11 -1
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +758 -513
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/context/react/utils/createContextStoreHook.d.ts.map +1 -1
- package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.d.ts +12 -1
- package/dist/legacy-runtime/cloud/auiV0.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.js +2 -1
- package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js +7 -6
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js +30 -15
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.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 +8 -4
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js +1 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +7 -1
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js +3 -3
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts +7 -6
- package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +10 -11
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreContent.js.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts.map +1 -1
- package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js.map +1 -1
- package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
- package/dist/primitives/assistantModal/popoverRenderPrimitives.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +1 -0
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +8 -2
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +1 -3
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerDictate.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +6 -4
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js.map +1 -1
- package/dist/primitives/composer/ComposerRoot.d.ts +5 -0
- package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +86 -40
- package/dist/primitives/composer/ComposerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +1 -0
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js +1 -0
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopover.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverBack.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverCategories.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverItems.js.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/TriggerPopoverRootContext.js.map +1 -1
- package/dist/primitives/composer/trigger/detectTrigger.d.ts +1 -1
- package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
- package/dist/primitives/dropdownMenuRenderPrimitives.d.ts.map +1 -1
- package/dist/primitives/error/ErrorMessage.d.ts.map +1 -1
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/error/ErrorRoot.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartImage.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/MessagePartText.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.d.ts +3 -2
- package/dist/primitives/messagePart/useMessagePartData.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartData.js +3 -2
- package/dist/primitives/messagePart/useMessagePartData.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.d.ts +5 -4
- package/dist/primitives/messagePart/useMessagePartFile.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartFile.js +11 -3
- package/dist/primitives/messagePart/useMessagePartFile.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.d.ts +5 -4
- package/dist/primitives/messagePart/useMessagePartImage.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartImage.js +10 -3
- package/dist/primitives/messagePart/useMessagePartImage.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts +5 -4
- package/dist/primitives/messagePart/useMessagePartReasoning.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartReasoning.js +10 -3
- package/dist/primitives/messagePart/useMessagePartReasoning.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.d.ts +6 -4
- package/dist/primitives/messagePart/useMessagePartSource.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartSource.js +12 -3
- package/dist/primitives/messagePart/useMessagePartSource.js.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.d.ts +6 -5
- package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -1
- package/dist/primitives/messagePart/useMessagePartText.js +10 -3
- package/dist/primitives/messagePart/useMessagePartText.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.d.ts.map +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js +1 -0
- package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.d.ts.map +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js +1 -0
- package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemText.d.ts.map +1 -1
- package/dist/primitives/queueItem/QueueItemText.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.d.ts.map +1 -1
- package/dist/primitives/suggestion/SuggestionDescription.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTitle.d.ts.map +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 +1 -0
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js +1 -0
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +53 -19
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/createReserveObservers.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.d.ts +4 -0
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js +14 -1
- package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts +13 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts.map +1 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.js +14 -1
- package/dist/primitives/thread/topAnchor/topAnchorTurn.js.map +1 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js +2 -1
- package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
- package/dist/primitives/threadList/ThreadListLoadMore.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListRoot.js.map +1 -1
- package/dist/primitives/threadListFocusGroup.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts.map +1 -1
- package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts.map +1 -1
- package/dist/tests/setup.d.ts +1 -1
- package/dist/utils/Primitive.d.ts.map +1 -1
- package/dist/utils/Primitive.js.map +1 -1
- package/dist/utils/createActionButton.d.ts.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +1 -0
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useSizeHandle.js +1 -0
- package/dist/utils/hooks/useSizeHandle.js.map +1 -1
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +2 -2
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/package.json +20 -20
- package/src/client/ExternalThread.ts +341 -53
- package/src/legacy-runtime/cloud/auiV0.ts +14 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts +4 -1
- package/src/legacy-runtime/runtime-cores/assistant-transport/runManager.ts +37 -10
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-delivery.test.tsx +79 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-parentid.test.tsx +97 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-scheduling.test.ts +113 -2
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransport.spec.md +10 -2
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.test.tsx +189 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +20 -4
- package/src/model-context/makeAssistantVisible.test.tsx +146 -0
- package/src/model-context/makeAssistantVisible.tsx +18 -1
- package/src/primitives/actionBar/useActionBarFloatStatus.ts +7 -5
- package/src/primitives/composer/ComposerAddAttachment.test.tsx +108 -0
- package/src/primitives/composer/ComposerAddAttachment.ts +10 -4
- package/src/primitives/composer/ComposerAttachmentDropzone.test.tsx +3 -2
- package/src/primitives/composer/ComposerAttachmentDropzone.tsx +3 -2
- package/src/primitives/composer/ComposerInput.test.tsx +98 -1
- package/src/primitives/composer/ComposerInput.tsx +10 -8
- package/src/primitives/composer/ComposerRoot.test.tsx +226 -5
- package/src/primitives/composer/ComposerRoot.tsx +50 -1
- package/src/primitives/messagePart/useMessagePartData.ts +3 -2
- package/src/primitives/messagePart/useMessagePartFile.ts +19 -7
- package/src/primitives/messagePart/useMessagePartImage.ts +18 -7
- package/src/primitives/messagePart/useMessagePartReasoning.ts +15 -6
- package/src/primitives/messagePart/useMessagePartSource.ts +20 -7
- package/src/primitives/messagePart/useMessagePartText.ts +15 -5
- package/src/primitives/thread/ThreadViewport.tsx +15 -0
- package/src/primitives/thread/topAnchor/mountTopAnchorReserve.test.ts +243 -0
- package/src/primitives/thread/topAnchor/mountTopAnchorReserve.ts +28 -7
- package/src/primitives/thread/topAnchor/topAnchorTurn.test.ts +69 -0
- package/src/primitives/thread/topAnchor/topAnchorTurn.ts +29 -0
- package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +86 -1
- package/src/primitives/thread/useThreadViewportAutoScroll.ts +6 -1
- package/src/tests/DataRenderers.test.tsx +212 -0
- package/src/tests/RemoteThreadListRuntime.adapterProvider.test.tsx +1 -11
- package/src/tests/external-thread-attachments.test.tsx +372 -0
- package/src/tests/external-thread-parity.test.tsx +232 -0
- package/src/tests/generative-ui.test.tsx +1 -46
- package/src/tests/messagePartSwitchRace.test.tsx +172 -0
- package/src/tests/messagePartTypeMismatch.test.tsx +146 -0
- package/src/tests/threadMessageById.test.tsx +0 -7
- package/src/utils/smooth/useSmooth.ts +7 -4
- package/src/tests/BaseComposerRuntimeCore.test.ts +0 -612
- package/src/tests/BaseSubscribable.test.ts +0 -54
- package/src/tests/DataRenderers.test.ts +0 -355
- package/src/tests/ExternalStoreThreadRuntimeCore.test.ts +0 -685
- package/src/tests/LocalThreadRuntimeCore.test.ts +0 -324
- package/src/tests/auiV0Encode.test.ts +0 -188
- package/src/tests/external-message-converter.test.ts +0 -346
- package/src/tests/shouldContinue.test.ts +0 -122
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ReasoningMessagePart, TextMessagePart } from "@assistant-ui/core";
|
|
1
|
+
import { MessagePartStatus, ReasoningMessagePart, TextMessagePart } from "@assistant-ui/core";
|
|
2
2
|
//#region src/primitives/messagePart/useMessagePartText.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
5
|
-
* Return `null` for optional rendering
|
|
6
|
-
*
|
|
5
|
+
* Return `null` for optional rendering. Do not throw inside the selector:
|
|
6
|
+
* selectors run inside `useSyncExternalStore`'s `getSnapshot`, so a transient
|
|
7
|
+
* part mismatch during thread switches can unmount the React root.
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* ```tsx
|
|
@@ -16,9 +17,9 @@ import { ReasoningMessagePart, TextMessagePart } from "@assistant-ui/core";
|
|
|
16
17
|
* See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.
|
|
17
18
|
*/
|
|
18
19
|
declare const useMessagePartText: () => (TextMessagePart & {
|
|
19
|
-
readonly status:
|
|
20
|
+
readonly status: MessagePartStatus | import("@assistant-ui/core").ToolCallMessagePartStatus;
|
|
20
21
|
}) | (ReasoningMessagePart & {
|
|
21
|
-
readonly status:
|
|
22
|
+
readonly status: MessagePartStatus | import("@assistant-ui/core").ToolCallMessagePartStatus;
|
|
22
23
|
});
|
|
23
24
|
//#endregion
|
|
24
25
|
export { useMessagePartText };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartText.d.ts","names":[],"sources":["../../../src/primitives/messagePart/useMessagePartText.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useMessagePartText.d.ts","names":[],"sources":["../../../src/primitives/messagePart/useMessagePartText.ts"],"mappings":";;;;;;;;;;;;;;;;;;cAkCa,2BAAkB"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useAuiState } from "@assistant-ui/store";
|
|
3
3
|
//#region src/primitives/messagePart/useMessagePartText.ts
|
|
4
|
+
const COMPLETE_STATUS = Object.freeze({ type: "complete" });
|
|
5
|
+
const EMPTY_TEXT_PART = Object.freeze({
|
|
6
|
+
type: "text",
|
|
7
|
+
text: "",
|
|
8
|
+
status: COMPLETE_STATUS
|
|
9
|
+
});
|
|
4
10
|
/**
|
|
5
11
|
* @deprecated Use {@link useAuiState} to select and narrow `s.part`.
|
|
6
|
-
* Return `null` for optional rendering
|
|
7
|
-
*
|
|
12
|
+
* Return `null` for optional rendering. Do not throw inside the selector:
|
|
13
|
+
* selectors run inside `useSyncExternalStore`'s `getSnapshot`, so a transient
|
|
14
|
+
* part mismatch during thread switches can unmount the React root.
|
|
8
15
|
*
|
|
9
16
|
* @example
|
|
10
17
|
* ```tsx
|
|
@@ -20,7 +27,7 @@ const useMessagePartText = () => {
|
|
|
20
27
|
return useAuiState(_temp);
|
|
21
28
|
};
|
|
22
29
|
function _temp(s) {
|
|
23
|
-
if (s.part.type !== "text" && s.part.type !== "reasoning")
|
|
30
|
+
if (s.part.type !== "text" && s.part.type !== "reasoning") return EMPTY_TEXT_PART;
|
|
24
31
|
return s.part;
|
|
25
32
|
}
|
|
26
33
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMessagePartText.js","names":["TextMessagePart","ReasoningMessagePart","MessagePartState","useAuiState","
|
|
1
|
+
{"version":3,"file":"useMessagePartText.js","names":["TextMessagePart","ReasoningMessagePart","MessagePartState","MessagePartStatus","useAuiState","COMPLETE_STATUS","Object","freeze","type","EMPTY_TEXT_PART","text","status","useMessagePartText","_temp","s","part"],"sources":["../../../src/primitives/messagePart/useMessagePartText.ts"],"sourcesContent":["\"use client\";\n\nimport type {\n TextMessagePart,\n ReasoningMessagePart,\n MessagePartState,\n MessagePartStatus,\n} from \"@assistant-ui/core\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\n\nconst EMPTY_TEXT_PART: MessagePartState & TextMessagePart = Object.freeze({\n type: \"text\",\n text: \"\",\n status: COMPLETE_STATUS,\n});\n\n/**\n * @deprecated Use {@link useAuiState} to select and narrow `s.part`.\n * Return `null` for optional rendering. Do not throw inside the selector:\n * selectors run inside `useSyncExternalStore`'s `getSnapshot`, so a transient\n * part mismatch during thread switches can unmount the React root.\n *\n * @example\n * ```tsx\n * const text = useAuiState((s) => {\n * if (s.part.type !== \"text\" && s.part.type !== \"reasoning\") return null;\n * return s.part;\n * });\n * ```\n *\n * See the {@link https://assistant-ui.com/docs/migrations/v0-12 migration guide}.\n */\nexport const useMessagePartText = () => {\n // Runs inside useSyncExternalStore's getSnapshot, where a throw tears down\n // the React root; the module-level frozen sentinel keeps snapshots stable.\n const text = useAuiState((s) => {\n if (s.part.type !== \"text\" && s.part.type !== \"reasoning\")\n return EMPTY_TEXT_PART;\n\n return s.part as MessagePartState &\n (TextMessagePart | ReasoningMessagePart);\n });\n\n return text;\n};\n"],"mappings":";;;AAUA,MAAMK,kBAAqCC,OAAOC,OAAO,EAAEC,MAAM,WAAW,CAAC;AAE7E,MAAMC,kBAAsDH,OAAOC,OAAO;CACxEC,MAAM;CACNE,MAAM;CACNC,QAAQN;AACV,CAAC;;;;;;;;;;;;;;;;;AAkBD,MAAaO,2BAAqB;CAS7B,OANUR,YAAYS,KAQlBH;AAAI;AAXqB,SAAAG,MAAAC,GAAA;CAI9B,IAAIA,EAACC,KAAKP,SAAU,UAAUM,EAACC,KAAKP,SAAU,aAAW,OAChDC;CAAgB,OAElBK,EAACC;AACkC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemRemove.d.ts","names":[],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"mappings":";;cAUM;kBAUW;OACH,UAAU;OACV,QAAQ,yBAAyB;;;;;;;;;;cAWlC,0CAAwB,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA"}
|
|
1
|
+
{"version":3,"file":"QueueItemRemove.d.ts","names":[],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"mappings":";;cAUM;kBAUW;OACH,UAAU;OACV,QAAQ,yBAAyB;;;;;;;;;;cAWlC,0CAAwB,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA;;;;oBAGpC,cAAA,6CAAA,cAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
3
|
import { useAui } from "@assistant-ui/store";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/queueItem/QueueItemRemove.ts
|
|
6
7
|
const useQueueItemRemove = () => {
|
|
7
8
|
const $ = c(2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemRemove.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemRemove","$","aui","t0","queueItem","remove","callback","QueueItemPrimitiveRemove","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemRemove = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem().remove();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveRemove {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemRemove>;\n}\n\n/**\n * A button that removes this item from the queue.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Remove>×</QueueItemPrimitive.Remove>\n * ```\n */\nexport const QueueItemPrimitiveRemove = createActionButton(\n \"QueueItemPrimitive.Remove\",\n useQueueItemRemove,\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueueItemRemove.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemRemove","$","aui","t0","queueItem","remove","callback","QueueItemPrimitiveRemove","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemRemove = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem().remove();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveRemove {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemRemove>;\n}\n\n/**\n * A button that removes this item from the queue.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Remove>×</QueueItemPrimitive.Remove>\n * ```\n */\nexport const QueueItemPrimitiveRemove = createActionButton(\n \"QueueItemPrimitive.Remove\",\n useQueueItemRemove,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,2BAAqB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACzB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,KAAA;EAEQC,WAAA;GAC3BD,IAAGE,UAAW,CAAC,CAAAC,OAAQ;EAAC;EACzBJ,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,2BAA2BV,mBACtC,6BACAG,kBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemSteer.d.ts","names":[],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"mappings":";;cAUM;kBAUW;OACH,UAAU;OACV,QAAQ,yBAAyB;;;;;;;;;;cAWlC,yCAAuB,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA"}
|
|
1
|
+
{"version":3,"file":"QueueItemSteer.d.ts","names":[],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"mappings":";;cAUM;kBAUW;OACH,UAAU;OACV,QAAQ,yBAAyB;;;;;;;;;;cAWlC,yCAAuB,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA;;;;oBAGnC,cAAA,6CAAA,cAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
3
|
import { useAui } from "@assistant-ui/store";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/queueItem/QueueItemSteer.ts
|
|
6
7
|
const useQueueItemSteer = () => {
|
|
7
8
|
const $ = c(2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemSteer.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemSteer","$","aui","t0","queueItem","steer","callback","QueueItemPrimitiveSteer","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemSteer = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem().steer();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveSteer {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemSteer>;\n}\n\n/**\n * A button that steers the current run to process this queue item immediately.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * ```\n */\nexport const QueueItemPrimitiveSteer = createActionButton(\n \"QueueItemPrimitive.Steer\",\n useQueueItemSteer,\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueueItemSteer.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemSteer","$","aui","t0","queueItem","steer","callback","QueueItemPrimitiveSteer","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemSteer = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem().steer();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveSteer {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemSteer>;\n}\n\n/**\n * A button that steers the current run to process this queue item immediately.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * ```\n */\nexport const QueueItemPrimitiveSteer = createActionButton(\n \"QueueItemPrimitive.Steer\",\n useQueueItemSteer,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,0BAAoB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACxB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,KAAA;EAEQC,WAAA;GAC3BD,IAAGE,UAAW,CAAC,CAAAC,MAAO;EAAC;EACxBJ,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,0BAA0BV,mBACrC,4BACAG,iBACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemText.d.ts","names":[],"sources":["../../../src/primitives/queueItem/QueueItemText.tsx"],"mappings":";;;kBAUiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;cAWnD,wCAAsB,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"QueueItemText.d.ts","names":[],"sources":["../../../src/primitives/queueItem/QueueItemText.tsx"],"mappings":";;;kBAUiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;cAWnD,wCAAsB,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,eAAA;;;;oBAWjC,cAAA,2CAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemText.js","names":["c","_c","Primitive","ComponentRef","ComponentPropsWithoutRef","forwardRef","useAuiState","QueueItemPrimitiveText","Element","span","Props","props","ref","$","prompt","_temp","t0","children","t1","displayName","s","queueItem"],"sources":["../../../src/primitives/queueItem/QueueItemText.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n type ComponentPropsWithoutRef,\n forwardRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace QueueItemPrimitiveText {\n export type Element = ComponentRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the prompt text of a queue item.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Text />\n * ```\n */\nexport const QueueItemPrimitiveText = forwardRef<\n QueueItemPrimitiveText.Element,\n QueueItemPrimitiveText.Props\n>((props, ref) => {\n const prompt = useAuiState((s) => s.queueItem.prompt);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? prompt}\n </Primitive.span>\n );\n});\n\nQueueItemPrimitiveText.displayName = \"QueueItemPrimitive.Text\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,yBAAyBF,YAGpCM,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,SAAeR,YAAYS,KAAyB;CAI/C,MAAAC,KAAAL,MAAKM,YAALH;CAAwB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD3BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;
|
|
1
|
+
{"version":3,"file":"QueueItemText.js","names":["c","_c","Primitive","ComponentRef","ComponentPropsWithoutRef","forwardRef","useAuiState","QueueItemPrimitiveText","Element","span","Props","props","ref","$","prompt","_temp","t0","children","t1","displayName","s","queueItem"],"sources":["../../../src/primitives/queueItem/QueueItemText.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n type ComponentPropsWithoutRef,\n forwardRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace QueueItemPrimitiveText {\n export type Element = ComponentRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the prompt text of a queue item.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Text />\n * ```\n */\nexport const QueueItemPrimitiveText = forwardRef<\n QueueItemPrimitiveText.Element,\n QueueItemPrimitiveText.Props\n>((props, ref) => {\n const prompt = useAuiState((s) => s.queueItem.prompt);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? prompt}\n </Primitive.span>\n );\n});\n\nQueueItemPrimitiveText.displayName = \"QueueItemPrimitive.Text\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,yBAAyBF,YAGpCM,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,SAAeR,YAAYS,KAAyB;CAI/C,MAAAC,KAAAL,MAAKM,YAALH;CAAwB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD3BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,uBAAuBY,cAAc;AAVnC,SAAAJ,MAAAK,GAAA;CAAA,OACkCA,EAACC,UAAUP;AAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbarQuote.d.ts","names":[],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarQuote.tsx"],"mappings":";;;kBAaiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;;;;;;;cAiBnD,gDAA8B,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA"}
|
|
1
|
+
{"version":3,"file":"SelectionToolbarQuote.d.ts","names":[],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarQuote.tsx"],"mappings":";;;kBAaiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;;;;;;;cAiBnD,gDAA8B,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA;;;;oBA2BzC,cAAA,6CAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbarRoot.d.ts","names":[],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarRoot.tsx"],"mappings":";;;KAeK;EACH;EACA;EACA,MAAM;;cAKK,+BAAuB;kBAGnB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;;;;;;;cAiBnD,+CAA6B,0BAAA,KAAA,qBAAA,gBAAA,kCAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"SelectionToolbarRoot.d.ts","names":[],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarRoot.tsx"],"mappings":";;;KAeK;EACH;EACA;EACA,MAAM;;cAKK,+BAAuB;kBAGnB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;;;;;;;cAiBnD,+CAA6B,0BAAA,KAAA,qBAAA,gBAAA,kCAAA,eAAA;;;;oBAmFxC,cAAA,0CAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbarRoot.js","names":["c","_c","Primitive","ComponentPropsWithoutRef","ComponentRef","createContext","forwardRef","useContext","useEffect","useState","createPortal","getSelectionMessageId","SelectionInfo","text","messageId","rect","DOMRect","SelectionToolbarContext","useSelectionToolbarInfo","SelectionToolbarPrimitiveRoot","Element","div","Props","t0","forwardedRef","$","onMouseDown","props","style","info","setInfo","t1","t2","Symbol","for","checkSelection","requestAnimationFrame","sel","window","getSelection","isCollapsed","toString","trim","range","getRangeAt","getBoundingClientRect","handleSelectionCollapse","sel_0","handleScroll","document","addEventListener","removeEventListener","t3","top","t4","left","width","t5","position","transform","zIndex","positionStyle","t6","e","preventDefault","t7","t8","body","displayName"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { getSelectionMessageId } from \"../../utils/getSelectionMessageId\";\n\ntype SelectionInfo = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nconst SelectionToolbarContext = createContext<SelectionInfo | null>(null);\n\nexport const useSelectionToolbarInfo = () =>\n useContext(SelectionToolbarContext);\n\nexport namespace SelectionToolbarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * A floating toolbar that appears when text is selected within a message.\n *\n * Listens for mouse and keyboard selection events, validates that the\n * selection is within a single message, and renders a positioned portal\n * near the selection. Prevents mousedown from clearing the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Root>\n * <SelectionToolbarPrimitive.Quote>Quote</SelectionToolbarPrimitive.Quote>\n * </SelectionToolbarPrimitive.Root>\n * ```\n */\nexport const SelectionToolbarPrimitiveRoot = forwardRef<\n SelectionToolbarPrimitiveRoot.Element,\n SelectionToolbarPrimitiveRoot.Props\n>(({ onMouseDown, style, ...props }, forwardedRef) => {\n const [info, setInfo] = useState<SelectionInfo | null>(null);\n\n useEffect(() => {\n const checkSelection = () => {\n requestAnimationFrame(() => {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n setInfo(null);\n return;\n }\n\n const text = sel.toString().trim();\n if (!text) {\n setInfo(null);\n return;\n }\n\n const messageId = getSelectionMessageId(sel);\n if (!messageId) {\n setInfo(null);\n return;\n }\n\n const range = sel.getRangeAt(0);\n const rect = range.getBoundingClientRect();\n setInfo({ text, messageId, rect });\n });\n };\n\n const handleSelectionCollapse = () => {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n setInfo(null);\n }\n };\n\n const handleScroll = () => {\n setInfo(null);\n };\n\n document.addEventListener(\"mouseup\", checkSelection);\n document.addEventListener(\"keyup\", checkSelection);\n document.addEventListener(\"selectionchange\", handleSelectionCollapse);\n document.addEventListener(\"scroll\", handleScroll, true);\n\n return () => {\n document.removeEventListener(\"mouseup\", checkSelection);\n document.removeEventListener(\"keyup\", checkSelection);\n document.removeEventListener(\"selectionchange\", handleSelectionCollapse);\n document.removeEventListener(\"scroll\", handleScroll, true);\n };\n }, []);\n\n if (!info) return null;\n\n const positionStyle: React.CSSProperties = {\n position: \"fixed\",\n top: `${info.rect.top - 8}px`,\n left: `${info.rect.left + info.rect.width / 2}px`,\n transform: \"translate(-50%, -100%)\",\n zIndex: 50,\n ...style,\n };\n\n return createPortal(\n <SelectionToolbarContext.Provider value={info}>\n <Primitive.div\n {...props}\n ref={forwardedRef}\n style={positionStyle}\n onMouseDown={(e) => {\n // Prevent mousedown from clearing the text selection\n e.preventDefault();\n onMouseDown?.(e);\n }}\n />\n </SelectionToolbarContext.Provider>,\n document.body,\n );\n});\n\nSelectionToolbarPrimitiveRoot.displayName = \"SelectionToolbarPrimitive.Root\";\n"],"mappings":";;;;;;;;AAqBA,MAAMiB,0BAA0BZ,cAAoC,IAA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A,QAAAoC,iBAAApC,EAAA,QAAAE,SAAAF,EAAA,QAAAqC,IAAA;EARHG,KAAA,oBAAA,UAAA,KAAA;GAAA,GACMtC;GACCH,KAAAA;GACEqC,OAAAA;GACM,aAAAC;EAIZ,CAAA;EACDrC,EAAA,MAAAD;EAAAC,EAAA,MAAAoC;EAAApC,EAAA,MAAAE;EAAAF,EAAA,MAAAqC;EAAArC,EAAA,MAAAwC;CAAA,OAAAA,KAAAxC,EAAA;CAAA,IAAAyC;CAAA,IAAAzC,EAAA,QAAAI,QAAAJ,EAAA,QAAAwC,IAAA;EAXCC,KAAAxD,aACL,oBAAA,wBAAA,UAAA;GAAyCmB,OAAAA;
|
|
1
|
+
{"version":3,"file":"SelectionToolbarRoot.js","names":["c","_c","Primitive","ComponentPropsWithoutRef","ComponentRef","createContext","forwardRef","useContext","useEffect","useState","createPortal","getSelectionMessageId","SelectionInfo","text","messageId","rect","DOMRect","SelectionToolbarContext","useSelectionToolbarInfo","SelectionToolbarPrimitiveRoot","Element","div","Props","t0","forwardedRef","$","onMouseDown","props","style","info","setInfo","t1","t2","Symbol","for","checkSelection","requestAnimationFrame","sel","window","getSelection","isCollapsed","toString","trim","range","getRangeAt","getBoundingClientRect","handleSelectionCollapse","sel_0","handleScroll","document","addEventListener","removeEventListener","t3","top","t4","left","width","t5","position","transform","zIndex","positionStyle","t6","e","preventDefault","t7","t8","body","displayName"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { getSelectionMessageId } from \"../../utils/getSelectionMessageId\";\n\ntype SelectionInfo = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nconst SelectionToolbarContext = createContext<SelectionInfo | null>(null);\n\nexport const useSelectionToolbarInfo = () =>\n useContext(SelectionToolbarContext);\n\nexport namespace SelectionToolbarPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\n/**\n * A floating toolbar that appears when text is selected within a message.\n *\n * Listens for mouse and keyboard selection events, validates that the\n * selection is within a single message, and renders a positioned portal\n * near the selection. Prevents mousedown from clearing the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Root>\n * <SelectionToolbarPrimitive.Quote>Quote</SelectionToolbarPrimitive.Quote>\n * </SelectionToolbarPrimitive.Root>\n * ```\n */\nexport const SelectionToolbarPrimitiveRoot = forwardRef<\n SelectionToolbarPrimitiveRoot.Element,\n SelectionToolbarPrimitiveRoot.Props\n>(({ onMouseDown, style, ...props }, forwardedRef) => {\n const [info, setInfo] = useState<SelectionInfo | null>(null);\n\n useEffect(() => {\n const checkSelection = () => {\n requestAnimationFrame(() => {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n setInfo(null);\n return;\n }\n\n const text = sel.toString().trim();\n if (!text) {\n setInfo(null);\n return;\n }\n\n const messageId = getSelectionMessageId(sel);\n if (!messageId) {\n setInfo(null);\n return;\n }\n\n const range = sel.getRangeAt(0);\n const rect = range.getBoundingClientRect();\n setInfo({ text, messageId, rect });\n });\n };\n\n const handleSelectionCollapse = () => {\n const sel = window.getSelection();\n if (!sel || sel.isCollapsed) {\n setInfo(null);\n }\n };\n\n const handleScroll = () => {\n setInfo(null);\n };\n\n document.addEventListener(\"mouseup\", checkSelection);\n document.addEventListener(\"keyup\", checkSelection);\n document.addEventListener(\"selectionchange\", handleSelectionCollapse);\n document.addEventListener(\"scroll\", handleScroll, true);\n\n return () => {\n document.removeEventListener(\"mouseup\", checkSelection);\n document.removeEventListener(\"keyup\", checkSelection);\n document.removeEventListener(\"selectionchange\", handleSelectionCollapse);\n document.removeEventListener(\"scroll\", handleScroll, true);\n };\n }, []);\n\n if (!info) return null;\n\n const positionStyle: React.CSSProperties = {\n position: \"fixed\",\n top: `${info.rect.top - 8}px`,\n left: `${info.rect.left + info.rect.width / 2}px`,\n transform: \"translate(-50%, -100%)\",\n zIndex: 50,\n ...style,\n };\n\n return createPortal(\n <SelectionToolbarContext.Provider value={info}>\n <Primitive.div\n {...props}\n ref={forwardedRef}\n style={positionStyle}\n onMouseDown={(e) => {\n // Prevent mousedown from clearing the text selection\n e.preventDefault();\n onMouseDown?.(e);\n }}\n />\n </SelectionToolbarContext.Provider>,\n document.body,\n );\n});\n\nSelectionToolbarPrimitiveRoot.displayName = \"SelectionToolbarPrimitive.Root\";\n"],"mappings":";;;;;;;;AAqBA,MAAMiB,0BAA0BZ,cAAoC,IAAI;AAExE,MAAaa,gCAA0B;CAAA,OACrCX,WAAWU,uBAAuB;AAAC;;;;;;;;;;;;;;;AAqBrC,MAAaE,gCAAgCb,YAG3CiB,IAAAC,iBAAA;CAAA,MAAAC,IAAAxB,EAAA,EAAA;CAAA,IAAAyB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAG,aAAAE,UAAAD,SAAAJ;EAAgCE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,cAAAD,EAAA;EAAAE,QAAAF,EAAA;EAAAG,QAAAH,EAAA;CAAA;CACjC,MAAA,CAAAI,MAAAC,WAAwBrB,SAA+B,IAAI;CAAE,IAAAsB;CAAA,IAAAC;CAAA,IAAAP,EAAA,OAAAQ,OAAAC,IAAA,2BAAA,GAAA;EAEnDH,WAAA;GACR,MAAAI,uBAAuB;IACrBC,4BAAsB;KACpB,MAAAC,MAAYC,OAAMC,aAAc;KAChC,IAAI,CAACF,OAAOA,IAAGG,aAAY;MACzBV,QAAQ,IAAI;MAAC;KAAA;KAIf,MAAAjB,OAAawB,IAAGI,SAAU,CAAC,CAAAC,KAAM;KACjC,IAAI,CAAC7B,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;;;;;cAWnD,gDAA8B,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"SuggestionDescription.d.ts","names":[],"sources":["../../../src/primitives/suggestion/SuggestionDescription.tsx"],"mappings":";;;kBAUiB;OACH,UAAU,kBAAkB,UAAU;OACtC,QAAQ,gCAAgC,UAAU;;;;;;;;;;cAWnD,gDAA8B,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,eAAA;;;;oBAWzC,cAAA,2CAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionDescription.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveDescription","Element","span","Props","props","ref","$","label","_temp","t0","children","t1","displayName","s","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionDescription.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveDescription {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the description/label of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Description />\n * ```\n */\nexport const SuggestionPrimitiveDescription = forwardRef<\n SuggestionPrimitiveDescription.Element,\n SuggestionPrimitiveDescription.Props\n>((props, ref) => {\n const label = useAuiState((s) => s.suggestion.label);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? label}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveDescription.displayName = \"SuggestionPrimitive.Description\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,iCAAiCH,YAG5CO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;
|
|
1
|
+
{"version":3,"file":"SuggestionDescription.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveDescription","Element","span","Props","props","ref","$","label","_temp","t0","children","t1","displayName","s","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionDescription.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveDescription {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the description/label of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Description />\n * ```\n */\nexport const SuggestionPrimitiveDescription = forwardRef<\n SuggestionPrimitiveDescription.Element,\n SuggestionPrimitiveDescription.Props\n>((props, ref) => {\n const label = useAuiState((s) => s.suggestion.label);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? label}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveDescription.displayName = \"SuggestionPrimitive.Description\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,iCAAiCH,YAG5CO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,+BAA+BY,cAAc;AAV3C,SAAAJ,MAAAK,GAAA;CAAA,OACiCA,EAACC,WAAWP;AAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionTitle.d.ts","names":[],"sources":["../../../src/primitives/suggestion/SuggestionTitle.tsx"],"mappings":";;;kBAUiB;OACH,UAAU,kBAAkB,UAAU;OACtC,QAAQ,gCAAgC,UAAU;;;;;;;;;;cAWnD,0CAAwB,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"SuggestionTitle.d.ts","names":[],"sources":["../../../src/primitives/suggestion/SuggestionTitle.tsx"],"mappings":";;;kBAUiB;OACH,UAAU,kBAAkB,UAAU;OACtC,QAAQ,gCAAgC,UAAU;;;;;;;;;;cAWnD,0CAAwB,0BAAA,KAAA,qBAAA,gBAAA,mCAAA,eAAA;;;;oBAWnC,cAAA,2CAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionTitle.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveTitle","Element","span","Props","props","ref","$","title","_temp","t0","children","t1","displayName","s","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionTitle.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveTitle {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the title of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Title />\n * ```\n */\nexport const SuggestionPrimitiveTitle = forwardRef<\n SuggestionPrimitiveTitle.Element,\n SuggestionPrimitiveTitle.Props\n>((props, ref) => {\n const title = useAuiState((s) => s.suggestion.title);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? title}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveTitle.displayName = \"SuggestionPrimitive.Title\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,2BAA2BH,YAGtCO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;
|
|
1
|
+
{"version":3,"file":"SuggestionTitle.js","names":["c","_c","Primitive","ElementRef","forwardRef","ComponentPropsWithoutRef","useAuiState","SuggestionPrimitiveTitle","Element","span","Props","props","ref","$","title","_temp","t0","children","t1","displayName","s","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionTitle.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ElementRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport namespace SuggestionPrimitiveTitle {\n export type Element = ElementRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\n/**\n * Renders the title of the suggestion.\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Title />\n * ```\n */\nexport const SuggestionPrimitiveTitle = forwardRef<\n SuggestionPrimitiveTitle.Element,\n SuggestionPrimitiveTitle.Props\n>((props, ref) => {\n const title = useAuiState((s) => s.suggestion.title);\n\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? title}\n </Primitive.span>\n );\n});\n\nSuggestionPrimitiveTitle.displayName = \"SuggestionPrimitive.Title\";\n"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAaO,2BAA2BH,YAGtCO,OAAAC,QAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CACA,MAAAa,QAAcR,YAAYS,KAAyB;CAI9C,MAAAC,KAAAL,MAAKM,YAALH;CAAuB,IAAAI;CAAA,IAAAL,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EAD1BE,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBP;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFjBK;AAEiB,CAEpB;AAEDX,yBAAyBY,cAAc;AAVrC,SAAAJ,MAAAK,GAAA;CAAA,OACiCA,EAACC,WAAWP;AAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionTrigger.d.ts","names":[],"sources":["../../../src/primitives/suggestion/SuggestionTrigger.ts"],"mappings":";;cAUM,yBAAwB,MAAA;;;;;EAQ5B;;;;;;;;EASA;;kBAmCe;OACH,UAAU;OACV,QAAQ,yBAAyB;;;;;;;;;;;;cAalC,4CAA0B,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA"}
|
|
1
|
+
{"version":3,"file":"SuggestionTrigger.d.ts","names":[],"sources":["../../../src/primitives/suggestion/SuggestionTrigger.ts"],"mappings":";;cAUM,yBAAwB,MAAA;;;;;EAQ5B;;;;;;;;EASA;;kBAmCe;OACH,UAAU;OACV,QAAQ,yBAAyB;;;;;;;;;;;;cAalC,4CAA0B,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA;;;;;;;;;EA3D9B;;;;;;;;EASS;oBAsDjB,cAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
3
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/suggestion/SuggestionTrigger.ts
|
|
6
7
|
const useSuggestionTrigger = (t0) => {
|
|
7
8
|
const $ = c(5);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionTrigger.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useAuiState","useAui","useSuggestionTrigger","t0","$","send","clearComposer","t1","undefined","aui","disabled","_temp","prompt","_temp2","resolvedSend","t2","isRunning","thread","getState","append","content","type","text","runConfig","composer","setText","currentText","trim","callback","SuggestionPrimitiveTrigger","Element","Props","s","isDisabled","s_0","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionTrigger.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\n\nconst useSuggestionTrigger = ({\n send,\n clearComposer = true,\n}: {\n /**\n * When true, automatically sends the message.\n * When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`.\n */\n send?: boolean | undefined;\n\n /**\n * Whether to clear the composer after sending.\n * When send is set to false, determines if composer text is replaced with suggestion (true, default),\n * or if it's appended to the composer text (false).\n *\n * @default true\n */\n clearComposer?: boolean | undefined;\n}) => {\n const aui = useAui();\n const disabled = useAuiState((s) => s.thread.isDisabled);\n const prompt = useAuiState((s) => s.suggestion.prompt);\n\n const resolvedSend = send ?? false;\n\n const callback = useCallback(() => {\n const isRunning = aui.thread().getState().isRunning;\n\n if (resolvedSend && !isRunning) {\n aui.thread().append({\n content: [{ type: \"text\", text: prompt }],\n runConfig: aui.composer().getState().runConfig,\n });\n if (clearComposer) {\n aui.composer().setText(\"\");\n }\n } else {\n if (clearComposer) {\n aui.composer().setText(prompt);\n } else {\n const currentText = aui.composer().getState().text;\n aui\n .composer()\n .setText(currentText.trim() ? `${currentText} ${prompt}` : prompt);\n }\n }\n }, [aui, resolvedSend, clearComposer, prompt]);\n\n if (disabled) return null;\n return callback;\n};\n\nexport namespace SuggestionPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useSuggestionTrigger>;\n}\n\n/**\n * A button that triggers the suggestion action (send or insert into composer).\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Trigger send>\n * Click me\n * </SuggestionPrimitive.Trigger>\n * ```\n */\nexport const SuggestionPrimitiveTrigger = createActionButton(\n \"SuggestionPrimitive.Trigger\",\n useSuggestionTrigger,\n [\"send\", \"clearComposer\"],\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SuggestionTrigger.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useAuiState","useAui","useSuggestionTrigger","t0","$","send","clearComposer","t1","undefined","aui","disabled","_temp","prompt","_temp2","resolvedSend","t2","isRunning","thread","getState","append","content","type","text","runConfig","composer","setText","currentText","trim","callback","SuggestionPrimitiveTrigger","Element","Props","s","isDisabled","s_0","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionTrigger.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\n\nconst useSuggestionTrigger = ({\n send,\n clearComposer = true,\n}: {\n /**\n * When true, automatically sends the message.\n * When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`.\n */\n send?: boolean | undefined;\n\n /**\n * Whether to clear the composer after sending.\n * When send is set to false, determines if composer text is replaced with suggestion (true, default),\n * or if it's appended to the composer text (false).\n *\n * @default true\n */\n clearComposer?: boolean | undefined;\n}) => {\n const aui = useAui();\n const disabled = useAuiState((s) => s.thread.isDisabled);\n const prompt = useAuiState((s) => s.suggestion.prompt);\n\n const resolvedSend = send ?? false;\n\n const callback = useCallback(() => {\n const isRunning = aui.thread().getState().isRunning;\n\n if (resolvedSend && !isRunning) {\n aui.thread().append({\n content: [{ type: \"text\", text: prompt }],\n runConfig: aui.composer().getState().runConfig,\n });\n if (clearComposer) {\n aui.composer().setText(\"\");\n }\n } else {\n if (clearComposer) {\n aui.composer().setText(prompt);\n } else {\n const currentText = aui.composer().getState().text;\n aui\n .composer()\n .setText(currentText.trim() ? `${currentText} ${prompt}` : prompt);\n }\n }\n }, [aui, resolvedSend, clearComposer, prompt]);\n\n if (disabled) return null;\n return callback;\n};\n\nexport namespace SuggestionPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useSuggestionTrigger>;\n}\n\n/**\n * A button that triggers the suggestion action (send or insert into composer).\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Trigger send>\n * Click me\n * </SuggestionPrimitive.Trigger>\n * ```\n */\nexport const SuggestionPrimitiveTrigger = createActionButton(\n \"SuggestionPrimitive.Trigger\",\n useSuggestionTrigger,\n [\"send\", \"clearComposer\"],\n);\n"],"mappings":";;;;;;AAUA,MAAMQ,wBAAuBC,OAAA;CAAA,MAAAC,IAAAT,EAAA,CAAA;CAAC,MAAA,EAAAU,MAAAC,eAAAC,OAAAJ;CAE5B,MAAAG,gBAAAC,OAAAC,KAAAA,IAAA,OAAAD;CAiBA,MAAAE,MAAYR,OAAO;CACnB,MAAAS,WAAiBV,YAAYW,KAA0B;CACvD,MAAAC,SAAeZ,YAAYa,MAA0B;CAErD,MAAAC,eAAqBT,QAAA;CAAc,IAAAU;CAAA,IAAAX,EAAA,OAAAK,OAAAL,EAAA,OAAAE,iBAAAF,EAAA,OAAAQ,UAAAR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;;;;;;;;;;cAoBnD,qCAAmB,0BAAA,KAAA,qBAAA,gBAAA,kCAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"ThreadRoot.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadRoot.tsx"],"mappings":";;;kBASiB;OACH,UAAU,oBAAoB,UAAU;;;;;OAKxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;;;;;;;;;;cAoBnD,qCAAmB,0BAAA,KAAA,qBAAA,gBAAA,kCAAA,eAAA;;;;oBAK9B,cAAA,0CAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadScrollToBottom.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"mappings":";;kBAaiB;OACH;IACV,WAAW;;;cAIT,4BAA2B,aAE9B,wBAAwB;kBAaV;OACH,UAAU;OACV,QAAQ,yBAAyB;;cAGlC,+CAA6B,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA"}
|
|
1
|
+
{"version":3,"file":"ThreadScrollToBottom.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"mappings":";;kBAaiB;OACH;IACV,WAAW;;;cAIT,4BAA2B,aAE9B,wBAAwB;kBAaV;OACH,UAAU;OACV,QAAQ,yBAAyB;;cAGlC,+CAA6B,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA;;;;oBAIzC,cAAA,6BAAA,wBAAA,0BAAA,cAAA"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useThreadViewport, useThreadViewportStore } from "../../context/react/ThreadViewportContext.js";
|
|
3
3
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/thread/ThreadScrollToBottom.ts
|
|
6
7
|
const useThreadScrollToBottom = (t0) => {
|
|
7
8
|
const $ = c(5);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadScrollToBottom.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useThreadViewport","useThreadViewportStore","useThreadScrollToBottom","Options","behavior","ScrollBehavior","t0","$","t1","undefined","isAtBottom","_temp","threadViewportStore","t2","getState","scrollToBottom","handleScrollToBottom","ThreadPrimitiveScrollToBottom","Element","Props","s"],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadScrollToBottom {\n export type Options = {\n behavior?: ScrollBehavior | undefined;\n };\n}\n\nconst useThreadScrollToBottom = ({\n behavior,\n}: useThreadScrollToBottom.Options = {}) => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom({ behavior });\n }, [threadViewportStore, behavior]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n [\"behavior\"],\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThreadScrollToBottom.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useThreadViewport","useThreadViewportStore","useThreadScrollToBottom","Options","behavior","ScrollBehavior","t0","$","t1","undefined","isAtBottom","_temp","threadViewportStore","t2","getState","scrollToBottom","handleScrollToBottom","ThreadPrimitiveScrollToBottom","Element","Props","s"],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadScrollToBottom {\n export type Options = {\n behavior?: ScrollBehavior | undefined;\n };\n}\n\nconst useThreadScrollToBottom = ({\n behavior,\n}: useThreadScrollToBottom.Options = {}) => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom({ behavior });\n }, [threadViewportStore, behavior]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n [\"behavior\"],\n);\n"],"mappings":";;;;;;AAmBA,MAAMQ,2BAA0BI,OAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CAAA,IAAAa;CAAA,IAAAD,EAAA,OAAAD,IAAA;EAACE,KAAAF,OAAAG,KAAAA,IAAA,CAEK,IAFLH;EAEMC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAFN,MAAA,EAAAH,aAAAI;CAG/B,MAAAE,aAAmBV,kBAAkBW,KAAmB;CAExD,MAAAC,sBAA4BX,uBAAuB;CAAE,IAAAY;CAAA,IAAAN,EAAA,OAAAH,YAAAG,EAAA,OAAAK,qBAAA;EAEZC,WAAA;GACvCD,oBAAmBE,SAAU,CAAC,CAAAC,eAAgB,EAAAX,SAAW,CAAC;EAAC;EAC5DG,EAAA,KAAAH;EAAAG,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAFD,MAAAS,uBAA6BH;CAI7B,IAAIH,YAAU,OAAS;CAAK,OACrBM;AAAoB;AAQ7B,MAAaC,gCAAgCnB,mBAC3C,kCACAI,yBACA,CAAC,UAAU,CACb;AAxBgC,SAAAS,MAAAS,GAAA;CAAA,OAGcA,EAACV;AAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadSuggestion.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadSuggestion.ts"],"mappings":";;cASM,wBAAuB,QAAA,MAAA,eAAA,UAAA,QAAA;;EAQ3B;;;;;EAMA;;;;;;;;EASA;;EAGA;;EAGA;;kBAae;OACH,UAAU;OACV,QAAQ,yBAAyB;;cAGlC,2CAAyB,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA"}
|
|
1
|
+
{"version":3,"file":"ThreadSuggestion.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadSuggestion.ts"],"mappings":";;cASM,wBAAuB,QAAA,MAAA,eAAA,UAAA,QAAA;;EAQ3B;;;;;EAMA;;;;;;;;EASA;;EAGA;;EAGA;;kBAae;OACH,UAAU;OACV,QAAQ,yBAAyB;;cAGlC,2CAAyB,0BAAA,KAAA,qBAAA,gBAAA,qCAAA,qBAAA;;;;;;EAvC5B;;;;;EAMD;;;;;;;;EASS;;EAGL;;EAGF;oBAsBV,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadViewport.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ThreadViewport.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"mappings":";;;kBA4BiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;IAO5D;;;;;;IAOA;;;;;;IAOA;;;;;;MAME;;;;;;MAMA;;;;;;;IAQF;;;;;;IAOA;;;;;;IAOA;;;;;;;;;;;;;;;;;;;cAoIS,yCAAuB,0BAAA,KAAA,qBAAA,gBAAA,kCAAA,eAAA;;;;;;;;;;;EApLnB;;;;;;EAOA;;;;;;EAOW;;;;;;IAMtB;;;;;;IAMA;;;;;;;EAQyB;;;;;;EAOE;;;;;;EAOE;oBA+IjC,cAAA"}
|
|
@@ -6,7 +6,7 @@ import { useManagedRef } from "../../utils/hooks/useManagedRef.js";
|
|
|
6
6
|
import { useThreadViewportAutoScroll } from "./useThreadViewportAutoScroll.js";
|
|
7
7
|
import { useSizeHandle } from "../../utils/hooks/useSizeHandle.js";
|
|
8
8
|
import { useTopAnchorReserve } from "./topAnchor/useTopAnchorReserve.js";
|
|
9
|
-
import { getActiveTopAnchorAnchorId, getActiveTopAnchorTargetId } from "./topAnchor/topAnchorTurn.js";
|
|
9
|
+
import { getActiveTopAnchorAnchorId, getActiveTopAnchorTargetId, isTopAnchorTurnValid } from "./topAnchor/topAnchorTurn.js";
|
|
10
10
|
import { useAuiEvent, useAuiState } from "@assistant-ui/store";
|
|
11
11
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
12
12
|
import { forwardRef, useLayoutEffect } from "@assistant-ui/tap/react-shim";
|
|
@@ -20,7 +20,7 @@ const useViewportElementRef = () => {
|
|
|
20
20
|
return useManagedRef(useThreadViewport(_temp3));
|
|
21
21
|
};
|
|
22
22
|
const useTopAnchorTurn = (enabled) => {
|
|
23
|
-
const $ = c(
|
|
23
|
+
const $ = c(21);
|
|
24
24
|
const threadViewportStore = useThreadViewportStore();
|
|
25
25
|
let t0;
|
|
26
26
|
if ($[0] !== enabled) {
|
|
@@ -42,6 +42,7 @@ const useTopAnchorTurn = (enabled) => {
|
|
|
42
42
|
$[3] = t1;
|
|
43
43
|
} else t1 = $[3];
|
|
44
44
|
const activeTargetId = useAuiState(t1);
|
|
45
|
+
const topAnchorTurn = useThreadViewport(_temp4);
|
|
45
46
|
let t2;
|
|
46
47
|
bb0: {
|
|
47
48
|
if (!activeAnchorId || !activeTargetId) {
|
|
@@ -62,34 +63,64 @@ const useTopAnchorTurn = (enabled) => {
|
|
|
62
63
|
}
|
|
63
64
|
const activeTurn = t2;
|
|
64
65
|
let t3;
|
|
66
|
+
if ($[7] !== enabled || $[8] !== topAnchorTurn) {
|
|
67
|
+
t3 = (s_2) => enabled && !!topAnchorTurn && isTopAnchorTurnValid(topAnchorTurn, s_2.thread.messages);
|
|
68
|
+
$[7] = enabled;
|
|
69
|
+
$[8] = topAnchorTurn;
|
|
70
|
+
$[9] = t3;
|
|
71
|
+
} else t3 = $[9];
|
|
72
|
+
const topAnchorTurnIsValid = useAuiState(t3);
|
|
65
73
|
let t4;
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
let t5;
|
|
75
|
+
if ($[10] !== threadViewportStore || $[11] !== topAnchorTurn || $[12] !== topAnchorTurnIsValid) {
|
|
76
|
+
t4 = () => {
|
|
77
|
+
if (!topAnchorTurn || topAnchorTurnIsValid) return;
|
|
78
|
+
threadViewportStore.getState().setTopAnchorTurn(null);
|
|
79
|
+
};
|
|
80
|
+
t5 = [
|
|
81
|
+
threadViewportStore,
|
|
82
|
+
topAnchorTurn,
|
|
83
|
+
topAnchorTurnIsValid
|
|
84
|
+
];
|
|
85
|
+
$[10] = threadViewportStore;
|
|
86
|
+
$[11] = topAnchorTurn;
|
|
87
|
+
$[12] = topAnchorTurnIsValid;
|
|
88
|
+
$[13] = t4;
|
|
89
|
+
$[14] = t5;
|
|
90
|
+
} else {
|
|
91
|
+
t4 = $[13];
|
|
92
|
+
t5 = $[14];
|
|
93
|
+
}
|
|
94
|
+
useLayoutEffect(t4, t5);
|
|
95
|
+
let t6;
|
|
96
|
+
let t7;
|
|
97
|
+
if ($[15] !== activeTurn || $[16] !== threadViewportStore) {
|
|
98
|
+
t6 = () => {
|
|
68
99
|
if (!activeTurn) return;
|
|
69
100
|
const state = threadViewportStore.getState();
|
|
70
101
|
const current = state.topAnchorTurn;
|
|
71
102
|
if (current?.anchorId === activeTurn.anchorId && current.targetId === activeTurn.targetId) return;
|
|
72
103
|
state.setTopAnchorTurn(activeTurn);
|
|
73
104
|
};
|
|
74
|
-
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[
|
|
78
|
-
$[
|
|
105
|
+
t7 = [activeTurn, threadViewportStore];
|
|
106
|
+
$[15] = activeTurn;
|
|
107
|
+
$[16] = threadViewportStore;
|
|
108
|
+
$[17] = t6;
|
|
109
|
+
$[18] = t7;
|
|
79
110
|
} else {
|
|
80
|
-
|
|
81
|
-
|
|
111
|
+
t6 = $[17];
|
|
112
|
+
t7 = $[18];
|
|
82
113
|
}
|
|
83
|
-
useLayoutEffect(
|
|
84
|
-
let
|
|
85
|
-
if ($[
|
|
86
|
-
|
|
114
|
+
useLayoutEffect(t6, t7);
|
|
115
|
+
let t8;
|
|
116
|
+
if ($[19] !== threadViewportStore) {
|
|
117
|
+
t8 = () => {
|
|
87
118
|
threadViewportStore.getState().setTopAnchorTurn(null);
|
|
88
119
|
};
|
|
89
|
-
$[
|
|
90
|
-
$[
|
|
91
|
-
} else
|
|
92
|
-
const clearTopAnchorTurn =
|
|
120
|
+
$[19] = threadViewportStore;
|
|
121
|
+
$[20] = t8;
|
|
122
|
+
} else t8 = $[20];
|
|
123
|
+
const clearTopAnchorTurn = t8;
|
|
93
124
|
useAuiEvent("thread.initialize", clearTopAnchorTurn);
|
|
94
125
|
useAuiEvent("threadListItem.switchedTo", clearTopAnchorTurn);
|
|
95
126
|
};
|
|
@@ -235,6 +266,9 @@ function _temp2(el) {
|
|
|
235
266
|
function _temp3(s) {
|
|
236
267
|
return s.registerViewportElement;
|
|
237
268
|
}
|
|
269
|
+
function _temp4(s_1) {
|
|
270
|
+
return s_1.topAnchorTurn;
|
|
271
|
+
}
|
|
238
272
|
//#endregion
|
|
239
273
|
export { ThreadPrimitiveViewport };
|
|
240
274
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadViewport.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useLayoutEffect","useMemo","useAuiEvent","useAuiState","useManagedRef","useThreadViewportAutoScroll","ThreadPrimitiveViewportProvider","useSizeHandle","useThreadViewport","useThreadViewportStore","useTopAnchorReserve","getActiveTopAnchorAnchorId","getActiveTopAnchorTargetId","ThreadPrimitiveViewport","Element","div","Props","autoScroll","turnAnchor","topAnchorMessageClamp","tallerThan","visibleHeight","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","useViewportSizeRef","register","_temp","getHeight","_temp2","useViewportElementRef","registerViewportElement","_temp3","useTopAnchorTurn","enabled","$","threadViewportStore","t0","s","thread","activeAnchorId","t1","s_0","activeTargetId","t2","bb0","t3","anchorId","targetId","activeTurn","t4","state","getState","current","topAnchorTurn","setTopAnchorTurn","t5","clearTopAnchorTurn","ThreadPrimitiveViewportScrollable","forwardedRef","children","rest","autoScrollRef","viewportSizeRef","viewportElementRef","topAnchorEnabled","ref","displayName","props","registerViewport","el","clientHeight"],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useLayoutEffect,\n useMemo,\n} from \"react\";\nimport { useAuiEvent, useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadPrimitiveViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { useTopAnchorReserve } from \"./topAnchor/useTopAnchorReserve\";\nimport {\n getActiveTopAnchorAnchorId,\n getActiveTopAnchorTargetId,\n} from \"./topAnchor/topAnchorTurn\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Controls scroll anchoring behavior for new messages.\n * - \"bottom\" (default): Messages anchor at the bottom, classic chat behavior.\n * - \"top\": New user messages anchor at the top of the viewport for a focused reading experience.\n */\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n\n /**\n * Clamps tall user messages so the assistant response stays in view.\n *\n * @default { tallerThan: \"10em\", visibleHeight: \"6em\" }\n */\n topAnchorMessageClamp?: {\n /**\n * Clamp messages taller than this. Supports `px`, `em`, and `rem`.\n *\n * @default \"10em\"\n */\n tallerThan?: string;\n /**\n * Visible portion of clamped messages. Supports `px`, `em`, and `rem`.\n *\n * @default \"6em\"\n */\n visibleHeight?: string;\n };\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when thread history is first loaded.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nconst useViewportSizeRef = () => {\n const register = useThreadViewport((s) => s.registerViewport);\n const getHeight = useCallback((el: HTMLElement) => el.clientHeight, []);\n return useSizeHandle(register, getHeight);\n};\n\nconst useViewportElementRef = () => {\n const registerViewportElement = useThreadViewport(\n (s) => s.registerViewportElement,\n );\n\n return useManagedRef(registerViewportElement);\n};\n\nconst useTopAnchorTurn = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n const activeAnchorId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorAnchorId(s.thread);\n });\n const activeTargetId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorTargetId(s.thread);\n });\n const activeTurn = useMemo(() => {\n if (!activeAnchorId || !activeTargetId) return null;\n return { anchorId: activeAnchorId, targetId: activeTargetId };\n }, [activeAnchorId, activeTargetId]);\n\n useLayoutEffect(() => {\n if (!activeTurn) return;\n\n const state = threadViewportStore.getState();\n const current = state.topAnchorTurn;\n if (\n current?.anchorId === activeTurn.anchorId &&\n current.targetId === activeTurn.targetId\n ) {\n return;\n }\n\n state.setTopAnchorTurn(activeTurn);\n }, [activeTurn, threadViewportStore]);\n\n const clearTopAnchorTurn = useCallback(() => {\n threadViewportStore.getState().setTopAnchorTurn(null);\n }, [threadViewportStore]);\n\n useAuiEvent(\"thread.initialize\", clearTopAnchorTurn);\n useAuiEvent(\"threadListItem.switchedTo\", clearTopAnchorTurn);\n};\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(\n (\n {\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n children,\n ...rest\n },\n forwardedRef,\n ) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n });\n const viewportSizeRef = useViewportSizeRef();\n const viewportElementRef = useViewportElementRef();\n const threadViewportStore = useThreadViewportStore();\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n const topAnchorEnabled = turnAnchor === \"top\";\n useTopAnchorTurn(topAnchorEnabled);\n useTopAnchorReserve(topAnchorEnabled);\n const ref = useComposedRefs(\n forwardedRef,\n autoScrollRef,\n viewportSizeRef,\n viewportElementRef,\n );\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n },\n);\n\nThreadPrimitiveViewportScrollable.displayName =\n \"ThreadPrimitive.ViewportScrollable\";\n\n/**\n * A scrollable viewport container for thread messages.\n *\n * This component provides a scrollable area for displaying thread messages with\n * automatic scrolling capabilities. It manages the viewport state and provides\n * context for child components to access viewport-related functionality.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Viewport turnAnchor=\"top\">\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * ```\n */\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ turnAnchor, topAnchorMessageClamp, ...props }, ref) => {\n return (\n <ThreadPrimitiveViewportProvider\n options={{ turnAnchor, topAnchorMessageClamp }}\n >\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </ThreadPrimitiveViewportProvider>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;;;;;;;;;;;;;AAwFA,MAAMiC,2BAAqB;CAE+C,OACjElB,cAFUC,kBAAkBmB,KAEdD,GAAUE,MAAS;AAAC;AAG3C,MAAME,8BAAwB;CAG1B,OAEK1B,cAJyBI,kBAC9BwB,MAGmBD,CAAuB;AAAC;AAG/C,MAAME,oBAAmBC,YAAA;CAAA,MAAAC,IAAA1C,EAAA,EAAA;CACvB,MAAA2C,sBAA4B3B,uBAAuB;CAAE,IAAA4B;CAAA,IAAAF,EAAA,OAAAD,SAAA;EAClBG,MAAAC,MAAA;GACjC,IAAI,CAACJ,SAAO;GAAmB,OACxBvB,2BAA2B2B,EAACC,MAAO;EAAC;EAC5CJ,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHD,MAAAK,iBAAuBrC,YAAYkC,EAGlC;CAAE,IAAAI;CAAA,IAAAN,EAAA,OAAAD,SAAA;EACgCO,MAAA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;EAAG,CAAA;EAAI/B,EAAA,KAAAiC;EAAAjC,EAAA,KAAA+B;EAAA/B,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,IAAAW;CAAA,IAAAX,EAAA,QAAAM,MAAAN,EAAA,QAAAS,IAAA;EAH5DE,KAAA,oBAAC,iCAAD;GACW,SAAAL;aAETG;EAH8B,CAAA;EAIET,EAAA,MAAAM;EAAAN,EAAA,MAAAS;EAAAT,EAAA,MAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OAJlCW;AAIkC,CAErC;AAEDjC,wBAAwBsD,cAAc;AA/HX,SAAAxC,MAAAW,GAAA;CAAA,OACiBA,EAAC+B;AAAiB;AADnC,SAAAxC,OAAAyC,IAAA;CAAA,OAE0BA,GAAEC;AAAa;AAItC,SAAAvC,OAAAM,GAAA;CAAA,OAEnBA,EAACP;AAAwB"}
|
|
1
|
+
{"version":3,"file":"ThreadViewport.js","names":["c","_c","useComposedRefs","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","useCallback","useLayoutEffect","useMemo","useAuiEvent","useAuiState","useManagedRef","useThreadViewportAutoScroll","ThreadPrimitiveViewportProvider","useSizeHandle","useThreadViewport","useThreadViewportStore","useTopAnchorReserve","getActiveTopAnchorAnchorId","getActiveTopAnchorTargetId","isTopAnchorTurnValid","ThreadPrimitiveViewport","Element","div","Props","autoScroll","turnAnchor","topAnchorMessageClamp","tallerThan","visibleHeight","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","useViewportSizeRef","register","_temp","getHeight","_temp2","useViewportElementRef","registerViewportElement","_temp3","useTopAnchorTurn","enabled","$","threadViewportStore","t0","s","thread","activeAnchorId","t1","s_0","activeTargetId","topAnchorTurn","_temp4","t2","bb0","t3","anchorId","targetId","activeTurn","s_2","messages","topAnchorTurnIsValid","t4","t5","getState","setTopAnchorTurn","t6","t7","state","current","t8","clearTopAnchorTurn","ThreadPrimitiveViewportScrollable","forwardedRef","children","rest","autoScrollRef","viewportSizeRef","viewportElementRef","topAnchorEnabled","ref","displayName","props","registerViewport","el","clientHeight","s_1"],"sources":["../../../src/primitives/thread/ThreadViewport.tsx"],"sourcesContent":["\"use client\";\n\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n useCallback,\n useLayoutEffect,\n useMemo,\n} from \"react\";\nimport { useAuiEvent, useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useThreadViewportAutoScroll } from \"./useThreadViewportAutoScroll\";\nimport { ThreadPrimitiveViewportProvider } from \"../../context/providers/ThreadViewportProvider\";\nimport { useSizeHandle } from \"../../utils/hooks/useSizeHandle\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { useTopAnchorReserve } from \"./topAnchor/useTopAnchorReserve\";\nimport {\n getActiveTopAnchorAnchorId,\n getActiveTopAnchorTargetId,\n isTopAnchorTurnValid,\n} from \"./topAnchor/topAnchorTurn\";\n\nexport namespace ThreadPrimitiveViewport {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div> & {\n /**\n * Whether to automatically scroll to the bottom when new messages are added.\n * When enabled, the viewport will automatically scroll to show the latest content.\n *\n * Default false if `turnAnchor` is \"top\", otherwise defaults to true.\n */\n autoScroll?: boolean | undefined;\n\n /**\n * Controls scroll anchoring behavior for new messages.\n * - \"bottom\" (default): Messages anchor at the bottom, classic chat behavior.\n * - \"top\": New user messages anchor at the top of the viewport for a focused reading experience.\n */\n turnAnchor?: \"top\" | \"bottom\" | undefined;\n\n /**\n * Clamps tall user messages so the assistant response stays in view.\n *\n * @default { tallerThan: \"10em\", visibleHeight: \"6em\" }\n */\n topAnchorMessageClamp?: {\n /**\n * Clamp messages taller than this. Supports `px`, `em`, and `rem`.\n *\n * @default \"10em\"\n */\n tallerThan?: string;\n /**\n * Visible portion of clamped messages. Supports `px`, `em`, and `rem`.\n *\n * @default \"6em\"\n */\n visibleHeight?: string;\n };\n\n /**\n * Whether to scroll to bottom when a new run starts.\n *\n * Defaults to true.\n */\n scrollToBottomOnRunStart?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when thread history is first loaded.\n *\n * Defaults to true.\n */\n scrollToBottomOnInitialize?: boolean | undefined;\n\n /**\n * Whether to scroll to bottom when switching to a different thread.\n *\n * Defaults to true.\n */\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n}\n\nconst useViewportSizeRef = () => {\n const register = useThreadViewport((s) => s.registerViewport);\n const getHeight = useCallback((el: HTMLElement) => el.clientHeight, []);\n return useSizeHandle(register, getHeight);\n};\n\nconst useViewportElementRef = () => {\n const registerViewportElement = useThreadViewport(\n (s) => s.registerViewportElement,\n );\n\n return useManagedRef(registerViewportElement);\n};\n\nconst useTopAnchorTurn = (enabled: boolean) => {\n const threadViewportStore = useThreadViewportStore();\n const activeAnchorId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorAnchorId(s.thread);\n });\n const activeTargetId = useAuiState((s) => {\n if (!enabled) return undefined;\n return getActiveTopAnchorTargetId(s.thread);\n });\n const topAnchorTurn = useThreadViewport((s) => s.topAnchorTurn);\n const activeTurn = useMemo(() => {\n if (!activeAnchorId || !activeTargetId) return null;\n return { anchorId: activeAnchorId, targetId: activeTargetId };\n }, [activeAnchorId, activeTargetId]);\n\n const topAnchorTurnIsValid = useAuiState(\n (s) =>\n enabled &&\n !!topAnchorTurn &&\n isTopAnchorTurnValid(topAnchorTurn, s.thread.messages),\n );\n\n useLayoutEffect(() => {\n if (!topAnchorTurn || topAnchorTurnIsValid) return;\n\n threadViewportStore.getState().setTopAnchorTurn(null);\n }, [threadViewportStore, topAnchorTurn, topAnchorTurnIsValid]);\n\n useLayoutEffect(() => {\n if (!activeTurn) return;\n\n const state = threadViewportStore.getState();\n const current = state.topAnchorTurn;\n if (\n current?.anchorId === activeTurn.anchorId &&\n current.targetId === activeTurn.targetId\n ) {\n return;\n }\n\n state.setTopAnchorTurn(activeTurn);\n }, [activeTurn, threadViewportStore]);\n\n const clearTopAnchorTurn = useCallback(() => {\n threadViewportStore.getState().setTopAnchorTurn(null);\n }, [threadViewportStore]);\n\n useAuiEvent(\"thread.initialize\", clearTopAnchorTurn);\n useAuiEvent(\"threadListItem.switchedTo\", clearTopAnchorTurn);\n};\n\nconst ThreadPrimitiveViewportScrollable = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(\n (\n {\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n children,\n ...rest\n },\n forwardedRef,\n ) => {\n const autoScrollRef = useThreadViewportAutoScroll<HTMLDivElement>({\n autoScroll,\n scrollToBottomOnRunStart,\n scrollToBottomOnInitialize,\n scrollToBottomOnThreadSwitch,\n });\n const viewportSizeRef = useViewportSizeRef();\n const viewportElementRef = useViewportElementRef();\n const threadViewportStore = useThreadViewportStore();\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n const topAnchorEnabled = turnAnchor === \"top\";\n useTopAnchorTurn(topAnchorEnabled);\n useTopAnchorReserve(topAnchorEnabled);\n const ref = useComposedRefs(\n forwardedRef,\n autoScrollRef,\n viewportSizeRef,\n viewportElementRef,\n );\n\n return (\n <Primitive.div {...rest} ref={ref}>\n {children}\n </Primitive.div>\n );\n },\n);\n\nThreadPrimitiveViewportScrollable.displayName =\n \"ThreadPrimitive.ViewportScrollable\";\n\n/**\n * A scrollable viewport container for thread messages.\n *\n * This component provides a scrollable area for displaying thread messages with\n * automatic scrolling capabilities. It manages the viewport state and provides\n * context for child components to access viewport-related functionality.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Viewport turnAnchor=\"top\">\n * <ThreadPrimitive.Messages>\n * {() => <MyMessage />}\n * </ThreadPrimitive.Messages>\n * </ThreadPrimitive.Viewport>\n * ```\n */\nexport const ThreadPrimitiveViewport = forwardRef<\n ThreadPrimitiveViewport.Element,\n ThreadPrimitiveViewport.Props\n>(({ turnAnchor, topAnchorMessageClamp, ...props }, ref) => {\n return (\n <ThreadPrimitiveViewportProvider\n options={{ turnAnchor, topAnchorMessageClamp }}\n >\n <ThreadPrimitiveViewportScrollable {...props} ref={ref} />\n </ThreadPrimitiveViewportProvider>\n );\n});\n\nThreadPrimitiveViewport.displayName = \"ThreadPrimitive.Viewport\";\n"],"mappings":";;;;;;;;;;;;;;;AAyFA,MAAMkC,2BAAqB;CAE+C,OACjEnB,cAFUC,kBAAkBoB,KAEdD,GAAUE,MAAS;AAAC;AAG3C,MAAME,8BAAwB;CAG1B,OAEK3B,cAJyBI,kBAC9ByB,MAGmBD,CAAuB;AAAC;AAG/C,MAAME,oBAAmBC,YAAA;CAAA,MAAAC,IAAA3C,EAAA,EAAA;CACvB,MAAA4C,sBAA4B5B,uBAAuB;CAAE,IAAA6B;CAAA,IAAAF,EAAA,OAAAD,SAAA;EAClBG,MAAAC,MAAA;GACjC,IAAI,CAACJ,SAAO;GAAmB,OACxBxB,2BAA2B4B,EAACC,MAAO;EAAC;EAC5CJ,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAHD,MAAAK,iBAAuBtC,YAAYmC,EAGlC;CAAE,IAAAI;CAAA,IAAAN,EAAA,OAAAD,SAAA;EACgCO,MAAAC,QAAA;GACjC,IAAI,CAACR,SAAO;GAAmB,OACxBvB,2BAA2B2B,IAACC,MAAO;EAAC;EAC5CJ,EAAA,KAAAD;EAAAC,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAHD,MAAAQ,iBAAuBzC,YAAYuC,EAGlC;CACD,MAAAG,gBAAsBrC,kBAAkBsC,MAAsB;CAAE,IAAAC;CAAAC,KAAA;EAE9D,IAAI,CAACP,kBAAD,CAAoBG,gBAAc;GAAEG,KAAO;GAA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,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;cA2BnD,+CAA6B,0BAAA,KAAA,qBAAA,gBAAA,kCAAA,eAAA"}
|
|
1
|
+
{"version":3,"file":"ThreadViewportFooter.d.ts","names":[],"sources":["../../../src/primitives/thread/ThreadViewportFooter.tsx"],"mappings":";;;kBAaiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;cA2BnD,+CAA6B,0BAAA,KAAA,qBAAA,gBAAA,kCAAA,eAAA;;;;oBAexC,cAAA,0CAAA,cAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReserveObservers.d.ts","names":[],"sources":["../../../../src/primitives/thread/topAnchor/createReserveObservers.ts"],"mappings":";cAEa,yBAA0B;
|
|
1
|
+
{"version":3,"file":"createReserveObservers.d.ts","names":[],"sources":["../../../../src/primitives/thread/topAnchor/createReserveObservers.ts"],"mappings":";cAEa,yBAA0B;EAkBvB,SAAA,UAAA,aAAW,QACb,aAAW,QACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mountTopAnchorReserve.d.ts","names":[],"sources":["../../../../src/primitives/thread/topAnchor/mountTopAnchorReserve.ts"],"mappings":";;;;;;KAmBY;EACV;IACE;IACA;MACE,UAAU;MACV,QAAQ;MACR,QAAQ;;IAEV;MACE;MACA;;;
|
|
1
|
+
{"version":3,"file":"mountTopAnchorReserve.d.ts","names":[],"sources":["../../../../src/primitives/thread/topAnchor/mountTopAnchorReserve.ts"],"mappings":";;;;;;KAmBY;EACV;IACE;IACA;MACE,UAAU;MACV,QAAQ;MACR,QAAQ;;IAEV;MACE;MACA;;IAEF;eACW;eACA;;;EAGb,UAAU;;cAuBC,wBAAyB,OAAO"}
|
|
@@ -28,7 +28,20 @@ const mountTopAnchorReserve = (store) => {
|
|
|
28
28
|
const state = store.getState();
|
|
29
29
|
const { viewport, anchor, target } = state.element;
|
|
30
30
|
const clamp = state.targetConfig;
|
|
31
|
-
if (state.turnAnchor !== "top" || !viewport
|
|
31
|
+
if (state.turnAnchor !== "top" || !viewport) {
|
|
32
|
+
observers.disconnect();
|
|
33
|
+
if (reserve) {
|
|
34
|
+
setReserveHeight(reserve, 0);
|
|
35
|
+
reserve.remove();
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!anchor && !target && !clamp && state.topAnchorTurn) {
|
|
40
|
+
observers.disconnect();
|
|
41
|
+
if (reserve?.parentElement && reserve.parentElement.lastElementChild !== reserve) reserve.parentElement.append(reserve);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!anchor || !target || !clamp) {
|
|
32
45
|
observers.disconnect();
|
|
33
46
|
if (reserve) {
|
|
34
47
|
setReserveHeight(reserve, 0);
|