Fix duplicate dividers caused by tool call messages in getUIStateFrom…
…AIState function
Here is an image of the bug - double divider on tool call
When loading message history, the current implementation of getUIStateFromAIState in ./lib/chat/actions.tsx results in duplicate dividers being rendered whenever a tool call message is present. This issue occurs due to how tool call messages are handled in the mapping logic without filtering out their assistant response counterparts.
This pull request addresses the issue by refining the mapping logic within getUIStateFromAIState. It introduces a filter to exclude assistant messages that are tool call responses, ensuring that only relevant messages are displayed without duplication.
Changes Made:
Added a filter condition to exclude assistant messages that are responses to tool calls. Updated the mapping logic to handle message display appropriately based on role and content type. This fix ensures a cleaner and more accurate rendering of message history, particularly when tool calls are involved, preventing unnecessary duplication of dividers.
@laurencebedford is attempting to deploy a commit to the Vercel Team on Vercel.
A member of the Team first needs to authorize it.
to fix #370
I cannot reproduce this issue.
Hi @leerob,
I tried reproducing the error. It occurs when you reload the page after using the tool call.
Double separator like @laurencebedford mentioned.
Tested on chat.vercel.ai too, but seems fine tho, no double separator. 🤷🏻♂️
Hi @leerob,
I tried reproducing the error. It occurs when you reload the page after using the tool call.
Double separator like @laurencebedford mentioned.
Im glad someone else is able to replicate this - it drove me crazy. This pull request sorts it. Let me know if you have any queries regarding the changes made.
we will fix this in the chatsdk revamp but thank you for the pr