From 7d47f68f733d5b53978847b0ce517e76866bcf67 Mon Sep 17 00:00:00 2001 From: Peter Krenesky Date: Tue, 23 May 2023 19:15:20 -0700 Subject: [PATCH] Chat artifact list wasn't resetting when switching chats. --- frontend/chat/sidebar/SideBarArtifactList.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/chat/sidebar/SideBarArtifactList.js b/frontend/chat/sidebar/SideBarArtifactList.js index 881501ca..35d1c377 100644 --- a/frontend/chat/sidebar/SideBarArtifactList.js +++ b/frontend/chat/sidebar/SideBarArtifactList.js @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { HStack, VStack, Heading, Box, Text } from "@chakra-ui/react"; import { useColorMode } from "@chakra-ui/color-mode"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -26,6 +26,11 @@ const SideBarArtifactList = ({ queryRef }) => { const { chat } = usePreloadedQuery(ChatByIdQuery, queryRef); const [artifacts, setArtifacts] = useState(chat.task.artifacts); + // Reset artifacts when chat.id changes + useEffect(() => { + setArtifacts(chat.task.artifacts); + }, [chat.id]); + const { colorMode } = useColorMode(); // Handle incoming new messages and update message groups