Polish provider setup and local-first settings
This commit is contained in:
+38
-15
@@ -1167,15 +1167,16 @@ impl settings_value::SettingsValue for AcpAgentSettings {}
|
||||
// Nested ACP discovery data is intentionally persisted as one setting so refreshes are atomic.
|
||||
|
||||
define_settings_group!(AISettings, settings: [
|
||||
// If `false`, all AI features are disabled.
|
||||
// Legacy compatibility value. Effective AI availability is derived from configured,
|
||||
// enabled providers rather than this historical global switch.
|
||||
is_any_ai_enabled: IsAnyAIEnabled {
|
||||
type: bool,
|
||||
default: false,
|
||||
default: true,
|
||||
supported_platforms: SupportedPlatforms::ALL,
|
||||
sync_to_cloud: SyncToCloud::Never,
|
||||
private: false,
|
||||
toml_path: "agents.warp_agent.is_any_ai_enabled",
|
||||
description: "Controls whether all AI features are enabled.",
|
||||
description: "Legacy global AI enablement value retained for settings compatibility.",
|
||||
},
|
||||
// This field should not be referenced directly to lookup active AI enablement -- use the
|
||||
// `is_active_ai_enabled()` getter.
|
||||
@@ -1206,7 +1207,7 @@ define_settings_group!(AISettings, settings: [
|
||||
// This is only used when `FeatureFlag::AgentView` is enabled.
|
||||
nld_in_terminal_enabled_internal: NLDInTerminalEnabled {
|
||||
type: bool,
|
||||
default: false,
|
||||
default: true,
|
||||
supported_platforms: SupportedPlatforms::ALL,
|
||||
sync_to_cloud: SyncToCloud::Never,
|
||||
private: false,
|
||||
@@ -2338,11 +2339,35 @@ impl AISettings {
|
||||
|
||||
pub fn is_any_ai_enabled(&self, app: &AppContext) -> bool {
|
||||
// Galaxy does not require Warp authentication for AI.
|
||||
// AI is enabled only when the user hasn't explicitly disabled it, at least one local
|
||||
// runtime is enabled, and there's no org policy blocking it.
|
||||
*self.is_any_ai_enabled
|
||||
&& self.has_enabled_ai_runtime()
|
||||
&& !self.is_ai_disabled_due_to_remote_session_org_policy(app)
|
||||
// Configuring and enabling a provider is the single source of truth for AI availability.
|
||||
self.has_enabled_ai_runtime() && !self.is_ai_disabled_due_to_remote_session_org_policy(app)
|
||||
}
|
||||
|
||||
/// Returns whether an OpenAI-compatible provider is enabled. The legacy global switch is
|
||||
/// consulted only for the legacy single-endpoint configuration, which has no per-provider
|
||||
/// enablement field.
|
||||
pub fn is_openai_provider_enabled(&self) -> bool {
|
||||
if !self.openai_providers.value().is_empty() {
|
||||
return self
|
||||
.openai_providers
|
||||
.value()
|
||||
.iter()
|
||||
.any(|provider| provider.enabled);
|
||||
}
|
||||
|
||||
*self.openai_enabled.value()
|
||||
}
|
||||
|
||||
/// Returns whether an OpenAI-compatible provider is enabled and has at least one enabled model.
|
||||
pub fn has_enabled_openai_provider(&self) -> bool {
|
||||
if !self.openai_providers.value().is_empty() {
|
||||
return self.openai_providers.value().iter().any(|provider| {
|
||||
provider.enabled && provider.models.iter().any(|model| model.enabled)
|
||||
});
|
||||
}
|
||||
|
||||
self.is_openai_provider_enabled()
|
||||
&& self.openai_models.value().iter().any(|model| model.enabled)
|
||||
}
|
||||
|
||||
pub(crate) fn configured_acp_providers(&self) -> Vec<AcpProviderConfig> {
|
||||
@@ -2409,11 +2434,11 @@ impl AISettings {
|
||||
|
||||
/// Returns whether Galaxy has a local model provider or agent runtime enabled.
|
||||
pub fn has_enabled_ai_runtime(&self) -> bool {
|
||||
*self.bedrock_enabled.value()
|
||||
|| *self.openai_enabled.value()
|
||||
(*self.bedrock_enabled.value() && !self.bedrock_models.value().is_empty())
|
||||
|| self.has_enabled_openai_provider()
|
||||
|| (cfg!(unix)
|
||||
&& FeatureFlag::AgentClientProtocol.is_enabled()
|
||||
&& *self.acp_enabled.value())
|
||||
&& !self.enabled_acp_providers().is_empty())
|
||||
}
|
||||
|
||||
pub fn default_session_mode(&self, app: &AppContext) -> DefaultSessionMode {
|
||||
@@ -2465,9 +2490,7 @@ impl AISettings {
|
||||
}
|
||||
|
||||
pub fn is_active_ai_enabled(&self, app: &galaxyui::AppContext) -> bool {
|
||||
self.is_any_ai_enabled(app)
|
||||
&& *self.is_active_ai_enabled_internal
|
||||
&& AppExecutionMode::as_ref(app).allows_active_ai()
|
||||
self.is_any_ai_enabled(app) && AppExecutionMode::as_ref(app).allows_active_ai()
|
||||
}
|
||||
|
||||
pub fn is_prompt_suggestions_enabled(&self, app: &galaxyui::AppContext) -> bool {
|
||||
|
||||
@@ -433,6 +433,21 @@ fn orchestration_is_enabled_when_ai_is_enabled() {
|
||||
initialize_settings_for_tests(&mut app);
|
||||
add_ai_enablement_dependencies_for_test(&mut app);
|
||||
|
||||
AISettings::handle(&app).update(&mut app, |settings, ctx| {
|
||||
settings
|
||||
.bedrock_models
|
||||
.set_value(
|
||||
vec![BedrockModelConfig {
|
||||
model_id: "test-model".to_string(),
|
||||
display_name: "Test model".to_string(),
|
||||
vision_supported: false,
|
||||
use_rig: false,
|
||||
}],
|
||||
ctx,
|
||||
)
|
||||
.expect("Bedrock models should update");
|
||||
});
|
||||
|
||||
AISettings::handle(&app).read(&app, |settings, ctx| {
|
||||
assert!(settings.is_orchestration_enabled(ctx));
|
||||
});
|
||||
|
||||
@@ -86,38 +86,6 @@ impl SettingsInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate NLD settings when AgentView is enabled.
|
||||
//
|
||||
// Explicitly set `nld_in_terminal_enabled_internal` for all users if
|
||||
// it has not previously been set.
|
||||
//
|
||||
// For existing users, when the old, previously-global autodetection setting
|
||||
// (`ai_autodetection_enabled_internal`) true, set `nld_in_terminal_enabled_internal` to
|
||||
// true. Otherwise, explicitly set to `false`.
|
||||
//
|
||||
// Any further user modification of the setting will be via explicit update, so it'll
|
||||
// be exempt from this logic, which is effectively one-time upon first startup of a binary
|
||||
// containing this logic.
|
||||
//
|
||||
// TODO(zachbai): Remove this approximately 6 weeks from 2/5/26.
|
||||
if FeatureFlag::AgentView.is_enabled() {
|
||||
AISettings::handle(ctx).update(ctx, |ai_settings, ctx| {
|
||||
if ai_settings
|
||||
.nld_in_terminal_enabled_internal
|
||||
.is_value_explicitly_set()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let is_existing_user = auth_state.is_onboarded() == Some(true);
|
||||
let was_global_autodetection_enabled_for_existing_user =
|
||||
*ai_settings.ai_autodetection_enabled_internal && is_existing_user;
|
||||
report_if_error!(ai_settings
|
||||
.nld_in_terminal_enabled_internal
|
||||
.set_value(was_global_autodetection_enabled_for_existing_user, ctx));
|
||||
});
|
||||
}
|
||||
|
||||
// Migrate the old `KeepThinkingExpanded` bool setting to the new
|
||||
// `ThinkingDisplayMode` enum setting.
|
||||
//
|
||||
|
||||
@@ -14,8 +14,7 @@ use crate::themes::theme::{RespectSystemTheme, SelectedSystemThemes, ThemeKind};
|
||||
define_settings_group!(ThemeSettings, settings: [
|
||||
theme_kind: Theme {
|
||||
type: ThemeKind,
|
||||
// Note that for new users, we now override this default value in SettingsInitializer
|
||||
// to set the default theme to Phenomenon.
|
||||
// New installations start with Galaxy's built-in brand theme.
|
||||
default: ThemeKind::default(),
|
||||
supported_platforms: SupportedPlatforms::ALL,
|
||||
sync_to_cloud: SyncToCloud::Never,
|
||||
|
||||
Reference in New Issue
Block a user