Revert "Load Profile state from Thread and tie visibility to the thread's model" (#30413)
This reverts commit 3615d6d96c
.
Ultimately, we want to restore the ability to store a profile
per-thread, but for now reverting this fixes a fairly disruptive bug.
Release Notes:
- Fixed a bug causing the agent to use the wrong profile in some cases.
This commit is contained in:
parent
8f07135201
commit
d6ab416168
3 changed files with 6 additions and 44 deletions
|
@ -101,7 +101,7 @@ impl ProfileSelector {
|
||||||
profile_id: AgentProfileId,
|
profile_id: AgentProfileId,
|
||||||
profile: &AgentProfile,
|
profile: &AgentProfile,
|
||||||
settings: &AssistantSettings,
|
settings: &AssistantSettings,
|
||||||
cx: &App,
|
_cx: &App,
|
||||||
) -> ContextMenuEntry {
|
) -> ContextMenuEntry {
|
||||||
let documentation = match profile.name.to_lowercase().as_str() {
|
let documentation = match profile.name.to_lowercase().as_str() {
|
||||||
builtin_profiles::WRITE => Some("Get help to write anything."),
|
builtin_profiles::WRITE => Some("Get help to write anything."),
|
||||||
|
@ -110,12 +110,8 @@ impl ProfileSelector {
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let current_profile_id = self.thread.read(cx).configured_profile_id();
|
let entry = ContextMenuEntry::new(profile.name.clone())
|
||||||
|
.toggleable(IconPosition::End, profile_id == settings.default_profile);
|
||||||
let entry = ContextMenuEntry::new(profile.name.clone()).toggleable(
|
|
||||||
IconPosition::End,
|
|
||||||
Some(profile_id.clone()) == current_profile_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
let entry = if let Some(doc_text) = documentation {
|
let entry = if let Some(doc_text) = documentation {
|
||||||
entry.documentation_aside(documentation_side(settings.dock), move |_| {
|
entry.documentation_aside(documentation_side(settings.dock), move |_| {
|
||||||
|
@ -129,13 +125,7 @@ impl ProfileSelector {
|
||||||
let fs = self.fs.clone();
|
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();
|
|
||||||
|
|
||||||
move |_window, cx| {
|
move |_window, cx| {
|
||||||
thread.update(cx, |thread, cx| {
|
|
||||||
thread.set_configured_profile_id(Some(profile_id.clone()), cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
update_settings_file::<AssistantSettings>(fs.clone(), cx, {
|
update_settings_file::<AssistantSettings>(fs.clone(), cx, {
|
||||||
let profile_id = profile_id.clone();
|
let profile_id = profile_id.clone();
|
||||||
move |settings, _cx| {
|
move |settings, _cx| {
|
||||||
|
@ -156,12 +146,8 @@ impl ProfileSelector {
|
||||||
impl Render for ProfileSelector {
|
impl Render for ProfileSelector {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let settings = AssistantSettings::get_global(cx);
|
let settings = AssistantSettings::get_global(cx);
|
||||||
let profile_id = self
|
let profile_id = &settings.default_profile;
|
||||||
.thread
|
let profile = settings.profiles.get(profile_id);
|
||||||
.read(cx)
|
|
||||||
.configured_profile_id()
|
|
||||||
.unwrap_or(settings.default_profile.clone());
|
|
||||||
let profile = settings.profiles.get(&profile_id).cloned();
|
|
||||||
|
|
||||||
let selected_profile = profile
|
let selected_profile = profile
|
||||||
.map(|profile| profile.name.clone())
|
.map(|profile| profile.name.clone())
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
use assistant_settings::{AgentProfileId, AssistantSettings, CompletionMode};
|
use assistant_settings::{AssistantSettings, CompletionMode};
|
||||||
use assistant_tool::{ActionLog, AnyToolCard, Tool, ToolWorkingSet};
|
use assistant_tool::{ActionLog, AnyToolCard, Tool, ToolWorkingSet};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
|
@ -359,7 +359,6 @@ pub struct Thread {
|
||||||
>,
|
>,
|
||||||
remaining_turns: u32,
|
remaining_turns: u32,
|
||||||
configured_model: Option<ConfiguredModel>,
|
configured_model: Option<ConfiguredModel>,
|
||||||
configured_profile_id: Option<AgentProfileId>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -380,8 +379,6 @@ impl Thread {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let (detailed_summary_tx, detailed_summary_rx) = postage::watch::channel();
|
let (detailed_summary_tx, detailed_summary_rx) = postage::watch::channel();
|
||||||
let configured_model = LanguageModelRegistry::read_global(cx).default_model();
|
let configured_model = LanguageModelRegistry::read_global(cx).default_model();
|
||||||
let assistant_settings = AssistantSettings::get_global(cx);
|
|
||||||
let configured_profile_id = assistant_settings.default_profile.clone();
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id: ThreadId::new(),
|
id: ThreadId::new(),
|
||||||
|
@ -424,7 +421,6 @@ impl Thread {
|
||||||
request_callback: None,
|
request_callback: None,
|
||||||
remaining_turns: u32::MAX,
|
remaining_turns: u32::MAX,
|
||||||
configured_model,
|
configured_model,
|
||||||
configured_profile_id: Some(configured_profile_id),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,8 +468,6 @@ impl Thread {
|
||||||
.completion_mode
|
.completion_mode
|
||||||
.unwrap_or_else(|| AssistantSettings::get_global(cx).preferred_completion_mode);
|
.unwrap_or_else(|| AssistantSettings::get_global(cx).preferred_completion_mode);
|
||||||
|
|
||||||
let configured_profile_id = serialized.profile.clone();
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
updated_at: serialized.updated_at,
|
updated_at: serialized.updated_at,
|
||||||
|
@ -547,7 +541,6 @@ impl Thread {
|
||||||
request_callback: None,
|
request_callback: None,
|
||||||
remaining_turns: u32::MAX,
|
remaining_turns: u32::MAX,
|
||||||
configured_model,
|
configured_model,
|
||||||
configured_profile_id,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,19 +596,6 @@ impl Thread {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn configured_profile_id(&self) -> Option<AgentProfileId> {
|
|
||||||
self.configured_profile_id.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_configured_profile_id(
|
|
||||||
&mut self,
|
|
||||||
id: Option<AgentProfileId>,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) {
|
|
||||||
self.configured_profile_id = id;
|
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const DEFAULT_SUMMARY: SharedString = SharedString::new_static("New Thread");
|
pub const DEFAULT_SUMMARY: SharedString = SharedString::new_static("New Thread");
|
||||||
|
|
||||||
pub fn summary_or_default(&self) -> SharedString {
|
pub fn summary_or_default(&self) -> SharedString {
|
||||||
|
@ -1120,7 +1100,6 @@ impl Thread {
|
||||||
provider: model.provider.id().0.to_string(),
|
provider: model.provider.id().0.to_string(),
|
||||||
model: model.model.id().0.to_string(),
|
model: model.model.id().0.to_string(),
|
||||||
}),
|
}),
|
||||||
profile: this.configured_profile_id.clone(),
|
|
||||||
completion_mode: Some(this.completion_mode),
|
completion_mode: Some(this.completion_mode),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -657,8 +657,6 @@ pub struct SerializedThread {
|
||||||
pub model: Option<SerializedLanguageModel>,
|
pub model: Option<SerializedLanguageModel>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub completion_mode: Option<CompletionMode>,
|
pub completion_mode: Option<CompletionMode>,
|
||||||
#[serde(default)]
|
|
||||||
pub profile: Option<AgentProfileId>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -804,7 +802,6 @@ impl LegacySerializedThread {
|
||||||
exceeded_window_error: None,
|
exceeded_window_error: None,
|
||||||
model: None,
|
model: None,
|
||||||
completion_mode: None,
|
completion_mode: None,
|
||||||
profile: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue