Open History to see the last commit
1import { Link, createFileRoute } from '@tanstack/react-router'
2import { fetchServerSentEvents, useChat } from '@tanstack/ai-react'
3import { DevtoolsHarness } from '@/components/DevtoolsHarness'
4import {
5 devtoolsRouteSearch,
6 parseDevtoolsRouteSearch,
7} from '@/lib/devtools-test'
8
9export const Route = createFileRoute('/devtools-route-a')({
10 component: DevtoolsRouteA,
11 validateSearch: parseDevtoolsRouteSearch,
12})
13
14function DevtoolsRouteA() {
15 const search = Route.useSearch()
16 const routeAChat = useChat({
17 threadId: 'devtools-route-a:chat',
18 connection: fetchServerSentEvents('/api/chat'),
19 forwardedProps: {
20 provider: 'openai',
21 feature: 'chat',
22 testId: search.testId,
23 aimockPort: search.aimockPort,
24 },
25 devtools: { name: 'Route A Chat' },
26 })
27 const routeAAux = useChat({
28 threadId: 'devtools-route-a:auxiliary',
29 connection: fetchServerSentEvents('/api/chat'),
30 forwardedProps: {
31 provider: 'openai',
32 feature: 'chat',
33 testId: search.testId,
34 aimockPort: search.aimockPort,
35 },
36 devtools: { name: 'Route A Aux' },
37 })
38
39 return (
40 <DevtoolsHarness>
41 <section className="space-y-3 rounded border border-gray-800 bg-gray-900/40 p-4">
42 <div
43 data-testid="route-name"
44 className="text-sm font-semibold text-orange-300"
45 >
46 Route A
47 </div>
48 <div
49 data-testid="route-a-chat-status"
50 className="text-xs text-gray-400"
51 >
52 {routeAChat.status}
53 </div>
54 <div data-testid="route-a-aux-status" className="text-xs text-gray-400">
55 {routeAAux.status}
56 </div>
57 <Link
58 to="/devtools-route-b"
59 search={search}
60 data-testid="route-b-link"
61 className="inline-flex rounded bg-orange-500 px-3 py-2 text-sm font-medium text-white"
62 >
63 Go to Route B
64 </Link>
65 <a
66 data-testid="generation-route-link"
67 className="ml-2 inline-flex rounded border border-gray-700 px-3 py-2 text-sm text-gray-200"
68 href={`/devtools-generation-hooks${devtoolsRouteSearch(search)}`}
69 >
70 Generation Hooks
71 </a>
72 </section>
73 </DevtoolsHarness>
74 )
75}