diff --git a/strix/interface/tui/renderers/proxy_renderer.py b/strix/interface/tui/renderers/proxy_renderer.py index 6fbbe121d..359b494d6 100644 --- a/strix/interface/tui/renderers/proxy_renderer.py +++ b/strix/interface/tui/renderers/proxy_renderer.py @@ -191,7 +191,7 @@ def render(cls, tool_data: dict[str, Any]) -> Static: # noqa: PLR0912, PLR0915 if i < len(lines) - 1: text.append("\n") - if has_more or len(lines) > 15: + if has_more or len(content.split("\n")) > 15: text.append("\n") text.append(" ... more content available", style="dim italic") diff --git a/tests/test_proxy_renderer.py b/tests/test_proxy_renderer.py new file mode 100644 index 000000000..341a1f40f --- /dev/null +++ b/tests/test_proxy_renderer.py @@ -0,0 +1,46 @@ +"""Tests for the proxy tool TUI renderers.""" + +from __future__ import annotations + +from rich.text import Text + +from strix.interface.tui.renderers.proxy_renderer import ViewRequestRenderer + + +def _plain(static: object) -> str: + content = static.content # type: ignore[attr-defined] + return content.plain if isinstance(content, Text) else str(content) + + +def _render(content: str, *, has_more: bool) -> str: + tool_data = { + "status": "completed", + "result": { + "content": content, + "has_more": has_more, + "page": 1, + "total_lines": len(content.split("\n")), + }, + } + return _plain(ViewRequestRenderer.render(tool_data)) + + +_MARKER = "... more content available" + + +def test_more_content_hint_shown_when_over_fifteen_lines() -> None: + content = "\n".join(f"line{i}" for i in range(30)) + + assert _MARKER in _render(content, has_more=False) + + +def test_no_more_content_hint_within_fifteen_lines() -> None: + content = "\n".join(f"line{i}" for i in range(5)) + + assert _MARKER not in _render(content, has_more=False) + + +def test_more_content_hint_shown_when_has_more_flag_set() -> None: + content = "\n".join(f"line{i}" for i in range(3)) + + assert _MARKER in _render(content, has_more=True)