Chat: show newest messages, load older history on demand - #209
Merged
Conversation
GetMessages returned the oldest 50 messages (ORDER BY sent_at ASC LIMIT 50) with no pagination, so any conversation past 50 messages silently hid everything newer - the list preview (separate DESC subquery) still showed the latest message, and freshly sent messages appeared live via Mercure but vanished on reload. The query now returns the newest window in chronological order plus a hasOlderMessages flag (fetches limit+1), with a (sent_at, id) cursor for walking history backwards. Conversation detail gets a "Load older messages" button that fetches batches from a new endpoint and prepends them with scroll position preserved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcS993Bupy5RapSDEk1SYs
load_older_messages (new in this branch) plus 6 pre-existing gaps from the events picker and API docs work (add_my_time, competition_hint_series, competition_live_badge, competition_not_selectable, table_section_puzzles, table_section_library). check-translations now reports 0 missing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GcS993Bupy5RapSDEk1SYs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug (user report)
GetMessages::forConversation()loaded messages withORDER BY sent_at ASC LIMIT 50and no pagination anywhere. Once a conversation passed 50 messages, opening it rendered the oldest 50 and silently dropped everything newer. The conversation list was unaffected (its preview is a separateDESC LIMIT 1subquery), and a freshly sent message appeared live via the Mercure/Turbo Stream append but vanished on reload — hence "disappearing" messages. No data was ever lost, only hidden.Confirmed on production: the reporting user's conversation has 64 messages; everything after 2026-07-15 (the day it crossed 50) was invisible to both participants. Two more conversations site-wide (59 and 54 messages) are affected.
Fix
GetMessages::forConversation()now selects the newestlimitmessages (ORDER BY sent_at DESC, id DESC LIMIT :limit+1, re-sorted ASC for display) and returns aMessagesPageresult with ahasOlderMessagesflag (the +1 row detects whether more history exists).beforeMessageIdreturns the newest window strictly older than that message, using a(sent_at, id)tuple comparison scoped to the conversation (an id from another conversation yields an empty page).Load older messages (full history access)
GET /en/messages/{conversationId}/older-messages?before=<messageId>(ConversationOlderMessagesController, participant-only) renders a batch of older bubbles as an HTML fragment carryingdata-has-older/data-oldest-id.messagingStimulus controller fetches a batch, prepends it below the button (each batch is older than the previous), preserves the scroll position, and hides the button when history is exhausted. The existing auto-scroll-to-bottom MutationObserver is suppressed during prepends.Tests
GetMessagesTestrewritten for the new behavior: newest-window selection, chronological order,hasOlderMessages, cursor walk reassembles the entire history exactly, foreign-conversation cursor returns nothing.🤖 Generated with Claude Code
https://claude.ai/code/session_01GcS993Bupy5RapSDEk1SYs