@@ -38,6 +38,32 @@ const getStatusText = (status?: string, error?: string) => {
38
38
return 'Tool call'
39
39
}
40
40
41
+ const getColorClasses = ( status ?: string , error ?: string ) => {
42
+ // Red for failed/error states
43
+ if ( error || status ?. includes ( 'failed' ) ) {
44
+ return {
45
+ icon : 'bg-red-100 text-red-600 dark:bg-red-900 dark:text-red-300' ,
46
+ content : 'bg-red-50 text-red-900 dark:bg-red-950 dark:text-red-100' ,
47
+ }
48
+ }
49
+
50
+ // Green for completed/done states
51
+ if ( status ?. includes ( 'completed' ) || status ?. includes ( 'done' ) ) {
52
+ return {
53
+ icon : 'bg-green-100 text-green-600 dark:bg-green-900 dark:text-green-300' ,
54
+ content :
55
+ 'bg-green-50 text-green-900 dark:bg-green-950 dark:text-green-100' ,
56
+ }
57
+ }
58
+
59
+ // Yellow for loading/working states (in progress, preparing, etc.)
60
+ return {
61
+ icon : 'bg-yellow-100 text-yellow-600 dark:bg-yellow-900 dark:text-yellow-300' ,
62
+ content :
63
+ 'bg-yellow-50 text-yellow-900 dark:bg-yellow-950 dark:text-yellow-100' ,
64
+ }
65
+ }
66
+
41
67
const getTitle = ( name : string , args : ToolCallMessageProps [ 'args' ] ) => {
42
68
// For tool calls, include the tool name if available
43
69
if ( args . toolName ) {
@@ -51,14 +77,20 @@ const getTitle = (name: string, args: ToolCallMessageProps['args']) => {
51
77
}
52
78
53
79
export function ToolCallMessage ( { name, args } : ToolCallMessageProps ) {
80
+ const colorClasses = getColorClasses ( args . status , args . error )
81
+
54
82
return (
55
83
< div className = "flex w-full max-w-full gap-2 py-2 animate-in fade-in justify-start" >
56
- < div className = "flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md bg-orange-100 text-orange-600 dark:bg-orange-900 dark:text-orange-300" >
84
+ < div
85
+ className = { `flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md ${ colorClasses . icon } ` }
86
+ >
57
87
< Wrench className = "h-5 w-5" />
58
88
</ div >
59
89
60
90
< div className = "flex flex-col space-y-1 items-start w-full sm:w-[85%] md:w-[75%] lg:w-[65%]" >
61
- < details className = "rounded-2xl px-4 py-2 text-sm w-full group [&:not([open])]:h-8 [&:not([open])]:flex [&:not([open])]:items-center [&:not([open])]:py-0 bg-orange-50 text-orange-900 dark:bg-orange-950 dark:text-orange-100" >
91
+ < details
92
+ className = { `rounded-2xl px-4 py-2 text-sm w-full group [&:not([open])]:h-8 [&:not([open])]:flex [&:not([open])]:items-center [&:not([open])]:py-0 ${ colorClasses . content } ` }
93
+ >
62
94
< summary className = "font-medium mb-1 flex items-center gap-2 list-none [&::-webkit-details-marker]:hidden cursor-pointer group-[&:not([open])]:mb-0" >
63
95
< ChevronRight className = "h-4 w-4 transition-transform group-open:rotate-90" />
64
96
{ getTitle ( name , args ) }
0 commit comments