feat(tui): refactor TUI components for improved text rendering and styling

- 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.
This commit is contained in:
0xallam
2026-01-05 00:07:54 -08:00
committed by Ahmed Allam
parent 7bcdedfb18
commit a2142cc985
19 changed files with 980 additions and 754 deletions

View File

@@ -1,5 +1,6 @@
from typing import Any, ClassVar
from rich.text import Text
from textual.widgets import Static
from .base_renderer import BaseToolRenderer
@@ -14,16 +15,18 @@ class ThinkRenderer(BaseToolRenderer):
@classmethod
def render(cls, tool_data: dict[str, Any]) -> Static:
args = tool_data.get("args", {})
thought = args.get("thought", "")
header = "🧠 [bold #a855f7]Thinking[/]"
text = Text()
text.append("🧠 ")
text.append("Thinking", style="bold #a855f7")
text.append("\n ")
if thought:
thought_display = thought[:600] + "..." if len(thought) > 600 else thought
content = f"{header}\n [italic dim]{cls.escape_markup(thought_display)}[/]"
thought_display = cls.truncate(thought, 600)
text.append(thought_display, style="italic dim")
else:
content = f"{header}\n [italic dim]Thinking...[/]"
text.append("Thinking...", style="italic dim")
css_classes = cls.get_css_classes("completed")
return Static(content, classes=css_classes)
return Static(text, classes=css_classes)