Hide the devices inventory from the menu, keep it on the CLI

By the time the interactive menu is up a companion is already selected,
so the read-only devices listing has no job there; it belongs on the
command line as a startup-time "which port is my radio?" diagnostic.

Add a menu_visible flag to the Tool contract (skipped by the menu loop,
never by CLI registration) and set it False on the devices tool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 4.8 committed 2026-07-09 00:23:26 -04:00
1 parent dd097e48e5
commit 76202ec0d1
3 files changed
+14 -5

No files matched your search

+4
View File
@@ -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:
+8 -5
View File
@@ -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.
+2
View File
@@ -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} ──"))