: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
fix(signals): show closed reports in inbox filters (#126571)
Mikayla Thompson06ea1485c23c
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.mdindex 580e58f1b90b..924c412c1cb7 100644--- a/docs/internal/signals-pr-lifecycle.md+++ b/docs/internal/signals-pr-lifecycle.md@@ -1,5 +1,7 @@# Report completion and late PR attachments+The inbox includes Closed reports in All statuses. The Closed filter appears when the project has closed reports, or when it is selected.+A report completes after all linked implementation PRs are closed or merged.At least one merged PR completes implementation: applicable follow-up checks enter Monitoring when enabled; otherwise the report resolves directly. All closed PRs without a merge suppress it.diff --git a/products/signals/frontend/inbox/components/shell/InboxStateFilter.tsx b/products/signals/frontend/inbox/components/shell/InboxStateFilter.tsxindex a9232539fdbc..7c96f809917e 100644--- a/products/signals/frontend/inbox/components/shell/InboxStateFilter.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxStateFilter.tsx@@ -5,6 +5,7 @@ import { LemonButton, LemonCheckbox, LemonDropdown, LemonTag } from '@posthog/leimport { inboxSceneLogic } from '../../inboxSceneLogic'import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'+import { reportListLogic, sectionListLogicProps } from '../../logics/reportListLogic'import {INBOX_REPORT_SECTION_DESCRIPTION,INBOX_REPORT_SECTION_KEYS,@@ -15,18 +16,21 @@ import {/*** Multi-select report-state filter for the flat Reports list: one checkbox per state (Needs decision,- * Review and merge, Resolved, Dismissed, plus Not actionable for staff). The open-work states are+ * Review and merge, Resolved, Closed, Dismissed, plus Not actionable for staff). The open-work states are* selected by default (see DEFAULT_STATE_FILTER); an empty selection means every state, so the* trigger reads "All statuses" then.*/export function InboxStateFilter(): JSX.Element {const { isStaff } = useValues(inboxSceneLogic)const { stateFilter, visibleStateFilter } = useValues(inboxFiltersLogic)+ const { hasProjectClosedReports } = useValues(reportListLogic(sectionListLogicProps('closed')))const { toggleState } = useActions(inboxFiltersLogic)const [visible, setVisible] = useState(false)const options = INBOX_REPORT_SECTION_KEYS.filter(- (key) => isStaff || !INBOX_STAFF_ONLY_REPORT_SECTION_KEYS.includes(key)+ (key) =>+ (isStaff || !INBOX_STAFF_ONLY_REPORT_SECTION_KEYS.includes(key)) &&+ (key !== 'closed' || hasProjectClosedReports || stateFilter.includes(key)))// Label from the visible selection: a shared link can carry the staff-only state, and the// trigger must not read "Not actionable" (or an inflated count) for a state whose checkbox thediff --git a/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsx b/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsxindex 6b2aad7a6204..f3cfa26a4d8f 100644--- a/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsx+++ b/products/signals/frontend/inbox/components/tabs/ReportsTab.test.tsx@@ -17,6 +17,7 @@ import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'import { inboxSetupLogic } from '../../logics/inboxSetupLogic'import { reportListLogic, sectionListLogicProps } from '../../logics/reportListLogic'import { INBOX_SCOPE_ENTIRE_PROJECT, InboxReportSectionKey, SignalReport, SignalReportStatus } from '../../types'+import { InboxStateFilter } from '../shell/InboxStateFilter'import { ReportsTab } from './ReportsTab'jest.mock('posthog-js')@@ -114,6 +115,7 @@ function mockReportRows(resolvedRowsGate?: { block: Promise<void>; onRequest: ()const needsPr = makeReport('needs-pr', SignalReportStatus.READY)const failed = makeReport('failed', SignalReportStatus.FAILED)const resolved = makeReport('resolved', SignalReportStatus.RESOLVED)+ const closed = makeReport('closed', SignalReportStatus.CLOSED)useMocks({get: {'/api/projects/:team_id/signals/reports/available_reviewers': {},@@ -131,7 +133,9 @@ function mockReportRows(resolvedRowsGate?: { block: Promise<void>; onRequest: ()? [needsPr, failed]: isResolved? [resolved]- : []+ : params.get('view') === 'closed'+ ? [closed]+ : []return [200, { count: results.length, next: null, previous: null, results }]},},@@ -288,10 +292,10 @@ describe('ReportsTab', () => {it.each([{ name: 'the visible sections', counts: COUNT_BY_FILTER, total: 14, empty: false },{- name: 'only hidden Closed reports',- counts: [{ match: (params: URLSearchParams) => params.get('status') === 'closed', count: 3 }],- total: 0,- empty: true,+ name: 'only Closed reports',+ counts: [{ match: (params: URLSearchParams) => params.get('view') === 'closed', count: 3 }],+ total: 3,+ empty: false,},])('fires Inbox viewed once for $name', async ({ counts, total, empty }) => {mockReportCounts(counts)@@ -300,7 +304,6 @@ describe('ReportsTab', () => {await waitFor(() => {const viewed = (posthog.capture as jest.Mock).mock.calls.filter(([event]) => event === INBOX_EVENTS.VIEWED)expect(viewed).toHaveLength(1)- // Needs decision + Review and merge + Resolved + Dismissed + Held back. Not actionable is staff-only triage.expect(viewed[0][1]).toMatchObject({ tab: 'reports', total_count: total, is_empty: empty })})})@@ -380,6 +383,7 @@ describe('ReportsTab', () => {)})expect(document.querySelector('[data-attr="report-card-resolved"]')).toBeNull()+ expect(document.querySelector('[data-attr="report-card-closed"]')).toBeNull()inboxFiltersLogic.actions.toggleState('resolved')@@ -401,6 +405,34 @@ describe('ReportsTab', () => {expect(document.querySelector('[data-attr="report-card-failed"]')).toBeNull()})expect(document.querySelector('[data-attr="report-card-with-pr"]')).not.toBeNull()++ inboxFiltersLogic.actions.setFilters({ ...inboxFiltersLogic.values, stateFilter: [] })+ await waitFor(() =>+ expect(document.querySelector('[data-attr="report-card-closed"]')).toHaveAttribute('data-section', 'closed')+ )++ inboxFiltersLogic.actions.setFilters({ ...inboxFiltersLogic.values, stateFilter: ['closed'] })+ await waitFor(() => expect(document.querySelector('[data-attr="report-card-with-pr"]')).toBeNull())+ expect(document.querySelector('[data-attr="report-card-closed"]')).not.toBeNull()+ })++ it.each([0, 2])('offers Closed only when the project has closed reports (%s)', async (count) => {+ mockReportCounts([+ {+ match: (params) =>+ params.get('view') === 'closed' && !params.has('search') && !params.has('suggested_reviewers'),+ count,+ },+ ])+ inboxFiltersLogic.mount()+ inboxFiltersLogic.actions.setSearchQuery('no matching reports')+ render(<InboxStateFilter />)++ await waitFor(() =>+ expect(reportListLogic(sectionListLogicProps('closed')).values.hasProjectClosedReports).toBe(count > 0)+ )+ fireEvent.click(screen.getByText('2 statuses'))+ expect(screen.queryByText('Closed') !== null).toBe(count > 0)})// A shared link or persisted storage can carry `state=not-actionable`, a staff-only state thediff --git a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsxindex 013591397c26..8ebab0ca884a 100644--- a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx+++ b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx@@ -44,7 +44,7 @@ import { useSelectableReportList } from '../useSelectableReportList'* surfaced nothing worth acting on. The empty-state verdict is a separate question, answered over* the states the current user can actually see.*/-const COUNTED_SECTION_KEYS = ['needs-decision', 'monitoring', 'resolved', 'dismissed', 'held-back'] as const+const COUNTED_SECTION_KEYS = ['needs-decision', 'monitoring', 'resolved', 'closed', 'dismissed', 'held-back'] as consttype CountedSectionKey = (typeof COUNTED_SECTION_KEYS)[number]@@ -88,7 +88,7 @@ function useSectionState(sectionKey: InboxReportSectionKey): SectionListState {}/**- * Every state's count and loaded rows, keyed by state. All six logics are mounted regardless of+ * Every state's count and loaded rows, keyed by state. All logics are mounted regardless of* who is looking or which states the filter selects, so the hooks never change shape when the* staff flag resolves or a checkbox toggles; callers decide which states matter to them.*/@@ -97,6 +97,7 @@ function useSectionStates(): Record<InboxReportSectionKey, SectionListState> {monitoring: useSectionState('monitoring'),'needs-decision': useSectionState('needs-decision'),resolved: useSectionState('resolved'),+ closed: useSectionState('closed'),dismissed: useSectionState('dismissed'),'held-back': useSectionState('held-back'),'not-actionable': useSectionState('not-actionable'),diff --git a/products/signals/frontend/inbox/components/useReportImpressions.ts b/products/signals/frontend/inbox/components/useReportImpressions.tsindex 4da25c06c937..155888a6b8d0 100644--- a/products/signals/frontend/inbox/components/useReportImpressions.ts+++ b/products/signals/frontend/inbox/components/useReportImpressions.ts@@ -55,6 +55,7 @@ export function useReportImpressions(rows: MergedReportRow[], selectedSections:monitoring: useSectionImpressionState('monitoring'),'needs-decision': useSectionImpressionState('needs-decision'),resolved: useSectionImpressionState('resolved'),+ closed: useSectionImpressionState('closed'),dismissed: useSectionImpressionState('dismissed'),'held-back': useSectionImpressionState('held-back'),'not-actionable': useSectionImpressionState('not-actionable'),diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.tsindex 177f48f4d934..24532e344e32 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts@@ -147,7 +147,7 @@ describe('inboxFiltersLogic', () => {...DEFAULT_STATE,sourceProductFilter: ['error_tracking', 'logs'],priorityFilter: ['P1'],- stateFilter: ['monitoring'],+ stateFilter: ['monitoring', 'closed'],})})diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.tsindex b559df9e2d73..e87cdf29576f 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts@@ -347,7 +347,15 @@ export interface inboxFiltersLogicValues {sortField: InboxSortFieldsourceFilterAvailable: booleansourceProductFilter: string[]- stateFilter: ('dismissed' | 'held-back' | 'monitoring' | 'needs-decision' | 'not-actionable' | 'resolved')[]+ stateFilter: (+ | 'closed'+ | 'dismissed'+ | 'held-back'+ | 'monitoring'+ | 'needs-decision'+ | 'not-actionable'+ | 'resolved'+ )[]timeWindowAvailable: booleanvisibleStateFilter: InboxReportSectionKey[]}@@ -449,7 +457,7 @@ export interface inboxFiltersLogicActions {source: string}toggleState: (state: InboxReportSectionKey) => {- state: 'dismissed' | 'held-back' | 'monitoring' | 'needs-decision' | 'not-actionable' | 'resolved'+ state: 'closed' | 'dismissed' | 'held-back' | 'monitoring' | 'needs-decision' | 'not-actionable' | 'resolved'}}@@ -485,6 +493,7 @@ export interface inboxFiltersLogicMeta {activeScoutFilter: (scoutFilter: string[], sourceFilterAvailable: boolean) => string[]visibleStateFilter: (stateFilter: (+ | 'closed'| 'dismissed'| 'held-back'| 'monitoring'diff --git a/products/signals/frontend/inbox/logics/reportListLogic.ts b/products/signals/frontend/inbox/logics/reportListLogic.tsindex b065f58d01a9..30bb8bab187e 100644--- a/products/signals/frontend/inbox/logics/reportListLogic.ts+++ b/products/signals/frontend/inbox/logics/reportListLogic.ts@@ -15,6 +15,7 @@ import type { UserType } from '~/types'import {signalsReportsRefreshMetricsCreate,+ signalsReportsList,signalsReportsReviewersMeCreate,signalsReportsReviewersMeDestroy,signalsReportsSourceMetadataCreate,@@ -100,6 +101,7 @@ export const INBOX_REPORT_SECTION_LIST_PARAMS: Record<InboxReportSectionKey, Rep'needs-decision': { view: 'needs_decision' },// Fixed by a merged implementation PR, or resolved by a person. Terminal, not restorable.resolved: { status: 'resolved' },+ closed: { view: 'closed' },// Dismissed by a person or agent, or suppressed because its PR closed without merging. Restorable.dismissed: { view: 'dismissed' },// Suppressed by the safety or actionability judge, with no dismissal from anyone.@@ -196,6 +198,8 @@ export interface reportListLogicValues {count: number | nullcountLoading: booleanhasMore: boolean+ hasProjectClosedReports: boolean | null+ hasProjectClosedReportsLoading: booleanisLoaded: booleanlistApiParams: anylivePrReportIds: string[]@@ -304,6 +308,21 @@ export interface reportListLogicActions {count: numberpayload?: void}+ loadHasProjectClosedReports: (_: void) => void+ loadHasProjectClosedReportsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadHasProjectClosedReportsSuccess: (+ hasProjectClosedReports: boolean,+ payload?: void+ ) => {+ hasProjectClosedReports: boolean+ payload?: void+ }loadMore: () => {value: true}@@ -407,7 +426,7 @@ export interface reportListLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface reportListLogicMeta {- key: 'dismissed' | 'held-back' | 'monitoring' | 'needs-decision' | 'not-actionable' | 'resolved'+ key: 'closed' | 'dismissed' | 'held-back' | 'monitoring' | 'needs-decision' | 'not-actionable' | 'resolved'__keaTypeGenInternalSelectorTypes: {scopeReviewerUuid: (scope: InboxScope, user: UserType | null) => string | undefinedscopeAssignee: (scope: InboxScope) => 'mine' | undefined@@ -540,6 +559,20 @@ export const reportListLogic = kea<reportListLogicType>([}),loaders(({ values, cache }) => ({+ hasProjectClosedReports: [+ null as boolean | null,+ {+ loadHasProjectClosedReports: async (_: void, breakpoint) => {+ const response = await signalsReportsList(String(values.currentTeamId), {+ view: 'closed',+ count_only: true,+ limit: 1,+ })+ breakpoint()+ return response.count > 0+ },+ },+ ],// Cheap count-only request – populates the state's count before its rows load. `count_only`// lets the backend answer with one `COUNT(*)`, skipping ordering, row serialization, and// the per-row metadata lookups.@@ -837,6 +870,11 @@ export const reportListLogic = kea<reportListLogicType>([}),listeners(({ actions, values, props, cache }) => ({+ loadCount: () => {+ if (props.sectionKey === 'closed') {+ actions.loadHasProjectClosedReports()+ }+ },// Announce this section's open pull requests so their CI state is resolved in one batch. Both// 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.diff --git a/products/signals/frontend/inbox/types.ts b/products/signals/frontend/inbox/types.tsindex 79655071115f..a7a6c1a89490 100644--- a/products/signals/frontend/inbox/types.ts+++ b/products/signals/frontend/inbox/types.ts@@ -307,6 +307,7 @@ export const INBOX_REPORT_SECTION_KEYS = ['monitoring','needs-decision','resolved',+ 'closed','dismissed','held-back','not-actionable',@@ -323,6 +324,7 @@ export const INBOX_REPORT_SECTION_LABEL: Record<InboxReportSectionKey, string> =monitoring: 'Review and merge','needs-decision': 'Needs decision',resolved: 'Resolved',+ closed: 'Closed',dismissed: 'Dismissed','held-back': 'Held back','not-actionable': 'Not actionable',@@ -333,6 +335,7 @@ export const INBOX_REPORT_SECTION_DESCRIPTION: Record<InboxReportSectionKey, strmonitoring: 'Reports with a pull request open, ready for you to review and merge on GitHub.','needs-decision': 'Reports an agent can act on that have no pull request yet.',resolved: 'Reports fixed by a merged pull request, or marked resolved.',+ closed: 'Reports marked closed, including reports whose verification checks failed.',dismissed:'Reports a person or agent dismissed, and reports whose pull request was closed without merging. Most can be restored to your inbox.','held-back':diff --git a/products/signals/frontend/inbox/utils/flatReportList.test.ts b/products/signals/frontend/inbox/utils/flatReportList.test.tsindex 078d17106f92..60ac4ec3955a 100644--- a/products/signals/frontend/inbox/utils/flatReportList.test.ts+++ b/products/signals/frontend/inbox/utils/flatReportList.test.ts@@ -25,6 +25,7 @@ function sections(monitoring: [],'needs-decision': [],resolved: [],+ closed: [],dismissed: [],'held-back': [],'not-actionable': [],