@@ -8,7 +8,7 @@ import { ChatInput } from "@/components/ui/chat/chat-input";
8
8
import { ChatMessageList } from "@/components/ui/chat/chat-message-list" ;
9
9
import { useTransition , animated , type AnimatedProps } from "@react-spring/web" ;
10
10
import { Paperclip , Send , X } from "lucide-react" ;
11
- import { useEffect , useRef , useState } from "react" ;
11
+ import { useEffect , useRef , useState , useCallback } from "react" ;
12
12
import type { Content , UUID } from "@elizaos/core" ;
13
13
import { useMutation , useQueryClient } from "@tanstack/react-query" ;
14
14
import { apiClient } from "@/lib/api" ;
@@ -49,12 +49,13 @@ export default function Page({ agentId }: { agentId: UUID }) {
49
49
const getMessageVariant = ( role : string ) =>
50
50
role !== "user" ? "received" : "sent" ;
51
51
52
- const scrollToBottom = ( ) => {
52
+ const scrollToBottom = useCallback ( ( ) => {
53
53
if ( messagesContainerRef . current ) {
54
54
messagesContainerRef . current . scrollTop =
55
55
messagesContainerRef . current . scrollHeight ;
56
56
}
57
- } ;
57
+ } , [ ] ) ;
58
+
58
59
useEffect ( ( ) => {
59
60
scrollToBottom ( ) ;
60
61
} , [ queryClient . getQueryData ( [ "messages" , agentId ] ) ] ) ;
@@ -153,7 +154,7 @@ export default function Page({ agentId }: { agentId: UUID }) {
153
154
154
155
const handleFileChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
155
156
const file = e . target . files ?. [ 0 ] ;
156
- if ( file && file . type . startsWith ( "image/" ) ) {
157
+ if ( file ? .type . startsWith ( "image/" ) ) {
157
158
setSelectedFile ( file ) ;
158
159
}
159
160
} ;
@@ -176,12 +177,12 @@ export default function Page({ agentId }: { agentId: UUID }) {
176
177
< div className = "flex flex-col w-full h-[calc(100dvh)] p-4" >
177
178
< div className = "flex-1 overflow-y-auto" >
178
179
< ChatMessageList ref = { messagesContainerRef } >
179
- { transitions ( ( styles , message ) => {
180
+ { transitions ( ( style , message : ContentWithUser ) => {
180
181
const variant = getMessageVariant ( message ?. user ) ;
181
182
return (
182
183
< CustomAnimatedDiv
183
184
style = { {
184
- ...styles ,
185
+ ...style ,
185
186
display : "flex" ,
186
187
flexDirection : "column" ,
187
188
gap : "0.5rem" ,
@@ -211,22 +212,21 @@ export default function Page({ agentId }: { agentId: UUID }) {
211
212
{ /* Attachments */ }
212
213
< div >
213
214
{ message ?. attachments ?. map (
214
- ( attachment , idx ) => (
215
+ ( attachment : IAttachment ) => (
215
216
< div
216
217
className = "flex flex-col gap-1 mt-2"
217
- key = { idx }
218
+ key = { ` ${ attachment . url } - ${ attachment . title } ` }
218
219
>
219
220
< img
220
- src = {
221
- attachment . url
222
- }
221
+ alt = "attachment"
222
+ src = { attachment . url }
223
223
width = "100%"
224
224
height = "100%"
225
225
className = "w-64 rounded-md"
226
226
/>
227
227
< div className = "flex items-center justify-between gap-4" >
228
- < span > </ span >
229
- < span > </ span >
228
+ < span / >
229
+ < span / >
230
230
</ div >
231
231
</ div >
232
232
)
@@ -298,6 +298,7 @@ export default function Page({ agentId }: { agentId: UUID }) {
298
298
< X />
299
299
</ Button >
300
300
< img
301
+ alt = "Selected file"
301
302
src = { URL . createObjectURL ( selectedFile ) }
302
303
height = "100%"
303
304
width = "100%"
0 commit comments