The feed opens on its columns, not on a status line

The live feed's heading said three things and none of them earned a row:
the order is what the TIME lane reads down, Enter is already named by the
footer hint and the F-key lane, and the live-light reported the hub's
subscription rather than any traffic — green over a silent mesh, and the
one screen that never starts the hub itself. Dropping the line gives the
feed a content row back, which is a row in thirteen on the PicoCalc.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-09-04 03:03:11 -04:00
1 parent 12d42a8804
commit 99bfdade64
3 files changed
+27 -48

No files matched your search

+12 -26
View File
@@ -73,8 +73,8 @@ from .widgets import NameKeyResolver, TypeOf
if TYPE_CHECKING:
from ..context import AppContext
#: Seconds between full repaints while the feed is open (keeps the live-light and any
#: age-sensitive chrome honest even between hub events).
#: Seconds between full repaints while the feed is open (keeps age-sensitive chrome
#: honest even between hub events).
_REFRESH_S = 1.0
#: How many feed rows are kept (the feed windows within the screen, so this is
@@ -207,7 +207,6 @@ class LiveFeedScreen(Screen):
session: Any,
resolve: Any,
seed: list[Observation],
hub_active: Any,
prefix_bytes: int = 0,
self_name: Optional[str] = None,
channels: Sequence[tuple[str, bytes]] = (),
@@ -222,7 +221,6 @@ class LiveFeedScreen(Screen):
resolve: Maps a node hash to a friendly contact name when known.
seed: Stored observations to open with (oldest first, as the repository
returns them); the newest :data:`_FEED_CAP` become the opening feed.
hub_active: Zero-arg callable: whether the event hub is pumping.
prefix_bytes: The hash width to light in the packet viewer's keys.
self_name: Our own node's name, drawn white wherever it appears.
channels: The device's configured channels, as ``(name, secret)`` pairs. The
@@ -243,7 +241,6 @@ class LiveFeedScreen(Screen):
self.title = "Live feed"
self._session = session
self._resolve = resolve
self._hub_active = hub_active
self._prefix_bytes = prefix_bytes
self._self_name = self_name
self._channels = channels
@@ -451,13 +448,12 @@ class LiveFeedScreen(Screen):
# --- rendering ---------------------------------------------------------------------
def render_body(self, width: int) -> list[str]:
"""The status line and column header, the feed's window, then the exit group.
"""The column header, then the feed's window.
Every line but the feed's own is pinned by construction rather than by the base
screen's sticky-header machinery: the chrome above and below is struck from the
viewport first and the feed windows *inside* what is left (see
:meth:`_feed_lines`), so the body never scrolls — the header can't travel off the
top of it, and the oldest packet can't sink past the bottom.
The header is pinned by construction rather than by the base screen's sticky-header
machinery: it is struck from the viewport first and the feed windows *inside* what
is left (see :meth:`_feed_lines`), so the body never scrolls — the header can't
travel off the top of it, and the oldest packet can't sink past the bottom.
"""
if self._selected is not None:
self._selected = min(self._selected, len(self._feed) - 1) if self._feed else None
@@ -465,7 +461,7 @@ class LiveFeedScreen(Screen):
self._hmax = 0 # nothing highlighted scrolls, so nothing advertises ←→
self._pinned = False # a feed with no rows has nothing to pin to
show_label = width >= _FEED_LABEL_MIN_WIDTH
lines = [render_to_ansi(self._heading(), width, no_wrap=True)]
lines: list[str] = []
if self._feed: # a header over nothing is noise; the empty note speaks for itself
lines.append(render_to_ansi(self._column_header(show_label), width, no_wrap=True))
win = max(1, self._scroll_viewport - len(lines))
@@ -473,23 +469,14 @@ class LiveFeedScreen(Screen):
self._scroll_total = max(1, len(lines))
return lines
def _heading(self) -> Text:
"""The feed's pinned status line, with a live-light for the hub."""
heading = Text("newest first · Enter opens a packet ", style="muted")
if self._hub_active():
heading.append("● live", style="ok")
else:
heading.append("○ waiting for a device", style="muted")
return heading
@staticmethod
def _column_header(show_label: bool) -> Text:
"""The lane names, in the app's uppercase muted column-header voice.
Laid out lane for lane against :meth:`_feed_row`, the pointer column included, so
every label sits over the values it names. Nothing here sorts — the feed is a
stream, and its one order (newest first) is the status line's to state — so no
column carries the contact list's sort triangle or its lit active-column style;
stream, and its one order (newest first) is what the ``TIME`` lane reads down — so
no column carries the contact list's sort triangle or its lit active-column style;
these are signposts, not controls. On a terminal too narrow for the class label
the header drops its ``CLASS`` too, leaving the icon lane unlabelled rather than
clipping a word into three cells.
@@ -807,7 +794,7 @@ async def open_livefeed(ctx: "AppContext") -> None:
Wires the screen to its feeds: stored recent observations seed it, a hub
subscription streams every new packet in, and a once-a-second ticker keeps the
live-light honest. Everything is torn down when the screen closes.
clock-sensitive rows honest. Everything is torn down when the screen closes.
Args:
ctx: The shared application context (must be running the interactive TUI surface).
@@ -854,7 +841,6 @@ async def open_livefeed(ctx: "AppContext") -> None:
session=session,
resolve=resolve,
seed=seed,
hub_active=lambda: ctx.events.active,
prefix_bytes=prefix_bytes,
self_name=self_name,
channels=channels,
@@ -866,7 +852,7 @@ async def open_livefeed(ctx: "AppContext") -> None:
unsubscribe = ctx.events.subscribe(screen.on_event)
async def tick() -> None:
"""Repaint once a second so the live-light and clock-sensitive rows stay honest."""
"""Repaint once a second so the clock-sensitive rows stay honest."""
while True:
await asyncio.sleep(_REFRESH_S)
session.invalidate()
-1
View File
@@ -313,7 +313,6 @@ def _livefeed(cols: int, rows: int) -> Screen:
Observation(node="a1b2c3d4", name="a1b2c3d4", kind="advert", snr=5.0, rssi=-90.0,
observed_at=utcnow()),
],
hub_active=lambda: True,
)
+15 -21
View File
@@ -44,12 +44,11 @@ class _Fut:
_KNOWN = {"a1b2": "Alice", "3d63": "YUL", "a1": "Alice", "3d": "YUL", "c0": "Us"}
def _screen(seed=None, active=True, **kwargs) -> LiveFeedScreen:
def _screen(seed=None, **kwargs) -> LiveFeedScreen:
screen = LiveFeedScreen(
session=_FakeSession(),
resolve=lambda h: _KNOWN.get(h, ""),
seed=list(seed or []),
hub_active=lambda: active,
**kwargs,
)
screen.note_viewport(48) # the frame records this before every real paint
@@ -72,8 +71,8 @@ def _stripped(lines: list[str]) -> list[str]:
def _rows(screen: LiveFeedScreen, width: int) -> list[str]:
"""Just the packet rows — the body past its heading and column header."""
return _stripped(screen.render_body(width))[2:]
"""Just the packet rows — the body past its column header."""
return _stripped(screen.render_body(width))[1:]
def _col(line: str, needle: str) -> int:
@@ -247,7 +246,7 @@ def test_livefeed_tokened_classes_are_about_their_token() -> None:
def test_livefeed_column_header_sits_over_the_lanes_it_names() -> None:
"""The header names each lane, and every label lands on the values beneath it."""
screen = _screen(seed=[_obs(node="3d63", kind="telemetry", snr=12.8, rssi=-105.0)])
header, row = _stripped(screen.render_body(72))[1:3]
header, row = _stripped(screen.render_body(72))[:2]
assert header.split() == ["TIME", "CLASS", "SUBJECT", "SNR", "RSSI"]
# Measured in display cells, not characters — the class icon is one character wide
# but two cells, so a character index would report every later lane one column early.
@@ -268,13 +267,13 @@ def test_livefeed_column_header_is_pinned_and_carries_no_sort_cue() -> None:
screen = _screen(seed=[_obs(node=f"n{i}", age_s=i) for i in range(40)])
screen.note_viewport(12)
lines = _stripped(screen.render_body(100))
assert "TIME" in lines[1]
assert not any(mark in lines[1] for mark in ("▲", "▼")) # nothing here sorts
assert "TIME" in lines[0]
assert not any(mark in lines[0] for mark in ("▲", "▼")) # nothing here sorts
screen.handle("end") # the list's last row — Back
screen.handle("up") # …and one up from it, the oldest packet: the window scrolls
after = _stripped(screen.render_body(100))
assert after[1] == lines[1] # …and the header is exactly where it was
assert "↑" in after[2] and "more" in after[2] # the rows really did travel
assert after[0] == lines[0] # …and the header is exactly where it was
assert "↑" in after[1] and "more" in after[1] # the rows really did travel
def test_livefeed_highlight_uses_the_app_wide_cursor() -> None:
@@ -284,7 +283,7 @@ def test_livefeed_highlight_uses_the_app_wide_cursor() -> None:
rows = _rows(screen, 100)
assert rows[0].startswith("❯ ") and rows[1].startswith(" ")
assert "▸" not in "\n".join(rows) # the old odd-one-out mark is gone
raw = screen.render_body(100)[2]
raw = screen.render_body(100)[1]
assert raw.startswith("\x1b[") # the pointer carries the cursor style, not bare text
@@ -391,7 +390,7 @@ def test_livefeed_carries_no_exit_row() -> None:
# The heading and column header stay put as the feed scrolls under them.
screen.handle("end")
after = _stripped(screen.render_body(100))
assert "↑" in after[2] and "more" in after[2]
assert "↑" in after[1] and "more" in after[1]
assert "Back" not in " ".join(after)
@@ -419,7 +418,7 @@ def test_livefeed_empty_feed_draws_its_note_and_nothing_else() -> None:
screen = _screen()
screen.future = _Fut()
lines = _stripped(screen.render_body(100))
assert "nothing heard yet" in lines[1]
assert "nothing heard yet" in lines[0]
assert "Back" not in " ".join(lines)
assert not any(line.startswith("❯") for line in lines) # nothing to point at
screen.handle("up") # nowhere to go, and no crash on the way
@@ -429,14 +428,14 @@ def test_livefeed_empty_feed_draws_its_note_and_nothing_else() -> None:
def test_livefeed_windows_inside_the_fixed_screen() -> None:
"""The heading stays pinned: the body fits the viewport and the feed rows window."""
"""The header stays pinned: the body fits the viewport and the feed rows window."""
seed = [_obs(node=f"n{i}", age_s=i) for i in range(40)]
screen = _screen(seed=seed)
screen.note_viewport(24)
lines = screen.render_body(100)
assert len(lines) <= 24 # heading + feed window == the viewport, never more
assert len(lines) <= 24 # column header + feed window == the viewport, never more
body = _plain(lines)
assert "newest first" in body # the pinned status line is still there
assert "TIME" in body # the pinned column header is still there
assert "↓" in body and "more" in body # hidden feed rows are counted below
@@ -448,7 +447,7 @@ _CRAMPED = 44
def test_livefeed_the_whole_row_fits_a_72_column_screen() -> None:
"""No row overflows at 72 — which is why ←→ has nothing to advertise there."""
screen = _screen(seed=[_obs(node="n0", kind="telemetry")])
for line in _stripped(screen.render_body(72))[1:]:
for line in _stripped(screen.render_body(72)):
assert len(line.rstrip()) <= 72
assert screen._hmax == 0
assert "←→" not in screen.footer_hint
@@ -497,8 +496,3 @@ def test_livefeed_advertises_line_scroll_only_where_it_acts() -> None:
assert "←→ scroll line" in screen.footer_hint
assert len(screen.footer_hint) <= 72 # the screens-at-72 rule, fullest state
def test_livefeed_without_a_device_reads_as_waiting() -> None:
"""With the hub idle the heading says so instead of pretending to be live."""
screen = _screen(active=False)
assert "○ waiting for a device" in _plain(screen.render_body(100))