Node detail + live feed: route rows through the path-line widget

The Routes tab's rows are one PathLine end to end (chips where the
terminal draws them, the same characters where it doesn't), and a feed
row's via chain fits its lane by eliding middle hops behind a mark — the
origin and the last relay survive where the right edge used to eat them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Fable 5 committed 2026-07-26 20:31:05 -04:00
1 parent 719b1edce6
commit 823c772c6e
2 files changed
+31 -27

No files matched your search

+17 -11
View File
@@ -41,7 +41,8 @@ from .packet_viewer import (
from .theme import name_style, snr_style
from .tui.render import render_to_ansi
from .tui.screen import ListWindow, Screen
from .widgets import NameKeyResolver, TypeOf, path_text
from .pathline import path_line
from .widgets import NameKeyResolver, TypeOf
if TYPE_CHECKING:
from ..context import AppContext
@@ -275,21 +276,24 @@ class LiveFeedScreen(Screen):
if top > 0:
out.append(render_to_ansi(ListWindow.marker(top, "above"), width))
for i in range(top, top + count):
row = self._feed_row(entries[i], i == self._selected, show_label)
row = self._feed_row(entries[i], i == self._selected, show_label, width)
out.append(render_to_ansi(row, width, no_wrap=True))
below = len(entries) - top - count
if below > 0:
out.append(render_to_ansi(ListWindow.marker(below, "below"), width))
return out
def _feed_row(self, entry: PacketEntry, selected: bool, show_label: bool) -> Text:
def _feed_row(
self, entry: PacketEntry, selected: bool, show_label: bool, width: int
) -> Text:
"""Lay one feed row out in fixed lanes: time, class, node, reception, detail.
The class lane leads with its two-cell icon; the textual label beside it is
dropped wholesale on a narrow terminal (``show_label``), keeping the lanes
aligned either way. The node name takes the app-wide palette hue (our own
node white, a bare hash muted). Never wraps — a long relay path ellipsizes
at the right edge instead of spilling a lone ``dBm`` onto its own line.
node white, a bare hash muted). Never wraps — the detail lane gets whatever
width the fixed lanes leave (``width``), so a long relay path elides its
middle hops there instead of spilling a lone ``dBm`` onto its own line.
"""
row = Text(no_wrap=True, overflow="ellipsis")
row.append("▸ " if selected else " ", style="accent")
@@ -310,7 +314,7 @@ class LiveFeedScreen(Screen):
f" {entry.rssi:5.0f} dBm" if entry.rssi is not None else " " * 10,
style="muted",
)
note = self._feed_note(entry)
note = self._feed_note(entry, max(1, width - row.cell_len - 2))
if note is not None:
row.append(" ")
row.append_text(note)
@@ -342,21 +346,23 @@ class LiveFeedScreen(Screen):
return entry.where, "muted" # an ack's code, or any other stray context
return "—", "muted"
def _feed_note(self, entry: PacketEntry) -> Optional[Text]:
def _feed_note(self, entry: PacketEntry, budget: int) -> Optional[Text]:
"""The row's trailing detail: a packet's relay path, a message's conversation.
The path renders through the shared compact path widget, so a relayed frame's
``via`` chain reads the same here as in the packet viewer and the chat paths.
The path renders through the shared path widget in its compact flavour, fitted
to the ``budget`` the row's fixed lanes leave: a chain too long for the lane
elides its *middle* hops behind ``⋯``, so the origin and the last relay — the
ends a right-edge cut would amputate — always survive.
"""
if entry.kind == "packet" and entry.path is not None:
note = Text("via ", style="muted")
note.append_text(
path_text(
path_line(
entry.path.split(","),
self._resolve,
prefix_bytes=self._prefix_bytes,
self_name=self._self_name,
)
).ellipsized(max(1, budget - 4))
)
return note
if entry.kind == "message" and entry.where:
+14 -16
View File
@@ -81,6 +81,7 @@ from .pathgraph import (
)
from .theme import name_style, snr_style
from .tui.render import render_hanging, render_lines, render_to_ansi
from .pathline import PathHop, PathLine, path_line
from .tui.screen import CANCEL, ListWindow, Screen
from .widgets import (
_DEFAULT_GLYPH,
@@ -90,7 +91,6 @@ from .widgets import (
format_ago,
highlighted_hash,
node_type_legend,
path_text,
tab_strip,
)
@@ -1075,24 +1075,22 @@ def _route_line(
"""One route rendered as a full line: contact → relays → us, then its context and tag.
The whole route reads left to right in the graph's own direction (contact on the left, us
on the right), so the row and the drawn line cross-read. The contact and our own node
anchor the two ends in their own hues (the contact's key-derived, us the white ``you``);
the relays in between render through THE path widget (:func:`~meshterm.ui.widgets.path_text`)
at a 1-byte hash width, each ``name (3d)`` — the trace presentation. The bottleneck SNR
and sample count trail as muted context, and a ``★ best`` / ``device route`` tag marks the
winner and the firmware's learned route.
on the right), so the row and the drawn line cross-read. The line is one
:class:`~meshterm.ui.pathline.PathLine` — the contact and our own node anchoring the two
ends in their own hues (the contact's key-derived, us the white ``you``), the relays at a
1-byte hash width, each ``name (3d)`` — the trace presentation, as powerline chips where
the terminal can draw them. The bottleneck SNR and sample count trail as muted context,
and a ``★ best`` / ``device route`` tag marks the winner and the firmware's learned route.
"""
text = Text()
text.append(node_label, style=name_style(node_label, name_key))
relays = path_text(
relays = path_line(
list(reversed(hops_out)), resolve, prefix_bytes=1, self_name=self_name,
empty="", show_hash=True, hash_bytes=1,
show_hash=True, hash_bytes=1,
)
if relays.plain:
text.append(" → ", style="muted")
text.append_text(relays)
text.append(" → ", style="muted")
text.append(self_name or "us", style="you")
text = PathLine([
PathHop(node_label, key=name_key),
*relays.hops,
PathHop(self_name or "us", you=True),
]).text()
if weakest is not None:
text.append(" · weakest ", style="muted")
text.append(f"{weakest:+.1f} dB", style=snr_style(weakest))