: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(conversations): default the support panel ticket list to unread (#96902)
Ben Leae35d2f11b296
diff --git a/products/conversations/frontend/components/SidePanel/TicketsList.tsx b/products/conversations/frontend/components/SidePanel/TicketsList.tsxindex 15e5b37d5e46..b20d99187cc6 100644--- a/products/conversations/frontend/components/SidePanel/TicketsList.tsx+++ b/products/conversations/frontend/components/SidePanel/TicketsList.tsx@@ -7,7 +7,12 @@ import { LemonBadge, LemonButton, LemonSelect, LemonTag, Link, Spinner } from '@import { TZLabel } from 'lib/components/TZLabel'import { stripMarkdown } from 'lib/utils/markdown'-import { statusOptions, type ConversationTicket } from '../../types'+import {+ type ConversationTicket,+ type SidePanelTicketFilter,+ sidePanelTicketFilterLabels,+ sidePanelTicketFilterOrder,+} from '../../types'import { sidepanelTicketsLogic } from './sidepanelTicketsLogic'interface TicketsListProps {@@ -16,11 +21,28 @@ interface TicketsListProps {}export function TicketsList({ selectedTicketId = null }: TicketsListProps): JSX.Element {- const { tickets, filteredTickets, ticketsLoading, canCreateTicket, statusFilter } = useValues(sidepanelTicketsLogic)+ const { tickets, filteredTickets, ticketsLoading, canCreateTicket, effectiveStatusFilter, ticketFilterCounts } =+ useValues(sidepanelTicketsLogic)const { setCurrentTicket, setView, setStatusFilter } = useActions(sidepanelTicketsLogic)const hasIdentityMode = !!window.JS_POSTHOG_IDENTITY_DISTINCT_ID+ // Unread / Active / All always show so the user can widen the view; a status only earns an+ // entry once there's at least one ticket in it, which keeps the dropdown short. The selected+ // filter also stays, because its count can fall to zero while it is selected (the last pending+ // ticket resolves on a poll) and dropping it would leave the select with no matching option.+ const filterOptions = sidePanelTicketFilterOrder+ .filter(+ (filter) =>+ ['unread', 'active', 'all'].includes(filter) ||+ ticketFilterCounts[filter] > 0 ||+ filter === effectiveStatusFilter+ )+ .map((filter) => ({+ value: filter,+ label: `${sidePanelTicketFilterLabels[filter]} (${ticketFilterCounts[filter]})`,+ }))+if (!hasIdentityMode && (!posthog.conversations || !posthog.conversations.isAvailable())) {return (<div className="text-center text-muted-alt py-8">@@ -69,13 +91,13 @@ export function TicketsList({ selectedTicketId = null }: TicketsListProps): JSX.<LemonSelectsize="small"fullWidth- value={statusFilter}- onChange={(status) => {+ value={effectiveStatusFilter}+ onChange={(status: SidePanelTicketFilter | null) => {if (status) {setStatusFilter(status)}}}- options={statusOptions}+ options={filterOptions}data-attr="sidebar-ticket-status-filter"className="shrink-0"/>@@ -90,7 +112,29 @@ export function TicketsList({ selectedTicketId = null }: TicketsListProps): JSX.</div>) : filteredTickets.length === 0 ? (<div className="text-center text-muted-alt py-8">- <p>No tickets with this status.</p>+ {effectiveStatusFilter === 'unread' ? (+ <>+ <p>You're all caught up.</p>+ <Link+ className="text-sm"+ onClick={() => setStatusFilter('active')}+ data-attr="sidebar-ticket-filter-show-active"+ >+ Show active tickets+ </Link>+ </>+ ) : (+ <>+ <p>No tickets match this filter.</p>+ <Link+ className="text-sm"+ onClick={() => setStatusFilter('all')}+ data-attr="sidebar-ticket-filter-show-all"+ >+ Show all tickets+ </Link>+ </>+ )}</div>) : (<div className="flex flex-col gap-1">@@ -132,12 +176,16 @@ export function TicketsList({ selectedTicketId = null }: TicketsListProps): JSX.)}</div>{ticket.last_message && (- <p className="text-sm text-primary truncate m-0">+ <p+ className={`text-sm text-primary truncate m-0 ${+ (ticket.unread_count ?? 0) > 0 ? 'font-semibold' : ''+ }`}+ >{stripMarkdown(ticket.last_message)}</p>)}<p className="text-xs text-muted-alt m-0 mt-1">- <TZLabel time={ticket.created_at} />+ <TZLabel time={ticket.last_message_at ?? ticket.created_at} /></p></div><IconChevronRight className="text-muted-alt" />diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.tsindex c54ac9eebc09..67e7859cd262 100644--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts@@ -570,11 +570,14 @@ describe('sidepanelTicketsLogic', () => {// TicketsList renders filteredTickets, so a broken selector would show the wrong chats// (or none) once someone picks a status.+ // Unread tickets sort first, then most recent activity, regardless of creation order.it.each([- ['all', ['t-open', 't-resolved']],+ ['all', ['t-unread', 't-resolved', 't-open']],+ ['active', ['t-unread', 't-open']],+ ['unread', ['t-unread']],['open', ['t-open']],['resolved', ['t-resolved']],- ] as const)('filters the ticket list to status %s', async (status, expectedIds) => {+ ] as const)('filters the ticket list to %s', async (filter, expectedIds) => {logic = sidepanelTicketsLogic.build()logic.mount()await expectLogic(logic).toFinishAllListeners()@@ -582,9 +585,129 @@ describe('sidepanelTicketsLogic', () => {logic.actions.setTickets([{ id: 't-open', status: 'open', message_count: 1, created_at: '2026-07-13T00:00:00Z' },{ id: 't-resolved', status: 'resolved', message_count: 1, created_at: '2026-07-14T00:00:00Z' },+ {+ id: 't-unread',+ status: 'pending',+ message_count: 2,+ unread_count: 1,+ created_at: '2026-07-12T00:00:00Z',+ },] as ConversationTicket[])- logic.actions.setStatusFilter(status)+ logic.actions.setStatusFilter(filter)expect(logic.values.filteredTickets.map((ticket) => ticket.id)).toEqual(expectedIds)})++ // The fixtures above carry no last_message_at, so ordering there falls back to created_at and+ // cannot tell the two apart. Surfacing a reply on an older thread is what this list is for.+ it('orders by the latest message, not the creation time', async () => {+ logic = sidepanelTicketsLogic.build()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.setTickets([+ {+ id: 't-new-thread-quiet-since',+ status: 'open',+ message_count: 1,+ created_at: '2026-07-14T00:00:00Z',+ last_message_at: '2026-07-14T00:00:00Z',+ },+ {+ id: 't-old-thread-fresh-reply',+ status: 'open',+ message_count: 2,+ created_at: '2026-07-12T00:00:00Z',+ last_message_at: '2026-07-15T00:00:00Z',+ },+ ] as ConversationTicket[])+ logic.actions.setStatusFilter('all')++ expect(logic.values.filteredTickets.map((ticket) => ticket.id)).toEqual([+ 't-old-thread-fresh-reply',+ 't-new-thread-quiet-since',+ ])+ })++ it('counts tickets per filter for the dropdown labels', async () => {+ logic = sidepanelTicketsLogic.build()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.setTickets([+ { id: 't-open', status: 'open', message_count: 1, unread_count: 2, created_at: '2026-07-13T00:00:00Z' },+ { id: 't-resolved', status: 'resolved', message_count: 1, created_at: '2026-07-14T00:00:00Z' },+ { id: 't-hold', status: 'on_hold', message_count: 1, created_at: '2026-07-12T00:00:00Z' },+ ] as ConversationTicket[])++ expect(logic.values.ticketFilterCounts).toEqual({+ unread: 1,+ active: 2,+ all: 3,+ new: 0,+ open: 1,+ pending: 0,+ on_hold: 1,+ resolved: 1,+ })+ })++ // A long ticket history shouldn't bury the reply you're waiting on: with nothing chosen the+ // list shows unread tickets when there are any, otherwise active ones, until the user picks.+ it('defaults the filter to unread, then active, until the user chooses', async () => {+ logic = sidepanelTicketsLogic.build()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ logic.actions.setTickets([+ { id: 't-open', status: 'open', message_count: 1, created_at: '2026-07-13T00:00:00Z' },+ { id: 't-resolved', status: 'resolved', message_count: 1, created_at: '2026-07-14T00:00:00Z' },+ ] as ConversationTicket[])+ expect(logic.values.effectiveStatusFilter).toBe('active')+ expect(logic.values.filteredTickets.map((ticket) => ticket.id)).toEqual(['t-open'])++ logic.actions.setTickets([+ { id: 't-open', status: 'open', message_count: 1, unread_count: 1, created_at: '2026-07-13T00:00:00Z' },+ { id: 't-resolved', status: 'resolved', message_count: 1, created_at: '2026-07-14T00:00:00Z' },+ ] as ConversationTicket[])+ expect(logic.values.effectiveStatusFilter).toBe('unread')++ logic.actions.setStatusFilter('all')+ expect(logic.values.effectiveStatusFilter).toBe('all')+ expect(logic.values.filteredTickets.map((ticket) => ticket.id)).toEqual(['t-open', 't-resolved'])+ })++ // The full-screen scene renders the list next to the open thread. Opening a ticket marks it+ // read, which under the unread filter would remove the row the user just clicked.+ it('keeps the open ticket at the top of the list while it is being read', async () => {+ logic = sidepanelTicketsLogic.build()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ const unreadTicket = {+ id: 't-reading',+ status: 'open',+ message_count: 2,+ unread_count: 1,+ created_at: '2026-07-12T00:00:00Z',+ } as ConversationTicket+ const otherUnread = {+ id: 't-other',+ status: 'open',+ message_count: 1,+ unread_count: 1,+ created_at: '2026-07-14T00:00:00Z',+ } as ConversationTicket+ logic.actions.setTickets([unreadTicket, otherUnread])+ expect(logic.values.effectiveStatusFilter).toBe('unread')++ logic.actions.setCurrentTicket(unreadTicket)+ logic.actions.setView('ticket')+ // Reading the thread clears its unread count on the next poll+ logic.actions.setTickets([{ ...unreadTicket, unread_count: 0 }, otherUnread])+ expect(logic.values.filteredTickets.map((ticket) => ticket.id)).toEqual(['t-other', 't-reading'])++ logic.actions.setView('list')+ expect(logic.values.filteredTickets.map((ticket) => ticket.id)).toEqual(['t-other'])+ })})diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.tsindex 5ee075aa5bb0..83d56c31d800 100644--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts@@ -40,10 +40,28 @@ import type {ConversationMessage,ConversationTicket,RestoreFlowState,+ SidePanelTicketFilter,SidePanelViewState,- TicketStatus,} from '../../types'+function ticketMatchesFilter(ticket: ConversationTicket, filter: SidePanelTicketFilter): boolean {+ switch (filter) {+ case 'all':+ return true+ case 'unread':+ return (ticket.unread_count ?? 0) > 0+ case 'active':+ return ticket.status !== 'resolved'+ default:+ return ticket.status === filter+ }+}++/** Most recent activity on a ticket, for ordering. Falls back to creation when nothing was said yet. */+function ticketActivityTime(ticket: ConversationTicket): number {+ return new Date(ticket.last_message_at ?? ticket.created_at).getTime() || 0+}+// Poll cadence scales with how actively the user is looking at support, so an open thread stays// fresh without every idle tab hammering the widget once a minute.const POLL_INTERVAL_BACKGROUND = 60 * 1000 // support surface not visible: only keep the unread badge fresh@@ -100,6 +118,7 @@ export interface sidepanelTicketsLogicValues {sendSupportRequest: SupportFormFields // supportLogiccanCreateTicket: booleancurrentTicket: ConversationTicket | null+ effectiveStatusFilter: SidePanelTicketFilterfilteredTickets: ConversationTicket[]hasMoreMessages: booleanhasSupportExemption: boolean@@ -112,7 +131,8 @@ export interface sidepanelTicketsLogicValues {pendingTicketId: string | nullrestoreError: string | nullrestoreState: RestoreFlowState- statusFilter: TicketStatus | 'all'+ statusFilter: SidePanelTicketFilter | null+ ticketFilterCounts: Record<SidePanelTicketFilter, number>tickets: ConversationTicket[]ticketsLoading: booleantotalUnreadCount: number@@ -200,8 +220,8 @@ export interface sidepanelTicketsLogicActions {setRestoreState: (state: RestoreFlowState) => {state: RestoreFlowState}- setStatusFilter: (status: TicketStatus | 'all') => {- status: TicketStatus | 'all'+ setStatusFilter: (status: SidePanelTicketFilter) => {+ status: SidePanelTicketFilter}setTickets: (tickets: ConversationTicket[]) => {tickets: ConversationTicket[]@@ -227,7 +247,17 @@ export interface sidepanelTicketsLogicActions {export interface sidepanelTicketsLogicMeta {__keaTypeGenInternalSelectorTypes: {totalUnreadCount: (tickets: ConversationTicket[]) => number- filteredTickets: (tickets: ConversationTicket[], statusFilter: TicketStatus | 'all') => ConversationTicket[]+ effectiveStatusFilter: (+ statusFilter: SidePanelTicketFilter | null,+ totalUnreadCount: number+ ) => SidePanelTicketFilter+ ticketFilterCounts: (tickets: ConversationTicket[]) => Record<SidePanelTicketFilter, number>+ filteredTickets: (+ tickets: ConversationTicket[],+ effectiveStatusFilter: SidePanelTicketFilter,+ currentTicket: ConversationTicket | null,+ view: SidePanelViewState+ ) => ConversationTicket[]canCreateTicket: (billing: BillingType | null,isCurrentOrganizationNew: boolean,@@ -294,7 +324,7 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([restoreFromUrlToken: (token: string) => ({ token }),setRestoreState: (state: RestoreFlowState) => ({ state }),setRestoreError: (error: string | null) => ({ error }),- setStatusFilter: (status: TicketStatus | 'all') => ({ status }),+ setStatusFilter: (status: SidePanelTicketFilter) => ({ status }),}),reducers({view: [@@ -383,8 +413,10 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([setRestoreState: () => null,},],+ // `null` means "not chosen yet": the list then defaults to unread tickets when there are+ // any, otherwise to active ones, so a long history never buries what needs attention.statusFilter: [- 'all' as TicketStatus | 'all',+ null as SidePanelTicketFilter | null,{setStatusFilter: (_, { status }) => status,},@@ -405,10 +437,57 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([(s) => [s.tickets],(tickets: ConversationTicket[]) => tickets.reduce((sum, t) => sum + (t.unread_count ?? 0), 0),],+ effectiveStatusFilter: [+ (s) => [s.statusFilter, s.totalUnreadCount],+ (statusFilter: SidePanelTicketFilter | null, totalUnreadCount: number): SidePanelTicketFilter =>+ statusFilter ?? (totalUnreadCount > 0 ? 'unread' : 'active'),+ ],+ ticketFilterCounts: [+ (s) => [s.tickets],+ (tickets: ConversationTicket[]): Record<SidePanelTicketFilter, number> => {+ const counts: Record<SidePanelTicketFilter, number> = {+ unread: 0,+ active: 0,+ all: tickets.length,+ new: 0,+ open: 0,+ pending: 0,+ on_hold: 0,+ resolved: 0,+ }+ for (const ticket of tickets) {+ counts[ticket.status] += 1+ if (ticket.status !== 'resolved') {+ counts.active += 1+ }+ if ((ticket.unread_count ?? 0) > 0) {+ counts.unread += 1+ }+ }+ return counts+ },+ ],+ // Unread threads float to the top, then most recent activity. The open thread counts as+ // unread while it is being read: opening it marks it read, and the full-screen scene keeps+ // the list beside the thread, so without the pin the row would drop or vanish on click.filteredTickets: [- (s) => [s.tickets, s.statusFilter],- (tickets: ConversationTicket[], statusFilter: TicketStatus | 'all'): ConversationTicket[] =>- statusFilter === 'all' ? tickets : tickets.filter((t) => t.status === statusFilter),+ (s) => [s.tickets, s.effectiveStatusFilter, s.currentTicket, s.view],+ (+ tickets: ConversationTicket[],+ effectiveStatusFilter: SidePanelTicketFilter,+ currentTicket: ConversationTicket | null,+ view: SidePanelViewState+ ): ConversationTicket[] => {+ const pinnedId = view === 'ticket' ? (currentTicket?.id ?? null) : null+ const surfaces = (ticket: ConversationTicket): boolean =>+ ticket.id === pinnedId || (ticket.unread_count ?? 0) > 0+ return tickets+ .filter((ticket) => ticket.id === pinnedId || ticketMatchesFilter(ticket, effectiveStatusFilter))+ .sort((a, b) => {+ const surfaceDelta = Number(surfaces(b)) - Number(surfaces(a))+ return surfaceDelta !== 0 ? surfaceDelta : ticketActivityTime(b) - ticketActivityTime(a)+ })+ },],// Opening a ticket is the paid part of support. Reading and replying to tickets already in// the account isn't — free plans can end up with tickets via billing questions or PostHog AIdiff --git a/products/conversations/frontend/types.ts b/products/conversations/frontend/types.tsindex b411688e1ef6..25476efdc59b 100644--- a/products/conversations/frontend/types.ts+++ b/products/conversations/frontend/types.ts@@ -247,6 +247,35 @@ export interface ChatMessage {clarifyingQuestions?: string[]}+/**+ * Filter for the support side panel's ticket list. `unread` and `active` (everything not resolved)+ * are the two views people actually want when they have more than a handful of tickets; the+ * individual statuses stay available for drilling in.+ */+export type SidePanelTicketFilter = 'unread' | 'active' | 'all' | TicketStatus++export const sidePanelTicketFilterLabels: Record<SidePanelTicketFilter, string> = {+ unread: 'Unread',+ active: 'Active',+ all: 'All',+ new: 'New',+ open: 'Open',+ pending: 'Pending',+ on_hold: 'On hold',+ resolved: 'Resolved',+}++export const sidePanelTicketFilterOrder: SidePanelTicketFilter[] = [+ 'unread',+ 'active',+ 'all',+ 'new',+ 'open',+ 'pending',+ 'on_hold',+ 'resolved',+]+export const statusOptions: { value: TicketStatus | 'all'; label: string }[] = [{ value: 'all', label: 'All statuses' },{ value: 'new', label: 'New' },