mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
codex: fix lenient enum CI fallout
Address clippy and compile failures from wrapping config enums in Lenient. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -50,6 +50,7 @@ use codex_app_server_protocol::TurnStartedNotification;
|
||||
use codex_app_server_protocol::TurnStatus;
|
||||
use codex_app_server_protocol::UserInput as V2UserInput;
|
||||
use codex_app_server_protocol::WarningNotification;
|
||||
use codex_config::Lenient;
|
||||
use codex_config::config_toml::ConfigToml;
|
||||
use codex_core::personality_migration::PERSONALITY_MIGRATION_FILENAME;
|
||||
use codex_features::FEATURES;
|
||||
@@ -1323,7 +1324,10 @@ async fn turn_start_uses_migrated_pragmatic_personality_without_override_v2() ->
|
||||
let persisted_toml: ConfigToml = toml::from_str(&std::fs::read_to_string(
|
||||
codex_home.path().join("config.toml"),
|
||||
)?)?;
|
||||
assert_eq!(persisted_toml.personality, Some(Personality::Pragmatic));
|
||||
assert_eq!(
|
||||
persisted_toml.personality,
|
||||
Some(Lenient::from(Personality::Pragmatic))
|
||||
);
|
||||
assert!(
|
||||
codex_home
|
||||
.path()
|
||||
|
||||
@@ -510,27 +510,21 @@ impl From<ConfigToml> for UserSavedConfig {
|
||||
.collect();
|
||||
|
||||
Self {
|
||||
approval_policy: config_toml
|
||||
.approval_policy
|
||||
.and_then(|value| value.into_valid()),
|
||||
sandbox_mode: config_toml
|
||||
.sandbox_mode
|
||||
.and_then(|value| value.into_valid()),
|
||||
approval_policy: config_toml.approval_policy.and_then(Lenient::into_valid),
|
||||
sandbox_mode: config_toml.sandbox_mode.and_then(Lenient::into_valid),
|
||||
sandbox_settings: config_toml.sandbox_workspace_write.map(From::from),
|
||||
forced_chatgpt_workspace_id: config_toml.forced_chatgpt_workspace_id,
|
||||
forced_login_method: config_toml
|
||||
.forced_login_method
|
||||
.and_then(|value| value.into_valid()),
|
||||
.and_then(Lenient::into_valid),
|
||||
model: config_toml.model,
|
||||
model_reasoning_effort: config_toml
|
||||
.model_reasoning_effort
|
||||
.and_then(|value| value.into_valid()),
|
||||
.and_then(Lenient::into_valid),
|
||||
model_reasoning_summary: config_toml
|
||||
.model_reasoning_summary
|
||||
.and_then(|value| value.into_valid()),
|
||||
model_verbosity: config_toml
|
||||
.model_verbosity
|
||||
.and_then(|value| value.into_valid()),
|
||||
.and_then(Lenient::into_valid),
|
||||
model_verbosity: config_toml.model_verbosity.and_then(Lenient::into_valid),
|
||||
tools: config_toml.tools.map(From::from),
|
||||
profile: config_toml.profile,
|
||||
profiles,
|
||||
|
||||
@@ -79,18 +79,14 @@ impl From<ConfigProfile> for codex_app_server_protocol::Profile {
|
||||
Self {
|
||||
model: config_profile.model,
|
||||
model_provider: config_profile.model_provider,
|
||||
approval_policy: config_profile
|
||||
.approval_policy
|
||||
.and_then(|value| value.into_valid()),
|
||||
approval_policy: config_profile.approval_policy.and_then(Lenient::into_valid),
|
||||
model_reasoning_effort: config_profile
|
||||
.model_reasoning_effort
|
||||
.and_then(|value| value.into_valid()),
|
||||
.and_then(Lenient::into_valid),
|
||||
model_reasoning_summary: config_profile
|
||||
.model_reasoning_summary
|
||||
.and_then(|value| value.into_valid()),
|
||||
model_verbosity: config_profile
|
||||
.model_verbosity
|
||||
.and_then(|value| value.into_valid()),
|
||||
.and_then(Lenient::into_valid),
|
||||
model_verbosity: config_profile.model_verbosity.and_then(Lenient::into_valid),
|
||||
chatgpt_base_url: config_profile.chatgpt_base_url,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3111,7 +3111,10 @@ async fn feedback_enabled_defaults_to_true() -> std::io::Result<()> {
|
||||
fn web_search_mode_defaults_to_none_if_unset() {
|
||||
let features = Features::with_defaults();
|
||||
|
||||
assert_eq!(resolve_web_search_mode(None, &features), None);
|
||||
assert_eq!(
|
||||
resolve_web_search_mode(/*configured_mode*/ None, &features),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2532,14 +2532,12 @@ impl Config {
|
||||
value.into_valid_with_warning("approval_policy", &mut startup_warnings)
|
||||
}) {
|
||||
approval_policy
|
||||
} else if active_project.is_trusted() {
|
||||
AskForApproval::OnRequest
|
||||
} else if active_project.is_untrusted() {
|
||||
AskForApproval::UnlessTrusted
|
||||
} else {
|
||||
if active_project.is_trusted() {
|
||||
AskForApproval::OnRequest
|
||||
} else if active_project.is_untrusted() {
|
||||
AskForApproval::UnlessTrusted
|
||||
} else {
|
||||
AskForApproval::default()
|
||||
}
|
||||
AskForApproval::default()
|
||||
};
|
||||
if !approval_policy_was_explicit
|
||||
&& let Err(err) = constrained_approval_policy.can_set(&approval_policy)
|
||||
|
||||
@@ -149,7 +149,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
lock.model_reasoning_effort
|
||||
.clone()
|
||||
.and_then(|value| value.into_valid()),
|
||||
.and_then(codex_config::Lenient::into_valid),
|
||||
sc.collaboration_mode.reasoning_effort()
|
||||
);
|
||||
assert_eq!(lock.profile, None);
|
||||
|
||||
@@ -23,7 +23,7 @@ use tokio::io::AsyncWriteExt;
|
||||
const TEST_TIMESTAMP: &str = "2025-01-01T00-00-00";
|
||||
|
||||
fn valid_lenient<T>(value: Option<Lenient<T>>) -> Option<T> {
|
||||
value.and_then(|value| value.into_valid())
|
||||
value.and_then(Lenient::into_valid)
|
||||
}
|
||||
|
||||
async fn read_config_toml(codex_home: &Path) -> io::Result<ConfigToml> {
|
||||
|
||||
Reference in New Issue
Block a user