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.
…AIState function
Here is an image of the bug - double divider on tool call![image](https://github.com/vercel/ai-chatbot/assets/69059597/a621020c-5b5d-4a4d-9606-797b4487de1e)
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.