Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
git_panel: Disable AI commit message button instead of hiding it (#46525)
Ivan Magdacc62b53ec1b0
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex 343875c60dc..19bb3251a17 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -3905,11 +3905,7 @@ impl GitPanel {&self,cx: &Context<Self>,) -> Option<AnyElement> {- if !agent_settings::AgentSettings::get_global(cx).enabled(cx)- || LanguageModelRegistry::read_global(cx)- .commit_message_model()- .is_none()- {+ if !agent_settings::AgentSettings::get_global(cx).enabled(cx) {return None;}@@ -3924,7 +3920,7 @@ impl GitPanel {.with_rotate_animation(2),).child(- Label::new("Generating Commit...")+ Label::new("Generating Commit…").size(LabelSize::Small).color(Color::Muted),)@@ -3932,25 +3928,37 @@ impl GitPanel {);}+ let model_registry = LanguageModelRegistry::read_global(cx);+ let has_commit_model_configuration_error = model_registry+ .configuration_error(model_registry.commit_message_model(), cx)+ .is_some();let can_commit = self.can_commit();+let editor_focus_handle = self.commit_editor.focus_handle(cx);+Some(IconButton::new("generate-commit-message", IconName::AiEdit).shape(ui::IconButtonShape::Square)- .icon_color(Color::Muted)+ .icon_color(if has_commit_model_configuration_error {+ Color::Disabled+ } else {+ Color::Muted+ }).tooltip(move |_window, cx| {- if can_commit {+ if !can_commit {+ Tooltip::simple("No Changes to Commit", cx)+ } else if has_commit_model_configuration_error {+ Tooltip::simple("Configure an LLM provider to generate commit messages", cx)+ } else {Tooltip::for_action_in("Generate Commit Message",&git::GenerateCommitMessage,&editor_focus_handle,cx,)- } else {- Tooltip::simple("No changes to commit", cx)}})- .disabled(!can_commit)+ .disabled(!can_commit || has_commit_model_configuration_error).on_click(cx.listener(move |this, _event, _window, cx| {this.generate_commit_message(cx);}))