MCPcopy Create free account
hub / github.com/HKUDS/OpenSpace / OpenSpaceUI

Class OpenSpaceUI

openspace/utils/ui.py:28–435  ·  view source on GitHub ↗

OpenSpace Terminal UI Provides real-time visualization of: - Agent activities and status - Grounding backend operations - Execution logs - System metrics Design Philosophy: - Lightweight and fast (no heavy dependencies) - Clean ANSI-based rendering

Source from the content-addressed store, hash-verified

26
27
28class OpenSpaceUI:
29 """
30 OpenSpace Terminal UI
31
32 Provides real-time visualization of:
33 - Agent activities and status
34 - Grounding backend operations
35 - Execution logs
36 - System metrics
37
38 Design Philosophy:
39 - Lightweight and fast (no heavy dependencies)
40 - Clean ANSI-based rendering
41 - Minimal CPU overhead
42 - Easy to customize
43 """
44
45 def __init__(self, enable_live: bool = True, compact: bool = False):
46 """
47 Initialize UI
48
49 Args:
50 enable_live: Whether to enable live display updates
51 compact: Use compact layout (for smaller terminals)
52 """
53 self.enable_live = enable_live
54 self.compact = compact
55
56 # Terminal dimensions
57 self.term_width, self.term_height = self._get_terminal_size()
58
59 # State tracking
60 self.agent_status: Dict[str, AgentStatus] = {}
61 self.agent_activities: Dict[str, List[str]] = {}
62 self.grounding_operations: List[Dict[str, Any]] = []
63 self.grounding_backends: List[Dict[str, Any]] = [] # Backend info (type, servers, etc.)
64 self.log_buffer: List[Tuple[str, str, datetime]] = [] # (message, level, timestamp)
65
66 # Metrics
67 self.metrics: Dict[str, Any] = {
68 "start_time": None,
69 "iterations": 0,
70 "completed_tasks": 0,
71 "llm_calls": 0,
72 "grounding_calls": 0,
73 }
74
75 # Live display state
76 self._live_running = False
77 self._live_task: Optional[asyncio.Task] = None
78 self._last_render: List[str] = []
79
80 def _get_terminal_size(self) -> Tuple[int, int]:
81 """Get terminal size"""
82 try:
83 size = shutil.get_terminal_size((80, 24))
84 return size.columns, size.lines
85 except:

Callers 1

create_uiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected