The oldest message owns the head of the transcript

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) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-08-31 20:48:44 -04:00
1 parent 8fc24d4901
commit 82b93cf155
2 files changed
+26 -1

No files matched your search

+6 -1
View File
@@ -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))
+20
View File
@@ -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())