This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Repository navigation
feat(code): introduce TanStack Router file-based routing #2455
Closed
Closed
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import path from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { Generator, getConfig } from "@tanstack/router-generator"; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const root = path.resolve(__dirname, ".."); | ||
|
|
||
| const config = getConfig( | ||
| { | ||
| target: "react", | ||
| autoCodeSplitting: true, | ||
| routesDirectory: path.resolve(root, "src/renderer/routes"), | ||
| generatedRouteTree: path.resolve(root, "src/renderer/routeTree.gen.ts"), | ||
| }, | ||
| root, | ||
| ); | ||
|
|
||
| const generator = new Generator({ config, root }); | ||
| await generator.run(); | ||
| console.log("Generated routeTree.gen.ts"); |
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
8 changes: 8 additions & 0 deletions
8
apps/code/src/renderer/features/settings/stores/settingsDialogStore.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { | ||
| createHashHistory, | ||
| createRouter as createTanStackRouter, | ||
| } from "@tanstack/react-router"; | ||
| import { routeTree } from "./routeTree.gen"; | ||
|
|
||
| export const router = createTanStackRouter({ | ||
| routeTree, | ||
| history: createHashHistory(), | ||
| defaultPreload: "intent", | ||
| scrollRestoration: false, | ||
| }); | ||
|
|
||
| declare module "@tanstack/react-router" { | ||
| interface Register { | ||
| router: typeof router; | ||
| } | ||
| } |
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 |
|---|---|---|
|
|
@@ -2,24 +2,14 @@ import { HeaderRow } from "@components/HeaderRow"; | |
| import { HedgehogMode } from "@components/HedgehogMode"; | ||
| import { KeyboardShortcutsSheet } from "@components/KeyboardShortcutsSheet"; | ||
| import { SpaceSwitcher } from "@components/SpaceSwitcher"; | ||
|
|
||
| import { ArchivedTasksView } from "@features/archive/components/ArchivedTasksView"; | ||
| import { UsageLimitModal } from "@features/billing/components/UsageLimitModal"; | ||
| import { CommandMenu } from "@features/command/components/CommandMenu"; | ||
| import { CommandCenterView } from "@features/command-center/components/CommandCenterView"; | ||
| import { InboxView } from "@features/inbox/components/InboxView"; | ||
| import { useInboxDeepLink } from "@features/inbox/hooks/useInboxDeepLink"; | ||
| import { McpServersView } from "@features/mcp-servers/components/McpServersView"; | ||
| import { FolderSettingsView } from "@features/settings/components/FolderSettingsView"; | ||
| import { SettingsDialog } from "@features/settings/components/SettingsDialog"; | ||
| import { useSetupDiscovery } from "@features/setup/hooks/useSetupDiscovery"; | ||
| import { MainSidebar } from "@features/sidebar/components/MainSidebar"; | ||
| import { useSidebarData } from "@features/sidebar/hooks/useSidebarData"; | ||
| import { useVisualTaskOrder } from "@features/sidebar/hooks/useVisualTaskOrder"; | ||
| import { SkillsView } from "@features/skills/components/SkillsView"; | ||
| import { TaskDetail } from "@features/task-detail/components/TaskDetail"; | ||
| import { TaskInput } from "@features/task-detail/components/TaskInput"; | ||
| import { TaskPendingView } from "@features/task-detail/components/TaskPendingView"; | ||
| import { useTasks } from "@features/tasks/hooks/useTasks"; | ||
| import { TourOverlay } from "@features/tour/components/TourOverlay"; | ||
| import { | ||
|
|
@@ -35,23 +25,23 @@ import { useCommandMenuStore } from "@stores/commandMenuStore"; | |
| import { useNavigationStore } from "@stores/navigationStore"; | ||
| import { useShortcutsSheetStore } from "@stores/shortcutsSheetStore"; | ||
| import { useQueryClient } from "@tanstack/react-query"; | ||
| import { createRootRoute, Outlet } from "@tanstack/react-router"; | ||
| import { TanStackRouterDevtools } from "@tanstack/react-router-devtools"; | ||
| import { logger } from "@utils/logger"; | ||
| import { useCallback, useEffect, useRef } from "react"; | ||
| import { GlobalEventHandlers } from "../components/GlobalEventHandlers"; | ||
| import { useNewTaskDeepLink } from "../hooks/useNewTaskDeepLink"; | ||
| import { useTaskDeepLink } from "../hooks/useTaskDeepLink"; | ||
| import { GlobalEventHandlers } from "./GlobalEventHandlers"; | ||
|
|
||
| const log = logger.scope("main-layout"); | ||
| const log = logger.scope("root-route"); | ||
|
|
||
| export function MainLayout() { | ||
| const { | ||
| view, | ||
| hydrateTask, | ||
| navigateToTaskInput, | ||
| navigateToTask, | ||
| taskInputReportAssociation, | ||
| taskInputCloudRepository, | ||
| } = useNavigationStore(); | ||
| export const Route = createRootRoute({ | ||
| component: RootLayout, | ||
| }); | ||
|
|
||
| function RootLayout() { | ||
| const { view, hydrateTask, navigateToTaskInput, navigateToTask } = | ||
| useNavigationStore(); | ||
| const { | ||
| isOpen: commandMenuOpen, | ||
| setOpen: setCommandMenuOpen, | ||
|
|
@@ -70,7 +60,6 @@ export function MainLayout() { | |
| const billingEnabled = useFeatureFlag(BILLING_FLAG); | ||
| const syncCloudTasksEnabled = useFeatureFlag(SYNC_CLOUD_TASKS_FLAG); | ||
|
|
||
| // Space switcher data | ||
| const sidebarData = useSidebarData({ activeView: view }); | ||
| const visualTaskOrder = useVisualTaskOrder(sidebarData); | ||
| const activeTaskId = | ||
|
|
@@ -100,8 +89,6 @@ export function MainLayout() { | |
| if (missing.length === 0) return; | ||
| const missingIds = missing.map((t) => t.id); | ||
| for (const id of missingIds) reconcilingTaskIds.current.add(id); | ||
| // Single batched IPC instead of one mutation per task — with many cloud | ||
| // tasks the per-task pattern saturates the main thread at boot. | ||
| workspaceApi | ||
| .reconcileCloudWorkspaces(missingIds) | ||
| .then((result) => { | ||
|
|
@@ -140,42 +127,8 @@ export function MainLayout() { | |
| <HeaderRow /> | ||
| <Flex flexGrow="1" overflow="hidden"> | ||
| <MainSidebar /> | ||
|
|
||
| <Box flexGrow="1" overflow="hidden"> | ||
| {view.type === "task-input" && ( | ||
| <TaskInput | ||
| initialPrompt={view.initialPrompt} | ||
| initialPromptKey={view.taskInputRequestId} | ||
| initialCloudRepository={ | ||
| view.initialCloudRepository ?? taskInputCloudRepository | ||
| } | ||
| initialModel={view.initialModel} | ||
| initialMode={view.initialMode} | ||
| reportAssociation={ | ||
| view.reportAssociation ?? taskInputReportAssociation | ||
| } | ||
| /> | ||
| )} | ||
|
|
||
| {view.type === "task-detail" && view.data && ( | ||
| <TaskDetail key={view.data.id} task={view.data} /> | ||
| )} | ||
|
|
||
| {view.type === "task-pending" && view.pendingTaskKey && ( | ||
| <TaskPendingView pendingTaskKey={view.pendingTaskKey} /> | ||
| )} | ||
|
|
||
| {view.type === "folder-settings" && <FolderSettingsView />} | ||
|
|
||
| {view.type === "inbox" && <InboxView />} | ||
|
|
||
| {view.type === "archived" && <ArchivedTasksView />} | ||
|
|
||
| {view.type === "command-center" && <CommandCenterView />} | ||
|
|
||
| {view.type === "skills" && <SkillsView />} | ||
|
|
||
| {view.type === "mcp-servers" && <McpServersView />} | ||
| <Outlet /> | ||
| </Box> | ||
| </Flex> | ||
|
|
||
|
|
@@ -200,6 +153,9 @@ export function MainLayout() { | |
| <TourOverlay /> | ||
| {billingEnabled && <UsageLimitModal />} | ||
| <HedgehogMode /> | ||
| {import.meta.env.DEV && ( | ||
| <TanStackRouterDevtools position="bottom-right" /> | ||
|
Comment on lines
155
to
+157
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/code/src/renderer/routes/__root.tsx
Line: 155-157
Comment:
**DevTools bundle not tree-shaken in prod** — The top-level `import { TanStackRouterDevtools } from "@tanstack/react-router-devtools"` is unconditional, so the entire devtools chunk is included in the production bundle regardless of the `import.meta.env.DEV` guard on the JSX. The fix is to use `React.lazy` with a conditional dynamic import so the module is only ever loaded in development builds.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| )} | ||
| </Flex> | ||
| ); | ||
| } | ||
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,6 @@ | ||
| import { ArchivedTasksView } from "@features/archive/components/ArchivedTasksView"; | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
|
|
||
| export const Route = createFileRoute("/code/archived")({ | ||
| component: ArchivedTasksView, | ||
| }); |
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,6 @@ | ||
| import { InboxView } from "@features/inbox/components/InboxView"; | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
|
|
||
| export const Route = createFileRoute("/code/inbox")({ | ||
| component: InboxView, | ||
| }); |
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,44 @@ | ||
| import { TaskInput } from "@features/task-detail/components/TaskInput"; | ||
| import { useNavigationStore } from "@stores/navigationStore"; | ||
| import { createFileRoute } from "@tanstack/react-router"; | ||
|
|
||
| export const Route = createFileRoute("/code/")({ | ||
| component: CodeIndexRoute, | ||
| }); | ||
|
|
||
| function CodeIndexRoute() { | ||
| const view = useNavigationStore((s) => s.view); | ||
| const taskInputReportAssociation = useNavigationStore( | ||
| (s) => s.taskInputReportAssociation, | ||
| ); | ||
| const taskInputCloudRepository = useNavigationStore( | ||
| (s) => s.taskInputCloudRepository, | ||
| ); | ||
|
|
||
| const initialPrompt = | ||
| view.type === "task-input" ? view.initialPrompt : undefined; | ||
| const initialPromptKey = | ||
| view.type === "task-input" ? view.taskInputRequestId : undefined; | ||
| const initialCloudRepository = | ||
| view.type === "task-input" | ||
| ? (view.initialCloudRepository ?? taskInputCloudRepository) | ||
| : taskInputCloudRepository; | ||
| const initialModel = | ||
| view.type === "task-input" ? view.initialModel : undefined; | ||
| const initialMode = view.type === "task-input" ? view.initialMode : undefined; | ||
| const reportAssociation = | ||
| view.type === "task-input" | ||
| ? (view.reportAssociation ?? taskInputReportAssociation) | ||
| : taskInputReportAssociation; | ||
|
|
||
| return ( | ||
| <TaskInput | ||
| initialPrompt={initialPrompt} | ||
| initialPromptKey={initialPromptKey} | ||
| initialCloudRepository={initialCloudRepository} | ||
| initialModel={initialModel} | ||
| initialMode={initialMode} | ||
| reportAssociation={reportAssociation} | ||
| /> | ||
| ); | ||
| } |
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.
window.history.pushState({ settingsOpen: true })call inopen()is now dead (see companion comment), the guard here readingwindow.history.state?.settingsOpenis always false andwindow.history.back()is never called. This dead branch can be removed, leaving just therouter.navigate({ to: "/code" })path to handle the URL change on close.Prompt To Fix With AI