ContentPart renamed to MessagePart#
All ContentPart-related types, hooks, and components have been renamed to MessagePart for better semantic clarity and consistency.
What changed#
The following types and components have been renamed:
Core Types#
TextContentPart→TextMessagePartReasoningContentPart→ReasoningMessagePartSourceContentPart→SourceMessagePartImageContentPart→ImageMessagePartFileContentPart→FileMessagePartUnstable_AudioContentPart→Unstable_AudioMessagePartToolCallContentPart→ToolCallMessagePartContentPartStatus→MessagePartStatusToolCallContentPartStatus→ToolCallMessagePartStatus
Thread Message Parts#
ThreadUserContentPart→ThreadUserMessagePartThreadAssistantContentPart→ThreadAssistantMessagePart
Runtime and State Types#
ContentPartRuntime→MessagePartRuntimeContentPartState→MessagePartState
Hooks#
useContentPart→useMessagePartuseContentPartRuntime→useMessagePartRuntimeuseContentPartText→useMessagePartTextuseContentPartReasoning→useMessagePartReasoninguseContentPartSource→useMessagePartSourceuseContentPartFile→useMessagePartFileuseContentPartImage→useMessagePartImageuseTextContentPart→useMessagePartText
Component Types#
EmptyContentPartComponent→EmptyMessagePartComponentTextContentPartComponent→TextMessagePartComponentReasoningContentPartComponent→ReasoningMessagePartComponentSourceContentPartComponent→SourceMessagePartComponentImageContentPartComponent→ImageMessagePartComponentFileContentPartComponent→FileMessagePartComponentUnstable_AudioContentPartComponent→Unstable_AudioMessagePartComponentToolCallContentPartComponent→ToolCallMessagePartComponent
Props Types#
EmptyContentPartProps→EmptyMessagePartPropsTextContentPartProps→TextMessagePartPropsReasoningContentPartProps→ReasoningMessagePartPropsSourceContentPartProps→SourceMessagePartPropsImageContentPartProps→ImageMessagePartPropsFileContentPartProps→FileMessagePartPropsUnstable_AudioContentPartProps→Unstable_AudioMessagePartPropsToolCallContentPartProps→ToolCallMessagePartProps
Providers and Context#
TextContentPartProvider→TextMessagePartProviderTextContentPartProviderProps→TextMessagePartProviderPropsContentPartRuntimeProvider→MessagePartRuntimeProviderContentPartContext→MessagePartContextContentPartContextValue→MessagePartContextValue
Primitives#
ContentPartPrimitive→MessagePartPrimitiveContentPartPrimitiveText→MessagePartPrimitiveTextContentPartPrimitiveImage→MessagePartPrimitiveImageContentPartPrimitiveInProgress→MessagePartPrimitiveInProgress
MessagePrimitive.Content renamed to MessagePrimitive.Parts#
The MessagePrimitive.Content component has been renamed to MessagePrimitive.Parts to better reflect its purpose of rendering message parts.
-<MessagePrimitive.Content components={{ Text: MyText }} />
+<MessagePrimitive.Parts>
+ {({ part }) => part.type === "text" ? <MyText {...part} /> : null}
+</MessagePrimitive.Parts>
Migration#
To migrate your codebase automatically, use the migration codemod:
# IMPORTANT: make sure to commit all changes to git / create a backup before running the codemod
npx assistant-ui@latest upgrade
Or run the specific migration:
npx assistant-ui@latest codemod v0-11/content-part-to-message-part .
Manual Migration Examples#
If you prefer to migrate manually, here are some examples:
Imports:
-import { TextContentPart, useContentPart, ToolCallContentPartComponent } from "@assistant-ui/react";
+import { TextMessagePart, useMessagePart, ToolCallMessagePartComponent } from "@assistant-ui/react";
Type annotations:
-function processContent(part: TextContentPart): void {
+function processContent(part: TextMessagePart): void {
console.log(part.text);
}
-const MyTool: ToolCallContentPartComponent = ({ toolName }) => {
+const MyTool: ToolCallMessagePartComponent = ({ toolName }) => {
return <div>{toolName}</div>;
};
Hooks:
function MyComponent() {
- const part = useContentPart();
- const text = useContentPartText();
- const runtime = useContentPartRuntime();
+ const part = useMessagePart();
+ const text = useMessagePartText();
+ const runtime = useMessagePartRuntime();
return null;
}
JSX Components:
-<ContentPartPrimitive.Text />
-<ContentPartPrimitive.Image />
+<MessagePartPrimitive.Text />
+<MessagePartPrimitive.Image />
Providers:
-<TextContentPartProvider text="Hello" isRunning={false}>
+<TextMessagePartProvider text="Hello" isRunning={false}>
<div>Content</div>
-</TextContentPartProvider>
+</TextMessagePartProvider>
Why this change?#
The ContentPart naming was inconsistent with the rest of the codebase, where "message parts" are used throughout. This change improves semantic clarity and makes the API more intuitive by aligning terminology across the entire library.
The old ContentPart APIs have been completely removed. You must update all references to use the new MessagePart names.