Skip to content

feat(ChatMessage): add color prop and header slot#6407

Open
maximepvrt wants to merge 6 commits intonuxt:v4from
maximepvrt:messages
Open

feat(ChatMessage): add color prop and header slot#6407
maximepvrt wants to merge 6 commits intonuxt:v4from
maximepvrt:messages

Conversation

@maximepvrt
Copy link
Copy Markdown
Contributor

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@github-actions github-actions Bot added the v4 #4488 label Apr 28, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

Adds a color variant and default color: 'neutral' to the ChatMessage theme (colors derived from theme plus neutral) and moves visual class logic into compound variants. Introduces a color prop and a header slot on the ChatMessage component, forwards color into the component's computed UI config, and conditionally renders a data-slot="header" wrapper that can use files as fallback. Adds documentation for the color prop, a Nuxt playground page exposing color and variant controls, appends chat-message to navigation, and expands tests to cover color cases and the new header slot. No public APIs removed.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: adding a color prop and header slot to the ChatMessage component, which aligns with all file modifications.
Description check ✅ Passed The description is minimal and lacks implementation details, but it correctly identifies the change type as an Enhancement and is related to the ChatMessage component modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
playgrounds/nuxt/app/pages/components/chat-message.vue (1)

19-21: Consider adding required props to UChatMessage.

The UChatMessage component requires id, role, and parts props (or the deprecated content). While content is provided, consider using the recommended parts format with proper id and role for a complete example:

♻️ Suggested enhancement
   <Matrix v-slot="props" :attrs="attrs">
-    <UChatMessage content="My message" v-bind="props" />
+    <UChatMessage
+      id="demo-message"
+      role="user"
+      :parts="[{ type: 'text', text: 'My message' }]"
+      v-bind="props"
+    />
   </Matrix>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@playgrounds/nuxt/app/pages/components/chat-message.vue` around lines 19 - 21,
The UChatMessage usage currently passes only the deprecated content prop; update
the Matrix slot render to provide UChatMessage with the required props: include
a unique id, a role (e.g., "user" or "assistant"), and the parts array (instead
of content) constructed from the slot props; locate the Matrix v-slot and
replace the UChatMessage attributes so it receives id, role and parts (e.g.,
parts: [{ content_type: "text", text: "My message" }]) while still binding
remaining props via v-bind="props".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@playgrounds/nuxt/app/pages/components/chat-message.vue`:
- Around line 19-21: The UChatMessage usage currently passes only the deprecated
content prop; update the Matrix slot render to provide UChatMessage with the
required props: include a unique id, a role (e.g., "user" or "assistant"), and
the parts array (instead of content) constructed from the slot props; locate the
Matrix v-slot and replace the UChatMessage attributes so it receives id, role
and parts (e.g., parts: [{ content_type: "text", text: "My message" }]) while
still binding remaining props via v-bind="props".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bb48fc2c-84bf-4283-9508-db1616c6bbfd

📥 Commits

Reviewing files that changed from the base of the PR and between 4587079 and 28cc3f1.

⛔ Files ignored due to path filters (4)
  • test/components/__snapshots__/ChatMessage-vue.spec.ts.snap is excluded by !**/*.snap
  • test/components/__snapshots__/ChatMessage.spec.ts.snap is excluded by !**/*.snap
  • test/components/__snapshots__/ChatMessages-vue.spec.ts.snap is excluded by !**/*.snap
  • test/components/__snapshots__/ChatMessages.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • docs/content/docs/2.components/chat-message.md
  • playgrounds/nuxt/app/composables/useNavigation.ts
  • playgrounds/nuxt/app/pages/components/chat-message.vue
  • src/runtime/components/ChatMessage.vue
  • src/theme/chat-message.ts
  • test/components/ChatMessage.spec.ts

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
playgrounds/nuxt/app/pages/components/chat-message.vue (1)

19-21: Consider showcasing the new header slot in this playground.

This page already demonstrates the new color behavior well; adding a simple #header example would make the slot addition easier to discover interactively.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@playgrounds/nuxt/app/pages/components/chat-message.vue` around lines 19 - 21,
Add a small example of the new header slot to the playground by updating the
UChatMessage usage inside the Matrix v-slot block: keep the existing props and
parts but add a header slot (e.g., a <template `#header`> or v-slot:header on
UChatMessage) that renders simple header content like a title, role label or
timestamp so users can interactively see the new header slot behavior alongside
the existing color demo; modify the Matrix v-slot="props" / UChatMessage id="1"
block to include that header slot example.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@playgrounds/nuxt/app/pages/components/chat-message.vue`:
- Around line 19-21: Add a small example of the new header slot to the
playground by updating the UChatMessage usage inside the Matrix v-slot block:
keep the existing props and parts but add a header slot (e.g., a <template
`#header`> or v-slot:header on UChatMessage) that renders simple header content
like a title, role label or timestamp so users can interactively see the new
header slot behavior alongside the existing color demo; modify the Matrix
v-slot="props" / UChatMessage id="1" block to include that header slot example.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4421a0cd-6c48-440d-b519-6e11e0c25535

📥 Commits

Reviewing files that changed from the base of the PR and between 28cc3f1 and d038310.

📒 Files selected for processing (1)
  • playgrounds/nuxt/app/pages/components/chat-message.vue

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 28, 2026

npm i https://pkg.pr.new/@nuxt/ui@6407

commit: 736ee06

Comment thread src/theme/chat-message.ts
leadingIcon: 'shrink-0',
leadingAvatar: 'shrink-0',
leadingAvatarSize: '',
files: 'flex items-center gap-1.5 mb-1.5',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maximepvrt I'm wondering if the mb-1.5 should not go on header slot now 🤔

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/components/ChatMessage.spec.ts (1)

31-31: ⚡ Quick win

header slot test only checks render, not slot-prop forwarding.

The new with header slot case verifies the slot renders without error, which is the minimum bar. The PR summary notes the header slot can receive slot props (e.g., files as a fallback). If the slot exposes any props, there is no assertion that confirms they are correctly forwarded — analogous to the existing forwards id, role, parts, metadata and content test for the content slot.

Consider adding a dedicated test that captures the header slot's props and asserts their shape, matching whatever ChatMessage.vue exposes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/components/ChatMessage.spec.ts` at line 31, The 'with header slot' test
only verifies render but doesn't assert that slot props are forwarded; update
the ChatMessage.spec.ts case named 'with header slot' to provide the header slot
as a function that captures the received slotProps into a variable and assert
its shape/values (e.g., that it includes the expected files fallback or whatever
props ChatMessage.vue exposes). Mirror the pattern used in the existing
"forwards id, role, parts, metadata and content" test: render the header slot as
a function, capture slotProps, and add assertions on keys/types/expected values
to confirm proper forwarding from ChatMessage.vue.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/components/ChatMessage.spec.ts`:
- Line 31: The 'with header slot' test only verifies render but doesn't assert
that slot props are forwarded; update the ChatMessage.spec.ts case named 'with
header slot' to provide the header slot as a function that captures the received
slotProps into a variable and assert its shape/values (e.g., that it includes
the expected files fallback or whatever props ChatMessage.vue exposes). Mirror
the pattern used in the existing "forwards id, role, parts, metadata and
content" test: render the header slot as a function, capture slotProps, and add
assertions on keys/types/expected values to confirm proper forwarding from
ChatMessage.vue.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d4140912-6446-447f-bbb4-0b287aca9348

📥 Commits

Reviewing files that changed from the base of the PR and between 5f278c3 and 736ee06.

📒 Files selected for processing (2)
  • src/runtime/components/ChatMessage.vue
  • test/components/ChatMessage.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/runtime/components/ChatMessage.vue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants