Skip to content

Fix interactive console detection when output is redirected (#1810)#2042

Merged
patriksvensson merged 1 commit intospectreconsole:mainfrom
1PetarVujakovic:fix-interaction-detector
Mar 13, 2026
Merged

Fix interactive console detection when output is redirected (#1810)#2042
patriksvensson merged 1 commit intospectreconsole:mainfrom
1PetarVujakovic:fix-interaction-detector

Conversation

@1PetarVujakovic
Copy link
Copy Markdown
Contributor

Fixes #1810

  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

Changes

Improve interactive console detection when output is redirected.

Previously "InteractionDetector" only checked "Console.IsInputRedirected"
when determining if the console was interactive.

This caused "Status" and "Progress" renderers to treat redirected output
(e.g. "command > file.log") as interactive, resulting in ANSI escape
sequences being written to files.

This change updates the detection logic to also consider:

  • "Console.IsOutputRedirected"
  • "Console.IsErrorRedirected"

Additionally, unit tests were added to verify the behavior.

@1PetarVujakovic
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@patriksvensson patriksvensson merged commit ad44bce into spectreconsole:main Mar 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Status component ignores NO_COLOR when output is redirected to file

2 participants