fix(lint): move AssistantSessionRedirect out of router.tsx (react-refresh gate)
react-refresh/only-export-components fires when a file with the \`router\` const export also defines a component (the redirect helper). Moves the small helper to its own file under components/routing/ so HMR can keep the route-component module hot-reload-eligible. No behavior change. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
11
frontend/src/components/routing/AssistantSessionRedirect.tsx
Normal file
11
frontend/src/components/routing/AssistantSessionRedirect.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Navigate, useParams } from 'react-router-dom'
|
||||
|
||||
/**
|
||||
* Permanent 301-style redirect from /assistant/:sessionId to /pilot/:sessionId.
|
||||
* Used by the Phase 1 route-rename; paired with a bare-path redirect to /pilot.
|
||||
* SPA redirects replace history so the legacy URL does not linger in back-nav.
|
||||
*/
|
||||
export function AssistantSessionRedirect() {
|
||||
const { sessionId } = useParams<{ sessionId: string }>()
|
||||
return <Navigate to={sessionId ? `/pilot/${sessionId}` : '/pilot'} replace />
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createBrowserRouter, Navigate, useParams } from 'react-router-dom'
|
||||
import { createBrowserRouter, Navigate } from 'react-router-dom'
|
||||
import { AssistantSessionRedirect } from '@/components/routing/AssistantSessionRedirect'
|
||||
import * as Sentry from '@sentry/react'
|
||||
import { Suspense } from 'react'
|
||||
import { AppLayout, ProtectedRoute } from '@/components/layout'
|
||||
@@ -102,16 +103,6 @@ function page(Component: React.LazyExoticComponent<React.ComponentType>) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanent 301-style redirect from /assistant/:sessionId to /pilot/:sessionId.
|
||||
* Used by the Phase 1 route-rename; paired with a bare-path redirect to /pilot.
|
||||
* SPA redirects replace history so the legacy URL does not linger in back-nav.
|
||||
*/
|
||||
function AssistantSessionRedirect() {
|
||||
const { sessionId } = useParams<{ sessionId: string }>()
|
||||
return <Navigate to={sessionId ? `/pilot/${sessionId}` : '/pilot'} replace />
|
||||
}
|
||||
|
||||
export const router = sentryCreateBrowserRouter([
|
||||
{
|
||||
path: '/landing',
|
||||
|
||||
Reference in New Issue
Block a user