Node detail: fold the vitals into an Info tab
The identity block was eating the stage's vertical budget on every tab. The pinned chrome shrinks to the one-line identity header + tab strip; the vitals rows (key, heard, packets, signal, where), the location preview, and the Open full map / Time machine actions all move into a new Info tab (replacing the Map tab — the preview now grows into whatever rows the tab spares). The Routes tab spends the freed lines on its graph and route list, and the strip costs a single line of air (the graph's own top padding provides it). Opening the full map from the page now also seeds the map's find filter with the node's name, so it opens centred on the node *and* lit among the rest — exactly as if the user had typed the find. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8193ac3823
commit
2d6e20ba2e
4 files changed
+178
-113
No files matched your search
@@ -80,6 +80,7 @@ class MapScreen(Screen):
|
||||
saved_view: Optional[tuple[float, float, int]] = None,
|
||||
on_view_change: Optional[Callable[[Viewport], None]] = None,
|
||||
view_fraction: float = DEFAULT_VIEW_FRACTION,
|
||||
find: str = "",
|
||||
) -> None:
|
||||
"""Create the map screen.
|
||||
|
||||
@@ -94,6 +95,9 @@ class MapScreen(Screen):
|
||||
the caller can persist it. Deduplicated — only actual changes fire it.
|
||||
view_fraction: Fraction of the nodes the default frame (and ``r`` reset) fits —
|
||||
the densest that many, so outliers don't dominate. See :meth:`geo.Viewport.fit`.
|
||||
find: A find query to open with, exactly as if the user had typed it — the
|
||||
matching nodes light and the rest dim (the node-detail page seeds its node's
|
||||
name here). Editable and Esc-clearable like any typed find; ``""`` = off.
|
||||
"""
|
||||
super().__init__()
|
||||
self.title = "Map"
|
||||
@@ -109,8 +113,9 @@ class MapScreen(Screen):
|
||||
self._last_saved = saved_view
|
||||
#: The live find-as-you-type node filter ("" = off). Every printable key lands
|
||||
#: here — the map binds no letters to actions — and rendering highlights the
|
||||
#: matching markers while dimming the rest.
|
||||
self._filter = ""
|
||||
#: matching markers while dimming the rest. A caller may seed it (``find``), which
|
||||
#: behaves exactly like a query the user had already typed.
|
||||
self._filter = find
|
||||
self._viewport: Optional[Viewport] = None
|
||||
self._size: tuple[int, int] = (0, 0) # (dot_w, dot_h) the viewport is built for
|
||||
# Ask the session to scrub the panel's right edge on the next paint (see
|
||||
@@ -513,6 +518,7 @@ async def open_map(
|
||||
markers: list[MapMarker],
|
||||
*,
|
||||
focus: Optional[tuple[float, float]] = None,
|
||||
find: Optional[str] = None,
|
||||
fraction: float = DEFAULT_VIEW_FRACTION,
|
||||
) -> None:
|
||||
"""Open the interactive full-screen map over ``markers`` and run until dismissed.
|
||||
@@ -528,6 +534,8 @@ async def open_map(
|
||||
is a transient peek: it deliberately wires no ``on_view_change``, so panning
|
||||
around it never overwrites that saved view and the Map tool still reopens
|
||||
where the user last left it.
|
||||
find: A find query to open with — the focused node's name, so it lights among the
|
||||
rest exactly as if the user had typed it. ``None`` opens with the find off.
|
||||
fraction: Fraction of the nodes the default view frames (see :class:`MapScreen`).
|
||||
|
||||
Raises:
|
||||
@@ -553,6 +561,7 @@ async def open_map(
|
||||
max_zoom,
|
||||
saved_view=(clamp_lat(lat), lon, min(13, max_zoom)),
|
||||
view_fraction=fraction,
|
||||
find=find or "",
|
||||
)
|
||||
else:
|
||||
screen = MapScreen(
|
||||
|
||||
@@ -4,18 +4,21 @@ Reached by pressing Enter on any contact in the Contacts list (see
|
||||
:mod:`~meshterm.ui.contacts_screen`). Where the list is one aligned row per node, this is
|
||||
the node itself, in full:
|
||||
|
||||
* **who it is** — its name in the node's own hue, its key with the routing hash lit, its
|
||||
type, when it was first and last heard, how many packets we've overheard, its reception
|
||||
SNR (median and best) and last RSSI, and where it sits — the fixed identity block pinned
|
||||
at the top of the page;
|
||||
* **who it is** — a one-line identity header (its type glyph, its name in the node's own
|
||||
hue, its type label), the only chrome pinned above the stage — so the stage keeps nearly
|
||||
the whole screen;
|
||||
* **a tabbed stage** below it — one full-height view at a time, switched with ``←→`` (or
|
||||
``Tab``/``Shift+Tab``) across a one-line tab strip (see
|
||||
:func:`~meshterm.ui.widgets.tab_strip`). Rather than stack the location preview and the
|
||||
route graph down one long scroll, each earns the whole stage:
|
||||
:func:`~meshterm.ui.widgets.tab_strip`). Rather than stack the vitals, the location
|
||||
preview, and the route graph down one long scroll, each view earns the whole stage:
|
||||
|
||||
* **Map** — a static basemap preview (see :class:`~meshterm.ui.minimap.MiniMap`) centred
|
||||
on the node with the rest of the mesh around it, shown when the node has advertised a
|
||||
location. Its ``Open full map`` action sits right under it.
|
||||
* **Info** — the node's vitals as labelled rows (its key with the routing hash lit, when
|
||||
it was first and last heard, how many packets we've overheard, its reception SNR and
|
||||
last RSSI, and where it sits), then — when the node has advertised a location — a
|
||||
static basemap preview (see :class:`~meshterm.ui.minimap.MiniMap`) centred on the node,
|
||||
grown to whatever rows the viewport spares. Its actions: ``Open full map`` (the full
|
||||
map opens centred here with its find filter seeded to this node, so it lights among
|
||||
the rest) and ``Time machine``.
|
||||
* **Routes** — the routes we've actually heard the node arrive over, drawn on the shared
|
||||
route graph (:mod:`~meshterm.ui.pathgraph`) node→us (the inbound direction the packets
|
||||
travelled, contact on the left, us on the right). Beneath the graph sits the *route
|
||||
@@ -29,19 +32,18 @@ the node itself, in full:
|
||||
(nothing transmits here — it opens the trace screen loaded with that path); when there
|
||||
is no route evidence to list, a ``🎯 Trace — auto route …`` action stands in.
|
||||
|
||||
* **the ways in** — the tab's action rows: ``Open full map`` on the Map tab plus the
|
||||
always-available ``Time machine`` (when the recorder holds history) and ``Back``. ``↑↓``
|
||||
moves the cursor through them, Enter commits, Esc backs to the list.
|
||||
* **the ways in** — each tab's action rows (``↑↓`` moves the cursor through them, Enter
|
||||
commits) and the shared ``Back`` closing every tab; Esc backs to the list.
|
||||
|
||||
The page never scrolls as one long strip. The identity block, the tab strip, and the stage
|
||||
are pinned; the stage sizes itself to the terminal (the route graph compresses its lanes
|
||||
before it would overflow) and a faint rule closes it under its caption, so the drawn view
|
||||
and the rows below read as separate bands. The route list scrolls *inside* the leftover
|
||||
rows with faint ``↑ n more`` / ``↓ n more`` edge markers — the app-wide windowed-list
|
||||
pattern (see :class:`~meshterm.ui.tui.screen.ListWindow`; the variable-height rows get
|
||||
their own fit here) — so the graph, the selection driving it, and the action rows share
|
||||
one screen however many routes a busy node has. ``PgUp/PgDn`` page the cursor through
|
||||
the window.
|
||||
The page never scrolls as one long strip. The identity header, the tab strip, and the
|
||||
stage are pinned; the stage sizes itself to the terminal (the route graph compresses its
|
||||
lanes before it would overflow, the location preview grows into what the Info tab spares)
|
||||
and a faint rule closes it, so the drawn view and the rows below read as separate bands.
|
||||
The route list scrolls *inside* the leftover rows with faint ``↑ n more`` / ``↓ n more``
|
||||
edge markers — the app-wide windowed-list pattern (see
|
||||
:class:`~meshterm.ui.tui.screen.ListWindow`; the variable-height rows get their own fit
|
||||
here) — so the graph, the selection driving it, and the action rows share one screen
|
||||
however many routes a busy node has. ``PgUp/PgDn`` page the cursor through the window.
|
||||
|
||||
The screen is a pure read-and-route view: it renders already-resolved display data and
|
||||
resolves an action token (the Trace token carrying the selected route's spec via
|
||||
@@ -95,8 +97,11 @@ if TYPE_CHECKING: # pragma: no cover - typing only
|
||||
#: Our own node's marker glyph and hue, matching the map/atlas star.
|
||||
_SELF_GLYPH = ("★", "#facc15")
|
||||
|
||||
#: How many character rows the inline location preview draws.
|
||||
_MAP_ROWS = 7
|
||||
#: The inline location preview's row bounds: it grows into whatever the Info tab's
|
||||
#: viewport spares (the vitals and action rows are short), floored so a cramped terminal
|
||||
#: still shows a recognisable neighbourhood and capped so a tall one doesn't become all map.
|
||||
_MAP_MIN_ROWS = 5
|
||||
_MAP_MAX_ROWS = 13
|
||||
|
||||
#: Route-graph tuning for the Routes tab. It draws the contact on the left and us on the
|
||||
#: right (node → us, so the graph reads left to right as the inbound direction its packets
|
||||
@@ -244,8 +249,8 @@ class _Tab:
|
||||
"""One tab in the stage's strip.
|
||||
|
||||
Attributes:
|
||||
name: The strip label (``Map`` / ``Routes``).
|
||||
kind: Which stage it draws (``map`` / ``routes``).
|
||||
name: The strip label (``Info`` / ``Routes``).
|
||||
kind: Which stage it draws (``info`` / ``routes``).
|
||||
"""
|
||||
|
||||
name: str
|
||||
@@ -264,8 +269,8 @@ class NodeDetailScreen(Screen):
|
||||
``Shift+Tab``) switches which view fills the stage, and ``↑↓`` moves the cursor *within*
|
||||
the active tab — through its route list (on the Routes tab, the selection drives the
|
||||
graph highlight and Enter arms a trace on the picked route) and action rows. The page
|
||||
itself never scrolls: the identity block, tab strip, and stage are pinned, the stage is
|
||||
sized to the viewport, and the route list windows itself into the leftover rows —
|
||||
itself never scrolls: the identity header, tab strip, and stage are pinned, the stage
|
||||
is sized to the viewport, and the route list windows itself into the leftover rows —
|
||||
``PgUp/PgDn`` page the cursor through it, ``Home/End`` jump it to the ends.
|
||||
"""
|
||||
|
||||
@@ -281,7 +286,7 @@ class NodeDetailScreen(Screen):
|
||||
minimap: Optional[MiniMap] = None,
|
||||
map_caption: Optional[Text] = None,
|
||||
routes: Optional[_RoutesView] = None,
|
||||
open_map_action: Optional[_Action] = None,
|
||||
info_actions: Optional[list[_Action]] = None,
|
||||
trace_action: Optional[_Action] = None,
|
||||
tail_actions: Optional[list[_Action]] = None,
|
||||
) -> None:
|
||||
@@ -290,19 +295,21 @@ class NodeDetailScreen(Screen):
|
||||
Args:
|
||||
title: The screen heading (``Node — <name>``).
|
||||
header: The identity line: type glyph, the coloured name, its type label.
|
||||
info_rows: ``(label, value)`` pairs for the fixed info block; each renders as
|
||||
a muted label lane with the value hanging under itself when it wraps.
|
||||
info_rows: ``(label, value)`` pairs for the Info tab's vitals block; each
|
||||
renders as a muted label lane with the value hanging under itself when it
|
||||
wraps.
|
||||
tabs: The stage tabs to offer, in strip order (empty = no stage, just actions).
|
||||
minimap: The inline location preview for the Map tab, or ``None``.
|
||||
minimap: The Info tab's inline location preview, or ``None`` (no advertised
|
||||
fix).
|
||||
map_caption: A faint line under the preview (its centre/scale), when a map shows.
|
||||
routes: The Routes tab's route list + graph callbacks (or a muted note), or
|
||||
``None`` when there is no Routes tab (we never overhear our own node).
|
||||
open_map_action: The Map tab's ``Open full map`` action, or ``None``.
|
||||
info_actions: The Info tab's action rows (Open full map when there is a fix,
|
||||
Time machine when the recorder holds history).
|
||||
trace_action: The Routes tab's ``Trace — auto route …`` action, shown only when
|
||||
there are no routes to list (with routes listed, Enter on a route row is the
|
||||
trace entry point), or ``None``.
|
||||
tail_actions: The always-available actions closing every tab (Time machine when
|
||||
there is history, then Back).
|
||||
tail_actions: The always-available actions closing every tab (Back).
|
||||
"""
|
||||
super().__init__()
|
||||
self.title = title
|
||||
@@ -312,7 +319,7 @@ class NodeDetailScreen(Screen):
|
||||
self._minimap = minimap
|
||||
self._map_caption = map_caption
|
||||
self._routes = routes
|
||||
self._open_map_action = open_map_action
|
||||
self._info_actions = info_actions or []
|
||||
self._trace_action = trace_action
|
||||
self._tail_actions = tail_actions or []
|
||||
self._tab_index = 0
|
||||
@@ -356,10 +363,10 @@ class NodeDetailScreen(Screen):
|
||||
return ""
|
||||
|
||||
def consume_edge_scrub(self) -> int:
|
||||
"""Scrub the panel's right edge only while the braille Map tab is the one showing."""
|
||||
"""Scrub the panel's right edge only while the Info tab is showing its braille map."""
|
||||
if self._minimap is None or not self._tabs:
|
||||
return 0
|
||||
return 2 if self._tabs[self._tab_index].kind == "map" else 0
|
||||
return 2 if self._tabs[self._tab_index].kind == "info" else 0
|
||||
|
||||
def handle(self, action: str, data: str = "") -> None:
|
||||
"""Switch tab, move the cursor within a tab, commit a row, page the list, or leave."""
|
||||
@@ -436,10 +443,10 @@ class NodeDetailScreen(Screen):
|
||||
def _focusables(self) -> list[tuple[str, object]]:
|
||||
"""The active tab's cursor stops: ``("path", route_idx)`` and ``("action", _Action)``.
|
||||
|
||||
The route rows come first (Routes tab only) — each is itself the trace entry point —
|
||||
with the auto-route Trace action standing in only when there are no routes to list;
|
||||
the Map tab leads with Open full map. The shared tail (Time machine, Back) closes
|
||||
every tab. A tab-less page (our own fix-less node) is just the tail.
|
||||
On the Routes tab the route rows come first — each is itself the trace entry
|
||||
point — with the auto-route Trace action standing in only when there are no routes
|
||||
to list; the Info tab offers its own actions (Open full map, Time machine). The
|
||||
shared tail (Back) closes every tab.
|
||||
"""
|
||||
tab = self._tabs[self._tab_index] if self._tabs else None
|
||||
focus: list[tuple[str, object]] = []
|
||||
@@ -447,8 +454,8 @@ class NodeDetailScreen(Screen):
|
||||
focus.extend(("path", i) for i in range(len(self._routes.routes)))
|
||||
if not self._routes.routes and self._trace_action is not None:
|
||||
focus.append(("action", self._trace_action))
|
||||
elif tab is not None and tab.kind == "map" and self._open_map_action is not None:
|
||||
focus.append(("action", self._open_map_action))
|
||||
elif tab is not None and tab.kind == "info":
|
||||
focus.extend(("action", a) for a in self._info_actions)
|
||||
focus.extend(("action", a) for a in self._tail_actions)
|
||||
return focus
|
||||
|
||||
@@ -458,11 +465,11 @@ class NodeDetailScreen(Screen):
|
||||
"""Render the pinned chrome, the sized-to-fit stage, and the windowed cursor rows.
|
||||
|
||||
The viewport the frame recorded (:meth:`~meshterm.ui.tui.screen.Screen.note_viewport`)
|
||||
is split three ways each paint: the pinned chrome (identity block, tab strip) and the
|
||||
action rows take their fixed lines first, the stage takes what it needs of the rest
|
||||
(the route graph's row ceiling shrinks to fit), and the route list windows itself
|
||||
into the leftover lines — so nothing here ever pushes the graph or the actions off
|
||||
the screen.
|
||||
is split three ways each paint: the pinned chrome (identity header, tab strip) and
|
||||
the action rows take their fixed lines first, the stage takes what it needs of the
|
||||
rest (the route graph's row ceiling shrinks to fit, the Info tab's location preview
|
||||
grows into what its rows spare), and the route list windows itself into the leftover
|
||||
lines — so nothing here ever pushes the graph or the actions off the screen.
|
||||
"""
|
||||
viewport = self._scroll_viewport
|
||||
focus = self._focusables()
|
||||
@@ -471,18 +478,11 @@ class NodeDetailScreen(Screen):
|
||||
self._cursor = None
|
||||
self._list_hidden = False
|
||||
|
||||
# -- pinned chrome: the identity block, then the tab strip.
|
||||
# -- pinned chrome: the identity header, then the tab strip. One line of air
|
||||
# follows the strip inside each stage (the route graph's own top padding, the
|
||||
# Info tab's leading blank) rather than here, so the strip never costs two.
|
||||
lines: list[str] = []
|
||||
lines.extend(render_lines(self._header, width))
|
||||
for label, value in self._info_rows:
|
||||
lines.extend(
|
||||
render_hanging(
|
||||
Text(f"{label:<{_LABEL_LANE}}", style="muted"),
|
||||
value,
|
||||
width,
|
||||
indent=_LABEL_LANE,
|
||||
)
|
||||
)
|
||||
if self._tabs:
|
||||
lines.append("")
|
||||
lines.extend(
|
||||
@@ -490,26 +490,32 @@ class NodeDetailScreen(Screen):
|
||||
tab_strip([t.name for t in self._tabs], self._tab_index), width, no_wrap=True
|
||||
)
|
||||
)
|
||||
lines.append("")
|
||||
|
||||
# The action rows are fixed chrome too — a leading blank, one line per row, a blank
|
||||
# setting Back apart — struck before the stage draws so it can size against them.
|
||||
# setting Back apart when rows precede it — struck before the stage draws so it can
|
||||
# size against them.
|
||||
actions = [payload for _kind, payload in focus if _kind == "action"]
|
||||
action_lines = 1 + len(actions) + (
|
||||
1 if any(a.key == "back" for a in actions if isinstance(a, _Action)) else 0
|
||||
1
|
||||
if len(actions) > 1
|
||||
and any(a.key == "back" for a in actions if isinstance(a, _Action))
|
||||
else 0
|
||||
)
|
||||
|
||||
# -- the stage, sized to what the viewport leaves, closed by a faint rule.
|
||||
route_blocks: list[list[str]] = []
|
||||
tab = self._tabs[self._tab_index] if self._tabs else None
|
||||
if tab is not None:
|
||||
if tab.kind == "map":
|
||||
lines.extend(self._map_stage(width))
|
||||
if tab.kind == "info":
|
||||
budget = viewport - len(lines) - action_lines - 1 # the rule's line
|
||||
lines.extend(self._info_stage(width, budget))
|
||||
else:
|
||||
route_blocks = [
|
||||
self._route_row_lines(route, i == self._row_index, width)
|
||||
for i, route in enumerate(self._routes.routes if self._routes else [])
|
||||
]
|
||||
if not route_blocks:
|
||||
lines.append("") # the bare note pays for its own air under the strip
|
||||
budget = viewport - len(lines) - action_lines - 1 # the rule's line
|
||||
lines.extend(self._routes_stage(width, budget, route_blocks))
|
||||
# The rule closes the stage, so the drawn view and the rows below it read as
|
||||
@@ -539,7 +545,7 @@ class NodeDetailScreen(Screen):
|
||||
base = len(route_blocks)
|
||||
for j, payload in enumerate(actions):
|
||||
assert isinstance(payload, _Action)
|
||||
if payload.key == "back":
|
||||
if payload.key == "back" and j > 0:
|
||||
lines.append("") # set the exit row apart, as the menus do
|
||||
selected = base + j == self._row_index
|
||||
if selected:
|
||||
@@ -580,12 +586,30 @@ class NodeDetailScreen(Screen):
|
||||
self._list_top = top
|
||||
return top, count
|
||||
|
||||
def _map_stage(self, width: int) -> list[str]:
|
||||
"""The location preview and its faint caption."""
|
||||
assert self._minimap is not None
|
||||
lines = list(self._minimap.render(width, _MAP_ROWS))
|
||||
if self._map_caption is not None:
|
||||
lines.extend(render_lines(self._map_caption, width, no_wrap=True))
|
||||
def _info_stage(self, width: int, budget: int) -> list[str]:
|
||||
"""The vitals block and, with a fix, the location preview grown to fit.
|
||||
|
||||
``budget`` is the viewport lines left for the whole stage; the vitals rows never
|
||||
truncate — it is the preview that flexes, taking whatever they and its caption
|
||||
leave, clamped to ``[_MAP_MIN_ROWS, _MAP_MAX_ROWS]``.
|
||||
"""
|
||||
lines: list[str] = [""] # the stage's one line of air under the strip
|
||||
for label, value in self._info_rows:
|
||||
lines.extend(
|
||||
render_hanging(
|
||||
Text(f"{label:<{_LABEL_LANE}}", style="muted"),
|
||||
value,
|
||||
width,
|
||||
indent=_LABEL_LANE,
|
||||
)
|
||||
)
|
||||
if self._minimap is not None:
|
||||
lines.append("")
|
||||
caption = 1 if self._map_caption is not None else 0
|
||||
rows = max(_MAP_MIN_ROWS, min(_MAP_MAX_ROWS, budget - len(lines) - caption))
|
||||
lines.extend(self._minimap.render(width, rows))
|
||||
if self._map_caption is not None:
|
||||
lines.extend(render_lines(self._map_caption, width, no_wrap=True))
|
||||
return lines
|
||||
|
||||
def _routes_stage(
|
||||
@@ -931,25 +955,26 @@ async def open_node_detail(ctx: "AppContext", contact: Optional["Contact"]) -> N
|
||||
name_key=key,
|
||||
)
|
||||
|
||||
# -- the tabs (only the views that have content) and their action rows.
|
||||
tabs: list[_Tab] = []
|
||||
if minimap is not None:
|
||||
tabs.append(_Tab(name="Map", kind="map"))
|
||||
# -- the tabs (Info always; Routes only when there is a routes view) and their actions.
|
||||
tabs: list[_Tab] = [_Tab(name="Info", kind="info")]
|
||||
if routes_view is not None:
|
||||
tabs.append(_Tab(name="Routes", kind="routes"))
|
||||
|
||||
open_map_action = _Action("map", "🌍", "", "Open full map") if minimap is not None else None
|
||||
info_actions: list[_Action] = []
|
||||
if minimap is not None:
|
||||
info_actions.append(_Action("map", "🌍", "", "Open full map"))
|
||||
if you:
|
||||
info_actions.append(_Action("timemachine", "⏳", "", "Time machine — your activity"))
|
||||
elif hn is not None:
|
||||
info_actions.append(
|
||||
_Action("timemachine", "⏳", "", f"Time machine — {hn.count} receptions")
|
||||
)
|
||||
# With routes listed, each route row is its own trace entry point (Enter arms it); the
|
||||
# dedicated action only stands in when there is no route evidence to list.
|
||||
trace_action: Optional[_Action] = None
|
||||
if not you and node_id and not (routes_view is not None and routes_view.routes):
|
||||
trace_action = _Action("trace", "🎯", "", "Trace — auto route …")
|
||||
tail_actions: list[_Action] = []
|
||||
if you:
|
||||
tail_actions.append(_Action("timemachine", "⏳", "", "Time machine — your activity"))
|
||||
elif hn is not None:
|
||||
tail_actions.append(_Action("timemachine", "⏳", "", f"Time machine — {hn.count} receptions"))
|
||||
tail_actions.append(_Action("back", "", "", "Back"))
|
||||
tail_actions = [_Action("back", "", "", "Back")]
|
||||
|
||||
title = f"Node — {label}" if not you else f"Node — {label} (you)"
|
||||
while True:
|
||||
@@ -961,7 +986,7 @@ async def open_node_detail(ctx: "AppContext", contact: Optional["Contact"]) -> N
|
||||
minimap=minimap,
|
||||
map_caption=map_caption,
|
||||
routes=routes_view,
|
||||
open_map_action=open_map_action,
|
||||
info_actions=info_actions,
|
||||
trace_action=trace_action,
|
||||
tail_actions=tail_actions,
|
||||
)
|
||||
@@ -973,9 +998,17 @@ async def open_node_detail(ctx: "AppContext", contact: Optional["Contact"]) -> N
|
||||
elif action == "map":
|
||||
if markers:
|
||||
# Open centred on this node — the very spot the inline preview showed —
|
||||
# not wherever the global map was last left. (The map action only exists
|
||||
# when the node has a fix, so lat/lon are set here.)
|
||||
await open_map(ctx, markers, focus=(lat, lon))
|
||||
# not wherever the global map was last left — with the find filter seeded
|
||||
# to it, so this node lights among the rest. Seed only when its label
|
||||
# actually matches a marker; a needle nothing matches would dim everything.
|
||||
# (The map action only exists when the node has a fix, so lat/lon are set.)
|
||||
needle = label.casefold()
|
||||
await open_map(
|
||||
ctx,
|
||||
markers,
|
||||
focus=(lat, lon),
|
||||
find=label if any(needle in m.label.casefold() for m in markers) else None,
|
||||
)
|
||||
elif action == "timemachine":
|
||||
if you:
|
||||
await open_timemachine_self(ctx)
|
||||
|
||||
+20
-1
@@ -686,11 +686,17 @@ async def test_open_map_focus_centres_on_the_node_without_clobbering_the_saved_v
|
||||
|
||||
session = _CapturingSession(80, 24, keys=("right", "pageup")) # pan + zoom the peek
|
||||
ctx.ui = TuiUi(session)
|
||||
await open_map(ctx, [MapMarker("Hub", 45.5, -73.6, is_repeater=True)], focus=(45.5, -73.6))
|
||||
await open_map(
|
||||
ctx,
|
||||
[MapMarker("Hub", 45.5, -73.6, is_repeater=True)],
|
||||
focus=(45.5, -73.6),
|
||||
find="Hub",
|
||||
)
|
||||
|
||||
# Opened on the node, at the detail preview's zoom (min(13, max_zoom)).
|
||||
assert session.screen._saved_view == (clamp_lat(45.5), -73.6, 13)
|
||||
assert session.screen._on_view_change is None # a focused peek wires no persistence
|
||||
assert session.screen._filter == "Hub" # the find opens seeded to the focused node
|
||||
# Panning/zooming the peek left the global 'where you left the map' view untouched.
|
||||
assert ctx.repo.get_map_view() == pytest.approx((10.0, 20.0, 8))
|
||||
assert session.repainted # cleaned the terminal on the way out, like the plain open
|
||||
@@ -717,6 +723,19 @@ async def test_open_map_without_focus_restores_and_persists_the_global_view(
|
||||
assert zoom == 12 and lon > -71.20 # the eastward pan persisted back to the global view
|
||||
|
||||
|
||||
def test_map_screen_seeded_find_behaves_like_a_typed_one() -> None:
|
||||
"""A seeded find matches, titles, and clears exactly as if the user had typed it."""
|
||||
from meshterm.ui.map_render import MapMarker
|
||||
from meshterm.ui.map_screen import MapScreen
|
||||
|
||||
markers = [MapMarker("Hub", 45.5, -73.6), MapMarker("Far", 45.6, -73.5)]
|
||||
screen = MapScreen(_StubSession(80, 24), markers, _StubSource(), 14, find="Hub")
|
||||
assert [m.label for m in screen._matches()] == ["Hub"] # only the seed's node lights
|
||||
assert "find: Hub" in screen.footer_hint # the query shows, editable, as ever
|
||||
screen.handle("escape") # first Esc clears the find (not the map)
|
||||
assert screen._filter == "" and len(screen._matches()) == 2
|
||||
|
||||
|
||||
def test_map_screen_scrubs_right_edge_after_move() -> None:
|
||||
"""A move asks the session to scrub the right edge once, to clear any braille smear."""
|
||||
from meshterm.ui.map_render import MapMarker
|
||||
|
||||
+29
-25
@@ -398,7 +398,7 @@ def _header() -> Text:
|
||||
|
||||
|
||||
def _screen(**over) -> NodeDetailScreen:
|
||||
"""A node detail screen over hand-built display data (a Routes tab with a bare note)."""
|
||||
"""A node detail screen over hand-built display data (Info + a bare-note Routes tab)."""
|
||||
kwargs = dict(
|
||||
title="Node — Hub",
|
||||
header=_header(),
|
||||
@@ -407,31 +407,34 @@ def _screen(**over) -> NodeDetailScreen:
|
||||
("heard", Text("5m ago")),
|
||||
("packets", Text("42")),
|
||||
],
|
||||
tabs=[_Tab("Routes", "routes")],
|
||||
tabs=[_Tab("Info", "info"), _Tab("Routes", "routes")],
|
||||
minimap=None,
|
||||
map_caption=None,
|
||||
routes=_RoutesView(note="no route observed yet — trace to discover one"),
|
||||
open_map_action=None,
|
||||
info_actions=[_Action("timemachine", "⏳", "", "Time machine — 42 receptions")],
|
||||
trace_action=_Action("trace", "🎯", "", "Trace — auto route …"),
|
||||
tail_actions=[
|
||||
_Action("timemachine", "⏳", "", "Time machine — 42 receptions"),
|
||||
_Action("back", "", "", "Back"),
|
||||
],
|
||||
tail_actions=[_Action("back", "", "", "Back")],
|
||||
)
|
||||
kwargs.update(over)
|
||||
return NodeDetailScreen(**kwargs)
|
||||
|
||||
|
||||
def test_node_detail_screen_renders_its_sections() -> None:
|
||||
"""The page shows identity, info, the active tab, its stage, and the action rows."""
|
||||
"""The Info tab carries the vitals and its actions; Routes carries the stage + Trace."""
|
||||
screen = _screen()
|
||||
screen.note_viewport(30)
|
||||
body = _plain(screen.render_body(72))
|
||||
assert "Hub" in body and "repeater" in body # identity
|
||||
assert "42" in body # a packet tally from the info block
|
||||
assert "── Routes ──" in body and "no route observed yet" in body # the tab + its stage
|
||||
assert "Trace" in body and "Time machine" in body and "Back" in body
|
||||
assert "Hub" in body and "repeater" in body # the pinned identity header
|
||||
assert "── Info ──" in body and "42" in body # the vitals moved into the Info tab
|
||||
assert "Time machine" in body and "Back" in body # the Info actions + shared tail
|
||||
assert "────────" in body # the faint rule closing the stage
|
||||
assert "no route observed yet" not in body # the Routes stage waits on its own tab
|
||||
|
||||
screen.handle("right")
|
||||
body = _plain(screen.render_body(72))
|
||||
assert "── Routes ──" in body and "no route observed yet" in body
|
||||
assert "Trace" in body and "Back" in body
|
||||
assert "packets" not in body # the vitals stay on the Info tab
|
||||
# Every rendered line fits the 72-column standard.
|
||||
for line in screen.render_body(72):
|
||||
assert len(_plain([line])) <= 72
|
||||
@@ -447,10 +450,11 @@ def test_node_detail_screen_cursor_and_commit() -> None:
|
||||
assert screen.cursor_line() is None # nothing rendered yet
|
||||
screen.note_viewport(30)
|
||||
screen.render_body(72)
|
||||
# The cursor opens on the first row (the Trace action) and is always reported, so the
|
||||
# frame can keep it visible on a terminal too short for the pinned layout.
|
||||
# The cursor opens on the Info tab's first row (Time machine) and is always reported,
|
||||
# so the frame can keep it visible on a terminal too short for the pinned layout.
|
||||
assert screen.cursor_line() is not None
|
||||
screen.handle("down") # onto "Time machine"
|
||||
screen.handle("down") # onto Back
|
||||
screen.handle("up") # and back onto Time machine
|
||||
screen.render_body(72)
|
||||
screen.handle("enter")
|
||||
assert resolved == ["timemachine"]
|
||||
@@ -467,7 +471,6 @@ def test_node_detail_back_row_leaves_like_escape() -> None:
|
||||
screen.resolve = lambda value: resolved.append(value) # type: ignore[method-assign]
|
||||
|
||||
screen.render_body(72)
|
||||
screen.handle("down") # Trace -> Time machine
|
||||
screen.handle("down") # Time machine -> Back
|
||||
screen.handle("enter")
|
||||
assert resolved == [CANCEL]
|
||||
@@ -488,7 +491,7 @@ def _two_routes() -> _RoutesView:
|
||||
|
||||
def test_node_detail_screen_route_selection_arms_the_trace() -> None:
|
||||
"""↑/↓ over the route rows moves the graph highlight and the spec a trace would arm on."""
|
||||
screen = _screen(routes=_two_routes())
|
||||
screen = _screen(routes=_two_routes(), tabs=[_Tab("Routes", "routes")])
|
||||
# Focusables: route 0, route 1, Time machine, Back — with routes listed, the rows are
|
||||
# the trace entry points, so no dedicated Trace action row renders.
|
||||
assert screen.selected_spec() == "3d,f2,3d"
|
||||
@@ -504,7 +507,7 @@ def test_node_detail_screen_route_selection_arms_the_trace() -> None:
|
||||
|
||||
def test_node_detail_enter_on_a_route_row_opens_its_trace() -> None:
|
||||
"""Enter on any route row arms a trace on that route — no separate Trace row needed."""
|
||||
screen = _screen(routes=_two_routes())
|
||||
screen = _screen(routes=_two_routes(), tabs=[_Tab("Routes", "routes")])
|
||||
resolved: list = []
|
||||
screen.resolve = lambda value: resolved.append(value) # type: ignore[method-assign]
|
||||
screen.handle("down") # onto route 1
|
||||
@@ -524,13 +527,13 @@ def test_node_detail_route_list_windows_inside_the_page() -> None:
|
||||
label_of=lambda n: n[:2],
|
||||
label_rgb_of=lambda n: (200, 200, 200),
|
||||
)
|
||||
screen = _screen(routes=routes)
|
||||
screen = _screen(routes=routes, tabs=[_Tab("Routes", "routes")])
|
||||
screen.note_viewport(30)
|
||||
lines = screen.render_body(72)
|
||||
assert len(lines) <= 30 # the body fits the viewport — nothing scrolls off
|
||||
body = _plain(lines)
|
||||
assert "↓" in body and "more" in body # the edge marker counts the hidden routes
|
||||
assert "Time machine" in body and "Back" in body # the pinned actions stay
|
||||
assert "Back" in body # the pinned tail never leaves
|
||||
assert "PgUp/PgDn scroll" in screen.footer_hint # paging advertised only when needed
|
||||
|
||||
# Walking the cursor to the last route slides the window down to keep it visible.
|
||||
@@ -559,24 +562,25 @@ def test_node_detail_screen_tabs_switch_the_stage() -> None:
|
||||
markers=[MapMarker(label="Hub", lat=45.5, lon=-73.6, key="3d63aa")],
|
||||
)
|
||||
screen = _screen(
|
||||
tabs=[_Tab("Map", "map"), _Tab("Routes", "routes")],
|
||||
minimap=mini,
|
||||
map_caption=Text("Hub · centred here", style="faint"),
|
||||
)
|
||||
screen.note_viewport(30)
|
||||
assert "←→ tab" in screen.footer_hint # two tabs, so the switch is advertised
|
||||
# Opens on the Map tab: its preview and caption show, and its braille edge gets scrubbed.
|
||||
# Opens on the Info tab: the vitals, the located preview's caption, and its braille
|
||||
# edge scrub all belong to it.
|
||||
body = _plain(screen.render_body(72))
|
||||
assert "── Map ──" in body and "centred here" in body
|
||||
assert "── Info ──" in body and "centred here" in body
|
||||
assert screen.consume_edge_scrub() == 2
|
||||
|
||||
screen.handle("right") # switch to the Routes tab
|
||||
body = _plain(screen.render_body(72))
|
||||
assert "── Routes ──" in body and "no route observed yet" in body
|
||||
assert screen.consume_edge_scrub() == 0 # the map isn't the showing tab now
|
||||
assert screen.consume_edge_scrub() == 0 # the braille preview isn't showing now
|
||||
|
||||
|
||||
def test_node_detail_single_tab_hides_the_switch_hint() -> None:
|
||||
"""A page with only one view drops the ←→ tab atom from its footer."""
|
||||
screen = _screen() # a lone Routes tab
|
||||
screen = _screen(tabs=[_Tab("Info", "info")]) # our own node: no Routes tab
|
||||
assert "←→ tab" not in screen.footer_hint
|
||||
assert "↑↓ move" in screen.footer_hint and screen.footer_hint.endswith("Esc back")
|
||||
Reference in new issue
Block a user