1- 'use client' ;
2-
31import * as React from 'react' ;
4- import Link from 'next/link' ;
5- import { usePathname } from 'next/navigation' ;
6- import { Room } from 'livekit-client' ;
7- import { RoomContext } from '@livekit/components-react' ;
8- import { toastAlert } from '@/components/alert-toast' ;
9- import useConnectionDetails from '@/hooks/useConnectionDetails' ;
10- import { cn } from '@/lib/utils' ;
11-
12- export default function ComponentsLayout ( { children } : { children : React . ReactNode } ) {
13- const { connectionDetails } = useConnectionDetails ( ) ;
14-
15- const pathname = usePathname ( ) ;
16- const room = React . useMemo ( ( ) => new Room ( ) , [ ] ) ;
17-
18- React . useEffect ( ( ) => {
19- if ( room . state === 'disconnected' && connectionDetails ) {
20- Promise . all ( [
21- room . localParticipant . setMicrophoneEnabled ( true , undefined , {
22- preConnectBuffer : true ,
23- } ) ,
24- room . connect ( connectionDetails . serverUrl , connectionDetails . participantToken ) ,
25- ] ) . catch ( ( error ) => {
26- toastAlert ( {
27- title : 'There was an error connecting to the agent' ,
28- description : `${ error . name } : ${ error . message } ` ,
29- } ) ;
30- } ) ;
31- }
32- return ( ) => {
33- room . disconnect ( ) ;
34- } ;
35- } , [ room , connectionDetails ] ) ;
2+ import { cn , getAppConfig } from '@/lib/utils' ;
3+ import { headers } from 'next/headers' ;
4+ import { Provider } from '@/components/provider' ;
5+ import { Tabs } from '@/app/components/Tabs' ;
366
7+ export default async function ComponentsLayout ( { children } : {
8+ children : React . ReactNode ;
9+ } ) {
10+ const hdrs = await headers ( ) ;
11+ const appConfig = await getAppConfig ( hdrs ) ;
3712 return (
3813 < div className = "mx-auto min-h-svh max-w-3xl space-y-8 px-4 py-8" >
3914 < header className = "flex flex-col gap-1" >
@@ -42,33 +17,10 @@ export default function ComponentsLayout({ children }: { children: React.ReactNo
4217 A quick start UI overview for the LiveKit Voice Assistant.
4318 </ p >
4419 </ header >
45-
46- < div className = "flex flex-row justify-between border-b" >
47- < Link
48- href = "/components/base"
49- className = { cn (
50- 'text-fg0 -mb-px cursor-pointer px-4 pt-2 text-xl font-bold tracking-tight uppercase' ,
51- pathname === '/components/base' &&
52- 'bg-background rounded-t-lg border-t border-r border-l'
53- ) }
54- >
55- Base components
56- </ Link >
57- < Link
58- href = "/components/livekit"
59- className = { cn (
60- 'text-fg0 -mb-px cursor-pointer px-4 py-2 text-xl font-bold tracking-tight uppercase' ,
61- pathname === '/components/livekit' &&
62- 'bg-background rounded-t-lg border-t border-r border-l'
63- ) }
64- >
65- LiveKit components
66- </ Link >
67- </ div >
68-
69- < RoomContext . Provider value = { room } >
20+ < Tabs />
21+ < Provider appConfig = { appConfig } >
7022 < main className = "flex w-full flex-1 flex-col items-stretch gap-8" > { children } </ main >
71- </ RoomContext . Provider >
23+ </ Provider >
7224 </ div >
7325 ) ;
7426}
0 commit comments