assistant: Improve language model selector design (#25036)
Closes https://github.com/zed-industries/zed/issues/23234 This PR adds a scrollbar to the model selector, and ensures no label (model and provider name) is cut off. Release Notes: - N/A
This commit is contained in:
parent
5eadeb67b0
commit
dc11a61ff8
1 changed files with 20 additions and 9 deletions
|
@ -41,7 +41,9 @@ impl LanguageModelSelector {
|
||||||
};
|
};
|
||||||
|
|
||||||
let picker = cx.new(|cx| {
|
let picker = cx.new(|cx| {
|
||||||
Picker::uniform_list(delegate, window, cx).max_height(Some(rems(20.).into()))
|
Picker::uniform_list(delegate, window, cx)
|
||||||
|
.show_scrollbar(true)
|
||||||
|
.max_height(Some(rems(20.).into()))
|
||||||
});
|
});
|
||||||
|
|
||||||
LanguageModelSelector {
|
LanguageModelSelector {
|
||||||
|
@ -305,7 +307,7 @@ impl PickerDelegate for LanguageModelPickerDelegate {
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
.mt_1()
|
.mt_1()
|
||||||
.mb_0p5()
|
.mb_0p5()
|
||||||
.ml_3()
|
.ml_2()
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -337,25 +339,34 @@ impl PickerDelegate for LanguageModelPickerDelegate {
|
||||||
let is_selected = Some(model_info.model.provider_id()) == active_provider_id
|
let is_selected = Some(model_info.model.provider_id()) == active_provider_id
|
||||||
&& Some(model_info.model.id()) == active_model_id;
|
&& Some(model_info.model.id()) == active_model_id;
|
||||||
|
|
||||||
|
let model_icon_color = if is_selected {
|
||||||
|
Color::Accent
|
||||||
|
} else {
|
||||||
|
Color::Muted
|
||||||
|
};
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
ListItem::new(ix)
|
ListItem::new(ix)
|
||||||
.inset(true)
|
.inset(true)
|
||||||
.spacing(ListItemSpacing::Sparse)
|
.spacing(ListItemSpacing::Sparse)
|
||||||
.toggle_state(selected)
|
.toggle_state(selected)
|
||||||
.start_slot(
|
.start_slot(
|
||||||
div().pr_0p5().child(
|
Icon::new(model_info.icon)
|
||||||
Icon::new(model_info.icon)
|
.color(model_icon_color)
|
||||||
.color(Color::Muted)
|
.size(IconSize::Small),
|
||||||
.size(IconSize::Medium),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.w_full()
|
.w_full()
|
||||||
.items_center()
|
.items_center()
|
||||||
.gap_1p5()
|
.gap_1p5()
|
||||||
.min_w(px(200.))
|
.pl_0p5()
|
||||||
.child(Label::new(model_info.model.name().0.clone()))
|
.min_w(px(240.))
|
||||||
|
.child(
|
||||||
|
div().max_w_40().child(
|
||||||
|
Label::new(model_info.model.name().0.clone()).text_ellipsis(),
|
||||||
|
),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_0p5()
|
.gap_0p5()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue