settings: Follow up to #48003 (#53985)

Bennet Bo Fenner created

This is a follow up to #48003, instead of removing the settings key in a
new migration, we can prevent the existing one from adding settings in
the first place.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A

Change summary

crates/migrator/src/migrations.rs                       |  6 
crates/migrator/src/migrations/m_2025_06_16/settings.rs |  4 
crates/migrator/src/migrations/m_2026_04_15/settings.rs | 19 --
crates/migrator/src/migrator.rs                         | 91 ++++------
4 files changed, 41 insertions(+), 79 deletions(-)

Detailed changes

crates/migrator/src/migrations.rs 🔗

@@ -334,9 +334,3 @@ pub(crate) mod m_2026_04_10 {
 
     pub(crate) use settings::rename_web_search_to_search_web;
 }
-
-pub(crate) mod m_2026_04_15 {
-    mod settings;
-
-    pub(crate) use settings::remove_settings_from_http_context_servers;
-}

crates/migrator/src/migrations/m_2025_06_16/settings.rs 🔗

@@ -34,6 +34,7 @@ fn migrate_context_server_settings(
 
     let mut has_command = false;
     let mut has_settings = false;
+    let mut has_url = false;
     let mut other_keys = 0;
     let mut column = None;
 
@@ -53,6 +54,7 @@ fn migrate_context_server_settings(
                     "source" => return None,
                     "command" => has_command = true,
                     "settings" => has_settings = true,
+                    "url" => has_url = true,
                     _ => other_keys += 1,
                 }
             }
@@ -65,7 +67,7 @@ fn migrate_context_server_settings(
     let start = server_settings.start_byte() + 1;
     let indent = " ".repeat(column.unwrap_or(12));
 
-    if !has_command && !has_settings {
+    if !has_command && !has_settings && !has_url {
         return Some((
             start..start,
             format!(

crates/migrator/src/migrations/m_2026_04_15/settings.rs 🔗

@@ -1,19 +0,0 @@
-use anyhow::Result;
-use serde_json::Value;
-
-pub fn remove_settings_from_http_context_servers(settings: &mut Value) -> Result<()> {
-    if let Some(obj) = settings.as_object_mut() {
-        if let Some(context_servers) = obj.get_mut("context_servers") {
-            if let Some(servers) = context_servers.as_object_mut() {
-                for (_, server) in servers.iter_mut() {
-                    if let Some(server_obj) = server.as_object_mut() {
-                        if server_obj.contains_key("url") {
-                            server_obj.remove("settings");
-                        }
-                    }
-                }
-            }
-        }
-    }
-    Ok(())
-}

crates/migrator/src/migrator.rs 🔗

@@ -250,7 +250,6 @@ pub fn migrate_settings(text: &str) -> Result<Option<String>> {
         MigrationType::Json(migrations::m_2026_03_30::make_play_sound_when_agent_done_an_enum),
         MigrationType::Json(migrations::m_2026_04_01::restructure_profiles_with_settings_key),
         MigrationType::Json(migrations::m_2026_04_10::rename_web_search_to_search_web),
-        MigrationType::Json(migrations::m_2026_04_15::remove_settings_from_http_context_servers),
     ];
     run_migrations(text, migrations)
 }
@@ -4983,61 +4982,47 @@ mod tests {
     }
 
     #[test]
-    fn test_remove_settings_from_http_context_servers() {
+    fn test_mcp_settings_migration_adds_settings_to_extension_servers() {
         assert_migrate_settings(
-            &r#"
-            {
-                "context_servers": {
-                    "http_server": {
-                        "url": "https://example.com/mcp",
-                        "settings": {}
-                    },
-                    "http_server_with_headers": {
-                        "url": "https://example.com/mcp",
-                        "headers": {
-                            "Authorization": "Bearer token"
-                        },
-                        "settings": {}
-                    },
-                    "extension_server": {
-                        "settings": {
-                            "foo": "bar"
-                        }
-                    },
-                    "stdio_server": {
-                        "command": "npx",
-                        "args": ["-y", "some-server"]
-                    }
-                }
+            r#"{
+    "context_servers": {
+        "extension_server": {},
+        "stdio_server": {
+            "command": "npx",
+            "args": ["-y", "some-server"]
+        },
+        "http_server": {
+            "url": "https://example.com/mcp"
+        },
+        "http_server_with_headers": {
+            "url": "https://example.com/mcp",
+            "headers": {
+                "Authorization": "Bearer token"
             }
-            "#
-            .unindent(),
+        }
+    }
+}"#,
             Some(
-                &r#"
-                {
-                    "context_servers": {
-                        "http_server": {
-                            "url": "https://example.com/mcp"
-                        },
-                        "http_server_with_headers": {
-                            "url": "https://example.com/mcp",
-                            "headers": {
-                                "Authorization": "Bearer token"
-                            }
-                        },
-                        "extension_server": {
-                            "settings": {
-                                "foo": "bar"
-                            }
-                        },
-                        "stdio_server": {
-                            "command": "npx",
-                            "args": ["-y", "some-server"]
-                        }
-                    }
-                }
-                "#
-                .unindent(),
+                r#"{
+    "context_servers": {
+        "extension_server": {
+            "settings": {}
+        },
+        "stdio_server": {
+            "command": "npx",
+            "args": ["-y", "some-server"]
+        },
+        "http_server": {
+            "url": "https://example.com/mcp"
+        },
+        "http_server_with_headers": {
+            "url": "https://example.com/mcp",
+            "headers": {
+                "Authorization": "Bearer token"
+            }
+        }
+    }
+}"#,
             ),
         );
     }