Add setting to disable all AI features (#34896)
https://github.com/user-attachments/assets/674bba41-40ac-4a98-99e4-0b47f9097b6a Release Notes: - Added setting to disable all AI features
This commit is contained in:
parent
939f9fffa3
commit
96f9942791
19 changed files with 308 additions and 68 deletions
|
@ -554,6 +554,7 @@ pub fn main() {
|
|||
supermaven::init(app_state.client.clone(), cx);
|
||||
language_model::init(app_state.client.clone(), cx);
|
||||
language_models::init(app_state.user_store.clone(), app_state.client.clone(), cx);
|
||||
agent_settings::init(cx);
|
||||
agent_servers::init(cx);
|
||||
web_search::init(cx);
|
||||
web_search_providers::init(app_state.client.clone(), cx);
|
||||
|
|
|
@ -2,6 +2,7 @@ mod preview;
|
|||
mod repl_menu;
|
||||
|
||||
use agent_settings::AgentSettings;
|
||||
use client::DisableAiSettings;
|
||||
use editor::actions::{
|
||||
AddSelectionAbove, AddSelectionBelow, CodeActionSource, DuplicateLineDown, GoToDiagnostic,
|
||||
GoToHunk, GoToPreviousDiagnostic, GoToPreviousHunk, MoveLineDown, MoveLineUp, SelectAll,
|
||||
|
@ -32,6 +33,7 @@ const MAX_CODE_ACTION_MENU_LINES: u32 = 16;
|
|||
|
||||
pub struct QuickActionBar {
|
||||
_inlay_hints_enabled_subscription: Option<Subscription>,
|
||||
_ai_settings_subscription: Subscription,
|
||||
active_item: Option<Box<dyn ItemHandle>>,
|
||||
buffer_search_bar: Entity<BufferSearchBar>,
|
||||
show: bool,
|
||||
|
@ -46,8 +48,28 @@ impl QuickActionBar {
|
|||
workspace: &Workspace,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let mut was_ai_disabled = DisableAiSettings::get_global(cx).disable_ai;
|
||||
let mut was_agent_enabled = AgentSettings::get_global(cx).enabled;
|
||||
let mut was_agent_button = AgentSettings::get_global(cx).button;
|
||||
|
||||
let ai_settings_subscription = cx.observe_global::<SettingsStore>(move |_, cx| {
|
||||
let is_ai_disabled = DisableAiSettings::get_global(cx).disable_ai;
|
||||
let agent_settings = AgentSettings::get_global(cx);
|
||||
|
||||
if was_ai_disabled != is_ai_disabled
|
||||
|| was_agent_enabled != agent_settings.enabled
|
||||
|| was_agent_button != agent_settings.button
|
||||
{
|
||||
was_ai_disabled = is_ai_disabled;
|
||||
was_agent_enabled = agent_settings.enabled;
|
||||
was_agent_button = agent_settings.button;
|
||||
cx.notify();
|
||||
}
|
||||
});
|
||||
|
||||
let mut this = Self {
|
||||
_inlay_hints_enabled_subscription: None,
|
||||
_ai_settings_subscription: ai_settings_subscription,
|
||||
active_item: None,
|
||||
buffer_search_bar,
|
||||
show: true,
|
||||
|
@ -575,7 +597,9 @@ impl Render for QuickActionBar {
|
|||
.children(self.render_preview_button(self.workspace.clone(), cx))
|
||||
.children(search_button)
|
||||
.when(
|
||||
AgentSettings::get_global(cx).enabled && AgentSettings::get_global(cx).button,
|
||||
AgentSettings::get_global(cx).enabled
|
||||
&& AgentSettings::get_global(cx).button
|
||||
&& !DisableAiSettings::get_global(cx).disable_ai,
|
||||
|bar| bar.child(assistant_button),
|
||||
)
|
||||
.children(code_actions_dropdown)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue