import { Center, Loader } from '@mantine/core'; import { lazy, Suspense, type ReactNode } from 'react'; import { Navigate, Route, Routes, useLocation, useSearchParams } from 'react-router-dom'; import { AssistantPage } from './pages/insights/AssistantPage'; import { AuthProvider, useAuth } from './auth/AuthContext'; import { Layout } from './components/Layout'; import { AdminOnly } from './components/AdminOnly'; import { NotFoundPage } from './components/ErrorPages'; import { PodsPage } from './pages/setup/PodsPage'; import { ReadinessPage } from './pages/home/ReadinessPage'; import { TicketsPage } from './pages/insights/QueuesPages'; import { RunWorkspace } from './pages/run/RunWorkspace'; import { RunsPage } from './pages/runs/RunsPage'; // Pages opened less often load on demand, so the first visit downloads less (Home, test runs, environments and defects // stay in the main bundle: they are the daily path). const named = >(load: () => Promise, name: keyof T) => lazy(() => load().then((m) => ({ default: m[name] as React.ComponentType }))); const AgentTeamPage = named(() => import('./pages/insights/AgentTeamPage'), 'AgentTeamPage'); const SettingsPage = named(() => import('./pages/setup/SettingsPage'), 'SettingsPage'); const AutonomyPage = named(() => import('./pages/setup/AdminPages'), 'AutonomyPage'); const KillSwitchPage = named(() => import('./pages/setup/AdminPages'), 'KillSwitchPage'); const SchedulerPage = named(() => import('./pages/setup/AdminPages'), 'SchedulerPage'); const UsersPage = named(() => import('./pages/setup/AdminPages'), 'UsersPage'); const AuditPage = named(() => import('./pages/insights/InsightPages'), 'AuditPage'); const LearnerPage = named(() => import('./pages/insights/InsightPages'), 'LearnerPage'); const ReportsPage = named(() => import('./pages/library/LibraryPages'), 'ReportsPage'); const ScenarioDetailPage = named(() => import('./pages/library/LibraryPages'), 'ScenarioDetailPage'); const ScenariosLibraryPage = named(() => import('./pages/library/LibraryPages'), 'ScenariosLibraryPage'); const HealPage = named(() => import('./pages/insights/QueuesPages'), 'HealPage'); const ScriptsPage = named(() => import('./pages/insights/QueuesPages'), 'ScriptsPage'); const AccountPage = named(() => import('./pages/account/AccountPage'), 'AccountPage'); const IntegrationsPage = named(() => import('./pages/setup/IntegrationsPage'), 'IntegrationsPage'); const LeftOnPodPage = named(() => import('./pages/setup/LeftOnPodPage'), 'LeftOnPodPage'); const AgentStudioPage = named(() => import('./pages/setup/AgentStudioPage'), 'AgentStudioPage'); const AiMonitoringPage = named(() => import('./pages/setup/AiMonitoringPage'), 'AiMonitoringPage'); const ImportCasesPage = named(() => import('./pages/library/ImportCasesPage'), 'ImportCasesPage'); // the sign-in page carries the beUI animation library: only people who sign in download it const LoginPage = named(() => import('./pages/auth/LoginPage'), 'LoginPage'); const RegisterPage = named(() => import('./pages/auth/RegisterPage'), 'RegisterPage'); const ForgotPage = named(() => import('./pages/auth/PasswordPages'), 'ForgotPage'); const ResetPage = named(() => import('./pages/auth/PasswordPages'), 'ResetPage'); // Dev-only fixture screens for design review; the branch is removed from the production build. const DevFixtures = import.meta.env.DEV ? lazy(() => import('./pages/dev/DevFixtures').then((m) => ({ default: m.DevFixtures }))) : null; const DevApprovalFixtures = import.meta.env.DEV ? lazy(() => import('./pages/dev/DevFixtures').then((m) => ({ default: m.DevApprovalFixtures }))) : null; /** The fixture routes this build registers (none outside dev builds). */ export const DEV_FIXTURE_PATHS: string[] = import.meta.env.DEV ? ['/dev/board-fixture', '/dev/approval-fixture'] : []; /** The account pages (sign in, register, forgot, reset) load on demand: they carry the beUI and 3D libraries. */ function SignInRoute({ children }: { children: ReactNode }) { return }>{children}; } function RequireAuth({ children }: { children: ReactNode }) { const { user, loading } = useAuth(); const loc = useLocation(); if (loading) return
; if (!user) return ; return <>{children}; } /** The old "new test run" page is now the Start sheet over the home page. */ function NewRunRedirect() { const [p] = useSearchParams(); const area = p.get('area'); return ; } export function AppRoutes() { return ( } /> } /> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* Admin & under the hood (engineering views) */} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {DevFixtures && DEV_FIXTURE_PATHS.includes('/dev/board-fixture') && } />} {DevApprovalFixtures && DEV_FIXTURE_PATHS.includes('/dev/approval-fixture') && } />} } /> ); } export function App() { return ; }