Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat: enable multiline wrapping for conditional block expressions (#5208)
Celal Zamanoğlu7931848ca97e
diff --git a/skyvern-frontend/src/components/AutoResizingTextarea/AutoResizingTextarea.tsx b/skyvern-frontend/src/components/AutoResizingTextarea/AutoResizingTextarea.tsxindex f3e202a6e..9313bae8d 100644--- a/skyvern-frontend/src/components/AutoResizingTextarea/AutoResizingTextarea.tsx+++ b/skyvern-frontend/src/components/AutoResizingTextarea/AutoResizingTextarea.tsx@@ -8,6 +8,7 @@ type Props = {onChange?: ChangeEventHandler<HTMLTextAreaElement>;className?: string;readOnly?: boolean;+ disabled?: boolean;placeholder?: string;onClick?: React.MouseEventHandler<HTMLTextAreaElement>;onKeyUp?: React.KeyboardEventHandler<HTMLTextAreaElement>;@@ -21,6 +22,7 @@ const AutoResizingTextarea = forwardRef<HTMLTextAreaElement, Props>(onChange,className,readOnly,+ disabled,placeholder,onClick,onKeyUp,@@ -70,6 +72,7 @@ const AutoResizingTextarea = forwardRef<HTMLTextAreaElement, Props>(value={value}onChange={onChange}readOnly={readOnly}+ disabled={disabled}placeholder={placeholder}onClick={onClick}onKeyUp={onKeyUp}diff --git a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsxindex 902c570ea..986aba4c4 100644--- a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx@@ -468,6 +468,29 @@ function FlowRenderer({};}, [reactFlowInstance, debouncedLayoutForDimensions]);+ // Re-layout when a conditional node's header height changes (e.g., expression textarea resized)+ useEffect(() => {+ const handleConditionalHeaderResized = () => {+ // Delay to let React process the updateNodeData state change+ setTimeout(() => {+ const currentNodes = reactFlowInstance.getNodes() as Array<AppNode>;+ const currentEdges = reactFlowInstance.getEdges();+ debouncedLayoutForDimensions(currentNodes, currentEdges);+ }, 10);+ };++ window.addEventListener(+ "conditional-header-resized",+ handleConditionalHeaderResized,+ );+ return () => {+ window.removeEventListener(+ "conditional-header-resized",+ handleConditionalHeaderResized,+ );+ };+ }, [reactFlowInstance, debouncedLayoutForDimensions]);+// Re-layout when a workflow trigger node's async content changes// (e.g., target workflow parameters finish loading, skeleton → actual fields)useEffect(() => {diff --git a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsxindex a87c88c45..7d58d43e1 100644--- a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx@@ -838,6 +838,31 @@ function Workspace({};}, [getNodes, getEdges, setNodes, setEdges, blockLabel]);+ // Re-layout when a conditional node's header height changes (e.g., expression textarea resized)+ useEffect(() => {+ const handleConditionalHeaderResized = () => {+ setTimeout(() => {+ const currentNodes = getNodes() as Array<AppNode>;+ const currentEdges = getEdges();++ const layoutedElements = layout(currentNodes, currentEdges, blockLabel);+ setNodes(layoutedElements.nodes);+ setEdges(layoutedElements.edges);+ }, 10);+ };++ window.addEventListener(+ "conditional-header-resized",+ handleConditionalHeaderResized,+ );+ return () => {+ window.removeEventListener(+ "conditional-header-resized",+ handleConditionalHeaderResized,+ );+ };+ }, [getNodes, getEdges, setNodes, setEdges, blockLabel]);+function addNode({nodeType,previous,diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsxindex 891de42dc..78e890682 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsx@@ -39,11 +39,11 @@ import {} from "./types";import type { BranchCondition } from "../../../types/workflowTypes";import { HelpTooltip } from "@/components/HelpTooltip";-import { WorkflowBlockInput } from "@/components/WorkflowBlockInput";+import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";function ConditionalNodeComponent({ id, data }: NodeProps<ConditionalNode>) {const nodes = useNodes<AppNode>();- const { setNodes, setEdges } = useReactFlow();+ const { setNodes, setEdges, updateNodeData } = useReactFlow();const node = nodes.find((n) => n.id === id);const { beginInternalUpdate, endInternalUpdate } =useWorkflowHasChangesStore();@@ -101,6 +101,26 @@ function ConditionalNodeComponent({ id, data }: NodeProps<ConditionalNode>) {return node ? getLoopNodeWidth(node, nodes) : 450;}, [node, nodes]);+ const headerRef = useRef<HTMLDivElement>(null);+ const lastHeaderHeight = useRef<number | undefined>(data._headerHeight);++ useEffect(() => {+ const el = headerRef.current;+ if (!el) return;++ const observer = new ResizeObserver(() => {+ const height = Math.round(el.offsetHeight);+ if (lastHeaderHeight.current !== height) {+ lastHeaderHeight.current = height;+ updateNodeData(id, { _headerHeight: height });+ window.dispatchEvent(new Event("conditional-header-resized"));+ }+ });++ observer.observe(el);+ return () => observer.disconnect();+ }, [id, updateNodeData]);+const orderedBranches = useMemo(() => {const defaultBranch = data.branches.find((branch) => branch.is_default);const nonDefault = data.branches.filter((branch) => !branch.is_default);@@ -528,6 +548,7 @@ function ConditionalNodeComponent({ id, data }: NodeProps<ConditionalNode>) {><div className="flex w-full justify-center"><div+ ref={headerRef}className={cn("w-[30rem] space-y-4 rounded-lg bg-slate-elevation3 px-6 py-4 transition-all",data.comparisonColor,@@ -763,7 +784,7 @@ function ConditionalNodeComponent({ id, data }: NodeProps<ConditionalNode>) {/>)}</div>- <WorkflowBlockInput+ <WorkflowBlockInputTextareanodeId={id}value={activeBranch.is_default@@ -775,6 +796,7 @@ function ConditionalNodeComponent({ id, data }: NodeProps<ConditionalNode>) {handleExpressionChange(value);}}placeholder="Enter condition to evaluate (Jinja, natural language, or both)"+ className="nopan text-xs"/></div>)}diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/types.ts b/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/types.tsindex bdddd78ee..a97148462 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/types.ts+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/types.ts@@ -12,6 +12,7 @@ export type ConditionalNodeData = NodeBaseData & {branches: Array<BranchCondition>;activeBranchId: string | null;mergeLabel: string | null;+ _headerHeight?: number; // internal: measured header card height for layout};export type ConditionalNode = Node<ConditionalNodeData, "conditional">;diff --git a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.tsindex 4db116e2a..a2caef740 100644--- a/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts+++ b/skyvern-frontend/src/routes/workflows/editor/workflowEditorUtils.ts@@ -74,6 +74,7 @@ import {conditionalNodeDefaultData,createDefaultBranchConditions,ConditionalNode,+ isConditionalNode,} from "./nodes/ConditionalNode/types";import {isLoopNode,@@ -400,7 +401,20 @@ function layout(const nodeLabel = isWorkflowBlockNode(node) ? node.data.label : undefined;const isTargetted =targettedBlockLabel && nodeLabel === targettedBlockLabel;- const marginy = isTargetted ? 225 + TARGETTED_BLOCK_EXTRA_MARGIN : 225;+ // Use measured header height when available, fall back to 225 for initial render.+ // Add 28px to account for outer container (border-2 + p-2 = 10px) + gap (16px) + buffer.+ const conditionalHeaderHeight = isConditionalNode(node)+ ? node.data._headerHeight+ : undefined;+ const conditionalBaseMargin = conditionalHeaderHeight+ ? conditionalHeaderHeight + 28+ : 225;+ // Only add extra margin for the status row when using the fallback height,+ // since the measured height already includes the status row content.+ const marginy =+ isTargetted && !conditionalHeaderHeight+ ? conditionalBaseMargin + TARGETTED_BLOCK_EXTRA_MARGIN+ : conditionalBaseMargin;const layouted = layoutUtil(childNodesWithResetPositions,childEdges,