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(conversations): show filtered ticket count next to the search bar (#73153)

Luke Belton16a1b650cca6
diff --git a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.test.tsx b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.test.tsx
index f25a9af0e7e1..833fe6fc7496 100644
--- a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.test.tsx
+++ b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.test.tsx
@@ -8,7 +8,7 @@ import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { Ticket } from '../../types'
-import { SupportTicketsTable } from './SupportTicketsScene'
+import { SupportTicketsTable, SupportTicketsTableFilters } from './SupportTicketsScene'
import { supportTicketsSceneLogic } from './supportTicketsSceneLogic'
const TICKET: Ticket = {
@@ -98,3 +98,51 @@ describe('SupportTicketsTable selection', () => {
expect(logic.values.selectedTicketIds).toEqual([])
})
})
+
+describe('SupportTicketsTableFilters count', () => {
+ let logic: ReturnType<typeof supportTicketsSceneLogic.build>
+ let mockCount = 0
+
+ beforeEach(() => {
+ mockCount = 0
+ useMocks({
+ get: {
+ '/api/projects/:team_id/conversations/tickets/': () => [200, { results: [TICKET], count: mockCount }],
+ '/api/organizations/:organization_id/members/': () => [200, { results: [] }],
+ '/api/projects/:team_id/tags': () => [200, []],
+ },
+ })
+ initKeaTests()
+ logic = supportTicketsSceneLogic()
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ cleanup()
+ })
+
+ // Set the count directly so the assertion doesn't race the debounced loadTickets; keep the
+ // mock in sync so a background reload can't reset the value out from under the assertion.
+ function setCount(count: number): void {
+ mockCount = count
+ act(() => {
+ logic.actions.setTotalCount(count)
+ })
+ }
+
+ it.each([
+ ['pluralizes the count of tickets matching the current query', 42, '42 tickets'],
+ ['uses the singular noun for a single ticket', 1, '1 ticket'],
+ ])('%s', async (_name, count, expected) => {
+ setCount(count)
+
+ render(
+ <Provider>
+ <SupportTicketsTableFilters />
+ </Provider>
+ )
+
+ expect(await screen.findByText(expected)).toBeInTheDocument()
+ })
+})
diff --git a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
index 734c6e9bf2ff..48dee05de283 100644
--- a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
+++ b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx
@@ -14,11 +14,13 @@ import {
LemonSelect,
LemonTable,
LemonTableColumns,
+ Tooltip,
} from '@posthog/lemon-ui'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { useBulkSelection } from 'lib/lemon-ui/LemonTable/useBulkSelection'
import { newInternalTab } from 'lib/utils/newInternalTab'
+import { pluralize } from 'lib/utils/strings'
import { SceneExport } from 'scenes/sceneTypes'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -260,6 +262,8 @@ export function SupportTicketsTableFilters({ embedded = false }: SupportTicketsT
dateFrom,
dateTo,
ticketsLoading,
+ totalCount,
+ hasActiveFilters,
} = useValues(logic)
const {
setSearchQuery,
@@ -290,6 +294,23 @@ export function SupportTicketsTableFilters({ embedded = false }: SupportTicketsT
size="small"
className="min-w-64"
/>
+ <Tooltip
+ title={
+ hasActiveFilters || searchQuery
+ ? 'Tickets matching the current filters, search, and view — not the total across all tickets'
+ : 'Tickets in the current view'
+ }
+ >
+ {/* Count of tickets matching the current query, shown next to the search/filter
+ controls so it reads as the filtered count rather than an all-time total.
+ Hidden until the first load resolves; dims on subsequent background refreshes. */}
+ <span
+ className={clsx('text-secondary text-sm whitespace-nowrap', ticketsLoading && 'opacity-50')}
+ aria-live="polite"
+ >
+ {ticketsLoading && totalCount === 0 ? null : pluralize(totalCount, 'ticket')}
+ </span>
+ </Tooltip>
<DateFilter
dateFrom={dateFrom}
dateTo={dateTo}