Lightweight coding agent that runs in your terminal
Rust
chore: clarify web_search deprecation notices and consolidate tests (#11224)
sayan-oaia1b8e34938a2
diff --git a/codex-rs/core/src/features.rs b/codex-rs/core/src/features.rsindex 3cab14d1fa..7ef7485ace 100644--- a/codex-rs/core/src/features.rs+++ b/codex-rs/core/src/features.rs@@ -356,7 +356,8 @@ fn legacy_usage_notice(alias: &str, feature: Feature) -> (String, Option<String>}_ => alias,};- let summary = format!("`{label}` is deprecated. Use `web_search` instead.");+ let summary =+ format!("`{label}` is deprecated because web search is enabled by default.");(summary, Some(web_search_details().to_string()))}_ => {@@ -374,7 +375,7 @@ fn legacy_usage_notice(alias: &str, feature: Feature) -> (String, Option<String>}fn web_search_details() -> &'static str {- "Set `web_search` to `\"live\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml."+ "Set `web_search` to `\"live\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it."}/// Keys accepted in `[features]` tables.diff --git a/codex-rs/core/tests/suite/deprecation_notice.rs b/codex-rs/core/tests/suite/deprecation_notice.rsindex a8323fcd71..0e4ffd88b7 100644--- a/codex-rs/core/tests/suite/deprecation_notice.rs+++ b/codex-rs/core/tests/suite/deprecation_notice.rs@@ -113,75 +113,43 @@ async fn emits_deprecation_notice_for_experimental_instructions_file() -> anyhow}#[tokio::test(flavor = "multi_thread", worker_threads = 2)]-async fn emits_deprecation_notice_for_web_search_feature_flags() -> anyhow::Result<()> {+async fn emits_deprecation_notice_for_web_search_feature_flag_values() -> anyhow::Result<()> {skip_if_no_network!(Ok(()));- let server = start_mock_server().await;-- let mut builder = test_codex().with_config(|config| {- let mut entries = BTreeMap::new();- entries.insert("web_search_request".to_string(), true);- config.features.apply_map(&entries);- });-- let TestCodex { codex, .. } = builder.build(&server).await?;-- let notice = wait_for_event_match(&codex, |event| match event {- EventMsg::DeprecationNotice(ev) if ev.summary.contains("[features].web_search_request") => {- Some(ev.clone())- }- _ => None,- })- .await;-- let DeprecationNoticeEvent { summary, details } = notice;- assert_eq!(- summary,- "`[features].web_search_request` is deprecated. Use `web_search` instead.".to_string(),- );- assert_eq!(- details.as_deref(),- Some(- "Set `web_search` to `\"live\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml."- ),- );-- Ok(())-}--#[tokio::test(flavor = "multi_thread", worker_threads = 2)]-async fn emits_deprecation_notice_for_disabled_web_search_feature_flag() -> anyhow::Result<()> {- skip_if_no_network!(Ok(()));-- let server = start_mock_server().await;-- let mut builder = test_codex().with_config(|config| {- let mut entries = BTreeMap::new();- entries.insert("web_search_request".to_string(), false);- config.features.apply_map(&entries);- });-- let TestCodex { codex, .. } = builder.build(&server).await?;-- let notice = wait_for_event_match(&codex, |event| match event {- EventMsg::DeprecationNotice(ev) if ev.summary.contains("[features].web_search_request") => {- Some(ev.clone())- }- _ => None,- })- .await;-- let DeprecationNoticeEvent { summary, details } = notice;- assert_eq!(- summary,- "`[features].web_search_request` is deprecated. Use `web_search` instead.".to_string(),- );- assert_eq!(- details.as_deref(),- Some(- "Set `web_search` to `\"live\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml."- ),- );+ for enabled in [true, false] {+ let server = start_mock_server().await;++ let mut builder = test_codex().with_config(move |config| {+ let mut entries = BTreeMap::new();+ entries.insert("web_search_request".to_string(), enabled);+ config.features.apply_map(&entries);+ });++ let TestCodex { codex, .. } = builder.build(&server).await?;++ let notice = wait_for_event_match(&codex, |event| match event {+ EventMsg::DeprecationNotice(ev)+ if ev.summary.contains("[features].web_search_request") =>+ {+ Some(ev.clone())+ }+ _ => None,+ })+ .await;++ let DeprecationNoticeEvent { summary, details } = notice;+ assert_eq!(+ summary,+ "`[features].web_search_request` is deprecated because web search is enabled by default."+ .to_string(),+ );+ assert_eq!(+ details.as_deref(),+ Some(+ "Set `web_search` to `\"live\"`, `\"cached\"`, or `\"disabled\"` at the top level (or under a profile) in config.toml if you want to override it."+ ),+ );+ }Ok(())}