mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Address review comments
This commit is contained in:
@@ -72,6 +72,7 @@ use codex_core::config::edit::ConfigEditsBuilder;
|
||||
use codex_core::config::find_codex_home;
|
||||
use codex_core::config::resolve_profile_v2_config_path;
|
||||
use codex_features::FEATURES;
|
||||
use codex_features::Feature;
|
||||
use codex_features::Stage;
|
||||
use codex_features::is_known_feature_key;
|
||||
use codex_login::AuthManager;
|
||||
@@ -868,15 +869,25 @@ impl FeatureToggles {
|
||||
let mut v = Vec::new();
|
||||
for feature in &self.enable {
|
||||
Self::validate_feature(feature)?;
|
||||
v.push(format!("features.{feature}=true"));
|
||||
let key = Self::config_override_key(feature);
|
||||
v.push(format!("{key}=true"));
|
||||
}
|
||||
for feature in &self.disable {
|
||||
Self::validate_feature(feature)?;
|
||||
v.push(format!("features.{feature}=false"));
|
||||
let key = Self::config_override_key(feature);
|
||||
v.push(format!("{key}=false"));
|
||||
}
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
fn config_override_key(feature: &str) -> String {
|
||||
if feature == Feature::SystemProxy.key() {
|
||||
format!("features.{feature}.enabled")
|
||||
} else {
|
||||
format!("features.{feature}")
|
||||
}
|
||||
}
|
||||
|
||||
fn validate_feature(feature: &str) -> anyhow::Result<()> {
|
||||
if is_known_feature_key(feature) {
|
||||
Ok(())
|
||||
@@ -3826,6 +3837,22 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn feature_toggles_system_proxy_generate_structured_overrides() {
|
||||
let toggles = FeatureToggles {
|
||||
enable: vec!["system_proxy".to_string()],
|
||||
disable: vec!["system_proxy".to_string()],
|
||||
};
|
||||
let overrides = toggles.to_overrides().expect("valid features");
|
||||
assert_eq!(
|
||||
overrides,
|
||||
vec![
|
||||
"features.system_proxy.enabled=true".to_string(),
|
||||
"features.system_proxy.enabled=false".to_string(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn feature_toggles_accept_legacy_linux_sandbox_flag() {
|
||||
let toggles = FeatureToggles {
|
||||
|
||||
@@ -73,6 +73,45 @@ async fn features_disable_writes_feature_flag_to_config() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn system_proxy_feature_toggles_preserve_mode() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let config_path = codex_home.path().join("config.toml");
|
||||
std::fs::write(
|
||||
&config_path,
|
||||
r#"[features.system_proxy]
|
||||
enabled = false
|
||||
mode = "system"
|
||||
"#,
|
||||
)?;
|
||||
|
||||
let mut cmd = codex_command(codex_home.path())?;
|
||||
cmd.args(["features", "enable", "system_proxy"])
|
||||
.assert()
|
||||
.success();
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(&config_path)?,
|
||||
r#"[features.system_proxy]
|
||||
enabled = true
|
||||
mode = "system"
|
||||
"#
|
||||
);
|
||||
|
||||
let mut cmd = codex_command(codex_home.path())?;
|
||||
cmd.args(["features", "disable", "system_proxy"])
|
||||
.assert()
|
||||
.success();
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(config_path)?,
|
||||
r#"[features.system_proxy]
|
||||
enabled = false
|
||||
mode = "system"
|
||||
"#
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn features_enable_under_development_feature_prints_warning() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
|
||||
Reference in New Issue
Block a user