Uh oh!
There was an error while loading. Please reload this page.
fix(workflow): use panel-aware viewport center for paste and block placement - #3024
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR fixes viewport center calculation for block paste and placement operations by using panel-aware bounds from the Key Changes:
Impact: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Workflow
participant useCanvasViewport
participant getVisibleCanvasBounds
participant calculatePasteOffset
participant executePasteOperation
participant regenerateBlockIds
User->>Workflow: Paste blocks (Cmd+V or Context Menu)
Workflow->>useCanvasViewport: getViewportCenter()
useCanvasViewport->>getVisibleCanvasBounds: Get visible bounds
Note over getVisibleCanvasBounds: Accounts for sidebar, panel,<br/>and terminal overlays
getVisibleCanvasBounds-->>useCanvasViewport: Returns visible bounds
useCanvasViewport->>useCanvasViewport: Calculate center from bounds
useCanvasViewport->>Workflow: screenToFlowPosition(center)
useCanvasViewport-->>Workflow: Viewport center in flow coords
Workflow->>calculatePasteOffset: Calculate offset
Note over calculatePasteOffset: Calculate clipboard center<br/>from block positions
calculatePasteOffset-->>Workflow: Paste offset
Workflow->>executePasteOperation: Execute paste
alt Pasting into subflow
executePasteOperation->>executePasteOperation: Validate (no triggers/subflows)
executePasteOperation->>executePasteOperation: Adjust positions to relative coords
executePasteOperation->>executePasteOperation: Clamp to container bounds
executePasteOperation->>executePasteOperation: Set parentId and extent
end
executePasteOperation->>regenerateBlockIds: Generate new IDs
alt Block has parent in existing workflow
Note over regenerateBlockIds: Cap large viewport offset to<br/>DEFAULT_DUPLICATE_OFFSET (180,20)
regenerateBlockIds->>regenerateBlockIds: Use capped offset
regenerateBlockIds->>regenerateBlockIds: Preserve parentId
else Block has parent in paste set
regenerateBlockIds->>regenerateBlockIds: Keep relative position
regenerateBlockIds->>regenerateBlockIds: Remap parentId to new ID
else Top-level block
regenerateBlockIds->>regenerateBlockIds: Apply full viewport offset
end
regenerateBlockIds-->>executePasteOperation: New blocks with remapped IDs
executePasteOperation->>Workflow: Add blocks to workflow
Workflow-->>User: Blocks pasted at viewport center
|
Uh oh!
There was an error while loading. Please reload this page.
437ddf7 to
e0cced0Comparewaleedlatif1
commented
Jan 27, 2026
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e0cced0 to
b579c9bCompareThere was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Uh oh!
There was an error while loading. Please reload this page.
b579c9b to
77e3acdCompareUh oh!
There was an error while loading. Please reload this page.
Summary
getViewportCenterfromuseCanvasViewporthook instead of naive rect.width/2 calculationgetVisibleCanvasCenterto reusegetVisibleCanvasBounds(removed duplicate code)isInvitationsDisabledandhandleContextInviteType of Change
Testing
Tested manually
Checklist