From 66338e48bde5d665dd9a815e629a86d1e32b322c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Mar 2026 12:18:45 -0500 Subject: [PATCH 1/5] refactor(progress): Pull out TERM_PROGRAM --- crates/anstyle-progress/src/query.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/anstyle-progress/src/query.rs b/crates/anstyle-progress/src/query.rs index c248e03..31a88cb 100644 --- a/crates/anstyle-progress/src/query.rs +++ b/crates/anstyle-progress/src/query.rs @@ -2,11 +2,12 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { let windows_terminal = std::env::var("WT_SESSION").is_ok(); let conemu = std::env::var("ConEmuANSI").ok() == Some("ON".into()); - let wezterm = std::env::var("TERM_PROGRAM").ok() == Some("WezTerm".into()); - let ghostty = std::env::var("TERM_PROGRAM").ok() == Some("ghostty".into()); + let term_program = std::env::var("TERM_PROGRAM").ok(); + let wezterm = term_program == Some("WezTerm".into()); + let ghostty = term_program == Some("ghostty".into()); // iTerm added OSC 9;4 support in v3.6.6, which we can check for. // For context: https://github.com/rust-lang/cargo/pull/16506#discussion_r2706584034 - let iterm = std::env::var("TERM_PROGRAM").ok() == Some("iTerm.app".into()) + let iterm = term_program == Some("iTerm.app".into()) && std::env::var("TERM_FEATURES") .ok() .map(|v| term_features_has_progress(&v)) From cfc550add6ac7e1947a9edcb3e781908dfd1f99f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Mar 2026 12:21:38 -0500 Subject: [PATCH 2/5] refactor(progress): Switch query to fallback scheme --- crates/anstyle-progress/src/query.rs | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/crates/anstyle-progress/src/query.rs b/crates/anstyle-progress/src/query.rs index 31a88cb..1eeba47 100644 --- a/crates/anstyle-progress/src/query.rs +++ b/crates/anstyle-progress/src/query.rs @@ -1,10 +1,22 @@ /// Determines whether the terminal supports ANSI OSC 9;4. pub fn supports_term_progress(is_terminal: bool) -> bool { - let windows_terminal = std::env::var("WT_SESSION").is_ok(); - let conemu = std::env::var("ConEmuANSI").ok() == Some("ON".into()); + if !is_terminal { + return false; + } + + if std::env::var("WT_SESSION").is_ok() { + return true; + } + + if std::env::var("ConEmuANSI").ok() == Some("ON".into()) { + return true; + } + let term_program = std::env::var("TERM_PROGRAM").ok(); - let wezterm = term_program == Some("WezTerm".into()); - let ghostty = term_program == Some("ghostty".into()); + if matches!(term_program.as_deref(), Some("WezTerm") | Some("ghostty")) { + return true; + } + // iTerm added OSC 9;4 support in v3.6.6, which we can check for. // For context: https://github.com/rust-lang/cargo/pull/16506#discussion_r2706584034 let iterm = term_program == Some("iTerm.app".into()) @@ -12,6 +24,10 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { .ok() .map(|v| term_features_has_progress(&v)) .unwrap_or(false); + if iterm { + return true; + } + // Ptyxis added OSC 9;4 support in 48.0. // See https://gitlab.gnome.org/chergert/ptyxis/-/issues/305 let ptyxis = std::env::var("PTYXIS_VERSION") @@ -19,8 +35,11 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { .and_then(|version| version.split(".").next()?.parse::().ok()) .map(|major_version| major_version >= 48) .unwrap_or(false); + if ptyxis { + return true; + } - (windows_terminal || conemu || wezterm || ghostty || iterm || ptyxis) && is_terminal + false } // For iTerm, the TERM_FEATURES value "P" indicates OSC 9;4 support. From ca5b41b802b8aeb393ad0fc8acfac2ce735551bb Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Mar 2026 12:39:30 -0500 Subject: [PATCH 3/5] docs(progress): Add citations --- crates/anstyle-progress/src/query.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/anstyle-progress/src/query.rs b/crates/anstyle-progress/src/query.rs index 1eeba47..56222da 100644 --- a/crates/anstyle-progress/src/query.rs +++ b/crates/anstyle-progress/src/query.rs @@ -4,14 +4,18 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { return false; } + // https://github.com/microsoft/terminal/pull/8055 if std::env::var("WT_SESSION").is_ok() { return true; } + // https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC if std::env::var("ConEmuANSI").ok() == Some("ON".into()) { return true; } + // https://github.com/wezterm/wezterm/issues/6581 + // https://ghostty.org/docs/install/release-notes/1-2-0#graphical-progress-bars let term_program = std::env::var("TERM_PROGRAM").ok(); if matches!(term_program.as_deref(), Some("WezTerm") | Some("ghostty")) { return true; From 62ec0dbc562edce285c1dc6d5d4ba9a8985613a8 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Mar 2026 12:41:35 -0500 Subject: [PATCH 4/5] fix(progress): Query for TERM_FEATURES without a gate --- crates/anstyle-progress/src/query.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/anstyle-progress/src/query.rs b/crates/anstyle-progress/src/query.rs index 56222da..4844585 100644 --- a/crates/anstyle-progress/src/query.rs +++ b/crates/anstyle-progress/src/query.rs @@ -21,14 +21,13 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { return true; } - // iTerm added OSC 9;4 support in v3.6.6, which we can check for. - // For context: https://github.com/rust-lang/cargo/pull/16506#discussion_r2706584034 - let iterm = term_program == Some("iTerm.app".into()) - && std::env::var("TERM_FEATURES") - .ok() - .map(|v| term_features_has_progress(&v)) - .unwrap_or(false); - if iterm { + // Terminal feature detection, includes + // - iTerm support in v3.6.6 + let term_features = std::env::var("TERM_FEATURES") + .ok() + .map(|v| term_features_has_progress(&v)) + .unwrap_or(false); + if term_features { return true; } @@ -47,6 +46,7 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { } // For iTerm, the TERM_FEATURES value "P" indicates OSC 9;4 support. +// // Context: https://iterm2.com/feature-reporting/ fn term_features_has_progress(value: &str) -> bool { let mut current = String::new(); From 883c5751219b12115a013512a342141cffc79946 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 16 Mar 2026 12:46:27 -0500 Subject: [PATCH 5/5] refactor(progress): Re-order query by likelihood --- crates/anstyle-progress/src/query.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/anstyle-progress/src/query.rs b/crates/anstyle-progress/src/query.rs index 4844585..a60ebb1 100644 --- a/crates/anstyle-progress/src/query.rs +++ b/crates/anstyle-progress/src/query.rs @@ -4,13 +4,13 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { return false; } - // https://github.com/microsoft/terminal/pull/8055 - if std::env::var("WT_SESSION").is_ok() { - return true; - } - - // https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC - if std::env::var("ConEmuANSI").ok() == Some("ON".into()) { + // Terminal feature detection, includes + // - iTerm support in v3.6.6 + let term_features = std::env::var("TERM_FEATURES") + .ok() + .map(|v| term_features_has_progress(&v)) + .unwrap_or(false); + if term_features { return true; } @@ -21,13 +21,13 @@ pub fn supports_term_progress(is_terminal: bool) -> bool { return true; } - // Terminal feature detection, includes - // - iTerm support in v3.6.6 - let term_features = std::env::var("TERM_FEATURES") - .ok() - .map(|v| term_features_has_progress(&v)) - .unwrap_or(false); - if term_features { + // https://github.com/microsoft/terminal/pull/8055 + if std::env::var("WT_SESSION").is_ok() { + return true; + } + + // https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC + if std::env::var("ConEmuANSI").ok() == Some("ON".into()) { return true; }