From d2f0bc1265cf7a7f2f6a265a9eb6310e209d38b2 Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Tue, 12 May 2026 22:46:00 +0800 Subject: [PATCH] fix(shell): Open empties cross-doc clipboard Codex caught: `clipboard: Vec` survives Open with nodes carrying NodeIds from the previous doc. Pasting them into the freshly-loaded doc would re-introduce ids the new allocator doesn't know about (or collide with freshly-loaded rows). Empty the clipboard alongside the history + UI resets so paste in the new doc starts from empty. --- crates/openpencil-desktop/src/persistence.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/openpencil-desktop/src/persistence.rs b/crates/openpencil-desktop/src/persistence.rs index a4ead7931..8fa600dc4 100644 --- a/crates/openpencil-desktop/src/persistence.rs +++ b/crates/openpencil-desktop/src/persistence.rs @@ -167,6 +167,11 @@ pub fn apply_payload(doc: &mut Document, payload: DocPayload) -> Result<(), Stri doc.ui.locale_picker_open = false; doc.ui.shape_picker_open = false; doc.ui.fill_type_picker_open = false; + // Cross-doc clipboard contents are nodes carrying old NodeIds — + // pasting them into the freshly-loaded doc would re-introduce + // ids the new allocator doesn't know about (or collide with + // freshly-loaded rows). Empty the clipboard on Open. + doc.clipboard.clear(); Ok(()) }