@@ -15,7 +15,16 @@ import type { IAttachment } from '@/types';
15
15
import type { Content , UUID } from '@elizaos/core' ;
16
16
import { AgentStatus } from '@elizaos/core' ;
17
17
import { useQueryClient } from '@tanstack/react-query' ;
18
- import { Activity , Database , PanelRight , Paperclip , Send , Terminal , X } from 'lucide-react' ;
18
+ import {
19
+ Activity ,
20
+ ChevronRight ,
21
+ Database ,
22
+ PanelRight ,
23
+ Paperclip ,
24
+ Send ,
25
+ Terminal ,
26
+ X ,
27
+ } from 'lucide-react' ;
19
28
import { useEffect , useRef , useState , useCallback } from 'react' ;
20
29
import AIWriter from 'react-aiwriter' ;
21
30
import { AgentActionViewer } from './action-viewer' ;
@@ -29,6 +38,7 @@ import { useAutoScroll } from './ui/chat/hooks/useAutoScroll';
29
38
import { Tabs , TabsContent , TabsList , TabsTrigger } from './ui/tabs' ;
30
39
import { Tooltip , TooltipContent , TooltipTrigger } from './ui/tooltip' ;
31
40
import { AgentMemoryViewer } from './memory-viewer' ;
41
+ import { Collapsible , CollapsibleContent , CollapsibleTrigger } from '@radix-ui/react-collapsible' ;
32
42
33
43
const SOURCE_NAME = 'client_chat' ;
34
44
@@ -49,6 +59,7 @@ function MessageContent({
49
59
agentId : UUID ;
50
60
isLastMessage : boolean ;
51
61
} ) {
62
+ console . log ( 'message' , message ) ;
52
63
// Only log message details in development mode
53
64
if ( import . meta. env . DEV ) {
54
65
console . log ( `[Chat] Rendering message from ${ message . name } :` , {
@@ -60,58 +71,88 @@ function MessageContent({
60
71
}
61
72
62
73
return (
63
- < div className = "flex flex-col" >
64
- < ChatBubbleMessage
65
- isLoading = { message . isLoading }
66
- { ...( message . name === USER_NAME ? { variant : 'sent' } : { } ) }
67
- >
68
- { message . name === USER_NAME ? (
69
- message . text
70
- ) : isLastMessage && message . name !== USER_NAME ? (
71
- < AIWriter > { message . text } </ AIWriter >
72
- ) : (
73
- message . text
74
- ) }
75
- { /* Attachments */ }
76
- < div >
77
- { message . attachments ?. map ( ( attachment : IAttachment ) => (
78
- < div className = "flex flex-col gap-1 mt-2" key = { `${ attachment . url } -${ attachment . title } ` } >
79
- < img
80
- alt = "attachment"
81
- src = { attachment . url }
82
- width = "100%"
83
- height = "100%"
84
- className = "w-64 rounded-md"
85
- />
86
- < div className = "flex items-center justify-between gap-4" >
87
- < span />
88
- < span />
89
- </ div >
74
+ < ChatBubbleMessage
75
+ isLoading = { message . isLoading }
76
+ { ...( message . name === USER_NAME ? { variant : 'sent' } : { } ) }
77
+ { ...( ! message . text ? { className : 'bg-transparent' } : { } ) }
78
+ >
79
+ < div className = "flex flex-col w-full m-0 p-0" >
80
+ { message . name !== USER_NAME && (
81
+ < >
82
+ < div className = "flex justify-end mb-2 absolute top-2 right-2" >
83
+ { message . text && ! message . isLoading ? (
84
+ < div className = "flex items-center gap-4" >
85
+ < CopyButton text = { message . text } />
86
+ < ChatTtsButton agentId = { agentId } text = { message . text } />
87
+ </ div >
88
+ ) : (
89
+ < div />
90
+ ) }
90
91
</ div >
91
- ) ) }
92
+ { message . text && message . thought && (
93
+ < Collapsible className = "mb-1" >
94
+ < CollapsibleTrigger className = "flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors group" >
95
+ < ChevronRight className = "h-4 w-4 transition-transform group-data-[state=open]:rotate-90" />
96
+ Thought Process
97
+ </ CollapsibleTrigger >
98
+ < CollapsibleContent className = "pl-5 pt-1" >
99
+ < Badge variant = "outline" className = "text-xs" >
100
+ { message . thought }
101
+ </ Badge >
102
+ </ CollapsibleContent >
103
+ </ Collapsible >
104
+ ) }
105
+ </ >
106
+ ) }
107
+ </ div >
108
+
109
+ { message . name === USER_NAME ? (
110
+ message . text
111
+ ) : isLastMessage && message . name !== USER_NAME ? (
112
+ < AIWriter > { message . text } </ AIWriter >
113
+ ) : (
114
+ message . text
115
+ ) }
116
+
117
+ { ! message . text && message . thought && (
118
+ < >
119
+ { message . name === USER_NAME ? (
120
+ message . thought
121
+ ) : isLastMessage && message . name !== USER_NAME ? (
122
+ < AIWriter >
123
+ < span className = "italic text-muted-foreground" > { message . thought } </ span >
124
+ </ AIWriter >
125
+ ) : (
126
+ < span className = "italic text-muted-foreground" > { message . thought } </ span >
127
+ ) }
128
+ </ >
129
+ ) }
130
+
131
+ { message . text && message . actions && (
132
+ < div className = "mt-2" >
133
+ Actions: < span className = "font-bold" > { message . actions } </ span >
92
134
</ div >
93
- </ ChatBubbleMessage >
94
- < div className = "flex items-center gap-4 justify-between w-full mt-1" >
95
- { message . text && ! message . isLoading ? (
96
- < div className = "flex items-center gap-1" >
97
- < CopyButton text = { message . text } />
98
- < ChatTtsButton agentId = { agentId } text = { message . text } />
135
+ ) }
136
+
137
+ { message . attachments ?. map ( ( attachment : IAttachment ) => (
138
+ < div className = "flex flex-col gap-1" key = { `${ attachment . url } -${ attachment . title } ` } >
139
+ < img
140
+ alt = "attachment"
141
+ src = { attachment . url }
142
+ width = "100%"
143
+ height = "100%"
144
+ className = "w-64 rounded-md"
145
+ />
146
+ < div className = "flex items-center justify-between gap-4" >
147
+ < span />
148
+ < span />
99
149
</ div >
100
- ) : null }
101
- < div
102
- className = { cn ( [
103
- message . isLoading ? 'mt-2' : '' ,
104
- 'flex items-center justify-between gap-4 select-none' ,
105
- ] ) }
106
- >
107
- { message . thought ? < Badge variant = "outline" > { message . thought } </ Badge > : null }
108
- { message . plan ? < Badge variant = "outline" > { message . plan } </ Badge > : null }
109
- { message . createdAt ? (
110
- < ChatBubbleTimestamp timestamp = { moment ( message . createdAt ) . format ( 'LT' ) } />
111
- ) : null }
112
150
</ div >
113
- </ div >
114
- </ div >
151
+ ) ) }
152
+ { message . text && message . createdAt && (
153
+ < ChatBubbleTimestamp timestamp = { moment ( message . createdAt ) . format ( 'LT' ) } />
154
+ ) }
155
+ </ ChatBubbleMessage >
115
156
) ;
116
157
}
117
158
@@ -412,23 +453,22 @@ export default function Page({ agentId }: { agentId: UUID }) {
412
453
>
413
454
< ChatBubble
414
455
variant = { isUser ? 'sent' : 'received' }
415
- className = { `flex flex-row items-center gap-2 ${
416
- isUser ? 'flex-row-reverse' : ''
417
- } `}
456
+ className = { `flex flex-row items-end gap-2 ${ isUser ? 'flex-row-reverse' : '' } ` }
418
457
>
419
- < Avatar className = "size-8 border rounded-full select-none" >
420
- < AvatarImage
421
- src = {
422
- isUser
423
- ? '/user-icon.png'
424
- : agentData ?. settings ?. avatar
425
- ? agentData ?. settings ?. avatar
426
- : '/elizaos-icon.png'
427
- }
428
- />
458
+ { message . text && ! isUser && (
459
+ < Avatar className = "size-8 border rounded-full select-none mb-2" >
460
+ < AvatarImage
461
+ src = {
462
+ isUser
463
+ ? '/user-icon.png'
464
+ : agentData ?. settings ?. avatar
465
+ ? agentData ?. settings ?. avatar
466
+ : '/elizaos-icon.png'
467
+ }
468
+ />
469
+ </ Avatar >
470
+ ) }
429
471
430
- { isUser && < AvatarFallback > U</ AvatarFallback > }
431
- </ Avatar >
432
472
< MessageContent
433
473
message = { message }
434
474
agentId = { agentId }
0 commit comments