fix: suppress ANSI escape sequences in PowerShell output via NO_COLOR#117
Merged
Jeomon merged 1 commit intoCursorTouch:mainfrom Mar 20, 2026
Merged
Conversation
Set NO_COLOR=1 in the subprocess environment so that pwsh 7.2+ disables ANSI formatting automatically. The variable is silently ignored by Windows PowerShell 5.1, which never emits ANSI sequences anyway, and is also respected by other CLI tools invoked inside the PowerShell session.
There was a problem hiding this comment.
Pull request overview
This PR reduces noisy ANSI escape sequences in captured PowerShell output by setting NO_COLOR=1 in the subprocess environment when spawning PowerShell, improving readability and reducing token usage in downstream consumption.
Changes:
- Set
NO_COLOR=1on the environment passed to the PowerShell subprocess inexecute_command.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
|
For certain window like vscode some of the ui elements name i usually get was [?] |
Collaborator
Author
Member
|
yes may be regex filter works |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
PowerShell 7.2+ (pwsh) can emit ANSI color escape sequences in its output (
\x1b[0m,\x1b[32;1m,\x1b[44;1m, ...), which makes the captured text harder to read and increase token consumption. This PR setsNO_COLOR=1in the subprocess environment so that pwsh 7.2+ disables ANSI formatting automatically, without touching the command string itself.Changes
src/windows_mcp/desktop/service.pyenv["NO_COLOR"] = "1"on the subprocess environment immediately afteros.environ.copy(), before the PowerShell process is spawned.Why
NO_COLOR