-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(comparison): add condition to prevent duplicate identical edges #2799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ignore from workflow change detection
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR restores duplicate edge prevention at the store level, implementing a more precise check that validates all four connection fields (source, sourceHandle, target, targetHandle) instead of just source and target nodes. This addresses the senior developer's previous feedback about programmatic edge additions potentially creating duplicates. Key Changes:
Why This Approach: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant onConnectStart
participant onConnect
participant onConnectEnd
participant batchAddEdges
User->>onConnectStart: Start dragging connection
activate onConnectStart
onConnectStart->>onConnectStart: Set connectionCompletedRef = false
onConnectStart->>onConnectStart: Store source node/handle
deactivate onConnectStart
alt Handle-to-handle connection
User->>onConnect: Drop on target handle
activate onConnect
onConnect->>onConnect: Validate connection
onConnect->>batchAddEdges: Add edge
activate batchAddEdges
batchAddEdges->>batchAddEdges: Check if edge ID exists
batchAddEdges->>batchAddEdges: Check for self-reference
batchAddEdges->>batchAddEdges: Check if identical connection exists<br/>(source, sourceHandle, target, targetHandle)
batchAddEdges->>batchAddEdges: Check for cycles
batchAddEdges->>batchAddEdges: Add edge to store
deactivate batchAddEdges
onConnect->>onConnect: Set connectionCompletedRef = true
deactivate onConnect
User->>onConnectEnd: Connection drag ends
activate onConnectEnd
onConnectEnd->>onConnectEnd: Check connectionCompletedRef = true
onConnectEnd->>onConnectEnd: Skip (already handled)
deactivate onConnectEnd
else Handle-to-body connection
User->>onConnectEnd: Drop on block body
activate onConnectEnd
onConnectEnd->>onConnectEnd: Check connectionCompletedRef = false
onConnectEnd->>onConnectEnd: Find target node at cursor
onConnectEnd->>onConnect: Create connection to 'target' handle
activate onConnect
onConnect->>batchAddEdges: Add edge
activate batchAddEdges
batchAddEdges->>batchAddEdges: Check duplicate (all 4 fields)
batchAddEdges->>batchAddEdges: Add edge to store
deactivate batchAddEdges
onConnect->>onConnect: Set connectionCompletedRef = true
deactivate onConnect
deactivate onConnectEnd
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (1)
-
apps/sim/stores/workflows/workflow/store.ts, line 300-311 (link)logic: Check that test still passes - it expects calling
batchAddEdgestwice with different IDs but same source/target creates only one edge. With duplicate check removed, both edges will be added.
2 files reviewed, 2 comments
Summary
Type of Change
Testing
Tested manaully
Checklist