ai-chatbot icon indicating copy to clipboard operation
ai-chatbot copied to clipboard

Fix duplicate dividers caused by tool call messages in getUIStateFrom…

Open laurencebedford opened this issue 1 year ago • 5 comments

…AIState function

Here is an image of the bug - double divider on tool call image

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 avatar Jun 22 '24 20:06 laurencebedford

@laurencebedford is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jun 22 '24 20:06 vercel[bot]

to fix #370

laurencebedford avatar Jun 23 '24 11:06 laurencebedford

CleanShot 2024-07-01 at 19 04 42@2x I cannot reproduce this issue.

leerob avatar Jul 02 '24 00:07 leerob

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. 🤷🏻‍♂️

aerrata avatar Jul 29 '24 09:07 aerrata

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.

laurencebedford avatar Jul 29 '24 09:07 laurencebedford

we will fix this in the chatsdk revamp but thank you for the pr

dancer avatar Nov 01 '25 04:11 dancer