From 3376a182710d35f49e1ee64b71534e341ac97932 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Tue, 11 Aug 2026 02:08:41 -0400 Subject: [PATCH] PicoCalc: a command row's icon lane is the first thing to go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every icon on the console is a one-glyph stand-in for an emoji, and the menu is where that pinches hardest: the main menu drew @ for both Map and Mesh walk, … for both Live feed and Time machine, and ?? for Trace path, in a lane costing three of fifty-three columns on every row (JP, on-device). So drop the lane there, mark and emoji alike. A command row's icon is decoration β€” it names the action's family while the label names the action β€” so where it can only be approximated it is worth less than the cells it takes, and the label and its description get them back. This is a platform choice (Platform.menu_icons), not a per-emoji one: a glyph that carries *data* is not an icon in this sense and never goes, which is why the Channels page keeps its οΌƒ/🌐/πŸ”’ openness mark, the feed keeps the class icon it shows in place of the class word at 53 columns, and node types, status marks and the mute mark in the channel lane all stay put. Three funnels do the work, so a screen never asks the platform itself: command_label for a label carrying its own icon, command_icon for a row that builds its own lane, and marked_label where the icon carried a tint β€” a delete row's red moves onto its words rather than leaving with the πŸ—‘. Section headings go through the same cut (a stand-in beside the ── rule is pure noise), which also retires the ?? that No revisits was drawing. Co-Authored-By: Claude Opus 5 (1M context) --- meshterm/platforms.py | 14 +++++ meshterm/ui/channels.py | 7 ++- meshterm/ui/contacts_screen.py | 4 +- meshterm/ui/courier_screen.py | 6 +- meshterm/ui/menu.py | 7 ++- meshterm/ui/menus.py | 96 ++++++++++++++++++++++++++++++- meshterm/ui/node_detail_screen.py | 8 ++- meshterm/ui/records_screen.py | 14 ++--- meshterm/ui/timemachine_screen.py | 4 +- meshterm/ui/trace_screen.py | 28 ++++----- meshterm/ui/tx_screen.py | 35 +++++++++-- meshterm/ui/watchtower_screen.py | 21 ++++--- 12 files changed, 192 insertions(+), 52 deletions(-) diff --git a/meshterm/platforms.py b/meshterm/platforms.py index d6c9a8f..40f9da3 100644 --- a/meshterm/platforms.py +++ b/meshterm/platforms.py @@ -43,6 +43,17 @@ class Platform: frame_border: Whether the base screen draws inside a bordered ``Panel``. ``False`` swaps it for a title-bar row instead (+4 cols, +1 row reclaimed) β€” a PicoCalc chrome saving, wired in P4. + menu_icons: Whether a *command row* leads with a decorative icon β€” the main menu's + per-tool mark, an action list's ``πŸ—‘``/``πŸ•’``, a body action's ``✎``. The label + already names the action, so the icon is a family cue, not information; where + the console can only spell it as a one-glyph stand-in the cue is worth less + than the cells it costs and reads as noise besides (``@`` for both Map and + Mesh walk, ``…`` for both Live feed and Time machine β€” JP, on-device, + 2026-08-11). ``False`` drops the whole lane, mark and emoji alike, and the + cells go to the label and its description. This is about *decoration* only: + a glyph that carries data β€” a channel's openness, a packet's class, a node's + type, a status mark on an outcome β€” is not a menu icon and is never dropped + (see :func:`~meshterm.ui.menus.command_label`). dialog_margin: Total columns a floating dialog leaves to the backdrop it sits over β€” half of it on each side (see :func:`~meshterm.ui.tui.frame._dialog_layout`). The gutter is what makes a @@ -106,6 +117,7 @@ class Platform: readable_cols: int readable_rows: int frame_border: bool + menu_icons: bool dialog_margin: int header_atoms: tuple[str, ...] footer_fkeys: bool @@ -126,6 +138,7 @@ REGULAR = Platform( readable_cols=72, readable_rows=24, frame_border=True, + menu_icons=True, dialog_margin=6, header_atoms=("version", "device", "badges", "pulse", "battery"), footer_fkeys=False, @@ -149,6 +162,7 @@ PICOCALC = Platform( readable_cols=53, readable_rows=26, frame_border=False, + menu_icons=False, dialog_margin=4, # JP's call (2026-08-01, post-P7 review): the handheld's header brands the app β€” # "MeshTerm vX" β€” rather than naming the device/port (on a soldered radio the port diff --git a/meshterm/ui/channels.py b/meshterm/ui/channels.py index d973a0d..0959b50 100644 --- a/meshterm/ui/channels.py +++ b/meshterm/ui/channels.py @@ -63,7 +63,7 @@ from ..core.connection import Device from ..core.models import Conversation from ..persistence.repository import ACTIVITY_DRAWN_BUCKETS from .braillechart import activity_peak, activity_sparkline -from .menus import back_rows, fit_cells, menu_rows, section_heading +from .menus import back_rows, command_label, fit_cells, menu_rows, section_heading from .qr import share_popup from .tui import CANCEL, Choice, SelectScreen, Separator from .widgets import _age_seconds, _format_age, channel_glyph, format_ago @@ -595,8 +595,9 @@ def _menu_items( items.append(section_heading("Organize")) # Two spaces after the arrow: ↕ (East-Asian-ambiguous width) renders one cell where # the sibling rows' glyphs (οΌ‹ οΌƒ πŸ”‘ πŸ”—) render two, so the extra space keeps this - # label's text column-aligned with theirs. - items.append(Choice(title="↕ Reorder channels", value=_REORDER)) + # label's text column-aligned with theirs. Both go together where the platform + # draws no icon lane at all. + items.append(Choice(title=command_label("↕ Reorder channels"), value=_REORDER)) items.append(section_heading("Add a channel")) rows = [] diff --git a/meshterm/ui/contacts_screen.py b/meshterm/ui/contacts_screen.py index 1c41ed6..5564f1c 100644 --- a/meshterm/ui/contacts_screen.py +++ b/meshterm/ui/contacts_screen.py @@ -28,7 +28,7 @@ from typing import TYPE_CHECKING from rich.text import Text from .contactlist import ContactListScreen, ContactRow -from .menus import back_rows, menu_rows +from .menus import back_rows, marked_label, menu_rows from .tui import Choice, Separator from .tui.screen import CANCEL from .widgets import ContactsSort, _age_seconds, _contact_pkts @@ -146,7 +146,7 @@ class ContactsScreen(ContactListScreen): tail = [ Separator(" "), Choice( - title=Text.assemble(("πŸ—‘ ", "err"), "Purge stale contacts…"), + title=marked_label("πŸ—‘", "Purge stale contacts…", "err"), value=_PURGE, ), *back_rows(_BACK), diff --git a/meshterm/ui/courier_screen.py b/meshterm/ui/courier_screen.py index 0c3db5f..56d89db 100644 --- a/meshterm/ui/courier_screen.py +++ b/meshterm/ui/courier_screen.py @@ -29,7 +29,7 @@ from rich.text import Text from ..core.courier_store import DELIVERED, QUEUED, QueuedMessage from ..core.models import Contact, is_direct_messageable, utcnow -from .menus import back_rows, section_heading +from .menus import back_rows, command_label, marked_label, section_heading from .contactlist import SORT_COLUMNS, SORT_OPENS_ASCENDING, ContactListScreen, ContactRow from .theme import glyph from .tui import CANCEL, DM_BYTE_LIMIT, Choice, SelectScreen, Separator @@ -472,8 +472,8 @@ async def _entry_actions(ctx: "AppContext", ident: int) -> None: await session.message_dialog(body, title=message.node_name) return items = [ - Choice("πŸ“€ Send now β€” one forced attempt", "send"), - Choice(Text.assemble(("βœ— ", "err"), "Cancel this message"), "cancel"), + Choice(command_label("πŸ“€ Send now β€” one forced attempt"), "send"), + Choice(marked_label("βœ—", "Cancel this message", "err"), "cancel"), ] picked = await session.select( f"{message.node_name} β€” β€œ{_shorten(message.text, 28)}”", diff --git a/meshterm/ui/menu.py b/meshterm/ui/menu.py index 6f7e486..e04bfee 100644 --- a/meshterm/ui/menu.py +++ b/meshterm/ui/menu.py @@ -29,7 +29,7 @@ from ..platforms import get_platform from ..tools import all_tools from .surface import TuiUi from .braillechart import activity_peak, activity_sparkline -from .menus import SEP_COMPACT, SEP_ROOMY, section_heading +from .menus import SEP_COMPACT, SEP_ROOMY, command_icon, command_label, section_heading from .theme import make_console from .widgets import battery_cell from .tui import ( @@ -464,7 +464,8 @@ async def _menu_loop(ctx: AppContext, session: TuiSession) -> None: def _label(tool) -> str: # noqa: ANN001 - registry Tool; typed at the source title = tool.title or tool.name - return f"{tool.icon} {title}" if tool.icon else title + icon = command_icon(tool.icon) + return f"{icon} {title}" if icon else title name_w = max((cell_len(_label(tool)) for tool in tools), default=0) items: list = [] @@ -479,7 +480,7 @@ async def _menu_loop(ctx: AppContext, session: TuiSession) -> None: row.append(tool.help, style="muted") items.append(Choice(title=row, value=tool.name)) items.append(Separator(" ")) - items.append(Choice(title="πŸšͺ Quit", value="__quit__")) + items.append(Choice(title=command_label("πŸšͺ Quit"), value="__quit__")) # Drive the menu list ourselves (rather than via session.select) so it stays on the # stack while the quit dialog floats over it: the confirm is drawn as a centered box diff --git a/meshterm/ui/menus.py b/meshterm/ui/menus.py index 0da2d1a..e2b1bd4 100644 --- a/meshterm/ui/menus.py +++ b/meshterm/ui/menus.py @@ -34,11 +34,17 @@ from typing import TYPE_CHECKING, Any, Iterable, Sequence, Union from rich.cells import cell_len from rich.text import Text +from ..platforms import get_platform +from .theme import glyph from .tui import Choice, Separator if TYPE_CHECKING: from ..context import AppContext +#: What a command row's label may be: plain text, or styled text whose spans survive the +#: icon cut (an err-tinted destructive row, a live unread badge). +LabelT = Union[str, Text] + #: The app's status-atom separator, in its two widths. ``Β·`` chains atoms (the standards' #: rule β€” ``Map Β· z12 Β· 34 nodes``); the roomy form is the default, and a surface running @@ -50,6 +56,79 @@ SEP_ROOMY = " Β· " SEP_COMPACT = " Β· " +def command_icon(icon: str) -> str: + """The glyph a command row leads with β€” empty where the platform drops the icon lane. + + The compose-time half of :data:`~meshterm.platforms.Platform.menu_icons`, for a row + that builds its own icon lane (a screen's body actions) rather than carrying the icon + inside a label string β€” :func:`command_label` is that case. Returning ``""`` rather + than a stand-in is the point: the caller measures what comes back, so an emptied lane + costs no cells at all, and the padding it would have taken goes to the label. + + Args: + icon: The row's icon, as written on the regular platform. + + Returns: + :func:`~meshterm.ui.theme.glyph`'s rendering of it, or ``""``. + """ + return glyph(icon) if get_platform().menu_icons else "" + + +def marked_label(icon: str, label: str, style: str) -> Text: + """A command row whose icon carries a tint β€” the tint moving to the label if it goes. + + The app marks a destructive command by tinting its icon, not its words (``πŸ—‘`` in + ``err`` before a plain "Delete all records…"). Drop the icon on a platform without an + icon lane and the tint would go with it, leaving a delete row looking like any other, + so it lands on the label instead β€” the presentation the config editor's *Factory + reset* has always used. + + Args: + icon: The row's icon, as written on the regular platform. + label: The row's words, with no icon and no leading space. + style: The theme style the mark (or, iconless, the label) is drawn in. + + Returns: + The composed row label. + """ + mark = command_icon(icon) + return Text.assemble((f"{mark} ", style), label) if mark else Text(label, style=style) + + +def command_label(label: LabelT) -> LabelT: + """``label`` with its leading icon dropped where the platform drops the icon lane. + + A command row's icon is *decoration*: it names the action's family while the label + names the action, so it is the first thing to go when cells are scarce (see + :data:`~meshterm.platforms.Platform.menu_icons`). The icon is taken to be everything + before the label's first space, and only when that head starts with a non-alphanumeric + character β€” so ``"πŸ—‘ Clear this slot…"`` and ``"↻ Read settings"`` both lose their + head while ``"Back"`` and ``"Trace target"`` pass through untouched. + + What must *not* come through here: a glyph carrying data (a channel's openness, a + packet's class, a node's type) or a status mark on an outcome or commit row + (``βœ“ Apply…``, ``βœ— Back β€” discard…``, built by :func:`exit_rows`). Those say something + the label doesn't, on every platform. + + Args: + label: The row's full label, icon included β€” a plain string or a styled + :class:`~rich.text.Text` (whose spans survive the cut). + + Returns: + The label, iconless or unchanged. The type is the one that went in. + """ + if get_platform().menu_icons: + return label + plain = label.plain if isinstance(label, Text) else label + head, sep, rest = plain.partition(" ") + if not sep or not head or head[0].isalnum() or not rest.strip(): + return label + # Take the gap with the icon: a row that padded a one-cell mark out to the width of + # its two-cell siblings ("↕ Reorder channels") must not leave the padding behind. + cut = len(plain) - len(rest.lstrip(" ")) + return label[cut:] + + def back_rows(value: Any = None) -> list: """The standard exit group closing a select list: a blank line, then ``Back``. @@ -102,6 +181,10 @@ def menu_rows(rows: Iterable[tuple[Union[str, Text], str, Any]]) -> list: description column starting two cells past the widest label, padding computed in display cells so a double-width emoji can't skew it. + Each label passes through :func:`command_label` first, so a platform that draws no + icon lane loses it *before* the lane is measured β€” the description column moves left + with the labels rather than going ragged behind them. + Args: rows: ``(label, description, value)`` triples. A :class:`Text` label keeps its own styling (an err-tinted destructive row, a live unread badge). @@ -110,8 +193,10 @@ def menu_rows(rows: Iterable[tuple[Union[str, Text], str, Any]]) -> list: One :class:`Choice` per row, lanes aligned across them all. """ prepared = [ - (label if isinstance(label, Text) else Text(label), help_text, value) - for label, help_text, value in rows + (Text(label) if isinstance(label, str) else label.copy(), help_text, value) + for label, help_text, value in ( + (command_label(label), help_text, value) for label, help_text, value in rows + ) ] width = max((cell_len(label.plain) for label, _, _ in prepared), default=0) items: list = [] @@ -267,8 +352,13 @@ def section_heading(label: str) -> Separator: :attr:`~meshterm.ui.tui.select.Separator.heading`, so it re-pins to the top row once its section scrolls under it and the Ctrl+PageUp/PageDown jumps step by it. Building the row by hand is how a section loses that β€” go through here. + + A heading that leads with an icon (``πŸ“‘ Channels``, a trophy discipline's mark) loses it + on a platform that draws no icon lane, exactly as a command row does β€” a heading is the + same kind of label, and a stand-in glyph beside the rule already drawing ``──`` reads as + noise (see :func:`command_label`). """ - return Separator(f"── {label} ──", style="accent", heading=True) + return Separator(f"── {command_label(label)} ──", style="accent", heading=True) def fit_cells(text: str, width: int, *, align: str = "left") -> str: diff --git a/meshterm/ui/node_detail_screen.py b/meshterm/ui/node_detail_screen.py index a58fe9c..b231794 100644 --- a/meshterm/ui/node_detail_screen.py +++ b/meshterm/ui/node_detail_screen.py @@ -81,6 +81,7 @@ from ..core.geo import EARTH_RADIUS_KM, usable_fix from ..core.models import NODE_TYPE_LABELS, Contact, utcnow from ..platforms import Platform, on_platform from .mapcanvas import RGB +from .menus import command_icon from .minimap import MiniMap from .pathgraph import ( DST_NODE, @@ -1043,8 +1044,11 @@ class NodeDetailScreen(Screen): def _action_line(self, action: _Action, selected: bool, width: int) -> str: """One action row: ``❯`` + icon + label, the whole row brand when it is the cursor's.""" text = Text("❯ " if selected else " ", style="brand" if selected else "") - if action.glyph: - text.append(f"{action.glyph} ", style=action.glyph_style) + # The icon lane is decoration a platform may drop whole (command_icon); the label + # is what names the action, so an emptied lane simply gives it the cells. + mark = command_icon(action.glyph) if action.glyph else "" + if mark: + text.append(f"{mark} ", style=action.glyph_style) text.append(action.label) if selected: text.style = "brand" diff --git a/meshterm/ui/records_screen.py b/meshterm/ui/records_screen.py index b956f3a..bc74636 100644 --- a/meshterm/ui/records_screen.py +++ b/meshterm/ui/records_screen.py @@ -47,7 +47,7 @@ from ..persistence.repository import DiscoveredPath from ..services import trace_runner from ..services.records import CATEGORIES, CATEGORY_BY_ID, Category, _local_xy from .mapcanvas import RGB, MapCanvas -from .menus import back_rows, fit_cells, section_heading +from .menus import back_rows, command_icon, fit_cells, marked_label, section_heading from .pathgraph import PathLayer, render_path_graph from .pathline import path_line from .theme import name_style, snr_style @@ -473,11 +473,11 @@ class RecordDialog(Screen): selected = i == self._index row = Text("❯ " if selected else " ", style="brand" if selected else "") if key == "trace": - row.append("πŸ‘£ ", style="accent") - row.append("Trace this path β€” reopen in Trace path") + row.append_text(marked_label( + "πŸ‘£", "Trace this path β€” reopen in Trace path", "accent" + )) elif key == "delete": - row.append("πŸ—‘ ", style="err") - row.append("Delete record…") + row.append_text(marked_label("πŸ—‘", "Delete record…", "err")) else: row.append("Back") if selected: @@ -840,11 +840,11 @@ async def open_records(ctx: "AppContext") -> dict: items.append(Separator(" ")) if total: items.append(Choice( - title=Text.assemble(("πŸ—‘ ", "err"), "Delete a discipline's records…"), + title=marked_label("πŸ—‘", "Delete a discipline's records…", "err"), value=("del_cat", None, 0, None), )) items.append(Choice( - title=Text.assemble(("πŸ—‘ ", "err"), "Delete all records…"), + title=marked_label("πŸ—‘", "Delete all records…", "err"), value=("del_all", None, 0, None), )) items.extend(back_rows(("back", None, 0, None))) diff --git a/meshterm/ui/timemachine_screen.py b/meshterm/ui/timemachine_screen.py index d85c0e2..3f6f0b1 100644 --- a/meshterm/ui/timemachine_screen.py +++ b/meshterm/ui/timemachine_screen.py @@ -41,7 +41,7 @@ from .braillechart import ( chart_span, timeline_rows, ) -from .menus import fit_cells, section_heading +from .menus import command_label, fit_cells, section_heading from .contactlist import SORT_COLUMNS, SORT_OPENS_ASCENDING, ContactListScreen, ContactRow from .theme import name_style, snr_style from .tui.render import render_lines @@ -1272,7 +1272,7 @@ class TimeMachinePickerScreen(ContactListScreen): sort=sort, prompt=prompt, lead=[ - Choice("🌐 The whole mesh β€” days, arrivals, the ledger", MESH), + Choice(command_label("🌐 The whole mesh β€” days, arrivals, the ledger"), MESH), Separator(" "), section_heading("Nodes"), ], diff --git a/meshterm/ui/trace_screen.py b/meshterm/ui/trace_screen.py index dedb7d8..e8019a4 100644 --- a/meshterm/ui/trace_screen.py +++ b/meshterm/ui/trace_screen.py @@ -96,8 +96,8 @@ from ..services import trace_runner from ..services.records import first_repeated_edge from ..services.topology import render_forced_spec from .braillechart import meter -from .menus import back_rows, section_heading -from .theme import glyph, snr_style +from .menus import back_rows, command_icon, marked_label, section_heading +from .theme import snr_style from .tui.render import render_lines, render_to_ansi from .tui.screen import ListWindow, Screen from .tui.spinner import Spinner, spinner_interval @@ -159,24 +159,26 @@ _ACTION_ICONS = ("✎", "⇄", "⚑", "βš™", "#", "β–Ά") def _icon_lane() -> int: """The action rows' icon column, in cells: the widest mark on this platform. - Measured rather than hard-coded because the marks themselves change width with - the platform: on PicoCalc every icon funnels through :func:`~meshterm.ui.theme.glyph` - to a single console-font character (``⚑`` β†’ ``!``), so the column tightens to one - cell and the labels move left with it β€” the same alignment rule at the console's - own resolution. + Measured rather than hard-coded because the marks themselves change with the + platform: PicoCalc draws no icon lane on a command row at all + (:func:`~meshterm.ui.menus.command_icon`), so the column measures zero and the labels + take the cells β€” the same alignment rule wherever the icons land. """ - return max(cell_len(glyph(icon)) for icon in _ACTION_ICONS) + return max(cell_len(command_icon(icon)) for icon in _ACTION_ICONS) def _icon(text: Text, icon: str, style: str) -> None: """Append an action row's mark in the icon column, its trailing space included. - A one-cell mark pads out to :func:`_icon_lane` so every label β€” narrow mark or - wide emoji β€” starts in the same column. + A one-cell mark pads out to :func:`_icon_lane` so every label starts in the same + column; an emptied lane (see there) appends nothing, separator included. """ - mark = glyph(icon) + lane = _icon_lane() + if not lane: + return + mark = command_icon(icon) text.append(mark, style=style) - text.append(" " * (_icon_lane() - cell_len(mark) + 1)) + text.append(" " * (lane - cell_len(mark) + 1)) def _lane_lines(label: str, value: list[Text], width: int) -> list[str]: @@ -1984,7 +1986,7 @@ async def _open_session( items.append(Separator(" ")) items.append( Choice( - title=Text.assemble(("⚑ ", "warn"), "Probe all β€” trace each path once and rank"), + title=marked_label("⚑", "Probe all β€” trace each path once and rank", "warn"), value=("probe", None), ) ) diff --git a/meshterm/ui/tx_screen.py b/meshterm/ui/tx_screen.py index 5002154..83d4722 100644 --- a/meshterm/ui/tx_screen.py +++ b/meshterm/ui/tx_screen.py @@ -33,6 +33,7 @@ import asyncio import re from typing import TYPE_CHECKING, Any, Callable, Optional +from rich.cells import cell_len from rich.console import Group, RenderableType from rich.table import Table from rich.text import Text @@ -41,6 +42,7 @@ from ..core.connection import REMOTE_TX_MAX, REMOTE_TX_MIN from ..core.models import Contact, TraceResult, TxLevelResult, TxOptResult from ..services import trace_runner, tx_optimizer from ..services.topology import build_topology, render_custom_spec +from .menus import command_icon from .pathline import SELF_GLYPH, PathHop, PathLine, cut_to, path_line from .theme import name_style, snr_style from .trace_screen import TracingDialog, _collapse_trace_width, snr_bar @@ -67,6 +69,27 @@ STEP_CHOICES = (1, 2, 3, 4, 5) SAMPLE_CHOICES = (1, 2, 3, 5, 8) +#: Every mark the sweep's action rows lead with. The list exists to *measure* the icon +#: column so each label starts in the same place, and so a platform that draws no icon +#: lane at all (see :func:`~meshterm.ui.menus.command_icon`) collapses it to nothing. +_ACTION_ICONS = ("✎", "βš™", "#", "β–Ά", "β˜…") + + +def _icon_lane() -> int: + """The action rows' icon column, in cells: the widest mark on this platform.""" + return max(cell_len(command_icon(icon)) for icon in _ACTION_ICONS) + + +def _icon(text: Text, icon: str, style: str) -> None: + """Append an action row's mark in the icon column, its trailing space included.""" + lane = _icon_lane() + if not lane: + return + mark = command_icon(icon) + text.append(mark, style=style) + text.append(" " * (lane - cell_len(mark) + 1)) + + class TxSweepScreen(Screen): """A full-screen TX-power sweep session β€” armed, but idle until told. @@ -379,29 +402,29 @@ class TxSweepScreen(Screen): """One action row: pointer, glyph, and label (current value inlined).""" text = Text("❯ " if selected else " ", style="brand" if selected else "") if key == "route": - text.append("✎ ", style="brand") + _icon(text, "✎", "brand") if self.route_hops: text.append("Route β€” via ") text.append_text(path_line(list(self.route_hops), self._resolve).text()) else: text.append(f"Route β€” direct to {self._admin_label}") elif key == "range": - text.append("βš™ ", style="accent") + _icon(text, "βš™", "accent") text.append(f"Range β€” TX {self.tx_min}–{self.tx_max}") elif key == "step": - text.append("βš™ ", style="accent") + _icon(text, "βš™", "accent") text.append(f"Step β€” every {_nth(self.step)} level, then refine" if self.step > 1 else "Step β€” every level (no refine needed)") elif key == "samples": - text.append("# ", style="accent") + _icon(text, "#", "accent") text.append( f"Samples β€” {self.samples} trace{'s' if self.samples != 1 else ''} per level" ) elif key == "sweep": - text.append("β–Ά ", style="ok") + _icon(text, "β–Ά", "ok") text.append(f"Sweep β€” up to {self.estimated_traces()} paced transmissions") elif key == "apply": - text.append("β˜… ", style="ok") + _icon(text, "β˜…", "ok") best = self._result.best_tx if self._result is not None else "?" text.append(f"Apply winner β€” set TX {best} on {self._admin_label}") else: diff --git a/meshterm/ui/watchtower_screen.py b/meshterm/ui/watchtower_screen.py index 1e8ddf7..40ef8df 100644 --- a/meshterm/ui/watchtower_screen.py +++ b/meshterm/ui/watchtower_screen.py @@ -23,7 +23,7 @@ from rich.text import Text from ..core.models import Contact from ..core.watch_store import OFF, SILENCE_CHOICES_H, Alert, WatchedNode from ..services.trace_runner import make_name_key_resolver -from .menus import back_rows, section_heading +from .menus import back_rows, command_label, marked_label, section_heading from .theme import name_style from .tui import Choice, Separator from .widgets import _DEFAULT_GLYPH, _NODE_GLYPHS, _age_seconds, _format_age @@ -198,9 +198,9 @@ def _menu_items( unacked = sum(1 for a in alerts if not a.acked) acked = len(alerts) - unacked if unacked: - items.append(Choice(f"βœ“ Acknowledge all ({unacked})", _ACK_ALL)) + items.append(Choice(marked_label("βœ“", f"Acknowledge all ({unacked})", "ok"), _ACK_ALL)) if acked: - items.append(Choice("πŸ—‘ Clear acknowledged", _CLEAR)) + items.append(Choice(marked_label("πŸ—‘", "Clear acknowledged", "err"), _CLEAR)) items.append(Separator(" ")) items.append(section_heading("Watched nodes")) @@ -208,13 +208,16 @@ def _menu_items( items.append(Separator(" none starred yet β€” silence and SNR rules need one")) for key in sorted(watched, key=lambda k: watched[k].name.casefold()): items.append(Choice(_watched_row(watched[key], type_of), ("node", key))) - items.append(Choice("⭐ Watch a node…", _WATCH)) + items.append(Choice(command_label("⭐ Watch a node…"), _WATCH)) items.append(Separator(" ")) state = "[ok]on[/ok]" if new_node_alerts else "[muted]off[/muted]" items.append( Choice( - Text.from_markup(f"πŸ”” New-node alerts: {state} [muted]β€” announce first-ever appearances[/muted]"), + command_label(Text.from_markup( + f"πŸ”” New-node alerts: {state}" + " [muted]β€” announce first-ever appearances[/muted]" + )), _TOGGLE_NEW, ) ) @@ -350,10 +353,12 @@ async def _node_rules(ctx: "AppContext", key: str) -> None: return silence = "off" if entry.silence_hours == OFF else f"after {entry.silence_hours} h" items = [ - Choice(f"πŸ•’ Silence alarm {silence}", "silence"), - Choice("πŸ“Ά SNR watch " + ("on" if entry.snr_watch else "off"), "snr"), + Choice(command_label(f"πŸ•’ Silence alarm {silence}"), "silence"), + Choice(command_label( + "πŸ“Ά SNR watch " + ("on" if entry.snr_watch else "off") + ), "snr"), Separator(" "), - Choice(Text.assemble(("βœ— ", "err"), "Stop watching this node"), "unwatch"), + Choice(marked_label("βœ—", "Stop watching this node", "err"), "unwatch"), *back_rows(), ] picked = await session.select(