From 1cec85d1bb8078889dab2f72485b2407ee2d2de3 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Sat, 10 Oct 2026 21:12:34 -0700 Subject: [PATCH] fix: preserve earlier recycled page snapshots on retry Retain the established append behavior when a recycle-bin receipt is uncertain. Repeated snapshots with the same page identity remain accessible, as the recycle-bin-repair corpus cold-read demonstrates. Retry coverage now checks both the original snapshot and the latest source edit without deleting earlier copies. Fixes #119 Assisted-by: gpt-6.1-sol --- crates/notebook/src/session.rs | 11 ----------- crates/notebook/src/session/tests.rs | 14 ++++++++++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/crates/notebook/src/session.rs b/crates/notebook/src/session.rs index 579de4c8ba6956a8fa98fb6a7c8645b516ffbb69..1121973f9355e47048787048211bbcd1003655cc 100644 --- a/crates/notebook/src/session.rs +++ b/crates/notebook/src/session.rs @@ -1181,18 +1181,7 @@ impl Notebook { let transaction = { let arena = onestore::Arena::default(); let mut section = onestore::Section::open(&arena, bytes)?; - let mut replaced = Vec::new(); - for (space, ..) in section.pages()? { - if section.page(space)?.identity.is_some_and(|identity| { - pages.iter().any(|page| page.identity == Some(identity)) - }) { - replaced.push(space); - } - } let mut ops = Vec::new(); - if !replaced.is_empty() { - ops.push(Op::Section(SectionOp::Delete(replaced))); - } for page in pages { ops.push(moved(page, author)?); } diff --git a/crates/notebook/src/session/tests.rs b/crates/notebook/src/session/tests.rs index b2bddeb3bc994821899eedcd8be449563352c5c5..25c906074b66a512b56dd3f6263bef4a961d16de 100644 --- a/crates/notebook/src/session/tests.rs +++ b/crates/notebook/src/session/tests.rs @@ -375,10 +375,16 @@ fn recycling_rejects_unconfirmed_appends_and_can_retry_each_stage() { .recycle_pages(std::slice::from_ref(&page), "Fixture") .unwrap(); let binned = stored_pages(&fs::read(folder.join(&deleted)).unwrap()).unwrap(); - assert_eq!(binned.len(), 1, "{rejected}"); - assert_eq!(binned[0].page.title, page.title); - assert_eq!(binned[0].page.identity, page.identity); - assert_eq!(binned[0].page.color, page.color); + assert_eq!(binned.len(), 1 + usize::from(retained), "{rejected}"); + for snapshot in &binned { + assert_eq!(snapshot.page.title, page.title); + assert_eq!(snapshot.page.identity, page.identity); + } + assert_eq!(binned.last().unwrap().page.color, page.color); + if retained { + assert_eq!(binned[0].page.color, None); + assert_eq!(binned.last().unwrap().page.color, Some(0xabcdef)); + } assert_eq!(fs::read(folder.join(&path)).unwrap(), source); } } -- 2.54.0