import { Navigate, Outlet, Route, Routes, useActiveCompanyPrefix, 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 { PipelinesExperimentalGate } from "./components/PipelinesExperimentalGate"; import { CasesExperimentalGate } from "./components/CasesExperimentalGate"; import { StatusCardsExperimentalGate } from "./components/StatusCardsExperimentalGate"; import { AppsExperimentalGate } from "./components/AppsExperimentalGate"; import { Cases } from "./pages/Cases"; import { CaseDetail } from "./pages/CaseDetail"; import { OnboardingWizardVariant } from "./components/OnboardingWizardVariant"; import { CloudAccessGate } from "./components/CloudAccessGate"; import { Dashboard } from "./pages/Dashboard"; import { DashboardLive } from "./pages/DashboardLive"; import { Timeline } from "./pages/Timeline"; import { Companies } from "./pages/Companies"; import { AGENT_FILTER_TABS, 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 { Learnings, PipelineItemDetail, PipelineItemLegacyRedirect, Pipelines, ReviewQueue } from "./pages/Pipelines"; import { PipelineSettings } from "./pages/PipelineSettings"; import { StatusCards } from "./pages/StatusCards"; 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 { WhatNeedsMe } from "./pages/WhatNeedsMe"; import { TrainingInspector, TrainingLibrary } from "./pages/Training"; 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 { ResponsibleUserDenialUxLab } from "./pages/ResponsibleUserDenialUxLab"; import { CompanySettingsPluginPage } from "./pages/CompanySettingsPluginPage"; import { CompanyAccess, CompanyAccessLegacyRoute } from "./pages/CompanyAccess"; import { AdvancedToolsRoute } from "./pages/tools/AdvancedToolsRoute"; import { ProfileWizardRoute } from "./pages/tools/profiles/ProfileWizardRoute"; import { ProfileDetailRoute } from "./pages/tools/profiles/ProfileDetailRoute"; import { Connections } from "./pages/apps/Connections"; import { Browse } from "./pages/apps/Browse"; import { AppsConnect } from "./pages/apps/AppsConnect"; import { AppsReview } from "./pages/apps/AppsReview"; import { AppDetail } from "./pages/apps/AppDetail"; import { AppNotConnected } from "./pages/apps/AppNotConnected"; import { GatewaysList } from "./pages/apps/gateways/GatewaysList"; import { GatewayDetail } from "./pages/apps/gateways/GatewayDetail"; import { CompanyInvites } from "./pages/CompanyInvites"; import { CompanySkills } from "./pages/CompanySkills"; import { SkillStudio } from "./pages/SkillStudio"; 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 ( <> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> }> } /> } /> } /> } /> } /> } /> {/* Needs attention folded into Connections (PAP-13254); keep legacy links working. */} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {AGENT_FILTER_TABS.map((tab) => ( } /> ))} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {import.meta.env.DEV ? ( } /> ) : null} } /> } /> } /> } /> } /> {/* Back-compat: the board lived at /status-cards before PAP-15223. */} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* 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 AppsConnectEntryRoute() { const location = useLocation(); const searchParams = new URLSearchParams(location.search); return searchParams.get("byo") === "1" ? : ; } function InboxRootRedirect() { return ; } function LegacyTrainingRedirect() { const { id } = useParams<{ id: string }>(); return ; } function LegacySkillStudioRedirect() { const location = useLocation(); const { companies, selectedCompany, loading } = useCompany(); const { companyPrefix, skillId } = useParams<{ companyPrefix?: string; skillId?: string }>(); if (loading) return null; const targetCompany = (companyPrefix ? companies.find((company) => company.issuePrefix.toUpperCase() === companyPrefix.toUpperCase()) : null) ?? selectedCompany ?? companies[0] ?? null; if (!targetCompany || !skillId) { return ; } 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 LegacyToolsSettingsRedirect() { const { tab } = useParams<{ tab?: string }>(); return ; } // The developer "Tools" surface moved under the Apps "Advanced setup" door // (PAP-10862). `/tools` and `/tools/:tab` redirect to their new home. function LegacyToolsRedirect() { const { tab } = useParams<{ tab?: string }>(); return ; } function legacyToolsRedirectTarget(tab?: string) { if (!tab) return "/apps/advanced/profiles"; if (tab === "applications" || tab === "connections" || tab === "overview" || tab === "examples") return "/apps"; return `/apps/advanced/${tab}`; } 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 StatusCardsLegacyRedirect() { const { cardId } = useParams<{ cardId?: string }>(); const prefix = useActiveCompanyPrefix(); const base = prefix ? `/${prefix}` : ""; 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 ( <> } /> } /> } /> } /> } /> } /> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> {AGENT_FILTER_TABS.map((tab) => ( } /> ))} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> }> {boardRoutes()} } /> ); }