-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Migrate web UI to TanStack Router #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
663b0cb
feat: migrate web routes to tanstack router
dastratakos 041833a
fix(web): make legacy hash redirect actually fire
dastratakos 0aaa0c1
refactor(web): extract countViewedChapters helper
dastratakos f91ff23
refactor(web): make router a module-level singleton
dastratakos db957b3
refactor(web): drop legacy hash-route redirect
dastratakos d4908f7
refactor(web): infer PR tab type from tabs array
dastratakos 3b7d776
refactor: scope query freshness by data type
dastratakos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import type { QueryClient } from "@tanstack/react-query"; | ||
| import { createRootRouteWithContext, Outlet } from "@tanstack/react-router"; | ||
|
|
||
| export const Route = createRootRouteWithContext<{ | ||
| queryClient: QueryClient; | ||
| }>()({ | ||
| component: RootLayout, | ||
| }); | ||
|
|
||
| function RootLayout() { | ||
| return ( | ||
| <div className="flex min-h-screen flex-col bg-background text-foreground"> | ||
| <Outlet /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { Topbar } from "@/components/layout/topbar"; | ||
|
|
||
| export const Route = createFileRoute("/")({ | ||
| component: NoRunSelected, | ||
| }); | ||
|
|
||
| function NoRunSelected() { | ||
| return ( | ||
| <> | ||
| <Topbar runId={null} /> | ||
| <div className="flex flex-1 items-center justify-center p-6"> | ||
| <div className="max-w-md text-center"> | ||
| <h1 className="font-semibold text-lg">No run selected</h1> | ||
| <p className="mt-2 text-muted-foreground text-sm"> | ||
| The URL is missing a <code>/runs/<runId></code> path. Open the app via{" "} | ||
| <code>stage-cli show <path></code>. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { FilesPage } from "@/routes/files-page"; | ||
|
|
||
| export const Route = createFileRoute("/runs/$runId/files")({ | ||
| component: FilesRoute, | ||
| }); | ||
|
|
||
| function FilesRoute() { | ||
| const { runId } = Route.useParams(); | ||
| return <FilesPage runId={runId} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { useMemo } from "react"; | ||
| import { useChapters } from "@/lib/use-chapters"; | ||
| import { countViewedChapters, useViewStateData } from "@/lib/use-view-state"; | ||
| import { ChaptersIndexPage } from "@/routes/chapters-index-page"; | ||
|
|
||
| export const Route = createFileRoute("/runs/$runId/")({ | ||
| component: ChaptersRoute, | ||
| }); | ||
|
|
||
| function ChaptersRoute() { | ||
| const { runId } = Route.useParams(); | ||
| const { data, isLoading } = useChapters(runId); | ||
| const { chapterIdSet } = useViewStateData(runId); | ||
| const chapters = data?.chapters; | ||
| const viewedCount = useMemo( | ||
| () => countViewedChapters(chapters, chapterIdSet), | ||
| [chapters, chapterIdSet], | ||
| ); | ||
|
|
||
| return ( | ||
| <ChaptersIndexPage | ||
| chapters={chapters} | ||
| runId={runId} | ||
| viewedCount={viewedCount} | ||
| isLoading={isLoading} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
| import { Topbar } from "@/components/layout/topbar"; | ||
| import { PullRequestLayout } from "@/routes/pull-request-layout"; | ||
|
|
||
| export const Route = createFileRoute("/runs/$runId")({ | ||
| component: RunLayout, | ||
| }); | ||
|
|
||
| function RunLayout() { | ||
| const { runId } = Route.useParams(); | ||
| return ( | ||
| <> | ||
| <Topbar runId={runId} /> | ||
| <PullRequestLayout runId={runId} /> | ||
| </> | ||
| ); | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Legacy hash URL redirect is missing
Medium Severity
The PR description states it preserves "a legacy
#/runs/...redirect," and the olduseHashRunIdhook is deleted, but no redirect from hash-based URLs to path-based URLs exists anywhere in the codebase. A user arriving at/#/runs/abc(e.g. from browser history or a cached link) lands on the/route and sees "No run selected" instead of being redirected to/runs/abc. The PR discussion references a fix in commit 041833a, but the redirect logic is absent from the final code.Additional Locations (1)
packages/web/src/app/__root.tsx#L3-L8Reviewed by Cursor Bugbot for commit db957b3. Configure here.