From 7da4e6a9ae7b374e57d312ce856bafab5ae993b6 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 16 Jun 2026 17:45:42 +0000 Subject: [PATCH] chore: adapt command cwd layer to current APIs --- .../src/protocol/item_builders.rs | 7 +----- .../src/protocol/thread_history.rs | 4 +--- .../app-server/src/bespoke_event_handling.rs | 6 +---- codex-rs/app-server/src/transport_tests.rs | 3 +-- .../app-server/tests/suite/v2/turn_start.rs | 6 ++--- .../tests/suite/v2/turn_start_zsh_fork.rs | 6 +---- .../core/src/tools/runtimes/unified_exec.rs | 24 +++++++++---------- .../src/unified_exec/process_manager_tests.rs | 2 +- .../remote_env_windows_test.rs | 1 - .../tests/event_processor_with_json_output.rs | 5 +--- codex-rs/tui/src/test_support.rs | 4 +--- 11 files changed, 22 insertions(+), 46 deletions(-) diff --git a/codex-rs/app-server-protocol/src/protocol/item_builders.rs b/codex-rs/app-server-protocol/src/protocol/item_builders.rs index 63471bf285..096072adf2 100644 --- a/codex-rs/app-server-protocol/src/protocol/item_builders.rs +++ b/codex-rs/app-server-protocol/src/protocol/item_builders.rs @@ -58,13 +58,8 @@ fn command_cwd_for_api_and_actions(cwd: &PathUri) -> (ApiPathString, AbsolutePat (api_cwd, host_cwd) } -#[expect( - clippy::expect_used, - reason = "guardian command paths are native to the app-server host" -)] fn api_path_from_host(cwd: &AbsolutePathBuf) -> ApiPathString { - ApiPathString::from_abs_path(cwd, PathConvention::native()) - .expect("guardian command cwd should render using the host path convention") + ApiPathString::from_abs_path(cwd) } pub fn build_file_change_approval_request_item( diff --git a/codex-rs/app-server-protocol/src/protocol/thread_history.rs b/codex-rs/app-server-protocol/src/protocol/thread_history.rs index 36758850e1..f1395ef03b 100644 --- a/codex-rs/app-server-protocol/src/protocol/thread_history.rs +++ b/codex-rs/app-server-protocol/src/protocol/thread_history.rs @@ -1279,7 +1279,6 @@ mod tests { use codex_utils_absolute_path::test_support::PathBufExt; use codex_utils_absolute_path::test_support::test_path_buf; use codex_utils_path_uri::ApiPathString; - use codex_utils_path_uri::PathConvention; use codex_utils_path_uri::PathUri; use pretty_assertions::assert_eq; use std::path::PathBuf; @@ -1287,8 +1286,7 @@ mod tests { use uuid::Uuid; fn test_api_path(path: &str) -> ApiPathString { - ApiPathString::from_abs_path(&test_path_buf(path).abs(), PathConvention::native()) - .expect("API path") + ApiPathString::from_abs_path(&test_path_buf(path).abs()) } #[test] diff --git a/codex-rs/app-server/src/bespoke_event_handling.rs b/codex-rs/app-server/src/bespoke_event_handling.rs index f1c5221001..3c1978ca31 100644 --- a/codex-rs/app-server/src/bespoke_event_handling.rs +++ b/codex-rs/app-server/src/bespoke_event_handling.rs @@ -2338,11 +2338,7 @@ mod tests { fn command_execution_completion_item(command: &str) -> CommandExecutionCompletionItem { CommandExecutionCompletionItem { command: command.to_string(), - 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()), command_actions: vec![V2ParsedCommand::Unknown { command: command.to_string(), }], diff --git a/codex-rs/app-server/src/transport_tests.rs b/codex-rs/app-server/src/transport_tests.rs index a4922b24b3..1cd0849955 100644 --- a/codex-rs/app-server/src/transport_tests.rs +++ b/codex-rs/app-server/src/transport_tests.rs @@ -6,7 +6,6 @@ use codex_app_server_protocol::ThreadRealtimeStartedNotification; use codex_protocol::protocol::RealtimeConversationVersion; use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_path_uri::ApiPathString; -use codex_utils_path_uri::PathConvention; use pretty_assertions::assert_eq; use serde_json::json; use tokio::time::Duration; @@ -17,7 +16,7 @@ fn absolute_path(path: &str) -> AbsolutePathBuf { } fn api_path(path: &str) -> ApiPathString { - ApiPathString::from_abs_path(&absolute_path(path), PathConvention::native()).expect("API path") + ApiPathString::from_abs_path(&absolute_path(path)) } fn thread_realtime_started_notification() -> ServerNotification { diff --git a/codex-rs/app-server/tests/suite/v2/turn_start.rs b/codex-rs/app-server/tests/suite/v2/turn_start.rs index caf65d4c42..6b0594b9b9 100644 --- a/codex-rs/app-server/tests/suite/v2/turn_start.rs +++ b/codex-rs/app-server/tests/suite/v2/turn_start.rs @@ -77,6 +77,7 @@ use codex_protocol::models::ImageDetail; use codex_protocol::openai_models::ReasoningEffort; use codex_protocol::user_input::MAX_USER_INPUT_TEXT_CHARS; use codex_utils_absolute_path::AbsolutePathBuf; +use codex_utils_path_uri::ApiPathString; use core_test_support::responses; use core_test_support::skip_if_no_network; use pretty_assertions::assert_eq; @@ -2440,10 +2441,7 @@ async fn turn_start_updates_sandbox_and_cwd_between_turns_v2() -> Result<()> { unreachable!("loop ensures we break on command execution items"); }; let second_cwd = codex_utils_absolute_path::AbsolutePathBuf::from_absolute_path(second_cwd)?; - assert_eq!( - cwd, - ApiPathString::from_abs_path(&second_cwd, PathConvention::native())? - ); + assert_eq!(cwd, ApiPathString::from_abs_path(&second_cwd)); let expected_command = format_with_current_shell_display("echo second turn"); assert_eq!(command, expected_command); assert_eq!(status, CommandExecutionStatus::InProgress); diff --git a/codex-rs/app-server/tests/suite/v2/turn_start_zsh_fork.rs b/codex-rs/app-server/tests/suite/v2/turn_start_zsh_fork.rs index 500e28a74d..2a3f64dbd0 100644 --- a/codex-rs/app-server/tests/suite/v2/turn_start_zsh_fork.rs +++ b/codex-rs/app-server/tests/suite/v2/turn_start_zsh_fork.rs @@ -34,7 +34,6 @@ use codex_features::FEATURES; use codex_features::Feature; use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_path_uri::ApiPathString; -use codex_utils_path_uri::PathConvention; use core_test_support::responses; use core_test_support::skip_if_no_network; use pretty_assertions::assert_eq; @@ -171,10 +170,7 @@ async fn turn_start_shell_zsh_fork_executes_command_v2() -> Result<()> { assert!(command.contains("sleep 0.01")); assert!(command.contains(&release_marker.display().to_string())); let workspace = AbsolutePathBuf::try_from(workspace)?; - assert_eq!( - cwd, - ApiPathString::from_abs_path(&workspace, PathConvention::native())? - ); + assert_eq!(cwd, ApiPathString::from_abs_path(&workspace)); mcp.interrupt_turn_and_wait_for_aborted(thread.id, turn.id, DEFAULT_READ_TIMEOUT) .await?; diff --git a/codex-rs/core/src/tools/runtimes/unified_exec.rs b/codex-rs/core/src/tools/runtimes/unified_exec.rs index 58ffed07f1..de78ab206d 100644 --- a/codex-rs/core/src/tools/runtimes/unified_exec.rs +++ b/codex-rs/core/src/tools/runtimes/unified_exec.rs @@ -340,12 +340,12 @@ impl<'a> ToolRuntime for UnifiedExecRunt &env, req.additional_permissions.clone(), ) - .map_err(|error| match error { - ToolError::Rejected(_) => { - ToolError::Rejected("missing command line for PTY".to_string()) - } - error @ ToolError::Codex(_) => error, - })?; + .map_err(|error| match error { + ToolError::Rejected(_) => { + ToolError::Rejected("missing command line for PTY".to_string()) + } + error @ ToolError::Codex(_) => error, + })?; let options = unified_exec_options(attempt.network_denial_cancellation_token.clone()); let mut exec_env = attempt .env_for(command, options, managed_network) @@ -401,12 +401,12 @@ impl<'a> ToolRuntime for UnifiedExecRunt &env, req.additional_permissions.clone(), ) - .map_err(|error| match error { - ToolError::Rejected(_) => { - ToolError::Rejected("missing command line for PTY".to_string()) - } - error @ ToolError::Codex(_) => error, - })?; + .map_err(|error| match error { + ToolError::Rejected(_) => { + ToolError::Rejected("missing command line for PTY".to_string()) + } + error @ ToolError::Codex(_) => error, + })?; let options = unified_exec_options(attempt.network_denial_cancellation_token.clone()); let mut exec_env = attempt .env_for(command, options, managed_network) diff --git a/codex-rs/core/src/unified_exec/process_manager_tests.rs b/codex-rs/core/src/unified_exec/process_manager_tests.rs index d27be7afb7..dc6e9e91ba 100644 --- a/codex-rs/core/src/unified_exec/process_manager_tests.rs +++ b/codex-rs/core/src/unified_exec/process_manager_tests.rs @@ -80,7 +80,7 @@ fn exec_server_params_use_path_uri_and_env_policy_overlay_contract() { let permission_profile = codex_protocol::models::PermissionProfile::Disabled; let request = ExecRequest { command: vec!["bash".to_string(), "-lc".to_string(), "true".to_string()], - cwd: command_cwd.clone(), + cwd: command_cwd, env: HashMap::from([ ("HOME".to_string(), "/client-home".to_string()), ("PATH".to_string(), "/sandbox-path".to_string()), 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 0601ed06f8..69bdee4d39 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,7 +3,6 @@ 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; diff --git a/codex-rs/exec/tests/event_processor_with_json_output.rs b/codex-rs/exec/tests/event_processor_with_json_output.rs index 496467b340..75484536ea 100644 --- a/codex-rs/exec/tests/event_processor_with_json_output.rs +++ b/codex-rs/exec/tests/event_processor_with_json_output.rs @@ -36,7 +36,6 @@ use codex_protocol::protocol::SessionConfiguredEvent; use codex_utils_absolute_path::test_support::PathBufExt; use codex_utils_absolute_path::test_support::test_path_buf; use codex_utils_path_uri::ApiPathString; -use codex_utils_path_uri::PathConvention; use pretty_assertions::assert_eq; use serde_json::json; @@ -77,10 +76,8 @@ use codex_exec::TurnStartedEvent; use codex_exec::Usage; use codex_exec::WebSearchItem; -#[expect(clippy::expect_used, reason = "test paths are absolute")] fn api_path(path: &str) -> ApiPathString { - ApiPathString::from_abs_path(&test_path_buf(path).abs(), PathConvention::native()) - .expect("API path") + ApiPathString::from_abs_path(&test_path_buf(path).abs()) } #[test] diff --git a/codex-rs/tui/src/test_support.rs b/codex-rs/tui/src/test_support.rs index e82a78ee2e..9ee6136e12 100644 --- a/codex-rs/tui/src/test_support.rs +++ b/codex-rs/tui/src/test_support.rs @@ -7,7 +7,6 @@ use codex_protocol::openai_models::ModelPreset; pub(crate) use codex_utils_absolute_path::test_support::PathBufExt; pub(crate) use codex_utils_absolute_path::test_support::test_path_buf; use codex_utils_path_uri::ApiPathString; -use codex_utils_path_uri::PathConvention; use serde::Serialize; use serde::de::DeserializeOwned; @@ -25,8 +24,7 @@ pub(crate) fn test_path_display(path: &str) -> String { } pub(crate) fn test_api_path(path: &str) -> ApiPathString { - ApiPathString::from_abs_path(&test_path_buf(path).abs(), PathConvention::native()) - .expect("API path") + ApiPathString::from_abs_path(&test_path_buf(path).abs()) } pub(crate) fn session_source_cli() -> T