mirror of
https://github.com/openai/codex.git
synced 2026-09-13 11:47:17 +00:00
cleanup
This commit is contained in:
@@ -49,22 +49,17 @@ pub struct TaskSummary {
|
||||
pub attempt_total: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
|
||||
pub enum AttemptStatus {
|
||||
Pending,
|
||||
InProgress,
|
||||
Completed,
|
||||
Failed,
|
||||
Cancelled,
|
||||
#[default]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl Default for AttemptStatus {
|
||||
fn default() -> Self {
|
||||
AttemptStatus::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct TurnAttempt {
|
||||
pub turn_id: String,
|
||||
|
||||
@@ -271,7 +271,6 @@ impl CloudBackend for HttpClient {
|
||||
|
||||
/// Best-effort extraction of assistant text messages from a raw `get_task_details` body.
|
||||
/// Falls back to worklog messages when structured turns are not present.
|
||||
|
||||
impl HttpClient {
|
||||
async fn apply_with_diff(
|
||||
&self,
|
||||
@@ -395,9 +394,8 @@ stderr_tail=
|
||||
let _ = writeln!(
|
||||
&mut log,
|
||||
"----- PATCH BEGIN -----
|
||||
{}
|
||||
----- PATCH END -----",
|
||||
diff
|
||||
{diff}
|
||||
----- PATCH END -----"
|
||||
);
|
||||
append_error_log(&log);
|
||||
}
|
||||
@@ -491,10 +489,10 @@ fn extract_diff_from_turn(turn: &HashMap<String, Value>) -> Option<String> {
|
||||
for item in items {
|
||||
match item.get("type").and_then(Value::as_str) {
|
||||
Some("output_diff") => {
|
||||
if let Some(diff) = item.get("diff").and_then(Value::as_str) {
|
||||
if !diff.is_empty() {
|
||||
return Some(diff.to_string());
|
||||
}
|
||||
if let Some(diff) = item.get("diff").and_then(Value::as_str)
|
||||
&& !diff.is_empty()
|
||||
{
|
||||
return Some(diff.to_string());
|
||||
}
|
||||
}
|
||||
Some("pr") => {
|
||||
@@ -503,10 +501,9 @@ fn extract_diff_from_turn(turn: &HashMap<String, Value>) -> Option<String> {
|
||||
.and_then(Value::as_object)
|
||||
.and_then(|od| od.get("diff"))
|
||||
.and_then(Value::as_str)
|
||||
&& !diff.is_empty()
|
||||
{
|
||||
if !diff.is_empty() {
|
||||
return Some(diff.to_string());
|
||||
}
|
||||
return Some(diff.to_string());
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@@ -526,29 +523,28 @@ fn extract_assistant_messages_from_turn(turn: &HashMap<String, Value>) -> Vec<St
|
||||
for part in content {
|
||||
if part.get("content_type").and_then(Value::as_str) == Some("text")
|
||||
&& let Some(txt) = part.get("text").and_then(Value::as_str)
|
||||
&& !txt.is_empty()
|
||||
{
|
||||
if !txt.is_empty() {
|
||||
msgs.push(txt.to_string());
|
||||
}
|
||||
msgs.push(txt.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if msgs.is_empty() {
|
||||
if let Some(err) = turn.get("error").and_then(Value::as_object) {
|
||||
let message = err.get("message").and_then(Value::as_str).unwrap_or("");
|
||||
let code = err.get("code").and_then(Value::as_str).unwrap_or("");
|
||||
if !message.is_empty() || !code.is_empty() {
|
||||
let text = if !code.is_empty() && !message.is_empty() {
|
||||
format!("{code}: {message}")
|
||||
} else if !code.is_empty() {
|
||||
code.to_string()
|
||||
} else {
|
||||
message.to_string()
|
||||
};
|
||||
msgs.push(format!("Task failed: {text}"));
|
||||
}
|
||||
if msgs.is_empty()
|
||||
&& let Some(err) = turn.get("error").and_then(Value::as_object)
|
||||
{
|
||||
let message = err.get("message").and_then(Value::as_str).unwrap_or("");
|
||||
let code = err.get("code").and_then(Value::as_str).unwrap_or("");
|
||||
if !message.is_empty() || !code.is_empty() {
|
||||
let text = if !code.is_empty() && !message.is_empty() {
|
||||
format!("{code}: {message}")
|
||||
} else if !code.is_empty() {
|
||||
code.to_string()
|
||||
} else {
|
||||
message.to_string()
|
||||
};
|
||||
msgs.push(format!("Task failed: {text}"));
|
||||
}
|
||||
}
|
||||
msgs
|
||||
@@ -648,7 +644,7 @@ fn map_task_list_item_to_summary(src: backend::TaskListItem) -> TaskSummary {
|
||||
is_review: src
|
||||
.pull_requests
|
||||
.as_ref()
|
||||
.map_or(false, |prs| !prs.is_empty()),
|
||||
.is_some_and(|prs| !prs.is_empty()),
|
||||
attempt_total: attempt_total_from_status_display(src.task_status_display.as_ref()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
mod api;
|
||||
|
||||
pub use api::ApplyOutcome;
|
||||
|
||||
@@ -187,7 +187,7 @@ impl DiffOverlay {
|
||||
if self.attempts.is_empty() {
|
||||
self.attempts.push(AttemptView::default());
|
||||
}
|
||||
self.attempts.get_mut(0).expect("base attempt present")
|
||||
&mut self.attempts[0]
|
||||
}
|
||||
|
||||
pub fn set_view(&mut self, view: DetailView) {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use codex_backend_client::Client as BackendClient;
|
||||
use codex_cloud_tasks::util::extract_chatgpt_account_id;
|
||||
use codex_cloud_tasks::util::normalize_base_url;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use codex_backend_client::Client as BackendClient;
|
||||
use codex_core::config::find_codex_home;
|
||||
use codex_core::default_client::get_codex_user_agent;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use base64::Engine;
|
||||
use clap::Parser;
|
||||
use codex_core::config::find_codex_home;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use base64::Engine;
|
||||
use clap::Parser;
|
||||
use codex_core::config::find_codex_home;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
mod app;
|
||||
mod cli;
|
||||
pub mod env_detect;
|
||||
|
||||
@@ -343,8 +343,7 @@ fn draw_diff_overlay(frame: &mut Frame, area: Rect, app: &mut App) {
|
||||
let mut content_area = content_full;
|
||||
if let Some(ov) = app.diff_overlay.as_mut() {
|
||||
let has_text = ov.current_attempt().is_some_and(AttemptView::has_text);
|
||||
let has_diff =
|
||||
ov.current_attempt().is_some_and(AttemptView::has_diff) || ov.base_can_apply;
|
||||
let has_diff = ov.current_attempt().is_some_and(AttemptView::has_diff) || ov.base_can_apply;
|
||||
if has_diff || has_text {
|
||||
let rows = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
@@ -381,15 +380,15 @@ fn draw_diff_overlay(frame: &mut Frame, area: Rect, app: &mut App) {
|
||||
} else {
|
||||
Some(ov.attempts.len())
|
||||
}
|
||||
})
|
||||
&& total > 1 {
|
||||
spans.extend(vec![
|
||||
" ".into(),
|
||||
format!("Attempt {}/{}", ov.selected_attempt + 1, total).dim(),
|
||||
" ".into(),
|
||||
"(Tab/Shift-Tab or [ ] to cycle attempts)".dim(),
|
||||
]);
|
||||
}
|
||||
}) && total > 1
|
||||
{
|
||||
spans.extend(vec![
|
||||
" ".into(),
|
||||
format!("Attempt {}/{}", ov.selected_attempt + 1, total).dim(),
|
||||
" ".into(),
|
||||
"(Tab/Shift-Tab or [ ] to cycle attempts)".dim(),
|
||||
]);
|
||||
}
|
||||
frame.render_widget(Paragraph::new(Line::from(spans)), rows[0]);
|
||||
ov.sd.set_width(rows[1].width);
|
||||
ov.sd.set_viewport(rows[1].height);
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use codex_cloud_tasks_client::CloudBackend;
|
||||
use codex_cloud_tasks_client::MockClient;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
Reference in New Issue
Block a user