From ebd9b37715b47c19d9f547e69a91bc6907e3da99 Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Sat, 4 Jul 2026 15:14:42 -0700 Subject: [PATCH] fix(tui): show 'more content available' for view_request over 15 lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ViewRequestRenderer sliced content to 15 lines, then guarded the truncation hint with len(lines) > 15 — always false, since lines was already capped at 15. Output longer than 15 lines with has_more falsy was silently truncated with no indicator. Measure the original line count via len(content.split()) instead, matching the sibling RepeatRequestRenderer. Add regression tests. Closes #685 --- .../interface/tui/renderers/proxy_renderer.py | 2 +- tests/test_proxy_renderer.py | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/test_proxy_renderer.py 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)