Skip to content

Rework clipboard handling to carry embedded resources across documents#4296

Merged
Keavon merged 3 commits into
masterfrom
clipboard-resources
Jul 1, 2026
Merged

Rework clipboard handling to carry embedded resources across documents#4296
Keavon merged 3 commits into
masterfrom
clipboard-resources

Conversation

@timon-schelling

Copy link
Copy Markdown
Member

No description provided.

@timon-schelling timon-schelling requested a review from Keavon June 30, 2026 21:45

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

Copy link
Copy Markdown
Contributor

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 refactors the editor's clipboard system, replacing type-specific clipboards with a unified ClipboardItem structure that can serialize and carry layers, nodes, vectors, and embedded resources (using base64 encoding). Clipboard handling logic is moved from the portfolio message handler to a dedicated clipboard message handler with a new context struct. Feedback on these changes includes resolving compilation issues due to missing imports (HashMap, HashSet) and a missing log:: prefix on an error! macro, as well as performance optimizations to avoid unnecessary clones and allocations during resource registration and base64 deserialization.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread editor/src/messages/clipboard/clipboard_message_handler.rs
Comment thread editor/src/messages/clipboard/clipboard_message_handler.rs
Comment thread editor/src/messages/clipboard/clipboard_message_handler.rs Outdated
Comment thread editor/src/messages/clipboard/utility_types.rs

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

5 issues found across 16 files

Confidence score: 2/5

  • In editor/src/messages/clipboard/clipboard_message_handler.rs, malformed clipboard payloads (invalid segment endpoints or layers missing root node 0) can currently panic during paste, which risks user-facing crashes on bad input — validate these structures up front and skip/reject invalid entries before indexing or insertion.
  • In editor/src/messages/clipboard/clipboard_message_handler.rs, embedded resource bytes are resolved without confirming they match the advertised hash, so pasted resources can be registered against missing/corrupt data and later fail to render correctly — enforce hash verification before resolution and reject mismatches.
  • In editor/src/messages/portfolio/portfolio_message.rs, the InsertImage/InsertSvg rename is only partial while downstream document messages still use PasteImage/PasteSvg, which is mainly a maintainability/semantics mismatch rather than a runtime blocker — finish the rename mapping in one pass or track it as a near-term follow-up.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread editor/src/messages/clipboard/clipboard_message_handler.rs Outdated
Comment thread editor/src/messages/clipboard/clipboard_message_handler.rs Outdated
Comment thread editor/src/messages/clipboard/clipboard_message_handler.rs Outdated
Comment thread editor/src/messages/clipboard/clipboard_message_handler.rs Outdated
Comment thread editor/src/messages/portfolio/portfolio_message.rs
@Keavon Keavon force-pushed the clipboard-resources branch from 2674201 to fb02b67 Compare July 1, 2026 08:30
@Keavon Keavon changed the title Clipboard resources Rework clipboard handling to carry embedded resources across documents Jul 1, 2026
@Keavon Keavon added this pull request to the merge queue Jul 1, 2026
Merged via the queue into master with commit 8a38af5 Jul 1, 2026
9 checks passed
@Keavon Keavon deleted the clipboard-resources branch July 1, 2026 09:32
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.

2 participants