From 1a879698d69e19726b3bb50d0bb3c4f46a27089d Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Tue, 24 Mar 2026 20:51:46 -0700 Subject: [PATCH] codex: narrow thread/list cwd fix Co-authored-by: Codex --- codex-rs/app-server/src/codex_message_processor.rs | 14 ++++---------- codex-rs/app-server/tests/suite/v2/thread_list.rs | 6 ++++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index cd896698b7..6e79a0c7aa 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -220,7 +220,6 @@ use codex_core::mcp::collect_mcp_snapshot; use codex_core::mcp::group_tools_by_server; use codex_core::models_manager::collaboration_mode_presets::CollaborationModesConfig; use codex_core::parse_cursor; -use codex_core::path_utils::normalize_for_path_comparison; use codex_core::plugins::MarketplaceError; use codex_core::plugins::MarketplacePluginSource; use codex_core::plugins::OPENAI_CURATED_MARKETPLACE_NAME; @@ -4411,10 +4410,6 @@ impl CodexMessageProcessor { let (allowed_sources_vec, source_kind_filter) = compute_source_filters(source_kinds); let allowed_sources = allowed_sources_vec.as_slice(); let state_db_ctx = self.shared_state_db().await; - let normalized_cwd = cwd - .as_ref() - .and_then(|cwd| normalize_for_path_comparison(cwd).ok()); - let cwd_filter = normalized_cwd.as_ref().or(cwd.as_ref()); while remaining > 0 { let page_size = remaining.min(THREAD_LIST_MAX_LIMIT); @@ -4456,7 +4451,7 @@ impl CodexMessageProcessor { let mut filtered = Vec::with_capacity(page.items.len()); for it in page.items { - let Some(mut summary) = summary_from_thread_list_item( + let Some(summary) = summary_from_thread_list_item( it, fallback_provider.as_str(), state_db_ctx.as_ref(), @@ -4468,11 +4463,10 @@ impl CodexMessageProcessor { if source_kind_filter .as_ref() .is_none_or(|filter| source_kind_matches(&summary.source, filter)) - && cwd_filter.is_none_or(|expected_cwd| &summary.cwd == expected_cwd) + && cwd + .as_ref() + .is_none_or(|expected_cwd| &summary.cwd == expected_cwd) { - if let Some(cwd) = cwd.as_ref() { - summary.cwd = cwd.clone(); - } filtered.push(summary); if filtered.len() >= remaining { break; diff --git a/codex-rs/app-server/tests/suite/v2/thread_list.rs b/codex-rs/app-server/tests/suite/v2/thread_list.rs index 2b5d1fe8a0..c5ea7abf3e 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_list.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_list.rs @@ -23,6 +23,7 @@ use codex_app_server_protocol::TurnStartParams; use codex_app_server_protocol::TurnStartResponse; use codex_app_server_protocol::UserInput; use codex_core::ARCHIVED_SESSIONS_SUBDIR; +use codex_core::path_utils::normalize_for_path_comparison; use codex_git_utils::GitSha; use codex_protocol::ThreadId; use codex_protocol::protocol::GitInfo as CoreGitInfo; @@ -478,6 +479,7 @@ async fn thread_list_respects_cwd_filter() -> Result<()> { let target_cwd = codex_home.path().join("target-cwd"); fs::create_dir_all(&target_cwd)?; + let expected_cwd = normalize_for_path_comparison(&target_cwd)?; set_rollout_cwd( rollout_path(codex_home.path(), "2025-01-02T10-00-00", &filtered_id).as_path(), &target_cwd, @@ -492,7 +494,7 @@ async fn thread_list_respects_cwd_filter() -> Result<()> { model_providers: Some(vec!["mock_provider".to_string()]), source_kinds: None, archived: None, - cwd: Some(target_cwd.to_string_lossy().into_owned()), + cwd: Some(expected_cwd.to_string_lossy().into_owned()), search_term: None, }) .await?; @@ -509,7 +511,7 @@ async fn thread_list_respects_cwd_filter() -> Result<()> { assert_eq!(data.len(), 1); assert_eq!(data[0].id, filtered_id); assert_ne!(data[0].id, unfiltered_id); - assert_eq!(data[0].cwd, target_cwd); + assert_eq!(data[0].cwd, expected_cwd); Ok(()) }