fix(autoconnect): cleaned up autoconnect#1127
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR enhances the autoconnect functionality in the workflow system by fixing critical edge cases related to nested containers and improving connection precision. The changes span two key files:
utils.ts Changes:
The primary fix addresses a bug in the isPointInLoopNode function where nested containers weren't being properly detected. Previously, the function used relative coordinates (n.position) for containment checks, which failed for nested loop/parallel nodes since their position is relative to their parent container, not the canvas. The fix switches to using getNodeAbsolutePosition(n.id, getNodes) for both containment rectangle calculations and returned position data, ensuring accurate spatial detection for nested container hierarchies.
workflow.tsx Enhancements:
Several significant improvements were made to the autoconnect system:
- A new
getNodeAnchorPositionfunction calculates precise connection points at the right-middle edge of blocks, replacing less accurate center-based positioning - Enhanced
findClosestOutputlogic that respects container boundaries and filters out child nodes when dropping blocks outside containers - New auto-connect functionality for drag-and-drop scenarios when blocks are moved into containers, automatically establishing connections to existing children or container start handles
- Container-aware filtering that prevents inappropriate cross-container connections
These changes integrate with the existing workflow store architecture and maintain the visual workflow building paradigm where spatial relationships and container hierarchies are fundamental to the user experience. The enhancements should make the autoconnect system more reliable and intuitive, particularly when working with complex nested workflow structures.
Confidence score: 4/5
- This PR appears safe to merge with generally well-structured improvements to autoconnect functionality
- Score reflects solid logic improvements and bug fixes, though the complexity of spatial calculations and container hierarchies introduces some inherent risk
- Pay close attention to the workflow.tsx file due to its complex auto-connect logic and potential impact on user interactions
2 files reviewed, no comments
Summary
Cleaned up autoconnect edge cases
Type of Change
Testing
Manually
Checklist