test: preserve themed badge contrast on light terminals

This commit is contained in:
Teknium
2026-09-07 02:44:43 -07:00
parent 99fb18d00d
commit d538f4e929
3 changed files with 26 additions and 4 deletions
@@ -0,0 +1,2 @@
pminervini
# PR #104222 salvage
+1
View File
@@ -512,6 +512,7 @@ def get_prompt_toolkit_style_overrides() -> Dict[str, str]:
palette: Dict[str, str] = {}
for name, key, fallback in _STYLE_PALETTE:
palette[name] = skin.get_color(key, palette[fallback[1:]] if fallback.startswith("@") else fallback)
# This badge paints both sides; foreground-only light remapping destroys its contrast.
palette["badge_bg"] = skin.colors.get(
"status_bar_strong", skin.colors.get("banner_title", "#FFD700"))
palette["badge_fg"] = skin.colors.get("status_bar_bg", "#1a1a2e")
+23 -4
View File
@@ -134,10 +134,29 @@ class TestLightModeRemap:
class TestSkinConfigHook:
"""The salvage wraps SkinConfig.get_color at module import time so
every skin color read goes through the light-mode remap. Verify
the hook installed and functions correctly.
"""
"""Exercise the installed color hook, including self-painted badge colors."""
@pytest.mark.parametrize("skin_name", ["default", "sisyphus"])
def test_badge_preserves_its_paired_colors_in_light_mode(
self, cli_mod, monkeypatch, skin_name
):
from hermes_cli.skin_engine import (
get_active_skin, get_prompt_toolkit_style_overrides, set_active_skin,
)
monkeypatch.setenv("HERMES_LIGHT", "1")
previous = get_active_skin().name
try:
set_active_skin(skin_name)
skin = get_active_skin()
background = skin.colors.get("status_bar_strong", skin.colors.get("banner_title", "#FFD700"))
foreground = skin.colors.get("status_bar_bg", "#1a1a2e")
assert get_prompt_toolkit_style_overrides()["status-bar-session-title"] == (
f"bg:{background} {foreground} bold"
)
finally:
set_active_skin(previous)
def test_hook_installed(self, cli_mod):
from hermes_cli.skin_engine import SkinConfig