From e7e347121c236326f4a147b72e90b321d81adebc Mon Sep 17 00:00:00 2001 From: clover caruso Date: Sat, 10 Oct 2026 19:51:11 -0700 Subject: [PATCH] fix(desktop): retain navigation after delayed notebook rename Deliver the renamed catalog and location migration regardless of navigation. Restore the captured section only while the loading generation and shown notebook lineage still match, and clear only the matching pending folder rename pair. Fixes #109 Assisted-by: gpt-6.1-sol --- crates/snowbound/src/manage.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/snowbound/src/manage.rs b/crates/snowbound/src/manage.rs index a73e77ac533eef1b77aa60c6a3924bf108b81695..697daf1b3db02327314d1d138948e4d8b19152a7 100644 --- a/crates/snowbound/src/manage.rs +++ b/crates/snowbound/src/manage.rs @@ -736,7 +736,7 @@ impl State { self.title(); } self.folder_rename = Some((library.location.clone(), to.clone())); - let (cache, proxy) = (self.cache.clone(), self.proxy.clone()); + let (cache, proxy, requested) = (self.cache.clone(), self.proxy.clone(), self.loading); crate::spawn_async(move || async move { let structure = Arc::clone(&library.structure); let _structure = structure.lock().await; @@ -773,7 +773,20 @@ impl State { } let reopened = Arc::new(reopened); let _ = proxy.send_event(crate::UserEvent::Then(Box::new(move |state| { - state.renamed_notebook(&library, reopened, showing.then_some(shown)); + if state + .folder_rename + .as_ref() + .is_some_and(|(from, target)| from == &library.location && target == &to) + { + state.folder_rename = None; + } + let restore = showing + && requested == state.loading + && state.notebook().is_some_and(|current| { + current.location == library.location + && Arc::ptr_eq(¤t.structure, &library.structure) + }); + state.renamed_notebook(&library, reopened, restore.then_some(shown)); if let Some(problem) = problem { platform::alert("Couldn't rename the folder", &problem); } @@ -791,7 +804,6 @@ impl State { reopened: Arc, shown: Option>, ) { - self.folder_rename = None; let (from, to) = (old.location.clone(), reopened.location.clone()); match (self.notebooks.iter_mut()).find(|open| Arc::ptr_eq(open, old)) { Some(open) => *open = Arc::clone(&reopened), -- 2.54.0