bd307f3a11
* feat(gateway): graph gateway protocol * refactor(cli): wire gateway in cli/tui * refactor(gateway): centralize runtime gateway init * chore(gateway): restrict RunRequest message type * feat(gateway): add langgraph server gateway * chore(cli): tighten serve runtime state typing * refactor(cli): route async task state reads through graph gateway * refactor(gateway): support graph targets in server gateway * refactor(cli): route session commands through graph gateway * refactor(cli): fold thread store under graph gateway * refactor(gateway): route graph state access through gateway * refactor(channels): wire graph gateway * refactor(memory): preserve graph threads for cloning * feat(gateway): add thread cloning * fix(tui): pass effective workspace for thread creation * chore(memory): add workspare dir to memory worker metadata * fix(sessions): filter preloaded UUID registy entries by the current scope * test(fakes): use https * refactor(consumer): consolidate imports * fix(stream): optional summarization event * fix(gateway): resolve abbreviated thread IDs by search * fix(gateway): page server thread listings * fix(gateway): emit pending interrupt events * style: fmt * feat(gateway): persist workspace_dir & model in thread metadata * fix(gateway): page server thread prefix resolution * fix(gateway): expose server thread list metadata * refactor: add back type def * refactor: tighten types * revert: add back worker thread deletion The worker thread forking changes are out of scope for now, so to maintain parity with the existing behavior we'll leave this intact. * fix(gateway): apply compaction to server thread history * refactor(stream): restore direct summary replay suppression * fix(gateway): preserve compaction state and server stream output * fix(gateway): close local stream generator on cancellation --------- Co-authored-by: Xi Zhang <106144707+X-iZhang@users.noreply.github.com>
80 lines
2.1 KiB
Python
80 lines
2.1 KiB
Python
"""Tests for UI backend runtime selection."""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from EvoScientist.cli.tui_runtime import (
|
|
normalize_ui_backend,
|
|
resolve_ui_backend,
|
|
run_streaming,
|
|
)
|
|
from tests.fakes import FakeGraphGateway
|
|
|
|
|
|
def test_normalize_ui_backend_defaults_to_cli():
|
|
assert normalize_ui_backend(None) == "cli"
|
|
assert normalize_ui_backend("") == "cli"
|
|
|
|
|
|
def test_normalize_ui_backend_accepts_known_values():
|
|
assert normalize_ui_backend("cli") == "cli"
|
|
assert normalize_ui_backend("tui") == "tui"
|
|
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"
|
|
|
|
|
|
def test_resolve_ui_backend_falls_back_when_textual_unavailable(monkeypatch):
|
|
monkeypatch.setattr(
|
|
"EvoScientist.cli.tui_runtime._has_textual_support", lambda: False
|
|
)
|
|
assert resolve_ui_backend("tui") == "cli"
|
|
|
|
|
|
def test_resolve_ui_backend_keeps_tui_when_available(monkeypatch):
|
|
monkeypatch.setattr(
|
|
"EvoScientist.cli.tui_runtime._has_textual_support", lambda: True
|
|
)
|
|
assert resolve_ui_backend("tui") == "tui"
|
|
|
|
|
|
@dataclass
|
|
class _BrokenBackend:
|
|
name: str = "tui"
|
|
|
|
def run_streaming(self, **kwargs):
|
|
raise RuntimeError("boom")
|
|
|
|
|
|
def test_run_streaming_falls_back_to_cli_on_runtime_error(monkeypatch):
|
|
monkeypatch.setattr(
|
|
"EvoScientist.cli.tui_runtime.get_backend", lambda *a, **k: _BrokenBackend()
|
|
)
|
|
|
|
class _RichStub:
|
|
def run_streaming(self, **kwargs):
|
|
return "fallback-ok"
|
|
|
|
monkeypatch.setattr(
|
|
"EvoScientist.cli.tui_runtime.RichStreamingBackend", lambda: _RichStub()
|
|
)
|
|
|
|
result = run_streaming(
|
|
ui_backend="tui",
|
|
agent=object(),
|
|
message="hello",
|
|
thread_id="t1",
|
|
show_thinking=False,
|
|
interactive=True,
|
|
gateway=FakeGraphGateway(),
|
|
)
|
|
assert result == "fallback-ok"
|