import { I18nextProvider } from 'react-i18next';
import {
Navigate,
Outlet,
RouterProvider,
createBrowserRouter,
useLocation,
useParams,
} from 'react-router-dom';
import { AuthProvider, ProtectedRoute } from './components/auth';
import { ThemeProvider } from './contexts/ThemeContext';
import { PluginsProvider } from './contexts/PluginsContext';
import { TaskMasterProvider } from './contexts/TaskMasterContext';
import { TasksSettingsProvider } from './contexts/TasksSettingsContext';
import { WebSocketProvider } from './contexts/WebSocketContext';
import i18n from './i18n/config.js';
import { SystemUIProvider } from '@/components/refactored/shared/contexts/system-ui-context/SystemUIProvider';
import { RootLayout } from '@/components/refactored/shared/layout/RootLayout';
import StandaloneShellRouterAdapter from '@/components/standalone-shell/view/StandaloneShellRouterAdapter';
import FileTreeRouterAdapter from '@/components/file-tree/view/FileTreeRouterAdapter.js';
const isValidRouteTab = (value: string | undefined): boolean => {
if (!value) {
return false;
}
const normalizedValue = decodeURIComponent(value);
return (
normalizedValue === 'chat' ||
normalizedValue === 'shell' ||
normalizedValue === 'files' ||
normalizedValue === 'git' ||
normalizedValue === 'tasks' ||
normalizedValue === 'plugins' ||
normalizedValue === 'preview' ||
normalizedValue.startsWith('plugin:')
);
};
function NoWorkspaceRoute() {
return (
Choose Your Project
This is the root route (`/`) empty state. Select a workspace from the sidebar to continue.
);
}
function WorkspaceLayout() {
const { workspaceId } = useParams<{ workspaceId: string }>();
if (!workspaceId) {
return ;
}
return (
);
}
function WorkspaceTabRoute() {
const location = useLocation();
const { workspaceId, sessionId, tab } = useParams<{
workspaceId: string;
sessionId?: string;
tab: string;
}>();
if (!workspaceId && !sessionId) {
return ;
}
if (!isValidRouteTab(tab)) {
return ;
}
const decodedWorkspaceId = workspaceId ? decodeURIComponent(workspaceId) : null;
const decodedSessionId = sessionId ? decodeURIComponent(sessionId) : null;
const decodedTab = tab ? decodeURIComponent(tab) : 'chat';
const pluginName = decodeURIComponent(new URLSearchParams(location.search).get('name') || '');
const tabLabel = decodedTab === 'plugins' && pluginName ? `plugin:${pluginName}` : decodedTab;
return (
{tabLabel} view
Workspace:{' '}
{decodedWorkspaceId || 'none (session-level route)'}
Session:{' '}
{decodedSessionId || 'none (workspace-level tab)'}
);
}
const router = createBrowserRouter(
[
{
path: '/',
element: ,
children: [
{ index: true, element: }, // TODO: Show empty state component loader here.
{
path: 'workspaces/:workspaceId',
element: ,
children: [
{ index: true, element: },
{ path: 'shell', element: },
{ path: 'files', element: },
{ path: ':tab', element: },
],
},
{
path: 'sessions/:sessionId',
children: [
{ index: true, element: },
{ path: 'shell', element: },
{ path: ':tab', element: },
],
},
],
},
],
{ basename: window.__ROUTER_BASENAME__ || '' },
);
export default function App() {
return (
);
}
// import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
// import { I18nextProvider } from 'react-i18next';
// import { ThemeProvider } from './contexts/ThemeContext';
// import { AuthProvider, ProtectedRoute } from './components/auth';
// import { TaskMasterProvider } from './contexts/TaskMasterContext';
// import { TasksSettingsProvider } from './contexts/TasksSettingsContext';
// import { WebSocketProvider } from './contexts/WebSocketContext';
// import { PluginsProvider } from './contexts/PluginsContext';
// import AppContent from './components/app/AppContent';
// import i18n from './i18n/config.js';
// export default function App() {
// return (
//
//
//
//
// 1
//
//
//
//
//
// } />
// } />
//
//
//
//
//
//
//
//
//
//
// );
// }