diff --git a/packages/react/src/context/providers/MessageProvider.tsx b/packages/react/src/context/providers/MessageProvider.tsx index c90b55c5b..acdb4ab3c 100644 --- a/packages/react/src/context/providers/MessageProvider.tsx +++ b/packages/react/src/context/providers/MessageProvider.tsx @@ -6,7 +6,7 @@ import type { CoreUserContentPart, ThreadMessage, } from "../../types/AssistantTypes"; -import { getMessageText } from "../../utils/getMessageText"; +import { getThreadMessageText } from "../../utils/getThreadMessageText"; import { MessageContext } from "../react/MessageContext"; import type { MessageContextValue } from "../react/MessageContext"; import { useThreadContext } from "../react/ThreadContext"; @@ -77,7 +77,7 @@ const useMessageContext = (messageIndex: number) => { "Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui.", ); - const text = getMessageText(message); + const text = getThreadMessageText(message); return text; }, diff --git a/packages/react/src/primitive-hooks/actionBar/useActionBarCopy.tsx b/packages/react/src/primitive-hooks/actionBar/useActionBarCopy.tsx index 5fcdf723c..d93591f19 100644 --- a/packages/react/src/primitive-hooks/actionBar/useActionBarCopy.tsx +++ b/packages/react/src/primitive-hooks/actionBar/useActionBarCopy.tsx @@ -1,7 +1,7 @@ import { useCallback } from "react"; import { useMessageContext } from "../../context/react/MessageContext"; import { useCombinedStore } from "../../utils/combined/useCombinedStore"; -import { getMessageText } from "../../utils/getMessageText"; +import { getThreadMessageText } from "../../utils/getThreadMessageText"; export type UseActionBarCopyProps = { copiedDuration?: number | undefined; @@ -27,7 +27,9 @@ export const useActionBarCopy = ({ const { setIsCopied } = useMessageUtils.getState(); const { isEditing, value: composerValue } = useEditComposer.getState(); - const valueToCopy = isEditing ? composerValue : getMessageText(message); + const valueToCopy = isEditing + ? composerValue + : getThreadMessageText(message); navigator.clipboard.writeText(valueToCopy).then(() => { setIsCopied(true); diff --git a/packages/react/src/utils/getMessageText.tsx b/packages/react/src/utils/getThreadMessageText.tsx similarity index 78% rename from packages/react/src/utils/getMessageText.tsx rename to packages/react/src/utils/getThreadMessageText.tsx index b38251ab4..76d38c242 100644 --- a/packages/react/src/utils/getMessageText.tsx +++ b/packages/react/src/utils/getThreadMessageText.tsx @@ -1,6 +1,6 @@ import type { TextContentPart, ThreadMessage } from "../types/AssistantTypes"; -export const getMessageText = (message: ThreadMessage) => { +export const getThreadMessageText = (message: ThreadMessage) => { const textParts = message.content.filter( (part) => part.type === "text", ) as TextContentPart[];