agent: Fix bug that prevented MCP servers to appear in the settings view (#33857)

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

After #33644 was merged, we would not start MCP servers coming from
extensions correctly anymore. The optimization uncovered a bug in the
implementation of `ContextServerDescriptorRegistry`, because we never
called `cx.notify()` when adding/removing context servers.
`ContextServerStore` listens for these events, and before #33644 this
was just working because of aace condition.

Release Notes:

- agent: Fixed bug that prevented MCP servers to appear in the settings
view.

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
This commit is contained in:
Danilo Leal 2025-07-03 12:05:29 -03:00 committed by GitHub
parent cc0d8a411e
commit 34322ef1cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View file

@ -4,7 +4,7 @@ use anyhow::Result;
use collections::HashMap;
use context_server::ContextServerCommand;
use extension::ContextServerConfiguration;
use gpui::{App, AppContext as _, AsyncApp, Entity, Global, Task};
use gpui::{App, AppContext as _, AsyncApp, Context, Entity, Global, Task};
use crate::worktree_store::WorktreeStore;
@ -66,12 +66,19 @@ impl ContextServerDescriptorRegistry {
&mut self,
id: Arc<str>,
descriptor: Arc<dyn ContextServerDescriptor>,
cx: &mut Context<Self>,
) {
self.context_servers.insert(id, descriptor);
cx.notify();
}
/// Unregisters the [`ContextServerDescriptor`] for the server with the given ID.
pub fn unregister_context_server_descriptor_by_id(&mut self, server_id: &str) {
pub fn unregister_context_server_descriptor_by_id(
&mut self,
server_id: &str,
cx: &mut Context<Self>,
) {
self.context_servers.remove(server_id);
cx.notify();
}
}