@assistant-ui/react-native 0.1.32 → 0.1.34

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.
Files changed (28) hide show
  1. package/dist/index.d.ts +3 -3
  2. package/dist/index.js +2 -2
  3. package/dist/primitives/attachment/AttachmentRemove.js +3 -3
  4. package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
  5. package/dist/primitives/attachment/AttachmentThumb.js +30 -16
  6. package/dist/primitives/attachment/AttachmentThumb.js.map +1 -1
  7. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +3 -3
  8. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
  9. package/dist/primitives/composer/ComposerInput.js +3 -3
  10. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  11. package/dist/primitives/message/MessageContent.d.ts.map +1 -1
  12. package/dist/primitives/message/MessageContent.js +4 -8
  13. package/dist/primitives/message/MessageContent.js.map +1 -1
  14. package/dist/primitives/thread/ThreadMessages.js +1 -1
  15. package/dist/primitives/thread/ThreadMessages.js.map +1 -1
  16. package/package.json +6 -6
  17. package/src/index.ts +2 -0
  18. package/src/primitives/attachment/AttachmentRemove.test.tsx +2 -3
  19. package/src/primitives/attachment/AttachmentRemove.tsx +1 -1
  20. package/src/primitives/attachment/AttachmentThumb.test.tsx +25 -10
  21. package/src/primitives/attachment/AttachmentThumb.tsx +12 -5
  22. package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.test.tsx +4 -3
  23. package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx +1 -1
  24. package/src/primitives/composer/ComposerInput.test.tsx +5 -6
  25. package/src/primitives/composer/ComposerInput.tsx +3 -3
  26. package/src/primitives/message/MessageContent.test.tsx +17 -17
  27. package/src/primitives/message/MessageContent.tsx +4 -9
  28. package/src/primitives/thread/ThreadMessages.tsx +1 -1
package/dist/index.d.ts CHANGED
@@ -13,9 +13,9 @@ import { threadListItem_d_exports } from "./primitives/threadListItem.js";
13
13
  import { chainOfThought_d_exports } from "./primitives/chainOfThought.js";
14
14
  import { suggestion_d_exports } from "./primitives/suggestion.js";
15
15
  import { index_d_exports } from "./primitives/error/index.js";
16
- import { AppendMessage, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, CompleteAttachment, ComposerRuntime, CompositeAttachmentAdapter, CreateAttachment, DataMessagePart, EditComposerRuntime, ExportedMessageRepository, ExportedMessageRepositoryItem, FeedbackAdapter, FileMessagePart, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, MessageRole, MessageRuntime, MessageStatus, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PendingAttachment, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, RemoteThreadListOptions, RespondToToolApprovalOptions, RunConfig, RuntimeCapabilities, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SuggestionAdapter, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListRuntime, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_InteractableSnapshotEntry, Unstable_InteractableVersion, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, createVoiceSession, fromThreadMessageLike, generateId, mergeModelContexts, tool, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
17
- import { AssistantClient, AssistantEventCallback, AssistantEventName, AssistantEventPayload, AssistantEventScope, AssistantEventSelector, AssistantState, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
16
+ import { AppendMessage, AssistantRuntime, Attachment, AttachmentAdapter, AttachmentRuntime, ChatModelAdapter, ChatModelRunOptions, ChatModelRunResult, CompleteAttachment, ComposerRuntime, CompositeAttachmentAdapter, CreateAttachment, DataMessagePart, EditComposerRuntime, ExportedMessageRepository, ExportedMessageRepositoryItem, FeedbackAdapter, FileMessagePart, ImageMessagePart, InMemoryThreadListAdapter, LanguageModelConfig, LanguageModelV1CallSettings, MessageRole, MessageRuntime, MessageStatus, ModelContext, ModelContextProvider, ModelContextRegistry, ModelContextRegistryInstructionHandle, ModelContextRegistryProviderHandle, ModelContextRegistryToolHandle, PendingAttachment, RealtimeVoiceAdapter, ReasoningMessagePart, RemoteThreadListAdapter, RemoteThreadListOptions, RemoteThreadListProviderComponent, RespondToToolApprovalOptions, RunConfig, RuntimeCapabilities, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SourceMessagePart, SuggestionAdapter, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadComposerRuntime, ThreadHistoryAdapter, ThreadListItemRuntime, ThreadListRuntime, ThreadMessage, ThreadMessageLike, ThreadRuntime, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, Unstable_InteractableSnapshotEntry, Unstable_InteractableVersion, Unsubscribe, VoiceSessionControls, VoiceSessionHelpers, createVoiceSession, fromThreadMessageLike, generateId, mergeModelContexts, tool, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
17
+ import { AssistantClient, AssistantEventCallback, AssistantEventName, AssistantEventPayload, AssistantEventScope, AssistantEventSelector, AssistantState, AuiConfig, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
18
18
  import { AssistantContextConfig, AssistantDataUI, AssistantDataUIProps, AssistantInteractableProps, AssistantTool, AssistantToolProps, AssistantToolUI, AssistantToolUIProps, ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ComposerAttachmentByIndexProvider, DataMessagePartComponent, DataMessagePartProps, DataRenderers, EmptyMessagePartComponent, EmptyMessagePartProps, FileMessagePartComponent, FileMessagePartProps, GroupByContext, ImageMessagePartComponent, ImageMessagePartProps, Interactables, McpToolkitDefinition, McpToolkitEntry, McpToolkitToolConfig, MessageAttachmentByIndexProvider, MessageByIndexProvider, PartByIndexProvider, ProviderToolConfig, ReasoningGroupComponent, ReasoningGroupProps, ReasoningMessagePartComponent, ReasoningMessagePartProps, RuntimeAdapterProvider, RuntimeAdapters, SourceMessagePartComponent, SourceMessagePartProps, SuggestionByIndexProvider, TextMessagePartComponent, TextMessagePartProps, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemRuntimeProvider, ToolArgsStatus, ToolCallMessagePartComponent, ToolCallMessagePartProps, ToolCallText, ToolDefinition, Toolkit, ToolkitDefinition, ToolkitDefinitionEntry, Tools, Unstable_AudioMessagePartComponent, Unstable_AudioMessagePartProps, Unstable_InferInteractableState, Unstable_InteractableConfig, Unstable_InteractableDefinition, Unstable_InteractablePersistedState, Unstable_InteractablePersistenceAdapter, Unstable_InteractablePersistenceStatus, Unstable_InteractableRegistration, Unstable_InteractableStateSchema, Unstable_InteractableToolConfig, Unstable_InteractableToolRenderProps, Unstable_InteractableVersionInfo, Unstable_InteractablesClientSchema, Unstable_InteractablesConfig, Unstable_InteractablesMethods, Unstable_InteractablesState, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, unstable_Interactables, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
19
19
  import { AttachmentState, ChainOfThoughtClient, ComposerState, MessageState, ModelContext as ModelContextClient, SuggestionConfig, Suggestions, ThreadListItemState, ThreadState, ThreadsState } from "@assistant-ui/core/store";
20
20
  import { Tool } from "assistant-stream";
21
- export { actionBar_d_exports as ActionBarPrimitive, type AppendMessage, type AssistantClient, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, type AssistantInteractableProps, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, ChainOfThoughtPartByIndexProvider, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerState, CompositeAttachmentAdapter, type CreateAttachment, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, type EditComposerRuntime, type EmptyMessagePartComponent, type EmptyMessagePartProps, index_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type GroupByContext, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadListAdapter, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type McpToolkitDefinition, type McpToolkitEntry, type McpToolkitToolConfig, MessageAttachmentByIndexProvider, MessageByIndexProvider, message_d_exports as MessagePrimitive, type MessageRole, type MessageRuntime, type MessageState, type MessageStatus, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PendingAttachment, type ProviderToolConfig, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, type RemoteThreadListOptions, type RespondToToolApprovalOptions, type RunConfig, RuntimeAdapterProvider, type RuntimeAdapters, type RuntimeCapabilities, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadsState, type Tool, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartProps, type ToolCallText, type ToolCallTiming, type ToolDefinition, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_InferInteractableState, type Unstable_InteractableConfig, type Unstable_InteractableDefinition, type Unstable_InteractablePersistedState, type Unstable_InteractablePersistenceAdapter, type Unstable_InteractablePersistenceStatus, type Unstable_InteractableRegistration, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableStateSchema, type Unstable_InteractableToolConfig, type Unstable_InteractableToolRenderProps, type Unstable_InteractableVersion, type Unstable_InteractableVersionInfo, type Unstable_InteractablesClientSchema, type Unstable_InteractablesConfig, type Unstable_InteractablesMethods, type Unstable_InteractablesState, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, mergeModelContexts, providerTool, stubTool, tool, unstable_Interactables, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useInlineRender, useInteractableState, useLocalRuntime, useRemoteThreadListRuntime, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
21
+ export { actionBar_d_exports as ActionBarPrimitive, type AppendMessage, type AssistantClient, type AssistantContextConfig, type AssistantDataUI, type AssistantDataUIProps, type AssistantEventCallback, type AssistantEventName, type AssistantEventPayload, type AssistantEventScope, type AssistantEventSelector, type AssistantInteractableProps, type AssistantRuntime, AssistantRuntimeProvider, type AssistantState, type AssistantTool, type AssistantToolProps, type AssistantToolUI, type AssistantToolUIProps, type Attachment, type AttachmentAdapter, attachment_d_exports as AttachmentPrimitive, type AttachmentRuntime, type AttachmentState, AuiConfig, AuiIf, AuiProvider, branchPicker_d_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, ChainOfThoughtPartByIndexProvider, chainOfThought_d_exports as ChainOfThoughtPrimitive, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type CompleteAttachment, ComposerAttachmentByIndexProvider, composer_d_exports as ComposerPrimitive, type ComposerRuntime, type ComposerState, CompositeAttachmentAdapter, type CreateAttachment, type DataMessagePart, type DataMessagePartComponent, type DataMessagePartProps, DataRenderers, type EditComposerRuntime, type EmptyMessagePartComponent, type EmptyMessagePartProps, index_d_exports as ErrorPrimitive, ExportedMessageRepository, type ExportedMessageRepositoryItem, type FeedbackAdapter, type FileMessagePart, type FileMessagePartComponent, type FileMessagePartProps, type GroupByContext, type ImageMessagePart, type ImageMessagePartComponent, type ImageMessagePartProps, InMemoryThreadListAdapter, Interactables, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptions, type McpToolkitDefinition, type McpToolkitEntry, type McpToolkitToolConfig, MessageAttachmentByIndexProvider, MessageByIndexProvider, message_d_exports as MessagePrimitive, type MessageRole, type MessageRuntime, type MessageState, type MessageStatus, type ModelContext, ModelContextClient, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, PartByIndexProvider, type PendingAttachment, type ProviderToolConfig, type RealtimeVoiceAdapter, type ReasoningGroupComponent, type ReasoningGroupProps, type ReasoningMessagePart, type ReasoningMessagePartComponent, type ReasoningMessagePartProps, type RemoteThreadListAdapter, type RemoteThreadListOptions, type RemoteThreadListProviderComponent, type RespondToToolApprovalOptions, type RunConfig, RuntimeAdapterProvider, type RuntimeAdapters, type RuntimeCapabilities, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SourceMessagePart, type SourceMessagePartComponent, type SourceMessagePartProps, type SuggestionAdapter, SuggestionByIndexProvider, type SuggestionConfig, suggestion_d_exports as SuggestionPrimitive, Suggestions, type TextMessagePart, type TextMessagePartComponent, type TextMessagePartProps, TextMessagePartProvider, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadHistoryAdapter, ThreadListItemByIndexProvider, threadListItem_d_exports as ThreadListItemPrimitive, type ThreadListItemRuntime, ThreadListItemRuntimeProvider, type ThreadListItemState, threadList_d_exports as ThreadListPrimitive, type ThreadListRuntime, type ThreadMessage, type ThreadMessageLike, thread_d_exports as ThreadPrimitive, type ThreadRuntime, type ThreadState, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ThreadsState, type Tool, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolArgsStatus, type ToolCallMessagePart, type ToolCallMessagePartComponent, type ToolCallMessagePartProps, type ToolCallText, type ToolCallTiming, type ToolDefinition, type ToolModelContentPart, type Toolkit, type ToolkitDefinition, type ToolkitDefinitionEntry, Tools, type Unstable_AudioMessagePart, type Unstable_AudioMessagePartComponent, type Unstable_AudioMessagePartProps, type Unstable_InferInteractableState, type Unstable_InteractableConfig, type Unstable_InteractableDefinition, type Unstable_InteractablePersistedState, type Unstable_InteractablePersistenceAdapter, type Unstable_InteractablePersistenceStatus, type Unstable_InteractableRegistration, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableStateSchema, type Unstable_InteractableToolConfig, type Unstable_InteractableToolRenderProps, type Unstable_InteractableVersion, type Unstable_InteractableVersionInfo, type Unstable_InteractablesClientSchema, type Unstable_InteractablesConfig, type Unstable_InteractablesMethods, type Unstable_InteractablesState, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, mergeModelContexts, providerTool, stubTool, tool, unstable_Interactables, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useInlineRender, useInteractableState, useLocalRuntime, useRemoteThreadListRuntime, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import { chainOfThought_exports } from "./primitives/chainOfThought.js";
13
13
  import { suggestion_exports } from "./primitives/suggestion.js";
14
14
  import { error_exports } from "./primitives/error/index.js";
15
15
  import { CompositeAttachmentAdapter, ExportedMessageRepository, InMemoryThreadListAdapter, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, createVoiceSession, fromThreadMessageLike, generateId, mergeModelContexts, tool, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions } from "@assistant-ui/core";
16
- import { AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
16
+ import { AuiConfig, AuiIf, AuiProvider, useAui, useAuiEvent, useAuiState } from "@assistant-ui/store";
17
17
  import { ChainOfThoughtByIndicesProvider, ChainOfThoughtPartByIndexProvider, ComposerAttachmentByIndexProvider, DataRenderers, Interactables, MessageAttachmentByIndexProvider, MessageByIndexProvider, PartByIndexProvider, RuntimeAdapterProvider, SuggestionByIndexProvider, TextMessagePartProvider, ThreadListItemByIndexProvider, ThreadListItemRuntimeProvider, Tools, defineMcpToolkit, defineToolkit, externalTool, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, providerTool, stubTool, unstable_Interactables, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAuiToolOverrides, useInlineRender, useInteractableState, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume } from "@assistant-ui/core/react";
18
18
  import { ChainOfThoughtClient, ModelContext as ModelContextClient, Suggestions } from "@assistant-ui/core/store";
19
- export { actionBar_exports as ActionBarPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, ChainOfThoughtPartByIndexProvider, chainOfThought_exports as ChainOfThoughtPrimitive, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, error_exports as ErrorPrimitive, ExportedMessageRepository, InMemoryThreadListAdapter, Interactables, MessageAttachmentByIndexProvider, MessageByIndexProvider, message_exports as MessagePrimitive, ModelContextClient, ModelContextRegistry, PartByIndexProvider, RuntimeAdapterProvider, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, mergeModelContexts, providerTool, stubTool, tool, unstable_Interactables, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useInlineRender, useInteractableState, useLocalRuntime, useRemoteThreadListRuntime, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
19
+ export { actionBar_exports as ActionBarPrimitive, AssistantRuntimeProvider, attachment_exports as AttachmentPrimitive, AuiConfig, AuiIf, AuiProvider, branchPicker_exports as BranchPickerPrimitive, ChainOfThoughtByIndicesProvider, ChainOfThoughtClient, ChainOfThoughtPartByIndexProvider, chainOfThought_exports as ChainOfThoughtPrimitive, ComposerAttachmentByIndexProvider, composer_exports as ComposerPrimitive, CompositeAttachmentAdapter, DataRenderers, error_exports as ErrorPrimitive, ExportedMessageRepository, InMemoryThreadListAdapter, Interactables, MessageAttachmentByIndexProvider, MessageByIndexProvider, message_exports as MessagePrimitive, ModelContextClient, ModelContextRegistry, PartByIndexProvider, RuntimeAdapterProvider, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, SuggestionByIndexProvider, suggestion_exports as SuggestionPrimitive, Suggestions, TextMessagePartProvider, ThreadListItemByIndexProvider, threadListItem_exports as ThreadListItemPrimitive, ThreadListItemRuntimeProvider, threadList_exports as ThreadListPrimitive, thread_exports as ThreadPrimitive, Tools, createVoiceSession, defineMcpToolkit, defineToolkit, externalTool, fromThreadMessageLike, generateId, groupPartByType, hitl, hitlTool, humanTool, makeAssistantDataUI, makeAssistantTool, makeAssistantToolUI, mergeModelContexts, providerTool, stubTool, tool, unstable_Interactables, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions, unstable_interactableTool, unstable_useInteractable, unstable_useInteractableState, unstable_useInteractableVersions, unstable_useThreadMessageIds, useAssistantContext, useAssistantDataUI, useAssistantInstructions, useAssistantInteractable, useAssistantTool, useAssistantToolUI, useAui, useAuiEvent, useAuiState, useAuiToolOverrides, useInlineRender, useInteractableState, useLocalRuntime, useRemoteThreadListRuntime, useRuntimeAdapters, useToolArgsStatus, useVoiceControls, useVoiceState, useVoiceVolume };
@@ -19,11 +19,11 @@ const AttachmentRemove = (t0) => {
19
19
  }
20
20
  const aui = useAui();
21
21
  let t1;
22
- if ($[3] !== aui) {
22
+ if ($[3] !== aui.attachment) {
23
23
  t1 = () => {
24
- aui.attachment().remove();
24
+ aui.attachment.remove();
25
25
  };
26
- $[3] = aui;
26
+ $[3] = aui.attachment;
27
27
  $[4] = t1;
28
28
  } else t1 = $[4];
29
29
  const handleRemove = t1;
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentRemove.js","names":["ReactNode","useCallback","Pressable","PressableProps","useAui","AttachmentRemoveProps","Omit","children","AttachmentRemove","t0","$","_c","pressableProps","aui","t1","attachment","remove","handleRemove","t2"],"sources":["../../../src/primitives/attachment/AttachmentRemove.tsx"],"sourcesContent":["import { type ReactNode, useCallback } from \"react\";\nimport { Pressable, type PressableProps } from \"react-native\";\n\nimport { useAui } from \"@assistant-ui/store\";\n\nexport type AttachmentRemoveProps = Omit<PressableProps, \"onPress\"> & {\n children: ReactNode;\n};\n\nexport const AttachmentRemove = ({\n children,\n ...pressableProps\n}: AttachmentRemoveProps) => {\n const aui = useAui();\n\n const handleRemove = useCallback(() => {\n aui.attachment().remove();\n }, [aui]);\n\n return (\n <Pressable onPress={handleRemove} {...pressableProps}>\n {children}\n </Pressable>\n );\n};\n"],"mappings":";;;;;;AASA,MAAaQ,oBAAmBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAJ;CAAA,IAAAK;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAF,aAAAK,kBAAAH;EAGTC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAE;CAAA,OAAA;EAAAL,WAAAG,EAAA;EAAAE,iBAAAF,EAAA;CAAA;CACtB,MAAAG,MAAYT,OAAO;CAAE,IAAAU;CAAA,IAAAJ,EAAA,OAAAG,KAAA;EAEYC,WAAA;GAC/BD,IAAGE,WAAY,CAAC,CAAAC,OAAQ;EAAC;EAC1BN,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAFD,MAAAO,eAAqBH;CAEX,IAAAI;CAAA,IAAAR,EAAA,OAAAH,YAAAG,EAAA,OAAAO,gBAAAP,EAAA,OAAAE,gBAAA;EAGRM,KAAA,oBAAC,WAAD;GAAoBD,SAAAA;GAAY,GAAML;GACnCL;EADO,CAAA;EAEEG,EAAA,KAAAH;EAAAG,EAAA,KAAAO;EAAAP,EAAA,KAAAE;EAAAF,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAFZQ;AAEY"}
1
+ {"version":3,"file":"AttachmentRemove.js","names":["ReactNode","useCallback","Pressable","PressableProps","useAui","AttachmentRemoveProps","Omit","children","AttachmentRemove","t0","$","_c","pressableProps","aui","t1","attachment","remove","handleRemove","t2"],"sources":["../../../src/primitives/attachment/AttachmentRemove.tsx"],"sourcesContent":["import { type ReactNode, useCallback } from \"react\";\nimport { Pressable, type PressableProps } from \"react-native\";\n\nimport { useAui } from \"@assistant-ui/store\";\n\nexport type AttachmentRemoveProps = Omit<PressableProps, \"onPress\"> & {\n children: ReactNode;\n};\n\nexport const AttachmentRemove = ({\n children,\n ...pressableProps\n}: AttachmentRemoveProps) => {\n const aui = useAui();\n\n const handleRemove = useCallback(() => {\n aui.attachment.remove();\n }, [aui]);\n\n return (\n <Pressable onPress={handleRemove} {...pressableProps}>\n {children}\n </Pressable>\n );\n};\n"],"mappings":";;;;;;AASA,MAAaQ,oBAAmBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAJ;CAAA,IAAAK;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAF,aAAAK,kBAAAH;EAGTC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAE;CAAA,OAAA;EAAAL,WAAAG,EAAA;EAAAE,iBAAAF,EAAA;CAAA;CACtB,MAAAG,MAAYT,OAAO;CAAE,IAAAU;CAAA,IAAAJ,EAAA,OAAAG,IAAAE,YAAA;EAEYD,WAAA;GAC/BD,IAAGE,WAAWC,OAAQ;EAAC;EACxBN,EAAA,KAAAG,IAAAE;EAAAL,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAFD,MAAAO,eAAqBH;CAEX,IAAAI;CAAA,IAAAR,EAAA,OAAAH,YAAAG,EAAA,OAAAO,gBAAAP,EAAA,OAAAE,gBAAA;EAGRM,KAAA,oBAAC,WAAD;GAAoBD,SAAAA;GAAY,GAAML;GACnCL;EADO,CAAA;EAEEG,EAAA,KAAAH;EAAAG,EAAA,KAAAO;EAAAP,EAAA,KAAAE;EAAAF,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,OAFZQ;AAEY"}
@@ -1,26 +1,40 @@
1
1
  import { useAuiState } from "@assistant-ui/store";
2
2
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
3
3
  import { Text } from "react-native";
4
- import { jsxs } from "react/jsx-runtime";
4
+ import { jsx } from "react/jsx-runtime";
5
5
  //#region src/primitives/attachment/AttachmentThumb.tsx
6
- const AttachmentThumb = (props) => {
7
- const $ = c(3);
8
- const ext = useAuiState(_temp);
9
- let t0;
10
- if ($[0] !== ext || $[1] !== props) {
11
- t0 = /* @__PURE__ */ jsxs(Text, {
12
- ...props,
13
- children: [".", ext]
6
+ const AttachmentThumb = (t0) => {
7
+ const $ = c(6);
8
+ let children;
9
+ let textProps;
10
+ if ($[0] !== t0) {
11
+ ({children, ...textProps} = t0);
12
+ $[0] = t0;
13
+ $[1] = children;
14
+ $[2] = textProps;
15
+ } else {
16
+ children = $[1];
17
+ textProps = $[2];
18
+ }
19
+ const label = useAuiState(_temp);
20
+ const t1 = children ?? label;
21
+ let t2;
22
+ if ($[3] !== t1 || $[4] !== textProps) {
23
+ t2 = /* @__PURE__ */ jsx(Text, {
24
+ ...textProps,
25
+ children: t1
14
26
  });
15
- $[0] = ext;
16
- $[1] = props;
17
- $[2] = t0;
18
- } else t0 = $[2];
19
- return t0;
27
+ $[3] = t1;
28
+ $[4] = textProps;
29
+ $[5] = t2;
30
+ } else t2 = $[5];
31
+ return t2;
20
32
  };
21
33
  function _temp(s) {
22
- const parts = s.attachment.name.split(".");
23
- return parts.length > 1 ? parts.pop() : "";
34
+ const name = s.attachment.name;
35
+ const dot = name.lastIndexOf(".");
36
+ if (dot > 0 && dot < name.length - 1) return `.${name.slice(dot + 1)}`;
37
+ return s.attachment.type;
24
38
  }
25
39
  //#endregion
26
40
  export { AttachmentThumb };
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentThumb.js","names":["FC","Text","TextProps","useAuiState","AttachmentThumbProps","AttachmentThumb","props","$","_c","ext","_temp","t0","s","parts","attachment","name","split","length","pop"],"sources":["../../../src/primitives/attachment/AttachmentThumb.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { Text, type TextProps } from \"react-native\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport type AttachmentThumbProps = TextProps;\n\nexport const AttachmentThumb: FC<AttachmentThumbProps> = (props) => {\n const ext = useAuiState((s) => {\n const parts = s.attachment.name.split(\".\");\n return parts.length > 1 ? parts.pop()! : \"\";\n });\n return <Text {...props}>.{ext}</Text>;\n};\n"],"mappings":";;;;;AAMA,MAAaK,mBAA4CC,UAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACvD,MAAAC,MAAYN,YAAYO,KAGvB;CAAE,IAAAC;CAAA,IAAAJ,EAAA,OAAAE,OAAAF,EAAA,OAAAD,OAAA;EACIK,KAAA,qBAAC,MAAD;GAAK,GAAKL;GAAV,UAAA,CAAiB,KAAEG,GAAd;;EAAyBF,EAAA,KAAAE;EAAAF,EAAA,KAAAD;EAAAC,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAA9BI;AAA8B;AALkB,SAAAD,MAAAE,GAAA;CAErD,MAAAC,QAAcD,EAACE,WAAWC,KAAKC,MAAO,GAAG;CAAE,OACpCH,MAAKI,SAAU,IAAIJ,MAAKK,IAAW,IAAnC;AAAoC"}
1
+ {"version":3,"file":"AttachmentThumb.js","names":["FC","Text","TextProps","useAuiState","AttachmentThumbProps","AttachmentThumb","t0","$","_c","children","textProps","label","_temp","t1","t2","s","name","attachment","dot","lastIndexOf","length","slice","type"],"sources":["../../../src/primitives/attachment/AttachmentThumb.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { Text, type TextProps } from \"react-native\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\nexport type AttachmentThumbProps = TextProps;\n\nexport const AttachmentThumb: FC<AttachmentThumbProps> = ({\n children,\n ...textProps\n}) => {\n const label = useAuiState((s) => {\n const name = s.attachment.name;\n const dot = name.lastIndexOf(\".\");\n if (dot > 0 && dot < name.length - 1) {\n return `.${name.slice(dot + 1)}`;\n }\n return s.attachment.type;\n });\n return <Text {...textProps}>{children ?? label}</Text>;\n};\n"],"mappings":";;;;;AAMA,MAAaK,mBAA4CC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAG,aAAAC,aAAAJ;EAGzDC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAD,WAAAF,EAAA;EAAAG,YAAAH,EAAA;CAAA;CACC,MAAAI,QAAcR,YAAYS,KAOzB;CAC4B,MAAAC,KAAAJ,YAAAE;CAAiB,IAAAG;CAAA,IAAAP,EAAA,OAAAM,MAAAN,EAAA,OAAAG,WAAA;EAAvCI,KAAA,oBAAC,MAAD;GAAK,GAAKJ;GAAYG,UAAAA;EAAjB,CAAA;EAA0CN,EAAA,KAAAM;EAAAN,EAAA,KAAAG;EAAAH,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAAA,OAA/CO;AAA+C;AAZC,SAAAF,MAAAG,GAAA;CAKrD,MAAAC,OAAaD,EAACE,WAAWD;CACzB,MAAAE,MAAYF,KAAIG,YAAa,GAAG;CAChC,IAAID,MAAM,KAAKA,MAAMF,KAAII,SAAU,GAAC,OAC3B,IAAIJ,KAAIK,MAAOH,MAAM,CAAC;CAC9B,OACMH,EAACE,WAAWK;AAAK"}
@@ -20,11 +20,11 @@ const ChainOfThoughtAccordionTrigger = (t0) => {
20
20
  const aui = useAui();
21
21
  const collapsed = useAuiState(_temp);
22
22
  let t1;
23
- if ($[3] !== aui || $[4] !== collapsed) {
23
+ if ($[3] !== aui.chainOfThought || $[4] !== collapsed) {
24
24
  t1 = () => {
25
- aui.chainOfThought().setCollapsed(!collapsed);
25
+ aui.chainOfThought.setCollapsed(!collapsed);
26
26
  };
27
- $[3] = aui;
27
+ $[3] = aui.chainOfThought;
28
28
  $[4] = collapsed;
29
29
  $[5] = t1;
30
30
  } else t1 = $[5];
@@ -1 +1 @@
1
- {"version":3,"file":"ChainOfThoughtAccordionTrigger.js","names":["useCallback","ReactNode","Pressable","PressableProps","useAuiState","useAui","ChainOfThoughtAccordionTriggerProps","Omit","children","ChainOfThoughtAccordionTrigger","t0","$","_c","pressableProps","aui","collapsed","_temp","t1","chainOfThought","setCollapsed","onPress","t2","s"],"sources":["../../../src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx"],"sourcesContent":["import { useCallback, type ReactNode } from \"react\";\nimport { Pressable, type PressableProps } from \"react-native\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\n\nexport type ChainOfThoughtAccordionTriggerProps = Omit<\n PressableProps,\n \"onPress\"\n> & {\n children: ReactNode;\n};\n\nexport const ChainOfThoughtAccordionTrigger = ({\n children,\n ...pressableProps\n}: ChainOfThoughtAccordionTriggerProps) => {\n const aui = useAui();\n const collapsed = useAuiState((s) => s.chainOfThought.collapsed);\n\n const onPress = useCallback(() => {\n aui.chainOfThought().setCollapsed(!collapsed);\n }, [aui, collapsed]);\n\n return (\n <Pressable onPress={onPress} {...pressableProps}>\n {children}\n </Pressable>\n );\n};\n"],"mappings":";;;;;;AAWA,MAAaS,kCAAiCC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAJ;CAAA,IAAAK;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAF,aAAAK,kBAAAH;EAGTC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAE;CAAA,OAAA;EAAAL,WAAAG,EAAA;EAAAE,iBAAAF,EAAA;CAAA;CACpC,MAAAG,MAAYT,OAAO;CACnB,MAAAU,YAAkBX,YAAYY,KAAiC;CAAE,IAAAC;CAAA,IAAAN,EAAA,OAAAG,OAAAH,EAAA,OAAAI,WAAA;EAErCE,WAAA;GAC1BH,IAAGI,eAAgB,CAAC,CAAAC,aAAc,CAACJ,SAAS;EAAC;EAC9CJ,EAAA,KAAAG;EAAAH,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAFD,MAAAS,UAAgBH;CAEK,IAAAI;CAAA,IAAAV,EAAA,OAAAH,YAAAG,EAAA,OAAAS,WAAAT,EAAA,OAAAE,gBAAA;EAGnBQ,KAAA,oBAAC,WAAD;GAAoBD;GAAO,GAAMP;GAC9BL;EADO,CAAA;EAEEG,EAAA,KAAAH;EAAAG,EAAA,KAAAS;EAAAT,EAAA,KAAAE;EAAAF,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFZU;AAEY;AAd8B,SAAAL,MAAAM,GAAA;CAAA,OAKPA,EAACJ,eAAeH;AAAU"}
1
+ {"version":3,"file":"ChainOfThoughtAccordionTrigger.js","names":["useCallback","ReactNode","Pressable","PressableProps","useAuiState","useAui","ChainOfThoughtAccordionTriggerProps","Omit","children","ChainOfThoughtAccordionTrigger","t0","$","_c","pressableProps","aui","collapsed","_temp","t1","chainOfThought","setCollapsed","onPress","t2","s"],"sources":["../../../src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx"],"sourcesContent":["import { useCallback, type ReactNode } from \"react\";\nimport { Pressable, type PressableProps } from \"react-native\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\n\nexport type ChainOfThoughtAccordionTriggerProps = Omit<\n PressableProps,\n \"onPress\"\n> & {\n children: ReactNode;\n};\n\nexport const ChainOfThoughtAccordionTrigger = ({\n children,\n ...pressableProps\n}: ChainOfThoughtAccordionTriggerProps) => {\n const aui = useAui();\n const collapsed = useAuiState((s) => s.chainOfThought.collapsed);\n\n const onPress = useCallback(() => {\n aui.chainOfThought.setCollapsed(!collapsed);\n }, [aui, collapsed]);\n\n return (\n <Pressable onPress={onPress} {...pressableProps}>\n {children}\n </Pressable>\n );\n};\n"],"mappings":";;;;;;AAWA,MAAaS,kCAAiCC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAJ;CAAA,IAAAK;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAAC,CAAA,CAAAF,aAAAK,kBAAAH;EAGTC,EAAA,KAAAD;EAAAC,EAAA,KAAAH;EAAAG,EAAA,KAAAE;CAAA,OAAA;EAAAL,WAAAG,EAAA;EAAAE,iBAAAF,EAAA;CAAA;CACpC,MAAAG,MAAYT,OAAO;CACnB,MAAAU,YAAkBX,YAAYY,KAAiC;CAAE,IAAAC;CAAA,IAAAN,EAAA,OAAAG,IAAAI,kBAAAP,EAAA,OAAAI,WAAA;EAErCE,WAAA;GAC1BH,IAAGI,eAAeC,aAAc,CAACJ,SAAS;EAAC;EAC5CJ,EAAA,KAAAG,IAAAI;EAAAP,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAFD,MAAAS,UAAgBH;CAEK,IAAAI;CAAA,IAAAV,EAAA,OAAAH,YAAAG,EAAA,OAAAS,WAAAT,EAAA,OAAAE,gBAAA;EAGnBQ,KAAA,oBAAC,WAAD;GAAoBD;GAAO,GAAMP;GAC9BL;EADO,CAAA;EAEEG,EAAA,KAAAH;EAAAG,EAAA,KAAAS;EAAAT,EAAA,KAAAE;EAAAF,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,OAFZU;AAEY;AAd8B,SAAAL,MAAAM,GAAA;CAAA,OAKPA,EAACJ,eAAeH;AAAU"}
@@ -58,11 +58,11 @@ const ComposerInput = (t0) => {
58
58
  t2 = (value) => {
59
59
  if (Platform.OS === "web") {
60
60
  flushTapSync(() => {
61
- aui.composer().setText(value);
61
+ aui.composer.setText(value);
62
62
  });
63
63
  return;
64
64
  }
65
- aui.composer().setText(value);
65
+ aui.composer.setText(value);
66
66
  };
67
67
  $[6] = aui;
68
68
  $[7] = t2;
@@ -92,7 +92,7 @@ const ComposerInput = (t0) => {
92
92
  if (nativeEvent.isComposing || nativeEvent.keyCode === 229) return;
93
93
  if (nativeEvent.key === "Enter" && !nativeEvent.shiftKey) {
94
94
  e.preventDefault?.();
95
- aui.composer().send();
95
+ aui.composer.send();
96
96
  }
97
97
  };
98
98
  $[11] = aui;
@@ -1 +1 @@
1
- {"version":3,"file":"ComposerInput.js","names":["useCallback","useEffect","useRef","Platform","TextInput","NativeSyntheticEvent","TextInputKeyPressEventData","TextInputProps","useAui","useAuiState","flushTapSync","ComposerInputProps","Omit","submitMode","getWebTextareaMaxHeight","el","HTMLTextAreaElement","computedMaxHeight","globalThis","getComputedStyle","maxHeight","parsedComputedMaxHeight","Number","parseFloat","isFinite","inlineMaxHeight","style","adjustWebTextareaHeight","ref","React","RefObject","OS","current","rows","overflowX","overflowY","height","scrollHeight","needsScrollbar","nextHeight","Math","min","ComposerInput","t0","$","_c","numberOfLines","onKeyPressProp","props","t1","onKeyPress","undefined","aui","text","_temp","inputRef","t2","value","composer","setText","onChangeText","t3","Symbol","for","t4","t5","e","nativeEvent","shiftKey","isComposing","keyCode","key","Event","preventDefault","send","t6","t7","s"],"sources":["../../../src/primitives/composer/ComposerInput.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef } from \"react\";\nimport {\n Platform,\n TextInput,\n type NativeSyntheticEvent,\n type TextInputKeyPressEventData,\n type TextInputProps,\n} from \"react-native\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\n\nexport type ComposerInputProps = Omit<\n TextInputProps,\n \"value\" | \"onChangeText\"\n> & {\n /**\n * Controls how the Enter key submits messages (web only).\n * - \"enter\": Plain Enter submits (Shift+Enter for newline)\n * - \"none\": Enter inserts newline (no keyboard submission)\n * @default \"enter\"\n */\n submitMode?: \"enter\" | \"none\";\n};\n\nconst getWebTextareaMaxHeight = (el: HTMLTextAreaElement) => {\n const computedMaxHeight = globalThis.getComputedStyle?.(el).maxHeight;\n const parsedComputedMaxHeight = Number.parseFloat(computedMaxHeight ?? \"\");\n if (Number.isFinite(parsedComputedMaxHeight)) return parsedComputedMaxHeight;\n\n const inlineMaxHeight = Number.parseFloat(el.style.maxHeight);\n return Number.isFinite(inlineMaxHeight) ? inlineMaxHeight : null;\n};\n\nconst adjustWebTextareaHeight = (ref: React.RefObject<TextInput | null>) => {\n if (Platform.OS !== \"web\") return;\n // On web, the TextInput ref IS the DOM element\n const el = ref.current as unknown as HTMLTextAreaElement | null;\n if (!el) return;\n // Ensure rows=1 so scrollHeight reflects actual content\n if (el.rows !== 1) el.rows = 1;\n\n el.style.overflowX = \"hidden\";\n el.style.overflowY = \"hidden\";\n el.style.height = \"auto\";\n\n const scrollHeight = el.scrollHeight;\n const maxHeight = getWebTextareaMaxHeight(el);\n const needsScrollbar = maxHeight !== null && scrollHeight > maxHeight;\n const nextHeight =\n maxHeight === null ? scrollHeight : Math.min(scrollHeight, maxHeight);\n\n el.style.overflowY = needsScrollbar ? \"auto\" : \"hidden\";\n el.style.height = `${nextHeight}px`;\n};\n\nexport const ComposerInput = ({\n submitMode = \"enter\",\n onKeyPress: onKeyPressProp,\n numberOfLines,\n style,\n ...props\n}: ComposerInputProps) => {\n const aui = useAui();\n const text = useAuiState((s) => s.composer.text);\n const inputRef = useRef<TextInput>(null);\n\n const onChangeText = useCallback(\n (value: string) => {\n if (Platform.OS === \"web\") {\n // Keep the controlled value in sync mid-IME so react-dom does not reset the textarea to a stale value\n flushTapSync(() => {\n aui.composer().setText(value);\n });\n return;\n }\n aui.composer().setText(value);\n },\n [aui],\n );\n\n // Auto-resize textarea on web when text changes\n useEffect(() => {\n void text; // trigger re-run when text changes\n adjustWebTextareaHeight(inputRef);\n }, [text]);\n\n const onKeyPress = useCallback(\n (e: NativeSyntheticEvent<TextInputKeyPressEventData>) => {\n onKeyPressProp?.(e);\n\n if (Platform.OS !== \"web\") return;\n if (submitMode !== \"enter\") return;\n\n const nativeEvent = e.nativeEvent as TextInputKeyPressEventData & {\n shiftKey?: boolean;\n isComposing?: boolean;\n keyCode?: number;\n };\n // react-native-web forwards the raw DOM keydown before its own composition guard, so re-check it here (mirrors isEventComposing)\n if (nativeEvent.isComposing || nativeEvent.keyCode === 229) return;\n if (nativeEvent.key === \"Enter\" && !nativeEvent.shiftKey) {\n (e as unknown as Event).preventDefault?.();\n aui.composer().send();\n }\n },\n [aui, submitMode, onKeyPressProp],\n );\n\n return (\n <TextInput\n ref={inputRef}\n value={text}\n onChangeText={onChangeText}\n onKeyPress={onKeyPress}\n numberOfLines={numberOfLines ?? (Platform.OS === \"web\" ? 1 : undefined)}\n style={style}\n {...props}\n />\n );\n};\n"],"mappings":";;;;;;;AAwBA,MAAMc,2BAA2BC,OAA4B;CAC3D,MAAME,oBAAoBC,WAAWC,mBAAmBJ,EAAE,CAAC,CAACK;CAC5D,MAAMC,0BAA0BC,OAAOC,WAAWN,qBAAqB,EAAE;CACzE,IAAIK,OAAOE,SAASH,uBAAuB,GAAG,OAAOA;CAErD,MAAMI,kBAAkBH,OAAOC,WAAWR,GAAGW,MAAMN,SAAS;CAC5D,OAAOE,OAAOE,SAASC,eAAe,IAAIA,kBAAkB;AAC9D;AAEA,MAAME,2BAA2BC,QAA2C;CAC1E,IAAIzB,SAAS4B,OAAO,OAAO;CAE3B,MAAMhB,KAAKa,IAAII;CACf,IAAI,CAACjB,IAAI;CAET,IAAIA,GAAGkB,SAAS,GAAGlB,GAAGkB,OAAO;CAE7BlB,GAAGW,MAAMQ,YAAY;CACrBnB,GAAGW,MAAMS,YAAY;CACrBpB,GAAGW,MAAMU,SAAS;CAElB,MAAMC,eAAetB,GAAGsB;CACxB,MAA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,EAAA,MAAAgB;EAAAhB,EAAA,MAAAM;EAAAN,EAAA,MAAAI;EAAAJ,EAAA,MAAAlB;EAAAkB,EAAA,MAAA+B;EAAA/B,EAAA,MAAAS;EAAAT,EAAA,MAAAgC;CAAA,OAAAA,KAAAhC,EAAA;CAAA,OARFgC;AAQE;AA9DuB,SAAAtB,MAAAuB,GAAA;CAAA,OAQKA,EAACnB,SAASL;AAAK"}
1
+ {"version":3,"file":"ComposerInput.js","names":["useCallback","useEffect","useRef","Platform","TextInput","NativeSyntheticEvent","TextInputKeyPressEventData","TextInputProps","useAui","useAuiState","flushTapSync","ComposerInputProps","Omit","submitMode","getWebTextareaMaxHeight","el","HTMLTextAreaElement","computedMaxHeight","globalThis","getComputedStyle","maxHeight","parsedComputedMaxHeight","Number","parseFloat","isFinite","inlineMaxHeight","style","adjustWebTextareaHeight","ref","React","RefObject","OS","current","rows","overflowX","overflowY","height","scrollHeight","needsScrollbar","nextHeight","Math","min","ComposerInput","t0","$","_c","numberOfLines","onKeyPressProp","props","t1","onKeyPress","undefined","aui","text","_temp","inputRef","t2","value","composer","setText","onChangeText","t3","Symbol","for","t4","t5","e","nativeEvent","shiftKey","isComposing","keyCode","key","Event","preventDefault","send","t6","t7","s"],"sources":["../../../src/primitives/composer/ComposerInput.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef } from \"react\";\nimport {\n Platform,\n TextInput,\n type NativeSyntheticEvent,\n type TextInputKeyPressEventData,\n type TextInputProps,\n} from \"react-native\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\n\nexport type ComposerInputProps = Omit<\n TextInputProps,\n \"value\" | \"onChangeText\"\n> & {\n /**\n * Controls how the Enter key submits messages (web only).\n * - \"enter\": Plain Enter submits (Shift+Enter for newline)\n * - \"none\": Enter inserts newline (no keyboard submission)\n * @default \"enter\"\n */\n submitMode?: \"enter\" | \"none\";\n};\n\nconst getWebTextareaMaxHeight = (el: HTMLTextAreaElement) => {\n const computedMaxHeight = globalThis.getComputedStyle?.(el).maxHeight;\n const parsedComputedMaxHeight = Number.parseFloat(computedMaxHeight ?? \"\");\n if (Number.isFinite(parsedComputedMaxHeight)) return parsedComputedMaxHeight;\n\n const inlineMaxHeight = Number.parseFloat(el.style.maxHeight);\n return Number.isFinite(inlineMaxHeight) ? inlineMaxHeight : null;\n};\n\nconst adjustWebTextareaHeight = (ref: React.RefObject<TextInput | null>) => {\n if (Platform.OS !== \"web\") return;\n // On web, the TextInput ref IS the DOM element\n const el = ref.current as unknown as HTMLTextAreaElement | null;\n if (!el) return;\n // Ensure rows=1 so scrollHeight reflects actual content\n if (el.rows !== 1) el.rows = 1;\n\n el.style.overflowX = \"hidden\";\n el.style.overflowY = \"hidden\";\n el.style.height = \"auto\";\n\n const scrollHeight = el.scrollHeight;\n const maxHeight = getWebTextareaMaxHeight(el);\n const needsScrollbar = maxHeight !== null && scrollHeight > maxHeight;\n const nextHeight =\n maxHeight === null ? scrollHeight : Math.min(scrollHeight, maxHeight);\n\n el.style.overflowY = needsScrollbar ? \"auto\" : \"hidden\";\n el.style.height = `${nextHeight}px`;\n};\n\nexport const ComposerInput = ({\n submitMode = \"enter\",\n onKeyPress: onKeyPressProp,\n numberOfLines,\n style,\n ...props\n}: ComposerInputProps) => {\n const aui = useAui();\n const text = useAuiState((s) => s.composer.text);\n const inputRef = useRef<TextInput>(null);\n\n const onChangeText = useCallback(\n (value: string) => {\n if (Platform.OS === \"web\") {\n // Keep the controlled value in sync mid-IME so react-dom does not reset the textarea to a stale value\n flushTapSync(() => {\n aui.composer.setText(value);\n });\n return;\n }\n aui.composer.setText(value);\n },\n [aui],\n );\n\n // Auto-resize textarea on web when text changes\n useEffect(() => {\n void text; // trigger re-run when text changes\n adjustWebTextareaHeight(inputRef);\n }, [text]);\n\n const onKeyPress = useCallback(\n (e: NativeSyntheticEvent<TextInputKeyPressEventData>) => {\n onKeyPressProp?.(e);\n\n if (Platform.OS !== \"web\") return;\n if (submitMode !== \"enter\") return;\n\n const nativeEvent = e.nativeEvent as TextInputKeyPressEventData & {\n shiftKey?: boolean;\n isComposing?: boolean;\n keyCode?: number;\n };\n // react-native-web forwards the raw DOM keydown before its own composition guard, so re-check it here (mirrors isEventComposing)\n if (nativeEvent.isComposing || nativeEvent.keyCode === 229) return;\n if (nativeEvent.key === \"Enter\" && !nativeEvent.shiftKey) {\n (e as unknown as Event).preventDefault?.();\n aui.composer.send();\n }\n },\n [aui, submitMode, onKeyPressProp],\n );\n\n return (\n <TextInput\n ref={inputRef}\n value={text}\n onChangeText={onChangeText}\n onKeyPress={onKeyPress}\n numberOfLines={numberOfLines ?? (Platform.OS === \"web\" ? 1 : undefined)}\n style={style}\n {...props}\n />\n );\n};\n"],"mappings":";;;;;;;AAwBA,MAAMc,2BAA2BC,OAA4B;CAC3D,MAAME,oBAAoBC,WAAWC,mBAAmBJ,EAAE,CAAC,CAACK;CAC5D,MAAMC,0BAA0BC,OAAOC,WAAWN,qBAAqB,EAAE;CACzE,IAAIK,OAAOE,SAASH,uBAAuB,GAAG,OAAOA;CAErD,MAAMI,kBAAkBH,OAAOC,WAAWR,GAAGW,MAAMN,SAAS;CAC5D,OAAOE,OAAOE,SAASC,eAAe,IAAIA,kBAAkB;AAC9D;AAEA,MAAME,2BAA2BC,QAA2C;CAC1E,IAAIzB,SAAS4B,OAAO,OAAO;CAE3B,MAAMhB,KAAKa,IAAII;CACf,IAAI,CAACjB,IAAI;CAET,IAAIA,GAAGkB,SAAS,GAAGlB,GAAGkB,OAAO;CAE7BlB,GAAGW,MAAMQ,YAAY;CACrBnB,GAAGW,MAAMS,YAAY;CACrBpB,GAAGW,MAAMU,SAAS;CAElB,MAAMC,eAAetB,GAAGsB;CACxB,MAAMjB,YAAYN,wBAAwBC,EAAE;CAC5C,MAAMuB,iBAAiBlB,cAAc,QAAQiB,eAAejB;CAC5D,MAAMmB,aACJnB,cAAc,OAAOiB,eAAeG,KAAKC,IAAIJ,cAAcjB,SAAS;CAE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;AA9DuB,SAAAtB,MAAAuB,GAAA;CAAA,OAQKA,EAACnB,SAASL;AAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"MessageContent.d.ts","names":[],"sources":["../../../src/primitives/message/MessageContent.tsx"],"mappings":";;;KAcK,qBAAqB,wBAAwB;KAEtC;EACV,cAAc;IACZ,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,kBAAkB;IAChB,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,eAAe;IACb,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,mBAAmB;IACjB,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,gBAAgB;IACd,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,cAAc;IACZ,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,cAAc;IACZ,MAAM,QAAQ;MAAsB;;IACpC;QACI;;cAqEK,mBAAkB,YAAA,gBAAA,aAAA,iBAAA,cAAA,YAAA,cAQ5B,wCAAmB,IAAA"}
1
+ {"version":3,"file":"MessageContent.d.ts","names":[],"sources":["../../../src/primitives/message/MessageContent.tsx"],"mappings":";;;KAcK,qBAAqB,wBAAwB;KAEtC;EACV,cAAc;IACZ,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,kBAAkB;IAChB,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,eAAe;IACb,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,mBAAmB;IACjB,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,gBAAgB;IACd,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,cAAc;IACZ,MAAM,QAAQ;MAAsB;;IACpC;QACI;EACN,cAAc;IACZ,MAAM,QAAQ;MAAsB;;IACpC;QACI;;cAgEK,mBAAkB,YAAA,gBAAA,aAAA,iBAAA,cAAA,YAAA,cAQ5B,wCAAmB,IAAA"}
@@ -21,19 +21,15 @@ const ToolUIDisplay = (t0) => {
21
21
  const aui = useAui();
22
22
  let t1;
23
23
  if ($[0] !== part.toolName) {
24
- t1 = (s) => {
25
- const renders = s.tools.tools[part.toolName];
26
- if (Array.isArray(renders)) return renders[0];
27
- return renders;
28
- };
24
+ t1 = (s) => s.tools.toolUIs[part.toolName]?.[0]?.render;
29
25
  $[0] = part.toolName;
30
26
  $[1] = t1;
31
27
  } else t1 = $[1];
32
28
  const Render = useAuiState(t1);
33
29
  let t2;
34
- if ($[2] !== aui || $[3] !== index) {
35
- t2 = aui.message().part({ index });
36
- $[2] = aui;
30
+ if ($[2] !== aui.message || $[3] !== index) {
31
+ t2 = aui.message.part({ index });
32
+ $[2] = aui.message;
37
33
  $[3] = index;
38
34
  $[4] = t2;
39
35
  } else t2 = $[4];
@@ -1 +1 @@
1
- {"version":3,"file":"MessageContent.js","names":["ReactElement","Fragment","useMemo","Text","ThreadUserMessagePart","ThreadAssistantMessagePart","ToolCallMessagePart","DataMessagePart","useAui","useAuiState","ToolCallMessagePartProps","DataMessagePartProps","MessageContentPart","MessageContentProps","renderText","props","part","Extract","type","index","renderToolCall","renderImage","renderReasoning","renderSource","renderFile","renderData","DefaultTextRenderer","t0","$","_c","t1","text","ToolUIDisplay","Fallback","aui","toolName","s","renders","tools","Array","isArray","Render","t2","message","partMethods","t3","t4","addToolResult","respondToToolApproval","resumeToolCall","DataUIDisplay","name","dataRenderers","renderers","MessageContent","content","_temp","key","map"],"sources":["../../../src/primitives/message/MessageContent.tsx"],"sourcesContent":["import { type ReactElement, Fragment, useMemo } from \"react\";\nimport { Text } from \"react-native\";\nimport type {\n ThreadUserMessagePart,\n ThreadAssistantMessagePart,\n ToolCallMessagePart,\n DataMessagePart,\n} from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type {\n ToolCallMessagePartProps,\n DataMessagePartProps,\n} from \"@assistant-ui/core/react\";\n\ntype MessageContentPart = ThreadUserMessagePart | ThreadAssistantMessagePart;\n\nexport type MessageContentProps = {\n renderText?: (props: {\n part: Extract<MessageContentPart, { type: \"text\" }>;\n index: number;\n }) => ReactElement;\n renderToolCall?: (props: {\n part: Extract<MessageContentPart, { type: \"tool-call\" }>;\n index: number;\n }) => ReactElement;\n renderImage?: (props: {\n part: Extract<MessageContentPart, { type: \"image\" }>;\n index: number;\n }) => ReactElement;\n renderReasoning?: (props: {\n part: Extract<MessageContentPart, { type: \"reasoning\" }>;\n index: number;\n }) => ReactElement;\n renderSource?: (props: {\n part: Extract<MessageContentPart, { type: \"source\" }>;\n index: number;\n }) => ReactElement;\n renderFile?: (props: {\n part: Extract<MessageContentPart, { type: \"file\" }>;\n index: number;\n }) => ReactElement;\n renderData?: (props: {\n part: Extract<MessageContentPart, { type: \"data\" }>;\n index: number;\n }) => ReactElement;\n};\n\nconst DefaultTextRenderer = ({\n part,\n}: {\n part: Extract<MessageContentPart, { type: \"text\" }>;\n}) => {\n return <Text>{part.text}</Text>;\n};\n\nconst ToolUIDisplay = ({\n Fallback,\n part,\n index,\n}: {\n Fallback:\n | ((props: { part: ToolCallMessagePart; index: number }) => ReactElement)\n | undefined;\n part: ToolCallMessagePart;\n index: number;\n}) => {\n const aui = useAui();\n const Render = useAuiState((s) => {\n const renders = s.tools.tools[part.toolName];\n if (Array.isArray(renders)) return renders[0];\n return renders;\n });\n\n const partMethods = useMemo(\n () => aui.message().part({ index }),\n [aui, index],\n );\n\n if (Render) {\n return (\n <Render\n {...(part as ToolCallMessagePartProps)}\n addResult={partMethods.addToolResult}\n resume={partMethods.resumeToolCall}\n respondToApproval={partMethods.respondToToolApproval}\n />\n );\n }\n if (Fallback) return <Fallback part={part} index={index} />;\n return null;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n part,\n index,\n}: {\n Fallback:\n | ((props: { part: DataMessagePart; index: number }) => ReactElement)\n | undefined;\n part: DataMessagePart;\n index: number;\n}) => {\n const Render = useAuiState((s) => {\n const renders = s.dataRenderers.renderers[part.name];\n if (Array.isArray(renders)) return renders[0];\n return renders;\n });\n if (Render) return <Render {...(part as DataMessagePartProps)} />;\n if (Fallback) return <Fallback part={part} index={index} />;\n return null;\n};\n\nexport const MessageContent = ({\n renderText,\n renderToolCall,\n renderImage,\n renderReasoning,\n renderSource,\n renderFile,\n renderData,\n}: MessageContentProps) => {\n const content = useAuiState((s) => s.message.content);\n\n return (\n <>\n {content.map((part, index) => {\n const key = `${part.type}-${index}`;\n switch (part.type) {\n case \"text\":\n return (\n <Fragment key={key}>\n {renderText ? (\n renderText({ part, index })\n ) : (\n <DefaultTextRenderer part={part} />\n )}\n </Fragment>\n );\n case \"tool-call\":\n return (\n <Fragment key={key}>\n <ToolUIDisplay\n Fallback={renderToolCall}\n part={part}\n index={index}\n />\n </Fragment>\n );\n case \"image\":\n if (!renderImage) return null;\n return (\n <Fragment key={key}>{renderImage({ part, index })}</Fragment>\n );\n case \"reasoning\":\n if (!renderReasoning) return null;\n return (\n <Fragment key={key}>{renderReasoning({ part, index })}</Fragment>\n );\n case \"source\":\n if (!renderSource) return null;\n return (\n <Fragment key={key}>{renderSource({ part, index })}</Fragment>\n );\n case \"file\":\n if (!renderFile) return null;\n return <Fragment key={key}>{renderFile({ part, index })}</Fragment>;\n case \"data\":\n return (\n <Fragment key={key}>\n <DataUIDisplay\n Fallback={renderData}\n part={part}\n index={index}\n />\n </Fragment>\n );\n default:\n return null;\n }\n })}\n </>\n );\n};\n"],"mappings":";;;;;;AA+CA,MAAM0B,uBAAsBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAb,SAAAW;CAI5B,IAAAG;CAAA,IAAAF,EAAA,OAAAZ,KAAAe,MAAA;EACQD,KAAA,oBAAC,MAAD,EAAA,UAAOd,KAAIe,KAAN,CAAA;EAAmBH,EAAA,KAAAZ,KAAAe;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAAxBE;AAAwB;AAGjC,MAAME,iBAAgBL,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAI,UAAAjB,MAAAG,UAA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,oBAAC,YAAD,EAAA,UAAqBA,aAAa;OAAAP;OAAAG;MAAc,CAAC,EAAxC,GAAMsC,GAAN;KAAqD,KAE7D;MACH,IAAI,CAACjC,YAAU,OAAS;MAAK,OACtB,oBAAC,YAAD,EAAA,UAAqBA,WAAW;OAAAR;OAAAG;MAAc,CAAC,EAAtC,GAAMsC,GAAN;KAAmD,KAChE,QAAM,OAEP,oBAAC,YAAD,EAAA,UACE,oBAAC,eAAD;MACYhC,UAAAA;MACJT;MACCG;KAAK,CAAA,EAJP,GAAMsC,GAAN;KAME,SAAA,OAGN;IACX;GAAC;GACF7B,EAAA,KAAAH;GAAAG,EAAA,MAAAJ;GAAAI,EAAA,MAAAP;GAAAO,EAAA,MAAAN;GAAAM,EAAA,MAAAL;GAAAK,EAAA,MAAAd;GAAAc,EAAA,MAAAR;GAAAQ,EAAA,MAAAc;EAAA,OAAAA,KAAAd,EAAA;EAtDAE,KAAAyB,QAAOG,IAAKhB,EAsDZ;EAACd,EAAA,KAAA2B;EAAA3B,EAAA,KAAAH;EAAAG,EAAA,KAAAJ;EAAAI,EAAA,KAAAP;EAAAO,EAAA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAd;EAAAc,EAAA,KAAAR;EAAAQ,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAc;CAAA,IAAAd,EAAA,QAAAE,IAAA;EAvDJY,KAAA,oBAAA,UAAA,EAAA,UACGZ,GAsDC,CAAA;EACDF,EAAA,MAAAE;EAAAF,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,OAxDHc;AAwDG;AApEuB,SAAAc,MAAApB,GAAA;CAAA,OASOA,EAACO,QAAQY;AAAQ"}
1
+ {"version":3,"file":"MessageContent.js","names":["ReactElement","Fragment","useMemo","Text","ThreadUserMessagePart","ThreadAssistantMessagePart","ToolCallMessagePart","DataMessagePart","useAui","useAuiState","ToolCallMessagePartProps","DataMessagePartProps","MessageContentPart","MessageContentProps","renderText","props","part","Extract","type","index","renderToolCall","renderImage","renderReasoning","renderSource","renderFile","renderData","DefaultTextRenderer","t0","$","_c","t1","text","ToolUIDisplay","Fallback","aui","toolName","s","tools","toolUIs","render","Render","t2","message","partMethods","t3","t4","addToolResult","respondToToolApproval","resumeToolCall","DataUIDisplay","name","renders","dataRenderers","renderers","Array","isArray","MessageContent","content","_temp","key","map"],"sources":["../../../src/primitives/message/MessageContent.tsx"],"sourcesContent":["import { type ReactElement, Fragment, useMemo } from \"react\";\nimport { Text } from \"react-native\";\nimport type {\n ThreadUserMessagePart,\n ThreadAssistantMessagePart,\n ToolCallMessagePart,\n DataMessagePart,\n} from \"@assistant-ui/core\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type {\n ToolCallMessagePartProps,\n DataMessagePartProps,\n} from \"@assistant-ui/core/react\";\n\ntype MessageContentPart = ThreadUserMessagePart | ThreadAssistantMessagePart;\n\nexport type MessageContentProps = {\n renderText?: (props: {\n part: Extract<MessageContentPart, { type: \"text\" }>;\n index: number;\n }) => ReactElement;\n renderToolCall?: (props: {\n part: Extract<MessageContentPart, { type: \"tool-call\" }>;\n index: number;\n }) => ReactElement;\n renderImage?: (props: {\n part: Extract<MessageContentPart, { type: \"image\" }>;\n index: number;\n }) => ReactElement;\n renderReasoning?: (props: {\n part: Extract<MessageContentPart, { type: \"reasoning\" }>;\n index: number;\n }) => ReactElement;\n renderSource?: (props: {\n part: Extract<MessageContentPart, { type: \"source\" }>;\n index: number;\n }) => ReactElement;\n renderFile?: (props: {\n part: Extract<MessageContentPart, { type: \"file\" }>;\n index: number;\n }) => ReactElement;\n renderData?: (props: {\n part: Extract<MessageContentPart, { type: \"data\" }>;\n index: number;\n }) => ReactElement;\n};\n\nconst DefaultTextRenderer = ({\n part,\n}: {\n part: Extract<MessageContentPart, { type: \"text\" }>;\n}) => {\n return <Text>{part.text}</Text>;\n};\n\nconst ToolUIDisplay = ({\n Fallback,\n part,\n index,\n}: {\n Fallback:\n | ((props: { part: ToolCallMessagePart; index: number }) => ReactElement)\n | undefined;\n part: ToolCallMessagePart;\n index: number;\n}) => {\n const aui = useAui();\n const Render = useAuiState(\n (s) => s.tools.toolUIs[part.toolName]?.[0]?.render,\n );\n\n const partMethods = useMemo(() => aui.message.part({ index }), [aui, index]);\n\n if (Render) {\n return (\n <Render\n {...(part as ToolCallMessagePartProps)}\n addResult={partMethods.addToolResult}\n resume={partMethods.resumeToolCall}\n respondToApproval={partMethods.respondToToolApproval}\n />\n );\n }\n if (Fallback) return <Fallback part={part} index={index} />;\n return null;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n part,\n index,\n}: {\n Fallback:\n | ((props: { part: DataMessagePart; index: number }) => ReactElement)\n | undefined;\n part: DataMessagePart;\n index: number;\n}) => {\n const Render = useAuiState((s) => {\n const renders = s.dataRenderers.renderers[part.name];\n if (Array.isArray(renders)) return renders[0];\n return renders;\n });\n if (Render) return <Render {...(part as DataMessagePartProps)} />;\n if (Fallback) return <Fallback part={part} index={index} />;\n return null;\n};\n\nexport const MessageContent = ({\n renderText,\n renderToolCall,\n renderImage,\n renderReasoning,\n renderSource,\n renderFile,\n renderData,\n}: MessageContentProps) => {\n const content = useAuiState((s) => s.message.content);\n\n return (\n <>\n {content.map((part, index) => {\n const key = `${part.type}-${index}`;\n switch (part.type) {\n case \"text\":\n return (\n <Fragment key={key}>\n {renderText ? (\n renderText({ part, index })\n ) : (\n <DefaultTextRenderer part={part} />\n )}\n </Fragment>\n );\n case \"tool-call\":\n return (\n <Fragment key={key}>\n <ToolUIDisplay\n Fallback={renderToolCall}\n part={part}\n index={index}\n />\n </Fragment>\n );\n case \"image\":\n if (!renderImage) return null;\n return (\n <Fragment key={key}>{renderImage({ part, index })}</Fragment>\n );\n case \"reasoning\":\n if (!renderReasoning) return null;\n return (\n <Fragment key={key}>{renderReasoning({ part, index })}</Fragment>\n );\n case \"source\":\n if (!renderSource) return null;\n return (\n <Fragment key={key}>{renderSource({ part, index })}</Fragment>\n );\n case \"file\":\n if (!renderFile) return null;\n return <Fragment key={key}>{renderFile({ part, index })}</Fragment>;\n case \"data\":\n return (\n <Fragment key={key}>\n <DataUIDisplay\n Fallback={renderData}\n part={part}\n index={index}\n />\n </Fragment>\n );\n default:\n return null;\n }\n })}\n </>\n );\n};\n"],"mappings":";;;;;;AA+CA,MAAM0B,uBAAsBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAb,SAAAW;CAI5B,IAAAG;CAAA,IAAAF,EAAA,OAAAZ,KAAAe,MAAA;EACQD,KAAA,oBAAC,MAAD,EAAA,UAAOd,KAAIe,KAAN,CAAA;EAAmBH,EAAA,KAAAZ,KAAAe;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAAxBE;AAAwB;AAGjC,MAAME,iBAAgBL,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAI,UAAAjB,MAAAG,UAAAQ;CAWrB,MAAAO,MAAY1B,OAAO;CAAE,IAAAsB;CAAA,IAAAF,EAAA,OAAAZ,KAAAmB,UAAA;EAEnBL,MAAAM,MAAOA,EAACC,MAAMC,QAAStB,KAAImB,SAAe,GAAA,EAAQ,EAAAI;EAAAX,EAAA,KAAAZ,KAAAmB;EAAAP,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CADpD,MAAAY,SAAe/B,YACbqB,EACF;CAAE,IAAAW;CAAA,IAAAb,EAAA,OAAAM,IAAAQ,WAAAd,EAAA,OAAAT,OAAA;EAEgCsB,KAAAP,IAAGQ,QAAQ1B,KAAM,EAAAG,MAAQ,CAAC;EAACS,EAAA,KAAAM,IAAAQ;EAAAd,EAAA,KAAAT;EAAAS,EAAA,KAAAa;CAAA,OAAAA,KAAAb,EAAA;CAA7D,MAAAe,cAAkCF;CAElC,IAAID,QAAM;EAGC,MAAAI,KAAA5B;EAAgC,IAAA6B;EAAA,IAAAjB,EAAA,OAAAY,UAAAZ,EAAA,O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,KAAAP;EAAAO,EAAA,KAAAN;EAAAM,EAAA,KAAAL;EAAAK,EAAA,KAAAd;EAAAc,EAAA,KAAAR;EAAAQ,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,QAAAE,IAAA;EAvDJW,KAAA,oBAAA,UAAA,EAAA,UACGX,GAsDC,CAAA;EACDF,EAAA,MAAAE;EAAAF,EAAA,MAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,OAxDHa;AAwDG;AApEuB,SAAAiB,MAAAtB,GAAA;CAAA,OASOA,EAACM,QAAQe;AAAQ"}
@@ -66,7 +66,7 @@ const ThreadMessageByChildren = memo(({ index, children }) => {
66
66
  return /* @__PURE__ */ jsx(MessageByIndexProvider, {
67
67
  index,
68
68
  children: /* @__PURE__ */ jsx(RenderChildrenWithAccessor, {
69
- getItemState: (aui) => aui.thread().message({ index }).getState(),
69
+ getItemState: (aui) => aui.thread.message({ index }).getState(),
70
70
  children: (getItem) => children({ get message() {
71
71
  return getItem();
72
72
  } })
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadMessages.js","names":["ComponentType","FC","ForwardedRef","ReactNode","RefObject","forwardRef","memo","useCallback","useEffect","useRef","FlatList","FlatListProps","LayoutChangeEvent","NativeScrollEvent","NativeSyntheticEvent","MessageState","ThreadMessage","RenderChildrenWithAccessor","useAuiEvent","useAuiState","MessageByIndexProvider","MessageComponents","Message","EditComposer","UserEditComposer","AssistantEditComposer","SystemEditComposer","UserMessage","AssistantMessage","SystemMessage","MessagesContent","components","children","value","message","ThreadMessagesFlatListProps","Omit","autoScroll","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","ThreadMessagesProps","DEFAULT_SYSTEM_MESSAGE","AT_BOTTOM_THRESHOLD","getComponent","role","isEditing","_exhaustiveCheck","Error","ThreadMessageComponent","t0","$","_c","_temp","_temp2","t1","Component","t2","ThreadMessageByIndex","index","prev","next","displayName","ThreadMessageByChildren","aui","thread","getState","getItem","setForwardedRef","ref","T","current","useComposedFlatListRef","forwardedRef","flatListRef","node","setFlatListRef","const","useThreadMessagesFlatListAutoScroll","hasMessages","t3","t4","undefined","t5","Symbol","for","contentHeight","viewportHeight","scrollY","metricsRef","isAtBottomRef","lastScrollEventYRef","initializeScrollRequestedRef","pendingScrollToBottomRef","t6","updateIsAtBottom","t7","animated","contentHeight_0","viewportHeight_0","Math","max","scrollToEnd","scrollToBottom","t8","event","wasAtBottom","previousViewportHeight","viewportHeight_1","nativeEvent","layout","height","pending","handleLayout","t9","event_0","contentOffset","contentSize","layoutMeasurement","previousEventY","wasPinnedToBottom","y","upwardMove","handleScroll","t10","_width","metrics","previousContentHeight","wasAtBottom_0","pendingScroll","handleContentSizeChange","t11","t12","t13","t14","t15","ThreadMessagesFlatList","flatListProps","onContentSizeChange","onLayout","onScroll","scrollEventThrottle","messages","_temp3","length","handleAutoScrollContentSizeChange","handleAutoScrollLayout","handleAutoScrollScroll","renderItem","keyExtractor","_temp4","scrollTracking","width","ThreadMessages","props","s","s_0","composer","item","id"],"sources":["../../../src/primitives/thread/ThreadMessages.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ForwardedRef,\n type ReactNode,\n type RefObject,\n forwardRef,\n memo,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport {\n FlatList,\n type FlatListProps,\n type LayoutChangeEvent,\n type NativeScrollEvent,\n type NativeSyntheticEvent,\n} from \"react-native\";\nimport type { MessageState, ThreadMessage } from \"@assistant-ui/core\";\nimport {\n RenderChildrenWithAccessor,\n useAuiEvent,\n useAuiState,\n} from \"@assistant-ui/store\";\nimport { MessageByIndexProvider } from \"@assistant-ui/core/react\";\n\ntype MessageComponents =\n | {\n Message: ComponentType;\n EditComposer?: ComponentType | undefined;\n UserEditComposer?: ComponentType | undefined;\n AssistantEditComposer?: ComponentType | undefined;\n SystemEditComposer?: ComponentType | undefined;\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n }\n | {\n Message?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n UserEditComposer?: ComponentType | undefined;\n AssistantEditComposer?: ComponentType | undefined;\n SystemEditComposer?: ComponentType | undefined;\n UserMessage: ComponentType;\n AssistantMessage: ComponentType;\n SystemMessage?: ComponentType | undefined;\n };\n\ntype MessagesContent =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageComponents;\n children?: never;\n }\n | {\n children: (value: { message: MessageState }) => ReactNode;\n components?: never;\n };\n\nexport type ThreadMessagesFlatListProps = Omit<\n FlatListProps<ThreadMessage>,\n \"data\" | \"renderItem\" | \"children\"\n> &\n MessagesContent & {\n autoScroll?: boolean | undefined;\n scrollToBottomOnRunStart?: boolean | undefined;\n scrollToBottomOnInitialize?: boolean | undefined;\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n\n/** @deprecated Use ThreadMessagesFlatListProps instead. */\nexport type ThreadMessagesProps = ThreadMessagesFlatListProps;\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\nconst AT_BOTTOM_THRESHOLD = 4;\n\nconst getComponent = (\n components: MessageComponents,\n role: ThreadMessage[\"role\"],\n isEditing: boolean,\n) => {\n switch (role) {\n case \"user\":\n if (isEditing) {\n return (\n components.UserEditComposer ??\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.UserMessage ?? (components.Message as ComponentType);\n }\n case \"assistant\":\n if (isEditing) {\n return (\n components.AssistantEditComposer ??\n components.EditComposer ??\n components.AssistantMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.AssistantMessage ?? (components.Message as ComponentType)\n );\n }\n case \"system\":\n if (isEditing) {\n return (\n components.SystemEditComposer ??\n components.EditComposer ??\n components.SystemMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.SystemMessage ??\n (components.Message as ComponentType) ??\n DEFAULT_SYSTEM_MESSAGE\n );\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unknown message role: ${_exhaustiveCheck}`);\n }\n }\n};\n\nconst ThreadMessageComponent: FC<{ components: MessageComponents }> = ({\n components,\n}) => {\n const role = useAuiState((s) => s.message.role);\n const isEditing = useAuiState((s) => s.message.composer.isEditing);\n const Component = getComponent(components, role, isEditing);\n\n return <Component />;\n};\n\nconst ThreadMessageByIndex = memo(\n ({ index, components }: { index: number; components: MessageComponents }) => {\n return (\n <MessageByIndexProvider index={index}>\n <ThreadMessageComponent components={components} />\n </MessageByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index && prev.components === next.components,\n);\nThreadMessageByIndex.displayName = \"ThreadPrimitive.MessageByIndex\";\n\nconst ThreadMessageByChildren = memo(\n ({\n index,\n children,\n }: {\n index: number;\n children: (value: { message: MessageState }) => ReactNode;\n }) => {\n return (\n <MessageByIndexProvider index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) => aui.thread().message({ index }).getState()}\n >\n {(getItem) =>\n children({\n get message() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageByIndexProvider>\n );\n },\n (prev, next) => prev.index === next.index && prev.children === next.children,\n);\nThreadMessageByChildren.displayName = \"ThreadPrimitive.MessageByChildren\";\n\nconst setForwardedRef = <T,>(ref: ForwardedRef<T>, value: T | null) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nconst useComposedFlatListRef = (\n forwardedRef: ForwardedRef<FlatList<ThreadMessage>>,\n) => {\n const flatListRef = useRef<FlatList<ThreadMessage> | null>(null);\n\n const setFlatListRef = useCallback(\n (node: FlatList<ThreadMessage> | null) => {\n flatListRef.current = node;\n setForwardedRef(forwardedRef, node);\n },\n [forwardedRef],\n );\n\n return [flatListRef, setFlatListRef] as const;\n};\n\nconst useThreadMessagesFlatListAutoScroll = ({\n flatListRef,\n hasMessages,\n autoScroll = true,\n scrollToBottomOnRunStart = true,\n scrollToBottomOnInitialize = true,\n scrollToBottomOnThreadSwitch = true,\n}: {\n flatListRef: RefObject<FlatList<ThreadMessage> | null>;\n hasMessages: boolean;\n autoScroll?: boolean | undefined;\n scrollToBottomOnRunStart?: boolean | undefined;\n scrollToBottomOnInitialize?: boolean | undefined;\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n}) => {\n const metricsRef = useRef({\n contentHeight: 0,\n viewportHeight: 0,\n scrollY: 0,\n });\n const isAtBottomRef = useRef(true);\n const lastScrollEventYRef = useRef(0);\n const initializeScrollRequestedRef = useRef(false);\n const pendingScrollToBottomRef = useRef<false | { animated: boolean }>(false);\n\n const updateIsAtBottom = useCallback(() => {\n const { contentHeight, scrollY, viewportHeight } = metricsRef.current;\n isAtBottomRef.current =\n contentHeight <= viewportHeight ||\n contentHeight - scrollY - viewportHeight <= AT_BOTTOM_THRESHOLD;\n }, []);\n\n // Commanding a scroll records the intended position immediately; the\n // native scroll echo is bridged and throttled, so waiting for it lets a\n // fast stream observe stale metrics and drop out of following.\n const scrollToBottom = useCallback(\n (animated: boolean) => {\n const { contentHeight, viewportHeight } = metricsRef.current;\n metricsRef.current.scrollY = Math.max(0, contentHeight - viewportHeight);\n isAtBottomRef.current = true;\n flatListRef.current?.scrollToEnd({ animated });\n },\n [flatListRef],\n );\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent) => {\n const wasAtBottom = isAtBottomRef.current;\n const previousViewportHeight = metricsRef.current.viewportHeight;\n const viewportHeight = event.nativeEvent.layout.height;\n metricsRef.current.viewportHeight = viewportHeight;\n updateIsAtBottom();\n if (!wasAtBottom) return;\n // Layout changes are never user gestures, so they must not unpin. Past\n // the first measurement, a viewport change while pinned re-commands the\n // bottom position, since no content-size event follows a bare keyboard\n // open or close.\n if (\n autoScroll &&\n previousViewportHeight !== 0 &&\n viewportHeight !== previousViewportHeight\n ) {\n const pending = pendingScrollToBottomRef.current;\n scrollToBottom(pending ? pending.animated : false);\n } else {\n isAtBottomRef.current = true;\n }\n },\n [autoScroll, scrollToBottom, updateIsAtBottom],\n );\n\n const handleScroll = useCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n const { contentOffset, contentSize, layoutMeasurement } =\n event.nativeEvent;\n const previousEventY = lastScrollEventYRef.current;\n const wasPinnedToBottom = isAtBottomRef.current;\n lastScrollEventYRef.current = contentOffset.y;\n metricsRef.current = {\n contentHeight: contentSize.height,\n viewportHeight: layoutMeasurement.height,\n scrollY: contentOffset.y,\n };\n updateIsAtBottom();\n const upwardMove = contentOffset.y < previousEventY;\n // Only a deliberate upward move unpins or cancels a pending scroll.\n // Gestures are detected echo-to-echo because a commanded scroll\n // optimistically moves the tracked position ahead of its ascending\n // animation echoes, and those echoes must not unpin mid-flight.\n if (wasPinnedToBottom && !upwardMove) {\n isAtBottomRef.current = true;\n }\n if (!isAtBottomRef.current && upwardMove) {\n pendingScrollToBottomRef.current = false;\n }\n },\n [updateIsAtBottom],\n );\n\n const handleContentSizeChange = useCallback(\n (_width: number, height: number) => {\n const metrics = metricsRef.current;\n const previousContentHeight = metrics.contentHeight;\n const wasAtBottom = isAtBottomRef.current;\n metrics.contentHeight = height;\n updateIsAtBottom();\n\n // FlatList.scrollToEnd is a no-op before the list has measured, so the\n // initialize and thread-switch scrolls land on the next content-size\n // event, once real metrics exist.\n const pendingScroll = pendingScrollToBottomRef.current;\n if (pendingScroll) {\n pendingScrollToBottomRef.current = false;\n scrollToBottom(pendingScroll.animated);\n return;\n }\n\n if (!autoScroll) return;\n if (!wasAtBottom) return;\n if (previousContentHeight === 0) return;\n if (height <= previousContentHeight) return;\n\n scrollToBottom(false);\n },\n [autoScroll, scrollToBottom, updateIsAtBottom],\n );\n\n useEffect(() => {\n if (!scrollToBottomOnInitialize) return;\n if (!hasMessages) {\n initializeScrollRequestedRef.current = false;\n return;\n }\n if (initializeScrollRequestedRef.current) return;\n\n initializeScrollRequestedRef.current = true;\n pendingScrollToBottomRef.current = { animated: false };\n scrollToBottom(false);\n }, [hasMessages, scrollToBottom, scrollToBottomOnInitialize]);\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!scrollToBottomOnRunStart) return;\n pendingScrollToBottomRef.current = { animated: true };\n scrollToBottom(true);\n });\n\n useAuiEvent(\"threadListItem.switchedTo\", () => {\n if (!scrollToBottomOnThreadSwitch) return;\n initializeScrollRequestedRef.current = false;\n lastScrollEventYRef.current = 0;\n pendingScrollToBottomRef.current = { animated: false };\n scrollToBottom(false);\n });\n\n return {\n handleLayout,\n handleScroll,\n handleContentSizeChange,\n };\n};\n\nexport const ThreadMessagesFlatList = forwardRef<\n FlatList<ThreadMessage>,\n ThreadMessagesFlatListProps\n>(\n (\n {\n autoScroll,\n components,\n children,\n onContentSizeChange,\n onLayout,\n onScroll,\n scrollEventThrottle,\n scrollToBottomOnInitialize,\n scrollToBottomOnRunStart,\n scrollToBottomOnThreadSwitch,\n ...flatListProps\n },\n forwardedRef,\n ) => {\n const messages = useAuiState((s) => s.thread.messages);\n const [flatListRef, setFlatListRef] = useComposedFlatListRef(forwardedRef);\n const {\n handleContentSizeChange: handleAutoScrollContentSizeChange,\n handleLayout: handleAutoScrollLayout,\n handleScroll: handleAutoScrollScroll,\n } = useThreadMessagesFlatListAutoScroll({\n flatListRef,\n hasMessages: messages.length > 0,\n autoScroll,\n scrollToBottomOnInitialize,\n scrollToBottomOnRunStart,\n scrollToBottomOnThreadSwitch,\n });\n\n const renderItem = useCallback(\n ({ index }: { item: ThreadMessage; index: number }) => {\n if (children) {\n return (\n <ThreadMessageByChildren index={index}>\n {children}\n </ThreadMessageByChildren>\n );\n }\n return <ThreadMessageByIndex index={index} components={components!} />;\n },\n [components, children],\n );\n\n const keyExtractor = useCallback((item: ThreadMessage) => item.id, []);\n\n const scrollTracking =\n (autoScroll ?? true) ||\n (scrollToBottomOnInitialize ?? true) ||\n (scrollToBottomOnRunStart ?? true) ||\n (scrollToBottomOnThreadSwitch ?? true);\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent) => {\n handleAutoScrollLayout(event);\n onLayout?.(event);\n },\n [handleAutoScrollLayout, onLayout],\n );\n\n const handleScroll = useCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n handleAutoScrollScroll(event);\n onScroll?.(event);\n },\n [handleAutoScrollScroll, onScroll],\n );\n\n const handleContentSizeChange = useCallback(\n (width: number, height: number) => {\n handleAutoScrollContentSizeChange(width, height);\n onContentSizeChange?.(width, height);\n },\n [handleAutoScrollContentSizeChange, onContentSizeChange],\n );\n\n return (\n <FlatList\n ref={setFlatListRef}\n data={messages as unknown as ThreadMessage[]}\n renderItem={renderItem}\n keyExtractor={keyExtractor}\n {...(scrollTracking\n ? {\n onContentSizeChange: handleContentSizeChange,\n onLayout: handleLayout,\n onScroll: handleScroll,\n scrollEventThrottle: scrollEventThrottle ?? 16,\n }\n : {\n ...(onContentSizeChange && { onContentSizeChange }),\n ...(onLayout && { onLayout }),\n ...(onScroll && { onScroll }),\n ...(scrollEventThrottle !== undefined && { scrollEventThrottle }),\n })}\n {...flatListProps}\n />\n );\n },\n);\nThreadMessagesFlatList.displayName = \"ThreadPrimitive.MessagesFlatList\";\n\n/** @deprecated Use ThreadPrimitive.MessagesFlatList instead. */\nexport const ThreadMessages = forwardRef<\n FlatList<ThreadMessage>,\n ThreadMessagesProps\n>(\n (\n {\n autoScroll = false,\n scrollToBottomOnInitialize = false,\n scrollToBottomOnRunStart = false,\n scrollToBottomOnThreadSwitch = false,\n ...props\n },\n ref,\n ) => (\n <ThreadMessagesFlatList\n ref={ref}\n autoScroll={autoScroll}\n scrollToBottomOnInitialize={scrollToBottomOnInitialize}\n scrollToBottomOnRunStart={scrollToBottomOnRunStart}\n scrollToBottomOnThreadSwitch={scrollToBottomOnThreadSwitch}\n {...props}\n />\n ),\n);\nThreadMessages.displayName = \"ThreadPrimitive.Messages\";\n"],"mappings":";;;;;;;AA0EA,MAAM0C,+BAA+B;AACrC,MAAMC,sBAAsB;AAE5B,MAAMC,gBACJb,YACAc,MACAC,cACG;CACH,QAAQD,MAAR;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AAAZ,8BAAAY,EAAA,QAAAb,4BAAAa,EAAA,QAAAX,8BAAA;EAKtC2C,KAAA,oBAAC,wBAAD;GACOd;GACOhC;GACgBE;GACFD;GACIE;GAA4B,GACtDkH;EAAK,CAAA;EACTvG,EAAA,KAAAd;EAAAc,EAAA,KAAAuG;EAAAvG,EAAA,KAAAkB;EAAAlB,EAAA,KAAAZ;EAAAY,EAAA,MAAAb;EAAAa,EAAA,MAAAX;EAAAW,EAAA,MAAAgC;CAAA,OAAAA,KAAAhC,EAAA;CAAA,OAPFgC;AAOE,CAEN;AACAsE,eAAe3F,cAAc;AAhXyC,SAAAT,MAAAsG,GAAA;CAAA,OAGpCA,EAACzH,QAAQW;AAAK;AAHsB,SAAAS,OAAAsG,KAAA;CAAA,OAI/BD,IAACzH,QAAQ2H,SAAS/G;AAAU;AA4OjE,SAAAiG,OAAAY,GAAA;CAAA,OAgBsCA,EAAC1F,OAAO6E;AAAS;AAhBvD,SAAAQ,OAAAQ,MAAA;CAAA,OA6C4DA,KAAIC;AAAG"}
1
+ {"version":3,"file":"ThreadMessages.js","names":["ComponentType","FC","ForwardedRef","ReactNode","RefObject","forwardRef","memo","useCallback","useEffect","useRef","FlatList","FlatListProps","LayoutChangeEvent","NativeScrollEvent","NativeSyntheticEvent","MessageState","ThreadMessage","RenderChildrenWithAccessor","useAuiEvent","useAuiState","MessageByIndexProvider","MessageComponents","Message","EditComposer","UserEditComposer","AssistantEditComposer","SystemEditComposer","UserMessage","AssistantMessage","SystemMessage","MessagesContent","components","children","value","message","ThreadMessagesFlatListProps","Omit","autoScroll","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","ThreadMessagesProps","DEFAULT_SYSTEM_MESSAGE","AT_BOTTOM_THRESHOLD","getComponent","role","isEditing","_exhaustiveCheck","Error","ThreadMessageComponent","t0","$","_c","_temp","_temp2","t1","Component","t2","ThreadMessageByIndex","index","prev","next","displayName","ThreadMessageByChildren","aui","thread","getState","getItem","setForwardedRef","ref","T","current","useComposedFlatListRef","forwardedRef","flatListRef","node","setFlatListRef","const","useThreadMessagesFlatListAutoScroll","hasMessages","t3","t4","undefined","t5","Symbol","for","contentHeight","viewportHeight","scrollY","metricsRef","isAtBottomRef","lastScrollEventYRef","initializeScrollRequestedRef","pendingScrollToBottomRef","t6","updateIsAtBottom","t7","animated","contentHeight_0","viewportHeight_0","Math","max","scrollToEnd","scrollToBottom","t8","event","wasAtBottom","previousViewportHeight","viewportHeight_1","nativeEvent","layout","height","pending","handleLayout","t9","event_0","contentOffset","contentSize","layoutMeasurement","previousEventY","wasPinnedToBottom","y","upwardMove","handleScroll","t10","_width","metrics","previousContentHeight","wasAtBottom_0","pendingScroll","handleContentSizeChange","t11","t12","t13","t14","t15","ThreadMessagesFlatList","flatListProps","onContentSizeChange","onLayout","onScroll","scrollEventThrottle","messages","_temp3","length","handleAutoScrollContentSizeChange","handleAutoScrollLayout","handleAutoScrollScroll","renderItem","keyExtractor","_temp4","scrollTracking","width","ThreadMessages","props","s","s_0","composer","item","id"],"sources":["../../../src/primitives/thread/ThreadMessages.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ForwardedRef,\n type ReactNode,\n type RefObject,\n forwardRef,\n memo,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport {\n FlatList,\n type FlatListProps,\n type LayoutChangeEvent,\n type NativeScrollEvent,\n type NativeSyntheticEvent,\n} from \"react-native\";\nimport type { MessageState, ThreadMessage } from \"@assistant-ui/core\";\nimport {\n RenderChildrenWithAccessor,\n useAuiEvent,\n useAuiState,\n} from \"@assistant-ui/store\";\nimport { MessageByIndexProvider } from \"@assistant-ui/core/react\";\n\ntype MessageComponents =\n | {\n Message: ComponentType;\n EditComposer?: ComponentType | undefined;\n UserEditComposer?: ComponentType | undefined;\n AssistantEditComposer?: ComponentType | undefined;\n SystemEditComposer?: ComponentType | undefined;\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n SystemMessage?: ComponentType | undefined;\n }\n | {\n Message?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n UserEditComposer?: ComponentType | undefined;\n AssistantEditComposer?: ComponentType | undefined;\n SystemEditComposer?: ComponentType | undefined;\n UserMessage: ComponentType;\n AssistantMessage: ComponentType;\n SystemMessage?: ComponentType | undefined;\n };\n\ntype MessagesContent =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageComponents;\n children?: never;\n }\n | {\n children: (value: { message: MessageState }) => ReactNode;\n components?: never;\n };\n\nexport type ThreadMessagesFlatListProps = Omit<\n FlatListProps<ThreadMessage>,\n \"data\" | \"renderItem\" | \"children\"\n> &\n MessagesContent & {\n autoScroll?: boolean | undefined;\n scrollToBottomOnRunStart?: boolean | undefined;\n scrollToBottomOnInitialize?: boolean | undefined;\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n };\n\n/** @deprecated Use ThreadMessagesFlatListProps instead. */\nexport type ThreadMessagesProps = ThreadMessagesFlatListProps;\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\nconst AT_BOTTOM_THRESHOLD = 4;\n\nconst getComponent = (\n components: MessageComponents,\n role: ThreadMessage[\"role\"],\n isEditing: boolean,\n) => {\n switch (role) {\n case \"user\":\n if (isEditing) {\n return (\n components.UserEditComposer ??\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.UserMessage ?? (components.Message as ComponentType);\n }\n case \"assistant\":\n if (isEditing) {\n return (\n components.AssistantEditComposer ??\n components.EditComposer ??\n components.AssistantMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.AssistantMessage ?? (components.Message as ComponentType)\n );\n }\n case \"system\":\n if (isEditing) {\n return (\n components.SystemEditComposer ??\n components.EditComposer ??\n components.SystemMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.SystemMessage ??\n (components.Message as ComponentType) ??\n DEFAULT_SYSTEM_MESSAGE\n );\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unknown message role: ${_exhaustiveCheck}`);\n }\n }\n};\n\nconst ThreadMessageComponent: FC<{ components: MessageComponents }> = ({\n components,\n}) => {\n const role = useAuiState((s) => s.message.role);\n const isEditing = useAuiState((s) => s.message.composer.isEditing);\n const Component = getComponent(components, role, isEditing);\n\n return <Component />;\n};\n\nconst ThreadMessageByIndex = memo(\n ({ index, components }: { index: number; components: MessageComponents }) => {\n return (\n <MessageByIndexProvider index={index}>\n <ThreadMessageComponent components={components} />\n </MessageByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index && prev.components === next.components,\n);\nThreadMessageByIndex.displayName = \"ThreadPrimitive.MessageByIndex\";\n\nconst ThreadMessageByChildren = memo(\n ({\n index,\n children,\n }: {\n index: number;\n children: (value: { message: MessageState }) => ReactNode;\n }) => {\n return (\n <MessageByIndexProvider index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) => aui.thread.message({ index }).getState()}\n >\n {(getItem) =>\n children({\n get message() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageByIndexProvider>\n );\n },\n (prev, next) => prev.index === next.index && prev.children === next.children,\n);\nThreadMessageByChildren.displayName = \"ThreadPrimitive.MessageByChildren\";\n\nconst setForwardedRef = <T,>(ref: ForwardedRef<T>, value: T | null) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nconst useComposedFlatListRef = (\n forwardedRef: ForwardedRef<FlatList<ThreadMessage>>,\n) => {\n const flatListRef = useRef<FlatList<ThreadMessage> | null>(null);\n\n const setFlatListRef = useCallback(\n (node: FlatList<ThreadMessage> | null) => {\n flatListRef.current = node;\n setForwardedRef(forwardedRef, node);\n },\n [forwardedRef],\n );\n\n return [flatListRef, setFlatListRef] as const;\n};\n\nconst useThreadMessagesFlatListAutoScroll = ({\n flatListRef,\n hasMessages,\n autoScroll = true,\n scrollToBottomOnRunStart = true,\n scrollToBottomOnInitialize = true,\n scrollToBottomOnThreadSwitch = true,\n}: {\n flatListRef: RefObject<FlatList<ThreadMessage> | null>;\n hasMessages: boolean;\n autoScroll?: boolean | undefined;\n scrollToBottomOnRunStart?: boolean | undefined;\n scrollToBottomOnInitialize?: boolean | undefined;\n scrollToBottomOnThreadSwitch?: boolean | undefined;\n}) => {\n const metricsRef = useRef({\n contentHeight: 0,\n viewportHeight: 0,\n scrollY: 0,\n });\n const isAtBottomRef = useRef(true);\n const lastScrollEventYRef = useRef(0);\n const initializeScrollRequestedRef = useRef(false);\n const pendingScrollToBottomRef = useRef<false | { animated: boolean }>(false);\n\n const updateIsAtBottom = useCallback(() => {\n const { contentHeight, scrollY, viewportHeight } = metricsRef.current;\n isAtBottomRef.current =\n contentHeight <= viewportHeight ||\n contentHeight - scrollY - viewportHeight <= AT_BOTTOM_THRESHOLD;\n }, []);\n\n // Commanding a scroll records the intended position immediately; the\n // native scroll echo is bridged and throttled, so waiting for it lets a\n // fast stream observe stale metrics and drop out of following.\n const scrollToBottom = useCallback(\n (animated: boolean) => {\n const { contentHeight, viewportHeight } = metricsRef.current;\n metricsRef.current.scrollY = Math.max(0, contentHeight - viewportHeight);\n isAtBottomRef.current = true;\n flatListRef.current?.scrollToEnd({ animated });\n },\n [flatListRef],\n );\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent) => {\n const wasAtBottom = isAtBottomRef.current;\n const previousViewportHeight = metricsRef.current.viewportHeight;\n const viewportHeight = event.nativeEvent.layout.height;\n metricsRef.current.viewportHeight = viewportHeight;\n updateIsAtBottom();\n if (!wasAtBottom) return;\n // Layout changes are never user gestures, so they must not unpin. Past\n // the first measurement, a viewport change while pinned re-commands the\n // bottom position, since no content-size event follows a bare keyboard\n // open or close.\n if (\n autoScroll &&\n previousViewportHeight !== 0 &&\n viewportHeight !== previousViewportHeight\n ) {\n const pending = pendingScrollToBottomRef.current;\n scrollToBottom(pending ? pending.animated : false);\n } else {\n isAtBottomRef.current = true;\n }\n },\n [autoScroll, scrollToBottom, updateIsAtBottom],\n );\n\n const handleScroll = useCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n const { contentOffset, contentSize, layoutMeasurement } =\n event.nativeEvent;\n const previousEventY = lastScrollEventYRef.current;\n const wasPinnedToBottom = isAtBottomRef.current;\n lastScrollEventYRef.current = contentOffset.y;\n metricsRef.current = {\n contentHeight: contentSize.height,\n viewportHeight: layoutMeasurement.height,\n scrollY: contentOffset.y,\n };\n updateIsAtBottom();\n const upwardMove = contentOffset.y < previousEventY;\n // Only a deliberate upward move unpins or cancels a pending scroll.\n // Gestures are detected echo-to-echo because a commanded scroll\n // optimistically moves the tracked position ahead of its ascending\n // animation echoes, and those echoes must not unpin mid-flight.\n if (wasPinnedToBottom && !upwardMove) {\n isAtBottomRef.current = true;\n }\n if (!isAtBottomRef.current && upwardMove) {\n pendingScrollToBottomRef.current = false;\n }\n },\n [updateIsAtBottom],\n );\n\n const handleContentSizeChange = useCallback(\n (_width: number, height: number) => {\n const metrics = metricsRef.current;\n const previousContentHeight = metrics.contentHeight;\n const wasAtBottom = isAtBottomRef.current;\n metrics.contentHeight = height;\n updateIsAtBottom();\n\n // FlatList.scrollToEnd is a no-op before the list has measured, so the\n // initialize and thread-switch scrolls land on the next content-size\n // event, once real metrics exist.\n const pendingScroll = pendingScrollToBottomRef.current;\n if (pendingScroll) {\n pendingScrollToBottomRef.current = false;\n scrollToBottom(pendingScroll.animated);\n return;\n }\n\n if (!autoScroll) return;\n if (!wasAtBottom) return;\n if (previousContentHeight === 0) return;\n if (height <= previousContentHeight) return;\n\n scrollToBottom(false);\n },\n [autoScroll, scrollToBottom, updateIsAtBottom],\n );\n\n useEffect(() => {\n if (!scrollToBottomOnInitialize) return;\n if (!hasMessages) {\n initializeScrollRequestedRef.current = false;\n return;\n }\n if (initializeScrollRequestedRef.current) return;\n\n initializeScrollRequestedRef.current = true;\n pendingScrollToBottomRef.current = { animated: false };\n scrollToBottom(false);\n }, [hasMessages, scrollToBottom, scrollToBottomOnInitialize]);\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!scrollToBottomOnRunStart) return;\n pendingScrollToBottomRef.current = { animated: true };\n scrollToBottom(true);\n });\n\n useAuiEvent(\"threadListItem.switchedTo\", () => {\n if (!scrollToBottomOnThreadSwitch) return;\n initializeScrollRequestedRef.current = false;\n lastScrollEventYRef.current = 0;\n pendingScrollToBottomRef.current = { animated: false };\n scrollToBottom(false);\n });\n\n return {\n handleLayout,\n handleScroll,\n handleContentSizeChange,\n };\n};\n\nexport const ThreadMessagesFlatList = forwardRef<\n FlatList<ThreadMessage>,\n ThreadMessagesFlatListProps\n>(\n (\n {\n autoScroll,\n components,\n children,\n onContentSizeChange,\n onLayout,\n onScroll,\n scrollEventThrottle,\n scrollToBottomOnInitialize,\n scrollToBottomOnRunStart,\n scrollToBottomOnThreadSwitch,\n ...flatListProps\n },\n forwardedRef,\n ) => {\n const messages = useAuiState((s) => s.thread.messages);\n const [flatListRef, setFlatListRef] = useComposedFlatListRef(forwardedRef);\n const {\n handleContentSizeChange: handleAutoScrollContentSizeChange,\n handleLayout: handleAutoScrollLayout,\n handleScroll: handleAutoScrollScroll,\n } = useThreadMessagesFlatListAutoScroll({\n flatListRef,\n hasMessages: messages.length > 0,\n autoScroll,\n scrollToBottomOnInitialize,\n scrollToBottomOnRunStart,\n scrollToBottomOnThreadSwitch,\n });\n\n const renderItem = useCallback(\n ({ index }: { item: ThreadMessage; index: number }) => {\n if (children) {\n return (\n <ThreadMessageByChildren index={index}>\n {children}\n </ThreadMessageByChildren>\n );\n }\n return <ThreadMessageByIndex index={index} components={components!} />;\n },\n [components, children],\n );\n\n const keyExtractor = useCallback((item: ThreadMessage) => item.id, []);\n\n const scrollTracking =\n (autoScroll ?? true) ||\n (scrollToBottomOnInitialize ?? true) ||\n (scrollToBottomOnRunStart ?? true) ||\n (scrollToBottomOnThreadSwitch ?? true);\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent) => {\n handleAutoScrollLayout(event);\n onLayout?.(event);\n },\n [handleAutoScrollLayout, onLayout],\n );\n\n const handleScroll = useCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n handleAutoScrollScroll(event);\n onScroll?.(event);\n },\n [handleAutoScrollScroll, onScroll],\n );\n\n const handleContentSizeChange = useCallback(\n (width: number, height: number) => {\n handleAutoScrollContentSizeChange(width, height);\n onContentSizeChange?.(width, height);\n },\n [handleAutoScrollContentSizeChange, onContentSizeChange],\n );\n\n return (\n <FlatList\n ref={setFlatListRef}\n data={messages as unknown as ThreadMessage[]}\n renderItem={renderItem}\n keyExtractor={keyExtractor}\n {...(scrollTracking\n ? {\n onContentSizeChange: handleContentSizeChange,\n onLayout: handleLayout,\n onScroll: handleScroll,\n scrollEventThrottle: scrollEventThrottle ?? 16,\n }\n : {\n ...(onContentSizeChange && { onContentSizeChange }),\n ...(onLayout && { onLayout }),\n ...(onScroll && { onScroll }),\n ...(scrollEventThrottle !== undefined && { scrollEventThrottle }),\n })}\n {...flatListProps}\n />\n );\n },\n);\nThreadMessagesFlatList.displayName = \"ThreadPrimitive.MessagesFlatList\";\n\n/** @deprecated Use ThreadPrimitive.MessagesFlatList instead. */\nexport const ThreadMessages = forwardRef<\n FlatList<ThreadMessage>,\n ThreadMessagesProps\n>(\n (\n {\n autoScroll = false,\n scrollToBottomOnInitialize = false,\n scrollToBottomOnRunStart = false,\n scrollToBottomOnThreadSwitch = false,\n ...props\n },\n ref,\n ) => (\n <ThreadMessagesFlatList\n ref={ref}\n autoScroll={autoScroll}\n scrollToBottomOnInitialize={scrollToBottomOnInitialize}\n scrollToBottomOnRunStart={scrollToBottomOnRunStart}\n scrollToBottomOnThreadSwitch={scrollToBottomOnThreadSwitch}\n {...props}\n />\n ),\n);\nThreadMessages.displayName = \"ThreadPrimitive.Messages\";\n"],"mappings":";;;;;;;AA0EA,MAAM0C,+BAA+B;AACrC,MAAMC,sBAAsB;AAE5B,MAAMC,gBACJb,YACAc,MACAC,cACG;CACH,QAAQD,MAAR;EACE,KAAK,QACH,IAAIC,WACF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AAA,QAAAX,8BAAA;EAKtC2C,KAAA,oBAAC,wBAAD;GACOd;GACOhC;GACgBE;GACFD;GACIE;GAA4B,GACtDkH;EAAK,CAAA;EACTvG,EAAA,KAAAd;EAAAc,EAAA,KAAAuG;EAAAvG,EAAA,KAAAkB;EAAAlB,EAAA,KAAAZ;EAAAY,EAAA,MAAAb;EAAAa,EAAA,MAAAX;EAAAW,EAAA,MAAAgC;CAAA,OAAAA,KAAAhC,EAAA;CAAA,OAPFgC;AAOE,CAEN;AACAsE,eAAe3F,cAAc;AAhXyC,SAAAT,MAAAsG,GAAA;CAAA,OAGpCA,EAACzH,QAAQW;AAAK;AAHsB,SAAAS,OAAAsG,KAAA;CAAA,OAI/BD,IAACzH,QAAQ2H,SAAS/G;AAAU;AA4OjE,SAAAiG,OAAAY,GAAA;CAAA,OAgBsCA,EAAC1F,OAAO6E;AAAS;AAhBvD,SAAAQ,OAAAQ,MAAA;CAAA,OA6C4DA,KAAIC;AAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/react-native",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "React Native bindings for assistant-ui",
5
5
  "keywords": [
6
6
  "assistant",
@@ -31,10 +31,10 @@
31
31
  ],
32
32
  "sideEffects": false,
33
33
  "dependencies": {
34
- "@assistant-ui/core": "^0.2.23",
35
- "@assistant-ui/store": "^0.2.22",
36
- "@assistant-ui/tap": "^0.9.6",
37
- "assistant-stream": "^0.3.28",
34
+ "@assistant-ui/core": "^0.3.6",
35
+ "@assistant-ui/store": "^0.3.4",
36
+ "@assistant-ui/tap": "^0.9.10",
37
+ "assistant-stream": "^0.3.34",
38
38
  "zustand": "^5.0.14"
39
39
  },
40
40
  "peerDependencies": {
@@ -56,7 +56,7 @@
56
56
  "react-native": "^0.86.0",
57
57
  "react-native-web": "^0.21.2",
58
58
  "vitest": "^4.1.10",
59
- "@assistant-ui/x-buildutils": "0.0.20"
59
+ "@assistant-ui/x-buildutils": "0.0.21"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public",
package/src/index.ts CHANGED
@@ -65,6 +65,7 @@ export type {
65
65
  export type {
66
66
  RemoteThreadListAdapter,
67
67
  RemoteThreadListOptions,
68
+ RemoteThreadListProviderComponent,
68
69
  } from "@assistant-ui/core";
69
70
  export { InMemoryThreadListAdapter } from "@assistant-ui/core";
70
71
  export { createVoiceSession } from "@assistant-ui/core";
@@ -93,6 +94,7 @@ export {
93
94
  useAuiState,
94
95
  useAuiEvent,
95
96
  AuiProvider,
97
+ AuiConfig,
96
98
  AuiIf,
97
99
  type AssistantClient,
98
100
  type AssistantState,
@@ -8,9 +8,8 @@ const h = vi.hoisted(() => ({
8
8
  }));
9
9
 
10
10
  vi.mock("@assistant-ui/store", () => {
11
- const aui = {
12
- attachment: () => ({ remove: h.remove }),
13
- };
11
+ const attachment = Object.assign(() => attachment, { remove: h.remove });
12
+ const aui = { attachment };
14
13
  return {
15
14
  useAui: () => aui,
16
15
  };
@@ -14,7 +14,7 @@ export const AttachmentRemove = ({
14
14
  const aui = useAui();
15
15
 
16
16
  const handleRemove = useCallback(() => {
17
- aui.attachment().remove();
17
+ aui.attachment.remove();
18
18
  }, [aui]);
19
19
 
20
20
  return (
@@ -4,7 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
4
  import { AttachmentThumb } from "./AttachmentThumb";
5
5
 
6
6
  const h = vi.hoisted(() => ({
7
- attachment: { name: "" },
7
+ attachment: { name: "", type: "file" },
8
8
  }));
9
9
 
10
10
  vi.mock("@assistant-ui/store", () => ({
@@ -20,6 +20,7 @@ describe("AttachmentThumb", () => {
20
20
 
21
21
  beforeEach(() => {
22
22
  h.attachment.name = "";
23
+ h.attachment.type = "file";
23
24
  container = document.createElement("div");
24
25
  document.body.appendChild(container);
25
26
  root = createRoot(container);
@@ -32,8 +33,9 @@ describe("AttachmentThumb", () => {
32
33
  container.remove();
33
34
  });
34
35
 
35
- const mount = async (name: string) => {
36
+ const mount = async (name: string, type = "file") => {
36
37
  h.attachment.name = name;
38
+ h.attachment.type = type;
37
39
  await act(async () => {
38
40
  root.render(<AttachmentThumb testID="thumb" />);
39
41
  });
@@ -50,19 +52,32 @@ describe("AttachmentThumb", () => {
50
52
  expect(el.textContent).toBe(".gz");
51
53
  });
52
54
 
53
- it("renders just a dot when the name has no extension", async () => {
54
- const el = await mount("noext");
55
- expect(el.textContent).toBe(".");
55
+ it("falls back to the attachment type when the name has no extension", async () => {
56
+ const el = await mount("noext", "document");
57
+ expect(el.textContent).toBe("document");
56
58
  });
57
59
 
58
- it("renders just a dot for an empty name", async () => {
59
- const el = await mount("");
60
- expect(el.textContent).toBe(".");
60
+ it("falls back to the attachment type for an empty name", async () => {
61
+ const el = await mount("", "image");
62
+ expect(el.textContent).toBe("image");
61
63
  });
62
64
 
63
- it("treats a leading-dot name as an extension", async () => {
65
+ it("treats a leading-dot name as extensionless", async () => {
64
66
  const el = await mount(".gitignore");
65
- expect(el.textContent).toBe(".gitignore");
67
+ expect(el.textContent).toBe("file");
68
+ });
69
+
70
+ it("falls back to the attachment type for a trailing-dot name", async () => {
71
+ const el = await mount("report.", "image");
72
+ expect(el.textContent).toBe("image");
73
+ });
74
+ it("renders custom children instead of the extension", async () => {
75
+ h.attachment.name = "photo.png";
76
+ await act(async () => {
77
+ root.render(<AttachmentThumb testID="thumb">custom</AttachmentThumb>);
78
+ });
79
+ const el = container.querySelector('[data-testid="thumb"]') as HTMLElement;
80
+ expect(el.textContent).toBe("custom");
66
81
  });
67
82
 
68
83
  it("forwards props to the underlying Text", async () => {
@@ -4,10 +4,17 @@ import { useAuiState } from "@assistant-ui/store";
4
4
 
5
5
  export type AttachmentThumbProps = TextProps;
6
6
 
7
- export const AttachmentThumb: FC<AttachmentThumbProps> = (props) => {
8
- const ext = useAuiState((s) => {
9
- const parts = s.attachment.name.split(".");
10
- return parts.length > 1 ? parts.pop()! : "";
7
+ export const AttachmentThumb: FC<AttachmentThumbProps> = ({
8
+ children,
9
+ ...textProps
10
+ }) => {
11
+ const label = useAuiState((s) => {
12
+ const name = s.attachment.name;
13
+ const dot = name.lastIndexOf(".");
14
+ if (dot > 0 && dot < name.length - 1) {
15
+ return `.${name.slice(dot + 1)}`;
16
+ }
17
+ return s.attachment.type;
11
18
  });
12
- return <Text {...props}>.{ext}</Text>;
19
+ return <Text {...textProps}>{children ?? label}</Text>;
13
20
  };
@@ -10,9 +10,10 @@ const h = vi.hoisted(() => ({
10
10
  }));
11
11
 
12
12
  vi.mock("@assistant-ui/store", () => {
13
- const aui = {
14
- chainOfThought: () => ({ setCollapsed: h.setCollapsed }),
15
- };
13
+ const chainOfThought = Object.assign(() => chainOfThought, {
14
+ setCollapsed: h.setCollapsed,
15
+ });
16
+ const aui = { chainOfThought };
16
17
  return {
17
18
  useAui: () => aui,
18
19
  useAuiState: <T,>(selector: (s: typeof h.state) => T) => selector(h.state),
@@ -17,7 +17,7 @@ export const ChainOfThoughtAccordionTrigger = ({
17
17
  const collapsed = useAuiState((s) => s.chainOfThought.collapsed);
18
18
 
19
19
  const onPress = useCallback(() => {
20
- aui.chainOfThought().setCollapsed(!collapsed);
20
+ aui.chainOfThought.setCollapsed(!collapsed);
21
21
  }, [aui, collapsed]);
22
22
 
23
23
  return (
@@ -12,12 +12,11 @@ const h = vi.hoisted(() => ({
12
12
  }));
13
13
 
14
14
  vi.mock("@assistant-ui/store", () => {
15
- const aui = {
16
- composer: () => ({
17
- setText: h.setText,
18
- send: h.sendSpy,
19
- }),
20
- };
15
+ const composer = Object.assign(() => composer, {
16
+ setText: h.setText,
17
+ send: h.sendSpy,
18
+ });
19
+ const aui = { composer };
21
20
  return {
22
21
  useAui: () => aui,
23
22
  useAuiState: <T,>(
@@ -69,11 +69,11 @@ export const ComposerInput = ({
69
69
  if (Platform.OS === "web") {
70
70
  // Keep the controlled value in sync mid-IME so react-dom does not reset the textarea to a stale value
71
71
  flushTapSync(() => {
72
- aui.composer().setText(value);
72
+ aui.composer.setText(value);
73
73
  });
74
74
  return;
75
75
  }
76
- aui.composer().setText(value);
76
+ aui.composer.setText(value);
77
77
  },
78
78
  [aui],
79
79
  );
@@ -100,7 +100,7 @@ export const ComposerInput = ({
100
100
  if (nativeEvent.isComposing || nativeEvent.keyCode === 229) return;
101
101
  if (nativeEvent.key === "Enter" && !nativeEvent.shiftKey) {
102
102
  (e as unknown as Event).preventDefault?.();
103
- aui.composer().send();
103
+ aui.composer.send();
104
104
  }
105
105
  },
106
106
  [aui, submitMode, onKeyPressProp],
@@ -11,23 +11,21 @@ const h = vi.hoisted(() => ({
11
11
  respondToToolApproval: vi.fn(),
12
12
  state: {
13
13
  message: { content: [] as AnyPart[] },
14
- tools: { tools: {} as Record<string, unknown> },
14
+ tools: { toolUIs: {} as Record<string, unknown> },
15
15
  dataRenderers: { renderers: {} as Record<string, unknown> },
16
16
  },
17
17
  }));
18
18
 
19
19
  vi.mock("@assistant-ui/store", () => {
20
- const aui = {
21
- message: () => ({
22
- part: ({ index }: { index: number }) => ({
23
- addToolResult: (...args: unknown[]) => h.addToolResult(index, ...args),
24
- resumeToolCall: (...args: unknown[]) =>
25
- h.resumeToolCall(index, ...args),
26
- respondToToolApproval: (...args: unknown[]) =>
27
- h.respondToToolApproval(index, ...args),
28
- }),
20
+ const message = Object.assign(() => message, {
21
+ part: ({ index }: { index: number }) => ({
22
+ addToolResult: (...args: unknown[]) => h.addToolResult(index, ...args),
23
+ resumeToolCall: (...args: unknown[]) => h.resumeToolCall(index, ...args),
24
+ respondToToolApproval: (...args: unknown[]) =>
25
+ h.respondToToolApproval(index, ...args),
29
26
  }),
30
- };
27
+ });
28
+ const aui = { message };
31
29
  return {
32
30
  useAui: () => aui,
33
31
  useAuiState: <T,>(selector: (s: typeof h.state) => T) => selector(h.state),
@@ -45,7 +43,7 @@ describe("MessageContent", () => {
45
43
  h.resumeToolCall.mockReset();
46
44
  h.respondToToolApproval.mockReset();
47
45
  h.state.message.content = [];
48
- h.state.tools.tools = {};
46
+ h.state.tools.toolUIs = {};
49
47
  h.state.dataRenderers.renderers = {};
50
48
 
51
49
  container = document.createElement("div");
@@ -153,7 +151,7 @@ describe("MessageContent", () => {
153
151
  (props.respondToApproval as () => void)();
154
152
  return <span data-testid="tool">tool:{String(props.toolName)}</span>;
155
153
  });
156
- h.state.tools.tools = { search: ToolRender };
154
+ h.state.tools.toolUIs = { search: [{ render: ToolRender }] };
157
155
 
158
156
  await mount();
159
157
 
@@ -164,13 +162,15 @@ describe("MessageContent", () => {
164
162
  expect(h.respondToToolApproval).toHaveBeenCalledWith(0);
165
163
  });
166
164
 
167
- it("picks the first renderer when the registry holds an array", async () => {
165
+ it("picks the first registration when multiple are registered", async () => {
168
166
  h.state.message.content = [
169
167
  { type: "tool-call", toolName: "search", toolCallId: "c1" },
170
168
  ];
171
169
  const First = vi.fn(() => <span data-testid="first">first</span>);
172
170
  const Second = vi.fn(() => <span>second</span>);
173
- h.state.tools.tools = { search: [First, Second] };
171
+ h.state.tools.toolUIs = {
172
+ search: [{ render: First }, { render: Second }],
173
+ };
174
174
 
175
175
  await mount();
176
176
 
@@ -265,8 +265,8 @@ describe("MessageContent", () => {
265
265
  { type: "tool-call", toolName: "t", toolCallId: "c" },
266
266
  { type: "data", name: "d", data: {} },
267
267
  ];
268
- h.state.tools.tools = {
269
- t: () => <span>[tool]</span>,
268
+ h.state.tools.toolUIs = {
269
+ t: [{ render: () => <span>[tool]</span> }],
270
270
  };
271
271
  h.state.dataRenderers.renderers = {
272
272
  d: () => <span>[data]</span>,
@@ -65,17 +65,12 @@ const ToolUIDisplay = ({
65
65
  index: number;
66
66
  }) => {
67
67
  const aui = useAui();
68
- const Render = useAuiState((s) => {
69
- const renders = s.tools.tools[part.toolName];
70
- if (Array.isArray(renders)) return renders[0];
71
- return renders;
72
- });
73
-
74
- const partMethods = useMemo(
75
- () => aui.message().part({ index }),
76
- [aui, index],
68
+ const Render = useAuiState(
69
+ (s) => s.tools.toolUIs[part.toolName]?.[0]?.render,
77
70
  );
78
71
 
72
+ const partMethods = useMemo(() => aui.message.part({ index }), [aui, index]);
73
+
79
74
  if (Render) {
80
75
  return (
81
76
  <Render
@@ -161,7 +161,7 @@ const ThreadMessageByChildren = memo(
161
161
  return (
162
162
  <MessageByIndexProvider index={index}>
163
163
  <RenderChildrenWithAccessor
164
- getItemState={(aui) => aui.thread().message({ index }).getState()}
164
+ getItemState={(aui) => aui.thread.message({ index }).getState()}
165
165
  >
166
166
  {(getItem) =>
167
167
  children({