Put context servers behind a trait (#20432)

This PR puts context servers behind the `ContextServer` trait to allow
us to provide context servers from an extension.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2024-11-08 13:36:41 -05:00
committed by GitHub
parent 01503511ad
commit 09c599385a
6 changed files with 102 additions and 61 deletions
@@ -1,3 +1,5 @@
use std::sync::Arc;
use anyhow::{anyhow, bail};
use assistant_tool::Tool;
use context_servers::manager::ContextServerManager;
@@ -6,14 +8,14 @@ use gpui::{Model, Task};
pub struct ContextServerTool {
server_manager: Model<ContextServerManager>,
server_id: String,
server_id: Arc<str>,
tool: types::Tool,
}
impl ContextServerTool {
pub fn new(
server_manager: Model<ContextServerManager>,
server_id: impl Into<String>,
server_id: impl Into<Arc<str>>,
tool: types::Tool,
) -> Self {
Self {
@@ -55,7 +57,7 @@ impl Tool for ContextServerTool {
cx.foreground_executor().spawn({
let tool_name = self.tool.name.clone();
async move {
let Some(protocol) = server.client.read().clone() else {
let Some(protocol) = server.client() else {
bail!("Context server not initialized");
};