From cc62b53ec1b0699b5a28b2ed9bb01810bf80fd42 Mon Sep 17 00:00:00 2001 From: Ivan Magda Date: Thu, 15 Jan 2026 16:15:01 +0300 Subject: [PATCH] git_panel: Disable AI commit message button instead of hiding it (#46525) Closes #46142 Release Notes: - Fixed AI commit message button in Git panel being hidden instead of disabled when no AI provider is configured. The button now remains visible with a tooltip explaining how to enable the feature. Screenshot: Screenshot 2026-01-10 at 18 16 12 --------- Co-authored-by: Danilo Leal --- crates/git_ui/src/git_panel.rs | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 343875c60dcc16c23007e37c42ffe8f74e5e3609..19bb3251a17f32219c12448a85ba321bafd3ba75 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, ) -> Option { - 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); }))