diff --git a/crates/agent/src/message_editor.rs b/crates/agent/src/message_editor.rs index 508c4e35b4..fa75d5beaf 100644 --- a/crates/agent/src/message_editor.rs +++ b/crates/agent/src/message_editor.rs @@ -200,7 +200,13 @@ impl MessageEditor { }); let profile_selector = cx.new(|cx| { - ProfileSelector::new(thread.clone(), thread_store, editor.focus_handle(cx), cx) + ProfileSelector::new( + fs, + thread.clone(), + thread_store, + editor.focus_handle(cx), + cx, + ) }); Self { diff --git a/crates/agent/src/profile_selector.rs b/crates/agent/src/profile_selector.rs index ae2aa5a160..9284fd2ee9 100644 --- a/crates/agent/src/profile_selector.rs +++ b/crates/agent/src/profile_selector.rs @@ -1,10 +1,13 @@ +use std::sync::Arc; + use assistant_settings::{ AgentProfile, AgentProfileId, AssistantDockPosition, AssistantSettings, GroupedAgentProfiles, builtin_profiles, }; +use fs::Fs; use gpui::{Action, Entity, FocusHandle, Subscription, WeakEntity, prelude::*}; use language_model::LanguageModelRegistry; -use settings::{Settings as _, SettingsStore}; +use settings::{Settings as _, SettingsStore, update_settings_file}; use ui::{ ContextMenu, ContextMenuEntry, DocumentationSide, PopoverMenu, PopoverMenuHandle, Tooltip, prelude::*, @@ -15,6 +18,7 @@ use crate::{ManageProfiles, Thread, ThreadStore, ToggleProfileSelector}; pub struct ProfileSelector { profiles: GroupedAgentProfiles, + fs: Arc, thread: Entity, thread_store: WeakEntity, menu_handle: PopoverMenuHandle, @@ -24,6 +28,7 @@ pub struct ProfileSelector { impl ProfileSelector { pub fn new( + fs: Arc, thread: Entity, thread_store: WeakEntity, focus_handle: FocusHandle, @@ -35,6 +40,7 @@ impl ProfileSelector { Self { profiles: GroupedAgentProfiles::from_settings(AssistantSettings::get_global(cx)), + fs, thread, thread_store, menu_handle: PopoverMenuHandle::default(), @@ -120,6 +126,7 @@ impl ProfileSelector { }; entry.handler({ + let fs = self.fs.clone(); let thread_store = self.thread_store.clone(); let profile_id = profile_id.clone(); let thread = self.thread.clone(); @@ -129,6 +136,13 @@ impl ProfileSelector { thread.set_configured_profile_id(Some(profile_id.clone()), cx); }); + update_settings_file::(fs.clone(), cx, { + let profile_id = profile_id.clone(); + move |settings, _cx| { + settings.set_profile(profile_id.clone()); + } + }); + thread_store .update(cx, |this, cx| { this.load_profile_by_id(profile_id.clone(), cx);