Skip to content

fix(ui): decide colour per output stream - #784

Merged
indaco merged 2 commits into
mainfrom
fix/stream-aware-color-enablement
Jul 26, 2026
Merged

fix(ui): decide colour per output stream#784
indaco merged 2 commits into
mainfrom
fix/stream-aware-color-enablement

Conversation

@indaco

@indaco indaco commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Description

Seven commands - info, which, uses, search, list, outdated, rollback --list - print colourised rows to stdout but decided whether to colour by looking at stderr. Run any of them from a terminal with stdout redirected and raw escape sequences landed in the file. Each now asks about the stream it writes to.

Colour already resolved to a policy in the previous change, and always / never are stream-independent, so only the auto case gained a per-stream probe. Callers that write to stderr keep the answer they had.

Related Issue

  • None

Notes for Reviewers

  • None

This is part 2 of 3 in a stack made with GitButler:

Base automatically changed from fix/clicolor-policy-resolver to main July 26, 2026 20:59
indaco added 2 commits July 26, 2026 22:59
Commands that print their colourised rows to stdout were deciding whether
to colour by probing stderr, so redirecting stdout to a file from a
terminal wrote raw escape sequences into the file. Each now asks about
the stream it actually writes to.

Colour already resolved to a policy, and always/never are stream-
independent, so only the auto case gained a per-stream probe.
isColorEnabled() read like the general question but answered only for
stderr, so a new stdout writer calling it by habit reintroduced the bug
this branch just fixed. Renaming it to isColorEnabledForStderr leaves no
default to get wrong; every caller now names the stream it writes to.

Mechanical rename, no behaviour change.
@indaco
indaco force-pushed the fix/stream-aware-color-enablement branch from f09f49d to a40d27b Compare July 26, 2026 20:59
@indaco
indaco merged commit 7b56595 into main Jul 26, 2026
3 checks passed
@indaco
indaco deleted the fix/stream-aware-color-enablement branch July 26, 2026 21:00
indaco added a commit that referenced this pull request Jul 27, 2026
* fix(ui): decide colour per output stream

Commands that print their colourised rows to stdout were deciding whether
to colour by probing stderr, so redirecting stdout to a file from a
terminal wrote raw escape sequences into the file. Each now asks about
the stream it actually writes to.

Colour already resolved to a policy, and always/never are stream-
independent, so only the auto case gained a per-stream probe.

* refactor(ui): name the stderr colour helper for its stream

isColorEnabled() read like the general question but answered only for
stderr, so a new stdout writer calling it by habit reintroduced the bug
this branch just fixed. Renaming it to isColorEnabledForStderr leaves no
default to get wrong; every caller now names the stream it writes to.

Mechanical rename, no behaviour change.

(cherry picked from commit 7b56595)
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.

1 participant