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.

feat(taxonomic-filter): batch suggested search results behind a reveal barrier (#59767)

Paul D'Ambraf9e6041a5d98
diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.yml
index 92a20d7c03cb..1b79e6311a88 100644
--- a/.github/workflows/ci-frontend.yml
+++ b/.github/workflows/ci-frontend.yml
@@ -274,7 +274,10 @@ jobs:
needs: [changes]
if: needs.changes.outputs.frontend_code == 'true'
runs-on: ubuntu-latest
- timeout-minutes: 15
+ # Kea typegen invalidates on changes to any logic plus everything that depends on it.
+ # For changes to shared core (TaxonomicFilter, Insight, etc.) the dependent set is large
+ # and the cache miss costs ~5min on top of the master baseline (~10min). 15 is too tight.
+ timeout-minutes: 20
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
index ffb3c2a6bc90..e8773c0c9398 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
@@ -1307,4 +1307,105 @@ describe('TaxonomicFilter', () => {
}
})
})
+
+ describe('reveal barrier and recent matches in SuggestedFilters search', () => {
+ // These tests cover the SuggestedFilters tab's two-phase reveal: matching recents
+ // surface immediately while every non-meta group renders as a skeleton, then when
+ // either every remote group resolves or the 5s timer fires the barrier opens and
+ // real results replace the skeletons.
+ const seedRecentEvent = (): void => {
+ const recentLogic = recentTaxonomicFiltersLogic.build()
+ recentLogic.mount()
+ recentLogic.actions.recordRecentFilter({
+ groupType: TaxonomicFilterGroupType.Events,
+ groupName: 'Events',
+ value: 'onboarding_completed_recent',
+ item: { id: 'recent-onboarding', name: 'onboarding_completed_recent' },
+ })
+ }
+
+ beforeEach(() => {
+ localStorage.clear()
+ // Slow the events endpoint so the barrier-closed state survives at least one paint
+ // — the default mock resolves synchronously, which collapses the close-then-open
+ // cycle inside a single React batch, making the transient skeleton state invisible
+ // to the DOM in CI. Production latency exceeds this comfortably.
+ useMocks({
+ get: {
+ '/api/projects/:team/event_definitions': async (req) => {
+ await new Promise((resolve) => setTimeout(resolve, 100))
+ return mockGetEventDefinitions(req)
+ },
+ '/api/projects/:team/property_definitions': mockGetPropertyDefinitions,
+ '/api/projects/:team/actions': { results: [mockActionDefinition] },
+ '/api/environments/:team/persons/properties': [
+ { id: 1, name: 'location', count: 1 },
+ { id: 2, name: 'role', count: 2 },
+ { id: 3, name: 'height', count: 3 },
+ ],
+ },
+ post: {
+ '/api/environments/:team/query': { results: [] },
+ },
+ })
+ const recentLogic = recentTaxonomicFiltersLogic.build()
+ recentLogic.mount()
+ recentLogic.actions.clearRecentFilters()
+ seedRecentEvent()
+ })
+
+ const renderWithSuggested = (): void => {
+ render(
+ <Provider>
+ <TaxonomicFilter
+ taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.Actions,
+ ]}
+ onChange={onChangeMock}
+ onClose={onCloseMock}
+ />
+ </Provider>
+ )
+ }
+
+ const findSuggestedSkeleton = (): Element | null =>
+ document.querySelector('[data-attr^="prop-skeleton-suggested_filters-"]')
+
+ it('renders a skeleton row per non-meta group while the reveal barrier is closed, then replaces them with real results', async () => {
+ renderWithSuggested()
+
+ const searchField = await screen.findByTestId('taxonomic-filter-searchfield')
+ await userEvent.type(searchField, 'event')
+
+ await waitFor(() => {
+ if (!findSuggestedSkeleton()) {
+ throw new Error('expected at least one suggested_filters skeleton row')
+ }
+ })
+
+ const testEventRows = await screen.findAllByText('test event', undefined, { timeout: 6000 })
+ expect(testEventRows.length).toBeGreaterThanOrEqual(1)
+
+ await waitFor(
+ () => {
+ if (findSuggestedSkeleton()) {
+ throw new Error('expected suggested_filters skeletons to be removed once the barrier opens')
+ }
+ },
+ { timeout: 6000 }
+ )
+ }, 10000)
+
+ it('a recent that matches the search appears in the SuggestedFilters list even though the barrier gates other groups', async () => {
+ renderWithSuggested()
+
+ const searchField = await screen.findByTestId('taxonomic-filter-searchfield')
+ await userEvent.type(searchField, 'onboarding_completed_recent')
+
+ const matches = await screen.findAllByText('onboarding_completed_recent', undefined, { timeout: 6000 })
+ expect(matches.length).toBeGreaterThanOrEqual(1)
+ }, 10000)
+ })
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
index 65381a644882..df7c34efa630 100644
--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
@@ -53,6 +53,33 @@ function pinnedItemMatchesSearch(
return name.toLowerCase().includes(query) || (label?.toLowerCase().includes(query) ?? false)
}
+function recentItemMatchesSearch(
+ item: TaxonomicDefinitionTypes,
+ query: string,
+ taxonomicGroups: TaxonomicFilterGroup[]
+): boolean {
+ if (!hasRecentContext(item)) {
+ return false
+ }
+ const sourceGroup = taxonomicGroups.find((g) => g.type === item._recentContext.sourceGroupType)
+ const name = sourceGroup?.getName?.(item) || ('name' in item ? item.name : '') || ''
+ if (name.toLowerCase().includes(query)) {
+ return true
+ }
+ const label = sourceGroup ? getCoreFilterDefinition(name, sourceGroup.type)?.label : undefined
+ if (label?.toLowerCase().includes(query)) {
+ return true
+ }
+ const propertyFilter = item._recentContext.propertyFilter
+ if (propertyFilter) {
+ const recentLabel = formatPropertyLabel(propertyFilter, {})
+ if (recentLabel?.toLowerCase().includes(query)) {
+ return true
+ }
+ }
+ return false
+}
+
export interface RowInfo {
startIndex: number
stopIndex: number
@@ -727,6 +754,23 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
)
},
],
+ suggestedRecentMatches: [
+ (s) => [s.contextFilteredRecentItems, s.searchQuery, s.listGroupType, s.taxonomicGroups],
+ (
+ contextFilteredRecentItems: TaxonomicDefinitionTypes[],
+ searchQuery: string,
+ listGroupType: TaxonomicFilterGroupType,
+ taxonomicGroups: TaxonomicFilterGroup[]
+ ): TaxonomicDefinitionTypes[] => {
+ if (listGroupType !== TaxonomicFilterGroupType.SuggestedFilters || !searchQuery) {
+ return []
+ }
+ const q = searchQuery.trim().toLowerCase()
+ return (contextFilteredRecentItems || []).filter((item) =>
+ recentItemMatchesSearch(item, q, taxonomicGroups)
+ )
+ },
+ ],
keywordShortcutItems: [
(s) => [s.group, s.searchQuery, (_, props) => props.enableKeywordShortcuts],
(
@@ -736,40 +780,117 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
): QuickFilterItem[] =>
enableKeywordShortcuts && searchQuery.trim() ? (group?.keywordShortcuts?.(searchQuery) ?? []) : [],
],
+ // Deduped per-group top matches for the SuggestedFilters tab: when a search surfaces the
+ // same `{ groupType, value }` from a per-group top-match AND from a recent/pinned row,
+ // drop the per-group row so the user doesn't see e.g. "Recent · pageview" stacked above
+ // "Events · pageview". Extracted from `items` to keep that selector's input count down —
+ // every extra input on `items` cascades into longer kea typegen times for downstream
+ // logics.
+ dedupedTopMatches: [
+ (s) => [
+ s.topMatchItemsWithSkeletons,
+ s.listGroupType,
+ s.searchQuery,
+ s.contextFilteredRecentItems,
+ s.contextFilteredPinnedItems,
+ s.suggestedRecentMatches,
+ s.suggestedPinnedMatches,
+ s.taxonomicGroups,
+ ],
+ (
+ topMatchItemsWithSkeletons,
+ listGroupType,
+ searchQuery,
+ contextFilteredRecentItems,
+ contextFilteredPinnedItems,
+ suggestedRecentMatches,
+ suggestedPinnedMatches,
+ taxonomicGroups
+ ): (TaxonomicDefinitionTypes | SkeletonItem)[] => {
+ const isSuggested = listGroupType === TaxonomicFilterGroupType.SuggestedFilters
+ if (!isSuggested) {
+ return []
+ }
+ const recentPrefix = !searchQuery ? (contextFilteredRecentItems || []).slice(0, 3) : []
+ const pinnedPrefix = !searchQuery ? (contextFilteredPinnedItems || []).slice(0, 3) : []
+
+ const dedupeKeys = new Set<string>()
+ const addRecentKey = (item: TaxonomicDefinitionTypes): void => {
+ if (hasRecentContext(item) && item._recentContext.sourceValue != null) {
+ dedupeKeys.add(`${item._recentContext.sourceGroupType}::${item._recentContext.sourceValue}`)
+ }
+ }
+ const addPinnedKey = (item: TaxonomicDefinitionTypes): void => {
+ if (hasPinnedContext(item) && item._pinnedContext.value != null) {
+ dedupeKeys.add(`${item._pinnedContext.sourceGroupType}::${item._pinnedContext.value}`)
+ }
+ }
+ recentPrefix.forEach(addRecentKey)
+ pinnedPrefix.forEach(addPinnedKey)
+ suggestedRecentMatches.forEach(addRecentKey)
+ suggestedPinnedMatches.forEach(addPinnedKey)
+
+ if (dedupeKeys.size === 0) {
+ return topMatchItemsWithSkeletons
+ }
+ const groupsByType = new Map(taxonomicGroups.map((g) => [g.type, g]))
+ return topMatchItemsWithSkeletons.filter((item) => {
+ if (isSkeletonItem(item)) {
+ return true
+ }
+ const group = (item as TaxonomicDefinitionTypes & { group?: TaxonomicFilterGroupType }).group
+ if (!group) {
+ return true
+ }
+ const value = groupsByType.get(group)?.getValue?.(item as TaxonomicDefinitionTypes)
+ if (value == null) {
+ return true
+ }
+ return !dedupeKeys.has(`${group}::${value}`)
+ })
+ },
+ ],
items: [
(s) => [
s.remoteItems,
s.localItems,
s.listGroupType,
- s.topMatchItemsWithSkeletons,
+ s.dedupedTopMatches,
s.searchQuery,
s.contextFilteredRecentItems,
s.contextFilteredPinnedItems,
s.suggestedPinnedMatches,
+ s.suggestedRecentMatches,
s.keywordShortcutItems,
],
(
remoteItems,
localItems,
listGroupType,
- topMatchItemsWithSkeletons,
+ dedupedTopMatches,
searchQuery,
contextFilteredRecentItems,
contextFilteredPinnedItems,
suggestedPinnedMatches,
+ suggestedRecentMatches,
keywordShortcutItems
) => {
const isSuggested = listGroupType === TaxonomicFilterGroupType.SuggestedFilters
- const topMatches = isSuggested ? topMatchItemsWithSkeletons : []
const recentPrefix = isSuggested && !searchQuery ? (contextFilteredRecentItems || []).slice(0, 3) : []
const pinnedPrefix = isSuggested && !searchQuery ? (contextFilteredPinnedItems || []).slice(0, 3) : []
+ const topMatches = isSuggested ? dedupedTopMatches : []
+
// Shortcuts lead the list so users searching for the verb they mean (e.g. "click")
// see the autocapture/event-type shortcut prominently and pressing Enter picks it.
// Real events with the same name remain accessible below the shortcut.
+ // Recent matches appear next: they're computed locally and revealed immediately
+ // so the user sees something useful while remote groups are still loading behind
+ // the reveal barrier.
const combinedResults = [
...keywordShortcutItems,
...recentPrefix,
...pinnedPrefix,
+ ...suggestedRecentMatches,
...suggestedPinnedMatches,
...localItems.results,
...remoteItems.results,
@@ -781,6 +902,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
keywordShortcutItems.length +
recentPrefix.length +
pinnedPrefix.length +
+ suggestedRecentMatches.length +
suggestedPinnedMatches.length +
localItems.count +
remoteItems.count +
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
index 0d524e6ead7c..5595dbd312d8 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.test.ts
@@ -21,6 +21,7 @@ import { mockEventDefinitions, mockSessionPropertyDefinitions } from '~/test/moc
import { AppContext, EventDefinition, PropertyDefinition } from '~/types'
import { infiniteListLogic } from './infiniteListLogic'
+import { recentTaxonomicFiltersLogic } from './recentTaxonomicFiltersLogic'
window.POSTHOG_APP_CONTEXT = {
current_team: { id: MOCK_TEAM_ID },
@@ -378,7 +379,7 @@ describe('taxonomicFilterLogic', () => {
await expectLogic(quickLogic, () => {
quickLogic.actions.setSearchQuery('$pageview')
})
- .toDispatchActions(['setSearchQuery', 'infiniteListResultsReceived'])
+ .toDispatchActions(['setSearchQuery', 'appendTopMatches'])
.delay(1)
expect(quickLogic.values.topMatchItems).toHaveLength(1)
@@ -430,17 +431,24 @@ describe('taxonomicFilterLogic', () => {
quickLogic.actions.setSearchQuery(query)
}).toDispatchActions(['setSearchQuery'])
+ // While the reveal barrier is closed, every non-meta group renders as a skeleton —
+ // even ones that don't have a remote loader — so partial results never reveal until
+ // the whole batch is ready (or the 5s timer fires). The non-meta groups here are
+ // Events and Actions; SuggestedFilters is the (meta) aggregator tab.
const duringLoading = quickLogic.values.topMatchItemsWithSkeletons
const skeletons = duringLoading.filter(isSkeletonItem)
- expect(skeletons).toHaveLength(SKELETON_ROWS_PER_GROUP)
- expect(skeletons.every((s) => s.group === TaxonomicFilterGroupType.Events)).toBe(true)
- expect(skeletons[0].groupName).toBe('Events')
+ expect(skeletons).toHaveLength(SKELETON_ROWS_PER_GROUP * 2)
+ const groupsWithSkeletons = new Set(skeletons.map((s) => s.group))
+ expect(groupsWithSkeletons).toEqual(
+ new Set([TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions])
+ )
await expectLogic(eventsListLogic).toDispatchActions(['loadRemoteItemsSuccess'])
await expectLogic(quickLogic).delay(1)
const afterLoading = quickLogic.values.topMatchItemsWithSkeletons
expect(afterLoading.filter(isSkeletonItem)).toHaveLength(0)
+ expect(quickLogic.values.revealBarrierOpen).toBe(true)
})
it('does not insert skeletons when search query is empty', async () => {
@@ -453,6 +461,190 @@ describe('taxonomicFilterLogic', () => {
expect(quickLogic.values.searchQuery).toBe('')
expect(quickLogic.values.topMatchItemsWithSkeletons).toEqual([])
+ expect(quickLogic.values.revealBarrierOpen).toBe(true)
+ })
+ })
+
+ describe('reveal barrier', () => {
+ let barrierLogic: ReturnType<typeof taxonomicFilterLogic.build>
+
+ beforeEach(() => {
+ const logicProps: TaxonomicFilterLogicProps = {
+ taxonomicFilterLogicKey: 'testRevealBarrier',
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.Actions,
+ ],
+ }
+ barrierLogic = taxonomicFilterLogic(logicProps)
+ barrierLogic.mount()
+ for (const listGroupType of logicProps.taxonomicGroupTypes) {
+ infiniteListLogic({ ...logicProps, listGroupType }).mount()
+ }
+ })
+
+ afterEach(() => {
+ barrierLogic.unmount()
+ })
+
+ it.each([
+ { searchQuery: 'email', expectedOpen: false },
+ { searchQuery: ' ', expectedOpen: true },
+ { searchQuery: '', expectedOpen: true },
+ ])(
+ 'setSearchQuery sets revealBarrierOpen=$expectedOpen for query "$searchQuery"',
+ async ({ searchQuery, expectedOpen }) => {
+ await expectLogic(barrierLogic, () => {
+ barrierLogic.actions.setSearchQuery(searchQuery)
+ }).toMatchValues({ revealBarrierOpen: expectedOpen })
+ }
+ )
+
+ it('openRevealBarrier action sets revealBarrierOpen=true', async () => {
+ barrierLogic.actions.setSearchQuery('email')
+ expect(barrierLogic.values.revealBarrierOpen).toBe(false)
+
+ await expectLogic(barrierLogic, () => {
+ barrierLogic.actions.openRevealBarrier()
+ }).toMatchValues({ revealBarrierOpen: true })
+ })
+
+ it('opens the barrier once every non-meta group finishes loading', async () => {
+ const eventsListLogic = infiniteListLogic({
+ ...barrierLogic.props,
+ listGroupType: TaxonomicFilterGroupType.Events,
+ })
+ await expectLogic(eventsListLogic).toDispatchActions(['loadRemoteItemsSuccess'])
+ await expectLogic(barrierLogic).delay(1)
+
+ await expectLogic(barrierLogic, () => {
+ barrierLogic.actions.setSearchQuery('whatever')
+ }).toMatchValues({ revealBarrierOpen: false })
+
+ await expectLogic(eventsListLogic).toDispatchActions(['loadRemoteItemsSuccess'])
+ await expectLogic(barrierLogic).toDispatchActions(['openRevealBarrier']).delay(1)
+ expect(barrierLogic.values.revealBarrierOpen).toBe(true)
+ })
+ })
+
+ describe('Recent matches surface in SuggestedFilters search', () => {
+ // Search hits recents locally so they reveal immediately, bypassing the reveal barrier
+ // that gates the remote groups. Per product reality, recents drive ~16% of selections
+ // — they should be visible while remote groups are still settling.
+ let recentLogic: ReturnType<typeof taxonomicFilterLogic.build>
+
+ beforeEach(() => {
+ recentTaxonomicFiltersLogic.mount()
+ recentTaxonomicFiltersLogic.actions.recordRecentFilter({
+ groupType: TaxonomicFilterGroupType.Events,
+ groupName: 'Events',
+ value: 'recent_login_event',
+ item: { id: 'recent-1', name: 'recent_login_event' },
+ teamId: MOCK_TEAM_ID,
+ })
+
+ const logicProps: TaxonomicFilterLogicProps = {
+ taxonomicFilterLogicKey: 'testRecentMatches',
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.Actions,
+ ],
+ }
+ recentLogic = taxonomicFilterLogic(logicProps)
+ recentLogic.mount()
+ for (const listGroupType of logicProps.taxonomicGroupTypes) {
+ infiniteListLogic({ ...logicProps, listGroupType }).mount()
+ }
+ })
+
+ afterEach(() => {
+ recentLogic.unmount()
+ })
+
+ it.each<{ query: string; expectedCount: number; expectedItemName?: string }>([
+ { query: 'login', expectedCount: 1, expectedItemName: 'recent_login_event' },
+ { query: 'nothing_matches_this', expectedCount: 0 },
+ ])(
+ 'suggestedRecentMatches has $expectedCount match(es) for query "$query"',
+ async ({ query, expectedCount, expectedItemName }) => {
+ await expectLogic(recentLogic, () => {
+ recentLogic.actions.setSearchQuery(query)
+ }).toMatchValues({ revealBarrierOpen: false })
+
+ const suggestedListLogic = infiniteListLogic({
+ ...recentLogic.props,
+ listGroupType: TaxonomicFilterGroupType.SuggestedFilters,
+ })
+
+ const recentMatches = suggestedListLogic.values.suggestedRecentMatches
+ expect(recentMatches).toHaveLength(expectedCount)
+
+ if (expectedItemName) {
+ expect(recentMatches[0]).toEqual(expect.objectContaining({ name: expectedItemName }))
+ const results = suggestedListLogic.values.items.results
+ const realRecent = results.find((item: any) => item && item.name === expectedItemName)
+ expect(realRecent).not.toBeUndefined()
+ }
+ }
+ )
+ })
+
+ describe('SuggestedFilters dedupe between recents and per-group top matches', () => {
+ // When the same underlying item appears as a Recent (because the user picked it before)
+ // and as a per-group top match (because the search hit the Events group), the recents
+ // row wins — otherwise the user sees "$pageview" stacked twice in the suggested list.
+ let dedupeLogic: ReturnType<typeof taxonomicFilterLogic.build>
+
+ beforeEach(() => {
+ recentTaxonomicFiltersLogic.mount()
+ recentTaxonomicFiltersLogic.actions.recordRecentFilter({
+ groupType: TaxonomicFilterGroupType.Events,
+ groupName: 'Events',
+ value: 'event1',
+ item: { id: 'uuid-0-foobar', name: 'event1' },
+ teamId: MOCK_TEAM_ID,
+ })
+
+ const logicProps: TaxonomicFilterLogicProps = {
+ taxonomicFilterLogicKey: 'testSuggestedDedupe',
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.SuggestedFilters, TaxonomicFilterGroupType.Events],
+ }
+ dedupeLogic = taxonomicFilterLogic(logicProps)
+ dedupeLogic.mount()
+ for (const listGroupType of logicProps.taxonomicGroupTypes) {
+ infiniteListLogic({ ...logicProps, listGroupType }).mount()
+ }
+ })
+
+ afterEach(() => {
+ dedupeLogic.unmount()
+ })
+
+ it('drops the events top match when a recent already surfaces the same value', async () => {
+ await expectLogic(dedupeLogic, () => {
+ dedupeLogic.actions.setSearchQuery('event1')
+ })
+ .toDispatchActions(['setSearchQuery', 'appendTopMatches', 'openRevealBarrier'])
+ .delay(1)
+
+ const suggestedListLogic = infiniteListLogic({
+ ...dedupeLogic.props,
+ listGroupType: TaxonomicFilterGroupType.SuggestedFilters,
+ })
+
+ const results = suggestedListLogic.values.items.results
+ const event1Rows = results.filter((item: any) => item && item.name === 'event1')
+ expect(event1Rows).toHaveLength(1)
+ expect(event1Rows[0]).toEqual(
+ expect.objectContaining({
+ _recentContext: expect.objectContaining({
+ sourceGroupType: TaxonomicFilterGroupType.Events,
+ sourceValue: 'event1',
+ }),
+ })
+ )
})
})
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 9bd831398cd2..e52fc4796b35 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -158,6 +158,8 @@ export type TopMatchItem = TaxonomicDefinitionTypes & { group: TaxonomicFilterGr
export const SKELETON_ROWS_PER_GROUP = 3
+export const REVEAL_BARRIER_TIMEOUT_MS = 5000
+
export { isSkeletonItem, type SkeletonItem } from 'lib/components/TaxonomicFilter/types'
export function redistributeTopMatches(
@@ -372,6 +374,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
appendTopMatches: (items: (TaxonomicDefinitionTypes & { group: TaxonomicFilterGroupType })[]) => ({
items,
}),
+ openRevealBarrier: true,
})),
reducers(({ props, selectors }) => ({
searchQuery: [
@@ -442,6 +445,17 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
},
},
],
+ revealBarrierOpen: [
+ // Gates the SuggestedFilters tab on every fresh search: once a search starts we
+ // hide all non-meta group contributions behind skeletons until either every group
+ // resolves or the 5s timer fires (see setSearchQuery listener). This stops rows
+ // from jumping around as slower groups settle on top of faster ones.
+ !(props.initialSearchQuery ?? '').trim(),
+ {
+ setSearchQuery: (_, { searchQuery }: { searchQuery: string }) => !(searchQuery ?? '').trim(),
+ openRevealBarrier: () => true,
+ },
+ ],
})),
selectors({
selectedItemMeta: [() => [(_, props) => props.filter], (filter) => filter],
@@ -1691,6 +1705,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
s.taxonomicGroups,
s.searchQuery,
s.metaGroupTypes,
+ s.revealBarrierOpen,
],
(
redistributed: TopMatchItem[],
@@ -1698,7 +1713,8 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
loadingGroupTypes: TaxonomicFilterGroupType[],
taxonomicGroups: TaxonomicFilterGroup[],
searchQuery: string,
- metaGroupTypes: Set<string>
+ metaGroupTypes: Set<string>,
+ revealBarrierOpen: boolean
): (TopMatchItem | SkeletonItem)[] => {
if (!searchQuery) {
return redistributed
@@ -1706,17 +1722,34 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
const nonMetaGroups = taxonomicGroupTypes.filter((t) => !metaGroupTypes.has(t))
+ const buildSkeletons = (groupType: TaxonomicFilterGroupType): SkeletonItem[] => {
+ const groupDef = taxonomicGroups.find((g) => g.type === groupType)
+ const groupName = groupDef?.name ?? groupType
+ const skeletons: SkeletonItem[] = []
+ for (let i = 0; i < SKELETON_ROWS_PER_GROUP; i++) {
+ skeletons.push({ _skeleton: true, group: groupType, groupName })
+ }
+ return skeletons
+ }
+
+ // Pre-barrier: every non-meta group renders as a skeleton — even ones that
+ // already resolved — so we don't reveal partial results that would shift
+ // when a slower group finishes.
+ if (!revealBarrierOpen) {
+ const result: SkeletonItem[] = []
+ for (const groupType of nonMetaGroups) {
+ result.push(...buildSkeletons(groupType))
+ }
+ return result
+ }
+
const result: (TopMatchItem | SkeletonItem)[] = []
for (const groupType of nonMetaGroups) {
const groupItems = redistributed.filter((item) => item.group === groupType)
if (groupItems.length > 0) {
result.push(...groupItems)
} else if (loadingGroupTypes.includes(groupType)) {
- const groupDef = taxonomicGroups.find((g) => g.type === groupType)
- const groupName = groupDef?.name ?? groupType
- for (let i = 0; i < SKELETON_ROWS_PER_GROUP; i++) {
- result.push({ _skeleton: true, group: groupType, groupName })
- }
+ result.push(...buildSkeletons(groupType))
}
}
return result
@@ -1730,6 +1763,15 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
if (props.eventNames?.length) {
actions.ensureLoadedForEvents(props.eventNames)
}
+ // If we land with an initial search query (e.g. deep-linked filter), arm the same
+ // 5s reveal-barrier timer as a normal keystroke would — the `setSearchQuery`
+ // listener doesn't run on mount because no action was dispatched.
+ if ((props.initialSearchQuery ?? '').trim()) {
+ cache.disposables.add(() => {
+ const timerId = window.setTimeout(() => actions.openRevealBarrier(), REVEAL_BARRIER_TIMEOUT_MS)
+ return () => window.clearTimeout(timerId)
+ }, 'revealBarrierTimer')
+ }
}),
beforeUnmount(({ values, cache }) => {
// Only capture when there's evidence the user actually engaged with the picker. The logic
@@ -1892,6 +1934,20 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
setSearchQuery: async ({ searchQuery }, breakpoint) => {
const { activeTaxonomicGroup } = values
+ // Re-arm the reveal barrier timer on every keystroke. The reducer has already
+ // closed the barrier (when searchQuery is non-empty) — the timer fallback opens
+ // it again after 5s if not all groups have completed. Re-adding under the same
+ // key auto-disposes the previous timer; we only need to explicitly dispose when
+ // the query clears (no fresh timer to schedule).
+ if ((searchQuery ?? '').trim()) {
+ cache.disposables.add(() => {
+ const timerId = window.setTimeout(() => actions.openRevealBarrier(), REVEAL_BARRIER_TIMEOUT_MS)
+ return () => window.clearTimeout(timerId)
+ }, 'revealBarrierTimer')
+ } else {
+ cache.disposables.dispose('revealBarrierTimer')
+ }
+
await breakpoint(500)
const pastedChars = cache.pastedCharsSinceLastCapture ?? 0
cache.pastedCharsSinceLastCapture = 0
@@ -1908,7 +1964,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
}
},
- infiniteListResultsReceived: ({ groupType, results }) => {
+ infiniteListResultsReceived: async ({ groupType, results }, breakpoint) => {
if (groupType && !values.metaGroupTypes.has(groupType)) {
const subLogic = values.infiniteListLogics[groupType]
if (subLogic?.isMounted()) {
@@ -1938,6 +1994,16 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
)
updatePropertyDefinitions(newPropertyDefinitions)
}
+
+ // Yield a microtask so all sibling `infiniteListResultsReceived` and
+ // `loadRemoteItems` dispatches triggered by the same `setSearchQuery` have
+ // settled — otherwise a local-only group firing synchronously would see
+ // `anyGroupLoading=false` before remote siblings have started loading.
+ await breakpoint(0)
+ if (values.searchQuery && !values.revealBarrierOpen && !values.anyGroupLoading) {
+ cache.disposables.dispose('revealBarrierTimer')
+ actions.openRevealBarrier()
+ }
},
})),
])