@@ -5,11 +5,13 @@ import { ToolTip } from "../../../components/gui/Tooltip";
5
5
import { Button , Card , Divider , EmptyState } from "../../../components/ui" ;
6
6
import { useAuth } from "../../../context/Auth" ;
7
7
import { IdeMessengerContext } from "../../../context/IdeMessenger" ;
8
+ import { useAppSelector } from "../../../redux/hooks" ;
8
9
import { ConfigHeader } from "../components/ConfigHeader" ;
9
10
10
11
export function AgentsSection ( ) {
11
- const { profiles } = useAuth ( ) ;
12
+ const { profiles, selectedProfile } = useAuth ( ) ;
12
13
const ideMessenger = useContext ( IdeMessengerContext ) ;
14
+ const configError = useAppSelector ( ( state ) => state . config . configError ) ;
13
15
14
16
function handleAddAgent ( ) {
15
17
void ideMessenger . request ( "config/newAssistantFile" , undefined ) ;
@@ -29,47 +31,51 @@ export function AgentsSection() {
29
31
30
32
< Card >
31
33
{ profiles && profiles . length > 0 ? (
32
- profiles . map ( ( profile , index ) => (
33
- < div key = { profile . id } >
34
- < div className = "flex items-center justify-between" >
35
- < div className = "flex items-baseline gap-3" >
36
- < div className = "flex h-6 w-6 flex-shrink-0 items-center justify-center" >
37
- < AssistantIcon assistant = { profile } />
34
+ profiles . map ( ( profile , index ) => {
35
+ const isSelected = profile . id === selectedProfile ?. id ;
36
+ const errors = isSelected ? configError : profile . errors ;
37
+ return (
38
+ < div key = { profile . id } >
39
+ < div className = "flex items-center justify-between" >
40
+ < div className = "flex items-baseline gap-3" >
41
+ < div className = "flex h-6 w-6 flex-shrink-0 items-center justify-center" >
42
+ < AssistantIcon assistant = { profile } />
43
+ </ div >
44
+ < div className = "flex-1" >
45
+ < h3
46
+ className = { `my-2 text-sm font-medium ${ errors && errors . length > 0 ? "text-error" : "" } ` }
47
+ >
48
+ { profile . title }
49
+ </ h3 >
50
+ { errors && errors . length > 0 && (
51
+ < div className = "mt-2 space-y-1" >
52
+ { errors . map ( ( error , errorIndex ) => (
53
+ < div
54
+ key = { errorIndex }
55
+ className = "text-error bg-error/10 rounded py-1 pr-2 text-xs"
56
+ >
57
+ { error . message }
58
+ </ div >
59
+ ) ) }
60
+ </ div >
61
+ ) }
62
+ </ div >
38
63
</ div >
39
- < div className = "flex-1" >
40
- < h3
41
- className = { `my-2 text-sm font-medium ${ profile . errors && profile . errors . length > 0 ? "text-error" : "" } ` }
64
+ < ToolTip content = "Configure agent" >
65
+ < Button
66
+ onClick = { ( ) => handleConfigureAgent ( profile . id ) }
67
+ variant = "ghost"
68
+ size = "sm"
69
+ className = "text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
42
70
>
43
- { profile . title }
44
- </ h3 >
45
- { profile . errors && profile . errors . length > 0 && (
46
- < div className = "mt-2 space-y-1" >
47
- { profile . errors . map ( ( error , errorIndex ) => (
48
- < div
49
- key = { errorIndex }
50
- className = "text-error bg-error/10 rounded py-1 pr-2 text-xs"
51
- >
52
- { error . message }
53
- </ div >
54
- ) ) }
55
- </ div >
56
- ) }
57
- </ div >
71
+ < Cog6ToothIcon className = "h-4 w-4 flex-shrink-0" />
72
+ </ Button >
73
+ </ ToolTip >
58
74
</ div >
59
- < ToolTip content = "Configure agent" >
60
- < Button
61
- onClick = { ( ) => handleConfigureAgent ( profile . id ) }
62
- variant = "ghost"
63
- size = "sm"
64
- className = "text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
65
- >
66
- < Cog6ToothIcon className = "h-4 w-4 flex-shrink-0" />
67
- </ Button >
68
- </ ToolTip >
75
+ { index < profiles . length - 1 && < Divider /> }
69
76
</ div >
70
- { index < profiles . length - 1 && < Divider /> }
71
- </ div >
72
- ) )
77
+ ) ;
78
+ } )
73
79
) : (
74
80
< EmptyState message = "No agents configured. Click the + button to add your first agent." />
75
81
) }
0 commit comments