fix(core): align color env priority and improve agent detection#936
Merged
fix(core): align color env priority and improve agent detection#936
Conversation
Deploying rstest with
|
| Latest commit: |
f72fa1e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://73d5aeb3.rstest.pages.dev |
| Branch Preview URL: | https://max-2026-02-04--1-17am.rstest.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines how color-related environment variables are handled and adds explicit agent detection controls, with corresponding test coverage to lock in the new behavior.
Changes:
- Centralizes color support handling in
logger.ts, introducesgetForceColorEnvthat prefers user-provided env vars, and re-exportsisColorSupportedfor use across core modules. - Adjusts worker/global setup pool environment merging so
process.envoverrides internal defaults, and defaults to plain output in AI agent environments (withRSTEST_NO_AGENTto opt out). - Adds and updates E2E tests to validate FORCE_COLOR/NO_COLOR propagation and to ensure agent-based Markdown reporting behavior remains correct.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
scripts/rstest.setup.ts |
Sets RSTEST_NO_AGENT=1 during repo self-tests to avoid mis-detecting the test runner as an AI agent. |
packages/core/src/utils/logger.ts |
Re-exports isColorSupported and rewrites getForceColorEnv to honor user FORCE_COLOR, sync FORCE_COLOR=0 when NO_COLOR=1, and default to no-color in agent/unsupported environments. |
packages/core/src/utils/agent/detectAgent.ts |
Adds RSTEST_NO_AGENT opt-out to force determineAgent() to report non-agent contexts when requested. |
packages/core/src/pool/index.ts |
Changes worker pool env merge order so getForceColorEnv() defaults are overridden by the parent process.env. |
packages/core/src/core/restart.ts |
Switches from ansiEnabled to isColorSupported for console clearing and wires through the new utils export. |
packages/core/src/core/globalSetup.ts |
Aligns global-setup worker env merging with the new getForceColorEnv() semantics (defaults first, process.env last). |
e2e/reporter/md.test.ts |
Introduces UNSET_ENV = ['RSTEST_NO_AGENT'] so these agent-reporting tests still exercise agent detection even though self-tests globally set RSTEST_NO_AGENT. |
e2e/env/index.test.ts |
Adds E2E cases verifying that user-set FORCE_COLOR is preserved and that NO_COLOR=1 causes workers to see FORCE_COLOR=0 to avoid downstream conflicts. |
e2e/env/fixtures/noColor.test.ts |
Asserts workers receive FORCE_COLOR=0 and NO_COLOR=1 when NO_COLOR=1 is configured. |
e2e/env/fixtures/forceColor.test.ts |
Asserts workers see FORCE_COLOR=1 when it is explicitly set by the parent process. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
FORCE_COLOR/NO_COLORalways overrides defaultsgetForceColorEnvto automatically disable colors in AI agent environments by defaultFORCE_COLOR=0whenNO_COLOR=1is detected to prevent conflicts in downstream toolsRSTEST_NO_AGENTenvironment variable to explicitly opt-out of agent detectionisColorSupportedRelated Links
Checklist