mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
Drive progress cursor off stderr tty
This commit is contained in:
@@ -81,12 +81,13 @@ pub(crate) struct EventProcessorWithHumanOutput {
|
||||
last_proposed_plan: Option<String>,
|
||||
progress_active: bool,
|
||||
progress_last_len: usize,
|
||||
use_ansi: bool,
|
||||
use_ansi_cursor: bool,
|
||||
}
|
||||
|
||||
impl EventProcessorWithHumanOutput {
|
||||
pub(crate) fn create_with_ansi(
|
||||
with_ansi: bool,
|
||||
cursor_ansi: bool,
|
||||
config: &Config,
|
||||
last_message_path: Option<PathBuf>,
|
||||
) -> Self {
|
||||
@@ -111,7 +112,7 @@ impl EventProcessorWithHumanOutput {
|
||||
last_proposed_plan: None,
|
||||
progress_active: false,
|
||||
progress_last_len: 0,
|
||||
use_ansi: true,
|
||||
use_ansi_cursor: cursor_ansi,
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
@@ -132,7 +133,7 @@ impl EventProcessorWithHumanOutput {
|
||||
last_proposed_plan: None,
|
||||
progress_active: false,
|
||||
progress_last_len: 0,
|
||||
use_ansi: false,
|
||||
use_ansi_cursor: cursor_ansi,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -961,7 +962,7 @@ impl EventProcessorWithHumanOutput {
|
||||
eta.as_str(),
|
||||
);
|
||||
let done = processed >= update.total_items;
|
||||
if !self.use_ansi {
|
||||
if !self.use_ansi_cursor {
|
||||
eprintln!("{line}");
|
||||
if done {
|
||||
self.progress_active = false;
|
||||
|
||||
@@ -122,6 +122,11 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
|
||||
supports_color::on_cached(Stream::Stderr).is_some(),
|
||||
),
|
||||
};
|
||||
let cursor_ansi = match color {
|
||||
cli::Color::Never => false,
|
||||
cli::Color::Always => true,
|
||||
cli::Color::Auto => std::io::stderr().is_terminal(),
|
||||
};
|
||||
|
||||
// Build fmt layer (existing logging) to compose with OTEL layer.
|
||||
let default_level = "error";
|
||||
@@ -301,6 +306,7 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
|
||||
true => Box::new(EventProcessorWithJsonOutput::new(last_message_file.clone())),
|
||||
_ => Box::new(EventProcessorWithHumanOutput::create_with_ansi(
|
||||
stderr_with_ansi,
|
||||
cursor_ansi,
|
||||
&config,
|
||||
last_message_file.clone(),
|
||||
)),
|
||||
|
||||
Reference in New Issue
Block a user