From 82b93cf155e7c628b0d1af79b2764c7c3dcf8415 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Mon, 31 Aug 2026 20:48:44 -0400 Subject: [PATCH] The oldest message owns the head of the transcript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A chat pick anchored on its own body, so ^Home landed the frame two lines into the transcript: the day divider survived only as a pin, the first sender's chip was gone, and the PicoCalc title bar lit its ↑ over a conversation with nothing above it. The first message has nothing before its divider, so its pick anchors at line 0 — the head is drawn, not pinned, and the arrow goes dim. Co-Authored-By: Claude Opus 5 (1M context) --- meshterm/ui/chat.py | 7 ++++++- tests/test_chat.py | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/meshterm/ui/chat.py b/meshterm/ui/chat.py index 76ebae9..ee4f041 100644 --- a/meshterm/ui/chat.py +++ b/meshterm/ui/chat.py @@ -411,7 +411,12 @@ class ChatScreen(Screen): header = self._group_header(sender, is_self=message.outbound) lines += render_lines(header, width) if selected: - self._selected_line = len(lines) + # The first message owns the head of the transcript: nothing precedes + # its day divider, so its pick anchors at line 0 rather than at its own + # body. Anchoring on the body left the view scrolled two lines in at the + # very top — the divider only pinned, the sender chip gone, and the + # title bar's ↑ lit over a transcript with nothing above it. + self._selected_line = 0 if idx == 0 else len(lines) lines += self._body_lines(body, message, width, selected=selected) prev_group, prev_day = group, day ids.append(id(message)) diff --git a/tests/test_chat.py b/tests/test_chat.py index 752ed55..95c8503 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -1229,6 +1229,26 @@ def test_chat_frame_pins_a_day_divider_when_stuck_to_the_newest() -> None: assert above is True # and the frame flags there's more above the pin +def test_chat_top_of_transcript_clears_the_more_above_flag() -> None: + """Picking the oldest message scrolls the head of the transcript into view. + + The first message's pick anchors at line 0, so the frame lands on offset 0: its day + divider and sender chip are real rows again instead of a pin over a hidden line, and + the title bar's clip arrow goes dim because there genuinely is nothing above. + """ + from meshterm.ui.tui import frame + + screen = _screen(_StubSession(), send=None, messages=_two_day_messages()) + lines = screen.render_body(60) + screen.handle("ctrl_home") # back to the oldest message + lines = screen.render_body(60) + visible, above, below = frame._visible_slice(screen, lines, 6) + + assert screen.scroll == 0 + assert above is False and below is True + assert _strip_ansi(visible[0]).strip().startswith("──") # the head, drawn not pinned + + def test_chat_home_end_and_word_keys_move_the_compose_cursor() -> None: """In a chat, Home/End and Ctrl+←/→ act on the compose line, not the transcript scroll.""" screen = _screen(_StubSession(), send=None, messages=_two_day_messages())