@assistant-ui/react 0.14.28 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ExternalThread.d.ts +11 -1
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +762 -516
- package/dist/client/ExternalThread.js.map +1 -1
- package/dist/client/InMemoryThreadList.js +3 -3
- package/dist/client/InMemoryThreadList.js.map +1 -1
- package/dist/context/index.d.ts +1 -8
- package/dist/context/index.js +1 -8
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -8
- package/dist/legacy-runtime/cloud/auiV0.d.ts +12 -1
- package/dist/legacy-runtime/cloud/auiV0.d.ts.map +1 -1
- package/dist/legacy-runtime/cloud/auiV0.js +2 -1
- package/dist/legacy-runtime/cloud/auiV0.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js +7 -6
- package/dist/legacy-runtime/runtime-cores/assistant-transport/commandQueue.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js +30 -15
- package/dist/legacy-runtime/runtime-cores/assistant-transport/runManager.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +11 -7
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js +1 -0
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useConvertedState.js.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +1 -1
- package/dist/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +26 -25
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +3 -3
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarRoot.js +3 -3
- package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts +7 -6
- package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts.map +1 -1
- package/dist/primitives/actionBar/useActionBarFloatStatus.js +10 -11
- package/dist/primitives/actionBar/useActionBarFloatStatus.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +4 -3
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +4 -3
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +11 -5
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAttachmentDropzone.js +2 -4
- package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
- package/dist/primitives/composer/ComposerInput.js +18 -16
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/primitives/composer/ComposerQuote.js +1 -1
- package/dist/primitives/composer/ComposerQuote.js.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +1 -0
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer/ComposerStopDictation.js +4 -3
- package/dist/primitives/composer/ComposerStopDictation.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js +3 -3
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
- package/dist/primitives/message/MessagePartsGrouped.js +67 -89
- package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
- package/dist/primitives/message/MessageRoot.js +3 -3
- package/dist/primitives/message/MessageRoot.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.js +4 -3
- package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemSteer.js +4 -3
- package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +1 -1
- package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +17 -15
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/thread/ThreadScrollToBottom.js +1 -0
- package/dist/primitives/thread/ThreadScrollToBottom.js.map +1 -1
- package/dist/unstable/useComposerInput.js +2 -2
- package/dist/unstable/useComposerInput.js.map +1 -1
- package/dist/unstable/useComposerInputHistory.js +6 -6
- package/dist/unstable/useComposerInputHistory.js.map +1 -1
- package/dist/unstable/useMentionAdapter.js +1 -1
- package/dist/unstable/useMentionAdapter.js.map +1 -1
- package/dist/utils/hooks/useOnResizeContent.js +1 -0
- package/dist/utils/hooks/useOnResizeContent.js.map +1 -1
- package/dist/utils/hooks/useSizeHandle.js +1 -0
- package/dist/utils/hooks/useSizeHandle.js.map +1 -1
- package/dist/utils/smooth/SmoothContext.js +3 -3
- package/dist/utils/smooth/SmoothContext.js.map +1 -1
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +3 -3
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/package.json +9 -9
- package/src/client/ExternalThread.ts +345 -56
- package/src/client/InMemoryThreadList.ts +3 -3
- package/src/context/index.ts +0 -44
- package/src/legacy-runtime/cloud/auiV0.ts +14 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/commandQueue.ts +4 -1
- package/src/legacy-runtime/runtime-cores/assistant-transport/runManager.ts +37 -10
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-delivery.test.tsx +79 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-parentid.test.tsx +97 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/transport-scheduling.test.ts +113 -2
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransport.spec.md +10 -2
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.test.tsx +185 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.ts +21 -5
- package/src/mcp-apps/McpAppRenderer.tsx +1 -1
- package/src/model-context/makeAssistantVisible.test.tsx +1 -1
- package/src/model-context/makeAssistantVisible.tsx +1 -1
- package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +1 -1
- package/src/primitives/actionBar/useActionBarFloatStatus.ts +7 -5
- package/src/primitives/attachment/AttachmentRemove.ts +1 -1
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.ts +1 -1
- package/src/primitives/composer/ComposerAddAttachment.test.tsx +108 -0
- package/src/primitives/composer/ComposerAddAttachment.ts +11 -5
- package/src/primitives/composer/ComposerAttachmentDropzone.test.tsx +5 -4
- package/src/primitives/composer/ComposerAttachmentDropzone.tsx +4 -3
- package/src/primitives/composer/ComposerInput.test.tsx +104 -7
- package/src/primitives/composer/ComposerInput.tsx +22 -20
- package/src/primitives/composer/ComposerQuote.tsx +1 -1
- package/src/primitives/composer/ComposerStopDictation.ts +1 -1
- package/src/primitives/composer/trigger/triggerSelectionResource.ts +7 -9
- package/src/primitives/message/MessagePartsGrouped.tsx +6 -8
- package/src/primitives/message/MessageRoot.tsx +1 -1
- package/src/primitives/queueItem/QueueItemRemove.ts +1 -1
- package/src/primitives/queueItem/QueueItemSteer.ts +1 -1
- package/src/primitives/selectionToolbar/SelectionToolbarQuote.tsx +1 -1
- package/src/primitives/suggestion/SuggestionTrigger.ts +9 -9
- package/src/tests/DataRenderers.test.tsx +212 -0
- package/src/tests/RemoteThreadListRuntime.adapterProvider.test.tsx +1 -11
- package/src/tests/RemoteThreadListRuntime.deferredProvider.test.tsx +3 -3
- package/src/tests/external-thread-attachments.test.tsx +300 -11
- package/src/tests/external-thread-branches.test.tsx +10 -10
- package/src/tests/external-thread-parity.test.tsx +230 -0
- package/src/tests/generative-ui.test.tsx +1 -46
- package/src/tests/local-runtime-queue.test.tsx +29 -34
- package/src/tests/messagePartSwitchRace.test.tsx +46 -15
- package/src/tests/messagePartTypeMismatch.test.tsx +2 -2
- package/src/tests/threadMessageById.test.tsx +0 -7
- package/src/unstable/useComposerInput.test.tsx +2 -2
- package/src/unstable/useComposerInput.ts +2 -2
- package/src/unstable/useComposerInputHistory.test.tsx +3 -3
- package/src/unstable/useComposerInputHistory.ts +6 -6
- package/src/unstable/useMentionAdapter.ts +1 -1
- package/src/utils/smooth/SmoothContext.tsx +1 -1
- package/src/utils/smooth/useSmooth.test.tsx +1 -1
- package/src/utils/smooth/useSmooth.ts +8 -5
- package/dist/context/react/utils/createStateHookForRuntime.d.ts +0 -34
- package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +0 -1
- package/dist/context/react/utils/createStateHookForRuntime.js +0 -21
- package/dist/context/react/utils/createStateHookForRuntime.js.map +0 -1
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts +0 -74
- package/dist/legacy-runtime/hooks/AssistantContext.d.ts.map +0 -1
- package/dist/legacy-runtime/hooks/AssistantContext.js +0 -29
- package/dist/legacy-runtime/hooks/AssistantContext.js.map +0 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +0 -1007
- package/dist/legacy-runtime/hooks/AttachmentContext.d.ts.map +0 -1
- package/dist/legacy-runtime/hooks/AttachmentContext.js +0 -47
- package/dist/legacy-runtime/hooks/AttachmentContext.js.map +0 -1
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts +0 -141
- package/dist/legacy-runtime/hooks/ComposerContext.d.ts.map +0 -1
- package/dist/legacy-runtime/hooks/ComposerContext.js +0 -65
- package/dist/legacy-runtime/hooks/ComposerContext.js.map +0 -1
- package/dist/legacy-runtime/hooks/MessageContext.d.ts +0 -155
- package/dist/legacy-runtime/hooks/MessageContext.d.ts.map +0 -1
- package/dist/legacy-runtime/hooks/MessageContext.js +0 -68
- package/dist/legacy-runtime/hooks/MessageContext.js.map +0 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +0 -44
- package/dist/legacy-runtime/hooks/MessagePartContext.d.ts.map +0 -1
- package/dist/legacy-runtime/hooks/MessagePartContext.js +0 -26
- package/dist/legacy-runtime/hooks/MessagePartContext.js.map +0 -1
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts +0 -139
- package/dist/legacy-runtime/hooks/ThreadContext.d.ts.map +0 -1
- package/dist/legacy-runtime/hooks/ThreadContext.js +0 -84
- package/dist/legacy-runtime/hooks/ThreadContext.js.map +0 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +0 -44
- package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts.map +0 -1
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js +0 -26
- package/dist/legacy-runtime/hooks/ThreadListItemContext.js.map +0 -1
- package/src/context/react/utils/createStateHookForRuntime.ts +0 -82
- package/src/legacy-runtime/hooks/AssistantContext.ts +0 -67
- package/src/legacy-runtime/hooks/AttachmentContext.ts +0 -99
- package/src/legacy-runtime/hooks/ComposerContext.ts +0 -131
- package/src/legacy-runtime/hooks/MessageContext.ts +0 -127
- package/src/legacy-runtime/hooks/MessagePartContext.ts +0 -32
- package/src/legacy-runtime/hooks/ThreadContext.ts +0 -120
- package/src/legacy-runtime/hooks/ThreadListItemContext.ts +0 -36
- package/src/tests/BaseComposerRuntimeCore.test.ts +0 -621
- package/src/tests/BaseSubscribable.test.ts +0 -54
- package/src/tests/DataRenderers.test.ts +0 -355
- package/src/tests/ExternalStoreThreadRuntimeCore.test.ts +0 -685
- package/src/tests/LocalThreadRuntimeCore.test.ts +0 -324
- package/src/tests/auiV0Encode.test.ts +0 -188
- package/src/tests/external-message-converter.test.ts +0 -346
- package/src/tests/shouldContinue.test.ts +0 -122
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessagePartsGrouped.js","names":["c","_c","ComponentType","FC","memo","PropsWithChildren","useMemo","useAuiState","useAui","PartByIndexProvider","TextMessagePartProvider","MessagePartPrimitiveText","MessagePartPrimitiveImage","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","MessagePartPrimitiveInProgress","MessagePartStatus","MessagePartGroup","groupKey","indices","GroupingFunction","parts","groupMessagePartsByParentId","groupMap","Map","i","length","part","parentId","groupId","get","push","set","groups","startsWith","undefined","useMessagePartsGrouped","groupingFunction","$","_temp","t0","bb0","t1","Symbol","for","MessagePrimitiveUnstable_PartsGrouped","Props","components","Empty","Text","Reasoning","Source","Image","File","Unstable_Audio","data","by_name","Record","Fallback","tools","Override","Group","ToolUIDisplay","props","toolName","s","Render","Array","isArray","Render_0","t2","DataUIDisplay","name","dataRenderers","renderers","defaultComponents","whiteSpace","fontFamily","children","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp2","type","t11","addResult","addToolResult","t12","resume","resumeToolCall","t13","respondToApproval","respondToToolApproval","t14","Tool","status","Error","Data","console","warn","MessagePartProps","partIndex","MessagePartImpl","MessagePart","prev","next","EmptyPartFallback","component","Component","COMPLETE_STATUS","Object","freeze","EmptyPartsImpl","_temp3","EmptyParts","contentLength","_temp4","messageGroups","group","groupIndex","GroupComponent","map","partsElements","displayName","MessagePrimitiveUnstable_PartsGroupedByParentId","Omit","message"],"sources":["../../../src/primitives/message/MessagePartsGrouped.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\nimport { PartByIndexProvider } from \"../../context/providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../context/providers/TextMessagePartProvider\";\nimport { MessagePartPrimitiveText } from \"../messagePart/MessagePartText\";\nimport { MessagePartPrimitiveImage } from \"../messagePart/MessagePartImage\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n} from \"@assistant-ui/core/react\";\nimport { MessagePartPrimitiveInProgress } from \"../messagePart/MessagePartInProgress\";\nimport type { MessagePartStatus } from \"@assistant-ui/core\";\n\ntype MessagePartGroup = {\n groupKey: string | undefined;\n indices: number[];\n};\n\nexport type GroupingFunction = (parts: readonly any[]) => MessagePartGroup[];\n\n/**\n * Groups message parts by their parent ID.\n * Parts without a parent ID appear in their chronological position as individual groups.\n * Parts with the same parent ID are grouped together at the position of their first occurrence.\n */\nconst groupMessagePartsByParentId: GroupingFunction = (\n parts: readonly any[],\n): MessagePartGroup[] => {\n // Map maintains insertion order, so groups appear in order of first occurrence\n const groupMap = new Map<string, number[]>();\n\n // Process each part in order\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n const parentId = part?.parentId as string | undefined;\n\n // For parts without parentId, assign a unique group ID to maintain their position\n const groupId = parentId ?? `__ungrouped_${i}`;\n\n // Get or create the indices array for this group\n const indices = groupMap.get(groupId) ?? [];\n indices.push(i);\n groupMap.set(groupId, indices);\n }\n\n // Convert map to array of groups\n const groups: MessagePartGroup[] = [];\n for (const [groupId, indices] of groupMap) {\n // Extract parentId (undefined for ungrouped parts)\n const groupKey = groupId.startsWith(\"__ungrouped_\") ? undefined : groupId;\n groups.push({ groupKey, indices });\n }\n\n return groups;\n};\n\nconst useMessagePartsGrouped = (\n groupingFunction: GroupingFunction,\n): MessagePartGroup[] => {\n const parts = useAuiState((s) => s.message.parts);\n\n return useMemo(() => {\n if (parts.length === 0) {\n return [];\n }\n return groupingFunction(parts);\n }, [parts, groupingFunction]);\n};\n\nexport namespace MessagePrimitiveUnstable_PartsGrouped {\n export type Props = {\n /**\n * Function that takes an array of message parts and returns an array of groups.\n * Each group contains a key (for identification) and an array of indices.\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * groupingFunction={(parts) => {\n * const groups = new Map<string, number[]>();\n * parts.forEach((part, i) => {\n * const key = part.parentId ?? `__ungrouped_${i}`;\n * const indices = groups.get(key) ?? [];\n * indices.push(i);\n * groups.set(key, indices);\n * });\n * return Array.from(groups.entries()).map(([key, indices]) => ({\n * key: key.startsWith(\"__ungrouped_\") ? undefined : key,\n * indices\n * }));\n * }}\n * ```\n *\n * @example\n * ```tsx\n * // Group by tool name\n * import { groupMessagePartsByToolName } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.Unstable_PartsGrouped\n * groupingFunction={groupMessagePartsByToolName}\n * components={{\n * Group: ({ key, indices, children }) => {\n * if (!key) return <>{children}</>;\n * return (\n * <div className=\"tool-group\">\n * <h4>Tool: {key}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\n groupingFunction: GroupingFunction;\n\n /**\n * Component configuration for rendering different types of message content.\n *\n * You can provide custom components for each content type (text, image, file, etc.)\n * and configure tool rendering behavior. If not provided, default components will be used.\n */\n components:\n | {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /** Component for rendering audio content (experimental) */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?:\n | {\n /** Map data event names to specific components */\n by_name?:\n | Record<string, DataMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n }\n | undefined;\n /** Configuration for tool call rendering */\n tools?:\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n }\n | undefined;\n\n /**\n * Component for rendering grouped message parts.\n *\n * When provided, this component will automatically wrap message parts that share\n * the same group key as determined by the groupingFunction.\n *\n * The component receives:\n * - `groupKey`: The group key (or undefined for ungrouped parts)\n * - `indices`: Array of indices for the parts in this group\n * - `children`: The rendered message part components\n *\n * @example\n * ```tsx\n * // Collapsible group\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <details className=\"message-group\">\n * <summary>\n * Group {groupKey} ({indices.length} parts)\n * </summary>\n * <div className=\"group-content\">\n * {children}\n * </div>\n * </details>\n * );\n * }\n * ```\n *\n * @param groupKey - The group key (undefined for ungrouped parts)\n * @param indices - Array of indices for the parts in this group\n * @param children - Rendered message part components to display within the group\n */\n Group?: ComponentType<\n PropsWithChildren<{\n groupKey: string | undefined;\n indices: number[];\n }>\n >;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState((s) => {\n const Render = s.tools.tools[props.toolName] ?? Fallback;\n if (Array.isArray(Render)) return Render[0] ?? Fallback;\n return Render;\n });\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) => {\n const Render = s.dataRenderers.renderers[props.name] ?? Fallback;\n if (Array.isArray(Render)) return Render[0] ?? Fallback;\n return Render;\n });\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <MessagePartPrimitiveText />\n <MessagePartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </MessagePartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Source: () => null,\n Image: () => <MessagePartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n Group: ({ children }) => children,\n} satisfies MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part().addToolResult;\n const resume = aui.part().resumeToolCall;\n const respondToApproval = aui.part().respondToToolApproval;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data = data?.by_name?.[part.name] ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\ntype MessagePartProps = {\n partIndex: number;\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartImpl: FC<MessagePartProps> = ({ partIndex, components }) => {\n return (\n <PartByIndexProvider index={partIndex}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n};\n\nconst MessagePart = memo(\n MessagePartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.Group === next.components?.Group,\n);\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\n/**\n * Renders the parts of a message grouped by a custom grouping function.\n *\n * This component allows you to group message parts based on any criteria you define.\n * The grouping function receives all message parts and returns an array of groups,\n * where each group has a key and an array of part indices.\n *\n * @deprecated Prefer `<MessagePrimitive.GroupedParts>` for adjacent\n * grouping — it dispatches all rendering through one `switch (part.type)`\n * and supports nested group paths. Keep this primitive only for\n * non-adjacent clustering (e.g., gathering parts with the same parent-id\n * across the message).\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * <MessagePrimitive.Unstable_PartsGrouped\n * components={{\n * Text: ({ text }) => <p className=\"message-text\">{text}</p>,\n * Image: ({ image }) => <img src={image} alt=\"Message image\" />,\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <div className=\"parent-group border rounded p-4\">\n * <h4>Parent ID: {groupKey}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\nexport const MessagePrimitiveUnstable_PartsGrouped: FC<\n MessagePrimitiveUnstable_PartsGrouped.Props\n> = ({ groupingFunction, components }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const messageGroups = useMessagePartsGrouped(groupingFunction);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n return messageGroups.map((group, groupIndex) => {\n const GroupComponent = components?.Group ?? defaultComponents.Group;\n\n return (\n <GroupComponent\n key={`group-${groupIndex}-${group.groupKey ?? \"ungrouped\"}`}\n groupKey={group.groupKey}\n indices={group.indices}\n >\n {group.indices.map((partIndex) => (\n <MessagePart\n key={partIndex}\n partIndex={partIndex}\n components={components}\n />\n ))}\n </GroupComponent>\n );\n });\n }, [messageGroups, components, contentLength]);\n\n return <>{partsElements}</>;\n};\n\nMessagePrimitiveUnstable_PartsGrouped.displayName =\n \"MessagePrimitive.Unstable_PartsGrouped\";\n\n/**\n * Renders the parts of a message grouped by their parent ID.\n * This is a convenience wrapper around Unstable_PartsGrouped with parent ID grouping.\n *\n * @deprecated Use MessagePrimitive.Unstable_PartsGrouped instead for more flexibility\n */\nexport const MessagePrimitiveUnstable_PartsGroupedByParentId: FC<\n Omit<MessagePrimitiveUnstable_PartsGrouped.Props, \"groupingFunction\">\n> = ({ components, ...props }) => {\n return (\n <MessagePrimitiveUnstable_PartsGrouped\n {...props}\n components={components}\n groupingFunction={groupMessagePartsByParentId}\n />\n );\n};\n\nMessagePrimitiveUnstable_PartsGroupedByParentId.displayName =\n \"MessagePrimitive.Unstable_PartsGroupedByParentId\";\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,MAAM+B,+BACJD,UACuB;CAEvB,MAAME,2BAAW,IAAIC,IAAsB;CAG3C,KAAK,IAAIC,IAAI,GAAGA,IAAIJ,MAAMK,QAAQD,KAAK;EAKrC,MAAMI,UAJOR,MAAMI,EACE,EAAEG,YAGK,eAAeH;EAG3C,MAAMN,UAAUI,SAASO,IAAID,OAAO,KAAK,CAAA;EACzCV,QAAQY,KAAKN,CAAC;EACdF,SAASS,IAAIH,SAASV,OAAO;CAC/B;CAGA,MAAMc,SAA6B,CAAA;CACnC,KAAK,MAAM,CAACJ,SAASV,YAAYI,UAAU;EAEzC,MAAML,WAAWW,QAAQK,WAAW,cAAc,IAAIC,KAAAA,IAAYN;EAClEI,OAAOF,KAAK;GAAEb;GAAUC;EAAQ,CAAC;CACnC;CAEA,OAAOc;AACT;AAEA,MAAMG,0BAAyBC,qBAAA;CAAA,MAAAC,IAAA9C,EAAA,CAAA;CAG7B,MAAA6B,QAAcvB,YAAYyC,KAAsB;CAAE,IAAAC;CAAAC,KAAA;EAGhD,IAAIpB,MAAKK,WAAY,GAAC;GAAA,IAAAgB;GAAA,IAAAJ,EAAA,OAAAK,OAAAC,IAAA,2BAAA,GAAA;IACbF,KAAA,CAAA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AAhC,EAAA;CAAA,OAApBgC;AAAoB;AAG7BzB,sCAAsCuF,cACpC;;;;;;;AAQF,MAAaC,mDAET7F,OAAA;CAAA,MAAAF,IAAA9C,EAAA,CAAA;CAAA,IAAAuD;CAAA,IAAAgB;CAAA,IAAAzB,EAAA,OAAAE,IAAA;EAAC,CAAA,CAAAO,eAAAgB,SAAAvB;EAAwBF,EAAA,KAAAE;EAAAF,EAAA,KAAAS;EAAAT,EAAA,KAAAyB;CAAA,OAAA;EAAAhB,aAAAT,EAAA;EAAAyB,QAAAzB,EAAA;CAAA;CAAA,IAAAI;CAAA,IAAAJ,EAAA,OAAAS,cAAAT,EAAA,OAAAyB,OAAA;EAEzBrB,KAAA,oBAAC,uCAAD;GAAsC,GAChCqB;GACQhB;GACMzB,kBAAAA;EAA2B,CAAA;EAC7CgB,EAAA,KAAAS;EAAAT,EAAA,KAAAyB;EAAAzB,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,OAJFI;AAIE;AAIN2F,gDAAgDD,cAC9C;AAjb6B,SAAA7F,MAAA0B,GAAA;CAAA,OAGIA,EAACsE,QAAQlH;AAAM;AAyMU,SAAAsE,OAAA1B,GAAA;CAAA,OAa1BA,EAACtC;AAAK;AAwGc,SAAA+F,OAAAzD,GAAA;CAAA,OAE1CA,EAACsE,QAAQ/B,UAATc;AAAyD;AAuDjE,SAAAO,OAAA5D,GAAA;CAAA,OACuCA,EAACsE,QAAQlH,MAAMK;AAAO"}
|
|
1
|
+
{"version":3,"file":"MessagePartsGrouped.js","names":["c","_c","ComponentType","FC","memo","PropsWithChildren","useMemo","useAuiState","useAui","PartByIndexProvider","TextMessagePartProvider","MessagePartPrimitiveText","MessagePartPrimitiveImage","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","MessagePartPrimitiveInProgress","MessagePartStatus","MessagePartGroup","groupKey","indices","GroupingFunction","parts","groupMessagePartsByParentId","groupMap","Map","i","length","part","parentId","groupId","get","push","set","groups","startsWith","undefined","useMessagePartsGrouped","groupingFunction","$","_temp","t0","bb0","t1","Symbol","for","MessagePrimitiveUnstable_PartsGrouped","Props","components","Empty","Text","Reasoning","Source","Image","File","Unstable_Audio","data","by_name","Record","Fallback","tools","Override","Group","ToolUIDisplay","props","toolName","s","toolUIs","render","Render","t2","DataUIDisplay","name","dataRenderers","renderers","Array","isArray","Render_0","defaultComponents","whiteSpace","fontFamily","children","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp2","type","addResult","addToolResult","resume","resumeToolCall","respondToApproval","respondToToolApproval","t11","Tool","status","Error","Data","console","warn","MessagePartProps","partIndex","MessagePartImpl","MessagePart","prev","next","EmptyPartFallback","component","Component","COMPLETE_STATUS","Object","freeze","EmptyPartsImpl","_temp3","EmptyParts","contentLength","_temp4","messageGroups","group","groupIndex","GroupComponent","map","partsElements","displayName","MessagePrimitiveUnstable_PartsGroupedByParentId","Omit","message"],"sources":["../../../src/primitives/message/MessagePartsGrouped.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\nimport { PartByIndexProvider } from \"../../context/providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../context/providers/TextMessagePartProvider\";\nimport { MessagePartPrimitiveText } from \"../messagePart/MessagePartText\";\nimport { MessagePartPrimitiveImage } from \"../messagePart/MessagePartImage\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n} from \"@assistant-ui/core/react\";\nimport { MessagePartPrimitiveInProgress } from \"../messagePart/MessagePartInProgress\";\nimport type { MessagePartStatus } from \"@assistant-ui/core\";\n\ntype MessagePartGroup = {\n groupKey: string | undefined;\n indices: number[];\n};\n\nexport type GroupingFunction = (parts: readonly any[]) => MessagePartGroup[];\n\n/**\n * Groups message parts by their parent ID.\n * Parts without a parent ID appear in their chronological position as individual groups.\n * Parts with the same parent ID are grouped together at the position of their first occurrence.\n */\nconst groupMessagePartsByParentId: GroupingFunction = (\n parts: readonly any[],\n): MessagePartGroup[] => {\n // Map maintains insertion order, so groups appear in order of first occurrence\n const groupMap = new Map<string, number[]>();\n\n // Process each part in order\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n const parentId = part?.parentId as string | undefined;\n\n // For parts without parentId, assign a unique group ID to maintain their position\n const groupId = parentId ?? `__ungrouped_${i}`;\n\n // Get or create the indices array for this group\n const indices = groupMap.get(groupId) ?? [];\n indices.push(i);\n groupMap.set(groupId, indices);\n }\n\n // Convert map to array of groups\n const groups: MessagePartGroup[] = [];\n for (const [groupId, indices] of groupMap) {\n // Extract parentId (undefined for ungrouped parts)\n const groupKey = groupId.startsWith(\"__ungrouped_\") ? undefined : groupId;\n groups.push({ groupKey, indices });\n }\n\n return groups;\n};\n\nconst useMessagePartsGrouped = (\n groupingFunction: GroupingFunction,\n): MessagePartGroup[] => {\n const parts = useAuiState((s) => s.message.parts);\n\n return useMemo(() => {\n if (parts.length === 0) {\n return [];\n }\n return groupingFunction(parts);\n }, [parts, groupingFunction]);\n};\n\nexport namespace MessagePrimitiveUnstable_PartsGrouped {\n export type Props = {\n /**\n * Function that takes an array of message parts and returns an array of groups.\n * Each group contains a key (for identification) and an array of indices.\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * groupingFunction={(parts) => {\n * const groups = new Map<string, number[]>();\n * parts.forEach((part, i) => {\n * const key = part.parentId ?? `__ungrouped_${i}`;\n * const indices = groups.get(key) ?? [];\n * indices.push(i);\n * groups.set(key, indices);\n * });\n * return Array.from(groups.entries()).map(([key, indices]) => ({\n * key: key.startsWith(\"__ungrouped_\") ? undefined : key,\n * indices\n * }));\n * }}\n * ```\n *\n * @example\n * ```tsx\n * // Group by tool name\n * import { groupMessagePartsByToolName } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.Unstable_PartsGrouped\n * groupingFunction={groupMessagePartsByToolName}\n * components={{\n * Group: ({ key, indices, children }) => {\n * if (!key) return <>{children}</>;\n * return (\n * <div className=\"tool-group\">\n * <h4>Tool: {key}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\n groupingFunction: GroupingFunction;\n\n /**\n * Component configuration for rendering different types of message content.\n *\n * You can provide custom components for each content type (text, image, file, etc.)\n * and configure tool rendering behavior. If not provided, default components will be used.\n */\n components:\n | {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /** Component for rendering audio content (experimental) */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?:\n | {\n /** Map data event names to specific components */\n by_name?:\n | Record<string, DataMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n }\n | undefined;\n /** Configuration for tool call rendering */\n tools?:\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n }\n | undefined;\n\n /**\n * Component for rendering grouped message parts.\n *\n * When provided, this component will automatically wrap message parts that share\n * the same group key as determined by the groupingFunction.\n *\n * The component receives:\n * - `groupKey`: The group key (or undefined for ungrouped parts)\n * - `indices`: Array of indices for the parts in this group\n * - `children`: The rendered message part components\n *\n * @example\n * ```tsx\n * // Collapsible group\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <details className=\"message-group\">\n * <summary>\n * Group {groupKey} ({indices.length} parts)\n * </summary>\n * <div className=\"group-content\">\n * {children}\n * </div>\n * </details>\n * );\n * }\n * ```\n *\n * @param groupKey - The group key (undefined for ungrouped parts)\n * @param indices - Array of indices for the parts in this group\n * @param children - Rendered message part components to display within the group\n */\n Group?: ComponentType<\n PropsWithChildren<{\n groupKey: string | undefined;\n indices: number[];\n }>\n >;\n }\n | undefined;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState(\n (s) => s.tools.toolUIs[props.toolName]?.[0]?.render ?? Fallback,\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) => {\n const Render = s.dataRenderers.renderers[props.name] ?? Fallback;\n if (Array.isArray(Render)) return Render[0] ?? Fallback;\n return Render;\n });\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst defaultComponents = {\n Text: () => (\n <p style={{ whiteSpace: \"pre-line\" }}>\n <MessagePartPrimitiveText />\n <MessagePartPrimitiveInProgress>\n <span style={{ fontFamily: \"revert\" }}>{\" \\u25CF\"}</span>\n </MessagePartPrimitiveInProgress>\n </p>\n ),\n Reasoning: () => null,\n Source: () => null,\n Image: () => <MessagePartPrimitiveImage />,\n File: () => null,\n Unstable_Audio: () => null,\n Group: ({ children }) => children,\n} satisfies MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part.addToolResult;\n const resume = aui.part.resumeToolCall;\n const respondToApproval = aui.part.respondToToolApproval;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data = data?.by_name?.[part.name] ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\ntype MessagePartProps = {\n partIndex: number;\n components: MessagePrimitiveUnstable_PartsGrouped.Props[\"components\"];\n};\n\nconst MessagePartImpl: FC<MessagePartProps> = ({ partIndex, components }) => {\n return (\n <PartByIndexProvider index={partIndex}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n};\n\nconst MessagePart = memo(\n MessagePartImpl,\n (prev, next) =>\n prev.partIndex === next.partIndex &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.Group === next.components?.Group,\n);\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\n/**\n * Renders the parts of a message grouped by a custom grouping function.\n *\n * This component allows you to group message parts based on any criteria you define.\n * The grouping function receives all message parts and returns an array of groups,\n * where each group has a key and an array of part indices.\n *\n * @deprecated Prefer `<MessagePrimitive.GroupedParts>` for adjacent\n * grouping — it dispatches all rendering through one `switch (part.type)`\n * and supports nested group paths. Keep this primitive only for\n * non-adjacent clustering (e.g., gathering parts with the same parent-id\n * across the message).\n *\n * @example\n * ```tsx\n * // Group by parent ID (default behavior)\n * <MessagePrimitive.Unstable_PartsGrouped\n * components={{\n * Text: ({ text }) => <p className=\"message-text\">{text}</p>,\n * Image: ({ image }) => <img src={image} alt=\"Message image\" />,\n * Group: ({ groupKey, indices, children }) => {\n * if (!groupKey) return <>{children}</>;\n * return (\n * <div className=\"parent-group border rounded p-4\">\n * <h4>Parent ID: {groupKey}</h4>\n * {children}\n * </div>\n * );\n * }\n * }}\n * />\n * ```\n */\nexport const MessagePrimitiveUnstable_PartsGrouped: FC<\n MessagePrimitiveUnstable_PartsGrouped.Props\n> = ({ groupingFunction, components }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const messageGroups = useMessagePartsGrouped(groupingFunction);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n return messageGroups.map((group, groupIndex) => {\n const GroupComponent = components?.Group ?? defaultComponents.Group;\n\n return (\n <GroupComponent\n key={`group-${groupIndex}-${group.groupKey ?? \"ungrouped\"}`}\n groupKey={group.groupKey}\n indices={group.indices}\n >\n {group.indices.map((partIndex) => (\n <MessagePart\n key={partIndex}\n partIndex={partIndex}\n components={components}\n />\n ))}\n </GroupComponent>\n );\n });\n }, [messageGroups, components, contentLength]);\n\n return <>{partsElements}</>;\n};\n\nMessagePrimitiveUnstable_PartsGrouped.displayName =\n \"MessagePrimitive.Unstable_PartsGrouped\";\n\n/**\n * Renders the parts of a message grouped by their parent ID.\n * This is a convenience wrapper around Unstable_PartsGrouped with parent ID grouping.\n *\n * @deprecated Use MessagePrimitive.Unstable_PartsGrouped instead for more flexibility\n */\nexport const MessagePrimitiveUnstable_PartsGroupedByParentId: FC<\n Omit<MessagePrimitiveUnstable_PartsGrouped.Props, \"groupingFunction\">\n> = ({ components, ...props }) => {\n return (\n <MessagePrimitiveUnstable_PartsGrouped\n {...props}\n components={components}\n groupingFunction={groupMessagePartsByParentId}\n />\n );\n};\n\nMessagePrimitiveUnstable_PartsGroupedByParentId.displayName =\n \"MessagePrimitive.Unstable_PartsGroupedByParentId\";\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,MAAM+B,+BACJD,UAC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|
14
14
|
const aui = useAui();
|
|
15
15
|
let t0;
|
|
16
|
-
if ($[0] !== aui) {
|
|
17
|
-
t0 = () => aui.message
|
|
18
|
-
$[0] = aui;
|
|
16
|
+
if ($[0] !== aui.message) {
|
|
17
|
+
t0 = () => aui.message;
|
|
18
|
+
$[0] = aui.message;
|
|
19
19
|
$[1] = t0;
|
|
20
20
|
} else t0 = $[1];
|
|
21
21
|
const message = useAuiState(t0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","ForwardedRef","useCallback","useAui","useAuiState","useManagedRef","useComposedRefs","useThreadViewport","useThreadViewportStore","parseCssLength","ThreadViewportStore","NonNullable","ReturnType","useIsHoveringRef","$","aui","t0","message","t1","el","handleMouseEnter","setIsHovering","handleMouseLeave","addEventListener","matches","queueMicrotask","removeEventListener","callbackRef","useIsTopAnchorUser","activeAnchorId","_temp","s_0","s","role","index","thread","messages","length","at","id","isRunning","useIsTopAnchorTarget","activeTargetId","_temp2","isLast","useTopAnchorUserRef","active","threadViewportStore","getState","registerAnchorElement","callback","useTopAnchorTargetRef","state","clamp","topAnchorMessageClamp","registerAnchorTargetElement","tallerThan","visibleHeight","targetRefCallback","MessagePrimitiveRoot","Element","div","Props","MessagePrimitiveRootInternalProps","forwardedRef","MessagePrimitiveRootDefault","props","isHoveringRef","ref","messageId","_temp3","MessagePrimitiveRootTopAnchor","isTopAnchorUser","isTopAnchorTarget","topAnchorUserRef","topAnchorTargetRef","_temp4","t2","undefined","t3","t4","turnAnchor","displayName","topAnchorTurn","anchorId","targetId"],"sources":["../../../src/primitives/message/MessageRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n useCallback,\n} from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { parseCssLength } from \"../thread/topAnchor/topAnchorUtils\";\n\ntype ThreadViewportStore = NonNullable<\n ReturnType<typeof useThreadViewportStore>\n>;\n\nconst useIsHoveringRef = () => {\n const aui = useAui();\n const message = useAuiState(() => aui.message());\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n const handleMouseEnter = () => {\n message.setIsHovering(true);\n };\n const handleMouseLeave = () => {\n message.setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n if (el.matches(\":hover\")) {\n // TODO this is needed for SSR to work, figure out why\n queueMicrotask(() => message.setIsHovering(true));\n }\n\n return () => {\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n message.setIsHovering(false);\n };\n },\n [message],\n );\n\n return useManagedRef(callbackRef);\n};\n\nconst useIsTopAnchorUser = () => {\n const activeAnchorId = useThreadViewport((s) => s.topAnchorTurn?.anchorId);\n return useAuiState(\n (s) =>\n s.message.role === \"user\" &&\n s.message.index > 0 &&\n s.message.index === s.thread.messages.length - 2 &&\n s.thread.messages.at(-1)?.role === \"assistant\" &&\n (s.message.id === activeAnchorId || s.thread.isRunning),\n );\n};\n\nconst useIsTopAnchorTarget = () => {\n const activeTargetId = useThreadViewport((s) => s.topAnchorTurn?.targetId);\n return useAuiState(\n (s) =>\n s.message.isLast &&\n s.message.role === \"assistant\" &&\n s.message.index >= 1 &&\n s.thread.messages.at(s.message.index - 1)?.role === \"user\" &&\n (s.message.id === activeTargetId || s.thread.isRunning),\n );\n};\n\nconst useTopAnchorUserRef = (\n active: boolean,\n threadViewportStore: ThreadViewportStore,\n) => {\n const callback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n return threadViewportStore.getState().registerAnchorElement(el);\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(callback);\n};\n\nconst useTopAnchorTargetRef = ({\n active,\n threadViewportStore,\n}: {\n active: boolean;\n threadViewportStore: ThreadViewportStore;\n}) => {\n const targetRefCallback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n const state = threadViewportStore.getState();\n const clamp = state.topAnchorMessageClamp;\n\n return state.registerAnchorTargetElement(el, {\n tallerThan: parseCssLength(clamp.tallerThan, el),\n visibleHeight: parseCssLength(clamp.visibleHeight, el),\n });\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(targetRefCallback);\n};\n\nexport namespace MessagePrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\ntype MessagePrimitiveRootInternalProps = MessagePrimitiveRoot.Props & {\n forwardedRef: ForwardedRef<MessagePrimitiveRoot.Element>;\n};\n\nconst MessagePrimitiveRootDefault = ({\n forwardedRef,\n ...props\n}: MessagePrimitiveRootInternalProps) => {\n const isHoveringRef = useIsHoveringRef();\n const ref = useComposedRefs<HTMLDivElement>(forwardedRef, isHoveringRef);\n const messageId = useAuiState((s) => s.message.id);\n\n return <Primitive.div {...props} ref={ref} data-message-id={messageId} />;\n};\n\nconst MessagePrimitiveRootTopAnchor = ({\n forwardedRef,\n threadViewportStore,\n ...props\n}: MessagePrimitiveRootInternalProps & {\n threadViewportStore: ThreadViewportStore;\n}) => {\n const isHoveringRef = useIsHoveringRef();\n const isTopAnchorUser = useIsTopAnchorUser();\n const isTopAnchorTarget = useIsTopAnchorTarget();\n const topAnchorUserRef = useTopAnchorUserRef(\n isTopAnchorUser,\n threadViewportStore,\n );\n const topAnchorTargetRef = useTopAnchorTargetRef({\n active: isTopAnchorTarget,\n threadViewportStore,\n });\n const ref = useComposedRefs<HTMLDivElement>(\n forwardedRef,\n isHoveringRef,\n topAnchorUserRef,\n topAnchorTargetRef,\n );\n const messageId = useAuiState((s) => s.message.id);\n\n return (\n <Primitive.div\n {...props}\n ref={ref}\n data-message-id={messageId}\n data-aui-top-anchor-user={isTopAnchorUser ? \"\" : undefined}\n data-aui-top-anchor-target={isTopAnchorTarget ? \"\" : undefined}\n />\n );\n};\n\n/**\n * The root container component for a message.\n *\n * This component provides the foundational wrapper for message content and handles\n * hover state management for the message. It automatically tracks when the user\n * is hovering over the message, which can be used by child components like action bars.\n *\n * When `turnAnchor=\"top\"` is set on the viewport, this component automatically\n * registers itself as the top-anchor user message (when it's the previous user\n * message) or as the top-anchor target (when it's the streaming assistant\n * response). No additional component is required.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Root>\n * <MessagePrimitive.Content />\n * <ActionBarPrimitive.Root>\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * </ActionBarPrimitive.Root>\n * </MessagePrimitive.Root>\n * ```\n */\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRoot.Element,\n MessagePrimitiveRoot.Props\n>((props, forwardedRef) => {\n const threadViewportStore = useThreadViewportStore();\n // turnAnchor is initial-only viewport config (see ThreadViewportProvider).\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n\n if (turnAnchor === \"top\") {\n return (\n <MessagePrimitiveRootTopAnchor\n {...props}\n forwardedRef={forwardedRef}\n threadViewportStore={threadViewportStore}\n />\n );\n }\n return <MessagePrimitiveRootDefault {...props} forwardedRef={forwardedRef} />;\n});\n\nMessagePrimitiveRoot.displayName = \"MessagePrimitive.Root\";\n"],"mappings":";;;;;;;;;;;AAuBA,MAAMkB,yBAAmB;CAAA,MAAAC,IAAAlB,EAAA,CAAA;CACvB,MAAAmB,MAAYZ,OAAO;CAAE,IAAAa;CAAA,IAAAF,EAAA,OAAAC,KAAA;EACOC,WAAMD,IAAGE,QAAS;EAACH,EAAA,KAAAC;EAAAD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAA/C,MAAAG,UAAgBb,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GACxBkD;IACUF;IACOjB;GAAmB,CAAA;GACxCjC,EAAA,KAAAkD;GAAAlD,EAAA,KAAAoD;GAAApD,EAAA,KAAAiC;GAAAjC,EAAA,KAAAE;EAAA,OAAAA,KAAAF,EAAA;EAAA,OAJFE;CAIE;CAEL,IAAAA;CAAA,IAAAF,EAAA,OAAAkD,gBAAAlD,EAAA,OAAAoD,OAAA;EACMlD,KAAA,oBAAC,6BAAD;GAA4B,GAAKkD;GAAqBF;EAAY,CAAA;EAAIlD,EAAA,KAAAkD;EAAAlD,EAAA,KAAAoD;EAAApD,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OAAtEE;AAAsE,CAC9E;AAED2C,qBAAqBuB,cAAc;AAnKR,SAAApD,MAAAE,GAAA;CAAA,OACuBA,EAACmD,eAAwBC;AAAA;AAW9C,SAAAzC,OAAAX,GAAA;CAAA,OACqBA,EAACmD,eAAwBE;AAAA;AA2DvC,SAAAf,OAAAtC,GAAA;CAAA,OAMGA,EAACf,QAAQsB;AAAG;AAKb,SAAAqC,OAAA5C,GAAA;CAAA,OAwBCA,EAACf,QAAQsB;AAAG"}
|
|
1
|
+
{"version":3,"file":"MessageRoot.js","names":["c","_c","Primitive","ComponentRef","forwardRef","ComponentPropsWithoutRef","ForwardedRef","useCallback","useAui","useAuiState","useManagedRef","useComposedRefs","useThreadViewport","useThreadViewportStore","parseCssLength","ThreadViewportStore","NonNullable","ReturnType","useIsHoveringRef","$","aui","t0","message","t1","el","handleMouseEnter","setIsHovering","handleMouseLeave","addEventListener","matches","queueMicrotask","removeEventListener","callbackRef","useIsTopAnchorUser","activeAnchorId","_temp","s_0","s","role","index","thread","messages","length","at","id","isRunning","useIsTopAnchorTarget","activeTargetId","_temp2","isLast","useTopAnchorUserRef","active","threadViewportStore","getState","registerAnchorElement","callback","useTopAnchorTargetRef","state","clamp","topAnchorMessageClamp","registerAnchorTargetElement","tallerThan","visibleHeight","targetRefCallback","MessagePrimitiveRoot","Element","div","Props","MessagePrimitiveRootInternalProps","forwardedRef","MessagePrimitiveRootDefault","props","isHoveringRef","ref","messageId","_temp3","MessagePrimitiveRootTopAnchor","isTopAnchorUser","isTopAnchorTarget","topAnchorUserRef","topAnchorTargetRef","_temp4","t2","undefined","t3","t4","turnAnchor","displayName","topAnchorTurn","anchorId","targetId"],"sources":["../../../src/primitives/message/MessageRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport {\n type ComponentRef,\n forwardRef,\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n useCallback,\n} from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport { useManagedRef } from \"../../utils/hooks/useManagedRef\";\nimport { useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\nimport { parseCssLength } from \"../thread/topAnchor/topAnchorUtils\";\n\ntype ThreadViewportStore = NonNullable<\n ReturnType<typeof useThreadViewportStore>\n>;\n\nconst useIsHoveringRef = () => {\n const aui = useAui();\n const message = useAuiState(() => aui.message);\n\n const callbackRef = useCallback(\n (el: HTMLElement) => {\n const handleMouseEnter = () => {\n message.setIsHovering(true);\n };\n const handleMouseLeave = () => {\n message.setIsHovering(false);\n };\n\n el.addEventListener(\"mouseenter\", handleMouseEnter);\n el.addEventListener(\"mouseleave\", handleMouseLeave);\n\n if (el.matches(\":hover\")) {\n // TODO this is needed for SSR to work, figure out why\n queueMicrotask(() => message.setIsHovering(true));\n }\n\n return () => {\n el.removeEventListener(\"mouseenter\", handleMouseEnter);\n el.removeEventListener(\"mouseleave\", handleMouseLeave);\n message.setIsHovering(false);\n };\n },\n [message],\n );\n\n return useManagedRef(callbackRef);\n};\n\nconst useIsTopAnchorUser = () => {\n const activeAnchorId = useThreadViewport((s) => s.topAnchorTurn?.anchorId);\n return useAuiState(\n (s) =>\n s.message.role === \"user\" &&\n s.message.index > 0 &&\n s.message.index === s.thread.messages.length - 2 &&\n s.thread.messages.at(-1)?.role === \"assistant\" &&\n (s.message.id === activeAnchorId || s.thread.isRunning),\n );\n};\n\nconst useIsTopAnchorTarget = () => {\n const activeTargetId = useThreadViewport((s) => s.topAnchorTurn?.targetId);\n return useAuiState(\n (s) =>\n s.message.isLast &&\n s.message.role === \"assistant\" &&\n s.message.index >= 1 &&\n s.thread.messages.at(s.message.index - 1)?.role === \"user\" &&\n (s.message.id === activeTargetId || s.thread.isRunning),\n );\n};\n\nconst useTopAnchorUserRef = (\n active: boolean,\n threadViewportStore: ThreadViewportStore,\n) => {\n const callback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n return threadViewportStore.getState().registerAnchorElement(el);\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(callback);\n};\n\nconst useTopAnchorTargetRef = ({\n active,\n threadViewportStore,\n}: {\n active: boolean;\n threadViewportStore: ThreadViewportStore;\n}) => {\n const targetRefCallback = useCallback(\n (el: HTMLElement) => {\n if (!active) return;\n const state = threadViewportStore.getState();\n const clamp = state.topAnchorMessageClamp;\n\n return state.registerAnchorTargetElement(el, {\n tallerThan: parseCssLength(clamp.tallerThan, el),\n visibleHeight: parseCssLength(clamp.visibleHeight, el),\n });\n },\n [active, threadViewportStore],\n );\n\n return useManagedRef<HTMLElement>(targetRefCallback);\n};\n\nexport namespace MessagePrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\ntype MessagePrimitiveRootInternalProps = MessagePrimitiveRoot.Props & {\n forwardedRef: ForwardedRef<MessagePrimitiveRoot.Element>;\n};\n\nconst MessagePrimitiveRootDefault = ({\n forwardedRef,\n ...props\n}: MessagePrimitiveRootInternalProps) => {\n const isHoveringRef = useIsHoveringRef();\n const ref = useComposedRefs<HTMLDivElement>(forwardedRef, isHoveringRef);\n const messageId = useAuiState((s) => s.message.id);\n\n return <Primitive.div {...props} ref={ref} data-message-id={messageId} />;\n};\n\nconst MessagePrimitiveRootTopAnchor = ({\n forwardedRef,\n threadViewportStore,\n ...props\n}: MessagePrimitiveRootInternalProps & {\n threadViewportStore: ThreadViewportStore;\n}) => {\n const isHoveringRef = useIsHoveringRef();\n const isTopAnchorUser = useIsTopAnchorUser();\n const isTopAnchorTarget = useIsTopAnchorTarget();\n const topAnchorUserRef = useTopAnchorUserRef(\n isTopAnchorUser,\n threadViewportStore,\n );\n const topAnchorTargetRef = useTopAnchorTargetRef({\n active: isTopAnchorTarget,\n threadViewportStore,\n });\n const ref = useComposedRefs<HTMLDivElement>(\n forwardedRef,\n isHoveringRef,\n topAnchorUserRef,\n topAnchorTargetRef,\n );\n const messageId = useAuiState((s) => s.message.id);\n\n return (\n <Primitive.div\n {...props}\n ref={ref}\n data-message-id={messageId}\n data-aui-top-anchor-user={isTopAnchorUser ? \"\" : undefined}\n data-aui-top-anchor-target={isTopAnchorTarget ? \"\" : undefined}\n />\n );\n};\n\n/**\n * The root container component for a message.\n *\n * This component provides the foundational wrapper for message content and handles\n * hover state management for the message. It automatically tracks when the user\n * is hovering over the message, which can be used by child components like action bars.\n *\n * When `turnAnchor=\"top\"` is set on the viewport, this component automatically\n * registers itself as the top-anchor user message (when it's the previous user\n * message) or as the top-anchor target (when it's the streaming assistant\n * response). No additional component is required.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.Root>\n * <MessagePrimitive.Content />\n * <ActionBarPrimitive.Root>\n * <ActionBarPrimitive.Copy />\n * <ActionBarPrimitive.Edit />\n * </ActionBarPrimitive.Root>\n * </MessagePrimitive.Root>\n * ```\n */\nexport const MessagePrimitiveRoot = forwardRef<\n MessagePrimitiveRoot.Element,\n MessagePrimitiveRoot.Props\n>((props, forwardedRef) => {\n const threadViewportStore = useThreadViewportStore();\n // turnAnchor is initial-only viewport config (see ThreadViewportProvider).\n const turnAnchor = threadViewportStore.getState().turnAnchor;\n\n if (turnAnchor === \"top\") {\n return (\n <MessagePrimitiveRootTopAnchor\n {...props}\n forwardedRef={forwardedRef}\n threadViewportStore={threadViewportStore}\n />\n );\n }\n return <MessagePrimitiveRootDefault {...props} forwardedRef={forwardedRef} />;\n});\n\nMessagePrimitiveRoot.displayName = \"MessagePrimitive.Root\";\n"],"mappings":";;;;;;;;;;;AAuBA,MAAMkB,yBAAmB;CAAA,MAAAC,IAAAlB,EAAA,CAAA;CACvB,MAAAmB,MAAYZ,OAAO;CAAE,IAAAa;CAAA,IAAAF,EAAA,OAAAC,IAAAE,SAAA;EACOD,WAAMD,IAAGE;EAAQH,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAA7C,MAAAG,UAAgBb,YAAYY,EAAiB;CAAE,IAAAE;CAAA,IAAAJ,EAAA,OAAAG,SAAA;EAG7CC,MAAAC,OAAA;GACE,MAAAC,yBAAyB;IACvBH,QAAOI,cAAe,IAAI;GAAC;GAE7B,MAAAC,yBAAyB;IACvBL,QAAOI,cAAe,KAAK;GAAC;GAG9BF,GAAEI,iBAAkB,cAAcH,gBAAgB;GAClDD,GAAEI,iBAAkB,cAAcD,gBAAgB;GAElD,IAAIH,GAAEK,QAAS,QAAQ,GAErBC,qBAAqBR,QAAOI,cAAe,IAAI,CAAC;GACjD,aAEM;IACLF,GAAEO,oBAAqB,cAAcN,gBAAgB;IACrDD,GAAEO,oBAAqB,cAAcJ,gBAAgB;IACrDL,QAAOI,cAAe,KAAK;GAAC;EAC7B;EACFP,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAED,OAEKT,cAAcsB,EAAW;AAAC;AAGnC,MAAMC,2BAAqB;CAAA,MAAAd,IAAAlB,EAAA,CAAA;CACzB,MAAAiC,iBAAuBtB,kBAAkBuB,KAAgC;CAAE,IAAAd;CAAA,IAAAF,EAAA,OAAAe,gBAAA;EAEzEb,MAAAe,QACEC,IAACf,QAAQgB,SAAU,UACnBD,IAACf,QAAQiB,QAAS,KAClBF,IAACf,QAAQi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
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/queueItem/QueueItemRemove.ts
|
|
6
7
|
const useQueueItemRemove = () => {
|
|
7
8
|
const $ = c(2);
|
|
8
9
|
const aui = useAui();
|
|
9
10
|
let t0;
|
|
10
|
-
if ($[0] !== aui) {
|
|
11
|
+
if ($[0] !== aui.queueItem) {
|
|
11
12
|
t0 = () => {
|
|
12
|
-
aui.queueItem
|
|
13
|
+
aui.queueItem.remove();
|
|
13
14
|
};
|
|
14
|
-
$[0] = aui;
|
|
15
|
+
$[0] = aui.queueItem;
|
|
15
16
|
$[1] = t0;
|
|
16
17
|
} else t0 = $[1];
|
|
17
18
|
return t0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemRemove.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemRemove","$","aui","t0","queueItem","remove","callback","QueueItemPrimitiveRemove","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemRemove = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem
|
|
1
|
+
{"version":3,"file":"QueueItemRemove.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemRemove","$","aui","t0","queueItem","remove","callback","QueueItemPrimitiveRemove","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemRemove.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemRemove = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem.remove();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveRemove {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemRemove>;\n}\n\n/**\n * A button that removes this item from the queue.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Remove>×</QueueItemPrimitive.Remove>\n * ```\n */\nexport const QueueItemPrimitiveRemove = createActionButton(\n \"QueueItemPrimitive.Remove\",\n useQueueItemRemove,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,2BAAqB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACzB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,IAAAE,WAAA;EAEQD,WAAA;GAC3BD,IAAGE,UAAUC,OAAQ;EAAC;EACvBJ,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,2BAA2BV,mBACtC,6BACAG,kBACF"}
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
3
|
import { useAui } from "@assistant-ui/store";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/queueItem/QueueItemSteer.ts
|
|
6
7
|
const useQueueItemSteer = () => {
|
|
7
8
|
const $ = c(2);
|
|
8
9
|
const aui = useAui();
|
|
9
10
|
let t0;
|
|
10
|
-
if ($[0] !== aui) {
|
|
11
|
+
if ($[0] !== aui.queueItem) {
|
|
11
12
|
t0 = () => {
|
|
12
|
-
aui.queueItem
|
|
13
|
+
aui.queueItem.steer();
|
|
13
14
|
};
|
|
14
|
-
$[0] = aui;
|
|
15
|
+
$[0] = aui.queueItem;
|
|
15
16
|
$[1] = t0;
|
|
16
17
|
} else t0 = $[1];
|
|
17
18
|
return t0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItemSteer.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemSteer","$","aui","t0","queueItem","steer","callback","QueueItemPrimitiveSteer","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemSteer = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem
|
|
1
|
+
{"version":3,"file":"QueueItemSteer.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useAui","useCallback","useQueueItemSteer","$","aui","t0","queueItem","steer","callback","QueueItemPrimitiveSteer","Element","Props"],"sources":["../../../src/primitives/queueItem/QueueItemSteer.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useCallback } from \"react\";\n\nconst useQueueItemSteer = () => {\n const aui = useAui();\n\n const callback = useCallback(() => {\n aui.queueItem.steer();\n }, [aui]);\n\n return callback;\n};\n\nexport namespace QueueItemPrimitiveSteer {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useQueueItemSteer>;\n}\n\n/**\n * A button that steers the current run to process this queue item immediately.\n *\n * @example\n * ```tsx\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * ```\n */\nexport const QueueItemPrimitiveSteer = createActionButton(\n \"QueueItemPrimitive.Steer\",\n useQueueItemSteer,\n);\n"],"mappings":";;;;;;AAUA,MAAMO,0BAAoB;CAAA,MAAAC,IAAAP,EAAA,CAAA;CACxB,MAAAQ,MAAYJ,OAAO;CAAE,IAAAK;CAAA,IAAAF,EAAA,OAAAC,IAAAE,WAAA;EAEQD,WAAA;GAC3BD,IAAGE,UAAUC,MAAO;EAAC;EACtBJ,EAAA,KAAAC,IAAAE;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAS,OAEHK;AAAQ;;;;;;;;;AAgBjB,MAAaC,0BAA0BV,mBACrC,4BACAG,iBACF"}
|
|
@@ -43,7 +43,7 @@ const SelectionToolbarPrimitiveQuote = forwardRef((t0, forwardedRef) => {
|
|
|
43
43
|
if ($[4] !== aui || $[5] !== info) {
|
|
44
44
|
t1 = () => {
|
|
45
45
|
if (!info) return;
|
|
46
|
-
aui.thread
|
|
46
|
+
aui.thread.composer().setQuote({
|
|
47
47
|
text: info.text,
|
|
48
48
|
messageId: info.messageId
|
|
49
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionToolbarQuote.js","names":["c","_c","Primitive","composeEventHandlers","ComponentPropsWithoutRef","ComponentRef","forwardRef","useCallback","useAui","useSelectionToolbarInfo","SelectionToolbarPrimitiveQuote","Element","button","Props","t0","forwardedRef","$","disabled","onClick","props","aui","info","t1","thread","composer","setQuote","text","messageId","window","getSelection","removeAllRanges","handleClick","t2","t3","t4","displayName"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarQuote.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n useCallback,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useSelectionToolbarInfo } from \"./SelectionToolbarRoot\";\n\nexport namespace SelectionToolbarPrimitiveQuote {\n export type Element = ComponentRef<typeof Primitive.button>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;\n}\n\n/**\n * A button that quotes the currently selected text.\n *\n * Must be placed inside `SelectionToolbarPrimitive.Root`. Reads the\n * selection info from context (captured by the Root), sets it as a\n * quote in the thread composer, and clears the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Quote>\n * <QuoteIcon /> Quote\n * </SelectionToolbarPrimitive.Quote>\n * ```\n */\nexport const SelectionToolbarPrimitiveQuote = forwardRef<\n SelectionToolbarPrimitiveQuote.Element,\n SelectionToolbarPrimitiveQuote.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const aui = useAui();\n const info = useSelectionToolbarInfo();\n\n const handleClick = useCallback(() => {\n if (!info) return;\n\n aui.thread
|
|
1
|
+
{"version":3,"file":"SelectionToolbarQuote.js","names":["c","_c","Primitive","composeEventHandlers","ComponentPropsWithoutRef","ComponentRef","forwardRef","useCallback","useAui","useSelectionToolbarInfo","SelectionToolbarPrimitiveQuote","Element","button","Props","t0","forwardedRef","$","disabled","onClick","props","aui","info","t1","thread","composer","setQuote","text","messageId","window","getSelection","removeAllRanges","handleClick","t2","t3","t4","displayName"],"sources":["../../../src/primitives/selectionToolbar/SelectionToolbarQuote.tsx"],"sourcesContent":["\"use client\";\n\nimport { Primitive } from \"../../utils/Primitive\";\nimport { composeEventHandlers } from \"@radix-ui/primitive\";\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n useCallback,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { useSelectionToolbarInfo } from \"./SelectionToolbarRoot\";\n\nexport namespace SelectionToolbarPrimitiveQuote {\n export type Element = ComponentRef<typeof Primitive.button>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.button>;\n}\n\n/**\n * A button that quotes the currently selected text.\n *\n * Must be placed inside `SelectionToolbarPrimitive.Root`. Reads the\n * selection info from context (captured by the Root), sets it as a\n * quote in the thread composer, and clears the selection.\n *\n * @example\n * ```tsx\n * <SelectionToolbarPrimitive.Quote>\n * <QuoteIcon /> Quote\n * </SelectionToolbarPrimitive.Quote>\n * ```\n */\nexport const SelectionToolbarPrimitiveQuote = forwardRef<\n SelectionToolbarPrimitiveQuote.Element,\n SelectionToolbarPrimitiveQuote.Props\n>(({ onClick, disabled, ...props }, forwardedRef) => {\n const aui = useAui();\n const info = useSelectionToolbarInfo();\n\n const handleClick = useCallback(() => {\n if (!info) return;\n\n aui.thread.composer().setQuote({\n text: info.text,\n messageId: info.messageId,\n });\n\n window.getSelection()?.removeAllRanges();\n }, [aui, info]);\n\n return (\n <Primitive.button\n type=\"button\"\n {...props}\n ref={forwardedRef}\n disabled={disabled || !info}\n onClick={composeEventHandlers(onClick, handleClick)}\n />\n );\n});\n\nSelectionToolbarPrimitiveQuote.displayName = \"SelectionToolbarPrimitive.Quote\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAaU,iCAAiCJ,YAG5CQ,IAAAC,iBAAA;CAAA,MAAAC,IAAAf,EAAA,EAAA;CAAA,IAAAgB;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAH,EAAA,OAAAF,IAAA;EAAC,CAAA,CAAAI,SAAAD,aAAAE,SAAAL;EAA+BE,EAAA,KAAAF;EAAAE,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAG;CAAA,OAAA;EAAAF,WAAAD,EAAA;EAAAE,UAAAF,EAAA;EAAAG,QAAAH,EAAA;CAAA;CAChC,MAAAI,MAAYZ,OAAO;CACnB,MAAAa,OAAaZ,wBAAwB;CAAE,IAAAa;CAAA,IAAAN,EAAA,OAAAI,OAAAJ,EAAA,OAAAK,MAAA;EAEPC,WAAA;GAC9B,IAAI,CAACD,MAAI;GAETD,IAAGG,OAAOC,SAAU,CAAC,CAAAC,SAAU;IAAAC,MACvBL,KAAIK;IAAKC,WACJN,KAAIM;GACjB,CAAC;GAEDC,OAAMC,aAA+B,CAAC,EAAAC,gBAAC;EAAC;EACzCd,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CATD,MAAAe,cAAoBT;CAgBN,MAAAU,KAAAf,YAAA,CAAaI;CAAI,IAAAY;CAAA,IAAAjB,EAAA,OAAAe,eAAAf,EAAA,OAAAE,SAAA;EAClBe,KAAA9B,qBAAqBe,SAASa,WAAW;EAACf,EAAA,KAAAe;EAAAf,EAAA,KAAAE;EAAAF,EAAA,KAAAiB;CAAA,OAAAA,KAAAjB,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,QAAAD,gBAAAC,EAAA,QAAAG,SAAAH,EAAA,QAAAgB,MAAAhB,EAAA,QAAAiB,IAAA;EALrDC,KAAA,oBAAA,UAAA,QAAA;GACO,MAAA;GAAQ,GACTf;GACCJ,KAAAA;GACK,UAAAiB;GACD,SAAAC;EAA0C,CAAA;EACnDjB,EAAA,MAAAD;EAAAC,EAAA,MAAAG;EAAAH,EAAA,MAAAgB;EAAAhB,EAAA,MAAAiB;EAAAjB,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAAA,OANFkB;AAME,CAEL;AAEDxB,+BAA+ByB,cAAc"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
3
3
|
import { useAui, useAuiState } from "@assistant-ui/store";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/suggestion/SuggestionTrigger.ts
|
|
6
7
|
const useSuggestionTrigger = (t0) => {
|
|
7
|
-
const $ = c(
|
|
8
|
+
const $ = c(6);
|
|
8
9
|
const { send, clearComposer: t1 } = t0;
|
|
9
10
|
const clearComposer = t1 === void 0 ? true : t1;
|
|
10
11
|
const aui = useAui();
|
|
@@ -12,30 +13,31 @@ const useSuggestionTrigger = (t0) => {
|
|
|
12
13
|
const prompt = useAuiState(_temp2);
|
|
13
14
|
const resolvedSend = send ?? false;
|
|
14
15
|
let t2;
|
|
15
|
-
if ($[0] !== aui || $[1] !==
|
|
16
|
+
if ($[0] !== aui.composer || $[1] !== aui.thread || $[2] !== clearComposer || $[3] !== prompt || $[4] !== resolvedSend) {
|
|
16
17
|
t2 = () => {
|
|
17
|
-
const isRunning = aui.thread
|
|
18
|
+
const isRunning = aui.thread.getState().isRunning;
|
|
18
19
|
if (resolvedSend && !isRunning) {
|
|
19
|
-
aui.thread
|
|
20
|
+
aui.thread.append({
|
|
20
21
|
content: [{
|
|
21
22
|
type: "text",
|
|
22
23
|
text: prompt
|
|
23
24
|
}],
|
|
24
|
-
runConfig: aui.composer
|
|
25
|
+
runConfig: aui.composer.getState().runConfig
|
|
25
26
|
});
|
|
26
|
-
if (clearComposer) aui.composer
|
|
27
|
-
} else if (clearComposer) aui.composer
|
|
27
|
+
if (clearComposer) aui.composer.setText("");
|
|
28
|
+
} else if (clearComposer) aui.composer.setText(prompt);
|
|
28
29
|
else {
|
|
29
|
-
const currentText = aui.composer
|
|
30
|
-
aui.composer
|
|
30
|
+
const currentText = aui.composer.getState().text;
|
|
31
|
+
aui.composer.setText(currentText.trim() ? `${currentText} ${prompt}` : prompt);
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
|
-
$[0] = aui;
|
|
34
|
-
$[1] =
|
|
35
|
-
$[2] =
|
|
36
|
-
$[3] =
|
|
37
|
-
$[4] =
|
|
38
|
-
|
|
34
|
+
$[0] = aui.composer;
|
|
35
|
+
$[1] = aui.thread;
|
|
36
|
+
$[2] = clearComposer;
|
|
37
|
+
$[3] = prompt;
|
|
38
|
+
$[4] = resolvedSend;
|
|
39
|
+
$[5] = t2;
|
|
40
|
+
} else t2 = $[5];
|
|
39
41
|
const callback = t2;
|
|
40
42
|
if (disabled) return null;
|
|
41
43
|
return callback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuggestionTrigger.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useAuiState","useAui","useSuggestionTrigger","t0","$","send","clearComposer","t1","undefined","aui","disabled","_temp","prompt","_temp2","resolvedSend","t2","
|
|
1
|
+
{"version":3,"file":"SuggestionTrigger.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useAuiState","useAui","useSuggestionTrigger","t0","$","send","clearComposer","t1","undefined","aui","disabled","_temp","prompt","_temp2","resolvedSend","t2","composer","thread","isRunning","getState","append","content","type","text","runConfig","setText","currentText","trim","callback","SuggestionPrimitiveTrigger","Element","Props","s","isDisabled","s_0","suggestion"],"sources":["../../../src/primitives/suggestion/SuggestionTrigger.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useAuiState, useAui } from \"@assistant-ui/store\";\n\nconst useSuggestionTrigger = ({\n send,\n clearComposer = true,\n}: {\n /**\n * When true, automatically sends the message.\n * When false, replaces or appends the composer text with the suggestion - depending on the value of `clearComposer`.\n */\n send?: boolean | undefined;\n\n /**\n * Whether to clear the composer after sending.\n * When send is set to false, determines if composer text is replaced with suggestion (true, default),\n * or if it's appended to the composer text (false).\n *\n * @default true\n */\n clearComposer?: boolean | undefined;\n}) => {\n const aui = useAui();\n const disabled = useAuiState((s) => s.thread.isDisabled);\n const prompt = useAuiState((s) => s.suggestion.prompt);\n\n const resolvedSend = send ?? false;\n\n const callback = useCallback(() => {\n const isRunning = aui.thread.getState().isRunning;\n\n if (resolvedSend && !isRunning) {\n aui.thread.append({\n content: [{ type: \"text\", text: prompt }],\n runConfig: aui.composer.getState().runConfig,\n });\n if (clearComposer) {\n aui.composer.setText(\"\");\n }\n } else {\n if (clearComposer) {\n aui.composer.setText(prompt);\n } else {\n const currentText = aui.composer.getState().text;\n aui.composer.setText(\n currentText.trim() ? `${currentText} ${prompt}` : prompt,\n );\n }\n }\n }, [aui, resolvedSend, clearComposer, prompt]);\n\n if (disabled) return null;\n return callback;\n};\n\nexport namespace SuggestionPrimitiveTrigger {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useSuggestionTrigger>;\n}\n\n/**\n * A button that triggers the suggestion action (send or insert into composer).\n *\n * @example\n * ```tsx\n * <SuggestionPrimitive.Trigger send>\n * Click me\n * </SuggestionPrimitive.Trigger>\n * ```\n */\nexport const SuggestionPrimitiveTrigger = createActionButton(\n \"SuggestionPrimitive.Trigger\",\n useSuggestionTrigger,\n [\"send\", \"clearComposer\"],\n);\n"],"mappings":";;;;;;AAUA,MAAMQ,wBAAuBC,OAAA;CAAA,MAAAC,IAAAT,EAAA,CAAA;CAAC,MAAA,EAAAU,MAAAC,eAAAC,OAAAJ;CAE5B,MAAAG,gBAAAC,OAAAC,KAAAA,IAAA,OAAAD;CAiBA,MAAAE,MAAYR,OAAO;CACnB,MAAAS,WAAiBV,YAAYW,KAA0B;CACvD,MAAAC,SAAeZ,YAAYa,MAA0B;CAErD,MAAAC,eAAqBT,QAAA;CAAc,IAAAU;CAAA,IAAAX,EAAA,OAAAK,IAAAO,YAAAZ,EAAA,OAAAK,IAAAQ,UAAAb,EAAA,OAAAE,iBAAAF,EAAA,OAAAQ,UAAAR,EAAA,OAAAU,cAAA;EAENC,WAAA;GAC3B,MAAAG,YAAkBT,IAAGQ,OAAOE,SAAU,CAAC,CAAAD;GAEvC,IAAIJ,gBAAA,CAAiBI,WAAS;IAC5BT,IAAGQ,OAAOG,OAAQ;KAAAC,SACP,CAAC;MAAAC,MAAQ;MAAMC,MAAQX;KAAO,CAAC;KAACY,WAC9Bf,IAAGO,SAASG,SAAU,CAAC,CAAAK;IACpC,CAAC;IACD,IAAIlB,eACFG,IAAGO,SAASS,QAAS,EAAE;GACxB,OAED,IAAInB,eACFG,IAAGO,SAASS,QAASb,MAAM;QAAC;IAE5B,MAAAc,cAAoBjB,IAAGO,SAASG,SAAU,CAAC,CAAAI;IAC3Cd,IAAGO,SAASS,QACVC,YAAWC,KAA4C,IAAvD,GAAwBD,YAAW,GAAId,WAAvCA,MACF;GAAC;EAEJ;EACFR,EAAA,KAAAK,IAAAO;EAAAZ,EAAA,KAAAK,IAAAQ;EAAAb,EAAA,KAAAE;EAAAF,EAAA,KAAAQ;EAAAR,EAAA,KAAAU;EAAAV,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CArBD,MAAAwB,WAAiBb;CAuBjB,IAAIL,UAAQ,OAAS;CAAK,OACnBkB;AAAQ;;;;;;;;;;;AAkBjB,MAAaC,6BAA6B/B,mBACxC,+BACAI,sBACA,CAAC,QAAQ,eAAe,CAC1B;AAvE6B,SAAAS,MAAAqB,GAAA;CAAA,OAoBSA,EAACf,OAAOgB;AAAW;AApB5B,SAAApB,OAAAqB,KAAA;CAAA,OAqBOF,IAACG,WAAWvB;AAAO"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useThreadViewport, useThreadViewportStore } from "../../context/react/ThreadViewportContext.js";
|
|
3
3
|
import { createActionButton } from "../../utils/createActionButton.js";
|
|
4
4
|
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import "@assistant-ui/tap/react-shim";
|
|
5
6
|
//#region src/primitives/thread/ThreadScrollToBottom.ts
|
|
6
7
|
const useThreadScrollToBottom = (t0) => {
|
|
7
8
|
const $ = c(5);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadScrollToBottom.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useThreadViewport","useThreadViewportStore","useThreadScrollToBottom","Options","behavior","ScrollBehavior","t0","$","t1","undefined","isAtBottom","_temp","threadViewportStore","t2","getState","scrollToBottom","handleScrollToBottom","ThreadPrimitiveScrollToBottom","Element","Props","s"],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadScrollToBottom {\n export type Options = {\n behavior?: ScrollBehavior | undefined;\n };\n}\n\nconst useThreadScrollToBottom = ({\n behavior,\n}: useThreadScrollToBottom.Options = {}) => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom({ behavior });\n }, [threadViewportStore, behavior]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n [\"behavior\"],\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThreadScrollToBottom.js","names":["c","_c","ActionButtonElement","ActionButtonProps","createActionButton","useCallback","useThreadViewport","useThreadViewportStore","useThreadScrollToBottom","Options","behavior","ScrollBehavior","t0","$","t1","undefined","isAtBottom","_temp","threadViewportStore","t2","getState","scrollToBottom","handleScrollToBottom","ThreadPrimitiveScrollToBottom","Element","Props","s"],"sources":["../../../src/primitives/thread/ThreadScrollToBottom.ts"],"sourcesContent":["\"use client\";\n\nimport {\n type ActionButtonElement,\n type ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport {\n useThreadViewport,\n useThreadViewportStore,\n} from \"../../context/react/ThreadViewportContext\";\n\nexport namespace useThreadScrollToBottom {\n export type Options = {\n behavior?: ScrollBehavior | undefined;\n };\n}\n\nconst useThreadScrollToBottom = ({\n behavior,\n}: useThreadScrollToBottom.Options = {}) => {\n const isAtBottom = useThreadViewport((s) => s.isAtBottom);\n\n const threadViewportStore = useThreadViewportStore();\n\n const handleScrollToBottom = useCallback(() => {\n threadViewportStore.getState().scrollToBottom({ behavior });\n }, [threadViewportStore, behavior]);\n\n if (isAtBottom) return null;\n return handleScrollToBottom;\n};\n\nexport namespace ThreadPrimitiveScrollToBottom {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useThreadScrollToBottom>;\n}\n\nexport const ThreadPrimitiveScrollToBottom = createActionButton(\n \"ThreadPrimitive.ScrollToBottom\",\n useThreadScrollToBottom,\n [\"behavior\"],\n);\n"],"mappings":";;;;;;AAmBA,MAAMQ,2BAA0BI,OAAA;CAAA,MAAAC,IAAAZ,EAAA,CAAA;CAAA,IAAAa;CAAA,IAAAD,EAAA,OAAAD,IAAA;EAACE,KAAAF,OAAAG,KAAAA,IAAA,CAEK,IAFLH;EAEMC,EAAA,KAAAD;EAAAC,EAAA,KAAAC;CAAA,OAAAA,KAAAD,EAAA;CAFN,MAAA,EAAAH,aAAAI;CAG/B,MAAAE,aAAmBV,kBAAkBW,KAAmB;CAExD,MAAAC,sBAA4BX,uBAAuB;CAAE,IAAAY;CAAA,IAAAN,EAAA,OAAAH,YAAAG,EAAA,OAAAK,qBAAA;EAEZC,WAAA;GACvCD,oBAAmBE,SAAU,CAAC,CAAAC,eAAgB,EAAAX,SAAW,CAAC;EAAC;EAC5DG,EAAA,KAAAH;EAAAG,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAFD,MAAAS,uBAA6BH;CAI7B,IAAIH,YAAU,OAAS;CAAK,OACrBM;AAAoB;AAQ7B,MAAaC,gCAAgCnB,mBAC3C,kCACAI,yBACA,CAAC,UAAU,CACb;AAxBgC,SAAAS,MAAAS,GAAA;CAAA,OAGcA,EAACV;AAAW"}
|
|
@@ -36,9 +36,9 @@ function unstable_useComposerInput(options) {
|
|
|
36
36
|
const value = useComposerInputValue();
|
|
37
37
|
const isDisabled = useComposerInputDisabled(options?.disabled);
|
|
38
38
|
const setText = useCallback((text) => {
|
|
39
|
-
if (!aui.composer
|
|
39
|
+
if (!aui.composer.getState().isEditing) return;
|
|
40
40
|
flushTapSync(() => {
|
|
41
|
-
aui.composer
|
|
41
|
+
aui.composer.setText(text);
|
|
42
42
|
});
|
|
43
43
|
}, [aui]);
|
|
44
44
|
const { send: rawSend, disabled: sendDisabled } = useComposerSend();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComposerInput.js","names":["useCallback","useAui","flushTapSync","useComposerSend","ComposerSendOptions","TriggerPopoverAriaProps","useComposerInputDisabled","useComposerInputValue","useTriggerPopoverAriaProps","Unstable_UseComposerInputOptions","disabled","Unstable_ComposerInput","value","setText","text","send","options","isDisabled","canSend","unstable_useComposerInput","aui","composer","getState","isEditing","rawSend","sendDisabled","sendOptions","Unstable_TriggerPopoverAriaProps","unstable_useTriggerPopoverAriaProps"],"sources":["../../src/unstable/useComposerInput.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport { useComposerSend } from \"@assistant-ui/core/react\";\nimport type { ComposerSendOptions } from \"@assistant-ui/core/store\";\nimport {\n type TriggerPopoverAriaProps,\n useComposerInputDisabled,\n useComposerInputValue,\n useTriggerPopoverAriaProps,\n} from \"../primitives/composer/useComposerInputState\";\n\nexport type Unstable_UseComposerInputOptions = {\n /**\n * Disables the input in addition to the composer's own disabled sources\n * (thread disabled, active dictation). When disabled, `isDisabled` is `true`\n * and `canSend` is `false`.\n */\n disabled?: boolean | undefined;\n};\n\nexport type Unstable_ComposerInput = {\n /** Current composer text, or `\"\"` when the composer is not editing. */\n value: string;\n /**\n * Writes `text` into the composer, mirroring `ComposerPrimitive.Input`:\n * a no-op unless the composer is editing, committed via `flushTapSync` so the\n * controlled value stays in sync within the same tick.\n */\n setText(text: string): void;\n /**\n * Sends the current message when `canSend` is `true`; otherwise a no-op.\n * Accepts the same options as the composer send action.\n */\n send(options?: ComposerSendOptions): void;\n /**\n * Whether the input is disabled, combining the `disabled` option with the\n * composer's own disabled sources (thread disabled, active dictation).\n */\n isDisabled: boolean;\n /**\n * Whether a send is currently available. Matches `ComposerPrimitive.Send`\n * gating (non-empty editing composer, not running without queue support) and\n * is additionally `false` while `isDisabled`.\n */\n canSend: boolean;\n};\n\n/**\n * @deprecated Under active development and might change without notice.\n *\n * Headless bridge to the composer's text value and send action, for building a\n * custom composer input without `ComposerPrimitive.Input`. It is a thin bridge,\n * not a second input: it does not own keyboard behavior, autosize, IME or\n * contentEditable sync, paste/drop attachments, focus management, or rich-text\n * state. Spread `unstable_useTriggerPopoverAriaProps()` onto your element for\n * trigger-popover combobox semantics.\n *\n * @example\n * ```tsx\n * const { value, setText, send, isDisabled, canSend } = unstable_useComposerInput();\n * <textarea\n * value={value}\n * disabled={isDisabled}\n * onChange={(e) => setText(e.target.value)}\n * onKeyDown={(e) => {\n * if (e.key === \"Enter\" && !e.shiftKey && canSend) {\n * e.preventDefault();\n * send();\n * }\n * }}\n * />\n * ```\n */\nexport function unstable_useComposerInput(\n options?: Unstable_UseComposerInputOptions,\n): Unstable_ComposerInput {\n const aui = useAui();\n const value = useComposerInputValue();\n const isDisabled = useComposerInputDisabled(options?.disabled);\n\n const setText = useCallback(\n (text: string) => {\n if (!aui.composer
|
|
1
|
+
{"version":3,"file":"useComposerInput.js","names":["useCallback","useAui","flushTapSync","useComposerSend","ComposerSendOptions","TriggerPopoverAriaProps","useComposerInputDisabled","useComposerInputValue","useTriggerPopoverAriaProps","Unstable_UseComposerInputOptions","disabled","Unstable_ComposerInput","value","setText","text","send","options","isDisabled","canSend","unstable_useComposerInput","aui","composer","getState","isEditing","rawSend","sendDisabled","sendOptions","Unstable_TriggerPopoverAriaProps","unstable_useTriggerPopoverAriaProps"],"sources":["../../src/unstable/useComposerInput.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport { useComposerSend } from \"@assistant-ui/core/react\";\nimport type { ComposerSendOptions } from \"@assistant-ui/core/store\";\nimport {\n type TriggerPopoverAriaProps,\n useComposerInputDisabled,\n useComposerInputValue,\n useTriggerPopoverAriaProps,\n} from \"../primitives/composer/useComposerInputState\";\n\nexport type Unstable_UseComposerInputOptions = {\n /**\n * Disables the input in addition to the composer's own disabled sources\n * (thread disabled, active dictation). When disabled, `isDisabled` is `true`\n * and `canSend` is `false`.\n */\n disabled?: boolean | undefined;\n};\n\nexport type Unstable_ComposerInput = {\n /** Current composer text, or `\"\"` when the composer is not editing. */\n value: string;\n /**\n * Writes `text` into the composer, mirroring `ComposerPrimitive.Input`:\n * a no-op unless the composer is editing, committed via `flushTapSync` so the\n * controlled value stays in sync within the same tick.\n */\n setText(text: string): void;\n /**\n * Sends the current message when `canSend` is `true`; otherwise a no-op.\n * Accepts the same options as the composer send action.\n */\n send(options?: ComposerSendOptions): void;\n /**\n * Whether the input is disabled, combining the `disabled` option with the\n * composer's own disabled sources (thread disabled, active dictation).\n */\n isDisabled: boolean;\n /**\n * Whether a send is currently available. Matches `ComposerPrimitive.Send`\n * gating (non-empty editing composer, not running without queue support) and\n * is additionally `false` while `isDisabled`.\n */\n canSend: boolean;\n};\n\n/**\n * @deprecated Under active development and might change without notice.\n *\n * Headless bridge to the composer's text value and send action, for building a\n * custom composer input without `ComposerPrimitive.Input`. It is a thin bridge,\n * not a second input: it does not own keyboard behavior, autosize, IME or\n * contentEditable sync, paste/drop attachments, focus management, or rich-text\n * state. Spread `unstable_useTriggerPopoverAriaProps()` onto your element for\n * trigger-popover combobox semantics.\n *\n * @example\n * ```tsx\n * const { value, setText, send, isDisabled, canSend } = unstable_useComposerInput();\n * <textarea\n * value={value}\n * disabled={isDisabled}\n * onChange={(e) => setText(e.target.value)}\n * onKeyDown={(e) => {\n * if (e.key === \"Enter\" && !e.shiftKey && canSend) {\n * e.preventDefault();\n * send();\n * }\n * }}\n * />\n * ```\n */\nexport function unstable_useComposerInput(\n options?: Unstable_UseComposerInputOptions,\n): Unstable_ComposerInput {\n const aui = useAui();\n const value = useComposerInputValue();\n const isDisabled = useComposerInputDisabled(options?.disabled);\n\n const setText = useCallback(\n (text: string) => {\n if (!aui.composer.getState().isEditing) return;\n flushTapSync(() => {\n aui.composer.setText(text);\n });\n },\n [aui],\n );\n\n const { send: rawSend, disabled: sendDisabled } = useComposerSend();\n const canSend = !sendDisabled && !isDisabled;\n const send = useCallback(\n (sendOptions?: ComposerSendOptions) => {\n if (!canSend) return;\n rawSend(sendOptions);\n },\n [canSend, rawSend],\n );\n\n return { value, setText, send, isDisabled, canSend };\n}\n\nexport type Unstable_TriggerPopoverAriaProps = TriggerPopoverAriaProps;\n\n/**\n * @deprecated Under active development and might change without notice.\n *\n * ARIA combobox attributes for the focused element (typically the composer\n * input) describing the open trigger popover, per the WAI-ARIA editable\n * combobox pattern. Returns an empty object outside a `TriggerPopoverRoot` or\n * when no popover is open. Spread these last so they take precedence over any\n * matching ARIA props you set yourself, mirroring `ComposerPrimitive.Input`.\n *\n * @example\n * ```tsx\n * const aria = unstable_useTriggerPopoverAriaProps();\n * <textarea {...aria} />\n * ```\n */\nexport function unstable_useTriggerPopoverAriaProps(): Unstable_TriggerPopoverAriaProps {\n return useTriggerPopoverAriaProps();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgBmB,0BACdH,SACwB;CACxB,MAAMI,MAAMnB,OAAO;CACnB,MAAMW,QAAQL,sBAAsB;CACpC,MAAMU,aAAaX,yBAAyBU,SAASN,QAAQ;CAE7D,MAAMG,UAAUb,aACbc,SAAiB;EAChB,IAAI,CAACM,IAAIC,SAASC,SAAS,CAAC,CAACC,WAAW;EACxCrB,mBAAmB;GACjBkB,IAAIC,SAASR,QAAQC,IAAI;EAC3B,CAAC;CACH,GACA,CAACM,GAAG,CACN;CAEA,MAAM,EAAEL,MAAMS,SAASd,UAAUe,iBAAiBtB,gBAAgB;CAClE,MAAMe,UAAU,CAACO,gBAAgB,CAACR;CASlC,OAAO;EAAEL;EAAOC;EAASE,MARZf,aACV0B,gBAAsC;GACrC,IAAI,CAACR,SAAS;GACdM,QAAQE,WAAW;EACrB,GACA,CAACR,SAASM,OAAO,CAGMT;EAAME;EAAYC;CAAQ;AACrD;;;;;;;;;;;;;;;;AAmBA,SAAgBU,sCAAwE;CACtF,OAAOpB,2BAA2B;AACpC"}
|
|
@@ -44,7 +44,7 @@ function unstable_useComposerInputHistory() {
|
|
|
44
44
|
const popoverCtx = useTriggerPopoverRootContextOptional();
|
|
45
45
|
const browseRef = useRef(null);
|
|
46
46
|
useEffect(() => {
|
|
47
|
-
if (aui.composer
|
|
47
|
+
if (aui.composer.getState().type !== "thread") return void 0;
|
|
48
48
|
return aui.on("threadListItem.switchedTo", () => {
|
|
49
49
|
browseRef.current = null;
|
|
50
50
|
});
|
|
@@ -55,14 +55,14 @@ function unstable_useComposerInputHistory() {
|
|
|
55
55
|
if (e.nativeEvent.isComposing) return;
|
|
56
56
|
if (e.shiftKey || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
57
57
|
if (popoverCtx && popoverCtx.getActiveAria() !== null) return;
|
|
58
|
-
if (aui.composer
|
|
58
|
+
if (aui.composer.getState().type !== "thread") return;
|
|
59
59
|
const textarea = e.currentTarget;
|
|
60
60
|
const { selectionStart, selectionEnd, value } = textarea;
|
|
61
61
|
if (selectionStart !== selectionEnd) return;
|
|
62
62
|
if (browseRef.current && value !== browseRef.current.lastRecalledText) browseRef.current = null;
|
|
63
63
|
const browse = browseRef.current;
|
|
64
64
|
const commitText = (text) => {
|
|
65
|
-
flushTapSync(() => aui.composer
|
|
65
|
+
flushTapSync(() => aui.composer.setText(text));
|
|
66
66
|
requestAnimationFrame(() => {
|
|
67
67
|
textarea.setSelectionRange(text.length, text.length);
|
|
68
68
|
});
|
|
@@ -85,12 +85,12 @@ function unstable_useComposerInputHistory() {
|
|
|
85
85
|
if (!isOnFirstLine(value, selectionStart)) return;
|
|
86
86
|
if (!browse) {
|
|
87
87
|
if (value.trim() !== "") return;
|
|
88
|
-
const history = deriveHistory(aui.thread
|
|
88
|
+
const history = deriveHistory(aui.thread.getState().messages);
|
|
89
89
|
if (history.length === 0) return;
|
|
90
90
|
recall(history, 0, value);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
|
-
const history = deriveHistory(aui.thread
|
|
93
|
+
const history = deriveHistory(aui.thread.getState().messages);
|
|
94
94
|
const next = browse.cursor + 1;
|
|
95
95
|
if (next >= history.length) {
|
|
96
96
|
e.preventDefault();
|
|
@@ -107,7 +107,7 @@ function unstable_useComposerInputHistory() {
|
|
|
107
107
|
commitText(browse.draftSnapshot);
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
recall(deriveHistory(aui.thread
|
|
110
|
+
recall(deriveHistory(aui.thread.getState().messages), next, browse.draftSnapshot);
|
|
111
111
|
}, [aui, popoverCtx]);
|
|
112
112
|
return useMemo(() => ({ onKeyDown }), [onKeyDown]);
|
|
113
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComposerInputHistory.js","names":["useCallback","useEffect","useMemo","useRef","KeyboardEvent","KeyboardEventHandler","useAui","flushTapSync","ThreadMessage","getThreadMessageText","useTriggerPopoverRootContextOptional","Unstable_ComposerInputHistory","onKeyDown","HTMLTextAreaElement","BrowseState","cursor","draftSnapshot","lastRecalledText","deriveHistory","messages","entries","i","length","message","role","text","trim","push","isOnFirstLine","value","caret","slice","includes","isOnLastLine","unstable_useComposerInputHistory","aui","popoverCtx","browseRef","composer","getState","type","undefined","on","current","e","defaultPrevented","key","nativeEvent","isComposing","shiftKey","ctrlKey","metaKey","altKey","getActiveAria","textarea","currentTarget","selectionStart","selectionEnd","browse","commitText","setText","requestAnimationFrame","setSelectionRange","preventDefault","recall","history","entry","thread","next"],"sources":["../../src/unstable/useComposerInputHistory.ts"],"sourcesContent":["\"use client\";\n\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n type KeyboardEvent,\n type KeyboardEventHandler,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport type { ThreadMessage } from \"@assistant-ui/core\";\nimport { getThreadMessageText } from \"@assistant-ui/core/internal\";\nimport { useTriggerPopoverRootContextOptional } from \"../primitives/composer/trigger/TriggerPopoverRootContext\";\n\nexport type Unstable_ComposerInputHistory = {\n /** Keydown handler to spread onto `ComposerPrimitive.Input`. */\n onKeyDown: KeyboardEventHandler<HTMLTextAreaElement>;\n};\n\ntype BrowseState = {\n cursor: number;\n draftSnapshot: string;\n lastRecalledText: string;\n};\n\nconst deriveHistory = (messages: readonly ThreadMessage[]): string[] => {\n const entries: string[] = [];\n for (let i = messages.length - 1; i >= 0; i--) {\n const message = messages[i]!;\n if (message.role !== \"user\") continue;\n const text = getThreadMessageText(message).trim();\n if (!text) continue;\n if (entries[entries.length - 1] === text) continue;\n entries.push(text);\n }\n return entries;\n};\n\nconst isOnFirstLine = (value: string, caret: number): boolean =>\n !value.slice(0, caret).includes(\"\\n\");\n\nconst isOnLastLine = (value: string, caret: number): boolean =>\n !value.slice(caret).includes(\"\\n\");\n\n/**\n * @deprecated Under active development and might change without notice.\n *\n * Terminal-style input history for the thread composer: ArrowUp on an\n * empty draft recalls previously sent user messages (newest first),\n * ArrowDown steps back toward the newest and finally restores the draft\n * that was being typed when browsing started.\n *\n * Recall only triggers when the caret is on the first/last line with no\n * selection, so multi-line editing keeps native arrow behavior. The\n * handler yields to an open mention/slash popover, to IME composition,\n * to modifier keys, and to consumer handlers that already called\n * `preventDefault`. It is inert on edit composers.\n *\n * @example\n * ```tsx\n * const history = unstable_useComposerInputHistory();\n * <ComposerPrimitive.Input {...history} />\n * ```\n */\nexport function unstable_useComposerInputHistory(): Unstable_ComposerInputHistory {\n const aui = useAui();\n const popoverCtx = useTriggerPopoverRootContextOptional();\n const browseRef = useRef<BrowseState | null>(null);\n\n useEffect(() => {\n if (aui.composer
|
|
1
|
+
{"version":3,"file":"useComposerInputHistory.js","names":["useCallback","useEffect","useMemo","useRef","KeyboardEvent","KeyboardEventHandler","useAui","flushTapSync","ThreadMessage","getThreadMessageText","useTriggerPopoverRootContextOptional","Unstable_ComposerInputHistory","onKeyDown","HTMLTextAreaElement","BrowseState","cursor","draftSnapshot","lastRecalledText","deriveHistory","messages","entries","i","length","message","role","text","trim","push","isOnFirstLine","value","caret","slice","includes","isOnLastLine","unstable_useComposerInputHistory","aui","popoverCtx","browseRef","composer","getState","type","undefined","on","current","e","defaultPrevented","key","nativeEvent","isComposing","shiftKey","ctrlKey","metaKey","altKey","getActiveAria","textarea","currentTarget","selectionStart","selectionEnd","browse","commitText","setText","requestAnimationFrame","setSelectionRange","preventDefault","recall","history","entry","thread","next"],"sources":["../../src/unstable/useComposerInputHistory.ts"],"sourcesContent":["\"use client\";\n\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n type KeyboardEvent,\n type KeyboardEventHandler,\n} from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport type { ThreadMessage } from \"@assistant-ui/core\";\nimport { getThreadMessageText } from \"@assistant-ui/core/internal\";\nimport { useTriggerPopoverRootContextOptional } from \"../primitives/composer/trigger/TriggerPopoverRootContext\";\n\nexport type Unstable_ComposerInputHistory = {\n /** Keydown handler to spread onto `ComposerPrimitive.Input`. */\n onKeyDown: KeyboardEventHandler<HTMLTextAreaElement>;\n};\n\ntype BrowseState = {\n cursor: number;\n draftSnapshot: string;\n lastRecalledText: string;\n};\n\nconst deriveHistory = (messages: readonly ThreadMessage[]): string[] => {\n const entries: string[] = [];\n for (let i = messages.length - 1; i >= 0; i--) {\n const message = messages[i]!;\n if (message.role !== \"user\") continue;\n const text = getThreadMessageText(message).trim();\n if (!text) continue;\n if (entries[entries.length - 1] === text) continue;\n entries.push(text);\n }\n return entries;\n};\n\nconst isOnFirstLine = (value: string, caret: number): boolean =>\n !value.slice(0, caret).includes(\"\\n\");\n\nconst isOnLastLine = (value: string, caret: number): boolean =>\n !value.slice(caret).includes(\"\\n\");\n\n/**\n * @deprecated Under active development and might change without notice.\n *\n * Terminal-style input history for the thread composer: ArrowUp on an\n * empty draft recalls previously sent user messages (newest first),\n * ArrowDown steps back toward the newest and finally restores the draft\n * that was being typed when browsing started.\n *\n * Recall only triggers when the caret is on the first/last line with no\n * selection, so multi-line editing keeps native arrow behavior. The\n * handler yields to an open mention/slash popover, to IME composition,\n * to modifier keys, and to consumer handlers that already called\n * `preventDefault`. It is inert on edit composers.\n *\n * @example\n * ```tsx\n * const history = unstable_useComposerInputHistory();\n * <ComposerPrimitive.Input {...history} />\n * ```\n */\nexport function unstable_useComposerInputHistory(): Unstable_ComposerInputHistory {\n const aui = useAui();\n const popoverCtx = useTriggerPopoverRootContextOptional();\n const browseRef = useRef<BrowseState | null>(null);\n\n useEffect(() => {\n if (aui.composer.getState().type !== \"thread\") return undefined;\n\n return aui.on(\"threadListItem.switchedTo\", () => {\n browseRef.current = null;\n });\n }, [aui]);\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.defaultPrevented) return;\n if (e.key !== \"ArrowUp\" && e.key !== \"ArrowDown\") return;\n if (e.nativeEvent.isComposing) return;\n if (e.shiftKey || e.ctrlKey || e.metaKey || e.altKey) return;\n if (popoverCtx && popoverCtx.getActiveAria() !== null) return;\n if (aui.composer.getState().type !== \"thread\") return;\n\n const textarea = e.currentTarget;\n const { selectionStart, selectionEnd, value } = textarea;\n if (selectionStart !== selectionEnd) return;\n\n if (browseRef.current && value !== browseRef.current.lastRecalledText) {\n browseRef.current = null;\n }\n const browse = browseRef.current;\n\n const commitText = (text: string): void => {\n flushTapSync(() => aui.composer.setText(text));\n // React's controlled-value commit restores the pre-recall caret;\n // reposition after the commit, before paint.\n requestAnimationFrame(() => {\n textarea.setSelectionRange(text.length, text.length);\n });\n e.preventDefault();\n };\n\n const recall = (\n history: readonly string[],\n cursor: number,\n draftSnapshot: string,\n ): void => {\n const entry = history[cursor];\n if (entry === undefined) {\n e.preventDefault();\n return;\n }\n browseRef.current = { cursor, draftSnapshot, lastRecalledText: entry };\n commitText(entry);\n };\n\n if (e.key === \"ArrowUp\") {\n if (!isOnFirstLine(value, selectionStart)) return;\n\n if (!browse) {\n if (value.trim() !== \"\") return;\n const history = deriveHistory(aui.thread.getState().messages);\n if (history.length === 0) return;\n recall(history, 0, value);\n return;\n }\n\n const history = deriveHistory(aui.thread.getState().messages);\n const next = browse.cursor + 1;\n if (next >= history.length) {\n e.preventDefault();\n return;\n }\n recall(history, next, browse.draftSnapshot);\n return;\n }\n\n if (!browse) return;\n if (!isOnLastLine(value, selectionEnd)) return;\n\n const next = browse.cursor - 1;\n if (next < 0) {\n browseRef.current = null;\n commitText(browse.draftSnapshot);\n return;\n }\n\n const history = deriveHistory(aui.thread.getState().messages);\n recall(history, next, browse.draftSnapshot);\n },\n [aui, popoverCtx],\n );\n\n return useMemo(() => ({ onKeyDown }), [onKeyDown]);\n}\n"],"mappings":";;;;;;;AA2BA,MAAMkB,iBAAiBC,aAAiD;CACtE,MAAMC,UAAoB,CAAA;CAC1B,KAAK,IAAIC,IAAIF,SAASG,SAAS,GAAGD,KAAK,GAAGA,KAAK;EAC7C,MAAME,UAAUJ,SAASE;EACzB,IAAIE,QAAQC,SAAS,QAAQ;EAC7B,MAAMC,OAAOhB,qBAAqBc,OAAO,CAAC,CAACG,KAAK;EAChD,IAAI,CAACD,MAAM;EACX,IAAIL,QAAQA,QAAQE,SAAS,OAAOG,MAAM;EAC1CL,QAAQO,KAAKF,IAAI;CACnB;CACA,OAAOL;AACT;AAEA,MAAMQ,iBAAiBC,OAAeC,UACpC,CAACD,MAAME,MAAM,GAAGD,KAAK,CAAC,CAACE,SAAS,IAAI;AAEtC,MAAMC,gBAAgBJ,OAAeC,UACnC,CAACD,MAAME,MAAMD,KAAK,CAAC,CAACE,SAAS,IAAI;;;;;;;;;;;;;;;;;;;;;AAsBnC,SAAgBE,mCAAkE;CAChF,MAAMC,MAAM7B,OAAO;CACnB,MAAM8B,aAAa1B,qCAAq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