diff --git a/meshterm/ui/repeater_admin.py b/meshterm/ui/repeater_admin.py index f0d1dda..1e23808 100644 --- a/meshterm/ui/repeater_admin.py +++ b/meshterm/ui/repeater_admin.py @@ -39,8 +39,10 @@ from ..core.remote_config import ( from .menus import ( confirm_discard, exit_rows, + icon_lane, lane_header, lane_row, + marked_label, menu_rows, section_heading, ) @@ -283,17 +285,23 @@ def _menu_items(node: Contact, cache: dict, pending: dict[str, str]) -> tuple[st Choice(title=lane_row(label, value, help_text, label_w, value_w), value=key) ) + # ↻ and ⌨ are one cell where 📡 🕒 🔐 🔄 are two, so the column is measured once and + # every mark padded out to it — otherwise Read settings and Command line start their + # labels a column left of the rows under them. + actions = [ + ("↻", "Read settings", "Fetch every value from the node, one paced get", _READ), + ("⌨", "Command line…", "Talk to the node's CLI directly", _CLI), + ("📡", "Send advert…", "Have the node announce itself now", _ADVERT), + ("🕒", "Sync clock…", "Set the node's clock over the mesh", _CLOCK), + ("🔐", "Admin password…", "Change the node's admin password", _PASSWORD), + ("🔄", "Reboot node…", "Restart it remotely", _REBOOT), + ] + lane = icon_lane(icon for icon, _, _, _ in actions) items.append(section_heading("Actions")) items.extend( menu_rows( - [ - ("↻ Read settings", "Fetch every value from the node, one paced get", _READ), - ("⌨ Command line…", "Talk to the node's CLI directly", _CLI), - ("📡 Send advert…", "Have the node announce itself now", _ADVERT), - ("🕒 Sync clock…", "Set the node's clock over the mesh", _CLOCK), - ("🔐 Admin password…", "Change the node's admin password", _PASSWORD), - ("🔄 Reboot node…", "Restart it remotely", _REBOOT), - ] + (marked_label(icon, label, "", lane=lane), help_text, value) + for icon, label, help_text, value in actions ) ) diff --git a/tests/test_repeater_admin.py b/tests/test_repeater_admin.py index ddbc4e5..d526036 100644 --- a/tests/test_repeater_admin.py +++ b/tests/test_repeater_admin.py @@ -366,6 +366,34 @@ def test_admin_menu_pins_the_column_header_over_the_category() -> None: assert above is True +def test_admin_actions_start_every_label_in_the_same_cell() -> None: + """``↻`` and ``⌨`` are one cell among two-cell siblings; the icon column absorbs it. + + The Actions rows used to write ``icon + " "``, which started *Read settings* and + *Command line…* a column left of *Send advert…* below them. + """ + from rich.cells import cell_len + + from meshterm.ui.repeater_admin import _menu_items + from meshterm.ui.tui import Choice + + _title, items = _menu_items(NODE, {}, {}) + labels = ("Read settings", "Command line…", "Send advert…", "Sync clock…", "Reboot node…") + rows = [ + item.title.plain + for item in items + if isinstance(item, Choice) + and hasattr(item.title, "plain") + and any(label in item.title.plain for label in labels) + ] + assert len(rows) == len(labels) + starts = set() + for row in rows: + label = next(label for label in labels if label in row) + starts.add(cell_len(row[: row.index(label)])) + assert len(starts) == 1, "a label starts a column early" + + def test_admin_menu_header_abbreviates_rather_than_wrapping() -> None: """Too narrow for the whole line, the last label shortens — the header stays one row.""" from rich.cells import cell_len