@@ -25,11 +25,17 @@ export function SessionListeners() {
2525 const router = useRouter ( ) ;
2626 const pathname = usePathname ( ) ;
2727 const { t } = useTranslation ( "common" ) ;
28- const { openLoginModal, setIsFromSessionExpired, logout , isSpeedMode } =
28+ const { openLoginModal, setIsFromSessionExpired, clearLocalSession , isSpeedMode } =
2929 useAuth ( ) ;
3030 const { modal } = App . useApp ( ) ;
3131 const modalShownRef = useRef < boolean > ( false ) ;
3232
33+ const isLocaleHomePath = ( path ?: string | null ) => {
34+ if ( ! path ) return false ;
35+ const segments = path . split ( "/" ) . filter ( Boolean ) ;
36+ return segments . length <= 1 ;
37+ } ;
38+
3339 /**
3440 * Show "Login Expired" confirmation modal
3541 * This function handles debounce logic to prevent modal from appearing repeatedly
@@ -46,25 +52,20 @@ export function SessionListeners() {
4652 okText : t ( "login.expired.okText" ) ,
4753 cancelText : t ( "login.expired.cancelText" ) ,
4854 closable : false ,
49- async onOk ( ) {
50- try {
51- // Silently logout
52- await logout ( { silent : true } ) ;
53- } finally {
54- // Mark the source as session expired
55- setIsFromSessionExpired ( true ) ;
56- Modal . destroyAll ( ) ;
57- openLoginModal ( ) ;
58- setTimeout ( ( ) => ( modalShownRef . current = false ) , 500 ) ;
59- }
55+ onOk ( ) {
56+ // Clear local session state (session already expired on backend)
57+ clearLocalSession ( ) ;
58+ // Mark the source as session expired
59+ setIsFromSessionExpired ( true ) ;
60+ Modal . destroyAll ( ) ;
61+ openLoginModal ( ) ;
62+ setTimeout ( ( ) => ( modalShownRef . current = false ) , 500 ) ;
6063 } ,
61- async onCancel ( ) {
62- try {
63- await logout ( ) ;
64- } finally {
65- router . push ( "/" ) ;
66- setTimeout ( ( ) => ( modalShownRef . current = false ) , 500 ) ;
67- }
64+ onCancel ( ) {
65+ // Clear local session state (session already expired on backend)
66+ clearLocalSession ( ) ;
67+ router . push ( "/" ) ;
68+ setTimeout ( ( ) => ( modalShownRef . current = false ) , 500 ) ;
6869 } ,
6970 } ) ;
7071 } ;
@@ -106,7 +107,7 @@ export function SessionListeners() {
106107 ) ;
107108 } ;
108109 // Remove confirm from dependency array to avoid duplicate registration due to function reference changes
109- } , [ router , pathname , openLoginModal , setIsFromSessionExpired , modal , isSpeedMode ] ) ;
110+ } , [ isSpeedMode ] ) ;
110111
111112 // When component first mounts, if no local session is found, show modal immediately
112113 useEffect ( ( ) => {
@@ -129,23 +130,20 @@ export function SessionListeners() {
129130 const session = await authService . getSession ( ) ;
130131
131132 // Only show session expired modal if a prior session existed and is now invalid
132- if ( ! session && hadLocalSession ) {
133+ if ( ( ! session && hadLocalSession ) || ( ! session && ! hadLocalSession && ! isLocaleHomePath ( pathname ) ) ) {
133134 window . dispatchEvent (
134135 new CustomEvent ( EVENTS . SESSION_EXPIRED , {
135136 detail : { message : "Session expired, please sign in again" } ,
136137 } )
137138 ) ;
138- } else if ( ! session && ! hadLocalSession ) {
139- // Full mode with no prior session: proactively prompt login
140- openLoginModal ( ) ;
141139 }
142140 } catch ( error ) {
143141 log . error ( "Error checking session status:" , error ) ;
144142 }
145143 } ;
146144
147145 checkSession ( ) ;
148- } , [ pathname , isSpeedMode , openLoginModal ] ) ;
146+ } , [ pathname , isSpeedMode ] ) ;
149147
150148 // Sliding expiration: refresh token shortly before expiry on user activity (skip in speed mode)
151149 useEffect ( ( ) => {
0 commit comments