fix(sockets): redrawing edges should not lead to socket ops#2804
fix(sockets): redrawing edges should not lead to socket ops#2804icecrasher321 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR consolidates duplicate edge filtering logic introduced in commit 8ccf454 into a reusable Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as User/UI
participant Hook as useCollaborativeWorkflow
participant Filter as filterNewEdges
participant Store as WorkflowStore
participant Queue as Operation Queue
participant Socket as WebSocket
User->>Hook: collaborativeBatchAddEdges(edges)
Hook->>Store: get current edges
Store-->>Hook: currentEdges[]
Hook->>Filter: filterNewEdges(edges, currentEdges)
Note over Filter: Filter out:<br/>1. Self-referencing edges<br/>2. Duplicate connections<br/>(same source/target/handles)
Filter-->>Hook: newEdges[]
alt newEdges.length > 0
Hook->>Queue: addToQueue(BATCH_ADD_EDGES, newEdges)
Queue->>Socket: Send to collaborators
Hook->>Store: batchAddEdges(newEdges)
Note over Store: Only cycle check needed,<br/>duplicates already filtered
Store-->>Hook: edges updated
Hook->>Hook: recordAddEdge (undo/redo)
else newEdges.length === 0
Note over Hook: No-op: all edges already exist<br/>Prevents redundant socket ops
end
Note over Socket: Collaborator receives operation
Socket->>Hook: BATCH_ADD_EDGES event
Hook->>Store: get current edges
Store-->>Hook: currentEdges[]
Hook->>Filter: filterNewEdges(payload.edges, currentEdges)
Filter-->>Hook: newEdges[]
alt newEdges.length > 0
Hook->>Store: batchAddEdges(newEdges)
Store-->>Hook: edges updated
else newEdges.length === 0
Note over Hook: Skip: edges already exist<br/>from redraw/sync
end
|
|
@greptile |
There was a problem hiding this comment.
Additional Comments (1)
-
apps/sim/stores/workflows/utils.ts, line 17-20 (link)style: imports split across the file - move all import statements to the top of the file before function definitions
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Context Used: Context from
dashboard- Import patterns for the Sim application (source)
4 files reviewed, 1 comment
Summary
Redrawing edges should not lead to socket ops -- add check to collab function.
Type of Change
Testing
Tested manually
Checklist