Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  • Only autoconnect on drag path for adding blocks
  • For cmd k click and toolbar click -- place into view.

Type of Change

  • Other: UX 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 Jan 7, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 7, 2026 8:47pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 7, 2026

Greptile Summary

This PR improves the UX for adding blocks by distinguishing between click and drag interactions:

  • Click path (toolbar button, Cmd+K): Blocks are now placed at viewport center without auto-connecting to existing blocks
  • Drag path: Blocks continue to auto-connect based on drop position
  • Extracted getViewportCenter() utility function for code reuse
  • Cleaned up handleAddBlockFromToolbar by removing unused auto-connect logic
  • Correctly removed unused dependencies from useEffect dependency array (tryCreateAutoConnectEdge, isPointInLoopNode, addNotification, activeWorkflowId)

The changes align with the PR description's goals and make block addition more intuitive by only auto-connecting when the user explicitly drags a block to a specific location.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-scoped and focused on a single UX improvement. The dependency array cleanup is correct (removed dependencies are not used in the new implementation). The extracted getViewportCenter() utility promotes code reuse without changing behavior. No breaking changes, security issues, or logical errors detected.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Simplified block addition UX by removing auto-connect for toolbar/cmd-k clicks and positioning new blocks at viewport center; auto-connect now only occurs during drag operations

Sequence Diagram

sequenceDiagram
    participant User
    participant Toolbar
    participant CmdK as Command Palette
    participant Canvas
    participant Handler as handleAddBlockFromToolbar
    participant DragHandler as handleToolbarDrop

    Note over User,DragHandler: Click Path (Toolbar/Cmd+K)
    User->>Toolbar: Click block
    Toolbar->>Handler: dispatch 'add-block-from-toolbar' event
    Handler->>Handler: getViewportCenter()
    Handler->>Canvas: addBlock(at viewport center, no autoconnect)
    
    User->>CmdK: Click block in Cmd+K
    CmdK->>Handler: dispatch 'add-block-from-toolbar' event
    Handler->>Handler: getViewportCenter()
    Handler->>Canvas: addBlock(at viewport center, no autoconnect)

    Note over User,DragHandler: Drag Path
    User->>Toolbar: Drag block
    User->>Canvas: Drop on canvas
    Canvas->>DragHandler: onDrop with cursor position
    DragHandler->>DragHandler: tryCreateAutoConnectEdge()
    DragHandler->>Canvas: addBlock(at drop position, WITH autoconnect)
Loading

@icecrasher321 icecrasher321 merged commit 3b4f7d6 into staging Jan 7, 2026
11 checks passed
waleedlatif1 pushed a commit that referenced this pull request Jan 8, 2026
* improvement(add-block): intuitive autoconnect + positioning

* cleanup code
@waleedlatif1 waleedlatif1 deleted the improvement/add-block-ux branch January 8, 2026 18:38
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