codex: fix flaky notify capture on windows (#13534)

This commit is contained in:
Ahmed Ibrahim
2026-03-05 02:16:38 -08:00
parent ab3b133acb
commit 406d8b71d8
3 changed files with 36 additions and 14 deletions
@@ -7,6 +7,10 @@ license.workspace = true
[lib]
path = "lib.rs"
[[bin]]
name = "codex-app-server-test-notify-capture"
path = "notify_capture.rs"
[dependencies]
anyhow = { workspace = true }
base64 = { workspace = true }
@@ -0,0 +1,22 @@
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() -> anyhow::Result<()> {
let mut args = env::args_os();
let _program = args.next();
let output_path = PathBuf::from(
args.next()
.ok_or_else(|| anyhow::anyhow!("expected output path as first argument"))?,
);
let payload = args
.next()
.ok_or_else(|| anyhow::anyhow!("expected payload as final argument"))?;
let mut file = File::create(&output_path)?;
file.write_all(payload.to_string_lossy().as_bytes())?;
file.sync_all()?;
Ok(())
}
@@ -14,6 +14,7 @@ use codex_app_server_protocol::ThreadStartResponse;
use codex_app_server_protocol::TurnStartParams;
use codex_app_server_protocol::TurnStartResponse;
use codex_app_server_protocol::UserInput as V2UserInput;
use codex_utils_cargo_bin::cargo_bin;
use pretty_assertions::assert_eq;
use serde_json::Value;
use std::path::Path;
@@ -192,27 +193,22 @@ async fn turn_start_notify_payload_includes_initialize_client_name() -> Result<(
let responses = vec![create_final_assistant_message_sse_response("Done")?];
let server = create_mock_responses_server_sequence_unchecked(responses).await;
let codex_home = TempDir::new()?;
let notify_script = codex_home.path().join("notify.py");
std::fs::write(
&notify_script,
r#"from pathlib import Path
import sys
payload_path = Path(__file__).with_name("notify.json")
payload_path.write_text(sys.argv[-1], encoding="utf-8")
"#,
)?;
let notify_file = codex_home.path().join("notify.json");
let notify_script = notify_script
let notify_capture = cargo_bin("codex-app-server-test-notify-capture")?;
let notify_capture = notify_capture
.to_str()
.expect("notify script path should be valid UTF-8");
.expect("notify capture path should be valid UTF-8");
let notify_file_str = notify_file
.to_str()
.expect("notify file path should be valid UTF-8");
create_config_toml_with_extra(
codex_home.path(),
&server.uri(),
"never",
&format!(
"notify = [\"python3\", {}]",
toml_basic_string(notify_script)
"notify = [{}, {}]",
toml_basic_string(notify_capture),
toml_basic_string(notify_file_str)
),
)?;