diff --git a/web/app/components/app/chat/index.tsx b/web/app/components/app/chat/index.tsx index 0abdaab6d59de..f8be6e6e80e9d 100644 --- a/web/app/components/app/chat/index.tsx +++ b/web/app/components/app/chat/index.tsx @@ -212,16 +212,18 @@ const Chat: FC = ({ if (i === index) { return { ...item, - content: answer, annotation: { ...item.annotation, - logAnnotation: undefined, + logAnnotation: { + ...item.annotation?.logAnnotation, + content: answer, + }, } as any, } } return item })) - }, []) + }, [chatList]) const handleAnnotationAdded = useCallback((annotationId: string, authorName: string, query: string, answer: string, index: number) => { onChatListChange?.(chatList.map((item, i) => { if (i === index - 1) { @@ -251,7 +253,7 @@ const Chat: FC = ({ } return item })) - }, []) + }, [chatList]) const handleAnnotationRemoved = useCallback((index: number) => { onChatListChange?.(chatList.map((item, i) => { if (i === index) { @@ -261,12 +263,13 @@ const Chat: FC = ({ annotation: { ...(item.annotation || {}), id: '', + logAnnotation: undefined, // remove log } as Annotation, } } return item })) - }, []) + }, [chatList]) return (