Skip to content

fix(plan): move FORCE_COLOR fallback after pattern filtering#379

Merged
branchseer merged 2 commits into
mainfrom
claude/review-force-color-env-FCm56
May 13, 2026
Merged

fix(plan): move FORCE_COLOR fallback after pattern filtering#379
branchseer merged 2 commits into
mainfrom
claude/review-force-color-env-FCm56

Conversation

@branchseer
Copy link
Copy Markdown
Member

@branchseer branchseer commented May 13, 2026

Motivation

The change respects the principle that cached output should always be colored by default (for consistency), while allowing users who need different behavior (e.g., FORCE_COLOR=0 for tools that misbehave with ANSI codes) to opt in explicitly via their task configuration.

Summary

Changes how FORCE_COLOR is handled during environment variable resolution. Instead of pre-injecting FORCE_COLOR=1 before pattern filtering (which forced it through regardless of user intent), the fallback is now applied after pattern filtering. This allows users to opt in to passing through their own FORCE_COLOR value via task config while still defaulting to colored output when not explicitly configured.

Key Changes

  • Move fallback timing: FORCE_COLOR=1 is now inserted after pattern filtering using entry().or_insert_with(), so it only applies when the user hasn't opted in to passing the variable through
  • Remove from DEFAULT_UNTRACKED_ENV: FORCE_COLOR is no longer in the default untracked env list, giving users explicit control via env or untrackedEnv config
  • Update test suite: Renamed and rewrote tests to reflect the new behavior:
    • test_force_color_defaults_to_one_when_user_does_not_opt_in — validates fallback when user doesn't list FORCE_COLOR
    • test_force_color_defaults_to_one_when_absent_from_parent — validates fallback when parent env has no FORCE_COLOR
    • test_force_color_passthrough_when_user_opts_in_via_untracked — validates parent value passes through when listed in untrackedEnv
    • test_force_color_passthrough_when_user_opts_in_via_fingerprinted — validates parent value passes through and is fingerprinted when listed in env
    • test_force_color_fallback_fingerprinted_when_opted_in_but_parent_absent — validates fallback is recorded in fingerprint when user opts in but parent has no value
  • Update documentation: Comments in both envs.rs and config/mod.rs clarify the new opt-in model and that users can override FORCE_COLOR by listing it in task config

https://claude.ai/code/session_01JZDXjffYu9W5qykGdmkUXD

Previously FORCE_COLOR was pre-inserted into all_envs before pattern
filtering and kept in DEFAULT_UNTRACKED_ENV, which unconditionally
overwrote any parent or user-provided value. Move the insert to a
post-resolution entry().or_insert() fallback and drop FORCE_COLOR from
DEFAULT_UNTRACKED_ENV. The default path (no user config) is unchanged
- the child still sees FORCE_COLOR=1 - but users opting in via env /
untrackedEnv now get their parent's value passed through, providing an
escape hatch for tools that need FORCE_COLOR=0.

https://claude.ai/code/session_01JZDXjffYu9W5qykGdmkUXD
@branchseer branchseer changed the title refactor(plan): move FORCE_COLOR fallback after pattern filtering fix(plan): move FORCE_COLOR fallback after pattern filtering May 13, 2026
@branchseer branchseer merged commit c63db22 into main May 13, 2026
12 checks passed
@branchseer branchseer deleted the claude/review-force-color-env-FCm56 branch May 13, 2026 01:41
branchseer added a commit to voidzero-dev/vite-plus that referenced this pull request May 13, 2026
Bumps the vite-task git dependency from `88bacaa` to `c63db22`.

## Notable upstream changes

- feat(cache): add `output` globs for cache restoration
([vite-task#375](voidzero-dev/vite-task#375))
- feat(cache): store colored task logs, strip at display when needed
([vite-task#378](voidzero-dev/vite-task#378))
- fix(plan): move FORCE_COLOR fallback after pattern filtering
([vite-task#379](voidzero-dev/vite-task#379))
- fix: preserve `PATHEXT` for Windows cached tasks
([vite-task#366](voidzero-dev/vite-task#366))

## Vite+ side changes

- Added the new `output: None` field to all `EnabledCacheConfig`
initializers in `packages/cli/binding/src/cli/{handler,resolver}.rs` to
match the new field added in vite-task#375.
- Bumped `rusqlite` to `0.39.0` to match vite-task's new requirement and
resolve a `libsqlite3-sys` links conflict.
- Regenerated `packages/cli/src/run-config.ts` types snapshot (vite-task
task map type tightened).
- Removed the `pass-no-color-env` snap test, which is no longer relevant
now that `NO_COLOR` is not in vite-task's default env passthrough.
- Updated `docs/config/run.md`:
  - Added an `output` cache config section.
- Refreshed the default-passthrough terminal env vars list (only
`FORCE_COLOR` is auto-passed; other color vars need opt-in).

Compare:
voidzero-dev/vite-task@88bacaa...c63db22#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed

---------

Co-authored-by: Claude <noreply@anthropic.com>
otnc pushed a commit to otnc/viteplus-ja that referenced this pull request May 13, 2026
Bumps the vite-task git dependency from `88bacaa` to `c63db22`.

## Notable upstream changes

- feat(cache): add `output` globs for cache restoration
([vite-task#375](voidzero-dev/vite-task#375))
- feat(cache): store colored task logs, strip at display when needed
([vite-task#378](voidzero-dev/vite-task#378))
- fix(plan): move FORCE_COLOR fallback after pattern filtering
([vite-task#379](voidzero-dev/vite-task#379))
- fix: preserve `PATHEXT` for Windows cached tasks
([vite-task#366](voidzero-dev/vite-task#366))

## Vite+ side changes

- Added the new `output: None` field to all `EnabledCacheConfig`
initializers in `packages/cli/binding/src/cli/{handler,resolver}.rs` to
match the new field added in vite-task#375.
- Bumped `rusqlite` to `0.39.0` to match vite-task's new requirement and
resolve a `libsqlite3-sys` links conflict.
- Regenerated `packages/cli/src/run-config.ts` types snapshot (vite-task
task map type tightened).
- Removed the `pass-no-color-env` snap test, which is no longer relevant
now that `NO_COLOR` is not in vite-task's default env passthrough.
- Updated `docs/config/run.md`:
  - Added an `output` cache config section.
- Refreshed the default-passthrough terminal env vars list (only
`FORCE_COLOR` is auto-passed; other color vars need opt-in).

Compare:
voidzero-dev/vite-task@88bacaa...c63db22#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed

---------

Co-authored-by: Claude <noreply@anthropic.com>
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