Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • use native reactflow getIntersectingNodes instead of custom impl for easy connect

Type of Change

  • Code Improvement

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 27, 2025 2:24am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 27, 2025

Greptile Summary

Replaced custom node position detection with ReactFlow's native getIntersectingNodes API in the easy connect feature. The new implementation creates a 2x2 pixel cursor rectangle and uses ReactFlow's built-in intersection detection instead of manually calculating bounding box overlaps.

Key improvements:

  • Uses ReactFlow's native getIntersectingNodes API for better performance and maintainability
  • Added distance-based selection when multiple nodes overlap (selects node closest to cursor center)
  • Removed unused imports: getNodeHierarchy, collaborativeSetSubblockValue, and updateNodeDimensions from dependencies
  • Removed obsolete comment about accounting for header/padding dimensions

The logic correctly filters out subflow nodes and handles both single and multiple intersection cases.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change replaces custom intersection logic with ReactFlow's well-tested native API, which is a code improvement. The new implementation correctly handles edge cases (no nodes, single node, multiple overlapping nodes) and maintains the same behavior of filtering out subflow nodes. Removed unused imports are verified to not be used elsewhere in this file.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Replaced custom node intersection logic with ReactFlow's native getIntersectingNodes API. Added distance-based selection for overlapping nodes. Removed unused imports.

Sequence Diagram

sequenceDiagram
    participant User
    participant WorkflowContent
    participant ReactFlow
    participant findNodeAtPosition
    participant onConnectEnd

    User->>onConnectEnd: Drag connection handle and release
    onConnectEnd->>findNodeAtPosition: Call with cursor position
    findNodeAtPosition->>findNodeAtPosition: Create 2x2 cursor rectangle
    findNodeAtPosition->>ReactFlow: getIntersectingNodes(cursorRect, true)
    ReactFlow-->>findNodeAtPosition: Return intersecting nodes
    findNodeAtPosition->>findNodeAtPosition: Filter out subflowNode types
    alt No intersecting nodes
        findNodeAtPosition-->>onConnectEnd: Return undefined
    else Single intersecting node
        findNodeAtPosition-->>onConnectEnd: Return that node
    else Multiple intersecting nodes
        findNodeAtPosition->>findNodeAtPosition: Calculate distance to each node center
        findNodeAtPosition->>findNodeAtPosition: Select closest node using hypot
        findNodeAtPosition-->>onConnectEnd: Return closest node
    end
    onConnectEnd->>WorkflowContent: onConnect() with target node
Loading

@waleedlatif1 waleedlatif1 merged commit 5add261 into staging Dec 27, 2025
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/autoconnect branch December 27, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants