@assistant-ui/react 0.7.8 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/AssistantRuntime.d.ts +4 -5
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +19 -22
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +16 -19
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js +4 -4
- package/dist/api/MessageRuntime.js +7 -7
- package/dist/api/ThreadListItemRuntime.d.ts +11 -2
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js +16 -5
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs +16 -5
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +3 -0
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +31 -12
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs +27 -8
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +10 -7
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +22 -12
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +16 -6
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/api/subscribable/LazyMemoizeSubject.js +2 -2
- package/dist/api/subscribable/NestedSubscriptionSubject.js +1 -1
- package/dist/api/subscribable/ShallowMemoizeSubject.js +3 -3
- package/dist/context/index.js +6 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +12 -5
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +8 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.js +2 -2
- package/dist/context/providers/ContentPartRuntimeProvider.js +2 -2
- package/dist/context/providers/MessageRuntimeProvider.js +3 -3
- package/dist/context/providers/TextContentPartProvider.js +3 -3
- package/dist/context/providers/ThreadListItemRuntimeProvider.js +2 -2
- package/dist/context/providers/ThreadRuntimeProvider.d.ts +2 -0
- package/dist/context/providers/ThreadRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.js +6 -5
- package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.mjs +3 -2
- package/dist/context/providers/ThreadRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/index.js +2 -2
- package/dist/context/react/AssistantContext.js +2 -2
- package/dist/context/react/AttachmentContext.js +1 -1
- package/dist/context/react/ComposerContext.js +3 -3
- package/dist/context/react/ContentPartContext.js +2 -2
- package/dist/context/react/MessageContext.js +2 -2
- package/dist/context/react/ThreadContext.js +2 -2
- package/dist/context/react/ThreadListItemContext.js +2 -2
- package/dist/context/react/index.js +6 -6
- package/dist/context/react/utils/createContextStoreHook.d.ts.map +1 -1
- package/dist/edge.js +1 -1
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +1 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +10 -13
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +0 -2
- package/dist/internal.mjs.map +1 -1
- package/dist/model-config/index.js +6 -6
- package/dist/model-config/makeAssistantTool.js +1 -1
- package/dist/model-config/makeAssistantToolUI.js +1 -1
- package/dist/model-config/useAssistantInstructions.js +1 -1
- package/dist/model-config/useAssistantTool.js +1 -1
- package/dist/model-config/useAssistantToolUI.js +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarCopy.js +2 -2
- package/dist/primitive-hooks/actionBar/useActionBarEdit.js +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackNegative.js +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarFeedbackPositive.js +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarReload.js +3 -3
- package/dist/primitive-hooks/actionBar/useActionBarSpeak.js +1 -1
- package/dist/primitive-hooks/actionBar/useActionBarStopSpeaking.js +1 -1
- package/dist/primitive-hooks/attachment/useAttachmentRemove.js +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerCount.js +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerNext.js +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerNumber.js +1 -1
- package/dist/primitive-hooks/branchPicker/useBranchPickerPrevious.js +1 -1
- package/dist/primitive-hooks/composer/useComposerAddAttachment.js +1 -1
- package/dist/primitive-hooks/composer/useComposerCancel.js +1 -1
- package/dist/primitive-hooks/composer/useComposerIf.js +1 -1
- package/dist/primitive-hooks/composer/useComposerSend.js +3 -3
- package/dist/primitive-hooks/contentPart/index.js +3 -3
- package/dist/primitive-hooks/contentPart/useContentPartDisplay.js +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartImage.js +1 -1
- package/dist/primitive-hooks/contentPart/useContentPartText.js +1 -1
- package/dist/primitive-hooks/index.js +2 -2
- package/dist/primitive-hooks/index.js.map +1 -1
- package/dist/primitive-hooks/message/useMessageIf.js +2 -2
- package/dist/primitive-hooks/thread/useThreadEmpty.js +1 -1
- package/dist/primitive-hooks/thread/useThreadIf.js +1 -1
- package/dist/primitive-hooks/thread/useThreadScrollToBottom.js +2 -2
- package/dist/primitive-hooks/thread/useThreadSuggestion.js +2 -2
- package/dist/primitive-hooks/thread/useThreadViewportAutoScroll.js +5 -5
- package/dist/primitives/actionBar/ActionBarCopy.js +2 -2
- package/dist/primitives/actionBar/ActionBarEdit.js +2 -2
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +2 -2
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +2 -2
- package/dist/primitives/actionBar/ActionBarReload.js +2 -2
- package/dist/primitives/actionBar/ActionBarRoot.js +1 -1
- package/dist/primitives/actionBar/ActionBarSpeak.js +2 -2
- package/dist/primitives/actionBar/ActionBarStopSpeaking.js +1 -1
- package/dist/primitives/actionBar/index.js +8 -8
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +3 -3
- package/dist/primitives/assistantModal/AssistantModalAnchor.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalContent.js +1 -1
- package/dist/primitives/assistantModal/AssistantModalRoot.js +2 -2
- package/dist/primitives/assistantModal/AssistantModalTrigger.js +1 -1
- package/dist/primitives/assistantModal/index.js +4 -4
- package/dist/primitives/attachment/AttachmentName.js +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +2 -2
- package/dist/primitives/attachment/AttachmentThumb.js +1 -1
- package/dist/primitives/attachment/index.js +4 -4
- package/dist/primitives/branchPicker/BranchPickerCount.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +2 -2
- package/dist/primitives/branchPicker/BranchPickerNumber.js +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +2 -2
- package/dist/primitives/branchPicker/BranchPickerRoot.js +1 -1
- package/dist/primitives/branchPicker/index.js +5 -5
- package/dist/primitives/composer/ComposerAddAttachment.js +2 -2
- package/dist/primitives/composer/ComposerAttachments.js +3 -3
- package/dist/primitives/composer/ComposerCancel.js +2 -2
- package/dist/primitives/composer/ComposerIf.js +1 -1
- package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +6 -4
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.mjs +3 -1
- package/dist/primitives/composer/ComposerInput.mjs.map +1 -1
- package/dist/primitives/composer/ComposerRoot.js +1 -1
- package/dist/primitives/composer/ComposerSend.js +2 -2
- package/dist/primitives/composer/index.js +7 -7
- package/dist/primitives/contentPart/ContentPartDisplay.js +1 -1
- package/dist/primitives/contentPart/ContentPartImage.js +1 -1
- package/dist/primitives/contentPart/ContentPartInProgress.js +1 -1
- package/dist/primitives/contentPart/ContentPartText.js +2 -2
- package/dist/primitives/contentPart/index.js +4 -4
- package/dist/primitives/index.js +10 -10
- package/dist/primitives/message/MessageAttachments.js +3 -3
- package/dist/primitives/message/MessageContent.js +8 -8
- package/dist/primitives/message/MessageIf.js +1 -1
- package/dist/primitives/message/MessageRoot.js +2 -2
- package/dist/primitives/message/index.js +4 -4
- package/dist/primitives/thread/ThreadEmpty.js +1 -1
- package/dist/primitives/thread/ThreadIf.js +1 -1
- package/dist/primitives/thread/ThreadMessages.js +3 -3
- package/dist/primitives/thread/ThreadScrollToBottom.js +2 -2
- package/dist/primitives/thread/ThreadSuggestion.js +2 -2
- package/dist/primitives/thread/ThreadViewport.js +1 -1
- package/dist/primitives/thread/index.js +7 -7
- package/dist/primitives/threadList/ThreadListItems.js +2 -2
- package/dist/primitives/threadList/ThreadListNew.js +2 -2
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.mjs +1 -1
- package/dist/primitives/threadList/ThreadListNew.mjs.map +1 -1
- package/dist/primitives/threadList/index.js +2 -2
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +2 -2
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +2 -2
- package/dist/primitives/threadListItem/ThreadListItemRoot.js +2 -2
- package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.mjs +1 -1
- package/dist/primitives/threadListItem/ThreadListItemRoot.mjs.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTitle.js +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +2 -2
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +2 -2
- package/dist/primitives/threadListItem/index.js +6 -6
- package/dist/runtimes/attachment/index.js +3 -3
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +2 -2
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js +1 -1
- package/dist/runtimes/core/BaseAssistantRuntimeCore.js +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +2 -4
- package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.js +5 -9
- package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs +1 -5
- package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +14 -6
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts +1 -15
- package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/index.d.ts +1 -1
- package/dist/runtimes/core/index.d.ts.map +1 -1
- package/dist/runtimes/core/index.js.map +1 -1
- package/dist/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.js +6 -6
- package/dist/runtimes/dangerous-in-browser/index.js +1 -1
- package/dist/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.js +3 -3
- package/dist/runtimes/edge/EdgeChatAdapter.js +7 -7
- package/dist/runtimes/edge/EdgeRuntimeRequestOptions.js +1 -1
- package/dist/runtimes/edge/converters/fromCoreMessage.js +1 -1
- package/dist/runtimes/edge/converters/index.js +6 -6
- package/dist/runtimes/edge/createEdgeRuntimeAPI.js +9 -9
- package/dist/runtimes/edge/index.js +6 -6
- package/dist/runtimes/edge/index.js.map +1 -1
- package/dist/runtimes/edge/partial-json/parse-partial-json.js +1 -1
- package/dist/runtimes/edge/streams/assistantDecoderStream.js +1 -1
- package/dist/runtimes/edge/streams/assistantEncoderStream.js +1 -1
- package/dist/runtimes/edge/streams/runResultStream.js +1 -1
- package/dist/runtimes/edge/streams/utils/index.js +2 -2
- package/dist/runtimes/edge/streams/utils/streamPartDecoderStream.js +2 -2
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.d.ts +1 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.d.ts.map +1 -1
- package/dist/runtimes/edge/streams/utils/streamPartEncoderStream.js +1 -1
- package/dist/runtimes/edge/useEdgeRuntime.js +3 -3
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +20 -3
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts +0 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +6 -13
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +3 -10
- package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +9 -11
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +19 -27
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs +19 -27
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +2 -2
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +10 -13
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +4 -7
- package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/external-store/external-message-converter.js +4 -4
- package/dist/runtimes/external-store/index.js +3 -3
- package/dist/runtimes/external-store/useExternalStoreRuntime.js +3 -3
- package/dist/runtimes/index.js +16 -16
- package/dist/runtimes/index.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts +0 -1
- package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.js +7 -16
- package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalRuntimeCore.mjs +3 -12
- package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +17 -15
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +95 -93
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +94 -92
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +4 -3
- package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.js +15 -14
- package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +11 -10
- package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/index.js +1 -1
- package/dist/runtimes/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.js +7 -10
- package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.mjs +4 -7
- package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
- package/dist/runtimes/speech/index.js +1 -1
- package/dist/runtimes/utils/MessageRepository.js +2 -2
- package/dist/styles/index.css +12 -0
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +1 -1
- package/dist/styles/tailwindcss/thread.css.json +1 -1
- package/dist/ui/assistant-action-bar.js +5 -5
- package/dist/ui/assistant-message.js +7 -7
- package/dist/ui/assistant-modal.js +5 -5
- package/dist/ui/attachment-ui.js +7 -7
- package/dist/ui/base/avatar.js +1 -1
- package/dist/ui/base/index.js +5 -5
- package/dist/ui/base/tooltip-icon-button.js +2 -2
- package/dist/ui/base/tooltip.js +1 -1
- package/dist/ui/branch-picker.js +5 -5
- package/dist/ui/composer.js +7 -7
- package/dist/ui/content-part.js +2 -2
- package/dist/ui/edit-composer.js +4 -4
- package/dist/ui/index.d.ts +4 -4
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +15 -15
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +18 -18
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/thread-config.d.ts +1 -1
- package/dist/ui/thread-config.d.ts.map +1 -1
- package/dist/ui/thread-config.js +2 -2
- package/dist/ui/thread-config.js.map +1 -1
- package/dist/ui/thread-config.mjs.map +1 -1
- package/dist/ui/thread-list-item.d.ts +2 -11
- package/dist/ui/thread-list-item.d.ts.map +1 -1
- package/dist/ui/thread-list-item.js +20 -33
- package/dist/ui/thread-list-item.js.map +1 -1
- package/dist/ui/thread-list-item.mjs +16 -29
- package/dist/ui/thread-list-item.mjs.map +1 -1
- package/dist/ui/thread-list.d.ts +10 -3
- package/dist/ui/thread-list.d.ts.map +1 -1
- package/dist/ui/thread-list.js +8 -9
- package/dist/ui/thread-list.js.map +1 -1
- package/dist/ui/thread-list.mjs +3 -4
- package/dist/ui/thread-list.mjs.map +1 -1
- package/dist/ui/thread-welcome.js +5 -5
- package/dist/ui/thread.js +10 -10
- package/dist/ui/user-action-bar.js +5 -5
- package/dist/ui/user-message.js +6 -6
- package/dist/utils/ProxyConfigProvider.js +1 -1
- package/dist/utils/combined/createCombinedStore.d.ts.map +1 -1
- package/dist/utils/combined/useCombinedStore.d.ts.map +1 -1
- package/dist/utils/combined/useCombinedStore.js +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +1 -1
- package/dist/utils/hooks/useOnScrollToBottom.js +1 -1
- package/dist/utils/smooth/SmoothContext.js +2 -2
- package/dist/utils/smooth/index.js +3 -3
- package/dist/utils/smooth/useSmooth.js +3 -3
- package/package.json +1 -1
- package/src/api/AssistantRuntime.ts +21 -25
- package/src/api/ThreadListItemRuntime.ts +36 -7
- package/src/api/ThreadListRuntime.ts +31 -9
- package/src/api/ThreadRuntime.ts +38 -10
- package/src/context/providers/AssistantRuntimeProvider.tsx +4 -1
- package/src/context/providers/ThreadRuntimeProvider.tsx +9 -2
- package/src/internal.ts +1 -1
- package/src/primitives/composer/ComposerInput.tsx +3 -1
- package/src/primitives/threadList/ThreadListNew.tsx +1 -1
- package/src/primitives/threadListItem/ThreadListItemRoot.tsx +1 -1
- package/src/runtimes/core/BaseThreadRuntimeCore.tsx +1 -9
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +16 -7
- package/src/runtimes/core/ThreadRuntimeCore.tsx +1 -19
- package/src/runtimes/core/index.ts +0 -1
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +20 -3
- package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +5 -12
- package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +22 -35
- package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +3 -7
- package/src/runtimes/local/LocalRuntimeCore.tsx +7 -14
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +110 -103
- package/src/runtimes/local/LocalThreadRuntimeCore.tsx +11 -10
- package/src/runtimes/local/useLocalRuntime.tsx +5 -12
- package/src/styles/tailwindcss/thread.css +1 -1
- package/src/ui/index.ts +6 -6
- package/src/ui/thread-config.tsx +1 -1
- package/src/ui/thread-list-item.tsx +24 -32
- package/src/ui/thread-list.tsx +13 -7
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.d.ts +0 -19
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.d.ts.map +0 -1
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.js +0 -87
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.js.map +0 -1
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.mjs +0 -62
- package/dist/runtimes/local/LocalThreadMetadataRuntimeCore.mjs.map +0 -1
- package/src/runtimes/local/LocalThreadMetadataRuntimeCore.tsx +0 -79
package/dist/ui/user-message.js
CHANGED
|
@@ -35,12 +35,12 @@ __export(user_message_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(user_message_exports);
|
|
37
37
|
var import_react = require("react");
|
|
38
|
-
var import_branch_picker = __toESM(require("./branch-picker.
|
|
39
|
-
var import_withDefaults = require("./utils/withDefaults.
|
|
40
|
-
var import_user_action_bar = __toESM(require("./user-action-bar.
|
|
41
|
-
var import_content_part = __toESM(require("./content-part.
|
|
42
|
-
var import_primitives = require("../primitives/index.
|
|
43
|
-
var import_attachment_ui = __toESM(require("./attachment-ui.
|
|
38
|
+
var import_branch_picker = __toESM(require("./branch-picker.js"));
|
|
39
|
+
var import_withDefaults = require("./utils/withDefaults.js");
|
|
40
|
+
var import_user_action_bar = __toESM(require("./user-action-bar.js"));
|
|
41
|
+
var import_content_part = __toESM(require("./content-part.js"));
|
|
42
|
+
var import_primitives = require("../primitives/index.js");
|
|
43
|
+
var import_attachment_ui = __toESM(require("./attachment-ui.js"));
|
|
44
44
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
45
|
var UserMessage = () => {
|
|
46
46
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(UserMessageRoot, { children: [
|
|
@@ -23,7 +23,7 @@ __export(ProxyConfigProvider_exports, {
|
|
|
23
23
|
ProxyConfigProvider: () => ProxyConfigProvider
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(ProxyConfigProvider_exports);
|
|
26
|
-
var import_ModelConfigTypes = require("../types/ModelConfigTypes.
|
|
26
|
+
var import_ModelConfigTypes = require("../types/ModelConfigTypes.js");
|
|
27
27
|
var ProxyConfigProvider = class {
|
|
28
28
|
_providers = /* @__PURE__ */ new Set();
|
|
29
29
|
getModelConfig() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCombinedStore.d.ts","sourceRoot":"","sources":["../../../src/utils/combined/createCombinedStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAE9E,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,GACtE,
|
|
1
|
+
{"version":3,"file":"createCombinedStore.d.ts","sourceRoot":"","sources":["../../../src/utils/combined/createCombinedStore.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,MAAM,CAAC,CAAC;IAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAE9E,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,GACtE,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACrC,gBAUmB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAM5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCombinedStore.d.ts","sourceRoot":"","sources":["../../../src/utils/combined/useCombinedStore.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gBAAgB,EAErB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,UAClD,GAAG,
|
|
1
|
+
{"version":3,"file":"useCombinedStore.d.ts","sourceRoot":"","sources":["../../../src/utils/combined/useCombinedStore.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gBAAgB,EAErB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,UAClD,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,YACtC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,KAC/B,CAIF,CAAC"}
|
|
@@ -24,7 +24,7 @@ __export(useCombinedStore_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(useCombinedStore_exports);
|
|
26
26
|
var import_react = require("react");
|
|
27
|
-
var import_createCombinedStore = require("./createCombinedStore.
|
|
27
|
+
var import_createCombinedStore = require("./createCombinedStore.js");
|
|
28
28
|
var useCombinedStore = (stores, selector) => {
|
|
29
29
|
const useCombined = (0, import_react.useMemo)(() => (0, import_createCombinedStore.createCombinedStore)(stores), stores);
|
|
30
30
|
return useCombined(selector);
|
|
@@ -25,7 +25,7 @@ __export(useOnResizeContent_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(useOnResizeContent_exports);
|
|
26
26
|
var import_react_use_callback_ref = require("@radix-ui/react-use-callback-ref");
|
|
27
27
|
var import_react = require("react");
|
|
28
|
-
var import_useManagedRef = require("./useManagedRef.
|
|
28
|
+
var import_useManagedRef = require("./useManagedRef.js");
|
|
29
29
|
var useOnResizeContent = (callback) => {
|
|
30
30
|
const callbackRef = (0, import_react_use_callback_ref.useCallbackRef)(callback);
|
|
31
31
|
const refCallback = (0, import_react.useCallback)(
|
|
@@ -25,7 +25,7 @@ __export(useOnScrollToBottom_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(useOnScrollToBottom_exports);
|
|
26
26
|
var import_react_use_callback_ref = require("@radix-ui/react-use-callback-ref");
|
|
27
27
|
var import_react = require("react");
|
|
28
|
-
var import_ThreadContext = require("../../context/react/ThreadContext.
|
|
28
|
+
var import_ThreadContext = require("../../context/react/ThreadContext.js");
|
|
29
29
|
var useOnScrollToBottom = (callback) => {
|
|
30
30
|
const callbackRef = (0, import_react_use_callback_ref.useCallbackRef)(callback);
|
|
31
31
|
const onScrollToBottom = (0, import_ThreadContext.useThreadViewport)((vp) => vp.onScrollToBottom);
|
|
@@ -28,8 +28,8 @@ __export(SmoothContext_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(SmoothContext_exports);
|
|
29
29
|
var import_react = require("react");
|
|
30
30
|
var import_zustand = require("zustand");
|
|
31
|
-
var import_ContentPartContext = require("../../context/react/ContentPartContext.
|
|
32
|
-
var import_createContextStoreHook = require("../../context/react/utils/createContextStoreHook.
|
|
31
|
+
var import_ContentPartContext = require("../../context/react/ContentPartContext.js");
|
|
32
|
+
var import_createContextStoreHook = require("../../context/react/utils/createContextStoreHook.js");
|
|
33
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
34
|
var SmoothContext = (0, import_react.createContext)(null);
|
|
35
35
|
var makeSmoothContext = (initialState) => {
|
|
@@ -25,9 +25,9 @@ __export(smooth_exports, {
|
|
|
25
25
|
withSmoothContextProvider: () => import_SmoothContext2.withSmoothContextProvider
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(smooth_exports);
|
|
28
|
-
var import_useSmooth = require("./useSmooth.
|
|
29
|
-
var import_SmoothContext = require("./SmoothContext.
|
|
30
|
-
var import_SmoothContext2 = require("./SmoothContext.
|
|
28
|
+
var import_useSmooth = require("./useSmooth.js");
|
|
29
|
+
var import_SmoothContext = require("./SmoothContext.js");
|
|
30
|
+
var import_SmoothContext2 = require("./SmoothContext.js");
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
32
|
0 && (module.exports = {
|
|
33
33
|
useSmooth,
|
|
@@ -25,10 +25,10 @@ __export(useSmooth_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(useSmooth_exports);
|
|
27
27
|
var import_react = require("react");
|
|
28
|
-
var import_context = require("../../context/index.
|
|
28
|
+
var import_context = require("../../context/index.js");
|
|
29
29
|
var import_react_use_callback_ref = require("@radix-ui/react-use-callback-ref");
|
|
30
|
-
var import_SmoothContext = require("./SmoothContext.
|
|
31
|
-
var import_ReadonlyStore = require("../../context/ReadonlyStore.
|
|
30
|
+
var import_SmoothContext = require("./SmoothContext.js");
|
|
31
|
+
var import_ReadonlyStore = require("../../context/ReadonlyStore.js");
|
|
32
32
|
var TextStreamAnimator = class {
|
|
33
33
|
constructor(currentText, setText) {
|
|
34
34
|
this.currentText = currentText;
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { AssistantRuntimeCore } from "../runtimes/core/AssistantRuntimeCore";
|
|
|
2
2
|
import { NestedSubscriptionSubject } from "./subscribable/NestedSubscriptionSubject";
|
|
3
3
|
import { ModelConfigProvider } from "../types/ModelConfigTypes";
|
|
4
4
|
import {
|
|
5
|
+
ThreadListItemRuntimeBinding,
|
|
5
6
|
ThreadRuntime,
|
|
6
7
|
ThreadRuntimeCoreBinding,
|
|
7
8
|
ThreadRuntimeImpl,
|
|
@@ -46,12 +47,27 @@ export class AssistantRuntimeImpl
|
|
|
46
47
|
AssistantRuntime
|
|
47
48
|
{
|
|
48
49
|
public readonly threadList;
|
|
50
|
+
public readonly _thread: ThreadRuntime;
|
|
49
51
|
|
|
50
52
|
protected constructor(
|
|
51
53
|
private readonly _core: AssistantRuntimeCore,
|
|
52
|
-
|
|
54
|
+
runtimeFactory: new (
|
|
55
|
+
binding: ThreadRuntimeCoreBinding,
|
|
56
|
+
threadListItemBinding: ThreadListItemRuntimeBinding,
|
|
57
|
+
) => ThreadRuntime = ThreadRuntimeImpl,
|
|
53
58
|
) {
|
|
54
59
|
this.threadList = new ThreadListRuntimeImpl(_core.threadList);
|
|
60
|
+
this._thread = new runtimeFactory(
|
|
61
|
+
new NestedSubscriptionSubject({
|
|
62
|
+
path: {
|
|
63
|
+
ref: "threads.main",
|
|
64
|
+
threadSelector: { type: "main" },
|
|
65
|
+
},
|
|
66
|
+
getState: () => _core.threadList.getMainThreadRuntimeCore(),
|
|
67
|
+
subscribe: (callback) => _core.threadList.subscribe(callback),
|
|
68
|
+
}),
|
|
69
|
+
this.threadList.mainThreadListItem, // TODO capture "main" threadListItem from context around useLocalRuntime / useExternalStoreRuntime
|
|
70
|
+
);
|
|
55
71
|
}
|
|
56
72
|
|
|
57
73
|
public get thread() {
|
|
@@ -70,33 +86,13 @@ export class AssistantRuntimeImpl
|
|
|
70
86
|
return this._core.registerModelConfigProvider(provider);
|
|
71
87
|
}
|
|
72
88
|
|
|
73
|
-
protected static createMainThreadRuntime(
|
|
74
|
-
_core: AssistantRuntimeCore,
|
|
75
|
-
CustomThreadRuntime: new (
|
|
76
|
-
binding: ThreadRuntimeCoreBinding,
|
|
77
|
-
) => ThreadRuntime = ThreadRuntimeImpl,
|
|
78
|
-
) {
|
|
79
|
-
return new CustomThreadRuntime(
|
|
80
|
-
new NestedSubscriptionSubject({
|
|
81
|
-
path: {
|
|
82
|
-
ref: "threads.main",
|
|
83
|
-
threadSelector: { type: "main" },
|
|
84
|
-
},
|
|
85
|
-
getState: () => _core.threadList.mainThread,
|
|
86
|
-
subscribe: (callback) => _core.threadList.subscribe(callback),
|
|
87
|
-
}),
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
89
|
public static create(
|
|
92
90
|
_core: AssistantRuntimeCore,
|
|
93
|
-
|
|
91
|
+
runtimeFactory: new (
|
|
94
92
|
binding: ThreadRuntimeCoreBinding,
|
|
93
|
+
threadListItemBinding: ThreadListItemRuntimeBinding,
|
|
95
94
|
) => ThreadRuntime = ThreadRuntimeImpl,
|
|
96
|
-
) {
|
|
97
|
-
return new AssistantRuntimeImpl(
|
|
98
|
-
_core,
|
|
99
|
-
AssistantRuntimeImpl.createMainThreadRuntime(_core, CustomThreadRuntime),
|
|
100
|
-
) as AssistantRuntime;
|
|
95
|
+
): AssistantRuntime {
|
|
96
|
+
return new AssistantRuntimeImpl(_core, runtimeFactory);
|
|
101
97
|
}
|
|
102
98
|
}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { ThreadMetadata } from "../runtimes/core/ThreadRuntimeCore";
|
|
2
1
|
import { Unsubscribe } from "../types";
|
|
3
2
|
import { ThreadListItemRuntimePath } from "./RuntimePathTypes";
|
|
4
3
|
import { SubscribableWithState } from "./subscribable/Subscribable";
|
|
5
4
|
import { ThreadListRuntimeCoreBinding } from "./ThreadListRuntime";
|
|
6
5
|
|
|
7
|
-
export type
|
|
6
|
+
export type ThreadListItemEventType = "switched-to" | "switched-away";
|
|
7
|
+
|
|
8
|
+
export type ThreadListItemState = {
|
|
8
9
|
readonly isMain: boolean;
|
|
10
|
+
|
|
11
|
+
readonly id: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated This field was renamed to `id`. This field will be removed in 0.8.0.
|
|
15
|
+
*/
|
|
16
|
+
readonly threadId: string;
|
|
17
|
+
|
|
18
|
+
readonly state: "archived" | "regular" | "new" | "deleted";
|
|
19
|
+
readonly title?: string | undefined;
|
|
9
20
|
};
|
|
10
21
|
|
|
11
22
|
export type ThreadListItemRuntime = {
|
|
@@ -19,6 +30,11 @@ export type ThreadListItemRuntime = {
|
|
|
19
30
|
delete(): Promise<void>;
|
|
20
31
|
|
|
21
32
|
subscribe(callback: () => void): Unsubscribe;
|
|
33
|
+
|
|
34
|
+
unstable_on(
|
|
35
|
+
event: ThreadListItemEventType,
|
|
36
|
+
callback: () => void,
|
|
37
|
+
): Unsubscribe;
|
|
22
38
|
};
|
|
23
39
|
|
|
24
40
|
export type ThreadListItemStateBinding = SubscribableWithState<
|
|
@@ -42,31 +58,44 @@ export class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {
|
|
|
42
58
|
|
|
43
59
|
public switchTo(): Promise<void> {
|
|
44
60
|
const state = this._core.getState();
|
|
45
|
-
return this._threadListBinding.switchToThread(state.
|
|
61
|
+
return this._threadListBinding.switchToThread(state.id);
|
|
46
62
|
}
|
|
47
63
|
|
|
48
64
|
public rename(newTitle: string): Promise<void> {
|
|
49
65
|
const state = this._core.getState();
|
|
50
66
|
|
|
51
|
-
return this._threadListBinding.rename(state.
|
|
67
|
+
return this._threadListBinding.rename(state.id, newTitle);
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
public archive(): Promise<void> {
|
|
55
71
|
const state = this._core.getState();
|
|
56
72
|
|
|
57
|
-
return this._threadListBinding.archive(state.
|
|
73
|
+
return this._threadListBinding.archive(state.id);
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
public unarchive(): Promise<void> {
|
|
61
77
|
const state = this._core.getState();
|
|
62
78
|
|
|
63
|
-
return this._threadListBinding.unarchive(state.
|
|
79
|
+
return this._threadListBinding.unarchive(state.id);
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
public delete(): Promise<void> {
|
|
67
83
|
const state = this._core.getState();
|
|
68
84
|
|
|
69
|
-
return this._threadListBinding.delete(state.
|
|
85
|
+
return this._threadListBinding.delete(state.id);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public unstable_on(event: ThreadListItemEventType, callback: () => void) {
|
|
89
|
+
let prevIsMain = this._core.getState().isMain;
|
|
90
|
+
return this.subscribe(() => {
|
|
91
|
+
const newIsMain = this._core.getState().isMain;
|
|
92
|
+
if (prevIsMain === newIsMain) return;
|
|
93
|
+
prevIsMain = newIsMain;
|
|
94
|
+
|
|
95
|
+
if (event === "switched-to" && !newIsMain) return;
|
|
96
|
+
if (event === "switched-away" && newIsMain) return;
|
|
97
|
+
callback();
|
|
98
|
+
});
|
|
70
99
|
}
|
|
71
100
|
|
|
72
101
|
public subscribe(callback: () => void): Unsubscribe {
|
|
@@ -21,6 +21,7 @@ export type ThreadListRuntime = {
|
|
|
21
21
|
|
|
22
22
|
subscribe(callback: () => void): Unsubscribe;
|
|
23
23
|
|
|
24
|
+
readonly mainThreadListItem: ThreadListItemRuntime;
|
|
24
25
|
getThreadListItemById(threadId: string): ThreadListItemRuntime;
|
|
25
26
|
getThreadListItemByIndex(idx: number): ThreadListItemRuntime;
|
|
26
27
|
getThreadListArchivedItemByIndex(idx: number): ThreadListItemRuntime;
|
|
@@ -30,10 +31,10 @@ const getThreadListState = (
|
|
|
30
31
|
threadList: ThreadListRuntimeCore,
|
|
31
32
|
): ThreadListState => {
|
|
32
33
|
return {
|
|
33
|
-
mainThreadId: threadList.
|
|
34
|
-
newThread: threadList.
|
|
35
|
-
threads: threadList.
|
|
36
|
-
archivedThreads: threadList.
|
|
34
|
+
mainThreadId: threadList.mainThreadId,
|
|
35
|
+
newThread: threadList.newThreadId,
|
|
36
|
+
threads: threadList.threadIds,
|
|
37
|
+
archivedThreads: threadList.archivedThreadIds,
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
|
|
@@ -43,13 +44,14 @@ const getThreadListItemState = (
|
|
|
43
44
|
): ThreadListItemState | SKIP_UPDATE => {
|
|
44
45
|
if (threadId === undefined) return SKIP_UPDATE;
|
|
45
46
|
|
|
46
|
-
const threadData = threadList.
|
|
47
|
+
const threadData = threadList.getItemById(threadId);
|
|
47
48
|
if (!threadData) return SKIP_UPDATE;
|
|
48
49
|
return {
|
|
49
|
-
|
|
50
|
+
id: threadData.threadId,
|
|
51
|
+
threadId: threadData.threadId, // TODO remove in 0.8.0
|
|
50
52
|
title: threadData.title,
|
|
51
53
|
state: threadData.state,
|
|
52
|
-
isMain:
|
|
54
|
+
isMain: threadData.threadId === threadList.mainThreadId,
|
|
53
55
|
};
|
|
54
56
|
};
|
|
55
57
|
|
|
@@ -65,6 +67,20 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
this._getState = stateBinding.getState.bind(stateBinding);
|
|
70
|
+
|
|
71
|
+
this._mainThreadListItemRuntime = new ThreadListItemRuntimeImpl(
|
|
72
|
+
new ShallowMemoizeSubject({
|
|
73
|
+
path: {
|
|
74
|
+
ref: `threadItems[main]`,
|
|
75
|
+
threadSelector: { type: "main" },
|
|
76
|
+
},
|
|
77
|
+
getState: () => {
|
|
78
|
+
return getThreadListItemState(this._core, this._core.mainThreadId);
|
|
79
|
+
},
|
|
80
|
+
subscribe: (callback) => this._core.subscribe(callback),
|
|
81
|
+
}),
|
|
82
|
+
this._core,
|
|
83
|
+
);
|
|
68
84
|
}
|
|
69
85
|
|
|
70
86
|
public getState(): ThreadListState {
|
|
@@ -75,6 +91,12 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
|
75
91
|
return this._core.subscribe(callback);
|
|
76
92
|
}
|
|
77
93
|
|
|
94
|
+
private _mainThreadListItemRuntime;
|
|
95
|
+
|
|
96
|
+
public get mainThreadListItem() {
|
|
97
|
+
return this._mainThreadListItemRuntime;
|
|
98
|
+
}
|
|
99
|
+
|
|
78
100
|
public getThreadListItemByIndex(idx: number) {
|
|
79
101
|
return new ThreadListItemRuntimeImpl(
|
|
80
102
|
new ShallowMemoizeSubject({
|
|
@@ -83,7 +105,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
|
83
105
|
threadSelector: { type: "index", index: idx },
|
|
84
106
|
},
|
|
85
107
|
getState: () => {
|
|
86
|
-
return getThreadListItemState(this._core, this._core.
|
|
108
|
+
return getThreadListItemState(this._core, this._core.threadIds[idx]);
|
|
87
109
|
},
|
|
88
110
|
subscribe: (callback) => this._core.subscribe(callback),
|
|
89
111
|
}),
|
|
@@ -101,7 +123,7 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
|
101
123
|
getState: () => {
|
|
102
124
|
return getThreadListItemState(
|
|
103
125
|
this._core,
|
|
104
|
-
this._core.
|
|
126
|
+
this._core.archivedThreadIds[idx],
|
|
105
127
|
);
|
|
106
128
|
},
|
|
107
129
|
subscribe: (callback) => this._core.subscribe(callback),
|
package/src/api/ThreadRuntime.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
ThreadRuntimeCore,
|
|
5
5
|
SpeechState,
|
|
6
6
|
ThreadRuntimeEventType,
|
|
7
|
-
ThreadMetadata,
|
|
8
7
|
} from "../runtimes/core/ThreadRuntimeCore";
|
|
9
8
|
import { ExportedMessageRepository } from "../runtimes/utils/MessageRepository";
|
|
10
9
|
import {
|
|
@@ -30,7 +29,12 @@ import {
|
|
|
30
29
|
} from "./ComposerRuntime";
|
|
31
30
|
import { LazyMemoizeSubject } from "./subscribable/LazyMemoizeSubject";
|
|
32
31
|
import { SKIP_UPDATE } from "./subscribable/SKIP_UPDATE";
|
|
33
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
MessageRuntimePath,
|
|
34
|
+
ThreadListItemRuntimePath,
|
|
35
|
+
ThreadRuntimePath,
|
|
36
|
+
} from "./RuntimePathTypes";
|
|
37
|
+
import { ThreadListItemState } from "./ThreadListItemRuntime";
|
|
34
38
|
|
|
35
39
|
export type CreateAppendMessage =
|
|
36
40
|
| string
|
|
@@ -74,17 +78,24 @@ export type ThreadRuntimeCoreBinding = SubscribableWithState<
|
|
|
74
78
|
outerSubscribe(callback: () => void): Unsubscribe;
|
|
75
79
|
};
|
|
76
80
|
|
|
81
|
+
export type ThreadListItemRuntimeBinding = SubscribableWithState<
|
|
82
|
+
ThreadListItemState,
|
|
83
|
+
ThreadListItemRuntimePath
|
|
84
|
+
>;
|
|
85
|
+
|
|
77
86
|
export type ThreadState = {
|
|
78
87
|
/**
|
|
79
88
|
* The thread ID.
|
|
80
|
-
* @deprecated This field is deprecated and will be removed in 0.8.0. Use `
|
|
89
|
+
* @deprecated This field is deprecated and will be removed in 0.8.0. Use `useThreadListItem().id` instead.
|
|
81
90
|
*/
|
|
82
91
|
readonly threadId: string;
|
|
83
92
|
|
|
84
93
|
/**
|
|
85
94
|
* The thread metadata.
|
|
95
|
+
*
|
|
96
|
+
* @deprecated Use `useThreadListItem()` instead. This field is deprecated and will be removed in 0.8.0.
|
|
86
97
|
*/
|
|
87
|
-
readonly metadata:
|
|
98
|
+
readonly metadata: ThreadListItemState;
|
|
88
99
|
|
|
89
100
|
/**
|
|
90
101
|
* Whether the thread is disabled. Disabled threads cannot receive new messages.
|
|
@@ -122,11 +133,14 @@ export type ThreadState = {
|
|
|
122
133
|
readonly speech: SpeechState | undefined;
|
|
123
134
|
};
|
|
124
135
|
|
|
125
|
-
export const getThreadState = (
|
|
136
|
+
export const getThreadState = (
|
|
137
|
+
runtime: ThreadRuntimeCore,
|
|
138
|
+
threadListItemState: ThreadListItemState,
|
|
139
|
+
): ThreadState => {
|
|
126
140
|
const lastMessage = runtime.messages.at(-1);
|
|
127
141
|
return Object.freeze({
|
|
128
|
-
threadId:
|
|
129
|
-
metadata:
|
|
142
|
+
threadId: threadListItemState.id,
|
|
143
|
+
metadata: threadListItemState,
|
|
130
144
|
capabilities: runtime.capabilities,
|
|
131
145
|
isDisabled: runtime.isDisabled,
|
|
132
146
|
isRunning:
|
|
@@ -208,11 +222,25 @@ export class ThreadRuntimeImpl implements ThreadRuntime {
|
|
|
208
222
|
getStateState(): ThreadState;
|
|
209
223
|
};
|
|
210
224
|
|
|
211
|
-
constructor(
|
|
225
|
+
constructor(
|
|
226
|
+
threadBinding: ThreadRuntimeCoreBinding,
|
|
227
|
+
threadListItemBinding: ThreadListItemRuntimeBinding,
|
|
228
|
+
) {
|
|
212
229
|
const stateBinding = new LazyMemoizeSubject({
|
|
213
230
|
path: threadBinding.path,
|
|
214
|
-
getState: () =>
|
|
215
|
-
|
|
231
|
+
getState: () =>
|
|
232
|
+
getThreadState(
|
|
233
|
+
threadBinding.getState(),
|
|
234
|
+
threadListItemBinding.getState(),
|
|
235
|
+
),
|
|
236
|
+
subscribe: (callback) => {
|
|
237
|
+
const sub1 = threadBinding.subscribe(callback);
|
|
238
|
+
const sub2 = threadListItemBinding.subscribe(callback);
|
|
239
|
+
return () => {
|
|
240
|
+
sub1();
|
|
241
|
+
sub2();
|
|
242
|
+
};
|
|
243
|
+
},
|
|
216
244
|
});
|
|
217
245
|
|
|
218
246
|
this._threadBinding = {
|
|
@@ -61,7 +61,10 @@ export const AssistantRuntimeProviderImpl: FC<
|
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
63
|
<AssistantContext.Provider value={context}>
|
|
64
|
-
<ThreadRuntimeProvider
|
|
64
|
+
<ThreadRuntimeProvider
|
|
65
|
+
runtime={runtime.thread}
|
|
66
|
+
listItemRuntime={runtime.threadList.mainThreadListItem}
|
|
67
|
+
>
|
|
65
68
|
{children}
|
|
66
69
|
</ThreadRuntimeProvider>
|
|
67
70
|
</AssistantContext.Provider>
|
|
@@ -7,8 +7,11 @@ import { writableStore } from "../ReadonlyStore";
|
|
|
7
7
|
import { ThreadRuntime } from "../../api/ThreadRuntime";
|
|
8
8
|
import { create } from "zustand";
|
|
9
9
|
import { ThreadComposerRuntime } from "../../api/ComposerRuntime";
|
|
10
|
+
import { ThreadListItemRuntime } from "../../api/ThreadListItemRuntime";
|
|
11
|
+
import { ThreadListItemRuntimeProvider } from "./ThreadListItemRuntimeProvider";
|
|
10
12
|
|
|
11
13
|
type ThreadProviderProps = {
|
|
14
|
+
listItemRuntime: ThreadListItemRuntime;
|
|
12
15
|
runtime: ThreadRuntime;
|
|
13
16
|
};
|
|
14
17
|
|
|
@@ -49,7 +52,7 @@ const useThreadComposerStore = (runtime: ThreadComposerRuntime) => {
|
|
|
49
52
|
|
|
50
53
|
export const ThreadRuntimeProvider: FC<
|
|
51
54
|
PropsWithChildren<ThreadProviderProps>
|
|
52
|
-
> = ({ children, runtime }) => {
|
|
55
|
+
> = ({ children, listItemRuntime: threadListItemRuntime, runtime }) => {
|
|
53
56
|
const useThreadRuntime = useThreadRuntimeStore(runtime);
|
|
54
57
|
const useThread = useThreadStore(runtime);
|
|
55
58
|
const useThreadComposer = useThreadComposerStore(runtime.composer);
|
|
@@ -66,6 +69,10 @@ export const ThreadRuntimeProvider: FC<
|
|
|
66
69
|
}, [useThread, useThreadRuntime, useThreadComposer]);
|
|
67
70
|
|
|
68
71
|
return (
|
|
69
|
-
<
|
|
72
|
+
<ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>
|
|
73
|
+
<ThreadContext.Provider value={context}>
|
|
74
|
+
{children}
|
|
75
|
+
</ThreadContext.Provider>
|
|
76
|
+
</ThreadListItemRuntimeProvider>
|
|
70
77
|
);
|
|
71
78
|
};
|
package/src/internal.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { AssistantRuntimeImpl } from "./api/AssistantRuntime";
|
|
|
10
10
|
export {
|
|
11
11
|
ThreadRuntimeImpl,
|
|
12
12
|
type ThreadRuntimeCoreBinding,
|
|
13
|
+
type ThreadListItemRuntimeBinding,
|
|
13
14
|
} from "./api/ThreadRuntime";
|
|
14
|
-
export { LocalThreadMetadataRuntimeCore } from "./runtimes/local/LocalThreadMetadataRuntimeCore";
|
|
15
15
|
|
|
16
16
|
export * from "./utils/smooth";
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import { useThread, useThreadRuntime } from "../../context/react/ThreadContext";
|
|
21
21
|
import { useEscapeKeydown } from "@radix-ui/react-use-escape-keydown";
|
|
22
22
|
import { useOnScrollToBottom } from "../../utils/hooks/useOnScrollToBottom";
|
|
23
|
+
import { useThreadListItemRuntime } from "../../context/react/ThreadListItemContext";
|
|
23
24
|
|
|
24
25
|
export namespace ComposerPrimitiveInput {
|
|
25
26
|
export type Element = HTMLTextAreaElement;
|
|
@@ -53,6 +54,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
53
54
|
},
|
|
54
55
|
forwardedRef,
|
|
55
56
|
) => {
|
|
57
|
+
const threadListItemRuntime = useThreadListItemRuntime();
|
|
56
58
|
const threadRuntime = useThreadRuntime();
|
|
57
59
|
const composerRuntime = useComposerRuntime();
|
|
58
60
|
|
|
@@ -124,7 +126,7 @@ export const ComposerPrimitiveInput = forwardRef<
|
|
|
124
126
|
if (composerRuntime.type !== "thread" || !unstable_focusOnThreadSwitched)
|
|
125
127
|
return undefined;
|
|
126
128
|
|
|
127
|
-
return
|
|
129
|
+
return threadListItemRuntime.unstable_on("switched-to", focus);
|
|
128
130
|
}, [unstable_focusOnThreadSwitched]);
|
|
129
131
|
|
|
130
132
|
return (
|
|
@@ -31,7 +31,7 @@ export const ThreadListPrimitiveNew = forwardRef<
|
|
|
31
31
|
return (
|
|
32
32
|
<Primitive.button
|
|
33
33
|
type="button"
|
|
34
|
-
{...(isMain ? { "data-active": "true" } : null)}
|
|
34
|
+
{...(isMain ? { "data-active": "true", "aria-current": "true" } : null)}
|
|
35
35
|
{...props}
|
|
36
36
|
ref={forwardedRef}
|
|
37
37
|
disabled={disabled || !callback}
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
RuntimeCapabilities,
|
|
18
18
|
SubmittedFeedback,
|
|
19
19
|
ThreadRuntimeEventType,
|
|
20
|
-
ThreadMetadataRuntimeCore,
|
|
21
20
|
} from "../core/ThreadRuntimeCore";
|
|
22
21
|
import { DefaultEditComposerRuntimeCore } from "../composer/DefaultEditComposerRuntimeCore";
|
|
23
22
|
import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
|
|
@@ -46,20 +45,13 @@ export abstract class BaseThreadRuntimeCore implements ThreadRuntimeCore {
|
|
|
46
45
|
public abstract addToolResult(options: AddToolResultOptions): void;
|
|
47
46
|
public abstract cancelRun(): void;
|
|
48
47
|
|
|
49
|
-
public get metadata() {
|
|
50
|
-
return this._metadata;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
public get messages() {
|
|
54
49
|
return this.repository.getMessages();
|
|
55
50
|
}
|
|
56
51
|
|
|
57
52
|
public readonly composer = new DefaultThreadComposerRuntimeCore(this);
|
|
58
53
|
|
|
59
|
-
constructor(
|
|
60
|
-
private readonly _configProvider: ModelConfigProvider,
|
|
61
|
-
private readonly _metadata: ThreadMetadataRuntimeCore,
|
|
62
|
-
) {}
|
|
54
|
+
constructor(private readonly _configProvider: ModelConfigProvider) {}
|
|
63
55
|
|
|
64
56
|
public getModelConfig() {
|
|
65
57
|
return this._configProvider.getModelConfig();
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
import { Unsubscribe } from "../../types";
|
|
2
|
-
import {
|
|
2
|
+
import { ThreadRuntimeCore } from "./ThreadRuntimeCore";
|
|
3
|
+
|
|
4
|
+
type ThreadListItemCoreState = {
|
|
5
|
+
readonly threadId: string;
|
|
6
|
+
readonly state: "archived" | "regular" | "new" | "deleted";
|
|
7
|
+
readonly title?: string | undefined;
|
|
8
|
+
|
|
9
|
+
readonly runtime?: ThreadRuntimeCore | undefined;
|
|
10
|
+
};
|
|
3
11
|
|
|
4
12
|
export type ThreadListRuntimeCore = {
|
|
5
|
-
|
|
13
|
+
mainThreadId: string;
|
|
14
|
+
newThreadId: string | undefined;
|
|
6
15
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
archivedThreads: readonly string[];
|
|
16
|
+
threadIds: readonly string[];
|
|
17
|
+
archivedThreadIds: readonly string[];
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
getMainThreadRuntimeCore(): ThreadRuntimeCore;
|
|
20
|
+
getItemById(threadId: string): ThreadListItemCoreState | undefined;
|
|
12
21
|
|
|
13
22
|
switchToThread(threadId: string): Promise<void>;
|
|
14
23
|
switchToNewThread(): Promise<void>;
|
|
15
24
|
|
|
16
25
|
// getLoadThreadsPromise(): Promise<void>;
|
|
17
26
|
// getLoadArchivedThreadsPromise(): Promise<void>;
|
|
18
|
-
|
|
27
|
+
|
|
19
28
|
rename(threadId: string, newTitle: string): Promise<void>;
|
|
20
29
|
archive(threadId: string): Promise<void>;
|
|
21
30
|
unarchive(threadId: string): Promise<void>;
|