diff --git a/codex-rs/core/src/codex_thread.rs b/codex-rs/core/src/codex_thread.rs index cc83c0a7c1..562b7c73cd 100644 --- a/codex-rs/core/src/codex_thread.rs +++ b/codex-rs/core/src/codex_thread.rs @@ -381,6 +381,13 @@ impl CodexThread { self.rollout_path.clone() } + pub async fn current_rollout_path(&self) -> Option { + match self.codex.session.current_rollout_path().await { + Ok(Some(path)) => Some(path), + Ok(None) | Err(_) => self.rollout_path.clone(), + } + } + pub(crate) fn session_configured(&self) -> SessionConfiguredEvent { self.session_configured.clone() } diff --git a/codex-rs/core/tests/suite/compact_resume_fork.rs b/codex-rs/core/tests/suite/compact_resume_fork.rs index 354e9a6a03..04d0ef0f4f 100644 --- a/codex-rs/core/tests/suite/compact_resume_fork.rs +++ b/codex-rs/core/tests/suite/compact_resume_fork.rs @@ -143,7 +143,7 @@ async fn compact_resume_and_fork_preserve_model_history_view() { user_turn(&base, "hello world").await; compact_conversation(&base).await; user_turn(&base, "AFTER_COMPACT").await; - let base_path = fetch_conversation_path(&base); + let base_path = fetch_conversation_path(&base).await; assert!( base_path.exists(), "compact+resume test expects base path {base_path:?} to exist", @@ -152,7 +152,7 @@ async fn compact_resume_and_fork_preserve_model_history_view() { shutdown_conversation(&base).await; let resumed = resume_conversation(&manager, &config, base_path).await; user_turn(&resumed, "AFTER_RESUME").await; - let resumed_path = fetch_conversation_path(&resumed); + let resumed_path = fetch_conversation_path(&resumed).await; assert!( resumed_path.exists(), "compact+resume test expects resumed path {resumed_path:?} to exist", @@ -299,7 +299,7 @@ async fn compact_resume_after_second_compaction_preserves_history() -> Result<() user_turn(&base, "hello world").await; compact_conversation(&base).await; user_turn(&base, "AFTER_COMPACT").await; - let base_path = fetch_conversation_path(&base); + let base_path = fetch_conversation_path(&base).await; assert!( base_path.exists(), "second compact test expects base path {base_path:?} to exist", @@ -308,7 +308,7 @@ async fn compact_resume_after_second_compaction_preserves_history() -> Result<() shutdown_conversation(&base).await; let resumed = resume_conversation(&manager, &config, base_path).await; user_turn(&resumed, "AFTER_RESUME").await; - let resumed_path = fetch_conversation_path(&resumed); + let resumed_path = fetch_conversation_path(&resumed).await; assert!( resumed_path.exists(), "second compact test expects resumed path {resumed_path:?} to exist", @@ -319,7 +319,7 @@ async fn compact_resume_after_second_compaction_preserves_history() -> Result<() compact_conversation(&forked).await; user_turn(&forked, "AFTER_COMPACT_2").await; - let forked_path = fetch_conversation_path(&forked); + let forked_path = fetch_conversation_path(&forked).await; assert!( forked_path.exists(), "second compact test expects forked path {forked_path:?} to exist", @@ -814,8 +814,11 @@ async fn compact_conversation(conversation: &Arc) { wait_for_event(conversation, |ev| matches!(ev, EventMsg::TurnComplete(_))).await; } -fn fetch_conversation_path(conversation: &Arc) -> std::path::PathBuf { - conversation.rollout_path().expect("rollout path") +async fn fetch_conversation_path(conversation: &Arc) -> std::path::PathBuf { + conversation + .current_rollout_path() + .await + .expect("rollout path") } async fn shutdown_conversation(conversation: &Arc) {