From e7c8cbeed602671fe959aac3bec0da8d43a470b3 Mon Sep 17 00:00:00 2001 From: Audi Nugraha Date: Mon, 5 Oct 2026 16:40:35 +0000 Subject: [PATCH] extensions_ui: Add `extension_suggestions` setting to disable extension suggestions (#65109) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Zed shows a notification suggesting extensions for the languages of the files you open. Right now the only way to silence it is to dismiss each suggestion one by one (stored per extension), or to add every extension to `auto_install_extensions`. There is no way to turn the feature off as a whole. This adds an `extension_suggestions` setting (default `true`). When set to `false`, `show_suggestion` returns early and no suggestion notification is shown. ```json { "extension_suggestions": false } ``` To make the feature discoverable, this also: - Adds an **Extension Suggestions** toggle to the General settings page. - Adds a third **Never Suggest Extensions** action to suggestion notifications that disables the setting globally. Changes: `ExtensionSettingsContent` / `ExtensionSettings` get the new field (non-optional `bool` with `serde(default_true)`), `assets/settings/default.json` and `docs/src/reference/all-settings.md` document it, `settings_ui` renders the toggle on the General page, `MessageNotification` gains support for a tertiary action, and `extension_suggestions.rs` checks the setting and wires up the new notification action. ## Testing - Added `test_no_suggestion_when_extension_suggestions_disabled` (opens `index.html` with the setting off, expects no notification). - Added `test_disabling_extension_suggestions_persists_and_stops_suggestions` (invokes the new action, asserts the setting is disabled and no further suggestions appear). - `cargo test -p extensions_ui extension_suggestions`: 22 pass, 2 fail. The 2 failures (`test_suggestion_returns_after_uninstall`, `test_suggestion_returns_after_failed_install`) also fail on `main` without this change. - Manually checked on macOS with a local release build: the General → Extensions toggle works, and the **Never Suggest Extensions** action disables the setting globally. To test: toggle it off in Settings → General → Extensions, or click **Never Suggest Extensions** on a suggestion notification, then open a file whose language has a suggested extension. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Added an `extension_suggestions` setting to turn off extension suggestions. --------- Co-authored-by: Claude Sonnet 5.5 Co-authored-by: MrSubidubi Co-authored-by: Finn Evers --- assets/settings/default.json | 2 + .../extension_host/src/extension_settings.rs | 2 + .../src/extension_suggestions.rs | 61 +++++++++++++++++ crates/settings_content/src/extension.rs | 19 +++++- crates/settings_ui/src/page_data.rs | 21 ++++++ .../ui/src/components/button/split_button.rs | 8 +++ crates/workspace/src/notifications.rs | 67 +++++++++++++++++-- docs/src/reference/all-settings.md | 16 +++++ 8 files changed, 191 insertions(+), 5 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index fe87add3b99..0a926bdd0df 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -2339,6 +2339,8 @@ "auto_install_extensions": { "html": true, }, + // Whether to suggest installing extensions based on the files you open. + "suggest_extensions": true, // The capabilities granted to extensions. // // This list can be customized to restrict what extensions are able to do. diff --git a/crates/extension_host/src/extension_settings.rs b/crates/extension_host/src/extension_settings.rs index 736dd6b87ae..2cb35df94f8 100644 --- a/crates/extension_host/src/extension_settings.rs +++ b/crates/extension_host/src/extension_settings.rs @@ -15,6 +15,7 @@ pub struct ExtensionSettings { /// Default: { "html": true } pub auto_install_extensions: HashMap, bool>, pub auto_update_extensions: HashMap, bool>, + pub suggest_extensions: bool, pub granted_capabilities: Vec, } @@ -40,6 +41,7 @@ impl Settings for ExtensionSettings { Self { auto_install_extensions: content.extension.auto_install_extensions.clone(), auto_update_extensions: content.extension.auto_update_extensions.clone(), + suggest_extensions: content.extension.suggest_extensions, granted_capabilities: content .extension .granted_extension_capabilities diff --git a/crates/extensions_ui/src/extension_suggestions.rs b/crates/extensions_ui/src/extension_suggestions.rs index 9080c5297d2..0d6103e431e 100644 --- a/crates/extensions_ui/src/extension_suggestions.rs +++ b/crates/extensions_ui/src/extension_suggestions.rs @@ -196,6 +196,9 @@ fn show_suggestion( if workspace.has_notification(¬ification_id) { return; } + if !ExtensionSettings::get_global(cx).suggest_extensions { + return; + } let extension_store = ExtensionStore::global(cx); let extension_store = extension_store.read(cx); @@ -231,10 +234,20 @@ fn show_suggestion( .secondary_icon(IconName::Close) .secondary_icon_color(Color::Error) .secondary_on_click(move |_window, cx| dismiss_suggestion(&extension_id, cx)) + .secondary_menu_entry("Disable Suggestions", |_window, cx| { + disable_extension_suggestions(cx) + }) }) }); } +fn disable_extension_suggestions(cx: &mut App) { + let fs = AppState::global(cx).fs.clone(); + settings::update_settings_file(fs, cx, |content, _| { + content.extension.suggest_extensions = false; + }); +} + #[cfg(test)] mod tests { use super::*; @@ -327,6 +340,54 @@ mod tests { assert_eq!(notification_ids(&workspace, cx), Vec::new()); } + #[gpui::test] + async fn test_no_suggestion_when_suggest_extensions_disabled(cx: &mut TestAppContext) { + let app_state = init_test(cx); + cx.update(|cx| { + cx.update_global::(|store, cx| { + store.update_user_settings(cx, |content| { + content.extension.suggest_extensions = false; + }); + }); + }); + let (workspace, cx) = open_test_workspace(&app_state, cx).await; + + open_file(&workspace, "index.html", cx).await; + open_file(&workspace, "main.gleam", cx).await; + + assert_eq!(notification_ids(&workspace, cx), Vec::new()); + } + + #[gpui::test] + async fn test_disabling_extension_suggestions_stops_suggestions(cx: &mut TestAppContext) { + let app_state = init_test(cx); + let (workspace, cx) = open_test_workspace(&app_state, cx).await; + open_file(&workspace, "index.html", cx).await; + assert_eq!( + notification_ids(&workspace, cx), + vec![notification_id(EMMET_EXTENSION_ID)] + ); + + let notification = notification_views(&workspace, cx) + .pop() + .unwrap() + .downcast::() + .ok() + .unwrap(); + cx.update(|_, cx| disable_extension_suggestions(cx)); + notification.update(cx, |notification, cx| notification.dismiss(cx)); + cx.run_until_parked(); + + assert_eq!(notification_ids(&workspace, cx), Vec::new()); + cx.update(|_, cx| { + assert!(!ExtensionSettings::get_global(cx).suggest_extensions); + assert!(!suggestion_dismissed(EMMET_EXTENSION_ID, cx)); + }); + + open_file(&workspace, "other.html", cx).await; + assert_eq!(notification_ids(&workspace, cx), Vec::new()); + } + #[gpui::test] async fn test_no_suggestion_after_dismissal(cx: &mut TestAppContext) { let app_state = init_test(cx); diff --git a/crates/settings_content/src/extension.rs b/crates/settings_content/src/extension.rs index 2fefd4ef38a..701c4b84d66 100644 --- a/crates/settings_content/src/extension.rs +++ b/crates/settings_content/src/extension.rs @@ -4,9 +4,10 @@ use collections::HashMap; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use settings_macros::{MergeFrom, with_fallible_options}; +use util::serde::default_true; #[with_fallible_options] -#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)] +#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, JsonSchema, MergeFrom)] pub struct ExtensionSettingsContent { /// The extensions that should be automatically installed by Zed. /// @@ -18,10 +19,26 @@ pub struct ExtensionSettingsContent { pub auto_install_extensions: HashMap, bool>, #[serde(default)] pub auto_update_extensions: HashMap, bool>, + /// Whether to suggest installing extensions based on the files you open. + /// + /// Default: true + #[serde(default = "default_true")] + pub suggest_extensions: bool, /// The capabilities granted to extensions. pub granted_extension_capabilities: Option>, } +impl Default for ExtensionSettingsContent { + fn default() -> Self { + Self { + auto_install_extensions: HashMap::default(), + auto_update_extensions: HashMap::default(), + suggest_extensions: true, + granted_extension_capabilities: None, + } + } +} + /// A capability for an extension. #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)] #[serde(tag = "kind", rename_all = "snake_case")] diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 525511fbf4f..9da1f4fc4f4 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -517,6 +517,26 @@ fn general_page(cx: &App) -> SettingsPage { ] } + fn extensions_section() -> [SettingsPageItem; 2] { + [ + SettingsPageItem::SectionHeader("Extensions"), + SettingsPageItem::SettingItem(SettingItem { + title: "Suggest Extensions", + description: "Whether to suggest installing extensions based on the files you open.", + field: Box::new(SettingField { + organization_override: None, + json_path: Some("suggest_extensions"), + pick: |settings_content| Some(&settings_content.extension.suggest_extensions), + write: |settings_content, value, _| { + settings_content.extension.suggest_extensions = value.unwrap_or(true); + }, + }), + metadata: None, + files: USER, + }), + ] + } + SettingsPage { title: "General", items: concat_sections!( @@ -527,6 +547,7 @@ fn general_page(cx: &App) -> SettingsPage { scoped_settings_section(), privacy_section(), auto_update_section(), + extensions_section(), ) .into(), } diff --git a/crates/ui/src/components/button/split_button.rs b/crates/ui/src/components/button/split_button.rs index 0173474690d..2b870cea149 100644 --- a/crates/ui/src/components/button/split_button.rs +++ b/crates/ui/src/components/button/split_button.rs @@ -17,10 +17,17 @@ pub enum SplitButtonStyle { } pub enum SplitButtonKind { + Button(Button), ButtonLike(ButtonLike), IconButton(IconButton), } +impl From