assistant-panel: Update model selector to a combo-box (#15693)

This updates the model selector to be a combobox (filterable list)

This PR causes the following regression: There is no longer a message in
the inline assistant explaining context is included from the assistant
panel. Will follow up with some sort of solution soon.

Before:
![CleanShot 2024-08-02 at 13 11
12@2x](https://github.com/user-attachments/assets/648ec4e3-48bc-4720-aaad-7659d848a4fa)

After:
![CleanShot 2024-08-02 at 13 10
37@2x](https://github.com/user-attachments/assets/09de098b-1a4a-44be-a6ae-6879f233d9a4)
![CleanShot 2024-08-02 at 13 10
48@2x](https://github.com/user-attachments/assets/701ce01c-3d6c-4c63-a6fc-53deff5d56c7)

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
Nate Butler 2024-08-05 11:52:07 -04:00 committed by GitHub
parent f11f3f2599
commit 03cc18dd20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 472 additions and 189 deletions

View file

@ -2801,21 +2801,19 @@ pub struct ContextEditorToolbarItem {
fs: Arc<dyn Fs>,
workspace: WeakView<Workspace>,
active_context_editor: Option<WeakView<ContextEditor>>,
model_selector_menu_handle: PopoverMenuHandle<ContextMenu>,
model_summary_editor: View<Editor>,
}
impl ContextEditorToolbarItem {
pub fn new(
workspace: &Workspace,
model_selector_menu_handle: PopoverMenuHandle<ContextMenu>,
_model_selector_menu_handle: PopoverMenuHandle<ContextMenu>,
model_summary_editor: View<Editor>,
) -> Self {
Self {
fs: workspace.app_state().fs.clone(),
workspace: workspace.weak_handle(),
active_context_editor: None,
model_selector_menu_handle,
model_summary_editor,
}
}
@ -2946,49 +2944,46 @@ impl Render for ContextEditorToolbarItem {
});
let right_side = h_flex()
.gap_2()
.child(
ModelSelector::new(
self.fs.clone(),
ButtonLike::new("active-model")
.style(ButtonStyle::Subtle)
.child(
h_flex()
.w_full()
.gap_0p5()
.child(
div()
.overflow_x_hidden()
.flex_grow()
.whitespace_nowrap()
.child(
Label::new(
LanguageModelRegistry::read_global(cx)
.active_model()
.map(|model| {
format!(
"{}: {}",
model.provider_name().0,
model.name().0
)
})
.unwrap_or_else(|| "No model selected".into()),
)
.size(LabelSize::Small)
.color(Color::Muted),
),
)
.child(
Icon::new(IconName::ChevronDown)
.color(Color::Muted)
.size(IconSize::XSmall),
),
)
.tooltip(move |cx| {
Tooltip::for_action("Change Model", &ToggleModelSelector, cx)
}),
)
.with_handle(self.model_selector_menu_handle.clone()),
)
.child(ModelSelector::new(
self.fs.clone(),
ButtonLike::new("active-model")
.style(ButtonStyle::Subtle)
.child(
h_flex()
.w_full()
.gap_0p5()
.child(
div()
.overflow_x_hidden()
.flex_grow()
.whitespace_nowrap()
.child(
Label::new(
LanguageModelRegistry::read_global(cx)
.active_model()
.map(|model| {
format!(
"{}: {}",
model.provider_name().0,
model.name().0
)
})
.unwrap_or_else(|| "No model selected".into()),
)
.size(LabelSize::Small)
.color(Color::Muted),
),
)
.child(
Icon::new(IconName::ChevronDown)
.color(Color::Muted)
.size(IconSize::XSmall),
),
)
.tooltip(move |cx| {
Tooltip::for_action("Change Model", &ToggleModelSelector, cx)
}),
))
.children(self.render_remaining_tokens(cx))
.child(self.render_inject_context_menu(cx));