From b65a9d33cd1241326d2659d7a39f155127e382f5 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Fri, 9 Jan 2026 17:18:16 -0800 Subject: [PATCH 1/5] Fix router block --- .../condition-input/condition-input.tsx | 15 +++++++--- .../workflow-block/workflow-block.tsx | 6 ++-- apps/sim/blocks/blocks/router.ts | 28 +++++++++++-------- .../handlers/router/router-handler.ts | 9 +++--- bun.lock | 1 - 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input/condition-input.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input/condition-input.tsx index 9801a4f57e..70f8691092 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input/condition-input.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input/condition-input.tsx @@ -654,16 +654,19 @@ export function ConditionInput({ } const removeBlock = (id: string) => { - if (isPreview || disabled || conditionalBlocks.length <= 2) return + if (isPreview || disabled) return + // Condition mode requires at least 2 blocks (if/else), router mode requires at least 1 + const minBlocks = isRouterMode ? 1 : 2 + if (conditionalBlocks.length <= minBlocks) return // Remove any associated edges before removing the block + const handlePrefix = isRouterMode ? `router-${id}` : `condition-${id}` edges.forEach((edge) => { - if (edge.sourceHandle?.startsWith(`condition-${id}`)) { + if (edge.sourceHandle?.startsWith(handlePrefix)) { removeEdge(edge.id) } }) - if (conditionalBlocks.length === 1) return shouldPersistRef.current = true setConditionalBlocks((blocks) => updateBlockTitles(blocks.filter((block) => block.id !== id))) @@ -815,7 +818,11 @@ export function ConditionInput({