Compare commits

...

1 Commits

2 changed files with 38 additions and 14 deletions

View File

@@ -24,7 +24,9 @@ export function hasWorkflowChanged(
deployedState: WorkflowState | null
): boolean {
// If no deployed state exists, then the workflow has changed
if (!deployedState) return true
if (!deployedState) {
return true
}
// 1. Compare edges (connections between blocks)
const currentEdges = currentState.edges || []

View File

@@ -95,19 +95,41 @@ export const useOperationQueueStore = create<OperationQueueState>((set, get) =>
return
}
// Enhanced duplicate content check - especially important for block operations
const duplicateContent = state.operations.find(
(op) =>
op.operation.operation === operation.operation.operation &&
op.operation.target === operation.operation.target &&
op.workflowId === operation.workflowId &&
// For block operations, check the block ID specifically
((operation.operation.target === 'block' &&
op.operation.payload?.id === operation.operation.payload?.id) ||
// For other operations, fall back to full payload comparison
(operation.operation.target !== 'block' &&
JSON.stringify(op.operation.payload) === JSON.stringify(operation.operation.payload)))
)
// Enhanced duplicate content check - especially important for block and edge operations
const duplicateContent = state.operations.find((op) => {
if (
op.operation.operation !== operation.operation.operation ||
op.operation.target !== operation.operation.target ||
op.workflowId !== operation.workflowId
) {
return false
}
// For block operations, check the block ID specifically
if (operation.operation.target === 'block') {
return op.operation.payload?.id === operation.operation.payload?.id
}
// For edge operations (batch-add-edges), check by source→target connection
// This prevents duplicate edges with different IDs but same connection
if (
operation.operation.target === 'edges' &&
operation.operation.operation === 'batch-add-edges'
) {
const newEdges = operation.operation.payload?.edges || []
const existingEdges = op.operation.payload?.edges || []
// Check if any new edge has the same source→target as an existing operation's edges
return newEdges.some((newEdge: any) =>
existingEdges.some(
(existingEdge: any) =>
existingEdge.source === newEdge.source && existingEdge.target === newEdge.target
)
)
}
// For other operations, fall back to full payload comparison
return JSON.stringify(op.operation.payload) === JSON.stringify(operation.operation.payload)
})
const isReplaceStateWorkflowOp =
operation.operation.target === 'workflow' && operation.operation.operation === 'replace-state'