Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Update cargo to 2024 edition (#842)

jcoens-openai8a89d3aeda1f
diff --git a/codex-rs/Cargo.toml b/codex-rs/Cargo.toml
index c16727dac3..20a0f160ee 100644
--- a/codex-rs/Cargo.toml
+++ b/codex-rs/Cargo.toml
@@ -16,6 +16,11 @@ members = [
[workspace.package]
version = "0.0.0"
+# Track the edition for all workspace crates in one place. Individual
+# crates can still override this value, but keeping it here means new
+# crates created with `cargo new -w ...` automatically inherit the 2024
+# edition.
+edition = "2024"
[profile.release]
lto = "fat"
diff --git a/codex-rs/ansi-escape/Cargo.toml b/codex-rs/ansi-escape/Cargo.toml
index f1832eda56..a2e5a41be7 100644
--- a/codex-rs/ansi-escape/Cargo.toml
+++ b/codex-rs/ansi-escape/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-ansi-escape"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[lib]
name = "codex_ansi_escape"
diff --git a/codex-rs/apply-patch/Cargo.toml b/codex-rs/apply-patch/Cargo.toml
index ab24ee62f1..69ff4fc1e9 100644
--- a/codex-rs/apply-patch/Cargo.toml
+++ b/codex-rs/apply-patch/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-apply-patch"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[lib]
name = "codex_apply_patch"
diff --git a/codex-rs/apply-patch/src/lib.rs b/codex-rs/apply-patch/src/lib.rs
index fef7d4f389..40a8791ec7 100644
--- a/codex-rs/apply-patch/src/lib.rs
+++ b/codex-rs/apply-patch/src/lib.rs
@@ -8,11 +8,11 @@ use std::path::PathBuf;
use anyhow::Context;
use anyhow::Error;
use anyhow::Result;
-pub use parser::parse_patch;
pub use parser::Hunk;
pub use parser::ParseError;
use parser::ParseError::*;
use parser::UpdateFileChunk;
+pub use parser::parse_patch;
use similar::TextDiff;
use thiserror::Error;
use tree_sitter::Parser;
@@ -409,7 +409,7 @@ fn derive_new_contents_from_chunks(
return Err(ApplyPatchError::IoError(IoError {
context: format!("Failed to read file to update {}", path.display()),
source: err,
- }))
+ }));
}
};
diff --git a/codex-rs/apply-patch/src/parser.rs b/codex-rs/apply-patch/src/parser.rs
index 4fa2ff711b..40547b4231 100644
--- a/codex-rs/apply-patch/src/parser.rs
+++ b/codex-rs/apply-patch/src/parser.rs
@@ -196,7 +196,12 @@ fn parse_one_hunk(lines: &[&str], line_number: usize) -> Result<(Hunk, usize), P
));
}
- Err(InvalidHunkError { message: format!("'{first_line}' is not a valid hunk header. Valid hunk headers: '*** Add File: {{path}}', '*** Delete File: {{path}}', '*** Update File: {{path}}'"), line_number })
+ Err(InvalidHunkError {
+ message: format!(
+ "'{first_line}' is not a valid hunk header. Valid hunk headers: '*** Add File: {{path}}', '*** Delete File: {{path}}', '*** Update File: {{path}}'"
+ ),
+ line_number,
+ })
}
fn parse_update_file_chunk(
@@ -273,7 +278,12 @@ fn parse_update_file_chunk(
}
_ => {
if parsed_lines == 0 {
- return Err(InvalidHunkError { message: format!("Unexpected line found in update hunk: '{line_contents}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)"), line_number: line_number + 1 });
+ return Err(InvalidHunkError {
+ message: format!(
+ "Unexpected line found in update hunk: '{line_contents}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)"
+ ),
+ line_number: line_number + 1,
+ });
}
// Assume this is the start of the next hunk.
break;
diff --git a/codex-rs/cli/Cargo.toml b/codex-rs/cli/Cargo.toml
index 848010e137..80ecd923d8 100644
--- a/codex-rs/cli/Cargo.toml
+++ b/codex-rs/cli/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-cli"
version = { workspace = true }
-edition = "2021"
+edition = "2024"
[[bin]]
name = "codex"
diff --git a/codex-rs/cli/src/linux-sandbox/main.rs b/codex-rs/cli/src/linux-sandbox/main.rs
index e8b887b226..f71f9b863b 100644
--- a/codex-rs/cli/src/linux-sandbox/main.rs
+++ b/codex-rs/cli/src/linux-sandbox/main.rs
@@ -7,9 +7,9 @@ fn main() -> anyhow::Result<()> {
#[cfg(target_os = "linux")]
fn main() -> anyhow::Result<()> {
use clap::Parser;
+ use codex_cli::LandlockCommand;
use codex_cli::create_sandbox_policy;
use codex_cli::landlock;
- use codex_cli::LandlockCommand;
let LandlockCommand {
full_auto,
diff --git a/codex-rs/cli/src/main.rs b/codex-rs/cli/src/main.rs
index af21742513..506c8d31d7 100644
--- a/codex-rs/cli/src/main.rs
+++ b/codex-rs/cli/src/main.rs
@@ -1,9 +1,9 @@
use clap::Parser;
+use codex_cli::LandlockCommand;
+use codex_cli::SeatbeltCommand;
use codex_cli::create_sandbox_policy;
use codex_cli::proto;
use codex_cli::seatbelt;
-use codex_cli::LandlockCommand;
-use codex_cli::SeatbeltCommand;
use codex_exec::Cli as ExecCli;
use codex_tui::Cli as TuiCli;
diff --git a/codex-rs/cli/src/proto.rs b/codex-rs/cli/src/proto.rs
index 5f4f466ed8..7c48b013b0 100644
--- a/codex-rs/cli/src/proto.rs
+++ b/codex-rs/cli/src/proto.rs
@@ -1,9 +1,9 @@
use std::io::IsTerminal;
use clap::Parser;
+use codex_core::Codex;
use codex_core::protocol::Submission;
use codex_core::util::notify_on_sigint;
-use codex_core::Codex;
use tokio::io::AsyncBufReadExt;
use tokio::io::BufReader;
use tracing::error;
diff --git a/codex-rs/common/Cargo.toml b/codex-rs/common/Cargo.toml
index c2abd5d242..3db4caacd8 100644
--- a/codex-rs/common/Cargo.toml
+++ b/codex-rs/common/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-common"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
chrono = { version = "0.4.40", optional = true }
diff --git a/codex-rs/core/Cargo.toml b/codex-rs/core/Cargo.toml
index 9e0105082d..2c841cf8ff 100644
--- a/codex-rs/core/Cargo.toml
+++ b/codex-rs/core/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-core"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[lib]
name = "codex_core"
diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs
index a087f86d3f..79f99e8c12 100644
--- a/codex-rs/core/src/client.rs
+++ b/codex-rs/core/src/client.rs
@@ -14,8 +14,8 @@ use futures::prelude::*;
use reqwest::StatusCode;
use serde::Deserialize;
use serde::Serialize;
-use serde_json::json;
use serde_json::Value;
+use serde_json::json;
use tokio::sync::mpsc;
use tokio::time::timeout;
use tokio_util::io::ReaderStream;
@@ -25,11 +25,11 @@ use tracing::warn;
use crate::error::CodexErr;
use crate::error::Result;
-use crate::flags::get_api_key;
use crate::flags::CODEX_RS_SSE_FIXTURE;
use crate::flags::OPENAI_API_BASE;
use crate::flags::OPENAI_REQUEST_MAX_RETRIES;
use crate::flags::OPENAI_STREAM_IDLE_TIMEOUT_MS;
+use crate::flags::get_api_key;
use crate::models::ResponseItem;
use crate::util::backoff;
diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs
index b5c04ddda6..36d4f119d7 100644
--- a/codex-rs/core/src/codex.rs
+++ b/codex-rs/core/src/codex.rs
@@ -9,18 +9,18 @@ use std::sync::Mutex;
use anyhow::Context;
use async_channel::Receiver;
use async_channel::Sender;
-use codex_apply_patch::maybe_parse_apply_patch_verified;
-use codex_apply_patch::print_summary;
use codex_apply_patch::AffectedPaths;
use codex_apply_patch::ApplyPatchAction;
use codex_apply_patch::ApplyPatchFileChange;
use codex_apply_patch::MaybeApplyPatchVerified;
+use codex_apply_patch::maybe_parse_apply_patch_verified;
+use codex_apply_patch::print_summary;
use fs_err as fs;
use futures::prelude::*;
use serde::Serialize;
use serde_json;
-use tokio::sync::oneshot;
use tokio::sync::Notify;
+use tokio::sync::oneshot;
use tokio::task::AbortHandle;
use tracing::debug;
use tracing::error;
@@ -35,13 +35,13 @@ use crate::config::Config;
use crate::config::ConfigOverrides;
use crate::error::CodexErr;
use crate::error::Result as CodexResult;
-use crate::exec::process_exec_tool_call;
use crate::exec::ExecParams;
use crate::exec::ExecToolCallOutput;
use crate::exec::SandboxType;
+use crate::exec::process_exec_tool_call;
use crate::flags::OPENAI_STREAM_MAX_RETRIES;
-use crate::mcp_connection_manager::try_parse_fully_qualified_tool_name;
use crate::mcp_connection_manager::McpConnectionManager;
+use crate::mcp_connection_manager::try_parse_fully_qualified_tool_name;
use crate::mcp_tool_call::handle_mcp_tool_call;
use crate::models::ContentItem;
use crate::models::FunctionCallOutputPayload;
@@ -57,9 +57,9 @@ use crate::protocol::Op;
use crate::protocol::ReviewDecision;
use crate::protocol::SandboxPolicy;
use crate::protocol::Submission;
+use crate::safety::SafetyCheck;
use crate::safety::assess_command_safety;
use crate::safety::assess_patch_safety;
-use crate::safety::SafetyCheck;
use crate::user_notification::UserNotification;
use crate::util::backoff;
use crate::zdr_transcript::ZdrTranscript;
diff --git a/codex-rs/core/src/codex_wrapper.rs b/codex-rs/core/src/codex_wrapper.rs
index 1481a01999..b27cab7151 100644
--- a/codex-rs/core/src/codex_wrapper.rs
+++ b/codex-rs/core/src/codex_wrapper.rs
@@ -1,13 +1,13 @@
-use std::sync::atomic::AtomicU64;
use std::sync::Arc;
+use std::sync::atomic::AtomicU64;
+use crate::Codex;
use crate::config::Config;
use crate::protocol::Event;
use crate::protocol::EventMsg;
use crate::protocol::Op;
use crate::protocol::Submission;
use crate::util::notify_on_sigint;
-use crate::Codex;
use tokio::sync::Notify;
/// Spawn a new [`Codex`] and initialise the session.
diff --git a/codex-rs/core/src/config.rs b/codex-rs/core/src/config.rs
index 205dea64cb..68fec35ebf 100644
--- a/codex-rs/core/src/config.rs
+++ b/codex-rs/core/src/config.rs
@@ -301,14 +301,12 @@ pub fn parse_sandbox_permission_with_base_path(
"disk-write-cwd" => Ok(DiskWriteCwd),
"disk-full-write-access" => Ok(DiskFullWriteAccess),
"network-full-access" => Ok(NetworkFullAccess),
- _ => Err(
- std::io::Error::new(
- std::io::ErrorKind::InvalidInput,
- format!(
- "`{raw}` is not a recognised permission.\nRun with `--help` to see the accepted values."
- ),
- )
- ),
+ _ => Err(std::io::Error::new(
+ std::io::ErrorKind::InvalidInput,
+ format!(
+ "`{raw}` is not a recognised permission.\nRun with `--help` to see the accepted values."
+ ),
+ )),
}
}
diff --git a/codex-rs/core/src/linux.rs b/codex-rs/core/src/linux.rs
index a69f561971..5ab579339d 100644
--- a/codex-rs/core/src/linux.rs
+++ b/codex-rs/core/src/linux.rs
@@ -7,11 +7,12 @@ use std::sync::Arc;
use crate::error::CodexErr;
use crate::error::Result;
use crate::error::SandboxErr;
-use crate::exec::exec;
use crate::exec::ExecParams;
use crate::exec::RawExecToolCallOutput;
+use crate::exec::exec;
use crate::protocol::SandboxPolicy;
+use landlock::ABI;
use landlock::Access;
use landlock::AccessFs;
use landlock::CompatLevel;
@@ -19,8 +20,6 @@ use landlock::Compatible;
use landlock::Ruleset;
use landlock::RulesetAttr;
use landlock::RulesetCreatedAttr;
-use landlock::ABI;
-use seccompiler::apply_filter;
use seccompiler::BpfProgram;
use seccompiler::SeccompAction;
use seccompiler::SeccompCmpArgLen;
@@ -29,6 +28,7 @@ use seccompiler::SeccompCondition;
use seccompiler::SeccompFilter;
use seccompiler::SeccompRule;
use seccompiler::TargetArch;
+use seccompiler::apply_filter;
use tokio::sync::Notify;
pub async fn exec_linux(
@@ -181,9 +181,9 @@ fn install_network_seccomp_filter_on_current_thread() -> std::result::Result<(),
#[cfg(test)]
mod tests_linux {
use super::*;
- use crate::exec::process_exec_tool_call;
use crate::exec::ExecParams;
use crate::exec::SandboxType;
+ use crate::exec::process_exec_tool_call;
use crate::protocol::SandboxPolicy;
use std::sync::Arc;
use tempfile::NamedTempFile;
diff --git a/codex-rs/core/src/mcp_connection_manager.rs b/codex-rs/core/src/mcp_connection_manager.rs
index 1c451a5a26..f03b9f201d 100644
--- a/codex-rs/core/src/mcp_connection_manager.rs
+++ b/codex-rs/core/src/mcp_connection_manager.rs
@@ -8,9 +8,9 @@
use std::collections::HashMap;
-use anyhow::anyhow;
use anyhow::Context;
use anyhow::Result;
+use anyhow::anyhow;
use codex_mcp_client::McpClient;
use mcp_types::Tool;
use tokio::task::JoinSet;
diff --git a/codex-rs/core/src/models.rs b/codex-rs/core/src/models.rs
index b1a131da8c..f6512e8131 100644
--- a/codex-rs/core/src/models.rs
+++ b/codex-rs/core/src/models.rs
@@ -1,7 +1,7 @@
use base64::Engine;
-use serde::ser::Serializer;
use serde::Deserialize;
use serde::Serialize;
+use serde::ser::Serializer;
use crate::protocol::InputItem;
diff --git a/codex-rs/core/tests/live_agent.rs b/codex-rs/core/tests/live_agent.rs
index 596e8e6ced..55476ecf44 100644
--- a/codex-rs/core/tests/live_agent.rs
+++ b/codex-rs/core/tests/live_agent.rs
@@ -17,13 +17,13 @@
use std::time::Duration;
+use codex_core::Codex;
use codex_core::config::Config;
use codex_core::protocol::EventMsg;
use codex_core::protocol::InputItem;
use codex_core::protocol::Op;
use codex_core::protocol::SandboxPolicy;
use codex_core::protocol::Submission;
-use codex_core::Codex;
use tokio::sync::Notify;
use tokio::time::timeout;
@@ -42,8 +42,17 @@ async fn spawn_codex() -> Codex {
// Environment tweaks to keep the tests snappy and inexpensive while still
// exercising retry/robustness logic.
- std::env::set_var("OPENAI_REQUEST_MAX_RETRIES", "2");
- std::env::set_var("OPENAI_STREAM_MAX_RETRIES", "2");
+ //
+ // NOTE: Starting with the 2024 edition `std::env::set_var` is `unsafe`
+ // because changing the process environment races with any other threads
+ // that might be performing environment look-ups at the same time.
+ // Restrict the unsafety to this tiny block that happens at the very
+ // beginning of the test, before we spawn any background tasks that could
+ // observe the environment.
+ unsafe {
+ std::env::set_var("OPENAI_REQUEST_MAX_RETRIES", "2");
+ std::env::set_var("OPENAI_STREAM_MAX_RETRIES", "2");
+ }
let agent = Codex::spawn(std::sync::Arc::new(Notify::new())).unwrap();
diff --git a/codex-rs/core/tests/live_cli.rs b/codex-rs/core/tests/live_cli.rs
index bfae984dfc..20820c5233 100644
--- a/codex-rs/core/tests/live_cli.rs
+++ b/codex-rs/core/tests/live_cli.rs
@@ -115,7 +115,9 @@ fn live_create_file_hello_txt() {
return;
}
- let (assert, dir) = run_live("Use the shell tool with the apply_patch command to create a file named hello.txt containing the text 'hello'.");
+ let (assert, dir) = run_live(
+ "Use the shell tool with the apply_patch command to create a file named hello.txt containing the text 'hello'.",
+ );
assert.success();
diff --git a/codex-rs/core/tests/previous_response_id.rs b/codex-rs/core/tests/previous_response_id.rs
index 830cda09b6..5487b5e3f2 100644
--- a/codex-rs/core/tests/previous_response_id.rs
+++ b/codex-rs/core/tests/previous_response_id.rs
@@ -1,20 +1,20 @@
use std::time::Duration;
+use codex_core::Codex;
use codex_core::config::Config;
use codex_core::protocol::InputItem;
use codex_core::protocol::Op;
use codex_core::protocol::SandboxPolicy;
use codex_core::protocol::Submission;
-use codex_core::Codex;
use serde_json::Value;
use tokio::time::timeout;
-use wiremock::matchers::method;
-use wiremock::matchers::path;
use wiremock::Match;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::Request;
use wiremock::ResponseTemplate;
+use wiremock::matchers::method;
+use wiremock::matchers::path;
/// Matcher asserting that JSON body has NO `previous_response_id` field.
struct NoPrevId;
@@ -79,10 +79,14 @@ async fn keeps_previous_response_id_between_tasks() {
.await;
// Environment
- std::env::set_var("OPENAI_API_KEY", "test-key");
- std::env::set_var("OPENAI_API_BASE", server.uri());
- std::env::set_var("OPENAI_REQUEST_MAX_RETRIES", "0");
- std::env::set_var("OPENAI_STREAM_MAX_RETRIES", "0");
+ // Update environment – `set_var` is `unsafe` starting with the 2024
+ // edition so we group the calls into a single `unsafe { … }` block.
+ unsafe {
+ std::env::set_var("OPENAI_API_KEY", "test-key");
+ std::env::set_var("OPENAI_API_BASE", server.uri());
+ std::env::set_var("OPENAI_REQUEST_MAX_RETRIES", "0");
+ std::env::set_var("OPENAI_STREAM_MAX_RETRIES", "0");
+ }
let codex = Codex::spawn(std::sync::Arc::new(tokio::sync::Notify::new())).unwrap();
diff --git a/codex-rs/core/tests/stream_no_completed.rs b/codex-rs/core/tests/stream_no_completed.rs
index adadd079e7..608516a0de 100644
--- a/codex-rs/core/tests/stream_no_completed.rs
+++ b/codex-rs/core/tests/stream_no_completed.rs
@@ -3,20 +3,20 @@
use std::time::Duration;
+use codex_core::Codex;
use codex_core::config::Config;
use codex_core::protocol::InputItem;
use codex_core::protocol::Op;
use codex_core::protocol::SandboxPolicy;
use codex_core::protocol::Submission;
-use codex_core::Codex;
use tokio::time::timeout;
-use wiremock::matchers::method;
-use wiremock::matchers::path;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::Request;
use wiremock::Respond;
use wiremock::ResponseTemplate;
+use wiremock::matchers::method;
+use wiremock::matchers::path;
fn sse_incomplete() -> String {
// Only a single line; missing the completed event.
@@ -62,11 +62,20 @@ async fn retries_on_early_close() {
.await;
// Environment
- std::env::set_var("OPENAI_API_KEY", "test-key");
- std::env::set_var("OPENAI_API_BASE", server.uri());
- std::env::set_var("OPENAI_REQUEST_MAX_RETRIES", "0");
- std::env::set_var("OPENAI_STREAM_MAX_RETRIES", "1");
- std::env::set_var("OPENAI_STREAM_IDLE_TIMEOUT_MS", "2000");
+ //
+ // As of Rust 2024 `std::env::set_var` has been made `unsafe` because
+ // mutating the process environment is inherently racy when other threads
+ // are running. We therefore have to wrap every call in an explicit
+ // `unsafe` block. These are limited to the test-setup section so the
+ // scope is very small and clearly delineated.
+
+ unsafe {
+ std::env::set_var("OPENAI_API_KEY", "test-key");
+ std::env::set_var("OPENAI_API_BASE", server.uri());
+ std::env::set_var("OPENAI_REQUEST_MAX_RETRIES", "0");
+ std::env::set_var("OPENAI_STREAM_MAX_RETRIES", "1");
+ std::env::set_var("OPENAI_STREAM_IDLE_TIMEOUT_MS", "2000");
+ }
let codex = Codex::spawn(std::sync::Arc::new(tokio::sync::Notify::new())).unwrap();
diff --git a/codex-rs/exec/Cargo.toml b/codex-rs/exec/Cargo.toml
index f6df12b6a3..8348ee345b 100644
--- a/codex-rs/exec/Cargo.toml
+++ b/codex-rs/exec/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-exec"
version = { workspace = true }
-edition = "2021"
+edition = "2024"
[[bin]]
name = "codex-exec"
diff --git a/codex-rs/exec/src/main.rs b/codex-rs/exec/src/main.rs
index 94a0281020..3a40da2336 100644
--- a/codex-rs/exec/src/main.rs
+++ b/codex-rs/exec/src/main.rs
@@ -1,6 +1,6 @@
use clap::Parser;
-use codex_exec::run_main;
use codex_exec::Cli;
+use codex_exec::run_main;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
diff --git a/codex-rs/execpolicy/Cargo.toml b/codex-rs/execpolicy/Cargo.toml
index 6d8fd5ac05..678e4dee80 100644
--- a/codex-rs/execpolicy/Cargo.toml
+++ b/codex-rs/execpolicy/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-execpolicy"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[[bin]]
name = "codex-execpolicy"
diff --git a/codex-rs/execpolicy/src/arg_matcher.rs b/codex-rs/execpolicy/src/arg_matcher.rs
index 12d91b4465..3d413fe7ff 100644
--- a/codex-rs/execpolicy/src/arg_matcher.rs
+++ b/codex-rs/execpolicy/src/arg_matcher.rs
@@ -5,14 +5,14 @@ use crate::starlark::values::ValueLike;
use allocative::Allocative;
use derive_more::derive::Display;
use starlark::any::ProvidesStaticType;
-use starlark::values::starlark_value;
-use starlark::values::string::StarlarkStr;
use starlark::values::AllocValue;
use starlark::values::Heap;
use starlark::values::NoSerialize;
use starlark::values::StarlarkValue;
use starlark::values::UnpackValue;
use starlark::values::Value;
+use starlark::values::starlark_value;
+use starlark::values::string::StarlarkStr;
/// Patterns that lists of arguments should be compared against.
#[derive(Clone, Debug, Display, Eq, PartialEq, NoSerialize, ProvidesStaticType, Allocative)]
diff --git a/codex-rs/execpolicy/src/arg_type.rs b/codex-rs/execpolicy/src/arg_type.rs
index 11be0277ec..e2c826eee9 100644
--- a/codex-rs/execpolicy/src/arg_type.rs
+++ b/codex-rs/execpolicy/src/arg_type.rs
@@ -7,8 +7,8 @@ use allocative::Allocative;
use derive_more::derive::Display;
use serde::Serialize;
use starlark::any::ProvidesStaticType;
-use starlark::values::starlark_value;
use starlark::values::StarlarkValue;
+use starlark::values::starlark_value;
#[derive(Debug, Clone, Display, Eq, PartialEq, ProvidesStaticType, Allocative, Serialize)]
#[display("{}", self)]
diff --git a/codex-rs/execpolicy/src/error.rs b/codex-rs/execpolicy/src/error.rs
index ff781f43a5..e6443d69dc 100644
--- a/codex-rs/execpolicy/src/error.rs
+++ b/codex-rs/execpolicy/src/error.rs
@@ -4,8 +4,8 @@ use serde::Serialize;
use crate::arg_matcher::ArgMatcher;
use crate::arg_resolver::PositionalArg;
-use serde_with::serde_as;
use serde_with::DisplayFromStr;
+use serde_with::serde_as;
pub type Result<T> = std::result::Result<T, Error>;
diff --git a/codex-rs/execpolicy/src/main.rs b/codex-rs/execpolicy/src/main.rs
index d8cb034d2a..65e1425f0f 100644
--- a/codex-rs/execpolicy/src/main.rs
+++ b/codex-rs/execpolicy/src/main.rs
@@ -1,15 +1,15 @@
use anyhow::Result;
use clap::Parser;
use clap::Subcommand;
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::ExecCall;
use codex_execpolicy::MatchedExec;
use codex_execpolicy::Policy;
use codex_execpolicy::PolicyParser;
use codex_execpolicy::ValidExec;
-use serde::de;
+use codex_execpolicy::get_default_policy;
use serde::Deserialize;
use serde::Serialize;
+use serde::de;
use std::path::PathBuf;
use std::str::FromStr;
diff --git a/codex-rs/execpolicy/src/opt.rs b/codex-rs/execpolicy/src/opt.rs
index 4a58037462..2325d99804 100644
--- a/codex-rs/execpolicy/src/opt.rs
+++ b/codex-rs/execpolicy/src/opt.rs
@@ -1,17 +1,17 @@
#![allow(clippy::needless_lifetimes)]
-use crate::starlark::values::ValueLike;
use crate::ArgType;
+use crate::starlark::values::ValueLike;
use allocative::Allocative;
use derive_more::derive::Display;
use starlark::any::ProvidesStaticType;
-use starlark::values::starlark_value;
use starlark::values::AllocValue;
use starlark::values::Heap;
use starlark::values::NoSerialize;
use starlark::values::StarlarkValue;
use starlark::values::UnpackValue;
use starlark::values::Value;
+use starlark::values::starlark_value;
/// Command line option that takes a value.
#[derive(Clone, Debug, Display, PartialEq, Eq, ProvidesStaticType, NoSerialize, Allocative)]
diff --git a/codex-rs/execpolicy/src/policy.rs b/codex-rs/execpolicy/src/policy.rs
index 5ce7d7b917..5dd1355081 100644
--- a/codex-rs/execpolicy/src/policy.rs
+++ b/codex-rs/execpolicy/src/policy.rs
@@ -2,15 +2,15 @@ use multimap::MultiMap;
use regex::Error as RegexError;
use regex::Regex;
-use crate::error::Error;
-use crate::error::Result;
-use crate::policy_parser::ForbiddenProgramRegex;
-use crate::program::PositiveExampleFailedCheck;
use crate::ExecCall;
use crate::Forbidden;
use crate::MatchedExec;
use crate::NegativeExamplePassedCheck;
use crate::ProgramSpec;
+use crate::error::Error;
+use crate::error::Result;
+use crate::policy_parser::ForbiddenProgramRegex;
+use crate::program::PositiveExampleFailedCheck;
pub struct Policy {
programs: MultiMap<String, ProgramSpec>,
diff --git a/codex-rs/execpolicy/src/policy_parser.rs b/codex-rs/execpolicy/src/policy_parser.rs
index caf4efd10d..594010f507 100644
--- a/codex-rs/execpolicy/src/policy_parser.rs
+++ b/codex-rs/execpolicy/src/policy_parser.rs
@@ -1,10 +1,10 @@
#![allow(clippy::needless_lifetimes)]
-use crate::arg_matcher::ArgMatcher;
-use crate::opt::OptMeta;
use crate::Opt;
use crate::Policy;
use crate::ProgramSpec;
+use crate::arg_matcher::ArgMatcher;
+use crate::opt::OptMeta;
use log::info;
use multimap::MultiMap;
use regex::Regex;
@@ -15,9 +15,9 @@ use starlark::environment::Module;
use starlark::eval::Evaluator;
use starlark::syntax::AstModule;
use starlark::syntax::Dialect;
+use starlark::values::Heap;
use starlark::values::list::UnpackList;
use starlark::values::none::NoneType;
-use starlark::values::Heap;
use std::cell::RefCell;
use std::collections::HashMap;
diff --git a/codex-rs/execpolicy/src/program.rs b/codex-rs/execpolicy/src/program.rs
index 6984f5cb3c..fbe0a104af 100644
--- a/codex-rs/execpolicy/src/program.rs
+++ b/codex-rs/execpolicy/src/program.rs
@@ -2,9 +2,11 @@ use serde::Serialize;
use std::collections::HashMap;
use std::collections::HashSet;
+use crate::ArgType;
+use crate::ExecCall;
use crate::arg_matcher::ArgMatcher;
-use crate::arg_resolver::resolve_observed_args_with_patterns;
use crate::arg_resolver::PositionalArg;
+use crate::arg_resolver::resolve_observed_args_with_patterns;
use crate::error::Error;
use crate::error::Result;
use crate::opt::Opt;
@@ -12,8 +14,6 @@ use crate::opt::OptMeta;
use crate::valid_exec::MatchedFlag;
use crate::valid_exec::MatchedOpt;
use crate::valid_exec::ValidExec;
-use crate::ArgType;
-use crate::ExecCall;
#[derive(Debug)]
pub struct ProgramSpec {
diff --git a/codex-rs/execpolicy/tests/bad.rs b/codex-rs/execpolicy/tests/bad.rs
index 91f8b52ba4..8b6e195fb0 100644
--- a/codex-rs/execpolicy/tests/bad.rs
+++ b/codex-rs/execpolicy/tests/bad.rs
@@ -1,5 +1,5 @@
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::NegativeExamplePassedCheck;
+use codex_execpolicy::get_default_policy;
#[test]
fn verify_everything_in_bad_list_is_rejected() {
diff --git a/codex-rs/execpolicy/tests/cp.rs b/codex-rs/execpolicy/tests/cp.rs
index 8981ac7a34..f34c7fc698 100644
--- a/codex-rs/execpolicy/tests/cp.rs
+++ b/codex-rs/execpolicy/tests/cp.rs
@@ -1,6 +1,5 @@
extern crate codex_execpolicy;
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::ArgMatcher;
use codex_execpolicy::ArgType;
use codex_execpolicy::Error;
@@ -10,6 +9,7 @@ use codex_execpolicy::MatchedExec;
use codex_execpolicy::Policy;
use codex_execpolicy::Result;
use codex_execpolicy::ValidExec;
+use codex_execpolicy::get_default_policy;
fn setup() -> Policy {
get_default_policy().expect("failed to load default policy")
diff --git a/codex-rs/execpolicy/tests/good.rs b/codex-rs/execpolicy/tests/good.rs
index 18a002850c..3b7313a335 100644
--- a/codex-rs/execpolicy/tests/good.rs
+++ b/codex-rs/execpolicy/tests/good.rs
@@ -1,5 +1,5 @@
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::PositiveExampleFailedCheck;
+use codex_execpolicy::get_default_policy;
#[test]
fn verify_everything_in_good_list_is_allowed() {
diff --git a/codex-rs/execpolicy/tests/head.rs b/codex-rs/execpolicy/tests/head.rs
index 196de081f6..3562bdbe2f 100644
--- a/codex-rs/execpolicy/tests/head.rs
+++ b/codex-rs/execpolicy/tests/head.rs
@@ -1,4 +1,3 @@
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::ArgMatcher;
use codex_execpolicy::ArgType;
use codex_execpolicy::Error;
@@ -9,6 +8,7 @@ use codex_execpolicy::MatchedOpt;
use codex_execpolicy::Policy;
use codex_execpolicy::Result;
use codex_execpolicy::ValidExec;
+use codex_execpolicy::get_default_policy;
extern crate codex_execpolicy;
diff --git a/codex-rs/execpolicy/tests/ls.rs b/codex-rs/execpolicy/tests/ls.rs
index f7e78f22f3..5c2e47f6ea 100644
--- a/codex-rs/execpolicy/tests/ls.rs
+++ b/codex-rs/execpolicy/tests/ls.rs
@@ -1,6 +1,5 @@
extern crate codex_execpolicy;
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::ArgType;
use codex_execpolicy::Error;
use codex_execpolicy::ExecCall;
@@ -10,6 +9,7 @@ use codex_execpolicy::MatchedFlag;
use codex_execpolicy::Policy;
use codex_execpolicy::Result;
use codex_execpolicy::ValidExec;
+use codex_execpolicy::get_default_policy;
fn setup() -> Policy {
get_default_policy().expect("failed to load default policy")
diff --git a/codex-rs/execpolicy/tests/parse_sed_command.rs b/codex-rs/execpolicy/tests/parse_sed_command.rs
index 6d03b626ef..20f5bbf301 100644
--- a/codex-rs/execpolicy/tests/parse_sed_command.rs
+++ b/codex-rs/execpolicy/tests/parse_sed_command.rs
@@ -1,5 +1,5 @@
-use codex_execpolicy::parse_sed_command;
use codex_execpolicy::Error;
+use codex_execpolicy::parse_sed_command;
#[test]
fn parses_simple_print_command() {
diff --git a/codex-rs/execpolicy/tests/pwd.rs b/codex-rs/execpolicy/tests/pwd.rs
index 4e29e4cbc1..0fc46f1390 100644
--- a/codex-rs/execpolicy/tests/pwd.rs
+++ b/codex-rs/execpolicy/tests/pwd.rs
@@ -2,7 +2,6 @@ extern crate codex_execpolicy;
use std::vec;
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::Error;
use codex_execpolicy::ExecCall;
use codex_execpolicy::MatchedExec;
@@ -10,6 +9,7 @@ use codex_execpolicy::MatchedFlag;
use codex_execpolicy::Policy;
use codex_execpolicy::PositionalArg;
use codex_execpolicy::ValidExec;
+use codex_execpolicy::get_default_policy;
fn setup() -> Policy {
get_default_policy().expect("failed to load default policy")
diff --git a/codex-rs/execpolicy/tests/sed.rs b/codex-rs/execpolicy/tests/sed.rs
index cc26bf1eb4..7e11315729 100644
--- a/codex-rs/execpolicy/tests/sed.rs
+++ b/codex-rs/execpolicy/tests/sed.rs
@@ -1,6 +1,5 @@
extern crate codex_execpolicy;
-use codex_execpolicy::get_default_policy;
use codex_execpolicy::ArgType;
use codex_execpolicy::Error;
use codex_execpolicy::ExecCall;
@@ -11,6 +10,7 @@ use codex_execpolicy::MatchedOpt;
use codex_execpolicy::Policy;
use codex_execpolicy::Result;
use codex_execpolicy::ValidExec;
+use codex_execpolicy::get_default_policy;
fn setup() -> Policy {
get_default_policy().expect("failed to load default policy")
diff --git a/codex-rs/mcp-client/Cargo.toml b/codex-rs/mcp-client/Cargo.toml
index 562675c845..72db8bd0f0 100644
--- a/codex-rs/mcp-client/Cargo.toml
+++ b/codex-rs/mcp-client/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-mcp-client"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
anyhow = "1"
diff --git a/codex-rs/mcp-client/src/mcp_client.rs b/codex-rs/mcp-client/src/mcp_client.rs
index 47f20fe55b..b36f78b334 100644
--- a/codex-rs/mcp-client/src/mcp_client.rs
+++ b/codex-rs/mcp-client/src/mcp_client.rs
@@ -12,14 +12,15 @@
//! issue requests and receive strongly-typed results.
use std::collections::HashMap;
+use std::sync::Arc;
use std::sync::atomic::AtomicI64;
use std::sync::atomic::Ordering;
-use std::sync::Arc;
-use anyhow::anyhow;
use anyhow::Result;
+use anyhow::anyhow;
use mcp_types::CallToolRequest;
use mcp_types::CallToolRequestParams;
+use mcp_types::JSONRPC_VERSION;
use mcp_types::JSONRPCMessage;
use mcp_types::JSONRPCNotification;
use mcp_types::JSONRPCRequest;
@@ -29,16 +30,15 @@ use mcp_types::ListToolsRequestParams;
use mcp_types::ListToolsResult;
use mcp_types::ModelContextProtocolRequest;
use mcp_types::RequestId;
-use mcp_types::JSONRPC_VERSION;
-use serde::de::DeserializeOwned;
use serde::Serialize;
+use serde::de::DeserializeOwned;
use tokio::io::AsyncBufReadExt;
use tokio::io::AsyncWriteExt;
use tokio::io::BufReader;
use tokio::process::Command;
+use tokio::sync::Mutex;
use tokio::sync::mpsc;
use tokio::sync::oneshot;
-use tokio::sync::Mutex;
use tracing::debug;
use tracing::error;
use tracing::info;
diff --git a/codex-rs/mcp-server/Cargo.toml b/codex-rs/mcp-server/Cargo.toml
index d50bcae97c..a81029ad14 100644
--- a/codex-rs/mcp-server/Cargo.toml
+++ b/codex-rs/mcp-server/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-mcp-server"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
codex-core = { path = "../core" }
diff --git a/codex-rs/mcp-server/src/codex_tool_config.rs b/codex-rs/mcp-server/src/codex_tool_config.rs
index aa1a620dc0..d05ec1549e 100644
--- a/codex-rs/mcp-server/src/codex_tool_config.rs
+++ b/codex-rs/mcp-server/src/codex_tool_config.rs
@@ -4,8 +4,8 @@ use std::path::PathBuf;
use mcp_types::Tool;
use mcp_types::ToolInputSchema;
-use schemars::r#gen::SchemaSettings;
use schemars::JsonSchema;
+use schemars::r#gen::SchemaSettings;
use serde::Deserialize;
use codex_core::protocol::AskForApproval;
diff --git a/codex-rs/mcp-server/src/codex_tool_runner.rs b/codex-rs/mcp-server/src/codex_tool_runner.rs
index c35b855c49..4d2b143994 100644
--- a/codex-rs/mcp-server/src/codex_tool_runner.rs
+++ b/codex-rs/mcp-server/src/codex_tool_runner.rs
@@ -10,11 +10,11 @@ use codex_core::protocol::InputItem;
use codex_core::protocol::Op;
use mcp_types::CallToolResult;
use mcp_types::CallToolResultContent;
+use mcp_types::JSONRPC_VERSION;
use mcp_types::JSONRPCMessage;
use mcp_types::JSONRPCResponse;
use mcp_types::RequestId;
use mcp_types::TextContent;
-use mcp_types::JSONRPC_VERSION;
use tokio::sync::mpsc::Sender;
/// Convert a Codex [`Event`] to an MCP notification.
diff --git a/codex-rs/mcp-server/src/message_processor.rs b/codex-rs/mcp-server/src/message_processor.rs
index 5fa2085a15..d7b4adec3e 100644
--- a/codex-rs/mcp-server/src/message_processor.rs
+++ b/codex-rs/mcp-server/src/message_processor.rs
@@ -1,11 +1,12 @@
-use crate::codex_tool_config::create_tool_for_codex_tool_call_param;
use crate::codex_tool_config::CodexToolCallParam;
+use crate::codex_tool_config::create_tool_for_codex_tool_call_param;
use codex_core::config::Config as CodexConfig;
use mcp_types::CallToolRequestParams;
use mcp_types::CallToolResult;
use mcp_types::CallToolResultContent;
use mcp_types::ClientRequest;
+use mcp_types::JSONRPC_VERSION;
use mcp_types::JSONRPCBatchRequest;
use mcp_types::JSONRPCBatchResponse;
use mcp_types::JSONRPCError;
@@ -20,7 +21,6 @@ use mcp_types::RequestId;
use mcp_types::ServerCapabilitiesTools;
use mcp_types::ServerNotification;
use mcp_types::TextContent;
-use mcp_types::JSONRPC_VERSION;
use serde_json::json;
use tokio::sync::mpsc;
use tokio::task;
diff --git a/codex-rs/mcp-types/Cargo.toml b/codex-rs/mcp-types/Cargo.toml
index cefbcc9cf7..29c117052c 100644
--- a/codex-rs/mcp-types/Cargo.toml
+++ b/codex-rs/mcp-types/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "mcp-types"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[dependencies]
serde = { version = "1", features = ["derive"] }
diff --git a/codex-rs/mcp-types/src/lib.rs b/codex-rs/mcp-types/src/lib.rs
index a1880ccd2d..7fb22a7dbf 100644
--- a/codex-rs/mcp-types/src/lib.rs
+++ b/codex-rs/mcp-types/src/lib.rs
@@ -5,9 +5,9 @@
// ```shell
// ./generate_mcp_types.py
// ```
-use serde::de::DeserializeOwned;
use serde::Deserialize;
use serde::Serialize;
+use serde::de::DeserializeOwned;
use std::convert::TryFrom;
pub const MCP_SCHEMA_VERSION: &str = "2025-03-26";
diff --git a/codex-rs/mcp-types/tests/initialize.rs b/codex-rs/mcp-types/tests/initialize.rs
index 12e7f0f936..69e8b3a68f 100644
--- a/codex-rs/mcp-types/tests/initialize.rs
+++ b/codex-rs/mcp-types/tests/initialize.rs
@@ -2,10 +2,10 @@ use mcp_types::ClientCapabilities;
use mcp_types::ClientRequest;
use mcp_types::Implementation;
use mcp_types::InitializeRequestParams;
+use mcp_types::JSONRPC_VERSION;
use mcp_types::JSONRPCMessage;
use mcp_types::JSONRPCRequest;
use mcp_types::RequestId;
-use mcp_types::JSONRPC_VERSION;
use serde_json::json;
#[test]
diff --git a/codex-rs/rustfmt.toml b/codex-rs/rustfmt.toml
index 8d5c740698..f9686f9732 100644
--- a/codex-rs/rustfmt.toml
+++ b/codex-rs/rustfmt.toml
@@ -1,4 +1,4 @@
-edition = "2021"
+edition = "2024"
# The warnings caused by this setting can be ignored.
# See https://github.com/openai/openai/pull/298039 for details.
imports_granularity = "Item"
diff --git a/codex-rs/tui/Cargo.toml b/codex-rs/tui/Cargo.toml
index c6b74bbe98..1ac23059e1 100644
--- a/codex-rs/tui/Cargo.toml
+++ b/codex-rs/tui/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "codex-tui"
version = "0.1.0"
-edition = "2021"
+edition = "2024"
[[bin]]
name = "codex-tui"
diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs
index cb2b44e0c3..edb413c9b2 100644
--- a/codex-rs/tui/src/app.rs
+++ b/codex-rs/tui/src/app.rs
@@ -12,9 +12,9 @@ use crossterm::event::KeyCode;
use crossterm::event::KeyEvent;
use crossterm::event::MouseEvent;
use crossterm::event::MouseEventKind;
-use std::sync::mpsc::channel;
use std::sync::mpsc::Receiver;
use std::sync::mpsc::Sender;
+use std::sync::mpsc::channel;
/// Top‑level application state – which full‑screen view is currently active.
enum AppState {
diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs
index 5250b67f9d..cb037e0aeb 100644
--- a/codex-rs/tui/src/chatwidget.rs
+++ b/codex-rs/tui/src/chatwidget.rs
@@ -1,7 +1,7 @@
use std::path::PathBuf;
+use std::sync::Arc;
use std::sync::mpsc::SendError;
use std::sync::mpsc::Sender;
-use std::sync::Arc;
use codex_core::codex_wrapper::init_codex;
use codex_core::config::Config;
@@ -17,8 +17,8 @@ use ratatui::layout::Layout;
use ratatui::layout::Rect;
use ratatui::widgets::Widget;
use ratatui::widgets::WidgetRef;
-use tokio::sync::mpsc::unbounded_channel;
use tokio::sync::mpsc::UnboundedSender;
+use tokio::sync::mpsc::unbounded_channel;
use crate::app_event::AppEvent;
use crate::bottom_pane::BottomPane;
diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs
index 0117135b49..3a25e85ba8 100644
--- a/codex-rs/tui/src/lib.rs
+++ b/codex-rs/tui/src/lib.rs
@@ -12,8 +12,8 @@ use codex_core::util::is_inside_git_repo;
use log_layer::TuiLogLayer;
use std::fs::OpenOptions;
use tracing_appender::non_blocking;
-use tracing_subscriber::prelude::*;
use tracing_subscriber::EnvFilter;
+use tracing_subscriber::prelude::*;
mod app;
mod app_event;
diff --git a/codex-rs/tui/src/log_layer.rs b/codex-rs/tui/src/log_layer.rs
index bc100cc3a3..5815b04fab 100644
--- a/codex-rs/tui/src/log_layer.rs
+++ b/codex-rs/tui/src/log_layer.rs
@@ -11,13 +11,13 @@
use std::fmt::Write as _;
use tokio::sync::mpsc::UnboundedSender;
-use tracing::field::Field;
-use tracing::field::Visit;
use tracing::Event;
use tracing::Subscriber;
+use tracing::field::Field;
+use tracing::field::Visit;
+use tracing_subscriber::Layer;
use tracing_subscriber::layer::Context;
use tracing_subscriber::registry::LookupSpan;
-use tracing_subscriber::Layer;
/// Maximum characters forwarded to the TUI. Longer messages are truncated so the
/// single‑line status indicator cannot overflow the viewport.
diff --git a/codex-rs/tui/src/main.rs b/codex-rs/tui/src/main.rs
index 56fd5cda79..531682daae 100644
--- a/codex-rs/tui/src/main.rs
+++ b/codex-rs/tui/src/main.rs
@@ -1,6 +1,6 @@
use clap::Parser;
-use codex_tui::run_main;
use codex_tui::Cli;
+use codex_tui::run_main;
#[tokio::main]
async fn main() -> std::io::Result<()> {
diff --git a/codex-rs/tui/src/scroll_event_helper.rs b/codex-rs/tui/src/scroll_event_helper.rs
index 7c358157df..c324ef2058 100644
--- a/codex-rs/tui/src/scroll_event_helper.rs
+++ b/codex-rs/tui/src/scroll_event_helper.rs
@@ -1,12 +1,12 @@
+use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering;
use std::sync::mpsc::Sender;
-use std::sync::Arc;
use tokio::runtime::Handle;
-use tokio::time::sleep;
use tokio::time::Duration;
+use tokio::time::sleep;
use crate::app_event::AppEvent;
diff --git a/codex-rs/tui/src/status_indicator_widget.rs b/codex-rs/tui/src/status_indicator_widget.rs
index e87beb5e24..f57c954cfe 100644
--- a/codex-rs/tui/src/status_indicator_widget.rs
+++ b/codex-rs/tui/src/status_indicator_widget.rs
@@ -6,11 +6,11 @@
//! [`StatusIndicatorWidget::update_text`], the parent widget triggers a
//! redraw so the change is visible immediately.
+use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::mpsc::Sender;
-use std::sync::Arc;
use std::thread;
use std::time::Duration;
diff --git a/codex-rs/tui/src/tui.rs b/codex-rs/tui/src/tui.rs
index 8cc54460a4..934cf94eb9 100644
--- a/codex-rs/tui/src/tui.rs
+++ b/codex-rs/tui/src/tui.rs
@@ -1,16 +1,16 @@
-use std::io::stdout;
use std::io::Stdout;
+use std::io::stdout;
use std::io::{self};
use crossterm::event::DisableMouseCapture;
use crossterm::event::EnableMouseCapture;
+use ratatui::Terminal;
use ratatui::backend::CrosstermBackend;
use ratatui::crossterm::execute;
-use ratatui::crossterm::terminal::disable_raw_mode;
-use ratatui::crossterm::terminal::enable_raw_mode;
use ratatui::crossterm::terminal::EnterAlternateScreen;
use ratatui::crossterm::terminal::LeaveAlternateScreen;
-use ratatui::Terminal;
+use ratatui::crossterm::terminal::disable_raw_mode;
+use ratatui::crossterm::terminal::enable_raw_mode;
/// A type alias for the terminal type used in this application
pub type Tui = Terminal<CrosstermBackend<Stdout>>;
diff --git a/codex-rs/tui/src/user_approval_widget.rs b/codex-rs/tui/src/user_approval_widget.rs
index 05841aa3b0..cbfccf1972 100644
--- a/codex-rs/tui/src/user_approval_widget.rs
+++ b/codex-rs/tui/src/user_approval_widget.rs
@@ -26,8 +26,8 @@ use ratatui::widgets::List;
use ratatui::widgets::Paragraph;
use ratatui::widgets::Widget;
use ratatui::widgets::WidgetRef;
-use tui_input::backend::crossterm::EventHandler;
use tui_input::Input;
+use tui_input::backend::crossterm::EventHandler;
use crate::app_event::AppEvent;
use crate::exec_command::relativize_to_home;