Hide generate commit message button when assistant is disabled (#26519)
Release Notes: - Git Beta: Fixed the generate commit message button still showing when the assistant is disabled.
This commit is contained in:
parent
2cd970f137
commit
050f5f6723
3 changed files with 23 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5441,6 +5441,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"askpass",
|
"askpass",
|
||||||
|
"assistant_settings",
|
||||||
"buffer_diff",
|
"buffer_diff",
|
||||||
"collections",
|
"collections",
|
||||||
"component",
|
"component",
|
||||||
|
|
|
@ -19,6 +19,7 @@ test-support = ["multi_buffer/test-support"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
askpass.workspace = true
|
askpass.workspace = true
|
||||||
|
assistant_settings.workspace = true
|
||||||
buffer_diff.workspace = true
|
buffer_diff.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
component.workspace = true
|
component.workspace = true
|
||||||
|
|
|
@ -11,6 +11,7 @@ use crate::{
|
||||||
use crate::{picker_prompt, project_diff, ProjectDiff};
|
use crate::{picker_prompt, project_diff, ProjectDiff};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use askpass::AskPassDelegate;
|
use askpass::AskPassDelegate;
|
||||||
|
use assistant_settings::AssistantSettings;
|
||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use editor::commit_tooltip::CommitTooltip;
|
use editor::commit_tooltip::CommitTooltip;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ use project::{
|
||||||
Fs, Project, ProjectPath,
|
Fs, Project, ProjectPath,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::Settings as _;
|
use settings::{Settings as _, SettingsStore};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -327,6 +328,7 @@ pub struct GitPanel {
|
||||||
workspace: WeakEntity<Workspace>,
|
workspace: WeakEntity<Workspace>,
|
||||||
context_menu: Option<(Entity<ContextMenu>, Point<Pixels>, Subscription)>,
|
context_menu: Option<(Entity<ContextMenu>, Point<Pixels>, Subscription)>,
|
||||||
modal_open: bool,
|
modal_open: bool,
|
||||||
|
_settings_subscription: Subscription,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RemoteOperationGuard {
|
struct RemoteOperationGuard {
|
||||||
|
@ -443,6 +445,14 @@ impl GitPanel {
|
||||||
hide_task: None,
|
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 {
|
let mut git_panel = Self {
|
||||||
pending_remote_operations: Default::default(),
|
pending_remote_operations: Default::default(),
|
||||||
remote_operation_id: 0,
|
remote_operation_id: 0,
|
||||||
|
@ -478,6 +488,7 @@ impl GitPanel {
|
||||||
entry_count: 0,
|
entry_count: 0,
|
||||||
horizontal_scrollbar,
|
horizontal_scrollbar,
|
||||||
vertical_scrollbar,
|
vertical_scrollbar,
|
||||||
|
_settings_subscription,
|
||||||
};
|
};
|
||||||
git_panel.schedule_update(false, window, cx);
|
git_panel.schedule_update(false, window, cx);
|
||||||
git_panel
|
git_panel
|
||||||
|
@ -3590,9 +3601,14 @@ impl GitPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_language_model(cx: &Context<'_, GitPanel>) -> Option<Arc<dyn LanguageModel>> {
|
fn current_language_model(cx: &Context<'_, GitPanel>) -> Option<Arc<dyn LanguageModel>> {
|
||||||
let provider = LanguageModelRegistry::read_global(cx).active_provider()?;
|
assistant_settings::AssistantSettings::get_global(cx)
|
||||||
let model = LanguageModelRegistry::read_global(cx).active_model()?;
|
.enabled
|
||||||
provider.is_authenticated(cx).then(|| model)
|
.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 {
|
impl Render for GitPanel {
|
||||||
|
@ -4326,6 +4342,7 @@ mod tests {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
let settings_store = SettingsStore::test(cx);
|
let settings_store = SettingsStore::test(cx);
|
||||||
cx.set_global(settings_store);
|
cx.set_global(settings_store);
|
||||||
|
AssistantSettings::register(cx);
|
||||||
WorktreeSettings::register(cx);
|
WorktreeSettings::register(cx);
|
||||||
workspace::init_settings(cx);
|
workspace::init_settings(cx);
|
||||||
theme::init(LoadThemes::JustBase, cx);
|
theme::init(LoadThemes::JustBase, cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue