diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx index bd9569248..e016918a1 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx @@ -168,11 +168,11 @@ export const ActionBar = memo( {(() => { - if (disabled) return getTooltipMessage('Run from this block') + if (disabled) return getTooltipMessage('Run from block') if (isExecuting) return 'Execution in progress' if (isInsideSubflow) return 'Cannot run from inside subflow' if (!dependenciesSatisfied) return 'Run upstream blocks first' - return 'Run from this block' + return 'Run from block' })()} diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/block-menu/block-menu.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/block-menu/block-menu.tsx index 8e1290ab6..dfeb6b0bd 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/block-menu/block-menu.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/block-menu/block-menu.tsx @@ -46,8 +46,6 @@ export interface BlockMenuProps { showRemoveFromSubflow?: boolean /** Whether run from block is available (has snapshot, was executed, not inside subflow) */ canRunFromBlock?: boolean - /** Reason why run from block is disabled (for tooltip) */ - runFromBlockDisabledReason?: string disableEdit?: boolean isExecuting?: boolean } @@ -77,7 +75,6 @@ export function BlockMenu({ hasClipboard = false, showRemoveFromSubflow = false, canRunFromBlock = false, - runFromBlockDisabledReason, disableEdit = false, isExecuting = false, }: BlockMenuProps) { @@ -228,11 +225,7 @@ export function BlockMenu({ } }} > - {isExecuting - ? 'Execution in progress...' - : !canRunFromBlock && runFromBlockDisabledReason - ? runFromBlockDisabledReason - : 'Run from this block'} + Run from block - {isExecuting ? 'Execution in progress...' : 'Run until this block'} + Run until block )} diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts index 983896fe2..7fd40b775 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts @@ -23,6 +23,7 @@ import { subscriptionKeys } from '@/hooks/queries/subscription' import { useExecutionStream } from '@/hooks/use-execution-stream' import { WorkflowValidationError } from '@/serializer' import { useExecutionStore } from '@/stores/execution' +import { useNotificationStore } from '@/stores/notifications' import { useVariablesStore } from '@/stores/panel' import { useEnvironmentStore } from '@/stores/settings/environment' import { type ConsoleEntry, useTerminalConsoleStore } from '@/stores/terminal' @@ -101,11 +102,13 @@ export function useWorkflowExecution() { setEdgeRunStatus, setLastExecutionSnapshot, getLastExecutionSnapshot, + clearLastExecutionSnapshot, } = useExecutionStore() const [executionResult, setExecutionResult] = useState(null) const executionStream = useExecutionStream() const currentChatExecutionIdRef = useRef(null) const isViewingDiff = useWorkflowDiffStore((state) => state.isShowingDiff) + const addNotification = useNotificationStore((state) => state.addNotification) /** * Validates debug state before performing debug operations @@ -1620,6 +1623,23 @@ export function useWorkflowExecution() { onExecutionError: (data) => { logger.error('Run-from-block execution error:', data.error) + + // If block not found, the snapshot is stale - clear it + if (data.error?.includes('Block not found in workflow')) { + clearLastExecutionSnapshot(workflowId) + addNotification({ + level: 'info', + message: 'Workflow was modified. Run the workflow again to refresh.', + workflowId, + }) + logger.info('Cleared stale execution snapshot', { workflowId }) + } else { + addNotification({ + level: 'error', + message: data.error || 'Run from block failed', + workflowId, + }) + } }, onExecutionCancelled: () => { @@ -1639,10 +1659,12 @@ export function useWorkflowExecution() { [ getLastExecutionSnapshot, setLastExecutionSnapshot, + clearLastExecutionSnapshot, setIsExecuting, setActiveBlocks, setBlockRunStatus, setEdgeRunStatus, + addNotification, addConsole, executionStream, ] diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx index 33b10a393..9727a9eb0 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx @@ -3356,7 +3356,6 @@ const WorkflowContent = React.memo(() => { (b) => b.parentId && (b.parentType === 'loop' || b.parentType === 'parallel') )} canRunFromBlock={runFromBlockState.canRun} - runFromBlockDisabledReason={runFromBlockState.reason} disableEdit={!effectivePermissions.canEdit} isExecuting={isExecuting} />