mirror of
https://github.com/openai/codex.git
synced 2026-06-03 11:52:03 +00:00
[codex-backend] Apply git metadata overlay on list fallback
This commit is contained in:
@@ -552,12 +552,11 @@ impl RolloutRecorder {
|
||||
// If SQLite listing still fails, return the filesystem page rather than failing the list.
|
||||
tracing::error!("Falling back on rollout system");
|
||||
tracing::warn!("state db discrepancy during list_threads_with_db_fallback: falling_back");
|
||||
Ok(page_from_filesystem_scan(
|
||||
fs_page,
|
||||
sort_direction,
|
||||
page_size,
|
||||
sort_key,
|
||||
))
|
||||
let page = page_from_filesystem_scan(fs_page, sort_direction, page_size, sort_key);
|
||||
Ok(
|
||||
overlay_thread_item_metadata_from_state_db(exact_lookup_state_db_ctx.as_ref(), page)
|
||||
.await,
|
||||
)
|
||||
}
|
||||
|
||||
/// Find the newest recorded thread path, optionally filtering to a matching cwd.
|
||||
|
||||
@@ -178,10 +178,6 @@ fn git_info_from_fields(fields: ThreadGitInfoFields) -> Option<GitInfo> {
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn git_info_from_metadata(metadata: &ThreadMetadata) -> Option<GitInfo> {
|
||||
git_info_from_fields(metadata.git_info_fields())
|
||||
}
|
||||
|
||||
pub(super) fn apply_metadata_git_info(thread: &mut StoredThread, metadata: &ThreadMetadata) {
|
||||
let mut git_info = git_info_fields_from_git_info(thread.git_info.as_ref());
|
||||
git_info.overlay_non_null(&metadata.git_info_fields());
|
||||
|
||||
@@ -14,7 +14,7 @@ use codex_state::ThreadMetadata;
|
||||
|
||||
use super::LocalThreadStore;
|
||||
use super::helpers::apply_metadata_git_info;
|
||||
use super::helpers::git_info_from_metadata;
|
||||
use super::helpers::git_info_from_parts;
|
||||
use super::helpers::stored_thread_from_rollout_item;
|
||||
use crate::ReadThreadParams;
|
||||
use crate::StoredThread;
|
||||
@@ -86,7 +86,9 @@ pub(super) async fn read_thread_by_rollout_path(
|
||||
message: format!("thread {} is archived", thread.thread_id),
|
||||
});
|
||||
}
|
||||
apply_sqlite_git_info_if_present(store, &mut thread).await;
|
||||
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)
|
||||
}
|
||||
@@ -206,12 +208,6 @@ async fn read_sqlite_metadata(
|
||||
.flatten()
|
||||
}
|
||||
|
||||
async fn apply_sqlite_git_info_if_present(store: &LocalThreadStore, thread: &mut StoredThread) {
|
||||
if let Some(metadata) = read_sqlite_metadata(store, thread.thread_id).await {
|
||||
apply_metadata_git_info(thread, &metadata);
|
||||
}
|
||||
}
|
||||
|
||||
async fn stored_thread_from_sqlite_metadata(
|
||||
store: &LocalThreadStore,
|
||||
metadata: ThreadMetadata,
|
||||
@@ -227,7 +223,11 @@ async fn stored_thread_from_sqlite_metadata(
|
||||
.await
|
||||
.ok()
|
||||
.and_then(|meta_line| meta_line.meta.forked_from_id);
|
||||
let git_info = git_info_from_metadata(&metadata);
|
||||
let git_info = git_info_from_parts(
|
||||
metadata.git_sha.clone(),
|
||||
metadata.git_branch.clone(),
|
||||
metadata.git_origin_url.clone(),
|
||||
);
|
||||
StoredThread {
|
||||
thread_id: metadata.id,
|
||||
rollout_path: Some(metadata.rollout_path),
|
||||
|
||||
Reference in New Issue
Block a user