Skip to content
TypeScript

fix(web): offer recovery from missing pages (#11314)

shivam4a39cade9829
diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx
index 0831a922325..63495ce5cd6 100644
--- a/apps/web/src/routes/__root.tsx
+++ b/apps/web/src/routes/__root.tsx
@@ -3,6 +3,7 @@ import { scopedProjectKey, scopeProjectRef } from "@t3tools/client-runtime/envir
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
import {
Outlet,
+ Link,
redirect,
createRootRoute,
type ErrorComponentProps,
@@ -104,11 +105,27 @@ export const Route = createRootRoute({
},
component: RootRouteView,
errorComponent: RootRouteErrorView,
+ notFoundComponent: RootRouteNotFoundView,
head: () => ({
meta: [{ name: "title", content: APP_DISPLAY_NAME }],
}),
});
+function RootRouteNotFoundView() {
+ return (
+ <main className="flex min-h-0 min-w-0 flex-1 items-center justify-center p-6">
+ <div className="flex max-w-sm flex-col items-center gap-4 text-center">
+ <h1 className="text-lg font-medium text-foreground">Page not found</h1>
+ <p className="text-sm text-muted-foreground">
+ This link doesn't point to a page in {APP_DISPLAY_NAME}. Go home to choose a project or
+ start a thread.
+ </p>
+ <Button render={<Link to="/" replace />}>Go home</Button>
+ </div>
+ </main>
+ );
+}
+
function RootRouteView() {
useEffect(() => installDesktopPasteAsText(window.desktopBridge, window), []);
const pathname = useLocation({ select: (location) => location.pathname });