Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
refactor(webui): add a central route registry; migrate the settings shell
Sergey Kozyrenkoae45bd7c4f6c
diff --git a/frontend/src/app.tsx b/frontend/src/app.tsxindex 8cc52632..7c6ce523 100644--- a/frontend/src/app.tsx+++ b/frontend/src/app.tsx@@ -21,6 +21,7 @@ import RouteErrorBoundary from '@/components/shared/route-error-boundary';import { Toaster } from '@/components/ui/sonner';import client from '@/lib/apollo';import { routeTitles } from '@/lib/route-titles';+import { routes } from '@/lib/routes';import { FavoritesProvider } from '@/providers/favorites-provider';import { FlowProvider } from '@/providers/flow-provider';import { KnowledgesProvider } from '@/providers/knowledges-provider';@@ -201,7 +202,7 @@ const router = createBrowserRouter(element={<Navigatereplace- to="account"+ to={routes.settings.account}/>}index@@ -241,7 +242,7 @@ const router = createBrowserRouter(element={<Navigatereplace- to="/settings/account"+ to={routes.settings.account}/>}path="*"diff --git a/frontend/src/components/layouts/main-sidebar.tsx b/frontend/src/components/layouts/main-sidebar.tsxindex 10c7bcf8..fca794ac 100644--- a/frontend/src/components/layouts/main-sidebar.tsx+++ b/frontend/src/components/layouts/main-sidebar.tsx@@ -49,6 +49,7 @@ import {import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';import { useResourcesUpload } from '@/features/resources/use-resources-upload';import { useTheme } from '@/hooks/use-theme';+import { routes } from '@/lib/routes';import { useFavorites } from '@/providers/favorites-provider';import { useSidebarFlows } from '@/providers/sidebar-flows-provider';import { useUser } from '@/providers/user-provider';@@ -271,7 +272,7 @@ export function MainSidebar() {><Linkstate={{ from: location.pathname }}- to="/settings"+ to={routes.settings.root}><Settings />Settings@@ -360,7 +361,7 @@ export function MainSidebar() {<DropdownMenuItem asChild><Linkstate={{ from: location.pathname }}- to="/settings/account"+ to={routes.settings.account}><UserIcon className="mr-2 size-4" />Profilediff --git a/frontend/src/components/layouts/settings-layout.tsx b/frontend/src/components/layouts/settings-layout.tsxindex ef5f7715..4ef13ef0 100644--- a/frontend/src/components/layouts/settings-layout.tsx+++ b/frontend/src/components/layouts/settings-layout.tsx@@ -17,6 +17,7 @@ import {SidebarProvider,SidebarTrigger,} from '@/components/ui/sidebar';+import { routes } from '@/lib/routes';import { getSafeReturnUrl } from '@/lib/utils/auth';export interface MenuItem {@@ -34,25 +35,25 @@ const menuItems: readonly MenuItem[] = [{icon: <User className="size-4" />,id: 'account',- path: '/settings/account',+ path: routes.settings.account,title: 'Account',},{icon: <Plug className="size-4" />,id: 'providers',- path: '/settings/providers',+ path: routes.settings.providers,title: 'Providers',},{icon: <FileText className="size-4" />,id: 'prompts',- path: '/settings/prompts',+ path: routes.settings.prompts,title: 'Prompts',},{icon: <Key className="size-4" />,id: 'api-tokens',- path: '/settings/api-tokens',+ path: routes.settings.apiTokens,title: 'API Tokens',},] as const;@@ -100,7 +101,7 @@ function SettingsHeader() {function SettingsLayout() {const location = useLocation();const [returnUrl] = useState(() =>- getSafeReturnUrl((location.state as null | { from?: string })?.from ?? null, '/flows'),+ getSafeReturnUrl((location.state as null | { from?: string })?.from ?? null, routes.flows),);return (diff --git a/frontend/src/lib/routes.ts b/frontend/src/lib/routes.tsnew file mode 100644index 00000000..1ca2c122--- /dev/null+++ b/frontend/src/lib/routes.ts@@ -0,0 +1,51 @@+import { getReturnUrlParam } from '@/lib/utils/auth';++// Central definition of every client route path. Build URLs from here instead of hardcoding+// strings, so a path lives in exactly one place and parameters are typed at the call site.++function withQuery(path: string, params: Record<string, string | undefined>): string {+ const search = new URLSearchParams();++ for (const [key, value] of Object.entries(params)) {+ if (value != null) {+ search.set(key, value);+ }+ }++ const query = search.toString();++ return query ? `${path}?${query}` : path;+}++export const routes = {+ dashboard: '/dashboard',++ flow: (id: number | string, { tab }: { tab?: string } = {}) => withQuery(`/flows/${id}`, { tab }),+ flowReport: (id: number | string) => `/flows/${id}/report`,+ flows: '/flows',++ knowledge: (id: number | string) => `/knowledges/${id}`,+ knowledges: '/knowledges',+ login: (fromPath?: string) => `/login${fromPath ? getReturnUrlParam(fromPath) : ''}`,+ newFlow: '/flows/new',++ oauthResult: '/oauth/result',+ resources: '/resources',++ root: '/',+ settings: {+ account: '/settings/account',+ apiTokens: '/settings/api-tokens',+ newProvider: ({ id, type }: { id?: string; type?: string } = {}) =>+ withQuery('/settings/providers/new', { id, type }),+ prompt: (name: string) => `/settings/prompts/${name}`,+ prompts: '/settings/prompts',+ provider: (id: string) => `/settings/providers/${id}`,+ providers: '/settings/providers',+ root: '/settings',+ },++ template: (id: number | string) => `/templates/${id}`,++ templates: '/templates',+} as const;