diff --git a/codex-rs/rollout/src/recorder.rs b/codex-rs/rollout/src/recorder.rs index 0a9ae6224..f24cd9db9 100644 --- a/codex-rs/rollout/src/recorder.rs +++ b/codex-rs/rollout/src/recorder.rs @@ -1046,13 +1046,13 @@ fn fill_missing_thread_item_metadata(item: &mut ThreadItem, state_item: ThreadIt if item.cwd.is_none() { item.cwd = cwd; } - if item.git_branch.is_none() { + if git_branch.is_some() { item.git_branch = git_branch; } - if item.git_sha.is_none() { + if git_sha.is_some() { item.git_sha = git_sha; } - if item.git_origin_url.is_none() { + if git_origin_url.is_some() { item.git_origin_url = git_origin_url; } if item.source.is_none() { diff --git a/codex-rs/rollout/src/recorder_tests.rs b/codex-rs/rollout/src/recorder_tests.rs index 151698766..a53731bec 100644 --- a/codex-rs/rollout/src/recorder_tests.rs +++ b/codex-rs/rollout/src/recorder_tests.rs @@ -779,7 +779,7 @@ async fn list_threads_metadata_filter_overlays_state_db_list_metadata() -> std:: } #[test] -fn fill_missing_thread_item_metadata_preserves_filesystem_identity() { +fn fill_missing_thread_item_metadata_preserves_identity_and_prefers_state_git_fields() { let filesystem_thread_id = ThreadId::new(); let state_thread_id = ThreadId::new(); let filesystem_path = PathBuf::from("/tmp/filesystem-rollout.jsonl"); @@ -789,9 +789,9 @@ fn fill_missing_thread_item_metadata_preserves_filesystem_identity() { thread_id: Some(filesystem_thread_id), first_user_message: Some("filesystem message".to_string()), cwd: None, - git_branch: None, - git_sha: None, - git_origin_url: None, + git_branch: Some("filesystem-branch".to_string()), + git_sha: Some("filesystem-sha".to_string()), + git_origin_url: Some("https://example.com/filesystem.git".to_string()), source: None, agent_nickname: None, agent_role: None,