diff --git a/src/components/App/SideBar/index.tsx b/src/components/App/SideBar/index.tsx index a10b46ec8..e5f4cd143 100644 --- a/src/components/App/SideBar/index.tsx +++ b/src/components/App/SideBar/index.tsx @@ -207,14 +207,16 @@ const Content = forwardRef(({ subViewOpen }, ref) = )} - {Object.keys(aiSummaryAnswers).map((i: string) => ( - - ))} + {Object.keys(aiSummaryAnswers) + .filter((key) => aiSummaryAnswers[key].shouldRender) + .map((i: string) => ( + + ))} {isLoading ? : !hasAiChats && } diff --git a/src/stores/useDataStore/index.ts b/src/stores/useDataStore/index.ts index 06600595c..bf43989e2 100644 --- a/src/stores/useDataStore/index.ts +++ b/src/stores/useDataStore/index.ts @@ -185,11 +185,15 @@ export const useDataStore = create()( if (data?.query_data?.ref_id) { useAiSummaryStore.setState({ aiRefId: data?.query_data?.ref_id }) + const { aiSummaryAnswers } = useAiSummaryStore.getState() + const { answer } = aiSummaryAnswers[data?.query_data?.ref_id] || {} + setAiSummaryAnswer(data?.query_data?.ref_id, { question: AISearchQuery, - answer: '', - answerLoading: true, - sourcesLoading: true, + answer: answer || '', + answerLoading: !answer, + sourcesLoading: !answer, + shouldRender: true, }) } diff --git a/src/types/index.ts b/src/types/index.ts index 5f1e6ee57..92927aaa1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -313,6 +313,7 @@ export type AIEntity = { questionsLoading?: boolean hasBeenRendered?: boolean entities?: ExtractedEntity[] + shouldRender?: boolean } export interface ExtractedEntity {