From e46d286b13be3c123a3ff672d6d98517dcb0dfcb Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Sun, 19 Jul 2026 16:14:07 -0400 Subject: [PATCH] Atlas focus line: name with its parenthesized hash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current-node line drew the name followed by a bare 12-hex slice of the key and then spelled out the node type. Drop the type atom — the leading glyph already carries it — and render the identity as name (hash): the addressed path-hash in parentheses, its digits lit in the node's hue. A keyless own-node ("local") has no hash, so the parenthetical is omitted. Co-Authored-By: Claude Opus 4.8 --- meshterm/ui/atlas_screen.py | 33 +++++++++++++++++++++++---------- tests/test_atlas.py | 3 ++- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/meshterm/ui/atlas_screen.py b/meshterm/ui/atlas_screen.py index 129ec43..a1465ff 100644 --- a/meshterm/ui/atlas_screen.py +++ b/meshterm/ui/atlas_screen.py @@ -50,7 +50,6 @@ from rich.cells import cell_len from rich.text import Text from ..core.models import ( - NODE_TYPE_LABELS, NODE_TYPE_REPEATER, Contact, utcnow, @@ -477,7 +476,12 @@ class AtlasScreen(Screen): return f"bold {base}" if last else base def _focus_line(self, depths: dict[str, int]) -> Text: - """Who is in focus: glyph, name, hash, kind, distance, and recency.""" + """Who is in focus: glyph, name with its parenthesized hash, distance, and recency. + + The leading glyph already carries the node type, so the line no longer spells it + out; the name reads ``name (hash)`` — the addressed path-hash in parentheses, its + digits lit in the node's hue — rather than a bare slice of the key. + """ node = self._focus glyph, color = self._glyph(node) contact = self._contacts.get(node) @@ -485,17 +489,14 @@ class AtlasScreen(Screen): line.append(glyph, style=color) line.append(" ") line.append(self._label(node), style=self._list_name_style(node)) - line.append(" ") - line.append_text(highlighted_hash(node, self._prefix_bytes)) + short = self._short_hash(node) + if short: + line.append(" (", style="muted") + line.append_text(highlighted_hash(short, self._prefix_bytes)) + line.append(")", style="muted") if node == self._topo.self_id: line.append(" · this device", style="muted") else: - kind = ( - NODE_TYPE_LABELS.get(contact.node_type, "node") - if contact is not None - else "unknown node" - ) - line.append(f" · {kind}", style="muted") if node not in depths: line.append(" · island — no observed path to you", style="warn") else: @@ -506,6 +507,18 @@ class AtlasScreen(Screen): line.append(f" · heard {_format_age(secs)}", style="muted") return line + def _short_hash(self, node: str) -> str: + """The node's addressable path-hash as hex, or ``''`` for a placeholder id. + + The first ``prefix_bytes`` bytes (at least one, so there is always a hash to show) + of a hex id; a non-hex stand-in like ``"local"`` — our own node with no key — has + no hash and yields the empty string, so the focus line drops the parenthetical. + """ + raw = node.lower() + if not raw or any(c not in "0123456789abcdef" for c in raw): + return "" + return raw[: max(1, self._prefix_bytes) * 2] + # -- the canvas -- def _canvas_lines( diff --git a/tests/test_atlas.py b/tests/test_atlas.py index c91ea15..9583542 100644 --- a/tests/test_atlas.py +++ b/tests/test_atlas.py @@ -104,7 +104,8 @@ def test_atlas_enter_walks_and_grows_the_trail() -> None: assert screen._focus == topo.canonical(YUL.public_key) body = _plain(screen.render_body(80)) assert "Homestead › YUL-Cartierville" in body # the trail - assert "repeater" in body and "1 hop out" in body + # The focus line reads name (hash) — the glyph carries the type, not a spelled-out kind. + assert "YUL-Cartierville (3d)" in body and "1 hop out" in body assert "Alice" in body # YUL's onward neighbour is now a row assert "⌫ back" in body # the row leading home is marked