authorclover caruso <git@paperclover.net> 2026-10-10 19:51:11-07:00
committerclover caruso <git@paperclover.net> 2026-10-10 22:56:05-07:00
loge7e347121c236326f4a147b72e90b321d81adebc
tree971ad78d9718d6b83c7b41c9b97652f53c5073c4
parent9c8254dbc5a7af05da2ef7a0b1835916f3c697ba
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU (~clover)

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

1 files changed, 15 insertions(+), 3 deletions(-)

crates/snowbound/src/manage.rs+15-3
......@@ -736,7 +736,7 @@ impl State {
736736 self.title();
737737 }
738738 self.folder_rename = Some((library.location.clone(), to.clone()));
739 let (cache, proxy) = (self.cache.clone(), self.proxy.clone());
739 let (cache, proxy, requested) = (self.cache.clone(), self.proxy.clone(), self.loading);
740740 crate::spawn_async(move || async move {
741741 let structure = Arc::clone(&library.structure);
742742 let _structure = structure.lock().await;
......@@ -773,7 +773,20 @@ impl State {
773773 }
774774 let reopened = Arc::new(reopened);
775775 let _ = proxy.send_event(crate::UserEvent::Then(Box::new(move |state| {
776 state.renamed_notebook(&library, reopened, showing.then_some(shown));
776 if state
777 .folder_rename
778 .as_ref()
779 .is_some_and(|(from, target)| from == &library.location && target == &to)
780 {
781 state.folder_rename = None;
782 }
783 let restore = showing
784 && requested == state.loading
785 && state.notebook().is_some_and(|current| {
786 current.location == library.location
787 && Arc::ptr_eq(&current.structure, &library.structure)
788 });
789 state.renamed_notebook(&library, reopened, restore.then_some(shown));
777790 if let Some(problem) = problem {
778791 platform::alert("Couldn't rename the folder", &problem);
779792 }
......@@ -791,7 +804,6 @@ impl State {
791804 reopened: Arc<Library>,
792805 shown: Option<Option<String>>,
793806 ) {
794 self.folder_rename = None;
795807 let (from, to) = (old.location.clone(), reopened.location.clone());
796808 match (self.notebooks.iter_mut()).find(|open| Arc::ptr_eq(open, old)) {
797809 Some(open) => *open = Arc::clone(&reopened),