@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 32 lines 1.26 KB
Raw
1 import { parseNewThreadLink } from "@t3tools/shared/promptLinksCopy";
2 import { createFileRoute, useLocation } from "@tanstack/react-router";
3 import { T, useMessages } from "gt-react";
4 import { NewThreadLinkView } from "../components/promptLinks/NewThreadLinkView";
5 import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "../components/ui/empty";
6 import { SidebarInset } from "../components/ui/sidebar";
7
8 // The query is read raw: the router's own search parsing turns `prompt=123` into a number.
9 function 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} />;
28 }
29
30 export const Route = createFileRoute("/_chat/new")({
31 component: NewThreadLinkRoute,
32 });