-
Notifications
You must be signed in to change notification settings - Fork 415
Expand file tree
/
Copy pathapp.tsx
More file actions
64 lines (56 loc) · 1.94 KB
/
app.tsx
File metadata and controls
64 lines (56 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use client';
import { useMemo } from 'react';
import { TokenSource } from 'livekit-client';
import { useSession } from '@livekit/components-react';
import { WarningIcon } from '@phosphor-icons/react/dist/ssr';
import type { AppConfig } from '@/app-config';
import { AgentSessionProvider } from '@/components/agents-ui/agent-session-provider';
import { StartAudioButton } from '@/components/agents-ui/start-audio-button';
import { ViewController } from '@/components/app/view-controller';
import { Toaster } from '@/components/ui/sonner';
import { useAgentErrors } from '@/hooks/useAgentErrors';
import { useDebugMode } from '@/hooks/useDebug';
import { getSandboxTokenSource } from '@/lib/utils';
const IN_DEVELOPMENT = process.env.NODE_ENV !== 'production';
function AppSetup() {
useDebugMode({ enabled: IN_DEVELOPMENT });
useAgentErrors();
return null;
}
interface AppProps {
appConfig: AppConfig;
}
export function App({ appConfig }: AppProps) {
const tokenSource = useMemo(() => {
return typeof process.env.NEXT_PUBLIC_CONN_DETAILS_ENDPOINT === 'string'
? getSandboxTokenSource(appConfig)
: TokenSource.endpoint('/api/token');
}, [appConfig]);
const session = useSession(
tokenSource,
appConfig.agentName ? { agentName: appConfig.agentName } : undefined
);
return (
<AgentSessionProvider session={session}>
<AppSetup />
<main className="grid h-svh grid-cols-1 place-content-center">
<ViewController appConfig={appConfig} />
</main>
<StartAudioButton label="Start Audio" />
<Toaster
icons={{
warning: <WarningIcon weight="bold" />,
}}
position="top-center"
className="toaster group"
style={
{
'--normal-bg': 'var(--popover)',
'--normal-text': 'var(--popover-foreground)',
'--normal-border': 'var(--border)',
} as React.CSSProperties
}
/>
</AgentSessionProvider>
);
}