feat(ChatMessage/ChatMessages): add message generics
๐ Linked issue
โ Type of change
- [ ] ๐ Documentation (updates to the documentation or readme)
- [ ] ๐ Bug fix (a non-breaking change that fixes an issue)
- [x] ๐ 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.
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.
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)
@benjamincanac @sandros94 should I open a PR also in the chat template to fix the error? Or this PR should be retro-compatible?
Also I noticed a missing prop in the ChatMessage default slot, I hope it's ok to add the fix in this PR.