From 93790a5de6b328a782b66515bc41ca2cc36d1c58 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 16 Jun 2026 17:00:55 +0000 Subject: [PATCH] tests: adapt remote path followups to current APIs --- .../src/protocol/common.rs | 5 +---- .../app-server/tests/suite/v2/thread_start.rs | 21 ++++++------------- codex-rs/core/src/session/tests.rs | 3 +-- codex-rs/core/src/session/turn_context.rs | 2 +- .../remote_env_windows_test.rs | 3 ++- codex-rs/exec/src/lib_tests.rs | 3 +-- codex-rs/tui/src/app_server_session.rs | 10 ++++----- 7 files changed, 17 insertions(+), 30 deletions(-) diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rs index 49a5b5671e..003284b53b 100644 --- a/codex-rs/app-server-protocol/src/protocol/common.rs +++ b/codex-rs/app-server-protocol/src/protocol/common.rs @@ -2516,10 +2516,7 @@ mod tests { model: "gpt-5".to_string(), model_provider: "openai".to_string(), service_tier: None, - cwd: codex_utils_path_uri::ApiPathString::from_abs_path( - &cwd, - codex_utils_path_uri::PathConvention::native(), - )?, + cwd: codex_utils_path_uri::ApiPathString::from_abs_path(&cwd), runtime_workspace_roots: Vec::new(), instruction_sources: vec![absolute_path("/tmp/AGENTS.md")], approval_policy: v2::AskForApproval::OnFailure, diff --git a/codex-rs/app-server/tests/suite/v2/thread_start.rs b/codex-rs/app-server/tests/suite/v2/thread_start.rs index dad13599ba..60ccea8320 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_start.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_start.rs @@ -33,6 +33,7 @@ use codex_login::REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR; use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE; use codex_protocol::config_types::TrustLevel; use codex_protocol::openai_models::ReasoningEffort; +use codex_utils_path_uri::ApiPathString; use pretty_assertions::assert_eq; use serde_json::Value; use serde_json::json; @@ -235,10 +236,7 @@ async fn thread_start_accepts_absolute_runtime_workspace_roots() -> Result<()> { assert_eq!(response_cwd.as_str(), cwd.to_string_lossy()); assert_eq!( runtime_workspace_roots, - vec![ApiPathString::from_abs_path( - &extra_root.abs(), - PathConvention::native(), - )?] + vec![ApiPathString::from_abs_path(&extra_root.abs())] ); Ok(()) @@ -263,10 +261,7 @@ async fn thread_start_preserves_explicit_root_equal_to_host_fallback_with_select runtime_workspace_roots: Some(vec![explicit_root.clone()]), environments: Some(vec![TurnEnvironmentParams { environment_id: "local".to_string(), - cwd: ApiPathString::from_abs_path( - &environment_cwd.path().to_path_buf().abs(), - PathConvention::native(), - )?, + cwd: ApiPathString::from_abs_path(&environment_cwd.path().to_path_buf().abs()), }]), ..Default::default() }) @@ -280,10 +275,7 @@ async fn thread_start_preserves_explicit_root_equal_to_host_fallback_with_select assert_eq!( response.runtime_workspace_roots, - vec![ApiPathString::from_abs_path( - &explicit_root, - PathConvention::native(), - )?] + vec![ApiPathString::from_abs_path(&explicit_root)] ); Ok(()) @@ -325,9 +317,8 @@ async fn thread_start_excludes_profile_workspace_roots_from_runtime_workspace_ro assert_eq!( runtime_workspace_roots, vec![ApiPathString::from_abs_path( - &cwd.path().to_path_buf().abs(), - PathConvention::native(), - )?] + &cwd.path().to_path_buf().abs() + )] ); Ok(()) diff --git a/codex-rs/core/src/session/tests.rs b/codex-rs/core/src/session/tests.rs index 5e432aa481..9e67b98a24 100644 --- a/codex-rs/core/src/session/tests.rs +++ b/codex-rs/core/src/session/tests.rs @@ -8146,8 +8146,7 @@ async fn turn_context_item_separates_host_and_model_workspace_roots() { current_environment.environment, windows_cwd.clone(), current_environment.shell, - ) - .expect("remote turn environment"); + ); let host_workspace_roots = turn_context.config.effective_workspace_roots(); let implicit_item = turn_context.to_turn_context_item(); diff --git a/codex-rs/core/src/session/turn_context.rs b/codex-rs/core/src/session/turn_context.rs index 2203f6d9cb..425219118b 100644 --- a/codex-rs/core/src/session/turn_context.rs +++ b/codex-rs/core/src/session/turn_context.rs @@ -433,7 +433,7 @@ impl TurnContext { && let Some(primary_environment) = self.environments.primary() && let Some(implicit_workspace_root) = workspace_roots.first_mut() { - *implicit_workspace_root = primary_environment.cwd_uri().clone(); + *implicit_workspace_root = primary_environment.cwd().clone(); } let mut seen = HashSet::new(); diff --git a/codex-rs/core/tests/remote_env_windows/remote_env_windows_test.rs b/codex-rs/core/tests/remote_env_windows/remote_env_windows_test.rs index cfb65370bb..4a6d9ac295 100644 --- a/codex-rs/core/tests/remote_env_windows/remote_env_windows_test.rs +++ b/codex-rs/core/tests/remote_env_windows/remote_env_windows_test.rs @@ -3,6 +3,7 @@ use anyhow::Context; use anyhow::Result; use app_test_support::TestAppServer; +use app_test_support::PathBufExt; use app_test_support::create_mock_responses_server_sequence; use app_test_support::to_response; use app_test_support::write_mock_responses_config_toml; @@ -390,7 +391,7 @@ async fn app_server_starts_thread_with_windows_environment_native_cwd() -> Resul Some(r"C:\windows"), ); assert!(environment_context.contains( - r"C:\codex runtime" + r"C:\windows" )); Ok(()) diff --git a/codex-rs/exec/src/lib_tests.rs b/codex-rs/exec/src/lib_tests.rs index ff541e276f..d4161ccfba 100644 --- a/codex-rs/exec/src/lib_tests.rs +++ b/codex-rs/exec/src/lib_tests.rs @@ -775,8 +775,7 @@ fn sample_thread_start_response() -> ThreadStartResponse { model: "gpt-5.4".to_string(), model_provider: "openai".to_string(), service_tier: None, - cwd: ApiPathString::from_abs_path(&test_path_buf("/tmp").abs(), PathConvention::native()) - .expect("API cwd"), + cwd: ApiPathString::from_abs_path(&test_path_buf("/tmp").abs()), runtime_workspace_roots: Vec::new(), instruction_sources: Vec::new(), approval_policy: codex_app_server_protocol::AskForApproval::OnRequest, diff --git a/codex-rs/tui/src/app_server_session.rs b/codex-rs/tui/src/app_server_session.rs index 0232c8670c..0ea6a54b43 100644 --- a/codex-rs/tui/src/app_server_session.rs +++ b/codex-rs/tui/src/app_server_session.rs @@ -1812,12 +1812,12 @@ mod tests { #[test] fn foreign_runtime_workspace_root_is_rejected_instead_of_projected_onto_the_tui_host() { - let (path, convention) = match PathConvention::native() { - PathConvention::Posix => (r"C:\workspace", PathConvention::Windows), - PathConvention::Windows => ("/workspace", PathConvention::Posix), + let path = match PathConvention::native() { + PathConvention::Posix => r"C:\workspace", + PathConvention::Windows => "/workspace", }; - let root = ApiPathString::from_native_absolute_path(path, convention) - .expect("foreign path should be valid"); + let root: ApiPathString = + serde_json::from_value(serde_json::json!(path)).expect("API path should deserialize"); assert_eq!( api_path_to_native_runtime_workspace_root(&root),