From 34f00a7f9e1c82f62afaa10dce5fab3de9ec8926 Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Wed, 9 Apr 2025 17:56:04 -0300 Subject: [PATCH] feat: Disable inspect button for empty node outputs (#7528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 (NodeOutputfield/index.tsx): refactor useMemo hook to check for empty output messages in the flowPoolNode data 🔧 (NodeOutputfield/index.tsx): refactor disabledInspectButton logic to include check for empty output messages Co-authored-by: Mike Fortman --- .../components/NodeOutputfield/index.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx b/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx index 7ab945713..bb47ed848 100644 --- a/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx @@ -213,6 +213,12 @@ function NodeOutputField({ [flowPool, flowPoolId, flowPoolNode?.data, internalOutputName], ); + const emptyOutput = useMemo(() => { + return Object.keys(flowPoolNode?.data?.outputs ?? {})?.every( + (key) => flowPoolNode?.data?.outputs[key]?.message?.length === 0, + ); + }, [flowPoolNode?.data?.outputs]); + const disabledOutput = useMemo( () => edges.some((edge) => edge.sourceHandle === scapedJSONStringfy(id)), [edges, id], @@ -369,6 +375,9 @@ function NodeOutputField({ ], ); + const disabledInspectButton = + !displayOutputPreview || unknownOutput || emptyOutput; + if (!showNode) return <>{Handle}; return ( @@ -424,7 +433,7 @@ function NodeOutputField({