agent_ui: Fix issue where MCP extension could not be uninstalled (#42384)

Closes https://github.com/zed-industries/zed/issues/42312

The issue here was that we assumed that context servers provided by
extensions would always need a config in the settings to be present when
actually the opposite was the case - context servers provided by
extensions are the only context servers that do not need a config to be
in place in order to be available in the UI.

Release Notes:

- Fixed an issue where context servers provided by extensions could not
be uninstalled if they were previously unconfigured.
This commit is contained in:
Finn Evers
2025-11-11 00:25:27 +01:00
committed by GitHub
parent f52549c1c4
commit e488b6cd0b
+9 -25
View File
@@ -638,15 +638,13 @@ impl AgentConfiguration {
let is_running = matches!(server_status, ContextServerStatus::Running); let is_running = matches!(server_status, ContextServerStatus::Running);
let item_id = SharedString::from(context_server_id.0.clone()); let item_id = SharedString::from(context_server_id.0.clone());
let is_from_extension = server_configuration // Servers without a configuration can only be provided by extensions.
.as_ref() let provided_by_extension = server_configuration.is_none_or(|config| {
.map(|config| { matches!(
matches!( config.as_ref(),
config.as_ref(), ContextServerConfiguration::Extension { .. }
ContextServerConfiguration::Extension { .. } )
) });
})
.unwrap_or(false);
let error = if let ContextServerStatus::Error(error) = server_status.clone() { let error = if let ContextServerStatus::Error(error) = server_status.clone() {
Some(error) Some(error)
@@ -660,7 +658,7 @@ impl AgentConfiguration {
.tools_for_server(&context_server_id) .tools_for_server(&context_server_id)
.count(); .count();
let (source_icon, source_tooltip) = if is_from_extension { let (source_icon, source_tooltip) = if provided_by_extension {
( (
IconName::ZedSrcExtension, IconName::ZedSrcExtension,
"This MCP server was installed from an extension.", "This MCP server was installed from an extension.",
@@ -710,7 +708,6 @@ impl AgentConfiguration {
let fs = self.fs.clone(); let fs = self.fs.clone();
let context_server_id = context_server_id.clone(); let context_server_id = context_server_id.clone();
let language_registry = self.language_registry.clone(); let language_registry = self.language_registry.clone();
let context_server_store = self.context_server_store.clone();
let workspace = self.workspace.clone(); let workspace = self.workspace.clone();
let context_server_registry = self.context_server_registry.clone(); let context_server_registry = self.context_server_registry.clone();
@@ -752,23 +749,10 @@ impl AgentConfiguration {
.entry("Uninstall", None, { .entry("Uninstall", None, {
let fs = fs.clone(); let fs = fs.clone();
let context_server_id = context_server_id.clone(); let context_server_id = context_server_id.clone();
let context_server_store = context_server_store.clone();
let workspace = workspace.clone(); let workspace = workspace.clone();
move |_, cx| { move |_, cx| {
let is_provided_by_extension = context_server_store
.read(cx)
.configuration_for_server(&context_server_id)
.as_ref()
.map(|config| {
matches!(
config.as_ref(),
ContextServerConfiguration::Extension { .. }
)
})
.unwrap_or(false);
let uninstall_extension_task = match ( let uninstall_extension_task = match (
is_provided_by_extension, provided_by_extension,
resolve_extension_for_context_server(&context_server_id, cx), resolve_extension_for_context_server(&context_server_id, cx),
) { ) {
(true, Some((id, manifest))) => { (true, Some((id, manifest))) => {