From 2fbbb1a11a0f7c0a0f67ecff9993176dfd5aabbd Mon Sep 17 00:00:00 2001 From: jif Date: Thu, 30 Jul 2026 14:10:45 +0000 Subject: [PATCH] Stabilize file approval replay test (#36165) ## What changed - Disable shell snapshots in the file-change approval replay fixture. - Wait for the thread to report `WaitingOnApproval` before resuming it. - Gracefully shut down the app server and assert that it exits successfully. GitOrigin-RevId: a1e18d31fcc819dcf9f0e066d0da73c25a47d984 --- .../tests/suite/v2/thread_resume.rs | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/codex-rs/app-server/tests/suite/v2/thread_resume.rs b/codex-rs/app-server/tests/suite/v2/thread_resume.rs index 304e0ed5de..9558034708 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_resume.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_resume.rs @@ -34,6 +34,7 @@ use codex_app_server_protocol::ServerNotification; use codex_app_server_protocol::ServerRequest; use codex_app_server_protocol::SessionSource; use codex_app_server_protocol::SortDirection; +use codex_app_server_protocol::ThreadActiveFlag; use codex_app_server_protocol::ThreadForkParams; use codex_app_server_protocol::ThreadForkResponse; use codex_app_server_protocol::ThreadGoalClearResponse; @@ -55,6 +56,7 @@ use codex_app_server_protocol::ThreadSource; use codex_app_server_protocol::ThreadStartParams; use codex_app_server_protocol::ThreadStartResponse; use codex_app_server_protocol::ThreadStatus; +use codex_app_server_protocol::ThreadStatusChangedNotification; use codex_app_server_protocol::ThreadTurnsListParams; use codex_app_server_protocol::ThreadTurnsListResponse; use codex_app_server_protocol::ThreadUnsubscribeParams; @@ -3700,7 +3702,9 @@ async fn thread_resume_replays_pending_file_change_request_approval() -> Result< create_final_assistant_message_sse_response("done")?, ]; let server = create_mock_responses_server_sequence_unchecked(responses).await; - mock_responses_config(&server.uri()).write(&codex_home)?; + mock_responses_config(&server.uri()) + .disable_feature(Feature::ShellSnapshot) + .write(&codex_home)?; let mut primary = TestAppServer::builder() .with_codex_home(&codex_home) @@ -3793,7 +3797,23 @@ async fn thread_resume_replays_pending_file_change_request_approval() -> Result< let ServerRequest::FileChangeRequestApproval { .. } = &original_request else { panic!("expected FileChangeRequestApproval request, got {original_request:?}"); }; - primary.clear_message_buffer(); + + timeout(DEFAULT_READ_TIMEOUT, async { + loop { + let notification: ThreadStatusChangedNotification = + primary.read_notification("thread/status/changed").await?; + if notification.thread_id == thread.id + && matches!( + notification.status, + ThreadStatus::Active { active_flags } + if active_flags.contains(&ThreadActiveFlag::WaitingOnApproval) + ) + { + return Ok::<(), anyhow::Error>(()); + } + } + }) + .await??; let resume_id = primary .send_thread_resume_request(ThreadResumeParams { @@ -3838,6 +3858,11 @@ async fn thread_resume_replays_pending_file_change_request_approval() -> Result< ) .await??; wait_for_responses_request_count(&server, /*expected_count*/ 3).await?; + let status = timeout(DEFAULT_READ_TIMEOUT, primary.shutdown_gracefully()).await??; + anyhow::ensure!( + status.success(), + "app-server exited unsuccessfully: {status}" + ); Ok(()) }