Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/turborepo-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl ColorConfig {
Self { should_strip_ansi }
}

/// Infer the color choice from environment variables and checking if stdout
/// Infer the color choice from environment variables and checking if stdin
/// is a tty
pub fn infer() -> Self {
let env_setting =
Expand All @@ -164,7 +164,7 @@ impl ColorConfig {
"true" | "1" | "2" | "3" => Some(false),
_ => None,
});
let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdout));
let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdin));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdin));
let should_strip_ansi = env_setting.unwrap_or_else(|| !atty::is(atty::Stream::Stdout));

The color detection logic incorrectly checks stdin instead of stdout for TTY status, which breaks color output in common shell redirection scenarios.

View Details

Analysis

ColorConfig::infer() checks stdin instead of stdout for TTY, breaking shell redirection

What fails: ColorConfig::infer() in crates/turborepo-ui/src/lib.rs:167 uses atty::is(atty::Stream::Stdin) instead of atty::is(atty::Stream::Stdout) for color output decisions

How to reproduce:

# Should show colors but won't (stdin is not TTY, stdout is TTY):
echo "data" | turborepo build

# Should disable colors but won't (stdin is TTY, stdout is not TTY):  
turborepo build > logfile.txt

Result: Colors are incorrectly enabled/disabled based on input source rather than output destination, causing missing colors in pipelines and ANSI codes polluting log files

Expected: Color decisions should check stdout TTY status per atty documentation examples and standard Unix convention - colors are output to stdout/stderr, so output stream TTY status determines color support

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, well this is funny. This check breaks my use case. I assume this is some AI comment, so I will wait for a human to address this.

Self { should_strip_ansi }
}

Expand Down