authorclover caruso <git@paperclover.net> 2026-10-10 19:43:04-07:00
committerclover caruso <git@paperclover.net> 2026-10-10 22:56:05-07:00
log22385a1dd2ed2b43ec61ba454d0b5d2317153cd6
tree0ed4f2b12ca61bcd7f7ca7decc0c978d277ad866
parent8dcd2f78650d5b4ebd9d18efaf37e73583c54de9
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU (~clover)

fix: retain the visible page while redirecting stale opens

Reconcile a loaded section against the latest notebook catalog before parking the visible page scene or ending its recording. When a deleted section redirects to a surviving one, the current page remains drawable until that replacement actually opens. Fixes #109 Assisted-by: gpt-6.1-sol

1 files changed, 30 insertions(+), 29 deletions(-)

crates/snowbound/src/main.rs+30-29
......@@ -3847,6 +3847,35 @@ impl State {
38473847 }
38483848 lap("switch pictures", opening.since);
38493849 let requested = opening.requested;
3850 if let Shown::Section(session) | Shown::Created(session) = &mut opening.loaded
3851 && let Some(library) = self
3852 .notebooks
3853 .iter()
3854 .find(|listed| {
3855 listed.location == session.library.location
3856 && Arc::ptr_eq(&listed.structure, &session.library.structure)
3857 && !Arc::ptr_eq(listed, &session.library)
3858 })
3859 .cloned()
3860 {
3861 let identity = session
3862 .library
3863 .section_identity(&session.tabs[session.tab].path);
3864 let path = library.catalog().and_then(|catalog| {
3865 catalog
3866 .sections()
3867 .find(|section| Some(section.file_id) == identity)
3868 .map(|section| section.path.clone())
3869 });
3870 if let Some(path) = path {
3871 session.follow(library, &path)?;
3872 } else if let Some(path) = library.first_section() {
3873 return self.apply(Command::OpenSection(library, path));
3874 } else {
3875 self.switching = None;
3876 return self.adopt(library, None);
3877 }
3878 }
38503879 // A recording goes on the page it started on.
38513880 self.stop_recording(true)?;
38523881 // The page shown so far keeps what was typed while the next one loaded.
......@@ -3869,35 +3898,7 @@ impl State {
38693898 }
38703899 let created = matches!(opening.loaded, Shown::Created(_));
38713900 match opening.loaded {
3872 Shown::Section(mut session) | Shown::Created(mut session) => {
3873 if let Some(library) = self
3874 .notebooks
3875 .iter()
3876 .find(|listed| {
3877 listed.location == session.library.location
3878 && Arc::ptr_eq(&listed.structure, &session.library.structure)
3879 && !Arc::ptr_eq(listed, &session.library)
3880 })
3881 .cloned()
3882 {
3883 let identity = session
3884 .library
3885 .section_identity(&session.tabs[session.tab].path);
3886 let path = library.catalog().and_then(|catalog| {
3887 catalog
3888 .sections()
3889 .find(|section| Some(section.file_id) == identity)
3890 .map(|section| section.path.clone())
3891 });
3892 if let Some(path) = path {
3893 session.follow(library, &path)?;
3894 } else if let Some(path) = library.first_section() {
3895 return self.apply(Command::OpenSection(library, path));
3896 } else {
3897 self.switching = None;
3898 return self.adopt(library, None);
3899 }
3900 }
3901 Shown::Section(session) | Shown::Created(session) => {
39013902 // The settings keep the notebook shown, not the section.
39023903 let other_notebook = self
39033904 .session