: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): give the compact sidebar room to breathe (#91717)
Rafael Audibert79beeaddd7ff
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 71d43c8eeee2..cf3d8fb45b19 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -3204,6 +3204,10 @@ snapshots:hash: v1.k794b7964.dea67e50d4956ed1865124e7dba12c5deeb0703b19cac0513c82facb069e6a60.gkkPUZ2bAqgN4OxaM6W5sfI8m4O2uxsHh7xqL1PLsg4layout-navigation-eventingestionrestrictiondetails--whole-project--light:hash: v1.k794b7964.56e91dee845e8cae758c631b29733ddb23d0bd46c4669cd904032f3f668c8dd9.lrp6-51HhFOiy6Rqy1o5KlQamvWmozjUVC8EQnCPhrU+ layout-navigation-sidebar--density-comparison--dark:+ hash: v1.k794b7964.0900d9026ecffa9c2ff0989ee4618cdddfbb184c1ae480b110fc618105865445.KjYyXIZzyGNorxnj3Xo_ymFB0DMbOVFMRj_IPeTgAhI+ layout-navigation-sidebar--density-comparison--light:+ hash: v1.k794b7964.1caaa1ff521dfe6a6435dbaa817e05cd8263abd3a5b619d572dcb2c372cece1a.MlYgyHdxlI7nKwGkZHh7jiaPWO3aop7aEJzzWmjW5Rslayout-project-tree--all-products--dark:hash: v1.k794b7964.f5ecd6decc0aa7b7e9641cc874f81b12d2f73973fc7a991367907c8bf9e6a3cf.GmiqvAu4XbxVgya6Rn15ChvXn-l9XU6ttxGUqmPoi4olayout-project-tree--all-products--light:diff --git a/frontend/src/layout/panel-layout/ai-first/Nav.scss b/frontend/src/layout/panel-layout/ai-first/Nav.scssindex 3cf792163a2d..5be130b04187 100644--- a/frontend/src/layout/panel-layout/ai-first/Nav.scss+++ b/frontend/src/layout/panel-layout/ai-first/Nav.scss@@ -1,7 +1,27 @@+// Density is set through custom properties rather than overriding rules. Tailwind utilities are+// !important in this app, so a rule that competes with one loses, but a variable it reads wins.[data-nav-density='compact'] {--button-height-base: var(--button-height-xs);+ // Section and category headers keep the padding of a comfortable row. Once the rows condense,+ // that space reads as a gap instead of as grouping.+ --nav-section-trigger-padding-y: 0.125rem;+ --nav-section-gap: 0.25rem;+ --lemon-tree-category-gap: 0.5rem;+ --lemon-tree-category-padding-y: 0.125rem;+.button-primitive {font-size: 0.75rem;}++ // The search bar is a control, not a list row, so it stays taller than the rows around it.+ // At the compact row height the ⌘K badge fills the box from edge to edge.+ [data-attr='nav-search-bar'] {+ --button-height-base: var(--button-height-sm);++ .KeyboardShortcut {+ min-width: 1.125rem;+ height: 1.125rem;+ }+ }}diff --git a/frontend/src/layout/panel-layout/ai-first/Nav.stories.tsx b/frontend/src/layout/panel-layout/ai-first/Nav.stories.tsxnew file mode 100644index 000000000000..402d7d899b85--- /dev/null+++ b/frontend/src/layout/panel-layout/ai-first/Nav.stories.tsx@@ -0,0 +1,86 @@+import './Nav.scss'++import type { Meta, StoryObj } from '@storybook/react'+import { useActions } from 'kea'++import { NavSearchBar } from 'lib/components/NavSearchButton/NavSearchButton'+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'++import { mswDecorator } from '~/mocks/browser'+import { SidebarDensity } from '~/queries/schema/schema-general'++import { customProductsLogic } from '../ProjectTree/customProductsLogic'+import { NavTabBrowse } from './tabs/NavTabBrowse'++/** Enough tools, across enough categories, for "My tools" to show its category headers. */+const MOCK_TOOLS = [+ 'Product analytics',+ 'Web analytics',+ 'Session replay',+ 'Surveys',+ 'Error tracking',+ 'Experiments',+ 'Feature flags',+].map((productPath, index) => ({+ id: `product-${index}`,+ product_path: productPath,+ enabled: true,+ created_at: '2026-01-01T00:00:00Z',+ updated_at: '2026-01-01T00:00:00Z',+}))++/**+ * Density comes from `data-nav-density`, which `Nav` sets from the user's sidebar setting.+ * Setting the attribute here keeps the story independent of the user API.+ */+function NavSidebar({ density }: { density: SidebarDensity }): JSX.Element {+ const { loadCustomProducts } = useActions(customProductsLogic)+ useOnMountEffect(() => loadCustomProducts())++ return (+ <div+ data-nav-density={density}+ className="flex flex-col w-[var(--project-navbar-width)] h-[640px] bg-surface-tertiary border rounded overflow-hidden"+ >+ <div className="px-2 py-1">+ <NavSearchBar toggleCommand={() => {}} />+ </div>+ <NavTabBrowse />+ </div>+ )+}++/** Both densities together, so a spacing change to one is visible against the other. */+function NavSidebarDensities(): JSX.Element {+ return (+ <div className="flex gap-4">+ <div className="flex flex-col gap-1">+ <span className="text-xs font-semibold text-secondary">Comfortable</span>+ <NavSidebar density="comfortable" />+ </div>+ <div className="flex flex-col gap-1">+ <span className="text-xs font-semibold text-secondary">Compact</span>+ <NavSidebar density="compact" />+ </div>+ </div>+ )+}++const meta: Meta<typeof NavSidebarDensities> = {+ title: 'Layout/Navigation sidebar',+ component: NavSidebarDensities,+ parameters: {+ layout: 'padded',+ viewMode: 'story',+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/environments/:team_id/user_product_list': () => [200, { results: MOCK_TOOLS }],+ },+ }),+ ],+}+export default meta++export const DensityComparison: StoryObj<typeof NavSidebarDensities> = {}diff --git a/frontend/src/layout/panel-layout/ai-first/Nav.tsx b/frontend/src/layout/panel-layout/ai-first/Nav.tsxindex 5ce9ddfeda7e..2d1cb7f14802 100644--- a/frontend/src/layout/panel-layout/ai-first/Nav.tsx+++ b/frontend/src/layout/panel-layout/ai-first/Nav.tsx@@ -70,7 +70,7 @@ export function SectionTrigger({return (<Collapsible.TriggerclassName={cn(- 'flex items-center py-1 cursor-pointer group pl-2 sticky top-0 bg-surface-tertiary z-4 -mx-1 px-2 w-[calc(100%+(var(--spacing)*2))] -outline-offset-2',+ 'flex items-center py-[var(--nav-section-trigger-padding-y,0.25rem)] cursor-pointer group pl-2 sticky top-0 bg-surface-tertiary z-4 -mx-1 px-2 w-[calc(100%+(var(--spacing)*2))] -outline-offset-2',isCollapsed && 'mx-0 w-full px-px')}>diff --git a/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsx b/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsxindex 3dc36f8a9f14..a51f551fbcbc 100644--- a/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsx+++ b/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsx@@ -329,7 +329,7 @@ export function NavTabBrowse(): JSX.Element {})toggleNavSection('recents')}}- className="mt-2 group/colorful-product-icons colorful-product-icons-true"+ className="mt-[var(--nav-section-gap,0.5rem)] group/colorful-product-icons colorful-product-icons-true"data-attr="nav-section-recents"><SectionTrigger icon={<IconClock />} label="Recents" isCollapsed={isLayoutNavCollapsed} />@@ -393,7 +393,7 @@ export function NavTabBrowse(): JSX.Element {})toggleNavSection('tools')}}- className="mt-2 group/colorful-product-icons colorful-product-icons-true"+ className="mt-[var(--nav-section-gap,0.5rem)] group/colorful-product-icons colorful-product-icons-true"data-attr="nav-section-tools"><div className="relative">diff --git a/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx b/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsxindex c09188412c50..9b2da4003399 100644--- a/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx+++ b/frontend/src/lib/lemon-ui/LemonTree/LemonTree.tsx@@ -626,7 +626,10 @@ const LemonTreeNode = forwardRef<HTMLDivElement, LemonTreeNodeProps>(return null}return (- <div key={item.id} className="not-first:mt-3 py-1 px-2 flex items-center">+ <div+ key={item.id}+ className="not-first:mt-[var(--lemon-tree-category-gap,0.75rem)] py-[var(--lemon-tree-category-padding-y,0.25rem)] px-2 flex items-center"+ ><span className="text-xs font-semibold text-tertiary">{item.displayName}</span></div>)