improvement(autoconnect): click to add paths also autoconnect#2737
Merged
icecrasher321 merged 1 commit intostagingfrom Jan 9, 2026
Merged
improvement(autoconnect): click to add paths also autoconnect#2737icecrasher321 merged 1 commit intostagingfrom
icecrasher321 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Adds auto-connect functionality to toolbar click events (Cmd+K and toolbar clicks), matching the existing drag-and-drop behavior. When users add blocks via these methods, edges are now automatically created to the closest suitable output block.
Major changes:
- Modified
handleAddBlockFromToolbarevent handler to calltryCreateAutoConnectEdgebefore adding blocks - Added
tryCreateAutoConnectEdgeto the useEffect dependency array - Updated settings label from "Auto-connect on drag" to "Auto-connect on drop"
Minor concern:
- The settings label "Auto-connect on drop" doesn't fully reflect that the feature now applies to both drag-drop AND click-to-add operations
Confidence Score: 4/5
- This PR is safe to merge with minimal risk
- The implementation correctly adds auto-connect functionality to click-to-add operations using the same battle-tested logic as drag-and-drop. Code follows existing patterns and maintains consistency. Only minor concern is a slightly misleading UI label that could be improved for clarity.
- No files require special attention - the implementation is straightforward and consistent with existing patterns
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx | 4/5 | Added auto-connect edge creation for toolbar click events (Cmd+K and toolbar clicks) to match drag-and-drop behavior. Implementation is consistent and correct. |
| apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/general/general.tsx | 3/5 | Updated label from 'Auto-connect on drag' to 'Auto-connect on drop', though this doesn't fully reflect that the feature now also applies to click-to-add operations. |
Sequence Diagram
sequenceDiagram
participant User
participant Toolbar/CmdK
participant WorkflowContent
participant tryCreateAutoConnectEdge
participant findClosestOutput
participant addBlock
User->>Toolbar/CmdK: Click to add block
Toolbar/CmdK->>WorkflowContent: dispatch 'add-block-from-toolbar' event
WorkflowContent->>WorkflowContent: getViewportCenter()
WorkflowContent->>WorkflowContent: checkTriggerConstraints()
WorkflowContent->>tryCreateAutoConnectEdge: call with position & block info
tryCreateAutoConnectEdge->>tryCreateAutoConnectEdge: check isAutoConnectEnabled
alt Auto-connect enabled
tryCreateAutoConnectEdge->>findClosestOutput: find closest block to position
findClosestOutput->>findClosestOutput: filter blocks by container context
findClosestOutput-->>tryCreateAutoConnectEdge: return closest block
tryCreateAutoConnectEdge->>tryCreateAutoConnectEdge: create edge object
tryCreateAutoConnectEdge-->>WorkflowContent: return Edge
else Auto-connect disabled
tryCreateAutoConnectEdge-->>WorkflowContent: return undefined
end
WorkflowContent->>addBlock: add block with optional edge
addBlock->>addBlock: collaborativeBatchAddBlocks(block, edges)
.../[workspaceId]/w/components/sidebar/components/settings-modal/components/general/general.tsx
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Click to add block paths [cmd k and toolbar] should also create autoconnect edges.
Type of Change
Testing
Tested manually
Checklist