Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Terminal monitor: one seven-view model (arrows and 1-7 reach Connect, wrap, hints say 1-7), the selected tab always marked and the names kept at narrow widths, Overview titled Overview, Connect separates vendor-tested history from this server's live result, light theme for Connect and pop-ups (T06, T08, T10)
Niko1221545fccf00795
diff --git a/strata_cli/dashboard.py b/strata_cli/dashboard.pyindex 9b18e516b..eef030f18 100644--- a/strata_cli/dashboard.py+++ b/strata_cli/dashboard.py@@ -18,6 +18,7 @@ from rich.panel import Panelfrom rich.table import Tablefrom rich.text import Text+from strata_cli import navfrom strata_cli.client import complete_slotsfrom strata_cli.render import (_queue_wait, activity_continuity_notice, activity_label, display_width,field, group_occupancy, number, safe)@@ -742,7 +743,7 @@ def _device_role(index: int, topology: dict) -> str:def render_dashboard(snapshot: dict, *, width: int, height: int, history: MonitorHistory,connection: str = "", connection_state: str = "connected", frozen: bool = False,filter_text: str = "", glyphs: str = "ascii", color: bool = True,- theme: str = "dark") -> Group:+ theme: str = "dark", connect: bool = False) -> Group:"""Compose the primary one-screen monitor at standard terminal sizes.Smaller terminals retain the existing compact text renderer in MonitorApp.@@ -792,7 +793,7 @@ def render_dashboard(snapshot: dict, *, width: int, height: int, history: Monitotitle=Text("CONNECTION", style=f"bold {danger}" if blocked else f"bold {accent}"),border_style=danger_border if blocked else "dim", box=_rounded(),height=max(8, height - 4))- return Group(header, panel, Text("r Retry q Detach 1-6 Views", style="dim"))+ return Group(header, panel, Text(f"r Retry q Detach {nav.keys(connect)} Views", style="dim"))model_name = safe(model.get("id"), 80)if compact and display_width(model_name) > 19:@@ -881,10 +882,8 @@ def render_dashboard(snapshot: dict, *, width: int, height: int, history: Monitorequests = _request_lines(snapshot, compact, filter_text, tall=height >= 40)activity = _activity(snapshot, compact, filter_text)age = _age(snapshot)- footer = Text((f"1 Over 2 Serve 3 Reqs 4 Engine 5 GPU 6 Logs age {number(age, 's', 1)}"- if compact else- f"1 Overview 2 Serving 3 Requests 4 Engine 5 Hardware 6 Logs"- f" age {number(age, 's', 1)}"), style="dim")+ age_text = f"age {number(age, 's', 1)}"+ footer = Text(nav.plain(0, max(20, width - len(age_text) - 4), connect) + " " + age_text, style="dim")if width >= 126 and height >= 34:return _visual_overview(snapshot, history, width=width, height=height,header=header, footer=footer, live=live, glyphs=glyphs,diff --git a/strata_cli/detail_dashboard.py b/strata_cli/detail_dashboard.pyindex 97afb37fa..3f64b797e 100644--- a/strata_cli/detail_dashboard.py+++ b/strata_cli/detail_dashboard.py@@ -13,11 +13,12 @@ from rich.console import Groupfrom rich.panel import Panelfrom rich.text import Text+from strata_cli import navfrom strata_cli.client import complete_slotsfrom strata_cli.dashboard import (set_ascii_boxes, _rounded, _age, _current_batch_value, _current_sample,_device_role, _gib, _meter, _rate_spark, _spark,_state, _visual_pair, _visual_panel, MonitorHistory)-from strata_cli.render import (_device_stage, _queue_wait, _recent_detail,+from strata_cli.render import (VIEWS, _device_stage, _queue_wait, _recent_detail,_request_detail, _slot_detail, activity_continuity_notice,activity_label, activity_rows, field, number,request_rows, safe)@@ -547,7 +548,7 @@ def render_detail_dashboard(snapshot: dict, view: str, *, width: int, height: inconnection_state: str = "connected", frozen: bool = False,filter_text: str = "", glyphs: str = "ascii",color: bool = True, theme: str = "dark", selected: int = 0,- detail: bool = False, serving_pane: str = "devices") -> Group:+ detail: bool = False, serving_pane: str = "devices", connect: bool = False) -> Group:"""Render the five wide pages with the visual Overview's panel language."""set_ascii_boxes(glyphs == "ascii")palette = _palette(color, theme)@@ -561,8 +562,10 @@ def render_detail_dashboard(snapshot: dict, view: str, *, width: int, height: inheader = Panel(heading, box=_rounded(), border_style=active if color else "",padding=(0, 1))age = _age(snapshot)- footer = _txt("1 Overview 2 Serving 3 Requests 4 Engine 5 Hardware 6 Logs "- f"Tab pane ↑↓ select Enter detail / filter age {number(age, 's', 1)}", "dim")+ hints = f"Tab pane ↑↓ select Enter detail / filter age {number(age, 's', 1)}"+ footer = nav.styled(VIEWS.index(view), max(24, width - len(hints) - 5), connect, accent=palette["cyan"] if color else "", color=color)+ footer.append(" ")+ footer.append(hints, style="dim")top_h = 6 if height >= 40 else 5room = max(0, height - 4 - top_h)mid_h = room // 2 + (3 if view in ("serving", "requests", "logs") else 1)diff --git a/strata_cli/launch/monitor_ext.py b/strata_cli/launch/monitor_ext.pyindex 2239c0ace..85c311d72 100644--- a/strata_cli/launch/monitor_ext.py+++ b/strata_cli/launch/monitor_ext.py@@ -2,41 +2,57 @@Everything about the monitor itself (the views, colours, polling, key hints) is `strata_cli.monitor.MonitorApp`, unchanged.This subclass adds-* key 7: the Connect view (the address, the API key hint and copy-ready setup for each app, with `c` copy, `w` write the config for- you after a backup, `h` check that the app's settings reach a server that answers a prompt and a tool call correctly);+* the seventh view, Connect (key 7, and the arrow keys reach it like any other view: Overview ... Logs, Connect, then round to Overview): the+ address, the API key hint and copy-ready setup for each app, with `c` copy, `w` write the config for you after a backup, `h` check that the+ app's settings reach a server that answers a prompt and a tool call correctly;* q: asks whether to keep serving in the background or stop (stopping frees the graphics memory).++The list says two different things about each app and keeps them apart: what its maker's version was tested with ("Vendor tested", fixed+history), and whether THIS server answered the app's prompt and tool call just now ("This server": Not checked / Checking / Passed / Failed)."""from __future__ import annotations+import textwrapimport threadingfrom rich.text import Textfrom textual.binding import Bindingfrom textual.widgets import Static+from strata_cli import navfrom strata_cli.launch import check, harnessfrom strata_cli.launch.screens import ConfirmScreen-from strata_cli.launch.widgets import ACCENT, BAD, MUTE, WARN, Glyphs+from strata_cli.launch.widgets import DARK, LIGHT, Glyphsfrom strata_cli.monitor import MonitorApp-from strata_cli.render import VIEWS, safe+CONNECT = 6 # the index of the Connect view (the seventh)+++def connect_palette(theme: str, color: bool):+ """The colours of the Connect view for the monitor's theme: dark, light (readable on white), or the terminal's own (no colours set)."""+ if not color or theme == "terminal":+ return None+ return LIGHT if theme == "light" else DARK-class LaunchMonitor(MonitorApp):- BINDINGS = MonitorApp.BINDINGS + [Binding("7", "connect", "Connect view", show=False)]+class LaunchMonitor(MonitorApp):def __init__(self, endpoint, snapshot, *, info: dict, ask_quit: bool = True, **kw) -> None:super().__init__(endpoint, snapshot, **kw)self.info = infoself.ask_quit = ask_quit # False: plain `strata monitor` (q detaches, nothing to stop)self.connect_enabled = True- self.connect_open = Falseself.connect_index = 0self.show_key = Falseself.check_results: dict[str, list[check.Check] | str] = {}self.glyphs = Glyphs()self.stop_requested = Falseself.notice = ""+ self.view_before_connect = 0++ @property+ def connect_open(self) -> bool:+ return self.view == CONNECT# ---- quit asksdef action_quit(self) -> None:@@ -59,17 +75,19 @@ class LaunchMonitor(MonitorApp):[("keep", "Keep serving in the background"), ("stop", "Stop serving and free the memory"),("cancel", "Stay in the monitor")]), done)- # ---- the Connect view+ # ---- the Connect view is the seventh viewdef _harness(self) -> harness.Harness:return harness.HARNESSES[self.connect_index % len(harness.HARNESSES)]def action_connect(self) -> None:- self.connect_open = not self.connect_open- self.notice = ""- self._paint()+ self._set_view(CONNECT)def _set_view(self, index: int) -> None:- self.connect_open = False+ if index != CONNECT and self.view == CONNECT:+ self.notice = ""+ if index == CONNECT and self.view != CONNECT:+ self.view_before_connect = self.view+ self.notice = ""super()._set_view(index)def action_next_row(self) -> None:@@ -90,8 +108,7 @@ class LaunchMonitor(MonitorApp):def action_filter_clear(self) -> None:if self.connect_open:- self.connect_open = False- self._paint()+ self._set_view(self.view_before_connect) # Esc leaves the Connect view for the one you came fromelse:super().action_filter_clear()@@ -99,12 +116,6 @@ class LaunchMonitor(MonitorApp):if not self.connect_open:super().action_request_detail()- def action_next_view(self) -> None:- if self.connect_open:- self.connect_open = False- self._paint()- super().action_next_view()-def on_key(self, event) -> None:if not self.connect_open:return@@ -188,70 +199,118 @@ class LaunchMonitor(MonitorApp):# ---- paintingdef _paint(self, size=None) -> None:- if not getattr(self, "connect_open", False):+ if not self.connect_open:super()._paint(size)if self.ask_quit and not self.error and not self.selection_notice and self.connection_state == "connected" and not self.frozen:try:- self.query_one("#message", Static).update("Read only | q asks: keep serving or stop | 7 connect an app")+ msg = "Read only | q asks: keep serving or stop | 7 connect an app"+ if (size or self.screen.size).width < 78:+ msg = "q asks: keep serving or stop | 7 connect"+ self.query_one("#message", Static).update(msg)except Exception: # noqa: BLE001passreturnsize = self.screen.size if size is None else size- width = max(40, size.width - 2)- self.query_one("#content", Static).update(self.connect_text(width))- idle = "c copy w write it for me (keeps a backup) h check it 1-7 views q quit (asks: keep serving / stop)"+ width = max(30, size.width - 2)+ self.query_one("#content", Static).update(self.connect_text(width, size.height - 2))+ pal = connect_palette(self.theme_choice, self.color_choice != "never")+ idle = ("c copy w write it for me (keeps a backup) h check it k key Esc back " if width >= 100 else "c copy w write h check Esc back ") + \+ f"{nav.keys(True)} views q quit"msg = self.notice or idle- self.query_one("#message", Static).update(Text(msg, style=WARN if msg.startswith("!") else ""))+ mute = pal.mute if pal else ""+ self.query_one("#message", Static).update(Text(msg, style=(pal.warn if pal else "") if msg.startswith("!") else mute, no_wrap=False))+ self.query_one("#message", Static).styles.height = 2 if len(msg) > width else 1++ # ---- what each app's row says+ @staticmethod+ def vendor_tested(h: harness.Harness) -> str:+ """What the app's maker's version was tested with (fixed history, nothing to do with this server)."""+ return "built into Strata" if h.built_in else (h.tested or "not tested")++ def server_state(self, h: harness.Harness) -> tuple[str, str]:+ """(words, kind) for THIS server and this app: Not checked / Checking / Passed (n/n) / Failed (n/n); kind is none | run | ok | bad."""+ res = self.check_results.get(h.id)+ if res == "running":+ return "Checking...", "run"+ if isinstance(res, list) and res:+ okn = sum(1 for c in res if c.ok)+ return (f"Passed ({okn}/{len(res)})", "ok") if okn == len(res) else (f"Failed ({okn}/{len(res)})", "bad")+ return "Not checked", "none"+- def connect_text(self, width: int) -> Text:+ @staticmethod+ def fit(text: str, width: int) -> str:+ """One line, cut with an ellipsis instead of wrapping onto the next row."""+ return text if len(text) <= width else text[:max(1, width - 1)] + "…"++ def connect_text(self, width: int, height: int | None = None) -> Text:g = self.glyphs+ height = max(8, height if height is not None else self.screen.size.height)+ compact = height < 24 or width < 70+ pal = connect_palette(self.theme_choice, self.color_choice != "never")+ accent = pal.accent if pal else ""+ mute = pal.mute if pal else "dim"+ warn_style = pal.warn if pal else "bold"+ bad_style = pal.bad if pal else "bold"+ sel_bg = f" on {pal.sel}" if pal else " reverse"+ bold_accent = f"bold {accent}".strip()state = {"connected": "[LIVE]", "stale": "[STALE]", "connecting": "[CONNECTING]", "disconnected": "[DISCONNECTED]","auth_required": "[AUTH REQUIRED]"}.get(self.connection_state, "[LIVE]")t = Text(no_wrap=True, overflow="crop")head = f"STRATA Connect {self.info['url']}"- t.append(head, style=f"bold {ACCENT}")- t.append(" " * max(2, width - len(head) - len(state)) + state + "\n", style=f"bold {ACCENT}")- nav = []- for i, name in enumerate(VIEWS):- nav.append(f"{i + 1} {name.title()}")- nav.append("[7 Connect]")- t.append(" ".join(nav) + "\n")- t.append(g.rule * min(width, 100) + "\n", style=MUTE)+ if len(head) + len(state) + 2 <= width:+ t.append(head, style=bold_accent)+ t.append(" " * max(2, width - len(head) - len(state)) + state + "\n", style=bold_accent)+ else:+ t.append(self.fit(head, width) + "\n", style=bold_accent)+ t.append_text(nav.styled(CONNECT, width, True, accent=accent, color=pal is not None))+ t.append("\n")+ t.append(g.rule * min(width, 100) + "\n", style=mute)key = self.info.get("key") or ""shown = key if self.show_key else (key[:10] + g.mask * 4 if key else "off")- t.append("Connect an app", style=f"bold {ACCENT}")- t.append(f" URL {self.info['url']}/v1 model {self.info.get('model') or 'strata'} key {shown} ")- t.append("(k hide)" if self.show_key else "(k show)", style=MUTE)- t.append("\n")- t.append(f" Claude Code and other Anthropic apps use {self.info['url']} (no /v1)\n", style=MUTE)- for u in self.info.get("urls", [])[1:]:- t.append(f" also reachable at {u}/v1\n", style=MUTE)- t.append("\n " + "App".ljust(20) + "Works with".ljust(22) + "Status\n", style="bold")+ if compact:+ t.append(self.fit(f"Connect an app {self.info['url']}/v1 key {shown} (k {'hide' if self.show_key else 'show'})", width) + "\n", style=bold_accent)+ else:+ t.append("Connect an app", style=bold_accent)+ line = f" URL {self.info['url']}/v1 model {self.info.get('model') or 'strata'} key {shown} "+ if len(line) > width - 9: # too long for the line: the model name goes, the address and the key stay+ line = f" URL {self.info['url']}/v1 key {shown} "+ t.append(self.fit(line, width - 9))+ t.append("(k hide)" if self.show_key else "(k show)", style=mute)+ t.append("\n")+ t.append(self.fit(f" Claude Code and other Anthropic apps use {self.info['url']} (no /v1)", width) + "\n", style=mute)+ for u in self.info.get("urls", [])[1:]:+ t.append(self.fit(f" also reachable at {u}/v1", width) + "\n", style=mute)+ # columns by width: App | Works with | Vendor tested | This server (the narrow ones drop "Works with", then "Vendor tested")+ show_speaks, show_tested = width >= 80, width >= 57+ cols = [("App", 17)] + ([("Works with", 18)] if show_speaks else []) + ([("Vendor tested", 24)] if show_tested else []) + [("This server", 0)]+ t.append(("" if compact else "\n") + " " + "".join(name.ljust(w) if w else name for name, w in cols) + "\n", style="bold")for i, h in enumerate(harness.HARNESSES):sel = i == self.connect_index % len(harness.HARNESSES)- res = self.check_results.get(h.id)- status = ("tested " + g.tick) if h.tested else "not tested yet"- style = ""- if res == "running":- status, style = "checking…", WARN- elif isinstance(res, list):- okn = sum(1 for c in res if c.ok)- status, style = (f"works {g.tick} ({okn}/{len(res)} checks)" if okn == len(res) else f"problem ({okn}/{len(res)} checks)"), \- (ACCENT if okn == len(res) else BAD)- row = (" " + (g.cursor + " " if sel else " ")) + h.title.ljust(20) + h.speaks.ljust(22) + status- t.append(row.ljust(width - 1) + "\n", style=(f"bold {ACCENT} on #1f2a27" if sel else style))+ words, kind = self.server_state(h)+ style = {"run": warn_style, "ok": accent, "bad": bad_style, "none": ""}[kind]+ cells = [h.title[:16]] + ([h.speaks] if show_speaks else []) + ([self.vendor_tested(h)[:23]] if show_tested else [])+ row = " " + (g.cursor + " " if sel else " ")+ for cell, (_n, w) in zip(cells, cols):+ row += cell.ljust(w)+ row += words+ t.append(self.fit(row, width - 1).ljust(width - 1) + "\n", style=(f"{bold_accent}{sel_bg}".strip() if sel else style))+ if not compact:+ note = ("Vendor tested = the app version its maker tested this setup with. This server = whether YOUR server answered the app's "+ "prompt and tool call (press h)." if width >= 100 else+ "Vendor tested: a past test of the app version. This server: press h to check yours.")+ t.append(self.fit(note, width) + "\n", style=mute)h = self._harness()out = self._rendered()- key = self.info.get("key") or ""- height = max(12, self.screen.size.height)- used = t.plain.count("\n") + 2- room = max(3, height - used - 3)+ used = t.plain.count("\n") + 1+ room = height - used - 3+ if room < 5: # no room for the app's setup text: the list and the keys are what matter here+ return tt.append("\n")paths = ", ".join(f["path"] for f in out["files"]) or ("built into the Strata app" if h.built_in else "")- t.append(f"{h.title} setup", style=f"bold {ACCENT}")- t.append(f" {paths}\n", style=MUTE)+ t.append(f"{h.title} setup", style=bold_accent)+ t.append(self.fit(f" {paths}", width - len(h.title) - 6) + "\n", style=mute)room -= 2- import textwraplimit_lines: list[str] = []for n in out["limits"]:wrapped = textwrap.wrap(n, max(30, width - 6)) or [n]@@ -266,15 +325,15 @@ class LaunchMonitor(MonitorApp):res_lines = ([f" {g.tick if c.ok else 'x'} {c.name}: {c.detail}" for c in res] if isinstance(res, list) else [])want_code = min(len(code), max(3, room - min(len(limit_lines), 6) - len(res_lines) - 1))for ln in code[:want_code]:- t.append(ln + "\n")+ t.append(self.fit(ln, width) + "\n")if len(code) > want_code:- t.append(f" ... {len(code) - want_code} more lines (c copies all)\n", style=MUTE)+ t.append(f" ... {len(code) - want_code} more lines (c copies all)\n", style=mute)left = max(0, room - want_code - (1 if len(code) > want_code else 0) - len(res_lines))if limit_lines:- t.append("Good to know\n", style=f"bold {ACCENT}")+ t.append("Good to know\n", style=bold_accent)for ln in limit_lines[:max(2, left)]:- t.append(ln + "\n", style=WARN if ln.lstrip().startswith("- WARNING") else MUTE)+ t.append(self.fit(ln, width) + "\n", style=warn_style if ln.lstrip().startswith("- WARNING") else mute)if isinstance(res, list):for c, ln in zip(res, res_lines):- t.append(ln + "\n", style=ACCENT if c.ok else BAD)+ t.append(self.fit(ln, width) + "\n", style=accent if c.ok else bad_style)return tdiff --git a/strata_cli/launch/screens.py b/strata_cli/launch/screens.pyindex 96dbf475b..7670bad68 100644--- a/strata_cli/launch/screens.py+++ b/strata_cli/launch/screens.py@@ -24,7 +24,7 @@ from strata_cli.launch import access as accfrom strata_cli.launch import params as Pfrom strata_cli.launch import settings as Sfrom strata_cli.launch import store-from strata_cli.launch.widgets import (ACCENT, BAD, FG, MUTE, WARN, Cell, Item, Menu, bar)+from strata_cli.launch.widgets import (ACCENT, BAD, DARK, FG, LIGHT, MUTE, WARN, Cell, Item, Menu, bar)STEPS = (("model", "Model"), ("cards", "Cards"), ("folder", "Folder"), ("context", "Context"), ("pictures", "Pictures"),("parallel", "Parallel"), ("tuning", "Tuning"), ("advanced", "Advanced"), ("access", "Access"), ("save", "Save"))@@ -319,7 +319,7 @@ class ConfirmScreen(ModalScreen):Binding("enter", "pick", show=False), Binding("escape", "cancel", show=False)]DEFAULT_CSS = f"""ConfirmScreen {{ align: center middle; background: #0e1113 80%; }}- #dialog {{ width: 70; height: auto; background: #161a1d; border: solid {ACCENT}; padding: 1 2; }}+ #dialog {{ width: 70; max-width: 100%; height: auto; max-height: 100%; background: #161a1d; border: solid {ACCENT}; padding: 1 2; }}"""def __init__(self, question: str, detail: str, options: list[tuple[str, str]]):@@ -327,16 +327,25 @@ class ConfirmScreen(ModalScreen):self.question, self.detail, self.options = question, detail, optionsdef compose(self) -> ComposeResult:+ pal = LIGHT if self.app.has_class("theme-light") else DARK # the monitor's light theme reaches its pop-upswith Vertical(id="dialog"):- yield Static(Text(self.question, style=f"bold {ACCENT}"), markup=False)- yield Static(Text(self.detail, style=MUTE), markup=False)+ yield Static(Text(self.question, style=f"bold {pal.accent}"), markup=False)+ yield Static(Text(self.detail, style=pal.mute), markup=False)yield Static("", markup=False)- yield Menu(id="confirm-menu")- yield Static(Text("Up/Down choose Enter confirm Esc cancel", style=MUTE), markup=False)+ yield Menu(id="confirm-menu", palette=pal)+ yield Static(Text("Up/Down choose Enter confirm Esc cancel", style=pal.mute), markup=False)def on_mount(self) -> None:m = self.query_one(Menu)m.set_items([Item([label], key=key) for key, label in self.options], 0)+ if self.app.has_class("theme-light"): # the monitor's light theme: a white dialog with dark text (the dark one is the default)+ dialog = self.query_one("#dialog")+ dialog.styles.background = LIGHT.panel+ dialog.styles.border = ("solid", LIGHT.accent)+ dialog.styles.color = LIGHT.fg+ self.styles.background = "#f9fafb 70%"+ for static in dialog.query(Static):+ static.styles.background = LIGHT.paneldef action_move(self, step: int) -> None:self.query_one(Menu).move(step)diff --git a/strata_cli/launch/widgets.py b/strata_cli/launch/widgets.pyindex 6efd80b59..63cfda07a 100644--- a/strata_cli/launch/widgets.py+++ b/strata_cli/launch/widgets.py@@ -20,6 +20,26 @@ BG, PANEL, FG, MUTE = "#0e1113", "#161a1d", "#eef1f3", "#8e979f"ACCENT, WARN, BAD, SEL, RULE = "#34d399", "#f5c56b", "#f28b82", "#1f2a27", "#3a4146"+@dataclass(frozen=True)+class Palette:+ """The colours of one theme. The launch screens are dark; the monitor's Connect view and its pop-ups follow the monitor's light theme."""++ bg: str+ panel: str+ fg: str+ mute: str+ accent: str+ warn: str+ bad: str+ sel: str+ rule: str+++DARK = Palette(BG, PANEL, FG, MUTE, ACCENT, WARN, BAD, SEL, RULE)+# Light: every text colour reads at 4.5:1 or better on the white panel (tests/terminal/test_tuiqa_monitor.py computes it).+LIGHT = Palette("#f9fafb", "#ffffff", "#221e1f", "#5b5f66", "#0a6b4a", "#8a5a00", "#b01a2e", "#cfeadf", "#c9ced3")++def unicode_ok() -> bool:if os.environ.get("TERM") == "dumb":return False@@ -92,8 +112,9 @@ class Menu(Static):DEFAULT_CSS = "Menu { height: auto; text-wrap: nowrap; text-overflow: clip; }"def __init__(self, columns: list[tuple[str, int]] | None = None, *, glyphs: Glyphs | None = None, id: str | None = None,- window: int = 0) -> None:+ window: int = 0, palette: Palette | None = None) -> None:super().__init__("", id=id, markup=False)+ self.palette = palette or DARKself.columns = columns or []self.items: list[Item] = []self.index = 0@@ -158,28 +179,28 @@ class Menu(Static):for n, it in enumerate(rows):selected = (self.top + n) == self.indexline = Text(no_wrap=True, overflow="crop")- line.append((self.g.cursor + " ") if selected else pad, style=f"bold {ACCENT}" if selected else "")+ line.append((self.g.cursor + " ") if selected else pad, style=f"bold {self.palette.accent}" if selected else "")for k, c in enumerate(it.cells):c = cell(c)w = widths[k] if k < len(widths) else 0txt = c.text.ljust(w) if w else c.textstyle = c.style if not selected else (c.style if c.style and not selected else "")if selected:- style = f"bold {ACCENT}" if c.style in ("", None) else c.style+ style = f"bold {self.palette.accent}" if c.style in ("", None) else c.styleelif not c.style and it.style:style = it.styleif not it.enabled and not selected:- style = MUTE+ style = self.palette.muteline.append(txt, style=style)if selected:- line.stylize(f"on {SEL}")+ line.stylize(f"on {self.palette.sel}")line.pad_right(max(0, (self.size.width or 100) - len(line.plain)))- line.stylize(f"on {SEL}")+ line.stylize(f"on {self.palette.sel}")out.append_text(line)if n < len(rows) - 1:out.append("\n")if self.window and len(self.items) > win:- out.append(f"\n {self.top + 1}-{min(len(self.items), self.top + win)} of {len(self.items)}", style=MUTE)+ out.append(f"\n {self.top + 1}-{min(len(self.items), self.top + win)} of {len(self.items)}", style=self.palette.mute)return outdef on_resize(self, _event) -> None:diff --git a/strata_cli/monitor.py b/strata_cli/monitor.pyindex a6c32f46d..f3cd372a1 100644--- a/strata_cli/monitor.py+++ b/strata_cli/monitor.py@@ -15,6 +15,7 @@ from textual.binding import Bindingfrom textual.containers import Verticalfrom textual.widgets import Input, Static+from strata_cli import navfrom strata_cli.client import ClientError, Endpointfrom strata_cli.dashboard import MonitorHistory, render_dashboardfrom strata_cli.detail_dashboard import render_detail_dashboard@@ -101,6 +102,7 @@ class MonitorApp(App):Binding("enter", "request_detail", "Row detail", show=False),Binding("question_mark", "help", "Help"), Binding("f1", "help", "Help", show=False),Binding("b", "browser", "Open in browser", show=False),+ Binding("7", "view_6", "Connect view", show=False),]def __init__(self, endpoint: Endpoint, snapshot: dict | None, *, interval: float = 1.0,@@ -170,6 +172,7 @@ class MonitorApp(App):}[self.theme_choice]if self.color_choice == "never":bg, panel, fg, mute = "transparent", "transparent", "ansi_default", "ansi_default"+ self.set_class(self.theme_choice == "light" and self.color_choice != "never", "theme-light") # pop-ups and the Connect view follow itself.screen.styles.background = bgself.query_one("#shell").styles.background = panelself.query_one("#content").styles.color = fg@@ -180,8 +183,14 @@ class MonitorApp(App):"""The glyph set of the text views (2-6): the Overview's solid look is not theirs, they keep the plain ASCII fallback."""return "ascii" if self.glyph_choice == "solid" else self.glyph_choice+ def _view_count(self) -> int:+ """Six views, and a seventh (Connect) when `strata launch` opened the monitor: arrows, number keys and the tab line all use this."""+ return nav.count(self.connect_enabled)+def _paint(self, size=None) -> None:size = self.screen.size if size is None else size+ if self.view >= len(VIEWS): # the Connect view belongs to the launch-aware monitor (strata_cli/launch/monitor_ext.py)+ returnsnapshot = {**self.displayed, "recent": (self.displayed.get("recent") or [])[:self.requests]}snapshot["activity_continuity"] = self.displayed_activity_continuitysnapshot["work"] = {**(self.displayed.get("work") or {}),@@ -200,7 +209,7 @@ class MonitorApp(App):history=self.history, connection=getattr(self.endpoint, "base_url", getattr(self.endpoint, "root", "")),connection_state=self.connection_state, frozen=self.frozen,filter_text=self.filter_text, glyphs=self.text_glyphs,- color=self.color_choice != "never", theme=self.theme_choice)+ color=self.color_choice != "never", theme=self.theme_choice, connect=self.connect_enabled)elif self.view != 0 and size.width >= 128 and size.height >= 36 and self.connection_state not in ("connecting", "disconnected", "auth_required", "incompatible"):display = render_detail_dashboard(@@ -210,7 +219,7 @@ class MonitorApp(App):connection_state=self.connection_state, frozen=self.frozen,filter_text=self.filter_text, glyphs=self.text_glyphs,color=self.color_choice != "never", theme=self.theme_choice,- selected=self.selected, detail=self.detail, serving_pane=self.serving_pane)+ selected=self.selected, detail=self.detail, serving_pane=self.serving_pane, connect=self.connect_enabled)else:content = render_view(snapshot, VIEWS[self.view],width=max(30, size.width - self.margin), height=max(8, size.height - 2),@@ -218,7 +227,7 @@ class MonitorApp(App):filter_text=self.filter_text, glyphs=self.text_glyphs,connection=getattr(self.endpoint, "base_url", getattr(self.endpoint, "root", "")),serving_pane=self.serving_pane,- detail=self.detail, connection_state=self.connection_state)+ detail=self.detail, connection_state=self.connection_state, connect=self.connect_enabled)display = Text(content, no_wrap=True, overflow="crop")if self.color_choice != "never":accent = "#0c8a60" if self.theme_choice == "light" else "#34d399"@@ -228,7 +237,7 @@ class MonitorApp(App):stripped = line.strip()if stripped.startswith("STRATA") or stripped.startswith(("REQUEST FLOW", "GPU SENSORS", "Hardware", "Recent requests", "Slots / groups", "Occupied slots by group")):display.stylize(f"bold {accent}", offset, offset + len(line.rstrip("\n")))- elif stripped.startswith(("---", "Sample age", "1-6 views", "Read only")):+ elif stripped.startswith(("---", "Sample age", "1-6 views", "1-7 views", "Read only")):display.stylize(muted, offset, offset + len(line.rstrip("\n")))offset += len(line)display.highlight_regex(r"\[LIVE\]|\[\d [^\]]+\]", f"bold {accent}")@@ -444,10 +453,10 @@ class MonitorApp(App):self._move_row(len(self._selectable_rows()))def action_previous_view(self) -> None:- self._set_view((self.view - 1) % len(VIEWS))+ self._set_view((self.view - 1) % self._view_count())def action_next_view(self) -> None:- self._set_view((self.view + 1) % len(VIEWS))+ self._set_view((self.view + 1) % self._view_count())def _move_row(self, amount: int) -> None:rows = self._selectable_rows()@@ -457,7 +466,7 @@ class MonitorApp(App):self._paint()def action_help(self) -> None:- self.error = "1-6/Left/Right views Tab pane Up/Down/PgUp/PgDn/Home/End rows Enter detail Space freeze r refresh t theme q detach"+ self.error = f"{nav.keys(self.connect_enabled)}/Left/Right views Tab pane Up/Down/PgUp/PgDn/Home/End rows Enter detail Space freeze r refresh t theme q detach"self._paint()def action_request_detail(self) -> None:@@ -545,3 +554,7 @@ class MonitorApp(App):def action_view_5(self) -> None:self._set_view(5)++ def action_view_6(self) -> None:+ if self.connect_enabled:+ self._set_view(6)diff --git a/strata_cli/nav.py b/strata_cli/nav.pynew file mode 100644index 000000000..cf6b590f2--- /dev/null+++ b/strata_cli/nav.py@@ -0,0 +1,90 @@+"""The monitor's view tabs: ONE model for every view and every width.++There are six views (Overview, Serving, Requests, Engine, Hardware, Logs) and, when `strata launch` opened the monitor, a seventh, Connect.+Every screen draws the same tab line from here, so the selected tab is always marked (in square brackets, and in colour when there is+colour), the hints say 1-6 or 1-7 to match, and a narrow terminal keeps the tab names: shorter names first, then only the tabs around the+selected one with < and > for the ones out of sight.+"""++from __future__ import annotations++from dataclasses import dataclass++from rich.text import Text++NAMES = ("Overview", "Serving", "Requests", "Engine", "Hardware", "Logs", "Connect")+SHORT = ("Over", "Serve", "Reqs", "Engine", "GPU", "Logs", "Conn")+++def count(connect: bool) -> int:+ return 7 if connect else 6+++def keys(connect: bool) -> str:+ """The number keys that switch views: "1-6", or "1-7" with the Connect view."""+ return "1-7" if connect else "1-6"+++def title(index: int) -> str:+ return NAMES[max(0, min(index, len(NAMES) - 1))]+++@dataclass+class Tabs:+ pieces: list[tuple[str, bool]] # (text, selected)+ sep: str+ left: bool = False # tabs hidden on the left+ right: bool = False # tabs hidden on the right++ def width(self) -> int:+ return (2 if self.left else 0) + (2 if self.right else 0) + sum(len(t) for t, _ in self.pieces) + len(self.sep) * max(0, len(self.pieces) - 1)+++def _items(labels: tuple[str, ...], current: int, n: int) -> list[str]:+ return [f"[{i + 1} {labels[i]}]" if i == current else f"{i + 1} {labels[i]}" for i in range(n)]+++def layout(current: int, width: int, connect: bool = False) -> Tabs:+ """The tabs for a line `width` columns wide: all names, else short names, else only the tabs around the selected one."""+ n = count(connect)+ current = max(0, min(current, n - 1))+ for labels, sep in ((NAMES, " "), (SHORT, " ")):+ tabs = Tabs([(t, i == current) for i, t in enumerate(_items(labels, current, n))], sep)+ if tabs.width() <= width:+ return tabs+ items = _items(SHORT, current, n)+ lo = hi = current+ while True:+ grew = False+ for nxt, is_hi in ((hi + 1, True), (lo - 1, False)):+ if not 0 <= nxt < n:+ continue+ new_lo, new_hi = (lo, nxt) if is_hi else (nxt, hi)+ trial = Tabs([(items[i], i == current) for i in range(new_lo, new_hi + 1)], " ", new_lo > 0, new_hi < n - 1)+ if trial.width() <= width:+ lo, hi, grew = new_lo, new_hi, True+ if not grew:+ break+ return Tabs([(items[i], i == current) for i in range(lo, hi + 1)], " ", lo > 0, hi < n - 1)+++def plain(current: int, width: int, connect: bool = False) -> str:+ """The tab line as plain text, at most `width` columns."""+ tabs = layout(current, width, connect)+ line = ("< " if tabs.left else "") + tabs.sep.join(t for t, _ in tabs.pieces) + (" >" if tabs.right else "")+ return line[:max(1, width)]+++def styled(current: int, width: int, connect: bool = False, *, accent: str = "", color: bool = True) -> Text:+ """The same line as rich Text: the selected tab in bold and the accent colour (just bold, in brackets, without colour)."""+ tabs = layout(current, width, connect)+ out = Text(no_wrap=True, overflow="crop")+ if tabs.left:+ out.append("< ", style="dim")+ for i, (text, selected) in enumerate(tabs.pieces):+ if i:+ out.append(tabs.sep)+ out.append(text, style=(f"bold {accent}" if color and accent else "bold") if selected else "")+ if tabs.right:+ out.append(" >", style="dim")+ return outdiff --git a/strata_cli/overview.py b/strata_cli/overview.pyindex 12bb689aa..d9dabfa35 100644--- a/strata_cli/overview.py+++ b/strata_cli/overview.py@@ -21,6 +21,8 @@ from rich.panel import Panelfrom rich.table import Tablefrom rich.text import Text+from strata_cli import nav+GIB = 2 ** 30BLUE = "#5aa9ff"AMBER = "#f5c56b"@@ -323,7 +325,7 @@ def render(model: dict, *, width: int, height: int, connection: str, connection_# ---- heading, tabs, rulehead = Text(no_wrap=True, overflow="crop")- head.append("STRATA Serving ", style=f"bold {accent}")+ head.append(f"STRATA {view_label} ", style=f"bold {accent}")head.append(connection + " ", style=f"bold {accent}")label = f"{model.get('model') or ''} {k(ctx_max) if ctx_max else ''}".strip()head.append(label, style="bold")@@ -335,10 +337,7 @@ def render(model: dict, *, width: int, height: int, connection: str, connection_pad = max(2, width - len(head.plain) - len(right.plain))head.append(" " * pad)head.append_text(right)- names = ["Overview", "Serving", "Requests", "Engine", "Hardware", "Logs"] + (["Connect"] if connect else [])- tabs = Text(no_wrap=True, overflow="crop")- for i, n in enumerate(names):- tabs.append((f"[{i + 1} {n}]" if i == 0 else f"{i + 1} {n}") + " ", style=f"bold {accent}" if i == 0 else "")+ tabs = nav.styled(0, min(width, 110), connect, accent=accent, color=color)rule = Text(("-" if ascii_mode else "─") * min(width, 110), style="dim")# ---- model state bar@@ -439,7 +438,7 @@ def render(model: dict, *, width: int, height: int, connection: str, connection_right = Group(Text("Recent requests", style=f"bold {accent}"), req)bottom.add_row(Group(*lines), right)- hint = Text(("1-7 views" if connect else "1-6 views") + " / filter Space freeze r refresh t theme b open in browser ? help q quit", style="dim")+ hint = Text(f"{nav.keys(connect)} views" + " / filter Space freeze r refresh t theme b open in browser ? help q quit", style="dim")parts: list[Any] = [head, tabs, rule, st, state_bar, Text(""), row(tiles1), row(tiles2)]if ncards:parts += [Text(""), _cards_strip(cards, glyphs, accent, ascii_mode)]diff --git a/strata_cli/render.py b/strata_cli/render.pyindex b81df7ae9..00934da40 100644--- a/strata_cli/render.py+++ b/strata_cli/render.py@@ -7,6 +7,7 @@ import timeimport unicodedatafrom typing import Any+from strata_cli import navfrom strata_cli.client import complete_slots@@ -332,7 +333,7 @@ def _row_window(rows: list[dict], selected: int, capacity: int) -> tuple[int, indef _wide_serving(lines: list[str], snapshot: dict, width: int, height: int,- filter_text: str, selected: int) -> str:+ filter_text: str, selected: int, connect: bool = False) -> str:work, rates = snapshot.get("work") or {}, snapshot.get("rates") or {}topology, devices = snapshot.get("topology") or {}, snapshot.get("devices") or []recent = snapshot.get("recent") or []@@ -400,15 +401,15 @@ def _wide_serving(lines: list[str], snapshot: dict, width: int, height: int,lines += ["Stage/layer mapping unavailable; groups are not GPU assignments"]age = time.time() - snapshot["sampled_at"] if isinstance(snapshot.get("sampled_at"), (int, float)) else Nonelines += ["", f"Sample age {number(age, ' s', 1)} | Source {safe(snapshot.get('source'))}",- "1-6 views / filter Space freeze r refresh t theme ? help q quit"]+ f"{nav.keys(connect)} views / filter Space freeze r refresh t theme ? help q quit"]return "\n".join(_line(x, width) for x in lines[:height])def render_view(snapshot: dict, view: str, width: int = 80, height: int = 24,selected: int = 0, frozen: bool = False, filter_text: str = "",glyphs: str = "ascii", connection: str = "", serving_pane: str = "devices",- detail: bool = False, connection_state: str | None = None) -> str:- """Render the six views with explicit unavailable markers and no fake rates."""+ detail: bool = False, connection_state: str | None = None, connect: bool = False) -> str:+ """Render the six views (seven with Connect, when `strata launch` opened the monitor) with explicit unavailable markers and no fake rates."""width, height = max(width, 30), max(height, 8)tiny = width < 60 or height < 14view = view if view in VIEWS else "overview"@@ -449,17 +450,12 @@ def render_view(snapshot: dict, view: str, width: int = 80, height: int = 24,else:marker = f"[{labels[state]}]"lines = [f"STRATA {view.title():<10} {safe(connection, max(0, width - 42))} {marker}"]- if width >= 60 and height >= 16:- if width < 80:- labels = ("Over", "Serve", "Reqs", "Engine", "GPU", "Logs")- nav = " ".join(f"[{i + 1}]{label}" if VIEWS[i] == view else f"{i + 1}{label}"- for i, label in enumerate(labels)) + " q quit"- else:- nav = " ".join(f"[{i + 1} {name.title()}]" if name == view else f"{i + 1} {name.title()}"- for i, name in enumerate(VIEWS))- lines += [_line(nav, width), "-" * min(width, 100)]+ if tiny: # a small window: the tabs (names kept, the selected one marked) and, under them, the keys that matter+ lines += [nav.plain(VIEWS.index(view), width, connect), f"{nav.keys(connect)} views q quit ? help"[:width]]else:- lines += [f"1-6 views q quit ? help", "-" * min(width, 100)]+ quit_hint = " q quit"+ tab_line = nav.plain(VIEWS.index(view), width - len(quit_hint), connect) if width < 80 else nav.plain(VIEWS.index(view), width, connect)+ lines += [tab_line + (quit_hint if width < 80 else ""), "-" * min(width, 100)]if connection_state in ("connecting", "disconnected", "auth_required", "incompatible"):title, message, action = {"connecting": ("CONNECTING", "Waiting for the first telemetry snapshot.",@@ -570,7 +566,7 @@ def render_view(snapshot: dict, view: str, width: int = 80, height: int = 24,lines += [f"Model {safe(model.get('id'), max(10, width-30))} {model_state}",f"In flight {number(work.get('active'))} Slots occupied {number(work.get('occupied_slots'))}/{number(work.get('slots_effective'))} Engine waiting {number(work.get('waiting'))} Pre-admit {number(work.get('queued'))}"]if view == "serving" and width >= 100 and height >= 24 and serving_pane == "devices" and not detail:- return _wide_serving(lines, snapshot, width, height, filter_text, selected)+ return _wide_serving(lines, snapshot, width, height, filter_text, selected, connect)if view == "overview":lines += [f"Answer speed {number(rates.get('answer_tok_s'), ' tok/s', 1)} [engine, {number(rates.get('answer_window_s'), ' s', 1)} window]",f"Prompt reading {number(rates.get('prefill_tok_s'), ' tok/s', 1)} [reported mean]",@@ -736,5 +732,5 @@ def render_view(snapshot: dict, view: str, width: int = 80, height: int = 24,if not detail:lines.append("")lines += [f"Sample age {number(age, ' s', 1)} Source {safe(snapshot.get('source'))}",- "1-6 views / filter Space freeze r refresh t theme ? help q quit"]+ f"{nav.keys(connect)} views / filter Space freeze r refresh t theme ? help q quit"]return "\n".join(_line(x, width) for x in lines[:height])diff --git a/tests/terminal/test_launch_monitor.py b/tests/terminal/test_launch_monitor.pyindex 97dcb1c8e..6fa802db1 100644--- a/tests/terminal/test_launch_monitor.py+++ b/tests/terminal/test_launch_monitor.py@@ -47,7 +47,10 @@ class Connect(unittest.TestCase):self.assertNotIn("abcdefghijklmnop", t) # masked until kfor name in ("OpenCode", "Codex CLI", "Claude Code", "oh-my-pi", "pi (pi.dev)", "Hermes Agent", "OpenClaw", "DeepSeek Harness"):self.assertIn(name, t)- self.assertIn("tested", t)+ self.assertIn("Vendor tested", t)+ self.assertIn("This server", t)+ self.assertIn("Not checked", t)+ self.assertIn("opencode 1.19.3", t)self.assertIn("OpenCode setup", t)self.assertIn("~/.config/opencode/opencode.json", t)await pilot.press("k")@@ -55,7 +58,10 @@ class Connect(unittest.TestCase):self.assertIn("abcdefghijklmnop", flat(app).replace("▒", ""))await pilot.press("7")await pilot.pause(0.2)- self.assertIn("Model state", text_of(app)) # 7 again goes back+ self.assertIn("Connect an app", text_of(app)) # 7 is a view like the others: pressing it again stays+ await pilot.press("escape")+ await pilot.pause(0.2)+ self.assertIn("Model state", text_of(app)) # Esc goes back to the view you came fromself.run_app(case)def test_views_one_to_six_leave_connect(self):@@ -94,10 +100,10 @@ class Connect(unittest.TestCase):await pilot.press("7", "h")for _ in range(30):await pilot.pause(0.1)- if "1/2 checks" in text_of(app):+ if "Failed (1/2)" in text_of(app):breakt = flat(app)- self.assertIn("problem (1/2 checks)", t)+ self.assertIn("Failed (1/2)", t)self.assertIn("prompt: It answered: 'pong'.", t)self.assertIn("did not call the tool", t)self.run_app(case)diff --git a/tests/terminal/test_overview.py b/tests/terminal/test_overview.pyindex a3faddf2e..fe40925f8 100644--- a/tests/terminal/test_overview.py+++ b/tests/terminal/test_overview.py@@ -94,7 +94,7 @@ class Build(unittest.TestCase):class Draw(unittest.TestCase):def test_the_approved_layout(self):text = draw(overview.build(metrics("reading")), connect=True)- for part in ("STRATA Serving", "IQ3_S 128K", "Reading prompt · 97%", "[LIVE]", "[1 Overview]", "7 Connect",+ for part in ("STRATA Overview", "IQ3_S 128K", "Reading prompt · 97%", "[LIVE]", "[1 Overview]", "7 Connect","Model state", "[Reading]", "35,610 / 36,742 tokens · 97%","Speed", "GPU load", "VRAM", "GPU temp", "Power", "PCIe", "CPU", "Disk read","88 %", "RTX 5070", "11.2 / 12 GB", "1,644 experts cached", "54 °C", "114 W", "of 250 W limit", "Gen4 x16",diff --git a/tests/terminal/test_tuiqa_monitor.py b/tests/terminal/test_tuiqa_monitor.pynew file mode 100644index 000000000..ce630662e--- /dev/null+++ b/tests/terminal/test_tuiqa_monitor.py@@ -0,0 +1,271 @@+"""Tester report 2026-10-18, T06 / T08 / T10 and the smaller monitor items: one seven-view model in every view and at every width,+Connect that says what is vendor history and what is this server's live result, and a light theme the Connect view and its pop-ups follow."""++from __future__ import annotations++import asyncio+import re+import unittest+from unittest import mock++from strata_cli import nav+from strata_cli.launch import check, harness+from strata_cli.launch.monitor_ext import LaunchMonitor+from strata_cli.launch.widgets import DARK, LIGHT+from strata_cli.monitor import MonitorApp+from tests.terminal.launch_support import Home, text_of+from tests.terminal.test_launch_monitor import INFO+from tests.terminal.test_overview import Source, metrics++SIZES = ((120, 40), (80, 24), (60, 20), (40, 15))+NAMES = ["Overview", "Serving", "Requests", "Engine", "Hardware", "Logs", "Connect"]+SHORT = {"Overview": "Over", "Serving": "Serve", "Requests": "Reqs", "Engine": "Engine", "Hardware": "GPU", "Logs": "Logs", "Connect": "Conn"}+++def tab_line(shown: str) -> str:+ """The row with the tab names: the one that has the marked tab."""+ for line in shown.splitlines():+ if re.search(r"\[\d [A-Za-z]+\]", line) and re.search(r"\b\d [A-Za-z]+", line.replace("[", " ")):+ return line+ return ""+++def marked(line: str) -> str | None:+ m = re.search(r"\[(\d) ([A-Za-z]+)\]", line)+ return None if m is None else m.group(2)+++class TabModel(unittest.TestCase):+ def test_all_names_when_there_is_room(self):+ self.assertEqual(nav.plain(1, 120, True), "1 Overview [2 Serving] 3 Requests 4 Engine 5 Hardware 6 Logs 7 Connect")+ self.assertEqual(nav.plain(1, 120, False), "1 Overview [2 Serving] 3 Requests 4 Engine 5 Hardware 6 Logs")++ def test_short_names_then_a_window_around_the_selected_tab_and_it_is_always_marked(self):+ for connect in (False, True):+ for current in range(nav.count(connect)):+ for width in (120, 90, 80, 60, 50, 40, 30, 24):+ line = nav.plain(current, width, connect)+ self.assertLessEqual(len(line), width, (current, width, connect))+ name = NAMES[current]+ self.assertTrue(f"[{current + 1} {name}]" in line or f"[{current + 1} {SHORT[name]}]" in line, (line, current, width))+ if width >= 60 + (10 if connect else 0):+ self.assertNotIn("<", line) # nothing hidden when the short names fit+ self.assertEqual(nav.plain(3, 40, True), "< 3 Reqs [4 Engine] 5 GPU 6 Logs 7 Conn")+ self.assertEqual(nav.plain(3, 34, True), "< 3 Reqs [4 Engine] 5 GPU 6 Logs >")++ def test_the_hint_matches_the_number_of_views(self):+ self.assertEqual((nav.keys(False), nav.keys(True)), ("1-6", "1-7"))++ def test_styled_marks_the_selected_tab_bold(self):+ t = nav.styled(2, 120, True, accent="#34d399")+ spans = [(t.plain[s.start:s.end], s.style) for s in t.spans if "bold" in str(s.style)]+ self.assertEqual([x for x, _ in spans], ["[3 Requests]"])+++class MonitorViews(unittest.TestCase):+ def run_app(self, cls, size, coro, **kw):+ async def go():+ if cls is LaunchMonitor:+ app = LaunchMonitor(Source(metrics("idle")), None, info=dict(INFO), interval=30, **kw)+ else:+ app = MonitorApp(Source(metrics("idle")), None, interval=30, **kw)+ async with app.run_test(size=size) as pilot:+ await pilot.pause(0.4)+ return await coro(app, pilot)+ with Home():+ return asyncio.run(go())++ def test_arrows_visit_all_seven_views_and_wrap_both_ways(self):+ async def case(app, pilot):+ seen = [app.view]+ for _ in range(7):+ await pilot.press("right")+ await pilot.pause(0.05)+ seen.append(app.view)+ self.assertEqual(seen, [0, 1, 2, 3, 4, 5, 6, 0]) # Logs -> Connect -> Overview+ await pilot.press("left")+ await pilot.pause(0.05)+ self.assertEqual(app.view, 6) # Overview <- Connect+ await pilot.press("left")+ await pilot.pause(0.05)+ self.assertEqual(app.view, 5) # Connect <- Logs: the previous tab, not a relative of the last ordinary view+ self.run_app(LaunchMonitor, (120, 40), case)++ def test_number_keys_and_arrows_agree(self):+ async def case(app, pilot):+ for n in range(1, 8):+ await pilot.press(str(n))+ await pilot.pause(0.05)+ self.assertEqual(app.view, n - 1)+ self.run_app(LaunchMonitor, (120, 40), case)++ def test_every_view_at_every_size_shows_the_tabs_the_hint_and_the_selection(self):+ async def case(app, pilot):+ for size in SIZES:+ await pilot.resize_terminal(*size)+ await pilot.pause(0.15)+ for index in range(7):+ await pilot.press(str(index + 1))+ await pilot.pause(0.08)+ shown = text_of(app)+ line = tab_line(shown)+ name = marked(line)+ self.assertIsNotNone(name, (size, index, shown[:400]))+ self.assertIn(name, (NAMES[index], SHORT[NAMES[index]]), (size, index, line))+ self.assertNotIn("1-6 views", shown, (size, index)) # the hint never disagrees with the tab line+ self.assertIn("Overview" if index == 0 and size[0] >= 78 else NAMES[index][:3], shown.replace("[", " "), (size, index))+ self.run_app(LaunchMonitor, (120, 40), case)++ def test_the_plain_monitor_has_six_views_and_says_1_6(self):+ async def case(app, pilot):+ for size in SIZES:+ await pilot.resize_terminal(*size)+ await pilot.pause(0.15)+ shown = text_of(app)+ self.assertNotIn("Connect", shown)+ self.assertNotIn("1-7", shown)+ await pilot.press("7")+ await pilot.pause(0.05)+ self.assertEqual(app.view, 0) # no seventh view here+ await pilot.press("left")+ await pilot.pause(0.05)+ self.assertEqual(app.view, 5)+ self.run_app(MonitorApp, (120, 40), case)++ def test_the_overview_is_titled_overview(self):+ async def case(app, pilot):+ self.assertIn("STRATA Overview", text_of(app))+ self.assertNotIn("STRATA Serving", text_of(app))+ await pilot.press("2")+ await pilot.pause(0.1)+ self.assertIn("Serving", text_of(app))+ self.run_app(LaunchMonitor, (120, 40), case)+++class ConnectStatus(unittest.TestCase):+ def run_app(self, coro, size=(120, 40), **kw):+ async def go():+ app = LaunchMonitor(Source(metrics("idle")), None, info=dict(INFO), interval=30, **kw)+ async with app.run_test(size=size) as pilot:+ await pilot.pause(0.4)+ return await coro(app, pilot)+ with Home():+ return asyncio.run(go())++ def test_vendor_history_and_this_servers_result_are_separate_columns(self):+ async def case(app, pilot):+ await pilot.press("7")+ await pilot.pause(0.2)+ shown = text_of(app)+ header = next(ln for ln in shown.splitlines() if "Vendor tested" in ln)+ self.assertIn("This server", header)+ for h in harness.HARNESSES:+ said = "built into Strata" if h.built_in else h.tested+ row = next(ln for ln in shown.splitlines() if h.title[:16] in ln and said[:23] in ln)+ self.assertIn("Not checked", row) # nothing has been tried against THIS server yet+ self.assertNotIn("tested ok", row)+ self.assertIn(said[:23], row)+ self.assertNotIn("Passed", shown)+ self.run_app(case)++ def test_a_check_turns_not_checked_into_passed_or_failed_for_that_app_only(self):+ good = [check.Check("prompt", True, "ok", 1.0), check.Check("tool call", True, "ok", 1.0)]+ bad = [check.Check("prompt", True, "ok", 1.0), check.Check("tool call", False, "no tool call", 1.0)]++ async def case(app, pilot):+ await pilot.press("7")+ for results, want in ((good, "Passed (2/2)"), (bad, "Failed (1/2)")):+ with mock.patch.object(check, "run_checks", return_value=results):+ await pilot.press("h")+ for _ in range(30):+ await pilot.pause(0.1)+ if want in text_of(app):+ break+ self.assertIn(want, text_of(app))+ await pilot.press("down")+ await pilot.pause(0.1)+ shown = text_of(app)+ self.assertEqual(shown.count("Not checked"), 6) # 8 apps, 2 checked+ self.run_app(case)++ def test_narrow_widths_keep_the_this_server_column(self):+ async def case(app, pilot):+ for width in (80, 60, 40):+ await pilot.resize_terminal(width, 24)+ await pilot.pause(0.15)+ await pilot.press("7")+ await pilot.pause(0.1)+ shown = text_of(app)+ self.assertIn("This server", shown, width)+ self.assertIn("Not checked", shown, width)+ self.run_app(case)+++def luminance(hex_color: str) -> float:+ r, g, b = (int(hex_color[i:i + 2], 16) / 255 for i in (1, 3, 5))+ f = lambda c: c / 12.92 if c <= 0.03928 else ((c + 0.055) / 1.055) ** 2.4 # noqa: E731+ return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b)+++def contrast(a: str, b: str) -> float:+ la, lb = sorted((luminance(a), luminance(b)), reverse=True)+ return (la + 0.05) / (lb + 0.05)+++class LightTheme(unittest.TestCase):+ def test_the_light_palette_is_readable_on_white_and_on_its_selection(self):+ for name in ("fg", "mute", "accent", "warn", "bad"):+ self.assertGreaterEqual(contrast(getattr(LIGHT, name), LIGHT.panel), 4.5, name)+ self.assertGreaterEqual(contrast(LIGHT.accent, LIGHT.sel), 4.5)+ self.assertLess(contrast(DARK.accent, "#ffffff"), 3.0) # the old dark colours are what the report measured (1.92:1)++ def run_app(self, coro, size=(120, 40)):+ async def go():+ app = LaunchMonitor(Source(metrics("idle")), None, info=dict(INFO), interval=30, theme="light")+ async with app.run_test(size=size) as pilot:+ await pilot.pause(0.4)+ return await coro(app, pilot)+ with Home():+ return asyncio.run(go())++ def test_connect_uses_the_light_colours_only(self):+ async def case(app, pilot):+ await pilot.press("7")+ await pilot.pause(0.2)+ t = app.connect_text(118)+ used = {str(s.style) for s in t.spans}+ joined = " ".join(used)+ for dark_only in ("#34d399", "#8e979f", "#f28b82", "#f5c56b", "#1f2a27"):+ self.assertNotIn(dark_only, joined)+ self.assertIn(LIGHT.accent, joined)+ self.assertIn(LIGHT.mute, joined)+ self.run_app(case)++ def test_the_dialog_opened_from_light_mode_is_light(self):+ async def case(app, pilot):+ self.assertTrue(app.has_class("theme-light"))+ await pilot.press("7")+ await pilot.pause(0.1)+ await pilot.press("w")+ await pilot.pause(0.3)+ dialog = app.screen.query_one("#dialog")+ self.assertEqual(str(dialog.styles.background.hex).lower()[:7], "#ffffff")+ await pilot.press("escape")+ await pilot.pause(0.1)+ self.run_app(case)++ def test_theme_cycling_moves_the_class_and_the_dialog_back_to_dark(self):+ async def case(app, pilot):+ self.assertTrue(app.has_class("theme-light"))+ await pilot.press("t") # light -> terminal+ await pilot.pause(0.05)+ self.assertFalse(app.has_class("theme-light"))+ await pilot.press("t") # terminal -> dark+ await pilot.press("7", "w")+ await pilot.pause(0.3)+ self.assertEqual(str(app.screen.query_one("#dialog").styles.background.hex).lower()[:7], "#161a1d")+ self.run_app(case)+++if __name__ == "__main__":+ unittest.main()