@assistant-ui/react 0.12.17 → 0.12.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/client/ExternalThread.d.ts +24 -3
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +107 -27
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/client/InMemoryThreadList.js +23 -30
- package/dist/client/InMemoryThreadList.js.map +1 -1
- package/dist/client/SingleThreadList.d.ts +12 -0
- package/dist/client/SingleThreadList.d.ts.map +1 -0
- package/dist/client/SingleThreadList.js +68 -0
- package/dist/client/SingleThreadList.js.map +1 -0
- package/dist/context/index.d.ts +19 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +18 -3
- package/dist/context/index.js.map +1 -1
- package/dist/context/react/ThreadViewportContext.d.ts +1 -1
- package/dist/context/react/ThreadViewportContext.d.ts.map +1 -1
- package/dist/hooks/useMessageQuote.d.ts.map +1 -1
- package/dist/hooks/useMessageQuote.js +2 -1
- package/dist/hooks/useMessageQuote.js.map +1 -1
- package/dist/index.d.ts +96 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -8
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -1
- package/dist/internal.js.map +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -1
- package/dist/legacy-runtime/AssistantRuntimeProvider.js.map +1 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts +1 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts +1 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +4 -13
- package/dist/primitives/actionBar/ActionBarSpeak.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +4 -9
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js.map +1 -1
- package/dist/primitives/actionBar.d.ts +10 -0
- package/dist/primitives/actionBar.d.ts.map +1 -0
- package/dist/primitives/actionBar.js +10 -0
- package/dist/primitives/actionBar.js.map +1 -0
- package/dist/primitives/actionBarMore.d.ts +6 -0
- package/dist/primitives/actionBarMore.d.ts.map +1 -0
- package/dist/primitives/actionBarMore.js +6 -0
- package/dist/primitives/actionBarMore.js.map +1 -0
- package/dist/primitives/assistantModal.d.ts +5 -0
- package/dist/primitives/assistantModal.d.ts.map +1 -0
- package/dist/primitives/assistantModal.js +5 -0
- package/dist/primitives/assistantModal.js.map +1 -0
- package/dist/primitives/attachment/AttachmentThumb.js +1 -1
- package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
- package/dist/primitives/attachment.d.ts +5 -0
- package/dist/primitives/attachment.d.ts.map +1 -0
- package/dist/primitives/attachment.js +5 -0
- package/dist/primitives/attachment.js.map +1 -0
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +3 -17
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +0 -21
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +3 -38
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/branchPicker.d.ts +6 -0
- package/dist/primitives/branchPicker.d.ts.map +1 -0
- package/dist/primitives/branchPicker.js +6 -0
- package/dist/primitives/branchPicker.js.map +1 -0
- package/dist/primitives/chainOfThought.d.ts +4 -0
- package/dist/primitives/chainOfThought.d.ts.map +1 -0
- package/dist/primitives/chainOfThought.js +4 -0
- package/dist/primitives/chainOfThought.js.map +1 -0
- package/dist/primitives/composer/ComposerDictate.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerDictate.js +3 -10
- package/dist/primitives/composer/ComposerDictate.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +37 -7
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQueue.d.ts +2 -0
- package/dist/primitives/composer/ComposerQueue.d.ts.map +1 -0
- package/dist/primitives/composer/ComposerQueue.js +3 -0
- package/dist/primitives/composer/ComposerQueue.js.map +1 -0
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +3 -1
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/mention/ComposerMentionBack.d.ts +21 -0
- package/dist/primitives/composer/mention/ComposerMentionBack.d.ts.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionBack.js +28 -0
- package/dist/primitives/composer/mention/ComposerMentionBack.js.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionCategories.d.ts +42 -0
- package/dist/primitives/composer/mention/ComposerMentionCategories.d.ts.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionCategories.js +32 -0
- package/dist/primitives/composer/mention/ComposerMentionCategories.js.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionContext.d.ts +23 -0
- package/dist/primitives/composer/mention/ComposerMentionContext.d.ts.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionContext.js +66 -0
- package/dist/primitives/composer/mention/ComposerMentionContext.js.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionItems.d.ts +46 -0
- package/dist/primitives/composer/mention/ComposerMentionItems.d.ts.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionItems.js +30 -0
- package/dist/primitives/composer/mention/ComposerMentionItems.js.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionPopover.d.ts +24 -0
- package/dist/primitives/composer/mention/ComposerMentionPopover.d.ts.map +1 -0
- package/dist/primitives/composer/mention/ComposerMentionPopover.js +28 -0
- package/dist/primitives/composer/mention/ComposerMentionPopover.js.map +1 -0
- package/dist/primitives/composer/mention/MentionResource.d.ts +39 -0
- package/dist/primitives/composer/mention/MentionResource.d.ts.map +1 -0
- package/dist/primitives/composer/mention/MentionResource.js +230 -0
- package/dist/primitives/composer/mention/MentionResource.js.map +1 -0
- package/dist/primitives/composer/mention/detectMentionTrigger.d.ts +2 -0
- package/dist/primitives/composer/mention/detectMentionTrigger.d.ts.map +1 -0
- package/dist/primitives/composer/mention/detectMentionTrigger.js +26 -0
- package/dist/primitives/composer/mention/detectMentionTrigger.js.map +1 -0
- package/dist/primitives/composer/mention/index.d.ts +6 -0
- package/dist/primitives/composer/mention/index.d.ts.map +1 -0
- package/dist/primitives/composer/mention/index.js +6 -0
- package/dist/primitives/composer/mention/index.js.map +1 -0
- package/dist/primitives/composer.d.ts +26 -0
- package/dist/primitives/composer.d.ts.map +1 -0
- package/dist/primitives/composer.js +26 -0
- package/dist/primitives/composer.js.map +1 -0
- package/dist/primitives/error/ErrorMessage.d.ts.map +1 -1
- package/dist/primitives/error/ErrorMessage.js +2 -7
- package/dist/primitives/error/ErrorMessage.js.map +1 -1
- package/dist/primitives/error.d.ts +3 -0
- package/dist/primitives/error.d.ts.map +1 -0
- package/dist/primitives/error.js +3 -0
- package/dist/primitives/error.js.map +1 -0
- package/dist/primitives/message/MessageError.d.ts.map +1 -1
- package/dist/primitives/message/MessageError.js +3 -4
- package/dist/primitives/message/MessageError.js.map +1 -1
- package/dist/primitives/message/MessageParts.d.ts.map +1 -1
- package/dist/primitives/message/MessageParts.js +6 -1
- package/dist/primitives/message/MessageParts.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +2 -1
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message.d.ts +11 -0
- package/dist/primitives/message.d.ts.map +1 -0
- package/dist/primitives/message.js +11 -0
- package/dist/primitives/message.js.map +1 -0
- package/dist/primitives/messagePart.d.ts +5 -0
- package/dist/primitives/messagePart.d.ts.map +1 -0
- package/dist/primitives/messagePart.js +5 -0
- package/dist/primitives/messagePart.js.map +1 -0
- package/dist/primitives/queueItem/QueueItemRemove.d.ts +19 -0
- package/dist/primitives/queueItem/QueueItemRemove.d.ts.map +1 -0
- package/dist/primitives/queueItem/QueueItemRemove.js +21 -0
- package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -0
- package/dist/primitives/queueItem/QueueItemSteer.d.ts +19 -0
- package/dist/primitives/queueItem/QueueItemSteer.d.ts.map +1 -0
- package/dist/primitives/queueItem/QueueItemSteer.js +21 -0
- package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -0
- package/dist/primitives/queueItem/QueueItemText.d.ts +18 -0
- package/dist/primitives/queueItem/QueueItemText.d.ts.map +1 -0
- package/dist/primitives/queueItem/QueueItemText.js +19 -0
- package/dist/primitives/queueItem/QueueItemText.js.map +1 -0
- package/dist/primitives/queueItem.d.ts +4 -0
- package/dist/primitives/queueItem.d.ts.map +1 -0
- package/dist/primitives/queueItem.js +4 -0
- package/dist/primitives/queueItem.js.map +1 -0
- package/dist/primitives/selectionToolbar.d.ts +3 -0
- package/dist/primitives/selectionToolbar.d.ts.map +1 -0
- package/dist/primitives/selectionToolbar.js +3 -0
- package/dist/primitives/selectionToolbar.js.map +1 -0
- package/dist/primitives/suggestion.d.ts +4 -0
- package/dist/primitives/suggestion.d.ts.map +1 -0
- package/dist/primitives/suggestion.js +4 -0
- package/dist/primitives/suggestion.js.map +1 -0
- package/dist/primitives/thread/ThreadRoot.d.ts +3 -1
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +3 -1
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +8 -29
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/thread/ThreadViewport.d.ts +3 -1
- package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewport.js +3 -1
- package/dist/primitives/thread/ThreadViewport.js.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.d.ts +3 -1
- package/dist/primitives/thread/ThreadViewportFooter.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadViewportFooter.js +3 -1
- package/dist/primitives/thread/ThreadViewportFooter.js.map +1 -1
- package/dist/primitives/thread.d.ts +13 -0
- package/dist/primitives/thread.d.ts.map +1 -0
- package/dist/primitives/thread.js +13 -0
- package/dist/primitives/thread.js.map +1 -0
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +4 -5
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadList.d.ts +5 -0
- package/dist/primitives/threadList.d.ts.map +1 -0
- package/dist/primitives/threadList.js +5 -0
- package/dist/primitives/threadList.js.map +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +3 -6
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +3 -6
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +3 -6
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +3 -6
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/dist/primitives/threadListItem.d.ts +7 -0
- package/dist/primitives/threadListItem.d.ts.map +1 -0
- package/dist/primitives/threadListItem.js +7 -0
- package/dist/primitives/threadListItem.js.map +1 -0
- package/dist/primitives/threadListItemMore.d.ts +6 -0
- package/dist/primitives/threadListItemMore.d.ts.map +1 -0
- package/dist/primitives/threadListItemMore.js +6 -0
- package/dist/primitives/threadListItemMore.js.map +1 -0
- package/dist/unstable/useToolMentionAdapter.d.ts +42 -0
- package/dist/unstable/useToolMentionAdapter.d.ts.map +1 -0
- package/dist/unstable/useToolMentionAdapter.js +65 -0
- package/dist/unstable/useToolMentionAdapter.js.map +1 -0
- package/package.json +12 -12
- package/src/client/ExternalThread.ts +161 -32
- package/src/client/InMemoryThreadList.ts +24 -35
- package/src/client/SingleThreadList.ts +95 -0
- package/src/context/index.ts +67 -3
- package/src/context/react/ThreadViewportContext.ts +1 -1
- package/src/hooks/useMessageQuote.ts +3 -7
- package/src/index.ts +357 -8
- package/src/internal.ts +5 -1
- package/src/legacy-runtime/AssistantRuntimeProvider.tsx +1 -1
- package/src/legacy-runtime/cloud/useCloudThreadListRuntime.ts +1 -1
- package/src/legacy-runtime/hooks/MessageContext.ts +1 -1
- package/src/legacy-runtime/hooks/ThreadContext.ts +2 -2
- package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +4 -1
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +1 -1
- package/src/model-context/frame/SPEC_AssistantFrame.md +2 -2
- package/src/primitives/actionBar/ActionBarSpeak.ts +4 -17
- package/src/primitives/actionBar/ActionBarStopSpeaking.tsx +4 -12
- package/src/primitives/actionBar.ts +9 -0
- package/src/primitives/actionBarMore.ts +5 -0
- package/src/primitives/assistantModal.ts +4 -0
- package/src/primitives/attachment/AttachmentThumb.tsx +1 -1
- package/src/primitives/attachment.ts +4 -0
- package/src/primitives/branchPicker/BranchPickerNext.ts +3 -20
- package/src/primitives/branchPicker/BranchPickerPrevious.ts +3 -41
- package/src/primitives/branchPicker/BranchPickerRoot.tsx +1 -1
- package/src/primitives/branchPicker.ts +5 -0
- package/src/primitives/{chainOfThought/index.ts → chainOfThought.ts} +3 -3
- package/src/primitives/composer/ComposerDictate.ts +3 -15
- package/src/primitives/composer/ComposerInput.tsx +49 -5
- package/src/primitives/composer/ComposerQueue.tsx +3 -0
- package/src/primitives/composer/ComposerSend.ts +3 -1
- package/src/primitives/composer/mention/ComposerMentionBack.tsx +55 -0
- package/src/primitives/composer/mention/ComposerMentionCategories.tsx +104 -0
- package/src/primitives/composer/mention/ComposerMentionContext.tsx +141 -0
- package/src/primitives/composer/mention/ComposerMentionItems.tsx +104 -0
- package/src/primitives/composer/mention/ComposerMentionPopover.tsx +52 -0
- package/src/primitives/composer/mention/MentionResource.ts +328 -0
- package/src/primitives/composer/mention/detectMentionTrigger.test.ts +78 -0
- package/src/primitives/composer/mention/detectMentionTrigger.ts +37 -0
- package/src/primitives/composer/mention/index.ts +16 -0
- package/src/primitives/composer.ts +25 -0
- package/src/primitives/error/ErrorMessage.tsx +2 -7
- package/src/primitives/error.ts +2 -0
- package/src/primitives/message/MessageError.ts +3 -7
- package/src/primitives/message/MessageParts.tsx +11 -4
- package/src/primitives/message/MessagePartsGrouped.tsx +3 -5
- package/src/primitives/message.ts +13 -0
- package/src/primitives/messagePart.ts +4 -0
- package/src/primitives/queueItem/QueueItemRemove.ts +37 -0
- package/src/primitives/queueItem/QueueItemSteer.ts +37 -0
- package/src/primitives/queueItem/QueueItemText.tsx +37 -0
- package/src/primitives/queueItem.ts +3 -0
- package/src/primitives/{selectionToolbar/index.ts → selectionToolbar.ts} +2 -2
- package/src/primitives/suggestion.ts +3 -0
- package/src/primitives/thread/ThreadRoot.tsx +3 -1
- package/src/primitives/thread/ThreadSuggestion.ts +8 -30
- package/src/primitives/thread/ThreadViewport.tsx +3 -1
- package/src/primitives/thread/ThreadViewportFooter.tsx +3 -1
- package/src/primitives/thread.ts +15 -0
- package/src/primitives/threadList/ThreadListNew.tsx +4 -5
- package/src/primitives/threadList.ts +4 -0
- package/src/primitives/threadListItem/ThreadListItemArchive.ts +3 -6
- package/src/primitives/threadListItem/ThreadListItemDelete.ts +3 -6
- package/src/primitives/threadListItem/ThreadListItemTrigger.ts +3 -6
- package/src/primitives/threadListItem/ThreadListItemUnarchive.ts +3 -6
- package/src/primitives/threadListItem.ts +6 -0
- package/src/primitives/threadListItemMore.ts +5 -0
- package/src/unstable/useToolMentionAdapter.ts +114 -0
- package/dist/client/index.d.ts +0 -7
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -10
- package/dist/client/index.js.map +0 -1
- package/dist/context/providers/index.d.ts +0 -10
- package/dist/context/providers/index.d.ts.map +0 -1
- package/dist/context/providers/index.js +0 -10
- package/dist/context/providers/index.js.map +0 -1
- package/dist/context/react/index.d.ts +0 -9
- package/dist/context/react/index.d.ts.map +0 -1
- package/dist/context/react/index.js +0 -10
- package/dist/context/react/index.js.map +0 -1
- package/dist/context/stores/index.d.ts +0 -2
- package/dist/context/stores/index.d.ts.map +0 -1
- package/dist/context/stores/index.js +0 -2
- package/dist/context/stores/index.js.map +0 -1
- package/dist/devtools/index.d.ts +0 -2
- package/dist/devtools/index.d.ts.map +0 -1
- package/dist/devtools/index.js +0 -2
- package/dist/devtools/index.js.map +0 -1
- package/dist/legacy-runtime/cloud/index.d.ts +0 -3
- package/dist/legacy-runtime/cloud/index.d.ts.map +0 -1
- package/dist/legacy-runtime/cloud/index.js +0 -3
- package/dist/legacy-runtime/cloud/index.js.map +0 -1
- package/dist/legacy-runtime/runtime/index.d.ts +0 -2
- package/dist/legacy-runtime/runtime/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime/index.js +0 -2
- package/dist/legacy-runtime/runtime/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/index.d.ts +0 -4
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/index.js +0 -4
- package/dist/legacy-runtime/runtime-cores/adapters/attachment/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.js +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/feedback/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/index.d.ts +0 -7
- package/dist/legacy-runtime/runtime-cores/adapters/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/index.js +0 -7
- package/dist/legacy-runtime/runtime-cores/adapters/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/speech/index.d.ts +0 -3
- package/dist/legacy-runtime/runtime-cores/adapters/speech/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/speech/index.js +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/speech/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.js +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/suggestion/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/thread-history/index.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/thread-history/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/adapters/thread-history/index.js +0 -2
- package/dist/legacy-runtime/runtime-cores/adapters/thread-history/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.d.ts +0 -3
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.js +0 -2
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/index.d.ts +0 -2
- package/dist/legacy-runtime/runtime-cores/core/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/core/index.js +0 -2
- package/dist/legacy-runtime/runtime-cores/core/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/index.d.ts +0 -7
- package/dist/legacy-runtime/runtime-cores/external-store/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/external-store/index.js +0 -6
- package/dist/legacy-runtime/runtime-cores/external-store/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/index.d.ts +0 -9
- package/dist/legacy-runtime/runtime-cores/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/index.js +0 -8
- package/dist/legacy-runtime/runtime-cores/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/index.d.ts +0 -8
- package/dist/legacy-runtime/runtime-cores/local/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/local/index.js +0 -7
- package/dist/legacy-runtime/runtime-cores/local/index.js.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/index.d.ts +0 -5
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/index.d.ts.map +0 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/index.js +0 -5
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/index.js.map +0 -1
- package/dist/model-context/frame/index.d.ts +0 -6
- package/dist/model-context/frame/index.d.ts.map +0 -1
- package/dist/model-context/frame/index.js +0 -5
- package/dist/model-context/frame/index.js.map +0 -1
- package/dist/model-context/index.d.ts +0 -10
- package/dist/model-context/index.d.ts.map +0 -1
- package/dist/model-context/index.js +0 -11
- package/dist/model-context/index.js.map +0 -1
- package/dist/model-context/registry/index.d.ts +0 -3
- package/dist/model-context/registry/index.d.ts.map +0 -1
- package/dist/model-context/registry/index.js +0 -2
- package/dist/model-context/registry/index.js.map +0 -1
- package/dist/primitives/actionBar/index.d.ts +0 -10
- package/dist/primitives/actionBar/index.d.ts.map +0 -1
- package/dist/primitives/actionBar/index.js +0 -10
- package/dist/primitives/actionBar/index.js.map +0 -1
- package/dist/primitives/actionBarMore/index.d.ts +0 -6
- package/dist/primitives/actionBarMore/index.d.ts.map +0 -1
- package/dist/primitives/actionBarMore/index.js +0 -6
- package/dist/primitives/actionBarMore/index.js.map +0 -1
- package/dist/primitives/assistantModal/index.d.ts +0 -5
- package/dist/primitives/assistantModal/index.d.ts.map +0 -1
- package/dist/primitives/assistantModal/index.js +0 -5
- package/dist/primitives/assistantModal/index.js.map +0 -1
- package/dist/primitives/attachment/index.d.ts +0 -5
- package/dist/primitives/attachment/index.d.ts.map +0 -1
- package/dist/primitives/attachment/index.js +0 -5
- package/dist/primitives/attachment/index.js.map +0 -1
- package/dist/primitives/branchPicker/index.d.ts +0 -6
- package/dist/primitives/branchPicker/index.d.ts.map +0 -1
- package/dist/primitives/branchPicker/index.js +0 -6
- package/dist/primitives/branchPicker/index.js.map +0 -1
- package/dist/primitives/chainOfThought/index.d.ts +0 -4
- package/dist/primitives/chainOfThought/index.d.ts.map +0 -1
- package/dist/primitives/chainOfThought/index.js +0 -4
- package/dist/primitives/chainOfThought/index.js.map +0 -1
- package/dist/primitives/composer/index.d.ts +0 -16
- package/dist/primitives/composer/index.d.ts.map +0 -1
- package/dist/primitives/composer/index.js +0 -16
- package/dist/primitives/composer/index.js.map +0 -1
- package/dist/primitives/error/index.d.ts +0 -3
- package/dist/primitives/error/index.d.ts.map +0 -1
- package/dist/primitives/error/index.js +0 -3
- package/dist/primitives/error/index.js.map +0 -1
- package/dist/primitives/index.d.ts +0 -27
- package/dist/primitives/index.d.ts.map +0 -1
- package/dist/primitives/index.js +0 -27
- package/dist/primitives/index.js.map +0 -1
- package/dist/primitives/message/index.d.ts +0 -10
- package/dist/primitives/message/index.d.ts.map +0 -1
- package/dist/primitives/message/index.js +0 -10
- package/dist/primitives/message/index.js.map +0 -1
- package/dist/primitives/messagePart/index.d.ts +0 -4
- package/dist/primitives/messagePart/index.d.ts.map +0 -1
- package/dist/primitives/messagePart/index.js +0 -4
- package/dist/primitives/messagePart/index.js.map +0 -1
- package/dist/primitives/reasoning/index.d.ts +0 -2
- package/dist/primitives/reasoning/index.d.ts.map +0 -1
- package/dist/primitives/reasoning/index.js +0 -2
- package/dist/primitives/reasoning/index.js.map +0 -1
- package/dist/primitives/selectionToolbar/index.d.ts +0 -3
- package/dist/primitives/selectionToolbar/index.d.ts.map +0 -1
- package/dist/primitives/selectionToolbar/index.js +0 -3
- package/dist/primitives/selectionToolbar/index.js.map +0 -1
- package/dist/primitives/suggestion/index.d.ts +0 -4
- package/dist/primitives/suggestion/index.d.ts.map +0 -1
- package/dist/primitives/suggestion/index.js +0 -4
- package/dist/primitives/suggestion/index.js.map +0 -1
- package/dist/primitives/thread/index.d.ts +0 -13
- package/dist/primitives/thread/index.d.ts.map +0 -1
- package/dist/primitives/thread/index.js +0 -13
- package/dist/primitives/thread/index.js.map +0 -1
- package/dist/primitives/threadList/index.d.ts +0 -5
- package/dist/primitives/threadList/index.d.ts.map +0 -1
- package/dist/primitives/threadList/index.js +0 -5
- package/dist/primitives/threadList/index.js.map +0 -1
- package/dist/primitives/threadListItem/index.d.ts +0 -7
- package/dist/primitives/threadListItem/index.d.ts.map +0 -1
- package/dist/primitives/threadListItem/index.js +0 -7
- package/dist/primitives/threadListItem/index.js.map +0 -1
- package/dist/primitives/threadListItemMore/index.d.ts +0 -6
- package/dist/primitives/threadListItemMore/index.d.ts.map +0 -1
- package/dist/primitives/threadListItemMore/index.js +0 -6
- package/dist/primitives/threadListItemMore/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/scopes/index.d.ts +0 -3
- package/dist/types/scopes/index.d.ts.map +0 -1
- package/dist/types/scopes/index.js +0 -2
- package/dist/types/scopes/index.js.map +0 -1
- package/dist/utils/smooth/index.d.ts +0 -3
- package/dist/utils/smooth/index.d.ts.map +0 -1
- package/dist/utils/smooth/index.js +0 -6
- package/dist/utils/smooth/index.js.map +0 -1
- package/src/client/index.ts +0 -18
- package/src/context/providers/index.ts +0 -15
- package/src/context/react/index.ts +0 -50
- package/src/context/stores/index.ts +0 -1
- package/src/devtools/index.ts +0 -1
- package/src/legacy-runtime/cloud/index.ts +0 -2
- package/src/legacy-runtime/runtime/index.ts +0 -25
- package/src/legacy-runtime/runtime-cores/adapters/attachment/index.ts +0 -10
- package/src/legacy-runtime/runtime-cores/adapters/feedback/index.ts +0 -2
- package/src/legacy-runtime/runtime-cores/adapters/index.ts +0 -6
- package/src/legacy-runtime/runtime-cores/adapters/speech/index.ts +0 -9
- package/src/legacy-runtime/runtime-cores/adapters/suggestion/index.ts +0 -2
- package/src/legacy-runtime/runtime-cores/adapters/thread-history/index.ts +0 -9
- package/src/legacy-runtime/runtime-cores/assistant-transport/index.ts +0 -11
- package/src/legacy-runtime/runtime-cores/core/index.ts +0 -7
- package/src/legacy-runtime/runtime-cores/external-store/index.ts +0 -21
- package/src/legacy-runtime/runtime-cores/index.ts +0 -10
- package/src/legacy-runtime/runtime-cores/local/index.ts +0 -18
- package/src/legacy-runtime/runtime-cores/remote-thread-list/index.ts +0 -7
- package/src/model-context/frame/index.ts +0 -10
- package/src/model-context/index.ts +0 -45
- package/src/model-context/registry/index.ts +0 -6
- package/src/primitives/actionBar/index.ts +0 -9
- package/src/primitives/actionBarMore/index.ts +0 -5
- package/src/primitives/assistantModal/index.ts +0 -4
- package/src/primitives/attachment/index.ts +0 -4
- package/src/primitives/branchPicker/index.ts +0 -5
- package/src/primitives/composer/index.ts +0 -15
- package/src/primitives/error/index.ts +0 -2
- package/src/primitives/index.ts +0 -27
- package/src/primitives/message/index.ts +0 -12
- package/src/primitives/messagePart/index.ts +0 -3
- package/src/primitives/reasoning/index.ts +0 -1
- package/src/primitives/suggestion/index.ts +0 -3
- package/src/primitives/thread/index.ts +0 -15
- package/src/primitives/threadList/index.ts +0 -4
- package/src/primitives/threadListItem/index.ts +0 -6
- package/src/primitives/threadListItemMore/index.ts +0 -5
- package/src/types/index.ts +0 -56
- package/src/types/scopes/index.ts +0 -59
- package/src/utils/smooth/index.ts +0 -6
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export {
|
|
2
2
|
ChainOfThoughtPrimitiveRoot as Root,
|
|
3
3
|
type ChainOfThoughtPrimitiveRoot as RootPrimitive,
|
|
4
|
-
} from "./ChainOfThoughtRoot";
|
|
4
|
+
} from "./chainOfThought/ChainOfThoughtRoot";
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
7
|
ChainOfThoughtPrimitiveAccordionTrigger as AccordionTrigger,
|
|
8
8
|
type ChainOfThoughtPrimitiveAccordionTrigger as AccordionTriggerPrimitive,
|
|
9
|
-
} from "./ChainOfThoughtAccordionTrigger";
|
|
9
|
+
} from "./chainOfThought/ChainOfThoughtAccordionTrigger";
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
12
|
ChainOfThoughtPrimitiveParts as Parts,
|
|
13
13
|
type ChainOfThoughtPrimitiveParts as PartsPrimitive,
|
|
14
|
-
} from "./ChainOfThoughtParts";
|
|
14
|
+
} from "./chainOfThought/ChainOfThoughtParts";
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useCallback } from "react";
|
|
4
|
-
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
5
3
|
import type {
|
|
6
4
|
ActionButtonElement,
|
|
7
5
|
ActionButtonProps,
|
|
8
6
|
} from "../../utils/createActionButton";
|
|
9
7
|
import { createActionButton } from "../../utils/createActionButton";
|
|
8
|
+
import { useComposerDictate as useComposerDictateBehavior } from "@assistant-ui/core/react";
|
|
10
9
|
|
|
11
10
|
const useComposerDictate = () => {
|
|
12
|
-
const
|
|
13
|
-
const disabled = useAuiState(
|
|
14
|
-
(s) =>
|
|
15
|
-
s.composer.dictation != null ||
|
|
16
|
-
!s.thread.capabilities.dictation ||
|
|
17
|
-
!s.composer.isEditing,
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const callback = useCallback(() => {
|
|
21
|
-
aui.composer().startDictation();
|
|
22
|
-
}, [aui]);
|
|
23
|
-
|
|
11
|
+
const { disabled, startDictation } = useComposerDictateBehavior();
|
|
24
12
|
if (disabled) return null;
|
|
25
|
-
return
|
|
13
|
+
return startDictation;
|
|
26
14
|
};
|
|
27
15
|
|
|
28
16
|
export namespace ComposerPrimitiveDictate {
|
|
@@ -18,6 +18,10 @@ import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
|
|
|
18
18
|
import { useOnScrollToBottom } from "../../utils/hooks/useOnScrollToBottom";
|
|
19
19
|
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
20
20
|
import { flushResourcesSync } from "@assistant-ui/tap";
|
|
21
|
+
import {
|
|
22
|
+
useMentionContextOptional,
|
|
23
|
+
useMentionInternalContext,
|
|
24
|
+
} from "./mention/ComposerMentionContext";
|
|
21
25
|
|
|
22
26
|
export namespace ComposerPrimitiveInput {
|
|
23
27
|
export type Element = HTMLTextAreaElement;
|
|
@@ -118,6 +122,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
118
122
|
onChange,
|
|
119
123
|
onKeyDown,
|
|
120
124
|
onPaste,
|
|
125
|
+
onSelect,
|
|
121
126
|
submitOnEnter,
|
|
122
127
|
submitMode,
|
|
123
128
|
cancelOnEscape = true,
|
|
@@ -130,6 +135,8 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
130
135
|
forwardedRef,
|
|
131
136
|
) => {
|
|
132
137
|
const aui = useAui();
|
|
138
|
+
const mentionContext = useMentionContextOptional();
|
|
139
|
+
const mentionInternalContext = useMentionInternalContext();
|
|
133
140
|
|
|
134
141
|
const effectiveSubmitMode =
|
|
135
142
|
submitMode ?? (submitOnEnter === false ? "none" : "enter");
|
|
@@ -149,11 +156,17 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
149
156
|
const ref = useComposedRefs(forwardedRef, textareaRef);
|
|
150
157
|
|
|
151
158
|
useEscapeKeydown((e) => {
|
|
152
|
-
if (!cancelOnEscape) return;
|
|
153
|
-
|
|
154
159
|
// Only handle ESC if it originated from within this input
|
|
155
160
|
if (!textareaRef.current?.contains(e.target as Node)) return;
|
|
156
161
|
|
|
162
|
+
// Let mention popover handle Escape first
|
|
163
|
+
if (mentionContext?.open) {
|
|
164
|
+
mentionContext.handleKeyDown(e);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!cancelOnEscape) return;
|
|
169
|
+
|
|
157
170
|
const composer = aui.composer();
|
|
158
171
|
if (composer.getState().canCancel) {
|
|
159
172
|
composer.cancel();
|
|
@@ -167,9 +180,31 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
167
180
|
// ignore IME composition events
|
|
168
181
|
if (e.nativeEvent.isComposing) return;
|
|
169
182
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
183
|
+
// Let the mention popover handle keyboard events first
|
|
184
|
+
if (mentionContext?.handleKeyDown(e)) return;
|
|
185
|
+
|
|
186
|
+
if (e.key === "Enter") {
|
|
187
|
+
const threadState = aui.thread().getState();
|
|
188
|
+
const hasQueue = threadState.capabilities.queue;
|
|
189
|
+
|
|
190
|
+
// Steer hotkey: Cmd/Ctrl+Shift+Enter (respects submitMode="none" and isEmpty)
|
|
191
|
+
if (
|
|
192
|
+
e.shiftKey &&
|
|
193
|
+
(e.ctrlKey || e.metaKey) &&
|
|
194
|
+
hasQueue &&
|
|
195
|
+
effectiveSubmitMode !== "none" &&
|
|
196
|
+
!aui.composer().getState().isEmpty
|
|
197
|
+
) {
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
aui.composer().send({ steer: true });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Regular newline: Shift+Enter
|
|
204
|
+
if (e.shiftKey) return;
|
|
205
|
+
|
|
206
|
+
// Block submission when running unless queue is supported
|
|
207
|
+
if (threadState.isRunning && !hasQueue) return;
|
|
173
208
|
|
|
174
209
|
let shouldSubmit = false;
|
|
175
210
|
if (effectiveSubmitMode === "ctrlEnter") {
|
|
@@ -254,8 +289,17 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
254
289
|
flushResourcesSync(() => {
|
|
255
290
|
aui.composer().setText(e.target.value);
|
|
256
291
|
});
|
|
292
|
+
mentionInternalContext?.setCursorPosition(
|
|
293
|
+
e.target.selectionStart ?? e.target.value.length,
|
|
294
|
+
);
|
|
257
295
|
})}
|
|
258
296
|
onKeyDown={composeEventHandlers(onKeyDown, handleKeyPress)}
|
|
297
|
+
onSelect={composeEventHandlers(onSelect, (e) => {
|
|
298
|
+
const target = e.target as HTMLTextAreaElement;
|
|
299
|
+
mentionInternalContext?.setCursorPosition(
|
|
300
|
+
target.selectionStart ?? target.value.length,
|
|
301
|
+
);
|
|
302
|
+
})}
|
|
259
303
|
onPaste={composeEventHandlers(onPaste, handlePaste)}
|
|
260
304
|
/>
|
|
261
305
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { useCallback } from "react";
|
|
3
4
|
import {
|
|
4
5
|
ActionButtonElement,
|
|
5
6
|
ActionButtonProps,
|
|
@@ -9,8 +10,9 @@ import { useComposerSend as useComposerSendBehavior } from "@assistant-ui/core/r
|
|
|
9
10
|
|
|
10
11
|
export const useComposerSend = () => {
|
|
11
12
|
const { disabled, send } = useComposerSendBehavior();
|
|
13
|
+
const callback = useCallback(() => send(), [send]);
|
|
12
14
|
if (disabled) return null;
|
|
13
|
-
return
|
|
15
|
+
return callback;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export namespace ComposerPrimitiveSend {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import {
|
|
5
|
+
type ComponentRef,
|
|
6
|
+
type ComponentPropsWithoutRef,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useCallback,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
11
|
+
import { useMentionContext } from "./ComposerMentionContext";
|
|
12
|
+
|
|
13
|
+
// =============================================================================
|
|
14
|
+
// MentionBack — Button to navigate back from items to categories
|
|
15
|
+
// =============================================================================
|
|
16
|
+
|
|
17
|
+
export namespace ComposerPrimitiveMentionBack {
|
|
18
|
+
export type Element = ComponentRef<typeof Primitive.button>;
|
|
19
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A button that navigates back from category items to the category list.
|
|
24
|
+
* Only renders when a category is active (drill-down view).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <ComposerPrimitive.MentionBack>
|
|
29
|
+
* ← Back
|
|
30
|
+
* </ComposerPrimitive.MentionBack>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const ComposerPrimitiveMentionBack = forwardRef<
|
|
34
|
+
ComposerPrimitiveMentionBack.Element,
|
|
35
|
+
ComposerPrimitiveMentionBack.Props
|
|
36
|
+
>(({ onClick, ...props }, forwardedRef) => {
|
|
37
|
+
const { activeCategoryId, isSearchMode, goBack } = useMentionContext();
|
|
38
|
+
|
|
39
|
+
const handleClick = useCallback(() => {
|
|
40
|
+
goBack();
|
|
41
|
+
}, [goBack]);
|
|
42
|
+
|
|
43
|
+
if (!activeCategoryId || isSearchMode) return null;
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Primitive.button
|
|
47
|
+
type="button"
|
|
48
|
+
{...props}
|
|
49
|
+
ref={forwardedRef}
|
|
50
|
+
onClick={composeEventHandlers(onClick, handleClick)}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
ComposerPrimitiveMentionBack.displayName = "ComposerPrimitive.MentionBack";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import {
|
|
5
|
+
type ComponentRef,
|
|
6
|
+
type ComponentPropsWithoutRef,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
forwardRef,
|
|
9
|
+
useCallback,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
12
|
+
import { useMentionContext } from "./ComposerMentionContext";
|
|
13
|
+
import type { Unstable_MentionCategory } from "@assistant-ui/core";
|
|
14
|
+
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// MentionCategories — Renders the list of categories
|
|
17
|
+
// =============================================================================
|
|
18
|
+
|
|
19
|
+
export namespace ComposerPrimitiveMentionCategories {
|
|
20
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
|
21
|
+
export type Props = Omit<
|
|
22
|
+
ComponentPropsWithoutRef<typeof Primitive.div>,
|
|
23
|
+
"children"
|
|
24
|
+
> & {
|
|
25
|
+
/**
|
|
26
|
+
* Render function that receives the filtered categories and returns
|
|
27
|
+
* the UI. A render-function pattern is used here (instead of a
|
|
28
|
+
* `components` prop) to give consumers full control over list layout,
|
|
29
|
+
* ordering, grouping, and empty states.
|
|
30
|
+
*/
|
|
31
|
+
children: (categories: readonly Unstable_MentionCategory[]) => ReactNode;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ComposerPrimitiveMentionCategories = forwardRef<
|
|
36
|
+
ComposerPrimitiveMentionCategories.Element,
|
|
37
|
+
ComposerPrimitiveMentionCategories.Props
|
|
38
|
+
>(({ children, ...props }, forwardedRef) => {
|
|
39
|
+
const { categories, activeCategoryId, isSearchMode } = useMentionContext();
|
|
40
|
+
|
|
41
|
+
if (activeCategoryId || isSearchMode) return null;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Primitive.div role="group" {...props} ref={forwardedRef}>
|
|
45
|
+
{children(categories)}
|
|
46
|
+
</Primitive.div>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
ComposerPrimitiveMentionCategories.displayName =
|
|
51
|
+
"ComposerPrimitive.MentionCategories";
|
|
52
|
+
|
|
53
|
+
// =============================================================================
|
|
54
|
+
// MentionCategoryItem — A single category row (clickable to drill-down)
|
|
55
|
+
// =============================================================================
|
|
56
|
+
|
|
57
|
+
export namespace ComposerPrimitiveMentionCategoryItem {
|
|
58
|
+
export type Element = ComponentRef<typeof Primitive.button>;
|
|
59
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.button> & {
|
|
60
|
+
categoryId: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A button that selects a category and triggers drill-down navigation.
|
|
66
|
+
* Automatically receives `data-highlighted` when keyboard-navigated.
|
|
67
|
+
*/
|
|
68
|
+
export const ComposerPrimitiveMentionCategoryItem = forwardRef<
|
|
69
|
+
ComposerPrimitiveMentionCategoryItem.Element,
|
|
70
|
+
ComposerPrimitiveMentionCategoryItem.Props
|
|
71
|
+
>(({ categoryId, onClick, ...props }, forwardedRef) => {
|
|
72
|
+
const {
|
|
73
|
+
selectCategory,
|
|
74
|
+
categories,
|
|
75
|
+
highlightedIndex,
|
|
76
|
+
activeCategoryId,
|
|
77
|
+
isSearchMode,
|
|
78
|
+
} = useMentionContext();
|
|
79
|
+
|
|
80
|
+
const handleClick = useCallback(() => {
|
|
81
|
+
selectCategory(categoryId);
|
|
82
|
+
}, [selectCategory, categoryId]);
|
|
83
|
+
|
|
84
|
+
// Derive highlighted state from context — no manual wiring needed
|
|
85
|
+
const isHighlighted =
|
|
86
|
+
!activeCategoryId &&
|
|
87
|
+
!isSearchMode &&
|
|
88
|
+
categories.findIndex((c) => c.id === categoryId) === highlightedIndex;
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Primitive.button
|
|
92
|
+
type="button"
|
|
93
|
+
role="option"
|
|
94
|
+
aria-selected={isHighlighted}
|
|
95
|
+
data-highlighted={isHighlighted ? "" : undefined}
|
|
96
|
+
{...props}
|
|
97
|
+
ref={forwardedRef}
|
|
98
|
+
onClick={composeEventHandlers(onClick, handleClick)}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
ComposerPrimitiveMentionCategoryItem.displayName =
|
|
104
|
+
"ComposerPrimitive.MentionCategoryItem";
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useState,
|
|
7
|
+
useCallback,
|
|
8
|
+
useMemo,
|
|
9
|
+
useEffect,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
type FC,
|
|
12
|
+
} from "react";
|
|
13
|
+
import { useResource } from "@assistant-ui/tap/react";
|
|
14
|
+
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
15
|
+
import type {
|
|
16
|
+
Unstable_MentionAdapter,
|
|
17
|
+
Unstable_DirectiveFormatter,
|
|
18
|
+
} from "@assistant-ui/core";
|
|
19
|
+
import { unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
|
|
20
|
+
import {
|
|
21
|
+
MentionResource,
|
|
22
|
+
type MentionResourceOutput,
|
|
23
|
+
type SelectItemOverride,
|
|
24
|
+
} from "./MentionResource";
|
|
25
|
+
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Context — public (popover components read state + actions from here)
|
|
28
|
+
// =============================================================================
|
|
29
|
+
|
|
30
|
+
const MentionContext = createContext<MentionResourceOutput | null>(null);
|
|
31
|
+
|
|
32
|
+
export const useMentionContext = () => {
|
|
33
|
+
const ctx = useContext(MentionContext);
|
|
34
|
+
if (!ctx)
|
|
35
|
+
throw new Error(
|
|
36
|
+
"useMentionContext must be used within ComposerPrimitive.MentionRoot",
|
|
37
|
+
);
|
|
38
|
+
return ctx;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const useMentionContextOptional = () => {
|
|
42
|
+
return useContext(MentionContext);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// =============================================================================
|
|
46
|
+
// Internal context — ComposerInput → MentionRoot communication
|
|
47
|
+
// =============================================================================
|
|
48
|
+
|
|
49
|
+
type MentionInternalContextValue = {
|
|
50
|
+
setCursorPosition(pos: number): void;
|
|
51
|
+
registerSelectItemOverride(fn: SelectItemOverride): () => void;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const MentionInternalContext =
|
|
55
|
+
createContext<MentionInternalContextValue | null>(null);
|
|
56
|
+
|
|
57
|
+
export const useMentionInternalContext = () => {
|
|
58
|
+
return useContext(MentionInternalContext);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// =============================================================================
|
|
62
|
+
// Provider Component
|
|
63
|
+
// =============================================================================
|
|
64
|
+
|
|
65
|
+
export namespace ComposerPrimitiveMentionRoot {
|
|
66
|
+
export type Props = {
|
|
67
|
+
children: ReactNode;
|
|
68
|
+
adapter?: Unstable_MentionAdapter | undefined;
|
|
69
|
+
/** Character(s) that trigger the mention popover. @default "@" */
|
|
70
|
+
trigger?: string | undefined;
|
|
71
|
+
/** Custom formatter for serializing/parsing mention directives. */
|
|
72
|
+
formatter?: Unstable_DirectiveFormatter | undefined;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const ComposerPrimitiveMentionRoot: FC<
|
|
77
|
+
ComposerPrimitiveMentionRoot.Props
|
|
78
|
+
> = ({
|
|
79
|
+
children,
|
|
80
|
+
adapter: adapterProp,
|
|
81
|
+
trigger: triggerChar = "@",
|
|
82
|
+
formatter: formatterProp,
|
|
83
|
+
}) => {
|
|
84
|
+
const aui = useAui();
|
|
85
|
+
const text = useAuiState((s) => s.composer.text);
|
|
86
|
+
const formatter = formatterProp ?? unstable_defaultDirectiveFormatter;
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
// Runtime adapter (subscribe to state changes instead of useAuiState to avoid
|
|
90
|
+
// infinite loop — getModelContext() returns a new object on every call)
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
const getRuntimeAdapter = useCallback(() => {
|
|
94
|
+
try {
|
|
95
|
+
const runtime = aui.composer().__internal_getRuntime?.();
|
|
96
|
+
return (runtime as any)?._core?.getState()?.getMentionAdapter?.();
|
|
97
|
+
} catch {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}, [aui]);
|
|
101
|
+
const [runtimeAdapter, setRuntimeAdapter] = useState(getRuntimeAdapter);
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
return aui.subscribe(() => {
|
|
104
|
+
setRuntimeAdapter((prev: unknown) => {
|
|
105
|
+
const next = getRuntimeAdapter();
|
|
106
|
+
return prev === next ? prev : next;
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}, [aui, getRuntimeAdapter]);
|
|
110
|
+
const adapter = adapterProp ?? runtimeAdapter;
|
|
111
|
+
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Mention resource (all state + logic managed via tap primitives)
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
|
|
116
|
+
const mention = useResource(
|
|
117
|
+
MentionResource({ adapter, text, triggerChar, formatter, aui }),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// Internal context (stable — methods come from tapEffectEvent)
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
|
|
124
|
+
const internalContextValue = useMemo<MentionInternalContextValue>(
|
|
125
|
+
() => ({
|
|
126
|
+
setCursorPosition: mention.setCursorPosition,
|
|
127
|
+
registerSelectItemOverride: mention.registerSelectItemOverride,
|
|
128
|
+
}),
|
|
129
|
+
[mention.setCursorPosition, mention.registerSelectItemOverride],
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<MentionContext.Provider value={mention}>
|
|
134
|
+
<MentionInternalContext.Provider value={internalContextValue}>
|
|
135
|
+
{children}
|
|
136
|
+
</MentionInternalContext.Provider>
|
|
137
|
+
</MentionContext.Provider>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
ComposerPrimitiveMentionRoot.displayName = "ComposerPrimitive.MentionRoot";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import {
|
|
5
|
+
type ComponentRef,
|
|
6
|
+
type ComponentPropsWithoutRef,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
forwardRef,
|
|
9
|
+
useCallback,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
12
|
+
import { useMentionContext } from "./ComposerMentionContext";
|
|
13
|
+
import type { Unstable_MentionItem } from "@assistant-ui/core";
|
|
14
|
+
|
|
15
|
+
// =============================================================================
|
|
16
|
+
// MentionItems — Renders the list of items within a category
|
|
17
|
+
// =============================================================================
|
|
18
|
+
|
|
19
|
+
export namespace ComposerPrimitiveMentionItems {
|
|
20
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
|
21
|
+
export type Props = Omit<
|
|
22
|
+
ComponentPropsWithoutRef<typeof Primitive.div>,
|
|
23
|
+
"children"
|
|
24
|
+
> & {
|
|
25
|
+
/**
|
|
26
|
+
* Render function that receives the filtered items and returns
|
|
27
|
+
* the UI. A render-function pattern is used here (instead of a
|
|
28
|
+
* `components` prop) to give consumers full control over list layout,
|
|
29
|
+
* ordering, grouping, and empty states.
|
|
30
|
+
*/
|
|
31
|
+
children: (items: readonly Unstable_MentionItem[]) => ReactNode;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ComposerPrimitiveMentionItems = forwardRef<
|
|
36
|
+
ComposerPrimitiveMentionItems.Element,
|
|
37
|
+
ComposerPrimitiveMentionItems.Props
|
|
38
|
+
>(({ children, ...props }, forwardedRef) => {
|
|
39
|
+
const { items, activeCategoryId, isSearchMode } = useMentionContext();
|
|
40
|
+
|
|
41
|
+
if (!activeCategoryId && !isSearchMode) return null;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Primitive.div role="group" {...props} ref={forwardedRef}>
|
|
45
|
+
{children(items)}
|
|
46
|
+
</Primitive.div>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
ComposerPrimitiveMentionItems.displayName = "ComposerPrimitive.MentionItems";
|
|
51
|
+
|
|
52
|
+
// =============================================================================
|
|
53
|
+
// MentionItem — A single selectable mention item
|
|
54
|
+
// =============================================================================
|
|
55
|
+
|
|
56
|
+
export namespace ComposerPrimitiveMentionItem {
|
|
57
|
+
export type Element = ComponentRef<typeof Primitive.button>;
|
|
58
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.button> & {
|
|
59
|
+
item: Unstable_MentionItem;
|
|
60
|
+
/** Position in the items list. Used for keyboard highlight matching. Falls back to findIndex by id. */
|
|
61
|
+
index?: number | undefined;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A button that inserts the mention item into the composer.
|
|
67
|
+
* Automatically receives `data-highlighted` when keyboard-navigated.
|
|
68
|
+
*/
|
|
69
|
+
export const ComposerPrimitiveMentionItem = forwardRef<
|
|
70
|
+
ComposerPrimitiveMentionItem.Element,
|
|
71
|
+
ComposerPrimitiveMentionItem.Props
|
|
72
|
+
>(({ item, index: indexProp, onClick, ...props }, forwardedRef) => {
|
|
73
|
+
const {
|
|
74
|
+
selectItem,
|
|
75
|
+
items,
|
|
76
|
+
highlightedIndex,
|
|
77
|
+
activeCategoryId,
|
|
78
|
+
isSearchMode,
|
|
79
|
+
} = useMentionContext();
|
|
80
|
+
|
|
81
|
+
const handleClick = useCallback(() => {
|
|
82
|
+
selectItem(item);
|
|
83
|
+
}, [selectItem, item]);
|
|
84
|
+
|
|
85
|
+
// Use explicit index prop if provided, fall back to findIndex
|
|
86
|
+
const itemIndex = indexProp ?? items.findIndex((i) => i.id === item.id);
|
|
87
|
+
const isHighlighted =
|
|
88
|
+
(isSearchMode || activeCategoryId !== null) &&
|
|
89
|
+
itemIndex === highlightedIndex;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Primitive.button
|
|
93
|
+
type="button"
|
|
94
|
+
role="option"
|
|
95
|
+
aria-selected={isHighlighted}
|
|
96
|
+
data-highlighted={isHighlighted ? "" : undefined}
|
|
97
|
+
{...props}
|
|
98
|
+
ref={forwardedRef}
|
|
99
|
+
onClick={composeEventHandlers(onClick, handleClick)}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
ComposerPrimitiveMentionItem.displayName = "ComposerPrimitive.MentionItem";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import {
|
|
5
|
+
type ComponentRef,
|
|
6
|
+
type ComponentPropsWithoutRef,
|
|
7
|
+
forwardRef,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { useMentionContext } from "./ComposerMentionContext";
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// MentionPopover — Container that only renders when mention is active
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
export namespace ComposerPrimitiveMentionPopover {
|
|
16
|
+
export type Element = ComponentRef<typeof Primitive.div>;
|
|
17
|
+
export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Renders a container for the mention picker popover.
|
|
22
|
+
* Only renders when a `@` trigger is detected in the composer text.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <ComposerPrimitive.MentionRoot adapter={mentionAdapter}>
|
|
27
|
+
* <ComposerPrimitive.Input />
|
|
28
|
+
* <ComposerPrimitive.MentionPopover>
|
|
29
|
+
* <ComposerPrimitive.MentionCategories />
|
|
30
|
+
* </ComposerPrimitive.MentionPopover>
|
|
31
|
+
* </ComposerPrimitive.MentionRoot>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const ComposerPrimitiveMentionPopover = forwardRef<
|
|
35
|
+
ComposerPrimitiveMentionPopover.Element,
|
|
36
|
+
ComposerPrimitiveMentionPopover.Props
|
|
37
|
+
>((props, forwardedRef) => {
|
|
38
|
+
const { open } = useMentionContext();
|
|
39
|
+
if (!open) return null;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Primitive.div
|
|
43
|
+
role="listbox"
|
|
44
|
+
data-state="open"
|
|
45
|
+
{...props}
|
|
46
|
+
ref={forwardedRef}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
ComposerPrimitiveMentionPopover.displayName =
|
|
52
|
+
"ComposerPrimitive.MentionPopover";
|