Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

fix(flows): steps inside a skipped parent no longer block publish (#15951)

Abdul77a48fe5d0bb
diff --git a/bun.lock b/bun.lock
index 4fdd24c2244..9b9387dfb51 100644
--- a/bun.lock
+++ b/bun.lock
@@ -120,7 +120,7 @@
},
"packages/core/execution": {
"name": "@activepieces/core-execution",
- "version": "0.23.6",
+ "version": "0.24.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
@@ -7669,7 +7669,7 @@
},
"packages/pieces/community/reddit": {
"name": "@activepieces/piece-reddit",
- "version": "0.3.0",
+ "version": "0.4.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/core/execution/package.json b/packages/core/execution/package.json
index 70d4935f90a..b46da93b4f7 100644
--- a/packages/core/execution/package.json
+++ b/packages/core/execution/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/core-execution",
- "version": "0.23.6",
+ "version": "0.24.0",
"type": "commonjs",
"main": "./dist/src/index.js",
"scripts": {
diff --git a/packages/core/execution/src/lib/flows/operations/index.ts b/packages/core/execution/src/lib/flows/operations/index.ts
index 84baa078e11..aa3a398409d 100644
--- a/packages/core/execution/src/lib/flows/operations/index.ts
+++ b/packages/core/execution/src/lib/flows/operations/index.ts
@@ -427,10 +427,8 @@ export const flowOperations = {
default:
break
}
- clonedVersion.valid = flowStructureUtil.getAllSteps(clonedVersion.trigger).every((step) => {
- const isSkipped = step.type != FlowTriggerType.EMPTY && step.type != FlowTriggerType.PIECE && step.skip
- return step.valid || isSkipped
- })
+ const skippedStepNames = flowStructureUtil.getSkippedStepNames({ trigger: clonedVersion.trigger })
+ clonedVersion.valid = flowStructureUtil.getAllSteps(clonedVersion.trigger).every((step) => step.valid || skippedStepNames.has(step.name))
return clonedVersion
},
}
diff --git a/packages/core/execution/src/lib/flows/util/flow-canvas-util.ts b/packages/core/execution/src/lib/flows/util/flow-canvas-util.ts
index 92931d57f56..dad71ca60b8 100644
--- a/packages/core/execution/src/lib/flows/util/flow-canvas-util.ts
+++ b/packages/core/execution/src/lib/flows/util/flow-canvas-util.ts
@@ -47,7 +47,7 @@ function getFlowBoundingBox(step: Step | FlowAction | null | undefined, forBranc
withChildHeight = merged.height
}
}
- else if (hasContinueOnFailureBranches(step)) {
+ else if (flowStructureUtil.hasContinueOnFailureBranches(step)) {
const branches = getContinueOnFailureBranchPair(step)
const childBoundingBoxes = branches.map(b => getFlowBoundingBox(b, true))
const merged = mergeBranchedChildBoundingBoxes(childBoundingBoxes)
@@ -92,7 +92,7 @@ function buildPositions({ step, offsetX, offsetY, positions }: {
const subgraphEndY = positionBranchedChildren({ children: step.children, offsetX, offsetY, positions })
buildPositions({ step: step.nextAction, offsetX, offsetY: offsetY + subgraphEndY, positions })
}
- else if (hasContinueOnFailureBranches(step)) {
+ else if (flowStructureUtil.hasContinueOnFailureBranches(step)) {
const subgraphEndY = positionBranchedChildren({ children: getContinueOnFailureBranchPair(step), offsetX, offsetY, positions })
buildPositions({ step: step.nextAction, offsetX, offsetY: offsetY + subgraphEndY, positions })
}
@@ -169,20 +169,13 @@ function positionBranchedChildren({ children, offsetX, offsetY, positions }: {
return FLOW_CANVAS_STEP_HEIGHT + FLOW_CANVAS_ROUTER_VOFFSET + maxChildHeight + FLOW_CANVAS_ARC + FLOW_CANVAS_VSPACE
}
-function hasContinueOnFailureBranches(step: Step | FlowAction): step is CodeAction | PieceAction {
- if (step.type !== FlowActionType.CODE && step.type !== FlowActionType.PIECE) {
- return false
- }
- return step.settings.errorHandlingOptions?.continueOnFailure?.value ?? false
-}
-
function getContinueOnFailureBranchPair(step: CodeAction | PieceAction): (FlowAction | undefined)[] {
const branches = step.continueOnFailureBranches
return [branches?.onSuccess, branches?.onFailure]
}
function getStepBranchRelativeTo(ancestor: Step | FlowAction, targetStepName: string): 'on-success' | 'on-failure' | null {
- if (!hasContinueOnFailureBranches(ancestor)) {
+ if (!flowStructureUtil.hasContinueOnFailureBranches(ancestor)) {
return null
}
const [onSuccess, onFailure] = getContinueOnFailureBranchPair(ancestor)
@@ -205,7 +198,6 @@ export const flowCanvasUtils = {
buildPositions({ step: trigger, offsetX: 0, offsetY: 0, positions })
return positions
},
- hasContinueOnFailureBranches,
getContinueOnFailureBranchPair,
getStepBranchRelativeTo,
computeRouterChildOffsets,
diff --git a/packages/core/execution/src/lib/flows/util/flow-structure-util.ts b/packages/core/execution/src/lib/flows/util/flow-structure-util.ts
index 6d687960a24..1cd6c84239a 100644
--- a/packages/core/execution/src/lib/flows/util/flow-structure-util.ts
+++ b/packages/core/execution/src/lib/flows/util/flow-structure-util.ts
@@ -1,7 +1,7 @@
import { AgentPieceProps } from '@activepieces/core-piece-types'
import { isNil, unique } from '@activepieces/core-utils'
import { ActivepiecesError, ErrorCode } from '@activepieces/core-utils'
-import { BranchCondition, BranchedAction, BranchExecutionType, emptyCondition, FlowAction, FlowActionType } from '../actions/action'
+import { BranchCondition, BranchedAction, BranchExecutionType, CodeAction, emptyCondition, FlowAction, FlowActionType, PieceAction } from '../actions/action'
import { FlowVersion } from '../flow-version'
import { FlowTrigger, FlowTriggerType } from '../triggers/trigger'
@@ -195,6 +195,22 @@ function getAllChildSteps(action: Step): Step[] {
})
}
+function hasContinueOnFailureBranches(step: Step): step is CodeAction | PieceAction {
+ if (step.type !== FlowActionType.CODE && step.type !== FlowActionType.PIECE) {
+ return false
+ }
+ return step.settings.errorHandlingOptions?.continueOnFailure?.value ?? false
+}
+
+function getSkippedStepNames({ trigger }: { trigger: FlowTrigger }): Set<string> {
+ const skippedSteps = getAllSteps(trigger).filter((step) => isAction(step.type) && 'skip' in step && step.skip === true)
+ return new Set(skippedSteps.flatMap((step) => getAllChildSteps(step).map((child) => child.name)))
+}
+
+function isSkipped({ stepName, trigger }: { stepName: string, trigger: FlowTrigger }): boolean {
+ return getSkippedStepNames({ trigger }).has(stepName)
+}
+
function isChildOf(parent: Step, childStepName: string): boolean {
return getAllChildSteps(parent).some((c) => c.name === childStepName && c.name !== parent.name)
}
@@ -297,6 +313,9 @@ export const flowStructureUtil = {
findUnusedNames,
getAllNextActionsWithoutChildren,
getAllChildSteps,
+ hasContinueOnFailureBranches,
+ getSkippedStepNames,
+ isSkipped,
extractConnectionIds,
isAgentPiece,
isBranchedAction,
diff --git a/packages/core/execution/test/flow/skipped-steps.test.ts b/packages/core/execution/test/flow/skipped-steps.test.ts
new file mode 100644
index 00000000000..be1e0a78a8a
--- /dev/null
+++ b/packages/core/execution/test/flow/skipped-steps.test.ts
@@ -0,0 +1,150 @@
+import { BranchExecutionType, CodeAction, FlowAction, FlowActionType, FlowOperationType, flowOperations, flowStructureUtil, FlowTriggerType, FlowVersion, FlowVersionState, LoopOnItemsAction, RouterAction, RouterExecutionType } from '../../src'
+
+function codeStep({ name, valid = true, skip, continueOnFailure = false, onSuccess, onFailure, nextAction }: { name: string, valid?: boolean, skip?: boolean, continueOnFailure?: boolean, onSuccess?: FlowAction, onFailure?: FlowAction, nextAction?: FlowAction }): CodeAction {
+ return {
+ name,
+ type: FlowActionType.CODE,
+ valid,
+ skip,
+ displayName: name,
+ lastUpdatedDate: '2026-09-28T00:00:00.000Z',
+ settings: {
+ sourceCode: { code: '', packageJson: '{}' },
+ input: {},
+ errorHandlingOptions: {
+ continueOnFailure: { value: continueOnFailure },
+ retryOnFailure: { value: false },
+ },
+ },
+ continueOnFailureBranches: onSuccess || onFailure ? { onSuccess, onFailure } : undefined,
+ nextAction,
+ }
+}
+
+function routerStep({ name, skip, children, nextAction }: { name: string, skip?: boolean, children: (FlowAction | null)[], nextAction?: FlowAction }): RouterAction {
+ return {
+ name,
+ type: FlowActionType.ROUTER,
+ valid: true,
+ skip,
+ displayName: name,
+ lastUpdatedDate: '2026-09-28T00:00:00.000Z',
+ settings: {
+ branches: children.map((_, index) => ({ branchName: `branch_${index}`, branchType: BranchExecutionType.CONDITION, conditions: [[]] })),
+ executionType: RouterExecutionType.EXECUTE_FIRST_MATCH,
+ },
+ children,
+ nextAction,
+ }
+}
+
+function loopStep({ name, skip, firstLoopAction, nextAction }: { name: string, skip?: boolean, firstLoopAction?: FlowAction, nextAction?: FlowAction }): LoopOnItemsAction {
+ return {
+ name,
+ type: FlowActionType.LOOP_ON_ITEMS,
+ valid: true,
+ skip,
+ displayName: name,
+ lastUpdatedDate: '2026-09-28T00:00:00.000Z',
+ settings: { items: '' },
+ firstLoopAction,
+ nextAction,
+ }
+}
+
+function flowWith(head: FlowAction): FlowVersion {
+ return {
+ id: 'version',
+ created: '2026-09-28T00:00:00.000Z',
+ updated: '2026-09-28T00:00:00.000Z',
+ flowId: 'flow',
+ displayName: 'Flow',
+ updatedBy: null,
+ valid: false,
+ schemaVersion: null,
+ agentIds: [],
+ state: FlowVersionState.DRAFT,
+ connectionIds: [],
+ backupFiles: null,
+ notes: [],
+ trigger: {
+ name: 'trigger',
+ type: FlowTriggerType.EMPTY,
+ valid: true,
+ displayName: 'Trigger',
+ lastUpdatedDate: '2026-09-28T00:00:00.000Z',
+ settings: {},
+ nextAction: head,
+ },
+ }
+}
+
+function rename(flowVersion: FlowVersion): FlowVersion {
+ return flowOperations.apply(flowVersion, { type: FlowOperationType.CHANGE_NAME, request: { displayName: 'Renamed' } })
+}
+
+describe('flowStructureUtil.getSkippedStepNames', () => {
+ it('includes a skipped loop and every step inside it, but not the step after it', () => {
+ const flowVersion = flowWith(loopStep({
+ name: 'step_1',
+ skip: true,
+ firstLoopAction: codeStep({ name: 'step_2' }),
+ nextAction: codeStep({ name: 'step_3' }),
+ }))
+ expect(flowStructureUtil.getSkippedStepNames({ trigger: flowVersion.trigger })).toEqual(new Set(['step_1', 'step_2']))
+ })
+
+ it('includes only the step itself for a skipped step without children', () => {
+ const flowVersion = flowWith(codeStep({ name: 'step_1', skip: true, nextAction: codeStep({ name: 'step_2' }) }))
+ expect(flowStructureUtil.getSkippedStepNames({ trigger: flowVersion.trigger })).toEqual(new Set(['step_1']))
+ })
+
+ it('includes a skipped router and the steps in every branch, but not the step after it', () => {
+ const flowVersion = flowWith(routerStep({
+ name: 'step_1',
+ skip: true,
+ children: [codeStep({ name: 'step_2' }), codeStep({ name: 'step_3' })],
+ nextAction: codeStep({ name: 'step_4' }),
+ }))
+ expect(flowStructureUtil.getSkippedStepNames({ trigger: flowVersion.trigger })).toEqual(new Set(['step_1', 'step_2', 'step_3']))
+ })
+
+ it('includes the success and failure branches of a skipped step with continue on failure', () => {
+ const flowVersion = flowWith(codeStep({
+ name: 'step_1',
+ skip: true,
+ continueOnFailure: true,
+ onSuccess: codeStep({ name: 'step_2' }),
+ onFailure: codeStep({ name: 'step_3' }),
+ nextAction: codeStep({ name: 'step_4' }),
+ }))
+ expect(flowStructureUtil.getSkippedStepNames({ trigger: flowVersion.trigger })).toEqual(new Set(['step_1', 'step_2', 'step_3']))
+ })
+
+ it('includes the saved branches of a skipped step when continue on failure is off', () => {
+ const flowVersion = flowWith(codeStep({
+ name: 'step_1',
+ skip: true,
+ onSuccess: codeStep({ name: 'step_2' }),
+ onFailure: codeStep({ name: 'step_3' }),
+ }))
+ expect(flowStructureUtil.getSkippedStepNames({ trigger: flowVersion.trigger })).toEqual(new Set(['step_1', 'step_2', 'step_3']))
+ })
+})
+
+describe('flow version validity with skipped steps', () => {
+ it('is valid when the only invalid step is inside a skipped loop', () => {
+ const flowVersion = flowWith(loopStep({ name: 'step_1', skip: true, firstLoopAction: codeStep({ name: 'step_2', valid: false }) }))
+ expect(rename(flowVersion).valid).toBe(true)
+ })
+
+ it('is valid when the only invalid step is in a saved branch of a skipped step', () => {
+ const flowVersion = flowWith(codeStep({ name: 'step_1', skip: true, onFailure: codeStep({ name: 'step_2', valid: false }) }))
+ expect(rename(flowVersion).valid).toBe(true)
+ })
+
+ it('is invalid when the invalid step is after a skipped loop', () => {
+ const flowVersion = flowWith(loopStep({ name: 'step_1', skip: true, nextAction: codeStep({ name: 'step_2', valid: false }) }))
+ expect(rename(flowVersion).valid).toBe(false)
+ })
+})
diff --git a/packages/server/api/src/app/mcp/tools/ap-flow-structure.ts b/packages/server/api/src/app/mcp/tools/ap-flow-structure.ts
index 323751f3919..95af698a227 100644
--- a/packages/server/api/src/app/mcp/tools/ap-flow-structure.ts
+++ b/packages/server/api/src/app/mcp/tools/ap-flow-structure.ts
@@ -1,5 +1,5 @@
import { isNil, Permission } from '@activepieces/core-utils'
-import { BranchCondition, BranchExecutionType, FlowActionType, flowCanvasUtils, flowStructureUtil, FlowTriggerType, McpToolDefinition, Note, ProjectScopedMcpServer, StepLocationRelativeToParent } from '@activepieces/shared'
+import { BranchCondition, BranchExecutionType, FlowActionType, flowCanvasUtils, flowStructureUtil, FlowTrigger, FlowTriggerType, McpToolDefinition, Note, ProjectScopedMcpServer, StepLocationRelativeToParent } from '@activepieces/shared'
import type { Step } from '@activepieces/shared'
import { FastifyBaseLogger } from 'fastify'
import { z } from 'zod'
@@ -19,8 +19,8 @@ type StepInfo = {
configStatus: string
}
-function getConfigStatus(step: Step): string {
- if ((step as { skip?: boolean }).skip) return 'skipped'
+function getConfigStatus({ step, skippedStepNames }: { step: Step, skippedStepNames: Set<string> }): string {
+ if (skippedStepNames.has(step.name)) return 'skipped'
if (step.valid) return 'configured'
const s = step.settings as { triggerName?: string, actionName?: string }
switch (step.type) {
@@ -114,8 +114,9 @@ function formatBranchConditions(conditions: BranchCondition[][]): string {
return groups.join(' OR ')
}
-function buildFlowStructure(trigger: Step): { structure: StepInfo[], stepByName: Map<string, Step> } {
+function buildFlowStructure(trigger: FlowTrigger): { structure: StepInfo[], stepByName: Map<string, Step> } {
const allSteps = flowStructureUtil.getAllSteps(trigger)
+ const skippedStepNames = flowStructureUtil.getSkippedStepNames({ trigger })
const stepByName = new Map(allSteps.map(s => [s.name, s]))
const structure = allSteps.map((step): StepInfo => {
if (flowStructureUtil.isTrigger(step.type)) {
@@ -126,8 +127,8 @@ function buildFlowStructure(trigger: Step): { structure: StepInfo[], stepByName:
parentName: null,
relationship: 'trigger',
valid: step.valid,
- skip: (step as { skip?: boolean }).skip,
- configStatus: getConfigStatus(step),
+ skip: skippedStepNames.has(step.name),
+ configStatus: getConfigStatus({ step, skippedStepNames }),
}
}
let parentName: string | null = null
@@ -177,8 +178,8 @@ function buildFlowStructure(trigger: Step): { structure: StepInfo[], stepByName:
relationship,
...(relationship === 'branch' && { branchIndex, branchName }),
valid: step.valid,
- skip: (step as { skip?: boolean }).skip,
- configStatus: getConfigStatus(step),
+ skip: skippedStepNames.has(step.name),
+ configStatus: getConfigStatus({ step, skippedStepNames }),
}
})
return { structure, stepByName }
diff --git a/packages/server/api/src/app/mcp/tools/ap-lock-and-publish.ts b/packages/server/api/src/app/mcp/tools/ap-lock-and-publish.ts
index 864923f18fd..50c1da10a31 100644
--- a/packages/server/api/src/app/mcp/tools/ap-lock-and-publish.ts
+++ b/packages/server/api/src/app/mcp/tools/ap-lock-and-publish.ts
@@ -31,7 +31,8 @@ export const apLockAndPublishTool = ({ mcp, userId }: McpToolContext, log: Fasti
}
const allSteps = flowStructureUtil.getAllSteps(flow.version.trigger)
- const invalidSteps = allSteps.filter(s => !s.valid && !(s as { skip?: boolean }).skip)
+ const skippedStepNames = flowStructureUtil.getSkippedStepNames({ trigger: flow.version.trigger })
+ const invalidSteps = allSteps.filter(s => !s.valid && !skippedStepNames.has(s.name))
if (invalidSteps.length > 0) {
const stepList = invalidSteps.map(s => `"${s.name}" (${s.displayName})`).join(', ')
return {
diff --git a/packages/server/api/src/app/mcp/tools/flow-validation.ts b/packages/server/api/src/app/mcp/tools/flow-validation.ts
index 7db18f4df55..445d74b903c 100644
--- a/packages/server/api/src/app/mcp/tools/flow-validation.ts
+++ b/packages/server/api/src/app/mcp/tools/flow-validation.ts
@@ -1,8 +1,9 @@
import { isNil } from '@activepieces/core-utils'
-import { BranchExecutionType, flowStructureUtil, FlowTriggerType, Step } from '@activepieces/shared'
+import { BranchExecutionType, flowStructureUtil, FlowTrigger, FlowTriggerType, Step } from '@activepieces/shared'
-function validateFlow({ trigger }: { trigger: Step }): ValidationResult {
+function validateFlow({ trigger }: { trigger: FlowTrigger }): ValidationResult {
const allSteps = flowStructureUtil.getAllSteps(trigger)
+ const skippedStepNames = flowStructureUtil.getSkippedStepNames({ trigger })
const allStepNames = new Set(allSteps.map(s => s.name))
const issues: ValidationIssue[] = []
@@ -16,12 +17,12 @@ function validateFlow({ trigger }: { trigger: Step }): ValidationResult {
let skippedCount = 0
for (const step of allSteps) {
- const isSkipped = 'skip' in step && step.skip === true
-
- if (isSkipped) {
+ if (skippedStepNames.has(step.name)) {
skippedCount++
+ seenSteps.add(step.name)
+ continue
}
- else if (step.valid) {
+ if (step.valid) {
validCount++
}
else {
diff --git a/packages/web/src/app/builder/data-selector/utils.ts b/packages/web/src/app/builder/data-selector/utils.ts
index 2861b046d25..a85812d97b6 100644
--- a/packages/web/src/app/builder/data-selector/utils.ts
+++ b/packages/web/src/app/builder/data-selector/utils.ts
@@ -3,6 +3,7 @@ import {
flowCanvasUtils,
FlowAction,
FlowActionType,
+ flowStructureUtil,
FlowTrigger,
FlowTriggerType,
} from '@activepieces/shared';
@@ -318,7 +319,7 @@ function traverseStep(
stepNode.data = { ...stepNode.data, stepName: step.name };
}
- const cofEnabled = flowCanvasUtils.hasContinueOnFailureBranches(step);
+ const cofEnabled = flowStructureUtil.hasContinueOnFailureBranches(step);
if (cofEnabled) {
const branch = flowCanvasUtils.getStepBranchRelativeTo(
step,
diff --git a/packages/web/src/app/builder/flow-canvas/index.tsx b/packages/web/src/app/builder/flow-canvas/index.tsx
index f41badeff74..7532b9eeb4e 100644
--- a/packages/web/src/app/builder/flow-canvas/index.tsx
+++ b/packages/web/src/app/builder/flow-canvas/index.tsx
@@ -1,6 +1,5 @@
import { isNil } from '@activepieces/core-utils';
import {
- flowCanvasUtils as sharedFlowCanvasUtils,
FlowActionType,
flowStructureUtil,
FlowTriggerType,
@@ -162,7 +161,7 @@ export const FlowCanvas = React.memo(
if (
step.type === FlowActionType.LOOP_ON_ITEMS ||
flowStructureUtil.isBranchedAction(step) ||
- sharedFlowCanvasUtils.hasContinueOnFailureBranches(step)
+ flowStructureUtil.hasContinueOnFailureBranches(step)
) {
const childrenNotSelected = flowStructureUtil
.getAllChildSteps(step)
@@ -284,8 +283,7 @@ const getChildrenKey = (step: Step) => {
}, '');
case FlowActionType.CODE:
case FlowActionType.PIECE: {
- const cofEnabled =
- sharedFlowCanvasUtils.hasContinueOnFailureBranches(step);
+ const cofEnabled = flowStructureUtil.hasContinueOnFailureBranches(step);
const branches = step.continueOnFailureBranches;
const onSuccessKey = branches?.onSuccess
? flowStructureUtil
diff --git a/packages/web/src/app/builder/flow-canvas/nodes/step-node/index.tsx b/packages/web/src/app/builder/flow-canvas/nodes/step-node/index.tsx
index 8b28da33c11..6f9d291587d 100644
--- a/packages/web/src/app/builder/flow-canvas/nodes/step-node/index.tsx
+++ b/packages/web/src/app/builder/flow-canvas/nodes/step-node/index.tsx
@@ -16,7 +16,6 @@ import { stepsHooks } from '@/features/pieces';
import { cn } from '@/lib/utils';
import { flowCanvasConsts } from '../../utils/consts';
-import { flowCanvasUtils } from '../../utils/flow-canvas-utils';
import { ApStepNode } from '../../utils/types';
import { StepNodeChevron } from './step-node-chevron';
@@ -61,7 +60,10 @@ const ApStepCanvasNode = React.memo(
[step, flowVersion],
);
const isTrigger = flowStructureUtil.isTrigger(step.type);
- const isSkipped = flowCanvasUtils.isSkipped(step.name, flowVersion.trigger);
+ const isSkipped = flowStructureUtil.isSkipped({
+ stepName: step.name,
+ trigger: flowVersion.trigger,
+ });
const chevronClickOverride =
step.type === FlowTriggerType.EMPTY
? () => setOpenedPieceSelectorStepNameOrAddButtonId(step.name)
diff --git a/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-skipped-status.tsx b/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-skipped-status.tsx
index 61b8adba822..f815aa158da 100644
--- a/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-skipped-status.tsx
+++ b/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-skipped-status.tsx
@@ -10,7 +10,6 @@ import { RouteOff } from 'lucide-react';
import { flowRunUtils } from '@/features/flow-runs';
import { useBuilderStateContext } from '../../../builder-hooks';
-import { flowCanvasUtils } from '../../utils/flow-canvas-utils';
import { StepNodeBadgeContainer } from './step-node-badge-container';
@@ -20,7 +19,10 @@ const ApStepNodeSkippedStatus = ({ stepName }: { stepName: string }) => {
state.run,
flowStructureUtil.getStep(stepName, state.flowVersion.trigger)?.type,
state.flowVersion.state === FlowVersionState.DRAFT,
- flowCanvasUtils.isSkipped(stepName, state.flowVersion.trigger),
+ flowStructureUtil.isSkipped({
+ stepName,
+ trigger: state.flowVersion.trigger,
+ }),
],
);
diff --git a/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-status-in-draft.tsx b/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-status-in-draft.tsx
index 30770bf0ac0..02365adfb29 100644
--- a/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-status-in-draft.tsx
+++ b/packages/web/src/app/builder/flow-canvas/nodes/step-node/step-node-status-in-draft.tsx
@@ -19,7 +19,6 @@ import { StepStatusIcon, flowRunUtils } from '@/features/flow-runs';
import { pieceSelectorUtils } from '@/features/pieces';
import { useBuilderStateContext } from '../../../builder-hooks';
-import { flowCanvasUtils } from '../../utils/flow-canvas-utils';
import { StepNodeBadgeContainer } from './step-node-badge-container';
type DraftStepStatus =
@@ -60,7 +59,10 @@ const ApStepNodeStatusInDraft = ({ stepName }: { stepName: string }) => {
state.flowVersion.state === FlowVersionState.DRAFT,
!!step?.valid,
isManualTrigger,
- flowCanvasUtils.isSkipped(stepName, state.flowVersion.trigger),
+ flowStructureUtil.isSkipped({
+ stepName,
+ trigger: state.flowVersion.trigger,
+ }),
];
});
diff --git a/packages/web/src/app/builder/flow-canvas/utils/flow-canvas-utils.ts b/packages/web/src/app/builder/flow-canvas/utils/flow-canvas-utils.ts
index 9f86b2d8048..b20528cd3c5 100644
--- a/packages/web/src/app/builder/flow-canvas/utils/flow-canvas-utils.ts
+++ b/packages/web/src/app/builder/flow-canvas/utils/flow-canvas-utils.ts
@@ -11,7 +11,6 @@ import {
BranchedAction,
StepLocationRelativeToParent,
FlowTrigger,
- FlowTriggerType,
Note,
} from '@activepieces/shared';
import { t } from 'i18next';
@@ -137,7 +136,7 @@ const createStepGraph: (params: {
edges:
step.type !== FlowActionType.LOOP_ON_ITEMS &&
!flowStructureUtil.isBranchedAction(step) &&
- !sharedFlowCanvasUtils.hasContinueOnFailureBranches(step)
+ !flowStructureUtil.hasContinueOnFailureBranches(step)
? [straightLineEdge]
: [],
};
@@ -164,7 +163,7 @@ const buildFlowGraph: (params: {
? buildLoopChildGraph({ step, orientation })
: flowStructureUtil.isBranchedAction(step)
? buildRouterChildGraph({ step, orientation })
- : sharedFlowCanvasUtils.hasContinueOnFailureBranches(step)
+ : flowStructureUtil.hasContinueOnFailureBranches(step)
? buildContinueOnFailureBranchesGraph({ step, orientation })
: null;
@@ -636,31 +635,6 @@ const createAddOperationFromAddButtonData = (data: ApButtonData) => {
} as const;
};
-const isSkipped = (stepName: string, trigger: FlowTrigger) => {
- const step = flowStructureUtil.getStep(stepName, trigger);
- if (
- isNil(step) ||
- step.type === FlowTriggerType.EMPTY ||
- step.type === FlowTriggerType.PIECE
- ) {
- return false;
- }
- const skippedParents = flowStructureUtil
- .findPathToStep(trigger, stepName)
- .filter(
- (stepInPath) =>
- stepInPath.type === FlowActionType.LOOP_ON_ITEMS ||
- flowStructureUtil.isBranchedAction(stepInPath) ||
- sharedFlowCanvasUtils.hasContinueOnFailureBranches(stepInPath),
- )
- .filter((parentInPath) =>
- flowStructureUtil.isChildOf(parentInPath, stepName),
- )
- .filter((parent) => parent.skip);
-
- return skippedParents.length > 0 || !!step.skip;
-};
-
const getStepStatus = (
stepName: string | undefined,
run: FlowRun | null,
@@ -749,7 +723,6 @@ export const flowCanvasUtils = {
createFocusStepInGraphParams,
calculateGraphBoundingBox,
createAddOperationFromAddButtonData,
- isSkipped,
getStepStatus,
determineInitiallySelectedStep,
doesSelectionRectangleExist,
diff --git a/packages/web/src/app/builder/flow-canvas/widgets/incomplete-settings-widget.tsx b/packages/web/src/app/builder/flow-canvas/widgets/incomplete-settings-widget.tsx
index 34dee84b647..d6e1e0366a8 100644
--- a/packages/web/src/app/builder/flow-canvas/widgets/incomplete-settings-widget.tsx
+++ b/packages/web/src/app/builder/flow-canvas/widgets/incomplete-settings-widget.tsx
@@ -1,8 +1,6 @@
import {
- FlowAction,
FlowTriggerType,
FlowVersion,
- Step,
flowStructureUtil,
} from '@activepieces/shared';
import { useReactFlow } from '@xyflow/react';
@@ -25,18 +23,13 @@ const IncompleteSettingsButton: React.FC<IncompleteSettingsButtonProps> = ({
selectStepByName,
setOpenedPieceSelectorStepNameOrAddButtonId,
}) => {
- const invalidSteps = useMemo(
- () =>
- flowStructureUtil
- .getAllSteps(flowVersion.trigger)
- .filter(filterValidOrSkippedSteps).length,
+ const invalidStepCount = useMemo(
+ () => getInvalidSteps(flowVersion).length,
[flowVersion],
);
const { fitView } = useReactFlow();
function onClick() {
- const invalidSteps = flowStructureUtil
- .getAllSteps(flowVersion.trigger)
- .filter(filterValidOrSkippedSteps);
+ const invalidSteps = getInvalidSteps(flowVersion);
if (invalidSteps.length > 0) {
const stepToFocus = invalidSteps[0];
selectStepByName(stepToFocus.name);
@@ -58,7 +51,7 @@ const IncompleteSettingsButton: React.FC<IncompleteSettingsButtonProps> = ({
e.preventDefault();
}}
>
- {t('incompleteSteps', { invalidSteps: invalidSteps })}
+ {t('incompleteSteps', { invalidSteps: invalidStepCount })}
</Button>
)
);
@@ -66,7 +59,11 @@ const IncompleteSettingsButton: React.FC<IncompleteSettingsButtonProps> = ({
IncompleteSettingsButton.displayName = 'IncompleteSettingsButton';
export default IncompleteSettingsButton;
-function filterValidOrSkippedSteps(step: Step) {
- if ((step as FlowAction).skip) return false;
- return !step.valid;
+function getInvalidSteps(flowVersion: FlowVersion) {
+ const skippedStepNames = flowStructureUtil.getSkippedStepNames({
+ trigger: flowVersion.trigger,
+ });
+ return flowStructureUtil
+ .getAllSteps(flowVersion.trigger)
+ .filter((step) => !step.valid && !skippedStepNames.has(step.name));
}