git_ui: Disable commit actions during commit message generation (#51727)

Release Notes:

- Add disable commit actions during commit message generation

---------

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Co-authored-by: Cole Miller <cole@zed.dev>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-07-18 20:06:31 +00:00
1 parent 80a1add64b
commit aa0923404f
2 files changed
+25 -9

No files matched your search

+12 -4
View File
@@ -268,15 +268,19 @@ impl CommitModal {
&self,
id: impl Into<ElementId>,
keybinding_target: Option<FocusHandle>,
disabled: bool,
) -> impl IntoElement {
let menu_open = self.commit_menu_handle.is_deployed();
PopoverMenu::new(id.into())
.with_handle(self.commit_menu_handle.clone())
.trigger(crate::render_split_button_chevron_trigger(
"modal-commit-split-button-right",
menu_open,
))
.trigger(
crate::render_split_button_chevron_trigger(
"modal-commit-split-button-right",
menu_open,
)
.disabled(disabled),
)
.menu({
let git_panel_entity = self.git_panel.clone();
move |window, cx| {
@@ -343,6 +347,7 @@ impl CommitModal {
is_amend_pending,
is_signoff_enabled,
workspace,
is_generating,
) = self.git_panel.update(cx, |git_panel, cx| {
let (can_commit, tooltip) = git_panel.configure_commit_button(cx);
let title = git_panel.commit_button_title();
@@ -351,6 +356,7 @@ impl CommitModal {
let active_repo = git_panel.active_repository.clone();
let is_amend_pending = git_panel.amend_pending();
let is_signoff_enabled = git_panel.signoff_enabled();
let is_generating = git_panel.is_generating_commit_message();
(
can_commit,
tooltip,
@@ -361,6 +367,7 @@ impl CommitModal {
is_amend_pending,
is_signoff_enabled,
git_panel.workspace.clone(),
is_generating,
)
});
@@ -478,6 +485,7 @@ impl CommitModal {
self.render_git_commit_menu(
format!("split-button-right-{}", commit_label),
Some(focus_handle),
is_generating,
)
.into_any_element(),
)),
+13 -5
View File
@@ -5344,15 +5344,16 @@ impl GitPanel {
&self,
id: impl Into<ElementId>,
keybinding_target: Option<FocusHandle>,
disabled: bool,
cx: &mut Context<Self>,
) -> impl IntoElement {
let menu_open = self.commit_menu_handle.is_deployed();
PopoverMenu::new(id.into())
.trigger(crate::render_split_button_chevron_trigger(
"commit-split-button-right",
menu_open,
))
.trigger(
crate::render_split_button_chevron_trigger("commit-split-button-right", menu_open)
.disabled(disabled),
)
.with_handle(self.commit_menu_handle.clone())
.menu({
let git_panel = cx.entity();
@@ -5401,8 +5402,14 @@ impl GitPanel {
})
}
pub fn is_generating_commit_message(&self) -> bool {
self.generate_commit_message_task.is_some()
}
pub fn configure_commit_button(&self, cx: &mut Context<Self>) -> (bool, &'static str) {
if self.has_unstaged_conflicts() {
if self.generate_commit_message_task.is_some() {
(false, "Generating commit message...")
} else if self.has_unstaged_conflicts() {
(false, "You must resolve conflicts before committing")
} else if !self.has_staged_changes() && !self.has_tracked_changes() && !self.amend_pending {
(false, "No changes to commit")
@@ -5896,6 +5903,7 @@ impl GitPanel {
self.render_git_commit_menu(
ElementId::Name(format!("split-button-right-{}", title).into()),
Some(commit_tooltip_focus_handle),
self.generate_commit_message_task.is_some(),
cx,
)
.into_any_element(),