From 4042c1f6c4f6fc93466d1d63cf7872d7f960ac31 Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Thu, 9 Jan 2025 17:41:27 +0800 Subject: [PATCH] fix: prevent show error when data is not ready --- .../nodes/agent/components/tool-icon.tsx | 4 +++- .../components/workflow/nodes/agent/node.tsx | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/web/app/components/workflow/nodes/agent/components/tool-icon.tsx b/web/app/components/workflow/nodes/agent/components/tool-icon.tsx index 0d2d3c2837..07c20e0f80 100644 --- a/web/app/components/workflow/nodes/agent/components/tool-icon.tsx +++ b/web/app/components/workflow/nodes/agent/components/tool-icon.tsx @@ -18,6 +18,7 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => { const { data: buildInTools } = useAllBuiltInTools() const { data: customTools } = useAllCustomTools() const { data: workflowTools } = useAllWorkflowTools() + const isDataReady = !!buildInTools && !!customTools && !!workflowTools const currentProvider = useMemo(() => { const mergedTools = [...(buildInTools || []), ...(customTools || []), ...(workflowTools || [])] return mergedTools.find((toolWithProvider) => { @@ -33,10 +34,11 @@ export const ToolIcon = memo(({ providerName }: ToolIconProps) => { return iconFromMarketPlace }, [author, currentProvider, name]) const status: Status = useMemo(() => { + if (!isDataReady) return undefined if (!currentProvider) return 'not-installed' if (currentProvider.is_team_authorization === false) return 'not-authorized' return undefined - }, [currentProvider]) + }, [currentProvider, isDataReady]) const indicator = status === 'not-installed' ? 'red' : status === 'not-authorized' ? 'yellow' : undefined const notSuccess = (['not-installed', 'not-authorized'] as Array).includes(status) const { t } = useTranslation() diff --git a/web/app/components/workflow/nodes/agent/node.tsx b/web/app/components/workflow/nodes/agent/node.tsx index 3543de1fcc..b3101c3d88 100644 --- a/web/app/components/workflow/nodes/agent/node.tsx +++ b/web/app/components/workflow/nodes/agent/node.tsx @@ -67,14 +67,20 @@ const AgentNode: FC> = (props) => { {inputs.agent_strategy_name ? {inputs.agent_strategy_label}