Route graph: draw the featured path in plain white, and give the packet viewer one

Two related passes on THE route graph (ui/pathgraph).

1. **Featured path is always white.** The Message paths dialog and the
   Trophy case coloured their selected/scored path by reception SNR
   (theme.snr_rgb). But on a graph that draws only *one* real path over a
   grey backdrop, colour carried no comparison — it just competed with the
   node-name hues on the same canvas. Drop the SNR tint: the selected/walked
   path reads white (the single-walk convention), the unused paths grey.
   Removes the now-unused theme.snr_rgb / _SNR_RGB and updates both captions.

2. **The packet viewer draws a relayed packet's route.** A `packet` frame
   that actually crossed a relay now slots the fan-lane graph between its
   parsed detail (heard/from/class/via) and its extras — origin → relays →
   us, the same picture Message paths and the Trophy case draw. A direct
   arrival skips it (its `direct — no relays` via row already says all there
   is). render_body splits into head/tail grids sharing one label-lane width
   so the rows stay aligned across the graph; the dashboard threads a
   node-type resolver through so relays wear their map marker (▲, …).

Full suite green (806).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 4.8 committed 2026-07-16 21:04:58 -04:00
1 parent 310783c6a3
commit ec41de0339
7 files changed
+190 -78

No files matched your search

+8 -2
View File
@@ -50,7 +50,7 @@ from ..core.models import NODE_TYPE_REPEATER, Observation, utcnow
from ..persistence.repository import ACTIVITY_WINDOW
from .braillechart import axis_chart, meter, timeline_rows
from .menus import fit_cells
from .widgets import path_text
from .widgets import TypeOf, path_text
from .packet_viewer import (
KIND_STYLES,
PacketEntry,
@@ -136,6 +136,7 @@ class DashboardScreen(Screen):
prefix_bytes: int = 0,
self_name: Optional[str] = None,
channels: Sequence[tuple[str, bytes]] = (),
type_of: Optional[TypeOf] = None,
) -> None:
"""Create the dashboard over its data feeds.
@@ -153,6 +154,8 @@ class DashboardScreen(Screen):
channels: The device's configured channels, as ``(name, secret)`` pairs,
handed to each opened :class:`~meshterm.ui.packet_viewer.PacketViewer`
so it can attempt to decrypt an overheard channel-text packet.
type_of: Maps a relay hash to its node type, handed to the packet viewer so a
relayed packet's route graph marks a repeater ``▲`` (etc.) over a dot.
"""
super().__init__()
self.title = "Dashboard — mesh overview"
@@ -165,6 +168,7 @@ class DashboardScreen(Screen):
self._prefix_bytes = prefix_bytes
self._self_name = self_name
self._channels = channels
self._type_of = type_of
#: The trailing window of observations (stored seed + live), oldest first.
self._window: deque[Observation] = deque(window, maxlen=4000)
#: The feed: latest events of every class as data, newest first — rendered
@@ -293,7 +297,7 @@ class DashboardScreen(Screen):
list(self._feed), self._selected,
resolve=self._resolve, prefix_bytes=self._prefix_bytes,
self_name=self._self_name, on_navigate=follow,
channels=self._channels,
channels=self._channels, type_of=self._type_of,
# The live feed itself (newest first), so the viewer keeps up with packets
# that arrive while it is open instead of freezing at this snapshot.
source=lambda: list(self._feed),
@@ -685,6 +689,7 @@ async def open_dashboard(ctx: "AppContext") -> None:
# Contacts first, every name the recorder ever overheard as the fallback — the
# app-wide rule that a node we can name never renders as a bare hash.
resolve = trace_runner.make_node_resolver(contacts, ctx.repo.node_names())
type_of = trace_runner.make_node_type_resolver(contacts)
prefix_bytes = await _routing_prefix_bytes(ctx)
window = ctx.repo.recent_observations(since=utcnow() - ACTIVITY_WINDOW)
@@ -699,6 +704,7 @@ async def open_dashboard(ctx: "AppContext") -> None:
prefix_bytes=prefix_bytes,
self_name=self_name,
channels=channels,
type_of=type_of,
)
unsubscribe = ctx.events.subscribe(screen.on_event)
+15 -20
View File
@@ -7,13 +7,12 @@ detail read together:
* a **graph** up top draws every distinct path the message took through the shared
route-graph widget (:mod:`~meshterm.ui.pathgraph`): the currently selected path
coloured by its reception SNR (the SNR palette), the unused paths gray beneath it.
The origin sits at the left, we sit at the right, and every relay in between gets its
own node-type marker (``▲`` repeater, …) plus the first byte of its hash — set straight
above or below the marker, in the mesh name's own colour, so the byte reads as that node
and never crowds the line running through it. A node-type key sits under the fan. The row
list carries the full names, so the graph's labels stay two cells wide and a
many-path graph stays readable.
white, the unused paths gray beneath it. The origin sits at the left, we sit at the
right, and every relay in between gets its own node-type marker (``▲`` repeater, …)
plus the first byte of its hash — set straight above or below the marker, in the mesh
name's own colour, so the byte reads as that node and never crowds the line running
through it. A node-type key sits under the fan. The row list carries the full names,
so the graph's labels stay two cells wide and a many-path graph stays readable.
* the **arrival list** beneath is one row per logged copy — time, reception SNR, and
the relay chain through the shared compact path widget, each named hop annotated
with the hash byte it is addressed by (``YUL-Poly (3d)``, the trace presentation);
@@ -36,7 +35,7 @@ from rich.text import Text
from ..core.models import ChatMessage
from ..services.message_paths import Arrival
from .pathgraph import PathLayer, render_path_graph
from .theme import snr_rgb, snr_style
from .theme import snr_style
from .tui.render import crop_cells, render_to_ansi
from .tui.screen import Screen
from .widgets import NodeResolver, TypeOf, node_type_legend, path_text, route_graph_style
@@ -44,8 +43,7 @@ from .widgets import NodeResolver, TypeOf, node_type_legend, path_text, route_gr
#: Cells one ←/→ press shifts the selected row by.
_HSTEP = 4
#: Edge colours: the selected path draws in its arrival's SNR hue (white when it carried no
#: reading) over the unused paths' gray.
#: Edge colours: the selected path draws white over the unused paths' gray.
_EDGE_SELECTED = (255, 255, 255)
_EDGE_UNUSED = (110, 110, 110)
@@ -175,7 +173,7 @@ class MessagePathsScreen(Screen):
lines.append("")
lines.extend(self._graph_lines(width))
caption = Text("origin → you · colour = SNR of selected · labels = hash byte",
caption = Text("origin → you · white = selected path · 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))
@@ -258,24 +256,21 @@ class MessagePathsScreen(Screen):
return seen
def _graph_lines(self, width: int) -> list[str]:
"""Draw every distinct path origin → us, the selected one in its SNR hue over gray.
"""Draw every distinct path origin → us, the selected one white over gray.
The shared route-graph widget does the layout (lanes fanned from the centre
in first-heard order, shared relays averaged together); this just maps each
distinct path to a :class:`~meshterm.ui.pathgraph.PathLayer` — the selected
one on top coloured by the selected arrival's reception SNR (the SNR palette,
white when it carried no reading), the rest gray beneath — and hands it the shared
route-graph callbacks (:func:`~meshterm.ui.widgets.route_graph_style`): endpoints
named, relays their own map marker where the type is known, each labelled by its
one white on top, the rest gray beneath — and hands it the shared route-graph
callbacks (:func:`~meshterm.ui.widgets.route_graph_style`): endpoints named,
relays their own map marker where the type is known, each labelled by its
first hash byte in the node's own hue.
"""
arrival = self._arrivals[self._index]
selected = arrival.hops
selected_color = snr_rgb(arrival.snr) if arrival.snr is not None else _EDGE_SELECTED
selected = self._arrivals[self._index].hops
layers = [
PathLayer(
hops=path,
color=selected_color if path == selected else _EDGE_UNUSED,
color=_EDGE_SELECTED if path == selected else _EDGE_UNUSED,
priority=3 if path == selected else 2,
)
for path in self._paths()
+118 -21
View File
@@ -6,9 +6,12 @@ class — and every row can open into the same viewer: a centered dialog over th
that lays the packet out in full, flavoured by kind. An advert shows the node's
identity, type, and location; telemetry shows the node and its reported values; an
RX-logged packet shows its parsed class and route plus the relay path it rode in on —
and, for an overheard channel-text frame naming a channel we hold the key for, the
decrypted text too (see :func:`~meshterm.core.channels.decrypt_channel_text`), even
though the radio itself never decoded it for us; a message shows the sender, the
as a ``via`` chain and, when it actually crossed a relay, as THE route graph
(:mod:`~meshterm.ui.pathgraph`): origin → relays → us, the same fan-lane picture the
Message paths dialog and the Trophy case draw — and, for an overheard channel-text frame
naming a channel we hold the key for, the decrypted text too (see
:func:`~meshterm.core.channels.decrypt_channel_text`), even though the radio itself never
decoded it for us; a message shows the sender, the
conversation, and the text; an ack shows its code. Common to all: the timestamp, the
node (name coloured by the app-wide palette, hash in the hash widget), reception
quality on the shared SNR bar, and any leftover raw field the flavoured layout doesn't
@@ -34,11 +37,20 @@ from rich.text import Text
from ..core.channels import decrypt_channel_text
from ..core.models import NODE_TYPE_LABELS, Observation
from ..services.trace_runner import NodeResolver
from .pathgraph import PathLayer, render_path_graph
from .theme import name_style, snr_style
from .trace_screen import snr_bar
from .tui.render import render_lines
from .tui.render import render_lines, render_to_ansi
from .tui.screen import Screen
from .widgets import _age_seconds, format_ago, highlighted_hash, path_text
from .widgets import (
TypeOf,
_age_seconds,
format_ago,
highlighted_hash,
node_type_legend,
path_text,
route_graph_style,
)
#: Friendly gloss for a raw packet's parsed payload class (mirrors the meshcore
#: library's own ``PAYLOAD_TYPENAMES``), shown on a ``packet`` entry's "class" row.
@@ -57,8 +69,8 @@ _PAYLOAD_GLOSS = {
"CONTROL": "control",
}
#: Raw-payload fields already folded into a flavoured row elsewhere in :meth:`_rows`
#: (frame plumbing parsed into "class"/"route", the channel crypto handled by
#: Raw-payload fields already folded into a flavoured row elsewhere (frame plumbing
#: parsed into "class"/"route", the channel crypto handled by
#: :meth:`PacketViewer._decrypt_rows`, or an advert field duplicating ``node``/
#: ``lat``/``lon``/etc.) — skipped so the generic dump doesn't repeat them.
_RAW_ROW_SKIP = frozenset({
@@ -93,6 +105,11 @@ KIND_ICONS = {
}
DEFAULT_ICON = "❔"
#: The colour a relayed packet's route draws in on THE route graph. It is the only path
#: on the canvas, so white just reads as "the route the packet rode" (the Trophy case's
#: single-walk convention).
_ROUTE_EDGE = (255, 255, 255)
@dataclass(slots=True)
class PacketEntry:
@@ -236,6 +253,7 @@ class PacketViewer(Screen):
on_navigate: Optional[Callable[[PacketEntry], None]] = None,
channels: Sequence[tuple[str, bytes]] = (),
source: Optional[Callable[[], Sequence[PacketEntry]]] = None,
type_of: Optional[TypeOf] = None,
) -> None:
"""Open the viewer over a packet list.
@@ -256,6 +274,9 @@ class PacketViewer(Screen):
keypress and re-locates the packet being viewed by identity, so packets
that arrive while the dialog is open become reachable (``↑`` walks up
into them) instead of the view being frozen at its opening snapshot.
type_of: Maps a relay hash to its node type, so a relayed packet's route
graph marks a repeater ``▲`` (etc.) instead of a generic dot; ``None``
keeps the plain named-dot / unknown-ring fallback.
"""
super().__init__()
self._entries = list(entries)
@@ -266,6 +287,7 @@ class PacketViewer(Screen):
self._on_navigate = on_navigate
self._channels = channels
self._source = source
self._type_of = type_of
#: The packet currently shown, tracked by identity so a live prepend to the
#: source (which shifts every index) never slides the view onto another packet.
self._current: Optional[PacketEntry] = (
@@ -355,34 +377,66 @@ class PacketViewer(Screen):
# --- rendering -------------------------------------------------------------
def render_body(self, width: int) -> list[str]:
"""Lay the current entry out as labelled rows, flavoured by its kind."""
"""Lay the current entry out as labelled rows, flavoured by its kind.
A relayed ``packet`` slots THE route graph (:mod:`~meshterm.ui.pathgraph`) between
its parsed detail (heard/from/class/via) and its extras (location/text/raw): the
via row names each hop precisely, the graph shows the same relay chain as a shape —
origin at the left, us at the right. The two label/value grids around it share one
label-lane width so their rows still line up across the picture.
"""
# Fold in any packets that arrived since the last paint, keeping the view on the
# same packet, so the title's ``n/total`` and the reachable range stay current.
self._sync()
entry = self._entries[self._index]
rows = self._rows(entry)
# The label lane is one fixed width for the whole grid so wrapped values align with
# their own block (the app-wide hanging-indent rule), never with column zero. Size it
# to the widest label actually present — a raw payload field's full name included, so
# none is clipped — plus a one-cell gutter, but never so wide it leaves the value
# column under 20 cells (a pathological key then ellipsises instead of crushing it).
head, tail = self._head_rows(entry), self._tail_rows(entry)
label_w = self._label_width(head + tail, width)
lines = self._grid_lines(head, width, label_w)
graph = self._graph_lines(entry, width)
if graph:
lines.append("")
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))
if tail:
lines.append("")
lines.extend(self._grid_lines(tail, width, label_w))
self._scroll_total = max(1, len(lines))
return lines
@staticmethod
def _label_width(rows: list[tuple[str, RenderableType]], width: int) -> int:
"""The shared label-lane width so wrapped values hang under their own block.
One fixed width for every grid on the card (the app-wide hanging-indent rule), never
column zero — sized to the widest label present (a raw payload field's full name
included, so none is clipped) plus a one-cell gutter, but never so wide it leaves the
value column under 20 cells (a pathological key then ellipsises instead of crushing it).
"""
widest = max((len(label) for label, _ in rows), default=0)
label_w = max(10, min(widest + 1, width - 20))
return max(10, min(widest + 1, width - 20))
@staticmethod
def _grid_lines(
rows: list[tuple[str, RenderableType]], width: int, label_w: int
) -> list[str]:
"""Render one label/value grid to ANSI lines (empty rows → no lines)."""
if not rows:
return []
grid = Table(
box=None, show_header=False, show_edge=False, pad_edge=False,
padding=(0, 0), expand=False,
)
grid.add_column(width=label_w, no_wrap=True)
grid.add_column(overflow="fold", max_width=max(20, width - label_w))
for label, value in rows:
grid.add_row(Text(label, style="muted"), value)
lines = render_lines(grid, width)
self._scroll_total = max(1, len(lines))
return lines
return render_lines(grid, width)
def _rows(self, entry: PacketEntry) -> list[tuple[str, RenderableType]]:
"""The labelled rows for one entry: the common core plus its kind's extras."""
def _head_rows(self, entry: PacketEntry) -> list[tuple[str, RenderableType]]:
"""The rows above the route graph: the common core plus a packet's parsed frame."""
rows: list[tuple[str, RenderableType]] = []
secs = _age_seconds(entry.when)
@@ -406,6 +460,11 @@ class PacketViewer(Screen):
rows.append(("snr", self._reception(entry)))
if entry.kind == "packet":
rows.extend(self._packet_rows(entry))
return rows
def _tail_rows(self, entry: PacketEntry) -> list[tuple[str, RenderableType]]:
"""The rows below the route graph: location, the message/ack fields, the raw dump."""
rows: list[tuple[str, RenderableType]] = []
if entry.lat is not None and entry.lon is not None:
rows.append(("location", Text(f"{entry.lat:.5f}, {entry.lon:.5f}")))
@@ -418,6 +477,44 @@ class PacketViewer(Screen):
rows.extend(self._raw_rows(entry))
return rows
def _graph_lines(self, entry: PacketEntry, width: int) -> list[str]:
"""Draw a relayed packet's origin → relays → us route on THE route graph.
Only a ``packet`` frame that actually crossed a relay draws one — a direct
arrival's ``via`` row (``direct — no relays``) already says all there is to say, so
a two-node graph would waste the height. The relay chain is the packet's path
(originator-nearest first), the left endpoint the origin when the frame named one
(an advert's ``adv_key``; other classes arrive origin-less, drawn ``?``), the right
endpoint always us — the same fan-lane widget the Message paths dialog and the
Trophy case draw, in a single white path.
"""
if entry.kind != "packet":
return []
hops = tuple(hop for hop in (entry.path or "").split(",") if hop)
if not hops:
return []
glyph_of, label_of, label_rgb_of = route_graph_style(
resolve=self._resolve, self_name=self._self_name,
source=self._graph_source(entry), type_of=self._type_of,
)
return render_path_graph(
[PathLayer(hops=hops, color=_ROUTE_EDGE, priority=3)],
width, glyph_of=glyph_of, label_of=label_of, label_rgb_of=label_rgb_of,
)
def _graph_source(self, entry: PacketEntry) -> Optional[str]:
"""The origin's display name for the graph's left endpoint, or ``None`` if unknown.
The naming rule the ``from`` row follows (a resolved contact wins, then the name the
frame carried), but a nameless origin returns ``None`` so the graph draws a plain
``?`` endpoint rather than passing a bare hash off as a named node.
"""
if entry.node:
resolved = self._resolve(entry.node)
if resolved and resolved != entry.node:
return resolved
return entry.name or None
def _reception(self, entry: PacketEntry) -> Text:
"""SNR (with the shared quality bar) and RSSI on one line."""
line = Text()
+10 -13
View File
@@ -40,7 +40,7 @@ from ..services.records import CATEGORIES, CATEGORY_BY_ID, Category, _local_xy
from .mapcanvas import RGB, MapCanvas
from .menus import back_rows, section_heading
from .pathgraph import PathLayer, render_path_graph
from .theme import name_style, snr_rgb, snr_style
from .theme import name_style, snr_style
from .tui.render import render_hanging, render_to_ansi
from .tui.screen import Screen
from .widgets import (
@@ -111,8 +111,8 @@ class RecordDialog(Screen):
history, the far point named with the node it reached — with the walk's enclosed area
drawn beside them on a braille mini-map (us at the origin, every positioned hop pinned
in its own name hue, no labels) when the terminal has the room; below, the walk on THE
route graph (us at both ends, coloured by its weakest link, relays wearing their map
marker over a node-type key), the route in full (wrapped, never truncated), and the
route graph (us at both ends, relays wearing their map marker over a node-type key),
the route in full (wrapped, never truncated), and the
record's provenance — when it was set and by which app version. The card scrolls
(PgUp/PgDn/Home/End) when it outgrows the frame, while the arrows drive the actions.
Two actions besides Back: *Trace this path* reopens Trace path with the record's route
@@ -216,14 +216,13 @@ class RecordDialog(Screen):
"""Draw the walked route as one path on THE route graph — us at both ends.
A scored walk leaves home and comes back, so it draws us (left) → its relays →
us (right) as a single path through the shared fan-lane widget
us (right) as a single white path through the shared fan-lane widget
(:func:`~meshterm.ui.pathgraph.render_path_graph`), the same shape the Message
paths dialog draws a delivery over. The path is coloured by the walk's weakest link
(the SNR palette), so the loop reads red when a hop barely carried; relays wear
their own map marker (``▲`` repeater, …) where the type is known. Nodes the walk
passed through more than once — a boomerang's mirrored return leg — collapse to
their first appearance: the depth-ordered graph can only seat a node once, and the
route line below still carries every hop, revisits and all.
paths dialog draws a delivery over. Relays wear their own map marker (``▲``
repeater, …) where the type is known. Nodes the walk passed through more than once
— a boomerang's mirrored return leg — collapse to their first appearance: the
depth-ordered graph can only seat a node once, and the route line below still
carries every hop, revisits and all.
"""
seen: set[str] = set()
hops: list[str] = []
@@ -237,10 +236,8 @@ class RecordDialog(Screen):
source=self._device_label,
type_of=self._type_of,
)
min_snr = self._record.stats.get("min_snr")
color = snr_rgb(min_snr) if min_snr is not None else _WALK_EDGE
return render_path_graph(
[PathLayer(hops=tuple(hops), color=color, priority=3)],
[PathLayer(hops=tuple(hops), color=_WALK_EDGE, priority=3)],
width,
glyph_of=glyph_of, label_of=label_of, label_rgb_of=label_rgb_of,
)
-15
View File
@@ -176,18 +176,3 @@ def snr_style(snr: float | None) -> str:
if snr >= -5:
return "snr.ok"
return "snr.bad"
#: The truecolour behind each :func:`snr_style` band, matching its ``snr.*`` theme hue, for
#: rasters that plot SNR directly (the route graph colouring a path by its link quality).
_SNR_RGB: dict[str, tuple[int, int, int]] = {
"snr.good": (74, 222, 128), # #4ade80
"snr.ok": (251, 191, 36), # #fbbf24
"snr.bad": (248, 113, 113), # #f87171
"muted": (148, 163, 184), # #94a3b8
}
def snr_rgb(snr: float | None) -> tuple[int, int, int]:
"""The ``(r, g, b)`` of an SNR reading's quality band (see :func:`snr_style`)."""
return _SNR_RGB[snr_style(snr)]
+7 -7
View File
@@ -49,7 +49,7 @@ def test_paths_screen_renders_graph_rows_and_cursor() -> None:
assert "Alice" in body and "Homestead" in body # origin and us, on the graph
assert body.count("via") == 2 # one row per arrival
assert "❯" in body
assert "colour = SNR of selected" in body # the graph caption
assert "white = selected path" in body # the graph caption
assert "★ you" in body and "▲ repeater" in body # the node-type legend
assert screen.cursor_line() is not None
@@ -85,15 +85,15 @@ def test_paths_screen_shows_unknown_relay_as_grey_mode_width_hash() -> None:
assert "e8" in graph # the row's byte still cross-references the graph label
def test_paths_screen_colours_selected_path_by_snr_over_gray() -> None:
"""The selected path's edges take its arrival's SNR hue; the unused path stays gray."""
screen = _screen(_arrivals()) # selected arrival's SNR is +4.0 dB → the "ok" band
def test_paths_screen_draws_selected_path_white_over_gray() -> None:
"""The selected path's edges render white; the unused path's edges gray."""
screen = _screen(_arrivals())
raw = "\n".join(screen.render_body(76)).split("origin →")[0]
assert "38;2;251;191;36" in raw # snr.ok amber — the selected path, by SNR
assert "38;2;255;255;255" in raw # the selected path, white
assert "38;2;110;110;110" in raw # the other path, gray beneath it
screen.handle("down") # select the weaker arrival (−2.0 dB, still "ok")
screen.handle("down") # move the selection to the other path
raw2 = "\n".join(screen.render_body(76)).split("origin →")[0]
assert "38;2;251;191;36" in raw2 # the newly selected path recolours
assert "38;2;255;255;255" in raw2 and "38;2;110;110;110" in raw2
def test_paths_screen_marks_a_repeater_relay_with_its_triangle() -> None:
+32
View File
@@ -139,3 +139,35 @@ def test_packet_viewer_shows_full_raw_field_labels() -> None:
})
body = _plain(_viewer(entry).render_body(80))
assert "battery_millivolts" in body # the 18-char key is not clipped to 8
def test_packet_viewer_draws_a_relayed_packets_route_graph() -> None:
"""A packet that crossed relays gets THE route graph — braille edges, caption, legend."""
entry = PacketEntry(when=utcnow(), kind="packet", path="3d63,a1b2")
body = _plain(_viewer(entry).render_body(80))
assert "origin → you" in body # the graph caption
assert "★ you" in body and "▲ repeater" in body # the node-type legend
assert any("⠀" <= ch <= "⣿" for ch in body) # braille edges are drawn
assert "3d" in body and "a1" in body # each relay labelled by its hash byte
def test_packet_viewer_skips_the_graph_for_a_direct_packet() -> None:
"""A packet with no relays says so in the via row and draws no (pointless) two-node graph."""
entry = PacketEntry(when=utcnow(), kind="packet", path="")
body = _plain(_viewer(entry).render_body(80))
assert "direct — no relays" in body
assert "origin → you" not in body
assert not any("⠀" <= ch <= "⣿" for ch in body)
def test_packet_viewer_graph_names_a_known_origin_else_a_question_mark() -> None:
"""The graph's left endpoint is the resolved origin name, or ``?`` when the frame named none."""
known = PacketEntry(when=utcnow(), kind="packet", node="c0ffee", path="3d63")
body = _plain(
PacketViewer([known], 0, resolve=lambda h: "Base" if h == "c0ffee" else "").render_body(80)
)
assert "Base" in body # the origin, resolved to its contact name
nameless = PacketEntry(when=utcnow(), kind="packet", path="3d63")
body2 = _plain(_viewer(nameless).render_body(80))
assert "?" in body2 # an origin-less flood draws a plain "?" endpoint