diff --git a/webui/src/app/router.test.tsx b/webui/src/app/router.test.tsx index b39cb553..72652b19 100644 --- a/webui/src/app/router.test.tsx +++ b/webui/src/app/router.test.tsx @@ -134,4 +134,22 @@ describe('createAppRouter', () => { expect(history.location.pathname).toBe('/discover'); }); + + it('redirects the root route to the profile home page', async () => { + window.SoulSyncWebShellBridge = createShellBridge({ + getProfileHomePage: vi.fn<() => ShellPageId>(() => 'search'), + }); + + const queryClient = createAppQueryClient(); + const history = createMemoryHistory({ initialEntries: ['/'] }); + const router = createAppRouter({ history, queryClient }); + + render(); + + await waitFor(() => { + expect(window.SoulSyncWebShellBridge?.activateLegacyPath).toHaveBeenCalledWith('/search'); + }); + + expect(history.location.pathname).toBe('/search'); + }); }); diff --git a/webui/src/routes/index.tsx b/webui/src/routes/index.tsx index 84aba6b4..8a6985b2 100644 --- a/webui/src/routes/index.tsx +++ b/webui/src/routes/index.tsx @@ -1,8 +1,15 @@ -import { createFileRoute } from '@tanstack/react-router'; +import { createFileRoute, redirect } from '@tanstack/react-router'; +import { getProfileHomePath } from '@/platform/shell/bridge'; import { LegacyRouteController } from '@/platform/shell/route-controllers'; export const Route = createFileRoute('/')({ + beforeLoad: ({ context }) => { + const bridge = context.platform.getShellBridge(); + if (!bridge) return; + + throw redirect({ href: getProfileHomePath(bridge), replace: true }); + }, component: IndexRouteComponent, });