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.

feat(navigation): add flat sidebar behind the flat-nav feature flag (#92011)

Rafael Audibert7e30c2561eaa
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index de3cbb39d3c0..07c26b3e58dd 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3252,6 +3252,10 @@ snapshots:
hash: v1.k794b7964.33dac53a2c2f3c8945bb52917b010f00a24b8d8b213106939af1037022d4ed5e.QNBv_MCq5SJyqzj3G7AuQxGF1qLYQLIQotnO3MfqpRE
insights-worldmap--default--light:
hash: v1.k794b7964.a4f523dbe2e78f12ddf6c95d6e1e0b1da4457008aa42a9b83fb5e21bc4519915.sRV9jpfMOemd-Hss7Y7z4hMMwHYzM7l8Dq9i4uoJBiE
+ layout-flat-nav--default--dark:
+ hash: v1.k794b7964.03613ec62699fc27a750adf012f4225aa584569ea3efe9998858d68c85397902.PFmiNHfyolZNauCpMSOgyJTs42J32h-GlFBxyCUvgVA
+ layout-flat-nav--default--light:
+ hash: v1.k794b7964.bc199653ab101a8f2e6ef2ddc0c9d9d66b0872b48b3e4407819c85d7d1d92253.peo-D7OiW3tooIMVAqjs5IHu9cpaT_bD9AZoXj5lpG4
layout-impersonation-reason-modal--loading--dark:
hash: v1.k794b7964.56bc03177fcbe93f212232c9025d90ec672e9043881ce4e9a3dbbb612b501066.mkYeZ8C0UhPLy7CKjURxERYeFMjyvXrOyEpykdHmmrM
layout-impersonation-reason-modal--loading--light:
diff --git a/frontend/src/layout/panel-layout/PanelLayout.tsx b/frontend/src/layout/panel-layout/PanelLayout.tsx
index 0b3d9232c80e..cb6e972695da 100644
--- a/frontend/src/layout/panel-layout/PanelLayout.tsx
+++ b/frontend/src/layout/panel-layout/PanelLayout.tsx
@@ -3,6 +3,7 @@ import { useActions, useMountedLogic, useValues } from 'kea'
import { IconX } from '@posthog/icons'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { IconMenu } from 'lib/lemon-ui/icons'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { cn } from 'lib/utils/css-classes'
@@ -12,6 +13,7 @@ import { supportTicketCounterLogic } from 'products/conversations/frontend/suppo
import { navigation3000Logic } from '../navigation-3000/navigationLogic'
import { Nav as AiFirstNavBar } from './ai-first/Nav'
import { PanelLayoutPanels } from './ai-first/PanelLayoutPanels'
+import { FlatNav } from './flat-nav/FlatNav'
import { panelLayoutLogic } from './panelLayoutLogic'
import { PROJECT_TREE_KEY } from './ProjectTree/ProjectTree'
import { projectTreeLogic } from './ProjectTree/projectTreeLogic'
@@ -83,6 +85,7 @@ export function PanelLayout({ className }: { className?: string }): JSX.Element
const { showLayoutPanel, clearActivePanelIdentifier, showLayoutNavBar } = useActions(panelLayoutLogic)
useMountedLogic(projectTreeLogic({ key: PROJECT_TREE_KEY }))
useMountedLogic(supportTicketCounterLogic) // Start polling for unread tickets on app load
+ const isFlatNavEnabled = useFeatureFlag('FLAT_NAV')
return (
<>
@@ -129,7 +132,7 @@ export function PanelLayout({ className }: { className?: string }): JSX.Element
: {}
}
>
- <AiFirstNavBar />
+ {isFlatNavEnabled ? <FlatNav /> : <AiFirstNavBar />}
</div>
{/* Mobile-only positioning anchor for panel content. Decoupled from #project-panel-layout
diff --git a/frontend/src/layout/panel-layout/flat-nav/FlatNav.scss b/frontend/src/layout/panel-layout/flat-nav/FlatNav.scss
new file mode 100644
index 000000000000..997a93244a5e
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/FlatNav.scss
@@ -0,0 +1,12 @@
+.FlatNav[data-nav-density='compact'] {
+ --button-height-base: var(--button-height-xs);
+
+ .button-primitive {
+ font-size: 0.75rem;
+ }
+}
+
+.FlatNav .show-scrollbar-on-hover::-webkit-scrollbar {
+ width: 6px;
+ height: 6px;
+}
diff --git a/frontend/src/layout/panel-layout/flat-nav/FlatNav.stories.tsx b/frontend/src/layout/panel-layout/flat-nav/FlatNav.stories.tsx
new file mode 100644
index 000000000000..8d0ee6979490
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/FlatNav.stories.tsx
@@ -0,0 +1,26 @@
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+
+import { FlatNav } from './FlatNav'
+
+type Story = StoryObj<typeof FlatNav>
+
+const meta: Meta<typeof FlatNav> = {
+ title: 'Layout/Flat Nav',
+ component: FlatNav,
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ featureFlags: [FEATURE_FLAGS.FLAT_NAV],
+ },
+ render: () => (
+ <div className="h-screen w-fit">
+ <FlatNav />
+ </div>
+ ),
+}
+
+export default meta
+
+export const Default: Story = {}
diff --git a/frontend/src/layout/panel-layout/flat-nav/FlatNav.tsx b/frontend/src/layout/panel-layout/flat-nav/FlatNav.tsx
new file mode 100644
index 000000000000..85fb0fa5cb8b
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/FlatNav.tsx
@@ -0,0 +1,256 @@
+import './FlatNav.scss'
+
+import { cva } from 'cva'
+import { useActions, useMountedLogic, useValues } from 'kea'
+import { router } from 'kea-router'
+import posthog from 'posthog-js'
+import { useEffect, useRef } from 'react'
+
+import { IconChat, IconClock, IconHome, IconNotification, IconPlusSmall } from '@posthog/icons'
+
+import { NewAccountMenu } from 'lib/components/Account/NewAccountMenu'
+import { commandLogic } from 'lib/components/Command/commandLogic'
+import { NavSearchBar, NavSearchButton } from 'lib/components/NavSearchButton/NavSearchButton'
+import { Resizer } from 'lib/components/Resizer/Resizer'
+import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'
+import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'
+import { keyBinds } from 'lib/components/Shortcuts/shortcuts'
+import { useShortcut } from 'lib/components/Shortcuts/useShortcut'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from 'lib/ui/DropdownMenu/DropdownMenu'
+import { cn } from 'lib/utils/css-classes'
+import { newDashboardLogic } from 'scenes/dashboard/newDashboardLogic'
+import { urls } from 'scenes/urls'
+
+import { navigation3000Logic } from '~/layout/navigation-3000/navigationLogic'
+import { navigationLogic } from '~/layout/navigation/navigationLogic'
+import { NavLink } from '~/layout/panel-layout/ai-first/NavLink'
+import { PanelLayoutPanels } from '~/layout/panel-layout/ai-first/PanelLayoutPanels'
+import { CreateMenu } from '~/layout/panel-layout/menus/CreateMenu'
+import { NavBarFooter } from '~/layout/panel-layout/NavBarFooter'
+import {
+ PANEL_NAVBAR_COLLAPSE_THRESHOLD,
+ PANEL_NAVBAR_DEFAULT_WIDTH,
+ panelLayoutLogic,
+} from '~/layout/panel-layout/panelLayoutLogic'
+import { uiCustomizationLogic } from '~/layout/uiCustomizationLogic'
+import { ActivityTab } from '~/types'
+
+import { FlatNavPanelButtons } from './FlatNavPanelButtons'
+import { FlatNavProducts } from './FlatNavProducts'
+import { FlatNavRecents } from './FlatNavRecents'
+
+const flatNavStyles = cva({
+ base: 'FlatNav flex flex-col max-h-screen min-h-screen bg-surface-tertiary z-[var(--z-layout-navbar)] relative border-r lg:border-r-transparent',
+ variants: {
+ isLayoutNavCollapsed: {
+ true: 'w-[var(--project-navbar-width-collapsed)]',
+ false: 'w-[var(--project-navbar-width)]',
+ },
+ isMobileLayout: {
+ true: 'absolute top-0 bottom-0 left-0',
+ false: '',
+ },
+ },
+})
+
+// Keeps newDashboardLogic mounted while the Create button is visible, so the "Start from scratch"
+// flow completes (and redirects) even after the menu closes and unmounts its own logic reference.
+function CreateMenuLogics(): null {
+ useMountedLogic(newDashboardLogic)
+ return null
+}
+
+export function FlatNav(): JSX.Element {
+ const containerRef = useRef<HTMLDivElement | null>(null)
+ const { toggleLayoutNavCollapsed, setNavbarWidth } = useActions(panelLayoutLogic)
+ const { isLayoutPanelVisible, isLayoutNavCollapsed } = useValues(panelLayoutLogic)
+ const { mobileLayout: isMobileLayout } = useValues(navigation3000Logic)
+ const { toggleCommand } = useActions(commandLogic)
+ const { sidebarDensity, isSidebarSectionShown, isSidebarItemShown, uiCustomizationEnabled } =
+ useValues(uiCustomizationLogic)
+ const { showConfigureHomeModal } = useActions(navigationLogic)
+ const isProductAutonomyEnabled = useFeatureFlag('PRODUCT_AUTONOMY')
+ const showCreateButton = useFeatureFlag('CREATE_BUTTON_NAV_EXPERIMENT', 'test')
+
+ 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])
+
+ useShortcut({
+ name: 'ToggleLeftNav',
+ keybind: [keyBinds.toggleLeftNav],
+ intent: 'Toggle collapse left navigation',
+ interaction: 'function',
+ callback: toggleLayoutNavCollapsed,
+ })
+
+ return (
+ <div className="flex gap-0 relative">
+ <nav
+ className={cn(flatNavStyles({ isLayoutNavCollapsed, isMobileLayout }))}
+ data-nav-density={sidebarDensity}
+ ref={containerRef}
+ >
+ <div
+ className={cn(
+ 'flex justify-between items-center',
+ isLayoutNavCollapsed ? 'justify-center' : 'h-[var(--scene-layout-header-height)]'
+ )}
+ >
+ <div
+ className={cn('flex gap-1 rounded-md w-full px-2 pt-2 pb-1', {
+ 'flex-col items-center pt-2 pb-0': isLayoutNavCollapsed,
+ })}
+ >
+ <NewAccountMenu isLayoutNavCollapsed={isLayoutNavCollapsed} />
+
+ {/* Collapsed nav has no room for the search bar, so it keeps the icon-only trigger */}
+ {isLayoutNavCollapsed && <NavSearchButton toggleCommand={toggleCommand} />}
+ </div>
+ </div>
+
+ {!isLayoutNavCollapsed && (
+ <div className="px-2 py-1">
+ <NavSearchBar toggleCommand={toggleCommand} />
+ </div>
+ )}
+
+ {showCreateButton && (
+ <div className={cn('px-2 py-1', isLayoutNavCollapsed && 'flex justify-center px-0')}>
+ <CreateMenuLogics />
+ <DropdownMenu
+ onOpenChange={(open) => {
+ if (open) {
+ posthog.capture('nav create button clicked')
+ }
+ }}
+ >
+ <DropdownMenuTrigger asChild>
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconPlusSmall />}
+ fullWidth={!isLayoutNavCollapsed}
+ center={!isLayoutNavCollapsed}
+ title={isLayoutNavCollapsed ? 'Create' : undefined}
+ data-attr="nav-create-button"
+ >
+ {!isLayoutNavCollapsed ? 'Create' : null}
+ </LemonButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent side="bottom" align="start" className="min-w-[220px]">
+ <CreateMenu />
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ )}
+
+ <ScrollableShadows
+ className="flex-1"
+ innerClassName="overflow-y-auto overflow-x-hidden pl-2 pr-0.5 pt-1 focus-visible:outline-accent -outline-offset-2"
+ direction="vertical"
+ styledScrollbars
+ >
+ <div className={cn('flex flex-col gap-px', isLayoutNavCollapsed && 'items-center')}>
+ {isSidebarItemShown('home') && (
+ <NavLink
+ to={urls.projectRoot()}
+ label="Home"
+ icon={<IconHome />}
+ isCollapsed={isLayoutNavCollapsed}
+ data-attr="nav-item-home"
+ onClick={() => posthog.capture('nav item clicked', { item: 'home' })}
+ sideAction={{
+ onClick: () =>
+ uiCustomizationEnabled
+ ? router.actions.push(urls.settings('user-navigation', 'homepage'))
+ : showConfigureHomeModal(),
+ tooltip: 'Configure home',
+ 'data-attr': 'nav-configure-home',
+ }}
+ />
+ )}
+
+ <NavLink
+ to={urls.ai()}
+ label="Chat"
+ icon={<IconChat className="text-ai" />}
+ isCollapsed={isLayoutNavCollapsed}
+ data-attr="flat-nav-item-chat"
+ onClick={() => posthog.capture('nav item clicked', { item: 'chat' })}
+ />
+
+ {isProductAutonomyEnabled && isSidebarItemShown('inbox') && (
+ <NavLink
+ to={urls.inbox()}
+ label="Self-driving"
+ icon={<IconNotification />}
+ isCollapsed={isLayoutNavCollapsed}
+ data-attr="nav-item-inbox"
+ tag="beta"
+ onClick={() => posthog.capture('nav item clicked', { item: 'inbox' })}
+ />
+ )}
+
+ <NavLink
+ to={urls.activity(ActivityTab.ExploreEvents)}
+ label="Activity"
+ icon={<IconClock />}
+ isCollapsed={isLayoutNavCollapsed}
+ data-attr="nav-item-activity"
+ onClick={() => posthog.capture('nav item clicked', { item: 'activity' })}
+ />
+
+ <FlatNavPanelButtons />
+ </div>
+
+ {!isLayoutNavCollapsed && isSidebarSectionShown('recents') && <FlatNavRecents />}
+ {!isLayoutNavCollapsed && isSidebarSectionShown('my_tools') && <FlatNavProducts />}
+ </ScrollableShadows>
+
+ <div className="px-2">
+ <div className="h-px bg-border-primary" />
+ </div>
+
+ <div className="p-1">
+ <NavBarFooter isLayoutNavCollapsed={isLayoutNavCollapsed} />
+ </div>
+
+ {!isMobileLayout && (
+ <Resizer
+ {...resizerLogicProps}
+ data-attr="tree-navbar-resizer"
+ className={cn('top-3 -right-px bottom-4 z-2', {
+ 'top-0': isLayoutPanelVisible,
+ })}
+ offset={0}
+ />
+ )}
+ </nav>
+
+ {/* Desktop renders panel content inline next to the nav (PanelLayoutPanel's
+ ResizableElement positions it via left:100% of this flex parent). On mobile the
+ panel is lifted out to PanelLayout.tsx for its own stacking context. */}
+ {!isMobileLayout && <PanelLayoutPanels />}
+ </div>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/flat-nav/FlatNavPanelButtons.tsx b/frontend/src/layout/panel-layout/flat-nav/FlatNavPanelButtons.tsx
new file mode 100644
index 000000000000..caa1e657b0ad
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/FlatNavPanelButtons.tsx
@@ -0,0 +1,100 @@
+import { useActions, useValues } from 'kea'
+import posthog from 'posthog-js'
+
+import { IconApps, IconChevronRight, IconDatabase, IconFolderOpen, IconStar } from '@posthog/icons'
+
+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
+import { cn } from 'lib/utils/css-classes'
+
+import { PanelIndicatorIcon } from '~/layout/panel-layout/ai-first/Nav'
+import { PanelLayoutNavIdentifier, panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'
+import { SidebarItemKey, uiCustomizationLogic } from '~/layout/uiCustomizationLogic'
+
+const PANEL_TRIGGER_ITEMS: {
+ identifier: PanelLayoutNavIdentifier
+ configKey: SidebarItemKey
+ label: string
+ icon: React.ReactNode
+}[] = [
+ { identifier: 'DataAndPeople', configKey: 'data', label: 'Data', icon: <IconDatabase /> },
+ { identifier: 'Project', configKey: 'files', label: 'Files', icon: <IconFolderOpen className="stroke-[1.2]" /> },
+ { identifier: 'Products', configKey: 'tools', label: 'Tools', icon: <IconApps /> },
+ { identifier: 'Shortcuts', configKey: 'starred', label: 'Starred', icon: <IconStar /> },
+]
+
+export function FlatNavPanelButtons(): JSX.Element {
+ const { showLayoutPanel, setActivePanelIdentifier, clearActivePanelIdentifier } = useActions(panelLayoutLogic)
+ const { isLayoutPanelVisible, isLayoutNavCollapsed, activePanelIdentifier, activePanelIdentifierFromUrlAiFirst } =
+ useValues(panelLayoutLogic)
+ const { isSidebarItemShown } = useValues(uiCustomizationLogic)
+
+ function handlePanelTriggerClick(item: PanelLayoutNavIdentifier): void {
+ const isOpening = activePanelIdentifier !== item
+ posthog.capture('nav panel trigger clicked', { panel: item, is_open: isOpening })
+ if (isOpening) {
+ setActivePanelIdentifier(item)
+ showLayoutPanel(true)
+ } else {
+ clearActivePanelIdentifier()
+ showLayoutPanel(false)
+ }
+ }
+
+ return (
+ <>
+ {PANEL_TRIGGER_ITEMS.filter((item) => isSidebarItemShown(item.configKey)).map((item) => {
+ const isActive =
+ activePanelIdentifier === item.identifier || activePanelIdentifierFromUrlAiFirst === item.identifier
+ const tooltip = isLayoutNavCollapsed
+ ? isLayoutPanelVisible && activePanelIdentifier === item.identifier
+ ? `Close ${item.label.toLowerCase()}`
+ : `Open ${item.label.toLowerCase()}`
+ : undefined
+
+ return (
+ <ButtonPrimitive
+ key={item.identifier}
+ active={isActive}
+ className="group -outline-offset-2"
+ menuItem={!isLayoutNavCollapsed}
+ iconOnly={isLayoutNavCollapsed}
+ tooltip={tooltip}
+ tooltipPlacement="right"
+ onClick={() => handlePanelTriggerClick(item.identifier)}
+ data-attr={`menu-item-${item.identifier.toLowerCase()}`}
+ >
+ <span
+ className={cn(
+ 'relative size-4 text-secondary group-hover:text-primary opacity-50 group-hover:opacity-100 transition-all duration-50',
+ isActive && 'text-primary opacity-100'
+ )}
+ >
+ {item.icon}
+ <PanelIndicatorIcon />
+ </span>
+ {!isLayoutNavCollapsed && (
+ <>
+ <span
+ className={cn(
+ 'truncate text-secondary group-hover:text-primary',
+ isActive && 'text-primary'
+ )}
+ >
+ {item.label}
+ </span>
+ <span className="ml-auto pr-1">
+ <IconChevronRight
+ className={cn(
+ 'size-3 text-secondary opacity-50 group-hover:opacity-100 transition-all duration-50',
+ isActive && 'opacity-100'
+ )}
+ />
+ </span>
+ </>
+ )}
+ </ButtonPrimitive>
+ )
+ })}
+ </>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/flat-nav/FlatNavProducts.tsx b/frontend/src/layout/panel-layout/flat-nav/FlatNavProducts.tsx
new file mode 100644
index 000000000000..ca1e28ace749
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/FlatNavProducts.tsx
@@ -0,0 +1,78 @@
+import { useValues } from 'kea'
+import posthog from 'posthog-js'
+import { Fragment } from 'react'
+
+import { IconGear } from '@posthog/icons'
+
+import { Link } from 'lib/lemon-ui/Link'
+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
+import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'
+import { urls } from 'scenes/urls'
+
+import { NavLink } from '~/layout/panel-layout/ai-first/NavLink'
+import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
+
+import { flatNavLogic } from './flatNavLogic'
+import { FlatNavSection } from './FlatNavSection'
+
+function slugify(path: string): string {
+ return path.toLowerCase().replace(/[^a-z0-9]+/g, '-')
+}
+
+export function FlatNavProducts(): JSX.Element {
+ const { productGroups, customProductsLoading } = useValues(flatNavLogic)
+
+ return (
+ <FlatNavSection
+ label="My tools"
+ action={
+ <Link
+ to={urls.settings('user-navigation')}
+ tooltip="Choose which tools to show in the sidebar"
+ tooltipPlacement="top"
+ onClick={() => posthog.capture('nav tools customize clicked')}
+ buttonProps={{ iconOnly: true, size: 'xs' }}
+ data-attr="flat-nav-tools-customize-button"
+ >
+ <IconGear className="size-3 text-secondary" />
+ </Link>
+ }
+ >
+ <div className="flex flex-col gap-px group/colorful-product-icons colorful-product-icons-true">
+ {customProductsLoading && productGroups.length === 0 ? (
+ Array.from({ length: 4 }).map((_, index) => (
+ <WrappingLoadingSkeleton fullWidth key={index}>
+ <ButtonPrimitive aria-hidden inert menuItem />
+ </WrappingLoadingSkeleton>
+ ))
+ ) : productGroups.length === 0 ? (
+ <span className="text-xs text-tertiary px-2 py-1">
+ No tools selected. Use the gear icon above to pick some.
+ </span>
+ ) : (
+ productGroups.map((group) => (
+ <Fragment key={group.category}>
+ {group.category && (
+ <div className="not-first:mt-3 py-1 px-2 flex items-center">
+ <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={() => posthog.capture('nav item clicked', { item: item.path })}
+ />
+ ))}
+ </Fragment>
+ ))
+ )}
+ </div>
+ </FlatNavSection>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/flat-nav/FlatNavRecents.tsx b/frontend/src/layout/panel-layout/flat-nav/FlatNavRecents.tsx
new file mode 100644
index 000000000000..be02b69afa97
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/FlatNavRecents.tsx
@@ -0,0 +1,45 @@
+import { useValues } from 'kea'
+
+import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
+
+import { NavLink } from '~/layout/panel-layout/ai-first/NavLink'
+import { navRecentsLogic } from '~/layout/panel-layout/ai-first/tabs/navRecentsLogic'
+import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
+import { splitPath, unescapePath } from '~/layout/panel-layout/ProjectTree/utils'
+import { FileSystemEntry, FileSystemIconType } from '~/queries/schema/schema-general'
+
+import { FlatNavSection } from './FlatNavSection'
+
+function getItemName(item: FileSystemEntry): string {
+ const lastPart = splitPath(item.path).pop()
+ return unescapePath(lastPart ?? item.path)
+}
+
+export function FlatNavRecents(): JSX.Element {
+ const { recentItems, recentItemsLoading } = useValues(navRecentsLogic)
+
+ return (
+ <FlatNavSection label="Recents" info="Items you viewed recently, most recent first.">
+ <div className="flex flex-col gap-px group/colorful-product-icons colorful-product-icons-true">
+ {recentItemsLoading && recentItems.length === 0 ? (
+ <div className="flex items-center justify-center py-2">
+ <Spinner className="size-4" />
+ </div>
+ ) : recentItems.length === 0 ? (
+ <span className="text-xs text-tertiary px-2 py-1">No recent items</span>
+ ) : (
+ recentItems.map((item) => (
+ <NavLink
+ key={item.id}
+ to={item.href ?? ''}
+ label={getItemName(item)}
+ icon={iconForType(item.type as FileSystemIconType)}
+ isCollapsed={false}
+ data-attr={`nav-recent-item-${item.id}`}
+ />
+ ))
+ )}
+ </div>
+ </FlatNavSection>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/flat-nav/FlatNavSection.tsx b/frontend/src/layout/panel-layout/flat-nav/FlatNavSection.tsx
new file mode 100644
index 000000000000..b965f6ca0fc3
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/FlatNavSection.tsx
@@ -0,0 +1,34 @@
+import { IconInfo } from '@posthog/icons'
+import { Tooltip } from '@posthog/lemon-ui'
+
+import { Label } from 'lib/ui/Label/Label'
+
+interface FlatNavSectionProps {
+ label: string
+ /** Short explanation of the section, shown behind an info icon next to the header. */
+ info?: string
+ /** Optional small control rendered at the right edge of the section header. */
+ action?: React.ReactNode
+ children: React.ReactNode
+}
+
+export function FlatNavSection({ label, info, action, children }: FlatNavSectionProps): JSX.Element {
+ return (
+ <div className="flex flex-col gap-px mt-3">
+ <div className="flex items-center justify-between pl-2 pr-1 min-h-5">
+ <span className="flex items-center gap-1">
+ <Label intent="menu" className="text-xxs text-secondary">
+ {label}
+ </Label>
+ {info && (
+ <Tooltip title={info} placement="top">
+ <IconInfo className="size-3 text-tertiary" />
+ </Tooltip>
+ )}
+ </span>
+ {action}
+ </div>
+ {children}
+ </div>
+ )
+}
diff --git a/frontend/src/layout/panel-layout/flat-nav/flatNavLogic.ts b/frontend/src/layout/panel-layout/flat-nav/flatNavLogic.ts
new file mode 100644
index 000000000000..c79dbaa0f898
--- /dev/null
+++ b/frontend/src/layout/panel-layout/flat-nav/flatNavLogic.ts
@@ -0,0 +1,104 @@
+import { MakeLogicType, connect, kea, path, selectors } from 'kea'
+
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
+
+import { customProductsLogic } from '~/layout/panel-layout/ProjectTree/customProductsLogic'
+import { getDefaultTreeProducts } from '~/layout/panel-layout/ProjectTree/defaultTree'
+import { getCategoryOrder, splitPath, unescapePath } from '~/layout/panel-layout/ProjectTree/utils'
+import { FileSystemIconType, UserProductListItem } from '~/queries/schema/schema-general'
+import { FileSystemIconColor } from '~/types'
+
+export interface FlatNavProductItem {
+ path: string
+ label: string
+ href: string
+ iconType?: FileSystemIconType
+ iconColor?: FileSystemIconColor
+ tag?: 'alpha' | 'beta'
+}
+
+export interface FlatNavProductGroup {
+ category: string
+ items: FlatNavProductItem[]
+}
+
+const UNCATEGORIZED_ORDER = 9999
+const UNORDERED_VISUAL_ORDER = 9999
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface flatNavLogicValues {
+ customProducts: UserProductListItem[] // customProductsLogic
+ customProductsLoading: boolean // customProductsLogic
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ productGroups: FlatNavProductGroup[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface flatNavLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ productGroups: (customProducts: UserProductListItem[], featureFlags: FeatureFlagsSet) => FlatNavProductGroup[]
+ }
+}
+
+export type flatNavLogicType = MakeLogicType<flatNavLogicValues, {}, Record<string, any>, flatNavLogicMeta>
+
+export const flatNavLogic = kea<flatNavLogicType>([
+ path(['layout', 'panel-layout', 'flat-nav', 'flatNavLogic']),
+ connect(() => ({
+ values: [customProductsLogic, ['customProducts', 'customProductsLoading'], featureFlagLogic, ['featureFlags']],
+ })),
+ selectors({
+ productGroups: [
+ (s) => [s.customProducts, s.featureFlags],
+ (customProducts: UserProductListItem[], featureFlags: FeatureFlagsSet): FlatNavProductGroup[] => {
+ const catalog = new Map(getDefaultTreeProducts().map((product) => [product.path, product]))
+ const seenPaths = new Set<string>()
+ const selected: (FlatNavProductItem & { category: string; sortOrder: number })[] = []
+ for (const { product_path: productPath } of customProducts) {
+ if (seenPaths.has(productPath)) {
+ continue
+ }
+ seenPaths.add(productPath)
+ const product = catalog.get(productPath)
+ if (
+ !product?.href ||
+ (product.flag && !(featureFlags as Record<string, boolean | string>)[product.flag]) ||
+ // Tools the user has no access to are hidden instead of shown disabled
+ getProductAccessDisabledReason(product)
+ ) {
+ continue
+ }
+ selected.push({
+ path: product.path,
+ label: product.displayLabel || unescapePath(splitPath(product.path).pop() ?? product.path),
+ href: product.href,
+ iconType: product.iconType ?? (product.type as FileSystemIconType | undefined),
+ iconColor: product.iconColor,
+ tag: product.tags?.[0],
+ category: product.category ?? '',
+ sortOrder: product.visualOrder ?? UNORDERED_VISUAL_ORDER,
+ })
+ }
+ selected.sort(
+ (a, b) =>
+ (a.category ? getCategoryOrder(a.category) : UNCATEGORIZED_ORDER) -
+ (b.category ? getCategoryOrder(b.category) : UNCATEGORIZED_ORDER) ||
+ a.category.localeCompare(b.category, undefined, { sensitivity: 'accent' }) ||
+ a.sortOrder - b.sortOrder ||
+ a.label.localeCompare(b.label, undefined, { sensitivity: 'accent' })
+ )
+ const groups: FlatNavProductGroup[] = []
+ for (const { category, sortOrder: _, ...item } of selected) {
+ const lastGroup = groups[groups.length - 1]
+ if (lastGroup && lastGroup.category === category) {
+ lastGroup.items.push(item)
+ } else {
+ groups.push({ category, items: [item] })
+ }
+ }
+ return groups
+ },
+ ],
+ }),
+])
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 4da289a0ed1a..477dcb579b6e 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -182,6 +182,7 @@ export const FEATURE_FLAGS = {
// UX flags, used to control the UX of the app
CREATE_BUTTON_NAV_EXPERIMENT: 'create-button-nav-experiment', // owner: #team-platform-ux multivariate=control,test — adds a Create dropdown to the top of the Browse tab in the left nav
+ FLAT_NAV: 'flat-nav', // owner: @rafaeelaudibert #team-growth, swaps the tree-based left nav for the flat sidebar, see FlatNav.tsx
GITHUB_FIRST_SELF_DRIVING_ONBOARDING: 'github-first-self-driving-onboarding', // owner: #team-self-driving
INBOX_SELF_DRIVING_EMPTY_STATE: 'inbox-self-driving-empty-state',
STARRED_REORDER: 'starred-reorder', // owner: #team-platform-ux, drag-and-drop reorder of starred shortcuts in the side panel