Render the monitoring dashboard
(state: MonitorState, width: int = 80)
| 138 | |
| 139 | |
| 140 | def render_dashboard(state: MonitorState, width: int = 80): |
| 141 | """Render the monitoring dashboard""" |
| 142 | lines = [] |
| 143 | |
| 144 | # Header |
| 145 | header = f" JCODE MONITOR " |
| 146 | padding = (width - len(header)) // 2 |
| 147 | lines.append(f"{Colors.BG_BLUE}{Colors.WHITE}{Colors.BOLD}{' ' * padding}{header}{' ' * padding}{Colors.RESET}") |
| 148 | lines.append("") |
| 149 | |
| 150 | # Connection status |
| 151 | if state.connected: |
| 152 | status = f"{Colors.GREEN}CONNECTED{Colors.RESET}" |
| 153 | session = f" | Session: {Colors.DIM}{state.session_id[:8]}...{Colors.RESET}" if state.session_id else "" |
| 154 | else: |
| 155 | status = f"{Colors.RED}DISCONNECTED{Colors.RESET}" |
| 156 | session = "" |
| 157 | lines.append(f" Status: {status}{session}") |
| 158 | |
| 159 | # Processing state |
| 160 | if state.is_processing: |
| 161 | proc = f"{Colors.YELLOW}{Colors.BOLD}PROCESSING{Colors.RESET}" |
| 162 | else: |
| 163 | proc = f"{Colors.DIM}idle{Colors.RESET}" |
| 164 | lines.append(f" State: {proc}") |
| 165 | lines.append("") |
| 166 | |
| 167 | # Token usage |
| 168 | lines.append(f" {Colors.BOLD}Tokens{Colors.RESET}") |
| 169 | lines.append(f" Input: {format_tokens(state.input_tokens)}") |
| 170 | lines.append(f" Output: {format_tokens(state.output_tokens)}") |
| 171 | lines.append("") |
| 172 | |
| 173 | # Active tools |
| 174 | lines.append(f" {Colors.BOLD}Active Tools{Colors.RESET}") |
| 175 | if state.active_tools: |
| 176 | for tool_id, tool_name in state.active_tools.items(): |
| 177 | lines.append(f" {Colors.CYAN}>{Colors.RESET} {format_tool(tool_name)}") |
| 178 | else: |
| 179 | lines.append(f" {Colors.DIM}(none){Colors.RESET}") |
| 180 | lines.append("") |
| 181 | |
| 182 | # Recent tool completions |
| 183 | lines.append(f" {Colors.BOLD}Recent Tools{Colors.RESET}") |
| 184 | if state.tool_history: |
| 185 | for item in state.tool_history[-5:]: |
| 186 | name, success, output = item |
| 187 | status = "done" if success else "error" |
| 188 | output_preview = truncate(output.replace("\n", " "), 40) |
| 189 | lines.append(f" {format_tool(name, status)}: {Colors.DIM}{output_preview}{Colors.RESET}") |
| 190 | else: |
| 191 | lines.append(f" {Colors.DIM}(none){Colors.RESET}") |
| 192 | lines.append("") |
| 193 | |
| 194 | # Current streaming text |
| 195 | lines.append(f" {Colors.BOLD}Streaming Text{Colors.RESET}") |
| 196 | if state.current_text: |
| 197 | # Show last few lines of streaming text |
no test coverage detected