CoverageCheck / web /src /App.tsx
TBM99's picture
Deploy coverage-check 3559250
23d418f verified
Raw History Blame Contribute Delete
3.38 kB
import { ShieldCheck } from 'lucide-react'
import { lazy, Suspense } from 'react'
import { BrowserRouter, Navigate, NavLink, Route, Routes } from 'react-router'
import { ChatProvider } from '@/hooks/ChatProvider'
import { cn } from '@/lib/utils'
import { AskPage } from '@/pages/AskPage'
import { AboutPage } from '@/pages/AboutPage'
// The Evals page carries the chart library (~150 kB gzip): loaded only when opened, so
// the chat stays light.
const EvalsPage = lazy(() => import('@/pages/EvalsPage').then((m) => ({ default: m.EvalsPage })))
// The Architecture page carries the graph library: also loaded only when opened.
const ArchitecturePage = lazy(() => import('@/pages/ArchitecturePage').then((m) => ({ default: m.ArchitecturePage })))
const PAGES = [
{ to: '/ask', label: 'Ask' },
{ to: '/evals', label: 'Evals' },
{ to: '/architecture', label: 'Architecture' },
{ to: '/about', label: 'About' },
]
/** The shell: a slim header with the pages, then the page filling the rest of the screen
* (the Ask page is a full-height chat). The server sends index.html for any of these
* paths (api.SpaFiles), so a reload keeps the page. */
export default function App() {
return (
<BrowserRouter>
<ChatProvider>
<div className="flex h-dvh flex-col bg-background text-foreground">
<header className="shrink-0 border-b">
<div className="mx-auto flex max-w-6xl items-center gap-6 px-4 py-2.5">
<NavLink to="/ask" className="flex items-center gap-2 font-semibold">
<ShieldCheck className="size-5 text-primary" />
<span className="hidden sm:inline">CoverageCheck</span>
</NavLink>
<nav className="flex gap-1 text-sm">
{PAGES.map((p) => (
<NavLink
key={p.to}
to={p.to}
className={({ isActive }) =>
cn(
'rounded-md px-3 py-1.5',
isActive ? 'bg-accent font-medium text-accent-foreground' : 'text-muted-foreground hover:text-foreground',
)
}
>
{p.label}
</NavLink>
))}
</nav>
</div>
</header>
<main className="min-h-0 flex-1">
<Routes>
<Route path="/" element={<Navigate to="/ask" replace />} />
<Route path="/ask" element={<AskPage />} />
<Route
path="/evals"
element={
<Suspense fallback={<div className="p-8 text-sm text-muted-foreground">Loading the results…</div>}>
<EvalsPage />
</Suspense>
}
/>
<Route
path="/architecture"
element={
<Suspense fallback={<div className="p-8 text-sm text-muted-foreground">Loading the architecture…</div>}>
<ArchitecturePage />
</Suspense>
}
/>
<Route path="/about" element={<AboutPage />} />
<Route path="*" element={<Navigate to="/ask" replace />} />
</Routes>
</main>
</div>
</ChatProvider>
</BrowserRouter>
)
}