Skip to content
Merged
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
9 changes: 6 additions & 3 deletions src/ghidra_deep_agent/tui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from langchain_core.language_models import BaseChatModel
from rich.rule import Rule
from rich.text import Text
from textual import work
from textual.app import App, ComposeResult
from textual.binding import Binding
Expand Down Expand Up @@ -432,8 +433,10 @@ async def _run_compaction(self) -> None:
)
except Exception as exc:
response.write(
f"[bold red]✗ Compaction failed: {exc} — "
"the conversation was not changed.[/bold red]"
Text(
f"✗ Compaction failed: {exc} — the conversation was not changed.",
style="bold red",
)
)
finally:
self._set_busy(False)
Expand Down Expand Up @@ -867,7 +870,7 @@ async def _run_agent(self, query: str | None) -> None:
response.write(Rule(style="yellow"))
except Exception as exc:
response.write(Rule(style="red"))
response.write(f"[bold red]✗ Error: {exc}[/bold red]")
response.write(Text(f"✗ Error: {exc}", style="bold red"))
response.write(Rule(style="red"))
finally:
# Runs on cancellation too (CancelledError is a BaseException and
Expand Down
8 changes: 7 additions & 1 deletion src/ghidra_deep_agent/tui/report_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ def compose(self) -> ComposeResult:
id="report-title",
)
yield ListView(*self._rows(), id="report-list")
yield RichLog(id="report-body", highlight=False, markup=False)
yield RichLog(
id="report-body",
highlight=False,
markup=False,
wrap=True,
min_width=1,
)

def on_mount(self) -> None:
self.query_one(ListView).focus()
Expand Down
21 changes: 19 additions & 2 deletions src/ghidra_deep_agent/tui/widgets/response_log.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from __future__ import annotations

from typing import Any

from rich.markdown import Markdown
from rich.rule import Rule
from rich.table import Table
from rich.text import Text
from textual.widgets import RichLog

from ghidra_deep_agent.tui.messages import AgentDone, ResponseFinal
Expand All @@ -10,6 +14,14 @@
class ResponseLog(RichLog):
"""Right pane: buffered markdown response."""

def __init__(self, *args: Any, **kwargs: Any) -> None:
# RichLog renders plain strings unwrapped and everything at least 78
# columns wide by default, so prompts, errors, and (in a narrow pane)
# markdown would run off the right edge of the pane.
kwargs.setdefault("wrap", True)
kwargs.setdefault("min_width", 1)
super().__init__(*args, **kwargs)

def on_mount(self) -> None:
self._response_buf = ""
self.last_response = ""
Expand All @@ -31,8 +43,13 @@ def log_plan(self, text: str) -> None:
def log_user(self, text: str) -> None:
self.transcript.append(f"❯ {text}")
self.write(Rule(style="dim cyan"))
shown = text.replace("\n", "\n ")
self.write(f"[bold cyan]❯ {shown}[/bold cyan]")
# A grid keeps wrapped and multi-line prompts aligned under the text,
# and Text (not markup) shows any [brackets] in the prompt literally.
prompt = Table.grid()
prompt.add_column(no_wrap=True)
prompt.add_column()
prompt.add_row(Text("❯ ", style="bold cyan"), Text(text, style="bold cyan"))
self.write(prompt)
self.write(Rule(style="dim cyan"))

def on_response_final(self, msg: ResponseFinal) -> None:
Expand Down
24 changes: 24 additions & 0 deletions tests/test_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,30 @@ async def run() -> None:
asyncio.run(run())


def test_response_log_wraps_long_lines() -> None:
"""Long prompts, error lines, and markdown wrap inside a pane narrower
than RichLog's 78-column default, and prompt brackets show literally."""

async def run() -> None:
app = _make_app()
async with app.run_test(size=(80, 30)) as pilot:
await pilot.pause()
response = app.query_one(ResponseLog)
assert response.wrap
response.clear()
response.log_user("word " * 60 + "[not markup]")
response.write("[bold red]✗ Error: " + "boom " * 60 + "[/bold red]")
response.log_assistant("reply " * 60)
await pilot.pause()
width = response.scrollable_content_region.width
texts = [strip.text for strip in response.lines]
assert len(texts) > 4
assert max(strip.cell_length for strip in response.lines) <= width
assert "[not markup]" in "".join(texts)

asyncio.run(run())


def test_nested_tool_calls_are_hidden() -> None:
"""A tool invoked from inside another tool's body (recover_prototypes →
scripts) is suppressed entirely — no tree row, no deferred-async leak."""
Expand Down
Loading