ACP work
This commit is contained in:
+14
-3
@@ -2091,9 +2091,20 @@ impl AISettings {
|
||||
|
||||
pub fn is_any_ai_enabled(&self, app: &AppContext) -> bool {
|
||||
// Galaxy does not require Warp authentication for AI.
|
||||
// AI is enabled as long as the user hasn't explicitly disabled it
|
||||
// and there's no org policy blocking it.
|
||||
*self.is_any_ai_enabled && !self.is_ai_disabled_due_to_remote_session_org_policy(app)
|
||||
// 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)
|
||||
}
|
||||
|
||||
/// 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()
|
||||
|| (cfg!(unix)
|
||||
&& FeatureFlag::AgentClientProtocol.is_enabled()
|
||||
&& *self.acp_enabled.value())
|
||||
}
|
||||
|
||||
pub fn default_session_mode(&self, app: &AppContext) -> DefaultSessionMode {
|
||||
|
||||
@@ -422,6 +422,47 @@ fn orchestration_is_enabled_when_ai_is_enabled() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ai_is_disabled_without_an_enabled_runtime() {
|
||||
let _acp_flag = FeatureFlag::AgentClientProtocol.override_enabled(true);
|
||||
App::test((), |mut app| async move {
|
||||
initialize_settings_for_tests(&mut app);
|
||||
add_ai_enablement_dependencies_for_test(&mut app);
|
||||
|
||||
AISettings::handle(&app).update(&mut app, |settings, ctx| {
|
||||
settings
|
||||
.bedrock_enabled
|
||||
.set_value(false, ctx)
|
||||
.expect("Bedrock setting should update");
|
||||
settings
|
||||
.openai_enabled
|
||||
.set_value(false, ctx)
|
||||
.expect("OpenAI setting should update");
|
||||
settings
|
||||
.acp_enabled
|
||||
.set_value(false, ctx)
|
||||
.expect("ACP setting should update");
|
||||
});
|
||||
|
||||
AISettings::handle(&app).read(&app, |settings, ctx| {
|
||||
assert!(!settings.has_enabled_ai_runtime());
|
||||
assert!(!settings.is_any_ai_enabled(ctx));
|
||||
});
|
||||
|
||||
AISettings::handle(&app).update(&mut app, |settings, ctx| {
|
||||
settings
|
||||
.acp_enabled
|
||||
.set_value(true, ctx)
|
||||
.expect("ACP setting should update");
|
||||
});
|
||||
|
||||
AISettings::handle(&app).read(&app, |settings, ctx| {
|
||||
assert!(settings.has_enabled_ai_runtime());
|
||||
assert!(settings.is_any_ai_enabled(ctx));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_should_display_quota_reset_banner_with_empty_history() {
|
||||
App::test((), |mut app| async move {
|
||||
|
||||
Reference in New Issue
Block a user