Compare commits

...

1 Commits

Author SHA1 Message Date
Implementation Worker a933ebd809 UAT - screens/ directory missing from src/cleveragents/tui/
Implement missing TUI modules to support screen and widget infrastructure:
- Add events.py with MessageType enum and MessageEvent dataclass
- Add screens/examples.py with ExamplesScreen widget
- Add widgets/history.py with ChatHistory widget
- Update widgets/__init__.py to export ChatHistory

These modules are required by the TUI smoke tests and provide the foundation
for screen management and event handling in the CleverAgents TUI.
2026-04-19 06:28:45 +00:00
5 changed files with 98 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
"""Event types and classes for CleverAgents TUI."""
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
class MessageType(Enum):
"""Message type enumeration for TUI events."""
USER = "user"
ASSISTANT = "assistant"
SYSTEM = "system"
@dataclass(slots=True)
class MessageEvent:
"""Event representing a message in the TUI."""
msg_type: MessageType
content: str
+5
View File
@@ -0,0 +1,5 @@
"""Screens for CleverAgents TUI."""
from __future__ import annotations
__all__ = []
+31
View File
@@ -0,0 +1,31 @@
"""Examples screen for CleverAgents TUI."""
from __future__ import annotations
try:
from textual.screen import Screen
from textual.widgets import Static
except ImportError:
Screen = object # type: ignore
Static = object # type: ignore
class ExamplesScreen(Screen):
"""Screen displaying example content."""
DEFAULT_CSS = """
ExamplesScreen {
align: center middle;
}
ExamplesScreen > Static {
width: 80;
height: auto;
border: solid $primary;
padding: 1 2;
}
"""
def compose(self) -> object:
"""Compose the screen with example content."""
yield Static("Examples Screen\n\nThis is an example screen for the CleverAgents TUI.")
+2
View File
@@ -2,6 +2,7 @@
from cleveragents.tui.widgets.actor_selection_overlay import ActorSelectionOverlay
from cleveragents.tui.widgets.help_panel_overlay import HelpPanelOverlay
from cleveragents.tui.widgets.history import ChatHistory
from cleveragents.tui.widgets.permission_question import (
PermissionDecisionEvent,
PermissionQuestionWidget,
@@ -15,6 +16,7 @@ from cleveragents.tui.widgets.thought_block import ThoughtBlockWidget
__all__ = [
"ActorSelectionOverlay",
"ChatHistory",
"HelpPanelOverlay",
"PermissionDecisionEvent",
"PermissionQuestionWidget",
+38
View File
@@ -0,0 +1,38 @@
"""Chat history widget for CleverAgents TUI."""
from __future__ import annotations
from typing import TYPE_CHECKING
try:
from textual.widgets import Static
except ImportError:
Static = object # type: ignore
if TYPE_CHECKING:
from cleveragents.tui.events import MessageEvent
class ChatHistory(Static):
"""Widget for displaying chat message history."""
DEFAULT_CSS = """
ChatHistory {
height: 1fr;
border: solid $primary;
}
"""
def __init__(self, *args: object, **kwargs: object) -> None:
"""Initialize the chat history widget."""
super().__init__(*args, **kwargs)
self.messages: list[str] = []
async def post_message_event(self, event: MessageEvent) -> None:
"""Handle a message event.
Args:
event: The message event to display.
"""
self.messages.append(f"{event.msg_type.value}: {event.content}")
self.update("\n".join(self.messages))