context_store: Refactor state management (#29910)

Because we instantiated `ContextServerManager` both in `agent` and
`assistant-context-editor`, and these two entities track the running MCP
servers separately, we were effectively running every MCP server twice.

This PR moves the `ContextServerManager` into the project crate (now
called `ContextServerStore`). The store can be accessed via a project
instance. This ensures that we only instantiate one `ContextServerStore`
per project.

Also, this PR adds a bunch of tests to ensure that the
`ContextServerStore` behaves correctly (Previously there were none).

Closes #28714
Closes #29530

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner
2025-05-05 21:36:12 +02:00
committed by GitHub
parent 8199664a5a
commit 9cb5ffac25
43 changed files with 1568 additions and 1047 deletions
Generated
+4 -27
View File
@@ -484,7 +484,6 @@ dependencies = [
"client",
"collections",
"command_palette_hooks",
"context_server",
"ctor",
"db",
"editor",
@@ -3328,40 +3327,19 @@ name = "context_server"
version = "0.1.0"
dependencies = [
"anyhow",
"assistant_tool",
"async-trait",
"collections",
"command_palette_hooks",
"context_server_settings",
"extension",
"futures 0.3.31",
"gpui",
"icons",
"language_model",
"log",
"parking_lot",
"postage",
"project",
"serde",
"serde_json",
"settings",
"smol",
"url",
"util",
"workspace-hack",
]
[[package]]
name = "context_server_settings"
version = "0.1.0"
dependencies = [
"anyhow",
"collections",
"gpui",
"schemars",
"serde",
"serde_json",
"settings",
"smol",
"url",
"util",
"workspace-hack",
]
@@ -5029,7 +5007,6 @@ dependencies = [
"clap",
"client",
"collections",
"context_server",
"dirs 4.0.0",
"dotenv",
"env_logger 0.11.8",
@@ -5182,7 +5159,6 @@ dependencies = [
"async-trait",
"client",
"collections",
"context_server_settings",
"ctor",
"env_logger 0.11.8",
"extension",
@@ -11112,6 +11088,7 @@ dependencies = [
"client",
"clock",
"collections",
"context_server",
"dap",
"dap_adapters",
"env_logger 0.11.8",