Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
git_ui: Add configure and docs links to commit message tooltip (#60357)
María Craig4da73e19700e
diff --git a/Cargo.lock b/Cargo.lockindex 432d250584e..480b91504c3 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -7368,6 +7368,7 @@ dependencies = ["async-channel 2.5.0","buffer_diff","call",+ "client","collections","component","ctor",diff --git a/crates/client/src/zed_urls.rs b/crates/client/src/zed_urls.rsindex 0473ff3932a..6eb69b83273 100644--- a/crates/client/src/zed_urls.rs+++ b/crates/client/src/zed_urls.rs@@ -69,6 +69,10 @@ pub fn skills_docs(cx: &App) -> String {format!("{docs_url}/ai/skills", docs_url = docs_url(cx))}+pub fn llm_provider_docs(cx: &App) -> String {+ format!("{docs_url}/ai/llm-providers", docs_url = docs_url(cx))+}+/// Returns the URL to Zed's ACP registry blog post.pub fn acp_registry_blog(cx: &App) -> String {format!(diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.tomlindex 4b6fc85041b..f46146ef8c3 100644--- a/crates/git_ui/Cargo.toml+++ b/crates/git_ui/Cargo.toml@@ -23,14 +23,15 @@ askpass.workspace = trueasync-channel.workspace = truebuffer_diff.workspace = truecall = { workspace = true, optional = true }+client.workspace = truecollections.workspace = truecomponent.workspace = truedb.workspace = trueeditor.workspace = truefile_icons.workspace = truefs.workspace = true-futures.workspace = truefutures-lite.workspace = true+futures.workspace = truefuzzy.workspace = truefuzzy_nucleo.workspace = truegit.workspace = true@@ -50,8 +51,8 @@ prompt_store.workspace = trueproto.workspace = truerand.workspace = truerelease_channel.workspace = true-remote_connection.workspace = trueremote.workspace = true+remote_connection.workspace = trueschemars.workspace = truesearch.workspace = trueserde.workspace = true@@ -67,6 +68,7 @@ theme.workspace = truetheme_settings.workspace = truetime.workspace = truetime_format.workspace = true+tracing.workspace = trueui.workspace = trueui_input.workspace = trueutil.workspace = true@@ -75,7 +77,6 @@ workspace.workspace = truezed_actions.workspace = truezeroize.workspace = trueztracing.workspace = true-tracing.workspace = true[target.'cfg(windows)'.dependencies]windows.workspace = true@@ -91,12 +92,12 @@ indoc.workspace = truepretty_assertions.workspace = trueproject = { workspace = true, features = ["test-support"] }rand.workspace = true+remote_connection = { workspace = true, features = ["test-support"] }settings = { workspace = true, features = ["test-support"] }task.workspace = trueunindent.workspace = trueworkspace = { workspace = true, features = ["test-support"] }zlog.workspace = true-remote_connection = { workspace = true, features = ["test-support"] }[package.metadata.cargo-machete]ignored = ["tracing"]diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex 0ace54e100e..445b991a132 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -13,6 +13,7 @@ use crate::{use agent_settings::{AgentSettings, UserAgentsMd};use anyhow::Context as _;use askpass::AskPassDelegate;+use client::zed_urls;use collections::{BTreeMap, HashMap, HashSet};use db::kvp::KeyValueStore;use editor::{Editor, EditorElement, EditorMode, MultiBuffer, MultiBufferOffset, SizingBehavior};@@ -4774,34 +4775,38 @@ impl GitPanel {let editor_focus_handle = self.commit_editor.focus_handle(cx);- Some(- IconButton::new("generate-commit-message", IconName::AiEdit)- .shape(ui::IconButtonShape::Square)- .icon_color(if has_commit_model_configuration_error {- Color::Disabled+ let button = IconButton::new("generate-commit-message", IconName::AiEdit)+ .shape(ui::IconButtonShape::Square)+ .icon_color(if has_commit_model_configuration_error {+ Color::Disabled+ } else {+ Color::Muted+ })+ .disabled(!can_commit || has_commit_model_configuration_error)+ .on_click(cx.listener(move |this, _event, _window, cx| {+ this.generate_commit_message(cx);+ }));++ let button = if can_commit && has_commit_model_configuration_error {+ button.hoverable_tooltip(move |_window, cx| {+ cx.new(|_| GenerateCommitMessageConfigurationTooltip).into()+ })+ } else {+ button.tooltip(move |_window, cx| {+ if !can_commit {+ Tooltip::simple("No Changes to Commit", cx)} else {- Color::Muted- })- .tooltip(move |_window, cx| {- 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,- )- }- })- .disabled(!can_commit || has_commit_model_configuration_error)- .on_click(cx.listener(move |this, _event, _window, cx| {- this.generate_commit_message(cx);- }))- .into_any_element(),- )+ Tooltip::for_action_in(+ "Generate Commit Message",+ &git::GenerateCommitMessage,+ &editor_focus_handle,+ cx,+ )+ }+ })+ };++ Some(button.into_any_element())}pub(crate) fn render_co_authors(&self, cx: &Context<Self>) -> Option<AnyElement> {@@ -7157,6 +7162,53 @@ impl GitPanel {}}+struct GenerateCommitMessageConfigurationTooltip;++impl Render for GenerateCommitMessageConfigurationTooltip {+ fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {+ ui::tooltip_container(cx, |container, _cx| {+ container+ .gap_1p5()+ .child(Label::new(+ "Configure an LLM provider to generate commit messages.",+ ))+ .child(+ h_flex()+ .gap_1()+ .child(+ Button::new("configure-commit-message-provider", "Configure Provider")+ .style(ButtonStyle::Filled)+ .layer(ElevationIndex::ModalSurface)+ .label_size(LabelSize::Small)+ .on_click(|_, window, cx| {+ window.dispatch_action(+ zed_actions::OpenSettingsAt {+ path: "llm_providers".to_string(),+ target: None,+ }+ .boxed_clone(),+ cx,+ );+ }),+ )+ .child(+ Button::new("llm-provider-docs", "See Docs")+ .style(ButtonStyle::OutlinedGhost)+ .end_icon(+ Icon::new(IconName::ArrowUpRight)+ .color(Color::Muted)+ .size(IconSize::Small),+ )+ .label_size(LabelSize::Small)+ .on_click(move |_, _, cx| {+ cx.open_url(&zed_urls::llm_provider_docs(cx))+ }),+ ),+ )+ })+ }+}+impl GitPanel {pub fn selected_file_history_target(&self) -> Option<(Entity<Repository>, RepoPath)> {let entry = self.get_selected_entry()?.status_entry()?;diff --git a/crates/ui/src/components/button/icon_button.rs b/crates/ui/src/components/button/icon_button.rsindex a05a538b4a7..2da97d4bc56 100644--- a/crates/ui/src/components/button/icon_button.rs+++ b/crates/ui/src/components/button/icon_button.rs@@ -124,6 +124,17 @@ impl IconButton {self}++ /// Use the given callback to construct a new tooltip view when the mouse hovers over this+ /// button. The tooltip itself is also hoverable and won't disappear when the user moves the+ /// mouse into the tooltip, allowing it to contain interactive elements like links or buttons.+ pub fn hoverable_tooltip(+ mut self,+ tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,+ ) -> Self {+ self.base = self.base.hoverable_tooltip(tooltip);+ self+ }}impl Disableable for IconButton {