From a446da268322c9e1a1c071fda818ac7fa2300b4c Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Mon, 21 Sep 2026 19:45:11 -0400 Subject: [PATCH] A type-1 node is a companion, everywhere 0.9.0 called the same advert type three things: `companion` in info, `client` in diagnostics, and `node` in contacts and every other screen that names a node's type. Room servers were `room server` in two places and `room` in the rest. JP picked companion. It is the ecosystem's word -- companion firmware, companion apps -- and the one MeshTerm's own docs already used most. "client" now belongs to MeshTerm itself, which the one-liner calls a MeshCore client, and "node" is the lexicon's umbrella for every type, so a TYPE column that says "node" for one of them tells a reader nothing. There is now one table, NODE_TYPE_LABELS, and one helper, node_type_label(), which gives "type N" for an advert type MeshTerm does not know. info and diagnostics lose the two role tables that had drifted apart, and the packet viewer its own copy of the fallback. The longer names made the node-type legend 59 cells wide, which the PicoCalc's 53 would have cropped, cutting "sensor" off. node_type_legend() now takes the width it has and breaks between entries, never inside one, so it stays on one line on a desktop and takes two on the PicoCalc. The four screens that draw it pass their width and take its lines. This changes --json output, so it goes under [Unreleased] for 0.9.1. docs/cli.md's samples, the value lists and CLAUDE.md's lexicon say companion and room server. Two tests pin the names and the PicoCalc legend. Co-Authored-By: Claude Opus 5 (1M context) --- CHANGELOG.md | 12 ++++++++++ CLAUDE.md | 8 +++---- docs/cli.md | 36 ++++++++++++++--------------- meshterm/core/models.py | 14 +++++++++-- meshterm/tools/diagnostics.py | 10 ++------ meshterm/tools/info.py | 8 +++---- meshterm/ui/message_paths_screen.py | 4 ++-- meshterm/ui/node_detail_screen.py | 2 +- meshterm/ui/packet_viewer.py | 7 +++--- meshterm/ui/records_screen.py | 2 +- meshterm/ui/widgets.py | 32 ++++++++++++++++++------- tests/test_records_screen.py | 15 ++++++++++++ tests/test_widgets.py | 11 +++++++++ 13 files changed, 108 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bac514e..9e776ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,18 @@ one caveat SemVer makes for a leading zero: while the major version is still `0` ## [Unreleased] +### Changed + +- **A type-1 node is a companion everywhere.** 0.9.0 called it three different things: + `companion` in `meshterm info`, `client` in `meshterm diagnostics`, and `node` in + `contacts` and every other screen that names a node's type. All three now say + `companion`, and a room server is `room server` everywhere rather than sometimes just + `room`. This changes `--json` output: `diagnostics` gives `"device_role": "companion"`, + and the `type` field on a node gives `"companion"` and `"room server"`. Scripts that + matched the old words need updating. +- The node-type legend under a route graph moves onto a second line when the screen is + too narrow for it, such as on the PicoCalc, instead of cutting the last entry off. + ## [0.9.0] — 2026-09-22 **The first public release.** Everything in MeshTerm is new today, so instead of a list of diff --git a/CLAUDE.md b/CLAUDE.md index f0da83e..348be8a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -56,7 +56,7 @@ them instead of hand-rolling: | Term | Meaning | |---|---| -| node | any device on the mesh — a radio broadcasting packets; roles: client, repeater, room server. The umbrella term | +| node | any device on the mesh — a radio broadcasting packets; roles: companion, repeater, room server, sensor. The umbrella term | | contact | a node your device knows: **discovered** (heard broadcasting, not yet added) or **added** (in the contact list, messageable). Every contact is a node; not every node is a contact | | heard | received from ("last heard", "first heard") — never "seen" in UX text | | key | the full fixed-length value — a node's public key, a channel secret | @@ -68,7 +68,7 @@ them instead of hand-rolling: | Quit | leave the app (main menu, device splash) — nowhere else | Node vs contact — the boundary: **node** is the hardware/participant sense — the map, -mesh walk, heard-nodes, relay hops, graph vertices, and node *types* (client/repeater/room/ +mesh walk, heard-nodes, relay hops, graph vertices, and node *types* (companion/repeater/room server/ sensor) all speak "node". **Contact** is the saved-identity sense — the Contacts screen, the courier recipient, anything you *address*. The reception/persistence layer (`observations.node`, `HeardNode`, `heard_nodes()`, `trace_hops.node`) stays "node"; the @@ -296,8 +296,8 @@ as a grouped list does. Filling a page in is editing its `.md`; no Python follow - Status marks (single-width, themed): `✓` ok · `✗` err · `⚠`/`?` warn · `●` unread/ unacked (err) · `○` acked/empty (muted). Never `✔`, `✖`, `✅`, `❌` as status. -- Node types (shared with the map): `★` you (yellow) · `●` node · `▲` repeater · - `■` room · `◉` sensor · `○` unknown. +- Node types (shared with the map): `★` you (yellow) · `●` companion · `▲` repeater · + `■` room server · `◉` sensor · `○` unknown. - Path cuts: a path line drawn as **chips** that gets cut — a lane that ran out, a row scrolled past its edge — breaks the chip off on a half block in that chip's own fill (`▐` ends a line, `▌` opens one; `pathline.cut_mark`/`cut_to`), so half the cell is diff --git a/docs/cli.md b/docs/cli.md index b5a62e8..3a73b3d 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -188,11 +188,11 @@ the device clock, an appointment set with `--at`, a live capture's own `TIME` co ```console $ meshterm --absolute contacts -NAME TYPE HEARD PKTS HASH LOCATION KEY -Observer-Bot node 2026-09-08T04:30:50-04:00 - c3 45.48800,-73.58100 c3d4e5f600000000000000000000000000000000000000000000000000000000 -Local-Repeater repeater 2026-09-08T04:30:49-04:00 - b2 45.47680,-73.59900 b2c3d4e500000000000000000000000000000000000000000000000000000000 -Yagi-Repeater repeater 2026-09-08T04:30:49-04:00 - a1 45.50190,-73.56740 a1b2c3d400000000000000000000000000000000000000000000000000000000 -Alice node 2026-09-08T04:30:48-04:00 - d4 - d4e5f6a700000000000000000000000000000000000000000000000000000000 +NAME TYPE HEARD PKTS HASH LOCATION KEY +Observer-Bot companion 2026-09-08T04:30:50-04:00 - c3 45.48800,-73.58100 c3d4e5f600000000000000000000000000000000000000000000000000000000 +Local-Repeater repeater 2026-09-08T04:30:49-04:00 - b2 45.47680,-73.59900 b2c3d4e500000000000000000000000000000000000000000000000000000000 +Yagi-Repeater repeater 2026-09-08T04:30:49-04:00 - a1 45.50190,-73.56740 a1b2c3d400000000000000000000000000000000000000000000000000000000 +Alice companion 2026-09-08T04:30:48-04:00 - d4 - d4e5f6a700000000000000000000000000000000000000000000000000000000 ``` The flag is an **override of a preference**, not a switch beside one: `cli_time_format` is @@ -374,7 +374,7 @@ present. | `name` | string \| null | The name the node advertises. Never quoted, never truncated. | | `key` | string \| null | The full public key, lowercase hex, 64 characters. `null` where only a hash was ever heard. | | `hash` | string \| null | The short derived id, at the width the surrounding surface addressed the node by. Never `key` cut short. | -| `type` | string \| null | `"node"` \| `"repeater"` \| `"room"` \| `"sensor"` \| `null`. | +| `type` | string \| null | `"companion"` \| `"repeater"` \| `"room server"` \| `"sensor"` \| `null`. | | `self` | boolean | `true` for our own node. What the menu's star says and the plain face deliberately does not. | Reception facts — when heard, how strong, where — belong to the **row**, not to the node: @@ -829,16 +829,16 @@ The contacts your device knows. ```console $ meshterm contacts --sort name -NAME TYPE HEARD PKTS HASH LOCATION KEY -Alice node 7m - d4 - d4e5f6a700000000000000000000000000000000000000000000000000000000 -Local-Repeater repeater 7m - b2 45.47680,-73.59900 b2c3d4e500000000000000000000000000000000000000000000000000000000 -Observer-Bot node 7m - c3 45.48800,-73.58100 c3d4e5f600000000000000000000000000000000000000000000000000000000 -Yagi-Repeater repeater 7m - a1 45.50190,-73.56740 a1b2c3d400000000000000000000000000000000000000000000000000000000 +NAME TYPE HEARD PKTS HASH LOCATION KEY +Alice companion 7m - d4 - d4e5f6a700000000000000000000000000000000000000000000000000000000 +Local-Repeater repeater 7m - b2 45.47680,-73.59900 b2c3d4e500000000000000000000000000000000000000000000000000000000 +Observer-Bot companion 7m - c3 45.48800,-73.58100 c3d4e5f600000000000000000000000000000000000000000000000000000000 +Yagi-Repeater repeater 7m - a1 45.50190,-73.56740 a1b2c3d400000000000000000000000000000000000000000000000000000000 ``` -`TYPE` is the node's advertised role in words — `node`, `repeater`, `room`, `sensor`, or -`unknown`. `HEARD` is a relative age, because "recently?" is what this listing is opened to -answer; `--absolute` turns it into an instant. `PKTS` is how many packets passive +`TYPE` is the node's advertised role in words — `companion`, `repeater`, `room server`, +`sensor`, or `unknown`. `HEARD` is a relative age, because "recently?" is what this listing +is opened to answer; `--absolute` turns it into an instant. `PKTS` is how many packets passive monitoring has overheard. **`HASH` is the token `--path` and `--to` take**, so it never has to be sliced out of `KEY` @@ -853,7 +853,7 @@ far more detail than a row could hold. **`--json`** is an array of rows, each embedding the `node` shape. ```json -{"node":{"name":"Observer-Bot","key":"c3d4e5f600000000000000000000000000000000000000000000000000000000","hash":"c3","type":"node","self":false},"heard_at":"2026-09-08T08:30:50Z","packets":null,"position":{"lat":45.488,"lon":-73.581}} +{"node":{"name":"Observer-Bot","key":"c3d4e5f600000000000000000000000000000000000000000000000000000000","hash":"c3","type":"companion","self":false},"heard_at":"2026-09-08T08:30:50Z","packets":null,"position":{"lat":45.488,"lon":-73.581}} ``` | Field | Type | Meaning | @@ -1050,7 +1050,7 @@ for working out whether messages are being pulled from the companion at all. ```console $ meshterm chat send "see you there" --to Alice --json -{"kind":"direct","node":{"name":"Alice","key":"d4e5f6a700000000000000000000000000000000000000000000000000000000","hash":"d4e5f6a7","type":"node","self":false},"channel":null,"sent":true,"acked":true} +{"kind":"direct","node":{"name":"Alice","key":"d4e5f6a700000000000000000000000000000000000000000000000000000000","hash":"d4e5f6a7","type":"companion","self":false},"channel":null,"sent":true,"acked":true} $ meshterm chat send "net in 5" --channel 0 --json {"kind":"channel","node":null,"channel":{"slot":0,"name":"#0","public":true,"hash":null},"sent":true,"acked":null} @@ -1335,7 +1335,7 @@ single transmission. objects, which matters most here: the two nodes are told apart by nothing else on the line. ```json -{"tuning_node":{"name":"Yagi-Repeater","key":"a1b2c3d400000000000000000000000000000000000000000000000000000000","hash":"a1b2c3d4","type":"repeater","self":false},"target":{"name":"Alice","key":"d4e5f6a700000000000000000000000000000000000000000000000000000000","hash":"d4e5f6a7","type":"node","self":false},"path":"a1b2c3d4,d4e5f6a7","optimal_tx_dbm":19,"target_snr_db":8.7,"reliability":1.0,"previous_tx_dbm":20,"applied":true,"levels":[{"tx_dbm":18,"target_snr_db":6.6,"successes":2,"samples":2},{"tx_dbm":19,"target_snr_db":8.7,"successes":4,"samples":4},{"tx_dbm":20,"target_snr_db":9.1,"successes":2,"samples":2},{"tx_dbm":21,"target_snr_db":7.6,"successes":2,"samples":2},{"tx_dbm":24,"target_snr_db":4.0,"successes":2,"samples":2},{"tx_dbm":27,"target_snr_db":-9.9,"successes":2,"samples":2},{"tx_dbm":28,"target_snr_db":-15.1,"successes":1,"samples":2}]} +{"tuning_node":{"name":"Yagi-Repeater","key":"a1b2c3d400000000000000000000000000000000000000000000000000000000","hash":"a1b2c3d4","type":"repeater","self":false},"target":{"name":"Alice","key":"d4e5f6a700000000000000000000000000000000000000000000000000000000","hash":"d4e5f6a7","type":"companion","self":false},"path":"a1b2c3d4,d4e5f6a7","optimal_tx_dbm":19,"target_snr_db":8.7,"reliability":1.0,"previous_tx_dbm":20,"applied":true,"levels":[{"tx_dbm":18,"target_snr_db":6.6,"successes":2,"samples":2},{"tx_dbm":19,"target_snr_db":8.7,"successes":4,"samples":4},{"tx_dbm":20,"target_snr_db":9.1,"successes":2,"samples":2},{"tx_dbm":21,"target_snr_db":7.6,"successes":2,"samples":2},{"tx_dbm":24,"target_snr_db":4.0,"successes":2,"samples":2},{"tx_dbm":27,"target_snr_db":-9.9,"successes":2,"samples":2},{"tx_dbm":28,"target_snr_db":-15.1,"successes":1,"samples":2}]} ``` `reliability` is a fraction in `[0, 1]`, not a formatted `"1.00"`. `levels` is ordered by @@ -1531,7 +1531,7 @@ powerline full (font:windows-terminal) connected yes transport ble port - -device_role client +device_role companion device_model Heltec V3 firmware v1.7.1 1c3f9a2 radio_freq_mhz 906.8750 diff --git a/meshterm/core/models.py b/meshterm/core/models.py index bdfad96..92745af 100644 --- a/meshterm/core/models.py +++ b/meshterm/core/models.py @@ -48,14 +48,24 @@ NODE_TYPE_ROOM = 3 NODE_TYPE_SENSOR = 4 #: Human-readable label for each advert type, for legends and summaries. +#: The one name for each advert type, everywhere MeshTerm prints one and in every +#: `--json` answer that carries a role or a type. A type-1 node is a companion: the radio +#: someone talks through, the same kind as the one in your hand. NODE_TYPE_LABELS = { - NODE_TYPE_CHAT: "node", + NODE_TYPE_CHAT: "companion", NODE_TYPE_REPEATER: "repeater", - NODE_TYPE_ROOM: "room", + NODE_TYPE_ROOM: "room server", NODE_TYPE_SENSOR: "sensor", } +def node_type_label(node_type: int | None) -> str | None: + """The name for an advert type, ``type N`` for one MeshTerm does not know, None for none.""" + if node_type is None: + return None + return NODE_TYPE_LABELS.get(int(node_type), f"type {node_type}") + + class LoginResult(Enum): """How an admin login ended — and, crucially, whether the node was there to end it. diff --git a/meshterm/tools/diagnostics.py b/meshterm/tools/diagnostics.py index ca10096..2f096d3 100644 --- a/meshterm/tools/diagnostics.py +++ b/meshterm/tools/diagnostics.py @@ -35,16 +35,12 @@ from pathlib import Path from typing import TYPE_CHECKING, Any from ..context import AppContext +from ..core.models import node_type_label from .base import Tool, ToolResult, register if TYPE_CHECKING: # pragma: no cover - typing only from ..ui.report import Report -#: MeshCore advert-type byte -> the role a person calls it. Duplicated from ``info`` -#: rather than shared: that module's copy is part of the device-status answer, and a -#: cross-import between two tools to save five entries buys a dependency and no clarity. -_ROLES = {1: "client", 2: "repeater", 3: "room server", 4: "sensor"} - #: What the saved file is called, in the config directory beside the log it sits next to #: in a bug report. Named for the app rather than just ``diagnostics.md`` because the one #: thing that happens to this file is being moved somewhere else and attached, and by then @@ -382,9 +378,7 @@ async def _device_facts(ctx: AppContext) -> Any: connected=True, transport="mock" if ctx.mock else (ctx.active_transport or "serial"), port=ctx.active_port, - device_role=( - _ROLES.get(int(adv_type), f"type {adv_type}") if adv_type is not None else None - ), + device_role=node_type_label(adv_type), device_model=info.get("model") or None, firmware=" ".join(str(info[k]) for k in ("ver", "fw_build") if info.get(k)) or None, radio_freq_mhz=snapshot.get("radio_freq"), diff --git a/meshterm/tools/info.py b/meshterm/tools/info.py index d6017bf..6ec4461 100644 --- a/meshterm/tools/info.py +++ b/meshterm/tools/info.py @@ -14,14 +14,12 @@ from rich.text import Text from ..context import AppContext from ..core.connection import Device +from ..core.models import node_type_label from .base import Tool, ToolResult, register if TYPE_CHECKING: # pragma: no cover - typing only from ..ui.report import Column, Facts -#: MeshCore advert-type byte -> human-readable node role. -_ROLES = {1: "companion", 2: "repeater", 3: "room server", 4: "sensor"} - @register class InfoTool(Tool): @@ -141,7 +139,7 @@ async def _status_panel(device: Device, snapshot: dict) -> Panel: adv_type = snapshot.get("adv_type") if adv_type is not None: - role = _ROLES.get(int(adv_type), f"type {adv_type}") + role = node_type_label(adv_type) rows.append(("role", Text(role, style="brand"))) if info.get("model"): @@ -239,7 +237,7 @@ async def status_facts(device: Device, snapshot: dict) -> Facts: # `config show`'s answer, not this one. "name": snapshot.get("name"), "public_key": str(snapshot.get("public_key") or "").lower() or None, - "role": _ROLES.get(int(adv_type), f"type {adv_type}") if adv_type is not None else None, + "role": node_type_label(adv_type), "model": info.get("model"), "firmware": _firmware(info) or None, "battery_v": round(int(level) / 1000, 2) if level else None, diff --git a/meshterm/ui/message_paths_screen.py b/meshterm/ui/message_paths_screen.py index c2517e2..19fad21 100644 --- a/meshterm/ui/message_paths_screen.py +++ b/meshterm/ui/message_paths_screen.py @@ -58,7 +58,7 @@ from .pathline import ( path_line, ) from .theme import snr_style -from .tui.render import crop_cells, render_to_ansi +from .tui.render import crop_cells, render_lines, render_to_ansi from .tui.screen import ListWindow, Screen from .widgets import ( NameKeyResolver, @@ -293,7 +293,7 @@ class MessagePathsScreen(Screen): style="faint", ) lines.append(render_to_ansi(caption, width, no_wrap=True)) - lines.append(render_to_ansi(node_type_legend(), width, no_wrap=True)) + lines.extend(render_lines(node_type_legend(width=width), width, no_wrap=True)) lines.extend(revisit) lines.append("") diff --git a/meshterm/ui/node_detail_screen.py b/meshterm/ui/node_detail_screen.py index 2a4d711..064666e 100644 --- a/meshterm/ui/node_detail_screen.py +++ b/meshterm/ui/node_detail_screen.py @@ -950,7 +950,7 @@ class NodeDetailScreen(Screen): while lines and not _SGR.sub("", lines[0]).strip(): lines.pop(0) if rv.legend: - lines.extend(render_lines(node_type_legend(), width, no_wrap=True)) + lines.extend(render_lines(node_type_legend(width=width), width, no_wrap=True)) self._stage_memo = (stage_key, lines) return lines diff --git a/meshterm/ui/packet_viewer.py b/meshterm/ui/packet_viewer.py index 7355703..c3b0c46 100644 --- a/meshterm/ui/packet_viewer.py +++ b/meshterm/ui/packet_viewer.py @@ -50,7 +50,7 @@ from rich.table import Table from rich.text import Text from ..core.channels import decrypt_channel_text, identify_channel -from ..core.models import NODE_TYPE_LABELS, Observation, utcnow +from ..core.models import Observation, node_type_label, utcnow from ..services.trace_runner import NodeResolver from .marks import SELF_MARK, UNKNOWN_MARK from .menus import SEP_COMPACT, SEP_ROOMY @@ -677,7 +677,7 @@ class PacketViewer(Screen): lines.extend(graph) caption = Text("origin → you · labels = hash byte", style="faint") lines.append(render_to_ansi(caption, width, no_wrap=True)) - lines.append(render_to_ansi(node_type_legend(), width, no_wrap=True)) + lines.extend(render_lines(node_type_legend(width=width), width, no_wrap=True)) if tail: lines.append("") lines.extend(self._grid_lines(tail, width, label_w)) @@ -748,8 +748,7 @@ class PacketViewer(Screen): who.append_text(highlighted_hash(entry.node, self._prefix_bytes)) rows.append(("from", who)) if entry.node_type is not None: - label = NODE_TYPE_LABELS.get(entry.node_type, f"type {entry.node_type}") - rows.append(("type", Text(label))) + rows.append(("type", Text(node_type_label(entry.node_type)))) if entry.kind == "packet": rows.extend(self._packet_rows(entry)) diff --git a/meshterm/ui/records_screen.py b/meshterm/ui/records_screen.py index f3bc5e9..d89ba3a 100644 --- a/meshterm/ui/records_screen.py +++ b/meshterm/ui/records_screen.py @@ -714,7 +714,7 @@ class RecordScreen(Screen): lines = self._graph_lines(width) caption = Text("you → … → you · labels = hash byte", style="faint") lines.append(render_to_ansi(caption, width, no_wrap=True)) - lines.append(render_to_ansi(node_type_legend(), width, no_wrap=True)) + lines.extend(render_lines(node_type_legend(width=width), width, no_wrap=True)) # The walk itself, on THE path widget, across the card's whole width. No ``route`` # label lane: the line under a route graph captioned "you → … → you" is the route, diff --git a/meshterm/ui/widgets.py b/meshterm/ui/widgets.py index b8c012a..cc31965 100644 --- a/meshterm/ui/widgets.py +++ b/meshterm/ui/widgets.py @@ -11,6 +11,7 @@ from itertools import pairwise from typing import TYPE_CHECKING from rich import box +from rich.cells import cell_len from rich.console import Console, Group from rich.panel import Panel from rich.progress import ( @@ -1140,24 +1141,39 @@ def _sort_header(label: str, column: str, sort: ContactsSort) -> str: return f"[cursor]{label} {triangle}[/]" -def node_type_legend(indent: str = "") -> Text: - """The one-line key to the node-type marks: ``★ you ▲ repeater ● node …``. +def node_type_legend(indent: str = "", width: int | None = None) -> Text: + """The key to the node-type marks: ``★ you ▲ repeater ● companion …``. Every glyph in its shared map colour (see :data:`NODE_GLYPHS`), each named muted after it. THE legend for any surface that draws typed node markers — the contacts list under its table, the route graph under its lanes — so one glyph means one thing app-wide. + One line where it fits. Where it does not — the full names run to 59 cells, and the + PicoCalc has 53 — it breaks onto a second line between entries, never inside one, so + a mark is never parted from its name and no name is cropped. + Args: indent: Leading spaces to sit the legend under a table or graph body. + width: The cells available. None keeps the legend on one line. """ - legend = Text(indent) - legend.append(SELF_MARK[0], style=SELF_MARK[1]) - legend.append(" you", style="muted") + entries = [Text.assemble((SELF_MARK[0], SELF_MARK[1]), (" you", "muted"))] for node_type in (NODE_TYPE_REPEATER, NODE_TYPE_CHAT, NODE_TYPE_ROOM, NODE_TYPE_SENSOR): glyph, color = NODE_GLYPHS[node_type] - legend.append(" ") - legend.append(glyph, style=color) - legend.append(f" {NODE_TYPE_LABELS[node_type]}", style="muted") + entries.append(Text.assemble((glyph, color), (f" {NODE_TYPE_LABELS[node_type]}", "muted"))) + + gap = " " + legend = Text(indent) + line = cell_len(indent) + for i, entry in enumerate(entries): + size = cell_len(entry.plain) + if i and width is not None and line + len(gap) + size > width: + legend.append("\n" + indent) + line = cell_len(indent) + elif i: + legend.append(gap) + line += len(gap) + legend.append_text(entry) + line += size return legend diff --git a/tests/test_records_screen.py b/tests/test_records_screen.py index 37a11f2..86636c0 100644 --- a/tests/test_records_screen.py +++ b/tests/test_records_screen.py @@ -169,6 +169,21 @@ def test_record_dialog_shows_the_node_type_legend() -> None: assert "★ you" in body and "▲ repeater" in body and "◉ sensor" in body +def test_record_dialog_legend_breaks_between_entries_on_a_picocalc_width() -> None: + """At 53 cells the legend takes two lines, and no mark is parted from its name. + + The full names run to 59 cells on one line, so cropping would cut "sensor" off the + PicoCalc; breaking inside an entry would leave a glyph at the end of one line and its + name at the start of the next. + """ + screen = _dialog(_record()) + screen.handle("tab") # the Route tab + body = _plain(screen.render_body(53)) + for entry in ("★ you", "▲ repeater", "● companion", "■ room server", "◉ sensor"): + assert entry in body + assert all(cell_len(line) <= 53 for line in body.splitlines()) + + def test_record_graph_marks_a_repeater_relay_with_its_triangle() -> None: """A relay whose type is a repeater draws ▲, not the generic ● dot.""" dialog = _dialog(_record(), type_of=lambda h: 2 if h == HUB_ID else None) diff --git a/tests/test_widgets.py b/tests/test_widgets.py index 1770aab..1d50730 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -11,6 +11,7 @@ from __future__ import annotations from rich.style import Style from rich.text import Text +from meshterm.core.models import node_type_label from meshterm.ui.pathline import ( POWERLINE_ROUND_CLOSE, POWERLINE_ROUND_OPEN, @@ -276,3 +277,13 @@ def test_name_chip_falls_back_to_the_bare_name_without_powerline(powerline) -> N assert chip.plain == "Alice" # exactly what an arrow-mode path line makes of one hop assert str(next(iter(chip.spans)).style) == node_style("a1b2") # still its own hue + + +def test_every_advert_type_has_one_name() -> None: + """Type 1 is a companion everywhere: info, diagnostics, contacts and the legend agree.""" + assert node_type_label(1) == "companion" + assert node_type_label(2) == "repeater" + assert node_type_label(3) == "room server" + assert node_type_label(4) == "sensor" + assert node_type_label(9) == "type 9" # an advert type MeshTerm does not know yet + assert node_type_label(None) is None