-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(workflow): use panel-aware viewport center for paste and block placement #3024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
437ddf7 to
e0cced0
Compare
|
@greptile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No files reviewed, no comments
e0cced0 to
b579c9b
Compare
There was a problem hiding this comment.
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 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
Summary
getViewportCenterfromuseCanvasViewporthook instead of naive rect.width/2 calculationgetVisibleCanvasCenterto reusegetVisibleCanvasBounds(removed duplicate code)isInvitationsDisabledandhandleContextInviteType of Change
Testing
Tested manually
Checklist