Skip to content

Conversation

zAlweNy26
Copy link
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

With this PR, I wanted to add generics in both ChatMessage and ChatMessages so that the correct type can be inferred inside slots (like the metadata of every message)

πŸ“ Checklist

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

@github-actions github-actions bot added the v4 #4488 label Oct 19, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 19, 2025

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

commit: 03f44b2

Copy link
Member

@benjamincanac benjamincanac left a comment

Choose a reason for hiding this comment

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

I need to look more closely but I'm not sure the generic will work this way πŸ€” @sandros94 do you have an opinion on this?

@zAlweNy26
Copy link
Contributor Author

Hi @benjamincanac, thanks for the response. I tested it, and it seems to work. I only have some doubts about the implementation I did. I could have probably used the UIMessage as a generic for the ChatMessages component instead of the split generics of the UIMessage interface, but for the ChatMessage component, it can't be done since the component props extend it.

@sandros94
Copy link
Member

sandros94 commented Oct 23, 2025

I need to look more closely but I'm not sure the generic will work this way πŸ€” @sandros94 do you have an opinion on this?

Somehow I've missed this notification.

UChatMessage implementation is mostly correct, the issue is with UChatMessages which if the generics are passed this way you endup with the same generics for all messages as well as it does not propagate to slots correctly.

@zAlweNy26 I will leave a couple of reviews with what should be the required changes (tho I'm on mobile, thus I cannot test them directly)

@zAlweNy26
Copy link
Contributor Author

@benjamincanac @sandros94 should I open a PR also in the chat template to fix the error? Or this PR should be retro-compatible?

@zAlweNy26
Copy link
Contributor Author

Also I noticed a missing prop in the ChatMessage default slot, I hope it's ok to add the fix in this PR.

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.

3 participants