import { Navigate, Outlet, Route, Routes, useLocation, useParams } from "@/lib/router"; import { Button } from "@/components/ui/button"; import { useTranslation } from "@/i18n"; import { Layout } from "./components/Layout"; import { ConferenceRoomChatGate } from "./components/ConferenceRoomChatGate"; import { OnboardingWizardVariant } from "./components/OnboardingWizardVariant"; import { CloudAccessGate } from "./components/CloudAccessGate"; import { Dashboard } from "./pages/Dashboard"; import { DashboardLive } from "./pages/DashboardLive"; import { Companies } from "./pages/Companies"; import { Agents } from "./pages/Agents"; import { AgentDetail } from "./pages/AgentDetail"; import { Projects } from "./pages/Projects"; import { ProjectDetail } from "./pages/ProjectDetail"; import { ProjectWorkspaceDetail } from "./pages/ProjectWorkspaceDetail"; import { Workspaces } from "./pages/Workspaces"; import { Issues } from "./pages/Issues"; import { Search } from "./pages/Search"; import { IssueDetail } from "./pages/IssueDetail"; import { IssueChatLongThreadPerf } from "./pages/IssueChatLongThreadPerf"; import { Routines } from "./pages/Routines"; import { RoutineDetail } from "./pages/RoutineDetail"; import { UserProfile } from "./pages/UserProfile"; import { ExecutionWorkspaceDetail } from "./pages/ExecutionWorkspaceDetail"; import { Goals } from "./pages/Goals"; import { Artifacts } from "./pages/Artifacts"; import { GoalDetail } from "./pages/GoalDetail"; import { Approvals } from "./pages/Approvals"; import { ApprovalDetail } from "./pages/ApprovalDetail"; import { Costs } from "./pages/Costs"; import { Activity } from "./pages/Activity"; import { Inbox } from "./pages/Inbox"; import { BoardChat } from "./pages/BoardChat"; import { CompanySettings } from "./pages/CompanySettings"; import { CompanyEnvironments } from "./pages/CompanyEnvironments"; import { CloudUpstream } from "./pages/CloudUpstream"; import { CloudUpstreamUxLab } from "./pages/CloudUpstreamUxLab"; import { BootstrapSetupUxLab } from "./pages/BootstrapSetupUxLab"; import { CompanySettingsPluginPage } from "./pages/CompanySettingsPluginPage"; import { CompanyAccess, CompanyAccessLegacyRoute } from "./pages/CompanyAccess"; import { CompanyInvites } from "./pages/CompanyInvites"; import { CompanySkills } from "./pages/CompanySkills"; import { Secrets } from "./pages/Secrets"; import { CompanyExport } from "./pages/CompanyExport"; import { CompanyImport } from "./pages/CompanyImport"; import { DesignGuide } from "./pages/DesignGuide"; import { InstanceGeneralSettings } from "./pages/InstanceGeneralSettings"; import { InstanceAccess } from "./pages/InstanceAccess"; import { InstanceSettings } from "./pages/InstanceSettings"; import { InstanceExperimentalSettings } from "./pages/InstanceExperimentalSettings"; import { ProfileSettings } from "./pages/ProfileSettings"; import { PluginManager } from "./pages/PluginManager"; import { PluginSettings } from "./pages/PluginSettings"; import { AdapterManager } from "./pages/AdapterManager"; import { PluginPage } from "./pages/PluginPage"; import { OrgChart } from "./pages/OrgChart"; import { NewAgent } from "./pages/NewAgent"; import { AuthPage } from "./pages/Auth"; import { BoardClaimPage } from "./pages/BoardClaim"; import { CliAuthPage } from "./pages/CliAuth"; import { InviteLandingPage } from "./pages/InviteLanding"; import { JoinRequestQueue } from "./pages/JoinRequestQueue"; import { NotFoundPage } from "./pages/NotFound"; import { useCompany } from "./context/CompanyContext"; import { useDialogActions, useDialogState } from "./context/DialogContext"; import { loadLastInboxTab } from "./lib/inbox"; import { isOnboardingWizardActive, shouldRedirectCompanylessRouteToOnboarding, } from "./lib/onboarding-route"; import { normalizeRememberedInstanceSettingsPath } from "./lib/instance-settings"; function boardRoutes() { return ( <> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {import.meta.env.DEV ? ( } /> ) : null} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* Conference Room Chat surfaces (PAP-136/PAP-137): routes stay registered but redirect to the company home while the experimental flag is off. The board-level `artifacts` mount below is the new conference-room one; the master-level mount above it still serves `/artifacts` in both modes. */} }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); } function InboxRootRedirect() { return ; } function LegacySettingsRedirect() { const location = useLocation(); const { companies, selectedCompany, loading } = useCompany(); const { companyPrefix } = useParams<{ companyPrefix?: string }>(); if (loading) { return
Loading...
; } const targetCompany = (companyPrefix ? companies.find((company) => company.issuePrefix.toUpperCase() === companyPrefix.toUpperCase()) : null) ?? selectedCompany ?? companies[0] ?? null; if (!targetCompany) { if ( shouldRedirectCompanylessRouteToOnboarding({ pathname: location.pathname, hasCompanies: false, }) ) { return ; } return ; } const normalizedPath = normalizeRememberedInstanceSettingsPath( `${location.pathname}${location.search}${location.hash}`, ); return ( ); } function OnboardingRoutePage() { const { companies } = useCompany(); const { openOnboarding } = useDialogActions(); const { onboardingOpen, onboardingRouteDismissed } = useDialogState(); const { companyPrefix } = useParams<{ companyPrefix?: string }>(); // The OnboardingWizard auto-opens on this route (and can also be opened // explicitly). While it is showing it covers the whole screen, so the // launcher card below must not stay interactive behind it — otherwise users // can tab/click through to the form behind the modal (PAP-52). The launcher // only needs to render as a re-entry point once the wizard is dismissed. if (isOnboardingWizardActive({ onboardingOpen, routeDismissed: onboardingRouteDismissed })) { return null; } const matchedCompany = companyPrefix ? companies.find((company) => company.issuePrefix.toUpperCase() === companyPrefix.toUpperCase()) ?? null : null; const title = matchedCompany ? `Add another agent to ${matchedCompany.name}` : companies.length > 0 ? "Create another company" : "Create your first company"; const description = matchedCompany ? "Run onboarding again to add an agent and a starter task for this company." : companies.length > 0 ? "Run onboarding again to create another company and seed its first agent." : "Get started by creating a company and your first agent."; return (

{title}

{description}

); } function CompanyRootRedirect() { const { companies, selectedCompany, loading } = useCompany(); const location = useLocation(); if (loading) { return
Loading...
; } const targetCompany = selectedCompany ?? companies[0] ?? null; if (!targetCompany) { if ( shouldRedirectCompanylessRouteToOnboarding({ pathname: location.pathname, hasCompanies: false, }) ) { return ; } return ; } return ; } function UnprefixedBoardRedirect() { const location = useLocation(); const { companies, selectedCompany, loading } = useCompany(); if (loading) { return
Loading...
; } const targetCompany = selectedCompany ?? companies[0] ?? null; if (!targetCompany) { if ( shouldRedirectCompanylessRouteToOnboarding({ pathname: location.pathname, hasCompanies: false, }) ) { return ; } return ; } return ( ); } function NoCompaniesStartPage() { const { openOnboarding } = useDialogActions(); const { t } = useTranslation(); return (

{t("app.noCompanies.title", { defaultValue: "Create your first company" })}

{t("app.noCompanies.description", { defaultValue: "Get started by creating a company." })}

); } export function App() { return ( <> } /> } /> } /> } /> } /> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> }> {boardRoutes()} } /> ); }