4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
"""Tests for the shared interactive-shell LLM loader."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import io
|
|
from typing import Any
|
|
|
|
from rich.console import Console
|
|
|
|
from surfaces.interactive_shell.ui.components import loaders
|
|
from surfaces.interactive_shell.ui.components.loaders import llm_loader
|
|
|
|
|
|
def _terminal_console() -> tuple[Console, io.StringIO]:
|
|
buf = io.StringIO()
|
|
return (
|
|
Console(file=buf, force_terminal=True, color_system=None, width=80, highlight=False),
|
|
buf,
|
|
)
|
|
|
|
|
|
def _plain_console() -> tuple[Console, io.StringIO]:
|
|
"""Console that reports ``is_terminal == False`` — the CI / piped case."""
|
|
buf = io.StringIO()
|
|
return (Console(file=buf, force_terminal=False, color_system=None, width=80), buf)
|
|
|
|
|
|
class TestLLMLoader:
|
|
def test_yields_to_caller_and_runs_wrapped_block(self) -> None:
|
|
console, _ = _terminal_console()
|
|
ran: list[bool] = []
|
|
with llm_loader(console):
|
|
ran.append(True)
|
|
assert ran == [True]
|
|
|
|
def test_skips_spinner_when_console_is_not_a_terminal(self) -> None:
|
|
"""In CI / piped output we must NOT pollute logs with spinner frames."""
|
|
console, buf = _plain_console()
|
|
with llm_loader(console):
|
|
pass
|
|
# Nothing should be written — no label, no escape sequences, nothing.
|
|
assert buf.getvalue() == ""
|
|
|
|
def test_loader_uses_subtle_spinner_style(self, monkeypatch: Any) -> None:
|
|
"""The loader uses a dim, quiet spinner — less visual noise than a bright accent."""
|
|
captured: dict[str, Any] = {}
|
|
|
|
# Fake context manager so we can introspect the kwargs without
|
|
# triggering Rich's Live renderer in the test.
|
|
class _FakeStatus:
|
|
def __enter__(self) -> _FakeStatus:
|
|
return self
|
|
|
|
def __exit__(self, *exc: object) -> None:
|
|
return None
|
|
|
|
def _fake_status(text: str, **kwargs: Any) -> _FakeStatus:
|
|
captured["text"] = text
|
|
captured["kwargs"] = kwargs
|
|
return _FakeStatus()
|
|
|
|
console, _ = _terminal_console()
|
|
monkeypatch.setattr(console, "status", _fake_status)
|
|
|
|
with llm_loader(console, label="consulting the model"):
|
|
pass
|
|
|
|
from platform.terminal.theme import SECONDARY
|
|
|
|
assert SECONDARY in captured["text"]
|
|
assert "consulting the model" in captured["text"]
|
|
assert captured["kwargs"]["spinner"] == "dots"
|
|
assert captured["kwargs"]["spinner_style"] == SECONDARY
|
|
|
|
|
|
def test_module_exports_loader_and_default_label() -> None:
|
|
assert "llm_loader" in loaders.__all__
|
|
assert "DEFAULT_LOADER_LABEL" in loaders.__all__
|