@@ -90,7 +90,19 @@ export abstract class ChatPaneSharing extends ChatPaneBase {
9090 // gateway/account change bumps the generation and clears this cache, so a
9191 // request that resolves after the switch must be dropped rather than
9292 // overwrite the new connection's menu with the previous account's data.
93- this . setSessionSharingState ( cacheKey , { ...current , loading : true , error : undefined } ) ;
93+ // Object identity also owns this key's request slot: same-key session
94+ // replacement or a forced reload must not let an older request win.
95+ const loadingState = { ...current , loading : true , error : undefined } ;
96+ const ownsLoadingState = ( ) => this . sessionSharingStates . get ( cacheKey ) === loadingState ;
97+ const clearOwnedLoadingState = ( ) => {
98+ if ( ! ownsLoadingState ( ) ) {
99+ return ;
100+ }
101+ const next = new Map ( this . sessionSharingStates ) ;
102+ next . delete ( cacheKey ) ;
103+ this . sessionSharingStates = next ;
104+ } ;
105+ this . setSessionSharingState ( cacheKey , loadingState ) ;
94106 try {
95107 const result = await scope . client . request < SessionMembersListResult > ( "session.members.list" , {
96108 sessionKey : currentRow . key ,
@@ -100,16 +112,24 @@ export abstract class ChatPaneSharing extends ChatPaneBase {
100112 } ) ;
101113 if (
102114 ! this . isConnectionScopeCurrent ( scope ) ||
103- ! this . currentSessionSharingRow ( scope , currentRow )
115+ ! this . currentSessionSharingRow ( scope , currentRow ) ||
116+ ! ownsLoadingState ( )
104117 ) {
118+ if ( this . isConnectionScopeCurrent ( scope ) ) {
119+ clearOwnedLoadingState ( ) ;
120+ }
105121 return ;
106122 }
107123 this . setSessionSharingState ( cacheKey , { loading : false , result } ) ;
108124 } catch ( error ) {
109125 if (
110126 ! this . isConnectionScopeCurrent ( scope ) ||
111- ! this . currentSessionSharingRow ( scope , currentRow )
127+ ! this . currentSessionSharingRow ( scope , currentRow ) ||
128+ ! ownsLoadingState ( )
112129 ) {
130+ if ( this . isConnectionScopeCurrent ( scope ) ) {
131+ clearOwnedLoadingState ( ) ;
132+ }
113133 return ;
114134 }
115135 this . setSessionSharingState ( cacheKey , { loading : false , error : String ( error ) } ) ;
0 commit comments