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.

fix: side panel url (#80738)

Christian Rafferty5a2faefcf2d1
diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx
index 1f11bbe53a13..1f2f7eaacae4 100644
--- a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx
+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx
@@ -254,7 +254,7 @@ export function SidePanelSupport(): JSX.Element {
useValues(userLogic)
const { openSidePanel, closeSidePanel } = useActions(sidePanelStateLogic)
const { billing, billingLoading, billingPlan } = useValues(billingLogic)
- const { tickets, canCreateTicket } = useValues(sidepanelTicketsLogic)
+ const { tickets, canCreateTicket, view, currentTicket } = useValues(sidepanelTicketsLogic)
const isCloudOrDev = preflight?.cloud || process.env.NODE_ENV === 'development'
const showMaxAI = isCloudOrDev
@@ -271,7 +271,7 @@ export function SidePanelSupport(): JSX.Element {
<LemonButton
size="xsmall"
icon={<IconExpand45 />}
- to={urls.myTickets()}
+ to={urls.myTickets(view === 'ticket' ? currentTicket?.id : undefined)}
onClick={() => closeSidePanel()}
tooltip="View your tickets full screen"
// LemonButton's tooltip→aria-label fallback only applies to plain buttons,
diff --git a/frontend/src/lib/components/Support/supportRouterLogic.ts b/frontend/src/lib/components/Support/supportRouterLogic.ts
index fc7c20c038e9..cc7c890e0339 100644
--- a/frontend/src/lib/components/Support/supportRouterLogic.ts
+++ b/frontend/src/lib/components/Support/supportRouterLogic.ts
@@ -42,6 +42,10 @@ export const supportRouterLogic = kea<supportRouterLogicType>([
// than by position — positionally, an old link's area would land in its slot.
const [kind] = panelOptions
+ if (kind === 'ticket') {
+ return
+ }
+
supportLogic.actions.openSupportForm({
kind: Object.keys(SUPPORT_KIND_TO_SUBJECT).includes(kind) ? kind : null,
isEmailFormOpen: panelOptions.includes('true') ? 'true' : 'false',
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index ecde07643c69..2ce6eb156215 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -1042,7 +1042,8 @@ export const productUrls = {
supportTickets: (): string => '/support/tickets',
supportTicketDetail: (ticketId: string | number): string => `/support/tickets/${ticketId}`,
supportSettings: (): string => '/support/settings',
- myTickets: (): string => '/my-tickets',
+ myTickets: (ticketId?: string): string =>
+ ticketId ? `/my-tickets?ticket=${encodeURIComponent(ticketId)}` : '/my-tickets',
customerAnalytics: (): string => '/customer_analytics',
customerAnalyticsDashboard: (): string => '/customer_analytics/dashboard',
customerAnalyticsAccounts: (): string => '/customer_analytics/accounts',
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
index 57f0e57e2ee9..89504124a88e 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.test.ts
@@ -1,3 +1,4 @@
+import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
@@ -6,10 +7,13 @@ import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { billingLogic } from 'scenes/billing/billingLogic'
import { organizationLogic } from 'scenes/organizationLogic'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { urls } from 'scenes/urls'
+import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
import { initKeaTests } from '~/test/init'
-import { BillingType } from '~/types'
+import { BillingType, SidePanelTab } from '~/types'
+import type { ConversationTicket } from '../../types'
import { sidepanelTicketsLogic } from './sidepanelTicketsLogic'
describe('sidepanelTicketsLogic', () => {
@@ -302,6 +306,91 @@ describe('sidepanelTicketsLogic', () => {
expect(supportLogic.values.pendingViewTicket).toBeNull()
})
+ // A ?ticket= deep link lands before the ticket list loads, so the id has to wait for it
+ it.each([
+ ['opens the linked ticket once tickets load', 't2', 'ticket', 't2'],
+ ['falls back to the list when the linked ticket does not exist', 'gone', 'list', undefined],
+ ])('%s', async (_case, linkedId, expectedView, expectedTicketId) => {
+ ;(posthog as any).conversations.getTickets = jest.fn().mockResolvedValue({
+ results: [
+ { id: 't1', status: 'open', message_count: 1, created_at: '2026-07-13T00:00:00Z' },
+ { id: 't2', status: 'open', message_count: 1, created_at: '2026-07-14T00:00:00Z' },
+ ],
+ })
+ router.actions.push(urls.myTickets(linkedId))
+
+ logic = sidepanelTicketsLogic.build()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.view).toBe(expectedView)
+ expect(logic.values.currentTicket?.id).toBe(expectedTicketId)
+ // Consumed either way, so a later poll can't yank the view
+ expect(logic.values.pendingTicketId).toBeNull()
+ })
+
+ it('opens the ticket a `#panel=support:ticket:` deep link points at', async () => {
+ ;(posthog as any).conversations.getTickets = jest.fn().mockResolvedValue({
+ results: [
+ { id: 't1', status: 'open', message_count: 1, created_at: '2026-07-13T00:00:00Z' },
+ { id: 't2', status: 'open', message_count: 1, created_at: '2026-07-14T00:00:00Z' },
+ ],
+ })
+ sidePanelStateLogic.mount()
+ sidePanelStateLogic.actions.openSidePanel(SidePanelTab.Support, 'ticket:t2')
+
+ logic = sidepanelTicketsLogic.build()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.view).toBe('ticket')
+ expect(logic.values.currentTicket?.id).toBe('t2')
+ })
+
+ it('mirrors the open ticket into the panel options and clears them on leaving the thread', async () => {
+ sidePanelStateLogic.mount()
+ sidePanelStateLogic.actions.openSidePanel(SidePanelTab.Support)
+
+ logic = sidepanelTicketsLogic.build()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ await expectLogic(logic, () => {
+ logic.actions.setCurrentTicket({
+ id: 't1',
+ status: 'open',
+ message_count: 1,
+ created_at: '2026-07-13T00:00:00Z',
+ } as ConversationTicket)
+ }).toFinishAllListeners()
+ expect(sidePanelStateLogic.values.selectedTabOptions).toBe('ticket:t1')
+
+ logic.actions.setView('list')
+ // The hash round-trip re-parses cleared options as '' rather than null; both mean none
+ expect(sidePanelStateLogic.values.selectedTabOptions ?? '').toBe('')
+ })
+
+ it('keeps the URL in sync with the selected ticket on the full-screen scene', async () => {
+ router.actions.push(urls.myTickets())
+ logic = sidepanelTicketsLogic.build()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ await expectLogic(logic, () => {
+ logic.actions.setCurrentTicket({
+ id: 't1',
+ status: 'open',
+ message_count: 1,
+ created_at: '2026-07-13T00:00:00Z',
+ } as ConversationTicket)
+ }).toFinishAllListeners()
+ expect(router.values.searchParams['ticket']).toBe('t1')
+
+ router.actions.push(urls.myTickets())
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.view).toBe('list')
+ })
+
// The panel already shows free plans the community and upgrade options, and they have no email
// channel, so warning them the chat failed would offer support they don't actually get.
it.each([
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
index 9d5080281cb7..ff729e2d01a2 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
@@ -11,7 +11,7 @@ import {
reducers,
selectors,
} from 'kea'
-import { router } from 'kea-router'
+import { actionToUrl, router, urlToAction } from 'kea-router'
import { subscriptions } from 'kea-subscriptions'
import posthog from 'posthog-js'
@@ -25,12 +25,14 @@ import {
warnSupportWidgetUnavailable,
} from 'lib/components/Support/supportLogic'
import { EMAIL_SUPPORT_BUTTON, lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
import { billingLogic } from 'scenes/billing/billingLogic'
import { organizationLogic } from 'scenes/organizationLogic'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { urls } from 'scenes/urls'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
-import type { BillingType } from '~/types'
+import { type BillingType, SidePanelTab } from '~/types'
import type { SupportFormFields } from '../../../../../frontend/src/lib/components/Support/supportLogic'
import type {
@@ -43,6 +45,9 @@ import type {
const POLL_INTERVAL = 60 * 1000 // 60 seconds
+// Panel options for a ticket deep link (#panel=support:ticket:<id>); supportRouterLogic skips this prefix
+const TICKET_OPTIONS_PREFIX = 'ticket:'
+
function removeRestoreTokenFromUrl(): void {
if ('ph_conv_restore' in router.values.searchParams) {
const { ph_conv_restore: _, ...rest } = router.values.searchParams
@@ -66,6 +71,8 @@ export interface sidepanelTicketsLogicValues {
billingLoading: boolean // billingLogic
isCurrentOrganizationNew: boolean // organizationLogic
isCloudOrDev: boolean | undefined // preflightLogic
+ selectedTab: SidePanelTab | null // sidePanelStateLogic
+ selectedTabOptions: string | null // sidePanelStateLogic
sidePanelOpen: boolean // sidePanelStateLogic
isBillingIssue: boolean // supportLogic
isEmailFormOpen: boolean // supportLogic
@@ -87,6 +94,7 @@ export interface sidepanelTicketsLogicValues {
messagesLoading: boolean
newTicketDraft: JSONContent | null
newTicketDraftRevision: number
+ pendingTicketId: string | null
restoreError: string | null
restoreState: RestoreFlowState
tickets: ConversationTicket[]
@@ -97,8 +105,11 @@ export interface sidepanelTicketsLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sidepanelTicketsLogicActions {
- closeSidePanel: (tab?: import('~/types').SidePanelTab | undefined) => {
- tab: import('~/types').SidePanelTab | undefined
+ closeSidePanel: (tab?: SidePanelTab | undefined) => {
+ tab: SidePanelTab | undefined
+ } // sidePanelStateLogic
+ setSidePanelOptions: (options: string | null) => {
+ options: string | null
} // sidePanelStateLogic
clearPendingViewTicket: () => {
value: true
@@ -130,6 +141,9 @@ export interface sidepanelTicketsLogicActions {
openPendingTicket: () => {
value: true
}
+ openTicketById: (ticketId: string) => {
+ ticketId: string
+ }
requestRestoreLink: (email: string) => {
email: string
}
@@ -161,6 +175,9 @@ export interface sidepanelTicketsLogicActions {
setNewTicketDraft: (content: JSONContent | null) => {
content: JSONContent | null
}
+ setPendingTicketId: (ticketId: string | null) => {
+ ticketId: string | null
+ }
setRestoreError: (error: string | null) => {
error: string | null
}
@@ -214,7 +231,7 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
connect(() => ({
values: [
sidePanelStateLogic,
- ['sidePanelOpen'],
+ ['sidePanelOpen', 'selectedTab', 'selectedTabOptions'],
supportLogic,
[
'isEmailFormOpen',
@@ -235,7 +252,7 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
supportLogic,
['closeEmailForm', 'closeSupportForm', 'clearPendingViewTicket', 'resetSendSupportRequest'],
sidePanelStateLogic,
- ['closeSidePanel'],
+ ['closeSidePanel', 'setSidePanelOptions'],
],
})),
actions({
@@ -258,6 +275,8 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
startTicketFromSupportForm: true,
openPendingTicket: true,
sendMessage: (content: string, onSuccess: () => void) => ({ content, onSuccess }),
+ openTicketById: (ticketId: string) => ({ ticketId }),
+ setPendingTicketId: (ticketId: string | null) => ({ ticketId }),
requestRestoreLink: (email: string) => ({ email }),
restoreFromUrlToken: (token: string) => ({ token }),
setRestoreState: (state: RestoreFlowState) => ({ state }),
@@ -300,6 +319,14 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
setCurrentTicket: (_, { ticket }) => ticket,
},
],
+ // Ticket id from a URL that arrived before the list loaded; consumed by setTickets
+ pendingTicketId: [
+ null as string | null,
+ {
+ setPendingTicketId: (_, { ticketId }) => ticketId,
+ setCurrentTicket: () => null,
+ },
+ ],
newTicketDraft: [
null as JSONContent | null,
{
@@ -649,6 +676,45 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
actions.setMessages([]) // Clear messages immediately to avoid showing stale data
actions.loadMessages(ticket.id)
actions.markAsRead(ticket.id)
+ // Mirror the open ticket into the panel hash so the address bar stays linkable
+ if (values.sidePanelOpen && values.selectedTab === SidePanelTab.Support) {
+ actions.setSidePanelOptions(`${TICKET_OPTIONS_PREFIX}${ticket.id}`)
+ }
+ },
+ setView: ({ view }) => {
+ // Only clear our own format; other option strings belong to the support form
+ if (
+ view !== 'ticket' &&
+ values.sidePanelOpen &&
+ values.selectedTab === SidePanelTab.Support &&
+ values.selectedTabOptions?.startsWith(TICKET_OPTIONS_PREFIX)
+ ) {
+ actions.setSidePanelOptions(null)
+ }
+ },
+ openTicketById: ({ ticketId }) => {
+ if (values.view === 'ticket' && values.currentTicket?.id === ticketId) {
+ return
+ }
+ const ticket = values.tickets.find((t) => t.id === ticketId)
+ if (ticket) {
+ actions.setCurrentTicket(ticket)
+ } else {
+ actions.setPendingTicketId(ticketId)
+ }
+ },
+ setTickets: ({ tickets }) => {
+ const pending = values.pendingTicketId
+ if (!pending) {
+ return
+ }
+ const ticket = tickets.find((t) => t.id === pending)
+ if (ticket) {
+ actions.setCurrentTicket(ticket)
+ } else {
+ // Loaded and absent means a stale link; clear so polls don't re-run the lookup
+ actions.setPendingTicketId(null)
+ }
},
// "Contact support" CTAs (error boundaries, empty states, etc.) open the support form via
// supportLogic, which should land in this composer instead, carrying any prefilled message
@@ -775,7 +841,49 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
}
},
})),
- subscriptions(({ actions }) => ({
+ // Both blocks guard on the pathname because this logic also backs the side panel, which can
+ // be open on any page where the URL must stay untouched
+ urlToAction(({ actions, values }) => ({
+ [urls.myTickets()]: (_, searchParams) => {
+ const ticketId = searchParams['ticket']
+ if (typeof ticketId === 'string' && ticketId) {
+ actions.openTicketById(ticketId)
+ } else if (values.view === 'ticket') {
+ // Also catches browser-back from ?ticket=
+ actions.setView('list')
+ }
+ },
+ })),
+ actionToUrl(() => ({
+ setCurrentTicket: ({ ticket }) => {
+ // The scene is project-based, so the window pathname carries a /project/<id> prefix
+ if (removeProjectIdIfPresent(router.values.location.pathname) !== urls.myTickets()) {
+ return undefined
+ }
+ return [
+ router.values.location.pathname,
+ { ...router.values.searchParams, ticket: ticket.id },
+ router.values.hashParams,
+ ]
+ },
+ setView: ({ view }) => {
+ if (
+ view === 'ticket' ||
+ removeProjectIdIfPresent(router.values.location.pathname) !== urls.myTickets() ||
+ !('ticket' in router.values.searchParams)
+ ) {
+ return undefined
+ }
+ const { ticket: _discarded, ...searchParams } = router.values.searchParams
+ return [router.values.location.pathname, searchParams, router.values.hashParams]
+ },
+ })),
+ subscriptions(({ actions, values }) => ({
+ selectedTabOptions: (options: string | null) => {
+ if (values.selectedTab === SidePanelTab.Support && options?.startsWith(TICKET_OPTIONS_PREFIX)) {
+ actions.openTicketById(options.slice(TICKET_OPTIONS_PREFIX.length))
+ }
+ },
sidePanelOpen: (open: boolean) => {
// Only on open — a close-triggered fetch is wasted (nothing renders the result), and the
// full-screen tickets scene closes the panel as it opens, which would double-fetch
@@ -817,5 +925,11 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
if (values.pendingViewTicket) {
actions.openPendingTicket()
}
+ if (
+ values.selectedTab === SidePanelTab.Support &&
+ values.selectedTabOptions?.startsWith(TICKET_OPTIONS_PREFIX)
+ ) {
+ actions.openTicketById(values.selectedTabOptions.slice(TICKET_OPTIONS_PREFIX.length))
+ }
}),
])
diff --git a/products/conversations/manifest.tsx b/products/conversations/manifest.tsx
index 196d55354665..5d77672104b2 100644
--- a/products/conversations/manifest.tsx
+++ b/products/conversations/manifest.tsx
@@ -48,7 +48,8 @@ export const manifest: ProductManifest = {
supportTickets: (): string => '/support/tickets',
supportTicketDetail: (ticketId: string | number): string => `/support/tickets/${ticketId}`,
supportSettings: (): string => '/support/settings',
- myTickets: (): string => '/my-tickets',
+ myTickets: (ticketId?: string): string =>
+ ticketId ? `/my-tickets?ticket=${encodeURIComponent(ticketId)}` : '/my-tickets',
},
fileSystemTypes: {},
treeItemsNew: [],