fix(colors): readable defaults on light terminals via HERMES_THEME + COLORFGBG - #9808
Closed
skyc1e wants to merge 1 commit into
Closed
fix(colors): readable defaults on light terminals via HERMES_THEME + COLORFGBG#9808skyc1e wants to merge 1 commit into
skyc1e wants to merge 1 commit into
Conversation
…COLORFGBG When hermes runs in a light-theme terminal (e.g. the default macOS Terminal.app profile), yellow text renders near-invisible against white and dim text loses nearly all contrast. Issue NousResearch#8526 reports this for the interactive chat, but it applies to every CLI surface that routes through `hermes_cli.colors.color()` — status, doctor, setup menus, etc. Introduce a small, call-site-free theme layer in `hermes_cli/colors.py`: * `HERMES_THEME=light|dark` is an explicit override. * `HERMES_THEME=auto` (or unset) falls back to COLORFGBG-based background detection. The heuristic is conservative: bg indices 7 and 15 → light; 0-6 and 8 → dark; anything else (including the literal "default") falls through and we keep today's behavior. * `NO_COLOR` still wins over every code path — honored first, exactly as before. In light mode, `color()` remaps: * YELLOW → MAGENTA (readable on white; still reads as "warning-ish") * DIM → "" (the terminal's default foreground is already readable on a light background) Red, green, cyan, blue, magenta, and bold are left untouched so the existing semantic meaning (error=red, ok=green, info=cyan) is preserved. No call sites change; no new dependencies; Rich/UI theming is out of scope. Closes NousResearch#8526
Contributor
|
Closing as superseded by #17113. Triage notes (medium confidence): Thanks for the contribution — the underlying problem this PR addresses has been resolved by the linked PR on current main. If you believe this was closed in error, please comment and we'll reopen. (Bulk-closed during a CLI PR triage sweep.) |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #8526 — on light-theme terminals (reported against macOS Terminal.app's default profile),
hermesrenders yellow-on-white and dim-on-white text that's effectively unreadable. The reporter's screenshot shows the interactive chat, but the problem applies to every CLI surface (status, doctor, setup menus, cron list, etc.) because they all funnel throughhermes_cli/colors.py::color().Fix
Small, call-site-free theme layer in
hermes_cli/colors.py:HERMES_THEME=light|dark— explicit opt-in override.HERMES_THEME=auto(or unset) — conservative background auto-detection viaCOLORFGBG. Onlybg ∈ {7, 15}is treated as light;0–6, 8are treated as dark; anything else (including the literaldefaultsome terminals emit) falls through and keeps today's behavior, so no one who's currently happy gets new visuals by accident.NO_COLORis honored first, identical to before — no theme configuration can override it.In light mode,
color()remaps exactly two codes:YELLOW(33)MAGENTA(35)DIM(2)""(unset)Red, green, cyan, blue, magenta, and bold are untouched so existing semantic meaning (error = red, ok = green, info = cyan) is preserved.
Scope is intentionally narrow:
hermes_cli/colors.py, ~70 lines added) plustests/hermes_cli/test_colors.py.color(text, Colors.YELLOW)/Colors.DIMusage (~200 across 14 modules) picks up the new behavior automatically.Test plan
New
tests/hermes_cli/test_colors.pycovers:NO_COLORstill wins over any theme configuration (includingHERMES_THEME=light).HERMES_THEME=light|darktakes priority overCOLORFGBG; case-insensitive, tolerates surrounding whitespace.HERMES_THEME=auto(and unset) fall through toCOLORFGBGdetection.COLORFGBGparsing: uses the trailing segment; handles 2- and 3-segment forms (rxvt usesfg;?;bg);defaultsegment returnsNone.YELLOW → MAGENTAand dropsDIM; dark mode and the default (no-env) path preserve both.BOLD + YELLOW) remap only the yellow.Notes
YELLOW(e.g.BLUEinstead ofMAGENTA), that's a one-line change in_LIGHT_REMAP.