Skip to content

Bug: a newly created message lands mid-feed instead of at the top #97

Closed

Description

@Adron

Found while implementing #22 (cursor pagination). Pre-existing, unrelated to that change, so filed
rather than fixed there.

The bug

DefaultMessagesRepository.createMessage inserts the new post at maxFeedOrder() - 1.

The feed sorts by feedOrder ASC. With a cached feed of more than two rows, maxFeedOrder() - 1
is not smaller than every other row's order — so the new message lands somewhere in the middle
of the feed instead of at the top.

Why the tests do not catch it

The existing coverage exercises a single-row feed, where maxFeedOrder() - 1 happens to be
correct. The bug only shows up with three or more cached rows.

Fix

Add a minFeedOrder() query to MessageDao and insert at minFeedOrder() - 1. Extend the test to
a feed of at least three rows so the regression is actually covered.

Reported by the agent implementing #22; left out of that PR because it sits in composer code that
#19 and #20 will be touching.

Activity

  1. added
    P2Completeness / settings surface
    area:messagesSocial messages feed & composer
    on Sep 16, 2026
  2. Adron commented on Sep 16, 2026

    @Adron
    MemberAuthor

    Fixed in #122 (the tag-feed PR), since that work replaced the feed's ordering scheme wholesale and the bug lived exactly there.

    A newly created message was inserted at maxFeedOrder - 1. With the feed sorting ascending, that is near the bottom of a loaded feed, not the top. It is now minPosition - 1 — a genuine head insert. As predicted in this issue, the existing "at the top of the feed" test passed only because it used a single-row feed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Completeness / settings surfacearea:messagesSocial messages feed & composer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions