Skip to content

Commit c9f7c88

Browse files
authored
fix: restore live event submit path for apply patch tests (#20108)
## Summary This fixes the CI regression introduced by [#20040](openai/codex#20040). That PR migrated several `apply_patch_cli` tests from direct `codex.submit(Op::UserTurn { ... })` calls to `harness.submit(...)`. `harness.submit()` waits for `TurnComplete` before returning, which drains the same event stream that these tests use to assert `TurnDiff`, `PatchApplyUpdated`, and related live events. The regressed tests then timed out waiting for events that had already been consumed. This change restores a no-wait submit path for the event-observing `apply_patch_cli` tests so they can watch the turn stream directly again. ## What Changed - added a local `submit_without_wait(...)` helper in `codex-rs/core/tests/suite/apply_patch_cli.rs` - switched the `apply_patch_cli` tests that assert live turn events back to that helper - left the profile-backed `harness.submit(...)` migration in place for tests that only care about final filesystem or tool output state ## Why macOS Looked Green In the failing run [25084487331](https://github.com/openai/codex/actions/runs/25084487331), `//codex-rs/core:core-all-test` was cached on macOS, so the regressed tests were not rerun there. The Linux GNU, Linux MUSL, and Windows Bazel jobs reran the target and exposed the failure. ## Verification - `cargo test -p codex-core apply_patch_ -- --nocapture` - previously failing local cases now pass again: - `apply_patch_cli_move_without_content_change_has_no_turn_diff` - `apply_patch_turn_diff_for_rename_with_content_change` - `apply_patch_aggregates_diff_across_multiple_tool_calls`
1 parent f8fe96d commit c9f7c88

1 file changed

Lines changed: 39 additions & 8 deletions

File tree

codex-rs/core/tests/suite/apply_patch_cli.rs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ use std::time::Duration;
1515
use codex_features::Feature;
1616
use codex_protocol::models::PermissionProfile;
1717
use codex_protocol::permissions::NetworkSandboxPolicy;
18+
use codex_protocol::protocol::AskForApproval;
1819
use codex_protocol::protocol::EventMsg;
20+
use codex_protocol::protocol::Op;
21+
use codex_protocol::protocol::SandboxPolicy;
22+
use codex_protocol::user_input::UserInput;
1923
#[cfg(target_os = "linux")]
2024
use codex_sandboxing::landlock::CODEX_LINUX_SANDBOX_ARG0;
2125
use core_test_support::assert_regex_match;
@@ -57,6 +61,33 @@ async fn apply_patch_harness_with(
5761
Box::pin(TestCodexHarness::with_remote_aware_builder(builder)).await
5862
}
5963

64+
async fn submit_without_wait(harness: &TestCodexHarness, prompt: &str) -> Result<()> {
65+
let test = harness.test();
66+
let session_model = test.session_configured.model.clone();
67+
test.codex
68+
.submit(Op::UserTurn {
69+
environments: None,
70+
items: vec![UserInput::Text {
71+
text: prompt.into(),
72+
text_elements: Vec::new(),
73+
}],
74+
final_output_json_schema: None,
75+
cwd: harness.cwd().to_path_buf(),
76+
approval_policy: AskForApproval::Never,
77+
approvals_reviewer: None,
78+
sandbox_policy: SandboxPolicy::DangerFullAccess,
79+
permission_profile: None,
80+
model: session_model,
81+
effort: None,
82+
summary: None,
83+
service_tier: None,
84+
collaboration_mode: None,
85+
personality: None,
86+
})
87+
.await?;
88+
Ok(())
89+
}
90+
6091
fn restrictive_workspace_write_profile() -> PermissionProfile {
6192
PermissionProfile::workspace_write_with(
6293
&[],
@@ -361,7 +392,7 @@ async fn apply_patch_cli_move_without_content_change_has_no_turn_diff(
361392
let call_id = "apply-move-no-change";
362393
mount_apply_patch(&harness, call_id, patch, "ok", model_output).await;
363394

364-
harness.submit("rename without content change").await?;
395+
submit_without_wait(&harness, "rename without content change").await?;
365396

366397
let mut saw_turn_diff = false;
367398
wait_for_event(&codex, |event| match event {
@@ -969,7 +1000,7 @@ async fn apply_patch_custom_tool_streaming_emits_updated_changes() -> Result<()>
9691000
)
9701001
.await;
9711002

972-
harness.submit("create streamed file").await?;
1003+
submit_without_wait(&harness, "create streamed file").await?;
9731004

9741005
let mut updates = Vec::new();
9751006
wait_for_event(&codex, |event| match event {
@@ -1047,7 +1078,7 @@ async fn apply_patch_shell_command_heredoc_with_cd_emits_turn_diff() -> Result<(
10471078
];
10481079
mount_sse_sequence(harness.server(), bodies).await;
10491080

1050-
harness.submit("apply via shell heredoc with cd").await?;
1081+
submit_without_wait(&harness, "apply via shell heredoc with cd").await?;
10511082

10521083
let mut saw_turn_diff = None;
10531084
let mut saw_patch_begin = false;
@@ -1112,7 +1143,7 @@ async fn apply_patch_shell_command_failure_propagates_error_and_skips_diff() ->
11121143
];
11131144
mount_sse_sequence(harness.server(), bodies).await;
11141145

1115-
harness.submit("apply patch via shell").await?;
1146+
submit_without_wait(&harness, "apply patch via shell").await?;
11161147

11171148
let mut saw_turn_diff = false;
11181149
wait_for_event(&codex, |event| match event {
@@ -1248,7 +1279,7 @@ async fn apply_patch_emits_turn_diff_event_with_unified_diff(
12481279
let patch = format!("*** Begin Patch\n*** Add File: {file}\n+hello\n*** End Patch\n");
12491280
mount_apply_patch(&harness, call_id, patch.as_str(), "ok", model_output).await;
12501281

1251-
harness.submit("emit diff").await?;
1282+
submit_without_wait(&harness, "emit diff").await?;
12521283

12531284
let mut saw_turn_diff = None;
12541285
wait_for_event(&codex, |event| match event {
@@ -1296,7 +1327,7 @@ async fn apply_patch_turn_diff_for_rename_with_content_change(
12961327
let patch = "*** Begin Patch\n*** Update File: old.txt\n*** Move to: new.txt\n@@\n-old\n+new\n*** End Patch";
12971328
mount_apply_patch(&harness, call_id, patch, "ok", model_output).await;
12981329

1299-
harness.submit("rename with change").await?;
1330+
submit_without_wait(&harness, "rename with change").await?;
13001331

13011332
let mut last_diff: Option<String> = None;
13021333
wait_for_event(&codex, |event| match event {
@@ -1353,7 +1384,7 @@ async fn apply_patch_aggregates_diff_across_multiple_tool_calls() -> Result<()>
13531384
]);
13541385
mount_sse_sequence(harness.server(), vec![s1, s2, s3]).await;
13551386

1356-
harness.submit("aggregate diffs").await?;
1387+
submit_without_wait(&harness, "aggregate diffs").await?;
13571388

13581389
let mut last_diff: Option<String> = None;
13591390
wait_for_event(&codex, |event| match event {
@@ -1410,7 +1441,7 @@ async fn apply_patch_aggregates_diff_preserves_success_after_failure() -> Result
14101441
];
14111442
mount_sse_sequence(harness.server(), responses).await;
14121443

1413-
harness.submit("apply patch twice with failure").await?;
1444+
submit_without_wait(&harness, "apply patch twice with failure").await?;
14141445

14151446
let mut last_diff: Option<String> = None;
14161447
wait_for_event_with_timeout(

0 commit comments

Comments
 (0)