Skip to content

Commit 315ea3c

Browse files
Preload console route chunks on sidebar link hover. (#2081)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 09c19e4 commit 315ea3c

6 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎apps/cloud/src/router.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createRouter } from "@tanstack/react-router";
2+
import { sharedConsoleRouterOptions } from "@executor-js/react/console-router-options";
23
import { routeTree } from "./routeTree.gen";
34

45
export const getRouter = () => {
56
return createRouter({
67
routeTree,
7-
scrollRestoration: true,
8-
defaultPreloadStaleTime: 0,
8+
...sharedConsoleRouterOptions,
99
});
1010
};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createRouter } from "@tanstack/react-router";
2+
import { sharedConsoleRouterOptions } from "@executor-js/react/console-router-options";
23

34
import { routeTree } from "./routeTree.gen";
45

56
export const getRouter = () =>
67
createRouter({
78
routeTree,
8-
scrollRestoration: true,
9-
defaultPreloadStaleTime: 0,
9+
...sharedConsoleRouterOptions,
1010
});

‎apps/host-selfhost/web/router.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createRouter } from "@tanstack/react-router";
2+
import { sharedConsoleRouterOptions } from "@executor-js/react/console-router-options";
23

34
import { routeTree } from "./routeTree.gen";
45

56
export const getRouter = () =>
67
createRouter({
78
routeTree,
8-
scrollRestoration: true,
9-
defaultPreloadStaleTime: 0,
9+
...sharedConsoleRouterOptions,
1010
});

‎packages/app/src/router.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { createRouter } from "@tanstack/react-router";
2+
import { sharedConsoleRouterOptions } from "@executor-js/react/console-router-options";
23
import { routeTree } from "./routeTree.gen";
34

45
export const getRouter = () => {
56
return createRouter({
67
routeTree,
7-
scrollRestoration: true,
8-
defaultPreloadStaleTime: 0,
8+
...sharedConsoleRouterOptions,
99
});
1010
};

‎packages/react/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"bun": "./src/console-routes.ts",
1010
"default": "./dist/console-routes.js"
1111
},
12+
"./console-router-options": "./src/console-router-options.ts",
1213
"./api/oauth-popup": "./src/api/oauth-popup.ts",
1314
"./api/shell-host": "./src/api/shell-host.ts",
1415
"./api/*": "./src/api/*.tsx",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Shared TanStack Router options for every Executor console host (desktop app,
2+
// cloud, self-host, Cloudflare). Keep navigation snappy: code-split route
3+
// chunks preload on link hover so clicking a sidebar tab does not suspend on
4+
// an empty outlet while the chunk downloads.
5+
6+
export const sharedConsoleRouterOptions = {
7+
scrollRestoration: true,
8+
defaultPreload: "intent" as const,
9+
// Effect atoms own their own cache; we do not use route loaders for data.
10+
defaultPreloadStaleTime: 0,
11+
};

0 commit comments

Comments
 (0)