|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | 3 | import React, { useEffect } from 'react'; |
4 | | -import { AnimatePresence, motion } from 'motion/react'; |
5 | 4 | import { Track } from 'livekit-client'; |
| 5 | +import { AnimatePresence, motion } from 'motion/react'; |
6 | 6 | import { |
7 | 7 | type AgentState, |
| 8 | + BarVisualizer, |
8 | 9 | useRoomContext, |
9 | 10 | useVoiceAssistant, |
10 | | - BarVisualizer, |
11 | 11 | } from '@livekit/components-react'; |
12 | 12 | import { PhoneDisconnectIcon } from '@phosphor-icons/react/dist/ssr'; |
13 | | - |
14 | 13 | import { toastAlert } from '@/components/alert-toast'; |
15 | | -import { Button } from '@/components/ui/button'; |
16 | | -import { useAgentControlBar } from '@/hooks/use-agent-control-bar'; |
| 14 | +import { ChatEntry } from '@/components/livekit/chat/chat-entry'; |
17 | 15 | import { DeviceSelect } from '@/components/livekit/device-select'; |
18 | 16 | import { TrackToggle } from '@/components/livekit/track-toggle'; |
| 17 | +import { Button } from '@/components/ui/button'; |
| 18 | +import { useAgentControlBar } from '@/hooks/use-agent-control-bar'; |
| 19 | +import useChatAndTranscription from '@/hooks/use-chat-and-transcription'; |
19 | 20 | import { useDebugMode } from '@/hooks/useDebug'; |
20 | 21 | import type { AppConfig } from '@/lib/types'; |
21 | 22 | import { cn } from '@/lib/utils'; |
22 | | -import useChatAndTranscription from '@/hooks/use-chat-and-transcription'; |
23 | | -import { ChatEntry } from '@/components/livekit/chat/chat-entry'; |
24 | 23 | import { ChatInput } from '../livekit/chat/chat-input'; |
25 | 24 |
|
26 | 25 | function isAgentAvailable(agentState: AgentState) { |
@@ -50,7 +49,7 @@ export const PopupView = ({ |
50 | 49 | handleDisconnect, |
51 | 50 | } = useAgentControlBar({ |
52 | 51 | controls: { microphone: true }, |
53 | | - saveUserChoices: true |
| 52 | + saveUserChoices: true, |
54 | 53 | }); |
55 | 54 | const { messages, send } = useChatAndTranscription(); |
56 | 55 |
|
@@ -102,18 +101,17 @@ export const PopupView = ({ |
102 | 101 | return () => clearTimeout(timeout); |
103 | 102 | }, [agentState, sessionStarted, room]); |
104 | 103 |
|
105 | | - const showAgentListening = ( |
106 | | - appConfig.isPreConnectBufferEnabled && |
| 104 | + const showAgentListening = |
| 105 | + appConfig.isPreConnectBufferEnabled && |
107 | 106 | agentState !== 'disconnected' && |
108 | 107 | agentState !== 'connecting' && |
109 | | - agentState !== 'initializing' |
110 | | - ); |
| 108 | + agentState !== 'initializing'; |
111 | 109 |
|
112 | 110 | return ( |
113 | | - <div ref={ref} inert={disabled} className="flex flex-col w-full h-full"> |
114 | | - <div className="relative flex flex-col justify-end h-0 p-2 grow-1 shrink-1 overflow-y-auto"> |
| 111 | + <div ref={ref} inert={disabled} className="flex h-full w-full flex-col"> |
| 112 | + <div className="relative flex h-0 shrink-1 grow-1 flex-col justify-end overflow-y-auto p-2"> |
115 | 113 | <motion.div |
116 | | - className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col items-center" |
| 114 | + className="absolute top-1/2 left-1/2 flex -translate-x-1/2 -translate-y-1/2 flex-col items-center" |
117 | 115 | initial={false} |
118 | 116 | animate={{ |
119 | 117 | opacity: agentState === 'connecting' ? 1 : 0, |
@@ -169,15 +167,15 @@ export const PopupView = ({ |
169 | 167 |
|
170 | 168 | <div |
171 | 169 | aria-label="Voice assistant controls" |
172 | | - className="relative flex items-center gap-1 px-2 h-12 grow-0 shrink-0" |
| 170 | + className="relative flex h-12 shrink-0 grow-0 items-center gap-1 px-2" |
173 | 171 | > |
174 | 172 | <motion.div |
175 | 173 | initial={false} |
176 | 174 | animate={{ |
177 | 175 | opacity: showAgentListening ? 1 : 0, |
178 | 176 | pointerEvents: showAgentListening ? 'auto' : 'none', |
179 | 177 | }} |
180 | | - className="absolute -top-8 right-2 flex justify-center items-center gap-2 bg-bg2 px-3 py-0.5 rounded-full" |
| 178 | + className="bg-bg2 absolute -top-8 right-2 flex items-center justify-center gap-2 rounded-full px-3 py-0.5" |
181 | 179 | > |
182 | 180 | <BarVisualizer |
183 | 181 | barCount={3} |
@@ -245,7 +243,7 @@ export const PopupView = ({ |
245 | 243 | {/* FIXME: do I need to handle the other channels here? */} |
246 | 244 | </div> |
247 | 245 |
|
248 | | - <ChatInput className="w-0 grow-1 shrink-1" onSend={onSend} /> |
| 246 | + <ChatInput className="w-0 shrink-1 grow-1" onSend={onSend} /> |
249 | 247 | </div> |
250 | 248 | </div> |
251 | 249 | ); |
|
0 commit comments