: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): show open, engage and fix ranking scores in the inbox (#115067)
posthog[bot]16a353e1519e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 543ec95345fb..faf9348b41ab 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -10918,6 +10918,10 @@ snapshots:hash: v1.k794b7964.4ce62fb05fc7b7b3451f940f333fe5894684ee134d50ed368bf05ed777466f3e.2arUhgxbdC9zFLt7VkffoeMNivMf_oZtsNPWQdrjH6cscenes-app-inbox-cards--pull-request-cards--light:hash: v1.k794b7964.19291313347041d3b8311d7a7e9b97ee8e60b7ccca476b1b3c43945a006de3fe.Lf3Mkhh7fJ5mnyomCZa2-Jcw4fOG4rgHZ5udu8CQNxg+ scenes-app-inbox-cards--report-card-ranking-tags--dark:+ hash: v1.k794b7964.abaf20aa7af1b1f3c1a6ccddab0e1165edd3cf45aaaec52d731367ed96e0d261.YVDei7lwTJkKyFpmmib-c_x-RLTGj8g63o5l33J0aag+ scenes-app-inbox-cards--report-card-ranking-tags--light:+ hash: v1.k794b7964.ee26ad3306af01e0c2e236809b2b65d794fdec1a39711ba0bc0700e1b2115f91.0vg4Aq4ScTkIch24e-EIvvT5FBlvNo4anozdw0lnJpsscenes-app-inbox-cards--report-card-states--dark:hash: v1.k794b7964.b987dc8b9a750647567259b3cfb6f65c1fc03c82294e599942d85f394182ec5f.tJh2uAs0GnyekhEbDh2gi3yZAm6ydVS4Tp8YEAowHccscenes-app-inbox-cards--report-card-states--light:@@ -14047,13 +14051,17 @@ snapshots:scenes-app-signals-artefactloglist--narrow--light:hash: v1.k794b7964.bc1bb17c0d0961d5b227fd437b445c7bd80e368d17beebe24e1c35f6ec962d18.NfYGRA8WerwD9NaJgX1I1fN3ZjRIb2fYJzJhlEiKubgscenes-app-signals-artefactloglist--ranking-score--dark:- hash: v1.k794b7964.a1cdfe743da3d2a27f7c85348a21b91bbd53ee02d1b9b6343f655cf042429855.EzgFt1k__5XCzw-0kS-sIYCpda-wtXeRCWmr05Q7n8M+ hash: v1.k794b7964.b2f6ecde64678b491e63960e212656014e26e0611601b29f975b797bf8c82ed2.fcO6NcbOIYxiZeLjd-JdG1BP0Mrk8nfNuj6a1AOS9AUscenes-app-signals-artefactloglist--ranking-score--light:- hash: v1.k794b7964.050c82bd6a9b5a30635677b03aed359aefafc825ea2545c5d1c61a4094587103.RWpu_yd7-1cgZXSOaGp2xtgDCH0AKCp1PaTjpItHROk+ hash: v1.k794b7964.9685c0e156d7aeb1473c4f7f77146f435ff21296909830abf39f620af9acf949.XX4CUKAxDWeV3C5vXULvpfVI1yOCd0hpi0WCT2KXAvU+ scenes-app-signals-artefactloglist--ranking-score-all-heads--dark:+ hash: v1.k794b7964.5cf2508f92e498071cf00b89916c9ceb6f1552c8b740ed63a62e185b4a8be59e.nAFTq4vg0FmgttoOvK_R1nMS4nxxl7-QfmqyA2Qnq88+ scenes-app-signals-artefactloglist--ranking-score-all-heads--light:+ hash: v1.k794b7964.59e9dff519bf23a0a343e7e6dd4976985486f823a73d0dd18140ab09bd89c666.bSSYwoWPv0Mei1LH-1L1tSe1r7wtnqcUVmW0xV8XxBsscenes-app-signals-artefactloglist--ranking-score-narrow--dark:- hash: v1.k794b7964.c42f2e1343bcdb3af03821ddc41269dfdde5f66c30cd52bb12cfe4133b4b5bb7.4plC8pdl_1Ju8IFWB8eqxCN8cUApwkNJ1MmA6JLoHZk+ hash: v1.k794b7964.c45f6c6f88fb8ec781d72d315e0447e12819e2e582aa457f79858cbc0e079549.kD4Ij85HrhYA9pyNaOiidYDdoX3SSqdma7NexCPydjYscenes-app-signals-artefactloglist--ranking-score-narrow--light:- hash: v1.k794b7964.61a61a657c98db9fb58f9f2b5ce2ca8fa5a61d3618fa87241e57709d7a4653e1.CuCHWqC9HRUTVypQtpAbEwjxOkxmI-WoI1K6t1STd80+ hash: v1.k794b7964.e6db177d796824ba271ca2a2fce62c6a637df3586753b2a5651c3c884a8feac2.hXYW48r-72Ns5eA4yz9fak_rR3IF0qbYVXlK8fhyj-wscenes-app-signals-artefactloglist--replacement-lifecycle--dark:hash: v1.k794b7964.f723b2160bdf85cd5a827fa3dac4c281d75950f47555cdef7fc01f2ef689dfc6.wAOg7AG2Pf4mYO8EjKdD8lFlC1Ulv4MhkXIEMkzfCrgscenes-app-signals-artefactloglist--replacement-lifecycle--light:diff --git a/products/signals/frontend/inbox/components/cards/InboxCards.stories.tsx b/products/signals/frontend/inbox/components/cards/InboxCards.stories.tsxindex 97407fef4fc4..923dc031969d 100644--- a/products/signals/frontend/inbox/components/cards/InboxCards.stories.tsx+++ b/products/signals/frontend/inbox/components/cards/InboxCards.stories.tsx@@ -5,6 +5,8 @@ import { FEATURE_FLAGS } from 'lib/constants'import { NodeKind, type InsightVizNode, type TrendsQuery } from '~/queries/schema/schema-general'import { BaseMathType, ChartDisplayType, PropertyMathType } from '~/types'+import { userEvent } from 'storybook/test'+import { makeReport, pullRequestReports, reportTabReports, runReportsMany } from '../../__mocks__/inboxMocks'import { SignalReport, SignalReportStatus } from '../../types'import { AgentRunCard } from './AgentRunCard'@@ -255,6 +257,56 @@ export const ReportCardWithImpact: Story = {),}+const RANKING = {+ served_key: 'report_embeddings@2026-06-10',+ model_name: 'report_embeddings',+ model_version: '2026-06-10',+ manifest_version: '12',+ scored_at: '2026-06-10T09:00:00Z',+ readable_heads: ['open', 'action', 'fixed', 'pr_merged'],+ stale: false,+}++// Under the Engage sort: a lift, a probability with no lift, an unscored report, and a report edited after scoring.+const rankedReports: SignalReport[] = [+ makeReport({+ title: 'Checkout button does nothing on Safari',+ priority: 'P1',+ source_products: ['session_replay'],+ ranking: {+ ...RANKING,+ scores: { open: 0.91, action: 0.78, fixed: 0.33, pr_merged: 0.52 },+ lifts: { open: 1.1, action: 2.1, fixed: 2.2, pr_merged: 2.6 },+ },+ }),+ makeReport({+ title: 'Slow dashboard load for large projects',+ priority: 'P2',+ source_products: ['error_tracking'],+ ranking: { ...RANKING, scores: { open: 0.4, action: 0.062, fixed: 0.05 }, lifts: {} },+ }),+ makeReport({ title: 'Typo in the billing settings page', priority: 'P4', ranking: null }),+ makeReport({+ title: 'Retry loop in the export job',+ priority: 'P3',+ ranking: { ...RANKING, scores: { action: 0.5 }, lifts: { action: 1.2 }, stale: true },+ }),+]++export const ReportCardRankingTags: Story = {+ parameters: { featureFlags: [FEATURE_FLAGS.INBOX_REDESIGN] },+ render: () => (+ <CardList>+ {rankedReports.map((report) => (+ <ReportCard key={report.id} report={report} rankingSortField="ranking_action" />+ ))}+ </CardList>+ ),+ play: async ({ canvas }) => {+ await userEvent.hover(await canvas.findByText('2.1x engage'))+ },+}+export const PullRequestCards: Story = {render: () => (<Stack>diff --git a/products/signals/frontend/inbox/components/cards/ReportCard.test.tsx b/products/signals/frontend/inbox/components/cards/ReportCard.test.tsxindex d11275fd2e47..d9aaad81029c 100644--- a/products/signals/frontend/inbox/components/cards/ReportCard.test.tsx+++ b/products/signals/frontend/inbox/components/cards/ReportCard.test.tsx@@ -413,12 +413,12 @@ describe('ReportCard', () => {})it.each([- ['with the impact column', true, 'ranking_pr_merged', '2.7x merge'],+ ['with the impact column', true, 'ranking_fixed', '2.7x fix'],['without the impact column, falling back to the probability for a head with no lift',false,'ranking_action',- '6.2% action',+ '6.2% engage',],] as const)('shows the active head lift in the meta row %s', (_name, impactColumn, sortField, tagText) => {// The harness renders a card for every test; these assert against their own.@@ -432,9 +432,9 @@ describe('ReportCard', () => {model_version: '2026-09-30',manifest_version: 'manifest',scored_at: '2026-09-30T12:00:00Z',- scores: { pr_merged: 0.41, action: 0.062 },- lifts: { pr_merged: 2.7 },- readable_heads: ['action', 'pr_merged'],+ scores: { fixed: 0.41, action: 0.062 },+ lifts: { fixed: 2.7 },+ readable_heads: ['action', 'fixed'],stale: false,},})@@ -450,7 +450,7 @@ describe('ReportCard', () => {// The harness renders a card for every test; these assert against their own.cleanup()enableRedesign()- const { rerender } = render(<ReportCard report={makeReport('r-2')} rankingSortField="ranking_pr_merged" />)+ const { rerender } = render(<ReportCard report={makeReport('r-2')} rankingSortField="ranking_fixed" />)expect(screen.getByText('Not scored')).toBeInTheDocument()const stale = makeReport('r-2', {@@ -460,15 +460,15 @@ describe('ReportCard', () => {model_version: '2026-09-30',manifest_version: 'manifest',scored_at: '2026-09-30T12:00:00Z',- scores: { pr_merged: 0.41 },- lifts: { pr_merged: 2.7 },- readable_heads: ['pr_merged'],+ scores: { fixed: 0.41 },+ lifts: { fixed: 2.7 },+ readable_heads: ['fixed'],stale: true,},})- rerender(<ReportCard report={stale} rankingSortField="ranking_pr_merged" />)+ rerender(<ReportCard report={stale} rankingSortField="ranking_fixed" />)expect(screen.getByText('Edited since scored')).toBeInTheDocument()- expect(screen.queryByText('2.7x merge')).not.toBeInTheDocument()+ expect(screen.queryByText('2.7x fix')).not.toBeInTheDocument()rerender(<ReportCard report={makeReport('r-2')} />)expect(screen.queryByText('Not scored')).not.toBeInTheDocument()diff --git a/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsx b/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsxindex d8d8b514d038..a8842afdf0bc 100644--- a/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsx+++ b/products/signals/frontend/inbox/components/cards/ReportCardRankingTag.tsx@@ -2,7 +2,7 @@ import clsx from 'clsx'import { LemonTag, Tooltip } from '@posthog/lemon-ui'-import { RANKING_HEAD_LABELS, RANKING_SORT_HEADS } from '../../filterOptions'+import { INBOX_RANKING_SCORES, InboxRankingScore, rankingScoreForField } from '../../filterOptions'import type { InboxRankingSortField } from '../../logics/inboxFiltersLogic'import { SignalReport } from '../../types'import { formatRankingLift, formatRankingProbability } from './rankingFormat'@@ -15,22 +15,24 @@ function rankingLift(ranking: NonNullable<SignalReport['ranking']>, head: stringfunction RankingTooltip({ranking,- head,+ active,}: {ranking: NonNullable<SignalReport['ranking']>- head: string+ active: InboxRankingScore}): JSX.Element {- const heads = [head, ...ranking.readable_heads.filter((name) => name !== head)].filter(- (name) => typeof ranking.scores[name] === 'number'+ const scores = [active, ...INBOX_RANKING_SCORES.filter((score) => score !== active)].filter(+ (score) =>+ typeof ranking.scores[score.head] === 'number' &&+ (score === active || ranking.readable_heads.includes(score.head)))return (<div className="flex min-w-72 flex-col gap-1 text-xs">- {heads.map((name) => {- const probability = ranking.scores[name]- const lift = rankingLift(ranking, name)+ {scores.map((score) => {+ const probability = ranking.scores[score.head]+ const lift = rankingLift(ranking, score.head)return (- <div key={name} className={clsx('flex items-center gap-2', name === head && 'font-bold')}>- <span className="w-28 shrink-0">{RANKING_HEAD_LABELS[name] ?? name}</span>+ <div key={score.head} className={clsx('flex items-center gap-2', score === active && 'font-bold')}>+ <span className="w-28 shrink-0">{score.name}</span><span className="flex-1"><RankingLiftBar lift={lift} /></span>@@ -59,7 +61,8 @@ export function ReportCardRankingTag({report: SignalReportsortField: InboxRankingSortField}): JSX.Element {- const { head, tagLabel } = RANKING_SORT_HEADS[sortField]+ const score = rankingScoreForField(sortField)+ const { head, tagLabel } = scoreconst probability = report.ranking?.scores[head]const lift = report.ranking ? rankingLift(report.ranking, head) : nullif (!report.ranking || typeof probability !== 'number') {@@ -79,7 +82,7 @@ export function ReportCardRankingTag({)}return (- <Tooltip title={<RankingTooltip ranking={report.ranking} head={head} />}>+ <Tooltip title={<RankingTooltip ranking={report.ranking} active={score} />}><LemonTag size="small" className="cursor-help tabular-nums" data-attr="inbox-ranking-tag">{lift !== null ? formatRankingLift(lift) : formatRankingProbability(probability)} {tagLabel}</LemonTag>diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsxindex 50c713226024..c28a28bc2987 100644--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.stories.tsx@@ -281,11 +281,20 @@ const rankingArtefacts = [roles: ['served'],feature_schema_version: 3,status: 'scored',- scores: { action: 0.78, pr_merged: 0.52, dismiss_wrong: 0.14, reviewer_fix: 0.04 },- lifts: { action: 1.3, pr_merged: 2.6, dismiss_wrong: 0.7 },+ scores: {+ open: 0.91,+ action: 0.78,+ fixed: 0.33,+ pr_merged: 0.52,+ dismiss_wrong: 0.14,+ reviewer_fix: 0.04,+ },+ lifts: { open: 1.1, action: 1.3, fixed: 2.2, pr_merged: 2.6, dismiss_wrong: 0.7 },metadata: {heads: [+ { head: 'open', readable: true, refit_classification_threshold: 0.8 },{ head: 'action', readable: true, refit_classification_threshold: 0.6 },+ { head: 'fixed', readable: true, refit_classification_threshold: 0.15 },{ head: 'pr_merged', readable: true, refit_classification_threshold: 0.2 },{ head: 'dismiss_wrong', readable: true, refit_classification_threshold: 0.2 },{ head: 'reviewer_fix', readable: false },@@ -299,10 +308,12 @@ const rankingArtefacts = [roles: ['challenger'],feature_schema_version: 3,status: 'scored',- scores: { action: 0.74, pr_merged: 0.55, dismiss_wrong: 0.11 },+ scores: { open: 0.88, action: 0.74, fixed: 0.29, pr_merged: 0.55, dismiss_wrong: 0.11 },metadata: {heads: [+ { head: 'open', readable: true, refit_classification_threshold: 0.8 },{ head: 'action', readable: true, refit_classification_threshold: 0.6 },+ { head: 'fixed', readable: true, refit_classification_threshold: 0.15 },{ head: 'pr_merged', readable: true, refit_classification_threshold: 0.2 },{ head: 'dismiss_wrong', readable: true, refit_classification_threshold: 0.2 },],@@ -330,11 +341,23 @@ const openOtherModels: Story['play'] = async ({ canvas }) => {summary.closest('details')?.setAttribute('open', '')}+const openAllDisclosures: Story['play'] = async ({ canvas, canvasElement }) => {+ // The list renders after play starts, so wait for the disclosure or the snapshot catches it closed.+ await canvas.findByText(/Other models/)+ canvasElement.querySelectorAll('details').forEach((details) => details.setAttribute('open', ''))+}+export const RankingScore: Story = {parameters: { mockDate: '2026-09-29T10:00:00Z' },args: { artefacts: rankingArtefacts },play: openOtherModels,}+/** Every head of every model, for debugging a score. */+export const RankingScoreAllHeads: Story = {+ parameters: { mockDate: '2026-09-29T10:00:00Z' },+ args: { artefacts: rankingArtefacts },+ play: openAllDisclosures,+}export const RankingScoreNarrow: Story = {parameters: { mockDate: '2026-09-29T10:00:00Z' },args: { artefacts: rankingArtefacts },diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsxindex ca0a081d75e9..756f44b701a4 100644--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsx+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.test.tsx@@ -205,7 +205,7 @@ describe('ArtefactLogList', () => {)})- it('shows the served ranking model heads, highest lift first, with challengers behind a disclosure', () => {+ it('shows the three scores first, with the other heads and the challengers behind collapsed disclosures', () => {const { container } = render(<ArtefactLogListreportId="report-1"@@ -219,7 +219,7 @@ describe('ArtefactLogList', () => {'report_embeddings@2026-06-10': {status: 'scored',roles: ['served'],- scores: { pr_merged: 0.52, action: 0.78, refund: 0.04, open: 0.9 },+ scores: { pr_merged: 0.52, action: 0.78, refund: 0.04, open: 0.9, fixed: 0.3 },lifts: { action: 1.5 },metadata: {heads: [@@ -227,6 +227,7 @@ describe('ArtefactLogList', () => {{ head: 'pr_merged', readable: true, refit_classification_threshold: 0.2 },{ head: 'refund', readable: false, refit_classification_threshold: 0.01 },{ head: 'open', readable: true },+ { head: 'fixed', readable: true, refit_classification_threshold: 0.15 },],},},@@ -245,12 +246,27 @@ describe('ArtefactLogList', () => {)expect(screen.getByText('Ranking scored')).toBeInTheDocument()- // Stored lifts win over the metadata threshold, and a head with no threshold sorts last.- expect(screen.getAllByText(/^[\d.]+x$/).map((node) => node.textContent)).toEqual(['4.0x', '2.6x', '1.5x'])- expect(screen.getAllByText(/^[\d.]+%$/).map((node) => node.textContent)).toEqual(['4.0%', '52%', '78%', '90%'])+ expect(screen.getByText('Open')).toBeInTheDocument()+ expect(screen.getByText('Engage')).toBeInTheDocument()+ expect(screen.getByText('Fix')).toBeInTheDocument()+ // The scores keep their display order. The other heads sort highest lift first, and stored lifts win over the metadata threshold.+ expect(screen.getAllByText(/^[\d.]+x$/).map((node) => node.textContent)).toEqual([+ '1.5x',+ '2.0x',+ '4.0x',+ '2.6x',+ ])+ expect(screen.getAllByText(/^[\d.]+%$/).map((node) => node.textContent)).toEqual([+ '90%',+ '78%',+ '30%',+ '4.0%',+ '52%',+ ])expect(screen.getByLabelText('No holdout read for this head yet').closest('span')).toHaveTextContent('4.0%')+ expect(screen.getByText('Other heads (2)').closest('details')).toContainElement(screen.getByText('Refund'))expect(screen.getByText('Other models (1)')).toBeInTheDocument()- expect(container.querySelector('details')).not.toHaveAttribute('open')+ container.querySelectorAll('details').forEach((details) => expect(details).not.toHaveAttribute('open'))expect(screen.getByText('Skipped: missing report vector')).toBeInTheDocument()})diff --git a/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx b/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsxindex 09c2c4ea6dd0..152d379abd3b 100644--- a/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx+++ b/products/signals/frontend/inbox/components/detail/ArtefactLogList.tsx@@ -36,7 +36,7 @@ import { urls } from 'scenes/urls'import { Task } from 'products/posthog_ai/frontend/types/taskTypes'import type { SignalReportPullRequestApi } from 'products/signals/frontend/generated/api.schemas'-import { PRIORITY_TAG_TYPE } from '../../filterOptions'+import { INBOX_RANKING_SCORES, PRIORITY_TAG_TYPE, rankingScoreForHead } from '../../filterOptions'import { SignalCard } from '../../SignalCard'import { EnrichedReviewer, SignalReportActionability, SignalReportPriority, SignalReportArtefact } from '../../types'import { SignalReportActionabilityBadge } from '../badges/SignalReportActionabilityBadge'@@ -485,9 +485,16 @@ function RankingHeadRows({ heads }: { heads: RankingHead[] }): JSX.Element {<div className="grid grid-cols-[minmax(0,max-content)_minmax(2rem,10rem)_auto_auto] items-center justify-start gap-x-2 gap-y-1">{heads.map((head) => {const tone = head.readable ? 'text-default' : 'text-tertiary'+ const score = rankingScoreForHead(head.name)return (<Fragment key={head.name}>- <span className={`truncate ${tone}`}>{prettify(head.name)}</span>+ {score ? (+ <Tooltip title={score.description}>+ <span className={`truncate ${tone}`}>{score.name}</span>+ </Tooltip>+ ) : (+ <span className={`truncate ${tone}`}>{prettify(head.name)}</span>+ )}<RankingLiftBarlift={head.lift}className={head.readable ? 'bg-primary-3000' : 'bg-border-bold'}@@ -512,11 +519,30 @@ function RankingHeadRows({ heads }: { heads: RankingHead[] }): JSX.Element {)}+/** The three scores first, in display order. Every other head stays behind a collapsed disclosure for debugging. */+function RankingHeads({ heads }: { heads: RankingHead[] }): JSX.Element {+ const scoreHeads = INBOX_RANKING_SCORES.flatMap((score) => heads.filter((head) => head.name === score.head))+ const otherHeads = heads.filter((head) => !rankingScoreForHead(head.name))+ return (+ <div className="flex min-w-0 flex-col gap-1">+ {scoreHeads.length > 0 ? <RankingHeadRows heads={scoreHeads} /> : null}+ {otherHeads.length > 0 ? (+ <details>+ <summary className="cursor-pointer text-secondary">Other heads ({otherHeads.length})</summary>+ <div className="mt-1 pl-3">+ <RankingHeadRows heads={otherHeads} />+ </div>+ </details>+ ) : null}+ </div>+ )+}+function RankingModelResult({ model }: { model: RankingModel }): JSX.Element {return model.status === 'skipped' || model.heads.length === 0 ? (<span className="text-tertiary">Skipped{model.skipReason ? `: ${model.skipReason}` : ''}</span>) : (- <RankingHeadRows heads={model.heads} />+ <RankingHeads heads={model.heads} />)}diff --git a/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx b/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsxindex a1d63ff8da29..20501734e6b9 100644--- a/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx@@ -5,7 +5,6 @@ import { LemonSelect } from '@posthog/lemon-ui'import {INBOX_CREATED_WINDOW_OPTIONS,INBOX_MODEL_SORT_OPTIONS,- INBOX_MODEL_SORT_SECTIONS,INBOX_PRIORITY_OPTIONS,INBOX_SORT_OPTIONS,inboxPriorityFilterLabel,@@ -37,14 +36,15 @@ const PRIORITY_SELECT_OPTIONS = [// No icons: the trigger reads out the active option, and an icon there would crowd the label the// order is already stated in.-const toSortSelectOption = (option: InboxSortOption): { value: string; label: string } => ({+const toSortSelectOption = (option: InboxSortOption): { value: string; label: string; tooltip?: string } => ({value: inboxSortOptionKey(option.field, option.direction),label: option.label,+ tooltip: option.description,})const SORT_SELECT_OPTIONS = INBOX_SORT_OPTIONS.map(toSortSelectOption)const SORT_SELECT_SECTIONS_WITH_MODEL = [{ options: SORT_SELECT_OPTIONS },- ...INBOX_MODEL_SORT_SECTIONS.map(({ title, options }) => ({ title, options: options.map(toSortSelectOption) })),+ { title: 'Model scores', options: INBOX_MODEL_SORT_OPTIONS.map(toSortSelectOption) },]const ALL_SORT_OPTIONS = [...INBOX_SORT_OPTIONS, ...INBOX_MODEL_SORT_OPTIONS]diff --git a/products/signals/frontend/inbox/filterOptions.tsx b/products/signals/frontend/inbox/filterOptions.tsxindex e2a943b55c67..cf304cd54b9c 100644--- a/products/signals/frontend/inbox/filterOptions.tsx+++ b/products/signals/frontend/inbox/filterOptions.tsx@@ -75,6 +75,7 @@ export interface InboxSortOption {field: InboxSortFielddirection: InboxSortDirectionicon: JSX.Element+ description?: string}export const INBOX_SORT_OPTIONS: InboxSortOption[] = [@@ -84,85 +85,71 @@ export const INBOX_SORT_OPTIONS: InboxSortOption[] = [{ label: 'Oldest first', field: 'created_at', direction: 'asc', icon: <IconClock /> },]-/** Staff-only sorts by the ranking model's served probability for one outcome head. Descending only. */-export const INBOX_MODEL_SORT_SECTIONS: { title: string; options: InboxSortOption[] }[] = [+/**+ * The three ranking model scores the staff UI shows, in display order. Each reads one outcome head.+ * The model serves more heads, but the sort menu, the card tag and the activity log lead with these.+ */+export interface InboxRankingScore {+ field: InboxRankingSortField+ head: string+ name: string+ sortLabel: string+ /** The short word the card tag uses after the lift ("2.1x fix"). */+ tagLabel: string+ description: string+}++export const INBOX_RANKING_SCORES: InboxRankingScore[] = [{- title: 'Model: good outcomes',- options: [- { label: 'Most likely to merge', field: 'ranking_pr_merged', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to get a PR', field: 'ranking_pr_created', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to need action', field: 'ranking_action', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to be opened', field: 'ranking_open', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to be fixed', field: 'ranking_fixed', direction: 'desc', icon: <IconBrain /> },- { label: 'Most likely to be discussed', field: 'ranking_discuss', direction: 'desc', icon: <IconBrain /> },- {- label: 'Most likely to get a thumbs up',- field: 'ranking_thumbs_up',- direction: 'desc',- icon: <IconBrain />,- },- ],+ field: 'ranking_open',+ head: 'open',+ name: 'Open',+ sortLabel: 'Most likely to be opened',+ tagLabel: 'open',+ description: 'A person opens the report within 3 days.',},{- title: 'Model: bad outcomes',- options: [- {- label: 'Most likely to need a reviewer fix',- field: 'ranking_reviewer_fix',- direction: 'desc',- icon: <IconBrain />,- },- { label: 'Most likely to be refunded', field: 'ranking_refund', direction: 'desc', icon: <IconBrain /> },- {- label: 'Most likely to be dismissed as wrong',- field: 'ranking_dismiss_wrong',- direction: 'desc',- icon: <IconBrain />,- },- {- label: 'Most likely to be dismissed as low value',- field: 'ranking_dismiss_lowvalue',- direction: 'desc',- icon: <IconBrain />,- },- ],+ field: 'ranking_action',+ head: 'action',+ name: 'Engage',+ sortLabel: 'Most likely to be acted on',+ tagLabel: 'engage',+ description: 'A person acts on the report within 7 days.',+ },+ {+ field: 'ranking_fixed',+ head: 'fixed',+ name: 'Fix',+ sortLabel: 'Most likely to be fixed',+ tagLabel: 'fix',+ description: 'Someone fixes the problem within 21 days.',},]-export const INBOX_MODEL_SORT_OPTIONS: InboxSortOption[] = INBOX_MODEL_SORT_SECTIONS.flatMap(({ options }) => options)+/** Staff-only sorts by the ranking model's served probability for one score. Descending only. */+export const INBOX_MODEL_SORT_OPTIONS: InboxSortOption[] = INBOX_RANKING_SCORES.map((score) => ({+ label: score.sortLabel,+ field: score.field,+ direction: 'desc',+ icon: <IconBrain />,+ description: score.description,+}))++const RANKING_SCORE_BY_FIELD = Object.fromEntries(INBOX_RANKING_SCORES.map((score) => [score.field, score])) as Record<+ InboxRankingSortField,+ InboxRankingScore+>export function isRankingSortField(field: InboxSortField): field is InboxRankingSortField {- return field.startsWith('ranking_')+ return field in RANKING_SCORE_BY_FIELD}-/** The outcome head each model sort reads, and the short word its card tag uses ("41% merge"). */-export const RANKING_SORT_HEADS: Record<InboxRankingSortField, { head: string; tagLabel: string }> = {- ranking_pr_merged: { head: 'pr_merged', tagLabel: 'merge' },- ranking_pr_created: { head: 'pr_created', tagLabel: 'PR' },- ranking_action: { head: 'action', tagLabel: 'action' },- ranking_open: { head: 'open', tagLabel: 'open' },- ranking_fixed: { head: 'fixed', tagLabel: 'fix' },- ranking_discuss: { head: 'discuss', tagLabel: 'discuss' },- ranking_thumbs_up: { head: 'thumbs_up', tagLabel: 'thumbs up' },- ranking_reviewer_fix: { head: 'reviewer_fix', tagLabel: 'reviewer fix' },- ranking_refund: { head: 'refund', tagLabel: 'refund' },- ranking_dismiss_wrong: { head: 'dismiss_wrong', tagLabel: 'wrong' },- ranking_dismiss_lowvalue: { head: 'dismiss_lowvalue', tagLabel: 'low value' },+export function rankingScoreForField(field: InboxRankingSortField): InboxRankingScore {+ return RANKING_SCORE_BY_FIELD[field]}-/** Display names for the ranking heads in the probability tooltip. Unknown heads show their raw name. */-export const RANKING_HEAD_LABELS: Record<string, string> = {- pr_merged: 'PR merged',- pr_created: 'PR created',- action: 'Needs action',- open: 'Opened',- fixed: 'Fixed',- thumbs_up: 'Thumbs up',- discuss: 'Discussed',- dismiss_wrong: 'Dismissed as wrong',- refund: 'Refunded',- reviewer_fix: 'Reviewer fix',- dismiss_lowvalue: 'Dismissed as low value',+export function rankingScoreForHead(head: string): InboxRankingScore | undefined {+ return INBOX_RANKING_SCORES.find((score) => score.head === head)}export const INBOX_CREATED_WINDOW_OPTIONS: { value: InboxCreatedWindow; label: string; hours: number }[] = [diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.tsindex 53565d5f22ba..6ea674ce310f 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts@@ -19,6 +19,7 @@ import {filterSearchParams,inboxFiltersLogic,InboxFilterState,+ InboxSortField,parseFilterSearchParams,} from './inboxFiltersLogic'@@ -56,9 +57,7 @@ describe('inboxFiltersLogic', () => {})it('leads with the ranking field for a model sort', () => {- expect(buildSignalReportListOrdering('ranking_pr_merged', 'desc')).toBe(- '-ranking_pr_merged,status,-updated_at'- )+ expect(buildSignalReportListOrdering('ranking_fixed', 'desc')).toBe('-ranking_fixed,status,-updated_at')})})@@ -130,10 +129,17 @@ describe('inboxFiltersLogic', () => {})it.each([- ['keeps a model sort for a user who can use it', true, 'ranking_pr_merged', 'desc'],- ['falls back to the default sort for a user who cannot', false, 'priority', 'asc'],- ] as const)('%s', (_name, modelSortAvailable, sortField, sortDirection) => {- expect(parseFilterSearchParams({ sort: 'ranking_pr_merged:desc' }, { modelSortAvailable })).toEqual({+ ['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 head the menu no longer offers',+ 'ranking_pr_merged:desc',+ true,+ 'priority',+ 'asc',+ ],+ ] as const)('%s', (_name, sort, modelSortAvailable, sortField, sortDirection) => {+ expect(parseFilterSearchParams({ sort }, { modelSortAvailable })).toEqual({...DEFAULT_STATE,sortField,sortDirection,@@ -244,15 +250,31 @@ describe('inboxFiltersLogic', () => {})it.each([- ['keeps a stored model sort for staff with the flag', true, true, 'ranking_pr_merged', 'desc'],- ['falls back to the default once the flag is off', false, true, 'priority', 'asc'],- ['falls back to the default for a non-staff user', true, false, 'priority', 'asc'],- ] as const)('%s', (_name, flagOn, isStaff, activeSortField, activeSortDirection) => {+ [+ 'keeps a stored model sort for staff with the flag',+ 'ranking_action',+ true,+ true,+ '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'],+ [+ 'falls back to the default for a stored head the menu no longer offers',+ 'ranking_pr_merged',+ true,+ true,+ 'priority',+ '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 })- logic.actions.setSort('ranking_pr_merged', 'desc')+ // 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,@@ -260,7 +282,7 @@ describe('inboxFiltersLogic', () => {userLogic.actions.loadUserSuccess({ ...MOCK_DEFAULT_USER, is_staff: isStaff })expect(logic.values).toMatchObject({- sortField: 'ranking_pr_merged',+ sortField: storedSortField,activeSortField,activeSortDirection,})diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.tsindex 12158a582377..d103154f7d45 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts@@ -41,18 +41,7 @@ export interface InboxReviewerOption {email: string}-export type InboxRankingSortField =- | 'ranking_pr_merged'- | 'ranking_pr_created'- | 'ranking_action'- | 'ranking_open'- | 'ranking_fixed'- | 'ranking_discuss'- | 'ranking_thumbs_up'- | 'ranking_reviewer_fix'- | 'ranking_refund'- | 'ranking_dismiss_wrong'- | 'ranking_dismiss_lowvalue'+export type InboxRankingSortField = 'ranking_open' | 'ranking_action' | 'ranking_fixed'export type InboxSortField = 'priority' | 'created_at' | 'updated_at' | InboxRankingSortFieldexport type InboxSortDirection = 'asc' | 'desc'/** Preset for the created-in window filter. Null means any time. */@@ -94,6 +83,14 @@ const VALID_SORT_KEYS = new Set(INBOX_SORT_OPTIONS.map((o) => `${o.field}:${o.diconst VALID_MODEL_SORT_KEYS = new Set(INBOX_MODEL_SORT_OPTIONS.map((o) => `${o.field}:${o.direction}`))const VALID_CREATED_WINDOWS = new Set<string>(INBOX_CREATED_WINDOW_OPTIONS.map((o) => o.value))+function isOfferedSortKey(key: string, modelSortAvailable: boolean): boolean {+ return VALID_SORT_KEYS.has(key) || (modelSortAvailable && VALID_MODEL_SORT_KEYS.has(key))+}++function isOfferedSort(field: InboxSortField, direction: InboxSortDirection, modelSortAvailable: boolean): boolean {+ return isOfferedSortKey(`${field}:${direction}`, modelSortAvailable)+}+export interface InboxFilterState {scope: InboxScopesourceProductFilter: string[]@@ -162,10 +159,7 @@ export function parseFilterSearchParams(): InboxFilterState {let sortField = DEFAULT_SORT_FIELDlet sortDirection = DEFAULT_SORT_DIRECTION- if (- typeof searchParams.sort === 'string' &&- (VALID_SORT_KEYS.has(searchParams.sort) || (modelSortAvailable && VALID_MODEL_SORT_KEYS.has(searchParams.sort)))- ) {+ if (typeof searchParams.sort === 'string' && isOfferedSortKey(searchParams.sort, modelSortAvailable)) {const [field, direction] = searchParams.sort.split(':')sortField = field as InboxSortFieldsortDirection = direction as InboxSortDirection@@ -408,7 +402,11 @@ export interface inboxFiltersLogicMeta {) => booleanisScopedToMe: (scope: InboxScope, user: UserType | null) => booleanmodelSortAvailable: (featureFlags: FeatureFlagsSet, user: UserType | null) => boolean- activeSortField: (sortField: InboxSortField, modelSortAvailable: boolean) => InboxSortField+ activeSortField: (+ sortField: InboxSortField,+ sortDirection: InboxSortDirection,+ modelSortAvailable: boolean+ ) => InboxSortFieldactiveSortDirection: (sortField: InboxSortField,sortDirection: InboxSortDirection,@@ -715,12 +713,16 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([(featureFlags: FeatureFlagsSet, user: UserType | null): boolean =>!!featureFlags[FEATURE_FLAGS.INBOX_MODEL_SORT] && !!user?.is_staff,],- // The sort the list requests and renders with. A model sort persisted while it was available- // falls back to the default once it is not, because the backend rejects it for non-staff.+ // The sort the list requests and renders with. A persisted sort the menu no longer offers, or a+ // model sort persisted while it was available, falls back to the default.activeSortField: [- (s) => [s.sortField, s.modelSortAvailable],- (sortField: InboxSortField, modelSortAvailable: boolean): InboxSortField =>- isRankingSortField(sortField) && !modelSortAvailable ? DEFAULT_SORT_FIELD : sortField,+ (s) => [s.sortField, s.sortDirection, s.modelSortAvailable],+ (+ sortField: InboxSortField,+ sortDirection: InboxSortDirection,+ modelSortAvailable: boolean+ ): InboxSortField =>+ isOfferedSort(sortField, sortDirection, modelSortAvailable) ? sortField : DEFAULT_SORT_FIELD,],activeSortDirection: [(s) => [s.sortField, s.sortDirection, s.modelSortAvailable],@@ -729,7 +731,7 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([sortDirection: InboxSortDirection,modelSortAvailable: boolean): InboxSortDirection =>- isRankingSortField(sortField) && !modelSortAvailable ? DEFAULT_SORT_DIRECTION : sortDirection,+ isOfferedSort(sortField, sortDirection, modelSortAvailable) ? sortDirection : DEFAULT_SORT_DIRECTION,],timeWindowAvailable: [(s) => [s.featureFlags],diff --git a/products/signals/frontend/inbox/utils/reportOrdering.ts b/products/signals/frontend/inbox/utils/reportOrdering.tsindex 99506b3b6ce4..538a3a51496c 100644--- a/products/signals/frontend/inbox/utils/reportOrdering.ts+++ b/products/signals/frontend/inbox/utils/reportOrdering.ts@@ -1,4 +1,4 @@-import { isRankingSortField, RANKING_SORT_HEADS } from '../filterOptions'+import { isRankingSortField, rankingScoreForField } from '../filterOptions'import type { InboxRankingSortField, InboxSortDirection, InboxSortField } from '../logics/inboxFiltersLogic'import { SignalReport, SignalReportStatus } from '../types'@@ -52,7 +52,7 @@ export function rankingSortScore(report: SignalReport, field: InboxRankingSortFiif (report.ranking?.stale) {return null}- const score = report.ranking?.scores[RANKING_SORT_HEADS[field].head]+ const score = report.ranking?.scores[rankingScoreForField(field).head]return typeof score === 'number' ? score : null}