Skip to content

fix(spinner): suppress ANSI output when stderr is not a terminal#3758

Open
KooshaPari wants to merge 1 commit into
tailcallhq:mainfrom
KooshaPari:fix/spinner-non-tty-ansi
Open

fix(spinner): suppress ANSI output when stderr is not a terminal#3758
KooshaPari wants to merge 1 commit into
tailcallhq:mainfrom
KooshaPari:fix/spinner-non-tty-ansi

Conversation

@KooshaPari

Copy link
Copy Markdown

Summary

Fixes #3615

When forge -p is used or output is piped/redirected, the spinner thread writes ANSI escape codes (\r\x1b[2K) to stderr, polluting non-TTY output. This PR adds terminal detection so the spinner is only created when stderr is an actual terminal.

Changes

  • Added std::io::IsTerminal import
  • Added is_terminal: bool field to SpinnerManager, auto-detected in new() via std::io::stderr().is_terminal()
  • start() returns None (no spinner thread) when !is_terminal
  • Added force_terminal() test helper (cfg(test) only) to allow unit tests to exercise spinner logic in non-TTY environments
  • Updated pause/resume test to use the test helper
  • All 10 spinner tests pass; full cargo check clean

Test plan

  • cargo check -p forge_spinner — 0 errors
  • cargo test -p forge_spinner — 10/10 pass
  • forge -p "hello" 2>/dev/null — no ANSI in stdout
  • forge -p "hello" | cat — clean output

Detects is_terminal at SpinnerManager construction. When stderr is not
a TTY (piped, redirected, or -p prompt mode), the spinner thread is
never started and write_ln/ewrite_ln emit plain text only.

Fixes tailcallhq#3615.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


KooshaPari seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: forge -p emits TUI spinner frames to stderr in non-TTY runs

2 participants