logoassistant-ui
Migrations

Migration to v0.11

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

  • TextContentPartTextMessagePart
  • ReasoningContentPartReasoningMessagePart
  • SourceContentPartSourceMessagePart
  • ImageContentPartImageMessagePart
  • FileContentPartFileMessagePart
  • Unstable_AudioContentPartUnstable_AudioMessagePart
  • ToolCallContentPartToolCallMessagePart
  • ContentPartStatusMessagePartStatus
  • ToolCallContentPartStatusToolCallMessagePartStatus

Thread Message Parts

  • ThreadUserContentPartThreadUserMessagePart
  • ThreadAssistantContentPartThreadAssistantMessagePart

Runtime and State Types

  • ContentPartRuntimeMessagePartRuntime
  • ContentPartStateMessagePartState

Hooks

  • useContentPartuseMessagePart
  • useContentPartRuntimeuseMessagePartRuntime
  • useContentPartTextuseMessagePartText
  • useContentPartReasoninguseMessagePartReasoning
  • useContentPartSourceuseMessagePartSource
  • useContentPartFileuseMessagePartFile
  • useContentPartImageuseMessagePartImage
  • useTextContentPartuseTextMessagePart

Component Types

  • EmptyContentPartComponentEmptyMessagePartComponent
  • TextContentPartComponentTextMessagePartComponent
  • ReasoningContentPartComponentReasoningMessagePartComponent
  • SourceContentPartComponentSourceMessagePartComponent
  • ImageContentPartComponentImageMessagePartComponent
  • FileContentPartComponentFileMessagePartComponent
  • Unstable_AudioContentPartComponentUnstable_AudioMessagePartComponent
  • ToolCallContentPartComponentToolCallMessagePartComponent

Props Types

  • EmptyContentPartPropsEmptyMessagePartProps
  • TextContentPartPropsTextMessagePartProps
  • ReasoningContentPartPropsReasoningMessagePartProps
  • SourceContentPartPropsSourceMessagePartProps
  • ImageContentPartPropsImageMessagePartProps
  • FileContentPartPropsFileMessagePartProps
  • Unstable_AudioContentPartPropsUnstable_AudioMessagePartProps
  • ToolCallContentPartPropsToolCallMessagePartProps

Providers and Context

  • TextContentPartProviderTextMessagePartProvider
  • TextContentPartProviderPropsTextMessagePartProviderProps
  • ContentPartRuntimeProviderMessagePartRuntimeProvider
  • ContentPartContextMessagePartContext
  • ContentPartContextValueMessagePartContextValue

Primitives

  • ContentPartPrimitiveMessagePartPrimitive
  • ContentPartPrimitiveTextMessagePartPrimitiveText
  • ContentPartPrimitiveImageMessagePartPrimitiveImage
  • ContentPartPrimitiveInProgressMessagePartPrimitiveInProgress

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 components={{ Text: MyText }} />

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/cli upgrade

Or run the specific migration:

npx @assistant-ui/cli 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 continue to work but are now deprecated and will be removed in a future major version.