assistant2: Allow customizing tools for default profiles (#27594)
This PR adds support for customizing the tools for the default profiles. Release Notes: - N/A
This commit is contained in:
parent
1c7cf1a5c1
commit
2dee03ebca
1 changed files with 34 additions and 16 deletions
|
@ -1,7 +1,8 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use assistant_settings::{
|
use assistant_settings::{
|
||||||
AgentProfile, AssistantSettings, AssistantSettingsContent, VersionedAssistantSettingsContent,
|
AgentProfile, AgentProfileContent, AssistantSettings, AssistantSettingsContent,
|
||||||
|
ContextServerPresetContent, VersionedAssistantSettingsContent,
|
||||||
};
|
};
|
||||||
use assistant_tool::{ToolSource, ToolWorkingSet};
|
use assistant_tool::{ToolSource, ToolWorkingSet};
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
|
@ -184,13 +185,33 @@ impl PickerDelegate for ToolPickerDelegate {
|
||||||
|
|
||||||
update_settings_file::<AssistantSettings>(self.fs.clone(), cx, {
|
update_settings_file::<AssistantSettings>(self.fs.clone(), cx, {
|
||||||
let profile_id = self.profile_id.clone();
|
let profile_id = self.profile_id.clone();
|
||||||
|
let default_profile = self.profile.clone();
|
||||||
let tool = tool.clone();
|
let tool = tool.clone();
|
||||||
move |settings, _cx| match settings {
|
move |settings, _cx| match settings {
|
||||||
AssistantSettingsContent::Versioned(VersionedAssistantSettingsContent::V2(
|
AssistantSettingsContent::Versioned(VersionedAssistantSettingsContent::V2(
|
||||||
settings,
|
settings,
|
||||||
)) => {
|
)) => {
|
||||||
if let Some(profiles) = &mut settings.profiles {
|
let profiles = settings.profiles.get_or_insert_default();
|
||||||
if let Some(profile) = profiles.get_mut(&profile_id) {
|
let profile =
|
||||||
|
profiles
|
||||||
|
.entry(profile_id)
|
||||||
|
.or_insert_with(|| AgentProfileContent {
|
||||||
|
name: default_profile.name.into(),
|
||||||
|
tools: default_profile.tools,
|
||||||
|
context_servers: default_profile
|
||||||
|
.context_servers
|
||||||
|
.into_iter()
|
||||||
|
.map(|(server_id, preset)| {
|
||||||
|
(
|
||||||
|
server_id,
|
||||||
|
ContextServerPresetContent {
|
||||||
|
tools: preset.tools,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
});
|
||||||
|
|
||||||
match tool.source {
|
match tool.source {
|
||||||
ToolSource::Native => {
|
ToolSource::Native => {
|
||||||
*profile.tools.entry(tool.name).or_default() = is_enabled;
|
*profile.tools.entry(tool.name).or_default() = is_enabled;
|
||||||
|
@ -200,10 +221,7 @@ impl PickerDelegate for ToolPickerDelegate {
|
||||||
.context_servers
|
.context_servers
|
||||||
.entry(id.clone().into())
|
.entry(id.clone().into())
|
||||||
.or_default();
|
.or_default();
|
||||||
*preset.tools.entry(tool.name.clone()).or_default() =
|
*preset.tools.entry(tool.name.clone()).or_default() = is_enabled;
|
||||||
is_enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue