From 3b5ad9c0b99cdad1febc085e6eed59a86b808804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=B5=A9=E6=96=87?= <13488293+haowenGuo@user.noreply.gitee.com> Date: Wed, 27 May 2026 11:43:40 +0800 Subject: [PATCH] Fix Windows running thread resume path comparison --- .../request_processors/thread_processor.rs | 6 ++++- .../thread_processor_tests.rs | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/codex-rs/app-server/src/request_processors/thread_processor.rs b/codex-rs/app-server/src/request_processors/thread_processor.rs index 1766c971b1ed..1c9b6e1f5368 100644 --- a/codex-rs/app-server/src/request_processors/thread_processor.rs +++ b/codex-rs/app-server/src/request_processors/thread_processor.rs @@ -2800,7 +2800,7 @@ impl ThreadRequestProcessor { .as_ref() .or(source_thread.rollout_path.as_ref()); if let (Some(requested_path), Some(active_path)) = (params.path.as_ref(), active_path) - && requested_path != active_path + && !rollout_paths_match_for_resume(requested_path, active_path) { return Err(invalid_request(format!( "cannot resume running thread {existing_thread_id} with stale path: requested `{}`, active `{}`", @@ -3835,6 +3835,10 @@ fn conversation_summary_rollout_path_read_error( } } +fn rollout_paths_match_for_resume(requested_path: &Path, active_path: &Path) -> bool { + path_utils::paths_match_after_normalization(requested_path, active_path) +} + fn core_thread_write_error(operation: &str, err: CodexErr) -> JSONRPCErrorError { match err { CodexErr::ThreadNotFound(thread_id) => { diff --git a/codex-rs/app-server/src/request_processors/thread_processor_tests.rs b/codex-rs/app-server/src/request_processors/thread_processor_tests.rs index f4593ab7c43d..d68345db73bf 100644 --- a/codex-rs/app-server/src/request_processors/thread_processor_tests.rs +++ b/codex-rs/app-server/src/request_processors/thread_processor_tests.rs @@ -88,6 +88,30 @@ mod thread_processor_behavior_tests { use std::sync::Arc; use tempfile::TempDir; + #[cfg(windows)] + #[test] + fn rollout_paths_match_for_resume_accepts_windows_verbatim_equivalents() -> Result<()> { + let temp_dir = TempDir::new()?; + let rollout_path = temp_dir.path().join("rollout.jsonl"); + std::fs::write(&rollout_path, "{}\n")?; + + let canonical_path = rollout_path.canonicalize()?; + let canonical_display = canonical_path.display().to_string(); + let non_verbatim_path = canonical_display + .strip_prefix(r"\\?\") + .map(PathBuf::from) + .unwrap_or_else(|| rollout_path.clone()); + + assert!( + rollout_paths_match_for_resume(&non_verbatim_path, &canonical_path), + "expected {} and {} to match after normalization", + non_verbatim_path.display(), + canonical_path.display() + ); + + Ok(()) + } + #[test] fn validate_dynamic_tools_rejects_unsupported_input_schema() { let tools = vec![ApiDynamicToolSpec {