: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(navigation): restore the support unread counter in the flat sidebar (#102103)
Alex V7b61a17f181e
diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.test.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.test.tsxnew file mode 100644index 000000000000..f3c394946cf3--- /dev/null+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.test.tsx@@ -0,0 +1,57 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import { render, waitFor } from '@testing-library/react'++import { useMocks } from '~/mocks/jest'+import { UserProductListItem } from '~/queries/schema/schema-general'+import { initKeaTests } from '~/test/init'+import { AppContext, TeamType } from '~/types'++import { FlatNavProducts } from './FlatNavProducts'++const productRow = (productPath: string): UserProductListItem => ({+ id: `id-${productPath}`,+ product_path: productPath,+ enabled: true,+ created_at: '2026-01-01T00:00:00Z',+ updated_at: '2026-01-01T00:00:00Z',+})++function toolRow(container: HTMLElement, slug: string): HTMLElement {+ const row = container.querySelector<HTMLElement>(`[data-attr="flat-nav-tool-${slug}"]`)+ if (!row) {+ throw new Error(`No flat-nav row rendered for "${slug}"`)+ }+ return row+}++describe('FlatNavProducts', () => {+ beforeEach(() => {+ useMocks({+ get: {+ '/api/projects/:team_id/conversations/tickets/unread_count': () => [200, { count: 3 }],+ },+ })+ // customProductsLogic seeds the picked tools from the page context rather than fetching them+ window.POSTHOG_APP_CONTEXT = {+ ...window.POSTHOG_APP_CONTEXT,+ custom_products: [productRow('Support'), productRow('Feature flags')],+ } as AppContext+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, conversations_enabled: true } as TeamType)+ })++ // customIconRegistry is the only thing that puts Support's unread count in the sidebar. A row+ // that falls back to the static product icon loses the count and shows no other symptom.+ it.each<[string, string | null]>([+ ['support', '3'],+ ['feature-flags', null],+ ])('renders the icon that the %s row resolves to', async (slug, expectedCount) => {+ const { container } = render(<FlatNavProducts />)++ await waitFor(() => {+ const row = toolRow(container, slug)+ expect(row.querySelector('.LemonBadge')?.textContent ?? null).toBe(expectedCount)+ expect(row.querySelector('svg')).not.toBeNull()+ })+ })+})diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsx b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsxindex 09259689d8a4..420b09fea12c 100644--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsx+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/FlatNavProducts.tsx@@ -10,7 +10,8 @@ import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/Wrappingimport { eventUsageLogic } from 'lib/utils/eventUsageLogic'import { urls } from 'scenes/urls'-import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'+import { getCustomIcon } from '~/layout/panel-layout/ProjectTree/customIconRegistry'+import { ProductIconWrapper, iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'import { NavLink } from '../../NavLink'import { flatNavLogic } from './flatNavLogic'@@ -59,18 +60,32 @@ export function FlatNavProducts(): JSX.Element {<span className="text-xs font-semibold text-tertiary">{group.category}</span></div>)}- {group.items.map((item) => (- <NavLink- key={item.path}- to={item.href}- label={item.label}- icon={iconForType(item.iconType, item.iconColor)}- isCollapsed={false}- tag={item.tag}- data-attr={`flat-nav-tool-${slugify(item.path)}`}- onClick={() => reportNavItemClicked(item.path, 'tools')}- />- ))}+ {group.items.map((item) => {+ // A product can register an icon that carries live state, such as the+ // support unread counter. iconForType supplies the color wrapper itself,+ // so a registered icon needs that wrapper added around it.+ const CustomIcon = getCustomIcon(item.type)+ return (+ <NavLink+ key={item.path}+ to={item.href}+ label={item.label}+ icon={+ CustomIcon ? (+ <ProductIconWrapper type={item.iconType} colorOverride={item.iconColor}>+ <CustomIcon />+ </ProductIconWrapper>+ ) : (+ iconForType(item.iconType, item.iconColor)+ )+ }+ isCollapsed={false}+ tag={item.tag}+ data-attr={`flat-nav-tool-${slugify(item.path)}`}+ onClick={() => reportNavItemClicked(item.path, 'tools')}+ />+ )+ })}</Fragment>)))}diff --git a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/flatNavLogic.ts b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/flatNavLogic.tsindex a6646c8118d7..128aae62b330 100644--- a/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/flatNavLogic.ts+++ b/frontend/src/layout/panel-layout/navbar/tabs/flat-nav/flatNavLogic.ts@@ -13,6 +13,7 @@ export interface FlatNavProductItem {path: stringlabel: stringhref: string+ type?: stringiconType?: FileSystemIconTypeiconColor?: FileSystemIconColortag?: 'alpha' | 'beta'@@ -73,6 +74,7 @@ export const flatNavLogic = kea<flatNavLogicType>([path: product.path,label: product.displayLabel || unescapePath(splitPath(product.path).pop() ?? product.path),href: product.href,+ type: product.type,iconType: product.iconType ?? (product.type as FileSystemIconType | undefined),iconColor: product.iconColor,tag: product.tags?.[0],