Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
context_servers: Fix tool/list and prompt/list (#20387)
David Soria Parra30a94fa59b53
diff --git a/crates/context_servers/src/client.rs b/crates/context_servers/src/client.rsindex 6681023c008..0bf0d04e866 100644--- a/crates/context_servers/src/client.rs+++ b/crates/context_servers/src/client.rs@@ -55,11 +55,20 @@ pub struct Client {#[repr(transparent)]pub struct ContextServerId(pub String);+fn is_null_value<T: Serialize>(value: &T) -> bool {+ if let Ok(Value::Null) = serde_json::to_value(value) {+ true+ } else {+ false+ }+}+#[derive(Serialize, Deserialize)]struct Request<'a, T> {jsonrpc: &'static str,id: RequestId,method: &'a str,+ #[serde(skip_serializing_if = "is_null_value")]params: T,}diff --git a/crates/context_servers/src/protocol.rs b/crates/context_servers/src/protocol.rsindex 996fc34f462..12fe18ecf5e 100644--- a/crates/context_servers/src/protocol.rs+++ b/crates/context_servers/src/protocol.rs@@ -113,7 +113,10 @@ impl InitializedContextServerProtocol {let response: types::PromptsListResponse = self.inner- .request(types::RequestType::PromptsList.as_str(), ())+ .request(+ types::RequestType::PromptsList.as_str(),+ serde_json::json!({}),+ ).await?;Ok(response.prompts)@@ -125,7 +128,10 @@ impl InitializedContextServerProtocol {let response: types::ResourcesListResponse = self.inner- .request(types::RequestType::ResourcesList.as_str(), ())+ .request(+ types::RequestType::ResourcesList.as_str(),+ serde_json::json!({}),+ ).await?;Ok(response)