fix: improve error handling and stability - no logout on transient errors, add ErrorBoundary, global error logging

This commit is contained in:
Agent Zero
2026-07-26 12:18:52 +02:00
parent e12b85c2ce
commit 808da564f3
7 changed files with 344 additions and 8 deletions
+9 -4
View File
@@ -4,14 +4,19 @@ import { useCurrentUser } from '@/api/hooks';
export function useAuth() {
const store = useAuthStore();
const { data, isLoading, isError } = useCurrentUser();
const { data, isLoading, isError, error } = useCurrentUser();
useEffect(() => {
if (isError) {
store.setAuthenticated(false);
store.setUser(null);
const status = (error as any)?.status || 0;
// Only logout on 401 Unauthorized — other errors are transient
if (status === 401) {
store.setAuthenticated(false);
store.setUser(null);
}
// For 403, 500, network errors: keep session, don't logout
}
}, [isError, store]);
}, [isError, error, store]);
return {
user: store.user,