Skip to content

Commit 2e692b5

Browse files
authored
Merge branch 'main' into main
2 parents ed4e614 + e628683 commit 2e692b5

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

‎apps/web/src/routes/__root.tsx‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { scopedProjectKey, scopeProjectRef } from "@t3tools/client-runtime/envir
33
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
44
import {
55
Outlet,
6+
Link,
67
redirect,
78
createRootRoute,
89
type ErrorComponentProps,
910
useLocation,
1011
useNavigate,
12+
useRouter,
1113
} from "@tanstack/react-router";
1214
import { CheckIcon, CopyIcon } from "lucide-react";
1315
import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
@@ -104,11 +106,27 @@ export const Route = createRootRoute({
104106
},
105107
component: RootRouteView,
106108
errorComponent: RootRouteErrorView,
109+
notFoundComponent: RootRouteNotFoundView,
107110
head: () => ({
108111
meta: [{ name: "title", content: APP_DISPLAY_NAME }],
109112
}),
110113
});
111114

115+
function RootRouteNotFoundView() {
116+
return (
117+
<main className="flex min-h-0 min-w-0 flex-1 items-center justify-center p-6">
118+
<div className="flex max-w-sm flex-col items-center gap-4 text-center">
119+
<h1 className="text-lg font-medium text-foreground">Page not found</h1>
120+
<p className="text-sm text-muted-foreground">
121+
This link doesn't point to a page in {APP_DISPLAY_NAME}. Go home to choose a project or
122+
start a thread.
123+
</p>
124+
<Button render={<Link to="/" replace />}>Go home</Button>
125+
</div>
126+
</main>
127+
);
128+
}
129+
112130
function RootRouteView() {
113131
useEffect(() => installDesktopPasteAsText(window.desktopBridge, window), []);
114132
const pathname = useLocation({ select: (location) => location.pathname });
@@ -336,7 +354,8 @@ function HostedStaticEnvironmentBootstrap() {
336354
return null;
337355
}
338356

339-
function RootRouteErrorView({ error, reset }: ErrorComponentProps) {
357+
function RootRouteErrorView({ error }: ErrorComponentProps) {
358+
const router = useRouter();
340359
const message = errorMessage(error);
341360
// Router pathname rather than window.location: desktop uses hash history, where the window path is always "/".
342361
const pathname = useLocation({ select: (location) => location.pathname });
@@ -359,7 +378,7 @@ function RootRouteErrorView({ error, reset }: ErrorComponentProps) {
359378
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{message}</p>
360379

361380
<div className="mt-5 flex flex-wrap gap-2">
362-
<Button size="sm" onClick={() => reset()}>
381+
<Button size="sm" onClick={() => void router.invalidate()}>
363382
Try again
364383
</Button>
365384
<Button size="sm" variant="outline" onClick={() => window.location.reload()}>

0 commit comments

Comments
 (0)