From 829ce9f730e4700a949d0bb1757a2d7879d97965 Mon Sep 17 00:00:00 2001 From: Joey Trasatti Date: Mon, 27 Apr 2026 11:51:51 -0700 Subject: [PATCH] [codex-backend] Merge git metadata during local thread reads --- .../thread-store/src/local/read_thread.rs | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/codex-rs/thread-store/src/local/read_thread.rs b/codex-rs/thread-store/src/local/read_thread.rs index 1240a5dffc..a096e15fd8 100644 --- a/codex-rs/thread-store/src/local/read_thread.rs +++ b/codex-rs/thread-store/src/local/read_thread.rs @@ -50,9 +50,6 @@ pub(super) async fn read_thread( })?; let mut thread = read_thread_from_rollout_path(store, path).await?; - if let Some(metadata) = sqlite_metadata.as_ref() { - apply_metadata_git_info(&mut thread, metadata); - } attach_history_if_requested(&mut thread, params.include_history).await?; Ok(thread) } @@ -86,9 +83,6 @@ pub(super) async fn read_thread_by_rollout_path( message: format!("thread {} is archived", thread.thread_id), }); } - if let Some(metadata) = read_sqlite_metadata(store, thread.thread_id).await { - apply_metadata_git_info(&mut thread, &metadata); - } attach_history_if_requested(&mut thread, include_history).await?; Ok(thread) } @@ -159,20 +153,23 @@ async fn read_thread_from_rollout_path( store: &LocalThreadStore, path: std::path::PathBuf, ) -> ThreadStoreResult { - let Some(item) = read_thread_item_from_rollout(path.clone()).await else { - return stored_thread_from_session_meta(store, path).await; - }; - let archived = path.starts_with( - store - .config - .codex_home - .join(codex_rollout::ARCHIVED_SESSIONS_SUBDIR), - ); - let mut thread = + let mut thread = if let Some(item) = read_thread_item_from_rollout(path.clone()).await { + let archived = path.starts_with( + store + .config + .codex_home + .join(codex_rollout::ARCHIVED_SESSIONS_SUBDIR), + ); stored_thread_from_rollout_item(item, archived, store.config.model_provider_id.as_str()) .ok_or_else(|| ThreadStoreError::Internal { message: format!("failed to read thread id from {}", path.display()), - })?; + })? + } else { + stored_thread_from_session_meta(store, path.clone()).await? + }; + if let Some(metadata) = read_sqlite_metadata(store, thread.thread_id).await { + apply_metadata_git_info(&mut thread, &metadata); + } thread.forked_from_id = read_session_meta_line(path.as_path()) .await .ok()