: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(navigation): make left nav resizable to any width (#62996)
Adam Leith98cc176a7fb6
diff --git a/frontend/src/layout/navigation-3000/Navigation.tsx b/frontend/src/layout/navigation-3000/Navigation.tsxindex 65386e4bd4bc..272640ea9a26 100644--- a/frontend/src/layout/navigation-3000/Navigation.tsx+++ b/frontend/src/layout/navigation-3000/Navigation.tsx@@ -41,7 +41,7 @@ export function Navigation({const { mobileLayout } = useValues(navigationLogic)const { mode } = useValues(navigation3000Logic)const mainRef = useRef<HTMLElement>(null)- const { mainContentRect, isLayoutNavCollapsed, isLayoutPanelVisible } = useValues(panelLayoutLogic)+ const { mainContentRect, isLayoutNavCollapsed, isLayoutPanelVisible, navbarWidth } = useValues(panelLayoutLogic)const { setMainContentRef, setMainContentRect } = useActions(panelLayoutLogic)const { setTabScrollDepth } = useActions(sceneLogic)const { activeTabId, activeSceneId } = useValues(sceneLogic)@@ -139,6 +139,11 @@ export function Navigation({? 'var(--color-bg-surface-primary)': 'var(--color-bg-primary)','--side-panel-width': sidePanelWidth + 'px',+ // Live navbar width from the resizer drives both the grid's left column+ // (via --left-nav-width below) and the nav element itself, which reads+ // --project-navbar-width. Collapsed/mobile fall back to the base default.+ '--project-navbar-width':+ !mobileLayout && !isLayoutNavCollapsed ? `${navbarWidth}px` : undefined,'--left-nav-width': isLayoutNavCollapsed? 'var(--project-navbar-width-collapsed)': 'var(--project-navbar-width)',diff --git a/frontend/src/layout/panel-layout/ai-first/Nav.tsx b/frontend/src/layout/panel-layout/ai-first/Nav.tsxindex 9442a1c97df3..42fb7be8b16d 100644--- a/frontend/src/layout/panel-layout/ai-first/Nav.tsx+++ b/frontend/src/layout/panel-layout/ai-first/Nav.tsx@@ -3,7 +3,7 @@ import { cva } from 'cva'import { useActions, useValues } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'-import { lazy, Suspense, useRef } from 'react'+import { lazy, Suspense, useEffect, useRef } from 'react'import { IconApps, IconChat, IconChevronRight, IconSearch } from '@posthog/icons'@@ -13,15 +13,21 @@ import { keyBinds } from 'lib/components/AppShortcuts/shortcuts'import { useAppShortcut } from 'lib/components/AppShortcuts/useAppShortcut'import { commandLogic } from 'lib/components/Command/commandLogic'import { Resizer } from 'lib/components/Resizer/Resizer'+import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'import { Collapsible } from 'lib/ui/Collapsible/Collapsible'import { Label } from 'lib/ui/Label/Label'import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'import { cn } from 'lib/utils/css-classes'-import { sceneLogic } from 'scenes/sceneLogic'import { urls } from 'scenes/urls'-import { NavExperimentTab, PanelLayoutNavIdentifier, panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'+import {+ NavExperimentTab,+ PANEL_NAVBAR_COLLAPSE_THRESHOLD,+ PANEL_NAVBAR_DEFAULT_WIDTH,+ PanelLayoutNavIdentifier,+ panelLayoutLogic,+} from '~/layout/panel-layout/panelLayoutLogic'import { navigation3000Logic } from '../../navigation-3000/navigationLogic'import { NavBarFooter } from '../NavBarFooter'@@ -99,13 +105,34 @@ export function Nav(): JSX.Element {setActivePanelIdentifier,showLayoutPanel,clearActivePanelIdentifier,+ setNavbarWidth,} = useActions(panelLayoutLogic)const { isLayoutPanelVisible, isLayoutNavCollapsed, navExperimentActiveTab, activePanelIdentifier } =useValues(panelLayoutLogic)const { mobileLayout: isMobileLayout } = useValues(navigation3000Logic)- const { firstTabIsActive } = useValues(sceneLogic)const { toggleCommand } = useActions(commandLogic)+ const resizerLogicProps: ResizerLogicProps = {+ logicKey: 'panel-layout-navbar',+ placement: 'right',+ containerRef,+ persistent: true,+ closeThreshold: PANEL_NAVBAR_COLLAPSE_THRESHOLD,+ onToggleClosed: (shouldBeClosed) => toggleLayoutNavCollapsed(shouldBeClosed),+ onDoubleClick: () => toggleLayoutNavCollapsed(),+ }+ const { desiredSize } = useValues(resizerLogic(resizerLogicProps))++ // Grow to any width upward; never render narrower than the collapse snap so the live drag+ // stays in sync with where onToggleClosed flips to collapsed mode.+ const openWidth = Math.max(Math.round(desiredSize ?? PANEL_NAVBAR_DEFAULT_WIDTH), PANEL_NAVBAR_COLLAPSE_THRESHOLD)++ useEffect(() => {+ if (!isLayoutNavCollapsed && !isMobileLayout) {+ setNavbarWidth(openWidth)+ }+ }, [openWidth, isLayoutNavCollapsed, isMobileLayout, setNavbarWidth])+useAppShortcut({name: 'ToggleLeftNav',keybind: [keyBinds.toggleLeftNav],@@ -296,15 +323,9 @@ export function Nav(): JSX.Element {</Tabs.Root>{!isMobileLayout && (<Resizer- logicKey="panel-layout-navbar"- placement="right"- containerRef={containerRef}- closeThreshold={100}- onToggleClosed={(shouldBeClosed) => toggleLayoutNavCollapsed(shouldBeClosed)}- onDoubleClick={() => toggleLayoutNavCollapsed()}+ {...resizerLogicProps}data-attr="tree-navbar-resizer"- className={cn('top-[calc(var(--scene-layout-header-height)+7px)] right-[-1px] bottom-4 z-2', {- 'top-[var(--scene-layout-header-height)]': firstTabIsActive,+ className={cn('top-3 -right-px bottom-4 z-2', {'top-0': isLayoutPanelVisible,})}offset={0}diff --git a/frontend/src/layout/panel-layout/panelLayoutLogic.tsx b/frontend/src/layout/panel-layout/panelLayoutLogic.tsxindex 853d076e6ecf..25b7571615c7 100644--- a/frontend/src/layout/panel-layout/panelLayoutLogic.tsx+++ b/frontend/src/layout/panel-layout/panelLayoutLogic.tsx@@ -23,6 +23,11 @@ export type PanelLayoutMainContentRef = React.RefObject<HTMLElement> | nullexport const PANEL_LAYOUT_DEFAULT_WIDTH: number = 245export const PANEL_LAYOUT_MIN_WIDTH: number = 160+// Navbar resize: any width upward, snapping to collapsed below the threshold.+export const PANEL_NAVBAR_DEFAULT_WIDTH: number = 215+// Below this the drag snaps to collapsed mode.+export const PANEL_NAVBAR_COLLAPSE_THRESHOLD: number = 140+export const panelLayoutLogic = kea<panelLayoutLogicType>([path(['layout', 'panel-layout', 'panelLayoutLogic']),connect(() => ({@@ -48,6 +53,7 @@ export const panelLayoutLogic = kea<panelLayoutLogicType>([setSidePanelWidth: (width: number) => ({ width }),toggleNavSection: (section: string) => ({ section }),setNavExperimentTab: (tab: NavExperimentTab) => ({ tab }),+ setNavbarWidth: (width: number) => ({ width }),}),reducers({isLayoutNavbarVisibleForDesktop: [@@ -157,6 +163,14 @@ export const panelLayoutLogic = kea<panelLayoutLogicType>([setNavExperimentTab: (_, { tab }) => tab,},],+ // Transient: the live open width is restored from the resizer's persisted size on mount,+ // so persisting here would only duplicate it and thrash localStorage on every drag frame.+ navbarWidth: [+ PANEL_NAVBAR_DEFAULT_WIDTH,+ {+ setNavbarWidth: (_, { width }) => width,+ },+ ],expandedNavSections: [{ ai: true, project: true, files: true, favorites: false, apps: true } as Record<string, boolean>,{ persist: true },