: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(inbox): compact the reports tab header in narrow containers (#128724)
posthog[bot]537b24d68679
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 2f7f54737527..d1018b5f8cf7 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -12582,6 +12582,10 @@ snapshots:hash: v1.k794b7964.87b4023d1181af0c9f5d86706035c57b717b85fe9cefaa264eccbc7d63937c2a.WqRDw9HiZyOJFYBCpiF4MSU0iKCqGrun34HL31jx5HUscenes-app-inbox-scene--report-without-evidence--light:hash: v1.k794b7964.e6d12bd6f862ac226548a221d7e6c4655cd2455d24903d31122ddc5c691451d9.EGSzgF4ca3R8GPVWCpadnc-09_LgNoXebfytHYYZA9w+ scenes-app-inbox-scene--reports-narrow--dark:+ hash: v1.k794b7964.281117c64fc5141cee0ca2eb0955504de79aaaba26101b06f647cc1d16e23053.MgRPSbf2yoIPnBhGmG4Ctcd0NstOaiXKLZMoR6cM_Xk+ scenes-app-inbox-scene--reports-narrow--light:+ hash: v1.k794b7964.9ecd8790364701078d187380cf3853f86de835f5de1345b1d88b8e9289bff3ee.aLMSWf2cvBLc_gMVODQSxuVokIV50-ocsmr-2OGSTZQscenes-app-inbox-scene--scouts--dark:hash: v1.k794b7964.342b6ade0a3245d92d924e2e7d37484d96e28dcc699b3f565f87c8dfda96be96.T5RoSmtn2CUXtooHEFwovo4fJfyjBXJDwg9KGBQs-lsscenes-app-inbox-scene--scouts--light:diff --git a/products/signals/frontend/inbox/InboxScene.stories.tsx b/products/signals/frontend/inbox/InboxScene.stories.tsxindex 947a96b2582a..c35b247d200d 100644--- a/products/signals/frontend/inbox/InboxScene.stories.tsx+++ b/products/signals/frontend/inbox/InboxScene.stories.tsx@@ -1,4 +1,5 @@import type { Decorator, Meta, StoryObj } from '@storybook/react'+import { waitFor, within } from '@testing-library/dom'import { useMountedLogic } from 'kea'import { router } from 'kea-router'import { useEffect } from 'react'@@ -10,7 +11,7 @@ import { urls } from 'scenes/urls'import { mswDecorator } from '~/mocks/browser'-import { expect } from 'storybook/test'+import { expect, userEvent } from 'storybook/test'import {allReports,@@ -130,6 +131,22 @@ const valueSummaryMocks = mswDecorator({},})+export const ReportsNarrow: Story = {+ parameters: {+ featureFlags: {+ ...meta.parameters?.featureFlags,+ [FEATURE_FLAGS.INBOX_TIME_WINDOW]: true,+ [FEATURE_FLAGS.INBOX_SOURCE_FILTER]: true,+ },+ testOptions: { viewport: { width: 390, height: 844 }, waitForLoadersToDisappear: false },+ },+ play: async ({ canvas }) => {+ await userEvent.click(await canvas.findByLabelText('Filters'))+ // The panel renders in a popover outside the story root, and fades in after the click.+ await waitFor(() => expect(within(document.body).getByText('Reset to default')).toBeVisible())+ },+}+export const WithValueSummary: Story = {parameters: {featureFlags: {diff --git a/products/signals/frontend/inbox/InboxScene.tsx b/products/signals/frontend/inbox/InboxScene.tsxindex 441fc6a32d5b..567280d72cf9 100644--- a/products/signals/frontend/inbox/InboxScene.tsx+++ b/products/signals/frontend/inbox/InboxScene.tsx@@ -113,8 +113,14 @@ function InboxListView(): JSX.Element {<div className="flex flex-col min-h-0 flex-1 min-w-0">{/* pl-5 (20px) aligns the first tab label with the SceneTitleSection description above. */}{!onboarding && !pending && (- <div className="border-b border-primary pl-5 pr-6 shrink-0">+ <div className="flex items-center gap-2 border-b border-primary pl-5 pr-6 shrink-0"><InboxTabBar />+ {/* Pairs with the header Triage button, which hides below the same @2xl/inbox width. */}+ {activeTab === 'reports' && (+ <div className="ml-auto shrink-0 @2xl/inbox:hidden">+ <InboxTriageButton compact />+ </div>+ )}</div>)}<div className="flex-1 overflow-auto min-h-0">@@ -261,11 +267,13 @@ export function InboxScene(): JSX.Element {const headerActions = !tabUnlocked ? undefined : activeTab === 'scouts' ? (<ScoutsRosterActions />) : activeTab === 'reports' ? (- <InboxTriageButton />+ <div className="hidden @2xl/inbox:contents">+ <InboxTriageButton />+ </div>) : undefinedreturn (- <SceneContent className="gap-y-0 border-b-0 flex-1 min-h-0">+ <SceneContent className="@container/inbox gap-y-0 border-b-0 flex-1 min-h-0"><div className={showDetail ? 'hidden' : 'flex flex-col gap-y-4 flex-1 min-h-0'}><SceneTitleSectionname="Self-driving inbox"diff --git a/products/signals/frontend/inbox/components/shell/InboxFiltersPanel.tsx b/products/signals/frontend/inbox/components/shell/InboxFiltersPanel.tsxnew file mode 100644index 000000000000..fb90cc104ee2--- /dev/null+++ b/products/signals/frontend/inbox/components/shell/InboxFiltersPanel.tsx@@ -0,0 +1,53 @@+import { useActions, useValues } from 'kea'+import { useState } from 'react'++import { IconFilter } from '@posthog/icons'+import { LemonBadge, LemonButton, LemonDivider, LemonDropdown } from '@posthog/lemon-ui'++import { inboxFiltersLogic } from '../../logics/inboxFiltersLogic'+import { InboxReportFilters } from './InboxReportFilters'++/** The Reports filters behind one button, for a container too narrow to show them in a row. */+export function InboxFiltersPanel(): JSX.Element {+ const { nonDefaultReportFilterCount: count } = useValues(inboxFiltersLogic)+ const { clearFilters } = useActions(inboxFiltersLogic)+ const [visible, setVisible] = useState(false)++ return (+ <LemonDropdown+ closeOnClickInside={false}+ visible={visible}+ onVisibilityChange={setVisible}+ matchWidth={false}+ actionable+ placement="bottom-start"+ overlay={+ <div className="flex w-72 max-w-[calc(100vw-2rem)] flex-col gap-2 p-2">+ <InboxReportFilters layout="panel" />+ <LemonDivider className="my-0" />+ <LemonButton+ size="small"+ type="tertiary"+ onClick={clearFilters}+ disabledReason={count === 0 ? 'The filters are already at their defaults' : undefined}+ data-attr="inbox-filters-reset"+ >+ Reset to default+ </LemonButton>+ </div>+ }+ >+ <LemonButton+ size="small"+ type="secondary"+ icon={<IconFilter />}+ sideIcon={count > 0 ? <LemonBadge.Number count={count} size="small" /> : undefined}+ aria-label={count > 0 ? `Filters, ${count} changed` : 'Filters'}+ // pinned: autocapture selector. It measures use of the compact filters, so renaming it breaks that.+ data-attr="inbox-filters-panel"+ >+ Filters+ </LemonButton>+ </LemonDropdown>+ )+}diff --git a/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx b/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsxindex 319991e39247..c01a9a229df6 100644--- a/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxReportFilters.tsx@@ -42,6 +42,15 @@ function createdWindowLabel(window: InboxCreatedWindow | null): string {return CREATED_WINDOW_SELECT_OPTIONS.find((option) => option.value === window)?.label ?? 'Any time'}+function PanelField({ label, children }: { label: string; children: JSX.Element }): JSX.Element {+ return (+ <div className="flex items-center justify-between gap-4">+ <span className="text-sm text-secondary">{label}</span>+ {children}+ </div>+ )+}+/*** What narrows the report list: report state, then priority, then the created-in window, then source.* Filter state is persisted via `inboxFiltersLogic`, and the list reloads on change.@@ -52,42 +61,54 @@ function createdWindowLabel(window: InboxCreatedWindow | null): string {* Sort and reviewer scope are deliberately not here. Sort orders the list rather than narrowing it,* and scope picks whose inbox this is, so both sit after a divider at the end of the row.*/-export function InboxReportFilters(): JSX.Element {+export function InboxReportFilters({ layout = 'row' }: { layout?: 'row' | 'panel' }): JSX.Element {const { priorityFilter, timeWindowAvailable, createdWindow, sourceFilterAvailable } = useValues(inboxFiltersLogic)const { setPriorityFilter, setCreatedWindow } = useActions(inboxFiltersLogic)+ const panel = layout === 'panel'+ const field = (label: string, control: JSX.Element): JSX.Element =>+ panel ? <PanelField label={label}>{control}</PanelField> : controlreturn (- <div className="flex flex-wrap items-center gap-2">- <InboxStateFilter />- <LemonSelect- size="small"- value={priorityFilter.length === 1 ? priorityFilter[0] : ALL_PRIORITIES}- onChange={(priority) => setPriorityFilter(priority ? [priority as SignalReportPriority] : [])}- options={PRIORITY_SELECT_OPTIONS}- // A shared link can carry several priorities, which no single option represents.- // Read the selection out of the filter itself so the button never understates it.- renderButtonContent={() => inboxPriorityFilterLabel(priorityFilter)}- data-attr="inbox-filter-priority"- />- {timeWindowAvailable && (+ <div className={panel ? 'flex flex-col gap-2' : 'flex flex-wrap items-center gap-2'}>+ {field('Status', <InboxStateFilter />)}+ {field(+ 'Priority',<LemonSelectsize="small"- value={createdWindow}- onChange={(window) => setCreatedWindow(window)}- options={CREATED_WINDOW_SELECT_OPTIONS}- icon={<IconCalendar />}- tooltip={`Created: ${createdWindowLabel(createdWindow)}`}- // The window value ("7d") doubles as the short label in a narrow container.- renderButtonContent={(leaf) => (- <>- <span className="@2xl:hidden">{leaf?.value ?? 'Any time'}</span>- <span className="hidden @2xl:inline">{leaf?.label ?? 'Any time'}</span>- </>- )}- data-attr="inbox-filter-created-window"+ value={priorityFilter.length === 1 ? priorityFilter[0] : ALL_PRIORITIES}+ onChange={(priority) => setPriorityFilter(priority ? [priority as SignalReportPriority] : [])}+ options={PRIORITY_SELECT_OPTIONS}+ // A shared link can carry several priorities, which no single option represents.+ // Read the selection out of the filter itself so the button never understates it.+ renderButtonContent={() => inboxPriorityFilterLabel(priorityFilter)}+ data-attr="inbox-filter-priority"/>)}- {sourceFilterAvailable && <InboxSourceFilter />}+ {timeWindowAvailable &&+ field(+ 'Created',+ <LemonSelect+ size="small"+ value={createdWindow}+ onChange={(window) => setCreatedWindow(window)}+ options={CREATED_WINDOW_SELECT_OPTIONS}+ icon={<IconCalendar />}+ tooltip={panel ? undefined : `Created: ${createdWindowLabel(createdWindow)}`}+ // The window value ("7d") doubles as the short label in a narrow container.+ renderButtonContent={(leaf) =>+ panel ? (+ (leaf?.label ?? 'Any time')+ ) : (+ <>+ <span className="@2xl:hidden">{leaf?.value ?? 'Any time'}</span>+ <span className="hidden @2xl:inline">{leaf?.label ?? 'Any time'}</span>+ </>+ )+ }+ data-attr="inbox-filter-created-window"+ />+ )}+ {sourceFilterAvailable && field('Source', <InboxSourceFilter />)}</div>)}diff --git a/products/signals/frontend/inbox/components/shell/InboxSortSelect.tsx b/products/signals/frontend/inbox/components/shell/InboxSortSelect.tsxindex 9894ccd21fc1..e69013d5872c 100644--- a/products/signals/frontend/inbox/components/shell/InboxSortSelect.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxSortSelect.tsx@@ -22,7 +22,7 @@ const ALL_SORT_OPTIONS = [...INBOX_SORT_OPTIONS, ...INBOX_MODEL_SORT_OPTIONS]/*** The report list's sort order. It orders the list rather than narrowing it, so it sits after the- * filters. In a narrow container the trigger shows only the icon, and the tooltip names the order.+ * filters. In a very narrow container the trigger shows only the icon, and the tooltip names the order.*/export function InboxSortSelect(): JSX.Element {const { activeSortField, activeSortDirection, modelSortAvailable } = useValues(inboxFiltersLogic)@@ -44,7 +44,7 @@ export function InboxSortSelect(): JSX.Element {options={modelSortAvailable ? SORT_SELECT_SECTIONS_WITH_MODEL : SORT_SELECT_OPTIONS}icon={<IconSort />}tooltip={`Sort: ${activeLabel}`}- renderButtonContent={(leaf) => <span className="hidden @2xl:inline">{leaf?.label ?? ''}</span>}+ renderButtonContent={(leaf) => <span className="hidden @md:inline">{leaf?.label ?? ''}</span>}data-attr="inbox-sort"/>)diff --git a/products/signals/frontend/inbox/components/shell/InboxTriageButton.tsx b/products/signals/frontend/inbox/components/shell/InboxTriageButton.tsxindex 53767e8cc631..6fb8bc83814c 100644--- a/products/signals/frontend/inbox/components/shell/InboxTriageButton.tsx+++ b/products/signals/frontend/inbox/components/shell/InboxTriageButton.tsx@@ -17,9 +17,12 @@ const NOTHING_TO_TRIAGE = 'No reports in this view need a pull request'// pinned: autocapture selector. Triage usage insights filter clicks on this data-attr.const TRIAGE_DATA_ATTR = 'inbox-triage-mode'-function triageLabel(count: number | null): string {+function triageLabel(count: number | null, compact: boolean): string {if (count === null) {- return 'Triage mode'+ return compact ? 'Triage' : 'Triage mode'+ }+ if (compact) {+ return `Triage ${humanFriendlyNumber(count)}`}return `Triage ${humanFriendlyNumber(count)} ${count === 1 ? 'report' : 'reports'}`}@@ -28,12 +31,13 @@ function triageLabel(count: number | null): string {* Opens triage mode from the scene header. It is an action, not a filter, so it sits apart from the* filter row. Triage walks the primary section with the Reports tab's filters and scope, so the* count comes from that same section and matches what triage will show.+ * `compact` drops the hotkey hint for the narrow tab row. The scene binds `t` either way.*/-export function InboxTriageButton(): JSX.Element {+export function InboxTriageButton({ compact = false }: { compact?: boolean }): JSX.Element {const { count } = useValues(reportListLogic(sectionListLogicProps(INBOX_PRIMARY_REPORT_SECTION_KEY)))const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')const disabledReason = count === 0 ? NOTHING_TO_TRIAGE : undefined- const label = triageLabel(count)+ const label = triageLabel(count, compact)if (todayRailNav) {return (@@ -45,7 +49,7 @@ export function InboxTriageButton(): JSX.Element {data-attr={TRIAGE_DATA_ATTR}>{label}- <Kbd>T</Kbd>+ {!compact && <Kbd>T</Kbd>}</Button>)}@@ -54,7 +58,7 @@ export function InboxTriageButton(): JSX.Element {type="primary"size="small"to={urls.inboxTriage()}- sideIcon={<KeyboardShortcut t />}+ sideIcon={compact ? undefined : <KeyboardShortcut t />}tooltip={TRIAGE_TOOLTIP}disabledReason={disabledReason}data-attr={TRIAGE_DATA_ATTR}diff --git a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsxindex 3d61402639fe..328f1fd1d207 100644--- a/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx+++ b/products/signals/frontend/inbox/components/tabs/ReportsTab.tsx@@ -30,6 +30,7 @@ import { InboxWaitingForWork } from '../emptyState/InboxWaitingForWork'import { InboxMcpBanner } from '../InboxMcpBanner'import { InboxActivationPanel } from '../onboarding/InboxActivationPanel'import { InboxBulkSelectionBar } from '../shell/InboxBulkSelectionBar'+import { InboxFiltersPanel } from '../shell/InboxFiltersPanel'import { InboxReportFilters } from '../shell/InboxReportFilters'import { InboxScopeFilter } from '../shell/InboxScopeFilter'import { InboxSortSelect } from '../shell/InboxSortSelect'@@ -358,7 +359,14 @@ export function ReportsTab(): JSX.Element {line it falls outside the clipped edge instead of leading the line. The sort groupgrows so scope always ends the row. */}<div className="@container -mx-1 overflow-x-clip px-1">- <div className="flex flex-wrap items-center gap-2">+ <div className="flex items-center gap-2 @2xl:hidden">+ <InboxFiltersPanel />+ <InboxSortSelect />+ <div className="ml-auto min-w-0">+ <InboxScopeFilter />+ </div>+ </div>+ <div className="hidden flex-wrap items-center gap-2 @2xl:flex"><InboxReportFilters /><div className="relative flex flex-1 items-center gap-2"><LemonDivider vertical className="absolute inset-y-1 -left-[5px] m-0" />diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.tsindex 24532e344e32..788efb370ccf 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.test.ts@@ -337,6 +337,55 @@ describe('inboxFiltersLogic', () => {.toMatchValues({ activeScoutFilter: ['my-custom-scout'], hasActiveFilters: true })})+ it.each([+ ['the default view', () => {}, null, 0],+ ['a ranking sort with its automatic window', () => logic.actions.setSort('ranking_fix', 'desc'), '7d', 0],+ [+ 'a different window under a ranking sort',+ () => {+ logic.actions.setSort('ranking_fix', 'desc')+ logic.actions.setCreatedWindow('14d')+ },+ '14d',+ 1,+ ],+ ['a 7 day window under a non-ranking sort', () => logic.actions.setCreatedWindow('7d'), '7d', 1],+ [+ 'status, priority and source',+ () => {+ logic.actions.toggleState('resolved')+ logic.actions.setPriorityFilter(['P1'])+ logic.actions.setSourceFilter({ kind: 'scout', value: 'my-custom-scout' })+ },+ null,+ 3,+ ],+ [+ 'a reset under a ranking sort',+ () => {+ logic.actions.setSort('ranking_fix', 'desc')+ logic.actions.setCreatedWindow('24h')+ logic.actions.setPriorityFilter(['P1'])+ logic.actions.clearFilters()+ },+ '7d',+ 0,+ ],+ ] as const)('counts non-default report filters for %s', (_name, act, createdWindow, count) => {+ featureFlagLogic.actions.setFeatureFlags(+ [FEATURE_FLAGS.INBOX_MODEL_SORT, FEATURE_FLAGS.INBOX_TIME_WINDOW, FEATURE_FLAGS.INBOX_SOURCE_FILTER],+ {+ [FEATURE_FLAGS.INBOX_MODEL_SORT]: true,+ [FEATURE_FLAGS.INBOX_TIME_WINDOW]: true,+ [FEATURE_FLAGS.INBOX_SOURCE_FILTER]: true,+ }+ )++ act()++ expect(logic.values).toMatchObject({ createdWindow, nonDefaultReportFilterCount: count })+ })+it.each([['keeps a stored model sort for staff with the flag',diff --git a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts b/products/signals/frontend/inbox/logics/inboxFiltersLogic.tsindex e87cdf29576f..ba4c83d54ac9 100644--- a/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts+++ b/products/signals/frontend/inbox/logics/inboxFiltersLogic.ts@@ -339,6 +339,7 @@ export interface inboxFiltersLogicValues {uuid: string} | nullmodelSortAvailable: boolean+ nonDefaultReportFilterCount: numberpriorityFilter: SignalReportPriority[]scope: InboxScopescoutFilter: string[]@@ -503,6 +504,22 @@ export interface inboxFiltersLogicMeta {)[],user: UserType | null) => InboxReportSectionKey[]+ nonDefaultReportFilterCount: (+ visibleStateFilter: (+ | 'closed'+ | 'dismissed'+ | 'held-back'+ | 'monitoring'+ | 'needs-decision'+ | 'not-actionable'+ | 'resolved'+ )[],+ priorityFilter: SignalReportPriority[],+ activeCreatedWindow: InboxCreatedWindow | null,+ activeSortField: InboxSortField,+ activeSourceProductFilter: string[],+ activeScoutFilter: string[]+ ) => number}}@@ -646,7 +663,13 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([togglePriority: () => captureQueryChange('priority'),setPriorityFilter: () => captureQueryChange('priority'),toggleState: () => captureQueryChange('state'),- clearFilters: () => captureQueryChange('clear'),+ clearFilters: () => {+ // Under a ranking sort the default is the sort's own window, not "any time".+ if (isRankingSortField(values.activeSortField) && values.timeWindowAvailable) {+ actions.applyDefaultCreatedWindow(MODEL_SORT_DEFAULT_WINDOW)+ }+ captureQueryChange('clear')+ },setFilters: () => {rememberSelectedTeammate()captureQueryChange('url')@@ -886,6 +909,33 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([? stateFilter: stateFilter.filter((key) => !INBOX_STAFF_ONLY_REPORT_SECTION_KEYS.includes(key)),],+ // The window a ranking sort applies on its own is that sort's default, so it does not count.+ nonDefaultReportFilterCount: [+ (s) => [+ s.visibleStateFilter,+ s.priorityFilter,+ s.activeCreatedWindow,+ s.activeSortField,+ s.activeSourceProductFilter,+ s.activeScoutFilter,+ ],+ (+ visibleStateFilter: InboxReportSectionKey[],+ priorityFilter: SignalReportPriority[],+ activeCreatedWindow: InboxCreatedWindow | null,+ activeSortField: InboxSortField,+ activeSourceProductFilter: string[],+ activeScoutFilter: string[]+ ): number => {+ const defaultCreatedWindow = isRankingSortField(activeSortField) ? MODEL_SORT_DEFAULT_WINDOW : null+ return [+ !isDefaultStateFilter(visibleStateFilter),+ priorityFilter.length > 0,+ activeCreatedWindow !== null && activeCreatedWindow !== defaultCreatedWindow,+ activeSourceProductFilter.length > 0 || activeScoutFilter.length > 0,+ ].filter(Boolean).length+ },+ ],}),subscriptions(({ actions, values }) => ({