codex: address PR review feedback (#17380)

This commit is contained in:
Eric Traut
2026-04-12 09:02:08 -07:00
parent 056135fa05
commit a68c825911

View File

@@ -5696,32 +5696,46 @@ impl CodexMessageProcessor {
}
// Move the rollout file to archived.
let result: std::io::Result<()> = async move {
let result: Result<(), JSONRPCErrorError> = async move {
let archive_folder = self
.config
.codex_home
.join(codex_core::ARCHIVED_SESSIONS_SUBDIR);
tokio::fs::create_dir_all(&archive_folder).await?;
tokio::fs::create_dir_all(&archive_folder)
.await
.map_err(|err| JSONRPCErrorError {
code: INTERNAL_ERROR_CODE,
message: format!("failed to archive thread: {err}"),
data: None,
})?;
let archived_path = archive_folder.join(&file_name);
tokio::fs::rename(&canonical_rollout_path, &archived_path).await?;
tokio::fs::rename(&canonical_rollout_path, &archived_path)
.await
.map_err(|err| JSONRPCErrorError {
code: INTERNAL_ERROR_CODE,
message: format!("failed to archive thread: {err}"),
data: None,
})?;
if let Some(ctx) = state_db_ctx {
let _ = ctx
.mark_archived(thread_id, archived_path.as_path(), Utc::now())
.await;
let thread_id_str = thread_id.to_string();
if let Err(err) = ctx.delete_thread_delivery_state(&thread_id_str).await {
warn!("failed to delete delivery state for archived thread {thread_id}: {err}");
}
ctx.delete_thread_delivery_state(&thread_id_str)
.await
.map_err(|err| JSONRPCErrorError {
code: INTERNAL_ERROR_CODE,
message: format!(
"failed to archive thread: failed to delete delivery state for archived thread {thread_id}: {err}"
),
data: None,
})?;
}
Ok(())
}
.await;
result.map_err(|err| JSONRPCErrorError {
code: INTERNAL_ERROR_CODE,
message: format!("failed to archive thread: {err}"),
data: None,
})
result
}
async fn apps_list(&self, request_id: ConnectionRequestId, params: AppsListParams) {