Add setting to allow disabling the Assistant (#9706)

This PR adds a new `assistant.enabled` setting that controls whether the
Zed Assistant is enabled.

Some users have requested the ability to disable the AI-related features
in Zed if they don't use them. Changing `assistant.enabled` to `false`
will hide the Assistant icon in the status bar (taking priority over the
`assistant.button` setting) as well as filter out the `assistant:`
actions.

The Assistant is enabled by default.

Release Notes:

- Added an `assistant.enabled` setting to control whether the Assistant
is enabled.
This commit is contained in:
Marshall Bowers 2024-03-22 11:55:29 -04:00 committed by GitHub
parent 4dc61f7ccd
commit c6d479715d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 100 additions and 37 deletions

View file

@ -55,6 +55,11 @@ pub fn init(cx: &mut AppContext) {
|workspace: &mut Workspace, _cx: &mut ViewContext<Workspace>| {
workspace
.register_action(|workspace, _: &ToggleFocus, cx| {
let settings = AssistantSettings::get_global(cx);
if !settings.enabled {
return;
}
workspace.toggle_panel_focus::<AssistantPanel>(cx);
})
.register_action(AssistantPanel::inline_assist)
@ -229,6 +234,11 @@ impl AssistantPanel {
_: &InlineAssist,
cx: &mut ViewContext<Workspace>,
) {
let settings = AssistantSettings::get_global(cx);
if !settings.enabled {
return;
}
let Some(assistant) = workspace.panel::<AssistantPanel>(cx) else {
return;
};
@ -1217,7 +1227,12 @@ impl Panel for AssistantPanel {
}
fn icon(&self, cx: &WindowContext) -> Option<IconName> {
Some(IconName::Ai).filter(|_| AssistantSettings::get_global(cx).button)
let settings = AssistantSettings::get_global(cx);
if !settings.enabled || !settings.button {
return None;
}
Some(IconName::Ai)
}
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {