@@ -673,6 +673,25 @@ class WorkspaceV2SessionProducer {
673673 return parsed . value ;
674674 }
675675
676+ readSessionPayloadForSaveAction ( sessionId ) {
677+ const storagePayload = this . readSessionPayloadForLibraryWrite ( sessionId ) ;
678+ if ( this . isValidSessionPayload ( storagePayload ) ) {
679+ return storagePayload ;
680+ }
681+ const recentPayload = this . readSessionPayloadFromRecentSessionId ( sessionId ) ;
682+ if ( this . isValidSessionPayload ( recentPayload ) ) {
683+ return recentPayload ;
684+ }
685+ const activePayload = this . readActiveSessionPayloadForLibraryActions ( ) ;
686+ if ( this . isValidSessionPayload ( activePayload ) ) {
687+ return activePayload ;
688+ }
689+ if ( this . isValidSessionPayload ( this . currentSessionPayload ) ) {
690+ return this . currentSessionPayload ;
691+ }
692+ return null ;
693+ }
694+
676695 selectedMergedSessionId ( ) {
677696 return typeof this . mergedSessionIdNode . value === "string" ? this . mergedSessionIdNode . value . trim ( ) : "" ;
678697 }
@@ -2680,23 +2699,27 @@ class WorkspaceV2SessionProducer {
26802699 return ;
26812700 }
26822701 const exists = Object . prototype . hasOwnProperty . call ( library , sessionName ) ;
2702+ if ( overwriteExisting && ! exists ) {
2703+ this . setLibraryStatus ( "Saved session not found. Use Save Session to create it first." ) ;
2704+ return ;
2705+ }
26832706 if ( ! overwriteExisting && exists ) {
26842707 this . setLibraryStatus ( "Saved session already exists. Use Overwrite Session." ) ;
26852708 return ;
26862709 }
2687- const payloadForWrite = this . readSessionPayloadForLibraryWrite ( sessionName ) ;
2710+ const payloadForWrite = this . readSessionPayloadForSaveAction ( sessionName ) ;
26882711 if ( ! this . isValidSessionPayload ( payloadForWrite ) ) {
2689- this . setLibraryStatus ( "Session ID does not resolve to a valid Workspace V2 session." ) ;
2690- return ;
2691- }
2692- if ( overwriteExisting && ! exists ) {
2693- this . setLibraryStatus ( "Saved session not found. Use Save Session to create it first." ) ;
2712+ this . setLibraryStatus ( overwriteExisting
2713+ ? "No active Workspace V2 session is available to overwrite from."
2714+ : "No active Workspace V2 session is available to save." ) ;
26942715 return ;
26952716 }
26962717 library [ sessionName ] = payloadForWrite ;
26972718 this . writeSessionLibrary ( library ) ;
26982719 this . renderSessionLibrary ( ) ;
2699- this . setLibraryStatus ( overwriteExisting ? "Saved session overwritten." : "Saved session created." ) ;
2720+ this . setLibraryStatus ( overwriteExisting
2721+ ? "Saved session overwritten."
2722+ : "Saved session created. New session ID is now available for Load, Overwrite, and Delete." ) ;
27002723 }
27012724
27022725 loadNamedSession ( ) {
0 commit comments