Commit c63db22
fix(plan): move FORCE_COLOR fallback after pattern filtering (#379)
## 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
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 51e35ea commit c63db22
2 files changed
Lines changed: 64 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
432 | 432 | | |
433 | | - | |
434 | 433 | | |
435 | 434 | | |
436 | 435 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
88 | | - | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
97 | 96 | | |
98 | 97 | | |
99 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
100 | 107 | | |
101 | 108 | | |
102 | 109 | | |
| |||
223 | 230 | | |
224 | 231 | | |
225 | 232 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
232 | 238 | | |
233 | | - | |
| 239 | + | |
234 | 240 | | |
235 | 241 | | |
236 | 242 | | |
| |||
241 | 247 | | |
242 | 248 | | |
243 | 249 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
253 | 256 | | |
254 | 257 | | |
255 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
256 | 272 | | |
257 | 273 | | |
258 | 274 | | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
265 | 278 | | |
266 | 279 | | |
267 | 280 | | |
268 | 281 | | |
269 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
270 | 301 | | |
271 | 302 | | |
272 | 303 | | |
| |||
0 commit comments