fix(cli): make TUI prompt and accent output skin-aware

Salvaged from PR #932 by Wayne onto current main.

Apply skin-aware prompt symbols and live prompt_toolkit color refresh,
replace lingering hardcoded accent output with active-skin colors, keep
ANSI-safe response rendering, preserve secret-capture and approval-prompt
state handling, and add integration coverage for prompt state and style
refresh behavior.
This commit is contained in:
Wayne
2026-03-14 03:12:52 -07:00
committed by teknium1
parent 29312a23d9
commit 41f22de20f
4 changed files with 436 additions and 51 deletions

View File

@@ -628,3 +628,88 @@ def init_skin_from_config(config: dict) -> None:
set_active_skin(skin_name.strip())
else:
set_active_skin("default")
# =============================================================================
# Convenience helpers for CLI modules
# =============================================================================
def get_active_prompt_symbol(fallback: str = " ") -> str:
"""Get the interactive prompt symbol from the active skin."""
try:
return get_active_skin().get_branding("prompt_symbol", fallback)
except Exception:
return fallback
def get_active_help_header(fallback: str = "(^_^)? Available Commands") -> str:
"""Get the /help header from the active skin."""
try:
return get_active_skin().get_branding("help_header", fallback)
except Exception:
return fallback
def get_active_goodbye(fallback: str = "Goodbye! ⚕") -> str:
"""Get the goodbye line from the active skin."""
try:
return get_active_skin().get_branding("goodbye", fallback)
except Exception:
return fallback
def get_prompt_toolkit_style_overrides() -> Dict[str, str]:
"""Return prompt_toolkit style overrides derived from the active skin.
These are layered on top of the CLI's base TUI style so /skin can refresh
the live prompt_toolkit UI immediately without rebuilding the app.
"""
try:
skin = get_active_skin()
except Exception:
return {}
prompt = skin.get_color("prompt", "#FFF8DC")
input_rule = skin.get_color("input_rule", "#CD7F32")
title = skin.get_color("banner_title", "#FFD700")
text = skin.get_color("banner_text", prompt)
dim = skin.get_color("banner_dim", "#555555")
label = skin.get_color("ui_label", title)
warn = skin.get_color("ui_warn", "#FF8C00")
error = skin.get_color("ui_error", "#FF6B6B")
return {
"input-area": prompt,
"placeholder": f"{dim} italic",
"prompt": prompt,
"prompt-working": f"{dim} italic",
"hint": f"{dim} italic",
"input-rule": input_rule,
"image-badge": f"{label} bold",
"completion-menu": f"bg:#1a1a2e {text}",
"completion-menu.completion": f"bg:#1a1a2e {text}",
"completion-menu.completion.current": f"bg:#333355 {title}",
"completion-menu.meta.completion": f"bg:#1a1a2e {dim}",
"completion-menu.meta.completion.current": f"bg:#333355 {label}",
"clarify-border": input_rule,
"clarify-title": f"{title} bold",
"clarify-question": f"{text} bold",
"clarify-choice": dim,
"clarify-selected": f"{title} bold",
"clarify-active-other": f"{title} italic",
"clarify-countdown": input_rule,
"sudo-prompt": f"{error} bold",
"sudo-border": input_rule,
"sudo-title": f"{error} bold",
"sudo-text": text,
"approval-border": input_rule,
"approval-title": f"{warn} bold",
"approval-desc": f"{text} bold",
"approval-cmd": f"{dim} italic",
"approval-choice": dim,
"approval-selected": f"{title} bold",
}