Grow-only dialogs, full raw labels, node rhythm in 15-min slices

Carried over from the last punch-list pass: the packet viewer opts into
a grow-only floating dialog (the box ratchets to its tallest body and
blank-pads shorter ones, so paging never re-centres it); raw payload
field names are shown whole by widening the label lane instead of
clipping at eight chars; the Time Machine node rhythm matches the mesh
page — 96 fifteen-minute slices sharing the Volume gutter — and its
time axis shortens marks to bare dates on multi-day windows; Courier
and Watchtower gain a visible Back exit beside Esc.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 4.8 committed 2026-07-12 03:25:15 -04:00
1 parent dfc4cb9845
commit 70efb7c694
10 files changed
+200 -56

No files matched your search

+21 -7
View File
@@ -98,13 +98,17 @@ def test_packet_viewer_without_a_source_stays_a_snapshot() -> None:
assert viewer.footer_hint == "Esc close"
def test_packet_viewer_holds_a_minimum_height() -> None:
"""A short packet's body is padded to a floor, so paging never shrinks the dialog."""
from meshterm.ui.packet_viewer import _MIN_BODY_ROWS
tiny = PacketEntry(when=utcnow(), kind="ack", where="01c3") # a two-row packet
def test_packet_viewer_grows_its_dialog_only() -> None:
"""The viewer opts into a grow-only dialog so paging enlarges but never shrinks it."""
tiny = PacketEntry(when=utcnow(), kind="ack", where="01c3")
viewer = PacketViewer([tiny], 0, resolve=lambda h: "")
assert len(viewer.render_body(80)) >= _MIN_BODY_ROWS
assert viewer.grow_only is True
# The body is left at its natural (unpadded) height; the frame, not a floor, pads it.
assert len(viewer.render_body(80)) < 10
# ratchet_viewport is the grow-only contract: it rises to a taller body and never drops.
assert viewer.ratchet_viewport(6) == 6
assert viewer.ratchet_viewport(14) == 14 # a taller packet enlarges the box
assert viewer.ratchet_viewport(4) == 14 # a shorter one after keeps the larger box
def test_packet_viewer_raw_dump_skips_fields_folded_into_flavoured_rows() -> None:
@@ -116,4 +120,14 @@ def test_packet_viewer_raw_dump_skips_fields_folded_into_flavoured_rows() -> Non
body = _plain(_viewer(entry).render_body(80))
assert "path_len" not in body
assert "header" not in body
assert "novel_fi" in body # an unrecognized field still surfaces (label truncates to 8)
assert "novel_field" in body # an unrecognized field surfaces with its full name
def test_packet_viewer_shows_full_raw_field_labels() -> None:
"""A long raw-field name is shown whole — the label lane widens rather than clipping it."""
entry = _grp_txt_entry({
"chan_hash": "ab", "cipher_mac": "0000", "crypted": "00" * 16,
"battery_millivolts": 4102,
})
body = _plain(_viewer(entry).render_body(80))
assert "battery_millivolts" in body # the 18-char key is not clipped to 8
+32 -1
View File
@@ -295,12 +295,43 @@ def test_node_page_renders_all_sections(tmp_path: Path) -> None:
body = _plain(_node_sections(ctx, NODE, "YUL", None, 90))
assert "Volume" in body and "24 receptions" in body
assert "SNR" in body and "-2.0" in body and "+8.0" in body
assert "Rhythm" in body and "local hour" in body
assert "Rhythm" in body and "15-min" in body # 15-minute slices, like the mesh page
assert "Record" in body and "median" in body
assert "advert 24" in body # kinds breakdown, packet rows absent
repo.close()
def test_node_page_rhythm_is_fifteen_minute_and_shares_the_volume_gutter(tmp_path: Path) -> None:
"""The node rhythm matches the mesh's: a full-day 15-min sweep, gutter-aligned to Volume."""
repo = _seeded_repo(tmp_path)
ctx = SimpleNamespace(repo=repo)
lines = _plain(_node_sections(ctx, NODE, "YUL", None, 90), width=90).split("\n")
def border_col(heading: str) -> int:
start = next(i for i, line in enumerate(lines) if heading in line)
border = next(line for line in lines[start:] if "└" in line)
return border.index("└")
assert border_col("Volume") == border_col("Rhythm") # shared gutter → aligned left edge
rhythm = next(i for i, line in enumerate(lines) if "Rhythm" in line)
caption = next(lines[i + 1] for i in range(rhythm, len(lines)) if "└" in lines[i])
assert "24 h" in caption # the full-day sweep closes on 24 h, like the mesh rhythm
def test_time_axis_shortens_to_dates_on_wide_windows_and_times_on_narrow() -> None:
"""A multi-day window labels marks as bare dates; a same-day one, as times."""
from datetime import datetime, timedelta, timezone
from meshterm.ui.timemachine_screen import _time_axis
start = datetime(2026, 7, 1, 8, 0, tzinfo=timezone.utc)
wide = _time_axis(start, start + timedelta(days=10))
narrow = _time_axis(start, start + timedelta(hours=12))
assert wide(1.0) == "now" and narrow(1.0) == "now"
assert any(ch.isalpha() for ch in wide(0.0)) # a month name, e.g. "Jul 1"
assert ":" in narrow(0.0) # a clock time, e.g. "08:00"
def test_node_page_empty_window_offers_widening(tmp_path: Path) -> None:
"""A window with nothing recorded says so instead of drawing empty charts."""
repo = _seeded_repo(tmp_path)
+39
View File
@@ -417,6 +417,45 @@ def test_compose_dialog_is_bounded() -> None:
assert out.count("\n") + 1 <= 20
def _box_height(screen: Screen) -> int:
"""The row height of the dialog box ``compose_dialog`` draws for ``screen``."""
return frame.compose_dialog(screen, 80, 40).count("\n") + 1
def test_ordinary_dialog_box_resizes_to_each_body() -> None:
"""A plain (non grow-only) dialog sizes to whatever body it is currently showing."""
short = _box_height(ScrollScreen(Text("one line"), title="d"))
tall = _box_height(ScrollScreen(Text("\n".join(f"row {i}" for i in range(15))), title="d"))
assert tall > short
class _GrowScreen(Screen):
"""A grow-only dialog whose body height is set per paint, for the ratchet test."""
grow_only = True
def __init__(self) -> None:
super().__init__()
self.title = "d"
self.footer_hint = ""
self.n = 1
def render_body(self, width: int) -> list[str]:
return [f"row {i}" for i in range(self.n)]
def test_grow_only_dialog_box_holds_its_tallest_size() -> None:
"""A grow-only dialog grows its box for a taller body and never shrinks for a shorter one."""
screen = _GrowScreen()
screen.n = 2
small = _box_height(screen)
screen.n = 16
grown = _box_height(screen)
assert grown > small # a taller body enlarges the box
screen.n = 2
assert _box_height(screen) == grown # a shorter body after keeps the larger box
def test_compose_startup_is_chromeless_and_shows_banner() -> None:
"""The startup splash fills the height, draws the banner, and omits header/footer bars."""
screen = SelectScreen("pick", [Choice("alpha", 1), Choice("beta", 2)])