authorclover caruso <git@paperclover.net> 2026-10-15 04:21:52-07:00
committerclover caruso <git@paperclover.net> 2026-10-15 04:45:06-07:00
logd87c4dd12ddaf3a9db36d09aa9d36d022f007734
treea8daefe5ce138a7c7e3aac924e4f190f7ec16f24
parentc414df0810a16db7b85ef4c2abddc5dbd289154b
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU (~clover)

fix(mobile): close waits for the background to check a section just left

Library::close compared each closed section's background sync time with a snapshot it took first. For a section whose view had just gone, the background still reported the departing session's live status in that snapshot, often never synced while working offline, and once the session let go of its replica it reported its own check from before the edit. That older check passed the comparison, so close returned before the edit was published: a notebook then deleted lost the edit from its file and left its replica behind. The background now reports a held section live only while its session syncs, so close compares two of its own checks and waits for one made after the session let go. Fixes #145 Assisted-by: claude-opus-5.5

1 files changed, 4 insertions(+), 2 deletions(-)

crates/notebook/src/background.rs+4-2
......@@ -459,7 +459,8 @@ impl Background {
459459 self.0.touched(paths);
460460 }
461461
462 /// Each watched section's status, in watch order; held sections report their live state.
462 /// Each watched section's status, in watch order: a held section's live state while its
463 /// session syncs, otherwise this thread's last check of it.
463464 pub fn status(&self) -> Vec<(String, SyncStatus)> {
464465 let sections: Vec<_> = self.0.watched.lock().map_or_else(
465466 |_| Vec::new(),
......@@ -489,7 +490,8 @@ impl Background {
489490 .into_iter()
490491 .map(|(path, fallback, held)| {
491492 let live = held.and_then(|held| {
492 let worker = held.worker.upgrade()?;
493 let worker = (held.worker.upgrade())
494 .filter(|worker| !worker.stopped.load(Ordering::Acquire))?;
493495 let replica = held.replica.upgrade()?;
494496 let observed = held.observed.upgrade()?;
495497 let synced =