Skip to content

refactor(core): simplify ANSI suppress color logic #906

Merged
fi3ework merged 1 commit intomainfrom
ansi2
Jan 26, 2026
Merged

refactor(core): simplify ANSI suppress color logic #906
fi3ework merged 1 commit intomainfrom
ansi2

Conversation

@fi3ework
Copy link
Copy Markdown
Member

Summary

human input:


  • ANSI/Color Logic Refactor
    • Removed custom AI agent detection and forced no-color logic
    • Aligned color behavior with upstream picocolors and tinyrainbow defaults
    • Implemented conditional FORCE_COLOR propagation to worker processes to ensure colored snapshot diffs in TTY environments
    • Refined isTTY utility to correctly handle CI environments
  • Deprecation & Cleanup
    • Removed legacy mockRuntimeCode.js and simplified mock type definitions
    • Deleted deprecated example projects: examples/react-rsbuild and examples/vue
    • Streamlined examples/react and synchronized its setup logic
    • Updated documentation (English/Chinese) to reflect mock module API changes
  • Testing Improvements
    • Added E2E coverage for ANSI output in snapshot diffs
    • Verified NO_COLOR and FORCE_COLOR environment variable priority

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 26, 2026 12:21
@fi3ework fi3ework changed the title refactor(core): simplify color logic and cleanup deprecated modules refactor(core): simplify ANSI suppress color logic Jan 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the ANSI/color output logic by removing custom AI agent detection and aligning with upstream picocolors defaults. The changes simplify color handling by leveraging picocolors' built-in support for NO_COLOR and FORCE_COLOR environment variables, while implementing conditional FORCE_COLOR propagation to worker processes in TTY environments.

Changes:

  • Removed AI agent detection logic and the yn package dependency, simplifying color control to rely on standard environment variables
  • Implemented getForceColorEnv() to conditionally set FORCE_COLOR for worker processes based on TTY status and color support
  • Added E2E tests to verify ANSI output behavior with NO_COLOR and FORCE_COLOR environment variables

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pnpm-lock.yaml Removed yn package entries
packages/core/src/utils/logger.ts Converted ansiEnabled from function to constant; added getForceColorEnv(); simplified createColors() usage; removed rslog.greet override; updated clearScreen to use isTTY
packages/core/src/utils/agent/index.ts Removed initAgentEnv and isAgentEnv functions, keeping only determineAgent export
packages/core/src/reporter/index.ts Removed redundant ansiEnabled() check in ensureStatusRenderer()
packages/core/src/pool/index.ts Replaced direct ansiEnabled() check with getForceColorEnv() call
packages/core/src/core/globalSetup.ts Applied same getForceColorEnv() pattern for global setup worker pool
packages/core/src/core/restart.ts Changed ansiEnabled() function call to ansiEnabled constant reference
packages/core/src/cli/prepare.ts Removed initAgentEnv() call from CLI initialization
packages/core/package.json Removed yn package from dependencies
e2e/snapshot/diff.test.ts Added test assertions for ANSI escape sequences with FORCE_COLOR
e2e/scripts/index.ts Added unsetEnv parameter support to test helper
e2e/reporter/ansi.test.ts Updated test descriptions and added new test case for FORCE_COLOR behavior
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fi3ework fi3ework enabled auto-merge (squash) January 26, 2026 12:32
@fi3ework fi3ework merged commit a227d7e into main Jan 26, 2026
18 checks passed
@fi3ework fi3ework deleted the ansi2 branch January 26, 2026 12:37
@9aoy 9aoy mentioned this pull request Jan 27, 2026
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.

2 participants