Skip to content

fix(core): propagate color env to worker processes for correct ANSI output#1081

Merged
fi3ework merged 3 commits intomainfrom
fix/worker-color-propagation
Mar 23, 2026
Merged

fix(core): propagate color env to worker processes for correct ANSI output#1081
fi3ework merged 3 commits intomainfrom
fix/worker-color-propagation

Conversation

@fi3ework
Copy link
Copy Markdown
Member

@fi3ework fi3ework commented Mar 20, 2026

Summary

Before After
image image

Background

Worker processes spawned by getForceColorEnv() use piped stdio (no TTY), so color-detection libraries (picocolors, chalk, jest-diff) always conclude "no color". This causes snapshot diff output and reporter output in workers to lose all ANSI styling, even when the user's terminal supports it.

Implementation

  • getForceColorEnv() now propagates FORCE_COLOR=1 to workers when the main process detects color support, fixing lost ANSI in diff output.
  • In agent (AI assistant) environments, both NO_COLOR=1 and FORCE_COLOR=0 are set for maximum tool compatibility.
  • Merged the previously separate resolveForceColorEnv (pure) + getForceColorEnv (wrapper) into a single function with optional parameters for testability without mocks.
  • Added unit tests covering the full color-decision matrix (5 cases).
  • Reworked the E2E snapshot diff test to conditionally assert ANSI presence based on environment capability, so it passes in both TTY terminals and non-TTY agent environments.

User Impact

Snapshot diff output now retains ANSI colors in terminal sessions where the parent process supports color, instead of silently stripping them in worker processes.

Checklist

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8a1c3db42

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fi3ework fi3ework merged commit 34a264f into main Mar 23, 2026
16 checks passed
@fi3ework fi3ework deleted the fix/worker-color-propagation branch March 23, 2026 02:57
@9aoy 9aoy mentioned this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant