Skip to content

fix(workflow): attach cmdk-added blocks to the selected block - #6836

Merged
j15z merged 3 commits into
stagingfrom
fix/attach-new-block-to-correct-prev
Aug 19, 2026
Merged

fix(workflow): attach cmdk-added blocks to the selected block#6836
j15z merged 3 commits into
stagingfrom
fix/attach-new-block-to-correct-prev

Conversation

@j15z

@j15z j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • cmdk/toolbar block adds auto-connected to the block closest to the viewport center, which kept wiring each new block back to the original block instead of the currently selected one
  • positionless adds now attach to the currently selected block, falling back to the last block touched this session (in-memory, resets on reload), then to the canvas's only block (a fresh workflow's trigger)
  • with no source to attach to (fresh load, untouched canvas), the block is added unattached and parked at the bottom of the rightmost column — near the end of the workflow
  • new blocks are placed one layout column after their source (nudged below occupied spots) instead of landing on top of existing blocks at the viewport center
  • drag-drop and drag-from-handle adds keep their existing proximity/forced-source behavior
  • includes the next-dev generated AGENTS.md rules block

Type of Change

  • Bug fix

Testing

Tested manually against the running app: fresh-workflow first add, chained cmdk adds, deselected add (last-touched fallback), fan-out from a re-selected upstream block, and a fresh load of an untouched multi-block workflow (rightmost-column parking, no edge). Lint, type-check, and the full audit suite pass.

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

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 19, 2026 2:02am

Request Review

@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes core canvas add/auto-connect and placement logic in a large workflow component; behavior is user-visible across cmdk/toolbar paths but drag-drop is unchanged and scope is localized to positionless adds.

Overview
Positionless block adds (command palette, toolbar click) no longer auto-connect from the block closest to the viewport center or land on top of existing cards at that point.

Auto-connect now picks a root-level source in order: the rightmost eligible selected block, then last interacted block this session (also used for z-order), then the only flow block on a fresh workflow. If nothing qualifies, the block is added without an edge instead of guessing a wire.

Placement places connected blocks one autolayout column to the right of the source (vertically centered, then nudged below overlapping root blocks). Unattached adds park under the rightmost root flow column; viewport center is only the last fallback.

Drag-drop and handle-release adds still use proximity-based tryCreateAutoConnectEdge via handleToolbarDrop.

Also includes the next dev generated AGENTS.md block (Next.js agent rules).

Reviewed by Cursor Bugbot for commit 1a6f6fe. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes positionless workflow-block additions to connect and position relative to an eligible selected or recently interacted block, with a deterministic fallback for unattached additions.

  • Filters selected auto-connect sources before choosing the rightmost eligible root-level flow block.
  • Places connected additions in the following layout column and nudges them around occupied space.
  • Excludes notes from unattached-placement anchors and parks unattached blocks beneath the rightmost flow column.
  • Adds the Next.js-generated agent guidance block.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Updates positionless block source resolution and placement; both previously reported selection-order and note-anchor issues are resolved at current HEAD.
apps/sim/AGENTS.md Adds generated Next.js agent guidance without affecting application runtime behavior.

Reviews (2): Last reviewed commit: "fix(workflow): validate positionless-add..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx
… park unattached blocks in the rightmost column
@j15z j15z changed the title fix(workflow): attach cmdk-added blocks to the selected block DONT MERGE fix(workflow): attach cmdk-added blocks to the selected block Aug 19, 2026
@j15z

j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1a6f6fe. Configure here.

if (!node.selected || !isEligibleSource(node.id)) continue
if (!sourceId || blocks[node.id].position.x > blocks[sourceId].position.x) {
sourceId = node.id
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same-column multi-select source tie

Low Severity

When several eligible selected blocks share the same x — typical for fan-out siblings stacked by nudgeBelowOccupiedSpots — the rightmost picker only uses a strict > on blocks.position.x, so the winner stays whichever node appears first in getNodes(). That is not a visual-end choice and can auto-connect from an arbitrary co-column sibling.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a6f6fe. Configure here.

@j15z
j15z merged commit 7bfd78c into staging Aug 19, 2026
30 checks passed
@j15z j15z changed the title DONT MERGE fix(workflow): attach cmdk-added blocks to the selected block fix(workflow): attach cmdk-added blocks to the selected block Aug 19, 2026
@waleedlatif1
waleedlatif1 deleted the fix/attach-new-block-to-correct-prev branch August 19, 2026 05:04
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.

1 participant