From 64a3330b583e04c52f5ec06116ca357db910e872 Mon Sep 17 00:00:00 2001 From: Jonathan Dobson Date: Thu, 21 Aug 2025 09:02:49 -0400 Subject: [PATCH] unconstrain editor for OSS (#3245) --- .../routes/workflows/editor/FlowRenderer.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx index f787457a..61345b59 100644 --- a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx +++ b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx @@ -78,6 +78,7 @@ import { layout, } from "./workflowEditorUtils"; import { useAutoPan } from "./useAutoPan"; +import { useUser } from "@/hooks/useUser"; const nextTick = () => new Promise((resolve) => setTimeout(resolve, 0)); @@ -249,12 +250,14 @@ function FlowRenderer({ }: Props) { const reactFlowInstance = useReactFlow(); const debugStore = useDebugStore(); + const user = useUser().get(); const { title, initializeTitle } = useWorkflowTitleStore(); // const [parameters] = useState(initialParameters); const parameters = useWorkflowParametersStore((state) => state.parameters); const nodesInitialized = useNodesInitialized(); const [shouldConstrainPan, setShouldConstrainPan] = useState(false); const onNodesChangeTimeoutRef = useRef(null); + const flowIsConstrained = debugStore.isDebugMode && Boolean(user); useEffect(() => { if (nodesInitialized) { @@ -491,7 +494,12 @@ function FlowRenderer({ }; useOnChange(debugStore.isDebugMode, (newValue) => { + if (!user) { + return; + } + const xLock = getXLock(); + if (newValue) { const currentY = reactFlowInstance.getViewport().y; reactFlowInstance.setViewport({ x: xLock, y: currentY, zoom: zoomLock }); @@ -647,18 +655,18 @@ function FlowRenderer({ }} deleteKeyCode={null} onMove={(_, viewport) => { - if (debugStore.isDebugMode && shouldConstrainPan) { + if (flowIsConstrained && shouldConstrainPan) { constrainPan(viewport); } }} - maxZoom={debugStore.isDebugMode ? 1 : 2} - minZoom={debugStore.isDebugMode ? 1 : 0.5} + maxZoom={flowIsConstrained ? 1 : 2} + minZoom={flowIsConstrained ? 1 : 0.5} panOnDrag={true} panOnScroll={true} panOnScrollMode={PanOnScrollMode.Vertical} - zoomOnDoubleClick={!debugStore.isDebugMode} - zoomOnPinch={!debugStore.isDebugMode} - zoomOnScroll={!debugStore.isDebugMode} + zoomOnDoubleClick={!flowIsConstrained} + zoomOnPinch={!flowIsConstrained} + zoomOnScroll={!flowIsConstrained} >