From 1cc93da83dc3d87fc88e5f1fc2366df640edf98b Mon Sep 17 00:00:00 2001 From: Camiel van Schoonhoven Date: Mon, 29 Sep 2025 17:18:44 -0700 Subject: [PATCH] Add debug mode for viewing ReactFlow Node ids --- .env.example | 5 +- .../ReactFlow/FlowCanvas/IONode/IONode.tsx | 38 ++++++-- .../TaskNode/TaskNodeCard/Handles.tsx | 89 ++++++++++++------- .../TaskNode/TaskNodeCard/TaskNodeCard.tsx | 60 ++++++++----- src/components/ui/tooltip.tsx | 6 ++ src/utils/constants.ts | 3 + 6 files changed, 136 insertions(+), 65 deletions(-) diff --git a/.env.example b/.env.example index ae9807efa..7e618dd4f 100644 --- a/.env.example +++ b/.env.example @@ -17,4 +17,7 @@ VITE_ENABLE_GOOGLE_CLOUD_SUBMITTER= # Github VITE_REQUIRE_AUTHORIZATION= -VITE_GITHUB_CLIENT_ID= \ No newline at end of file +VITE_GITHUB_CLIENT_ID= + +# Dev Tools +VITE_ENABLE_DEBUG_MODE= \ No newline at end of file diff --git a/src/components/shared/ReactFlow/FlowCanvas/IONode/IONode.tsx b/src/components/shared/ReactFlow/FlowCanvas/IONode/IONode.tsx index aae6b9336..5a2b7ae3f 100644 --- a/src/components/shared/ReactFlow/FlowCanvas/IONode/IONode.tsx +++ b/src/components/shared/ReactFlow/FlowCanvas/IONode/IONode.tsx @@ -6,6 +6,11 @@ import { OutputNameEditor } from "@/components/Editor/IOEditor/OutputNameEditor" import { getOutputConnectedDetails } from "@/components/Editor/utils/getOutputConnectedDetails"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { BlockStack, InlineStack } from "@/components/ui/layout"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip"; import { Paragraph } from "@/components/ui/typography"; import { useNodeManager } from "@/hooks/useNodeManager"; import { cn } from "@/lib/utils"; @@ -13,6 +18,7 @@ import { useComponentSpec } from "@/providers/ComponentSpecProvider"; import { useContextPanel } from "@/providers/ContextPanelProvider"; import type { IONodeData } from "@/types/nodes"; import { isInputSpec, typeSpecToString } from "@/utils/componentSpec"; +import { ENABLE_DEBUG_MODE } from "@/utils/constants"; interface IONodeProps { type: "input" | "output"; @@ -24,7 +30,7 @@ interface IONodeProps { const IONode = ({ type, data, selected = false }: IONodeProps) => { const { currentGraphSpec, currentSubgraphSpec } = useComponentSpec(); const { setContent, clearContent } = useContextPanel(); - const { getHandleNodeId } = useNodeManager(); + const { getNodeId, getHandleNodeId } = useNodeManager(); const { spec, readOnly } = data; @@ -51,6 +57,7 @@ const IONode = ({ type, data, selected = false }: IONodeProps) => { [currentSubgraphSpec.outputs, spec.name], ); + const nodeId = getNodeId(spec.name, type); const handleNodeType = isInput ? "handle-out" : "handle-in"; const nodeHandleId = getHandleNodeId(spec.name, spec.name, handleNodeType); @@ -107,6 +114,11 @@ const IONode = ({ type, data, selected = false }: IONodeProps) => { {spec.name} + {ENABLE_DEBUG_MODE && ( + + Node Id: {nodeId} + + )} @@ -141,12 +153,24 @@ const IONode = ({ type, data, selected = false }: IONodeProps) => { - + + + + + +
+ {type} Name: {spec.name} +
+
Handle Name: {spec.name}
+
parentNodeId: {nodeId}
+
handleNodeId: {nodeHandleId}
+
+
); diff --git a/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/Handles.tsx b/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/Handles.tsx index 2a04b8f10..26aaa51bd 100644 --- a/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/Handles.tsx +++ b/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/Handles.tsx @@ -15,6 +15,7 @@ import { useNodeManager } from "@/hooks/useNodeManager"; import { cn } from "@/lib/utils"; import { useTaskNode } from "@/providers/TaskNodeProvider"; import type { InputSpec, OutputSpec } from "@/utils/componentSpec"; +import { ENABLE_DEBUG_MODE } from "@/utils/constants"; type InputHandleProps = { input: InputSpec; @@ -34,7 +35,7 @@ export const InputHandle = ({ onHandleSelectionChange, }: InputHandleProps) => { const { getInputHandleNodeId } = useNodeManager(); - const { taskId, nodeId, state } = useTaskNode(); + const { taskId, nodeId, state, name } = useTaskNode(); const fromHandle = useConnection((connection) => connection.fromHandle?.id); const toHandle = useConnection((connection) => connection.toHandle?.id); @@ -131,23 +132,33 @@ export const InputHandle = ({ data-active={active} >
- + + + + + +
Task Name: {name}
+
Handle Name: {input.name}
+
parentNodeId: {nodeId}
+
handleNodeId: {handleId}
+
+
{ const { getOutputHandleNodeId } = useNodeManager(); - const { taskId, nodeId, state } = useTaskNode(); + const { taskId, nodeId, state, name } = useTaskNode(); const fromHandle = useConnection((connection) => connection.fromHandle?.id); const toHandle = useConnection((connection) => connection.toHandle?.id); @@ -339,21 +350,31 @@ export const OutputHandle = ({
)} - + + + + + +
Task Name: {name}
+
Handle Name: {output.name}
+
parentNodeId: {nodeId}
+
handleNodeId: {handleId}
+
+
); }; diff --git a/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/TaskNodeCard.tsx b/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/TaskNodeCard.tsx index e76d6a1f4..bc3f9f655 100644 --- a/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/TaskNodeCard.tsx +++ b/src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskNodeCard/TaskNodeCard.tsx @@ -17,6 +17,7 @@ import { useComponentSpec } from "@/providers/ComponentSpecProvider"; import { useContextPanel } from "@/providers/ContextPanelProvider"; import { useTaskNode } from "@/providers/TaskNodeProvider"; import { isCacheDisabled } from "@/utils/cache"; +import { ENABLE_DEBUG_MODE } from "@/utils/constants"; import { getSubgraphDescription, isSubgraph } from "@/utils/subgraphUtils"; import { @@ -254,25 +255,40 @@ const TaskNodeCard = () => { ref={nodeRef} onDoubleClick={handleDoubleClick} > - + - - {isSubgraphNode && isSubgraphNavigationEnabled && ( - - - + + + {isSubgraphNode && isSubgraphNavigationEnabled && ( + + + + )} + {disabledCache && !readOnly && ( + + + + )} + + {name} + + + {isRemoteComponentLibrarySearchEnabled ? ( + + {digestMarkup} + + ) : ( + digestMarkup )} - {disabledCache && !readOnly && ( - - - - )} - - {name} - {taskId && taskId !== name && @@ -283,12 +299,10 @@ const TaskNodeCard = () => { )} - {isRemoteComponentLibrarySearchEnabled ? ( - - {digestMarkup} - - ) : ( - digestMarkup + {ENABLE_DEBUG_MODE && ( + + Node Id: {nodeId} + )} diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx index d84b451a3..ff0f2579e 100644 --- a/src/components/ui/tooltip.tsx +++ b/src/components/ui/tooltip.tsx @@ -40,6 +40,7 @@ function TooltipTrigger({ interface TooltipContentProps extends React.ComponentProps { arrowClassName?: string; + disabled?: boolean; } function TooltipContent({ @@ -47,8 +48,13 @@ function TooltipContent({ sideOffset = 0, children, arrowClassName, + disabled, ...props }: TooltipContentProps) { + if (disabled) { + return null; + } + return (