diff --git a/meshterm/tools/base.py b/meshterm/tools/base.py index c87e5d2..8e3d86a 100644 --- a/meshterm/tools/base.py +++ b/meshterm/tools/base.py @@ -41,12 +41,16 @@ class Tool(ABC): help: One-line description shown in the menu and ``--help``. category: Grouping label used to organize the interactive menu. order: Sort key within a category (lower sorts first). + menu_visible: Whether the tool appears in the interactive menu. Set ``False`` for + CLI-only tools (e.g. startup-time diagnostics with no place in a connected + session); such tools still register a CLI subcommand as usual. """ name: str = "" help: str = "" category: str = "General" order: int = 100 + menu_visible: bool = True @abstractmethod async def run(self, ctx: "AppContext", params: dict[str, Any]) -> ToolResult: diff --git a/meshterm/tools/devices.py b/meshterm/tools/devices.py index bab3576..5f68930 100644 --- a/meshterm/tools/devices.py +++ b/meshterm/tools/devices.py @@ -1,10 +1,12 @@ """The ``devices`` tool: enumerate attached serial companion devices. -Discovery never opens the radio — it only lists what is attached. This is a read-only -inventory in both the menu and the CLI; it marks devices already confirmed as MeshCore -companions (and the active one). Selecting a companion is a startup-only concern: pass -``--port`` on the CLI (remembered after it connects), or pick from the prompt shown when the -menu launches (which smoke-tests the choice before confirming it). +Discovery never opens the radio — it only lists what is attached. This is a CLI-only, +read-only inventory (``menu_visible = False``): by the time the interactive menu is up a +device is already selected, so the listing has no job there — it belongs on the command line +as a startup-time "which port is my radio?" diagnostic. It marks devices already confirmed as +MeshCore companions (and the active one). Selecting a companion is a startup-only concern: +pass ``--port`` on the CLI (remembered after it connects), or pick from the prompt shown when +the menu launches (which smoke-tests the choice before confirming it). """ from __future__ import annotations @@ -40,6 +42,7 @@ class DevicesTool(Tool): help = "List attached serial devices and flag likely LoRa hardware." category = "Device" order = 5 + menu_visible = False # CLI-only: a startup diagnostic with no place in a connected session async def run(self, ctx: AppContext, params: dict[str, Any]) -> ToolResult: """Enumerate serial devices and render them as a table. diff --git a/meshterm/ui/menu.py b/meshterm/ui/menu.py index f5aff15..a130adb 100644 --- a/meshterm/ui/menu.py +++ b/meshterm/ui/menu.py @@ -198,6 +198,8 @@ async def _menu_loop(ctx: AppContext, session: TuiSession) -> None: items: list = [] current_category: str | None = None for tool in all_tools(): + if not tool.menu_visible: + continue if tool.category != current_category: current_category = tool.category items.append(Separator(f"── {current_category} ──"))