fix: clean up runtime UI and harden session expiry handling
Remove redundant "X/X LIVE" badge from runtime page, breadcrumb trail and routes section from agent detail page (pills moved into Process Information card). Fix session expiry: guard against concurrent 401 refresh races and skip re-entrant triggers on auth endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useAuthStore } from './auth-store';
|
||||
import { configureAuth } from '../api/client';
|
||||
import { useNavigate } from 'react-router';
|
||||
@@ -6,14 +6,21 @@ import { useNavigate } from 'react-router';
|
||||
export function useAuth() {
|
||||
const { accessToken, isAuthenticated, refresh, logout } = useAuthStore();
|
||||
const navigate = useNavigate();
|
||||
const refreshingRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
configureAuth({
|
||||
onUnauthorized: async () => {
|
||||
const ok = await useAuthStore.getState().refresh();
|
||||
if (!ok) {
|
||||
useAuthStore.getState().logout();
|
||||
navigate('/login', { replace: true });
|
||||
if (refreshingRef.current) return;
|
||||
refreshingRef.current = true;
|
||||
try {
|
||||
const ok = await useAuthStore.getState().refresh();
|
||||
if (!ok) {
|
||||
useAuthStore.getState().logout();
|
||||
navigate('/login', { replace: true });
|
||||
}
|
||||
} finally {
|
||||
refreshingRef.current = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user