Skip to content

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

fix(signals): show an error and retry when the inbox list fails to load (#92319)

posthog[bot]a8aee2230138
diff --git a/products/signals/frontend/inbox/components/InboxReportList.test.tsx b/products/signals/frontend/inbox/components/InboxReportList.test.tsx
index ae21a2e9d1ce..7a63f8d56e21 100644
--- a/products/signals/frontend/inbox/components/InboxReportList.test.tsx
+++ b/products/signals/frontend/inbox/components/InboxReportList.test.tsx
@@ -5,6 +5,7 @@ import { act, cleanup, render, screen, waitFor } from '@testing-library/react'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
+import { legacyTabListLogicProps, reportListLogic } from '../logics/reportListLogic'
import { SignalReport, SignalReportStatus } from '../types'
import { InboxReportList, InboxReportCardProps } from './InboxReportList'
@@ -100,4 +101,76 @@ describe('InboxReportList', () => {
await screen.findByText('Report page-2')
expect(requestedOffsets).toEqual(['0', '1'])
})
+
+ it('shows an error with retry when the first page fails, and recovers on retry', async () => {
+ let firstPageAttempts = 0
+ useMocks({
+ get: {
+ '/api/projects/:team_id/signals/reports/available_reviewers': {},
+ '/api/projects/:team_id/signals/reports/': ({ request }) => {
+ const { searchParams } = new URL(request.url)
+ // The badge count request must still succeed — a non-zero count is what used to
+ // hold the skeleton up forever once the page load failed.
+ if (searchParams.get('limit') === '1') {
+ return [200, { count: 5, next: null, previous: null, results: [] }]
+ }
+ firstPageAttempts += 1
+ if (firstPageAttempts === 1) {
+ return [500, { detail: 'boom' }]
+ }
+ return [200, { count: 5, next: null, previous: null, results: [makeReport('recovered')] }]
+ },
+ },
+ })
+
+ render(<InboxReportList tabKey="reports" Card={StubCard} emptyState={{ content: <div>empty</div> }} />)
+
+ const retry = await screen.findByText('Retry')
+ expect(screen.getByText("Couldn't load these reports.")).toBeInTheDocument()
+
+ act(() => retry.click())
+
+ await screen.findByText('Report recovered')
+ expect(screen.queryByText("Couldn't load these reports.")).not.toBeInTheDocument()
+ })
+
+ it('retry refetches when a refresh fails on an already-loaded empty list', async () => {
+ let pageAttempts = 0
+ useMocks({
+ get: {
+ '/api/projects/:team_id/signals/reports/available_reviewers': {},
+ '/api/projects/:team_id/signals/reports/': ({ request }) => {
+ const { searchParams } = new URL(request.url)
+ if (searchParams.get('limit') === '1') {
+ return [200, { count: 0, next: null, previous: null, results: [] }]
+ }
+ pageAttempts += 1
+ // First load lands empty (a tab or filter with no matches), the refresh fails,
+ // then the retry recovers. A failed load keeps the earlier empty response, so
+ // `ensureLoaded` alone would send no request — the retry must refetch.
+ if (pageAttempts === 1) {
+ return [200, { count: 0, next: null, previous: null, results: [] }]
+ }
+ if (pageAttempts === 2) {
+ return [500, { detail: 'boom' }]
+ }
+ return [200, { count: 1, next: null, previous: null, results: [makeReport('recovered')] }]
+ },
+ },
+ })
+
+ render(<InboxReportList tabKey="reports" Card={StubCard} emptyState={{ content: <div>empty</div> }} />)
+
+ await screen.findByText('empty')
+ // A reload (filter/scope change, bulk broadcast) refetches the loaded list and fails here.
+ act(() => reportListLogic(legacyTabListLogicProps('reports')).actions.refresh())
+
+ const retry = await screen.findByText('Retry')
+ expect(screen.getByText("Couldn't load these reports.")).toBeInTheDocument()
+
+ act(() => retry.click())
+
+ await screen.findByText('Report recovered')
+ expect(screen.queryByText("Couldn't load these reports.")).not.toBeInTheDocument()
+ })
})
diff --git a/products/signals/frontend/inbox/components/InboxReportList.tsx b/products/signals/frontend/inbox/components/InboxReportList.tsx
index 1f59e1058f9f..2c740dea0ff7 100644
--- a/products/signals/frontend/inbox/components/InboxReportList.tsx
+++ b/products/signals/frontend/inbox/components/InboxReportList.tsx
@@ -1,6 +1,8 @@
import { BindLogic, useActions, useValues } from 'kea'
import { ComponentType, JSX, useCallback, useEffect, useRef } from 'react'
+import { LemonButton } from '@posthog/lemon-ui'
+
import { captureInboxReportsImpressed, captureInboxViewed } from '../inboxAnalytics'
import { inboxSceneLogic } from '../inboxSceneLogic'
import { inboxFiltersLogic } from '../logics/inboxFiltersLogic'
@@ -45,8 +47,18 @@ export function InboxReportList(props: InboxReportListProps): JSX.Element {
}
function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListProps): JSX.Element {
- const { reports, count, totalCount, hasMore, reportsResponseLoading, isLoaded, loadedQueryKey, loadedContext } =
- useValues(reportListLogic)
+ const {
+ reports,
+ count,
+ totalCount,
+ hasMore,
+ reportsResponseLoading,
+ isLoaded,
+ reportsLoadFailed,
+ pageLoadFailed,
+ loadedQueryKey,
+ loadedContext,
+ } = useValues(reportListLogic)
const { ensureLoaded, loadMore, dismissReport, restoreReport, refresh } = useActions(reportListLogic)
const { hasActiveFilters, sourceProductFilter, priorityFilter, scope } = useValues(inboxFiltersLogic)
// The list stays mounted (hidden) while a report/scout detail is open, so gate the view event on
@@ -179,8 +191,10 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListProps
)
useEffect(() => () => observerRef.current?.disconnect(), [])
- // Skeleton while a tab we know is non-empty loads its first page.
- const showSkeleton = !isLoaded && (reportsResponseLoading || (count ?? 0) > 0)
+ // Skeleton while a tab we know is non-empty loads its first page. A settled failed load leaves
+ // `reportsResponse` null, so without the `reportsLoadFailed` guard a non-zero badge count would
+ // hold the skeleton up forever instead of surfacing the error below.
+ const showSkeleton = !isLoaded && !reportsLoadFailed && (reportsResponseLoading || (count ?? 0) > 0)
return (
<div className="@container mx-auto max-w-4xl flex flex-col gap-4 px-6 py-4">
@@ -189,6 +203,18 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListProps
{showSkeleton ? (
<CardSkeleton count={Math.min(count ?? 4, 6)} variant="cards" dashed={tabKey !== 'pulls'} />
+ ) : reportsLoadFailed && reports.length === 0 ? (
+ <div className="flex flex-col items-start gap-2 px-1 py-2">
+ <p className="m-0 text-sm text-tertiary">Couldn't load these reports.</p>
+ <LemonButton
+ size="small"
+ type="secondary"
+ onClick={() => (isLoaded ? refresh() : ensureLoaded())}
+ data-attr="inbox-report-list-retry"
+ >
+ Retry
+ </LemonButton>
+ </div>
) : reports.length === 0 ? (
'content' in emptyState ? (
emptyState.content
@@ -219,6 +245,21 @@ function InboxReportListInner({ tabKey, Card, emptyState }: InboxReportListProps
{isLoaded && reportsResponseLoading && (
<CardSkeleton count={2} variant="cards" dashed={tabKey !== 'pulls'} />
)}
+ {/* A failed next page keeps the loaded rows and the sentinel may sit inside the
+ viewport without re-firing, so offer an explicit way to fetch it again. */}
+ {isLoaded && !reportsResponseLoading && pageLoadFailed && (
+ <div className="flex items-center gap-2 px-1 py-2">
+ <p className="m-0 text-sm text-tertiary">Couldn't load more reports.</p>
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ onClick={() => loadMore()}
+ data-attr="inbox-report-list-retry-page"
+ >
+ Retry
+ </LemonButton>
+ </div>
+ )}
</div>
{hasMore && <div ref={sentinelRef} className="h-1" aria-hidden />}
</>