11'use client' ;
22
33import * as React from 'react' ;
4+ import { AnimatePresence , motion } from 'motion/react' ;
45import { ReceivedChatMessage } from '@livekit/components-react' ;
56import { AgentAudioTile } from '@/components/livekit/agent-audio-tile' ;
67import { AgentControlBar } from '@/components/livekit/agent-control-bar/agent-control-bar' ;
78import { ChatEntry } from '@/components/livekit/chat/chat-entry' ;
89import { ChatMessageView } from '@/components/livekit/chat/chat-message-view' ;
910import useChatAndTranscription from '@/hooks/useChatAndTranscription' ;
1011import { useDebugMode } from '@/hooks/useDebug' ;
11- import { AppConfig } from '@/lib/types' ;
1212import { cn } from '@/lib/utils' ;
1313
14- interface SessionViewProp {
15- capabilities : AppConfig [ 'capabilities' ] ;
14+ interface SessionViewProps {
15+ capabilities : {
16+ suportsChatInput : boolean ;
17+ suportsVideoInput : boolean ;
18+ suportsScreenShare : boolean ;
19+ } ;
20+ sessionStarted : boolean ;
1621}
1722
18- export default function SessionView ( { capabilities } : SessionViewProp ) {
23+ export default function SessionView ( { capabilities, sessionStarted } : SessionViewProps ) {
1924 const [ chatOpen , setChatOpen ] = React . useState ( false ) ;
2025 const { messages, send } = useChatAndTranscription ( ) ;
2126
@@ -27,62 +32,86 @@ export default function SessionView({ capabilities }: SessionViewProp) {
2732
2833 return (
2934 < main >
30- { chatOpen && (
31- < ChatMessageView className = "appear-fade-in mx-auto min-h-svh w-full max-w-2xl px-3 pt-56 pb-48 delay-300 duration-1000 ease-out md:px-0" >
32- < div className = "space-y-3 whitespace-pre-wrap" >
35+ < ChatMessageView
36+ className = { cn (
37+ 'mx-auto min-h-svh w-full max-w-2xl px-3 pt-56 pb-48 transition-[opacity,translate] duration-300 ease-out md:px-0' ,
38+ chatOpen ? 'translate-y-0 opacity-100' : 'translate-y-20 opacity-0'
39+ ) }
40+ >
41+ < div className = "space-y-3 whitespace-pre-wrap" >
42+ < AnimatePresence >
3343 { messages . map ( ( message : ReceivedChatMessage ) => (
34- < ChatEntry
35- hideName
44+ < motion . div
3645 key = { message . id }
37- entry = { message }
38- className = "appear-fade-in duration-2000 ease-out"
39- />
46+ initial = { { opacity : 0 , height : 0 } }
47+ animate = { { opacity : 1 , height : 'auto' } }
48+ exit = { { opacity : 1 , height : 'auto' , translateY : 0.001 } }
49+ transition = { { duration : 0.5 , ease : 'easeOut' } }
50+ >
51+ < ChatEntry hideName key = { message . id } entry = { message } />
52+ </ motion . div >
4053 ) ) }
41- </ div >
42- </ ChatMessageView >
43- ) }
54+ </ AnimatePresence >
55+ </ div >
56+ </ ChatMessageView >
4457
4558 < div className = "bg-background mp-12 fixed top-0 right-0 left-0 h-40" >
4659 { /* skrim */ }
4760 < div className = "from-background absolute bottom-0 left-0 h-12 w-full translate-y-full bg-gradient-to-b to-transparent" />
4861 </ div >
4962
50- < div
63+ < motion . div
5164 className = { cn (
52- 'bg-background fixed left-1/2 z-50 rounded-2xl border border-transparent p-8 transition-[left,top,transform, shadow,border] duration-500 ease-out' ,
53- chatOpen ? 'border-border top-24 drop-shadow-2xl/3' : 'top-1/2 '
65+ 'bg-background fixed left-1/2 z-50 -translate-1/2 rounded-2xl border border-transparent p-8 transition-[shadow,border] duration-500 ease-out' ,
66+ chatOpen && 'border-border drop-shadow-2xl/3'
5467 ) }
55- style = { {
56- transform : chatOpen
57- ? 'translate(-50%, -50%) scale(0.4)'
58- : 'translate(-50%, -50%) scale(1)' ,
68+ animate = { {
69+ top : chatOpen ? '96px' : '50%' ,
70+ scale : chatOpen ? 0.4 : 1 ,
5971 } }
72+ transition = { { type : 'spring' , damping : 18 } }
6073 >
6174 < AgentAudioTile />
62- </ div >
75+ </ motion . div >
6376
64- < div className = "bg-background appear-from-bottom fixed right-0 bottom-0 left-0 z-50 px-3 pb-3 delay-300 duration-300 ease-out md:px-12 md:pb-12" >
65- < div className = "relative mx-auto w-full max-w-2xl" >
66- < div
67- aria-hidden = { messages . length > 0 }
68- className = { cn (
69- 'appear-fade-in absolute inset-x-0 -top-12 delay-600 duration-2000 ease-in' ,
70- messages . length === 0 ? 'opacity-100' : '!opacity-0'
71- ) }
72- >
73- < p className = "animate-text-gradient from-foreground/20 via-foreground to-foreground/20 mx-auto bg-gradient-to-r bg-clip-text text-center text-sm font-semibold text-transparent" >
74- Agent is listening, ask it a question
75- </ p >
76- </ div >
77+ < div className = "bg-background fixed right-0 bottom-0 left-0 z-50 px-3 pb-3 md:px-12 md:pb-12" >
78+ < motion . div
79+ key = "control-bar"
80+ initial = { { opacity : 0 , translateY : '100%' } }
81+ animate = { {
82+ opacity : sessionStarted ? 1 : 0 ,
83+ translateY : sessionStarted ? '0%' : '100%' ,
84+ } }
85+ transition = { { duration : 0.3 , delay : sessionStarted ? 0.5 : 0 , ease : 'easeOut' } }
86+ >
87+ < div className = "relative mx-auto w-full max-w-2xl" >
88+ < motion . div
89+ initial = { { opacity : 0 } }
90+ animate = { {
91+ opacity : sessionStarted && messages . length === 0 ? 1 : 0 ,
92+ transition : {
93+ ease : 'easeIn' ,
94+ delay : messages . length > 0 ? 0 : 0.8 ,
95+ duration : messages . length > 0 ? 0.2 : 0.5 ,
96+ } ,
97+ } }
98+ aria-hidden = { messages . length > 0 }
99+ className = { cn ( 'absolute inset-x-0 -top-12' ) }
100+ >
101+ < p className = "animate-text-gradient from-foreground/20 via-foreground to-foreground/20 mx-auto bg-gradient-to-r bg-clip-text text-center text-sm font-semibold text-transparent" >
102+ Agent is listening, ask it a question
103+ </ p >
104+ </ motion . div >
77105
78- < AgentControlBar
79- capabilities = { capabilities }
80- onChatOpenChange = { setChatOpen }
81- onSendMessage = { handleSendMessage }
82- />
83- </ div >
84- { /* skrim */ }
85- < div className = "from-background border-background absolute top-0 left-0 h-12 w-full -translate-y-full border-b-8 bg-gradient-to-t to-transparent" />
106+ < AgentControlBar
107+ capabilities = { capabilities }
108+ onChatOpenChange = { setChatOpen }
109+ onSendMessage = { handleSendMessage }
110+ />
111+ </ div >
112+ { /* skrim */ }
113+ < div className = "from-background border-background absolute top-0 left-0 h-12 w-full -translate-y-full border-b-8 bg-gradient-to-t to-transparent" />
114+ </ motion . div >
86115 </ div >
87116 </ main >
88117 ) ;
0 commit comments