Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Hide generate commit message button when assistant is disabled (#26519)
Mikayla Maki050f5f6723c9
diff --git a/Cargo.lock b/Cargo.lockindex 959ea95ee74..2388f9d211d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -5441,6 +5441,7 @@ version = "0.1.0"dependencies = ["anyhow","askpass",+ "assistant_settings","buffer_diff","collections","component",diff --git a/crates/git_ui/Cargo.toml b/crates/git_ui/Cargo.tomlindex ddff1f440e0..4d7d300d19e 100644--- a/crates/git_ui/Cargo.toml+++ b/crates/git_ui/Cargo.toml@@ -19,6 +19,7 @@ test-support = ["multi_buffer/test-support"][dependencies]anyhow.workspace = trueaskpass.workspace = true+assistant_settings.workspace = truebuffer_diff.workspace = truecollections.workspace = truecomponent.workspace = truediff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex d46957c59f1..7efb74ef014 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -11,6 +11,7 @@ use crate::{use crate::{picker_prompt, project_diff, ProjectDiff};use anyhow::Result;use askpass::AskPassDelegate;+use assistant_settings::AssistantSettings;use db::kvp::KEY_VALUE_STORE;use editor::commit_tooltip::CommitTooltip;@@ -49,7 +50,7 @@ use project::{Fs, Project, ProjectPath,};use serde::{Deserialize, Serialize};-use settings::Settings as _;+use settings::{Settings as _, SettingsStore};use std::cell::RefCell;use std::future::Future;use std::path::{Path, PathBuf};@@ -327,6 +328,7 @@ pub struct GitPanel {workspace: WeakEntity<Workspace>,context_menu: Option<(Entity<ContextMenu>, Point<Pixels>, Subscription)>,modal_open: bool,+ _settings_subscription: Subscription,}struct RemoteOperationGuard {@@ -443,6 +445,14 @@ impl GitPanel {hide_task: None,};+ let mut assistant_enabled = AssistantSettings::get_global(cx).enabled;+ let _settings_subscription = cx.observe_global::<SettingsStore>(move |_, cx| {+ if assistant_enabled != AssistantSettings::get_global(cx).enabled {+ assistant_enabled = AssistantSettings::get_global(cx).enabled;+ cx.notify();+ }+ });+let mut git_panel = Self {pending_remote_operations: Default::default(),remote_operation_id: 0,@@ -478,6 +488,7 @@ impl GitPanel {entry_count: 0,horizontal_scrollbar,vertical_scrollbar,+ _settings_subscription,};git_panel.schedule_update(false, window, cx);git_panel@@ -3590,9 +3601,14 @@ impl GitPanel {}fn current_language_model(cx: &Context<'_, GitPanel>) -> Option<Arc<dyn LanguageModel>> {- let provider = LanguageModelRegistry::read_global(cx).active_provider()?;- let model = LanguageModelRegistry::read_global(cx).active_model()?;- provider.is_authenticated(cx).then(|| model)+ assistant_settings::AssistantSettings::get_global(cx)+ .enabled+ .then(|| {+ let provider = LanguageModelRegistry::read_global(cx).active_provider()?;+ let model = LanguageModelRegistry::read_global(cx).active_model()?;+ provider.is_authenticated(cx).then(|| model)+ })+ .flatten()}impl Render for GitPanel {@@ -4326,6 +4342,7 @@ mod tests {cx.update(|cx| {let settings_store = SettingsStore::test(cx);cx.set_global(settings_store);+ AssistantSettings::register(cx);WorktreeSettings::register(cx);workspace::init_settings(cx);theme::init(LoadThemes::JustBase, cx);