Skip to content

Fix Alt-drag duplicate cleanup on right-click abort#3782

Open
jsjgdh wants to merge 11 commits intoGraphiteEditor:masterfrom
jsjgdh:Alt-Fix
Open

Fix Alt-drag duplicate cleanup on right-click abort#3782
jsjgdh wants to merge 11 commits intoGraphiteEditor:masterfrom
jsjgdh:Alt-Fix

Conversation

@jsjgdh
Copy link
Copy Markdown
Contributor

@jsjgdh jsjgdh commented Feb 17, 2026

@jsjgdh jsjgdh marked this pull request as draft February 17, 2026 23:16
@Keavon
Copy link
Copy Markdown
Member

Keavon commented Feb 17, 2026

/gemini review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to ensure Alt-drag node duplication is cleaned up correctly when the drag is aborted (notably via right-click), by tracking whether duplication occurred during the drag and adjusting transaction handling.

Changes:

  • Introduces a duplicated_in_drag flag to track Alt-drag duplication state across drag lifecycle.
  • Splits duplication into a regular path vs. an Alt-drag path (DuplicateSelectedNodesForDrag) via a shared helper implementation.
  • Adjusts abort/commit behavior on right-click/Escape/PointerUp to try to undo or finalize Alt-drag duplication.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs Adds duplicated_in_drag, introduces DuplicateSelectedNodesForDrag, and changes duplication + drag abort/commit behavior
editor/src/messages/portfolio/document/node_graph/node_graph_message.rs Adds the DuplicateSelectedNodesForDrag message variant
editor/src/messages/portfolio/document/document_message_handler.rs Changes Escape handling to attempt undoing Alt-drag duplication on abort

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs Outdated
Comment thread editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs Outdated
Comment thread editor/src/messages/portfolio/document/document_message_handler.rs Outdated
Comment thread editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue with cleaning up duplicated nodes when an Alt-drag operation is aborted. The changes introduce a duplicated_in_drag flag to track when a duplication has occurred during a drag, and uses this flag to ensure proper cleanup via transaction abortion and undos. The logic has been updated for both Escape key and right-click aborts. A good refactoring was done to extract the node duplication logic into a shared duplicate_selected_nodes_impl function.

I have one suggestion to improve code clarity by removing a redundant if/else block. Overall, the changes look good and correctly solve the issue.

Comment thread editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs Outdated
Comment thread editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs Outdated
@Keavon Keavon force-pushed the master branch 4 times, most recently from 3697b7d to 90533e6 Compare March 11, 2026 12:15
@jsjgdh jsjgdh marked this pull request as ready for review March 13, 2026 14:31
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs">

<violation number="1" location="editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs:1134">
P2: Alt-drag duplicates are now created inside the current drag transaction (no AddTransaction), but ShakeNode still aborts that transaction mid-drag to reset state. This rollback now deletes the duplicate itself, so Alt-drag followed by Shake loses the duplicated nodes and leaves shake logic operating on the pre-duplication selection. The new duplicated_in_drag flag is never used to guard this path.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Keavon Keavon force-pushed the master branch 6 times, most recently from fcc53f5 to 9b97ab7 Compare March 19, 2026 10:27
@Keavon Keavon force-pushed the master branch 2 times, most recently from f07c79b to 76938eb Compare April 29, 2026 12:16
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.

3 participants