: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(inbox): scroll the filter popovers and list only enabled sources (#84994)
Paul D'Ambra588184e2540b
diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxSearchFilterBar.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxSearchFilterBar.tsxindex 5f49cdc9f774..bb593d3579fc 100644--- a/products/desktop/packages/ui/src/features/inbox/components/InboxSearchFilterBar.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxSearchFilterBar.tsx@@ -9,14 +9,14 @@ import {import {INBOX_PRIORITY_OPTIONS,INBOX_SORT_OPTIONS,- INBOX_SOURCE_OPTIONS,inboxPriorityFilterLabel,inboxSortOptionKey,inboxSourceFilterLabel,} from "@posthog/ui/features/inbox/filterOptions";+import { useInboxSourceFilterOptions } from "@posthog/ui/features/inbox/hooks/useInboxSourceFilterOptions";import { useInboxSignalsFilterStore } from "@posthog/ui/features/inbox/stores/inboxSignalsFilterStore";import { Flex, Popover } from "@radix-ui/themes";-import { type ReactNode, useId } from "react";+import { type ReactNode, useId, useMemo } from "react";interface InboxSearchFilterBarProps {searchPlaceholder?: string;@@ -49,6 +49,12 @@ export function InboxSearchFilterBar({(s) => s.setPriorityFilter,);+ const sourceOptions = useInboxSourceFilterOptions(sourceProductFilter);+ const selectedSources = useMemo(+ () => new Set(sourceProductFilter),+ [sourceProductFilter],+ );+const activeSort = INBOX_SORT_OPTIONS.find((option) =>option.field === sortField && option.direction === sortDirection,@@ -83,8 +89,8 @@ export function InboxSearchFilterBar({active={sourceProductFilter.length === 0}onClick={clearSourceProductFilter}/>- {INBOX_SOURCE_OPTIONS.map((option) => {- const isActive = sourceProductFilter.includes(option.value);+ {sourceOptions.map((option) => {+ const isActive = selectedSources.has(option.value);return (<buttonkey={option.value}@@ -226,7 +232,9 @@ function InboxFilterPopover({align="start"side="bottom"sideOffset={6}- className="min-w-[220px] p-1.5"+ // Option lists can outgrow the viewport (sources especially), so the+ // panel scrolls inside whatever room the popper has below the trigger.+ className="max-h-[min(22rem,calc(var(--available-height,22rem)-1rem))] min-w-[220px] overflow-y-auto p-1.5">{children}</Popover.Content>diff --git a/products/desktop/packages/ui/src/features/inbox/filterOptions.test.ts b/products/desktop/packages/ui/src/features/inbox/filterOptions.test.tsindex 314db8191346..2809e83d2220 100644--- a/products/desktop/packages/ui/src/features/inbox/filterOptions.test.ts+++ b/products/desktop/packages/ui/src/features/inbox/filterOptions.test.ts@@ -2,7 +2,9 @@ import type { AvailableSuggestedReviewer } from "@posthog/shared/types";import { describe, expect, it } from "vitest";import {buildSuggestedReviewerFilterOptions,+ filterInboxSourceOptions,getSuggestedReviewerDisplayName,+ INBOX_SOURCE_OPTIONS,} from "./filterOptions";function makeReviewer(@@ -61,6 +63,47 @@ describe("getSuggestedReviewerDisplayName", () => {});});+describe("filterInboxSourceOptions", () => {+ const values = (enabled?: ReadonlySet<string>) =>+ filterInboxSourceOptions(enabled, []).map((option) => option.value);++ it("keeps only the warehouse sources that are switched on", () => {+ expect(values(new Set(["github", "zendesk"]))).toEqual([+ "session_replay",+ "error_tracking",+ "llm_analytics",+ "conversations",+ "signals_scout",+ "health_checks",+ "github",+ "zendesk",+ ]);+ });++ it("keeps PostHog's own products when nothing is switched on", () => {+ expect(values(new Set())).toEqual([+ "session_replay",+ "error_tracking",+ "llm_analytics",+ "conversations",+ "signals_scout",+ "health_checks",+ ]);+ });++ it("keeps a selected source so an active filter stays visible", () => {+ expect(filterInboxSourceOptions(new Set(), ["sentry"])).toContainEqual(+ expect.objectContaining({ value: "sentry" }),+ );+ });++ it("hides nothing while the enabled set is unknown", () => {+ expect(filterInboxSourceOptions(undefined, [])).toEqual(+ INBOX_SOURCE_OPTIONS,+ );+ });+});+describe("buildSuggestedReviewerFilterOptions", () => {it("pins the current user to the top and marks them as me", () => {const me = {diff --git a/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx b/products/desktop/packages/ui/src/features/inbox/filterOptions.tsxindex 2a643e195f73..77f591a34c64 100644--- a/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx+++ b/products/desktop/packages/ui/src/features/inbox/filterOptions.tsx@@ -71,11 +71,13 @@ export const INBOX_PRIORITY_OPTIONS: {{ value: "P4", accent: "var(--gray-9)" },];-export const INBOX_SOURCE_OPTIONS: {+export type InboxSourceOption = {value: SourceProduct;label: string;icon: ReactNode;-}[] = [+};++export const INBOX_SOURCE_OPTIONS: InboxSourceOption[] = [{value: "session_replay",label: "Session replay",@@ -114,6 +116,37 @@ export const INBOX_SOURCE_OPTIONS: {}),];+const EXTERNAL_SOURCE_PRODUCTS = new Set<string>(+ EXTERNAL_INBOX_SOURCES.map((source) => source.product),+);++/**+ * Narrow the source filter down to what a project actually uses.+ *+ * The registry carries every warehouse-backed integration we support (~40),+ * while a project runs a handful — listing them all makes the filter taller than+ * the screen. So warehouse sources are kept only when they are switched on, plus+ * anything currently selected, so an active filter is never invisible. PostHog's+ * own products stay listed unconditionally: they need no setup, and some+ * (Scouts) emit reports without a `signal_source_config` row at all.+ *+ * Pass `undefined` when the enabled set is unknown (still loading, or the+ * request failed) and nothing is hidden — better a long list than a filter that+ * silently can't reach a source.+ */+export function filterInboxSourceOptions(+ enabledSourceProducts: ReadonlySet<string> | undefined,+ selected: readonly SourceProduct[],+): InboxSourceOption[] {+ if (!enabledSourceProducts) return INBOX_SOURCE_OPTIONS;+ return INBOX_SOURCE_OPTIONS.filter(+ (option) =>+ !EXTERNAL_SOURCE_PRODUCTS.has(option.value) ||+ enabledSourceProducts.has(option.value) ||+ selected.includes(option.value),+ );+}+export function inboxSortOptionKey(field: InboxSortField,direction: "asc" | "desc",diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.tsnew file mode 100644index 000000000000..093cf2d4ab9a--- /dev/null+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxSourceFilterOptions.ts@@ -0,0 +1,27 @@+import type { SourceProduct } from "@posthog/shared/types";+import {+ filterInboxSourceOptions,+ type InboxSourceOption,+} from "@posthog/ui/features/inbox/filterOptions";+import { useSignalSourceConfigs } from "@posthog/ui/features/inbox/hooks/useSignalSourceConfigs";+import { useMemo } from "react";++/**+ * Source options worth offering in the inbox filter: the sources this project+ * has switched on, plus PostHog's own products. See `filterInboxSourceOptions`+ * for the rules.+ */+export function useInboxSourceFilterOptions(+ selected: SourceProduct[],+): InboxSourceOption[] {+ const { data: configs } = useSignalSourceConfigs();++ return useMemo(() => {+ if (!configs) return filterInboxSourceOptions(undefined, selected);+ const enabled = new Set<string>();+ for (const config of configs) {+ if (config.enabled) enabled.add(config.source_product);+ }+ return filterInboxSourceOptions(enabled, selected);+ }, [configs, selected]);+}