: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(signals): make recommended the default inbox sort (#115451)
posthog[bot]53a3a34dbc41
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e59d5480a340..f36bec87e75a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -11327,9 +11327,9 @@ snapshots:scenes-app-inbox-scene--empty-with-many-scouts--light:hash: v1.k794b7964.facecddc48f471398f32d48fed8287b91573105ddd2d2ce2adc18eaf649900e7.QVbf6XPS8aj7-Jrj-3T_o1fu7tZNl8ZCJqGw3yRl8Qwscenes-app-inbox-scene--inbox--dark:- hash: v1.k794b7964.5c0c0dad3ce293f8e53cca3c47230d86f59c3b3b6c23ac011a2fa91d7940693e.Q6QOfQtNc3kU2ZqZ_lMDSlQgQSyhCiTzhUAiae_Uw0g+ hash: v1.k794b7964.9e408067ea1f3714dcf8d9e812dde013bd58ce007872c1edadbabca46f30dae9.rsVWshwBIWY3KXFqChFMc0qts9C78Rkju8Cmq5Nofvoscenes-app-inbox-scene--inbox--light:- hash: v1.k794b7964.9633249568528ba0cf713518954e57136d54cc6fd75a4fef991ac56c4d7eebde.jZQmmA8AYHKW87BbWCdgOyPXcrJ-5koAkz9W0MMcRPc+ hash: v1.k794b7964.15269c659aaeb20cd4a2a936d5bf054e5ca05d8f87aef18a6171d2a6d4567f6a.byy1SwJvJwuPeS2qF9ao-gFZexk5Yirs0zF9D5YeBC4scenes-app-inbox-scene--installing-self-driving--dark:hash: v1.k794b7964.9c63d0aec1e590c399c59a6d974d4c57c2aaba654944bc18065c43212ea67c20.Vcq4DkgtGa7JtssCwGJMnDbhspFmWkFUrEyZpBbhEIIscenes-app-inbox-scene--installing-self-driving--light:@@ -11367,9 +11367,9 @@ snapshots:scenes-app-inbox-scene--self-driving-onboarding--light:hash: v1.k794b7964.87b9241bd7aadc4910ea54b999c3ce8ff1771db2af89a861f53b118a55f4dab8.f9dpoa9HTkP2rgnZ7LIHJrFW5s2WhpMl4fpKVZIO55Yscenes-app-inbox-scene--self-driving-paused--dark:- hash: v1.k794b7964.42dc0343700bfb92c34ac993a87ddff9e8d98811769f32f8776d704af62fafe9.W79Y5DTmdsyLjf7K7-wxsG_ZXok-7CAfnJVl_a5ptdI+ hash: v1.k794b7964.d93230f18f04b762f3ae875c5a326911b98476668fa8cfd8e37894fe43ba1f1f._zlmaBrFV16p8GGadEQ1GL7s0r_HfNZZypbmh0fGYd4scenes-app-inbox-scene--self-driving-paused--light:- hash: v1.k794b7964.e9d32def129b1d7789f5b5c16831abf579301b87e6875738756200d45f3b83b1.pZItVs7u0wUKy7mwFCt66F-2SLtajHhFKbFlxHvWjYw+ hash: v1.k794b7964.7e6ff4a2bb7189f5f5efbf1e3b5d8b48b0bef96fb3196487e5466b59547d4905.b1dML8lwCJjG7D7rai6EKPJ4NLXfxQ6xP0O5RNOXX2cscenes-app-inbox-scene--self-driving-verdict-pending--dark:hash: v1.k794b7964.6070171adce8ba72d73e5ef46ddc59a6ebd25afbb16d2c4ae0837fa9af66e0fd.crmCZN0uPyF4FXAVize9Qi7juxKUap5RRLyfRbpmo9Qscenes-app-inbox-scene--self-driving-verdict-pending--light:@@ -12043,9 +12043,9 @@ snapshots:scenes-app-inbox-tabs--pull-requests-legacy--light:hash: v1.k794b7964.43939118a6c7870fc12e612c5b973b2058fdde444f403551f8f6011c82ca4949.EWtT_yr95gc5cVXtIii_dBY1un73ZJSKdJlcgiTWSQEscenes-app-inbox-tabs--reports--dark:- hash: v1.k794b7964.d4649f4b9f76f791386003c2773782ba83b3981ff3433ba834ff31458d96e7b1.JPLFwjR1k6qO2vqsNO_-R5eh7RELWEXl5-XbKLXk1Vg+ hash: v1.k794b7964.de579e94a1887015af027dbecb7d2dcce02439872137ac00b0e4d5cc0a1e8589.YwsBhRpOZnH8C9lQakkHwKeCOwBUHpW5lGJ8lFGYR_Ascenes-app-inbox-tabs--reports--light:- hash: v1.k794b7964.d0621c88f48c2ea6fa2dd7ecdd6f851970d22c781c922f23d1109751d8702e7a.8NdZZ5H3HdHE7JuCnJbJhUA3Zd-cqhpXbf57aqMjBKc+ hash: v1.k794b7964.1131b6f871b60e5b46a3c641cc7473984906dded2510368629d644ae0e6262d8.uC2varzBj67yNHHXpbCwbO5xkUGZv3fbnxcj0bi9MaEscenes-app-inbox-tabs--reports-empty--dark:hash: v1.k794b7964.a4766b945dbac1ec8fc6d4dd000b02c42912ca216f9f8e6b16cad697bd8e92a8.w39hYf6soNmmsPVoiutqVtA86Xx00ECeouUh022ElgEscenes-app-inbox-tabs--reports-empty--light:@@ -12055,9 +12055,9 @@ snapshots:scenes-app-inbox-tabs--reports-legacy--light:hash: v1.k794b7964.803282f156dce837dfa6cc6423460eca7ffe9f210f66e63dfd958e528a6cb9c0.8vtgsr_oU-CqNE6HcibYDIvewF5uSZDakY7_J_DQuGwscenes-app-inbox-tabs--reports-state-filtered--dark:- hash: v1.k794b7964.4b4001656ea14d5e0080d2872de96be57b4b6c54b93a6d9e54b21b567ae80fa6.6ll9EbBF7Ebqk2f87IcA1Rwzc89fnfAjg8SXfwcVc8E+ hash: v1.k794b7964.cd552155244b7fee125a642815382e031b6b1e6992a82fb18859ff2a95920c0a.E6OOCjW9Qo3XrsehudLeJi4gWzPPYoT1cjHTjgvy9Nwscenes-app-inbox-tabs--reports-state-filtered--light:- hash: v1.k794b7964.61a5c31e1a909839d7c16c534b3b7aab2e8c45fcd769e4088c30a704c2b055b2.09yi3fMFqV9A0LsA9RQB6w3Rq8tpzamXNlWEg25qluk+ hash: v1.k794b7964.8f90287bdd692dfc987cd12b004e9aa80152ecba47c0a54ae6b52a65c15cb230.z71B4YVRspFa2Q51LTzEJ3G-TWUwohig63cvZ1n6s_Uscenes-app-inbox-tabs--runs--dark:hash: v1.k794b7964.b0eb8ed605bd36103e79e0a60b214bb3923082a8a3e942619b209e2e63c4c27b.tc-_hXddEA1-okpf16Of3a1wM9gWn-D4ZW1_LLaPKq4scenes-app-inbox-tabs--runs--light:diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.tsindex cc08cadc0ac7..0fd8fff400ad 100644--- a/frontend/src/lib/api.ts+++ b/frontend/src/lib/api.ts@@ -4933,6 +4933,8 @@ const api = {status?: stringsearch?: stringordering?: string+ /** Inbox sort preset, for example `recommended`. The server ignores it when `ordering` is set. */+ sort?: string/** Comma-separated source products. */source_product?: string/** Comma-separated P0–P4. */diff --git a/products/signals/frontend/inbox/components/InboxReportList.tsx b/products/signals/frontend/inbox/components/InboxReportList.tsxindex 3464c19493f1..938eb93c451c 100644--- a/products/signals/frontend/inbox/components/InboxReportList.tsx+++ b/products/signals/frontend/inbox/components/InboxReportList.tsx@@ -87,6 +87,7 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListPropspageLoadFailed,loadedQueryKey,loadedContext,+ loadedRanker,} = useValues(reportListLogic)const { ensureLoaded, loadMore, dismissReport, restoreReport, refresh } = useActions(reportListLogic)const { hasActiveFilters, sourceProductFilter, priorityFilter, scope } = useValues(inboxFiltersLogic)@@ -160,8 +161,10 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListPropsif (!listVisible || !isLoaded || totalCount === null || loadedQueryKey === null || loadedContext === null) {return}- if (loadedQueryKey !== impressionQueryKeyRef.current) {- impressionQueryKeyRef.current = loadedQueryKey+ // The ranker is in the key because `sort=recommended` keeps the same query when the server switches rankers.+ const impressionKey = `${loadedQueryKey}|${loadedRanker}`+ if (impressionKey !== impressionQueryKeyRef.current) {+ impressionQueryKeyRef.current = impressionKeyimpressedIdsRef.current = new Set<string>()}const fresh = reports@@ -182,8 +185,9 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListPropssortField: loadedContext.sortField,sortDirection: loadedContext.sortDirection,createdWindow: loadedContext.createdWindow,+ rankerId: loadedRanker,})- }, [listVisible, isLoaded, totalCount, reports, tabKey, loadedQueryKey, loadedContext])+ }, [listVisible, isLoaded, totalCount, reports, tabKey, loadedQueryKey, loadedContext, loadedRanker])// Read fresh state at intersection time via refs so the observer isn't rebuilt twice per page// fetch (`hasMore`/`reportsResponseLoading` both flip during a load).diff --git a/products/signals/frontend/inbox/components/useReportImpressions.ts b/products/signals/frontend/inbox/components/useReportImpressions.tsindex 767d98e7b91b..4da25c06c937 100644--- a/products/signals/frontend/inbox/components/useReportImpressions.ts+++ b/products/signals/frontend/inbox/components/useReportImpressions.ts@@ -14,12 +14,28 @@ interface SectionImpressionState {totalCount: number | nullloadedQueryKey: string | nullloadedContext: ReportListRequestContext | null+ loadedRanker: string | null}function useSectionImpressionState(sectionKey: InboxReportSectionKey): SectionImpressionState {- const { isLoaded, reportsLoadFailed, reportsResponseLoading, totalCount, loadedQueryKey, loadedContext } =- useValues(reportListLogic(sectionListLogicProps(sectionKey)))- return { isLoaded, reportsLoadFailed, reportsResponseLoading, totalCount, loadedQueryKey, loadedContext }+ const {+ isLoaded,+ reportsLoadFailed,+ reportsResponseLoading,+ totalCount,+ loadedQueryKey,+ loadedContext,+ loadedRanker,+ } = useValues(reportListLogic(sectionListLogicProps(sectionKey)))+ return {+ isLoaded,+ reportsLoadFailed,+ reportsResponseLoading,+ totalCount,+ loadedQueryKey,+ loadedContext,+ loadedRanker,+ }}/**@@ -60,7 +76,10 @@ export function useReportImpressions(rows: MergedReportRow[], selectedSections:const settled = selectedSections.every((key) => (sections[key].isLoaded || sections[key].reportsLoadFailed) && !sections[key].reportsResponseLoading)- const contextKey = JSON.stringify(selectedSections.map((key) => [key, sections[key].loadedQueryKey]))+ // The ranker is in the key because `sort=recommended` keeps the same query when the server switches rankers.+ const contextKey = JSON.stringify(+ selectedSections.map((key) => [key, sections[key].loadedQueryKey, sections[key].loadedRanker])+ )const impressedIdsRef = useRef(new Set<string>())const impressionContextKeyRef = useRef('')@@ -104,6 +123,7 @@ export function useReportImpressions(rows: MergedReportRow[], selectedSections:sortField: context.sortField,sortDirection: context.sortDirection,createdWindow: context.createdWindow,+ rankerId: sections[sectionKey].loadedRanker,})}// `sections` is a fresh object each render; `contextKey` and `settled` already change withdiff --git a/products/signals/frontend/inbox/filterOptions.tsx b/products/signals/frontend/inbox/filterOptions.tsxindex cf304cd54b9c..4845a4d7fccc 100644--- a/products/signals/frontend/inbox/filterOptions.tsx+++ b/products/signals/frontend/inbox/filterOptions.tsx@@ -15,6 +15,7 @@ import {IconReceipt,IconRefresh,IconStack,+ IconStar,IconSupport,} from '@posthog/icons'import { LemonTagType } from '@posthog/lemon-ui'@@ -79,6 +80,13 @@ export interface InboxSortOption {}export const INBOX_SORT_OPTIONS: InboxSortOption[] = [+ {+ label: 'Recommended',+ field: 'recommended',+ direction: 'asc',+ icon: <IconStar />,+ description: 'The reports most worth a look come first.',+ },{ label: 'Priority first', field: 'priority', direction: 'asc', icon: <IconList /> },{ label: 'Last updated first', field: 'updated_at', direction: 'desc', icon: <IconRefresh /> },{ label: 'Newest first', field: 'created_at', direction: 'desc', icon: <IconCalendar /> },diff --git a/products/signals/frontend/inbox/inboxAnalytics.test.ts b/products/signals/frontend/inbox/inboxAnalytics.test.tsindex c4fd85c5c683..365b0a8f5ad2 100644--- a/products/signals/frontend/inbox/inboxAnalytics.test.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.test.ts@@ -11,6 +11,7 @@ import {captureScoutConfigChanged,captureSignalSourceConnected,INBOX_EVENTS,+ setInboxServedRanker,} from './inboxAnalytics'import { SignalReport, SignalReportStatus } from './types'@@ -42,6 +43,7 @@ function makeReport(overrides: Partial<SignalReport> = {}): SignalReport {describe('inboxAnalytics', () => {beforeEach(() => {;(posthog.capture as jest.Mock).mockClear()+ setInboxServedRanker(null)})it('stamps every event with the cloud client discriminator', () => {@@ -142,6 +144,7 @@ describe('inboxAnalytics', () => {sortField: 'ranking_pr_merged',sortDirection: 'desc',createdWindow: '7d',+ rankerId: 'fixed',})const props = lastCapture(INBOX_EVENTS.REPORTS_IMPRESSED)expect(props).toMatchObject({@@ -152,6 +155,7 @@ describe('inboxAnalytics', () => {sort_field: 'ranking_pr_merged',sort_direction: 'desc',created_window: '7d',+ ranker_id: 'fixed',})expect(props?.impressions).toEqual([expect.objectContaining({@@ -173,7 +177,8 @@ describe('inboxAnalytics', () => {])})- it('emits a single-report action with the report context', () => {+ it('emits a single-report action with the report context and the ranker of the list in view', () => {+ setInboxServedRanker('fixed')captureInboxReportAction({report: makeReport(),actionType: 'create_pr',@@ -185,9 +190,16 @@ describe('inboxAnalytics', () => {surface: 'detail_pane',is_bulk: false,bulk_size: 1,+ ranker_id: 'fixed',})})+ it('never attributes a Today action to the Inbox ranker', () => {+ setInboxServedRanker('fixed')+ captureInboxReportAction({ report: makeReport(), actionType: 'discuss', surface: 'today' })+ expect(lastCapture(INBOX_EVENTS.REPORT_ACTION)?.ranker_id).toBeNull()+ })+it('emits a bulk action with a null report and the selection size', () => {captureInboxReportAction({actionType: 'dismiss',diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex d50a7c45313d..bb1df9239137 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -284,6 +284,16 @@ function reportAgeHours(report: Pick<SignalReport, 'created_at'>): number {return Math.max(0, Math.round(hours * 10) / 10)}+// The ranker that ordered the Inbox list in view, from the latest list response. Inbox report actions+// and sort changes read it, so the ranking test can join them to the ranker without each caller+// passing it. The Inbox scene clears it on unmount.+let servedInboxRankerId: string | null = null++/** Record the ranker of the latest list response. Null when the sort is not Recommended. */+export function setInboxServedRanker(rankerId: string | null): void {+ servedInboxRankerId = rankerId+}+interface BaseReportProperties {report_id: stringreport_age_hours: number@@ -440,6 +450,8 @@ export function captureInboxReportsImpressed(params: {sortField: stringsortDirection: stringcreatedWindow: string | null+ /** The ranker the server used for a Recommended list. Null for other sorts. */+ rankerId: string | null}): void {const rankingSort = params.sortField.startsWith('ranking_')captureInboxEvent(INBOX_EVENTS.REPORTS_IMPRESSED, {@@ -451,6 +463,7 @@ export function captureInboxReportsImpressed(params: {sort_field: params.sortField,sort_direction: params.sortDirection,created_window: params.createdWindow,+ ranker_id: params.rankerId,impression_count: params.reports.length,impressions: params.reports.map((report, index) => ({...baseReportProperties(report),@@ -479,6 +492,8 @@ export function captureInboxReportOpened(rank: number | nulllistSize: number | nullsection: InboxReportSectionKey | null+ /** The ranker of the list the report was opened from. Null for other sorts and for a cold deep-link. */+ rankerId: string | null},/** The unload flush passes `{ send_instantly: true }` so the open leaves before the page does. */options?: CaptureOptions@@ -495,6 +510,7 @@ export function captureInboxReportOpened(rank: params.rank,list_size: params.listSize,section: params.section,+ ranker_id: params.rankerId,},options)@@ -558,6 +574,8 @@ export function captureInboxReportAction(params: {surface: params.surface,is_bulk: params.isBulk ?? false,bulk_size: params.bulkSize ?? 1,+ // Today lists reports in its own order, so its actions never belong to an Inbox ranker.+ ranker_id: params.surface === 'today' ? null : servedInboxRankerId,...params.extra,})}@@ -899,6 +917,8 @@ export function captureInboxQueryChanged(params: {search_length: search.length,has_active_filters: params.hasActiveFilters,created_window: params.createdWindow,+ // The ranker of the list the user changed away from, not of the list the change requests.+ ranker_id: servedInboxRankerId,})}diff --git a/products/signals/frontend/inbox/inboxSceneLogic.ts b/products/signals/frontend/inbox/inboxSceneLogic.tsindex 10f97ad3dbb4..971589ebd0df 100644--- a/products/signals/frontend/inbox/inboxSceneLogic.ts+++ b/products/signals/frontend/inbox/inboxSceneLogic.ts@@ -33,6 +33,7 @@ import type { SignalReportMetricSnapshotsApi } from 'products/signals/frontend/gimport {captureInboxReportClosed,captureInboxReportOpened,+ setInboxServedRanker,captureInboxReportScrolled,InboxReportCloseMethod,InboxReportLinkSource,@@ -283,11 +284,13 @@ function findReportRank(rank: number | nulllistSize: number | nullsection: InboxReportSectionKey | null+ rankerId: string | null} {+ const notFound = { rank: null, listSize: null, section: null, rankerId: null }if (flatList) {const filterValues = inboxFiltersLogic.findMounted()?.valuesif (!filterValues) {- return { rank: null, listSize: null, section: null }+ return notFound}const isStaff = userLogic.findMounted()?.values.user?.is_staff ?? falseconst reportsBySection = Object.fromEntries(@@ -307,9 +310,13 @@ function findReportRank()const idx = rows.findIndex((row) => row.report.id === id)if (idx >= 0) {- return { rank: idx + 1, listSize: rows.length, section: rows[idx].sectionKey }+ const sectionKey = rows[idx].sectionKey+ const rankerId =+ reportListLogic.findMounted({ sectionKey, listParams: INBOX_REPORT_SECTION_LIST_PARAMS[sectionKey] })+ ?.values.loadedRanker ?? null+ return { rank: idx + 1, listSize: rows.length, section: sectionKey, rankerId }}- return { rank: null, listSize: null, section: null }+ return notFound}for (const sectionKey of Object.keys(INBOX_REPORT_SECTION_LIST_PARAMS) as InboxReportSectionKey[]) {const mounted = reportListLogic.findMounted({@@ -322,10 +329,15 @@ function findReportRank(}const idx = reports.findIndex((r: SignalReport) => r.id === id)if (idx >= 0) {- return { rank: idx + 1, listSize: reports.length, section: sectionKey }+ return {+ rank: idx + 1,+ listSize: reports.length,+ section: sectionKey,+ rankerId: mounted.values.loadedRanker,+ }}}- return { rank: null, listSize: null, section: null }+ return notFound}// One list answered, with rows or with a failure, and none is still fetching. Until then, a missing@@ -368,6 +380,7 @@ function captureOpenWhenRanked(rank: resolved.rank,listSize: resolved.listSize,section: resolved.section,+ rankerId: resolved.rankerId,},// The wait puts the capture up to `OPEN_RANK_WAIT_MS` after the report opened, and// posthog-js stamps an event at the capture moment. Without the override, a scroll or an@@ -1216,6 +1229,7 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([beforeUnmount: () => {// Flush dwell time for a report still open when the scene unmounts (navigated away).flushOpenReport(cache, 'unmount')+ setInboxServedRanker(null)},})),diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.tsindex 6ea674ce310f..4445da318b6d 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts@@ -16,6 +16,7 @@ import { initKeaTests } from '~/test/init'import { INBOX_EVENTS } from '../inboxAnalytics'import {buildSignalReportListOrdering,+ buildSignalReportListSortParams,filterSearchParams,inboxFiltersLogic,InboxFilterState,@@ -31,7 +32,7 @@ const DEFAULT_STATE: InboxFilterState = {scoutFilter: [],priorityFilter: [],stateFilter: ['monitoring', 'needs-decision'],- sortField: 'priority',+ sortField: 'recommended',sortDirection: 'asc',searchQuery: '',createdWindow: null,@@ -59,6 +60,14 @@ describe('inboxFiltersLogic', () => {it('leads with the ranking field for a model sort', () => {expect(buildSignalReportListOrdering('ranking_fixed', 'desc')).toBe('-ranking_fixed,status,-updated_at')})++ // The server ignores the `sort` preset whenever `ordering` is present.+ it.each([+ ['recommended', 'asc', { sort: 'recommended' }],+ ['priority', 'asc', { ordering: 'priority,status,-updated_at' }],+ ] as const)('sends %s:%s as %p', (field, direction, expected) => {+ expect(buildSignalReportListSortParams(field, direction)).toEqual(expected)+ })})describe('filter URL params', () => {@@ -130,14 +139,21 @@ describe('inboxFiltersLogic', () => {it.each([['keeps a model sort for a user who can use it', 'ranking_action:desc', true, 'ranking_action', 'desc'],- ['falls back to the default sort for a user who cannot', 'ranking_action:desc', false, 'priority', 'asc'],+ [+ 'falls back to the default sort for a user who cannot',+ 'ranking_action:desc',+ false,+ 'recommended',+ 'asc',+ ],['falls back to the default sort for a head the menu no longer offers','ranking_pr_merged:desc',true,- 'priority',+ 'recommended','asc',],+ ['keeps an explicit Priority first from a shared link', 'priority:asc', false, 'priority', 'asc'],] as const)('%s', (_name, sort, modelSortAvailable, sortField, sortDirection) => {expect(parseFilterSearchParams({ sort }, { modelSortAvailable })).toEqual({...DEFAULT_STATE,@@ -256,36 +272,105 @@ describe('inboxFiltersLogic', () => {true,true,'ranking_action',+ 'ranking_action','desc',],- ['falls back to the default once the flag is off', 'ranking_action', false, true, 'priority', 'asc'],- ['falls back to the default for a non-staff user', 'ranking_action', true, false, 'priority', 'asc'],+ // The reset reloads the lists, so rows loaded with the model sort do not stay on screen.+ [+ 'resets the stored sort once the flag is off',+ 'ranking_action',+ false,+ true,+ 'recommended',+ 'recommended',+ 'asc',+ ],+ [+ 'resets the stored sort for a non-staff user',+ 'ranking_action',+ true,+ false,+ 'recommended',+ 'recommended',+ 'asc',+ ],['falls back to the default for a stored head the menu no longer offers','ranking_pr_merged',true,true,- 'priority',+ 'ranking_pr_merged',+ 'recommended','asc',],- ] as const)('%s', (_name, storedSortField, flagOn, isStaff, activeSortField, activeSortDirection) => {- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.INBOX_MODEL_SORT], {- [FEATURE_FLAGS.INBOX_MODEL_SORT]: true,- })- userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, is_staff: true })- // A sort persisted by an older build can name a head the type no longer lists.- logic.actions.setSort(storedSortField as InboxSortField, 'desc')+ ] as const)(+ '%s',+ (_name, storedSortField, flagOn, isStaff, sortField, activeSortField, activeSortDirection) => {+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.INBOX_MODEL_SORT], {+ [FEATURE_FLAGS.INBOX_MODEL_SORT]: true,+ })+ userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, is_staff: true })+ // A sort persisted by an older build can name a head the type no longer lists.+ logic.actions.setSort(storedSortField as InboxSortField, 'desc')- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.INBOX_MODEL_SORT], {- [FEATURE_FLAGS.INBOX_MODEL_SORT]: flagOn,- })- userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, is_staff: isStaff })+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.INBOX_MODEL_SORT], {+ [FEATURE_FLAGS.INBOX_MODEL_SORT]: flagOn,+ })+ userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, is_staff: isStaff })- expect(logic.values).toMatchObject({- sortField: storedSortField,- activeSortField,- activeSortDirection,- })+ expect(logic.values).toMatchObject({+ sortField,+ activeSortField,+ activeSortDirection,+ })+ }+ )+ })++ describe('stored sort migration', () => {+ const STORAGE_PREFIX = 'scenes.inbox.logics.inboxFiltersLogic'+ let logic: ReturnType<typeof inboxFiltersLogic.build>++ beforeEach(() => {+ localStorage.clear()+ initKeaTests()+ useMocks({ get: { '/api/projects/:team_id/signals/reports/available_reviewers/': () => [200, {}] } })+ })++ afterEach(() => {+ logic.unmount()+ })++ it.each([+ ['moves the old Priority first default to Recommended', 'priority', 'asc', null, 'recommended', 'asc'],+ ['keeps a Priority first the user picked', 'priority', 'asc', true, 'priority', 'asc'],+ ['keeps Newest first from before Recommended existed', 'created_at', 'desc', null, 'created_at', 'desc'],+ ] as const)('%s', (_name, storedField, storedDirection, chosen, sortField, sortDirection) => {+ localStorage.setItem(`${STORAGE_PREFIX}.sortField`, JSON.stringify(storedField))+ localStorage.setItem(`${STORAGE_PREFIX}.sortDirection`, JSON.stringify(storedDirection))+ if (chosen !== null) {+ localStorage.setItem(`${STORAGE_PREFIX}.hasUserChosenSort`, JSON.stringify(chosen))+ }+ router.actions.push(urls.inbox())++ logic = inboxFiltersLogic()+ logic.mount()++ expect(logic.values).toMatchObject({ sortField, sortDirection })+ expect(router.values.searchParams.sort).toBe(+ sortField === 'recommended' ? undefined : `${sortField}:${sortDirection}`+ )+ })++ it('lets a shared link override the migration', () => {+ localStorage.setItem(`${STORAGE_PREFIX}.sortField`, JSON.stringify('priority'))+ localStorage.setItem(`${STORAGE_PREFIX}.sortDirection`, JSON.stringify('asc'))+ router.actions.push(urls.inbox(), { sort: 'created_at:desc' })++ logic = inboxFiltersLogic()+ logic.mount()++ expect(logic.values).toMatchObject({ sortField: 'created_at', sortDirection: 'desc' })})})})diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.tsindex d103154f7d45..6c57784915f0 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts@@ -1,6 +1,7 @@import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'import { loaders } from 'kea-loaders'import { actionToUrl, router, urlToAction } from 'kea-router'+import { subscriptions } from 'kea-subscriptions'import api from 'lib/api'import { FEATURE_FLAGS } from 'lib/constants'@@ -42,7 +43,7 @@ export interface InboxReviewerOption {}export type InboxRankingSortField = 'ranking_open' | 'ranking_action' | 'ranking_fixed'-export type InboxSortField = 'priority' | 'created_at' | 'updated_at' | InboxRankingSortField+export type InboxSortField = 'recommended' | 'priority' | 'created_at' | 'updated_at' | InboxRankingSortFieldexport type InboxSortDirection = 'asc' | 'desc'/** Preset for the created-in window filter. Null means any time. */export type InboxCreatedWindow = '24h' | '3d' | '7d' | '14d'@@ -50,9 +51,14 @@ export type InboxCreatedWindow = '24h' | '3d' | '7d' | '14d'/** The window a model sort picks when none is set: the ranking sweep only scores reports from the last 7 days. */const MODEL_SORT_DEFAULT_WINDOW: InboxCreatedWindow = '7d'-const DEFAULT_SORT_FIELD: InboxSortField = 'priority'+const DEFAULT_SORT_FIELD: InboxSortField = 'recommended'const DEFAULT_SORT_DIRECTION: InboxSortDirection = 'asc'+/** Whether a stored sort is the old default, which a user who never picked a sort gets moved off. */+function isLegacyDefaultSort(field: InboxSortField, direction: InboxSortDirection): boolean {+ return field === 'priority' && direction === 'asc'+}+/*** The states selected by default: the two that hold open work. The closed states (Resolved,* Dismissed) stay one checkbox away so the fresh inbox leads with what needs a person.@@ -270,6 +276,19 @@ export function buildSignalReportListOrdering(field: InboxSortField, direction:return field === 'updated_at' ? `${fieldKey},status` : `${fieldKey},status,-updated_at`}+/**+ * The sort params for the list request. Recommended is a server preset that a user flag resolves+ * to a ranker, so it goes out as `sort` with no `ordering`, because `ordering` overrides the preset.+ */+export function buildSignalReportListSortParams(+ field: InboxSortField,+ direction: InboxSortDirection+): { ordering?: string; sort?: string } {+ return field === 'recommended'+ ? { sort: 'recommended' }+ : { ordering: buildSignalReportListOrdering(field, direction) }+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface inboxFiltersLogicValues {featureFlags: FeatureFlagsSet // featureFlagLogic@@ -282,6 +301,7 @@ export interface inboxFiltersLogicValues {createdWindow: InboxCreatedWindow | nullhasActiveFilters: booleanhasUserChosenScope: boolean+ hasUserChosenSort: booleanisRedesign: booleanisScopedToMe: booleanknownTeammate: {@@ -344,6 +364,12 @@ export interface inboxFiltersLogicActions {query?: string}}+ migrateLegacyDefaultSort: () => {+ value: true+ }+ resetUnavailableSort: () => {+ value: true+ }searchAvailableReviewers: (query: string) => {query: string}@@ -442,7 +468,7 @@ export type inboxFiltersLogicType = MakeLogicType</*** Persisted inbox filter state. Mirrors desktop's zustand stores:* - `inboxReviewerScopeStore` → `scope` (persisted, default "for-you")- * - `inboxSignalsFilterStore` v2 → `sortField`/`sortDirection` (default priority/asc),+ * - `inboxSignalsFilterStore` v2 → `sortField`/`sortDirection` (default recommended/asc here),* `sourceProductFilter`, `priorityFilter` (all persisted). `searchQuery` is NOT* persisted on desktop, so it isn't here either.*@@ -469,6 +495,11 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([applyDefaultScope: (scope: InboxScope) => ({ scope }),setSearchQuery: (searchQuery: string) => ({ searchQuery }),setSort: (field: InboxSortField, direction: InboxSortDirection) => ({ field, direction }),+ // Moves a user still on the old Priority first default to Recommended. Not a user choice, so+ // it is not a query change and does not rewrite the URL.+ migrateLegacyDefaultSort: true,+ // Resets a stored model sort the user can no longer use, so the lists reload in the default order.+ resetUnavailableSort: true,setCreatedWindow: (createdWindow: InboxCreatedWindow | null) => ({ createdWindow }),// Set by a model sort, not by the user, so it is not a query change of its own.applyDefaultCreatedWindow: (createdWindow: InboxCreatedWindow) => ({ createdWindow }),@@ -615,6 +646,8 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([{setSort: (_, { field }) => field,setFilters: (_, { filters }) => filters.sortField,+ migrateLegacyDefaultSort: () => DEFAULT_SORT_FIELD,+ resetUnavailableSort: () => DEFAULT_SORT_FIELD,},],sortDirection: [@@ -623,6 +656,19 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([{setSort: (_, { direction }) => direction,setFilters: (_, { filters }) => filters.sortDirection,+ migrateLegacyDefaultSort: () => DEFAULT_SORT_DIRECTION,+ resetUnavailableSort: () => DEFAULT_SORT_DIRECTION,+ },+ ],+ // Whether the stored sort is a choice: one the user picked, or one a shared link set. Users+ // stored on Priority first from before Recommended existed have no choice recorded, so+ // `migrateLegacyDefaultSort` can tell them apart from users who pick Priority first now.+ hasUserChosenSort: [+ false,+ { persist: true },+ {+ setSort: () => true,+ setFilters: () => true,},],createdWindow: [@@ -762,6 +808,23 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([],}),+ subscriptions(({ actions, values }) => ({+ // Rows loaded with a model sort carry no merge key. Without a reload, the Recommended merge+ // would show them in an arbitrary order.+ modelSortAvailable: (available: boolean, wasAvailable: boolean | undefined) => {+ if (wasAvailable && !available && isRankingSortField(values.sortField)) {+ actions.resetUnavailableSort()+ }+ },+ })),++ // Before `urlToAction`, so a shared link still wins over the migrated sort.+ afterMount(({ actions, values }) => {+ if (!values.hasUserChosenSort && isLegacyDefaultSort(values.sortField, values.sortDirection)) {+ actions.migrateLegacyDefaultSort()+ }+ }),+actionToUrl(({ values }) => {// Every filter mutation rewrites the current URL from the full (non-default) filter state.const toUrl = (): [string, Record<string, any>, any, { replace: boolean }] => currentUrlWithFilters(values)@@ -771,6 +834,7 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([setScope: toUrl,applyDefaultScope: toUrl,setSort: toUrl,+ resetUnavailableSort: toUrl,setCreatedWindow: toUrl,applyDefaultCreatedWindow: toUrl,toggleSourceProduct: toUrl,diff --git a/products/signals/frontend/inbox/logics/reportListLogic.ts b/products/signals/frontend/inbox/logics/reportListLogic.tsindex 0e7004f1889a..10c651a52bb1 100644--- a/products/signals/frontend/inbox/logics/reportListLogic.ts+++ b/products/signals/frontend/inbox/logics/reportListLogic.ts@@ -21,7 +21,7 @@ import {import type { SignalReportMetricSnapshotsApi } from 'products/signals/frontend/generated/api.schemas'import { createdAfterForWindow } from '../filterOptions'-import { captureInboxReportAction, type InboxReportActionSurface } from '../inboxAnalytics'+import { captureInboxReportAction, type InboxReportActionSurface, setInboxServedRanker } from '../inboxAnalytics'import {INBOX_LEGACY_PRIMARY_REPORT_SECTION_KEY,INBOX_PRIMARY_REPORT_SECTION_KEY,@@ -39,7 +39,7 @@ import { isInboxRedesignEnabled } from '../utils/inboxRedesign'import { isReportMetricsEnabled, mergeReportMetricSnapshots, reportNeedsMetricRefresh } from '../utils/reportMetrics'import { reportPullRequests, primaryReportPullRequest } from '../utils/reportPullRequests'import { inboxBulkActionsLogic } from './inboxBulkActionsLogic'-import { buildSignalReportListOrdering, inboxFiltersLogic } from './inboxFiltersLogic'+import { buildSignalReportListSortParams, inboxFiltersLogic } from './inboxFiltersLogic'import type { InboxCreatedWindow, InboxFilterState, InboxSortDirection, InboxSortField } from './inboxFiltersLogic'import { prCiStatusLogic } from './prCiStatusLogic'@@ -64,6 +64,8 @@ export interface ReportListRequestContext {/** A list response stamped with the query params and display context that produced it (see the loader). */export type ReportListResponse = CountedPaginatedResponse<SignalReport> & {+ /** The ranker the server used for `sort=recommended`. Null for every other sort. */+ ranker?: string | nullrequestParams?: Record<string, unknown>requestContext?: ReportListRequestContext}@@ -196,6 +198,7 @@ export interface reportListLogicValues {livePrReportIds: string[]loadedContext: ReportListRequestContext | nullloadedQueryKey: string | null+ loadedRanker: string | nullpageLoadFailed: booleanprimarySectionKey: InboxReportSectionKeyreportSourceMeta: Record<string, ReportSourceMeta>@@ -220,6 +223,9 @@ export interface reportListLogicActions {clearFilters: () => {value: true} // inboxFiltersLogic+ resetUnavailableSort: () => {+ value: true+ } // inboxFiltersLogicsetCreatedWindow: (createdWindow: InboxCreatedWindow | null) => {createdWindow: InboxCreatedWindow | null} // inboxFiltersLogic@@ -397,6 +403,7 @@ export interface reportListLogicMeta {totalCount: (reportsResponse: ReportListResponse | null) => number | nullloadedQueryKey: (reportsResponse: ReportListResponse | null) => string | nullloadedContext: (reportsResponse: ReportListResponse | null) => ReportListRequestContext | null+ loadedRanker: (reportsResponse: ReportListResponse | null) => string | null}}@@ -450,6 +457,7 @@ export const reportListLogic = kea<reportListLogicType>([['setSearchQuery','setSort',+ 'resetUnavailableSort','toggleSourceProduct','toggleScout','togglePriority',@@ -667,7 +675,7 @@ export const reportListLogic = kea<reportListLogicType>([return {...listParams,search: searchQuery.trim() || undefined,- ordering: buildSignalReportListOrdering(sortField, sortDirection),+ ...buildSignalReportListSortParams(sortField, sortDirection),source_product: sourceProductFilter.length > 0 ? sourceProductFilter.join(',') : undefined,scout: scoutFilter.length > 0 ? scoutFilter.join(',') : undefined,priority: priorityFilter.length > 0 ? priorityFilter.join(',') : undefined,@@ -746,6 +754,11 @@ export const reportListLogic = kea<reportListLogicType>([(reportsResponse: ReportListResponse | null): ReportListRequestContext | null =>reportsResponse?.requestContext ?? null,],+ // The ranker the server used for a Recommended list: `priority` or a model head. Null for other sorts.+ loadedRanker: [+ (s) => [s.reportsResponse],+ (reportsResponse: ReportListResponse | null): string | null => reportsResponse?.ranker ?? null,+ ],}),listeners(({ actions, values, props, cache }) => ({@@ -753,6 +766,7 @@ export const reportListLogic = kea<reportListLogicType>([// loaders report: the first page and each appended page bring rows that need painting. An// empty announcement matters too, because it retires the rows a narrowed filter dropped.loadReportsSuccess: () => {+ setInboxServedRanker(values.loadedRanker)actions.trackReports(props.sectionKey, values.livePrReportIds)actions.refreshReportMetrics(values.staleMetricReportIds)// A first page or a refresh asks again for every row, because a report gains sources as@@ -856,6 +870,7 @@ export const reportListLogic = kea<reportListLogicType>([actions.refresh()},setSort: () => actions.refresh(),+ resetUnavailableSort: () => actions.refresh(),setCreatedWindow: () => actions.refresh(),applyDefaultCreatedWindow: () => actions.refresh(),toggleSourceProduct: () => actions.refresh(),diff --git a/products/signals/frontend/inbox/types.ts b/products/signals/frontend/inbox/types.tsindex edbb239c78c7..d44355df048c 100644--- a/products/signals/frontend/inbox/types.ts+++ b/products/signals/frontend/inbox/types.ts@@ -150,6 +150,8 @@ export interface SignalReport {refund_ineligibility_reason?: string | null/** The served ranking model's score. Staff only: null for other users and for unscored reports. */ranking?: ReportRankingApi | null+ /** Coarse sort key from the list response's ranker, for the Recommended sort only. Lower keys rank first. */+ inbox_merge_key?: number | null}export enum SignalReportStatus {diff --git a/products/signals/frontend/inbox/utils/flatReportList.test.ts b/products/signals/frontend/inbox/utils/flatReportList.test.tsnew file mode 100644index 000000000000..078d17106f92--- /dev/null+++ b/products/signals/frontend/inbox/utils/flatReportList.test.ts@@ -0,0 +1,66 @@+import { InboxReportSectionKey, SignalReport, SignalReportStatus } from '../types'+import { mergeReportRows } from './flatReportList'++function report(id: string, overrides: Partial<SignalReport> = {}): SignalReport {+ return {+ id,+ title: id,+ summary: null,+ status: SignalReportStatus.READY,+ total_weight: 0,+ signal_count: 1,+ artefact_count: 0,+ is_suggested_reviewer: false,+ priority: 'P2',+ created_at: '2026-06-01T10:00:00Z',+ updated_at: '2026-06-01T10:00:00Z',+ ...overrides,+ }+}++function sections(+ rows: Partial<Record<InboxReportSectionKey, SignalReport[]>>+): Record<InboxReportSectionKey, SignalReport[]> {+ return {+ monitoring: [],+ 'needs-decision': [],+ resolved: [],+ dismissed: [],+ 'held-back': [],+ 'not-actionable': [],+ ...rows,+ }+}++describe('mergeReportRows', () => {+ // The server orders a Recommended response by the raw score, so the coarse key is not monotonic+ // within one response. A plain sort by key would undo that order.+ it('merges Recommended responses by the merge key and keeps each response in server order', () => {+ const rows = mergeReportRows(+ sections({+ monitoring: [+ report('m-key-9', { inbox_merge_key: 9 }),+ report('m-key-6', { inbox_merge_key: 6 }),+ report('m-unkeyed', { inbox_merge_key: null }),+ ],+ 'needs-decision': [+ report('n-key-3', { inbox_merge_key: 3, priority: 'P4' }),+ report('n-key-9', { inbox_merge_key: 9, priority: 'P0' }),+ report('n-key-20', { inbox_merge_key: 20 }),+ ],+ }),+ ['monitoring', 'needs-decision'],+ 'recommended',+ 'asc'+ )++ expect(rows.map((row) => [row.report.id, row.sectionKey])).toEqual([+ ['n-key-3', 'needs-decision'],+ ['m-key-9', 'monitoring'],+ ['m-key-6', 'monitoring'],+ ['n-key-9', 'needs-decision'],+ ['n-key-20', 'needs-decision'],+ ['m-unkeyed', 'monitoring'],+ ])+ })+})diff --git a/products/signals/frontend/inbox/utils/flatReportList.ts b/products/signals/frontend/inbox/utils/flatReportList.tsindex f1b44d17e5f1..ef22b29180a4 100644--- a/products/signals/frontend/inbox/utils/flatReportList.ts+++ b/products/signals/frontend/inbox/utils/flatReportList.ts@@ -31,13 +31,43 @@ export function selectedFlatListSections(: visibleSections}+/**+ * Merge per-state rows that are each already in server order. Each step takes the state head with the+ * lowest key, and an earlier state wins a tie. Unlike a sort, this keeps each response's own order,+ * which the server set from finer data than the merge key carries.+ */+function mergeSortedSections(+ rowsBySection: MergedReportRow[][],+ compare: (a: SignalReport, b: SignalReport) => number+): MergedReportRow[] {+ const cursors = rowsBySection.map(() => 0)+ const merged: MergedReportRow[] = []+ for (;;) {+ let best = -1+ rowsBySection.forEach((rows, index) => {+ if (+ cursors[index] < rows.length &&+ (best === -1 || compare(rows[cursors[index]].report, rowsBySection[best][cursors[best]].report) < 0)+ ) {+ best = index+ }+ })+ if (best === -1) {+ return merged+ }+ merged.push(rowsBySection[best][cursors[best]])+ cursors[best] += 1+ }+}+/*** The flat list's rows: the loaded rows of every selected state, deduplicated (a report can match* two states' filters, e.g. a PR'd report judged not actionable is in both Review and merge and the* staff Not actionable state; the first state in canonical order claims it), then ordered with the- * same keys the server sorted each response by. Rows past a state's loaded page can sort below- * later-keyed rows from a shorter state until the next page lands; the scroll sentinel keeps every- * selected state paging together.+ * same keys the server sorted each response by. The Recommended sort merges the responses by the+ * server's merge key instead, because the server orders each response by a score it does not send.+ * Rows past a state's loaded page can sort below later-keyed rows from a shorter state until the+ * next page lands; the scroll sentinel keeps every selected state paging together.*/export function mergeReportRows(reportsBySection: Record<InboxReportSectionKey, SignalReport[]>,@@ -46,15 +76,20 @@ export function mergeReportRows(sortDirection: InboxSortDirection): MergedReportRow[] {const seen = new Set<string>()- const rows: MergedReportRow[] = []+ const rowsBySection: MergedReportRow[][] = []for (const sectionKey of selectedSections) {+ const sectionRows: MergedReportRow[] = []for (const report of reportsBySection[sectionKey]) {if (!seen.has(report.id)) {seen.add(report.id)- rows.push({ report, sectionKey })+ sectionRows.push({ report, sectionKey })}}+ rowsBySection.push(sectionRows)}const compare = compareSignalReports(sortField, sortDirection)- return rows.sort((a, b) => compare(a.report, b.report))+ if (sortField === 'recommended') {+ return mergeSortedSections(rowsBySection, compare)+ }+ return rowsBySection.flat().sort((a, b) => compare(a.report, b.report))}diff --git a/products/signals/frontend/inbox/utils/reportOrdering.ts b/products/signals/frontend/inbox/utils/reportOrdering.tsindex 538a3a51496c..f039ee3f96d1 100644--- a/products/signals/frontend/inbox/utils/reportOrdering.ts+++ b/products/signals/frontend/inbox/utils/reportOrdering.ts@@ -56,6 +56,20 @@ export function rankingSortScore(report: SignalReport, field: InboxRankingSortFireturn typeof score === 'number' ? score : null}+/**+ * The Recommended sort's comparator. The server orders each response by the ranker's fine-grained+ * order and gives each row only a coarse merge key, so rows with equal keys keep their input order.+ * A row without a key sorts last.+ */+export function compareInboxMergeKeys(a: SignalReport, b: SignalReport): number {+ const keyA = a.inbox_merge_key ?? null+ const keyB = b.inbox_merge_key ?? null+ if (keyA === null || keyB === null) {+ return keyA === keyB ? 0 : keyA === null ? 1 : -1+ }+ return keyA - keyB+}+// The server puts unscored reports after every scored report, in both directions.function compareRankingScores(a: number | null, b: number | null, dir: number): number {if (a === null || b === null) {@@ -69,6 +83,9 @@ export function compareSignalReports(field: InboxSortField,direction: InboxSortDirection): (a: SignalReport, b: SignalReport) => number {+ if (field === 'recommended') {+ return compareInboxMergeKeys+ }const dir = direction === 'desc' ? -1 : 1return (a, b) => {if (isRankingSortField(field)) {