Rework clipboard handling to carry embedded resources across documents#4296
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 node0) 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, theInsertImage/InsertSvgrename is only partial while downstream document messages still usePasteImage/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
cb1d46e to
cadd07c
Compare
eb9657b to
2674201
Compare
2674201 to
fb02b67
Compare
No description provided.