fix(ui): map legacy UI backend values to current equivalents in normalization
This commit is contained in:
@@ -9,6 +9,7 @@ from .tui_backends import RichStreamingBackend, StreamingTUIBackend
|
||||
|
||||
DEFAULT_UI_BACKEND = "cli"
|
||||
SUPPORTED_UI_BACKENDS = ("cli", "tui")
|
||||
_LEGACY_BACKEND_MAP = {"textual": "tui", "rich": "cli"}
|
||||
|
||||
|
||||
def normalize_ui_backend(value: str | None) -> str:
|
||||
@@ -16,6 +17,7 @@ def normalize_ui_backend(value: str | None) -> str:
|
||||
if not value:
|
||||
return DEFAULT_UI_BACKEND
|
||||
normalized = value.strip().lower()
|
||||
normalized = _LEGACY_BACKEND_MAP.get(normalized, normalized)
|
||||
if normalized in SUPPORTED_UI_BACKENDS:
|
||||
return normalized
|
||||
return DEFAULT_UI_BACKEND
|
||||
|
||||
@@ -483,10 +483,9 @@ def _step_ui_backend(config: EvoScientistConfig) -> str:
|
||||
]
|
||||
|
||||
# Map legacy values to current ones
|
||||
default_backend = config.ui_backend
|
||||
if default_backend == "textual":
|
||||
default_backend = "tui"
|
||||
elif default_backend not in ("tui", "cli"):
|
||||
_legacy_map = {"textual": "tui", "rich": "cli"}
|
||||
default_backend = _legacy_map.get(config.ui_backend, config.ui_backend)
|
||||
if default_backend not in ("tui", "cli"):
|
||||
default_backend = "tui"
|
||||
|
||||
backend = questionary.select(
|
||||
|
||||
@@ -16,6 +16,13 @@ def test_normalize_ui_backend_accepts_known_values():
|
||||
assert normalize_ui_backend("TUI") == "tui"
|
||||
|
||||
|
||||
def test_normalize_ui_backend_maps_legacy_values():
|
||||
assert normalize_ui_backend("textual") == "tui"
|
||||
assert normalize_ui_backend("Textual") == "tui"
|
||||
assert normalize_ui_backend("rich") == "cli"
|
||||
assert normalize_ui_backend("Rich") == "cli"
|
||||
|
||||
|
||||
def test_normalize_ui_backend_unknown_falls_back_to_cli():
|
||||
assert normalize_ui_backend("unknown-ui") == "cli"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user