agent: write latest profile change to default setting (#30408)
Reverts back to previous behavior where we update your settings so we can load a new thread from your last configuration. Release Notes: - agent: Persist profile changes for new threads
This commit is contained in:
parent
cf8f003916
commit
1dfddf0a29
2 changed files with 22 additions and 2 deletions
|
@ -200,7 +200,13 @@ impl MessageEditor {
|
||||||
});
|
});
|
||||||
|
|
||||||
let profile_selector = cx.new(|cx| {
|
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 {
|
Self {
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use assistant_settings::{
|
use assistant_settings::{
|
||||||
AgentProfile, AgentProfileId, AssistantDockPosition, AssistantSettings, GroupedAgentProfiles,
|
AgentProfile, AgentProfileId, AssistantDockPosition, AssistantSettings, GroupedAgentProfiles,
|
||||||
builtin_profiles,
|
builtin_profiles,
|
||||||
};
|
};
|
||||||
|
use fs::Fs;
|
||||||
use gpui::{Action, Entity, FocusHandle, Subscription, WeakEntity, prelude::*};
|
use gpui::{Action, Entity, FocusHandle, Subscription, WeakEntity, prelude::*};
|
||||||
use language_model::LanguageModelRegistry;
|
use language_model::LanguageModelRegistry;
|
||||||
use settings::{Settings as _, SettingsStore};
|
use settings::{Settings as _, SettingsStore, update_settings_file};
|
||||||
use ui::{
|
use ui::{
|
||||||
ContextMenu, ContextMenuEntry, DocumentationSide, PopoverMenu, PopoverMenuHandle, Tooltip,
|
ContextMenu, ContextMenuEntry, DocumentationSide, PopoverMenu, PopoverMenuHandle, Tooltip,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
@ -15,6 +18,7 @@ use crate::{ManageProfiles, Thread, ThreadStore, ToggleProfileSelector};
|
||||||
|
|
||||||
pub struct ProfileSelector {
|
pub struct ProfileSelector {
|
||||||
profiles: GroupedAgentProfiles,
|
profiles: GroupedAgentProfiles,
|
||||||
|
fs: Arc<dyn Fs>,
|
||||||
thread: Entity<Thread>,
|
thread: Entity<Thread>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
thread_store: WeakEntity<ThreadStore>,
|
||||||
menu_handle: PopoverMenuHandle<ContextMenu>,
|
menu_handle: PopoverMenuHandle<ContextMenu>,
|
||||||
|
@ -24,6 +28,7 @@ pub struct ProfileSelector {
|
||||||
|
|
||||||
impl ProfileSelector {
|
impl ProfileSelector {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
fs: Arc<dyn Fs>,
|
||||||
thread: Entity<Thread>,
|
thread: Entity<Thread>,
|
||||||
thread_store: WeakEntity<ThreadStore>,
|
thread_store: WeakEntity<ThreadStore>,
|
||||||
focus_handle: FocusHandle,
|
focus_handle: FocusHandle,
|
||||||
|
@ -35,6 +40,7 @@ impl ProfileSelector {
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
profiles: GroupedAgentProfiles::from_settings(AssistantSettings::get_global(cx)),
|
profiles: GroupedAgentProfiles::from_settings(AssistantSettings::get_global(cx)),
|
||||||
|
fs,
|
||||||
thread,
|
thread,
|
||||||
thread_store,
|
thread_store,
|
||||||
menu_handle: PopoverMenuHandle::default(),
|
menu_handle: PopoverMenuHandle::default(),
|
||||||
|
@ -120,6 +126,7 @@ impl ProfileSelector {
|
||||||
};
|
};
|
||||||
|
|
||||||
entry.handler({
|
entry.handler({
|
||||||
|
let fs = self.fs.clone();
|
||||||
let thread_store = self.thread_store.clone();
|
let thread_store = self.thread_store.clone();
|
||||||
let profile_id = profile_id.clone();
|
let profile_id = profile_id.clone();
|
||||||
let thread = self.thread.clone();
|
let thread = self.thread.clone();
|
||||||
|
@ -129,6 +136,13 @@ impl ProfileSelector {
|
||||||
thread.set_configured_profile_id(Some(profile_id.clone()), cx);
|
thread.set_configured_profile_id(Some(profile_id.clone()), cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
update_settings_file::<AssistantSettings>(fs.clone(), cx, {
|
||||||
|
let profile_id = profile_id.clone();
|
||||||
|
move |settings, _cx| {
|
||||||
|
settings.set_profile(profile_id.clone());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
thread_store
|
thread_store
|
||||||
.update(cx, |this, cx| {
|
.update(cx, |this, cx| {
|
||||||
this.load_profile_by_id(profile_id.clone(), cx);
|
this.load_profile_by_id(profile_id.clone(), cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue