assistant2: Order agent profiles in the order they are defined in settings (#27255)

This PR updates the ordering of the agent profiles in the tool selector
to respect the order they are defined in in the settings instead of
sorting them alphabetically.

This gives the user more control, and allows them to order the profiles
as they desire.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-03-21 11:38:02 -04:00 committed by GitHub
parent 6397872c49
commit 0de5c2ed53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 17 additions and 15 deletions

View file

@ -2,14 +2,14 @@ use std::sync::Arc;
use assistant_settings::{AgentProfile, AssistantSettings};
use assistant_tool::{ToolSource, ToolWorkingSet};
use collections::BTreeMap;
use gpui::{Entity, Subscription};
use indexmap::IndexMap;
use scripting_tool::ScriptingTool;
use settings::{Settings as _, SettingsStore};
use ui::{prelude::*, ContextMenu, PopoverMenu, Tooltip};
pub struct ToolSelector {
profiles: BTreeMap<Arc<str>, AgentProfile>,
profiles: IndexMap<Arc<str>, AgentProfile>,
tools: Arc<ToolWorkingSet>,
_subscriptions: Vec<Subscription>,
}
@ -21,7 +21,7 @@ impl ToolSelector {
});
let mut this = Self {
profiles: BTreeMap::default(),
profiles: IndexMap::default(),
tools,
_subscriptions: vec![settings_subscription],
};
@ -33,7 +33,7 @@ impl ToolSelector {
fn refresh_profiles(&mut self, cx: &mut Context<Self>) {
let settings = AssistantSettings::get_global(cx);
self.profiles = BTreeMap::from_iter(settings.profiles.clone());
self.profiles = settings.profiles.clone();
}
fn build_context_menu(