Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

_chat.new.tsx

32 lines1.3 KB

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