1import { createBrowserRouter, RouterProvider } from 'react-router-dom'
2import { Shell } from '@/components/layout/Shell'
3import { RepoShell } from '@/lib/repo'
4import { RepoPickerPage } from '@/pages/RepoPickerPage'
5import { BugListPage } from '@/pages/BugListPage'
6import { BugDetailPage } from '@/pages/BugDetailPage'
7import { NewBugPage } from '@/pages/NewBugPage'
8import { CodePage } from '@/pages/CodePage'
9import { UserProfilePage } from '@/pages/UserProfilePage'
10import { CommitPage } from '@/pages/CommitPage'
11import { IdentitySelectPage } from '@/pages/IdentitySelectPage'
12
13// Route structure:
14// / → repo picker
15// /:repo → code browser (repo home)
16// /:repo/issues → issue list
17// /_/auth/select-identity → OAuth identity adoption (first-time login)
18//
19// The /_/auth/* prefix uses "_" as a reserved namespace so it never collides
20// with a real repo slug.
21const router = createBrowserRouter([
22 {
23 path: '/',
24 element: <Shell />,
25 children: [
26 { index: true, element: <RepoPickerPage /> },
27 // Reserved namespace for app-level pages that are not repo-scoped.
28 {
29 path: '_',
30 children: [
31 { path: 'auth/select-identity', element: <IdentitySelectPage /> },
32 ],
33 },
34 {
35 path: ':repo',
36 element: <RepoShell />,
37 children: [
38 { index: true, element: <CodePage /> },
39 { path: 'issues', element: <BugListPage /> },
40 { path: 'issues/new', element: <NewBugPage /> },
41 { path: 'issues/:id', element: <BugDetailPage /> },
42 { path: 'user/:id', element: <UserProfilePage /> },
43 { path: 'commit/:hash', element: <CommitPage /> },
44 ],
45 },
46 ],
47 },
48])
49
50export function App() {
51 return <RouterProvider router={router} />
52}