From e6bcd08f19232453ee33070b3aa8b212f61e2c38 Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Wed, 27 Nov 2024 15:45:29 -0700 Subject: [PATCH] Fix: fix fe code to not make requests when validating cache Signed-off-by: Daishan Peng --- .../components/knowledge/AgentKnowledgePanel.tsx | 4 ++-- .../components/knowledge/KnowledgeSourceDetail.tsx | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx b/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx index ea93c431c..91ebbb53e 100644 --- a/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx +++ b/ui/admin/app/components/knowledge/AgentKnowledgePanel.tsx @@ -97,7 +97,7 @@ export default function AgentKnowledgePanel({ ), { revalidateOnFocus: false, - refreshInterval: blockPollingLocalFiles ? undefined : 1000, + refreshInterval: blockPollingLocalFiles ? undefined : 5000, } ); const localFiles = useMemo( @@ -110,7 +110,7 @@ export default function AgentKnowledgePanel({ ({ agentId }) => KnowledgeService.getKnowledgeSourcesForAgent(agentId), { revalidateOnFocus: false, - refreshInterval: blockPollingSources ? undefined : 1000, + refreshInterval: blockPollingSources ? undefined : 5000, } ); const knowledgeSources = useMemo( diff --git a/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx b/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx index 2e29ab917..4f302b278 100644 --- a/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx +++ b/ui/admin/app/components/knowledge/KnowledgeSourceDetail.tsx @@ -97,7 +97,7 @@ const KnowledgeSourceDetail: FC = ({ ), { revalidateOnFocus: false, - refreshInterval: blockPollingFiles ? undefined : 1000, + refreshInterval: blockPollingFiles ? undefined : 5000, } ); @@ -156,7 +156,7 @@ const KnowledgeSourceDetail: FC = ({ if (knowledgeSource.state === KnowledgeSourceStatus.Synced) { getFiles.mutate(); } - }, [knowledgeSource, getFiles]); + }, [knowledgeSource]); const onSourceUpdate = async (syncSchedule: string) => { const updatedSource = await KnowledgeService.updateKnowledgeSource( @@ -176,8 +176,9 @@ const KnowledgeSourceDetail: FC = ({ file.id, approved ); - getFiles.mutate((files) => - files?.map((f) => (f.id === file.id ? updatedFile : f)) + getFiles.mutate( + (files) => files?.map((f) => (f.id === file.id ? updatedFile : f)), + false ); }; @@ -203,8 +204,9 @@ const KnowledgeSourceDetail: FC = ({ file.id, knowledgeSource.id ); - getFiles.mutate((files) => - files?.map((f) => (f.id === file.id ? updatedFile : f)) + getFiles.mutate( + (files) => files?.map((f) => (f.id === file.id ? updatedFile : f)), + false ); };