From 9e7e84c03cbfb6d183c0625e0e7e48daa2818da0 Mon Sep 17 00:00:00 2001 From: famez Date: Sun, 15 Feb 2026 22:33:47 +0100 Subject: [PATCH] Added chevron icon and additional text on the tool message indicating that clicking over the message allows to see the tool result. --- pentestagent/interface/tui.py | 38 ++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/pentestagent/interface/tui.py b/pentestagent/interface/tui.py index 384eef2..caed3bc 100644 --- a/pentestagent/interface/tui.py +++ b/pentestagent/interface/tui.py @@ -648,8 +648,13 @@ class ThinkingMessage(Static): class ToolMessage(Static): """Tool execution message""" - TOOL_ICON = "$" TOOL_COLOR = "#9a9a9a" + ARG_COLOR = "#6b6b6b" + HINT_COLOR = "#6b6b6b" + + CHEVRON_COLLAPSED = "▶" + CHEVRON_EXPANDED = "▼" + HINT_TEXT = " (click to see result)" expanded: bool = reactive(False, layout=True) @@ -661,43 +666,51 @@ class ToolMessage(Static): def render(self) -> Text: text = Text() - text.append(f"{self.TOOL_ICON} ", style=self.TOOL_COLOR) + + chevron = ( + self.CHEVRON_EXPANDED if self.expanded else self.CHEVRON_COLLAPSED + ) + + # Header line + text.append(f"{chevron} ", style=self.TOOL_COLOR) text.append(self.tool_name, style=self.TOOL_COLOR) + + # Hint text (only when result exists and is collapsed) + if self._result_widget and not self.expanded: + text.append(self.HINT_TEXT, style=self.HINT_COLOR) + text.append("\n") + # Tool arguments if self.tool_args: for line in wrap_text_lines(self.tool_args, width=110): - text.append(f" {line}\n", style="#6b6b6b") + text.append(f" {line}\n", style=self.ARG_COLOR) return text def attach_result(self, result_widget: "ToolResultMessage") -> None: """Attach a ToolResultMessage widget below this message.""" - - # Prevent double mounting if self._result_widget is not None: return self._result_widget = result_widget self._result_widget.display = self.expanded - # Mount immediately after this widget + # Mount directly after this widget self.mount(self._result_widget, after=self) - - def on_click(self) -> None: self.expanded = not self.expanded if self._result_widget: self._result_widget.display = self.expanded - class ToolResultMessage(Static): """Tool result/output message""" RESULT_ICON = "#" - RESULT_COLOR = "#7a7a7a" + RESULT_COLOR = "#124670" + OUTPUT_COLOR = "#17606d" def __init__(self, tool_name: str, result: str = "", **kwargs): super().__init__(**kwargs) @@ -706,13 +719,14 @@ class ToolResultMessage(Static): def render(self) -> Text: text = Text() + text.append(f"{self.RESULT_ICON} ", style=self.RESULT_COLOR) text.append(f"{self.tool_name} output", style=self.RESULT_COLOR) - text.append("\n", style="") + text.append("\n") if self.result: for line in wrap_text_lines(self.result, width=110): - text.append(f" {line}\n", style="#5a5a5a") + text.append(f" {line}\n", style=self.OUTPUT_COLOR) return text