@@ -606,15 +606,17 @@ async function loadApp() {
606606 if ( Array . isArray ( files ) && files . length ) {
607607 try {
608608 await restoreFiles ( files ) ;
609- // save state to handle file loading gracefully
610- sessionStorage . setItem ( "isfilesRestored" , true ) ;
611- // Process any pending intents that were queued before files were restored
612- await processPendingIntents ( ) ;
613609 } catch ( error ) {
614610 window . log ( "error" , "File loading failed!" ) ;
615611 window . log ( "error" , error ) ;
616612 toast ( "File loading failed!" ) ;
613+ } finally {
614+ // Mark restoration complete even after a partial failure so
615+ // switch-file persistence and queued intents are not blocked.
616+ sessionStorage . setItem ( "isfilesRestored" , true ) ;
617617 }
618+ // Process any pending intents that were queued before files were restored
619+ await processPendingIntents ( ) ;
618620 } else {
619621 // Even when no files need to be restored, mark as restored and process pending intents
620622 sessionStorage . setItem ( "isfilesRestored" , true ) ;
@@ -661,6 +663,9 @@ async function loadApp() {
661663 if ( settings . value . rememberFiles && activeFile ) {
662664 localStorage . setItem ( "lastfile" , activeFile . id ) ;
663665 }
666+ if ( saveState && sessionStorage . getItem ( "isfilesRestored" ) === "true" ) {
667+ acode . exec ( "save-state" ) ;
668+ }
664669 return ;
665670 }
666671
0 commit comments