From 3d12b46b18a9ff7562467cd76136e28211db5c4d Mon Sep 17 00:00:00 2001 From: easong-openai Date: Fri, 5 Sep 2025 19:50:10 -0700 Subject: [PATCH] clippy --- codex-rs/cloud-tasks-client/src/http.rs | 62 ++++++++++++------------- codex-rs/cloud-tasks/src/ui.rs | 1 - 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/codex-rs/cloud-tasks-client/src/http.rs b/codex-rs/cloud-tasks-client/src/http.rs index 1d0b6e4b0b..226011a488 100644 --- a/codex-rs/cloud-tasks-client/src/http.rs +++ b/codex-rs/cloud-tasks-client/src/http.rs @@ -182,42 +182,40 @@ impl CloudBackend for HttpClient { .map_err(|e| Error::Http(format!("get_task_details failed: {e}")))?; let prompt = details.user_text_prompt(); let mut messages = details.assistant_text_messages(); - if messages.is_empty() { - if let Ok(full) = serde_json::from_str::(&body) { - if let Some(arr) = full - .get("current_assistant_turn") - .and_then(|v| v.get("worklog")) - .and_then(|v| v.get("messages")) - .and_then(|v| v.as_array()) + if messages.is_empty() + && let Ok(full) = serde_json::from_str::(&body) + && let Some(arr) = full + .get("current_assistant_turn") + .and_then(|v| v.get("worklog")) + .and_then(|v| v.get("messages")) + .and_then(|v| v.as_array()) + { + for m in arr { + let is_assistant = m + .get("author") + .and_then(|a| a.get("role")) + .and_then(|r| r.as_str()) + == Some("assistant"); + if !is_assistant { + continue; + } + if let Some(parts) = m + .get("content") + .and_then(|c| c.get("parts")) + .and_then(|p| p.as_array()) { - for m in arr { - let is_assistant = m - .get("author") - .and_then(|a| a.get("role")) - .and_then(|r| r.as_str()) - == Some("assistant"); - if !is_assistant { + for p in parts { + if let Some(s) = p.as_str() { + if !s.is_empty() { + messages.push(s.to_string()); + } continue; } - if let Some(parts) = m - .get("content") - .and_then(|c| c.get("parts")) - .and_then(|p| p.as_array()) + if let Some(obj) = p.as_object() + && obj.get("content_type").and_then(|t| t.as_str()) == Some("text") + && let Some(txt) = obj.get("text").and_then(|t| t.as_str()) { - for p in parts { - if let Some(s) = p.as_str() { - if !s.is_empty() { - messages.push(s.to_string()); - } - continue; - } - if let Some(obj) = p.as_object() - && obj.get("content_type").and_then(|t| t.as_str()) == Some("text") - && let Some(txt) = obj.get("text").and_then(|t| t.as_str()) - { - messages.push(txt.to_string()); - } - } + messages.push(txt.to_string()); } } } diff --git a/codex-rs/cloud-tasks/src/ui.rs b/codex-rs/cloud-tasks/src/ui.rs index 70612f2407..4e0fc3611c 100644 --- a/codex-rs/cloud-tasks/src/ui.rs +++ b/codex-rs/cloud-tasks/src/ui.rs @@ -14,7 +14,6 @@ use ratatui::widgets::ListItem; use ratatui::widgets::ListState; use ratatui::widgets::Padding; use ratatui::widgets::Paragraph; -use ratatui::widgets::Wrap; use std::sync::OnceLock; use crate::app::App;