Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(signals): make inbox "Newest first" sort lead with created_at (#64505)

Georgiy Tarasov0f11012a552a
diff --git a/frontend/src/scenes/inbox/logics/inboxFiltersLogic.test.ts b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.test.ts
new file mode 100644
index 000000000000..32ea6d38e432
--- /dev/null
+++ b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.test.ts
@@ -0,0 +1,20 @@
+import { buildSignalReportListOrdering } from './inboxFiltersLogic'
+
+describe('buildSignalReportListOrdering', () => {
+ it('leads with the selected time field so "Newest first" surfaces the newest reports', () => {
+ // The list is flat, so created_at must be the primary key — not a sub-sort within status buckets.
+ expect(buildSignalReportListOrdering('created_at', 'desc')).toBe('-created_at,status,-updated_at')
+ })
+
+ it('leads with created_at ascending for "Oldest first"', () => {
+ expect(buildSignalReportListOrdering('created_at', 'asc')).toBe('created_at,status,-updated_at')
+ })
+
+ it('leads with updated_at and drops the redundant tiebreak for "Last updated first"', () => {
+ expect(buildSignalReportListOrdering('updated_at', 'desc')).toBe('-updated_at,status')
+ })
+
+ it('leads with priority for "Priority first"', () => {
+ expect(buildSignalReportListOrdering('priority', 'asc')).toBe('priority,status,-updated_at')
+ })
+})
diff --git a/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts
index ac84d18655f1..ac371d8b49c4 100644
--- a/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts
+++ b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts
@@ -32,12 +32,15 @@ export type InboxSortField = 'priority' | 'created_at' | 'updated_at'
export type InboxSortDirection = 'asc' | 'desc'
/**
- * Build the `ordering` query param. Mirrors desktop `buildSignalReportListOrdering`:
- * 1. Status rank (semantic server-side rank, always applied)
- * 2. Toolbar-selected field (priority, updated_at, created_at)
- * 3. `-updated_at` as a recency tiebreak, so reports tied on status + field
- * surface most-recently-updated first instead of in arbitrary order.
- * (Skipped when the selected field is already `updated_at`.)
+ * Build the `ordering` query param. The list is a flat list (no status section
+ * headers), so the toolbar-selected field must lead — otherwise an explicit sort
+ * like "Newest first" only reorders reports *within* each status bucket and the
+ * genuinely newest reports never reach the top:
+ * 1. Toolbar-selected field (priority, updated_at, created_at) with direction
+ * 2. Status rank (semantic server-side rank) as a secondary key, so reports tied
+ * on the selected field surface in pipeline-status order
+ * 3. `-updated_at` as a final recency tiebreak (skipped when the selected field
+ * is already `updated_at`).
*
* Reviewer scope is NOT an ordering tiebreak. A `-is_suggested_reviewer` sort
* floats the current user's own reports to the top of the single loaded page,
@@ -47,7 +50,7 @@ export type InboxSortDirection = 'asc' | 'desc'
*/
export function buildSignalReportListOrdering(field: InboxSortField, direction: InboxSortDirection): string {
const fieldKey = direction === 'desc' ? `-${field}` : field
- return field === 'updated_at' ? `status,${fieldKey}` : `status,${fieldKey},-updated_at`
+ return field === 'updated_at' ? `${fieldKey},status` : `${fieldKey},status,-updated_at`
}
/**