From fce47dab095a04f33f082bea4d54be91a791356e Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Fri, 30 Jan 2026 09:11:30 +0000 Subject: [PATCH] Add UI modules and tests --- src/ui/display.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/ui/display.py diff --git a/src/ui/display.py b/src/ui/display.py new file mode 100644 index 0000000..6a649c5 --- /dev/null +++ b/src/ui/display.py @@ -0,0 +1,65 @@ +"""Display utilities for DevTrace UI.""" + +from typing import Dict, Any +from datetime import datetime + +from rich.console import Console +from rich.table import Table +from rich.panel import Panel + + +class DisplayManager: + """Manages rich display utilities for DevTrace.""" + + def __init__(self): + self.console = Console() + + def show_status(self, stats: Dict[str, Any]) -> None: + """Display DevTrace status and statistics.""" + table = Table(title="DevTrace Statistics") + table.add_column("Metric", style="cyan") + table.add_column("Value", style="green", justify="right") + + table.add_row("Total Sessions", str(stats.get("total_sessions", 0))) + table.add_row("Active Sessions", str(stats.get("active_sessions", 0))) + table.add_row("File Events", str(stats.get("file_events", 0))) + table.add_row("Command Events", str(stats.get("command_events", 0))) + table.add_row("Git Events", str(stats.get("git_events", 0))) + table.add_row("Total Events", str(stats.get("total_events", 0))) + + self.console.print(Panel(table, title="DevTrace Status")) + + def show_success(self, message: str) -> None: + """Show a success message.""" + self.console.print(Panel( + f"[bold green]✓ {message}[/]", + style="green" + )) + + def show_error(self, message: str) -> None: + """Show an error message.""" + self.console.print(Panel( + f"[bold red]✗ {message}[/]", + style="red" + )) + + def show_warning(self, message: str) -> None: + """Show a warning message.""" + self.console.print(Panel( + f"[bold yellow]⚠ {message}[/]", + style="yellow" + )) + + def format_duration(self, seconds: float) -> str: + """Format duration in human-readable format.""" + if seconds < 60: + return f"{seconds:.1f}s" + elif seconds < 3600: + mins = seconds / 60 + return f"{mins:.1f}m" + elif seconds < 86400: + hours = seconds / 3600 + return f"{hours:.1f}h" + else: + days = seconds / 86400 + return f"{days:.1f}d"