assistant2: Add profile selector (#27520)
This PR replaces the tool selector with a new profile selector. <img width="1394" alt="Screenshot 2025-03-26 at 2 35 42 PM" src="https://github.com/user-attachments/assets/9631c6e9-9c47-411e-b9fc-5d61ed9ca1fe" /> <img width="1394" alt="Screenshot 2025-03-26 at 2 35 50 PM" src="https://github.com/user-attachments/assets/3abe4e08-d044-4d3f-aa95-f472938452a8" /> Release Notes: - N/A
This commit is contained in:
parent
7e4320f587
commit
cdaad2655a
9 changed files with 268 additions and 181 deletions
|
@ -3,7 +3,8 @@ use std::path::PathBuf;
|
|||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use assistant_tool::{ToolId, ToolWorkingSet};
|
||||
use assistant_settings::AssistantSettings;
|
||||
use assistant_tool::{ToolId, ToolSource, ToolWorkingSet};
|
||||
use chrono::{DateTime, Utc};
|
||||
use collections::HashMap;
|
||||
use context_server::manager::ContextServerManager;
|
||||
|
@ -19,6 +20,7 @@ use language_model::{LanguageModelToolUseId, Role};
|
|||
use project::Project;
|
||||
use prompt_store::PromptBuilder;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::Settings as _;
|
||||
use util::ResultExt as _;
|
||||
|
||||
use crate::thread::{MessageId, ProjectSnapshot, Thread, ThreadEvent, ThreadId};
|
||||
|
@ -57,6 +59,7 @@ impl ThreadStore {
|
|||
context_server_tool_ids: HashMap::default(),
|
||||
threads: Vec::new(),
|
||||
};
|
||||
this.load_default_profile(cx);
|
||||
this.register_context_server_handlers(cx);
|
||||
this.reload(cx).detach_and_log_err(cx);
|
||||
|
||||
|
@ -184,6 +187,38 @@ impl ThreadStore {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn load_default_profile(&self, cx: &mut Context<Self>) {
|
||||
let assistant_settings = AssistantSettings::get_global(cx);
|
||||
|
||||
if let Some(profile) = assistant_settings
|
||||
.profiles
|
||||
.get(&assistant_settings.default_profile)
|
||||
{
|
||||
self.tools.disable_source(ToolSource::Native, cx);
|
||||
self.tools.enable(
|
||||
ToolSource::Native,
|
||||
&profile
|
||||
.tools
|
||||
.iter()
|
||||
.filter_map(|(tool, enabled)| enabled.then(|| tool.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
for (context_server_id, preset) in &profile.context_servers {
|
||||
self.tools.enable(
|
||||
ToolSource::ContextServer {
|
||||
id: context_server_id.clone().into(),
|
||||
},
|
||||
&preset
|
||||
.tools
|
||||
.iter()
|
||||
.filter_map(|(tool, enabled)| enabled.then(|| tool.clone()))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn register_context_server_handlers(&self, cx: &mut Context<Self>) {
|
||||
cx.subscribe(
|
||||
&self.context_server_manager.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue