22 lines
627 B
Python
22 lines
627 B
Python
"""Chat display widget for oAI TUI."""
|
|
|
|
from textual.containers import ScrollableContainer
|
|
from textual.widgets import Static
|
|
|
|
|
|
class ChatDisplay(ScrollableContainer):
|
|
"""Scrollable container for chat messages."""
|
|
|
|
def __init__(self):
|
|
super().__init__(id="chat-display")
|
|
|
|
async def add_message(self, widget: Static) -> None:
|
|
"""Add a message widget to the display."""
|
|
await self.mount(widget)
|
|
self.scroll_end(animate=False)
|
|
|
|
def clear_messages(self) -> None:
|
|
"""Clear all messages from the display."""
|
|
for child in list(self.children):
|
|
child.remove()
|