Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion strix/interface/tui/renderers/proxy_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
46 changes: 46 additions & 0 deletions tests/test_proxy_renderer.py
Original file line number Diff line number Diff line change
@@ -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)