| author | |
| committer | |
| log | d87c4dd12ddaf3a9db36d09aa9d36d022f007734 |
| tree | a8daefe5ce138a7c7e3aac924e4f190f7ec16f24 |
| parent | c414df0810a16db7b85ef4c2abddc5dbd289154b |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU (~clover) |
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.51 files changed, 4 insertions(+), 2 deletions(-)
crates/notebook/src/background.rs+4-2| ... | ... | @@ -459,7 +459,8 @@ impl Background { |
| 459 | 459 | self.0.touched(paths); |
| 460 | 460 | } |
| 461 | 461 | |
| 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. | |
| 463 | 464 | pub fn status(&self) -> Vec<(String, SyncStatus)> { |
| 464 | 465 | let sections: Vec<_> = self.0.watched.lock().map_or_else( |
| 465 | 466 | |_| Vec::new(), |
| ... | ... | @@ -489,7 +490,8 @@ impl Background { |
| 489 | 490 | .into_iter() |
| 490 | 491 | .map(|(path, fallback, held)| { |
| 491 | 492 | 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))?; | |
| 493 | 495 | let replica = held.replica.upgrade()?; |
| 494 | 496 | let observed = held.observed.upgrade()?; |
| 495 | 497 | let synced = |