Skip to content

Commit 026bc91

Browse files
jvorcakclaude
andcommitted
fix(messages): restore newest-first default ordering in message list
The default topic message view (non-continuous pagination, "Newest" origin, last-50) rendered rows in raw backend/stream order rather than newest-first, so messages were not sorted by timestamp descending as users expect. Client-side sort was only applied in the narrow `continuousPaginationEnabled && startOffset === EndMinusResults` case, introduced in #2229. The default paginated path fell through to the unsorted list. Apply a stable newest-first sort (timestamp desc, then offset desc as a cross-partition tiebreak) to the full loaded set before client-side pagination, so page 1 of a last-50 fetch shows the globally newest rows. Header click still overrides via the sorted row model. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7ee42a0 commit 026bc91

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

  • frontend/src/components/pages/topics/Tab.Messages

frontend/src/components/pages/topics/Tab.Messages/index.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,23 @@ export const TopicMessageView: FC<TopicMessageViewProps> = (props) => {
572572
})
573573
: messages;
574574

575-
// For continuous pagination, just use the filtered messages directly
576-
// We don't use placeholders as they cause page content to shift
577-
const filteredMessages =
578-
continuousPaginationEnabled && startOffset === PartitionOffsetOrigin.EndMinusResults
579-
? [...baseFilteredMessages].sort((a, b) => b.timestamp - a.timestamp)
580-
: baseFilteredMessages;
575+
// Newest-first display ordering: timestamp descending, then offset descending
576+
// as a tiebreak (offset isn't global across partitions, so timestamp is the
577+
// best cross-partition key). This is a pure client-side sort of the rows we
578+
// already hold — independent of the backend request.
579+
const newestFirst = (list: TopicMessage[]) =>
580+
[...list].sort((a, b) => b.timestamp - a.timestamp || b.offset - a.offset);
581+
582+
const filteredMessages = continuousPaginationEnabled
583+
? // In infinite-scroll mode the append order depends on scroll direction, so
584+
// only the "Newest" fetch gets forced newest-first; other origins keep the
585+
// streamed order. Header sorting is disabled here.
586+
startOffset === PartitionOffsetOrigin.EndMinusResults
587+
? newestFirst(baseFilteredMessages)
588+
: baseFilteredMessages
589+
: // Normal paginated view: newest-first is just the default display order.
590+
// Clicking a column header still overrides it via the sorted row model.
591+
newestFirst(baseFilteredMessages);
581592

582593
// Convert @computed activePreviewTags to useMemo
583594
const activePreviewTags = useMemo(

0 commit comments

Comments
 (0)