import { lazy, type ReactNode, useEffect } from "react"; import { useLayoutMode } from "@/core/system-settings/hooks"; import { isEmbedActive, isHideChromeActive } from "@/core/embed/embed-session"; import { Navigate, Route, Routes, useLocation, useNavigate, useParams } from "react-router-dom"; import { toast } from "@/core/ui/feedback"; import { SidebarInset, SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar"; import { WorkspaceSidebar } from "@/components/workspace/workspace-sidebar"; import { getAccountDisplayName, getStoredAuth } from "@/core/auth"; import { readTaskContext } from "@/core/auth/task-purpose"; import { persistCopTaskDetail, prefetchTaskDeeplink, resolveTaskDeeplinkTarget, stubCopTaskDetail, } from "@/core/auth/task-deeplink"; import { isSentimentAgentVisible } from "@/core/sentiment-agent/config"; import { RouteBaseProvider } from "@/core/route-base"; import "@/roundtable-planning/styles/roundtable-planning.css"; import { AGENT_MODULES } from "@/components/workspace/agents/agent-module-sidebar"; import { ChatRuntime } from "@/components/workspace/chat-runtime"; const AnalysisProjectsPage = lazy(() => import("./AnalysisProjectsPage")); const GeneralQA = lazy(() => import("@/strategy-components/components/chat-qa/GeneralQA")); const SentimentAnalyzes = lazy( () => import("@/strategy-components/components/task-components/SentimentAnalyzes"), ); const TaskManagement = lazy( () => import("@/strategy-components/components/task-components/TaskManagement"), ); const TaskPgFrom = lazy( () => import("@/strategy-components/components/task-components/TaskPgFrom"), ); const TaskTyFrom = lazy( () => import("@/strategy-components/components/task-components/TaskTyFrom"), ); const TaskXkFrom = lazy( () => import("@/strategy-components/components/task-components/TaskXkFrom"), ); const TaskAnalyzes = lazy( () => import("@/strategy-components/components/task-components/TaskAnalyzes"), ); const TaskFxWorkspace = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskFxWorkspace, })), ); const TaskFxIndexResolver = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskFxIndexResolver, })), ); const TaskFxChat = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskFxChat, })), ); const TaskBindChat = lazy(() => import("@/strategy-components/components/task-components/TaskFxWorkspace").then((module) => ({ default: module.TaskBindChat, })), ); const AgentFxWorkspace = lazy(() => import("@/strategy-components/components/task-components/AgentFxWorkspace").then((module) => ({ default: module.AgentFxWorkspace, })), ); const AgentFxIndexResolver = lazy(() => import("@/strategy-components/components/task-components/AgentFxWorkspace").then((module) => ({ default: module.AgentFxIndexResolver, })), ); const AgentFxChat = lazy(() => import("@/strategy-components/components/task-components/AgentFxWorkspace").then((module) => ({ default: module.AgentFxChat, })), ); const TaskAnalysisWorkspace = lazy(() => import("@/strategy-components/components/task-components/TaskAnalysisWorkspace").then((module) => ({ default: module.TaskAnalysisWorkspace, })), ); const TaskAnalysisIndexResolver = lazy(() => import("@/strategy-components/components/task-components/TaskAnalysisWorkspace").then((module) => ({ default: module.TaskAnalysisIndexResolver, })), ); const TaskAnalysisChat = lazy(() => import("@/strategy-components/components/task-components/TaskAnalysisWorkspace").then((module) => ({ default: module.TaskAnalysisChat, })), ); const ActionAnalyzes = lazy(() => import("@/strategy-components/components/task-components/ActionAnalyzes").then((module) => ({ default: module.ActionAnalyzes, })), ); const KnowledgeBaseResourceManagement = lazy( () => import("@/strategy-components/components/resource-management/KnowledgeBaseResourceManagement"), ); const NetworkActorResourceManagement = lazy( () => import("@/strategy-components/components/resource-management/NetworkActorResourceManagement"), ); const RoundtablePlanningPage = lazy( () => import("@/roundtable-planning/pages/RoundtablePlanningPage"), ); const PositionRoundtablePage = lazy( () => import("@/position-roundtable/pages/PositionRoundtablePage"), ); const EightBfRoundtablePage = lazy( () => import("@/eightbf-roundtable/pages/EightBfRoundtablePage"), ); const DashboardAgentPage = lazy( () => import("@/roundtable-planning/pages/DashboardAgentPage"), ); const DeepResearchPage = lazy(() => import("./DeepResearchPage")); const GongwenWorkbench = lazy(() => import("./deep-research/GongwenWorkbench")); const ReportStructureCreatePage = lazy( () => import("./deep-research/ReportStructureCreatePage"), ); const EnterpriseResearchPage = lazy(() => import("./EnterpriseResearchPage")); const BusinessChainListPage = lazy( () => import("@/roundtable-planning/pages/BusinessChainListPage"), ); const BusinessChainEditorPage = lazy( () => import("@/roundtable-planning/pages/BusinessChainEditorPage"), ); const AgentChatPage = lazy(() => import("./AgentChatPage")); const SentimentAgentChatPage = lazy(() => import("./SentimentAgentChatPage")); const AgentModuleRoutes = lazy(() => import("./AgentModulePage").then((module) => ({ default: module.AgentModuleRoutes })), ); const AgentsPage = lazy(() => import("./AgentsPage")); const AgentsPlazaPage = lazy(() => import("./AgentsPlazaPage")); const BusinessChainMappingPage = lazy(() => import("./BusinessChainMappingPage")); const ChatPage = lazy(() => import("./ChatPage")); const ChatsPage = lazy(() => import("./ChatsPage")); const AdminUserLeaderboardPage = lazy(() => import("./AdminUserLeaderboardPage")); const AdminUserLeaderboardSettingsPage = lazy( () => import("./AdminUserLeaderboardSettingsPage"), ); const PublicLeaderboardPage = lazy(() => import("./PublicLeaderboardPage")); const LightAppIframeView = lazy(() => import("./LightAppIframeView")); const LightAppListPage = lazy(() => import("./LightAppListPage")); const LightAppManagementPage = lazy(() => import("./LightAppManagementPage")); const MenuManagementPage = lazy(() => import("./MenuManagementPage")); const LoginWhitelistPage = lazy(() => import("./LoginWhitelistPage")); const FixedQuestionsPage = lazy(() => import("./FixedQuestionsPage")); const SensitiveWordsPage = lazy(() => import("./SensitiveWordsPage")); const SkillAddressesPage = lazy(() => import("./SkillAddressesPage")); const TaskButtonsPage = lazy(() => import("./TaskButtonsPage")); const HtmlTemplatesPage = lazy(() => import("./HtmlTemplatesPage")); const PositionRolesPage = lazy(() => import("./PositionRolesPage")); const RoundtableDiagnosticsPage = lazy(() => import("./RoundtableDiagnosticsPage")); const LightAppNewNotePage = lazy(() => import("./LightAppNewNotePage")); const LightAppNoteListPage = lazy(() => import("./LightAppNoteListPage")); const LightAppNoteQAPage = lazy(() => import("./LightAppNoteQAPage")); const NewAgentPage = lazy(() => import("./NewAgentPage")); const PromptPrefixSettingsPage = lazy(() => import("./PromptPrefixSettingsPage")); const PrivateSquareSettingsPage = lazy(() => import("./PrivateSquareSettingsPage")); const ModelConcurrencySettingsPage = lazy(() => import("./ModelConcurrencySettingsPage")); const RecommendedQuestionsPage = lazy(() => import("./RecommendedQuestionsPage")); const ScheduledTaskRunDetailPage = lazy(() => import("./ScheduledTaskRunDetailPage")); const ScheduledTasksPage = lazy(() => import("./ScheduledTasksPage")); const SkillEvolutionPage = lazy(() => import("./SkillEvolutionPage")); const SkillsPage = lazy(() => import("./SkillsPage")); const PositionsPage = lazy(() => import("./PositionsPage")); const TagsPage = lazy(() => import("./TagsPage")); const UsersPage = lazy(() => import("./UsersPage")); const LlmMetricsPage = lazy(() => import("./LlmMetricsPage")); const AdminScheduledTasksPage = lazy(() => import("./AdminScheduledTasksPage")); const AdminUserActivityPage = lazy(() => import("./AdminUserActivityPage")); const AdminAuditRetentionPage = lazy(() => import("./AdminAuditRetentionPage")); const StrategyProjectsPage = lazy( () => import("@/strategy-selection/StrategyProjectsPage"), ); const StrategySelectionPage = lazy( () => import("@/strategy-selection/StrategySelectionPage"), ); /** * Strategy's legacy `/chats/:thread_id` route shares ChatPage's header. * Unlike WorkspaceRoutes it did not render a WorkspaceSidebar, leaving the * header's expand/collapse control with no visible panel to operate. */ function StrategyChatThreadLayout() { return (