11'use client' ;
22
33import { AnimatePresence , type HTMLMotionProps , motion } from 'motion/react' ;
4- import { type ReceivedMessage } from '@livekit/components-react' ;
4+ import { type ReceivedMessage , useVoiceAssistant } from '@livekit/components-react' ;
55import { ChatEntry } from '@/components/livekit/chat-entry' ;
6+ import { ChatIndicator } from '@/components/livekit/chat-indicator' ;
67
78const MotionContainer = motion . create ( 'div' ) ;
89const MotionChatEntry = motion . create ( ChatEntry ) ;
@@ -24,7 +25,6 @@ const CONTAINER_MOTION_PROPS = {
2425 delay : 0.2 ,
2526 ease : 'easeOut' ,
2627 duration : 0.3 ,
27- stagerDelay : 0.2 ,
2828 staggerChildren : 0.1 ,
2929 staggerDirection : 1 ,
3030 } ,
@@ -58,31 +58,35 @@ export function ChatTranscript({
5858 messages = [ ] ,
5959 ...props
6060} : ChatTranscriptProps & Omit < HTMLMotionProps < 'div' > , 'ref' > ) {
61+ const { state : agentState } = useVoiceAssistant ( ) ;
6162 return (
62- < AnimatePresence >
63- { ! hidden && (
64- < MotionContainer { ...CONTAINER_MOTION_PROPS } { ...props } >
65- { messages . map ( ( receivedMessage ) => {
66- const { id, timestamp, from, message } = receivedMessage ;
67- const locale = navigator ?. language ?? 'en-US' ;
68- const messageOrigin = from ?. isLocal ? 'local' : 'remote' ;
69- const hasBeenEdited =
70- receivedMessage . type === 'chatMessage' && ! ! receivedMessage . editTimestamp ;
63+ < >
64+ < AnimatePresence >
65+ { ! hidden && (
66+ < MotionContainer { ...CONTAINER_MOTION_PROPS } { ...props } >
67+ { messages . map ( ( receivedMessage ) => {
68+ const { id, timestamp, from, message } = receivedMessage ;
69+ const locale = navigator ?. language ?? 'en-US' ;
70+ const messageOrigin = from ?. isLocal ? 'local' : 'remote' ;
71+ const hasBeenEdited =
72+ receivedMessage . type === 'chatMessage' && ! ! receivedMessage . editTimestamp ;
7173
72- return (
73- < MotionChatEntry
74- key = { id }
75- locale = { locale }
76- timestamp = { timestamp }
77- message = { message }
78- messageOrigin = { messageOrigin }
79- hasBeenEdited = { hasBeenEdited }
80- { ...MESSAGE_MOTION_PROPS }
81- />
82- ) ;
83- } ) }
84- </ MotionContainer >
85- ) }
86- </ AnimatePresence >
74+ return (
75+ < MotionChatEntry
76+ key = { id }
77+ locale = { locale }
78+ timestamp = { timestamp }
79+ message = { message }
80+ messageOrigin = { messageOrigin }
81+ hasBeenEdited = { hasBeenEdited }
82+ { ...MESSAGE_MOTION_PROPS }
83+ />
84+ ) ;
85+ } ) }
86+ < ChatIndicator agentState = { agentState } />
87+ </ MotionContainer >
88+ ) }
89+ </ AnimatePresence >
90+ </ >
8791 ) ;
8892}
0 commit comments