From e664af63ef8db114f7fd81c898ef3f93edf87089 Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Sat, 22 Nov 2025 18:53:31 +0100 Subject: [PATCH] Move component health into main dashboard panel --- src/reactor_sim/dashboard.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/reactor_sim/dashboard.py b/src/reactor_sim/dashboard.py index d07a83c..de3b46b 100644 --- a/src/reactor_sim/dashboard.py +++ b/src/reactor_sim/dashboard.py @@ -325,7 +325,7 @@ class ReactorDashboard: ], ) y = self._draw_section(win, y, "Maintenance", self._maintenance_lines()) - self._draw_health_bar(win, y + 1) + y = self._draw_section(win, y, "Component Health", self._health_lines()) def _draw_help_panel(self, win: "curses._CursesWindow") -> None: win.erase() @@ -429,6 +429,15 @@ class ReactorDashboard: lines.append(("Alphas", f"{particles.get('alpha', 0.0):9.2e}")) return lines + def _health_lines(self) -> list[tuple[str, str]]: + comps = self.reactor.health_monitor.components + lines: list[tuple[str, str]] = [] + for name, comp in comps.items(): + pct = f"{comp.integrity*100:5.1f}%" + state = "FAILED" if comp.failed else pct + lines.append((name, state)) + return lines + def _maintenance_lines(self) -> list[tuple[str, str]]: if not self.reactor.maintenance_active: return [("Active", "None")] @@ -440,26 +449,6 @@ class ReactorDashboard: state = pumps[index] return f"{'ON ' if state.active else 'OFF'} {state.flow_rate:6.0f} kg/s" - def _draw_health_bar(self, win: "curses._CursesWindow", start_y: int) -> None: - height, width = win.getmaxyx() - if start_y >= height - 2: - return - win.addstr(start_y, 2, "Component Health", curses.A_BOLD | curses.color_pair(1)) - bar_width = max(10, min(width - 28, 40)) - for idx, (name, comp) in enumerate(self.reactor.health_monitor.components.items(), start=1): - filled = int(bar_width * comp.integrity) - bar = "█" * filled + "-" * (bar_width - filled) - color = 3 if comp.integrity > 0.5 else 2 if comp.integrity > 0.2 else 4 - row = start_y + idx - if row >= height - 1: - break - label = f"{name:<12}:" - win.addstr(row, 4, label[:14], curses.A_BOLD) - bar_start = 4 + max(len(label), 14) + 1 - win.addstr(row, bar_start, bar[:bar_width], curses.color_pair(color)) - percent_col = min(width - 8, bar_start + bar_width + 2) - win.addstr(row, percent_col, f"{comp.integrity*100:5.1f}%", curses.color_pair(color)) - def _current_demand(self) -> float: if self.reactor.consumer: return self.reactor.consumer.demand_mw