Node detail: flatten unselected tabs into a continuous underline

Only the active tab now breaks the bottom rule (up, across open, back
down); inactive tabs sit flush against it with no corners or seams of
their own, so they read as behind/in-the-dark rather than each having
their own raised box. Top border and its z-order layering (active tab
always wins both corners) are unchanged. Adds a 2-column left margin
when the width has slack for it.

Tab switching moves off the shared Left/Right handler onto Tab/Shift+Tab
only, freeing the arrow keys for other use on this screen.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Sonnet 5 committed 2026-07-26 13:53:02 -04:00
1 parent 76125f7402
commit d1c2df61c9
3 files changed
+81 -44

No files matched your search

+7 -8
View File
@@ -7,8 +7,8 @@ the node itself, in full:
* **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 boxed tab strip (see
* **a tabbed stage** below it — one full-height view at a time, switched with
``Tab``/``Shift+Tab`` across a boxed tab strip (see
: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:
@@ -267,9 +267,8 @@ class NodeDetailScreen(Screen):
action's token for the opener to act on (a Trace token is paired with
:meth:`selected_spec`); Esc resolves :data:`CANCEL` to leave.
Two axes of navigation, matching the app's spatial feel: ``←→`` (or ``Tab`` /
``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
Two axes of navigation, matching the app's spatial feel: ``Tab``/``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 header, tab strip, and stage are pinned, the stage
is sized to the viewport, and the route list windows itself into the leftover rows —
@@ -346,7 +345,7 @@ class NodeDetailScreen(Screen):
"""Tab switch (when there are tabs to switch), move, open, list paging, Esc last."""
parts: list[str] = []
if len(self._tabs) >= 2:
parts.append("←→ tab")
parts.append("Tab/⇧Tab switch")
parts.extend(("↑↓ move", "Enter open"))
if self._list_hidden:
parts.append("PgUp/PgDn scroll")
@@ -388,9 +387,9 @@ class NodeDetailScreen(Screen):
# CANCEL the opener's loop breaks on, not a "back" token the loop would
# ignore and re-show the page over.
self.resolve(CANCEL if payload.key == "back" else payload.key)
elif action in ("right", "tab"):
elif action == "tab":
self._switch_tab(1)
elif action in ("left", "shift_tab"):
elif action == "shift_tab":
self._switch_tab(-1)
elif action == "up":
if n:
+48 -28
View File
@@ -910,22 +910,30 @@ def node_type_legend(indent: str = "") -> Text:
def tab_strip(labels: Sequence[str], active: int, width: int) -> Group:
"""A boxed tab strip: every tab always boxed, the active one lit on top of the rest.
"""A boxed tab strip: every tab always boxed on top, the active one open into the page.
THE navigation header for a screen that pages one full-height view at a time between a
handful of named views (the node detail page's ``Info`` / ``Routes``) instead of stacking
them. Every tab is always drawn as a full box — muted by default, accent when active —
instead of only the active one; this keeps every tab's width fixed regardless of which
is selected, so switching tabs never shifts the labels that come after it. Tabs share a
vertical between neighbours (one glyph, not two), and each shared corner is drawn as if
the tab to the left sits on top of the tab to the right: the corner "opens" (rounds
them. Every tab is always drawn as a full-topped box — muted by default, accent when
active — instead of only the active one; this keeps every tab's width fixed regardless
of which is selected, so switching tabs never shifts the labels that come after it. Tabs
share a vertical between neighbours (one glyph, not two), and each shared *top* corner is
drawn as if the tab to the left sits on top of the tab to the right: it "opens" (rounds
toward the tab starting there) only at the very first tab and at the active tab's own
left edge, and "closes" (rounds back, ceding the position to the tab on its left)
everywhere else — so the active tab is the one exception that always wins both of its
corners, reading as lifted in front of its neighbours. A lone tab collapses to the plain
accent heading (:func:`~meshterm.ui.menus.section_heading`'s ``── Label ──`` form) since
there is nothing to switch between or layer. The owning screen switches the active index
(``←→``, with ``Tab``/``Shift+Tab`` as a backup); the strip itself is pure presentation.
everywhere else — so the active tab is the one exception that always wins both of its top
corners, reading as lifted in front of its neighbours.
The *bottom* border is a single continuous rule the inactive tabs sit flush against —
they get no corners or seams of their own down there, just plain muted line passing
behind them — broken only under the active tab, which is why it reads as merged into the
page below it: the rule steps up into ``╰``, leaves the active tab's width open (no
line — that gap *is* the page starting), then steps back down through ``╯`` and carries
on flat. A lone tab collapses to the plain accent heading
(:func:`~meshterm.ui.menus.section_heading`'s ``── Label ──`` form) since there is
nothing to switch between or layer. When there's slack in ``width``, the whole strip
sits two columns in from the left rather than flush against it. The owning screen
switches the active index (``Tab``/``Shift+Tab``); the strip itself is pure presentation.
Args:
labels: The tab names in display order.
@@ -934,7 +942,7 @@ def tab_strip(labels: Sequence[str], active: int, width: int) -> Group:
Returns:
A :class:`~rich.console.Group` of one line (a lone tab, or none) or three (the shared
top border, the boxed labels, and the shared bottom border).
top border, the boxed labels, and the shared bottom rule).
"""
if not labels:
return Group(Text(""))
@@ -943,31 +951,43 @@ def tab_strip(labels: Sequence[str], active: int, width: int) -> Group:
n = len(labels)
inner = [f" {label} " for label in labels]
content_width = sum(len(cell) for cell in inner) + (n + 1)
margin = 2 if content_width + 2 <= width else 0
pad = " " * margin
def owner(junction: int) -> int:
"""Which tab's corner glyph sits at this junction — see the docstring's layering rule."""
def top_owner(junction: int) -> int:
"""Which tab's top corner glyph sits at this junction — see the docstring's rule."""
return junction if junction == 0 or junction == active else junction - 1
def corner_style(junction: int) -> str:
return "accent" if owner(junction) == active else "muted"
def top_style(junction: int) -> str:
return "accent" if top_owner(junction) == active else "muted"
top = Text(no_wrap=True)
mid = Text(no_wrap=True)
bot = Text(no_wrap=True)
def bot_glyph(junction: int) -> tuple[str, str]:
"""The bottom rule's glyph at this junction: an accent step around the active tab,
else a flat muted pass-through — see the docstring's continuous-rule rule."""
if junction == active:
return "╰", "accent"
if junction == active + 1:
return "╯", "accent"
return "─", "muted"
top = Text(pad, no_wrap=True)
mid = Text(pad, no_wrap=True)
bot = Text(pad, no_wrap=True)
for i, label in enumerate(labels):
opens = i == 0 or i == active
style = corner_style(i)
top.append("╭" if opens else "╮", style=style)
mid.append("│", style=style)
bot.append("╰" if opens else "╯", style=style)
top.append("╭" if opens else "╮", style=top_style(i))
mid.append("│", style=top_style(i))
glyph, style = bot_glyph(i)
bot.append(glyph, style=style)
tab_style = "accent" if i == active else "muted"
top.append("─" * len(inner[i]), style=tab_style)
mid.append(inner[i], style=tab_style)
bot.append("─" * len(inner[i]), style=tab_style)
last_style = corner_style(n)
top.append("╮", style=last_style)
mid.append("│", style=last_style)
bot.append("╯", style=last_style)
bot.append(" " * len(inner[i]) if i == active else "─" * len(inner[i]), style=tab_style)
top.append("╮", style=top_style(n))
mid.append("│", style=top_style(n))
glyph, style = bot_glyph(n)
bot.append(glyph, style=style)
bot.append("─" * max(0, width - len(bot.plain)), style="muted")
return Group(top, mid, bot)
+26 -8
View File
@@ -124,16 +124,27 @@ def test_signal_row_summarizes_snr_and_rssi() -> None:
# --- the tab strip --------------------------------------------------------------
def test_tab_strip_boxes_every_tab_and_lights_the_active_one() -> None:
"""Every tab is always boxed; only the active tab's corners and fill read as lit."""
def test_tab_strip_boxes_every_tab_on_top_and_lights_the_active_one() -> None:
"""Every tab is boxed across its top; only the active tab's corners/fill read as lit."""
group = tab_strip(["Map", "Routes"], 1, width=20)
top, mid, bot = group.renderables
assert mid.plain == "│ Map │ Routes │" # both tabs boxed, sharing one vertical
assert top.plain == "╭───────╭──────────╮" # active tab's left corner opens (wins the seam)
assert bot.plain == "╰───────╰──────────╯" # mirrored on the bottom border
assert len(top.plain) == len(mid.plain) == len(bot.plain) == 20 # no fill needed yet
def test_tab_strip_bottom_is_a_continuous_rule_notched_at_the_active_tab() -> None:
"""The bottom border is flat under inactive tabs and opens only under the active one."""
group = tab_strip(["Map", "Routes"], 1, width=20)
_, _, bot = group.renderables
# flat rule under "Map" (no corner of its own), then the notch opens/closes around
# "Routes" — up into the box, blank across its width (open into the page), back down.
assert bot.plain == "────────╰ ╯"
_, _, bot_first = tab_strip(["Map", "Routes"], 0, width=20).renderables
assert bot_first.plain == "╰ ╯───────────" # notch now sits under the first tab
def test_tab_strip_labels_hold_position_across_the_active_index() -> None:
"""Selecting a different tab only relights corners — no label ever shifts column."""
mid_first = tab_strip(["Map", "Routes"], 0, width=20).renderables[1]
@@ -144,12 +155,19 @@ def test_tab_strip_labels_hold_position_across_the_active_index() -> None:
def test_tab_strip_rule_fills_out_to_the_render_width() -> None:
"""The closing rule under the strip extends to the full render width."""
"""The bottom rule extends to the full render width, margin included."""
_, _, bot = tab_strip(["Map", "Routes"], 1, width=25).renderables
assert bot.plain == "╰───────╰──────────╯─────" # 20 chars of box/rule, then 5 chars filler
# 2-column left margin (there's room), then the 20-cell strip, then 3 cells of filler.
assert bot.plain == " ────────╰ ╯───"
assert len(bot.plain) == 25
def test_tab_strip_skips_the_margin_when_there_is_no_room() -> None:
"""The two-column left margin only appears when the width has slack for it."""
top, _, _ = tab_strip(["Map", "Routes"], 1, width=20).renderables
assert top.plain.startswith("╭") # width 20 == the strip's natural width, no slack
def test_tab_strip_collapses_a_lone_tab_to_a_plain_heading() -> None:
"""A single tab renders as the plain accent heading, no box needed."""
(lone,) = tab_strip(["Routes"], 0, width=40).renderables
@@ -454,7 +472,7 @@ def test_node_detail_screen_renders_its_sections() -> None:
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")
screen.handle("tab")
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
@@ -590,14 +608,14 @@ def test_node_detail_screen_tabs_switch_the_stage() -> None:
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
assert "Tab/⇧Tab switch" in screen.footer_hint # two tabs, so the switch is advertised
# 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 "│ Info │" in body and "centred here" in body
assert screen.consume_edge_scrub() == 2
screen.handle("right") # switch to the Routes tab
screen.handle("tab") # 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 braille preview isn't showing now