Open History to see the last commit
1import { parseNewThreadLink } from "@t3tools/shared/promptLinks";
2import { createFileRoute, useLocation } from "@tanstack/react-router";
3import { NewThreadLinkView } from "../components/promptLinks/NewThreadLinkView";
4import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "../components/ui/empty";
5import { SidebarInset } from "../components/ui/sidebar";
6
7// The query is read raw: the router's own search parsing turns `prompt=123` into a number.
8function NewThreadLinkRoute() {
9 const search = useLocation({ select: (location) => location.searchStr });
10 const parsed = parseNewThreadLink(search);
11 if (!parsed.ok) {
12 return (
13 <SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none">
14 <Empty className="flex-1">
15 <EmptyHeader className="max-w-md">
16 <EmptyTitle>Could not open the link</EmptyTitle>
17 <EmptyDescription>{parsed.error}</EmptyDescription>
18 </EmptyHeader>
19 </Empty>
20 </SidebarInset>
21 );
22 }
23 return <NewThreadLinkView key={search} link={parsed.value} />;
24}
25
26export const Route = createFileRoute("/_chat/new")({
27 component: NewThreadLinkRoute,
28});