Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • prevent cross-boundary connections on autoconnect drop between subflow blocks and regular blocks

Type of Change

  • Bug fix

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 14, 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 14, 2025 1:32am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 14, 2025

Greptile Overview

Greptile Summary

This PR fixes a critical bug in the autoconnect functionality by preventing cross-boundary connections between subflow blocks and regular blocks. The fix modifies the findClosestOutput function in the workflow component by replacing incomplete boundary checking logic with explicit parent ID comparison. Previously, the system only prevented connections when dropping outside containers while having a parent ID, but missed other boundary violation scenarios like connecting between different subflows. The new logic compares the parent IDs of both the drop location and the source block to ensure they match, maintaining workflow execution integrity by enforcing that connections only occur between blocks in the same container context.

Important Files Changed

Filename Score Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx 5/5 Enhanced boundary checking logic to prevent cross-container autoconnect by comparing parent IDs

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only strengthens existing validation logic
  • Score reflects the focused nature of the fix addressing a specific architectural constraint violation with clear, logical boundary checking
  • No files require special attention as the change is isolated and improves system integrity

Sequence Diagram

sequenceDiagram
    participant User
    participant WorkflowCanvas as "Workflow Canvas"
    participant DragHandler as "Drag Handler"
    participant AutoConnect as "Auto Connect Logic"
    participant BlockValidator as "Block Validator"
    participant EdgeManager as "Edge Manager"
    participant Store as "Workflow Store"

    User->>WorkflowCanvas: "Drag block from toolbar"
    WorkflowCanvas->>DragHandler: "onDrop(event)"
    DragHandler->>DragHandler: "Parse drag data"
    DragHandler->>DragHandler: "Calculate drop position"
    
    alt "Block dropped inside subflow"
        DragHandler->>BlockValidator: "Check if trigger block"
        BlockValidator-->>DragHandler: "Validation result"
        alt "Is trigger block"
            DragHandler->>User: "Show error notification"
        else "Valid block type"
            DragHandler->>AutoConnect: "findClosestOutput(position)"
            AutoConnect->>AutoConnect: "Filter candidates by same parent"
            AutoConnect-->>DragHandler: "Return closest block or null"
            alt "Auto-connect enabled and closest block found"
                DragHandler->>AutoConnect: "determineSourceHandle(closestBlock)"
                AutoConnect-->>DragHandler: "Return source handle"
                DragHandler->>EdgeManager: "Create auto-connect edge"
            end
            DragHandler->>Store: "addBlock(id, type, name, position, parentData, autoConnectEdge)"
        end
    else "Block dropped on main canvas"
        DragHandler->>AutoConnect: "findClosestOutput(position)"
        AutoConnect->>AutoConnect: "Filter candidates excluding child nodes"
        AutoConnect-->>DragHandler: "Return closest block or null"
        alt "Auto-connect enabled and closest block found"
            DragHandler->>AutoConnect: "determineSourceHandle(closestBlock)"
            AutoConnect-->>DragHandler: "Return source handle"
            DragHandler->>EdgeManager: "Create auto-connect edge"
        end
        DragHandler->>Store: "addBlock(id, type, name, position, undefined, autoConnectEdge)"
    end
    
    Store->>WorkflowCanvas: "Update workflow state"
    WorkflowCanvas->>User: "Display updated workflow"
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 0fb084b into staging Dec 14, 2025
10 checks passed
@waleedlatif1 waleedlatif1 deleted the sim-503 branch December 14, 2025 01:39
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