@@ -5,7 +5,10 @@ use fs::Fs;
5
5
use gpui:: { prelude:: * , Action , Entity , FocusHandle , Subscription , WeakEntity } ;
6
6
use indexmap:: IndexMap ;
7
7
use settings:: { update_settings_file, Settings as _, SettingsStore } ;
8
- use ui:: { prelude:: * , ContextMenu , ContextMenuEntry , PopoverMenu , PopoverMenuHandle , Tooltip } ;
8
+ use ui:: {
9
+ prelude:: * , ButtonLike , ContextMenu , ContextMenuEntry , KeyBinding , PopoverMenu ,
10
+ PopoverMenuHandle ,
11
+ } ;
9
12
use util:: ResultExt as _;
10
13
11
14
use crate :: { ManageProfiles , ThreadStore , ToggleProfileSelector } ;
@@ -60,7 +63,7 @@ impl ProfileSelector {
60
63
) -> Entity < ContextMenu > {
61
64
ContextMenu :: build ( window, cx, |mut menu, _window, cx| {
62
65
let settings = AssistantSettings :: get_global ( cx) ;
63
- let icon_position = IconPosition :: Start ;
66
+ let icon_position = IconPosition :: End ;
64
67
65
68
menu = menu. header ( "Profiles" ) ;
66
69
for ( profile_id, profile) in self . profiles . clone ( ) {
@@ -91,48 +94,65 @@ impl ProfileSelector {
91
94
}
92
95
93
96
menu = menu. separator ( ) ;
94
- menu = menu. item (
95
- ContextMenuEntry :: new ( "Configure Profiles" )
96
- . icon ( IconName :: Pencil )
97
- . icon_color ( Color :: Muted )
98
- . handler ( move |window, cx| {
99
- window. dispatch_action ( ManageProfiles . boxed_clone ( ) , cx) ;
100
- } ) ,
101
- ) ;
97
+ menu = menu. item ( ContextMenuEntry :: new ( "Configure Profiles" ) . handler (
98
+ move |window, cx| {
99
+ window. dispatch_action ( ManageProfiles . boxed_clone ( ) , cx) ;
100
+ } ,
101
+ ) ) ;
102
102
103
103
menu
104
104
} )
105
105
}
106
106
}
107
107
108
108
impl Render for ProfileSelector {
109
- fn render ( & mut self , _window : & mut Window , cx : & mut Context < Self > ) -> impl IntoElement {
109
+ fn render ( & mut self , window : & mut Window , cx : & mut Context < Self > ) -> impl IntoElement {
110
110
let settings = AssistantSettings :: get_global ( cx) ;
111
- let profile = settings
112
- . profiles
113
- . get ( & settings. default_profile )
111
+ let profile_id = & settings. default_profile ;
112
+ let profile = settings. profiles . get ( profile_id) ;
113
+
114
+ let selected_profile = profile
114
115
. map ( |profile| profile. name . clone ( ) )
115
116
. unwrap_or_else ( || "Unknown" . into ( ) ) ;
116
117
118
+ let icon = match profile_id. as_ref ( ) {
119
+ "write" => IconName :: Pencil ,
120
+ "ask" => IconName :: MessageBubbles ,
121
+ _ => IconName :: UserRoundPen ,
122
+ } ;
123
+
117
124
let this = cx. entity ( ) . clone ( ) ;
118
125
let focus_handle = self . focus_handle . clone ( ) ;
119
126
PopoverMenu :: new ( "profile-selector" )
120
127
. menu ( move |window, cx| {
121
128
Some ( this. update ( cx, |this, cx| this. build_context_menu ( window, cx) ) )
122
129
} )
123
- . trigger_with_tooltip (
124
- Button :: new ( "profile-selector-button" , profile)
125
- . style ( ButtonStyle :: Filled )
126
- . label_size ( LabelSize :: Small ) ,
127
- move |window, cx| {
128
- Tooltip :: for_action_in (
129
- "Change Profile" ,
130
- & ToggleProfileSelector ,
131
- & focus_handle,
132
- window,
133
- cx,
134
- )
135
- } ,
130
+ . trigger (
131
+ ButtonLike :: new ( "profile-selector-button" ) . child (
132
+ h_flex ( )
133
+ . gap_1 ( )
134
+ . child ( Icon :: new ( icon) . size ( IconSize :: XSmall ) . color ( Color :: Muted ) )
135
+ . child (
136
+ Label :: new ( selected_profile)
137
+ . size ( LabelSize :: Small )
138
+ . color ( Color :: Muted ) ,
139
+ )
140
+ . child (
141
+ Icon :: new ( IconName :: ChevronDown )
142
+ . size ( IconSize :: XSmall )
143
+ . color ( Color :: Muted ) ,
144
+ )
145
+ . child ( div ( ) . opacity ( 0.5 ) . children ( {
146
+ let focus_handle = focus_handle. clone ( ) ;
147
+ KeyBinding :: for_action_in (
148
+ & ToggleProfileSelector ,
149
+ & focus_handle,
150
+ window,
151
+ cx,
152
+ )
153
+ . map ( |kb| kb. size ( rems_from_px ( 10. ) ) )
154
+ } ) ) ,
155
+ ) ,
136
156
)
137
157
. anchor ( gpui:: Corner :: BottomLeft )
138
158
. with_handle ( self . menu_handle . clone ( ) )
0 commit comments