Skip to content

Commit 65f5093

Browse files
jvorcakclaude
andcommitted
fix(topics): default message list to newest-first ordering
The message table defaulted to `sorting: []`, so rows rendered in raw backend stream order (per-partition arrival, oldest-first within a partition) instead of newest-first. A newest-first default existed in the original 2019 table (offset:descending) but was dropped in the migration to the nuqs/TanStack table; the only surviving newest-first sort was gated behind continuous pagination. For the "Newest" (last N / EndMinusResults) view, sort by timestamp descending with offset descending as a tiebreaker. Offset isn't global across partitions, so timestamp is the primary key. This applies only when the user hasn't chosen an explicit column sort, so header sorting still wins; continuous pagination (which forces sorting to []) also lands here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7ee42a0 commit 65f5093

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

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

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,14 @@ 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
575+
// Default ordering for the "Newest" (last N) view: show messages newest-first, sorted by
576+
// timestamp descending with offset descending as a tiebreaker. Offset isn't global across
577+
// partitions, so timestamp is the primary key. This applies unless the user has picked an
578+
// explicit column sort (sorting.length > 0), in which case the table's sorted row model wins.
579+
// Continuous pagination forces sorting to [] and disables column sorting, so it always lands here.
577580
const filteredMessages =
578-
continuousPaginationEnabled && startOffset === PartitionOffsetOrigin.EndMinusResults
579-
? [...baseFilteredMessages].sort((a, b) => b.timestamp - a.timestamp)
581+
startOffset === PartitionOffsetOrigin.EndMinusResults && sorting.length === 0
582+
? [...baseFilteredMessages].sort((a, b) => b.timestamp - a.timestamp || b.offset - a.offset)
580583
: baseFilteredMessages;
581584

582585
// Convert @computed activePreviewTags to useMemo

0 commit comments

Comments
 (0)