fix(workflow): use panel-aware viewport center for paste and block placement#3024
Merged
waleedlatif1 merged 1 commit intostagingfrom Jan 27, 2026
Merged
fix(workflow): use panel-aware viewport center for paste and block placement#3024waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
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
|
437ddf7 to
e0cced0
Compare
Collaborator
Author
|
@greptile |
e0cced0 to
b579c9b
Compare
There 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.
b579c9b to
77e3acd
Compare
6 tasks
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
getViewportCenterfromuseCanvasViewporthook instead of naive rect.width/2 calculationgetVisibleCanvasCenterto reusegetVisibleCanvasBounds(removed duplicate code)isInvitationsDisabledandhandleContextInviteType of Change
Testing
Tested manually
Checklist