From a68c825911d6e68650334f5f80fc87f57ebf92a3 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 12 Apr 2026 09:02:08 -0700 Subject: [PATCH] codex: address PR review feedback (#17380) --- .../app-server/src/codex_message_processor.rs | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index 26e9031e7c..5aff5de8f7 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -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) {