session_skin.py 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. """The owning profile's resolved skin for a canonical client's readiness.
  2. Main's TUI booted its theme from ``gateway.ready.skin`` (``tui_gateway/entry.py`` / ``ws.py``, both
  3. ``change_watcher.resolve_skin()``). On the session authority the client publishes its own ready after
  4. ``runtime.describe``, so the describe reply carries the same payload, resolved for the profile that
  5. owns this authority (``display.skin`` and ``<home>/skins/*.yaml`` are per profile).
  6. """
  7. from __future__ import annotations
  8. import logging
  9. logger = logging.getLogger(__name__)
  10. def resolved_skin() -> dict:
  11. """``resolve_skin()``'s dict for the profile in scope (the dispatcher's ``owner_scope``); ``{}``
  12. when the skin engine fails, which the client treats as the default theme, as main did."""
  13. try:
  14. from hermes_cli.config_effective import load_user_config_effective
  15. from hermes_cli.skin_engine import get_active_skin, init_skin_from_config
  16. from hermes_constants import get_hermes_home
  17. init_skin_from_config(load_user_config_effective(get_hermes_home() / "config.yaml"))
  18. skin = get_active_skin()
  19. return {
  20. "name": skin.name, "colors": skin.colors,
  21. "light_colors": skin.light_colors, "dark_colors": skin.dark_colors,
  22. "branding": skin.branding, "banner_logo": skin.banner_logo,
  23. "banner_hero": skin.banner_hero, "tool_prefix": skin.tool_prefix,
  24. "help_header": (skin.branding or {}).get("help_header", ""),
  25. "customCSS": skin.custom_css}
  26. except Exception: # health: allow BLE001 -- main's resolve_skin: a broken skin boots the default theme
  27. logger.debug("runtime.describe: skin resolution failed", exc_info=True)
  28. return {}