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(inbox): limit report evidence to two cards (#98542)

Chris Volzercfbb7e62013a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 9875e8d20baf..8b1c1817c52f 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7689,17 +7689,17 @@ snapshots:
scenes-app-inbox-detail--pull-request-inline-review--light:
hash: v1.k794b7964.54ed775e300bcacc3daf06411648d037ff8a8bc464af075cc698621bba55d60d.TE0nzlUiGZ4x0DtSJd7cofvbgPhzgzgRc_Z2DbW5yeg
scenes-app-inbox-detail--pull-request-legacy--dark:
- hash: v1.k794b7964.ef57e40504fc3662dd7381d0b986feee0ecc8d682e1c79ec6460fb976014b0b7.qXT15FA9NhZXhUhWqQzU6VqMhEZYcfsLu7Spv9ce7do
+ hash: v1.k794b7964.65e0f6c79aa699db5bd97c4992c466bb397a403759a319f975f22d333a1d1b22.UTxHA3q-zjbbBNNw80FIpeh60n_r2tTpgYXBNH3ee_g
scenes-app-inbox-detail--pull-request-legacy--light:
- hash: v1.k794b7964.3d146b1096428e88c408f072c3b0b4d65872149c278c39aaa8cd719433e2765a.zGaCBLTBoIc-TstfxXybD1E0r3R_wM-HhZKJW1gvV-w
+ hash: v1.k794b7964.ff5c040a6eab57a8848e74860feb865e13ed794c202fade12f081f8aa51cdef9.voP6KPCl7SXMMY-tjoUVcSrd8J9GIhhs5vvZQsAUW9Y
scenes-app-inbox-detail--report--dark:
hash: v1.k794b7964.0516b8985888b92018506cee3a0cf40c7f7499027455fb8f6957853a91440557.heUzrn_iZd5CtI3GTUAKNrrP2zEkv-NEUxo3FnmZKF0
scenes-app-inbox-detail--report--light:
hash: v1.k794b7964.f42eb359e62e037d7b75d0348f507dea76b69e442f80adc8b54736e0edcd8da5.42xwdpzwUuNAIMlWPnm3StGJdZdEOr-0lSd9-xtvvmc
scenes-app-inbox-detail--report-legacy--dark:
- hash: v1.k794b7964.d7a01f7a2a244386c3ec004e61de0fd02236bccdafcec4ba7e93ff32718ffe13.jUGu-FHFfhAd2qeCWI5wOXQQysSf6WfTdZzeLU_O_eM
+ hash: v1.k794b7964.63d5cb716e6d12b53f7ad598951276a460f1ac5230608b5ddf94612b27be18cd.vhD05tMulytQUTFXZFSAZ6-ppYCGP5Svpg7AUgUAM2U
scenes-app-inbox-detail--report-legacy--light:
- hash: v1.k794b7964.392775470a41cccd95b251ee30d09f015663edab59f852b12afc37aef730b19c.lnlu12qEUqkUiiNGmEYw9IPajbwBudChG3gReWHDOCg
+ hash: v1.k794b7964.092396db276487cd0c86aa905db974c41835aa53d5eadd5c1809c9f26dac2047.-KXnP1Hpm-NmE2ZDf-K2jDlwB67_AN4SIDqfc_K5v40
scenes-app-inbox-detail--report-minimal--dark:
hash: v1.k794b7964.7b457e88868510c008646ab0ed37de232ec66ccbd001e82256e156e44a4cfa23.38qy-CrE1s8-psQTdpOZqMVW5alFzYnH7On3bETCnGU
scenes-app-inbox-detail--report-minimal--light:
@@ -7793,13 +7793,25 @@ snapshots:
scenes-app-inbox-scene--legacy--light:
hash: v1.k794b7964.76ea52563f9f53e051fd54634ebfc726b5f5570d3e6c7dd8b0663951c41c7f5c._pNa0ljBd_71oP2dETrcKP92bjh9QWeYpVKcR0LfL-k
scenes-app-inbox-scene--legacy-report--dark:
- hash: v1.k794b7964.394f0282b127fd767d9c1810af66bdd2d5203ca478321b40e727ed16c18987c7.JkcauZfmV5rs015oieOBoNd5zf3Re8tnNFVYCklLk0k
+ hash: v1.k794b7964.765aac167b96a09a811fd20d151724f6a1bd5b39f8e19cb2b564afc27e2eade2.My854S8qZrRgOAVoejF1VL0352TmLk9ZM59rGiZIfPg
scenes-app-inbox-scene--legacy-report--light:
- hash: v1.k794b7964.51dc2d5bfd3811ee214103b68083e2ac2232b64a092eca8cebaffcc7e69b3cbb.dujympeX0YqXxpaI_BbT7jlZ5S8WwYYl3KA3VSoHV5k
+ hash: v1.k794b7964.d010ce340ce11fb839a94510f5e43a514e3940a4952c69076752da1ed936bb89.lfzVEN0SJMIZ25GnV83_YC2APjZ9qcYmpYcJc9xxAdw
scenes-app-inbox-scene--legacy-scouts--dark:
hash: v1.k794b7964.00a0feaa86beaa3b1b60c03a3b303f7ffd216ff4d5f764aa6d252c16bdf23a39.xuzoMnnhjmWiLMObrfueetj7cdv6JIIAoqKI7PXZoQQ
scenes-app-inbox-scene--legacy-scouts--light:
hash: v1.k794b7964.fbdba6b2b4d3fccde859fd2213b1580d43744013be41922b19fe371cc8c72e5b.MsUe8tUW9R4bOplWlproOR3eYuTgTKGTuYQoiarWC54
+ scenes-app-inbox-scene--report-with-many-evidence-items--dark:
+ hash: v1.k794b7964.cdf433915e692e878772c4299885f968c99c039e535ce00eedde96142225dc8a.3jz4_ynFjRQTKIFVz6-5ofn0AVAdDN3pilwzZWHmrKo
+ scenes-app-inbox-scene--report-with-many-evidence-items--light:
+ hash: v1.k794b7964.333f20aae372ab4f77e80174ad32954456822753634ddea6f33428721714916b.aLrk4Xz2cfDmJMCaaNJDhEwnAG42-aOiocdHYCeyoO4
+ scenes-app-inbox-scene--report-with-two-evidence-items--dark:
+ hash: v1.k794b7964.cdf433915e692e878772c4299885f968c99c039e535ce00eedde96142225dc8a.6wHcOKpGxRD2TtvfDNsKZ0r3-Dq0bqPkD5SXIM8s_RM
+ scenes-app-inbox-scene--report-with-two-evidence-items--light:
+ hash: v1.k794b7964.333f20aae372ab4f77e80174ad32954456822753634ddea6f33428721714916b.8YsGQze5b2tb7DUMnAUPgg16ZBXiwUl4CQszDI4CZxw
+ scenes-app-inbox-scene--report-without-evidence--dark:
+ hash: v1.k794b7964.cdf433915e692e878772c4299885f968c99c039e535ce00eedde96142225dc8a.5v5qRqUu0VBkG6ypk6Yv2KHizGze2d613iDpMkjZgKk
+ scenes-app-inbox-scene--report-without-evidence--light:
+ hash: v1.k794b7964.333f20aae372ab4f77e80174ad32954456822753634ddea6f33428721714916b.AWi8H5joJwmrMRc5_mNH01H_fIT-Ogxxo2zRS7IoQzs
scenes-app-inbox-scene--scouts--dark:
hash: v1.k794b7964.7053803019f3c5c4d33bad380d4e4f8e8f066ef6d8e4936908cb73958143455a.0r-TdrrkSFVt7rRBizrLuOXauYQQbDJV_SfkCoavUeQ
scenes-app-inbox-scene--scouts--light:
diff --git a/products/signals/frontend/inbox/InboxScene.stories.tsx b/products/signals/frontend/inbox/InboxScene.stories.tsx
index 90bab6e18449..1432941e51b5 100644
--- a/products/signals/frontend/inbox/InboxScene.stories.tsx
+++ b/products/signals/frontend/inbox/InboxScene.stories.tsx
@@ -19,6 +19,7 @@ import {
mockTask,
mockTeamConfig,
pullRequestReports,
+ reportTabReports,
} from './__mocks__/inboxMocks'
import { mockLargeScoutFleet, mockScoutConfigs, mockScoutRuns } from './__mocks__/scoutConfigs'
import { InboxScene } from './InboxScene'
@@ -93,6 +94,26 @@ type Story = StoryObj
export const Inbox: Story = {}
+function reportWithEvidenceItems(count: number): Story {
+ return {
+ decorators: [
+ routeTo(urls.inboxReport('reports', reportTabReports[0].id)),
+ mswDecorator({
+ get: {
+ '/api/projects/:id/signals/reports/:reportId/signals': (req) => [
+ 200,
+ { report: null, signals: mockSignals(req.params.reportId as string, count) },
+ ],
+ },
+ }),
+ ],
+ }
+}
+
+export const ReportWithManyEvidenceItems: Story = reportWithEvidenceItems(12)
+export const ReportWithTwoEvidenceItems: Story = reportWithEvidenceItems(2)
+export const ReportWithoutEvidence: Story = reportWithEvidenceItems(0)
+
// Triage mode over the Needs-a-decision queue: one report at a time, keyboard-driven.
export const Triage: Story = {
decorators: [routeTo(urls.inboxTriage())],
diff --git a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx b/products/signals/frontend/inbox/components/detail/ReportDetail.tsx
index a114239a7c88..fbb75ef53455 100644
--- a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportDetail.tsx
@@ -84,7 +84,7 @@ export function ReportDetailBadges({
/** Placeholder finding rows shown while the signals query is in flight, sized to the known count. */
function EvidenceSkeleton({ count }: { count: number }): JSX.Element {
- const rows = Math.max(1, Math.min(count, 4))
+ const rows = Math.max(1, Math.min(count, 2))
return (
<div className="flex flex-col gap-3" aria-hidden>
{Array.from({ length: rows }).map((_, i) => (
@@ -215,9 +215,16 @@ export function InboxDetailFrame({
: 'Back'
: 'Self-driving inbox'
const logicProps = { reportId: report.id, report }
- const { reportSignals, reportSignalsLoading, priorityExplanation, chartPlacements, trailingCharts, detailTab } =
- useValues(inboxReportDetailLogic(logicProps))
- const { setDetailTab } = useActions(inboxReportDetailLogic(logicProps))
+ const {
+ reportSignals,
+ reportSignalsLoading,
+ evidenceExpanded,
+ priorityExplanation,
+ chartPlacements,
+ trailingCharts,
+ detailTab,
+ } = useValues(inboxReportDetailLogic(logicProps))
+ const { setDetailTab, expandEvidence, collapseEvidence } = useActions(inboxReportDetailLogic(logicProps))
const { evidenceRailCollapsed } = useValues(inboxDetailLayoutLogic)
const { toggleEvidenceRail } = useActions(inboxDetailLayoutLogic)
// The API returns evidence oldest-first, but a reader wants the most recent signal at the top of
@@ -396,9 +403,20 @@ export function InboxDetailFrame({
<EvidenceSkeleton count={evidenceCount} />
) : (
<div className="flex flex-col gap-3">
- {signals.map((signal: SignalNode) => (
- <SignalCard key={signal.signal_id} signal={signal} />
- ))}
+ {(evidenceExpanded ? signals : signals.slice(0, 2)).map(
+ (signal: SignalNode) => (
+ <SignalCard key={signal.signal_id} signal={signal} />
+ )
+ )}
+ {signals.length > 2 && (
+ <LemonButton
+ type="tertiary"
+ size="small"
+ onClick={evidenceExpanded ? collapseEvidence : expandEvidence}
+ >
+ {evidenceExpanded ? 'Show less' : 'Show more'}
+ </LemonButton>
+ )}
</div>
)}
</DetailSection>
diff --git a/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx b/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx
index 82128c65d777..9e84485a657d 100644
--- a/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx
@@ -1,4 +1,4 @@
-import { BindLogic, useValues } from 'kea'
+import { BindLogic, useActions, useValues } from 'kea'
import { router } from 'kea-router'
import { ReactNode, useCallback, useState } from 'react'
@@ -167,7 +167,7 @@ function MetaSourceStack({
/** Placeholder finding rows shown while the signals query is in flight, sized to the known count. */
function EvidenceSkeleton({ count }: { count: number }): JSX.Element {
- const rows = Math.max(1, Math.min(count, 4))
+ const rows = Math.max(1, Math.min(count, 2))
return (
<div className="flex flex-col gap-3" aria-hidden>
{Array.from({ length: rows }).map((_, i) => (
@@ -281,11 +281,13 @@ function InboxDetailFrameLegacy({
const {
reportSignals,
reportSignalsLoading,
+ evidenceExpanded,
priorityExplanation,
actionabilityExplanation,
chartPlacements,
trailingCharts,
} = useValues(inboxReportDetailLogic(logicProps))
+ const { expandEvidence, collapseEvidence } = useActions(inboxReportDetailLogic(logicProps))
// GitHub-style PR view: when the report has a PR, the overview and the diff live behind two tabs.
const [activeDetailTab, setActiveDetailTab] = useState<'overview' | 'files'>('overview')
const hasDiff = !!showFilesTab
@@ -387,9 +389,18 @@ function InboxDetailFrameLegacy({
<EvidenceSkeleton count={evidenceCount} />
) : (
<div className="flex flex-col gap-3">
- {signals.map((signal: SignalNode) => (
+ {(evidenceExpanded ? signals : signals.slice(0, 2)).map((signal: SignalNode) => (
<SignalCard key={signal.signal_id} signal={signal} />
))}
+ {signals.length > 2 && (
+ <LemonButton
+ type="tertiary"
+ size="small"
+ onClick={evidenceExpanded ? collapseEvidence : expandEvidence}
+ >
+ {evidenceExpanded ? 'Show less' : 'Show more'}
+ </LemonButton>
+ )}
</div>
)}
</DetailSection>
diff --git a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts
index b8028bd6a00d..df84414be347 100644
--- a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts
+++ b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.test.ts
@@ -1,4 +1,5 @@
import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'
import { useMocks } from '~/mocks/jest'
@@ -7,6 +8,7 @@ import { initKeaTests } from '~/test/init'
import { TaskRunStatus } from 'products/posthog_ai/frontend/types/taskTypes'
import { ReportTaskPurpose } from '../components/detail/artefactTypes'
+import { INBOX_EVENTS } from '../inboxAnalytics'
import { SignalReport } from '../types'
import { ReportTaskEntry, implementationSlotClaim, inboxReportDetailLogic } from './inboxReportDetailLogic'
@@ -57,6 +59,71 @@ describe('inboxReportDetailLogic', () => {
})
})
+ describe('evidence expansion', () => {
+ let logic: ReturnType<typeof inboxReportDetailLogic.build>
+
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/projects/:team_id/signals/reports/:id/artefacts/': { results: [] },
+ '/api/projects/:team_id/signals/reports/:id/signals/': {
+ signals: [{ signal_id: 's1' }, { signal_id: 's2' }, { signal_id: 's3' }],
+ },
+ '/api/projects/:team_id/signals/reports/available_reviewers/': [],
+ },
+ })
+ initKeaTests()
+ logic = inboxReportDetailLogic({ reportId: REPORT.id, report: REPORT })
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ })
+
+ // The disclosure control has to put the value back. Without the collapse case a reader who
+ // opens a long evidence list is stuck with it for the rest of the visit to that report.
+ it('expands and collapses again', () => {
+ expect(logic.values.evidenceExpanded).toBe(false)
+
+ logic.actions.expandEvidence()
+ expect(logic.values.evidenceExpanded).toBe(true)
+
+ logic.actions.collapseEvidence()
+ expect(logic.values.evidenceExpanded).toBe(false)
+ })
+
+ // Reaching past the two shown cards is the only evidence that the limit is set too low, so
+ // a silently dropped event would leave the default untestable.
+ it('reports the expansion with the number of cards there were to reach for', async () => {
+ await expectLogic(logic).toDispatchActions(['loadReportSignalsSuccess'])
+ ;(posthog.capture as jest.Mock).mockClear()
+
+ logic.actions.expandEvidence()
+ await expectLogic(logic).toFinishAllListeners()
+
+ const reported = (posthog.capture as jest.Mock).mock.calls
+ .filter(([event]) => event === INBOX_EVENTS.REPORT_ACTION)
+ .map(([, properties]) => [properties.action_type, properties.section, properties.signal_count])
+ expect(reported).toEqual([['show_more', 'evidence', 3]])
+ })
+
+ // The logic is keyed on the report, which is the only thing keeping one reader's expanded
+ // list from following them into the next report they open.
+ it('holds the expanded state per report', () => {
+ const otherReport = { ...REPORT, id: 'report-9' } as SignalReport
+ const otherLogic = inboxReportDetailLogic({ reportId: otherReport.id, report: otherReport })
+ otherLogic.mount()
+
+ logic.actions.expandEvidence()
+
+ expect(logic.values.evidenceExpanded).toBe(true)
+ expect(otherLogic.values.evidenceExpanded).toBe(false)
+
+ otherLogic.unmount()
+ })
+ })
+
describe('feedback note submission', () => {
let logic: ReturnType<typeof inboxReportDetailLogic.build>
let notePosts: number
diff --git a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
index 1757004d403d..2bf4f5b88d7c 100644
--- a/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
+++ b/products/signals/frontend/inbox/logics/inboxReportDetailLogic.ts
@@ -255,6 +255,7 @@ export interface inboxReportDetailLogicValues {
displayReviewers: EnrichedReviewer[] | null
draftThread: DraftThread | null
editingCommentId: string | null
+ evidenceExpanded: boolean
expandedTaskIds: string[]
feedbackNoteDraft: string
feedbackNoteOpen: boolean
@@ -309,6 +310,9 @@ export interface inboxReportDetailLogicActions {
closeDraftThread: () => {
value: true
}
+ collapseEvidence: () => {
+ value: true
+ }
deleteReviewComment: (commentId: string) => {
commentId: string
}
@@ -319,6 +323,9 @@ export interface inboxReportDetailLogicActions {
body: string
commentId: string
}
+ expandEvidence: () => {
+ value: true
+ }
loadAvailableReviewers: ({ query }?: { query?: string }) => {
query?: string
}
@@ -588,6 +595,8 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
})),
actions({
+ expandEvidence: true,
+ collapseEvidence: true,
// Open a not-yet-posted comment thread on a diff line (one draft at a time).
openDraftThread: (draft: DraftThread) => ({ draft }),
closeDraftThread: true,
@@ -782,6 +791,7 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
})),
reducers({
+ evidenceExpanded: [false, { expandEvidence: () => true, collapseEvidence: () => false }],
report: [
null as SignalReport | null,
{
@@ -1205,6 +1215,18 @@ export const inboxReportDetailLogic = kea<inboxReportDetailLogicType>([
captureInboxReportAction({ report: values.report, actionType: 'view_diff', surface: 'detail_pane' })
}
},
+ expandEvidence: () => {
+ // The two-card default is a guess. This is the only signal for how often a reader wants
+ // the rest of the evidence, so it carries how much there was to reach for.
+ if (values.report) {
+ captureInboxReportAction({
+ report: values.report,
+ actionType: 'show_more',
+ surface: 'detail_pane',
+ extra: { section: 'evidence', signal_count: values.reportSignals?.length ?? 0 },
+ })
+ }
+ },
rateReport: ({ sentiment }) => {
if (!values.report) {
return