From 69c8a1ef9e7c5a3c447ea8b0f01ec5d3a068693d Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Fri, 13 Mar 2026 19:15:58 -0700 Subject: [PATCH] Fix Windows CI assertions for guardian and Smart Approvals (#14645) - Normalize guardian assessment path serialization to use forward slashes for cross-platform stability. - Seed workspace-write defaults in the Smart Approvals override-turn-context test so Windows and non-Windows selection flows are consistent. --------- Co-authored-by: Codex Co-authored-by: Charles Cunningham --- codex-rs/core/src/guardian_tests.rs | 15 +++++++++++---- codex-rs/tui/src/chatwidget/tests.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/src/guardian_tests.rs b/codex-rs/core/src/guardian_tests.rs index a687e379a..b03977bdf 100644 --- a/codex-rs/core/src/guardian_tests.rs +++ b/codex-rs/core/src/guardian_tests.rs @@ -219,10 +219,17 @@ fn guardian_approval_request_to_json_renders_mcp_tool_call_shape() { #[test] fn guardian_assessment_action_value_redacts_apply_patch_patch_text() { + let (cwd, file) = if cfg!(windows) { + (r"C:\tmp", r"C:\tmp\guardian.txt") + } else { + ("/tmp", "/tmp/guardian.txt") + }; + let cwd = PathBuf::from(cwd); + let file = AbsolutePathBuf::try_from(file).expect("absolute path"); let action = GuardianApprovalRequest::ApplyPatch { id: "patch-1".to_string(), - cwd: PathBuf::from("/tmp"), - files: vec![AbsolutePathBuf::try_from("/tmp/guardian.txt").expect("absolute path")], + cwd: cwd.clone(), + files: vec![file.clone()], change_count: 1usize, patch: "*** Begin Patch\n*** Update File: guardian.txt\n@@\n+secret\n*** End Patch" .to_string(), @@ -232,8 +239,8 @@ fn guardian_assessment_action_value_redacts_apply_patch_patch_text() { guardian_assessment_action_value(&action), serde_json::json!({ "tool": "apply_patch", - "cwd": "/tmp", - "files": ["/tmp/guardian.txt"], + "cwd": cwd, + "files": [file], "change_count": 1, }) ); diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs index bd3612240..730aa9900 100644 --- a/codex-rs/tui/src/chatwidget/tests.rs +++ b/codex-rs/tui/src/chatwidget/tests.rs @@ -8648,9 +8648,35 @@ async fn permissions_selection_sends_approvals_reviewer_in_override_turn_context } chat.config.notices.hide_full_access_warning = Some(true); chat.set_feature_enabled(Feature::GuardianApproval, true); + chat.config + .permissions + .approval_policy + .set(AskForApproval::OnRequest) + .expect("set approval policy"); + chat.config + .permissions + .sandbox_policy + .set(SandboxPolicy::new_workspace_write_policy()) + .expect("set sandbox policy"); + chat.set_approvals_reviewer(ApprovalsReviewer::User); chat.open_permissions_popup(); + let popup = render_bottom_popup(&chat, 120); + assert!( + popup + .lines() + .any(|line| line.contains("(current)") && line.contains('›')), + "expected permissions popup to open with the current preset selected: {popup}" + ); + chat.handle_key_event(KeyEvent::from(KeyCode::Down)); + let popup = render_bottom_popup(&chat, 120); + assert!( + popup + .lines() + .any(|line| line.contains("Smart Approvals") && line.contains('›')), + "expected one Down from Default to select Smart Approvals: {popup}" + ); chat.handle_key_event(KeyEvent::from(KeyCode::Enter)); let op = std::iter::from_fn(|| rx.try_recv().ok())