Skip to content

feat(context): consolidate message UI overrides on the MessageUI slot - #3268

Merged
oliverlaz merged 1 commit into
release-v15from
feat/message-ui-override-cleanup
Aug 17, 2026
Merged

feat(context): consolidate message UI overrides on the MessageUI slot#3268
oliverlaz merged 1 commit into
release-v15from
feat/message-ui-override-cleanup

Conversation

@oliverlaz

@oliverlaz oliverlaz commented Aug 17, 2026

Copy link
Copy Markdown
Member

Goal

REACT-1027

ComponentContext.Message was deprecated in favour of MessageUI during v14 but never removed. Removing it surfaced four more ways to reach the same component — a Message prop on Message, MessageList, VirtualizedMessageList and Thread — now all collapsed onto the MessageUI slot.

BREAKING CHANGES:

  • ComponentContext.Message removed → use the MessageUI slot.

  • The Message prop is removed from Message, MessageList, VirtualizedMessageList and Thread, and therefore from additionalMessageListProps, additionalVirtualizedMessageListProps and additionalParentMessageProps. To replace a per-component prop, scope the slot to that subtree:

    // before
    <Thread Message={CustomThreadMessage} />
    
    // after
    <WithComponents overrides={{ MessageUI: CustomThreadMessage }}>
      <Thread />
    </WithComponents>
  • areMessagePropsEqual no longer compares the message UI component — it comes from context, and context updates re-render consumers regardless of React.memo.

VirtualMessage is unchanged and still wins inside VirtualizedMessageList, but now only within that list. Full migration detail: ai-docs/ai-migration-v14-v15.md.

Implementation details

MessageProps.Message was the transport VirtualizedMessageList and Thread used to inject their resolved component, so deleting it naively would have silently broken the VirtualMessage slot. Instead, VirtualizedMessageList applies VirtualMessage to its own subtree's ComponentContext — wrapping only when the slot is set — which also retires VirtuosoContext.Message. Thread's three-step resolution collapses entirely; context already carries the component. WithComponents now memoizes its merged override map: required, not cosmetic, since an unmemoized provider on the list's render path would defeat per-message memoization.

VirtualMessage had no test coverage, which is what made this risky. Added three tests — precedence, subtree scoping, unset fallback — and the precedence one fails on release-v15. They assert what useComponentContext() resolves to rather than inspecting rendered items, because Virtuoso renders zero items under jsdom and an item-level assertion would pass either way.

Verified: tsc -p tsconfig.lib.json --noEmit clean · yarn test 231 files, 2828 passed / 1 skipped · yarn lint-fix clean. Each documented failure mode was compiled to confirm it errors (TS2322 for props, TS2561 for override keys).

Unrelated change: the v14 → v15 guide also gains a section on the context-hook componentName removal from #3267, included at the author's request rather than split out.

UI Changes

None — override plumbing only; the default message UI and every existing MessageUI / VirtualMessage override render exactly as before.

The `Message` override was deprecated in favour of `MessageUI` during v14 but
never removed, so two context slots and four props all resolved to the same
component. Collapse them onto `MessageUI`.

Removing `MessageProps.Message` is not a pure deletion: it was the transport
`VirtualizedMessageList` and `Thread` used to inject their resolved component.
`VirtualizedMessageList` now applies `VirtualMessage` to its own subtree's
`ComponentContext` instead of drilling it through each `Message`, which also
retires `VirtuosoContext.Message`, and `Thread`'s three-step resolution
collapses entirely — context already carries the component.

BREAKING CHANGE:
- **`ComponentContext.Message` is removed.** Use the `MessageUI` slot.
- **The `Message` prop is removed from `Message`, `MessageList`,
  `VirtualizedMessageList` and `Thread`** (and therefore from
  `additionalMessageListProps`, `additionalVirtualizedMessageListProps` and
  `additionalParentMessageProps`). Override `MessageUI` via `WithComponents`;
  scope it to a subtree to replace a per-component prop. `VirtualMessage` is
  unchanged and still takes precedence inside `VirtualizedMessageList`, but now
  only within that list.
- **`areMessagePropsEqual` no longer compares the message UI component.** It is
  resolved from context, and context updates re-render consumers regardless of
  `React.memo`.

Also in this commit:
- `WithComponents` memoizes its merged override map, so a provider on the
  virtualized list's render path cannot defeat per-message memoization.
- ai-docs: the v14 -> v15 guide gains the message-UI override section plus a
  previously unwritten section on the context-hook `componentName` removal.

Closes REACT-1027
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 089019c6-dab0-4862-837e-7fb7a079be45

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@oliverlaz
oliverlaz had a problem deploying to Vite Example Public (Preview) August 17, 2026 12:36 — with GitHub Actions Failure
@oliverlaz
oliverlaz had a problem deploying to Vite Example Development (Preview) August 17, 2026 12:36 — with GitHub Actions Error
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-v15@9194215). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             release-v15    #3268   +/-   ##
==============================================
  Coverage               ?   84.46%           
==============================================
  Files                  ?      526           
  Lines                  ?    15939           
  Branches               ?     5108           
==============================================
  Hits                   ?    13463           
  Misses                 ?     2476           
  Partials               ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@oliverlaz
oliverlaz merged commit 0766489 into release-v15 Aug 17, 2026
10 of 12 checks passed
@oliverlaz
oliverlaz deleted the feat/message-ui-override-cleanup branch August 17, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants