Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Send copilot log messages into the log panel
Kirill Bulatov7bc4f0bc11e2
diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rsindex d36d5456bef..29b92ec3619 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::<LogMessage, _>(|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::<StatusNotification, _>(|_, _| { /* Silence the notification */ },diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex b54296ee2aa..42f26a65410 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<gpui::Subscription>,+ copilot_log_subscription: Option<lsp::Subscription>,current_lsp_settings: HashMap<Arc<str>, LspSettings>,}@@ -664,6 +665,7 @@ impl Project {local_handles: Vec::new(),},copilot_lsp_subscription,+ copilot_log_subscription: None,current_lsp_settings: settings::get::<ProjectSettings>(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::<ProjectSettings>(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::<copilot::request::LogMessage, _>(+ 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));}