diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index d36d5456bef96bf2a2670bba508f2436594d9bae..29b92ec3619ed3bb60eba10fffc35e124927f968 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -14,10 +14,9 @@ use language::{ point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, BufferSnapshot, Language, LanguageServerName, PointUtf16, ToPointUtf16, }; -use log::{debug, error}; use lsp::{LanguageServer, LanguageServerBinary, LanguageServerId}; use node_runtime::NodeRuntime; -use request::{LogMessage, StatusNotification}; +use request::StatusNotification; use settings::SettingsStore; use smol::{fs, io::BufReader, stream::StreamExt}; use std::{ @@ -391,20 +390,6 @@ impl Copilot { let server = LanguageServer::new(new_server_id, binary, Path::new("/"), None, cx.clone())?; - server - .on_notification::(|params, _cx| { - match params.level { - // Copilot is pretty aggressive about logging - 0 => debug!("copilot: {}", params.message), - 1 => debug!("copilot: {}", params.message), - _ => error!("copilot: {}", params.message), - } - - debug!("copilot metadata: {}", params.metadata_str); - debug!("copilot extra: {:?}", params.extra); - }) - .detach(); - server .on_notification::( |_, _| { /* Silence the notification */ }, diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index b54296ee2aa121596efa4e6b8d1683ba2b345a42..42f26a654104a0253e1835b3a16492016dd1c54c 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -150,6 +150,7 @@ pub struct Project { _maintain_workspace_config: Task<()>, terminals: Terminals, copilot_lsp_subscription: Option, + copilot_log_subscription: Option, current_lsp_settings: HashMap, LspSettings>, } @@ -664,6 +665,7 @@ impl Project { local_handles: Vec::new(), }, copilot_lsp_subscription, + copilot_log_subscription: None, current_lsp_settings: settings::get::(cx).lsp.clone(), } }) @@ -760,6 +762,7 @@ impl Project { local_handles: Vec::new(), }, copilot_lsp_subscription, + copilot_log_subscription: None, current_lsp_settings: settings::get::(cx).lsp.clone(), }; for worktree in worktrees { @@ -8041,6 +8044,21 @@ fn subscribe_for_copilot_events( if let hash_map::Entry::Vacant(v) = project.supplementary_language_servers.entry(new_server_id) { + let weak_project = cx.weak_handle(); + let copilot_log_subscription = copilot_server + .on_notification::( + move |params, mut cx| { + if let Some(project) = weak_project.upgrade(&mut cx) { + project.update(&mut cx, |_, cx| { + cx.emit(Event::LanguageServerLog( + new_server_id, + params.message, + )); + }) + } + }, + ); + project.copilot_log_subscription = Some(copilot_log_subscription); v.insert((name.clone(), Arc::clone(copilot_server))); cx.emit(Event::LanguageServerAdded(new_server_id)); }