fix(subflows): added change detection for parallels, updated deploy and status schemas to match parallel/loop (#956)

This commit is contained in:
Waleed Latif
2025-08-13 21:18:07 -07:00
committed by GitHub
parent d4f412af92
commit da04ea0e9f
3 changed files with 43 additions and 10 deletions

View File

@@ -211,16 +211,19 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
const config = (subflow.config as any) || {}
if (subflow.type === 'loop') {
loops[subflow.id] = {
id: subflow.id,
nodes: config.nodes || [],
iterationCount: config.iterationCount || 1,
iterationType: config.iterationType || 'fixed',
collection: config.collection || '',
iterations: config.iterations || 1,
loopType: config.loopType || 'for',
forEachItems: config.forEachItems || '',
}
} else if (subflow.type === 'parallel') {
parallels[subflow.id] = {
id: subflow.id,
nodes: config.nodes || [],
parallelCount: config.parallelCount || 2,
collection: config.collection || '',
count: config.count || 2,
distribution: config.distribution || '',
parallelType: config.parallelType || 'count',
}
}
})

View File

@@ -57,16 +57,19 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
const config = (subflow.config as any) || {}
if (subflow.type === 'loop') {
loops[subflow.id] = {
id: subflow.id,
nodes: config.nodes || [],
iterationCount: config.iterationCount || 1,
iterationType: config.iterationType || 'fixed',
collection: config.collection || '',
iterations: config.iterations || 1,
loopType: config.loopType || 'for',
forEachItems: config.forEachItems || '',
}
} else if (subflow.type === 'parallel') {
parallels[subflow.id] = {
id: subflow.id,
nodes: config.nodes || [],
parallelCount: config.parallelCount || 2,
collection: config.collection || '',
count: config.count || 2,
distribution: config.distribution || '',
parallelType: config.parallelType || 'count',
}
}
})

View File

@@ -313,6 +313,33 @@ export function hasWorkflowChanged(
}
}
// 5. Compare parallels
const currentParallels = currentState.parallels || {}
const deployedParallels = deployedState.parallels || {}
const currentParallelIds = Object.keys(currentParallels).sort()
const deployedParallelIds = Object.keys(deployedParallels).sort()
if (
currentParallelIds.length !== deployedParallelIds.length ||
normalizedStringify(currentParallelIds) !== normalizedStringify(deployedParallelIds)
) {
return true
}
// Compare each parallel with normalized values
for (const parallelId of currentParallelIds) {
const normalizedCurrentParallel = normalizeValue(currentParallels[parallelId])
const normalizedDeployedParallel = normalizeValue(deployedParallels[parallelId])
if (
normalizedStringify(normalizedCurrentParallel) !==
normalizedStringify(normalizedDeployedParallel)
) {
return true
}
}
return false
}