@@ -23,6 +23,7 @@ export const initSessionSync = ({
2323 const sessionWarningKey = "pm:session:warning" ;
2424 // Track keep-alive progress across tabs.
2525 const sessionRenewingKey = "pm:session:renewing" ;
26+ const sessionSuppressKey = "pm:session:suppress-warning" ;
2627 const sessionMessageKey = "pm:session:message" ;
2728 const sessionTabId = `${ Date . now ( ) } -${ Math . random ( ) . toString ( 16 ) . slice ( 2 ) } ` ;
2829 const leaderHeartbeatMs = 4000 ;
@@ -103,11 +104,18 @@ export const initSessionSync = ({
103104
104105 let warningState = readStorageJson ( sessionWarningKey ) ;
105106 let renewingState = readStorageJson ( sessionRenewingKey ) ;
107+ let suppressWarningState = readStorageJson ( sessionSuppressKey ) ;
106108
107109 const refreshWarningStateFromStorage = ( ) => {
108110 const storedWarningState = readStorageJson ( sessionWarningKey ) ;
109111 if ( storedWarningState ?. time && storedWarningState ?. ts ) {
110- warningState = storedWarningState ;
112+ // Clear stale warning from previous session.
113+ if ( sessionState ?. startedAt && storedWarningState . ts < sessionState . startedAt ) {
114+ warningState = null ;
115+ removeStorageKey ( sessionWarningKey ) ;
116+ } else {
117+ warningState = storedWarningState ;
118+ }
111119 } else {
112120 warningState = null ;
113121 }
@@ -154,10 +162,24 @@ export const initSessionSync = ({
154162 } else {
155163 renewingState = null ;
156164 removeStorageKey ( sessionRenewingKey ) ;
165+ setSuppressWarning ( 1000 ) ;
157166 }
158167 syncRenewingUi ( ) ;
159168 } ;
160169
170+ const refreshSuppressWarningState = ( ) => {
171+ const storedSuppressState = readStorageJson ( sessionSuppressKey ) ;
172+ suppressWarningState = storedSuppressState ?. until ? storedSuppressState : null ;
173+ return suppressWarningState ;
174+ } ;
175+
176+ const setSuppressWarning = ( durationMs ) => {
177+ suppressWarningState = {
178+ until : Date . now ( ) + durationMs ,
179+ } ;
180+ writeStorageJson ( sessionSuppressKey , suppressWarningState ) ;
181+ } ;
182+
161183 const sessionChannel = "BroadcastChannel" in window ? new BroadcastChannel ( sessionChannelName ) : null ;
162184 const recentMessageIds = new Map ( ) ;
163185 const recentMessageTtlMs = 5000 ;
@@ -294,6 +316,10 @@ export const initSessionSync = ({
294316 if ( renewingState ?. isRenewing ) {
295317 return ;
296318 }
319+ refreshSuppressWarningState ( ) ;
320+ if ( suppressWarningState ?. until && Date . now ( ) < suppressWarningState . until ) {
321+ return ;
322+ }
297323 sessionDebugLog ( "warning:show" , { remainingTime } ) ;
298324 const sessionModal = resolveSessionModal ( ) ;
299325 // Guard for layouts that don't include the session modal.
@@ -344,6 +370,7 @@ export const initSessionSync = ({
344370 const timeout = Number ( message . data ?. timeout ) || accountTimeoutLength ;
345371 clearWarningState ( ) ;
346372 setRenewingState ( false ) ;
373+ setSuppressWarning ( 1000 ) ;
347374 setSessionState ( timeout ) ;
348375 const closeSessionModal = resolveCloseSessionModal ( ) ;
349376 if ( closeSessionModal ) {
@@ -555,6 +582,7 @@ export const initSessionSync = ({
555582 isLeader,
556583 setSessionState,
557584 clearWarningState,
585+ setRenewingState,
558586 } ,
559587 } ;
560588} ;
0 commit comments