diff --git a/backend/app/controller/health_controller.py b/backend/app/controller/health_controller.py index 1ee53719e..cd0fcbd8b 100644 --- a/backend/app/controller/health_controller.py +++ b/backend/app/controller/health_controller.py @@ -16,6 +16,15 @@ from fastapi import APIRouter from pydantic import BaseModel +<<<<<<< HEAD +<<<<<<< HEAD +from utils import traceroot_wrapper as traceroot +======= +from sqlalchemy import text +import logging +>>>>>>> 22fd45e11845bd7da55863bcd59260d410e6af81 +======= +>>>>>>> upstream/main logger = logging.getLogger("health_controller") @@ -29,12 +38,31 @@ class HealthResponse(BaseModel): @router.get("/health", name="health check", response_model=HealthResponse) async def health_check(): +<<<<<<< HEAD + """ + Health check endpoint for verifying backend readiness. + """ + + logger.debug("Health check requested") + + response = HealthResponse( + status="ok", + service="eigent", + ) + +======= """Health check endpoint for verifying backend is ready to accept requests.""" logger.debug("Health check requested") response = HealthResponse(status="ok", service="eigent") +>>>>>>> upstream/main logger.debug( "Health check completed", extra={"status": response.status, "service": response.service}, ) +<<<<<<< HEAD + + return response +======= return response +>>>>>>> upstream/main diff --git a/src/pages/Diagnostics.tsx b/src/pages/Diagnostics.tsx new file mode 100644 index 000000000..bf112cc84 --- /dev/null +++ b/src/pages/Diagnostics.tsx @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Eigent + * + * Licensed under the Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +import { useEffect, useState } from "react"; +import { fetchGet } from "@/api/http"; + +type HealthResponse = { + status: string; + service: string; +}; + +export default function Diagnostics() { + const [data, setData] = useState(null); + const [error, setError] = useState(""); + + useEffect(() => { + fetchGet("/health") + .then(setData) + .catch((err) => setError(err.message)); + }, []); + + if (error) { + return
❌ {error}
; + } + + if (!data) { + return
Loading system diagnostics...
; + } + + return ( +
+

System Diagnostics

+ +

Backend: ✅ Running

+

Service: {data.service}

+
+ ); +} \ No newline at end of file diff --git a/src/routers/index.tsx b/src/routers/index.tsx index b72235a1c..80b6c729d 100644 --- a/src/routers/index.tsx +++ b/src/routers/index.tsx @@ -17,6 +17,17 @@ import { useAuthStore } from '@/store/authStore'; import { lazy, useEffect, useReducer } from 'react'; import { Navigate, Outlet, Route, Routes } from 'react-router-dom'; +<<<<<<< HEAD +import Layout from "@/components/Layout"; + +// Lazy load page components +const Login = lazy(() => import("@/pages/Login")); +const Signup = lazy(() => import("@/pages/SignUp")); +const Home = lazy(() => import("@/pages/Home")); +const History = lazy(() => import("@/pages/History")); +const Diagnostics = lazy(() => import("@/pages/Diagnostics")); +const NotFound = lazy(() => import("@/pages/NotFound")); +======= import Layout from '@/components/Layout'; // Lazy load page components const Login = lazy(() => import('@/pages/Login')); @@ -55,6 +66,7 @@ const authReducer = (state: AuthState, action: AuthAction): AuthState => { return state; } }; +>>>>>>> upstream/main // Route guard: Check if user is logged in const ProtectedRoute = () => { @@ -64,6 +76,41 @@ const ProtectedRoute = () => { initialized: false, }); +<<<<<<< HEAD + const { token, localProxyValue, logout } = useAuthStore(); + + useEffect(() => { + // Check VITE_USE_LOCAL_PROXY value on app startup + if (token) { + const currentProxyValue = import.meta.env.VITE_USE_LOCAL_PROXY || null; + const storedProxyValue = localProxyValue; + + // If stored value exists and differs from current, logout + if (storedProxyValue !== null && storedProxyValue !== currentProxyValue) { + console.warn("VITE_USE_LOCAL_PROXY value changed, logging out user"); + logout(); + setIsAuthenticated(false); + setLoading(false); + setInitialized(true); + return; + } + } + + setIsAuthenticated(!!token); + setLoading(false); + setInitialized(true); + }, [token, localProxyValue, logout]); + + if (loading || !initialized) { + return ( +
+
+
+ ); + } + + return isAuthenticated ? : ; +======= const { token, localProxyValue, @@ -130,10 +177,38 @@ const ProtectedRoute = () => { ); } return state.isAuthenticated ? : ; +>>>>>>> upstream/main }; // Main route configuration const AppRoutes = () => ( +<<<<<<< HEAD + + {/* Public routes */} + } /> + } /> + + {/* Protected routes */} + }> + }> + } /> + } /> + } /> + } + /> + } + /> + + + + {/* Fallback */} + } /> + +======= } /> } /> @@ -153,6 +228,7 @@ const AppRoutes = () => ( } /> +>>>>>>> upstream/main ); export default AppRoutes;