mirror of
https://github.com/usestrix/strix.git
synced 2026-08-18 01:39:19 +02:00
- Removed unused escape_markup function and integrated rich.text for better text handling. - Updated various renderers to utilize Text for consistent styling and formatting. - Enhanced chat and agent message displays with dynamic text features. - Improved error handling and display for various tool components. - Refined TUI styles for better visual consistency across components.
33 lines
970 B
Python
33 lines
970 B
Python
from typing import Any, ClassVar
|
|
|
|
from rich.text import Text
|
|
from textual.widgets import Static
|
|
|
|
from .base_renderer import BaseToolRenderer
|
|
from .registry import register_tool_renderer
|
|
|
|
|
|
@register_tool_renderer
|
|
class ThinkRenderer(BaseToolRenderer):
|
|
tool_name: ClassVar[str] = "think"
|
|
css_classes: ClassVar[list[str]] = ["tool-call", "thinking-tool"]
|
|
|
|
@classmethod
|
|
def render(cls, tool_data: dict[str, Any]) -> Static:
|
|
args = tool_data.get("args", {})
|
|
thought = args.get("thought", "")
|
|
|
|
text = Text()
|
|
text.append("🧠 ")
|
|
text.append("Thinking", style="bold #a855f7")
|
|
text.append("\n ")
|
|
|
|
if thought:
|
|
thought_display = cls.truncate(thought, 600)
|
|
text.append(thought_display, style="italic dim")
|
|
else:
|
|
text.append("Thinking...", style="italic dim")
|
|
|
|
css_classes = cls.get_css_classes("completed")
|
|
return Static(text, classes=css_classes)
|