From 606d5e36e1016d473f15869757a1efb39c7f45cf Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 15 May 2023 16:44:09 -0700 Subject: [PATCH 1/9] Add events for copilot suggestion accepting and discarding --- crates/copilot/src/copilot.rs | 36 ++++++++++++++++++++++++++++++++++- crates/editor/src/editor.rs | 16 ++++++++++++++-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 9ccd9c445d..55c4c70f65 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -47,6 +47,10 @@ pub fn init(http: Arc, node_runtime: Arc, cx: &mut }); cx.set_global(copilot.clone()); + ////////////////////////////////////// + // SUBSCRIBE TO COPILOT EVENTS HERE // + ////////////////////////////////////// + cx.observe(&copilot, |handle, cx| { let status = handle.read(cx).status(); cx.update_default_global::(move |filter, _cx| { @@ -270,8 +274,19 @@ pub struct Copilot { buffers: HashMap>, } +pub enum Event { + CompletionAccepted { + uuid: String, + file_type: Option>, + }, + CompletionDiscarded { + uuids: Vec, + file_type: Option>, + }, +} + impl Entity for Copilot { - type Event = (); + type Event = Event; fn app_will_quit( &mut self, @@ -737,18 +752,26 @@ impl Copilot { pub fn accept_completion( &mut self, completion: &Completion, + file_type: Option>, cx: &mut ModelContext, ) -> Task> { let server = match self.server.as_authenticated() { Ok(server) => server, Err(error) => return Task::ready(Err(error)), }; + + cx.emit(Event::CompletionAccepted { + uuid: completion.uuid.clone(), + file_type, + }); + let request = server .lsp .request::(request::NotifyAcceptedParams { uuid: completion.uuid.clone(), }); + cx.background().spawn(async move { request.await?; Ok(()) @@ -758,12 +781,22 @@ impl Copilot { pub fn discard_completions( &mut self, completions: &[Completion], + file_type: Option>, cx: &mut ModelContext, ) -> Task> { let server = match self.server.as_authenticated() { Ok(server) => server, Err(error) => return Task::ready(Err(error)), }; + + cx.emit(Event::CompletionDiscarded { + uuids: completions + .iter() + .map(|completion| completion.uuid.clone()) + .collect(), + file_type: file_type.clone(), + }); + let request = server .lsp @@ -773,6 +806,7 @@ impl Copilot { .map(|completion| completion.uuid.clone()) .collect(), }); + cx.background().spawn(async move { request.await?; Ok(()) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b6d44397a9..221e94370e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3094,8 +3094,14 @@ impl Editor { if let Some((copilot, completion)) = Copilot::global(cx).zip(self.copilot_state.active_completion()) { + let language = self + .language_at(completion.range.start.offset, cx) + .map(|language| language.name()); + copilot - .update(cx, |copilot, cx| copilot.accept_completion(completion, cx)) + .update(cx, |copilot, cx| { + copilot.accept_completion(completion, language, cx) + }) .detach_and_log_err(cx); } self.insert_with_autoindent_mode(&suggestion.text.to_string(), None, cx); @@ -3109,9 +3115,15 @@ impl Editor { fn discard_copilot_suggestion(&mut self, cx: &mut ViewContext) -> bool { if self.has_active_copilot_suggestion(cx) { if let Some(copilot) = Copilot::global(cx) { + let file_type = self.copilot_state + .completions + .get(0) + .and_then(|completion| self.language_at(completion.range.start.offset, cx)) + .map(|language| language.name()); + copilot .update(cx, |copilot, cx| { - copilot.discard_completions(&self.copilot_state.completions, cx) + copilot.discard_completions(&self.copilot_state.completions, file_type, cx) }) .detach_and_log_err(cx); } From ead9ac6f236423ee4f04fe5451e35bbdb9bdd0b8 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 15 May 2023 16:47:39 -0700 Subject: [PATCH 2/9] Fix typo --- crates/copilot/src/copilot.rs | 4 ++-- crates/editor/src/editor.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 55c4c70f65..b9e850b371 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -279,7 +279,7 @@ pub enum Event { uuid: String, file_type: Option>, }, - CompletionDiscarded { + CompletionsDiscarded { uuids: Vec, file_type: Option>, }, @@ -789,7 +789,7 @@ impl Copilot { Err(error) => return Task::ready(Err(error)), }; - cx.emit(Event::CompletionDiscarded { + cx.emit(Event::CompletionsDiscarded { uuids: completions .iter() .map(|completion| completion.uuid.clone()) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 221e94370e..9c5fe7e940 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3115,7 +3115,8 @@ impl Editor { fn discard_copilot_suggestion(&mut self, cx: &mut ViewContext) -> bool { if self.has_active_copilot_suggestion(cx) { if let Some(copilot) = Copilot::global(cx) { - let file_type = self.copilot_state + let file_type = self + .copilot_state .completions .get(0) .and_then(|completion| self.language_at(completion.range.start.offset, cx)) From a6a2f9360743a9fa12b199c9b0df8eb26caf15cb Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 16 May 2023 00:34:58 -0400 Subject: [PATCH 3/9] Update telemetry client to accept copilot events --- crates/client/src/telemetry.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index 7151dcd7bb..d11a78bb62 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -86,6 +86,11 @@ pub enum ClickhouseEvent { copilot_enabled: bool, copilot_enabled_for_language: bool, }, + Copilot { + suggestion_id: String, + suggestion_accepted: bool, + file_extension: Option, + }, } #[derive(Serialize, Debug)] From f50afefed337ca13dc44bb175e90b73dfc2c997e Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 16 May 2023 00:35:21 -0400 Subject: [PATCH 4/9] Subscribe to copilot events (WIP) --- crates/copilot/src/copilot.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index b9e850b371..07c54c7785 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -47,9 +47,21 @@ pub fn init(http: Arc, node_runtime: Arc, cx: &mut }); cx.set_global(copilot.clone()); - ////////////////////////////////////// - // SUBSCRIBE TO COPILOT EVENTS HERE // - ////////////////////////////////////// + cx.subscribe(&copilot, |_, event, _| { + match event { + Event::CompletionAccepted { uuid, file_type } => { + // Build event object and pass it in + // telemetry.report_clickhouse_event(event, settings.telemetry()) + } + Event::CompletionsDiscarded { uuids, file_type } => { + for uuid in uuids { + // Build event object and pass it in + // telemetry.report_clickhouse_event(event, settings.telemetry()) + } + } + }; + }) + .detach(); cx.observe(&copilot, |handle, cx| { let status = handle.read(cx).status(); From a7fc07a8cd62570f9f44bbad1fa4bcaeb97548cf Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 16 May 2023 03:12:39 -0400 Subject: [PATCH 5/9] Init copilot with client instead of http client --- Cargo.lock | 1 + crates/copilot/Cargo.toml | 1 + crates/copilot/src/copilot.rs | 38 ++++++++++++++++++++++------------- crates/zed/src/main.rs | 3 ++- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e009cfd342..2af1a4aa36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1338,6 +1338,7 @@ dependencies = [ "anyhow", "async-compression", "async-tar", + "client", "clock", "collections", "context_menu", diff --git a/crates/copilot/Cargo.toml b/crates/copilot/Cargo.toml index bac335f7b7..1a6ec7968d 100644 --- a/crates/copilot/Cargo.toml +++ b/crates/copilot/Cargo.toml @@ -22,6 +22,7 @@ test-support = [ collections = { path = "../collections" } context_menu = { path = "../context_menu" } gpui = { path = "../gpui" } +client = { path = "../client" } language = { path = "../language" } settings = { path = "../settings" } theme = { path = "../theme" } diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index 07c54c7785..f1b547a182 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -4,6 +4,7 @@ mod sign_in; use anyhow::{anyhow, Context, Result}; use async_compression::futures::bufread::GzipDecoder; use async_tar::Archive; +use client::{ClickhouseEvent, Client}; use collections::HashMap; use futures::{channel::oneshot, future::Shared, Future, FutureExt, TryFutureExt}; use gpui::{ @@ -40,26 +41,35 @@ actions!( [Suggest, NextSuggestion, PreviousSuggestion, Reinstall] ); -pub fn init(http: Arc, node_runtime: Arc, cx: &mut AppContext) { +pub fn init(client: &Client, node_runtime: Arc, cx: &mut AppContext) { let copilot = cx.add_model({ let node_runtime = node_runtime.clone(); - move |cx| Copilot::start(http, node_runtime, cx) + move |cx| Copilot::start(client.http_client(), node_runtime, cx) }); cx.set_global(copilot.clone()); - cx.subscribe(&copilot, |_, event, _| { - match event { - Event::CompletionAccepted { uuid, file_type } => { - // Build event object and pass it in - // telemetry.report_clickhouse_event(event, settings.telemetry()) + let telemetry_settings = cx.global::().telemetry(); + let telemetry = client.telemetry(); + + cx.subscribe(&copilot, move |_, event, _| match event { + Event::CompletionAccepted { uuid, file_type } => { + let event = ClickhouseEvent::Copilot { + suggestion_id: uuid.clone(), + suggestion_accepted: true, + file_extension: file_type.clone().map(|a| a.to_string()), + }; + telemetry.report_clickhouse_event(event, telemetry_settings); + } + Event::CompletionsDiscarded { uuids, file_type } => { + for uuid in uuids { + let event = ClickhouseEvent::Copilot { + suggestion_id: uuid.clone(), + suggestion_accepted: false, + file_extension: file_type.clone().map(|a| a.to_string()), + }; + telemetry.report_clickhouse_event(event, telemetry_settings); } - Event::CompletionsDiscarded { uuids, file_type } => { - for uuid in uuids { - // Build event object and pass it in - // telemetry.report_clickhouse_event(event, settings.telemetry()) - } - } - }; + } }) .detach(); diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index f498078b52..434234f7f6 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -178,7 +178,6 @@ fn main() { vim::init(cx); terminal_view::init(cx); theme_testbench::init(cx); - copilot::init(http.clone(), node_runtime, cx); cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx)) .detach(); @@ -197,6 +196,8 @@ fn main() { cx.global::().telemetry(), ); + copilot::init(&client, node_runtime, cx); + let app_state = Arc::new(AppState { languages, themes, From 2d4b2e0844ee6415375b3f768d8e7df73e16f333 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 16 May 2023 11:51:20 -0400 Subject: [PATCH 6/9] Fix compile error --- crates/copilot/src/copilot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index f1b547a182..c7671cee7a 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -49,7 +49,7 @@ pub fn init(client: &Client, node_runtime: Arc, cx: &mut AppContext cx.set_global(copilot.clone()); let telemetry_settings = cx.global::().telemetry(); - let telemetry = client.telemetry(); + let telemetry = client.telemetry().clone(); cx.subscribe(&copilot, move |_, event, _| match event { Event::CompletionAccepted { uuid, file_type } => { From 6976d60bfed7af33a5147c910e45c756711a2204 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 16 May 2023 13:24:25 -0400 Subject: [PATCH 7/9] Rework code to contain submitting of copilot events within editor --- Cargo.lock | 1 - crates/copilot/Cargo.toml | 1 - crates/copilot/src/copilot.rs | 64 +++-------------------------------- crates/editor/src/editor.rs | 50 +++++++++++++++++++-------- crates/zed/src/main.rs | 3 +- 5 files changed, 40 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2af1a4aa36..e009cfd342 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1338,7 +1338,6 @@ dependencies = [ "anyhow", "async-compression", "async-tar", - "client", "clock", "collections", "context_menu", diff --git a/crates/copilot/Cargo.toml b/crates/copilot/Cargo.toml index 1a6ec7968d..bac335f7b7 100644 --- a/crates/copilot/Cargo.toml +++ b/crates/copilot/Cargo.toml @@ -22,7 +22,6 @@ test-support = [ collections = { path = "../collections" } context_menu = { path = "../context_menu" } gpui = { path = "../gpui" } -client = { path = "../client" } language = { path = "../language" } settings = { path = "../settings" } theme = { path = "../theme" } diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rs index c7671cee7a..65d0a19bed 100644 --- a/crates/copilot/src/copilot.rs +++ b/crates/copilot/src/copilot.rs @@ -4,7 +4,6 @@ mod sign_in; use anyhow::{anyhow, Context, Result}; use async_compression::futures::bufread::GzipDecoder; use async_tar::Archive; -use client::{ClickhouseEvent, Client}; use collections::HashMap; use futures::{channel::oneshot, future::Shared, Future, FutureExt, TryFutureExt}; use gpui::{ @@ -41,38 +40,13 @@ actions!( [Suggest, NextSuggestion, PreviousSuggestion, Reinstall] ); -pub fn init(client: &Client, node_runtime: Arc, cx: &mut AppContext) { +pub fn init(http: Arc, node_runtime: Arc, cx: &mut AppContext) { let copilot = cx.add_model({ let node_runtime = node_runtime.clone(); - move |cx| Copilot::start(client.http_client(), node_runtime, cx) + move |cx| Copilot::start(http, node_runtime, cx) }); cx.set_global(copilot.clone()); - let telemetry_settings = cx.global::().telemetry(); - let telemetry = client.telemetry().clone(); - - cx.subscribe(&copilot, move |_, event, _| match event { - Event::CompletionAccepted { uuid, file_type } => { - let event = ClickhouseEvent::Copilot { - suggestion_id: uuid.clone(), - suggestion_accepted: true, - file_extension: file_type.clone().map(|a| a.to_string()), - }; - telemetry.report_clickhouse_event(event, telemetry_settings); - } - Event::CompletionsDiscarded { uuids, file_type } => { - for uuid in uuids { - let event = ClickhouseEvent::Copilot { - suggestion_id: uuid.clone(), - suggestion_accepted: false, - file_extension: file_type.clone().map(|a| a.to_string()), - }; - telemetry.report_clickhouse_event(event, telemetry_settings); - } - } - }) - .detach(); - cx.observe(&copilot, |handle, cx| { let status = handle.read(cx).status(); cx.update_default_global::(move |filter, _cx| { @@ -284,7 +258,7 @@ impl RegisteredBuffer { #[derive(Debug)] pub struct Completion { - uuid: String, + pub uuid: String, pub range: Range, pub text: String, } @@ -296,19 +270,8 @@ pub struct Copilot { buffers: HashMap>, } -pub enum Event { - CompletionAccepted { - uuid: String, - file_type: Option>, - }, - CompletionsDiscarded { - uuids: Vec, - file_type: Option>, - }, -} - impl Entity for Copilot { - type Event = Event; + type Event = (); fn app_will_quit( &mut self, @@ -774,26 +737,18 @@ impl Copilot { pub fn accept_completion( &mut self, completion: &Completion, - file_type: Option>, cx: &mut ModelContext, ) -> Task> { let server = match self.server.as_authenticated() { Ok(server) => server, Err(error) => return Task::ready(Err(error)), }; - - cx.emit(Event::CompletionAccepted { - uuid: completion.uuid.clone(), - file_type, - }); - let request = server .lsp .request::(request::NotifyAcceptedParams { uuid: completion.uuid.clone(), }); - cx.background().spawn(async move { request.await?; Ok(()) @@ -803,22 +758,12 @@ impl Copilot { pub fn discard_completions( &mut self, completions: &[Completion], - file_type: Option>, cx: &mut ModelContext, ) -> Task> { let server = match self.server.as_authenticated() { Ok(server) => server, Err(error) => return Task::ready(Err(error)), }; - - cx.emit(Event::CompletionsDiscarded { - uuids: completions - .iter() - .map(|completion| completion.uuid.clone()) - .collect(), - file_type: file_type.clone(), - }); - let request = server .lsp @@ -828,7 +773,6 @@ impl Copilot { .map(|completion| completion.uuid.clone()) .collect(), }); - cx.background().spawn(async move { request.await?; Ok(()) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 9c5fe7e940..b4af9abb85 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3094,15 +3094,11 @@ impl Editor { if let Some((copilot, completion)) = Copilot::global(cx).zip(self.copilot_state.active_completion()) { - let language = self - .language_at(completion.range.start.offset, cx) - .map(|language| language.name()); - copilot - .update(cx, |copilot, cx| { - copilot.accept_completion(completion, language, cx) - }) + .update(cx, |copilot, cx| copilot.accept_completion(completion, cx)) .detach_and_log_err(cx); + + self.report_copilot_event(completion.uuid.clone(), true, cx) } self.insert_with_autoindent_mode(&suggestion.text.to_string(), None, cx); cx.notify(); @@ -3115,18 +3111,15 @@ impl Editor { fn discard_copilot_suggestion(&mut self, cx: &mut ViewContext) -> bool { if self.has_active_copilot_suggestion(cx) { if let Some(copilot) = Copilot::global(cx) { - let file_type = self - .copilot_state - .completions - .get(0) - .and_then(|completion| self.language_at(completion.range.start.offset, cx)) - .map(|language| language.name()); - copilot .update(cx, |copilot, cx| { - copilot.discard_completions(&self.copilot_state.completions, file_type, cx) + copilot.discard_completions(&self.copilot_state.completions, cx) }) .detach_and_log_err(cx); + + for completion in &self.copilot_state.completions { + self.report_copilot_event(completion.uuid.clone(), false, cx) + } } self.display_map @@ -6889,6 +6882,33 @@ impl Editor { .collect() } + fn report_copilot_event( + &self, + suggestion_id: String, + suggestion_accepted: bool, + cx: &AppContext, + ) { + if let Some((project, file)) = self.project.as_ref().zip( + self.buffer + .read(cx) + .as_singleton() + .and_then(|b| b.read(cx).file()), + ) { + let telemetry_settings = cx.global::().telemetry(); + let extension = Path::new(file.file_name(cx)) + .extension() + .and_then(|e| e.to_str()); + let telemetry = project.read(cx).client().telemetry().clone(); + + let event = ClickhouseEvent::Copilot { + suggestion_id, + suggestion_accepted, + file_extension: extension.map(ToString::to_string), + }; + telemetry.report_clickhouse_event(event, telemetry_settings); + } + } + fn report_editor_event(&self, name: &'static str, cx: &AppContext) { if let Some((project, file)) = self.project.as_ref().zip( self.buffer diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 434234f7f6..f498078b52 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -178,6 +178,7 @@ fn main() { vim::init(cx); terminal_view::init(cx); theme_testbench::init(cx); + copilot::init(http.clone(), node_runtime, cx); cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx)) .detach(); @@ -196,8 +197,6 @@ fn main() { cx.global::().telemetry(), ); - copilot::init(&client, node_runtime, cx); - let app_state = Arc::new(AppState { languages, themes, From afe75e8cbd750a7b18dbf6d5dfacefdaa9be7adf Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 16 May 2023 14:02:36 -0400 Subject: [PATCH 8/9] Send copilot events even if file_extension is not known at the time --- crates/editor/src/editor.rs | 39 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b4af9abb85..c51ed1a14a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -6888,25 +6888,28 @@ impl Editor { suggestion_accepted: bool, cx: &AppContext, ) { - if let Some((project, file)) = self.project.as_ref().zip( - self.buffer - .read(cx) - .as_singleton() - .and_then(|b| b.read(cx).file()), - ) { - let telemetry_settings = cx.global::().telemetry(); - let extension = Path::new(file.file_name(cx)) - .extension() - .and_then(|e| e.to_str()); - let telemetry = project.read(cx).client().telemetry().clone(); + let Some(project) = &self.project else { + return + }; - let event = ClickhouseEvent::Copilot { - suggestion_id, - suggestion_accepted, - file_extension: extension.map(ToString::to_string), - }; - telemetry.report_clickhouse_event(event, telemetry_settings); - } + // If None, we are either getting suggestions in a new, unsaved file, or in a file without an extension + let file_extension = self + .buffer + .read(cx) + .as_singleton() + .and_then(|b| b.read(cx).file()) + .and_then(|file| Path::new(file.file_name(cx)).extension()) + .and_then(|e| e.to_str()); + + let telemetry = project.read(cx).client().telemetry().clone(); + let telemetry_settings = cx.global::().telemetry(); + + let event = ClickhouseEvent::Copilot { + suggestion_id, + suggestion_accepted, + file_extension: file_extension.map(ToString::to_string), + }; + telemetry.report_clickhouse_event(event, telemetry_settings); } fn report_editor_event(&self, name: &'static str, cx: &AppContext) { From ffd503951ba4a3cc87403cf66177325aae3876ac Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 16 May 2023 17:19:05 -0400 Subject: [PATCH 9/9] Don't make events for every rejected suggestion --- crates/client/src/telemetry.rs | 2 +- crates/editor/src/editor.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/client/src/telemetry.rs b/crates/client/src/telemetry.rs index d11a78bb62..5e3c78420d 100644 --- a/crates/client/src/telemetry.rs +++ b/crates/client/src/telemetry.rs @@ -87,7 +87,7 @@ pub enum ClickhouseEvent { copilot_enabled_for_language: bool, }, Copilot { - suggestion_id: String, + suggestion_id: Option, suggestion_accepted: bool, file_extension: Option, }, diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index c51ed1a14a..ff4c0846cb 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3098,7 +3098,7 @@ impl Editor { .update(cx, |copilot, cx| copilot.accept_completion(completion, cx)) .detach_and_log_err(cx); - self.report_copilot_event(completion.uuid.clone(), true, cx) + self.report_copilot_event(Some(completion.uuid.clone()), true, cx) } self.insert_with_autoindent_mode(&suggestion.text.to_string(), None, cx); cx.notify(); @@ -3117,9 +3117,7 @@ impl Editor { }) .detach_and_log_err(cx); - for completion in &self.copilot_state.completions { - self.report_copilot_event(completion.uuid.clone(), false, cx) - } + self.report_copilot_event(None, false, cx) } self.display_map @@ -6884,7 +6882,7 @@ impl Editor { fn report_copilot_event( &self, - suggestion_id: String, + suggestion_id: Option, suggestion_accepted: bool, cx: &AppContext, ) {