diff --git a/crates/edit_prediction_ui/src/edit_prediction_button.rs b/crates/edit_prediction_ui/src/edit_prediction_button.rs index d6772847ffb861038ee581bebac05bdf07118d9f..7f9415763de55439e081dff72cabe09770ae5c85 100644 --- a/crates/edit_prediction_ui/src/edit_prediction_button.rs +++ b/crates/edit_prediction_ui/src/edit_prediction_button.rs @@ -630,6 +630,28 @@ impl EditPredictionButton { menu } + fn add_configure_providers_item(&self, menu: ContextMenu) -> ContextMenu { + menu.separator().item( + ContextMenuEntry::new("Configure Providers") + .icon(IconName::Settings) + .icon_position(IconPosition::Start) + .icon_color(Color::Muted) + .handler(move |window, cx| { + telemetry::event!( + "Edit Prediction Menu Action", + action = "configure_providers", + ); + window.dispatch_action( + OpenSettingsAt { + path: "edit_predictions.providers".to_string(), + } + .boxed_clone(), + cx, + ); + }), + ) + } + pub fn build_copilot_start_menu( &mut self, window: &mut Window, @@ -637,39 +659,38 @@ impl EditPredictionButton { ) -> Entity { let fs = self.fs.clone(); let project = self.project.clone(); - ContextMenu::build(window, cx, |menu, _, _| { - menu.entry("Sign In to Copilot", None, move |window, cx| { - telemetry::event!( - "Edit Prediction Menu Action", - action = "sign_in", - provider = "copilot", - ); - if let Some(copilot) = EditPredictionStore::try_global(cx).and_then(|store| { - store.update(cx, |this, cx| { - this.start_copilot_for_project(&project.upgrade()?, cx) - }) - }) { - copilot_ui::initiate_sign_in(copilot, window, cx); - } - }) - .entry("Disable Copilot", None, { - let fs = fs.clone(); - move |_window, cx| { + ContextMenu::build(window, cx, |menu, _, cx| { + let menu = menu + .entry("Sign In to Copilot", None, move |window, cx| { telemetry::event!( "Edit Prediction Menu Action", - action = "disable_provider", + action = "sign_in", provider = "copilot", ); - hide_copilot(fs.clone(), cx) - } - }) - .separator() - .entry("Use Zed AI", None, { - let fs = fs.clone(); - move |_window, cx| { - set_completion_provider(fs.clone(), cx, EditPredictionProvider::Zed) - } - }) + if let Some(copilot) = EditPredictionStore::try_global(cx).and_then(|store| { + store.update(cx, |this, cx| { + this.start_copilot_for_project(&project.upgrade()?, cx) + }) + }) { + copilot_ui::initiate_sign_in(copilot, window, cx); + } + }) + .entry("Disable Copilot", None, { + let fs = fs.clone(); + move |_window, cx| { + telemetry::event!( + "Edit Prediction Menu Action", + action = "disable_provider", + provider = "copilot", + ); + hide_copilot(fs.clone(), cx) + } + }); + + let menu = + self.add_provider_switching_section(menu, EditPredictionProvider::Copilot, cx); + let menu = self.add_configure_providers_item(menu); + menu }) } @@ -1008,7 +1029,9 @@ impl EditPredictionButton { let menu = self.add_provider_switching_section(menu, EditPredictionProvider::Copilot, cx); - menu.separator() + let menu = self.add_configure_providers_item(menu); + let menu = menu + .separator() .item( ContextMenuEntry::new("Copilot: Next Edit Suggestions") .toggleable(IconPosition::Start, next_edit_suggestions) @@ -1034,7 +1057,8 @@ impl EditPredictionButton { "Go to Copilot Settings", OpenBrowser { url: settings_url }.boxed_clone(), ) - .action("Sign Out", copilot::SignOut.boxed_clone()) + .action("Sign Out", copilot::SignOut.boxed_clone()); + menu }) } @@ -1048,6 +1072,7 @@ impl EditPredictionButton { let menu = self.add_provider_switching_section(menu, EditPredictionProvider::Codestral, cx); + let menu = self.add_configure_providers_item(menu); menu }) } @@ -1290,26 +1315,7 @@ impl EditPredictionButton { } } - menu = menu.separator().item( - ContextMenuEntry::new("Configure Providers") - .icon(IconName::Settings) - .icon_position(IconPosition::Start) - .icon_color(Color::Muted) - .handler(move |window, cx| { - telemetry::event!( - "Edit Prediction Menu Action", - action = "configure_providers", - ); - window.dispatch_action( - OpenSettingsAt { - path: "edit_predictions.providers".to_string(), - } - .boxed_clone(), - cx, - ); - }), - ); - + let menu = self.add_configure_providers_item(menu); menu }) }