Use supports_color in codex exec (#4633)

It knows how to detect github actions
This commit is contained in:
pakrym-oai
2025-10-02 18:15:03 -07:00
committed by GitHub
parent 2d6cd6951a
commit 1d94b9111c
3 changed files with 5 additions and 2 deletions

1
codex-rs/Cargo.lock generated
View File

@@ -929,6 +929,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"shlex", "shlex",
"supports-color",
"tempfile", "tempfile",
"tokio", "tokio",
"tracing", "tracing",

View File

@@ -31,6 +31,7 @@ owo-colors = { workspace = true }
serde = { workspace = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true } serde_json = { workspace = true }
shlex = { workspace = true } shlex = { workspace = true }
supports-color = { workspace = true }
tokio = { workspace = true, features = [ tokio = { workspace = true, features = [
"io-std", "io-std",
"macros", "macros",

View File

@@ -28,6 +28,7 @@ use serde_json::Value;
use std::io::IsTerminal; use std::io::IsTerminal;
use std::io::Read; use std::io::Read;
use std::path::PathBuf; use std::path::PathBuf;
use supports_color::Stream;
use tracing::debug; use tracing::debug;
use tracing::error; use tracing::error;
use tracing::info; use tracing::info;
@@ -113,8 +114,8 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
cli::Color::Always => (true, true), cli::Color::Always => (true, true),
cli::Color::Never => (false, false), cli::Color::Never => (false, false),
cli::Color::Auto => ( cli::Color::Auto => (
std::io::stdout().is_terminal(), supports_color::on_cached(Stream::Stdout).is_some(),
std::io::stderr().is_terminal(), supports_color::on_cached(Stream::Stderr).is_some(),
), ),
}; };